diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/ShrinkingJetSeminorms.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/ShrinkingJetSeminorms.lean new file mode 100644 index 0000000000000000000000000000000000000000..66ab0506ef29807635295a5db3d27956617be149 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/ShrinkingJetSeminorms.lean @@ -0,0 +1,97 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Rigidity.VanishingJetGrowth +import OAI.Analysis.RieszRectifiability.Limits.SchwartzCutoffConvergence + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open SchwartzMap Metric Set Filter Topology +open scoped ContDiff + +def jetCutoffCoefficient (C : ℕ → ℝ) (n : ℕ) : ℝ := + ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * C i * 2 ^ (i + 1) + +theorem jetCutoffCoefficient_nonneg (C : ℕ → ℝ) (hC : ∀ i, 0 ≤ C i) (n : ℕ) : + 0 ≤ jetCutoffCoefficient C n := + Finset.sum_nonneg fun i _ => mul_nonneg (mul_nonneg (by positivity) (hC i)) (by positivity) + +theorem inverse_scale_cancel (r : ℝ) (hr : 0 < r) (i : ℕ) : + (r⁻¹) ^ i * (2 * r) ^ (i + 1) = 2 ^ (i + 1) * r := by + rw [mul_pow, pow_succ r] + calc + _ = 2 ^ (i + 1) * ((r⁻¹) ^ i * r ^ i) * r := by ring + _ = _ := by rw [← mul_pow, inv_mul_cancel₀ hr.ne', one_pow, mul_one] + +theorem zero_jet_localized_derivative_bound {d : ℕ} {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] + (g : 𝓢(Ambient d, F)) (n : ℕ) + (hz : ∀ i, i ≤ n → iteratedFDeriv ℝ i g 0 = 0) + (q : Ambient d → ℝ) (hq : ContDiff ℝ ∞ q) + (C : ℕ → ℝ) (hC : ∀ i, 0 ≤ C i) (r : ℝ) (hr : 0 < r) + (hb : ∀ i x, ‖iteratedFDeriv ℝ i q x‖ ≤ C i * (r⁻¹) ^ i) + (x : Ambient d) (hx : ‖x‖ ≤ 2 * r) : + ‖iteratedFDeriv ℝ n (fun y => q y • g y) x‖ ≤ + SchwartzMap.seminorm ℝ 0 (n + 1) g * jetCutoffCoefficient C n * r := by + let M := SchwartzMap.seminorm ℝ 0 (n + 1) g + have hM : 0 ≤ M := apply_nonneg _ _ + have hd := norm_iteratedFDeriv_smul_le hq (g.smooth ⊤) x (n := n) (mod_cast le_top) + apply hd.trans + calc + _ ≤ ∑ i ∈ Finset.range (n + 1), M * ((n.choose i : ℝ) * C i * 2 ^ (i + 1)) * r := by + apply Finset.sum_le_sum + intro i hi + have hin : i ≤ n := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using! hi + have hg : ‖iteratedFDeriv ℝ (n - i) g x‖ ≤ M * (2 * r) ^ (i + 1) := by + have ht := schwartz_zero_jet_derivative_bound g n (n - i) (by omega) hz x + rw [show n + 1 - (n - i) = i + 1 by omega] at ht + exact ht.trans (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (norm_nonneg _) hx _) hM) + calc + _ ≤ (n.choose i : ℝ) * (C i * (r⁻¹) ^ i) * (M * (2 * r) ^ (i + 1)) := by + exact mul_le_mul (mul_le_mul_of_nonneg_left (hb i x) (by positivity)) hg + (norm_nonneg _) (mul_nonneg (by positivity) (mul_nonneg (hC i) (by positivity))) + _ = M * ((n.choose i : ℝ) * C i) * ((r⁻¹) ^ i * (2 * r) ^ (i + 1)) := by ring + _ = _ := by rw [inverse_scale_cancel r hr i]; ring + _ = _ := by + unfold jetCutoffCoefficient + rw [Finset.mul_sum, Finset.sum_mul] + +theorem zero_jet_localized_seminorm_bound {d : ℕ} {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] + (g : 𝓢(Ambient d, F)) (k n : ℕ) + (hz : ∀ i, i ≤ n → iteratedFDeriv ℝ i g 0 = 0) + (q : Ambient d → ℝ) (hq : q.HasTemperateGrowth) + (C : ℕ → ℝ) (hC : ∀ i, 0 ≤ C i) (r : ℝ) (hr : 0 < r) (hrsmall : 2 * r ≤ 1) + (hb : ∀ i x, ‖iteratedFDeriv ℝ i q x‖ ≤ C i * (r⁻¹) ^ i) + (hs : tsupport q ⊆ closedBall (0 : Ambient d) (2 * r)) : + SchwartzMap.seminorm ℝ k n (smulLeftCLM F q g) ≤ + SchwartzMap.seminorm ℝ 0 (n + 1) g * jetCutoffCoefficient C n * r := by + have hnonneg : 0 ≤ SchwartzMap.seminorm ℝ 0 (n + 1) g * jetCutoffCoefficient C n * r := + mul_nonneg (mul_nonneg (apply_nonneg _ _) (jetCutoffCoefficient_nonneg C hC n)) hr.le + apply seminorm_le_bound ℝ k n _ hnonneg + intro x + rw [smulLeftCLM_apply hq] + by_cases hx : x ∈ closedBall (0 : Ambient d) (2 * r) + · have hxr : ‖x‖ ≤ 2 * r := by simpa only [mem_closedBall, dist_zero_right] using! hx + calc + _ ≤ 1 * ‖iteratedFDeriv ℝ n (fun y => q y • g y) x‖ := + mul_le_mul_of_nonneg_right (pow_le_one₀ (norm_nonneg _) (hxr.trans hrsmall)) (norm_nonneg _) + _ ≤ _ := by + rw [one_mul] + exact zero_jet_localized_derivative_bound g n hz q hq.1 C hC r hr hb x hxr + · have hnot : x ∉ tsupport q := fun h => hx (hs h) + have heq : (fun y => q y • g y) =ᶠ[𝓝 x] (fun _ => (0 : F)) := by + filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hnot] with y hy + simp only [Pi.zero_apply] at hy + rw [hy, zero_smul] + have hd := (heq.iteratedFDeriv ℝ n).eq_of_nhds + rw [hd] + simpa only [iteratedFDeriv_fun_zero, Pi.zero_apply, norm_zero, mul_zero] using! hnonneg + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/SourceDensityFractionalEquation.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/SourceDensityFractionalEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..397c7691841a41422f277c10b894cd7128c2e916 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/SourceDensityFractionalEquation.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Kernel.SourceDensityRieszEquation +import OAI.Analysis.RieszRectifiability.Foundations.DensityGradientEquation + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory SchwartzMap Metric Set Filter Topology +open scoped NNReal ENNReal + +theorem source_planar_density_fractional_equation {d : ℕ} (p : ℕ) (C G : ℝ) + (μ : ℕ → Measure (Ambient d)) (ν : Measure (Ambient d)) + [∀ j, IsFiniteMeasureOnCompacts (μ j)] [IsFiniteMeasureOnCompacts ν] + (hgrowth : ∀ j, GlobalUpperGrowth (p + 1) C (μ j)) + (hgν : GlobalUpperGrowth (p + 1) G ν) (hweak : CompactTestConvergence μ ν) + (D : ℝ≥0) + (hB : ∀ j ε, 0 < ε → ∀ u : Ambient d → ℝ, MemLp u 2 (μ j) → + MemLp (truncated (p + 1) (μ j) ε u) 2 (μ j) ∧ + eLpNorm (truncated (p + 1) (μ j) ε u) 2 (μ j) ≤ (D : ℝ≥0∞) * eLpNorm u 2 (μ j)) + (L : Ambient (p + 1) →ₗᵢ[ℝ] Ambient d) (f : Ambient (p + 1) → ℝ) + (hf : Measurable f) (c : ℝ) (hc : 0 < c) (hlower : ∀ x, c ≤ f x) + (M : ℝ) (hupper : ∀ x, |f x| ≤ M) + (hdensity : ((volume : Measure (Ambient (p + 1))).withDensity + (fun x => ENNReal.ofReal (f x))).map L = ν) + (a : Ambient (p + 1)) (H R : ℝ) (hH : 0 < H) (hR : 0 < R) (hHR : 2 * H ≤ R) + (hboundary : ν (frontier (ball (L a) R)) = 0) (hmass : ν (ball (L a) R) ≠ 0) + (cMass : ℝ) (hcMass : 0 < cMass) + (hlowerMass : ENNReal.ofReal (cMass * (H / 4) ^ (p + 1)) ≤ ν (ball (L a) (H / 4))) + (hreflect : ScalarReflectionlessAt (p + 1) ν (L a)) + (ψ : 𝓢(Ambient (p + 1), ℝ)) (hψc : HasCompactSupport ψ) (hψs : tsupport ψ ⊆ ball a H) : + Integrable (fun y => f y * ((-1 / 2 : ℝ) * ∫ h, fractionalSchwartzKernel (p + 1) ψ y h)) volume ∧ + (∫ y, f y * ((-1 / 2 : ℝ) * ∫ h, fractionalSchwartzKernel (p + 1) ψ y h)) = 0 := by + apply density_fractional_equation_of_riesz_tests p f ψ + intro e + obtain ⟨_, _, hDs, _, hmean⟩ := + compact_smooth_directional_derivative_test ψ (ψ.smooth ⊤) hψc e + have hsupport : ∀ x, scalarSchwartzDerivative ψ e x ≠ 0 → x ∈ ball a H := by + intro x hx + exact hψs (hDs (subset_tsupport (fun y => fderiv ℝ ψ y e) hx)) + exact source_planar_density_riesz_test_equation p C G μ ν hgrowth hgν hweak D hB + L f hf c hc hlower M hupper hdensity e a H R hH hR hHR hboundary hmass cMass hcMass + hlowerMass hreflect (scalarSchwartzDerivative ψ e) hmean hsupport + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/SupportedFractionalCutoff.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/SupportedFractionalCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..add684fae179123115d4042dcae20d06066a5829 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/SupportedFractionalCutoff.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Nets.FinitePairingCancellation +import OAI.Analysis.RieszRectifiability.Rigidity.FiniteFractionalHeightPairing +import OAI.Analysis.RieszRectifiability.Kernel.SupportedKernelDecomposition + +namespace OAI + +/-! +# Fractional cutoffs for supported tests + +Separation between the test support and the exterior region makes the cutoff +inactive in cross terms. The cutoff increment is also the closed-exterior +indicator of the full increment, giving its integrability and its equality +with the truncated fractional Schwartz test. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Filter SchwartzMap + +theorem supported_fractional_cutoff_cross {d : ℕ} (m : ℕ) (ε H R : ℝ) + (a x y : Ambient d) (g : Ambient d → ℂ) + (hnear : g x ≠ 0 → dist x a ≤ H) (hfar : y ∈ closedExterior a R) + (hsep : ε + H ≤ R) : + symmetricFractionalCutoffKernel m ε (x, y) • g x = + inverseDistancePow (m + 1) x y • g x := by + by_cases hg : g x = 0 + · rw [hg] + exact (smul_zero _).trans (smul_zero _).symm + · have hy : R ≤ dist a y := hfar + have ht := dist_triangle a x y + rw [dist_comm a x] at ht + have hd : ε ≤ dist x y := by linarith [hnear hg] + simp only [symmetricFractionalCutoffKernel, ite_eq_left hd] + +theorem supported_fractional_cutoff_cross_swap {d : ℕ} (m : ℕ) (ε H R : ℝ) + (a x y : Ambient d) (g : Ambient d → ℂ) + (hnear : g x ≠ 0 → dist x a ≤ H) (hfar : y ∈ closedExterior a R) + (hsep : ε + H ≤ R) : + symmetricFractionalCutoffKernel m ε (y, x) • g x = + inverseDistancePow (m + 1) x y • g x := by + rw [show symmetricFractionalCutoffKernel m ε (y, x) = + symmetricFractionalCutoffKernel m ε (x, y) from + symmetricFractionalCutoffKernel_swap m ε (x, y)] + exact supported_fractional_cutoff_cross m ε H R a x y g hnear hfar hsep + +theorem test_zero_outside_localization {d : ℕ} (g : Ambient d → ℂ) + (a : Ambient d) (H R : ℝ) (hHR : H < R) + (hnear : ∀ x, g x ≠ 0 → dist x a ≤ H) : + ∀ y ∈ (ball a R)ᶜ, g y = 0 := by + intro y hy + by_contra hgy + have hh := hnear y hgy + have hf : R ≤ dist y a := by simpa only [mem_compl_iff, mem_ball, not_lt] using! hy + linarith + +theorem fractional_cutoff_increment_eq_indicator {d : ℕ} (m : ℕ) (ε : ℝ) + (g : Ambient d → ℂ) (x : Ambient d) : + (fun y => symmetricFractionalCutoffKernel m ε (x, y) • (g x - g y)) = + (closedExterior x ε).indicator (fun y => inverseDistancePow (m + 1) x y • (g x - g y)) := by + funext y + by_cases h : ε ≤ dist x y + · rw [indicator_of_mem (show y ∈ closedExterior x ε from h)] + simp only [symmetricFractionalCutoffKernel, ite_eq_left h] + · rw [indicator_of_notMem (show y ∉ closedExterior x ε from h)] + simp only [symmetricFractionalCutoffKernel, ite_eq_right h] + exact zero_smul ℝ (g x - g y) + +theorem fractional_cutoff_increment_integrable (p : ℕ) (ε : ℝ) (hε : 0 < ε) + (g : 𝓢(Ambient (p + 1), ℂ)) (x : Ambient (p + 1)) : + Integrable (fun y => symmetricFractionalCutoffKernel (p + 1) ε (x, y) • (g x - g y)) volume := by + rw [fractional_cutoff_increment_eq_indicator] + exact (integrable_indicator_iff (closedExterior_measurable x ε)).2 + (fractionalSchwartz_single_increment_integrable p ε hε g x) + +theorem fractional_cutoff_increment_integral (p : ℕ) (ε : ℝ) (hε : 0 < ε) + (g : 𝓢(Ambient (p + 1), ℂ)) (x : Ambient (p + 1)) : + (∫ y, symmetricFractionalCutoffKernel (p + 1) ε (x, y) • (g x - g y)) = + fractionalSchwartzTruncatedTest p ε g x := by + rw [fractional_cutoff_increment_eq_indicator, integral_indicator (closedExterior_measurable x ε)] + exact (fractionalSchwartzTruncatedTest_eq_single_increment p ε hε g x).symm + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedFiniteOrderBound.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedFiniteOrderBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4225ee85904bb009da8d825b91a51e0b693adce --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedFiniteOrderBound.lean @@ -0,0 +1,28 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Rigidity.HeightTemperedDistribution + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open SchwartzMap MeasureTheory + +theorem tempered_distribution_finite_seminorm_bound {d : ℕ} + (T : 𝓢'(Ambient d, ℂ)) : + ∃ s : Finset (ℕ × ℕ), ∃ C : ℝ, 0 < C ∧ + ∀ g : 𝓢(Ambient d, ℂ), + ‖T g‖ ≤ C * s.sup (schwartzSeminormFamily ℂ (Ambient d) ℂ) g := by + let q : Seminorm ℂ 𝓢(Ambient d, ℂ) := (normSeminorm ℂ ℂ).comp T.toLinearMap + have hq : Continuous q := continuous_norm.comp T.continuous + obtain ⟨s, C, hC, hbound⟩ := Seminorm.bound_of_continuous + (schwartz_withSeminorms ℂ (Ambient d) ℂ) q hq + refine ⟨s, C, by exact_mod_cast (pos_iff_ne_zero.mpr hC), fun g => ?_⟩ + exact hbound g + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedHeightWeights.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedHeightWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ebab2b685fdee192dd6a2dbb30c7fccf9a016a4 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedHeightWeights.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Nets.FinitePairingCancellation + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Function Filter Topology + +def polynomialDecay {d : ℕ} (q : ℕ) (x : Ambient d) : ℝ := ((1 + ‖x‖) ^ q)⁻¹ + +theorem polynomialDecay_measurable {d : ℕ} (q : ℕ) : + Measurable (polynomialDecay (d := d) q) := by + unfold polynomialDecay + fun_prop + +theorem polynomialDecay_nonneg {d : ℕ} (q : ℕ) (x : Ambient d) : 0 ≤ polynomialDecay q x := by + unfold polynomialDecay + positivity + +theorem polynomialDecay_le_one {d : ℕ} (q : ℕ) (x : Ambient d) : polynomialDecay q x ≤ 1 := by + unfold polynomialDecay + apply inv_le_one_of_one_le₀ + exact one_le_pow₀ (by linarith [norm_nonneg x] : (1 : ℝ) ≤ 1 + ‖x‖) + +theorem polynomialDecay_eq_rpow {d : ℕ} (q : ℕ) (x : Ambient d) : + polynomialDecay q x = (1 + ‖x‖) ^ (-(q : ℝ)) := by + rw [Real.rpow_neg (by positivity), Real.rpow_natCast] + rfl + +theorem polynomialDecay_le_far {d : ℕ} (q : ℕ) (a x : Ambient d) (hx : 0 < dist a x) : + polynomialDecay q x ≤ (1 + ‖a‖) ^ q * inverseDistancePow q a x := by + have hd : dist a x ≤ (1 + ‖a‖) * (1 + ‖x‖) := by + have h : dist a x ≤ ‖a‖ + ‖x‖ := by + rw [dist_eq_norm] + exact norm_sub_le a x + nlinarith [norm_nonneg a, norm_nonneg x, mul_nonneg (norm_nonneg a) (norm_nonneg x)] + have hp := pow_le_pow_left₀ (by positivity : 0 ≤ dist a x) hd q + rw [inverseDistancePow, ← div_eq_mul_inv] + apply (le_div_iff₀ (pow_pos hx q)).mpr + calc + _ ≤ polynomialDecay q x * ((1 + ‖a‖) * (1 + ‖x‖)) ^ q := + mul_le_mul_of_nonneg_left hp (polynomialDecay_nonneg q x) + _ = _ := by + unfold polynomialDecay + rw [mul_pow] + field_simp + +theorem polynomial_weight_integrable_from_height_tail {d : ℕ} (q : ℕ) + (μ : Measure (Ambient d)) (f : Ambient d → ℝ) (hf : Measurable f) + (a : Ambient d) (R : ℝ) (hR : 0 < R) + (hnear : IntegrableOn f (ball a R) μ) + (hfar : IntegrableOn (fun x => |f x| * inverseDistancePow q a x) (closedExterior a R) μ) : + Integrable (fun x => |f x| * polynomialDecay q x) μ := by + have hm : Measurable (fun x => |f x| * polynomialDecay q x) := + hf.abs.mul (polynomialDecay_measurable q) + have hi : IntegrableOn (fun x => |f x| * polynomialDecay q x) (ball a R) μ := by + apply hnear.abs.mono' hm.aestronglyMeasurable + apply Eventually.of_forall + intro x + rw [Real.norm_of_nonneg (mul_nonneg (abs_nonneg _) (polynomialDecay_nonneg q x))] + simpa only [mul_one] using! mul_le_mul_of_nonneg_left (polynomialDecay_le_one q x) (abs_nonneg _) + have ho : IntegrableOn (fun x => |f x| * polynomialDecay q x) (closedExterior a R) μ := by + apply (hfar.const_mul ((1 + ‖a‖) ^ q)).mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem (closedExterior_measurable a R)] with x hx + rw [Real.norm_of_nonneg (mul_nonneg (abs_nonneg _) (polynomialDecay_nonneg q x))] + calc + _ ≤ |f x| * ((1 + ‖a‖) ^ q * inverseDistancePow q a x) := + mul_le_mul_of_nonneg_left (polynomialDecay_le_far q a x (hR.trans_le hx)) (abs_nonneg _) + _ = _ := by ring + have hu := hi.union ho + rw [closedExterior_eq_compl_ball, union_compl_self, integrableOn_univ] at hu + exact hu + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedRealFiniteOrderBound.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedRealFiniteOrderBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a2399bdf676448106a97f7b5e977b785eb91896 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TemperedRealFiniteOrderBound.lean @@ -0,0 +1,29 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Rigidity.TemperedFiniteOrderBound + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open SchwartzMap + +theorem tempered_distribution_finite_real_seminorm_bound {d : ℕ} + (T : 𝓢'(Ambient d, ℂ)) : + ∃ s : Finset (ℕ × ℕ), ∃ C : ℝ, 0 < C ∧ + ∀ g : 𝓢(Ambient d, ℂ), + ‖T g‖ ≤ C * s.sup (schwartzSeminormFamily ℝ (Ambient d) ℂ) g := by + obtain ⟨s, C, hC, hbound⟩ := tempered_distribution_finite_seminorm_bound T + refine ⟨s, C, hC, fun g => ?_⟩ + have heq : s.sup (schwartzSeminormFamily ℂ (Ambient d) ℂ) g = + s.sup (schwartzSeminormFamily ℝ (Ambient d) ℂ) g := by + simp only [Seminorm.finset_sup_apply] + rfl + exact (hbound g).trans_eq (congrArg (fun t : ℝ => C * t) heq) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/TruncatedRenormalizedHeightIdentity.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TruncatedRenormalizedHeightIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..27a80ec9e2babf1afc54dd71a1c66f6506d5432b --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/TruncatedRenormalizedHeightIdentity.lean @@ -0,0 +1,127 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Rigidity.SupportedFractionalCutoff +import OAI.Analysis.RieszRectifiability.Kernel.ComplexExteriorIntegrability +import OAI.Analysis.RieszRectifiability.Nets.RenormalizedCrossCancellation + +namespace OAI + +/-! +# Truncated height pairing and its renormalized exterior term + +For a compactly supported mean-zero Schwartz test, the weighted truncated +fractional pairing splits into a symmetric local pairing and a renormalized +exterior integral. Support separation removes the cutoff in cross terms, and +the weighted exterior hypothesis supplies the integrability needed for cancellation. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Filter SchwartzMap + +theorem compact_schwartz_truncated_height_pairing (p : ℕ) + (a : Ambient (p + 1)) (H R : ℝ) (hH : 0 ≤ H) (hR : 0 < R) (hHR : 2 * H ≤ R) + (ε : ℝ) (hε : 0 < ε) (hsep : ε + H ≤ R) + (w : Ambient (p + 1) → ℝ) (hwm : Measurable w) + (hw : IntegrableOn w (ball a R) volume) + (g : 𝓢(Ambient (p + 1), ℂ)) (hzero : (∫ x, g x) = 0) + (hnear : ∀ x, g x ≠ 0 → dist x a ≤ H) + (B : ℝ) (hB : 0 ≤ B) (hgB : ∀ x, ‖g x‖ ≤ B) + (hweighted : IntegrableOn (fun y => |w y| * inverseDistancePow (p + 1 + 2) a y) + (closedExterior a R) volume) : + Integrable (fun x => w x • fractionalSchwartzTruncatedTest p ε g x) volume ∧ + (∫ x, w x • fractionalSchwartzTruncatedTest p ε g x) = + (1 / 2 : ℝ) • (∫ q : Ambient (p + 1) × Ambient (p + 1), + (w q.1 - w q.2) • (symmetricFractionalCutoffKernel (p + 1) ε q • (g q.1 - g q.2)) + ∂(volume.restrict (ball a R)).prod (volume.restrict (ball a R))) + + ∫ q, complexRenormalizedNormalIntegrand (p + 1) w g a q + ∂(volume.restrict (ball a R)).prod (volume.restrict (ball a R)ᶜ) := by + let μ : Measure (Ambient (p + 1)) := volume + let ν := μ.restrict (ball a R) + let η := μ.restrict (ball a R)ᶜ + let C := (volume (ball (0 : Ambient (p + 1)) 1)).toReal + let k := symmetricFractionalCutoffKernel (d := p + 1) (p + 1) ε + have hgrowth : GlobalUpperGrowth (p + 1) C μ := volume_global_upper_growth (p + 1) + let : IsFiniteMeasure ν := finiteMeasure_restrict_ball_of_globalGrowth (p + 1) C μ hgrowth a R hR + have hgs := test_zero_outside_localization g a H R (by linarith) hnear + have hgm : Measurable g := g.continuous.measurable + have hgn : Integrable (fun x => ‖g x‖) ν := g.integrable.restrict.norm + have hgnw : Integrable (fun x => ‖g x‖ * w x) ν := + hw.bdd_mul hgm.norm.aestronglyMeasurable + (Eventually.of_forall fun x => by simpa only [norm_norm] using! hgB x) + have hzν : (∫ x, g x ∂ν) = 0 := by + exact (setIntegral_eq_integral_of_forall_compl_eq_zero hgs).trans hzero + have hD : Integrable (fun q : Ambient (p + 1) × Ambient (p + 1) => + w q.1 • (inverseDistancePow (p + 1 + 1) q.1 q.2 • g q.1)) (ν.prod η) := by + simpa only [closedExterior_eq_compl_ball] using! direct_height_exterior_integrable + (p + 1) C μ ν hgrowth w g hwm hgm hgnw a H R hR hHR (Eventually.of_forall hnear) + have hN : Integrable (complexRenormalizedNormalIntegrand (p + 1) w g a) (ν.prod η) := by + simpa only [closedExterior_eq_compl_ball] using! complex_renormalized_exterior_integrable + (p + 1) C μ ν hgrowth w g hwm hgm hgn hgnw a H R hH hR hHR + (Eventually.of_forall hnear) hweighted + have hraw : ∀ᵐ y ∂η, Integrable (fun x => inverseDistancePow (p + 1 + 1) x y • g x) ν := by + filter_upwards [ae_restrict_mem (μ := μ) + (show MeasurableSet (ball a R)ᶜ from measurableSet_ball.compl)] with y hy + have hy' : R ≤ dist a y := by + rwa [← closedExterior_eq_compl_ball] at hy + exact far_kernel_test_integrable_of_support ν g hgm g.integrable.restrict + (p + 1) a y H R hR hHR (Eventually.of_forall hnear) hy' + have hcross := renormalized_complex_cross_integral_identity (p + 1) ν η w g a + g.integrable.restrict hzν hraw hD hN + have hcut (x y : Ambient (p + 1)) (hy : y ∈ (ball a R)ᶜ) : + k (x, y) • g x = inverseDistancePow (p + 1 + 1) x y • g x := + supported_fractional_cutoff_cross (p + 1) ε H R a x y g (hnear x) + (by rwa [closedExterior_eq_compl_ball]) hsep + have hcutswap (x y : Ambient (p + 1)) (hy : y ∈ (ball a R)ᶜ) : + k (y, x) • g x = inverseDistancePow (p + 1 + 1) x y • g x := + supported_fractional_cutoff_cross_swap (p + 1) ε H R a x y g (hnear x) + (by rwa [closedExterior_eq_compl_ball]) hsep + have hDcut : Integrable (fun q : Ambient (p + 1) × Ambient (p + 1) => + w q.1 • (k q • g q.1)) (ν.prod η) := by + apply hD.congr + filter_upwards [Measure.quasiMeasurePreserving_snd.ae + (ae_restrict_mem (μ := μ) (show MeasurableSet (ball a R)ᶜ from measurableSet_ball.compl))] with q hq + exact congrArg (fun z : ℂ => w q.1 • z) (hcut q.1 q.2 hq).symm + have hOeq : (fun y => w y • (∫ x, k (y, x) • g x ∂ν)) =ᵐ[η] + fun y => w y • (∫ x, inverseDistancePow (p + 1 + 1) x y • g x ∂ν) := by + filter_upwards [ae_restrict_mem (μ := μ) + (show MeasurableSet (ball a R)ᶜ from measurableSet_ball.compl)] with y hy + apply congrArg (fun z : ℂ => w y • z) + exact integral_congr_ae (Eventually.of_forall fun x => hcutswap x y hy) + have hO := hcross.1.congr hOeq.symm + have hL := bounded_kernel_height_integrable ν w hwm hw g hgm B hB hgB k + (symmetricFractionalCutoffKernel_measurable (p + 1) ε) ((ε ^ (p + 1 + 1))⁻¹) + (symmetricFractionalCutoffKernel_bound (p + 1) ε hε) + have hdec := supported_height_kernel_integral_decomposition μ (ball a R) measurableSet_ball + w g hgs k (fractional_cutoff_increment_integrable p ε hε g) hL hDcut hO + have hpair := (finite_symmetric_height_kernel_pairing ν w hwm hw g hgm B hB hgB k + (symmetricFractionalCutoffKernel_measurable (p + 1) ε) ((ε ^ (p + 1 + 1))⁻¹) + (symmetricFractionalCutoffKernel_bound (p + 1) ε hε) + (symmetricFractionalCutoffKernel_swap (p + 1) ε)).2 + have hDeq : (∫ x, w x • (∫ y, k (x, y) • g x ∂η) ∂ν) = + ∫ x, w x • (∫ y, inverseDistancePow (p + 1 + 1) x y • g x ∂η) ∂ν := by + apply integral_congr_ae + apply Eventually.of_forall + intro x + apply congrArg (fun z : ℂ => w x • z) + apply setIntegral_congr_fun measurableSet_ball.compl + intro y hy + exact hcut x y hy + have hAe : (fun x => w x • (∫ y, k (x, y) • (g x - g y) ∂μ)) = + fun x => w x • fractionalSchwartzTruncatedTest p ε g x := by + funext x + exact congrArg (fun z : ℂ => w x • z) (fractional_cutoff_increment_integral p ε hε g x) + rw [hAe] at hdec + refine ⟨hdec.1, ?_⟩ + change (∫ x, w x • fractionalSchwartzTruncatedTest p ε g x ∂μ) = + (1 / 2 : ℝ) • (∫ q, (w q.1 - w q.2) • (k q • (g q.1 - g q.2)) ∂ν.prod ν) + + ∫ q, complexRenormalizedNormalIntegrand (p + 1) w g a q ∂ν.prod η + rw [hdec.2, ← hpair, hDeq, integral_congr_ae hOeq, hcross.2] + abel + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Rigidity/VanishingJetGrowth.lean b/lean/OAI/Analysis/RieszRectifiability/Rigidity/VanishingJetGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfeec13e466e1b8d9a53c306727241a28f73e242 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Rigidity/VanishingJetGrowth.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Kernel.SchwartzSecondDifference + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open SchwartzMap Metric Set +open scoped ContDiff + +theorem iteratedFDeriv_growth_of_zero_jets {d : ℕ} {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] + (f : Ambient d → F) (hf : ContDiff ℝ ∞ f) + (M : ℝ) (hM : 0 ≤ M) (n k : ℕ) + (hz : ∀ j, n ≤ j → j < n + k → iteratedFDeriv ℝ j f 0 = 0) + (hb : ∀ x, ‖iteratedFDeriv ℝ (n + k) f x‖ ≤ M) (x : Ambient d) : + ‖iteratedFDeriv ℝ n f x‖ ≤ M * ‖x‖ ^ k := by + induction k generalizing n x with + | zero => simpa only [Nat.add_zero, pow_zero, mul_one] using! hb x + | succ k ih => + have hn : ∀ y, ‖iteratedFDeriv ℝ (n + 1) f y‖ ≤ M * ‖y‖ ^ k := by + intro y + apply ih (n + 1) + · intro j hj hjk + exact hz j (by omega) (by omega) + · intro z + rw [show n + 1 + k = n + (k + 1) by omega] + exact hb z + have hfinite : ContDiff ℝ (n + 1 : ℕ) f := hf.of_le (by exact_mod_cast le_top) + have hd : Differentiable ℝ (iteratedFDeriv ℝ n f) := + hfinite.differentiable_iteratedFDeriv (by exact_mod_cast Nat.lt_succ_self n) + have hbound : ∀ y ∈ segment ℝ (0 : Ambient d) x, + ‖fderiv ℝ (iteratedFDeriv ℝ n f) y‖ ≤ M * ‖x‖ ^ k := by + intro y hy + rw [norm_fderiv_iteratedFDeriv] + apply (hn y).trans + have hxy : ‖y‖ ≤ ‖x‖ := by + simpa only [sub_zero] using! norm_sub_le_of_mem_segment hy + gcongr + have hv := (convex_segment (0 : Ambient d) x).norm_image_sub_le_of_norm_fderiv_le + (fun y _ => hd y) hbound (left_mem_segment ℝ 0 x) (right_mem_segment ℝ 0 x) + rw [hz n le_rfl (by omega), sub_zero, sub_zero] at hv + simpa only [pow_succ, mul_assoc] using! hv + +theorem schwartz_zero_jet_derivative_bound {d : ℕ} {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] + (g : 𝓢(Ambient d, F)) (N j : ℕ) (hj : j ≤ N + 1) + (hz : ∀ i, i ≤ N → iteratedFDeriv ℝ i g 0 = 0) (x : Ambient d) : + ‖iteratedFDeriv ℝ j g x‖ ≤ + SchwartzMap.seminorm ℝ 0 (N + 1) g * ‖x‖ ^ (N + 1 - j) := by + apply iteratedFDeriv_growth_of_zero_jets g (g.smooth ⊤) + (SchwartzMap.seminorm ℝ 0 (N + 1) g) (apply_nonneg _ _) j (N + 1 - j) + · intro i _ hi + exact hz i (by omega) + · intro y + rw [show j + (N + 1 - j) = N + 1 by omega] + exact norm_iteratedFDeriv_le_seminorm ℝ g (N + 1) y + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ActualNativeSurfaceGeometry.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ActualNativeSurfaceGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..474263d9aef5a27097fe2c7325b9b5c700201506 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ActualNativeSurfaceGeometry.lean @@ -0,0 +1,77 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.NativeSurfaceRegularity +import OAI.Analysis.RieszRectifiability.Restart.ActiveRegionMatchedProjection + +namespace OAI + +/-! +# Geometry of the native area measure on a limit surface + +Two-sided Hausdorff area bounds on a closed embedded active-region limit image +give regularity, exact support, AD regularity, and infinite support diameter for +its native area measure. Matched projection estimates then transfer to that +support with the same explicit flatness and disk-coverage constants. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Topology +open scoped ENNReal + +theorem active_region_native_surface_geometry {n d : ℕ} (hn : 0 < n) + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (Good : SupportCellDescendant μ R hR k z → Prop) + (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)) (ε : ℝ) (hε : 0 < ε) + (hεfine : ε ≤ 1 / 72057594037927936) (hsmall : activeProjectionError d ε ≤ 1 / 4096) + (hfit : ∀ i, activeRegionCell Good i → + bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) + (f : S (supportCellRoot μ R hR k z) → Ambient d) + (hmodel : IsActiveRegionLimitModel μ R hR k z Good S hS ε f) + (hembed : IsClosedEmbedding f) + (c C : ℝ≥0∞) (hc : 0 < c) (hcfin : c < ⊤) (hC : C < ⊤) + (hlower : ∀ p ∈ Set.range f, ∀ r : ℝ, 0 < r → + c * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (Set.range f ∩ closedBall p r)) + (hupper : ∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (Set.range f ∩ closedBall p r) ≤ + C * (ENNReal.ofReal r) ^ n) : + let ν := nativeSurfaceArea n (Set.range f) + ν.Regular ∧ ν.support = Set.range f ∧ ADRegular n ν ∧ ediam ν.support = ⊤ ∧ + 1 ≤ nativeSurfaceADConstant n c C ∧ + GlobalUpperGrowth n (nativeSurfaceADConstant n c C) ν ∧ + (∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ENNReal.ofReal (r ^ n / nativeSurfaceADConstant n c C) ≤ ν (ball p r)) ∧ + ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ + (281474976710656 * (ε + activeProjectionError d ε)) * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16)) := by + dsimp only + have hclosed := hembed.isClosed_range + have hs := nativeSurfaceArea_support (Set.range f) hclosed c hc hlower + have hne : (Set.range f).Nonempty := by + obtain ⟨a, ha⟩ := (hS (supportCellRoot μ R hR k z)).1 + exact ⟨f ⟨a, ha⟩, Set.mem_range_self _⟩ + obtain ⟨hK, hg, hl⟩ := nativeSurfaceArea_uniform_bounds (Set.range f) c C hc hcfin hC hlower hupper + refine ⟨nativeSurfaceArea_regular _ C hC hupper, hs, + nativeSurfaceArea_adRegular _ hclosed c C hc hcfin hC hlower hupper, + nativeSurfaceArea_support_ediam_top hn _ hclosed hne c C hc hcfin hC hlower hupper, + hK, hg, ?_, ?_⟩ + · intro p hp r hr + exact hl p (hs ▸ hp) r hr + · rw [hs] + intro p hp r hr + exact exists_active_region_matched_projection_all_scales μ R hR k z Good S hS + ε hε hεfine hsmall hfit f hmodel p hp r hr + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/BallChartPartialMap.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/BallChartPartialMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..d71ff1edb28d4e0bfd3a36f75f5cc954d27b86b1 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/BallChartPartialMap.lean @@ -0,0 +1,52 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +/-! +# Ball charts as ambient parameter maps + +A chart on a parameter ball is extended by zero outside its domain. On the ball, +this ambient map agrees with the chart and retains its Lipschitz bound. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +def ballChartPartialMap {n d : ℕ} (r : ℝ) + (g : ball (0 : Ambient n) r → Ambient d) (u : Ambient n) : Ambient d := by + classical + exact if hu : u ∈ ball (0 : Ambient n) r then g ⟨u, hu⟩ else 0 + +theorem ballChartPartialMap_apply {n d : ℕ} (r : ℝ) + (g : ball (0 : Ambient n) r → Ambient d) (u : Ambient n) (hu : u ∈ ball (0 : Ambient n) r) : + ballChartPartialMap r g u = g ⟨u, hu⟩ := by + simp only [ballChartPartialMap, dite_eq_left hu] + +theorem ballChartPartialMap_lipschitzOn {n d : ℕ} (r : ℝ) + (g : ball (0 : Ambient n) r → Ambient d) (M : ℝ≥0) (hg : LipschitzWith M g) : + LipschitzOnWith M (ballChartPartialMap r g) (ball (0 : Ambient n) r) := by + apply LipschitzOnWith.of_dist_le_mul + intro x hx y hy + rw [ballChartPartialMap_apply r g x hx, ballChartPartialMap_apply r g y hy] + exact hg.dist_le_mul ⟨x, hx⟩ ⟨y, hy⟩ + +theorem ballChartPartialMap_image {n d : ℕ} (r : ℝ) + (g : ball (0 : Ambient n) r → Ambient d) : + ballChartPartialMap r g '' ball (0 : Ambient n) r = Set.range g := by + apply Set.Subset.antisymm + · rintro y ⟨u, hu, rfl⟩ + rw [ballChartPartialMap_apply r g u hu] + exact Set.mem_range_self (⟨u, hu⟩ : ball (0 : Ambient n) r) + · rintro y ⟨u, rfl⟩ + exact ⟨u.val, u.property, ballChartPartialMap_apply r g u.val u.property⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/BoundedNormalizedBallCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/BoundedNormalizedBallCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fb7008446d73ddd7c6294f4d7f116682f63598e --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/BoundedNormalizedBallCharts.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.RescaledBallCharts + +namespace OAI + +/-! +# Bounded normalized ball charts + +Metric projection onto a nonempty complete convex set gives a nonexpansive retraction. +Composing this retraction with a rescaled ball chart bounds its range by a closed ball +while preserving every point of the original image in that ball. The normalization +halves the domain radius and multiplies the Lipschitz bound by two. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem exists_nonexpansive_retraction_of_complete_convex {d : ℕ} + (K : Set (Ambient d)) (hne : K.Nonempty) (hcomplete : IsComplete K) (hconvex : Convex ℝ K) : + ∃ p : Ambient d → Ambient d, LipschitzWith 1 p ∧ + (∀ x, p x ∈ K) ∧ ∀ x ∈ K, p x = x := by + classical + choose p hp hmin using exists_norm_eq_iInf_of_complete_convex hne hcomplete hconvex + have hv (x : Ambient d) : ∀ w ∈ K, inner ℝ (x - p x) (w - p x) ≤ 0 := + (norm_eq_iInf_iff_real_inner_le_zero hconvex (hp x)).mp (hmin x) + refine ⟨p, ?_, hp, ?_⟩ + · apply LipschitzWith.of_dist_le_mul + intro x y + have hx := hv x (p y) (hp y) + have hy := hv y (p x) (hp x) + have hid : inner ℝ (x - y) (p x - p y) = ‖p x - p y‖ ^ 2 - + inner ℝ (x - p x) (p y - p x) - inner ℝ (y - p y) (p x - p y) := by + rw [← real_inner_self_eq_norm_sq] + simp only [inner_sub_left, inner_sub_right] + ring + have hc := real_inner_le_norm (x - y) (p x - p y) + simp only [NNReal.coe_one, one_mul, dist_eq_norm] + nlinarith [norm_nonneg (x - y), norm_nonneg (p x - p y)] + · intro x hx + have h := hv x x hx + rw [real_inner_self_eq_norm_sq] at h + have hz : ‖x - p x‖ = 0 := by nlinarith [norm_nonneg (x - p x)] + exact (sub_eq_zero.mp (norm_eq_zero.mp hz)).symm + +theorem exists_bounded_normalized_ball_chart {n d : ℕ} + (r : ℝ) (c : Ambient d) (b : ℝ) (hb : 0 ≤ b) + (f : ball (0 : Ambient n) (2 * r) → Ambient d) (M : ℝ≥0) (hf : LipschitzWith M f) : + ∃ g : ball (0 : Ambient n) r → Ambient d, + LipschitzWith (M * 2) g ∧ Set.range g ⊆ closedBall c b ∧ + (closedBall c b ∩ Set.range f) ⊆ Set.range g := by + obtain ⟨p, hp, hpRange, hpFix⟩ := exists_nonexpansive_retraction_of_complete_convex + (closedBall c b) ⟨c, mem_closedBall_self hb⟩ isClosed_closedBall.isComplete (convex_closedBall c b) + obtain ⟨h, hhLip, hhRange⟩ := exists_rescaled_ball_chart (2 * r) (0 : Ambient n) + 2 (by norm_num) f M hf + have heq : (2 * r) / ((2 : ℝ≥0) : ℝ) = r := by change (2 * r) / 2 = r; ring + rw [heq] at hhLip hhRange + let h' : ball (0 : Ambient n) r → Ambient d := (ball (0 : Ambient n) r).domRestrict h + have hh'Lip : LipschitzWith (M * 2) h' := hhLip.to_restrict + have hh'Range : Set.range h' = Set.range f := by + apply Set.Subset.antisymm + · rintro y ⟨u, rfl⟩ + exact hhRange ▸ mem_image_of_mem h u.property + · intro y hy + obtain ⟨u, hu, he⟩ := hhRange ▸ hy + exact ⟨⟨u, hu⟩, he⟩ + refine ⟨p ∘ h', ?_, ?_, ?_⟩ + · simpa only [one_mul] using! hp.comp hh'Lip + · rintro y ⟨u, rfl⟩ + exact hpRange (h' u) + · intro y hy + obtain ⟨u, hu⟩ := hh'Range ▸ hy.2 + exact ⟨u, by change p (h' u) = y; rw [hu, hpFix y hy.1]⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/CenteredPerturbedBallCoverage.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/CenteredPerturbedBallCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..381139804fc3c237f0062c650b620299abcf8bdd --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/CenteredPerturbedBallCoverage.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.PerturbedBallCoverage + +namespace OAI + +/-! +# Centered coverage for perturbed charts + +Lipschitz perturbations of the identity cover balls centered at any parameter +with sufficient room in the domain. Applied to tangential projection, this gives +a disk covered by the portion of the surface inside a controlled ambient ball. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem centered_ball_covered_by_lipschitz_perturbation {X : Type*} + [NormedAddCommGroup X] [CompleteSpace X] + (c : X) (R : ℝ) (f : closedBall c R → X) (K : ℝ≥0) (hK : K < 1) + (herr : LipschitzWith K (fun u => f u - u.val)) + (a : closedBall c R) (r : ℝ) (hr : 0 ≤ r) (hroom : dist a.val c + r ≤ R) : + ∀ z ∈ closedBall (f a) ((1 - (K : ℝ)) * r), + ∃ u : closedBall c R, dist u a ≤ r ∧ f u = z := by + have hsub : closedBall a.val r ⊆ closedBall c R := by + intro x hx + have hx' : dist x a.val ≤ r := hx + change dist x c ≤ R + exact (dist_triangle x a.val c).trans (by linarith) + let j : closedBall a.val r → closedBall c R := fun u => ⟨u.val, hsub u.property⟩ + let g : closedBall a.val r → X := fun u => f (j u) - f a + a.val + have hdisp : ∀ u, dist (g u) u.val ≤ (K : ℝ) * r := by + intro u + have hid : g u - u.val = (f (j u) - (j u).val) - (f a - a.val) := by + dsimp [g, j] + abel + rw [dist_eq_norm, hid] + have h := (herr.dist_le_mul (j u) a).trans + (mul_le_mul_of_nonneg_left (show dist (j u) a ≤ r from u.property) K.coe_nonneg) + simpa only [dist_eq_norm] using! h + have hLip : LipschitzWith K (fun u : closedBall a.val r => g u - u.val) := by + apply LipschitzWith.of_dist_le_mul + intro u v + have hid : (g u - u.val) - (g v - v.val) = + (f (j u) - (j u).val) - (f (j v) - (j v).val) := by + dsimp [g, j] + abel + rw [dist_eq_norm, hid] + simpa only [dist_eq_norm] using! herr.dist_le_mul (j u) (j v) + intro z hz + have hz' : z - f a + a.val ∈ closedBall a.val (r - (K : ℝ) * r) := by + have hd : dist (z - f a + a.val) a.val = dist z (f a) := by + rw [dist_eq_norm, dist_eq_norm] + congr 1 + abel + rw [mem_closedBall, hd] + have hzr : dist z (f a) ≤ (1 - (K : ℝ)) * r := hz + nlinarith + obtain ⟨u, hu⟩ := closedBall_covered_by_lipschitz_perturbation a.val r ((K : ℝ) * r) + hr K hK g hdisp hLip hz' + refine ⟨j u, u.property, ?_⟩ + change f (j u) - f a + a.val = z - f a + a.val at hu + exact sub_left_inj.mp (add_right_cancel hu) + +theorem centered_projection_disk_in_surface_ball {d : ℕ} + (P : Submodule ℝ (Ambient d)) (c : P) (R : ℝ) + (H : closedBall c R → Ambient d) (K L : ℝ≥0) + (hK : (K : ℝ) ≤ 1 / 2) (hL : (L : ℝ) ≤ 1 / 2) + (hError : LipschitzWith K (fun u => P.orthogonalProjectionOnto (H u) - u.val)) + (hNormal : LipschitzWith L (fun u => (Pᗮ : Submodule ℝ (Ambient d)).starProjection (H u))) + (a : closedBall c R) (ρ : ℝ) (hρ : 0 ≤ ρ) + (hroom : dist a.val c + 2 * ρ ≤ R) + (surface : Set (Ambient d)) (hSurface : ∀ u, dist u a ≤ 2 * ρ → H u ∈ surface) : + closedBall (P.orthogonalProjectionOnto (H a)) ρ ⊆ + P.orthogonalProjectionOnto '' (surface ∩ closedBall (H a) (2 * ρ)) := by + have hKone : K < 1 := by + have hreal : (K : ℝ) < 1 := by linarith + exact_mod_cast hreal + intro z hz + have hz' : z ∈ closedBall (P.orthogonalProjectionOnto (H a)) ((1 - (K : ℝ)) * (2 * ρ)) := by + have hdist : dist z (P.orthogonalProjectionOnto (H a)) ≤ ρ := hz + change dist z (P.orthogonalProjectionOnto (H a)) ≤ _ + nlinarith [mul_le_mul_of_nonneg_right hK hρ] + obtain ⟨u, hua, hu⟩ := centered_ball_covered_by_lipschitz_perturbation c R + (fun v => P.orthogonalProjectionOnto (H v)) K hKone hError a (2 * ρ) + (by positivity) hroom z hz' + change P.orthogonalProjectionOnto (H u) = z at hu + refine ⟨H u, ⟨hSurface u hua, ?_⟩, hu⟩ + have hp : ‖P.starProjection (H u - H a)‖ ≤ ρ := by + rw [map_sub] + change dist (P.orthogonalProjectionOnto (H u)) (P.orthogonalProjectionOnto (H a)) ≤ ρ + rw [hu] + exact hz + have hn := hNormal.dist_le_mul u a + rw [dist_eq_norm, ← map_sub] at hn + have ht := norm_add_le (P.starProjection (H u - H a)) + ((Pᗮ : Submodule ℝ (Ambient d)).starProjection (H u - H a)) + rw [P.starProjection_add_starProjection_orthogonal] at ht + change dist (H u) (H a) ≤ 2 * ρ + rw [dist_eq_norm] + have hnr : (L : ℝ) * dist u a ≤ ρ := by + have hb := mul_le_mul_of_nonneg_left hua L.coe_nonneg + nlinarith [mul_le_mul_of_nonneg_right hL hρ] + linarith + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ChartNormalCone.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ChartNormalCone.lean new file mode 100644 index 0000000000000000000000000000000000000000..04f249ea9af3de2920d7dc7671c88e30bb800a46 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ChartNormalCone.lean @@ -0,0 +1,34 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal + +theorem normal_projection_bound_on_chart_range {X : Type*} [PseudoMetricSpace X] {d : ℕ} + (P : Submodule ℝ (Ambient d)) (H : X → Ambient d) (K L : ℝ≥0) + (hNormal : LipschitzWith K (fun u => (Pᗮ : Submodule ℝ (Ambient d)).starProjection (H u))) + (hSep : AntilipschitzWith L H) + (x : Ambient d) (hx : x ∈ Set.range H) (y : Ambient d) (hy : y ∈ Set.range H) : + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection (x - y)‖ ≤ + ((K * L : ℝ≥0) : ℝ) * dist x y := by + obtain ⟨u, rfl⟩ := hx + obtain ⟨v, rfl⟩ := hy + have h := hNormal.dist_le_mul u v + rw [dist_eq_norm, ← map_sub] at h + calc + _ ≤ (K : ℝ) * dist u v := h + _ ≤ (K : ℝ) * ((L : ℝ) * dist (H u) (H v)) := + mul_le_mul_of_nonneg_left (hSep.le_mul_dist u v) K.coe_nonneg + _ = _ := by rw [NNReal.coe_mul]; ring + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ChildAndPointChartGluing.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ChildAndPointChartGluing.lean new file mode 100644 index 0000000000000000000000000000000000000000..d98cdd632cbf0fa0d7f31faf43f71394bed477f3 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ChildAndPointChartGluing.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.RescaledChildChartGluing + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem exists_ball_lipschitz_cover_of_children_and_points {n d : ℕ} {ι κ : Type*} + (a : ι → Ambient n) (c : ι → Ambient d) (r : ι → ℝ) + (b : κ → Ambient n) (y : κ → Ambient d) + (f : ∀ i : ι, ball (0 : Ambient n) (r i) → Ambient d) + (M A L : ℝ≥0) (hA : 0 < A) + (hsep : ∀ i j : ι, i ≠ j → r i + r j ≤ (A : ℝ) * dist (a i) (a j)) + (hcenters : ∀ i j : ι, dist (c i) (c j) ≤ (L : ℝ) * dist (a i) (a j)) + (hsepPoint : ∀ i : ι, ∀ j : κ, r i ≤ (A : ℝ) * dist (a i) (b j)) + (hcenterPoint : ∀ i : ι, ∀ j : κ, dist (c i) (y j) ≤ (L : ℝ) * dist (a i) (b j)) + (hpointLip : ∀ i j : κ, dist (y i) (y j) ≤ (L : ℝ) * dist (b i) (b j)) + (himage : ∀ i : ι, Set.range (f i) ⊆ closedBall (c i) (3 * r i)) + (hLip : ∀ i : ι, LipschitzWith M (f i)) + (ρ : ℝ) (hball : ∀ i : ι, ball (a i) (r i / (4 * (A : ℝ))) ⊆ ball (0 : Ambient n) ρ) + (hpointBall : ∀ j : κ, b j ∈ ball (0 : Ambient n) ρ) : + ∃ F : ball (0 : Ambient n) ρ → Ambient d, + LipschitzWith (lipschitzExtensionConstant (Ambient d) * + separatedPatchGluingConstant (M * (4 * A)) A L) F ∧ + ((⋃ i : ι, Set.range (f i)) ∪ Set.range y) ⊆ Set.range F := by + classical + have hs : 0 < 4 * A := by positivity + have hc (i : ι) := exists_rescaled_ball_chart (r i) (a i) (4 * A) hs (f i) M (hLip i) + choose g hg hrange using hc + have hrange' (i : ι) : g i '' ball (a i) (r i / (4 * (A : ℝ))) = Set.range (f i) := by + simpa only [NNReal.coe_mul, NNReal.coe_ofNat] using! hrange i + have hg' (i : ι) : LipschitzOnWith (M * (4 * A)) (g i) + (ball (a i) (r i / (4 * (A : ℝ)))) := by + simpa only [NNReal.coe_mul, NNReal.coe_ofNat] using! hg i + let a' : Sum ι κ → Ambient n := Sum.elim a b + let c' : Sum ι κ → Ambient d := Sum.elim c y + let r' : Sum ι κ → ℝ := Sum.elim r (fun _ => 0) + let D' : Sum ι κ → Set (Ambient n) := + Sum.elim (fun i => ball (a i) (r i / (4 * (A : ℝ)))) (fun j => {b j}) + let g' : Sum ι κ → Ambient n → Ambient d := Sum.elim g (fun j _ => y j) + have hsep' (i j : Sum ι κ) (hij : i ≠ j) : + r' i + r' j ≤ (A : ℝ) * dist (a' i) (a' j) := by + cases i with + | inl i => + cases j with + | inl j => exact hsep i j (fun heq => hij (congrArg Sum.inl heq)) + | inr j => simpa only [r', a', Sum.elim_inl, Sum.elim_inr, add_zero] using! hsepPoint i j + | inr i => + cases j with + | inl j => simpa only [r', a', Sum.elim_inl, Sum.elim_inr, zero_add, dist_comm] using! hsepPoint j i + | inr j => + change 0 + 0 ≤ _ + rw [zero_add] + exact mul_nonneg A.coe_nonneg dist_nonneg + have hcenters' (i j : Sum ι κ) : dist (c' i) (c' j) ≤ (L : ℝ) * dist (a' i) (a' j) := by + cases i with + | inl i => + cases j with + | inl j => exact hcenters i j + | inr j => exact hcenterPoint i j + | inr i => + cases j with + | inl j => simpa only [c', a', Sum.elim_inl, Sum.elim_inr, dist_comm] using! hcenterPoint j i + | inr j => exact hpointLip i j + have hparam' (i : Sum ι κ) (u : Ambient n) (hu : u ∈ D' i) : + dist u (a' i) ≤ r' i / (4 * (A : ℝ)) := by + cases i with + | inl i => exact le_of_lt hu + | inr j => + have heq : u = b j := hu + simp only [a', r', Sum.elim_inr, heq, dist_self, zero_div, le_refl] + have himage' (i : Sum ι κ) (u : Ambient n) (hu : u ∈ D' i) : + dist (g' i u) (c' i) ≤ 3 * r' i := by + cases i with + | inl i => exact himage i (hrange' i ▸ mem_image_of_mem (g i) hu) + | inr j => simp only [g', c', r', Sum.elim_inr, dist_self, mul_zero, le_refl] + have hLip' (i : Sum ι κ) : LipschitzOnWith (M * (4 * A)) (g' i) (D' i) := by + cases i with + | inl i => exact hg' i + | inr j => + apply LipschitzOnWith.of_dist_le_mul + intro u hu v hv + change dist (y j) (y j) ≤ _ + rw [dist_self] + positivity + have hball' : (⋃ i : Sum ι κ, D' i) ⊆ ball (0 : Ambient n) ρ := by + apply iUnion_subset + intro i + cases i with + | inl i => exact hball i + | inr j => exact singleton_subset_iff.mpr (hpointBall j) + obtain ⟨F, hF, hcover⟩ := exists_ball_lipschitz_cover_of_separated_parameter_patches + a' c' r' D' g' (M * (4 * A)) A L hA hsep' hcenters' hparam' himage' hLip' ρ hball' + refine ⟨F, hF, ?_⟩ + intro v hv + rcases hv with hchild | hpoint + · obtain ⟨i, hi⟩ := mem_iUnion.mp hchild + have hi' : v ∈ g i '' ball (a i) (r i / (4 * (A : ℝ))) := hrange' i ▸ hi + exact hcover (mem_iUnion.mpr ⟨Sum.inl i, hi'⟩) + · obtain ⟨j, rfl⟩ := hpoint + exact hcover (mem_iUnion.mpr ⟨Sum.inr j, b j, mem_singleton (b j), rfl⟩) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/CoherentCellCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/CoherentCellCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fab1baf895b3cfa9166973a6a3a70b084185220 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/CoherentCellCharts.lean @@ -0,0 +1,71 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Nets.PointCellChains +import OAI.Analysis.RieszRectifiability.Projections.ProjectionPieceParameterization + +namespace OAI + +/-! +# Lipschitz charts from coherent cell fits + +For each pair of points, a descendant at the separation scale supplies a nearby affine +plane with small angle to a fixed subspace. The resulting lower bound on projected +distances gives an inverse Lipschitz estimate and a ball parameterization of the piece. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +theorem projection_separates_of_coherent_cell_fits {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (E : Set (Ambient d)) (hE : E ⊆ cleanSupportCell μ R hR k z) + (P : Submodule ℝ (Ambient d)) + (hfit : ∀ i : SupportCellDescendant μ R hR k z, + (E ∩ i.cell).Nonempty → ∃ S : AffineSubspace ℝ (Ambient d), + IsAffineNPlane n S ∧ + (∀ w ∈ E ∩ ball i.center (1024 * i.radius), infDist w (S : Set (Ambient d)) ≤ i.radius) ∧ + ∀ v ∈ S.direction, + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection v‖ ≤ (1 / 4) * ‖v‖) : + ∀ x ∈ E, ∀ y ∈ E, dist x y ≤ 2 * dist (P.starProjection x) (P.starProjection y) := by + intro x hx y hy + by_cases hxy : x = y + · simp only [hxy, dist_self, mul_zero, le_refl] + obtain ⟨i, hxi, hupper, _, hxball, hyball⟩ := + exists_pair_scale_support_descendant μ R hR k z x y (hE hx) (hE hy) hxy + obtain ⟨S, hS, hnear, hangle⟩ := hfit i ⟨x, hx, hxi⟩ + let : Nonempty S := hS.1.to_subtype + have hxs : infDist x (S : Set (Ambient d)) ≤ (1 / 8) * dist x y := by + have h := hnear x ⟨hx, hxball⟩ + linarith + have hys : infDist y (S : Set (Ambient d)) ≤ (1 / 8) * dist x y := by + have h := hnear y ⟨hy, hyball⟩ + linarith + exact projection_separates_of_pairwise_plane P S x y (1 / 8) (1 / 4) + (by norm_num) (by norm_num) hxs hys hangle + +theorem exists_ball_lipschitz_cover_of_coherent_cell_fits {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (E : Set (Ambient d)) (hE : E ⊆ cleanSupportCell μ R hR k z) + (a : Ambient d) (r : ℝ) (hball : E ⊆ ball a r) + (P : Submodule ℝ (Ambient d)) (hdim : Module.finrank ℝ P = n) + (hfit : ∀ i : SupportCellDescendant μ R hR k z, + (E ∩ i.cell).Nonempty → ∃ S : AffineSubspace ℝ (Ambient d), + IsAffineNPlane n S ∧ + (∀ w ∈ E ∩ ball i.center (1024 * i.radius), infDist w (S : Set (Ambient d)) ≤ i.radius) ∧ + ∀ v ∈ S.direction, + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection v‖ ≤ (1 / 4) * ‖v‖) : + ∃ g : (ball (0 : Ambient n) r) → Ambient d, + LipschitzWith (lipschitzExtensionConstant (Ambient d) * 2) g ∧ E ⊆ range g := by + exact exists_ball_lipschitz_cover_of_projection E a r hball P hdim 2 + (projection_separates_of_coherent_cell_fits μ R hR k z E hE P hfit) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ContinuousChartInnerCoverage.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ContinuousChartInnerCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..34425eb738aad7e4a5c690acc532f162d2f71565 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ContinuousChartInnerCoverage.lean @@ -0,0 +1,67 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Projections.ProjectionTubeLocation +import OAI.Analysis.RieszRectifiability.Surfaces.ContinuousPerturbedBallCoverage + +namespace OAI + +/-! +# Inner projection coverage of continuous charts + +A chart whose projected displacement is small covers an inner ball in the plane direction. +Bounds on the chart height and the base point's distance to the plane keep the covering +points inside the required ambient ball. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set + +theorem continuous_chart_inner_projection_coverage {d : ℕ} + (S : AffineSubspace ℝ (Ambient d)) (hS : (S : Set (Ambient d)).Nonempty) + (c : S.direction) (R : ℝ) (H : closedBall c R → Ambient d) + (hH : Continuous H) (surface : Set (Ambient d)) (hRange : Set.range H ⊆ surface) + (p : Ambient d) (ρ e a b : ℝ) (hρ : 0 ≤ ρ) + (hroom : dist (S.direction.orthogonalProjectionOnto p) c + 2 * ρ ≤ R) + (hDisp : ∀ u, dist (S.direction.orthogonalProjectionOnto (H u)) u.val ≤ e) + (hHeight : ∀ u, infDist (H u) (S : Set (Ambient d)) ≤ a) + (hBase : infDist p (S : Set (Ambient d)) ≤ b) + (he : e ≤ ρ) (hab : a + b ≤ ρ) : + closedBall (S.direction.orthogonalProjectionOnto p) ρ ⊆ + S.direction.orthogonalProjectionOnto '' (surface ∩ closedBall p (2 * ρ)) := by + let P := S.direction + have hsub : closedBall (P.orthogonalProjectionOnto p) (2 * ρ) ⊆ closedBall c R := by + intro u hu + have ht := dist_triangle u (P.orthogonalProjectionOnto p) c + have hud : dist u (P.orthogonalProjectionOnto p) ≤ 2 * ρ := hu + change dist u c ≤ R + linarith + let j : closedBall (P.orthogonalProjectionOnto p) (2 * ρ) → closedBall c R := + fun u => ⟨u.val, hsub u.property⟩ + have hj : Continuous j := continuous_subtype_val.subtype_mk _ + have hCont : Continuous (fun u => P.orthogonalProjectionOnto (H (j u))) := + P.orthogonalProjectionOnto.continuous.comp (hH.comp hj) + intro z hz + have hz' : z ∈ closedBall (P.orthogonalProjectionOnto p) (2 * ρ - e) := by + have hzd : dist z (P.orthogonalProjectionOnto p) ≤ ρ := hz + change dist z (P.orthogonalProjectionOnto p) ≤ _ + linarith + obtain ⟨u, hu⟩ := closedBall_covered_by_continuous_perturbation + (P.orthogonalProjectionOnto p) (2 * ρ) e (by positivity) + (fun u => P.orthogonalProjectionOnto (H (j u))) hCont (fun u => hDisp (j u)) hz' + change P.orthogonalProjectionOnto (H (j u)) = z at hu + refine ⟨H (j u), ⟨hRange ⟨j u, rfl⟩, ?_⟩, hu⟩ + have hprojected : dist (P.starProjection (H (j u))) (P.starProjection p) ≤ ρ := by + change dist (P.orthogonalProjectionOnto (H (j u))) (P.orthogonalProjectionOnto p) ≤ ρ + rw [hu] + exact hz + have ht := dist_le_projection_add_plane_distances S hS (H (j u)) p + change dist (H (j u)) p ≤ 2 * ρ + linarith [hHeight (j u)] + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ContinuousPerturbedBallCoverage.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ContinuousPerturbedBallCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef672c9341092c1ddc42219732aae674f88f1ad4 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ContinuousPerturbedBallCoverage.lean @@ -0,0 +1,52 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds +import FixedPointTheorems.brouwer + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set + +theorem closedBall_covered_by_continuous_perturbation {X : Type*} + [NormedAddCommGroup X] [NormedSpace ℝ X] [FiniteDimensional ℝ X] + (a : X) (r δ : ℝ) (hr : 0 ≤ r) + (f : closedBall a r → X) (hf : Continuous f) + (hdisp : ∀ x, dist (f x) x.val ≤ δ) : + closedBall a (r - δ) ⊆ Set.range f := by + intro z hz + have hz' : ‖z - a‖ ≤ r - δ := by + simpa only [mem_closedBall, dist_eq_norm] using! hz + have hmaps (x : closedBall a r) : z - (f x - x.val) ∈ closedBall a r := by + change dist (z - (f x - x.val)) a ≤ r + calc + _ = ‖(z - a) - (f x - x.val)‖ := by + rw [dist_eq_norm] + congr 1 + abel + _ ≤ ‖z - a‖ + ‖f x - x.val‖ := norm_sub_le _ _ + _ ≤ (r - δ) + δ := add_le_add hz' + (by simpa only [dist_eq_norm] using! hdisp x) + _ = r := by ring + let T : C(closedBall a r, closedBall a r) := + ⟨fun x => ⟨z - (f x - x.val), hmaps x⟩, + (continuous_const.sub (hf.sub continuous_subtype_val)).subtype_mk _⟩ + obtain ⟨u, hu⟩ := _root_.brouwer_fixed_point (closedBall a r) + (convex_closedBall a r) (isCompact_closedBall a r) + ⟨a, mem_closedBall_self hr⟩ T + have heq := congrArg (fun x : closedBall a r => x.val) hu + change z - (f u - u.val) = u.val at heq + refine ⟨u, ?_⟩ + calc + f u = (f u - u.val) + u.val := (sub_add_cancel _ _).symm + _ = (f u - u.val) + (z - (f u - u.val)) := + congrArg (fun w => (f u - u.val) + w) heq.symm + _ = z := by abel + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ConvexChartContraction.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ConvexChartContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cf603a1d407d193e6905fe4199bd8ba8a9bfd14 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ConvexChartContraction.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set Topology + +theorem exists_contraction_in_convex_chart {E V : Type*} + [NormedAddCommGroup E] [NormedSpace ℝ E] [MetricSpace V] + (C : Set E) (hC : Convex ℝ C) (H : C → V) (hH : IsEmbedding H) + (A : Set V) (hA : A ⊆ Set.range H) (p : V) (hp : p ∈ A) : + ∃ F : unitInterval × A → V, Continuous F ∧ + (∀ x, F (0, x) = x.val) ∧ (∀ x, F (1, x) = p) ∧ + (∀ s, F (s, ⟨p, hp⟩) = p) ∧ (∀ w, F w ∈ Set.range H) := by + classical + have hpre : ∀ x : A, ∃ u : C, H u = x.val := fun x => hA x.property + choose j hj using hpre + have hjcont : Continuous j := hH.continuous_iff.mpr (by + have hid : H ∘ j = (Subtype.val : A → V) := funext hj + rw [hid] + exact continuous_subtype_val) + let u0 : C := j ⟨p, hp⟩ + let T : unitInterval × A → C := fun w => + ⟨(1 - (w.1 : ℝ)) • (j w.2 : E) + (w.1 : ℝ) • (u0 : E), + hC (j w.2).property u0.property (sub_nonneg.mpr w.1.property.2) + w.1.property.1 (by ring)⟩ + have hs : Continuous (fun w : unitInterval × A => (w.1 : ℝ)) := + continuous_subtype_val.comp continuous_fst + have hjv : Continuous (fun w : unitInterval × A => (j w.2 : E)) := + continuous_subtype_val.comp (hjcont.comp continuous_snd) + have hT : Continuous T := + (((continuous_const.sub hs).smul hjv).add (hs.smul continuous_const)).subtype_mk _ + let F := H ∘ T + refine ⟨F, hH.continuous.comp hT, ?_, ?_, ?_, ?_⟩ + · intro x + have ht : T (0, x) = j x := by apply Subtype.ext; simp [T] + change H (T (0, x)) = x.val + rw [ht] + exact hj x + · intro x + have ht : T (1, x) = u0 := by apply Subtype.ext; simp [T] + change H (T (1, x)) = p + rw [ht] + exact hj ⟨p, hp⟩ + · intro s + have ht : T (s, ⟨p, hp⟩) = u0 := by + apply Subtype.ext + change (1 - (s : ℝ)) • (u0 : E) + (s : ℝ) • (u0 : E) = (u0 : E) + rw [← add_smul] + simp + change H (T (s, ⟨p, hp⟩)) = p + rw [ht] + exact hj ⟨p, hp⟩ + · intro w + exact ⟨T w, rfl⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteBallChartUnion.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteBallChartUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..69eb445f1d229a8d112911970be0a87d692c5906 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteBallChartUnion.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.RescaledChildChartGluing +import OAI.Analysis.RieszRectifiability.Surfaces.BoundedNormalizedBallCharts +import OAI.Analysis.RieszRectifiability.Surfaces.FiniteChartParameterPacking + +namespace OAI + +/-! +# Finite unions of ball charts + +Separated parameter islands encode finitely many bounded Lipschitz charts in a single +ball chart. The union constant combines the packing factor, the gluing estimate, and +the ambient Lipschitz extension constant. Extension followed by a nonexpansive +retraction also handles charts initially defined on subsets of the parameter ball. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +def finiteBallChartUnionConstant (d N : ℕ) (M : ℝ≥0) : ℝ≥0 := + lipschitzExtensionConstant (Ambient d) * + separatedPatchGluingConstant (M * (4 * finiteChartPackingFactor N)) (finiteChartPackingFactor N) 0 + +theorem exists_ball_lipschitz_cover_of_finite_ball_charts {n d : ℕ} (hn : 0 < n) + (N : ℕ) (r : ℝ) (hr : 0 < r) (z : Ambient d) + (f : Fin N → ball (0 : Ambient n) r → Ambient d) + (M : ℝ≥0) (hLip : ∀ i, LipschitzWith M (f i)) + (himage : ∀ i, Set.range (f i) ⊆ closedBall z (3 * r)) : + ∃ g : ball (0 : Ambient n) r → Ambient d, + LipschitzWith (finiteBallChartUnionConstant d N M) g ∧ + (⋃ i : Fin N, Set.range (f i)) ⊆ Set.range g := by + have hdim : 0 < Module.finrank ℝ (Ambient n) := by simpa [Ambient] using! hn + let : Nontrivial (Ambient n) := Module.nontrivial_of_finrank_pos hdim + obtain ⟨e, he⟩ := exists_norm_eq (Ambient n) (show 0 ≤ (1 : ℝ) by norm_num) + have hA : 0 < finiteChartPackingFactor N := by unfold finiteChartPackingFactor; positivity + exact exists_ball_lipschitz_cover_of_rescaled_children (finiteChartParameterCenter e r N) + (fun _ => z) (fun _ => r) f M (finiteChartPackingFactor N) 0 hA + (finite_chart_parameter_centers_separated e he r hr N) + (fun _ _ => by simp only [dist_self, NNReal.coe_zero, zero_mul, le_refl]) + himage hLip r (finite_chart_parameter_island_subset e he r hr N) + +theorem exists_ball_lipschitz_cover_of_finite_partial_charts {n d : ℕ} (hn : 0 < n) + (N : ℕ) (r : ℝ) (hr : 0 < r) (z : Ambient d) + (D : Fin N → Set (Ambient n)) (hD : ∀ i, D i ⊆ ball (0 : Ambient n) r) + (f : Fin N → Ambient n → Ambient d) (M : ℝ≥0) + (hLip : ∀ i, LipschitzOnWith M (f i) (D i)) + (himage : ∀ i, f i '' D i ⊆ closedBall z (3 * r)) : + ∃ g : ball (0 : Ambient n) r → Ambient d, + LipschitzWith (finiteBallChartUnionConstant d N (lipschitzExtensionConstant (Ambient d) * M)) g ∧ + (⋃ i : Fin N, f i '' D i) ⊆ Set.range g := by + classical + have hext (i : Fin N) := (hLip i).extend_finite_dimension + choose F hF hEq using hext + obtain ⟨p, hp, hpRange, hpFix⟩ := exists_nonexpansive_retraction_of_complete_convex + (closedBall z (3 * r)) ⟨z, mem_closedBall_self (by positivity)⟩ + isClosed_closedBall.isComplete (convex_closedBall z (3 * r)) + let g : Fin N → ball (0 : Ambient n) r → Ambient d := + fun i => p ∘ (ball (0 : Ambient n) r).domRestrict (F i) + have hgLip (i : Fin N) : LipschitzWith (lipschitzExtensionConstant (Ambient d) * M) (g i) := by + simpa only [one_mul] using! hp.comp ((hF i).restrict (ball (0 : Ambient n) r)) + have hgRange (i : Fin N) : Set.range (g i) ⊆ closedBall z (3 * r) := by + rintro y ⟨u, rfl⟩ + exact hpRange (F i u.val) + obtain ⟨h, hhLip, hhCover⟩ := exists_ball_lipschitz_cover_of_finite_ball_charts hn N r hr z g + (lipschitzExtensionConstant (Ambient d) * M) hgLip hgRange + refine ⟨h, hhLip, ?_⟩ + intro y hy + obtain ⟨i, u, hu, rfl⟩ := mem_iUnion.mp hy + apply hhCover + apply mem_iUnion.mpr + refine ⟨i, ⟨u, hD i hu⟩, ?_⟩ + change p (F i u) = f i u + rw [← hEq i hu, hpFix (f i u) (himage i (mem_image_of_mem (f i) hu))] + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteChartParameterPacking.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteChartParameterPacking.lean new file mode 100644 index 0000000000000000000000000000000000000000..11ed7b36b94cfe46717bf74341398f6cc0381b06 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteChartParameterPacking.lean @@ -0,0 +1,84 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +def finiteChartPackingFactor (N : ℕ) : ℝ≥0 := 4 * ((N : ℝ≥0) + 1) + +def finiteChartParameterCenter {n : ℕ} (e : Ambient n) (r : ℝ) (N : ℕ) (i : Fin N) : Ambient n := + (((i.val : ℝ) + 1) * (r / (2 * ((N : ℝ) + 1)))) • e + +theorem finite_chart_parameter_center_mem {n : ℕ} + (e : Ambient n) (he : ‖e‖ = 1) (r : ℝ) (hr : 0 < r) (N : ℕ) (i : Fin N) : + finiteChartParameterCenter e r N i ∈ closedBall (0 : Ambient n) (r / 2) := by + have hi : (i.val : ℝ) + 1 ≤ (N : ℝ) := by exact_mod_cast Nat.succ_le_of_lt i.isLt + have hN : 0 ≤ (N : ℝ) := Nat.cast_nonneg N + rw [mem_closedBall_zero_iff, finiteChartParameterCenter, norm_smul, + Real.norm_eq_abs, abs_of_nonneg (by positivity), he, mul_one] + have hden : 0 < 2 * ((N : ℝ) + 1) := by positivity + rw [← mul_div_assoc, div_le_iff₀ hden] + nlinarith + +theorem finite_chart_parameter_centers_separated {n : ℕ} + (e : Ambient n) (he : ‖e‖ = 1) (r : ℝ) (hr : 0 < r) (N : ℕ) + (i j : Fin N) (hij : i ≠ j) : + r + r ≤ (finiteChartPackingFactor N : ℝ) * + dist (finiteChartParameterCenter e r N i) (finiteChartParameterCenter e r N j) := by + let δ := r / (2 * ((N : ℝ) + 1)) + have hδ : 0 < δ := by dsimp [δ]; positivity + have hneq : i.val ≠ j.val := fun h => hij (Fin.ext h) + have habs : 1 ≤ |(i.val : ℝ) - (j.val : ℝ)| := by + rcases lt_or_gt_of_ne hneq with hlt | hgt + · have h : (i.val : ℝ) + 1 ≤ (j.val : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hlt + rw [abs_of_nonpos (by linarith)] + linarith + · have h : (j.val : ℝ) + 1 ≤ (i.val : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hgt + rw [abs_of_nonneg (by linarith)] + linarith + have hdist : δ ≤ dist (finiteChartParameterCenter e r N i) (finiteChartParameterCenter e r N j) := by + rw [dist_eq_norm, finiteChartParameterCenter, finiteChartParameterCenter, + ← sub_smul, norm_smul, Real.norm_eq_abs, he, mul_one] + change δ ≤ |((i.val : ℝ) + 1) * δ - ((j.val : ℝ) + 1) * δ| + rw [show ((i.val : ℝ) + 1) * δ - ((j.val : ℝ) + 1) * δ = + ((i.val : ℝ) - (j.val : ℝ)) * δ by ring, abs_mul, abs_of_pos hδ] + simpa only [one_mul] using! mul_le_mul_of_nonneg_right habs hδ.le + have hid : (finiteChartPackingFactor N : ℝ) * δ = r + r := by + change (4 * ((N : ℝ) + 1)) * (r / (2 * ((N : ℝ) + 1))) = r + r + have hN : (N : ℝ) + 1 ≠ 0 := by positivity + field_simp + ring + rw [← hid] + exact mul_le_mul_of_nonneg_left hdist (finiteChartPackingFactor N).coe_nonneg + +theorem finite_chart_parameter_island_subset {n : ℕ} + (e : Ambient n) (he : ‖e‖ = 1) (r : ℝ) (hr : 0 < r) (N : ℕ) (i : Fin N) : + ball (finiteChartParameterCenter e r N i) (r / (4 * (finiteChartPackingFactor N : ℝ))) ⊆ + ball (0 : Ambient n) r := by + intro u hu + have hc : dist (finiteChartParameterCenter e r N i) (0 : Ambient n) ≤ r / 2 := + finite_chart_parameter_center_mem e he r hr N i + have hA : 4 ≤ (finiteChartPackingFactor N : ℝ) := by + change 4 ≤ 4 * ((N : ℝ) + 1) + have hN := Nat.cast_nonneg (α := ℝ) N + linarith + have hden : 0 < 4 * (finiteChartPackingFactor N : ℝ) := by linarith + have hrad : r / (4 * (finiteChartPackingFactor N : ℝ)) ≤ r / 4 := + (div_le_iff₀ hden).mpr (by nlinarith) + have ht := dist_triangle u (finiteChartParameterCenter e r N i) (0 : Ambient n) + have hu' : dist u (finiteChartParameterCenter e r N i) < + r / (4 * (finiteChartPackingFactor N : ℝ)) := hu + change dist u (0 : Ambient n) < r + linarith + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteChartUnionBounds.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteChartUnionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..50c769ea3d36af72edd0553527526d2f94b68b7b --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FiniteChartUnionBounds.lean @@ -0,0 +1,43 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.FiniteBallChartUnion + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem finiteBallChartUnionConstant_mono (d : ℕ) {N K : ℕ} (hNK : N ≤ K) + {M L : ℝ≥0} (hML : M ≤ L) : + finiteBallChartUnionConstant d N M ≤ finiteBallChartUnionConstant d K L := by + have hNK' : (N : ℝ≥0) ≤ (K : ℝ≥0) := by exact_mod_cast hNK + unfold finiteBallChartUnionConstant separatedPatchGluingConstant finiteChartPackingFactor + gcongr + +theorem exists_ball_lipschitz_cover_of_bounded_finite_family {n d : ℕ} (hn : 0 < n) + {ι : Type*} [Fintype ι] (N : ℕ) (hN : Fintype.card ι ≤ N) + (r : ℝ) (hr : 0 < r) (z : Ambient d) + (f : ι → ball (0 : Ambient n) r → Ambient d) + (M : ℝ≥0) (hLip : ∀ i, LipschitzWith M (f i)) + (himage : ∀ i, Set.range (f i) ⊆ closedBall z (3 * r)) : + ∃ g : ball (0 : Ambient n) r → Ambient d, + LipschitzWith (finiteBallChartUnionConstant d N M) g ∧ + (⋃ i : ι, Set.range (f i)) ⊆ Set.range g := by + let e : Fin (Fintype.card ι) ≃ ι := (Fintype.equivFin ι).symm + obtain ⟨g, hg, hcover⟩ := exists_ball_lipschitz_cover_of_finite_ball_charts hn + (Fintype.card ι) r hr z (fun j => f (e j)) M (fun j => hLip (e j)) (fun j => himage (e j)) + refine ⟨g, hg.weaken (finiteBallChartUnionConstant_mono d hN le_rfl), ?_⟩ + intro y hy + obtain ⟨i, hi⟩ := mem_iUnion.mp hy + apply hcover + apply mem_iUnion.mpr + exact ⟨e.symm i, by simpa only [e.apply_symm_apply] using! hi⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/FittingPlaneInputChart.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FittingPlaneInputChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..86716cd9cf446b06c2436ac960c9f56e2bbe0daf --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/FittingPlaneInputChart.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.InitialAffineCharts + +namespace OAI + +/-! +# Input charts on fitting planes + +A small bilateral plane error bounds the offset of a support center from the fitting +plane. The located affine chart then gives the input disk, with constant normal component, +exact projected range, and image contained in the ambient ball of radius `3 * r`. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal + +theorem exists_fitting_plane_input_chart {n d : ℕ} + (μ : Measure (Ambient d)) (c : Ambient d) (hc : c ∈ μ.support) + (r : ℝ) (hr : 0 < r) (ε : ℝ) (hεsmall : ε ≤ 1 / 2048) + (S : AffineSubspace ℝ (Ambient d)) (hS : IsAffineNPlane n S) + (hfit : bilateralPlaneError μ c (1024 * r) S < ε) : + ∃ g : closedBall (S.direction.orthogonalProjectionOnto c) ((5 / 2 : ℝ) * r) → Ambient d, + LipschitzWith 2 g ∧ + LipschitzWith 0 (fun u => (S.directionᗮ : Submodule ℝ (Ambient d)).starProjection (g u)) ∧ + (∀ u, g u ∈ S ∧ S.direction.orthogonalProjectionOnto (g u) = u.val ∧ + g u ∈ closedBall c (3 * r)) ∧ + Set.range g = (S : Set (Ambient d)) ∩ S.direction.orthogonalProjectionOnto ⁻¹' + closedBall (S.direction.orthogonalProjectionOnto c) ((5 / 2 : ℝ) * r) := by + have hcenter := (bilateralPlaneError_lt_pointwise μ ⟨c, hc⟩ c (1024 * r) ε + (by positivity) S hS hfit).1 c (mem_ball_self (by positivity)) hc + have hoffset : infDist c (S : Set (Ambient d)) ≤ r / 2 := by + have hm := mul_le_mul_of_nonneg_right hεsmall (show 0 ≤ 1024 * r by positivity) + linarith + obtain ⟨g, hLip, hnLip, hcoords, hrange⟩ := + exists_located_affine_plane_disk_chart S hS.1 c ((5 / 2 : ℝ) * r) + refine ⟨g, hLip.weaken (by norm_num), hnLip, ?_, hrange⟩ + intro u + refine ⟨(hcoords u).1, (hcoords u).2.1, ?_⟩ + have hloc := (hcoords u).2.2 + change dist (g u) c ≤ 3 * r + linarith + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ImmediateChildChartAssembly.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ImmediateChildChartAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..a80090ace7fac4f6ace869df6f09d4617384916c --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ImmediateChildChartAssembly.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.FiniteChartUnionBounds +import OAI.Analysis.RieszRectifiability.Surfaces.ImmediateChildChartRescaling + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +def immediateChildAssemblyConstant (d : ℕ) (M : ℝ≥0) : ℝ≥0 := + finiteBallChartUnionConstant d (257 ^ d) (M / 64) + +theorem exists_immediate_child_chart_assembly {n d : ℕ} (hn : 0 < n) + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (f : ∀ i : supportImmediateChildren μ R hR k z, ball (0 : Ambient n) i.val.radius → Ambient d) + (M : ℝ≥0) (hLip : ∀ i, LipschitzWith M (f i)) + (himage : ∀ i, Set.range (f i) ⊆ closedBall i.val.center (2 * i.val.radius)) : + ∃ g : ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + LipschitzWith (immediateChildAssemblyConstant d M) g ∧ + Set.range g ⊆ closedBall (z : Ambient d) (2 * latticeRadius R k) ∧ + (∀ i, i.val.cell ∩ Set.range (f i) ⊆ Set.range g) ∧ + μ (cleanSupportCell μ R hR k z \ Set.range g) ≤ + ∑ i : supportImmediateChildren μ R hR k z, μ (i.val.cell \ Set.range (f i)) := by + classical + have hr : 0 < latticeRadius R k := latticeRadius_pos R hR k + obtain ⟨F, hF, hFRange⟩ := exists_immediate_child_charts_on_parent_ball μ R hR k z f M hLip + have hcount : Fintype.card (supportImmediateChildren μ R hR k z) ≤ 257 ^ d := by + simpa using! supportImmediateChildren_card_le μ R hR k z + have hFImage (i : supportImmediateChildren μ R hR k z) : + Set.range (F i) ⊆ closedBall (z : Ambient d) (3 * latticeRadius R k) := by + intro y hy + have hnear : dist y i.val.center ≤ 2 * i.val.radius := himage i (hFRange i ▸ hy) + have hc := i.val.center_dist_top + have ht := dist_triangle y i.val.center (z : Ambient d) + rw [supportImmediateChild_radius μ R hR k z i] at hnear + change dist y (z : Ambient d) ≤ 3 * latticeRadius R k + linarith + obtain ⟨g, hgLip, hgCover⟩ := exists_ball_lipschitz_cover_of_bounded_finite_family hn + (257 ^ d) hcount (latticeRadius R k) hr (z : Ambient d) F (M / 64) hF hFImage + obtain ⟨p, hpLip, hpRange, hpFix⟩ := exists_nonexpansive_retraction_of_complete_convex + (closedBall (z : Ambient d) (2 * latticeRadius R k)) + ⟨(z : Ambient d), mem_closedBall_self (by positivity)⟩ isClosed_closedBall.isComplete + (convex_closedBall (z : Ambient d) (2 * latticeRadius R k)) + have hcover (i : supportImmediateChildren μ R hR k z) (y : Ambient d) + (hy : y ∈ i.val.cell) (hyRange : y ∈ Set.range (f i)) : y ∈ Set.range (p ∘ g) := by + have htop := i.val.cell_subset_top hy + have hball : y ∈ closedBall (z : Ambient d) (2 * latticeRadius R k) := + (supportLatticeCell_bounds μ R hR k z).2 htop.1 + have hyF : y ∈ Set.range (F i) := hFRange i ▸ hyRange + obtain ⟨u, hu⟩ := hgCover (mem_iUnion.mpr ⟨i, hyF⟩) + exact ⟨u, by change p (g u) = y; rw [hu, hpFix y hball]⟩ + have hsub : cleanSupportCell μ R hR k z \ Set.range (p ∘ g) ⊆ + ⋃ i : supportImmediateChildren μ R hR k z, i.val.cell \ Set.range (f i) := by + intro y hy + have hpart : y ∈ ⋃ i : supportImmediateChildren μ R hR k z, i.val.cell := + cleanSupportCell_eq_immediate_children μ R hR k z ▸ hy.1 + obtain ⟨i, hi⟩ := mem_iUnion.mp hpart + exact mem_iUnion.mpr ⟨i, hi, fun h => hy.2 (hcover i y hi h)⟩ + refine ⟨p ∘ g, ?_, ?_, ?_, ?_⟩ + · simpa only [one_mul] using! hpLip.comp hgLip + · rintro y ⟨u, rfl⟩ + exact hpRange (g u) + · intro i y hy + exact hcover i y hy.1 hy.2 + · have h : μ (cleanSupportCell μ R hR k z \ Set.range (p ∘ g)) ≤ + ∑' i : supportImmediateChildren μ R hR k z, μ (i.val.cell \ Set.range (f i)) := + (measure_mono hsub).trans (measure_iUnion_le _) + simpa only [tsum_fintype] using! h + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ImmediateChildChartRescaling.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ImmediateChildChartRescaling.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae0bec7a111189b51d88442ba0810847ea543274 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ImmediateChildChartRescaling.lean @@ -0,0 +1,57 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.RescaledBallCharts +import OAI.Analysis.RieszRectifiability.Foundations.ImmediateChildPartition + +namespace OAI + +/-! +# Immediate-child charts on a parent ball + +Rescaling immediate-child charts to the parent lattice ball preserves their images and divides +their Lipschitz bounds by the fixed radius ratio of 64. Restricting the rescaled maps to the open +parent ball gives a common parameter domain for all children. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal + +theorem exists_immediate_child_charts_on_parent_ball {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (f : ∀ i : supportImmediateChildren μ R hR k z, ball (0 : Ambient n) i.val.radius → Ambient d) + (M : ℝ≥0) (hLip : ∀ i, LipschitzWith M (f i)) : + ∃ F : supportImmediateChildren μ R hR k z → ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + (∀ i, LipschitzWith (M / 64) (F i)) ∧ ∀ i, Set.range (F i) = Set.range (f i) := by + classical + have hcharts (i : supportImmediateChildren μ R hR k z) : + ∃ g : Ambient n → Ambient d, + LipschitzOnWith (M / 64) g (ball (0 : Ambient n) (latticeRadius R k)) ∧ + g '' ball (0 : Ambient n) (latticeRadius R k) = Set.range (f i) := by + have h := exists_rescaled_ball_chart i.val.radius (0 : Ambient n) (1 / 64) + (by norm_num) (f i) M (hLip i) + have hdom : i.val.radius / ((1 / 64 : ℝ≥0) : ℝ) = latticeRadius R k := by + change i.val.radius / (1 / 64 : ℝ) = latticeRadius R k + rw [supportImmediateChild_radius μ R hR k z i] + ring + rw [hdom] at h + simpa only [one_div, div_eq_mul_inv, one_mul] using! h + choose g hg hRange using hcharts + refine ⟨fun i => (ball (0 : Ambient n) (latticeRadius R k)).domRestrict (g i), + fun i => (hg i).to_restrict, ?_⟩ + intro i + apply Set.Subset.antisymm + · rintro y ⟨u, rfl⟩ + exact hRange i ▸ mem_image_of_mem (g i) u.property + · intro y hy + obtain ⟨u, hu, he⟩ := hRange i ▸ hy + exact ⟨⟨u, hu⟩, he⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/InitialAffineCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/InitialAffineCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f703a10270e40f003f155641b7f3ba19d764cde0 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/InitialAffineCharts.lean @@ -0,0 +1,88 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.ActiveProjectionDiskCoverage +import OAI.Analysis.RieszRectifiability.Projections.CoveredProjectionCharts + +namespace OAI + +/-! +# Initial affine-plane charts + +Orthogonal coordinates parametrize each affine-plane disk by a 1-Lipschitz chart with +constant normal component and exact range. A distance estimate locates the chart near +an ambient center, with error given by that center's distance to the plane. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set EuclideanGeometry +open scoped NNReal + +theorem exists_affine_plane_disk_chart {d : ℕ} + (S : AffineSubspace ℝ (Ambient d)) (hS : (S : Set (Ambient d)).Nonempty) + (a : S.direction) (ρ : ℝ) : + ∃ g : closedBall a ρ → Ambient d, + LipschitzWith 1 g ∧ + LipschitzWith 0 (fun u => (S.directionᗮ : Submodule ℝ (Ambient d)).starProjection (g u)) ∧ + (∀ u, g u ∈ S ∧ S.direction.orthogonalProjectionOnto (g u) = u.val) ∧ + Set.range g = (S : Set (Ambient d)) ∩ S.direction.orthogonalProjectionOnto ⁻¹' closedBall a ρ := by + let : Nonempty S := hS.to_subtype + have hcover : closedBall a ρ ⊆ S.direction.orthogonalProjectionOnto '' (S : Set (Ambient d)) := by + intro v _ + refine ⟨nonemptyAffineProjection S hS (v : Ambient d), ?_, ?_⟩ + · exact orthogonalProjection_mem (v : Ambient d) + · rw [nonemptyAffineProjection_tangential] + exact S.direction.orthogonalProjectionOnto_mem_subspace_eq_self v + have hcone : ∀ x ∈ (S : Set (Ambient d)), ∀ y ∈ (S : Set (Ambient d)), + ‖(S.directionᗮ : Submodule ℝ (Ambient d)).starProjection (x - y)‖ ≤ + ((0 : ℝ≥0) : ℝ) * dist (S.direction.starProjection x) (S.direction.starProjection y) := by + intro x hx y hy + have hv : x - y ∈ S.direction := AffineSubspace.vsub_mem_direction hx hy + rw [S.direction.starProjection_orthogonal_val, + S.direction.starProjection_eq_self_iff.mpr hv, sub_self, norm_zero, NNReal.coe_zero, zero_mul] + simpa only [add_zero] using! + exists_chart_on_covered_projection S.direction (S : Set (Ambient d)) 0 (closedBall a ρ) hcover hcone + +theorem affine_plane_dist_le_projection_add_offset {d : ℕ} + (S : AffineSubspace ℝ (Ambient d)) (hS : (S : Set (Ambient d)).Nonempty) + (x c : Ambient d) (hx : x ∈ S) : + dist x c ≤ dist (S.direction.starProjection x) (S.direction.starProjection c) + + infDist c (S : Set (Ambient d)) := by + let : Nonempty S := hS.to_subtype + have hn := normal_projection_bound_by_plane_distances S x c + rw [infDist_zero_of_mem hx, zero_add] at hn + have ht := norm_add_le (S.direction.starProjection (x - c)) + ((S.directionᗮ : Submodule ℝ (Ambient d)).starProjection (x - c)) + rw [S.direction.starProjection_add_starProjection_orthogonal] at ht + rw [map_sub, ← dist_eq_norm x c, + ← dist_eq_norm (S.direction.starProjection x) (S.direction.starProjection c)] at ht + exact ht.trans (add_le_add le_rfl hn) + +theorem exists_located_affine_plane_disk_chart {d : ℕ} + (S : AffineSubspace ℝ (Ambient d)) (hS : (S : Set (Ambient d)).Nonempty) + (c : Ambient d) (ρ : ℝ) : + ∃ g : closedBall (S.direction.orthogonalProjectionOnto c) ρ → Ambient d, + LipschitzWith 1 g ∧ + LipschitzWith 0 (fun u => (S.directionᗮ : Submodule ℝ (Ambient d)).starProjection (g u)) ∧ + (∀ u, g u ∈ S ∧ S.direction.orthogonalProjectionOnto (g u) = u.val ∧ + dist (g u) c ≤ ρ + infDist c (S : Set (Ambient d))) ∧ + Set.range g = (S : Set (Ambient d)) ∩ S.direction.orthogonalProjectionOnto ⁻¹' + closedBall (S.direction.orthogonalProjectionOnto c) ρ := by + obtain ⟨g, hLip, hnLip, hcoords, hrange⟩ := + exists_affine_plane_disk_chart S hS (S.direction.orthogonalProjectionOnto c) ρ + refine ⟨g, hLip, hnLip, ?_, hrange⟩ + intro u + refine ⟨(hcoords u).1, (hcoords u).2, ?_⟩ + have hstar : S.direction.starProjection (g u) = (u.val : Ambient d) := + congrArg (fun v : S.direction => (v : Ambient d)) (hcoords u).2 + have h := affine_plane_dist_le_projection_add_offset S hS (g u) c (hcoords u).1 + rw [hstar] at h + have hu : dist (u.val : Ambient d) (S.direction.starProjection c) ≤ ρ := u.property + exact h.trans (add_le_add hu le_rfl) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/LipschitzChartLift.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/LipschitzChartLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecf14def425f837cdc783cec2fa03bf14a89c59c --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/LipschitzChartLift.lean @@ -0,0 +1,37 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Set +open scoped NNReal + +theorem exists_lipschitz_lift_of_antilipschitz {X U V : Type*} + [MetricSpace X] [MetricSpace U] [MetricSpace V] + (F : U → V) (K : ℝ≥0) (hF : AntilipschitzWith K F) + (g : X → V) (L : ℝ≥0) (hg : LipschitzWith L g) + (hinto : Set.range g ⊆ Set.range F) : + ∃ h : X → U, LipschitzWith (K * L) h ∧ ∀ x, F (h x) = g x := by + classical + have hpre : ∀ x : X, ∃ u : U, F u = g x := fun x => hinto ⟨x, rfl⟩ + choose h hh using hpre + refine ⟨h, ?_, hh⟩ + apply LipschitzWith.of_dist_le_mul + intro x y + have hb := hF.le_mul_dist (h x) (h y) + rw [hh x, hh y] at hb + calc + dist (h x) (h y) ≤ (K : ℝ) * dist (g x) (g y) := hb + _ ≤ (K : ℝ) * ((L : ℝ) * dist x y) := + mul_le_mul_of_nonneg_left (hg.dist_le_mul x y) K.coe_nonneg + _ = ((K * L : ℝ≥0) : ℝ) * dist x y := by rw [NNReal.coe_mul]; ring + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceBallDepthCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceBallDepthCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdbb8b920ed44eeb8d4e169b116880bc612e4675 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceBallDepthCharts.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.MatchedSurfaceDepthCharts +import OAI.Analysis.RieszRectifiability.Surfaces.SurfaceBallChartAssembly + +namespace OAI + +/-! +# Finite-depth charts on surface balls + +Finite unions of matched-surface cell charts produce maps from Euclidean balls. +The construction retains the finite-depth mass-deficit estimate and an explicit +Lipschitz bound determined by the cell-chart bound and the covering multiplicity. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Filter Topology +open scoped NNReal ENNReal + +variable {n d : ℕ} + (ν : Measure (Ambient d)) (A : Set (Ambient d)) (hν : ν = nativeSurfaceArea n A) + (hsupport : ν.support = A) + (C G : ℝ) (hC : 0 < C) (hG : 0 < G) (hg : GlobalUpperGrowth n G ν) + (hlower : ∀ x ∈ ν.support, ∀ r : ℝ, AdmissibleRadius ν r → + ENNReal.ofReal (r ^ n / C) ≤ ν (ball x r)) + (σ κ : ℝ) (hσ : 0 < σ) (hκ : 0 < κ) (hκ1 : κ ≤ 1) + (hwidth : σ + κ ≤ 1) (hsmall : 2048 * σ * (κ + 1) ≤ κ) + (hshadow : projectionStopShadowConstant n C σ κ ≤ nativeCoreAreaFraction n G) + (hgeometry : ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ σ * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16))) + (hdiam : ediam ν.support = ⊤) + +include hν hsupport hC hG hg hlower hσ hκ hκ1 hwidth hsmall hshadow hgeometry hdiam + +theorem exists_matched_surface_ball_depth_chart (hn : 0 < n) (J : ℕ) + (r : ℝ) (hr : 0 < r) (a : Ambient d) : + ∃ g : ball (0 : Ambient n) r → Ambient d, + LipschitzWith (finiteBallChartUnionConstant d (11 ^ d) + (projectionRegionDepthConstant d (Real.toNNReal (2 / κ)) J)) g ∧ + Set.range g ⊆ closedBall a (3 * r) ∧ + (μH[(n : ℝ)] : Measure (Ambient d)) ((A ∩ closedBall a (3 * r)) \ Set.range g) ≤ + (ENNReal.ofReal (1 - nativeCoreAreaFraction n G)) ^ J * ENNReal.ofReal (G * (8 * r) ^ n) := by + apply exists_surface_ball_chart_of_cell_deficits hn ν A hν hsupport C G hC hG hg hlower + r hr a (projectionRegionDepthConstant d (Real.toNNReal (2 / κ)) J) + ((ENNReal.ofReal (1 - nativeCoreAreaFraction n G)) ^ J) + intro z + have hlocal := exists_matched_surface_depth_chart ν A hν hsupport C G hC hG hg hlower + σ κ hσ hκ hκ1 hwidth hsmall hshadow hgeometry hdiam J r hr 0 z.val + obtain ⟨g₀, hg₀, _, hdef⟩ := hlocal + let cast : ball (0 : Ambient n) r → ball (0 : Ambient n) (latticeRadius r 0) := + fun u => ⟨u.val, by simpa only [latticeRadius_zero] using! u.property⟩ + have hcast : Isometry cast := fun _ _ => rfl + have hsurj : Function.Surjective cast := by + intro u + exact ⟨⟨u.val, by simpa only [latticeRadius_zero] using! u.property⟩, Subtype.ext rfl⟩ + let g := g₀ ∘ cast + have hrange : Set.range g = Set.range g₀ := by + apply Set.Subset.antisymm + · rintro y ⟨u, rfl⟩ + exact Set.mem_range_self (cast u) + · rintro y ⟨u, rfl⟩ + obtain ⟨v, hv⟩ := hsurj u + exact ⟨v, congrArg g₀ hv⟩ + refine ⟨g, ?_, ?_⟩ + · simpa only [mul_one] using! hg₀.comp hcast.lipschitzWith + · rw [hrange] + exact hdef + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceCellPlanes.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceCellPlanes.lean new file mode 100644 index 0000000000000000000000000000000000000000..79fffc610690e7874123deae1dabe3d6d5303161 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceCellPlanes.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Projections.ProjectionConditionedRegions + +namespace OAI + +/-! +# Matched planes for support-cell descendants + +Pointwise geometric fits select an affine plane through every descendant center. +The root plane retains the projected disk coverage supplied by the same choice. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set + +theorem exists_matched_surface_cell_planes {n d : ℕ} + (ν : Measure (Ambient d)) (σ : ℝ) + (hgeometry : ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ σ * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16))) + (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets ν R hR k).points) : + ∃ S : SupportCellDescendant ν R hR k z → AffineSubspace ℝ (Ambient d), + (∀ i, IsAffineNPlane n (S i)) ∧ (∀ i, i.center ∈ S i) ∧ + (∀ i, ∀ x ∈ ν.support ∩ closedBall i.center (1024 * i.radius), + infDist x (S i : Set (Ambient d)) ≤ σ * i.radius) ∧ + let P := (S (supportCellRoot ν R hR k z)).direction + closedBall (P.orthogonalProjectionOnto z) (latticeRadius R k / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall (z : Ambient d) (latticeRadius R k / 16)) := by + classical + have hall (i : SupportCellDescendant ν R hR k z) := + hgeometry i.center i.center_mem_support i.radius i.radius_pos + choose Ps hdim hfit hcover using hall + let S (i : SupportCellDescendant ν R hR k z) := AffineSubspace.mk' i.center (Ps i) + have hS : ∀ i, IsAffineNPlane n (S i) := by + intro i + refine ⟨AffineSubspace.mk'_nonempty i.center (Ps i), ?_⟩ + rw [AffineSubspace.direction_mk'] + exact hdim i + refine ⟨S, hS, ?_, hfit, ?_⟩ + · intro i + apply AffineSubspace.mem_mk'.mpr + simpa only [vsub_self] using! (Ps i).zero_mem + · change closedBall ((S (supportCellRoot ν R hR k z)).direction.orthogonalProjectionOnto z) _ ⊆ _ + dsimp only [S] + rw [AffineSubspace.direction_mk'] + exact hcover (supportCellRoot ν R hR k z) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceDepthCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceDepthCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fd3255c633e84b808f070e8f9e0c8a4321651e6 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfaceDepthCharts.lean @@ -0,0 +1,91 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Projections.ProjectionRegionDepthCharts +import OAI.Analysis.RieszRectifiability.Projections.ContractingProjectionRegions + +namespace OAI + +/-! +# Matched surface charts with controlled loss + +For surfaces of infinite support diameter, contracting projection regions provide +finite-depth charts with geometric mass loss. Choosing the depth from a positive +loss tolerance gives one Lipschitz bound valid at every lattice scale and cell. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Filter Topology +open scoped NNReal ENNReal + +variable {n d : ℕ} + (ν : Measure (Ambient d)) (A : Set (Ambient d)) (hν : ν = nativeSurfaceArea n A) + (hsupport : ν.support = A) + (C G : ℝ) (hC : 0 < C) (hG : 0 < G) (hg : GlobalUpperGrowth n G ν) + (hlower : ∀ x ∈ ν.support, ∀ r : ℝ, AdmissibleRadius ν r → + ENNReal.ofReal (r ^ n / C) ≤ ν (ball x r)) + (σ κ : ℝ) (hσ : 0 < σ) (hκ : 0 < κ) (hκ1 : κ ≤ 1) + (hwidth : σ + κ ≤ 1) (hsmall : 2048 * σ * (κ + 1) ≤ κ) + (hshadow : projectionStopShadowConstant n C σ κ ≤ nativeCoreAreaFraction n G) + (hgeometry : ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ σ * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16))) + (hdiam : ediam ν.support = ⊤) + +include hν hsupport hC hG hg hlower hσ hκ hκ1 hwidth hsmall hshadow hgeometry hdiam + +theorem exists_matched_surface_depth_chart (J : ℕ) : + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets ν R hR k).points), + ∃ g : ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + LipschitzWith (projectionRegionDepthConstant d (Real.toNNReal (2 / κ)) J) g ∧ + Set.range g ⊆ closedBall (z : Ambient d) (2 * latticeRadius R k) ∧ + ν (cleanSupportCell ν R hR k z \ Set.range g) ≤ + (ENNReal.ofReal (1 - nativeCoreAreaFraction n G)) ^ J * ν (cleanSupportCell ν R hR k z) := by + have hL : 1 ≤ Real.toNNReal (2 / κ) := by + have h : (1 : ℝ) ≤ (Real.toNNReal (2 / κ) : ℝ) := by + rw [Real.coe_toNNReal _ (by positivity)] + apply (le_div_iff₀ hκ).mpr + linarith + exact_mod_cast h + apply exists_projection_region_depth_chart ν (Real.toNNReal (2 / κ)) hL (nativeCoreAreaFraction n G) ?_ J + intro R hR k z + have hcore : AdmissibleRadius ν (latticeRadius R k / 8) := by + refine ⟨by have hr := latticeRadius_pos R hR k; positivity, ?_⟩ + rw [hdiam] + exact le_top + obtain ⟨Good, _, P, hdim, hsep, _, hstop⟩ := exists_contracting_projection_region + ν A hν hsupport C G hC hG hg hlower σ κ hσ hκ hκ1 hwidth hsmall hshadow hgeometry R hR k hcore z + refine ⟨Good, P, hdim, ?_, hstop⟩ + simpa only [Real.coe_toNNReal _ (by positivity : 0 ≤ 2 / κ)] using! hsep + +theorem exists_matched_surface_uniform_small_loss_chart (δ : ℝ) (hδ : 0 < δ) : + ∃ M : ℝ≥0, ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets ν R hR k).points), + ∃ g : ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + LipschitzWith M g ∧ + Set.range g ⊆ closedBall (z : Ambient d) (2 * latticeRadius R k) ∧ + ν (cleanSupportCell ν R hR k z \ Set.range g) ≤ + ENNReal.ofReal δ * ν (cleanSupportCell ν R hR k z) := by + have hθ := nativeCoreAreaFraction_pos_le_half n G hG + have hzero : 0 ≤ 1 - nativeCoreAreaFraction n G := by linarith [hθ.2] + have hone : 1 - nativeCoreAreaFraction n G < 1 := by linarith [hθ.1] + have hlim := tendsto_pow_atTop_nhds_zero_of_lt_one hzero hone + have hevent : ∀ᶠ J : ℕ in atTop, (1 - nativeCoreAreaFraction n G) ^ J < δ := + hlim.eventually (gt_mem_nhds hδ) + obtain ⟨J, hJ⟩ := hevent.exists + refine ⟨projectionRegionDepthConstant d (Real.toNNReal (2 / κ)) J, ?_⟩ + intro R hR k z + obtain ⟨g, hg, hrange, hdeficit⟩ := exists_matched_surface_depth_chart + ν A hν hsupport C G hC hG hg hlower σ κ hσ hκ hκ1 hwidth hsmall hshadow hgeometry hdiam J R hR k z + refine ⟨g, hg, hrange, hdeficit.trans (mul_le_mul' ?_ le_rfl)⟩ + rw [← ENNReal.ofReal_pow hzero] + exact ENNReal.ofReal_le_ofReal hJ.le + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfacePrecision.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfacePrecision.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ad0dac508f185464a989e6257f57988f295cc3e --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/MatchedSurfacePrecision.lean @@ -0,0 +1,33 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.ActiveRegionSurfaceModel + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +theorem exists_matched_surface_precision (d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 / 72057594037927936 ∧ + activeProjectionError d ε ≤ 1 / 4096 ∧ + 281474976710656 * (ε + activeProjectionError d ε) ≤ δ := by + let C : ℝ := 2048 + 1048576 * (9 : ℝ) ^ d + have hC : 0 < C := by dsimp only [C]; positivity + let ε : ℝ := min (1 / 72057594037927936) (min (1 / (4096 * C)) + (δ / (281474976710656 * (1 + C)))) + have hε : 0 < ε := lt_min (by norm_num) (lt_min (by positivity) (by positivity)) + have h₁ : ε ≤ 1 / (4096 * C) := (min_le_right _ _).trans (min_le_left _ _) + have h₂ : ε ≤ δ / (281474976710656 * (1 + C)) := (min_le_right _ _).trans (min_le_right _ _) + refine ⟨ε, hε, min_le_left _ _, ?_, ?_⟩ + · change C * ε ≤ 1 / 4096 + have heq : C * (1 / (4096 * C)) = 1 / 4096 := by field_simp + exact (mul_le_mul_of_nonneg_left h₁ hC.le).trans_eq heq + · change 281474976710656 * (ε + C * ε) ≤ δ + have h := (le_div_iff₀ (by positivity : 0 < 281474976710656 * (1 + C))).mp h₂ + nlinarith + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeCoreAreaFraction.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeCoreAreaFraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbad120c3eb139b1f6a157ae30763ec0ec035df0 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeCoreAreaFraction.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Packing.LatticeMassPacking +import OAI.Analysis.RieszRectifiability.Surfaces.PlaneDiskLowerArea +import OAI.Analysis.RieszRectifiability.Foundations.NativeHausdorffGrowth + +namespace OAI + +/-! +# A uniform fraction for core area + +The core-area fraction depends only on the dimension and upper growth +constant. Its coefficient bound compares lattice-cell mass with the +Hausdorff measure of a plane disk at the smaller core scale. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped ENNReal + +def nativeCoreAreaFraction (n : ℕ) (G : ℝ) : ℝ := + min (1 / 2) ((planeUnitHausdorffMeasure n).toReal / + (2 * (G * (3 : ℝ) ^ n * (32 : ℝ) ^ n))) + +theorem nativeCoreAreaFraction_pos_le_half (n : ℕ) (G : ℝ) (hG : 0 < G) : + 0 < nativeCoreAreaFraction n G ∧ nativeCoreAreaFraction n G ≤ 1 / 2 := by + have hu : 0 < (planeUnitHausdorffMeasure n).toReal := + ENNReal.toReal_pos_iff.mpr ⟨planeUnitHausdorffMeasure_pos n, planeUnitHausdorffMeasure_lt_top n⟩ + exact ⟨lt_min (by norm_num) (by positivity), min_le_left _ _⟩ + +theorem nativeCoreAreaFraction_coefficient_bound (n : ℕ) (G : ℝ) (hG : 0 < G) : + 2 * nativeCoreAreaFraction n G * (G * (3 : ℝ) ^ n) ≤ + (planeUnitHausdorffMeasure n).toReal / (32 : ℝ) ^ n := by + have h := min_le_right (1 / 2 : ℝ) + ((planeUnitHausdorffMeasure n).toReal / (2 * (G * (3 : ℝ) ^ n * (32 : ℝ) ^ n))) + change nativeCoreAreaFraction n G ≤ _ at h + have hb := (le_div_iff₀ (by positivity : 0 < 2 * (G * (3 : ℝ) ^ n * (32 : ℝ) ^ n))).mp h + apply (le_div_iff₀ (by positivity : 0 < (32 : ℝ) ^ n)).mpr + nlinarith + +theorem native_core_disk_area_ge_double_fraction {n d : ℕ} + (ν : Measure (Ambient d)) (G : ℝ) (hG : 0 < G) (hg : GlobalUpperGrowth n G ν) + (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets ν R hR k).points) + (a : Ambient n) : + ENNReal.ofReal (2 * nativeCoreAreaFraction n G) * ν (cleanSupportCell ν R hR k z) ≤ + (μH[(n : ℝ)] : Measure (Ambient n)) (closedBall a (latticeRadius R k / 32)) := by + have hr := latticeRadius_pos R hR k + have hθ := (nativeCoreAreaFraction_pos_le_half n G hG).1 + have htop : ν (cleanSupportCell ν R hR k z) ≤ ENNReal.ofReal (G * (3 * latticeRadius R k) ^ n) := by + have hb := (supportLatticeCell_bounds ν R hR k z).2 + have hsub : cleanSupportCell ν R hR k z ⊆ ball (z : Ambient d) (3 * latticeRadius R k) := + sdiff_subset.trans (hb.trans (closedBall_subset_ball (by have hr := latticeRadius_pos R hR k; linarith))) + exact (measure_mono hsub).trans (hg.2 z _ (by positivity)) + have hcoeff := nativeCoreAreaFraction_coefficient_bound n G hG + have hreal : (2 * nativeCoreAreaFraction n G) * (G * (3 * latticeRadius R k) ^ n) ≤ + (latticeRadius R k / 32) ^ n * (planeUnitHausdorffMeasure n).toReal := by + have h := mul_le_mul_of_nonneg_right hcoeff (pow_nonneg (latticeRadius_pos R hR k).le n) + calc + _ = (2 * nativeCoreAreaFraction n G * (G * (3 : ℝ) ^ n)) * (latticeRadius R k) ^ n := by + rw [mul_pow]; ring + _ ≤ ((planeUnitHausdorffMeasure n).toReal / (32 : ℝ) ^ n) * (latticeRadius R k) ^ n := h + _ = _ := by rw [div_pow]; ring + calc + _ ≤ ENNReal.ofReal (2 * nativeCoreAreaFraction n G) * + ENNReal.ofReal (G * (3 * latticeRadius R k) ^ n) := mul_le_mul' le_rfl htop + _ = ENNReal.ofReal ((2 * nativeCoreAreaFraction n G) * (G * (3 * latticeRadius R k) ^ n)) := + (ENNReal.ofReal_mul (by positivity)).symm + _ ≤ ENNReal.ofReal ((latticeRadius R k / 32) ^ n * (planeUnitHausdorffMeasure n).toReal) := + ENNReal.ofReal_le_ofReal hreal + _ = _ := by + rw [ambient_closedBall_hausdorffMeasure n a _ (by positivity), + ENNReal.ofReal_mul (by positivity), + ENNReal.ofReal_toReal (planeUnitHausdorffMeasure_lt_top n).ne, + ENNReal.ofReal_pow (by positivity)] + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeSurfaceArea.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeSurfaceArea.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d8f899a6884aa248180aed8d5a1a21a220d72e8 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeSurfaceArea.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Kernel.KernelBasic + +namespace OAI + +/-! +# Intrinsic surface-area measures + +The native surface-area measure is Hausdorff measure restricted to the surface. +Upper area growth gives local finiteness and regularity, while lower area bounds +identify the support when the surface is closed. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Topology +open scoped ENNReal + +def nativeSurfaceArea {d : ℕ} (n : ℕ) (A : Set (Ambient d)) : Measure (Ambient d) := + (μH[(n : ℝ)] : Measure (Ambient d)).restrict A + +theorem nativeSurfaceArea_apply {n d : ℕ} (A B : Set (Ambient d)) + (hB : MeasurableSet B) : + nativeSurfaceArea n A B = (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ B) := by + rw [nativeSurfaceArea, Measure.restrict_apply hB, inter_comm] + +theorem nativeSurfaceArea_open_ball_lower {n d : ℕ} + (A : Set (Ambient d)) (c : ℝ≥0∞) + (hlower : ∀ p ∈ A, ∀ r : ℝ, 0 < r → + c * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r)) + (p : Ambient d) (hp : p ∈ A) (r : ℝ) (hr : 0 < r) : + (c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n) * (ENNReal.ofReal r) ^ n ≤ + nativeSurfaceArea n A (ball p r) := by + rw [nativeSurfaceArea_apply A _ measurableSet_ball] + have h := hlower p hp (r / 2) (by positivity) + have heq : c * (ENNReal.ofReal (r / 2)) ^ n = + (c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n) * (ENNReal.ofReal r) ^ n := by + rw [show r / 2 = (1 / 2) * r by ring, + ENNReal.ofReal_mul (by norm_num : (0 : ℝ) ≤ 1 / 2), mul_pow] + exact (mul_assoc _ _ _).symm + rw [heq] at h + exact h.trans (measure_mono (inter_subset_inter_right _ + (closedBall_subset_ball (by linarith : r / 2 < r)))) + +theorem nativeSurfaceArea_global_upper_growth {n d : ℕ} + (A : Set (Ambient d)) (C : ℝ≥0∞) (hC : C < ⊤) + (hupper : ∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r) ≤ + C * (ENNReal.ofReal r) ^ n) : + GlobalUpperGrowth n C.toReal (nativeSurfaceArea n A) := by + refine ⟨ENNReal.toReal_nonneg, ?_⟩ + intro p r hr + rw [nativeSurfaceArea_apply A _ measurableSet_ball, + ENNReal.ofReal_mul ENNReal.toReal_nonneg, ENNReal.ofReal_toReal hC.ne, + ENNReal.ofReal_pow hr.le] + exact (measure_mono (inter_subset_inter_right _ ball_subset_closedBall)).trans + (hupper p r hr) + +theorem nativeSurfaceArea_regular {n d : ℕ} + (A : Set (Ambient d)) (C : ℝ≥0∞) (hC : C < ⊤) + (hupper : ∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r) ≤ + C * (ENNReal.ofReal r) ^ n) : + (nativeSurfaceArea n A).Regular := by + have hg := nativeSurfaceArea_global_upper_growth A C hC hupper + let : IsLocallyFiniteMeasure (nativeSurfaceArea n A) := + ⟨fun x => ⟨ball x 1, ball_mem_nhds x (by norm_num), + (hg.2 x 1 (by norm_num)).trans_lt ENNReal.ofReal_lt_top⟩⟩ + infer_instance + +theorem nativeSurfaceArea_support {n d : ℕ} + (A : Set (Ambient d)) (hA : IsClosed A) (c : ℝ≥0∞) (hc : 0 < c) + (hlower : ∀ p ∈ A, ∀ r : ℝ, 0 < r → + c * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r)) : + (nativeSurfaceArea n A).support = A := by + apply Subset.antisymm + · exact (nativeSurfaceArea n A).support_subset_of_isClosed hA + (ae_restrict_mem hA.measurableSet) + · intro p hp + apply ((nativeSurfaceArea n A).mem_support_iff_forall p).mpr + intro U hU + obtain ⟨r, hr, hsub⟩ := Metric.mem_nhds_iff.mp hU + have hpos : 0 < (c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n) * (ENNReal.ofReal r) ^ n := by + positivity + exact (hpos.trans_le (nativeSurfaceArea_open_ball_lower A c hlower p hp r hr)).trans_le + (measure_mono hsub) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeSurfaceRegularity.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeSurfaceRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..26889f77be1cc0f6c3cf4867289f1bcfe8ec54cc --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/NativeSurfaceRegularity.lean @@ -0,0 +1,115 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Flatness.PlaneBoxGrowth +import OAI.Analysis.RieszRectifiability.Surfaces.NativeSurfaceArea +import OAI.Analysis.RieszRectifiability.Foundations.GlobalLowerDiameter + +namespace OAI + +/-! +Two-sided Hausdorff measure bounds yield a single AD constant for native surface area. +Global positive-dimensional lower growth also forces infinite support diameter. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Topology +open scoped ENNReal + +def nativeSurfaceADConstant (n : ℕ) (c C : ℝ≥0∞) : ℝ := + 1 + C.toReal + (c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n).toReal⁻¹ + +theorem nativeSurfaceArea_uniform_bounds {n d : ℕ} + (A : Set (Ambient d)) (c C : ℝ≥0∞) (hc : 0 < c) (hcfin : c < ⊤) (hC : C < ⊤) + (hlower : ∀ p ∈ A, ∀ r : ℝ, 0 < r → + c * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r)) + (hupper : ∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r) ≤ + C * (ENNReal.ofReal r) ^ n) : + 1 ≤ nativeSurfaceADConstant n c C ∧ + GlobalUpperGrowth n (nativeSurfaceADConstant n c C) (nativeSurfaceArea n A) ∧ + ∀ p ∈ A, ∀ r : ℝ, 0 < r → + ENNReal.ofReal (r ^ n / nativeSurfaceADConstant n c C) ≤ + nativeSurfaceArea n A (ball p r) := by + let l : ℝ≥0∞ := c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n + have hlpos : 0 < l := by dsimp only [l]; positivity + have hlfin : l < ⊤ := ENNReal.mul_lt_top hcfin (ENNReal.pow_lt_top ENNReal.ofReal_lt_top) + have hlreal : 0 < l.toReal := ENNReal.toReal_pos_iff.mpr ⟨hlpos, hlfin⟩ + have hCnonneg : 0 ≤ C.toReal := ENNReal.toReal_nonneg + have hK1 : 1 ≤ nativeSurfaceADConstant n c C := by + change 1 ≤ 1 + C.toReal + l.toReal⁻¹ + have : 0 ≤ l.toReal⁻¹ := (inv_pos.mpr hlreal).le + linarith + have hKC : C.toReal ≤ nativeSurfaceADConstant n c C := by + change C.toReal ≤ 1 + C.toReal + l.toReal⁻¹ + have : 0 ≤ l.toReal⁻¹ := (inv_pos.mpr hlreal).le + linarith + have hKinv : l.toReal⁻¹ ≤ nativeSurfaceADConstant n c C := by + change l.toReal⁻¹ ≤ 1 + C.toReal + l.toReal⁻¹ + linarith + refine ⟨hK1, (nativeSurfaceArea_global_upper_growth A C hC hupper).mono_constant hKC, ?_⟩ + intro p hp r hr + have hKpos : 0 < nativeSurfaceADConstant n c C := zero_lt_one.trans_le hK1 + have hprod : 1 ≤ l.toReal * nativeSurfaceADConstant n c C := by + have h := mul_le_mul_of_nonneg_left hKinv hlreal.le + simpa only [mul_inv_cancel₀ hlreal.ne'] using! h + have hdiv : r ^ n / nativeSurfaceADConstant n c C ≤ l.toReal * r ^ n := by + apply (div_le_iff₀ hKpos).mpr + calc + r ^ n = 1 * r ^ n := (one_mul _).symm + _ ≤ (l.toReal * nativeSurfaceADConstant n c C) * r ^ n := + mul_le_mul_of_nonneg_right hprod (pow_nonneg hr.le n) + _ = (l.toReal * r ^ n) * nativeSurfaceADConstant n c C := by ring + have h := nativeSurfaceArea_open_ball_lower A c hlower p hp r hr + have heq : ENNReal.ofReal (l.toReal * r ^ n) = l * (ENNReal.ofReal r) ^ n := by + rw [ENNReal.ofReal_mul hlreal.le, ENNReal.ofReal_toReal hlfin.ne, ENNReal.ofReal_pow hr.le] + exact (ENNReal.ofReal_le_ofReal hdiv).trans (heq.symm ▸ h) + +theorem nativeSurfaceArea_adRegular {n d : ℕ} + (A : Set (Ambient d)) (hA : IsClosed A) + (c C : ℝ≥0∞) (hc : 0 < c) (hcfin : c < ⊤) (hC : C < ⊤) + (hlower : ∀ p ∈ A, ∀ r : ℝ, 0 < r → + c * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r)) + (hupper : ∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r) ≤ + C * (ENNReal.ofReal r) ^ n) : + ADRegular n (nativeSurfaceArea n A) := by + obtain ⟨hK, hg, hl⟩ := nativeSurfaceArea_uniform_bounds A c C hc hcfin hC hlower hupper + refine ⟨nativeSurfaceADConstant n c C, hK, ?_⟩ + intro p hp r hr + rw [nativeSurfaceArea_support A hA c hc hlower] at hp + exact ⟨hl p hp r hr.1, hg.2 p r hr.1⟩ + +theorem nativeSurfaceArea_support_ediam_top {n d : ℕ} (hn : 0 < n) + (A : Set (Ambient d)) (hA : IsClosed A) (hne : A.Nonempty) + (c C : ℝ≥0∞) (hc : 0 < c) (hcfin : c < ⊤) (hC : C < ⊤) + (hlower : ∀ p ∈ A, ∀ r : ℝ, 0 < r → + c * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r)) + (hupper : ∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (A ∩ closedBall p r) ≤ + C * (ENNReal.ofReal r) ^ n) : + ediam (nativeSurfaceArea n A).support = ⊤ := by + let : (nativeSurfaceArea n A).Regular := nativeSurfaceArea_regular A C hC hupper + have hs := nativeSurfaceArea_support A hA c hc hlower + obtain ⟨hK, _, hl⟩ := nativeSurfaceArea_uniform_bounds A c C hc hcfin hC hlower hupper + have hKpos : 0 < nativeSurfaceADConstant n c C := zero_lt_one.trans_le hK + have hnz : nativeSurfaceArea n A ≠ 0 := by + intro hz + obtain ⟨p, hp⟩ := hne + have h := hl p hp 1 (by norm_num) + rw [hz] at h + have hpos : 0 < ENNReal.ofReal ((1 : ℝ) ^ n / nativeSurfaceADConstant n c C) := + ENNReal.ofReal_pos.mpr (by positivity) + exact (not_le_of_gt hpos) (by simpa using! h) + exact global_lower_growth_support_ediam_top n hn (nativeSurfaceArea n A) hnz + (nativeSurfaceADConstant n c C) hKpos (fun p hp r hr => hl p (hs ▸ hp) r hr) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADMatchedSurfaceModels.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADMatchedSurfaceModels.lean new file mode 100644 index 0000000000000000000000000000000000000000..edd296a0f54e8d305a22ad0714573af859d3045d --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADMatchedSurfaceModels.lean @@ -0,0 +1,75 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.OriginalADUniformPrecisionAreaModels +import OAI.Analysis.RieszRectifiability.Surfaces.ActualNativeSurfaceGeometry +import OAI.Analysis.RieszRectifiability.Surfaces.MatchedSurfacePrecision + +namespace OAI + +/-! +# Matched surface models for an AD-regular measure + +Uniform-precision area models combine with the native surface geometry to give +matched projection coverage at every scale. The top-mass and AD constants are +chosen before the precision and support cell, while the resulting surface keeps +its exact support, infinite support diameter, and two-sided growth bounds. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Topology +open scoped ENNReal + +theorem exists_original_AD_matched_surface_models {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (μ : Measure (Ambient d)) [μ.Regular] (hAD : ADRegular n μ) : + ∃ Ktop : ℝ≥0∞, Ktop < ⊤ ∧ ∃ K : ℝ, 1 ≤ K ∧ + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 72057594037927936 → activeProjectionError d ε ≤ 1 / 4096 → + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + ∃ (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell Good i → bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR k z) → Ambient d, + IsActiveRegionLimitModel μ R hR k z Good S hS ε f ∧ + (μH[(n : ℝ)] : Measure (Ambient d)) + (Set.range f ∩ closedBall (z : Ambient d) (2 * latticeRadius R k)) ≤ + Ktop * μ (cleanSupportCell μ R hR k z) ∧ + let ν := nativeSurfaceArea n (Set.range f) + ν.Regular ∧ ν.support = Set.range f ∧ ADRegular n ν ∧ ediam ν.support = ⊤ ∧ + GlobalUpperGrowth n K ν ∧ + (∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ENNReal.ofReal (r ^ n / K) ≤ ν (ball p r)) ∧ + ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ + (281474976710656 * (ε + activeProjectionError d ε)) * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16)) := by + obtain ⟨Ktop, hKtop, C, hC, c, hc, hcfin, hmodels⟩ := + exists_actual_AD_uniform_precision_area_models hn hnd μ hAD + have hK1 : 1 ≤ nativeSurfaceADConstant n c C := by + have hCnonneg : 0 ≤ C.toReal := ENNReal.toReal_nonneg + have hinv : 0 ≤ (c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n).toReal⁻¹ := + inv_nonneg.mpr ENNReal.toReal_nonneg + dsimp only [nativeSurfaceADConstant] + linarith + refine ⟨Ktop, hKtop, nativeSurfaceADConstant n c C, hK1, ?_⟩ + intro ε hε hεfine hsmall R hR k z hcore + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + obtain ⟨S, hS, hfit, f, hmodel, hembed, htop, hupper, hlower⟩ := + hmodels ε hε (by linarith) (by linarith) R hR k z hcore + obtain ⟨hreg, hs, hADν, hdiam, _, hg, hl, hplanes⟩ := + active_region_native_surface_geometry hn μ R hR k z Good S hS ε hε hεfine hsmall hfit + f hmodel hembed c C hc hcfin hC hlower hupper + exact ⟨S, hS, hfit, f, hmodel, htop, hreg, hs, hADν, hdiam, hg, hl, hplanes⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADUniformPrecisionAreaModels.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADUniformPrecisionAreaModels.lean new file mode 100644 index 0000000000000000000000000000000000000000..66bcb7ed63b473a64949bf68bad3ad6dba6fc24a --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADUniformPrecisionAreaModels.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.OriginalADActiveRegionAllRadiusAreaModel + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Topology +open scoped ENNReal + +theorem exists_actual_AD_uniform_precision_area_models {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (μ : Measure (Ambient d)) [μ.Regular] (hAD : ADRegular n μ) : + ∃ Ktop : ℝ≥0∞, Ktop < ⊤ ∧ ∃ Kupper : ℝ≥0∞, Kupper < ⊤ ∧ + ∃ Klower : ℝ≥0∞, 0 < Klower ∧ Klower < ⊤ ∧ + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 281474976710656 → activeProjectionError d ε ≤ 1 / 128 → + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + ∃ (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell Good i → bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR k z) → Ambient d, + IsActiveRegionLimitModel μ R hR k z Good S hS ε f ∧ IsClosedEmbedding f ∧ + (μH[(n : ℝ)] : Measure (Ambient d)) + (Set.range f ∩ closedBall (z : Ambient d) (2 * latticeRadius R k)) ≤ + Ktop * μ (cleanSupportCell μ R hR k z) ∧ + (∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (Set.range f ∩ closedBall p r) ≤ + Kupper * (ENNReal.ofReal r) ^ n) ∧ + ∀ p ∈ Set.range f, ∀ (r : ℝ), 0 < r → + Klower * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (Set.range f ∩ closedBall p r) := by + by_cases hsupport : μ.support.Nontrivial + · obtain ⟨G, hg⟩ := globalGrowth_of_ADRegular_nontrivial n μ hAD hsupport + have hG : 0 < G + 1 := by linarith [hg.1] + have hg' : GlobalUpperGrowth n (G + 1) μ := hg.mono_constant (by linarith) + obtain ⟨C, hC, hballs⟩ := hAD + have hCpos : 0 < C := zero_lt_one.trans_le hC + refine ⟨activeRegionUniformAreaConstant n d C (G + 1), + activeRegionUniformAreaConstant_lt_top n d C (G + 1), + activeRegionLocalUpperAreaConstant n d C (G + 1), + activeRegionLocalUpperAreaConstant_lt_top n d C (G + 1), + activeRegionAllRadiusLowerAreaConstant n C (G + 1), + activeRegionAllRadiusLowerAreaConstant_pos n C (G + 1), + activeRegionAllRadiusLowerAreaConstant_lt_top n C (G + 1), ?_⟩ + intro ε hε hεfine hsmall R hR k z hcore + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + have hεtiny : ε ≤ 1 / 268435456 := by linarith + obtain ⟨S, hS, hfit, _⟩ := exists_active_level_projection_maps μ R hR k z hnd ε hε + obtain ⟨f, hmodel⟩ := exists_active_region_limit_model μ R hR k z Good S hS ε hε hεtiny hsmall hfit + refine ⟨S, hS, hfit, f, hmodel, + active_region_limit_isClosedEmbedding μ R hR k z Good S hS ε hε hεtiny hsmall hfit f hmodel, + active_region_limit_area_le_original_top μ C (G + 1) hCpos hG hg' + (fun x hx r hr => (hballs x hx r hr).1) R hR k hcore z Good S hS ε hε hεfine hsmall hfit f hmodel, + ?_, ?_⟩ + · intro p r hr + exact active_region_limit_local_ball_area_le μ C (G + 1) hCpos hG hg' + (fun x hx s hs => (hballs x hx s hs).1) R hR k hcore z Good S hS + ε hε hεfine hsmall hfit f hmodel p r hr + · intro p hp r hr + exact active_region_limit_all_radius_ball_area_ge hn μ C (G + 1) hCpos hG hg' + (fun x hx s hs => (hballs x hx s hs).1) R hR k hcore z Good S hS + ε hε hεfine hsmall hfit f hmodel p hp r hr + · refine ⟨0, by norm_num, 0, by norm_num, 1, by norm_num, by norm_num, ?_⟩ + intro ε hε hεfine hsmall R hR k z hcore + have hdiam : ediam μ.support = 0 := ediam_eq_zero_iff.mpr (Set.not_nontrivial_iff.mp hsupport) + have hzero : ENNReal.ofReal (latticeRadius R k / 8) = 0 := + le_antisymm (hdiam ▸ hcore.2) (zero_le) + exact ((ENNReal.ofReal_pos.mpr hcore.1).ne' hzero).elim + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADUniformSurfaceBallCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADUniformSurfaceBallCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..1efaab81f452cc894b500657a530fba643292862 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalADUniformSurfaceBallCharts.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.OriginalADMatchedSurfaceModels +import OAI.Analysis.RieszRectifiability.Surfaces.SurfaceBallTransferFoundations + +namespace OAI + +/-! +# Uniform ball charts for active-region surfaces + +Matched surface models give a precision independent of the support cell. For +each positive loss tolerance, a finite-depth ball chart covers the model up to +weighted Hausdorff area bounded by that tolerance times the original cell mass. +Its Lipschitz constant is chosen before the cell scale and center. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +theorem exists_original_AD_uniform_surface_ball_charts {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (μ : Measure (Ambient d)) [μ.Regular] (hAD : ADRegular n μ) + (G : ℝ) (hG : 0 < G) (hg : GlobalUpperGrowth n G μ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 / 281474976710656 ∧ activeProjectionError d ε ≤ 1 / 128 ∧ + ∀ δ : ℝ, 0 < δ → ∃ M : ℝ≥0, + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + ∃ (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell Good i → bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR k z) → Ambient d, + IsActiveRegionLimitModel μ R hR k z Good S hS ε f ∧ + ∃ g : ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + LipschitzWith M g ∧ Set.range g ⊆ closedBall (z : Ambient d) (3 * latticeRadius R k) ∧ + (ENNReal.ofReal G + activeRegionStopMassAreaConstant n G) * + (μH[(n : ℝ)] : Measure (Ambient d)) + ((Set.range f ∩ closedBall (z : Ambient d) (3 * latticeRadius R k)) \ Set.range g) ≤ + ENNReal.ofReal δ * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨Ktop, hKtop, K, hK, hmodels⟩ := exists_original_AD_matched_surface_models hn hnd μ hAD + have hKpos : 0 < K := zero_lt_one.trans_le hK + obtain ⟨κ, hκ, hκquarter, σ, hσ, hwidth, hpair, hshadow⟩ := exists_projection_region_thresholds n K K hKpos hKpos + obtain ⟨ε, hε, hεfine, hsmall, hprecision⟩ := exists_matched_surface_precision d σ hσ + refine ⟨ε, hε, by linarith, by linarith, ?_⟩ + intro δ hδ + obtain ⟨C, hC, hballs⟩ := hAD + have hCpos : 0 < C := zero_lt_one.trans_le hC + let W := ENNReal.ofReal G + activeRegionStopMassAreaConstant n G + have hW : W < ⊤ := by + have hstop := activeRegionStopMassAreaConstant_lt_top n G + exact ENNReal.add_lt_top.mpr ⟨ENNReal.ofReal_lt_top, hstop⟩ + have hθ := nativeCoreAreaFraction_pos_le_half n K hKpos + have hzero : 0 ≤ 1 - nativeCoreAreaFraction n K := by linarith [hθ.2] + have hone : 1 - nativeCoreAreaFraction n K < 1 := by linarith [hθ.1] + obtain ⟨J, hJ⟩ := exists_depth_for_weighted_geometric_loss + (1 - nativeCoreAreaFraction n K) hzero hone W hW (K * C * (64 : ℝ) ^ n) (by positivity) δ hδ + let M := finiteBallChartUnionConstant d (11 ^ d) (projectionRegionDepthConstant d (Real.toNNReal (2 / κ)) J) + refine ⟨M, ?_⟩ + intro R hR k z hcore + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + obtain ⟨S, hS, hfit, f, hmodel, _, hreg, hs, _, hdiam, hgν, hlν, hplanes⟩ := + hmodels ε hε hεfine hsmall R hR k z hcore + let ν := nativeSurfaceArea n (Set.range f) + have hgeometry : ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ σ * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16)) := by + intro p hp r hr + obtain ⟨P, hP, hheight, hcover⟩ := hplanes p hp r hr + exact ⟨P, hP, fun x hx => (hheight x hx).trans (mul_le_mul_of_nonneg_right hprecision hr.le), hcover⟩ + obtain ⟨g, hglip, hgrange, harea⟩ := exists_matched_surface_ball_depth_chart ν (Set.range f) rfl hs + K K hKpos hKpos hgν (fun p hp r hr => hlν p hp r hr.1) σ κ hσ hκ (by linarith) hwidth hpair hshadow + hgeometry hdiam hn J (latticeRadius R k) (latticeRadius_pos R hR k) z + have hmass := radius_eight_growth_le_original_cell_mass μ C G hCpos hG hg + (fun p hp r hr => (hballs p hp r hr).1) R hR k hcore z K hKpos.le + refine ⟨S, hS, hfit, f, hmodel, g, hglip, hgrange, ?_⟩ + calc + _ ≤ W * ((ENNReal.ofReal (1 - nativeCoreAreaFraction n K)) ^ J * + (ENNReal.ofReal (K * C * (64 : ℝ) ^ n) * μ (cleanSupportCell μ R hR k z))) := + mul_le_mul' le_rfl (harea.trans (mul_le_mul' le_rfl hmass)) + _ = (W * (ENNReal.ofReal (1 - nativeCoreAreaFraction n K)) ^ J * + ENNReal.ofReal (K * C * (64 : ℝ) ^ n)) * μ (cleanSupportCell μ R hR k z) := by ring + _ ≤ _ := mul_le_mul' hJ le_rfl + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalTopAreaCharges.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalTopAreaCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..79d731552132a417730d6f0a4e377a12a8d66f51 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/OriginalTopAreaCharges.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.ActiveLevelOriginalMass +import OAI.Analysis.RieszRectifiability.Nets.SupportCellRoot + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped ENNReal + +def enlargedTopMassConstant (n : ℕ) (C G : ℝ) : ℝ≥0∞ := + ENNReal.ofReal (G * 4 ^ n) * ENNReal.ofReal (C * 8 ^ n) + +theorem enlargedTopMassConstant_lt_top (n : ℕ) (C G : ℝ) : + enlargedTopMassConstant n C G < ⊤ := by + exact ENNReal.mul_lt_top ENNReal.ofReal_lt_top ENNReal.ofReal_lt_top + +theorem clean_top_radius_power_le_mass {n d : ℕ} + (μ : Measure (Ambient d)) (C G : ℝ) (hC : 0 < C) (hG : 0 < G) + (hg : GlobalUpperGrowth n G μ) + (hlower : ∀ x ∈ μ.support, ∀ r : ℝ, AdmissibleRadius μ r → + ENNReal.ofReal (r ^ n / C) ≤ μ (ball x r)) + (R : ℝ) (hR : 0 < R) (k : ℕ) (hcore : AdmissibleRadius μ (latticeRadius R k / 8)) + (z : (supportLatticeNets μ R hR k).points) : + (ENNReal.ofReal (latticeRadius R k)) ^ n ≤ + ENNReal.ofReal (C * 8 ^ n) * μ (cleanSupportCell μ R hR k z) := by + simpa only [SupportCellDescendant.radius, SupportCellDescendant.cell, supportCellRoot, Nat.add_zero] + using! SupportCellDescendant.radius_power_le_mass μ C G hC hG hg hlower R hR k hcore z + (supportCellRoot μ R hR k z) + +theorem enlarged_top_ball_mass_le_clean_top {n d : ℕ} + (μ : Measure (Ambient d)) (C G : ℝ) (hC : 0 < C) (hG : 0 < G) + (hg : GlobalUpperGrowth n G μ) + (hlower : ∀ x ∈ μ.support, ∀ r : ℝ, AdmissibleRadius μ r → + ENNReal.ofReal (r ^ n / C) ≤ μ (ball x r)) + (R : ℝ) (hR : 0 < R) (k : ℕ) (hcore : AdmissibleRadius μ (latticeRadius R k / 8)) + (z : (supportLatticeNets μ R hR k).points) : + μ (closedBall (z : Ambient d) (3 * latticeRadius R k)) ≤ + enlargedTopMassConstant n C G * μ (cleanSupportCell μ R hR k z) := by + have hr := latticeRadius_pos R hR k + have hupper : μ (closedBall (z : Ambient d) (3 * latticeRadius R k)) ≤ + ENNReal.ofReal (G * 4 ^ n) * (ENNReal.ofReal (latticeRadius R k)) ^ n := by + calc + _ ≤ μ (ball (z : Ambient d) (4 * latticeRadius R k)) := + measure_mono (closedBall_subset_ball (by linarith)) + _ ≤ ENNReal.ofReal (G * (4 * latticeRadius R k) ^ n) := + hg.2 (z : Ambient d) (4 * latticeRadius R k) (by positivity) + _ = _ := by + rw [mul_pow, ← mul_assoc, ENNReal.ofReal_mul (by positivity : 0 ≤ G * 4 ^ n), + ENNReal.ofReal_pow hr.le] + have hlowerTop := clean_top_radius_power_le_mass μ C G hC hG hg hlower R hR k hcore z + calc + _ ≤ ENNReal.ofReal (G * 4 ^ n) * (ENNReal.ofReal (latticeRadius R k)) ^ n := hupper + _ ≤ ENNReal.ofReal (G * 4 ^ n) * + (ENNReal.ofReal (C * 8 ^ n) * μ (cleanSupportCell μ R hR k z)) := mul_le_mul_right hlowerTop _ + _ = _ := by unfold enlargedTopMassConstant; rw [mul_assoc] + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ParentChartPlaneHeight.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ParentChartPlaneHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..be1182c04d06f4d28c9e7df75db8df3946b81354 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ParentChartPlaneHeight.lean @@ -0,0 +1,67 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Projections.NeighborProjectionEstimates + +namespace OAI + +/-! +# Transferring parent-chart height bounds + +For adjacent cell scales, neighboring-plane projection estimates transfer a height bound +relative to the parent plane to a quantitative bound relative to the child plane. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set EuclideanGeometry + +theorem parent_chart_plane_height_transfer {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (i q : SupportCellDescendant μ R hR k z) + (hscale : q.radius = 64 * i.radius) + (hnear : dist i.center q.center ≤ 2 * q.radius) + (ε : ℝ) (hε : 0 < ε) (hεsmall : ε ≤ 1 / 1024) + (S W : AffineSubspace ℝ (Ambient d)) (hS : IsAffineNPlane n S) (hW : IsAffineNPlane n W) + (hSi : bilateralPlaneError μ i.center (1024 * i.radius) S < ε) + (hWq : bilateralPlaneError μ q.center (1024 * q.radius) W < ε) + (x : Ambient d) (hx : x ∈ closedBall q.center (3 * q.radius)) + (hheight : infDist x (W : Set (Ambient d)) ≤ (262144 * ε) * q.radius) : + infDist x (S : Set (Ambient d)) ≤ (524288 * ε) * q.radius := by + let : Nonempty S := hS.1.to_subtype + let : Nonempty W := hW.1.to_subtype + have hri := i.radius_pos + have hrq := q.radius_pos + have hsmall : i.radius ≤ q.radius := by rw [hscale]; linarith + have hlarge : q.radius ≤ 64 * i.radius := hscale.le + have hneighbor : dist i.center q.center ≤ 128 * q.radius := by linarith + have hop := neighbor_cell_projection_operator_norm_le μ R hR k z i q + hsmall hlarge hneighbor ε hε hεsmall S W hS hW hSi hWq + have hScenter := (bilateralPlaneError_lt_pointwise μ ⟨i.center, i.center_mem_support⟩ + i.center (1024 * i.radius) ε (by positivity) S hS hSi).1 i.center + (mem_ball_self (by positivity)) i.center_mem_support + have hWcenter := (bilateralPlaneError_lt_pointwise μ ⟨i.center, i.center_mem_support⟩ + q.center (1024 * q.radius) ε (by positivity) W hW hWq).1 i.center + (by change dist i.center q.center < 1024 * q.radius; linarith) i.center_mem_support + have hdx : dist x i.center ≤ 5 * q.radius := by + have ht := dist_triangle x q.center i.center + rw [dist_comm q.center i.center] at ht + have hx' : dist x q.center ≤ 3 * q.radius := hx + linarith + have hpair := affine_projection_pair_dist_bound S W i.center x (2048 * ε) hop + have hm := mul_le_mul_of_nonneg_left hdx (show 0 ≤ 2048 * ε by positivity) + have ht := dist_triangle (orthogonalProjection S x : Ambient d) + (orthogonalProjection W x : Ambient d) x + rw [dist_comm (orthogonalProjection S x : Ambient d) x, + dist_orthogonalProjection_eq_infDist S x, + dist_comm (orthogonalProjection W x : Ambient d) x, + dist_orthogonalProjection_eq_infDist W x] at ht + have hscaleError := mul_le_mul_of_nonneg_left hsmall hε.le + nlinarith [mul_pos hε hrq] + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/ParentToChildInputChart.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ParentToChildInputChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d9ee58eb247e4add19233acf95eb10bfc70fd1b --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/ParentToChildInputChart.lean @@ -0,0 +1,152 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.RecenteredDiskCharts +import OAI.Analysis.RieszRectifiability.Projections.ProjectionTubeLocation +import OAI.Analysis.RieszRectifiability.Surfaces.ParentChartPlaneHeight +import OAI.Analysis.RieszRectifiability.Surfaces.PlaneChangeCharts + +namespace OAI + +/-! +# Parent-to-child input charts + +A parent chart is reparametrized over the nearby child plane and restricted to the child +disk. Projection and height estimates preserve the exact restricted range, the Lipschitz +and normal-component bounds, and containment in the physical child ball. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal + +theorem exists_parent_to_child_input_chart {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (i q : SupportCellDescendant μ R hR k z) + (hscale : q.radius = 64 * i.radius) + (hnear : dist i.center q.center ≤ 2 * q.radius) + (ε : ℝ) (hε : 0 < ε) (hεtiny : ε ≤ 1 / 268435456) + (S W : AffineSubspace ℝ (Ambient d)) (hS : IsAffineNPlane n S) (hW : IsAffineNPlane n W) + (hSi : bilateralPlaneError μ i.center (1024 * i.radius) S < ε) + (hWq : bilateralPlaneError μ q.center (1024 * q.radius) W < ε) + (g : closedBall (W.direction.orthogonalProjectionOnto q.center) ((5 / 2 : ℝ) * q.radius) → Ambient d) + (L : ℝ≥0) (hsmall : (L : ℝ) + 2048 * ε ≤ 1 / 8) + (hcoordinates : ∀ u, W.direction.orthogonalProjectionOnto (g u) = u.val) + (hnormal : LipschitzWith L + (fun u => (W.directionᗮ : Submodule ℝ (Ambient d)).starProjection (g u))) + (hheight : ∀ u, infDist (g u) (W : Set (Ambient d)) ≤ (262144 * ε) * q.radius) + (hphysical : ∀ u, g u ∈ closedBall q.center (3 * q.radius)) : + ∃ h : closedBall (S.direction.orthogonalProjectionOnto i.center) ((11 / 4 : ℝ) * i.radius) → Ambient d, + LipschitzWith 2 h ∧ + LipschitzWith (2 * (L + Real.toNNReal (2048 * ε))) + (fun u => (S.directionᗮ : Submodule ℝ (Ambient d)).starProjection (h u)) ∧ + (∀ u, h u ∈ Set.range g ∧ S.direction.orthogonalProjectionOnto (h u) = u.val ∧ + h u ∈ closedBall i.center (3 * i.radius)) ∧ + Set.range h = Set.range g ∩ S.direction.orthogonalProjectionOnto ⁻¹' + closedBall (S.direction.orthogonalProjectionOnto i.center) ((11 / 4 : ℝ) * i.radius) := by + let P := W.direction + let Q := S.direction + let a := P.orthogonalProjectionOnto q.center + let ac := Q.orthogonalProjectionOnto i.center + let ρ := (5 / 2 : ℝ) * q.radius + have hri := i.radius_pos + have hrq := q.radius_pos + have hρ : 0 < ρ := by dsimp [ρ]; positivity + let u0 : closedBall a ρ := ⟨a, mem_closedBall_self hρ.le⟩ + let b := Q.orthogonalProjectionOnto (g u0) + let α : ℝ≥0 := ⟨2048 * ε, by positivity⟩ + have hα : α = Real.toNNReal (2048 * ε) := by + apply Subtype.ext + exact (Real.coe_toNNReal _ (by positivity : 0 ≤ 2048 * ε)).symm + have hεsmall : ε ≤ 1 / 1024 := by linarith + have hop := neighbor_cell_projection_operator_norm_le μ R hR k z i q + (by rw [hscale]; linarith) hscale.le (by linarith) + ε hε hεsmall S W hS hW hSi hWq + have hop' : ‖P.starProjection - Q.starProjection‖ ≤ (α : ℝ) := by + rw [norm_sub_rev] + exact hop + have hsmall' : (L : ℝ) + (α : ℝ) ≤ 1 / 4 := by + change (L : ℝ) + 2048 * ε ≤ 1 / 4 + linarith + have hcq := (bilateralPlaneError_lt_pointwise μ ⟨q.center, q.center_mem_support⟩ + q.center (1024 * q.radius) ε (by positivity) W hW hWq).1 q.center + (mem_ball_self (by positivity)) q.center_mem_support + have hci := (bilateralPlaneError_lt_pointwise μ ⟨i.center, i.center_mem_support⟩ + i.center (1024 * i.radius) ε (by positivity) S hS hSi).1 i.center + (mem_ball_self (by positivity)) i.center_mem_support + have hx0 : dist (g u0) q.center ≤ (263168 * ε) * q.radius := by + have h := dist_le_projection_add_plane_distances W hW.1 (g u0) q.center + have hc : P.starProjection (g u0) = P.starProjection q.center := + congrArg (fun v : P => (v : Ambient d)) (hcoordinates u0) + change dist (g u0) q.center ≤ dist (P.starProjection (g u0)) (P.starProjection q.center) + + infDist (g u0) (W : Set (Ambient d)) + infDist q.center (W : Set (Ambient d)) at h + rw [hc, dist_self, zero_add] at h + nlinarith [hheight u0] + have hx0small : dist (g u0) q.center ≤ q.radius / 16 := by + have hm := mul_le_mul_of_nonneg_right hεtiny hrq.le + nlinarith + have hb : dist ac b ≤ 2 * q.radius + q.radius / 16 := by + have hp := Q.norm_starProjection_apply_le (i.center - g u0) + rw [map_sub, ← dist_eq_norm, ← dist_eq_norm] at hp + have ht := dist_triangle i.center q.center (g u0) + rw [dist_comm q.center (g u0)] at ht + change dist (Q.starProjection i.center) (Q.starProjection (g u0)) ≤ _ + linarith + obtain ⟨hradius, j, hjLip, hjNormal, hjCoords, hjRange⟩ := + exists_chart_over_nearby_plane P Q a ρ hρ g L α hsmall' hcoordinates hnormal hop' + have hcontain : dist ac b + (11 / 4 : ℝ) * i.radius ≤ + ρ - ((L : ℝ) + (α : ℝ)) * ρ := by + have hm := mul_le_mul_of_nonneg_right hsmall hrq.le + change dist ac b + (11 / 4 : ℝ) * i.radius ≤ + (5 / 2 : ℝ) * q.radius - ((L : ℝ) + 2048 * ε) * ((5 / 2 : ℝ) * q.radius) + nlinarith + obtain ⟨h, hhLip, hhNormal, hhCoords, hhRange⟩ := + exists_recentered_disk_chart Q b (ρ - ((L : ℝ) + (α : ℝ)) * ρ) j (2 * (L + α)) + (fun u => (hjCoords u).2) hjNormal ac ((11 / 4 : ℝ) * i.radius) hcontain + have hL : 1 + 2 * (L + α) ≤ (2 : ℝ≥0) := by + have hreal : ((1 + 2 * (L + α) : ℝ≥0) : ℝ) ≤ 2 := by + change 1 + 2 * ((L : ℝ) + 2048 * ε) ≤ 2 + linarith + exact_mod_cast hreal + have hrange : Set.range h = Set.range g ∩ Q.orthogonalProjectionOnto ⁻¹' + closedBall ac ((11 / 4 : ℝ) * i.radius) := by + rw [hhRange, hjRange] + ext y + constructor + · intro hy + exact ⟨hy.1.1, hy.2⟩ + · intro hy + refine ⟨⟨hy.1, ?_⟩, hy.2⟩ + have hy' : dist (Q.orthogonalProjectionOnto y) ac ≤ (11 / 4 : ℝ) * i.radius := hy.2 + have ht := dist_triangle (Q.orthogonalProjectionOnto y) ac b + change dist (Q.orthogonalProjectionOnto y) b ≤ ρ - ((L : ℝ) + (α : ℝ)) * ρ + linarith + have hhg : ∀ u, h u ∈ Set.range g := by + intro u + exact (hrange ▸ (show h u ∈ Set.range h from ⟨u, rfl⟩)).1 + have hhheight : ∀ u, infDist (h u) (S : Set (Ambient d)) ≤ (524288 * ε) * q.radius := by + intro u + obtain ⟨v, hv⟩ := hhg u + rw [← hv] + exact parent_chart_plane_height_transfer μ R hR k z i q hscale hnear ε hε hεsmall + S W hS hW hSi hWq (g v) (hphysical v) (hheight v) + have hhphysical : ∀ u, h u ∈ closedBall i.center (3 * i.radius) := by + intro u + have hloc := plane_chart_location_of_height S hS.1 i.center ((11 / 4 : ℝ) * i.radius) + ((524288 * ε) * q.radius) h (fun v => (hhCoords v).2) hhheight u + have hm := mul_le_mul_of_nonneg_right hεtiny hri.le + rw [hscale] at hloc + change dist (h u) i.center ≤ 3 * i.radius + nlinarith + refine ⟨h, hhLip.weaken hL, ?_, ?_, hrange⟩ + · rwa [← hα] + · intro u + exact ⟨hhg u, (hhCoords u).2, hhphysical u⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/PerturbedBallCoverage.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PerturbedBallCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ad9aca7632316646aaaff134bc71dc4ed9d689e --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PerturbedBallCoverage.lean @@ -0,0 +1,67 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +/-! +# Ball coverage by a Lipschitz perturbation + +A map with bounded displacement whose error from the identity is a strict +contraction covers a smaller concentric closed ball. A fixed point of the +associated correction map provides the preimage of each target point. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem closedBall_covered_by_lipschitz_perturbation {X : Type*} + [NormedAddCommGroup X] [CompleteSpace X] + (a : X) (r δ : ℝ) (hr : 0 ≤ r) (K : ℝ≥0) (hK : K < 1) + (f : closedBall a r → X) + (hdisp : ∀ x, dist (f x) x.val ≤ δ) + (herr : LipschitzWith K (fun x : closedBall a r => f x - x.val)) : + closedBall a (r - δ) ⊆ Set.range f := by + intro z hz + have hz' : ‖z - a‖ ≤ r - δ := by simpa only [mem_closedBall, dist_eq_norm] using! hz + have hmaps (x : closedBall a r) : z - (f x - x.val) ∈ closedBall a r := by + change dist (z - (f x - x.val)) a ≤ r + calc + _ = ‖(z - a) - (f x - x.val)‖ := by + rw [dist_eq_norm] + congr 1 + abel + _ ≤ ‖z - a‖ + ‖f x - x.val‖ := norm_sub_le _ _ + _ ≤ (r - δ) + δ := add_le_add hz' (by simpa only [dist_eq_norm] using! hdisp x) + _ = r := by ring + let T : closedBall a r → closedBall a r := + fun x => ⟨z - (f x - x.val), hmaps x⟩ + have hLip : LipschitzWith K T := by + apply LipschitzWith.of_dist_le_mul + intro x y + change dist (z - (f x - x.val)) (z - (f y - y.val)) ≤ K * dist x y + have heq : (z - (f x - x.val)) - (z - (f y - y.val)) = + -((f x - x.val) - (f y - y.val)) := by abel + rw [dist_eq_norm, heq, norm_neg] + simpa only [dist_eq_norm] using! herr.dist_le_mul x y + let : CompleteSpace (closedBall a r) := + (show IsClosed (closedBall a r) from isClosed_closedBall).isComplete.completeSpace_coe + have hT : ContractingWith K T := ⟨hK, hLip⟩ + obtain ⟨u, hu, _, _⟩ := hT.exists_fixedPoint ⟨a, mem_closedBall_self hr⟩ (edist_ne_top _ _) + have heq := congrArg (fun x : closedBall a r => x.val) hu + change z - (f u - u.val) = u.val at heq + refine ⟨u, ?_⟩ + calc + f u = (f u - u.val) + u.val := (sub_add_cancel _ _).symm + _ = (f u - u.val) + (z - (f u - u.val)) := + congrArg (fun w => (f u - u.val) + w) heq.symm + _ = z := by abel + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneChangeCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneChangeCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e39540c55c9f7f99193be8c142d3a225918e615 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneChangeCharts.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Projections.CoveredProjectionCharts +import OAI.Analysis.RieszRectifiability.Flatness.PlaneChangeCoverage +import OAI.Analysis.RieszRectifiability.Projections.ProjectionConeTransfer + +namespace OAI + +/-! +# Reparameterizing a chart over a nearby plane + +Small normal slope and a small change of projection leave a positive disk +covered in the new plane. The projection inverse defines a chart on this disk, +with quantitative Lipschitz bounds for the chart and its normal component. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem exists_chart_over_nearby_plane {d : ℕ} + (P Q : Submodule ℝ (Ambient d)) (a : P) (ρ : ℝ) (hρ : 0 < ρ) + (g : closedBall a ρ → Ambient d) (L α : ℝ≥0) + (hsmall : (L : ℝ) + (α : ℝ) ≤ 1 / 4) + (hcoordinates : ∀ v, P.orthogonalProjectionOnto (g v) = v.val) + (hnormal : LipschitzWith L + (fun v => (Pᗮ : Submodule ℝ (Ambient d)).starProjection (g v))) + (hop : ‖P.starProjection - Q.starProjection‖ ≤ (α : ℝ)) : + let b := Q.orthogonalProjectionOnto (g ⟨a, mem_closedBall_self hρ.le⟩) + let r := ρ - ((L : ℝ) + (α : ℝ)) * ρ + let D := closedBall b r + 0 < r ∧ ∃ h : D → Ambient d, + LipschitzWith 2 h ∧ + LipschitzWith (2 * (L + α)) + (fun u => (Qᗮ : Submodule ℝ (Ambient d)).starProjection (h u)) ∧ + (∀ u, h u ∈ Set.range g ∧ Q.orthogonalProjectionOnto (h u) = u.val) ∧ + Set.range h = Set.range g ∩ Q.orthogonalProjectionOnto ⁻¹' D := by + let b := Q.orthogonalProjectionOnto (g ⟨a, mem_closedBall_self hρ.le⟩) + let r := ρ - ((L : ℝ) + (α : ℝ)) * ρ + let D := closedBall b r + have hr : 0 < r := by + have hm := mul_le_mul_of_nonneg_right hsmall hρ.le + dsimp only [r] + linarith + have hcontract : L + α < 1 := by + have h : ((L + α : ℝ≥0) : ℝ) < 1 := by + rw [NNReal.coe_add] + linarith + exact_mod_cast h + have hcover : D ⊆ Q.orthogonalProjectionOnto '' Set.range g := + graph_covers_changed_plane_disk P Q a ρ hρ.le g L α hcontract hcoordinates hnormal hop + have hstar (u : closedBall a ρ) : P.starProjection (g u) = (u.val : Ambient d) := + congrArg (fun v : P => (v : Ambient d)) (hcoordinates u) + have hcone : ∀ x ∈ Set.range g, ∀ y ∈ Set.range g, + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection (x - y)‖ ≤ + (L : ℝ) * dist (P.starProjection x) (P.starProjection y) := by + rintro x ⟨u, rfl⟩ y ⟨v, rfl⟩ + have h := hnormal.dist_le_mul u v + rw [dist_eq_norm, ← map_sub] at h + rw [hstar u, hstar v] + exact h + have hconeQ : ∀ x ∈ Set.range g, ∀ y ∈ Set.range g, + ‖(Qᗮ : Submodule ℝ (Ambient d)).starProjection (x - y)‖ ≤ + ((2 * (L + α) : ℝ≥0) : ℝ) * dist (Q.starProjection x) (Q.starProjection y) := by + intro x hx y hy + simpa only [NNReal.coe_mul, NNReal.coe_ofNat, NNReal.coe_add] using! + projection_cone_transfer P Q (Set.range g) L α (hsmall.trans (by norm_num)) hop hcone x hx y hy + obtain ⟨h, hLip, hnLip, hcoords, hrange⟩ := + exists_chart_on_covered_projection Q (Set.range g) (2 * (L + α)) D hcover hconeQ + have hL : 1 + 2 * (L + α) ≤ (2 : ℝ≥0) := by + have hh : ((1 + 2 * (L + α) : ℝ≥0) : ℝ) ≤ 2 := by + rw [NNReal.coe_add, NNReal.coe_one, NNReal.coe_mul, NNReal.coe_ofNat, NNReal.coe_add] + linarith + exact_mod_cast hh + exact ⟨hr, h, hLip.weaken hL, hnLip, hcoords, hrange⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneChartBallArea.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneChartBallArea.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6ec748ead87ead4fb1cfc454d80a6d292ef8b66 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneChartBallArea.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Flatness.PlaneDiskHausdorffMeasure + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +def planeChartBallAreaConstant (n : ℕ) (K L : ℝ≥0) : ℝ≥0∞ := + ((2 : ℝ≥0∞) * (K : ℝ≥0∞) * (L : ℝ≥0∞)) ^ n * planeUnitHausdorffMeasure n + +theorem planeChartBallAreaConstant_lt_top (n : ℕ) (K L : ℝ≥0) : + planeChartBallAreaConstant n K L < ⊤ := by + exact ENNReal.mul_lt_top (by finiteness) (planeUnitHausdorffMeasure_lt_top n) + +theorem plane_chart_ball_hausdorffMeasure_le {n d e : ℕ} + (P : Submodule ℝ (Ambient d)) (hdim : Module.finrank ℝ P = n) + (C : Set P) (g : C → Ambient e) (K L : ℝ≥0) (hL : 0 < L) + (hg : LipschitzWith K g) (hsep : AntilipschitzWith L g) + (p : Ambient e) (r : ℝ) (hr : 0 < r) : + (μH[(n : ℝ)] : Measure (Ambient e)) (Set.range g ∩ closedBall p r) ≤ + planeChartBallAreaConstant n K L * (ENNReal.ofReal r) ^ n := by + classical + by_cases hempty : Set.range g ∩ closedBall p r = ∅ + · rw [hempty, measure_empty] + exact zero_le + obtain ⟨y, hy⟩ := Set.nonempty_iff_ne_empty.mpr hempty + obtain ⟨a, ha⟩ := hy.1 + let T := g ⁻¹' closedBall p r + have hdomain : (Subtype.val : C → P) '' T ⊆ closedBall a.val (2 * (L : ℝ) * r) := by + rintro _ ⟨x, hx, rfl⟩ + have hxball : dist (g x) p ≤ r := hx + have hyball : dist (g a) p ≤ r := by rw [ha]; exact hy.2 + have ht := dist_triangle_right (g x) (g a) p + have hpair : dist (g x) (g a) ≤ 2 * r := by linarith + have h := (hsep.le_mul_dist x a).trans (mul_le_mul_of_nonneg_left hpair L.coe_nonneg) + change dist x.val a.val ≤ 2 * (L : ℝ) * r + change dist x.val a.val ≤ (L : ℝ) * (2 * r) at h + linarith + have hrad : 0 < 2 * (L : ℝ) * r := by + have hLreal : 0 < (L : ℝ) := hL + positivity + have hdom : (μH[(n : ℝ)] : Measure C) T ≤ + (ENNReal.ofReal (2 * (L : ℝ) * r)) ^ n * planeUnitHausdorffMeasure n := by + have hiso := (isometry_subtype_coe (s := C)).hausdorffMeasure_image + (Or.inl (show 0 ≤ (n : ℝ) by positivity)) T + rw [← hiso] + exact (measure_mono hdomain).trans_eq (plane_closedBall_hausdorffMeasure P hdim a.val _ hrad) + have himage : g '' T = Set.range g ∩ closedBall p r := by + ext x + constructor + · rintro ⟨u, hu, rfl⟩ + exact ⟨⟨u, rfl⟩, hu⟩ + · rintro ⟨⟨u, rfl⟩, hu⟩ + exact ⟨u, hu, rfl⟩ + have harea := hg.hausdorffMeasure_image_le (show 0 ≤ (n : ℝ) by positivity) T + rw [himage, ENNReal.rpow_natCast] at harea + calc + _ ≤ (K : ℝ≥0∞) ^ n * (μH[(n : ℝ)] : Measure C) T := harea + _ ≤ (K : ℝ≥0∞) ^ n * + ((ENNReal.ofReal (2 * (L : ℝ) * r)) ^ n * planeUnitHausdorffMeasure n) := + mul_le_mul_right hdom _ + _ = planeChartBallAreaConstant n K L * (ENNReal.ofReal r) ^ n := by + rw [ENNReal.ofReal_mul (by positivity : 0 ≤ 2 * (L : ℝ)), + ENNReal.ofReal_mul (by norm_num : (0 : ℝ) ≤ 2), + ENNReal.ofReal_ofNat, ENNReal.ofReal_coe_nnreal] + unfold planeChartBallAreaConstant + simp only [mul_pow] + ring + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneDiskLowerArea.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneDiskLowerArea.lean new file mode 100644 index 0000000000000000000000000000000000000000..454af9dffd01dcc7f03bec9b1122615a8f6223d7 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/PlaneDiskLowerArea.lean @@ -0,0 +1,54 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Flatness.PlaneDiskHausdorffMeasure + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +theorem planeUnitHausdorffMeasure_pos (n : ℕ) : + 0 < planeUnitHausdorffMeasure n := by + have h := measure_closedBall_pos + (μH[(Module.finrank ℝ (Ambient n) : ℝ)] : Measure (Ambient n)) + (0 : Ambient n) (by norm_num : (0 : ℝ) < 1) + simpa only [finrank_euclideanSpace_fin, planeUnitHausdorffMeasure] using! h + +def planeDiskLowerAreaConstant (n : ℕ) (L : ℝ≥0) : ℝ≥0∞ := + planeUnitHausdorffMeasure n / (L : ℝ≥0∞) ^ n + +theorem planeDiskLowerAreaConstant_pos (n : ℕ) (L : ℝ≥0) : + 0 < planeDiskLowerAreaConstant n L := by + exact ENNReal.div_pos (planeUnitHausdorffMeasure_pos n).ne' (by finiteness) + +theorem planeDiskLowerAreaConstant_lt_top (n : ℕ) (L : ℝ≥0) (hL : 0 < L) : + planeDiskLowerAreaConstant n L < ⊤ := by + have hL0 : (L : ℝ≥0∞) ≠ 0 := by exact_mod_cast hL.ne' + exact ENNReal.div_lt_top (planeUnitHausdorffMeasure_lt_top n).ne + (pow_ne_zero n hL0) + +theorem plane_disk_antilipschitz_range_hausdorffMeasure_ge {n d e : ℕ} + (P : Submodule ℝ (Ambient d)) (hdim : Module.finrank ℝ P = n) + (a : P) (r : ℝ) (hr : 0 < r) (L : ℝ≥0) (hL : 0 < L) + (g : closedBall a r → Ambient e) (hg : AntilipschitzWith L g) : + planeDiskLowerAreaConstant n L * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient e)) (Set.range g) := by + have h := hg.le_hausdorffMeasure_image (show 0 ≤ (n : ℝ) by positivity) Set.univ + simp only [Set.image_univ, ENNReal.rpow_natCast, + plane_closedBall_subtype_hausdorffMeasure P hdim a r hr] at h + have hL0 : (L : ℝ≥0∞) ^ n ≠ 0 := pow_ne_zero n (by exact_mod_cast hL.ne') + have hLt : (L : ℝ≥0∞) ^ n ≠ ⊤ := by finiteness + have hdiv := (ENNReal.div_le_iff' hL0 hLt).mpr h + convert! hdiv using 1 + unfold planeDiskLowerAreaConstant + simp only [div_eq_mul_inv] + ring + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/QuantitativeConvexChartContraction.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/QuantitativeConvexChartContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..34c527c5000fb1164d4092572333627c91f0f76f --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/QuantitativeConvexChartContraction.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.ConvexChartContraction + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set Topology +open scoped NNReal + +theorem exists_bounded_contraction_in_bilipschitz_convex_chart {E V : Type*} + [NormedAddCommGroup E] [NormedSpace ℝ E] [MetricSpace V] + (C : Set E) (hC : Convex ℝ C) (H : C → V) (K L : ℝ≥0) + (hLip : LipschitzWith K H) (hsep : AntilipschitzWith L H) + (A : Set V) (hA : A ⊆ Set.range H) (p : V) (hp : p ∈ A) + (r : ℝ) (hball : A ⊆ closedBall p r) : + ∃ F : unitInterval × A → V, Continuous F ∧ + (∀ x, F (0, x) = x.val) ∧ (∀ x, F (1, x) = p) ∧ + (∀ s, F (s, ⟨p, hp⟩) = p) ∧ + (∀ w, F w ∈ Set.range H ∩ closedBall p ((K : ℝ) * (L : ℝ) * r)) := by + classical + have hH : IsEmbedding H := hsep.isEmbedding hLip.continuous + have hpre : ∀ x : A, ∃ u : C, H u = x.val := fun x => hA x.property + choose j hj using hpre + have hjcont : Continuous j := hH.continuous_iff.mpr (by + have hid : H ∘ j = (Subtype.val : A → V) := funext hj + rw [hid] + exact continuous_subtype_val) + let u0 : C := j ⟨p, hp⟩ + have hH0 : H u0 = p := hj ⟨p, hp⟩ + let T : unitInterval × A → C := fun w => + ⟨(1 - (w.1 : ℝ)) • (j w.2 : E) + (w.1 : ℝ) • (u0 : E), + hC (j w.2).property u0.property (sub_nonneg.mpr w.1.property.2) + w.1.property.1 (by ring)⟩ + have hs : Continuous (fun w : unitInterval × A => (w.1 : ℝ)) := + continuous_subtype_val.comp continuous_fst + have hjv : Continuous (fun w : unitInterval × A => (j w.2 : E)) := + continuous_subtype_val.comp (hjcont.comp continuous_snd) + have hT : Continuous T := + (((continuous_const.sub hs).smul hjv).add (hs.smul continuous_const)).subtype_mk _ + let F := H ∘ T + refine ⟨F, hLip.continuous.comp hT, ?_, ?_, ?_, ?_⟩ + · intro x + have ht : T (0, x) = j x := by apply Subtype.ext; simp [T] + change H (T (0, x)) = x.val + rw [ht] + exact hj x + · intro x + have ht : T (1, x) = u0 := by apply Subtype.ext; simp [T] + change H (T (1, x)) = p + rw [ht] + exact hH0 + · intro s + have ht : T (s, ⟨p, hp⟩) = u0 := by + apply Subtype.ext + change (1 - (s : ℝ)) • (u0 : E) + (s : ℝ) • (u0 : E) = (u0 : E) + rw [← add_smul] + simp + change H (T (s, ⟨p, hp⟩)) = p + rw [ht] + exact hH0 + · intro w + refine ⟨⟨T w, rfl⟩, ?_⟩ + have hseg : dist (T w) u0 ≤ dist (j w.2) u0 := by + calc + dist (T w) u0 = (1 - (w.1 : ℝ)) * dist (j w.2) u0 := by + simp only [Subtype.dist_eq, dist_eq_norm] + change ‖((1 - (w.1 : ℝ)) • (j w.2 : E) + (w.1 : ℝ) • (u0 : E)) - (u0 : E)‖ = + (1 - (w.1 : ℝ)) * ‖(j w.2 : E) - (u0 : E)‖ + rw [show ((1 - (w.1 : ℝ)) • (j w.2 : E) + (w.1 : ℝ) • (u0 : E)) - (u0 : E) = + (1 - (w.1 : ℝ)) • ((j w.2 : E) - (u0 : E)) by module] + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (sub_nonneg.mpr w.1.property.2)] + _ ≤ dist (j w.2) u0 := mul_le_of_le_one_left dist_nonneg (by linarith [w.1.property.1]) + have hjdist : dist (j w.2) u0 ≤ (L : ℝ) * r := by + have h := hsep.le_mul_dist (j w.2) u0 + rw [hj w.2, hH0] at h + exact h.trans (mul_le_mul_of_nonneg_left (hball w.2.property) L.coe_nonneg) + change dist (H (T w)) p ≤ (K : ℝ) * (L : ℝ) * r + rw [← hH0] + calc + dist (H (T w)) (H u0) ≤ (K : ℝ) * dist (T w) u0 := hLip.dist_le_mul _ _ + _ ≤ (K : ℝ) * ((L : ℝ) * r) := + mul_le_mul_of_nonneg_left (hseg.trans hjdist) K.coe_nonneg + _ = (K : ℝ) * (L : ℝ) * r := by ring + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/RecenteredDiskCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RecenteredDiskCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..3066531605b6c4d8513e3508782806e507c58f6c --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RecenteredDiskCharts.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Projections.CoveredProjectionCharts + +namespace OAI + +/-! +# Recentering disk charts + +A chart whose projection is the identity restricts to any closed disk contained in +its parameter disk. The recentered chart preserves the normal Lipschitz bound and +parametrizes exactly the part of the original range over the smaller disk. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem exists_recentered_disk_chart {d : ℕ} + (P : Submodule ℝ (Ambient d)) (a : P) (ρ : ℝ) + (g : closedBall a ρ → Ambient d) (L : ℝ≥0) + (hcoordinates : ∀ v, P.orthogonalProjectionOnto (g v) = v.val) + (hnormal : LipschitzWith L + (fun v => (Pᗮ : Submodule ℝ (Ambient d)).starProjection (g v))) + (b : P) (r : ℝ) (hcontain : dist b a + r ≤ ρ) : + ∃ h : closedBall b r → Ambient d, + LipschitzWith (1 + L) h ∧ + LipschitzWith L (fun u => (Pᗮ : Submodule ℝ (Ambient d)).starProjection (h u)) ∧ + (∀ u, h u ∈ Set.range g ∧ P.orthogonalProjectionOnto (h u) = u.val) ∧ + Set.range h = Set.range g ∩ P.orthogonalProjectionOnto ⁻¹' closedBall b r := by + have hcover : closedBall b r ⊆ P.orthogonalProjectionOnto '' Set.range g := by + intro v hv + have hnear : v ∈ closedBall a ρ := by + have ht := dist_triangle v b a + have hv' : dist v b ≤ r := hv + change dist v a ≤ ρ + linarith + let u : closedBall a ρ := ⟨v, hnear⟩ + exact ⟨g u, ⟨u, rfl⟩, hcoordinates u⟩ + have hstar (u : closedBall a ρ) : P.starProjection (g u) = (u.val : Ambient d) := + congrArg (fun v : P => (v : Ambient d)) (hcoordinates u) + have hcone : ∀ x ∈ Set.range g, ∀ y ∈ Set.range g, + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection (x - y)‖ ≤ + (L : ℝ) * dist (P.starProjection x) (P.starProjection y) := by + rintro x ⟨u, rfl⟩ y ⟨v, rfl⟩ + have h := hnormal.dist_le_mul u v + rw [dist_eq_norm, ← map_sub] at h + rw [hstar u, hstar v] + exact h + exact exists_chart_on_covered_projection P (Set.range g) L (closedBall b r) hcover hcone + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/RegionRepresentativeCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RegionRepresentativeCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2cb6f634c02458b1bc7fc2a42c8b6d4522c3e62 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RegionRepresentativeCharts.lean @@ -0,0 +1,88 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.RegionRepresentativeGeometry + +namespace OAI + +/-! +# Lipschitz charts for region representatives + +Good cells at the scale of each pair provide affine-plane tube and angle bounds. +These bounds make projection onto the reference plane separate region representatives +with inverse Lipschitz constant two. A Lipschitz extension then covers the representatives +by the image of a ball in the Euclidean space of the plane's dimension. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal + +theorem projection_separates_region_representatives {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (Good : SupportCellDescendant μ R hR k z → Prop) + (hroot : ∀ i : SupportCellDescendant μ R hR k z, i.depth = 0 → Good i) + (P : Submodule ℝ (Ambient d)) + (hfit : ∀ i : SupportCellDescendant μ R hR k z, Good i → + ∃ S : AffineSubspace ℝ (Ambient d), IsAffineNPlane n S ∧ + (∀ w ∈ ball i.center (1024 * i.radius), w ∈ μ.support → + infDist w (S : Set (Ambient d)) ≤ i.radius / 16384) ∧ + ∀ v ∈ S.direction, + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection v‖ ≤ (1 / 4 : ℝ) * ‖v‖) : + ∀ x ∈ cellRegionRepresentatives μ R hR k z Good, + ∀ y ∈ cellRegionRepresentatives μ R hR k z Good, + dist x y ≤ 2 * dist (P.starProjection x) (P.starProjection y) := by + intro x hx y hy + by_cases hxy : x = y + · simp only [hxy, dist_self, mul_zero, le_refl] + obtain ⟨q, hgood, _, hupper, _, hxball, hyball⟩ := + exists_good_pair_cell_for_representatives μ R hR k z Good hroot x y hx hy hxy + obtain ⟨S, hS, htube, hangle⟩ := hfit q hgood + let : Nonempty S := hS.1.to_subtype + have hxμ := supportLatticeCell_subset_support μ R hR k z + (cellRegionRepresentatives_subset_top μ R hR k z Good hx).1 + have hyμ := supportLatticeCell_subset_support μ R hR k z + (cellRegionRepresentatives_subset_top μ R hR k z Good hy).1 + have hxS : infDist x (S : Set (Ambient d)) ≤ (1 / 32 : ℝ) * dist x y := by + have h := htube x hxball hxμ + linarith + have hyS : infDist y (S : Set (Ambient d)) ≤ (1 / 32 : ℝ) * dist x y := by + have h := htube y hyball hyμ + linarith + exact projection_separates_of_pairwise_plane P S x y (1 / 32) (1 / 4) + (by norm_num) (by norm_num) hxS hyS hangle + +theorem exists_ball_lipschitz_cover_of_region_representatives {n d : ℕ} + (μ : Measure (Ambient d)) (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points) + (Good : SupportCellDescendant μ R hR k z → Prop) + (hroot : ∀ i : SupportCellDescendant μ R hR k z, i.depth = 0 → Good i) + (P : Submodule ℝ (Ambient d)) (hdim : Module.finrank ℝ P = n) + (hfit : ∀ i : SupportCellDescendant μ R hR k z, Good i → + ∃ S : AffineSubspace ℝ (Ambient d), IsAffineNPlane n S ∧ + (∀ w ∈ ball i.center (1024 * i.radius), w ∈ μ.support → + infDist w (S : Set (Ambient d)) ≤ i.radius / 16384) ∧ + ∀ v ∈ S.direction, + ‖(Pᗮ : Submodule ℝ (Ambient d)).starProjection v‖ ≤ (1 / 4 : ℝ) * ‖v‖) : + ∃ g : (ball (0 : Ambient n) (3 * latticeRadius R k)) → Ambient d, + LipschitzWith (lipschitzExtensionConstant (Ambient d) * 2) g ∧ + cellRegionRepresentatives μ R hR k z Good ⊆ range g := by + have hball : cellRegionRepresentatives μ R hR k z Good ⊆ + ball (z : Ambient d) (3 * latticeRadius R k) := by + intro x hx + have hb := (supportLatticeCell_bounds μ R hR k z).2 + (cellRegionRepresentatives_subset_top μ R hR k z Good hx).1 + change dist x (z : Ambient d) ≤ 2 * latticeRadius R k at hb + rw [mem_ball] + have hr := latticeRadius_pos R hR k + linarith + exact exists_ball_lipschitz_cover_of_projection _ _ _ hball P hdim 2 + (projection_separates_region_representatives μ R hR k z Good hroot P hfit) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/RescaledBallCharts.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RescaledBallCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee9240b17a3254615681d6e345b9b0f05710467b --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RescaledBallCharts.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.MeasureBounds + +namespace OAI + +/-! +A Lipschitz chart on a centered ball can be translated and rescaled without changing its image. +Rescaling the parameter ball by the inverse factor multiplies the Lipschitz bound by that factor. +-/ + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem exists_rescaled_ball_chart {n d : ℕ} + (r : ℝ) (a : Ambient n) (s : ℝ≥0) (hs : 0 < s) + (f : ball (0 : Ambient n) r → Ambient d) (M : ℝ≥0) (hf : LipschitzWith M f) : + ∃ g : Ambient n → Ambient d, + LipschitzOnWith (M * s) g (ball a (r / (s : ℝ))) ∧ + g '' ball a (r / (s : ℝ)) = Set.range f := by + classical + have hsr : 0 < (s : ℝ) := hs + have hnorm (u : Ambient n) : ‖(s : ℝ) • (u - a)‖ = (s : ℝ) * dist u a := by + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg s.coe_nonneg, dist_eq_norm] + have hmem (u : Ambient n) (hu : u ∈ ball a (r / (s : ℝ))) : + (s : ℝ) • (u - a) ∈ ball (0 : Ambient n) r := by + rw [mem_ball_zero_iff] + rw [hnorm] + have h := (lt_div_iff₀ hsr).mp hu + simpa only [mul_comm] using! h + let T : ball a (r / (s : ℝ)) → ball (0 : Ambient n) r := + fun u => ⟨(s : ℝ) • (u.val - a), hmem u.val u.property⟩ + have hTdist (u v : ball a (r / (s : ℝ))) : + dist (T u) (T v) = (s : ℝ) * dist u v := by + change dist ((s : ℝ) • (u.val - a)) ((s : ℝ) • (v.val - a)) = + (s : ℝ) * dist u.val v.val + rw [dist_smul₀, Real.norm_eq_abs, abs_of_nonneg s.coe_nonneg] + congr 1 + simp only [dist_eq_norm] + congr 1 + abel + have hsurj : Function.Surjective T := by + intro v + let u : Ambient n := a + (s : ℝ)⁻¹ • v.val + have hu : u ∈ ball a (r / (s : ℝ)) := by + change dist (a + (s : ℝ)⁻¹ • v.val) a < r / (s : ℝ) + rw [dist_eq_norm, add_sub_cancel_left, norm_smul, Real.norm_eq_abs, + abs_of_pos (inv_pos.mpr hsr)] + have hv : ‖v.val‖ < r := mem_ball_zero_iff.mp v.property + have h := mul_lt_mul_of_pos_left hv (inv_pos.mpr hsr) + simpa only [div_eq_mul_inv, mul_comm] using! h + refine ⟨⟨u, hu⟩, ?_⟩ + apply Subtype.ext + change (s : ℝ) • ((a + (s : ℝ)⁻¹ • v.val) - a) = v.val + rw [add_sub_cancel_left, smul_smul, mul_inv_cancel₀ hsr.ne', one_smul] + let g : Ambient n → Ambient d := fun u => + if hu : u ∈ ball a (r / (s : ℝ)) then f (T ⟨u, hu⟩) else 0 + have hg (u : Ambient n) (hu : u ∈ ball a (r / (s : ℝ))) : g u = f (T ⟨u, hu⟩) := by + simp only [g, dite_eq_left hu] + refine ⟨g, ?_, ?_⟩ + · apply LipschitzOnWith.of_dist_le_mul + intro u hu v hv + rw [hg u hu, hg v hv] + have h := hf.dist_le_mul (T ⟨u, hu⟩) (T ⟨v, hv⟩) + rw [hTdist] at h + simpa only [NNReal.coe_mul, Subtype.dist_eq, mul_assoc] using! h + · apply Set.Subset.antisymm + · rintro y ⟨u, hu, rfl⟩ + exact ⟨T ⟨u, hu⟩, (hg u hu).symm⟩ + · rintro y ⟨v, rfl⟩ + obtain ⟨u, hu⟩ := hsurj v + exact ⟨u.val, u.property, (hg u.val u.property).trans (congrArg f hu)⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/RescaledChildChartGluing.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RescaledChildChartGluing.lean new file mode 100644 index 0000000000000000000000000000000000000000..573f027c3b501d0030d7004df915a1fe53f5ce8f --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RescaledChildChartGluing.lean @@ -0,0 +1,64 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Foundations.SeparatedParameterPatchGluing +import OAI.Analysis.RieszRectifiability.Surfaces.RescaledBallCharts + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open Metric Set +open scoped NNReal + +theorem exists_ball_lipschitz_cover_of_rescaled_children {n d : ℕ} {ι : Type*} + (a : ι → Ambient n) (c : ι → Ambient d) (r : ι → ℝ) + (f : ∀ i : ι, ball (0 : Ambient n) (r i) → Ambient d) + (M A L : ℝ≥0) (hA : 0 < A) + (hsep : ∀ i j : ι, i ≠ j → r i + r j ≤ (A : ℝ) * dist (a i) (a j)) + (hcenters : ∀ i j : ι, dist (c i) (c j) ≤ (L : ℝ) * dist (a i) (a j)) + (himage : ∀ i : ι, Set.range (f i) ⊆ closedBall (c i) (3 * r i)) + (hLip : ∀ i : ι, LipschitzWith M (f i)) + (ρ : ℝ) (hball : ∀ i : ι, ball (a i) (r i / (4 * (A : ℝ))) ⊆ ball (0 : Ambient n) ρ) : + ∃ F : ball (0 : Ambient n) ρ → Ambient d, + LipschitzWith (lipschitzExtensionConstant (Ambient d) * + separatedPatchGluingConstant (M * (4 * A)) A L) F ∧ + (⋃ i : ι, Set.range (f i)) ⊆ Set.range F := by + classical + have hs : 0 < 4 * A := by positivity + have hc (i : ι) := exists_rescaled_ball_chart (r i) (a i) (4 * A) hs (f i) M (hLip i) + choose g hg hrange using hc + have hrange' (i : ι) : g i '' ball (a i) (r i / (4 * (A : ℝ))) = Set.range (f i) := by + simpa only [NNReal.coe_mul, NNReal.coe_ofNat] using! hrange i + have hg' (i : ι) : LipschitzOnWith (M * (4 * A)) (g i) + (ball (a i) (r i / (4 * (A : ℝ)))) := by + simpa only [NNReal.coe_mul, NNReal.coe_ofNat] using! hg i + obtain ⟨F, hF, hcover⟩ := exists_ball_lipschitz_cover_of_separated_parameter_patches + a c r (fun i => ball (a i) (r i / (4 * (A : ℝ)))) g (M * (4 * A)) A L hA hsep hcenters + (fun _ _ hu => le_of_lt hu) + (fun i u hu => himage i (hrange' i ▸ mem_image_of_mem (g i) hu)) hg' + ρ (iUnion_subset hball) + refine ⟨F, hF, ?_⟩ + intro y hy + obtain ⟨i, hi⟩ := mem_iUnion.mp hy + exact hcover (mem_iUnion.mpr ⟨i, hrange' i ▸ hi⟩) + +theorem small_parameter_ball_subset_double_ball {n : ℕ} + (a : Ambient n) (ρ r : ℝ) (hρ : 0 < ρ) (ha : a ∈ closedBall (0 : Ambient n) ρ) + (s : ℝ≥0) (hs : 1 ≤ s) (hr : r ≤ ρ) : + ball a (r / (s : ℝ)) ⊆ ball (0 : Ambient n) (2 * ρ) := by + intro u hu + have hs' : 1 ≤ (s : ℝ) := hs + have hsp : 0 < (s : ℝ) := lt_of_lt_of_le zero_lt_one hs' + have hrad : r / (s : ℝ) ≤ ρ := (div_le_iff₀ hsp).mpr (by nlinarith) + have hnear : dist u a < r / (s : ℝ) := hu + have hac : dist a (0 : Ambient n) ≤ ρ := ha + have ht := dist_triangle u a (0 : Ambient n) + change dist u (0 : Ambient n) < 2 * ρ + linarith + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/RieszFromUniformSurfacePieces.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RieszFromUniformSurfacePieces.lean new file mode 100644 index 0000000000000000000000000000000000000000..12e0964d6c4fc671823df76e20bff83869361a90 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/RieszFromUniformSurfacePieces.lean @@ -0,0 +1,60 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.CleanCellChartTargetBridge + +namespace OAI + +/-! +# Uniform rectifiability from restart surface pieces + +`HasUniformRestartSurfacePieces` uniformly bounds the number and Lipschitz +constants of pieces covering restart models up to a prescribed weighted area +loss. Combining this data with AD regularity and the Riesz bound gives clean-cell +charts with half-mass deficit, and hence uniform rectifiability. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +def HasUniformRestartSurfacePieces {d : ℕ} (n : ℕ) + (μ : Measure (Ambient d)) (G ε : ℝ) : Prop := + ∀ δ : ℝ, 0 < δ → ∃ (N : ℕ) (P : ℝ≥0), + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta n μ i.center (1024 * i.radius) + ∃ (E : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q} → Set (Ambient d)) + (data : ∀ q : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q}, + ¬ Bad q.val → SelectedRestartSurfaceData n Bad q.val (E q) ε N P), + ∀ q hq, (ENNReal.ofReal G + activeRegionStopMassAreaConstant n G) * + (μH[(n : ℝ)] : Measure (Ambient d)) + ((Set.range (data q hq).model ∩ closedBall q.val.center (3 * q.val.radius)) \ E q) ≤ + ENNReal.ofReal δ * μ q.val.cell + +theorem uniformlyRectifiable_of_Riesz_and_uniform_restart_surface_pieces + {p d : ℕ} (hnd : p + 1 ≤ d) (μ : Measure (Ambient d)) [μ.Regular] + (hAD : ADRegular (p + 1) μ) (hRiesz : RieszL2Bounded (p + 1) μ) + (G : ℝ) (hG : 0 < G) (hg : GlobalUpperGrowth (p + 1) G μ) + (ε : ℝ) (hε : 0 < ε) (hεfine : ε ≤ 1 / 281474976710656) + (hsmall : activeProjectionError d ε ≤ 1 / 128) + (hpieces : HasUniformRestartSurfacePieces (p + 1) μ G ε) : + UniformlyRectifiable (p + 1) μ := by + obtain ⟨δ, hδ, b, _, hcharts⟩ := original_AD_Riesz_recursive_chart_from_surface_pieces + hnd μ hAD hRiesz G hG hg 1024 ε (by norm_num) hε hεfine hsmall (1 / 2) (by norm_num) + obtain ⟨N, P, hdata⟩ := hpieces δ hδ + apply uniformlyRectifiable_of_uniform_clean_cell_deficits μ hAD G hG hg + (1 / 2) (by norm_num) (by norm_num) + (badBudgetChartConstant (fun M => restartChartStepConstant d N P (restartChartStepConstant d N P M)) b) + intro R hR k z hcore + obtain ⟨E, data, hloss⟩ := hdata R hR k z hcore + obtain ⟨g, hg, _, hdeficit⟩ := hcharts N P R hR k z hcore E data hloss + exact ⟨g, hg, hdeficit⟩ + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallCellCover.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallCellCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4c9652bd91f983503664e1a31eb6fa7090f7fae --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallCellCover.lean @@ -0,0 +1,101 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.CleanSupportPartition +import OAI.Analysis.RieszRectifiability.Packing.EuclideanPackingBound + +namespace OAI + +/-! +# Finite cell centers near a surface ball + +Compactness makes the separated lattice centers near a ball finite. A Euclidean packing +estimate bounds their number uniformly in the ball center and radius. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set + +theorem surface_ball_cell_centers_finite {d : ℕ} (ν : Measure (Ambient d)) + (r : ℝ) (hr : 0 < r) (a : Ambient d) : + {z : (supportLatticeNets ν r hr 0).points | dist (z : Ambient d) a ≤ 5 * r}.Finite := by + have hf := separated_set_finite_inter_compact (supportLatticeNets ν r hr 0).points + (closedBall a (5 * r)) (latticeRadius r 0) (latticeRadius_pos r hr 0) + (supportLatticeNets ν r hr 0).separated (isCompact_closedBall _ _) + have hpre := hf.preimage (f := fun z : (supportLatticeNets ν r hr 0).points => (z : Ambient d)) + Subtype.val_injective.injOn + apply hpre.subset + intro z hz + exact ⟨z.property, hz⟩ + +def surfaceBallCellCenters {d : ℕ} (ν : Measure (Ambient d)) + (r : ℝ) (hr : 0 < r) (a : Ambient d) : Finset (supportLatticeNets ν r hr 0).points := + (surface_ball_cell_centers_finite ν r hr a).toFinset + +theorem mem_surfaceBallCellCenters {d : ℕ} (ν : Measure (Ambient d)) + (r : ℝ) (hr : 0 < r) (a : Ambient d) (z : (supportLatticeNets ν r hr 0).points) : + z ∈ surfaceBallCellCenters ν r hr a ↔ dist (z : Ambient d) a ≤ 5 * r := by + simp only [surfaceBallCellCenters, Set.Finite.mem_toFinset, mem_ofPred_eq] + +theorem surfaceBallCellCenters_card_le {d : ℕ} (ν : Measure (Ambient d)) + (r : ℝ) (hr : 0 < r) (a : Ambient d) : + (surfaceBallCellCenters ν r hr a).card ≤ 11 ^ d := by + classical + let F := surfaceBallCellCenters ν r hr a + let f : (supportLatticeNets ν r hr 0).points → Ambient d := fun z => z.val - a + have hinj : Set.InjOn f F := by + intro z hz w hw heq + apply Subtype.ext + have h := congrArg (fun v : Ambient d => v + a) heq + simpa only [f, sub_add_cancel] using! h + have hbound : ∀ x ∈ F.image f, ‖x‖ ≤ 5 * r := by + intro x hx + obtain ⟨z, hz, rfl⟩ := Finset.mem_image.mp hx + simpa only [f, ← dist_eq_norm] using! (mem_surfaceBallCellCenters ν r hr a z).mp hz + have hsep : ∀ x ∈ F.image f, ∀ y ∈ F.image f, x ≠ y → 2 * (r / 2) ≤ dist x y := by + intro x hx y hy hxy + obtain ⟨z, hz, rfl⟩ := Finset.mem_image.mp hx + obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hy + have hzw : (z : Ambient d) ≠ (w : Ambient d) := fun h => hxy (congrArg (fun v => v - a) h) + have h := (supportLatticeNets ν r hr 0).separated z.property w.property hzw + simpa only [f, dist_sub_right, latticeRadius_zero, + mul_div_cancel₀ _ (by norm_num : (2 : ℝ) ≠ 0)] using! h + have hcard := euclidean_separated_card_le (F.image f) (5 * r) (r / 2) + (by positivity) (by positivity) hbound hsep + have heq : (5 * r + r / 2) / (r / 2) = 11 := by + apply (div_eq_iff (show r / 2 ≠ 0 by positivity)).mpr + ring + rw [Finset.card_image_iff.mpr hinj, heq] at hcard + exact_mod_cast hcard + +theorem surface_ball_covered_by_selected_cells_off_exceptional {d : ℕ} + (ν : Measure (Ambient d)) (r : ℝ) (hr : 0 < r) (a : Ambient d) + (x : Ambient d) (hx : x ∈ ν.support ∩ closedBall a (3 * r)) + (hnot : x ∉ supportLatticeExceptional ν r hr) : + ∃ z ∈ surfaceBallCellCenters ν r hr a, x ∈ cleanSupportCell ν r hr 0 z := by + obtain ⟨z, hz⟩ := cleanSupportCell_cover ν r hr 0 x hx.1 hnot + refine ⟨z, (mem_surfaceBallCellCenters ν r hr a z).mpr ?_, hz⟩ + have hnear := (supportLatticeCell_bounds ν r hr 0 z).2 hz.1 + simp only [latticeRadius_zero] at hnear + have hnear' : dist (z : Ambient d) x ≤ 2 * r := by simpa only [mem_closedBall, dist_comm] using! hnear + have ha : dist x a ≤ 3 * r := hx.2 + exact (dist_triangle _ x a).trans (by linarith) + +theorem selected_surface_ball_cell_subset_seven_ball {d : ℕ} + (ν : Measure (Ambient d)) (r : ℝ) (hr : 0 < r) (a : Ambient d) + (z : (supportLatticeNets ν r hr 0).points) (hz : z ∈ surfaceBallCellCenters ν r hr a) : + cleanSupportCell ν r hr 0 z ⊆ closedBall a (7 * r) := by + intro x hx + have hnear := (supportLatticeCell_bounds ν r hr 0 z).2 hx.1 + simp only [latticeRadius_zero] at hnear + have hxz : dist x (z : Ambient d) ≤ 2 * r := hnear + have hza := (mem_surfaceBallCellCenters ν r hr a z).mp hz + change dist x a ≤ 7 * r + exact (dist_triangle x (z : Ambient d) a).trans (by linarith) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallCellMass.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallCellMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc6c875abc4c8c2eca2fce7e258daaf57ed80581 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallCellMass.lean @@ -0,0 +1,40 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.SurfaceBallCellCover + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped ENNReal + +theorem surface_ball_cell_mass_sum_le {n d : ℕ} + (ν : Measure (Ambient d)) (G : ℝ) (hg : GlobalUpperGrowth n G ν) + (r : ℝ) (hr : 0 < r) (a : Ambient d) : + (∑ z : surfaceBallCellCenters ν r hr a, ν (cleanSupportCell ν r hr 0 z.val)) ≤ + ENNReal.ofReal (G * (8 * r) ^ n) := by + let F := surfaceBallCellCenters ν r hr a + have hd : Pairwise (fun z w : F => Disjoint (cleanSupportCell ν r hr 0 z.val) + (cleanSupportCell ν r hr 0 w.val)) := by + intro z w hzw + exact cleanSupportCell_disjoint ν r hr 0 z.val w.val (fun h => hzw (Subtype.ext h)) + have hm : ∀ z : F, MeasurableSet (cleanSupportCell ν r hr 0 z.val) := + fun z => cleanSupportCell_measurable ν r hr 0 z.val + have hsum : (∑ z : F, ν (cleanSupportCell ν r hr 0 z.val)) = + ν (⋃ z : F, cleanSupportCell ν r hr 0 z.val) := by + simpa only [tsum_fintype] using! (measure_iUnion hd hm).symm + have hsub : (⋃ z : F, cleanSupportCell ν r hr 0 z.val) ⊆ ball a (8 * r) := by + apply iUnion_subset + intro z + exact (selected_surface_ball_cell_subset_seven_ball ν r hr a z.val z.property).trans + (closedBall_subset_ball (by linarith : 7 * r < 8 * r)) + rw [hsum] + exact (measure_mono hsub).trans (hg.2 a _ (by positivity)) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallChartAssembly.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallChartAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad7a6934150e9973d2c561b9855241fbc9037ed7 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallChartAssembly.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.NativeSurfaceArea +import OAI.Analysis.RieszRectifiability.Surfaces.SurfaceBallCellMass +import OAI.Analysis.RieszRectifiability.Nets.FiniteFamilyRetractionCover + +namespace OAI + +/-! +# Assembling surface ball charts + +Finite cell charts combine into a ball chart whose uncovered surface mass is +controlled by the sum of the cell deficits. Restriction to the surface identifies +this deficit with the corresponding Hausdorff measure. +-/ + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set +open scoped NNReal ENNReal + +theorem exists_surface_ball_chart_of_cell_deficits {n d : ℕ} (hn : 0 < n) + (ν : Measure (Ambient d)) (A : Set (Ambient d)) (hν : ν = nativeSurfaceArea n A) + (hsupport : ν.support = A) + (C G : ℝ) (hC : 0 < C) (hG : 0 < G) (hg : GlobalUpperGrowth n G ν) + (hlower : ∀ x ∈ ν.support, ∀ s : ℝ, AdmissibleRadius ν s → + ENNReal.ofReal (s ^ n / C) ≤ ν (ball x s)) + (r : ℝ) (hr : 0 < r) (a : Ambient d) (M : ℝ≥0) (loss : ℝ≥0∞) + (hcharts : ∀ z : surfaceBallCellCenters ν r hr a, + ∃ g : ball (0 : Ambient n) r → Ambient d, LipschitzWith M g ∧ + ν (cleanSupportCell ν r hr 0 z.val \ Set.range g) ≤ loss * ν (cleanSupportCell ν r hr 0 z.val)) : + ∃ g : ball (0 : Ambient n) r → Ambient d, + LipschitzWith (finiteBallChartUnionConstant d (11 ^ d) M) g ∧ + Set.range g ⊆ closedBall a (3 * r) ∧ + (μH[(n : ℝ)] : Measure (Ambient d)) ((A ∩ closedBall a (3 * r)) \ Set.range g) ≤ + loss * ENNReal.ofReal (G * (8 * r) ^ n) := by + classical + let F := surfaceBallCellCenters ν r hr a + choose child hLip hLoss using hcharts + have hN : Fintype.card F ≤ 11 ^ d := by + simpa only [Fintype.card_coe] using! surfaceBallCellCenters_card_le ν r hr a + obtain ⟨g, hglip, hgrange, hcover⟩ := exists_bounded_ball_cover_of_finite_family hn + (11 ^ d) hN r hr a child M hLip + let B := supportLatticeExceptional ν r hr + have hB : ν B = 0 := supportLatticeExceptional_null ν C G hC hG hg hlower r hr + have hsub : ((A ∩ closedBall a (3 * r)) \ Set.range g) ⊆ + B ∪ ⋃ z : F, cleanSupportCell ν r hr 0 z.val \ Set.range (child z) := by + intro x hx + by_cases hxB : x ∈ B + · exact Or.inl hxB + have hxν : x ∈ ν.support := hsupport.symm ▸ hx.1.1 + obtain ⟨z, hz, hcell⟩ := surface_ball_covered_by_selected_cells_off_exceptional + ν r hr a x ⟨hxν, hx.1.2⟩ hxB + refine Or.inr (mem_iUnion.mpr ⟨⟨z, hz⟩, hcell, ?_⟩) + intro h + exact hx.2 (hcover ⟨z, hz⟩ ⟨hx.1.2, h⟩) + have hEq : (μH[(n : ℝ)] : Measure (Ambient d)) ((A ∩ closedBall a (3 * r)) \ Set.range g) = + ν ((A ∩ closedBall a (3 * r)) \ Set.range g) := by + rw [hν] + exact ((μH[(n : ℝ)] : Measure (Ambient d)).restrict_eq_self + (sdiff_subset.trans inter_subset_left)).symm + refine ⟨g, hglip, hgrange, ?_⟩ + rw [hEq] + calc + _ ≤ ν (B ∪ ⋃ z : F, cleanSupportCell ν r hr 0 z.val \ Set.range (child z)) := measure_mono hsub + _ ≤ ν B + ν (⋃ z : F, cleanSupportCell ν r hr 0 z.val \ Set.range (child z)) := measure_union_le _ _ + _ = ν (⋃ z : F, cleanSupportCell ν r hr 0 z.val \ Set.range (child z)) := by rw [hB, zero_add] + _ ≤ ∑ z : F, ν (cleanSupportCell ν r hr 0 z.val \ Set.range (child z)) := by + simpa only [tsum_fintype] using! (measure_iUnion_le + (fun z : F => cleanSupportCell ν r hr 0 z.val \ Set.range (child z)) (μ := ν)) + _ ≤ ∑ z : F, loss * ν (cleanSupportCell ν r hr 0 z.val) := Finset.sum_le_sum (fun z _ => hLoss z) + _ = loss * ∑ z : F, ν (cleanSupportCell ν r hr 0 z.val) := (Finset.mul_sum ..).symm + _ ≤ _ := mul_le_mul' le_rfl (surface_ball_cell_mass_sum_le ν G hg r hr a) + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallOriginalMass.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallOriginalMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a2900250bc729ecc8802c3f3bdee375d01a5e24 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallOriginalMass.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.ActiveRegionStopMassArea + +namespace OAI + +namespace RieszRectifiability + +noncomputable section + +open MeasureTheory Metric Set Filter Topology +open scoped ENNReal + +theorem radius_eight_growth_le_original_cell_mass {n d : ℕ} + (μ : Measure (Ambient d)) (C G : ℝ) (hC : 0 < C) (hG : 0 < G) + (hg : GlobalUpperGrowth n G μ) + (hlower : ∀ x ∈ μ.support, ∀ r : ℝ, AdmissibleRadius μ r → + ENNReal.ofReal (r ^ n / C) ≤ μ (ball x r)) + (R : ℝ) (hR : 0 < R) (k : ℕ) (hcore : AdmissibleRadius μ (latticeRadius R k / 8)) + (z : (supportLatticeNets μ R hR k).points) (K : ℝ) (hK : 0 ≤ K) : + ENNReal.ofReal (K * (8 * latticeRadius R k) ^ n) ≤ + ENNReal.ofReal (K * C * (64 : ℝ) ^ n) * μ (cleanSupportCell μ R hR k z) := by + have hmass := (cleanSupportCell_measure_bounds μ C G hC hG hg hlower R hR k hcore z).1 + have heq : ENNReal.ofReal (K * (8 * latticeRadius R k) ^ n) = + ENNReal.ofReal (K * C * (64 : ℝ) ^ n) * ENNReal.ofReal ((latticeRadius R k / 8) ^ n / C) := by + rw [← ENNReal.ofReal_mul (by positivity : 0 ≤ K * C * (64 : ℝ) ^ n)] + congr 1 + rw [show (64 : ℝ) = 8 * 8 by norm_num, mul_pow, mul_pow, div_pow] + field_simp + rw [heq] + exact mul_le_mul' le_rfl hmass + +theorem exists_depth_for_weighted_geometric_loss + (ρ : ℝ) (hρ : 0 ≤ ρ) (hρ1 : ρ < 1) + (W : ℝ≥0∞) (hW : W < ⊤) (A : ℝ) (hA : 0 ≤ A) (δ : ℝ) (hδ : 0 < δ) : + ∃ J : ℕ, W * (ENNReal.ofReal ρ) ^ J * ENNReal.ofReal A ≤ ENNReal.ofReal δ := by + let B : ℝ := W.toReal * A + 1 + have hB : 0 < B := by dsimp only [B]; positivity + have htend := tendsto_pow_atTop_nhds_zero_of_lt_one hρ hρ1 + have hevent : ∀ᶠ J : ℕ in atTop, ρ ^ J < δ / B := + htend.eventually (gt_mem_nhds (div_pos hδ hB)) + obtain ⟨J, hJ⟩ := hevent.exists + have hJ' : ρ ^ J * B < δ := (lt_div_iff₀ hB).mp hJ + have hpow : 0 ≤ ρ ^ J := pow_nonneg hρ J + refine ⟨J, ?_⟩ + rw [← ENNReal.ofReal_toReal hW.ne, ← ENNReal.ofReal_pow hρ, + ← ENNReal.ofReal_mul ENNReal.toReal_nonneg, + ← ENNReal.ofReal_mul (mul_nonneg ENNReal.toReal_nonneg hpow)] + apply ENNReal.ofReal_le_ofReal + dsimp only [B] at hJ' + nlinarith + +end + +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallTransferFoundations.lean b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallTransferFoundations.lean new file mode 100644 index 0000000000000000000000000000000000000000..df603dc0046a5795f829de7c0df561c83a1a3eed --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Surfaces/SurfaceBallTransferFoundations.lean @@ -0,0 +1,3 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Surfaces.MatchedSurfaceBallDepthCharts +import OAI.Analysis.RieszRectifiability.Surfaces.SurfaceBallOriginalMass diff --git a/lean/OAI/Analysis/RieszRectifiability/Uniformity/Growth.lean b/lean/OAI/Analysis/RieszRectifiability/Uniformity/Growth.lean new file mode 100644 index 0000000000000000000000000000000000000000..97034a01b5ee1721337c9554ea7cde0cdb951f4c --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Uniformity/Growth.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Nets.SeparatedSupportNets +import OAI.Analysis.RieszRectifiability.Kernel.KernelBasic +import OAI.Analysis.RieszRectifiability.Packing.EuclideanPackingBound + +namespace OAI + +namespace RieszRectifiability +noncomputable section +open MeasureTheory Metric Set Topology +open scoped NNReal ENNReal + +theorem quantitative_total_mass_of_bounded_support {d n : ℕ} + (μ : Measure (Ambient d)) (C : ℝ) (hAD : ADRegularWithConstant n C μ) + (hpos : μ.support.Nontrivial) (hfin : ediam μ.support ≠ ⊤) : + μ Set.univ ≤ ENNReal.ofReal ((9 : ℝ) ^ d * C * (diam μ.support / 2) ^ n) := by + classical + let D := diam μ.support + have hb : Bornology.IsBounded μ.support := isBounded_iff_ediam_ne_top.mpr hfin + have hD : 0 < D := diam_pos hpos hb + have hc : IsCompact μ.support := isCompact_iff_isClosed_bounded.mpr ⟨μ.isClosed_support, hb⟩ + obtain ⟨N, _, hNE, hsep, hcover⟩ := exists_separated_cover_extension μ.support ∅ + (D / 4) (by positivity) (empty_subset _) (by simp) + have hNfin : N.Finite := by + have h := separated_set_finite_inter_compact N μ.support (D / 4) + (by positivity) hsep hc + simpa only [inter_eq_left.mpr hNE] using! h + let s := hNfin.toFinset + obtain ⟨a, ha⟩ := hpos.nonempty + let t := s.image (fun x => x - a) + have hcard : t.card = s.card := Finset.card_image_of_injective _ (fun x y h => sub_left_inj.mp h) + have hball : ∀ x ∈ t, ‖x‖ ≤ D := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hx + rw [← dist_eq_norm] + exact dist_le_diam_of_mem hb (hNE (hNfin.mem_toFinset.mp hy)) ha + have hsep' : ∀ x ∈ t, ∀ y ∈ t, x ≠ y → 2 * (D / 8) ≤ dist x y := by + intro x hx y hy hxy + obtain ⟨z, hz, rfl⟩ := Finset.mem_image.mp hx + obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hy + rw [dist_sub_right] + have hn : z ≠ w := by rintro rfl; exact hxy rfl + have hh := hsep (hNfin.mem_toFinset.mp hz) (hNfin.mem_toFinset.mp hw) hn + linarith + have hs : (s.card : ℝ) ≤ (9 : ℝ) ^ d := by + have hp := euclidean_separated_card_le t D (D / 8) hD.le (by positivity) hball hsep' + have heq : (D + D / 8) / (D / 8) = 9 := by field_simp; ring + simpa only [hcard, heq] using! hp + have hadmiss : AdmissibleRadius μ (D / 2) := by + refine ⟨by positivity, ?_⟩ + calc + ENNReal.ofReal (D / 2) ≤ ENNReal.ofReal D := ENNReal.ofReal_le_ofReal (by linarith) + _ = ediam μ.support := ENNReal.ofReal_toReal hfin + have hcov : μ.support ⊆ ⋃ x ∈ s, ball x (D / 2) := by + intro y hy + obtain ⟨x, hx, hyx⟩ := hcover y hy + exact mem_iUnion₂.mpr ⟨x, hNfin.mem_toFinset.mpr hx, lt_trans hyx (by linarith)⟩ + have heq : μ μ.support = μ Set.univ := by + simpa only [univ_inter] using! (measure_inter_conull (μ := μ) (s := Set.univ) μ.measure_compl_support) + calc + μ Set.univ = μ μ.support := heq.symm + _ ≤ μ (⋃ x ∈ s, ball x (D / 2)) := measure_mono hcov + _ ≤ ∑ x ∈ s, μ (ball x (D / 2)) := measure_biUnion_finset_le s _ + _ ≤ ∑ _x ∈ s, ENNReal.ofReal (C * (D / 2) ^ n) := by + apply Finset.sum_le_sum + intro x hx + exact (hAD.2 x (hNE (hNfin.mem_toFinset.mp hx)) _ hadmiss).2 + _ = ENNReal.ofReal ((s.card : ℝ) * (C * (D / 2) ^ n)) := by + simp only [Finset.sum_const, nsmul_eq_mul, ENNReal.ofReal_mul (by positivity : 0 ≤ (s.card : ℝ)), ENNReal.ofReal_natCast] + _ ≤ ENNReal.ofReal (9 ^ d * C * (D / 2) ^ n) := by + apply ENNReal.ofReal_le_ofReal + have hC : 0 ≤ C := zero_le_one.trans hAD.1 + nlinarith [mul_le_mul_of_nonneg_right hs (mul_nonneg hC (pow_nonneg (by positivity : 0 ≤ D / 2) n))] + +theorem quantitative_global_growth {d n : ℕ} (hnd : n ≤ d) + (μ : Measure (Ambient d)) (C : ℝ) (hAD : ADRegularWithConstant n C μ) + (hpos : μ.support.Nontrivial) : + GlobalUpperGrowth n ((9 : ℝ) ^ d * C) μ := by + have hC : 0 ≤ C := zero_le_one.trans hAD.1 + have hG : 0 ≤ (9 : ℝ) ^ d * C := mul_nonneg (by positivity) hC + refine ⟨hG, ?_⟩ + intro a r hr + by_cases hz : μ (ball a r) = 0 + · rw [hz] + exact zero_le + obtain ⟨x, hxa, hx⟩ := μ.nonempty_inter_support_of_pos (pos_iff_ne_zero.mpr hz) + by_cases hsmall : ENNReal.ofReal (2 * r) ≤ ediam μ.support + · have hsub : ball a r ⊆ ball x (2 * r) := by + intro y hy + change dist y x < 2 * r + calc + dist y x ≤ dist y a + dist a x := dist_triangle _ _ _ + _ < r + r := add_lt_add hy (by simpa only [mem_ball, dist_comm] using! hxa) + _ = 2 * r := by ring + have hpow : (2 : ℝ) ^ n ≤ 9 ^ d := + (pow_le_pow_left₀ (by norm_num) (by norm_num : (2 : ℝ) ≤ 9) n).trans + (pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 9) hnd) + calc + μ (ball a r) ≤ μ (ball x (2 * r)) := measure_mono hsub + _ ≤ ENNReal.ofReal (C * (2 * r) ^ n) := (hAD.2 x hx _ ⟨by positivity, hsmall⟩).2 + _ ≤ ENNReal.ofReal (9 ^ d * C * r ^ n) := by + apply ENNReal.ofReal_le_ofReal + rw [mul_pow] + nlinarith [mul_le_mul_of_nonneg_right hpow (mul_nonneg hC (pow_nonneg hr.le n))] + · have hdiam : ediam μ.support < ENNReal.ofReal (2 * r) := lt_of_not_ge hsmall + have hfin : ediam μ.support ≠ ⊤ := ne_top_of_lt hdiam + have hdr : diam μ.support < 2 * r := by + have h := (ENNReal.toReal_lt_toReal hfin ENNReal.ofReal_ne_top).mpr hdiam + simpa only [diam, ENNReal.toReal_ofReal (by positivity : 0 ≤ 2 * r)] using! h + calc + μ (ball a r) ≤ μ Set.univ := measure_mono (subset_univ _) + _ ≤ ENNReal.ofReal (9 ^ d * C * (diam μ.support / 2) ^ n) := + quantitative_total_mass_of_bounded_support μ C hAD hpos hfin + _ ≤ ENNReal.ofReal (9 ^ d * C * r ^ n) := by + apply ENNReal.ofReal_le_ofReal + exact mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (div_nonneg diam_nonneg (by norm_num)) (by linarith) n) hG + +end +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Uniformity/Rectifiability.lean b/lean/OAI/Analysis/RieszRectifiability/Uniformity/Rectifiability.lean new file mode 100644 index 0000000000000000000000000000000000000000..0926de65656949e1f3c4cc4dd40295772448a4c9 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Uniformity/Rectifiability.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.CleanCellChartTargetBridge +import OAI.Analysis.RieszRectifiability.Uniformity.Growth +import OAI.Analysis.RieszRectifiability.Uniformity.SurfacePieces +import OAI.Analysis.RieszRectifiability.Uniformity.RestartBudgets + +namespace OAI + +/-! +# Quantitative ball images with constants chosen before the measure + +Clean-cell charts with relative deficit `ζ` yield genuine ball images with mass +fraction `(1 - ζ) / (C * 32 ^ n)` and the rescaled Lipschitz bound. The final +assembly chooses the surface-piece and restart budgets from the fixed dimension, +AD constant, and common Riesz bound before introducing the measure. Degenerate +supports are handled directly through the admissible-radius condition. +-/ + +namespace RieszRectifiability +noncomputable section +open MeasureTheory Metric Set Topology +open scoped NNReal ENNReal + +theorem quantitative_ball_images_of_clean_cell_deficits {n d : ℕ} + (μ : Measure (Ambient d)) (C : ℝ) (hAD : ADRegularWithConstant n C μ) + (G : ℝ) (hG : 0 < G) (hg : GlobalUpperGrowth n G μ) + (ζ : ℝ) (hζ : 0 ≤ ζ) (hζone : ζ < 1) (M : ℝ≥0) + (hcharts : ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + ∃ f : ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + LipschitzWith M f ∧ μ (cleanSupportCell μ R hR k z \ Set.range f) ≤ + ENNReal.ofReal ζ * μ (cleanSupportCell μ R hR k z)) : BallImageConclusion n μ ((1 - ζ) / (C * 32 ^ n)) (M * (1 / 4)) := by + obtain ⟨hC, hballs⟩ := hAD + have hCpos : 0 < C := zero_lt_one.trans_le hC + have hkeep : 0 < 1 - ζ := sub_pos.mpr hζone + let θ := (1 - ζ) / (C * 32 ^ n) + have hθ : 0 < θ := div_pos hkeep (mul_pos hCpos (by positivity)) + change BallImageConclusion n μ θ (M * (1 / 4)) + intro x hx r hr + have hR : 0 < r / 4 := div_pos hr.1 (by norm_num) + obtain ⟨zc, hzc, hnear⟩ := (supportLatticeNets μ (r / 4) hR 0).covers x hx + let z : (supportLatticeNets μ (r / 4) hR 0).points := ⟨zc, hzc⟩ + have hrad : latticeRadius (r / 4) 0 = r / 4 := by simp only [latticeRadius, pow_zero, mul_one] + have hcore : AdmissibleRadius μ (latticeRadius (r / 4) 0 / 8) := by + refine ⟨div_pos (latticeRadius_pos _ hR 0) (by norm_num), ?_⟩ + apply (ENNReal.ofReal_le_ofReal ?_).trans hr.2 + rw [hrad] + linarith [hr.1] + obtain ⟨f, hf, hdeficit⟩ := hcharts (r / 4) hR 0 z hcore + have hmass := cleanSupportCell_measure_bounds μ C G hCpos hG hg + (fun y hy s hs => (hballs y hy s hs).1) (r / 4) hR 0 hcore z + have hfinite : μ (cleanSupportCell μ (r / 4) hR 0 z) ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.ofReal_ne_top hmass.2 + have hret := retained_mass_of_chart_deficit μ _ (Set.range f) hfinite ζ hζ hdeficit + have hcoef : θ * r ^ n = (1 - ζ) * ((latticeRadius (r / 4) 0 / 8) ^ n / C) := by + rw [hrad] + change (1 - ζ) / (C * 32 ^ n) * r ^ n = (1 - ζ) * ((r / 4 / 8) ^ n / C) + rw [div_div, show (4 : ℝ) * 8 = 32 by norm_num, div_pow] + ring + have hretained : ENNReal.ofReal (θ * r ^ n) ≤ + μ (cleanSupportCell μ (r / 4) hR 0 z ∩ Set.range f) := by + rw [hcoef, ENNReal.ofReal_mul hkeep.le] + exact (mul_le_mul_right hmass.1 (ENNReal.ofReal (1 - ζ))).trans hret + have hcell : cleanSupportCell μ (r / 4) hR 0 z ⊆ ball x r := by + intro y hy + have hdist := (supportLatticeCell_bounds μ (r / 4) hR 0 z).2 hy.1 + change dist y zc ≤ 2 * latticeRadius (r / 4) 0 at hdist + rw [hrad] at hdist hnear + have htri := dist_triangle y zc x + rw [dist_comm zc x] at htri + change dist y x < r + linarith [hr.1] + obtain ⟨F, hF, hFRange⟩ := exists_rescaled_ball_chart (latticeRadius (r / 4) 0) + (0 : Ambient n) (1 / 4) (by norm_num) f M hf + have hdomain : latticeRadius (r / 4) 0 / ((1 / 4 : ℝ≥0) : ℝ) = r := by + rw [hrad] + norm_num + ring + rw [hdomain] at hF hFRange + let g := (ball (0 : Ambient n) r).domRestrict F + have hcover : Set.range f ⊆ Set.range g := by + intro y hy + obtain ⟨u, hu, hFu⟩ := hFRange.symm ▸ hy + exact ⟨⟨u, hu⟩, hFu⟩ + refine ⟨g, hF.to_restrict, hretained.trans (measure_mono ?_)⟩ + exact fun y hy => ⟨hcell hy.1, hcover hy.2⟩ + +theorem quantitative_higher_codimension_riesz_rectifiability : QuantitativeFullStatement := by + intro d n _hd hn hnd C hC D + cases n with + | zero => omega + | succ p => + have hnd' : p + 1 ≤ d := by omega + let G : ℝ := 9 ^ d * C + have hG : 0 < G := mul_pos (by positivity) (zero_lt_one.trans_le hC) + obtain ⟨ε, hε, hεfine, hsmall, hpieces⟩ := + quantitative_uniform_restart_surface_pieces (Nat.succ_pos p) hnd' C G hC hG + obtain ⟨δ, hδ, b, _hb, hcharts⟩ := quantitative_recursive_chart_from_surface_pieces + hnd' C G D hC hG 1024 ε (by norm_num) hε hεfine hsmall (1 / 2) (by norm_num) + obtain ⟨N, P, hdata⟩ := hpieces δ hδ + let M := badBudgetChartConstant + (fun M => restartChartStepConstant d N P (restartChartStepConstant d N P M)) b + refine ⟨(1 - (1 / 2 : ℝ)) / (C * 32 ^ (p + 1)), + div_pos (by norm_num) (mul_pos (zero_lt_one.trans_le hC) (by positivity)), + M * (1 / 4), ?_⟩ + intro μ hreg hAD hRiesz + let : μ.Regular := hreg + by_cases hsupport : μ.support.Nontrivial + · have hg : GlobalUpperGrowth (p + 1) G μ := quantitative_global_growth hnd' μ C hAD hsupport + apply quantitative_ball_images_of_clean_cell_deficits μ C hAD G hG hg + (1 / 2) (by norm_num) (by norm_num) M + intro R hR k z hcore + obtain ⟨E, data, hloss⟩ := hdata μ hAD hg R hR k z hcore + obtain ⟨g, hglip, _, hdeficit⟩ := hcharts N P μ hAD hg hRiesz R hR k z hcore E data hloss + exact ⟨g, hglip, hdeficit⟩ + · intro x _hx r hr + have hdiam : ediam μ.support = 0 := ediam_eq_zero_iff.mpr (Set.not_nontrivial_iff.mp hsupport) + have hz : ENNReal.ofReal r = 0 := le_antisymm (hdiam ▸ hr.2) zero_le + exact ((ENNReal.ofReal_pos.mpr hr.1).ne' hz).elim + +end +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Uniformity/RestartBudgets.lean b/lean/OAI/Analysis/RieszRectifiability/Uniformity/RestartBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfb8b85754d85af107ee48b03f17e4f5f7cc9b98 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Uniformity/RestartBudgets.lean @@ -0,0 +1,273 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.SelectedRestartAreaLoss + +namespace OAI + +/-! +# Uniform budgets for bad cells and restarts + +The class-uniform bad-beta packing constant controls multiplicity tails and the +total mass of restart roots. A relative loss tolerance and a finite bad-depth +budget are chosen before the measure, using only the fixed geometric and Riesz +bounds. Splitting the desired deficit into two halves pays separately for the +discarded high-multiplicity set and the remainders of selected restart regions. +These budgets feed the recursive chart assembly without changing its image or +Lipschitz conclusions. +-/ + +namespace RieszRectifiability +noncomputable section +open MeasureTheory Metric Set Topology +open scoped NNReal ENNReal + +theorem quantitative_bad_beta_total_mass {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) + (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) : + ∃ K : ℝ, 0 < K ∧ ∀ (μ : Measure (Ambient d)) [μ.Regular], + ADRegularWithConstant (p + 1) C μ → GlobalUpperGrowth (p + 1) G μ → + RieszL2BoundedWithConstant (p + 1) D μ → + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + ∑' i : BadBetaDescendant (p + 1) μ R hR k z H ε, + μ i.val.cell ≤ ENNReal.ofReal K * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨K, hK, hpack⟩ := exists_uniform_bad_beta_total_mass hnd C G H ε D + (zero_lt_one.trans_le hC) hG hH hε + refine ⟨K, hK, ?_⟩ + intro μ _hreg hAD hg hRiesz + exact hpack μ hg (fun x hx r hr => (hAD.2 x hx r hr).1) hRiesz + +theorem quantitative_bad_beta_stopping {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) : + ∃ K : ℝ, 0 < K ∧ ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + (∀ t : ℝ≥0∞, t ≠ 0 → t ≠ ∞ → + μ {x | t ≤ badBetaMultiplicity (p + 1) μ R hR k z H ε x} ≤ + (ENNReal.ofReal K * μ (cleanSupportCell μ R hR k z)) / t) ∧ + (∀ᵐ x ∂μ, {i : BadBetaDescendant (p + 1) μ R hR k z H ε | x ∈ i.val.cell}.Finite) := by + obtain ⟨K, hK, hpack⟩ := quantitative_bad_beta_total_mass hnd C G D hC hG H ε hH hε + refine ⟨K, hK, ?_⟩ + intro μ _hreg hAD hg hRiesz R hR k z hcore + have hpack := hpack μ hAD hg hRiesz + let := badBetaDescendant_countable (p + 1) μ R hR k z H ε + let A (i : BadBetaDescendant (p + 1) μ R hR k z H ε) := i.val.cell + have hA : ∀ i, MeasurableSet (A i) := fun i => cleanSupportCell_measurable + μ R hR (k + i.val.depth) ⟨i.val.center, i.val.mem_net⟩ + have hp := hpack R hR k z hcore + constructor + · intro t ht htt + exact cellMultiplicity_tail_bound μ A hA _ t hp ht htt + · have htop : μ (cleanSupportCell μ R hR k z) < ∞ := + (measure_mono (show cleanSupportCell μ R hR k z ⊆ supportLatticeCell μ R hR k z + from fun _ hx => hx.1)).trans_lt (supportLatticeCell_compact μ R hR k z).measure_lt_top + apply ae_finite_cell_incidence μ A hA + exact ne_top_of_le_ne_top (ENNReal.mul_ne_top ENNReal.ofReal_ne_top htop.ne) hp + +theorem quantitative_bad_beta_restart_mass {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) : + ∃ K : ℝ, 0 < K ∧ ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + ∑' i : {i : SupportCellDescendant μ R hR k z // cellRestartsAfter + (fun q => ε ≤ bilateralBeta (p + 1) μ q.center (H * q.radius)) i}, + μ i.val.cell ≤ ENNReal.ofReal K * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨K, hK, hpack⟩ := quantitative_bad_beta_total_mass hnd C G D hC hG H ε hH hε + refine ⟨1 + K, by linarith, ?_⟩ + intro μ _hreg hAD hg hRiesz R hR k z hcore + have hpack := hpack μ hAD hg hRiesz + have h := restart_roots_total_mass_le μ R hR k z + (fun q => ε ≤ bilateralBeta (p + 1) μ q.center (H * q.radius)) + (ENNReal.ofReal K) (hpack R hR k z hcore) + simpa only [ENNReal.ofReal_add zero_le_one hK.le, ENNReal.ofReal_one] using! h + +theorem quantitative_restart_loss_budget {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) + (ζ : ℝ) (hζ : 0 < ζ) : + ∃ δ : ℝ, 0 < δ ∧ ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + ∀ loss : {i : SupportCellDescendant μ R hR k z // cellRestartsAfter + (fun q => ε ≤ bilateralBeta (p + 1) μ q.center (H * q.radius)) i} → ℝ≥0∞, + (∀ i, loss i ≤ ENNReal.ofReal δ * μ i.val.cell) → + (∑' i, loss i) ≤ ENNReal.ofReal ζ * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨K, hK, hpack⟩ := quantitative_bad_beta_restart_mass hnd C G D hC hG H ε hH hε + refine ⟨ζ / K, div_pos hζ hK, ?_⟩ + intro μ _hreg hAD hg hRiesz R hR k z hcore loss hloss + have hpack := hpack μ hAD hg hRiesz + have h := relative_losses_sum_le_packed_mass (fun i => μ i.val.cell) loss + (ENNReal.ofReal (ζ / K)) (ENNReal.ofReal K) (μ (cleanSupportCell μ R hR k z)) + hloss (hpack R hR k z hcore) + have heq : ENNReal.ofReal (ζ / K) * ENNReal.ofReal K = ENNReal.ofReal ζ := by + rw [← ENNReal.ofReal_mul (div_nonneg hζ.le hK.le), div_mul_cancel₀ ζ hK.ne'] + rwa [heq] at h + +theorem quantitative_bad_depth_loss_budget {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) + (ζ : ℝ) (hζ : 0 < ζ) : + ∃ N : ℕ, 0 < N ∧ ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + μ {x | (N : ℝ≥0∞) ≤ badBetaMultiplicity (p + 1) μ R hR k z H ε x} ≤ + ENNReal.ofReal ζ * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨K, hK, hstop⟩ := quantitative_bad_beta_stopping hnd C G D hC hG H ε hH hε + obtain ⟨N, hN⟩ := exists_nat_ge (max 1 (K / ζ)) + have hN1 : 1 ≤ (N : ℝ) := (le_max_left _ _).trans hN + have hNratio : K / ζ ≤ (N : ℝ) := (le_max_right _ _).trans hN + have hNpos : 0 < N := by exact_mod_cast lt_of_lt_of_le zero_lt_one hN1 + have hNrpos : 0 < (N : ℝ) := by exact_mod_cast hNpos + have hratio : K / (N : ℝ) ≤ ζ := by + apply (div_le_iff₀ hNrpos).mpr + have h := (div_le_iff₀ hζ).mp hNratio + nlinarith + have hcoef : ENNReal.ofReal K / (N : ℝ≥0∞) ≤ ENNReal.ofReal ζ := by + have h := ENNReal.ofReal_le_ofReal hratio + simpa only [ENNReal.ofReal_div_of_pos hNrpos, ENNReal.ofReal_natCast] using! h + refine ⟨N, hNpos, ?_⟩ + intro μ _hreg hAD hg hRiesz R hR k z hcore + have hstop := hstop μ hAD hg hRiesz + have ht := (hstop R hR k z hcore).1 (N : ℝ≥0∞) (by exact_mod_cast hNpos.ne') (by simp) + calc + _ ≤ (ENNReal.ofReal K * μ (cleanSupportCell μ R hR k z)) / (N : ℝ≥0∞) := ht + _ = (ENNReal.ofReal K / (N : ℝ≥0∞)) * μ (cleanSupportCell μ R hR k z) := by + simp only [div_eq_mul_inv, mul_right_comm] + _ ≤ _ := mul_le_mul_left hcoef _ + +theorem quantitative_cell_bad_count_budget {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) + (ζ : ℝ) (hζ : 0 < ζ) : + ∃ N : ℕ, 0 < N ∧ ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) + (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + ∃ A : Set (Ambient d), MeasurableSet A ∧ A ⊆ cleanSupportCell μ R hR k z ∧ + μ (cleanSupportCell μ R hR k z \ A) ≤ ENNReal.ofReal ζ * μ (cleanSupportCell μ R hR k z) ∧ + ∀ x ∈ A, ∀ q : SupportCellDescendant μ R hR k z, + cellBadCountBound (fun i => ε ≤ bilateralBeta (p + 1) μ i.center (H * i.radius)) q N x := by + classical + obtain ⟨N, hN, htail⟩ := quantitative_bad_depth_loss_budget hnd C G D hC hG H ε hH hε ζ hζ + refine ⟨N, hN, ?_⟩ + intro μ _hreg hAD hg hRiesz R hR k z hcore + have htail := htail μ hAD hg hRiesz + let A := {x ∈ cleanSupportCell μ R hR k z | + badBetaMultiplicity (p + 1) μ R hR k z H ε x < (N : ℝ≥0∞)} + have hAmeas : MeasurableSet A := (cleanSupportCell_measurable μ R hR k z).inter + (measurableSet_lt (badBetaMultiplicity_measurable (p + 1) μ R hR k z H ε) measurable_const) + have hsub : cleanSupportCell μ R hR k z \ A ⊆ + {x | (N : ℝ≥0∞) ≤ badBetaMultiplicity (p + 1) μ R hR k z H ε x} := by + intro x hx + by_contra hn + exact hx.2 ⟨hx.1, lt_of_not_ge hn⟩ + refine ⟨A, hAmeas, fun _ hx => hx.1, (measure_mono hsub).trans (htail R hR k z hcore), ?_⟩ + intro x hx q + apply cellBadCountBound_of_subtype_incidence_bound _ q N x + intro F hF + have hcount : (F.card : ℝ≥0∞) ≤ badBetaMultiplicity (p + 1) μ R hR k z H ε x := by + calc + _ = ∑ i ∈ F, i.val.cell.indicator (fun _ => (1 : ℝ≥0∞)) x := by + symm + calc + _ = ∑ _i ∈ F, (1 : ℝ≥0∞) := + Finset.sum_congr rfl (fun i hi => Set.indicator_of_mem (hF i hi) _) + _ = _ := by simp + _ ≤ _ := ENNReal.sum_le_tsum F + exact_mod_cast hcount.trans hx.2.le + +theorem quantitative_selected_restart_uniform_deficit {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) + (ζ : ℝ) (hζ : 0 < ζ) : + ∃ δ : ℝ, 0 < δ ∧ ∃ b : ℕ, 0 < b ∧ + ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta (p + 1) μ i.center (H * i.radius) + ∀ (E : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q} → Set (Ambient d)) + (step : ℝ≥0 → ℝ≥0), + HasSelectedRestartAssembly (p + 1) Bad E step → + (∀ q, μ (selectedRestartRemainder Bad q.val (E q)) ≤ ENNReal.ofReal δ * μ q.val.cell) → + ∃ g : ball (0 : Ambient (p + 1)) (latticeRadius R k) → Ambient d, + LipschitzWith (badBudgetChartConstant step b) g ∧ + Set.range g ⊆ closedBall (z : Ambient d) (2 * latticeRadius R k) ∧ + μ (cleanSupportCell μ R hR k z \ Set.range g) ≤ + ENNReal.ofReal ζ * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨δ, hδ, hregions⟩ := quantitative_restart_loss_budget hnd C G D hC hG H ε hH hε + (ζ / 2) (half_pos hζ) + obtain ⟨b, hb, hcounts⟩ := quantitative_cell_bad_count_budget hnd C G D hC hG H ε hH hε + (ζ / 2) (half_pos hζ) + refine ⟨δ, hδ, b, hb, ?_⟩ + intro μ _hreg hAD hg hRiesz R hR k z hcore + have hregions := hregions μ hAD hg hRiesz + have hcounts := hcounts μ hAD hg hRiesz + dsimp only + intro E step hassemble hloss + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta (p + 1) μ i.center (H * i.radius) + let q : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q} := + ⟨supportCellRoot μ R hR k z, Or.inl rfl⟩ + obtain ⟨A, _, _, hAmass, hAcount⟩ := hcounts R hR k z hcore + obtain ⟨g, hg, hgrange, _, hdeficit⟩ := exists_restart_chart_with_original_mass_deficit + μ R hR k z Bad + (fun r => selectedRestartRemainder Bad r.val (E r)) + (fun r => selectedRestartParent Bad r.val (E r)) + (fun r => selectedRestartNext Bad r.val (E r)) step + (fun r w hw => selected_restart_next_consumes_bad_cell Bad r.val (E r) w hw) + (fun r => selected_restart_partition Bad r.val (E r)) hassemble b q A + (fun x hx => hAcount x hx.2 q.val) + have hsum := hregions R hR k z hcore + (fun r => μ (selectedRestartRemainder Bad r.val (E r))) hloss + have hbound := hdeficit.trans (add_le_add hAmass hsum) + have heq : ENNReal.ofReal (ζ / 2) + ENNReal.ofReal (ζ / 2) = ENNReal.ofReal ζ := by + rw [← ENNReal.ofReal_add (half_pos hζ).le (half_pos hζ).le, add_halves] + refine ⟨g, hg, hgrange, ?_⟩ + simpa only [← add_mul, heq] using! hbound + +theorem quantitative_recursive_chart_from_surface_pieces {p d : ℕ} (hnd : p + 1 ≤ d) + (C G : ℝ) (D : ℝ≥0) (hC : 1 ≤ C) (hG : 0 < G) (H ε : ℝ) (hH : 1 ≤ H) (hε : 0 < ε) + (hεfine : ε ≤ 1 / 281474976710656) (hsmall : activeProjectionError d ε ≤ 1 / 128) + (ζ : ℝ) (hζ : 0 < ζ) : + ∃ δ : ℝ, 0 < δ ∧ ∃ b : ℕ, 0 < b ∧ ∀ (N : ℕ) (P : ℝ≥0), ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant (p + 1) C μ → + GlobalUpperGrowth (p + 1) G μ → RieszL2BoundedWithConstant (p + 1) D μ → + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta (p + 1) μ i.center (H * i.radius) + ∀ (E : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q} → Set (Ambient d)) + (data : ∀ q : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q}, + ¬ Bad q.val → SelectedRestartSurfaceData (p + 1) Bad q.val (E q) ε N P), + (∀ q hq, (ENNReal.ofReal G + activeRegionStopMassAreaConstant (p + 1) G) * + (μH[((p + 1 : ℕ) : ℝ)] : Measure (Ambient d)) + ((Set.range (data q hq).model ∩ closedBall q.val.center (3 * q.val.radius)) \ E q) ≤ + ENNReal.ofReal δ * μ q.val.cell) → + ∃ g : ball (0 : Ambient (p + 1)) (latticeRadius R k) → Ambient d, + LipschitzWith (badBudgetChartConstant + (fun M => restartChartStepConstant d N P (restartChartStepConstant d N P M)) b) g ∧ + Set.range g ⊆ closedBall (z : Ambient d) (2 * latticeRadius R k) ∧ + μ (cleanSupportCell μ R hR k z \ Set.range g) ≤ + ENNReal.ofReal ζ * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨δ, hδ, b, hb, hcharts⟩ := quantitative_selected_restart_uniform_deficit + hnd C G D hC hG H ε hH hε ζ hζ + refine ⟨δ, hδ, b, hb, ?_⟩ + intro N P μ _hreg hAD hg hRiesz R hR k z hcore + have hcharts := hcharts μ hAD hg hRiesz + dsimp only + intro E data hloss + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta (p + 1) μ i.center (H * i.radius) + have hassemble := has_selected_restart_assembly_of_surface_data (Nat.succ_pos p) + G hG hg Bad E ε hε hεfine hsmall N P data + apply hcharts R hR k z hcore E _ hassemble + intro q + by_cases hq : Bad q.val + · rw [selected_restart_remainder_of_bad_root Bad q.val hq (E q), measure_empty] + exact zero_le + · exact (selected_restart_remainder_mass_le_surface_loss μ G hG hg R hR k z + Bad q.val hq (E q) ε hε hεfine hsmall N P (data q hq)).trans (hloss q hq) + +end +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RieszRectifiability/Uniformity/SurfacePieces.lean b/lean/OAI/Analysis/RieszRectifiability/Uniformity/SurfacePieces.lean new file mode 100644 index 0000000000000000000000000000000000000000..742a878d1ec327573b1d2254a97b47edb5ef17a9 --- /dev/null +++ b/lean/OAI/Analysis/RieszRectifiability/Uniformity/SurfacePieces.lean @@ -0,0 +1,267 @@ +import Mathlib +import OAI.Analysis.RieszRectifiability.Restart.ActiveRegionUniformArea +import OAI.Analysis.RieszRectifiability.Restart.ActiveRegionLocalUpperArea +import OAI.Analysis.RieszRectifiability.Restart.ActiveRegionAllRadiusLowerArea +import OAI.Analysis.RieszRectifiability.Surfaces.ActualNativeSurfaceGeometry +import OAI.Analysis.RieszRectifiability.Surfaces.MatchedSurfacePrecision +import OAI.Analysis.RieszRectifiability.Surfaces.MatchedSurfaceBallDepthCharts +import OAI.Analysis.RieszRectifiability.Surfaces.SurfaceBallOriginalMass +import OAI.Analysis.RieszRectifiability.Restart.SelectedRestartBallChartData + +namespace OAI + +/-! +# Class-uniform surface pieces for restart charts + +Uniform upper and lower area estimates give native surface measures with common +growth and projection bounds. A geometric loss estimate then chooses a finite +chart depth for any positive deficit. The precision, Lipschitz bounds, and restart +piece parameters are selected from the fixed dimensions and regularity constants +before the original measure or its support cell is introduced. +-/ + +namespace RieszRectifiability +noncomputable section +open MeasureTheory Metric Set Topology +open scoped NNReal ENNReal + +/-- Area comparison constants are uniform over the measure class and the allowed precision. -/ +theorem quantitative_uniform_precision_area_models {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (C G : ℝ) (hC : 1 ≤ C) (hG : 0 < G) : + ∃ Ktop : ℝ≥0∞, Ktop < ⊤ ∧ ∃ Kupper : ℝ≥0∞, Kupper < ⊤ ∧ + ∃ Klower : ℝ≥0∞, 0 < Klower ∧ Klower < ⊤ ∧ + ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant n C μ → + GlobalUpperGrowth n G μ → ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 281474976710656 → activeProjectionError d ε ≤ 1 / 128 → + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + ∃ (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell Good i → bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR k z) → Ambient d, + IsActiveRegionLimitModel μ R hR k z Good S hS ε f ∧ IsClosedEmbedding f ∧ + (μH[(n : ℝ)] : Measure (Ambient d)) + (Set.range f ∩ closedBall (z : Ambient d) (2 * latticeRadius R k)) ≤ + Ktop * μ (cleanSupportCell μ R hR k z) ∧ + (∀ (p : Ambient d) (r : ℝ), 0 < r → + (μH[(n : ℝ)] : Measure (Ambient d)) (Set.range f ∩ closedBall p r) ≤ + Kupper * (ENNReal.ofReal r) ^ n) ∧ + ∀ p ∈ Set.range f, ∀ (r : ℝ), 0 < r → + Klower * (ENNReal.ofReal r) ^ n ≤ + (μH[(n : ℝ)] : Measure (Ambient d)) (Set.range f ∩ closedBall p r) := by + have hCpos : 0 < C := zero_lt_one.trans_le hC + refine ⟨activeRegionUniformAreaConstant n d C G, + activeRegionUniformAreaConstant_lt_top n d C G, + activeRegionLocalUpperAreaConstant n d C G, + activeRegionLocalUpperAreaConstant_lt_top n d C G, + activeRegionAllRadiusLowerAreaConstant n C G, + activeRegionAllRadiusLowerAreaConstant_pos n C G, + activeRegionAllRadiusLowerAreaConstant_lt_top n C G, ?_⟩ + intro μ _hreg hAD hg ε hε hεfine hsmall R hR k z hcore + have hballs := hAD.2 + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + have hεtiny : ε ≤ 1 / 268435456 := by linarith + obtain ⟨S, hS, hfit, _⟩ := exists_active_level_projection_maps μ R hR k z hnd ε hε + obtain ⟨f, hmodel⟩ := exists_active_region_limit_model μ R hR k z Good S hS ε hε hεtiny hsmall hfit + refine ⟨S, hS, hfit, f, hmodel, + active_region_limit_isClosedEmbedding μ R hR k z Good S hS ε hε hεtiny hsmall hfit f hmodel, + active_region_limit_area_le_original_top μ C G hCpos hG hg + (fun x hx r hr => (hballs x hx r hr).1) R hR k hcore z Good S hS ε hε hεfine hsmall hfit f hmodel, + ?_, ?_⟩ + · intro p r hr + exact active_region_limit_local_ball_area_le μ C G hCpos hG hg + (fun x hx s hs => (hballs x hx s hs).1) R hR k hcore z Good S hS + ε hε hεfine hsmall hfit f hmodel p r hr + · intro p hp r hr + exact active_region_limit_all_radius_ball_area_ge hn μ C G hCpos hG hg + (fun x hx s hs => (hballs x hx s hs).1) R hR k hcore z Good S hS + ε hε hεfine hsmall hfit f hmodel p hp r hr + +/-- The model surfaces carry regular, unbounded AD measures with common projection geometry. -/ +theorem quantitative_matched_surface_models {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (C₀ G : ℝ) (hC₀ : 1 ≤ C₀) (hG : 0 < G) : + ∃ Ktop : ℝ≥0∞, Ktop < ⊤ ∧ ∃ K : ℝ, 1 ≤ K ∧ + ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant n C₀ μ → + GlobalUpperGrowth n G μ → ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 72057594037927936 → activeProjectionError d ε ≤ 1 / 4096 → + ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + ∃ (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell Good i → bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR k z) → Ambient d, + IsActiveRegionLimitModel μ R hR k z Good S hS ε f ∧ + (μH[(n : ℝ)] : Measure (Ambient d)) + (Set.range f ∩ closedBall (z : Ambient d) (2 * latticeRadius R k)) ≤ + Ktop * μ (cleanSupportCell μ R hR k z) ∧ + let ν := nativeSurfaceArea n (Set.range f) + ν.Regular ∧ ν.support = Set.range f ∧ ADRegular n ν ∧ ediam ν.support = ⊤ ∧ + GlobalUpperGrowth n K ν ∧ + (∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ENNReal.ofReal (r ^ n / K) ≤ ν (ball p r)) ∧ + ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ + (281474976710656 * (ε + activeProjectionError d ε)) * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16)) := by + obtain ⟨Ktop, hKtop, C, hC, c, hc, hcfin, hmodels⟩ := + quantitative_uniform_precision_area_models hn hnd C₀ G hC₀ hG + have hK1 : 1 ≤ nativeSurfaceADConstant n c C := by + have hCnonneg : 0 ≤ C.toReal := ENNReal.toReal_nonneg + have hinv : 0 ≤ (c * (ENNReal.ofReal (1 / 2 : ℝ)) ^ n).toReal⁻¹ := + inv_nonneg.mpr ENNReal.toReal_nonneg + dsimp only [nativeSurfaceADConstant] + linarith + refine ⟨Ktop, hKtop, nativeSurfaceADConstant n c C, hK1, ?_⟩ + intro μ _hreg hAD hg ε hε hεfine hsmall R hR k z hcore + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + obtain ⟨S, hS, hfit, f, hmodel, hembed, htop, hupper, hlower⟩ := + hmodels μ hAD hg ε hε (by linarith) (by linarith) R hR k z hcore + obtain ⟨hreg, hs, hADν, hdiam, _, hg, hl, hplanes⟩ := + active_region_native_surface_geometry hn μ R hR k z Good S hS ε hε hεfine hsmall hfit + f hmodel hembed c C hc hcfin hC hlower hupper + exact ⟨S, hS, hfit, f, hmodel, htop, hreg, hs, hADν, hdiam, hg, hl, hplanes⟩ + +/-- A measure-independent precision admits ball charts with any prescribed positive area deficit. +The Lipschitz constant may depend on that deficit, but is chosen before the measure. -/ +theorem quantitative_uniform_surface_ball_charts {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (C G : ℝ) (hC : 1 ≤ C) (hG : 0 < G) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 / 281474976710656 ∧ activeProjectionError d ε ≤ 1 / 128 ∧ + ∀ δ : ℝ, 0 < δ → ∃ M : ℝ≥0, + ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant n C μ → + GlobalUpperGrowth n G μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + ∃ (S : SupportCellDescendant μ R hR k z → AffineSubspace ℝ (Ambient d)) + (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell Good i → bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR k z) → Ambient d, + IsActiveRegionLimitModel μ R hR k z Good S hS ε f ∧ + ∃ g : ball (0 : Ambient n) (latticeRadius R k) → Ambient d, + LipschitzWith M g ∧ Set.range g ⊆ closedBall (z : Ambient d) (3 * latticeRadius R k) ∧ + (ENNReal.ofReal G + activeRegionStopMassAreaConstant n G) * + (μH[(n : ℝ)] : Measure (Ambient d)) + ((Set.range f ∩ closedBall (z : Ambient d) (3 * latticeRadius R k)) \ Set.range g) ≤ + ENNReal.ofReal δ * μ (cleanSupportCell μ R hR k z) := by + obtain ⟨Ktop, hKtop, K, hK, hmodels⟩ := quantitative_matched_surface_models hn hnd C G hC hG + have hKpos : 0 < K := zero_lt_one.trans_le hK + obtain ⟨κ, hκ, hκquarter, σ, hσ, hwidth, hpair, hshadow⟩ := exists_projection_region_thresholds n K K hKpos hKpos + obtain ⟨ε, hε, hεfine, hsmall, hprecision⟩ := exists_matched_surface_precision d σ hσ + refine ⟨ε, hε, by linarith, by linarith, ?_⟩ + intro δ hδ + have hCpos : 0 < C := zero_lt_one.trans_le hC + let W := ENNReal.ofReal G + activeRegionStopMassAreaConstant n G + have hW : W < ⊤ := by + have hstop := activeRegionStopMassAreaConstant_lt_top n G + exact ENNReal.add_lt_top.mpr ⟨ENNReal.ofReal_lt_top, hstop⟩ + have hθ := nativeCoreAreaFraction_pos_le_half n K hKpos + have hzero : 0 ≤ 1 - nativeCoreAreaFraction n K := by linarith [hθ.2] + have hone : 1 - nativeCoreAreaFraction n K < 1 := by linarith [hθ.1] + obtain ⟨J, hJ⟩ := exists_depth_for_weighted_geometric_loss + (1 - nativeCoreAreaFraction n K) hzero hone W hW (K * C * (64 : ℝ) ^ n) (by positivity) δ hδ + let M := finiteBallChartUnionConstant d (11 ^ d) (projectionRegionDepthConstant d (Real.toNNReal (2 / κ)) J) + refine ⟨M, ?_⟩ + intro μ _hreg hAD hg R hR k z hcore + have hballs := hAD.2 + let Good := fun q : SupportCellDescendant μ R hR k z => + bilateralBeta n μ q.center (1024 * q.radius) < ε + obtain ⟨S, hS, hfit, f, hmodel, _, hreg, hs, _, hdiam, hgν, hlν, hplanes⟩ := + hmodels μ hAD hg ε hε hεfine hsmall R hR k z hcore + let ν := nativeSurfaceArea n (Set.range f) + have hgeometry : ∀ p ∈ ν.support, ∀ r : ℝ, 0 < r → + ∃ P : Submodule ℝ (Ambient d), Module.finrank ℝ P = n ∧ + (∀ x ∈ ν.support ∩ closedBall p (1024 * r), + infDist x (AffineSubspace.mk' p P : Set (Ambient d)) ≤ σ * r) ∧ + closedBall (P.orthogonalProjectionOnto p) (r / 32) ⊆ + P.orthogonalProjectionOnto '' (ν.support ∩ closedBall p (r / 16)) := by + intro p hp r hr + obtain ⟨P, hP, hheight, hcover⟩ := hplanes p hp r hr + exact ⟨P, hP, fun x hx => (hheight x hx).trans (mul_le_mul_of_nonneg_right hprecision hr.le), hcover⟩ + obtain ⟨g, hglip, hgrange, harea⟩ := exists_matched_surface_ball_depth_chart ν (Set.range f) rfl hs + K K hKpos hKpos hgν (fun p hp r hr => hlν p hp r hr.1) σ κ hσ hκ (by linarith) hwidth hpair hshadow + hgeometry hdiam hn J (latticeRadius R k) (latticeRadius_pos R hR k) z + have hmass := radius_eight_growth_le_original_cell_mass μ C G hCpos hG hg + (fun p hp r hr => (hballs p hp r hr).1) R hR k hcore z K hKpos.le + refine ⟨S, hS, hfit, f, hmodel, g, hglip, hgrange, ?_⟩ + calc + _ ≤ W * ((ENNReal.ofReal (1 - nativeCoreAreaFraction n K)) ^ J * + (ENNReal.ofReal (K * C * (64 : ℝ) ^ n) * μ (cleanSupportCell μ R hR k z))) := + mul_le_mul' le_rfl (harea.trans (mul_le_mul' le_rfl hmass)) + _ = (W * (ENNReal.ofReal (1 - nativeCoreAreaFraction n K)) ^ J * + ENNReal.ofReal (K * C * (64 : ℝ) ^ n)) * μ (cleanSupportCell μ R hR k z) := by ring + _ ≤ _ := mul_le_mul' hJ le_rfl + +/-- Choose common piece-count and Lipschitz parameters before assembling all selected restarts. -/ +theorem quantitative_uniform_restart_surface_pieces {n d : ℕ} (hn : 0 < n) (hnd : n ≤ d) + (C G : ℝ) (hC : 1 ≤ C) (hG : 0 < G) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 / 281474976710656 ∧ activeProjectionError d ε ≤ 1 / 128 ∧ + ∀ δ : ℝ, 0 < δ → ∃ (N : ℕ) (P : ℝ≥0), + ∀ (μ : Measure (Ambient d)) [μ.Regular], ADRegularWithConstant n C μ → + GlobalUpperGrowth n G μ → ∀ (R : ℝ) (hR : 0 < R) (k : ℕ) (z : (supportLatticeNets μ R hR k).points), + AdmissibleRadius μ (latticeRadius R k / 8) → + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta n μ i.center (1024 * i.radius) + ∃ (E : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q} → Set (Ambient d)) + (data : ∀ q : {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q}, + ¬ Bad q.val → SelectedRestartSurfaceData n Bad q.val (E q) ε N P), + ∀ q hq, (ENNReal.ofReal G + activeRegionStopMassAreaConstant n G) * + (μH[(n : ℝ)] : Measure (Ambient d)) + ((Set.range (data q hq).model ∩ closedBall q.val.center (3 * q.val.radius)) \ E q) ≤ + ENNReal.ofReal δ * μ q.val.cell := by + classical + obtain ⟨ε, hε, hεfine, hsmall, hcharts⟩ := quantitative_uniform_surface_ball_charts hn hnd C G hC hG + refine ⟨ε, hε, hεfine, hsmall, ?_⟩ + intro δ hδ + obtain ⟨M, hM⟩ := hcharts δ hδ + refine ⟨1, M, ?_⟩ + intro μ _hreg hAD hg R hR k z hcore + have hM := hM μ hAD hg + let Bad := fun i : SupportCellDescendant μ R hR k z => + ε ≤ bilateralBeta n μ i.center (1024 * i.radius) + let Q := {q : SupportCellDescendant μ R hR k z // cellRestartsAfter Bad q} + have hlocal (q : Q) : + ∃ (S : SupportCellDescendant μ R hR (k + q.val.depth) ⟨q.val.center, q.val.mem_net⟩ → + AffineSubspace ℝ (Ambient d)) (hS : ∀ i, IsAffineNPlane n (S i)), + (∀ i, activeRegionCell (relativeRestartGood Bad q.val) i → + bilateralPlaneError μ i.center (1024 * i.radius) (S i) < ε) ∧ + ∃ f : S (supportCellRoot μ R hR (k + q.val.depth) ⟨q.val.center, q.val.mem_net⟩) → Ambient d, + IsActiveRegionLimitModel μ R hR (k + q.val.depth) ⟨q.val.center, q.val.mem_net⟩ + (relativeRestartGood Bad q.val) S hS ε f ∧ + ∃ g : ball (0 : Ambient n) q.val.radius → Ambient d, + LipschitzWith M g ∧ Set.range g ⊆ closedBall q.val.center (3 * q.val.radius) ∧ + (ENNReal.ofReal G + activeRegionStopMassAreaConstant n G) * + (μH[(n : ℝ)] : Measure (Ambient d)) + ((Set.range f ∩ closedBall q.val.center (3 * q.val.radius)) \ Set.range g) ≤ + ENNReal.ofReal δ * μ q.val.cell := by + have hqcore : AdmissibleRadius μ (latticeRadius R (k + q.val.depth) / 8) := by + simpa only [one_div, mul_comm, div_eq_mul_inv, one_mul] using! q.val.core_admissible hcore + obtain ⟨S, hS, hfit, f, hmodel, g, hglip, hgrange, hloss⟩ := + hM R hR (k + q.val.depth) ⟨q.val.center, q.val.mem_net⟩ hqcore + have hGood : relativeRestartGood Bad q.val = + (fun i => bilateralBeta n μ i.center (1024 * i.radius) < ε) := relativeRestartGood_beta_eq ε q.val + exact ⟨S, hS, by simpa only [hGood] using! hfit, + f, by simpa only [hGood] using! hmodel, g, hglip, hgrange, hloss⟩ + choose S hS hfit f hmodel g hglip hgrange hloss using hlocal + let E (q : Q) : Set (Ambient d) := Set.range (g q) + let data (q : Q) : SelectedRestartSurfaceData n Bad q.val (E q) ε 1 M := + selectedRestartSurfaceDataOfBallChart Bad q.val (S q) (hS q) ε (hfit q) + (f q) (hmodel q) (g q) M (hglip q) (hgrange q) + refine ⟨E, (fun q _ => data q), ?_⟩ + intro q _hq + change (ENNReal.ofReal G + activeRegionStopMassAreaConstant n G) * + (μH[(n : ℝ)] : Measure (Ambient d)) + ((Set.range (f q) ∩ closedBall q.val.center (3 * q.val.radius)) \ Set.range (g q)) ≤ + ENNReal.ofReal δ * μ q.val.cell + exact hloss q + +end +end RieszRectifiability + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/ActualDigits.lean b/lean/OAI/Analysis/RotationWeights/ActualDigits.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cd77334d8d01d450b0175d77fbacdd2304bec5e --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/ActualDigits.lean @@ -0,0 +1,455 @@ +import OAI.Analysis.RotationWeights.CrossingEstimates + +namespace OAI + +noncomputable section + +universe uX + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal + +namespace CircleSampling + +section + +section +open Set Filter MeasureTheory +open scoped Topology BigOperators + +def coordinateRadix (i : ℕ) : ℕ := frequency (i+2)/frequency (i+1) +def bridgeWidth (j : ℕ) : ℝ := bridgeSize j/(blockLength j:ℝ) +def rangeWidth (j : ℕ) : ℝ := (blockLength j:ℝ)^(-(19:ℝ)/20) + +lemma coordinateRadix_mul (i : ℕ) : coordinateRadix i*frequency (i+1)=frequency (i+2) := + Nat.div_mul_cancel (frequency_dvd (i+1)) +lemma coordinateRadix_cast (i : ℕ) : (coordinateRadix i:ℝ)=(frequency (i+2):ℝ)/frequency (i+1) := by + unfold coordinateRadix + exact Nat.cast_div (frequency_dvd (i+1)) (Nat.cast_ne_zero.mpr (frequency_pos _).ne') +lemma coordinateBlock_equiv (x : Σ j, Fin (blocks.m j)) : coordinateBlock (blocks.equiv x)=x.1 := by + exact blocks.number_eq (by change blockEnd x.1≤blockEnd x.1+x.2.val; omega) + (by change blockEnd x.1+x.2.val (if stageTagged j i then (10:ℝ) else 0)/(blockLength (coordinateBlock i):ℝ)) := by + apply summable_of_hasFiniteSupport + apply (stageTagged_finite j).subset + intro i hi + simp only [Function.mem_support] at hi + cases h : stageTagged j i + · simp [h] at hi + · exact h + +lemma summable_kappa_sq : Summable (fun j => (kappa j)^2) := by + have hs : Summable (fun j : ℕ => (1:ℝ)/(j:ℝ)^2) := by + exact Real.summable_one_div_nat_pow.mpr (by norm_num : 1<2) + have ht := (summable_nat_add_iff 1).mpr hs + have he : (fun j => (kappa j)^2)=(fun j => (1/(100:ℝ)^2)*(1/((j+1:ℕ):ℝ)^2)) := by + funext j + dsimp [kappa] + push_cast + field_simp + rw [he] + exact ht.mul_left (1/(100:ℝ)^2) + +lemma summable_coordinateKappaError : + Summable (fun i => 60*(kappa (coordinateBlock i))^2/(blockLength (coordinateBlock i):ℝ)) := by + apply blocks.equiv.summable_iff.mp + apply (summable_sigma_of_nonneg (fun x : Σ j, Fin (blocks.m j) => (by positivity : + 0≤60*(kappa (coordinateBlock (blocks.equiv x)))^2/(blockLength (coordinateBlock (blocks.equiv x)):ℝ)))).mpr + refine ⟨fun _ => Summable.of_finite,?_⟩ + have he (j : ℕ) : (∑' i : Fin (blocks.m j),60*(kappa (coordinateBlock (blocks.equiv ⟨j,i⟩)))^2/ + (blockLength (coordinateBlock (blocks.equiv ⟨j,i⟩)):ℝ))=60*(kappa j)^2 := by + simp_rw [coordinateBlock_equiv] + rw [tsum_fintype] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + change (blockLength j:ℝ)*(_/(blockLength j:ℝ))=_ + have hm : (blockLength j:ℝ)≠0 := Nat.cast_ne_zero.mpr (scaleStep j).mpos.ne' + field_simp + simp_rw [he] + exact summable_kappa_sq.mul_left 60 +end + +open MeasureTheory Set Filter CircleCoupling +open scoped BigOperators ENNReal Topology + +def actualCoordinate (i : ℕ) : CoordinateParameters where + l := coordinateRadix i + m := blockLength (coordinateBlock i) + κ := kappa (coordinateBlock i) + a := bridgeWidth (coordinateBlock i) + b := rangeWidth (coordinateBlock i) + hm := blockLength_ge_twoHundred _ + hl := coordinateRadix_bound i + hκ0 := (kappa_pos _).le + hκ := kappa_le _ + ha := bridgeWidth_bounds _ + hb := rangeWidth_bounds _ +def actualSystem : DigitSystem where + b₀ := frequency 1 + hb₀ := frequency_one_gt + coord := actualCoordinate + +lemma actual_radix_zero : actualSystem.radix 0=frequency 1 := rfl +lemma actual_radix_succ (i : ℕ) : actualSystem.radix (i+1)=coordinateRadix i := rfl +lemma actual_denominator (i : ℕ) : CircleDigits.denominator actualSystem.radix i=frequency i := by + induction i with + | zero => exact frequency_zero.symm + | succ i ih => + rw [CircleDigits.denominator_succ,ih] + cases i with + | zero => simp only [actual_radix_zero,frequency_zero,one_mul] + | succ i => + rw [actual_radix_succ,mul_comm] + exact coordinateRadix_mul i + +lemma actual_error_succ (j i : ℕ) : actualSystem.error (stageTagged j) (i+1)= + 60*(kappa (coordinateBlock i))^2/(blockLength (coordinateBlock i):ℝ)+ + (if stageTagged j i then 10 else 0)/(blockLength (coordinateBlock i):ℝ) := by + dsimp [DigitSystem.error,actualSystem,actualCoordinate] + split <;> ring +lemma summable_actual_error (j : ℕ) : Summable (actualSystem.error (stageTagged j)) := by + apply (summable_nat_add_iff 1).mp + simp_rw [actual_error_succ] + exact summable_coordinateKappaError.add (summable_stageTagError j) + +lemma ae_actual_order (j : ℕ) : ∀ᵐ ω ∂actualSystem.probability (stageTagged j), ∀ i, + (AddCircle.measurableEquivIco 1 0 (modelFrequency i • actualSystem.endpoint (fun _ => false) ω)).val ≤ + (AddCircle.measurableEquivIco 1 0 (modelFrequency i • actualSystem.endpoint (fun _ => true) ω)).val := by + filter_upwards [actualSystem.ae_coordinate_order (stageTagged j) (summable_actual_error j)] with ω hω + intro i + simpa only [actual_denominator,modelFrequency] using hω (i+1) +end + +open MeasureTheory Set Filter CircleCoupling +open scoped BigOperators ENNReal Topology + +lemma actual_error_sum (j : ℕ) : (∑' i,actualSystem.error (stageTagged j) i)= + 60*(∑' s,(kappa s)^2)+10 := by + rw [tsum_eq_zero_add' ((summable_nat_add_iff 1).mpr (summable_actual_error j)),show actualSystem.error (stageTagged j) 0=0 by rfl,zero_add] + simp_rw [actual_error_succ] + rw [summable_coordinateKappaError.tsum_add (summable_stageTagError j)] + have hκ : (∑' i,60*(kappa (coordinateBlock i))^2/(blockLength (coordinateBlock i):ℝ))= + 60*(∑' s,(kappa s)^2) := by + rw [←blocks.equiv.tsum_eq] + have hs := blocks.equiv.summable_iff.mpr summable_coordinateKappaError + simp only [Function.comp_def] at hs + rw [hs.tsum_sigma] + have he (s : ℕ) : (∑' i : Fin (blocks.m s),60*(kappa (coordinateBlock (blocks.equiv ⟨s,i⟩)))^2/ + (blockLength (coordinateBlock (blocks.equiv ⟨s,i⟩)):ℝ))=60*(kappa s)^2 := by + simp_rw [coordinateBlock_equiv] + rw [tsum_fintype] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + change (blockLength s:ℝ)*(_/(blockLength s:ℝ))=_ + have hm : (blockLength s:ℝ)≠0 := Nat.cast_ne_zero.mpr (scaleStep s).mpos.ne' + field_simp + simp_rw [he] + exact tsum_mul_left + have ht : (∑' i,(if stageTagged j i then (10:ℝ) else 0)/(blockLength (coordinateBlock i):ℝ))=10 := by + rw [←blocks.equiv.tsum_eq] + have hs := blocks.equiv.summable_iff.mpr (summable_stageTagError j) + simp only [Function.comp_def] at hs + rw [hs.tsum_sigma] + have he (s : ℕ) : (∑' i : Fin (blocks.m s), + (if stageTagged j (blocks.equiv ⟨s,i⟩) then (10:ℝ) else 0)/ + (blockLength (coordinateBlock (blocks.equiv ⟨s,i⟩)):ℝ))=if s=j then 10 else 0 := by + simp only [stageTagged,coordinateBlock_equiv,decide_eq_true_eq] + split_ifs with hs + · rw [tsum_fintype] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + change (blockLength s:ℝ)*(10/(blockLength s:ℝ))=10 + have hm : (blockLength s:ℝ)≠0 := Nat.cast_ne_zero.mpr (scaleStep s).mpos.ne' + field_simp + · simp + simp_rw [he] + exact tsum_ite_eq j (fun _ => 10) + rw [hκ,ht] + +def marginalConstant : ℝ := Real.exp (30*(∑' s,(kappa s)^2)+5) +lemma marginalConstant_pos : 0 < marginalConstant := Real.exp_pos _ +lemma actual_hybrid_bound (j : ℕ) (e : ℕ → Bool) (A : Set CircleDigits.CircleX) (hA : MeasurableSet A) : + (actualSystem.probability (stageTagged j)).real (actualSystem.endpoint e ⁻¹' A) ≤ + marginalConstant*Real.sqrt (volume.real A) := by + have hh := actualSystem.hybrid_sqrt_bound (stageTagged j) e (summable_actual_error j) A hA + rw [actual_error_sum] at hh + convert hh using 1 + unfold marginalConstant + congr 2 + ring +end CircleSampling + +namespace CircleDigits +open Filter Set +open scoped Topology BigOperators + +def hybrid {b : ℕ → ℕ} (d e : Digits b) (D : ℕ) : Digits b := fun i => if i first | exact h i | rfl +lemma hybrid_tail {b : ℕ → ℕ} (hb : ∀ i,2 ≤ b i) (d e : Digits b) (D : ℕ) : + scaledTail b (hybrid d e D) D=scaledTail b d D := by + rw [scaledTail_tsum hb,scaledTail_tsum hb] + congr 1 + apply tsum_congr + intro i + simp only [digitTerm,hybrid,show ¬i+D expansion b (hybrid d e D)) atTop (𝓝 (expansion b e)) := by + have hprefix (D : ℕ) : ∑ i∈Finset.range D,digitTerm b (hybrid d e D) i = ∑ i∈Finset.range D,digitTerm b e i := by + apply Finset.sum_congr rfl + intro i hi + simp only [digitTerm,hybrid,Finset.mem_range.mp hi,ite_true] + have hbound (D : ℕ) : |expansion b (hybrid d e D)-expansion b e| ≤ (denominator b D:ℝ)⁻¹ := by + have hh := expansion_tail_bound hb (hybrid d e D) D + have he := expansion_tail_bound hb e D + rw [hprefix] at hh + exact abs_le.mpr ⟨by linarith,by linarith⟩ + apply tendsto_iff_dist_tendsto_zero.mpr + apply squeeze_zero (fun D => dist_nonneg) (fun D => ?_) (denominator_inv_tendsto hb) + simpa only [Real.dist_eq] using hbound D +lemma hybrid_endpoint_tendsto {b : ℕ → ℕ} (hb : ∀ i,2 ≤ b i) (d e : Digits b) : + Tendsto (fun D => endpoint b (hybrid d e D)) atTop (𝓝 (endpoint b e)) := + ((AddCircle.continuous_mk' 1).tendsto _).comp (hybrid_expansion_tendsto hb d e) +end CircleDigits + +namespace CircleSampling +open MeasureTheory Set Filter ContinuousCircleWeight CircleCoupling +open scoped Topology ENNReal ComplexInnerProductSpace +local instance : MeasurableSpace FiberHilbert := borel FiberHilbert +local instance : BorelSpace FiberHilbert := ⟨rfl⟩ + +abbrev ActualSamples := actualSystem.Samples +def hybridChoice (D : ℕ) (i : ℕ) : Bool := decide (i false) +def lastEndpoint : ActualSamples → CircleX := actualSystem.endpoint (fun _ => true) +def hybridEndpoint (D : ℕ) : ActualSamples → CircleX := actualSystem.endpoint (hybridChoice D) +lemma firstEndpoint_measurable : Measurable firstEndpoint := actualSystem.measurable_endpoint _ +lemma lastEndpoint_measurable : Measurable lastEndpoint := actualSystem.measurable_endpoint _ +lemma hybridEndpoint_measurable (D : ℕ) : Measurable (hybridEndpoint D) := actualSystem.measurable_endpoint _ +lemma hybrid_observe (D : ℕ) (ω : ActualSamples) : + actualSystem.observe (hybridChoice D) ω = CircleDigits.hybrid + (actualSystem.observe (fun _ => false) ω) (actualSystem.observe (fun _ => true) ω) (D+1) := by + funext i + simp only [DigitSystem.observe,CircleDigits.hybrid,hybridChoice] + by_cases hi : i simp [hi] +lemma actual_hybrid_grid (D : ℕ) (ω : ActualSamples) : + ∃ a : Fin (frequency (D+1)), hybridEndpoint D ω=firstEndpoint ω+rationalPoint D a := by + have hh := CircleDigits.hybrid_grid actualSystem.radix_ge_two + (actualSystem.observe (fun _ => false) ω) (actualSystem.observe (fun _ => true) ω) (D+1) + rw [←hybrid_observe,actual_denominator] at hh + obtain ⟨a,ha⟩ := hh + exact ⟨a,by simpa [hybridEndpoint,firstEndpoint,DigitSystem.endpoint,rationalPoint] using (sub_eq_iff_eq_add.mp ha).trans (add_comm _ _)⟩ +lemma actual_hybrid_tendsto (ω : ActualSamples) : Tendsto (fun D => hybridEndpoint D ω) atTop (𝓝 (lastEndpoint ω)) := by + have hh := (CircleDigits.hybrid_endpoint_tendsto actualSystem.radix_ge_two + (actualSystem.observe (fun _ => false) ω) (actualSystem.observe (fun _ => true) ω)).comp (tendsto_add_atTop_nat 1) + simpa only [hybridEndpoint,lastEndpoint,DigitSystem.endpoint,hybrid_observe,Function.comp_def] using hh + +lemma ae_endpoint_good (j : ℕ) (e : ℕ → Bool) : + ∀ᵐ ω ∂actualSystem.probability (stageTagged j), actualSystem.endpoint e ω∈modelGood := + ae_of_ae_map (actualSystem.measurable_endpoint e).aemeasurable + ((actualSystem.hybrid_ac (stageTagged j) e (summable_actual_error j)).ae_le model_good_ae) +lemma ae_hybrid_coordinate_order (j D : ℕ) : + ∀ᵐ ω ∂actualSystem.probability (stageTagged j), ∀ i, + CircleModel.Xi modelFrequency i (firstEndpoint ω) ≤ CircleModel.Xi modelFrequency i (hybridEndpoint D ω) := by + filter_upwards [actualSystem.ae_digit_order (stageTagged j), + actualSystem.ae_hybrid_gridFree (stageTagged j) (fun _ => false) (summable_actual_error j), + actualSystem.ae_hybrid_gridFree (stageTagged j) (hybridChoice D) (summable_actual_error j)] with ω hω hx hy + intro i + change (AddCircle.measurableEquivIco 1 0 (frequency (i+1) • actualSystem.endpoint (fun _ => false) ω)).val ≤ + (AddCircle.measurableEquivIco 1 0 (frequency (i+1) • actualSystem.endpoint (hybridChoice D) ω)).val + rw [←actual_denominator] + dsimp only [DigitSystem.endpoint] at hx hy ⊢ + rw [CircleDigits.scaledTail_repr actualSystem.radix_ge_two _ hx,CircleDigits.scaledTail_repr actualSystem.radix_ge_two _ hy] + apply CircleDigits.scaledTail_mono actualSystem.radix_ge_two + intro k + rw [hybrid_observe] + exact CircleDigits.hybrid_order hω (D+1) k + +lemma cappedDiagonal_eq_of_ratio_le {X : Type uX} (F : ℤ → X → ℝ) (hF : ∀ k x,0 false) (summable_actual_error j)).ae_le hg) + filter_upwards [hh,ae_endpoint_good j (fun _ => false),ae_endpoint_good j (hybridChoice D),ae_hybrid_coordinate_order j D] with ω hω hx hy hord + obtain ⟨a,ha⟩ := actual_hybrid_grid D ω + have hb (k : ℤ) : modelF k (hybridEndpoint D ω)/modelF k (firstEndpoint ω) ≤ 1 := modelF_ratio_ordered hx hy hord k + have he := cappedDiagonal_eq_of_ratio_le modelF modelF_pos (rationalCap D) 1 + (fun k => (hb k).trans (rationalCap_ge_one D)) hb + rw [←he,ha] + exact hω a + +def actualPairLaw (j : ℕ) (e : ℕ → Bool) : FiniteMeasure (CircleX×CircleX) := + ⟨Measure.map (fun ω => (firstEndpoint ω,actualSystem.endpoint e ω)) (actualSystem.probability (stageTagged j)),inferInstance⟩ +lemma actualPairLaw_uc (j : ℕ) (e : ℕ → ℕ → Bool) : + ∀ ε : ℝ≥0∞, ε≠0 → ∃ δ : ℝ≥0∞, δ≠0 ∧ ∀ A : Set CircleX, volume A<δ → ∀ D, + (actualPairLaw j (e D):Measure (CircleX×CircleX)) (Prod.fst ⁻¹' A) ≤ ε ∧ + (actualPairLaw j (e D):Measure (CircleX×CircleX)) (Prod.snd ⁻¹' A) ≤ ε := by + have hf := finiteMeasure_sqrt_uc volume (fun D => (actualPairLaw j (e D):Measure (CircleX×CircleX))) Prod.fst measurable_fst marginalConstant_pos + (by + intro D A hA + change (Measure.map (fun ω => (firstEndpoint ω,actualSystem.endpoint (e D) ω)) (actualSystem.probability (stageTagged j)) (Prod.fst ⁻¹' A)).toReal ≤ _ + rw [Measure.map_apply (firstEndpoint_measurable.prodMk (actualSystem.measurable_endpoint _)) (hA.preimage measurable_fst)] + exact actual_hybrid_bound j (fun _ => false) A hA) + have hs := finiteMeasure_sqrt_uc volume (fun D => (actualPairLaw j (e D):Measure (CircleX×CircleX))) Prod.snd measurable_snd marginalConstant_pos + (by + intro D A hA + change (Measure.map (fun ω => (firstEndpoint ω,actualSystem.endpoint (e D) ω)) (actualSystem.probability (stageTagged j)) (Prod.snd ⁻¹' A)).toReal ≤ _ + rw [Measure.map_apply (firstEndpoint_measurable.prodMk (actualSystem.measurable_endpoint _)) (hA.preimage measurable_snd)] + exact actual_hybrid_bound j (e D) A hA) + intro ε hε + obtain ⟨δ,hδ,hf⟩ := hf ε hε + obtain ⟨η,hη,hs⟩ := hs ε hε + refine ⟨min δ η,ne_of_gt (lt_min (pos_iff_ne_zero.mpr hδ) (pos_iff_ne_zero.mpr hη)),?_⟩ + intro A hA D + exact ⟨hf A (lt_of_lt_of_le hA (min_le_left _ _)) D,hs A (lt_of_lt_of_le hA (min_le_right _ _)) D⟩ + +lemma actualPairLaw_tendsto (j : ℕ) : Tendsto (fun D => actualPairLaw j (hybridChoice D)) atTop (𝓝 (actualPairLaw j (fun _ => true))) := by + apply FiniteMeasure.tendsto_iff_forall_integral_tendsto.mpr + intro φ + have he (e : ℕ → Bool) : (∫ z,φ z ∂(actualPairLaw j e:Measure (CircleX×CircleX)))= + ∫ ω,φ (firstEndpoint ω,actualSystem.endpoint e ω) ∂actualSystem.probability (stageTagged j) := + integral_map (firstEndpoint_measurable.prodMk (actualSystem.measurable_endpoint e)).aemeasurable φ.continuous.measurable.aestronglyMeasurable + simp_rw [he] + apply tendsto_integral_of_dominated_convergence (fun _ => ‖φ‖) + · intro D; exact (φ.continuous.measurable.comp (firstEndpoint_measurable.prodMk (hybridEndpoint_measurable D))).aestronglyMeasurable + · exact integrable_const _ + · intro D; exact ae_of_all _ (fun ω => φ.norm_coe_le_norm _) + · exact ae_of_all _ (fun ω => (φ.continuous.tendsto _).comp (tendsto_const_nhds.prodMk_nhds (actual_hybrid_tendsto ω))) + +lemma actual_pair_identity (P : ModelProjectionField) (j : ℕ) : + ∀ᵐ ω ∂actualSystem.probability (stageTagged j), + (1-P.p (lastEndpoint ω))*cappedDiagonal modelF 1 (firstEndpoint ω) (lastEndpoint ω)*P.p (firstEndpoint ω)=0 := by + have hg (D : ℕ) : ∀ᵐ z ∂(actualPairLaw j (hybridChoice D):Measure (CircleX×CircleX)), + (1-P.p z.2)*cappedDiagonal modelF 1 z.1 z.2*P.p z.1=0 := by + have hm : MeasurableSet {z : CircleX×CircleX | (1-P.p z.2)*cappedDiagonal modelF 1 z.1 z.2*P.p z.1=0} := by + convert measurableSet_cappedPairRelation P.p P.measurable modelF modelF_measurable 1 using 1 + ext z; exact (cappedPairRelation_iff P.p modelF 1 z.1 z.2).symm + exact (ae_map_iff (firstEndpoint_measurable.prodMk (hybridEndpoint_measurable D)).aemeasurable hm).mpr (ae_hybrid_pair P j D) + have hh := capped_pair_identity_transfer (μ := volume) (νs := fun D => actualPairLaw j (hybridChoice D)) + P.p P.norm_le P.measurable modelF modelF_measurable modelF_pos 1 (actualPairLaw_tendsto j) hg (actualPairLaw_uc j hybridChoice) + exact ae_of_ae_map (firstEndpoint_measurable.prodMk lastEndpoint_measurable).aemeasurable hh +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/BorelTransport.lean b/lean/OAI/Analysis/RotationWeights/BorelTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..88f7cf0ecc57c4380449a6a62e5459bdae107b0b --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/BorelTransport.lean @@ -0,0 +1,140 @@ +import OAI.Analysis.RotationWeights.Transport + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace + +open Filter Set +open scoped Topology + +def fractionB (a : CircleX → ℝ) (ha : Measurable a) (hp : ∀ x,0 ne_of_gt (fractionB_pos a ha hp x))) + (realPi_injective _ c (fun x => ne_of_gt (fractionC_pos a ha hp x))) + (realPi_selfAdjoint _ b) (realPi_selfAdjoint _ c) (realPi_commute _ b c) + (realPi_fiberCommutant θ b) (realPi_fiberCommutant θ c) + (realCutoffRange (θ:CircleX) b) (realCutoffRange (θ:CircleX) c) + (fun n B hB => by rw [realCutoffRange_projection]; exact realPi_fiberCommutant θ _ B hB) + (fun n B hB => by rw [realCutoffRange_projection]; exact realPi_fiberCommutant θ _ B hB) + (realCutoffRange_le _ b) (realCutoffRange_le _ c) + (realCutoffRange_tendsto _ b (fractionB_pos a ha hp) fiberVacuum) + (realCutoffRange_tendsto _ c (fractionC_pos a ha hp) fiberVacuum) + P (by simpa only [hP] using hpc) hP0 hP1 + (fiberShiftL2 1*realPi (θ:CircleX) f) (fiberShiftL2 1*realPi (θ:CircleX) F) _ hTP hrel.1 hrel.2 + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/BorelWeights.lean b/lean/OAI/Analysis/RotationWeights/BorelWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ee7ffe52f5ed67b809770550da6b495958a280f --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/BorelWeights.lean @@ -0,0 +1,226 @@ +import OAI.Analysis.RotationWeights.FunctionalCalculus + +namespace OAI + +noncomputable section + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace + +namespace ContinuousCircleWeight + +section +open Set Filter +open scoped Topology + +structure RealBorel where + f : CircleX → ℝ + measurable : Measurable f + bound : ℝ≥0 + norm_le : ∀ x,‖f x‖≤bound +instance : CoeFun RealBorel (fun _ => CircleX → ℝ) := ⟨RealBorel.f⟩ +namespace RealBorel +def const (c : ℝ) : RealBorel := ⟨fun _ => c,measurable_const,⟨|c|,abs_nonneg _⟩,by intro x; exact le_refl _⟩ +def add (g h : RealBorel) : RealBorel := + ⟨fun x => g x+h x,g.measurable.add h.measurable,g.bound+h.bound, + fun x => (norm_add_le _ _).trans (add_le_add (g.norm_le x) (h.norm_le x))⟩ +def mul (g h : RealBorel) : RealBorel := + ⟨fun x => g x*h x,g.measurable.mul h.measurable,g.bound*h.bound, + fun x => (norm_mul _ _).le.trans (mul_le_mul (g.norm_le x) (h.norm_le x) (norm_nonneg _) g.bound.property)⟩ +def shift (θ : CircleX) (g : RealBorel) : RealBorel := + ⟨fun x => g (x+θ),g.measurable.comp (measurable_id.add_const θ),g.bound,fun x => g.norm_le (x+θ)⟩ +def ofContinuous (g : C(CircleX,ℝ)) : RealBorel := + ⟨g,g.continuous.measurable,⟨‖g‖,norm_nonneg _⟩,g.norm_coe_le_norm⟩ +end RealBorel + +def realPi (θ : CircleX) (g : RealBorel) : CircleFiberOperator := + boundedPi θ (fun x => (g x:ℂ)) (Complex.measurable_ofReal.comp g.measurable) g.bound + (fun x => by simpa using g.norm_le x) +def realPiField (θ : CircleX) (g : RealBorel) (x : CircleX) : FiberOperator := + boundedPiField θ (fun x => (g x:ℂ)) g.bound (fun x => by simpa using g.norm_le x) x +@[simp] lemma realPiField_apply (θ : CircleX) (g : RealBorel) (x : CircleX) (u : FiberHilbert) (k : ℤ) : + realPiField θ g x u k=(g (x+k•θ):ℂ)*u k := rfl +lemma realPiField_bound (θ : CircleX) (g : RealBorel) (x : CircleX) : ‖realPiField θ g x‖≤g.bound := + boundedPiField_bound _ _ _ _ _ +lemma realPi_coe (θ : CircleX) (g : RealBorel) (u : CircleFiberL2) : + realPi θ g u =ᵐ[AddCircle.haarAddCircle] fun x => realPiField θ g x (u x) := + boundedPi_coe _ _ _ _ _ _ +lemma realPi_norm_le (θ : CircleX) (g : RealBorel) : ‖realPi θ g‖≤g.bound := boundedPi_norm_le _ _ _ _ _ +lemma realPi_congr (θ : CircleX) (g h : RealBorel) (he : (fun x => g x)=ᵐ[AddCircle.haarAddCircle] (fun x => h x)) : + realPi θ g=realPi θ h := + boundedPi_congr θ _ _ _ _ _ _ _ _ (he.mono (fun _x hx => congrArg Complex.ofReal hx)) +lemma realPi_continuous (θ : CircleX) (g : C(CircleX,ℝ)) : + realPi θ (RealBorel.ofContinuous g)=continuousPi θ (complexCircleMap g) := by + apply (boundedPi_congr θ _ (complexCircleMap g) _ _ _ _ _ _ (Eventually.of_forall (fun _ => rfl))).trans + exact boundedPi_eq_continuousPi θ (complexCircleMap g) (RealBorel.ofContinuous g).bound (fun x => by simpa [complexCircleMap,RealBorel.ofContinuous] using (RealBorel.ofContinuous g).norm_le x) +lemma realPi_add (θ : CircleX) (g h : RealBorel) : realPi θ (g.add h)=realPi θ g+realPi θ h := by + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [realPi_coe θ (g.add h) u,realPi_coe θ g u,realPi_coe θ h u,Lp.coeFn_add (realPi θ g u) (realPi θ h u)] with x h1 h2 h3 h4 + change (realPi θ (g.add h) u) x=(realPi θ g u+realPi θ h u) x + rw [h1,h4] + ext k + simp only [Pi.add_apply,h2,h3,realPiField_apply,RealBorel.add,lp.coeFn_add,Complex.ofReal_add] + ring +lemma realPi_mul (θ : CircleX) (g h : RealBorel) : realPi θ (g.mul h)=realPi θ g*realPi θ h := by + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [realPi_coe θ (g.mul h) u,realPi_coe θ h u,realPi_coe θ g (realPi θ h u)] with x h1 h2 h3 + change (realPi θ (g.mul h) u) x=(realPi θ g (realPi θ h u)) x + rw [h1,h3,h2] + ext k + simp only [realPiField_apply,RealBorel.mul,Complex.ofReal_mul,mul_assoc] +lemma realPi_one (θ : CircleX) : realPi θ (RealBorel.const 1)=1 := by + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [realPi_coe θ (RealBorel.const 1) u] with x hx + rw [hx] + ext k + simp only [realPiField_apply,RealBorel.const,Complex.ofReal_one,one_mul] + rfl +lemma realPi_commute (θ : CircleX) (g h : RealBorel) : Commute (realPi θ g) (realPi θ h) := by + change _*_= _*_ + rw [←realPi_mul,←realPi_mul] + apply realPi_congr + exact Eventually.of_forall (fun x => mul_comm _ _) +lemma realPiField_symmetric (θ : CircleX) (g : RealBorel) (x : CircleX) + (u v : FiberHilbert) : inner ℂ (realPiField θ g x u) v=inner ℂ u (realPiField θ g x v) := by + simp only [lp.inner_eq_tsum] + apply tsum_congr + intro k + simp only [realPiField_apply,RCLike.inner_apply,map_mul,Complex.conj_ofReal] + ring +lemma realPi_selfAdjoint (θ : CircleX) (g : RealBorel) : IsSelfAdjoint (realPi θ g) := by + rw [ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric] + intro u v + simp only [L2.inner_def] + apply integral_congr_ae + filter_upwards [realPi_coe θ g u,realPi_coe θ g v] with x hu hv + change inner ℂ ((realPi θ g u) x) (v x)=inner ℂ (u x) ((realPi θ g v) x) + rw [hu,hv] + exact realPiField_symmetric θ g x (u x) (v x) +lemma realPi_commutes (θ : CircleX) (B : CircleFiberOperator) + (hB : ∀ f : C(CircleX,ℝ),Commute (continuousPi θ (complexCircleMap f)) B) (g : RealBorel) : + Commute (realPi θ g) B := commute_boundedPi_real _ _ hB _ g.measurable _ g.norm_le +lemma realPi_injective (θ : CircleX) (g : RealBorel) (hg : ∀ x,g x≠0) : Function.Injective (realPi θ g) := by + apply (injective_iff_map_eq_zero (realPi θ g)).mpr + intro u hu + apply Lp.ext + filter_upwards [realPi_coe θ g u,Lp.coeFn_zero FiberHilbert 2 AddCircle.haarAddCircle] with x hx hz + rw [hu,hz] at hx + rw [hz] + ext k + have h := congrArg (fun v : FiberHilbert => v k) hx + change (0:ℂ)=(g (x+k•θ):ℂ)*u x k at h + exact (mul_eq_zero.mp h.symm).resolve_left (Complex.ofReal_ne_zero.mpr (hg _)) + +lemma realPi_shift (θ : CircleX) (g : RealBorel) : + realPi θ g*fiberShiftL2 1 = fiberShiftL2 1*realPi θ (g.shift θ) := by + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [realPi_coe θ g (fiberShiftL2 1 u),fiberShiftL2_coe 1 u, + realPi_coe θ (g.shift θ) u,fiberShiftL2_coe 1 (realPi θ (g.shift θ) u)] with x h1 h2 h3 h4 + change (realPi θ g (fiberShiftL2 1 u)) x=(fiberShiftL2 1 (realPi θ (g.shift θ) u)) x + rw [h1,h2,h4,h3] + ext k + simp only [realPiField_apply,fiberShift_apply,RealBorel.shift] + congr 3 + rw [sub_zsmul,one_zsmul] + abel +end + +open Set Filter +open scoped Topology + +def realCutoff (g : RealBorel) (n : ℕ) : RealBorel where + f x := if (1:ℝ)/(n+1) ≤ g x then 1 else 0 + measurable := Measurable.ite (measurableSet_le measurable_const g.measurable) measurable_const measurable_const + bound := 1 + norm_le x := by split_ifs <;> norm_num + +def realCutoffInv (g : RealBorel) (n : ℕ) : RealBorel where + f x := if (1:ℝ)/(n+1) ≤ g x then (g x)⁻¹ else 0 + measurable := Measurable.ite (measurableSet_le measurable_const g.measurable) g.measurable.inv measurable_const + bound := n+1 + norm_le x := by + split_ifs with h + · have hn : (0:ℝ) by change (if _ then (1:ℝ) else 0)*(if _ then 1 else 0)=(if _ then 1 else 0); split_ifs <;> norm_num) + +lemma realCutoff_mul_inv (θ : CircleX) (g : RealBorel) (n : ℕ) : + realPi θ g * realPi θ (realCutoffInv g n) = realPi θ (realCutoff g n) := by + rw [←realPi_mul] + apply realPi_congr + apply Eventually.of_forall + intro x + change g x*(if (1:ℝ)/(n+1)≤g x then (g x)⁻¹ else 0)=(if (1:ℝ)/(n+1)≤g x then 1 else 0) + split_ifs with h + · apply mul_inv_cancel₀ + exact ne_of_gt ((one_div_pos.mpr (by positivity : (0:ℝ) g n x) atTop (𝓝 (h x))) + (u : CircleFiberL2) : Tendsto (fun n => realPi θ (g n) u) atTop (𝓝 (realPi θ h u)) := by + have hg' (n : ℕ) (x : CircleX) : ‖(g n x:ℂ)‖≤C := by simpa using hg n x + have hh' (x : CircleX) : ‖(h x:ℂ)‖≤C := by simpa using hh x + have he (f : RealBorel) (hf : ∀ x,‖(f x:ℂ)‖≤C) : + boundedPi θ (fun x => (f x:ℂ)) (Complex.measurable_ofReal.comp f.measurable) C hf=realPi θ f := + boundedPi_congr θ _ _ _ _ _ _ _ _ (EventuallyEq.rfl) + have hhlim := boundedPi_tendsto θ (fun n x => (g n x:ℂ)) (fun x => (h x:ℂ)) + (fun n => Complex.measurable_ofReal.comp (g n).measurable) + (Complex.measurable_ofReal.comp h.measurable) C hg' hh' + (hl.mono (fun x hx => Complex.continuous_ofReal.continuousAt.tendsto.comp hx)) u + simpa only [he] using hhlim + +lemma realCutoffRange_tendsto (θ : CircleX) (g : RealBorel) (hg : ∀ x,0 (realCutoffRange θ g n).starProjection u) atTop (𝓝 u) := by + simp_rw [realCutoffRange_projection] + have hh := realPi_tendsto θ (realCutoff g) (RealBorel.const 1) 1 + (fun n x => (realCutoff g n).norm_le x) (fun _ => by norm_num [RealBorel.const]) (Eventually.of_forall (fun x => by + have ht : Tendsto (fun n : ℕ => (1:ℝ)/(n+1)) atTop (𝓝 0) := tendsto_one_div_add_atTop_nhds_zero_nat + have hev : ∀ᶠ n : ℕ in atTop,(1:ℝ)/(n+1)≤g x := (ht.eventually_le_const (hg x)).mono (fun _ hn => hn) + apply tendsto_const_nhds.congr' + filter_upwards [hev] with n hn + exact (ite_eq_left hn).symm)) u + simpa only [realPi_one,one_apply_eq_self] using hh +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Concentration.lean b/lean/OAI/Analysis/RotationWeights/Concentration.lean new file mode 100644 index 0000000000000000000000000000000000000000..25202b72e1195617d7e2e5af63a87a8d075b35bb --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Concentration.lean @@ -0,0 +1,286 @@ +import OAI.Analysis.RotationWeights.Rounding + +namespace OAI + +noncomputable section + +namespace CircleConcentration + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators + +section +open Set Filter MeasureTheory +open scoped Topology ENNReal +abbrev X := AddCircle (1:ℝ) +def orbitMin (θ : X) (j : ℕ) (x : X) : ℝ := + (Finset.range (j+1)).inf' (by simp) (fun b => dist (x+b • θ) 0) +lemma orbitMin_continuous (θ : X) (j : ℕ) : Continuous (orbitMin θ j) := by + unfold orbitMin + exact (Continuous.finset_inf'_apply (f := fun b : ℕ => fun x : X => dist (x+b • θ) 0) (by simp : (Finset.range (j+1)).Nonempty) (fun _ _ => by fun_prop)) +lemma orbitMin_nonneg (θ : X) (j : ℕ) (x : X) : 0 ≤ orbitMin θ j x := + Finset.le_inf' _ _ (fun _ _ => dist_nonneg) +lemma orbitMin_le (θ : X) (j b : ℕ) (hb : b≤j) (x : X) : orbitMin θ j x ≤ dist (x+b • θ) 0 := + Finset.inf'_le _ (Finset.mem_range.mpr (by omega)) +lemma orbitMin_max (θ : X) (j : ℕ) : ∃ x : X, ∀ y, orbitMin θ j y ≤ orbitMin θ j x := by + obtain ⟨x,_,hx⟩ := isCompact_univ.exists_isMaxOn (Set.univ_nonempty : (Set.univ:Set X).Nonempty) (orbitMin_continuous θ j).continuousOn + exact ⟨x,fun y => hx (Set.mem_univ y)⟩ +def orbitRadius (θ : X) (j : ℕ) : ℝ := orbitMin θ j (Classical.choose (orbitMin_max θ j)) +lemma orbitMin_le_radius (θ : X) (j : ℕ) (x : X) : orbitMin θ j x ≤ orbitRadius θ j := + Classical.choose_spec (orbitMin_max θ j) x +lemma orbitRadius_nonneg (θ : X) (j : ℕ) : 0 ≤ orbitRadius θ j := orbitMin_nonneg _ _ _ +lemma finite_orbit_cover (θ : X) (hd : DenseRange (fun n : ℕ => n • θ)) {ε : ℝ} (hε : 0<ε) : + ∃ N : ℕ, ∀ x : X, ∃ b≤N, dist (x+b • θ) 0<ε := by + have hx : ∀ x : X, ∃ b : ℕ, dist (x+b • θ) 0<ε := by + intro x + obtain ⟨b,hb⟩ := hd.exists_dist_lt (-x) hε + refine ⟨b,?_⟩ + rw [dist_eq_norm] at hb ⊢ + rw [show -x-b • θ=-(x+b • θ) by abel,norm_neg] at hb + simpa using hb + obtain ⟨s,hs⟩ := isCompact_univ.elim_finite_subcover (fun b : ℕ => {x : X | dist (x+b • θ) 0<ε}) + (fun _ => isOpen_lt (by fun_prop) continuous_const) (by simpa only [subset_def,mem_univ,mem_iUnion,mem_ofPred_eq,true_implies] using hx) + refine ⟨s.sup id,fun x => ?_⟩ + obtain ⟨b,hb,hx⟩ := Set.mem_iUnion₂.mp (hs (Set.mem_univ x)) + exact ⟨b,Finset.le_sup (f:=id) hb,hx⟩ +lemma orbitRadius_tendsto (θ : X) (hd : DenseRange (fun n : ℕ => n • θ)) : Tendsto (orbitRadius θ) atTop (𝓝 0) := by + apply tendsto_order.mpr + constructor + · intro a ha; exact Eventually.of_forall (fun j => ha.trans_le (orbitRadius_nonneg θ j)) + · intro ε hε + obtain ⟨N,hN⟩ := finite_orbit_cover θ hd hε + filter_upwards [eventually_ge_atTop N] with j hj + obtain ⟨b,hb,hx⟩ := hN (Classical.choose (orbitMin_max θ j)) + exact (orbitMin_le θ j b (hb.trans hj) _).trans_lt hx + +def supportRadius (θ : X) (j : ℕ) : ℝ := orbitRadius θ j+1/((j:ℝ)+1) +lemma orbitRadius_lt_supportRadius (θ : X) (j : ℕ) : orbitRadius θ j n • θ)) : Tendsto (supportRadius θ) atTop (𝓝 0) := by + change Tendsto (fun j : ℕ => orbitRadius θ j+1/((j:ℝ)+1)) atTop (𝓝 0) + simpa only [add_zero] using (orbitRadius_tendsto θ hd).add (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℝ)) +def bump (θ : X) (j : ℕ) (x : X) : ℝ := max 0 (1-dist x 0/supportRadius θ j) +lemma bump_continuous (θ : X) (j : ℕ) : Continuous (bump θ j) := by unfold bump; fun_prop +lemma bump_nonneg (θ : X) (j : ℕ) (x : X) : 0≤bump θ j x := le_max_left _ _ +lemma bump_le_one (θ : X) (j : ℕ) (x : X) : bump θ j x≤1 := by + apply max_le (by norm_num) + have := div_nonneg (dist_nonneg (x:=x) (y:=0)) (supportRadius_pos θ j).le + linarith +lemma bump_zero (θ : X) (j : ℕ) : bump θ j 0=1 := by simp [bump] +lemma bump_eq_zero (θ : X) (j : ℕ) (x : X) (hx : supportRadius θ j ≤ dist x 0) : bump θ j x=0 := by + apply max_eq_left + have hh : (1:ℝ)≤dist x 0/supportRadius θ j := (le_div_iff₀ (supportRadius_pos θ j)).mpr (by simpa using hx) + linarith +lemma bump_pos (θ : X) (j : ℕ) (x : X) (hx : dist x 0 bump_nonneg _ _ _) + obtain ⟨b,hb,he⟩ := Finset.exists_mem_eq_inf' (by simp : (Finset.range (j+1)).Nonempty) (fun b => dist (x+b • θ) 0) + refine ⟨b,hb,bump_pos θ j _ ?_⟩ + rw [←he] + exact (orbitMin_le_radius θ j x).trans_lt (orbitRadius_lt_supportRadius θ j) +lemma partitionDenom_le (θ : X) (j : ℕ) (x : X) : partitionDenom θ j x ≤ (j:ℝ)+1 := by + calc + _ ≤ ∑ _b∈Finset.range (j+1), (1:ℝ) := Finset.sum_le_sum (fun b _=>bump_le_one θ j _) + _ = _ := by simp + +def partition (θ : X) (j b : ℕ) (x : X) : ℝ := bump θ j (x+b • θ)/partitionDenom θ j x +lemma partition_continuous (θ : X) (j b : ℕ) : Continuous (partition θ j b) := + ((bump_continuous θ j).comp (continuous_id.add continuous_const)).div (partitionDenom_continuous θ j) (fun x => ne_of_gt (partitionDenom_pos θ j x)) +lemma partition_nonneg (θ : X) (j b : ℕ) (x : X) : 0≤partition θ j b x := div_nonneg (bump_nonneg _ _ _) (partitionDenom_pos _ _ _).le +lemma partition_sum (θ : X) (j : ℕ) (x : X) : ∑ b∈Finset.range (j+1),partition θ j b x=1 := by + simp only [partition,←Finset.sum_div] + exact div_self (ne_of_gt (partitionDenom_pos θ j x)) +lemma partition_zero_lower (θ : X) (j : ℕ) : 1/((j:ℝ)+1)≤partition θ j 0 0 := by + simp only [partition,zero_nsmul,add_zero,bump_zero] + exact one_div_le_one_div_of_le (partitionDenom_pos θ j 0) (partitionDenom_le θ j 0) +end + +open Set Filter MeasureTheory +open scoped Topology ENNReal + +def moveTerm (θ : X) (j b : ℕ) (h : X → ℝ) (x : X) : ℝ := partition θ j b x*h x +def movedDrop (θ : X) (j : ℕ) (h : X → ℝ) (x : X) : ℝ := + ∑ b∈Finset.range (j+1),moveTerm θ j b h (x-b • θ) +def moveCorrection (θ : X) (j : ℕ) (h : X → ℝ) (x : X) : ℝ := + -(∑ b∈Finset.range (j+1), ∑ r∈Finset.range b,moveTerm θ j b h (x-(r+1) • θ)) +lemma moveTerm_continuous (θ : X) (j b : ℕ) {h : X → ℝ} (hc : Continuous h) : Continuous (moveTerm θ j b h) := + (partition_continuous θ j b).mul hc +lemma movedDrop_continuous (θ : X) (j : ℕ) {h : X → ℝ} (hc : Continuous h) : Continuous (movedDrop θ j h) := by + apply continuous_finsetSum + intro b _ + exact (moveTerm_continuous θ j b hc).comp (continuous_id.sub continuous_const) +lemma moveCorrection_continuous (θ : X) (j : ℕ) {h : X → ℝ} (hc : Continuous h) : Continuous (moveCorrection θ j h) := by + apply Continuous.neg + apply continuous_finsetSum + intro b _ + apply continuous_finsetSum + intro r _ + exact (moveTerm_continuous θ j b hc).comp (continuous_id.sub continuous_const) +lemma moveTerm_nonneg (θ : X) (j b : ℕ) {h : X → ℝ} (hh : ∀ x,0≤h x) (x : X) : 0≤ moveTerm θ j b h x := + mul_nonneg (partition_nonneg θ j b x) (hh x) +lemma movedDrop_nonneg (θ : X) (j : ℕ) {h : X → ℝ} (hh : ∀ x,0≤h x) (x : X) : 0≤ movedDrop θ j h x := + Finset.sum_nonneg (fun _ _ => moveTerm_nonneg _ _ _ hh _) +lemma movedDrop_zero_off (θ : X) (j : ℕ) (h : X → ℝ) (x : X) (hx : supportRadius θ j ≤ dist x 0) : movedDrop θ j h x=0 := by + apply Finset.sum_eq_zero + intro b _ + simp only [moveTerm,partition,sub_add_cancel,bump_eq_zero θ j x hx,zero_div,zero_mul] +lemma movedDrop_zero_lower (θ : X) (j : ℕ) {h : X → ℝ} (hh : ∀ x,0≤h x) : h 0/((j:ℝ)+1)≤ movedDrop θ j h 0 := by + calc + h 0/((j:ℝ)+1) = (1/((j:ℝ)+1))*h 0 := by ring + _ ≤ partition θ j 0 0*h 0 := mul_le_mul_of_nonneg_right (partition_zero_lower θ j) (hh 0) + _ = moveTerm θ j 0 h (0-0 • θ) := by simp [moveTerm] + _ ≤ movedDrop θ j h 0 := Finset.single_le_sum (f := fun b => moveTerm θ j b h (0-b • θ)) (fun _ _ => moveTerm_nonneg θ j _ hh _) (by simp : 0∈Finset.range (j+1)) +lemma moveTerm_sum (θ : X) (j : ℕ) (h : X → ℝ) (x : X) : ∑ b∈Finset.range (j+1),moveTerm θ j b h x=h x := by + simp only [moveTerm,←Finset.sum_mul,partition_sum,one_mul] +lemma moveCorrection_coboundary (θ : X) (j : ℕ) (h : X → ℝ) (x : X) : + movedDrop θ j h x-h x=moveCorrection θ j h (x+θ)-moveCorrection θ j h x := by + have he (r : ℕ) : x+θ-(r+1) • θ=x-r • θ := by rw [add_nsmul,one_nsmul]; abel + have ht (b : ℕ) : + (∑ r∈Finset.range b,moveTerm θ j b h (x-r • θ))- + (∑ r∈Finset.range b,moveTerm θ j b h (x-(r+1) • θ))=moveTerm θ j b h x-moveTerm θ j b h (x-b • θ) := by + rw [←Finset.sum_sub_distrib] + simpa using Finset.sum_range_sub' (fun r => moveTerm θ j b h (x-r • θ)) b + unfold movedDrop moveCorrection + simp_rw [he] + rw [←moveTerm_sum θ j h x,←Finset.sum_sub_distrib] + calc + _ = ∑ b∈Finset.range (j+1),-((∑ r∈Finset.range b,moveTerm θ j b h (x-r • θ))-(∑ r∈Finset.range b,moveTerm θ j b h (x-(r+1) • θ))) := by + apply Finset.sum_congr rfl + intro b _ + rw [ht] + ring + _ = _ := by rw [Finset.sum_neg_distrib,Finset.sum_sub_distrib]; ring +lemma measurePreserving_sub (a : X) : MeasurePreserving (fun x : X => x-a) volume volume := by + simpa only [sub_eq_add_neg] using measurePreserving_add_right (volume : Measure X) (-a) +lemma integral_sub_circle (a : X) (f : X → ℝ) : (∫ x : X, f (x-a))=∫ x : X,f x := by + have he : MeasurableEmbedding (fun x : X => x-a) := by + convert (Homeomorph.addRight (-a)).isClosedEmbedding.measurableEmbedding using 1 + ext x; simp [sub_eq_add_neg] + exact (measurePreserving_sub a).integral_comp he f +lemma moveTerm_integrable (θ : X) (j b : ℕ) {h : X → ℝ} (hc : Continuous h) : + Integrable (moveTerm θ j b h) (volume : Measure X) := + (moveTerm_continuous θ j b hc).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) +lemma movedTerm_integrable (θ : X) (j b : ℕ) {h : X → ℝ} (hc : Continuous h) : + Integrable (fun x : X => moveTerm θ j b h (x-b • θ)) volume := + ((moveTerm_continuous θ j b hc).comp (continuous_id.sub continuous_const)).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) +lemma movedDrop_integral (θ : X) (j : ℕ) {h : X → ℝ} (hc : Continuous h) : + (∫ x : X,movedDrop θ j h x)=∫ x : X,h x := by + change (∫ x : X, ∑ b ∈ Finset.range (j+1), moveTerm θ j b h (x-b • θ))= _ + rw [integral_finsetSum _ (fun b _ => movedTerm_integrable θ j b hc)] + calc + _ = ∑ b ∈ Finset.range (j+1), ∫ x : X, moveTerm θ j b h x := + Finset.sum_congr rfl (fun b _ => integral_sub_circle (b • θ) (moveTerm θ j b h)) + _ = ∫ x : X, ∑ b ∈ Finset.range (j+1), moveTerm θ j b h x := + (integral_finsetSum _ (fun b _ => moveTerm_integrable θ j b hc)).symm + _ = ∫ x : X, h x := integral_congr_ae (Eventually.of_forall (moveTerm_sum θ j h)) +lemma moveCorrection_support (θ : X) (j : ℕ) (h : X → ℝ) : + {x | moveCorrection θ j h x≠0} ⊆ ⋃ r∈Finset.range j,{x : X | h (x-(r+1) • θ)≠0} := by + intro x hx + by_contra hh + have hh' : ∀ r x-(r+1) • θ) volume volume := by + simpa only [sub_eq_add_neg] using measurePreserving_add_right (volume:Measure X) (-((r+1) • θ)) + change volume ((fun x : X => x-(r+1) • θ) ⁻¹' {x : X | h x≠0}) = _ + exact hσ.measure_preimage (hm (measurableSet_singleton 0).compl).nullMeasurableSet + simp only [hs,Finset.sum_const,Finset.card_range,nsmul_eq_mul,le_refl] + + +end CircleConcentration + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/ConditionalBounds.lean b/lean/OAI/Analysis/RotationWeights/ConditionalBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f75b89bac8d920c46a1f92a34fb1b9560038740 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/ConditionalBounds.lean @@ -0,0 +1,399 @@ +import OAI.Analysis.RotationWeights.EndpointMoments + +namespace OAI + +noncomputable section + +universe uD uΩ uι uT uX uY + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff + +open MeasureTheory Set +open scoped ENNReal BigOperators +namespace CircleCoupling + +lemma measure_le_of_singletons {D : Type uD} [MeasurableSpace D] [Countable D] + [MeasurableSingletonClass D] {μ ν : Measure D} + (h : ∀ d, μ {d} ≤ ν {d}) : μ ≤ ν := by + rw [← Measure.sum_smul_dirac μ, ← Measure.sum_smul_dirac ν] + apply Measure.le_iff.mpr + intro s hs + simp only [Measure.sum_apply _ hs, Measure.smul_apply, smul_eq_mul] + exact ENNReal.tsum_le_tsum (fun d => mul_le_mul' (h d) le_rfl) + +lemma map_restrict_le_of_fibers {Ω : Type uΩ} {D : Type uD} [MeasurableSpace Ω] + [MeasurableSpace D] [Countable D] [MeasurableSingletonClass D] + (μ : Measure Ω) (f : Ω → D) (hf : Measurable f) (H : Set Ω) + (δ : ℝ≥0∞) + (h : ∀ d, μ ((f ⁻¹' {d}) ∩ H) ≤ δ * μ (f ⁻¹' {d})) : + Measure.map f (μ.restrict H) ≤ δ • Measure.map f μ := by + apply measure_le_of_singletons + intro d + simpa only [Measure.map_apply hf (measurableSet_singleton d), + Measure.restrict_apply (hf (measurableSet_singleton d)), + Measure.smul_apply, smul_eq_mul] using h d + +lemma independent_fiber_failures {ι : Type uι} [Fintype ι] [DecidableEq ι] + {Ω : ι → Type uΩ} {D : ι → Type uD} [∀ i, MeasurableSpace (Ω i)] [∀ i, MeasurableSpace (D i)] + (μ : ∀ i, Measure (Ω i)) [∀ i, SigmaFinite (μ i)] + (f : ∀ i, Ω i → D i) (d : ∀ i, D i) (H : ∀ i, Set (Ω i)) + (A : Finset ι) (c : ι → ℝ≥0∞) + (h : ∀ i ∈ A, μ i ((f i ⁻¹' {d i}) ∩ H i) ≤ c i * μ i (f i ⁻¹' {d i})) : + (Measure.pi μ) {ω | (∀ i, f i (ω i) = d i) ∧ ∀ i ∈ A, ω i ∈ H i} ≤ + (∏ i ∈ A, c i) * (Measure.pi μ) {ω | ∀ i, f i (ω i) = d i} := by + classical + have hset : {ω | (∀ i, f i (ω i) = d i) ∧ ∀ i ∈ A, ω i ∈ H i} = + univ.pi (fun i => (f i ⁻¹' {d i}) ∩ if i ∈ A then H i else univ) := by + ext ω + simp only [mem_ofPred_eq, Set.mem_pi, mem_univ, forall_const, mem_inter_iff, + mem_preimage, mem_singleton_iff] + constructor + · rintro ⟨hf,hH⟩ i + exact ⟨hf i, by split_ifs with hi; exact hH i hi; trivial⟩ + · intro hp + exact ⟨fun i => (hp i).1, fun i hi => by simpa [hi] using (hp i).2⟩ + have hset' : {ω | ∀ i, f i (ω i) = d i} = univ.pi (fun i => f i ⁻¹' {d i}) := by + ext ω + simp + rw [hset,hset',Measure.pi_pi,Measure.pi_pi] + calc + _ ≤ ∏ i, (if i ∈ A then c i else 1) * μ i (f i ⁻¹' {d i}) := by + apply Finset.prod_le_prod + intro i _ + by_cases hi : i ∈ A + · simpa [hi] using h i hi + · simp [hi] + _ = _ := by rw [Finset.prod_mul_distrib]; congr 1; simp + +lemma independent_selected_failures {ι : Type uι} [Fintype ι] [DecidableEq ι] + {Ω : ι → Type uΩ} {D : ι → Type uD} [∀ i, MeasurableSpace (Ω i)] [∀ i, MeasurableSpace (D i)] + [∀ i, Countable (D i)] [∀ i, MeasurableSingletonClass (D i)] + (μ : ∀ i, Measure (Ω i)) [∀ i, SigmaFinite (μ i)] + (f : ∀ i, Ω i → D i) (hf : ∀ i, Measurable (f i)) + (H : Set (∀ i, Ω i)) (bad : ∀ i, Set (Ω i)) + (A : (∀ i, D i) → Finset ι) (c : ι → ℝ≥0∞) (δ : ℝ≥0∞) + (hlocal : ∀ d i, i ∈ A d → + μ i ((f i ⁻¹' {d i}) ∩ bad i) ≤ c i * μ i (f i ⁻¹' {d i})) + (hprod : ∀ d, (∃ ω ∈ H, (fun i => f i (ω i)) = d) → (∏ i∈A d, c i) ≤ δ) + (hbad : ∀ ω ∈ H, ∀ i ∈ A (fun i => f i (ω i)), ω i ∈ bad i) : + Measure.map (fun ω i => f i (ω i)) ((Measure.pi μ).restrict H) ≤ + δ • Measure.map (fun ω i => f i (ω i)) (Measure.pi μ) := by + apply map_restrict_le_of_fibers _ _ (Measurable.of_eval (fun i => (hf i).comp (measurable_pi_apply i))) + intro d + change (Measure.pi μ) (((fun ω : ∀ i, Ω i => fun i => f i (ω i)) ⁻¹' {d}) ∩ H) ≤ + δ * (Measure.pi μ) ((fun ω : ∀ i, Ω i => fun i => f i (ω i)) ⁻¹' {d}) + by_cases hex : ∃ ω ∈ H, (fun i => f i (ω i)) = d + swap + · have hempty : ((fun ω i => f i (ω i)) ⁻¹' {d}) ∩ H = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + rintro ω ⟨he,hω⟩ + exact hex ⟨ω,hω,he⟩ + rw [hempty,measure_empty] + exact bot_le + have hs : ((fun ω i => f i (ω i)) ⁻¹' {d}) ∩ H ⊆ + {ω | (∀ i, f i (ω i) = d i) ∧ ∀ i ∈ A d, ω i ∈ bad i} := by + rintro ω ⟨hd,hω⟩ + have he : (fun i => f i (ω i)) = d := hd + exact ⟨fun i => congrFun he i, by simpa only [← he] using hbad ω hω⟩ + apply (measure_mono hs).trans + apply (independent_fiber_failures μ f d bad (A d) c (hlocal d)).trans + have hset : {ω : ∀ i, Ω i | ∀ i, f i (ω i) = d i} = (fun ω i => f i (ω i)) ⁻¹' {d} := by + ext ω + simp only [mem_ofPred_eq, mem_preimage, mem_singleton_iff, funext_iff] + rw [hset] + exact mul_le_mul' (hprod d hex) le_rfl + +lemma full_tail_domination {T : Type uT} {Ω : Type uΩ} {D : Type uD} [MeasurableSpace T] + [MeasurableSpace Ω] [MeasurableSpace D] + (ν : Measure T) (μ : Measure Ω) [SFinite μ] + (f : Ω → D) (hf : Measurable f) (H : Set (T × Ω)) (hH : MeasurableSet H) + (δ : ℝ≥0∞) + (hsection : ∀ t, Measure.map f (μ.restrict {ω | (t,ω) ∈ H}) ≤ + δ • Measure.map f μ) : + Measure.map (fun z : T × Ω => (z.1,f z.2)) ((ν.prod μ).restrict H) ≤ + δ • Measure.map (fun z : T × Ω => (z.1,f z.2)) (ν.prod μ) := by + have hF : Measurable (fun z : T × Ω => (z.1,f z.2)) := + measurable_fst.prodMk (hf.comp measurable_snd) + apply Measure.le_iff.mpr + intro s hs + rw [Measure.map_apply hF hs,Measure.restrict_apply (hF hs),Measure.smul_apply, + Measure.map_apply hF hs,Measure.prod_apply ((hF hs).inter hH), + Measure.prod_apply (hF hs)] + simp only [smul_eq_mul] + calc + _ ≤ ∫⁻ t, δ * μ ((fun ω => (t,f ω)) ⁻¹' s) ∂ν := by + apply lintegral_mono + intro t + have hst : MeasurableSet (Prod.mk t ⁻¹' s) := + (measurable_const.prodMk measurable_id) hs + have hh := hsection t (Prod.mk t ⁻¹' s) + rw [Measure.map_apply hf hst,Measure.restrict_apply (hf hst), + Measure.smul_apply,Measure.map_apply hf hst] at hh + exact hh + _ = _ := by + exact lintegral_const_mul δ (show Measurable (fun t => μ ((fun ω => (t,f ω)) ⁻¹' s)) from + measurable_measure_prodMk_left (ν := μ) (hF hs)) + + +lemma map_domination {X : Type uX} {Y : Type uY} [MeasurableSpace X] [MeasurableSpace Y] + (f : X → Y) (hf : Measurable f) {μ ν : Measure X} (δ : ℝ≥0∞) + (h : μ ≤ δ • ν) : Measure.map f μ ≤ δ • Measure.map f ν := by + rw [← Measure.map_smul _ hf.aemeasurable] + exact Measure.map_mono h hf + +lemma selected_failures_endpoint {ι : Type uι} [Fintype ι] [DecidableEq ι] + {Ω : ι → Type uΩ} {D : ι → Type uD} [∀ i, MeasurableSpace (Ω i)] [∀ i, MeasurableSpace (D i)] + [∀ i, Countable (D i)] [∀ i, MeasurableSingletonClass (D i)] + {T : Type uT} {Y : Type uY} [MeasurableSpace T] [MeasurableSpace Y] + (ν : Measure T) (μ : ∀ i, Measure (Ω i)) [∀ i, SigmaFinite (μ i)] + (f : ∀ i, Ω i → D i) (hf : ∀ i, Measurable (f i)) + (E : T × (∀ i, D i) → Y) (hE : Measurable E) + (H : Set (T × (∀ i, Ω i))) (hH : MeasurableSet H) (bad : ∀ i, Set (Ω i)) + (A : T → (∀ i, D i) → Finset ι) (c : ι → ℝ≥0∞) (δ : ℝ≥0∞) + (hlocal : ∀ t d i, i ∈ A t d → + μ i ((f i ⁻¹' {d i}) ∩ bad i) ≤ c i * μ i (f i ⁻¹' {d i})) + (hprod : ∀ t d, (∃ ω, (t,ω) ∈ H ∧ (fun i => f i (ω i)) = d) → + (∏ i ∈ A t d, c i) ≤ δ) + (hbad : ∀ t ω, (t,ω) ∈ H → ∀ i ∈ A t (fun i => f i (ω i)), ω i ∈ bad i) : + Measure.map (fun z : T × (∀ i, Ω i) => E (z.1,fun i => f i (z.2 i))) + ((ν.prod (Measure.pi μ)).restrict H) ≤ + δ • Measure.map (fun z : T × (∀ i, Ω i) => E (z.1,fun i => f i (z.2 i))) + (ν.prod (Measure.pi μ)) := by + have hf' : Measurable (fun ω : ∀ i, Ω i => fun i => f i (ω i)) := + Measurable.of_eval (fun i => (hf i).comp (measurable_pi_apply i)) + have hsection (t : T) := independent_selected_failures μ f hf {ω | (t,ω) ∈ H} + bad (A t) c δ (hlocal t) (hprod t) (hbad t) + have hdom := full_tail_domination ν (Measure.pi μ) _ hf' H hH δ hsection + have hh := map_domination E hE δ hdom + have hG : Measurable (fun z : T × (∀ i, Ω i) => (z.1,fun i => f i (z.2 i))) := + measurable_fst.prodMk (hf'.comp measurable_snd) + rw [Measure.map_map hE hG,Measure.map_map hE hG] at hh + exact hh + +lemma failure_power_exponential (ρ m : ℝ) (n : ℕ) + (hρ : 0 ≤ ρ) (hρ' : ρ ≤ 1) (hcard : m/40 ≤ (n : ℝ)) : + (ENNReal.ofReal (1-ρ/10)) ^ n ≤ ENNReal.ofReal (Real.exp (-m*ρ/400)) := by + rw [← ENNReal.ofReal_pow (by linarith : 0 ≤ 1-ρ/10)] + apply ENNReal.ofReal_le_ofReal + calc + (1-ρ/10)^n ≤ (Real.exp (-ρ/10))^n := by + apply pow_le_pow_left₀ (by linarith) + have h := Real.add_one_le_exp (-ρ/10) + linarith + _ = Real.exp ((n : ℝ)*(-ρ/10)) := (Real.exp_nat_mul _ n).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + +end CircleCoupling +open MeasureTheory Set +open scoped ENNReal +namespace CircleCoupling +lemma infinitePi_split {ι : Type uι} {Ω : ι → Type uΩ} + [∀ i, MeasurableSpace (Ω i)] (μ : ∀ i, Measure (Ω i)) + [∀ i, IsProbabilityMeasure (μ i)] (p : ι → Prop) [DecidablePred p] : + Measure.map (MeasurableEquiv.piEquivPiSubtypeProd Ω p).symm + ((Measure.infinitePi fun i : {i // p i} => μ i).prod + (Measure.infinitePi fun i : {i // ¬p i} => μ i)) = Measure.infinitePi μ := by + classical + apply Measure.eq_infinitePi + intro s t ht + rw [Measure.map_apply (by fun_prop) (.pi (Finset.countable_toSet _) fun i _ => ht i)] + have hset : (MeasurableEquiv.piEquivPiSubtypeProd Ω p).symm ⁻¹' Set.pi (s : Set ι) t = + (Set.pi ((s.subtype p) : Set {i // p i}) (fun i => t i)) ×ˢ + (Set.pi ((s.subtype (fun i => ¬p i)) : Set {i // ¬p i}) (fun i => t i)) := by + ext z + simp only [mem_preimage, Set.mem_pi, mem_prod, Finset.mem_coe, Finset.mem_subtype] + constructor + · intro hz + constructor + · rintro ⟨i,hi⟩ his + simpa [MeasurableEquiv.piEquivPiSubtypeProd, Equiv.piEquivPiSubtypeProd, hi] + using hz i his + · rintro ⟨i,hi⟩ his + simpa [MeasurableEquiv.piEquivPiSubtypeProd, Equiv.piEquivPiSubtypeProd, hi] + using hz i his + · rintro ⟨hx,hy⟩ i his + by_cases hi : p i + · simpa [MeasurableEquiv.piEquivPiSubtypeProd, Equiv.piEquivPiSubtypeProd, hi] + using hx ⟨i,hi⟩ his + · simpa [MeasurableEquiv.piEquivPiSubtypeProd, Equiv.piEquivPiSubtypeProd, hi] + using hy ⟨i,hi⟩ his + rw [hset, Measure.prod_prod, Measure.infinitePi_pi, Measure.infinitePi_pi] + · rw [Finset.prod_subtype_eq_prod_filter (fun i : ι => μ i (t i)), + Finset.prod_subtype_eq_prod_filter (fun i : ι => μ i (t i))] + exact Finset.prod_filter_mul_prod_filter_not s p (fun i => μ i (t i)) + · intro i hi; exact ht i + · intro i hi; exact ht i + +def glue {ι : Type uι} (Ω : ι → Type uΩ) (I : Finset ι) [DecidablePred (· ∈ I)] + (z : (∀ i : {i // i ∉ I}, Ω i) × (∀ i : I, Ω i)) : ∀ i, Ω i := + fun i => if hi : i ∈ I then z.2 ⟨i,hi⟩ else z.1 ⟨i,hi⟩ + +lemma measurable_glue {ι : Type uι} (Ω : ι → Type uΩ) [∀ i, MeasurableSpace (Ω i)] + (I : Finset ι) [DecidablePred (· ∈ I)] : Measurable (glue Ω I) := by + apply Measurable.of_eval + intro i + dsimp [glue] + split_ifs <;> fun_prop + +lemma map_glue {ι : Type uι} {Ω : ι → Type uΩ} [∀ i, MeasurableSpace (Ω i)] + (μ : ∀ i, Measure (Ω i)) [∀ i, IsProbabilityMeasure (μ i)] + (I : Finset ι) [DecidablePred (· ∈ I)] : + Measure.map (glue Ω I) + ((Measure.infinitePi (fun i : {i // i ∉ I} => μ i)).prod (Measure.pi (fun i : I => μ i))) = + Measure.infinitePi μ := by + classical + let e := MeasurableEquiv.piEquivPiSubtypeProd Ω (· ∈ I) + have he : glue Ω I = e.symm ∘ Prod.swap := by + funext z i + simp [glue,e,MeasurableEquiv.piEquivPiSubtypeProd,Equiv.piEquivPiSubtypeProd] + rw [he,← Measure.map_map e.symm.measurable measurable_swap,Measure.prod_swap] + rw [← Measure.infinitePi_eq_pi (fun i : I => μ i)] + exact infinitePi_split μ (· ∈ I) + +lemma observe_glue {ι : Type uι} {Ω : ι → Type uΩ} {D : ι → Type uD} (I : Finset ι) + [DecidablePred (· ∈ I)] (f : ∀ i, Ω i → D i) + (z : (∀ i : {i // i ∉ I}, Ω i) × (∀ i : I, Ω i)) : + (fun i => f i (glue Ω I z i)) = + glue D I (fun i : {i // i ∉ I} => f i (z.1 i),fun i : I => f i (z.2 i)) := by + funext i + dsimp [glue] + split_ifs <;> rfl + +lemma infinite_selected_failures {ι : Type uι} {Ω : ι → Type uΩ} {D : ι → Type uD} + [∀ i, MeasurableSpace (Ω i)] [∀ i, MeasurableSpace (D i)] + [∀ i, Countable (D i)] [∀ i, MeasurableSingletonClass (D i)] + {Y : Type uY} [MeasurableSpace Y] + (μ : ∀ i, Measure (Ω i)) [∀ i, IsProbabilityMeasure (μ i)] + (I : Finset ι) (f : ∀ i, Ω i → D i) (hf : ∀ i, Measurable (f i)) + (E : (∀ i, D i) → Y) (hE : Measurable E) + (H : Set (∀ i, Ω i)) (hH : MeasurableSet H) (bad : ∀ i : I, Set (Ω i)) + (A : (∀ i, D i) → Finset I) (c : I → ℝ≥0∞) (δ : ℝ≥0∞) + (hlocal : ∀ d i, i ∈ A d → + μ i ((f i ⁻¹' {d i}) ∩ bad i) ≤ c i * μ i (f i ⁻¹' {d i})) + (hprod : ∀ ω, ω ∈ H → (∏ i ∈ A (fun i => f i (ω i)), c i) ≤ δ) + (hbad : ∀ ω, ω ∈ H → ∀ i ∈ A (fun i => f i (ω i)), ω i ∈ bad i) : + Measure.map (fun ω => E (fun i => f i (ω i))) ((Measure.infinitePi μ).restrict H) ≤ + δ • Measure.map (fun ω => E (fun i => f i (ω i))) (Measure.infinitePi μ) := by + classical + let T := ∀ i : {i // i ∉ I}, Ω i + let ν : Measure T := Measure.infinitePi (fun i : {i // i ∉ I} => μ i) + let o : (∀ i, Ω i) → (∀ i, D i) := fun ω i => f i (ω i) + have ho : Measurable o := Measurable.of_eval (fun i => (hf i).comp (measurable_pi_apply i)) + let g : T × (∀ i : I, D i) → (∀ i, D i) := + fun z => glue D I (fun i : {i // i ∉ I} => f i (z.1 i),z.2) + have hg : Measurable g := (measurable_glue D I).comp + ((Measurable.of_eval (fun i : {i // i ∉ I} => (hf i).comp ((measurable_pi_apply i).comp measurable_fst))).prodMk measurable_snd) + have hh := selected_failures_endpoint ν (fun i : I => μ i) (fun i : I => f i) + (fun i => hf i) (E ∘ g) (hE.comp hg) ((glue Ω I) ⁻¹' H) + ((measurable_glue Ω I) hH) bad (fun t d => A (g (t,d))) c δ + (by + intro t d i hi + have hh := hlocal (g (t,d)) i hi + simpa [g,glue,i.property] using hh) + (by + intro t d hd + obtain ⟨ω,hω,hfd⟩ := hd + have hh := hprod (glue Ω I (t,ω)) hω + rw [observe_glue,hfd] at hh + exact hh) + (by + intro t ω hω i hi + have hh := hbad (glue Ω I (t,ω)) hω i + rw [observe_glue] at hh + simpa [glue,i.property] using hh hi) + have hid : (fun z : T × (∀ i : I, Ω i) => (E ∘ g) (z.1, fun i => f i (z.2 i))) = + (E ∘ o) ∘ glue Ω I := by + funext z + dsimp [Function.comp_def,o,g] + rw [observe_glue] + rw [hid,← Measure.map_map (hE.comp ho) (measurable_glue Ω I), + ← Measure.restrict_map (measurable_glue Ω I) hH, + show Measure.map (glue Ω I) (ν.prod (Measure.pi (fun i : I => μ i))) = Measure.infinitePi μ from map_glue μ I, + ← Measure.map_map (hE.comp ho) (measurable_glue Ω I), + show Measure.map (glue Ω I) (ν.prod (Measure.pi (fun i : I => μ i))) = Measure.infinitePi μ from map_glue μ I] at hh + exact hh + +end CircleCoupling +namespace CircleDigits +lemma digit_interval_weak {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) (d : Digits b) (n : ℕ) : + (d n : ℝ)/(b n : ℝ) ≤ scaledTail b d n ∧ + scaledTail b d n ≤ ((d n : ℝ)+1)/(b n : ℝ) := by + have hpos : (0:ℝ) prefixNumeral b d n) := by + induction n with + | zero => exact measurable_const + | succ n ih => + simp only [prefixNumeral] + exact (measurable_const.mul ih).add ((measurable_of_countable (fun x : Fin (b n) => x.val)).comp (measurable_pi_apply n)) +lemma measurable_scaledTail (b : ℕ → ℕ) (n : ℕ) : Measurable (fun d : Digits b => scaledTail b d n) := + (measurable_const.mul (measurable_expansion b)).sub ((measurable_of_countable (fun x : ℕ => (x:ℝ))).comp (measurable_prefixNumeral b n)) +end CircleDigits + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/ContinuousWeight.lean b/lean/OAI/Analysis/RotationWeights/ContinuousWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..8943f063e3a6e489304fe9d95c0e2bce2c5e1233 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/ContinuousWeight.lean @@ -0,0 +1,271 @@ +import OAI.Analysis.RotationWeights.Concentration + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uX + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators + +open MeasureTheory Filter Set +open scoped Topology ENNReal BigOperators + +def concentratedWeight {X : Type uX} (H : ℕ → X → ℝ) (z : X) (x : X) : ℝ := + by classical exact if x = z then 0 else Real.exp (- ∑' i, H i x) + +@[simp] lemma concentratedWeight_self {X : Type uX} (H : ℕ → X → ℝ) (z : X) : + concentratedWeight H z z = 0 := by simp [concentratedWeight] + +lemma concentratedWeight_bounds {X : Type uX} (H : ℕ → X → ℝ) (z : X) + (hH : ∀ i x, 0 ≤ H i x) (x : X) : + 0 ≤ concentratedWeight H z x ∧ concentratedWeight H z x ≤ 1 := by + classical + unfold concentratedWeight + split_ifs + · exact ⟨le_rfl, zero_le_one⟩ + · exact ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (neg_nonpos.mpr (tsum_nonneg (fun i ↦ hH i x)))⟩ + +@[simp] lemma concentratedWeight_eq_zero {X : Type uX} (H : ℕ → X → ℝ) (z x : X) : + concentratedWeight H z x = 0 ↔ x = z := by + classical + unfold concentratedWeight + split_ifs with h + · simp [h] + · simp [h, Real.exp_ne_zero] + +def LocallyFiniteOff {X : Type uX} [TopologicalSpace X] (H : ℕ → X → ℝ) (z : X) : Prop := + ∀ x, x ≠ z → ∃ s : Finset ℕ, ∀ᶠ y in 𝓝 x, ∀ i, i ∉ s → H i y = 0 + +lemma finite_support_of_locallyFiniteOff {X : Type uX} [TopologicalSpace X] + (H : ℕ → X → ℝ) (z : X) (hlocal : LocallyFiniteOff H z) {x : X} (hx : x ≠ z) : + (Function.support (fun i ↦ H i x)).Finite := by + obtain ⟨s,hs⟩ := hlocal x hx + exact s.finite_toSet.subset (by + intro i hi + by_contra his + exact hi (mem_of_mem_nhds hs i his)) + +lemma concentratedWeight_continuousAt_off {X : Type uX} [TopologicalSpace X] [T1Space X] + (H : ℕ → X → ℝ) (z : X) (hc : ∀ i, Continuous (H i)) + (hlocal : LocallyFiniteOff H z) {x : X} (hx : x ≠ z) : + ContinuousAt (concentratedWeight H z) x := by + classical + obtain ⟨s,hs⟩ := hlocal x hx + have he : concentratedWeight H z =ᶠ[𝓝 x] (fun y ↦ Real.exp (-∑ i ∈ s, H i y)) := by + filter_upwards [hs, isOpen_compl_singleton.mem_nhds hx] with y hy hyz + change y ≠ z at hyz + rw [concentratedWeight, ite_eq_right hyz] + congr 2 + exact tsum_eq_sum (fun i hi ↦ hy i hi) + exact ((continuous_finsetSum s (fun i _ ↦ hc i)).neg.rexp.continuousAt).congr_of_eventuallyEq he + +lemma concentratedWeight_le_finite {X : Type uX} [TopologicalSpace X] + (H : ℕ → X → ℝ) (z : X) (hH : ∀ i x, 0 ≤ H i x) + (hlocal : LocallyFiniteOff H z) (s : Finset ℕ) (x : X) : + concentratedWeight H z x ≤ Real.exp (-∑ i ∈ s, H i x) := by + classical + by_cases hx : x = z + · simp only [concentratedWeight, ite_eq_left hx] + exact (Real.exp_pos _).le + rw [concentratedWeight, ite_eq_right hx] + apply Real.exp_le_exp.mpr + apply _root_.neg_le_neg + exact Summable.sum_le_tsum s (fun i _ ↦ hH i x) + (summable_of_hasFiniteSupport (finite_support_of_locallyFiniteOff H z hlocal hx)) + +theorem continuous_concentratedWeight {X : Type uX} [TopologicalSpace X] [T1Space X] + (H : ℕ → X → ℝ) (z : X) (hc : ∀ i, Continuous (H i)) (hH : ∀ i x, 0 ≤ H i x) + (hlocal : LocallyFiniteOff H z) + (hdiv : ∀ B : ℝ, ∃ s : Finset ℕ, B < ∑ i ∈ s, H i z) : + Continuous (concentratedWeight H z) := by + classical + rw [continuous_iff_continuousAt] + intro x + by_cases hx : x = z + · subst x + rw [ContinuousAt, Metric.tendsto_nhds] + intro ε hε + obtain ⟨s,hs⟩ := hdiv (-Real.log ε) + have he : Real.exp (-∑ i ∈ s, H i z) < ε := by + rw [← Real.exp_log hε] + exact Real.exp_lt_exp.mpr (by linarith) + have hev : ∀ᶠ x in 𝓝 z, Real.exp (-∑ i ∈ s, H i x) < ε := + ((continuous_finsetSum s (fun i _ ↦ hc i)).neg.rexp.continuousAt).eventually (gt_mem_nhds he) + filter_upwards [hev] with x hx + rw [concentratedWeight_self, dist_zero_right, Real.norm_eq_abs] + rw [abs_of_nonneg (concentratedWeight_bounds H z hH x).1] + exact (concentratedWeight_le_finite H z hH hlocal s x).trans_lt hx + · exact concentratedWeight_continuousAt_off H z hc hlocal hx + +lemma negativeLog_concentratedWeight {X : Type uX} [TopologicalSpace X] + (H : ℕ → X → ℝ) (z : X) (hH : ∀ i x, 0 ≤ H i x) + (hlocal : LocallyFiniteOff H z) + (hdiv : ∀ B : ℝ, ∃ s : Finset ℕ, B < ∑ i ∈ s, H i z) (x : X) : + negativeLog (concentratedWeight H z x) = ∑' i, ENNReal.ofReal (H i x) := by + classical + by_cases hx : x = z + · subst x + rw [concentratedWeight_self, negativeLog, ite_eq_left rfl] + symm + apply ENNReal.eq_top_of_forall_nnreal_le + intro b + obtain ⟨s,hs⟩ := hdiv b + calc + (b : ℝ≥0∞) ≤ ENNReal.ofReal (∑ i ∈ s, H i z) := by + simpa only [ENNReal.ofReal_coe_nnreal] using ENNReal.ofReal_le_ofReal hs.le + _ = ∑ i ∈ s, ENNReal.ofReal (H i z) := ENNReal.ofReal_sum_of_nonneg (fun i _ ↦ hH i z) + _ ≤ ∑' i, ENNReal.ofReal (H i z) := ENNReal.sum_le_tsum s + · rw [negativeLog, ite_eq_right ((concentratedWeight_eq_zero H z x).not.mpr hx), + concentratedWeight, ite_eq_right hx, Real.log_exp, neg_neg] + exact ENNReal.ofReal_tsum_of_nonneg (fun i ↦ hH i x) + (summable_of_hasFiniteSupport (finite_support_of_locallyFiniteOff H z hlocal hx)) + +theorem lintegral_negativeLog_concentratedWeight {X : Type uX} [TopologicalSpace X] + [MeasurableSpace X] [BorelSpace X] (μ : Measure X) + (H : ℕ → X → ℝ) (z : X) (hc : ∀ i, Continuous (H i)) (hH : ∀ i x, 0 ≤ H i x) + (hlocal : LocallyFiniteOff H z) + (hdiv : ∀ B : ℝ, ∃ s : Finset ℕ, B < ∑ i ∈ s, H i z) : + (∫⁻ x, negativeLog (concentratedWeight H z x) ∂μ) = + ∑' i, ∫⁻ x, ENNReal.ofReal (H i x) ∂μ := by + simp_rw [negativeLog_concentratedWeight H z hH hlocal hdiv] + exact lintegral_tsum (fun i ↦ ((hc i).measurable.ennreal_ofReal).aemeasurable) + +lemma locallyFiniteOff_of_shrinking_supports {X : Type uX} [MetricSpace X] + (H : ℕ → X → ℝ) (z : X) (r : ℕ → ℝ) (hr : Tendsto r atTop (𝓝 0)) + (hs : ∀ i x, r i ≤ dist x z → H i x = 0) : LocallyFiniteOff H z := by + classical + intro x hx + have hd : 0 < dist x z := dist_pos.mpr hx + obtain ⟨N,hN⟩ := eventually_atTop.mp (hr.eventually (gt_mem_nhds (half_pos hd))) + refine ⟨Finset.range N, ?_⟩ + filter_upwards [Metric.ball_mem_nhds x (half_pos hd)] with y hy + intro i hi + apply hs + have hn : N ≤ i := by simpa only [Finset.mem_range, not_lt] using hi + have hlt := hN i hn + have htri := dist_triangle x y z + have hxy : dist x y < dist x z / 2 := by + simpa only [Metric.mem_ball, dist_comm y x] using hy + linarith + +lemma ae_finite_support_of_support_measure_sum {X : Type uX} [MeasurableSpace X] + (μ : Measure X) (w : ℕ → X → ℝ) + (hw : (∑' i, μ {x | w i x ≠ 0}) ≠ ∞) : + ∀ᵐ x ∂μ, (Function.support (fun i ↦ w i x)).Finite := + ae_finite_setOfPred_mem hw + +theorem concentrated_coboundary {X : Type uX} [MeasurableSpace X] + (μ : Measure X) (σ : X → X) (hσ : MeasurePreserving σ μ μ) + (H G w : ℕ → X → ℝ) (z : X) (hz : μ {z} = 0) + (hwm : ∀ i, Measurable (w i)) + (hG : (∑' i, μ {x | G i x ≠ 0}) ≠ ∞) + (hw : (∑' i, μ {x | w i x ≠ 0}) ≠ ∞) + (hid : ∀ᵐ x ∂μ, ∀ i, H i x - G i x = w i (σ x) - w i x) : + ∃ a : X → ℝ, Measurable a ∧ (∀ x, 0 < a x) ∧ + ∀ᵐ x ∂μ, concentratedWeight H z x = + Real.exp (-∑' i, G i x) * a x / a (σ x) := by + classical + let b : X → ℝ := fun x ↦ ∑' i, w i x + let a : X → ℝ := fun x ↦ Real.exp (b x) + refine ⟨a, (Measurable.tsum hwm).exp, (fun x ↦ Real.exp_pos _), ?_⟩ + have hfin := ae_finite_support_of_support_measure_sum μ w hw + have hfinσ := hσ.quasiMeasurePreserving.ae hfin + have hfinG := ae_finite_support_of_support_measure_sum μ G hG + have hne : ∀ᵐ x ∂μ, x ≠ z := by + rw [ae_iff] + simpa only [not_not, ofPred_eq_eq_singleton] using hz + filter_upwards [hfin, hfinσ, hfinG, hid, hne] with x hx hxσ hxG hix hxz + have hsw : Summable (fun i ↦ w i x) := summable_of_hasFiniteSupport hx + have hswσ : Summable (fun i ↦ w i (σ x)) := summable_of_hasFiniteSupport hxσ + have hsG : Summable (fun i ↦ G i x) := summable_of_hasFiniteSupport hxG + have he : (fun i ↦ H i x) = (fun i ↦ G i x + (w i (σ x) - w i x)) := by + funext i + linarith [hix i] + have ht : (∑' i, H i x) = (∑' i, G i x) + (b (σ x) - b x) := by + rw [he, hsG.tsum_add (hswσ.sub hsw), hswσ.tsum_sub hsw] + rw [concentratedWeight, ite_eq_right hxz, ht] + change Real.exp _ = Real.exp _ * Real.exp (b x) / Real.exp (b (σ x)) + rw [← Real.exp_add, ← Real.exp_sub] + congr 1 + ring + + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Convolution.lean b/lean/OAI/Analysis/RotationWeights/Convolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..520328d4f87c90961450cf5114d8c8eb99b55b84 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Convolution.lean @@ -0,0 +1,286 @@ +import OAI.Analysis.RotationWeights.MaskedEstimates + +namespace OAI + +noncomputable section + +namespace CircleSampling + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators + +section +open MeasureTheory Set Filter ContinuousCircleWeight +open scoped ENNReal BigOperators + +structure ConvolutionMasks (j n : ℕ) where + left : ℤ → Set ActualSamples + right : ℤ → Set ActualSamples + left_measurable : ∀ v,MeasurableSet (left v) + right_measurable : ∀ v,MeasurableSet (right v) + left_dom : ∀ v,Measure.map firstEndpoint ((actualSystem.probability (stageTagged j)).restrict (left v)) ≤ + ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map firstEndpoint (actualSystem.probability (stageTagged j)) + right_dom : ∀ v,Measure.map lastEndpoint ((actualSystem.probability (stageTagged j)).restrict (right v)) ≤ + ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map lastEndpoint (actualSystem.probability (stageTagged j)) + decay : ∀ v,v∉retainedIndices (polynomialWindow j) n → ∀ ω∈regularSamples,ω∈stageTagEvent j → + ω∉left v → ω∉right v → modelF (longIndex j n v) (lastEndpoint ω)/modelF (longIndex j n v) (firstEndpoint ω) ≤ Real.exp (-crossingBudget j) + +lemma convolutionMasks_nonempty (j n : ℕ) : Nonempty (ConvolutionMasks j n) := by + classical + have hex (v : ℤ) : ∃ H₁ H₂ : Set ActualSamples,MeasurableSet H₁ ∧ MeasurableSet H₂ ∧ + Measure.map firstEndpoint ((actualSystem.probability (stageTagged j)).restrict H₁) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map firstEndpoint (actualSystem.probability (stageTagged j)) ∧ + Measure.map lastEndpoint ((actualSystem.probability (stageTagged j)).restrict H₂) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map lastEndpoint (actualSystem.probability (stageTagged j)) ∧ + (v∉retainedIndices (polynomialWindow j) n → ∀ ω∈regularSamples,ω∈stageTagEvent j → ω∉H₁ → ω∉H₂ → modelF (longIndex j n v) (lastEndpoint ω)/modelF (longIndex j n v) (firstEndpoint ω) ≤ Real.exp (-crossingBudget j)) := by + by_cases hv : v∈retainedIndices (polynomialWindow j) n + · exact ⟨∅,∅,MeasurableSet.empty,MeasurableSet.empty,by simp; exact bot_le,by simp; exact bot_le,fun h => False.elim (h hv)⟩ + · obtain ⟨A,B,hA,hB,hdA,hdB,hc⟩ := all_masks j _ (longIndex_long j n v hv) + exact ⟨A,B,hA,hB,hdA,hdB,fun _ => hc⟩ + choose A B hA hB hdA hdB hc using hex + exact ⟨⟨A,B,hA,hB,hdA,hdB,hc⟩⟩ +def convolutionMasks (j n : ℕ) : ConvolutionMasks j n := Classical.choice (convolutionMasks_nonempty j n) + +lemma model_ratio_bounds {ω : ActualSamples} (hω : ω∈regularSamples) (j n : ℕ) (v : ℤ) : + 0 < modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω) ∧ + modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω) ≤ 1 ∧ + modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω) ≤ + modelF (longIndex j n v) (lastEndpoint ω)/modelF (longIndex j n v) (firstEndpoint ω) := by + have hh := cocycle_two_ratio_bounds (fun k => modelF k (firstEndpoint ω)) (fun k => modelF k (lastEndpoint ω)) + (fun k => modelF_pos k _) (fun k => modelF_pos k _) (modelF_antitone _) (modelF_antitone _) (regular_model_order hω) n v + refine ⟨hh.1,hh.2.1.trans hh.2.2.2.1,?_⟩ + unfold longIndex + split_ifs + · exact hh.2.1 + · exact hh.2.2.1 + +lemma model_ratio_masked {ω : ActualSamples} (hω : ω∈regularSamples) (j n : ℕ) (v : ℤ) + (hv : v∉retainedIndices (polynomialWindow j) n) (ht : ω∈stageTagEvent j) : + ENNReal.ofReal (modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω)) ≤ + ENNReal.ofReal (Real.exp (-crossingBudget j))+ + ((convolutionMasks j n).left v).indicator (fun _ => (1:ℝ≥0∞)) ω+ + ((convolutionMasks j n).right v).indicator (fun _ => (1:ℝ≥0∞)) ω := by + classical + have hh := model_ratio_bounds hω j n v + have hone : ENNReal.ofReal (modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω)) ≤ 1 := by + simpa using ENNReal.ofReal_le_ofReal hh.2.1 + by_cases hl : ω∈(convolutionMasks j n).left v + · simp only [Set.indicator_of_mem hl] + exact hone.trans ((le_add_self).trans le_self_add) + · by_cases hr : ω∈(convolutionMasks j n).right v + · simp only [Set.indicator_of_notMem hl,Set.indicator_of_mem hr,add_zero] + exact hone.trans le_add_self + · simp only [Set.indicator_of_notMem hl,Set.indicator_of_notMem hr,add_zero] + exact ENNReal.ofReal_le_ofReal (hh.2.2.trans ((convolutionMasks j n).decay v hv ω hω ht hl hr)) + +lemma shifted_complement_squares (P : ModelProjectionField) (y : CircleX) (n : ℕ) : + (∑' v : ℤ,‖modelComplement P y ((n:ℤ)+v)‖ₑ^2) ≤ 1 := by + have hh := fiber_squares_le (modelComplement_norm P y) + rwa [←(Equiv.addLeft (n:ℤ)).tsum_eq] at hh +lemma shifted_product_bound (P : ModelProjectionField) (x y : CircleX) (n : ℕ) : + (∑' v : ℤ,‖modelColumn P x v‖ₑ*‖modelComplement P y ((n:ℤ)+v)‖ₑ) ≤ 1 := by + have hh := fiber_product_le (modelColumn_norm P x) (show ‖fiberShift (-(n:ℤ)) (modelComplement P y)‖ ≤ 1 by simpa using modelComplement_norm P y) + simpa only [fiberShift_apply,sub_neg_eq_add,add_comm] using hh + +lemma modelTerm_enorm (P : ModelProjectionField) (n : ℕ) (v : ℤ) (ω : ActualSamples) : + ‖modelTerm P n v ω‖ₑ=‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ* + ENNReal.ofReal (modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω)) := by + rw [←ofReal_norm,modelTerm,norm_mul,norm_mul,Complex.norm_conj,Complex.norm_real,Real.norm_eq_abs, + abs_of_pos (div_pos (modelF_pos _ _) (modelF_pos _ _)), + ENNReal.ofReal_mul (mul_nonneg (div_pos (modelF_pos _ _) (modelF_pos _ _)).le (norm_nonneg _)), + ENNReal.ofReal_mul (div_pos (modelF_pos _ _) (modelF_pos _ _)).le,ofReal_norm,ofReal_norm] + ring + +lemma modelRetained_cut (P : ModelProjectionField) (j n : ℕ) {ω : ActualSamples} + (hω : ω∈regularSamples) (ht : ω∈stageTagEvent j) + (hc : Summable (fun v => modelTerm P n v ω) ∧ (∑' v,modelTerm P n v ω)=0) : + ‖modelRetained P j n ω‖ₑ ≤ ENNReal.ofReal (Real.exp (-crossingBudget j))+ + (∑' v, ((convolutionMasks j n).left v).indicator (fun ω => ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) ω)+ + (∑' v, ((convolutionMasks j n).right v).indicator (fun ω => ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) ω) := by + classical + have hh := convolution_cut_bound (fun v => modelTerm P n v ω) (retainedIndices (polynomialWindow j) n) + hc.1 hc.2 (fun v => ‖modelColumn P (firstEndpoint ω) v‖ₑ) (fun v => ‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) + (fun v => ((convolutionMasks j n).left v).indicator (fun _ => (1:ℝ≥0∞)) ω) + (fun v => ((convolutionMasks j n).right v).indicator (fun _ => (1:ℝ≥0∞)) ω) + (ENNReal.ofReal (Real.exp (-crossingBudget j))) (shifted_product_bound P _ _ n) (fun v hv => by + rw [modelTerm_enorm P n v ω] + exact mul_le_mul' le_rfl (model_ratio_masked hω j n v hv ht)) + have hleft (v : ℤ) : ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ* + ((convolutionMasks j n).left v).indicator (fun _ => (1:ℝ≥0∞)) ω = + ((convolutionMasks j n).left v).indicator (fun ω => ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) ω := by + by_cases h : ω∈(convolutionMasks j n).left v <;> simp [h] + have hright (v : ℤ) : ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ* + ((convolutionMasks j n).right v).indicator (fun _ => (1:ℝ≥0∞)) ω = + ((convolutionMasks j n).right v).indicator (fun ω => ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) ω := by + by_cases h : ω∈(convolutionMasks j n).right v <;> simp [h] + simpa only [hleft,hright,modelRetained] using hh +end + +open MeasureTheory Set Filter ContinuousCircleWeight +open scoped ENNReal BigOperators Topology + +def convolutionError (j : ℕ) : ℝ := Real.exp (-crossingBudget j)+2*Real.exp (-crossingBudget j/800) +lemma convolutionError_pos (j : ℕ) : 0 ‖modelRetained P j n ω‖ₑ) ω ∂actualSystem.probability (stageTagged j)) ≤ + ENNReal.ofReal (convolutionError j) := by + have hc : ∀ᵐ ω ∂actualSystem.probability (stageTagged j), + (projectionEvent (modelDiagonal P) j).indicator (fun ω => ‖modelRetained P j n ω‖ₑ) ω ≤ + ENNReal.ofReal (Real.exp (-crossingBudget j))+ + (∑' v, ((convolutionMasks j n).left v).indicator (fun ω => ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) ω)+ + (∑' v, ((convolutionMasks j n).right v).indicator (fun ω => ‖modelColumn P (firstEndpoint ω) v‖ₑ*‖modelComplement P (lastEndpoint ω) ((n:ℤ)+v)‖ₑ) ω) := by + filter_upwards [model_convolution_ae P j] with ω hω + by_cases he : ω∈projectionEvent (modelDiagonal P) j + · rw [Set.indicator_of_mem he] + exact modelRetained_cut P j n hω.1 he.1 (hω.2 n) + · rw [Set.indicator_of_notMem he] + exact zero_le + have hh := two_endpoint_error_bound (actualSystem.probability (stageTagged j)) firstEndpoint lastEndpoint + firstEndpoint_measurable lastEndpoint_measurable + (fun v x => ‖modelColumn P x v‖ₑ) (fun v y => ‖modelComplement P y ((n:ℤ)+v)‖ₑ) + (fun v => (modelColumn_coordinate P v).enorm) (fun v => (modelComplement_coordinate P _).enorm) + (convolutionMasks j n).left (convolutionMasks j n).right + (convolutionMasks j n).left_measurable (convolutionMasks j n).right_measurable + (ENNReal.ofReal (Real.exp (-crossingBudget j/400))) (ENNReal.ofReal (Real.exp (-crossingBudget j))) + (convolutionMasks j n).left_dom (convolutionMasks j n).right_dom + (Eventually.of_forall (fun ω => fiber_squares_le (modelColumn_norm P (firstEndpoint ω)))) + (Eventually.of_forall (fun ω => shifted_complement_squares P (lastEndpoint ω) n)) _ hc + rwa [convolutionError_eq] at hh + +lemma projectionEvent_upper (P : ModelProjectionField) (j : ℕ) : + (actualSystem.probability (stageTagged j)).real (projectionEvent (modelDiagonal P) j) ≤ 1/((j:ℝ)+1) := by + let μ := actualSystem.probability (stageTagged j) + let E := projectionEvent (modelDiagonal P) j + have hE : MeasurableSet E := projectionEvent_measurable (modelDiagonal_measurable P) j + have hlow : (ENNReal.ofReal (scaleStep j).ε)*μ E ≤ + ∫⁻ ω,∑ t : Fin (2*polynomialWindow j+1),E.indicator (fun ω => ‖modelRetained P j (2*polynomialWindow j-t.val) ω‖ₑ) ω ∂μ := by + rw [←lintegral_indicator_const hE] + apply lintegral_mono_ae + filter_upwards [ae_regularSamples j] with ω hω + by_cases he : ω∈E + · rw [Set.indicator_of_mem he] + obtain ⟨t,ht⟩ := model_coefficient_lower P j hω he + calc + _ ≤ ‖modelRetained P j (2*polynomialWindow j-t.val) ω‖ₑ := by simpa only [ofReal_norm] using ENNReal.ofReal_le_ofReal ht + _ = E.indicator (fun ω => ‖modelRetained P j (2*polynomialWindow j-t.val) ω‖ₑ) ω := by rw [Set.indicator_of_mem he] + _ ≤ _ := Finset.single_le_sum (f := fun t : Fin (2*polynomialWindow j+1) => E.indicator (fun ω => ‖modelRetained P j (2*polynomialWindow j-t.val) ω‖ₑ) ω) (fun _ _ => zero_le) (Finset.mem_univ t) + · simp [he] + have hu : (ENNReal.ofReal (scaleStep j).ε)*μ E ≤ ENNReal.ofReal ((2*(polynomialWindow j:ℝ)+1)*convolutionError j) := by + apply hlow.trans + rw [lintegral_finsetSum _ (fun t _ => (modelRetained_measurable P j _).enorm.indicator hE)] + calc + _ ≤ ∑ _t : Fin (2*polynomialWindow j+1), ENNReal.ofReal (convolutionError j) := Finset.sum_le_sum (fun t _ => integrated_retained_bound P j _) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]; rw [ENNReal.ofReal_mul (by positivity)]; norm_cast + have hreal : (scaleStep j).ε*μ.real E ≤ (2*(polynomialWindow j:ℝ)+1)*convolutionError j := by + have hh := ENNReal.toReal_mono (ENNReal.ofReal_ne_top) hu + simpa only [ENNReal.toReal_mul,ENNReal.toReal_ofReal (scaleStep j).εpos.le, + ENNReal.toReal_ofReal (mul_nonneg (by positivity : (0:ℝ)≤2*(polynomialWindow j:ℝ)+1) (convolutionError_pos j).le),measureReal_def] using hh + have hb := (scaleStep j).exponential + have hc : (2*(polynomialWindow j:ℝ)+1)*convolutionError j ≤ (scaleStep j).ε/((j:ℝ)+1) := by + apply le_trans (mul_le_mul_of_nonneg_left (convolutionError_bound j) (by positivity)) + change (2*(polynomialWindow j:ℝ)+1)*3*Real.exp (-crossingBudget j/10000) ≤ (scaleStep j).ε/((j:ℝ)+1) at hb + simpa only [mul_assoc] using hb + have hh := hreal.trans hc + have hε := (scaleStep j).εpos + change μ.real E ≤ _ + nlinarith [show (scaleStep j).ε/((j:ℝ)+1)=(scaleStep j).ε*(1/((j:ℝ)+1)) by ring] + +theorem model_no_strict_projection (P : ModelProjectionField) + (hp : ∀ᵐ x,0 < modelDiagonal P x ∧ modelDiagonal P x<1) : False := by + have hm := projectionEvent_mass (modelDiagonal_measurable P) hp + have ht : Tendsto (fun j : ℕ => 1/((j:ℝ)+1)) atTop (𝓝 0) := by + exact tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ) + have he := ht.eventually (gt_mem_nhds (by positivity : (0:ℝ) positivity +lemma τ_le (tagged : Bool) : P.τ tagged ≤ 1/(P.m:ℝ) := by unfold τ; split <;> first | rfl | positivity +lemma ρ_le_one : P.ρ ≤ 1 := (crossingProbability_le_kappa P.hκ0 (by exact_mod_cast (by have := P.hm; omega : 1≤P.m)) (by linarith [P.ha.2])).trans (by linarith [P.hκ]) +lemma σ_le_one : P.σ ≤ 1 := (crossingProbability_le_kappa P.hκ0 (by exact_mod_cast (by have := P.hm; omega : 1≤P.m)) (by linarith [P.hb.2])).trans (by linarith [P.hκ]) +lemma probabilities (tagged : Bool) : 2*ENNReal.ofReal P.ρ+2*ENNReal.ofReal P.σ+ENNReal.ofReal (P.τ tagged) ≤ 1 := + six_probabilities_le_one P.κ P.a P.b P.m P.hκ0 P.hκ (by exact_mod_cast P.hm) P.ha.2 P.hb.2 + (P.τ tagged) (P.τ_nonneg tagged) (P.τ_le tagged) + +abbrev Sample := Option (Fin 5) × (Fin P.l × Fin P.l) +def law (tagged : Bool) : Measure P.Sample := + sixLaw P.l (roundedWidth P.l P.a) (roundedWidth P.l P.b) (roundedTag P.l P.m) + ⟨P.width_a.1,P.width_a.2.1⟩ ⟨P.width_b.1,P.width_b.2.1⟩ ⟨P.tag_bounds.1,P.tag_bounds.2.1⟩ + (ENNReal.ofReal P.ρ) (ENNReal.ofReal P.σ) (ENNReal.ofReal (P.τ tagged)) +instance (tagged : Bool) : IsProbabilityMeasure (P.law tagged) := + sixLaw_probability _ _ _ _ _ _ _ _ _ _ (P.probabilities tagged) + +lemma rounded_width_a_half : (roundedWidth P.l P.a:ℝ) ≤ (P.l:ℝ)/2 := by + have hl : (0:ℝ) ≤ P.l := Nat.cast_nonneg _ + calc + _ ≤ (P.l:ℝ)*P.a/2 := P.width_a.2.2.2 + _ ≤ _ := by nlinarith [P.ha.2] +lemma rounded_width_b_half : (roundedWidth P.l P.b:ℝ) ≤ (P.l:ℝ)/2 := by + have hl : (0:ℝ) ≤ P.l := Nat.cast_nonneg _ + calc + _ ≤ (P.l:ℝ)*P.b/2 := P.width_b.2.2.2 + _ ≤ _ := by nlinarith [P.hb.2] +lemma rounded_tag_half : (roundedTag P.l P.m:ℝ) ≤ (P.l:ℝ)/2 := by + apply P.tag_bounds.2.2.2.trans + exact div_le_div_of_nonneg_left (Nat.cast_nonneg _) (by norm_num) (by exact_mod_cast (by have := P.hm; omega : 2≤P.m)) + +lemma law_second_moment (tagged e : Bool) : + (P.l:ℝ)* ∑ d : Fin P.l, ((P.law tagged).real {ω | digitEndpoint e ω.2=d})^2 ≤ + 1+(60*P.κ^2+10*(if tagged then (1:ℝ) else 0))/(P.m:ℝ) := by + apply sixLaw_second_moment _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ P.a_pos P.b_pos P.m_pos + P.ρ_nonneg P.σ_nonneg (P.τ_nonneg tagged) P.width_a.2.2.1 P.rounded_width_a_half + P.width_b.2.2.1 P.rounded_width_b_half P.tag_bounds.2.2.1 P.rounded_tag_half + (crossingProbability_sq P.a_pos.le P.m_pos.le) (crossingProbability_sq P.b_pos.le P.m_pos.le) _ (P.probabilities tagged) + cases tagged <;> simp [τ,one_div,inv_pow] + +lemma law_density_ten (tagged e : Bool) (d : Fin P.l) : + (P.law tagged).real {ω | digitEndpoint e ω.2=d} ≤ 10/(P.l:ℝ) := by + apply sixLaw_density_ten _ _ _ _ _ _ _ _ _ _ _ _ _ _ P.a_pos P.b_pos P.m_pos + P.hκ P.ρ_nonneg P.σ_nonneg (P.τ_nonneg tagged) P.width_a.2.2.1 P.rounded_width_a_half + P.width_b.2.2.1 P.rounded_width_b_half P.tag_bounds.2.2.1 P.rounded_tag_half + (crossingProbability_div_le P.hκ0 P.m_pos P.ha.1) (crossingProbability_div_le P.hκ0 P.m_pos P.hb.1) + (P.τ_le tagged) (P.probabilities tagged) +end CoordinateParameters +lemma ae_labelled {κ : Type uκ} {D : Type uD} [MeasurableSpace κ] [MeasurableSpace D] + (a : Option κ) (μ : Measure (D × D)) (P : Option κ × (D × D) → Prop) + (hP : MeasurableSet {z | P z}) (h : ∀ᵐ z ∂μ, P (a,z)) : + ∀ᵐ z ∂labelled a μ, P z := by + exact (ae_map_iff (by fun_prop) hP).mpr h + +lemma ae_mixture {κ : Type uκ} {D : Type uD} [Fintype κ] [MeasurableSpace κ] [MeasurableSpace D] + (p : κ → ℝ≥0∞) (p₀ : ℝ≥0∞) (μ₀ : Measure (D × D)) (μ : κ → Measure (D × D)) + (P : Option κ × (D × D) → Prop) (hP : MeasurableSet {z | P z}) + (h₀ : ∀ᵐ z ∂μ₀, P (none,z)) (h : ∀ a, ∀ᵐ z ∂μ a, P (some a,z)) : + ∀ᵐ z ∂mixture p p₀ μ₀ μ, P z := by + rw [mixture,ae_add_measure_iff,ae_finsetSum_measure_iff] + exact ⟨Measure.ae_smul_measure (ae_labelled _ _ _ hP h₀) _,fun a _ => + Measure.ae_smul_measure (ae_labelled _ _ _ hP (h a)) _⟩ + +def supportCondition (l t u r : ℕ) (z : Option (Fin 5) × (Fin l × Fin l)) : Prop := + match z.1 with + | none => z.2.1 = z.2.2 + | some a => if a=0 then z.2.1.val < l-t ∧ l-t ≤ z.2.2.val + else if a=1 then z.2.1.val < t ∧ t ≤ z.2.2.val + else if a=2 then z.2.1.val < l-u ∧ l-u ≤ z.2.2.val + else if a=3 then z.2.1.val < u ∧ u ≤ z.2.2.val + else z.2.1.val < r ∧ l-r ≤ z.2.2.val + +lemma sixLaw_support (l t u r : ℕ) [NeZero l] (ht : 0 < t ∧ t < l) + (hu : 0 < u ∧ u < l) (hr : 0 < r ∧ r < l) (p q τ : ℝ≥0∞) : + ∀ᵐ z ∂sixLaw l t u r ht hu hr p q τ, supportCondition l t u r z := by + apply ae_mixture _ _ _ _ _ (by measurability) + · unfold diagonal + apply (ae_map_iff (by fun_prop) (by measurability)).mpr + exact ae_of_all _ (fun _ => rfl) + · intro a + fin_cases a <;> dsimp [supportCondition,components] <;> + apply rectangle_ae + +namespace CoordinateParameters +variable (P : CoordinateParameters) +lemma law_support (tagged : Bool) : + ∀ᵐ z ∂P.law tagged, supportCondition P.l (roundedWidth P.l P.a) + (roundedWidth P.l P.b) (roundedTag P.l P.m) z := + sixLaw_support _ _ _ _ _ _ _ _ _ _ +lemma law_order (tagged : Bool) : ∀ᵐ z ∂P.law tagged, z.2.1 ≤ z.2.2 := by + filter_upwards [P.law_support tagged] with z hz + have htag : 2*roundedTag P.l P.m ≤ P.l := by + have h := P.rounded_tag_half + have : (2:ℝ)*(roundedTag P.l P.m:ℝ) ≤ P.l := by linarith + exact_mod_cast this + rcases z with ⟨a,x,y⟩ + cases a with + | none => exact le_of_eq hz + | some a => + fin_cases a <;> simp [supportCondition] at hz <;> + change x.val ≤ y.val <;> omega + +lemma top_a_failure (tagged : Bool) (d : Fin P.l) + (hd : d.val < P.l-roundedWidth P.l P.a) : + P.law tagged ({z | z.2.1=d} ∩ {z | z.1=some (0:Fin 5)}ᶜ) ≤ + ENNReal.ofReal (1-P.ρ/10)*P.law tagged {z | z.2.1=d} := + sixLaw_top_t_failure _ _ _ _ _ _ _ _ _ _ P.ρ_nonneg P.ρ_le_one + (P.probabilities tagged) d hd (P.law_density_ten tagged false d) +lemma bottom_a_failure (tagged : Bool) (d : Fin P.l) + (hd : roundedWidth P.l P.a ≤ d.val) : + P.law tagged ({z | z.2.2=d} ∩ {z | z.1=some (1:Fin 5)}ᶜ) ≤ + ENNReal.ofReal (1-P.ρ/10)*P.law tagged {z | z.2.2=d} := + sixLaw_bottom_t_failure _ _ _ _ _ _ _ _ _ _ P.ρ_nonneg P.ρ_le_one + (P.probabilities tagged) d hd (P.law_density_ten tagged true d) +lemma top_b_failure (tagged : Bool) (d : Fin P.l) + (hd : d.val < P.l-roundedWidth P.l P.b) : + P.law tagged ({z | z.2.1=d} ∩ {z | z.1=some (2:Fin 5)}ᶜ) ≤ + ENNReal.ofReal (1-P.σ/10)*P.law tagged {z | z.2.1=d} := + sixLaw_top_u_failure _ _ _ _ _ _ _ _ _ _ P.σ_nonneg P.σ_le_one + (P.probabilities tagged) d hd (P.law_density_ten tagged false d) +lemma bottom_b_failure (tagged : Bool) (d : Fin P.l) + (hd : roundedWidth P.l P.b ≤ d.val) : + P.law tagged ({z | z.2.2=d} ∩ {z | z.1=some (3:Fin 5)}ᶜ) ≤ + ENNReal.ofReal (1-P.σ/10)*P.law tagged {z | z.2.2=d} := + sixLaw_bottom_u_failure _ _ _ _ _ _ _ _ _ _ P.σ_nonneg P.σ_le_one + (P.probabilities tagged) d hd (P.law_density_ten tagged true d) +end CoordinateParameters +end CircleCoupling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/CouplingMoments.lean b/lean/OAI/Analysis/RotationWeights/CouplingMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..7629dbeea31e07714d5f33ebac7a3e28b46e7477 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/CouplingMoments.lean @@ -0,0 +1,482 @@ +import OAI.Analysis.RotationWeights.DigitCouplings + +namespace OAI + +noncomputable section + +namespace CircleCoupling + +universe uD uA uι uΩ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +section + +lemma sum_sq_le_card_mul {D : Type uD} [Fintype D] (f : D → ℝ) : + (∑ d, f d)^2 ≤ (Fintype.card D : ℝ) * ∑ d, (f d)^2 := by + simpa [mul_comm] using Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset D) f (fun _ => (1 : ℝ)) + +lemma centered_density_squares {D : Type uD} [Fintype D] (g : D → ℝ) (M : ℝ) + (hg : ∀ d, 0 ≤ g d) (hM : ∀ d, g d ≤ M) + (hmean : ∑ d, g d = (Fintype.card D : ℝ)) : + ∑ d, (g d - 1)^2 ≤ (Fintype.card D : ℝ) * M := by + have hsq : ∑ d, (g d)^2 ≤ M * ∑ d, g d := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro d _ + nlinarith [mul_le_mul_of_nonneg_right (hM d) (hg d)] + have heq : ∑ d, (g d - 1)^2 = (∑ d, (g d)^2) - (Fintype.card D : ℝ) := by + simp_rw [sub_sq] + simp only [Finset.sum_add_distrib,Finset.sum_sub_distrib,Finset.sum_const, + Finset.card_univ,nsmul_eq_mul,one_pow,mul_one] + rw [← Finset.mul_sum, hmean] + ring + rw [heq] + rw [hmean] at hsq + have : (0 : ℝ) ≤ Fintype.card D := Nat.cast_nonneg _ + nlinarith + +lemma mixture_density_squares {D : Type uD} {A : Type uA} [Fintype D] [Fintype A] + (g : A → D → ℝ) (p M : A → ℝ) + (hg : ∀ a d, 0 ≤ g a d) (hM : ∀ a d, g a d ≤ M a) + (hmean : ∀ a, ∑ d, g a d = (Fintype.card D : ℝ)) : + ∑ d, (1 + ∑ a, p a * (g a d - 1))^2 ≤ + (Fintype.card D : ℝ) * (1 + (Fintype.card A : ℝ) * ∑ a, (p a)^2 * M a) := by + let v : D → ℝ := fun d => ∑ a, p a * (g a d - 1) + have hvmean : ∑ d, v d = 0 := by + simp only [v] + rw [Finset.sum_comm] + apply Finset.sum_eq_zero + intro a _ + rw [← Finset.mul_sum,Finset.sum_sub_distrib,hmean] + simp + have hv : ∑ d, (v d)^2 ≤ (Fintype.card D : ℝ) * + ((Fintype.card A : ℝ) * ∑ a, (p a)^2 * M a) := by + calc + ∑ d, (v d)^2 ≤ ∑ d, (Fintype.card A : ℝ) * ∑ a, (p a * (g a d-1))^2 := + Finset.sum_le_sum (fun d _ => sum_sq_le_card_mul _) + _ = (Fintype.card A : ℝ) * ∑ a, (p a)^2 * ∑ d, (g a d-1)^2 := by + simp_rw [mul_pow] + rw [← Finset.mul_sum,Finset.sum_comm] + simp_rw [← Finset.mul_sum] + _ ≤ (Fintype.card A : ℝ) * ∑ a, (p a)^2 * ((Fintype.card D : ℝ) * M a) := by + gcongr with a + exact centered_density_squares (g a) (M a) (hg a) (hM a) (hmean a) + _ = _ := by simp_rw [mul_left_comm ((p _)^2) (Fintype.card D : ℝ)]; rw [← Finset.mul_sum]; ring + have heq : ∑ d, (1+v d)^2 = (Fintype.card D : ℝ) + ∑ d, (v d)^2 := by + simp_rw [add_sq] + simp only [Finset.sum_add_distrib,one_pow,Finset.sum_const, + Finset.card_univ,nsmul_eq_mul,mul_one,← Finset.mul_sum,hvmean,mul_zero,add_zero] + change ∑ d, (1+v d)^2 ≤ _ + rw [heq] + nlinarith + +lemma probability_sum_singleton_real {D : Type uD} [Fintype D] [MeasurableSpace D] + [MeasurableSingletonClass D] (μ : Measure D) [IsProbabilityMeasure μ] : + ∑ d, μ.real {d} = 1 := by + simp + +lemma uniform_l2_set_bound {D : Type uD} [Fintype D] [Nonempty D] + [MeasurableSpace D] [MeasurableSingletonClass D] + (μ ν : Measure D) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] + (hμ : ∀ d, μ.real {d} = (Fintype.card D : ℝ)⁻¹) {H : ℝ} (hH : 0 ≤ H) + (hL2 : (Fintype.card D : ℝ) * ∑ d, (ν.real {d})^2 ≤ H^2) + (A : Set D) : ν.real A ≤ H * Real.sqrt (μ.real A) := by + classical + let s := A.toFinite.toFinset + have hs : (s : Set D) = A := by simp [s] + have hνA : ν.real A = ∑ d ∈ s, ν.real {d} := by rw [← hs, sum_measureReal_singleton] + have hμA : μ.real A = (s.card : ℝ) / (Fintype.card D : ℝ) := by + rw [← hs, ← sum_measureReal_singleton] + simp only [hμ,Finset.sum_const,nsmul_eq_mul,div_eq_mul_inv] + have hc : (0 : ℝ) < Fintype.card D := Nat.cast_pos.mpr Fintype.card_pos + have hsq : (ν.real A)^2 ≤ H^2 * μ.real A := by + rw [hνA,hμA] + have hh := Finset.sum_mul_sq_le_sq_mul_sq s (fun d => ν.real {d}) (fun _ => (1 : ℝ)) + simp only [mul_one,one_pow,Finset.sum_const,nsmul_eq_mul,mul_one] at hh + have hsub : ∑ d ∈ s, (ν.real {d})^2 ≤ ∑ d, (ν.real {d})^2 := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun _ _ _ => sq_nonneg _) + have hcard : (0 : ℝ) ≤ s.card := Nat.cast_nonneg _ + have hbound := mul_le_mul_of_nonneg_right hsub hcard + have hbound2 := mul_le_mul_of_nonneg_left ((le_div_iff₀ hc).mpr (by nlinarith : + (∑ d, (ν.real {d})^2) * (Fintype.card D : ℝ) ≤ H^2)) hcard + calc + _ ≤ (∑ d, (ν.real {d})^2) * (s.card : ℝ) := hh.trans hbound + _ ≤ (s.card : ℝ) * (H^2 / (Fintype.card D : ℝ)) := by simpa [mul_comm] using hbound2 + _ = _ := by ring + apply (sq_le_sq₀ measureReal_nonneg (mul_nonneg hH (Real.sqrt_nonneg _))).mp + simpa [mul_pow,Real.sq_sqrt measureReal_nonneg] using hsq + +lemma pi_second_moment {ι : Type uι} [Fintype ι] [DecidableEq ι] {D : ι → Type uD} + [∀ i, Fintype (D i)] [∀ i, MeasurableSpace (D i)] + [∀ i, MeasurableSingletonClass (D i)] (μ : ∀ i, Measure (D i)) + [∀ i, IsProbabilityMeasure (μ i)] : + (Fintype.card (∀ i, D i) : ℝ) * ∑ d, ((Measure.pi μ).real {d})^2 = + ∏ i, (Fintype.card (D i) : ℝ) * ∑ d, ((μ i).real {d})^2 := by + classical + simp only [Measure.real,Measure.pi_singleton,ENNReal.toReal_prod,← Finset.prod_pow] + rw [← Fintype.prod_sum (fun i (d : D i) => ((μ i) {d}).toReal^2), + Fintype.card_pi,Nat.cast_prod,Finset.prod_mul_distrib] + +lemma pi_uniform_singleton_real {ι : Type uι} [Fintype ι] [DecidableEq ι] {D : ι → Type uD} + [∀ i, Fintype (D i)] [∀ i, Nonempty (D i)] [∀ i, MeasurableSpace (D i)] + [∀ i, MeasurableSingletonClass (D i)] (d : ∀ i, D i) : + (Measure.pi (fun i => (PMF.uniformOfFintype (D i)).toMeasure)).real {d} = + (Fintype.card (∀ i, D i) : ℝ)⁻¹ := by + classical + simp [Measure.real,Measure.pi_singleton,ENNReal.toReal_prod,PMF.uniformOfFintype_apply, + Fintype.card_pi,Finset.prod_inv_distrib] + + +lemma mixture_endpoint_second_moment {A : Type uA} {D : Type uD} [Fintype A] [Fintype D] [Nonempty D] + [MeasurableSpace A] [MeasurableSpace D] [MeasurableSingletonClass D] + (p : A → ℝ≥0∞) (μ₀ : Measure (D × D)) (μ : A → Measure (D × D)) + [IsProbabilityMeasure μ₀] [∀ a, IsProbabilityMeasure (μ a)] + (hp : ∑ a, p a ≤ 1) (f : D × D → D) (hf : Measurable f) + (hdiag : ∀ d, μ₀.real (f ⁻¹' {d}) = (Fintype.card D : ℝ)⁻¹) + (M : A → ℝ) (hM : ∀ a d, (Fintype.card D : ℝ) * (μ a).real (f ⁻¹' {d}) ≤ M a) : + (Fintype.card D : ℝ) * ∑ d, + ((mixture p (1-∑ a, p a) μ₀ μ).real {ω | f ω.2 = d})^2 ≤ + 1 + (Fintype.card A : ℝ) * ∑ a, (p a).toReal^2 * M a := by + classical + let L : ℝ := Fintype.card D + have hL : 0 < L := Nat.cast_pos.mpr Fintype.card_pos + have hpfin (a : A) : p a ≠ ∞ := ne_top_of_le_ne_top ENNReal.one_ne_top + ((Finset.single_le_sum (fun _ _ => bot_le) (Finset.mem_univ a)).trans hp) + have hsfin : (∑ a, p a) ≠ ∞ := ne_top_of_le_ne_top ENNReal.one_ne_top hp + have hremfin : 1-∑ a, p a ≠ (∞ : ℝ≥0∞) := ne_top_of_le_ne_top ENNReal.one_ne_top tsub_le_self + have hrem : (1-∑ a, p a).toReal = 1-∑ a, (p a).toReal := by + rw [ENNReal.toReal_sub_of_le hp ENNReal.one_ne_top,ENNReal.toReal_one, + ENNReal.toReal_sum (fun a _ => hpfin a)] + let g : A → D → ℝ := fun a d => L * (μ a).real (f ⁻¹' {d}) + have hg : ∀ a d, 0 ≤ g a d := fun a d => mul_nonneg hL.le measureReal_nonneg + have hgmean : ∀ a, ∑ d, g a d = L := by + intro a + rw [show (∑ d, g a d) = L * ∑ d, (μ a).real (f ⁻¹' {d}) by + simp only [g,Finset.mul_sum]] + rw [sum_measureReal_preimage_singleton Finset.univ (fun d _ => hf (measurableSet_singleton d))] + simp + have hden (d : D) : L * (mixture p (1-∑ a, p a) μ₀ μ).real {ω | f ω.2 = d} = + 1 + ∑ a, (p a).toReal * (g a d-1) := by + rw [mixture_fiber_real p _ μ₀ μ hpfin hremfin f hf d,hdiag d,hrem] + change L * ((1-∑ a, (p a).toReal)*L⁻¹ + ∑ a, (p a).toReal*(μ a).real (f ⁻¹' {d})) = _ + simp only [g,mul_sub,Finset.sum_sub_distrib,mul_one] + rw [mul_add,← mul_assoc,mul_comm L (1-∑ a, (p a).toReal),mul_assoc,mul_inv_cancel₀ hL.ne',mul_one] + rw [Finset.mul_sum] + simp_rw [mul_left_comm L] + ring + have hh := mixture_density_squares g (fun a => (p a).toReal) M hg hM hgmean + simp_rw [← hden,mul_pow] at hh + rw [← Finset.mul_sum] at hh + apply (mul_le_mul_iff_right₀ hL).mp + nlinarith + + +def digitEndpoint {D : Type uD} (e : Bool) (z : D × D) : D := if e then z.2 else z.1 +lemma digitEndpoint_measurable {D : Type uD} [MeasurableSpace D] (e : Bool) : + Measurable (digitEndpoint (D := D) e) := by + cases e + · exact measurable_fst + · exact measurable_snd + +lemma diagonal_endpoint_real (l : ℕ) [NeZero l] (e : Bool) (d : Fin l) : + (diagonal l).real (digitEndpoint e ⁻¹' {d}) = (l : ℝ)⁻¹ := by + cases e + · change ((diagonal l) (Prod.fst ⁻¹' {d})).toReal = _ + rw [diagonal_fiber_fst]; simp + · change ((diagonal l) (Prod.snd ⁻¹' {d})).toReal = _ + rw [diagonal_fiber_snd]; simp + +lemma rectangle_endpoint_density_bound (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) + (e : Bool) (M : ℝ) (hM : 0 ≤ M) + (hA : (l : ℝ) * (a : ℝ)⁻¹ ≤ M) (hB : (l : ℝ) * ((l-b : ℕ) : ℝ)⁻¹ ≤ M) + (d : Fin l) : (l : ℝ) * (rectangle l a b ha hp hb).real (digitEndpoint e ⁻¹' {d}) ≤ M := by + cases e + · change (l : ℝ) * (rectangle l a b ha hp hb).real (Prod.fst ⁻¹' {d}) ≤ M + rw [rectangle_fst_real] + split_ifs <;> simp_all + · change (l : ℝ) * (rectangle l a b ha hp hb).real (Prod.snd ⁻¹' {d}) ≤ M + rw [rectangle_snd_real] + split_ifs <;> simp_all + +lemma sixComponents_density_bound (l t u r : ℕ) [NeZero l] + (ht : 0 < t ∧ t < l) (hu : 0 < u ∧ u < l) (hr : 0 < r ∧ r < l) + (a b m : ℝ) (ha : 0 < a) (hb : 0 < b) (hm : 0 < m) + (htlo : (l : ℝ)*a/3 ≤ (t : ℝ)) (hthi : (t : ℝ) ≤ (l : ℝ)/2) + (hulo : (l : ℝ)*b/3 ≤ (u : ℝ)) (huhi : (u : ℝ) ≤ (l : ℝ)/2) + (hrlo : (l : ℝ)/(2*m) ≤ (r : ℝ)) (_hrhi : (r : ℝ) ≤ (l : ℝ)/2) + (e : Bool) : ∀ i d, (l : ℝ) * (components l t u r ht hu hr i).real + (digitEndpoint e ⁻¹' {d}) ≤ (![3/a,3/a,3/b,3/b,2*m] : Fin 5 → ℝ) i := by + have bound (n : ℕ) (hn : 0 < n) (w : ℝ) (hw : 0 < w) (hnw : (l : ℝ)*w/3 ≤ n) : + (l : ℝ)*(n : ℝ)⁻¹ ≤ 3/w := by + rw [← div_eq_mul_inv,div_le_div_iff₀ (by exact_mod_cast hn) hw] + linarith + have ht1 := bound t ht.1 a ha htlo + have hu1 := bound u hu.1 b hb hulo + have ht2 := bound (l-t) (by omega) a ha (by rw [Nat.cast_sub ht.2.le]; linarith) + have hu2 := bound (l-u) (by omega) b hb (by rw [Nat.cast_sub hu.2.le]; linarith) + have hr1 : (l : ℝ)*(r : ℝ)⁻¹ ≤ 2*m := by + rw [← div_eq_mul_inv,div_le_iff₀ (by exact_mod_cast hr.1)] + have hh := (div_le_iff₀ (by positivity : 0 < 2*m)).mp hrlo + nlinarith + intro i d + fin_cases i + all_goals dsimp [components] + · exact rectangle_endpoint_density_bound l (l-t) (l-t) (by omega) (by omega) (by omega) e + (3/a) (by positivity) ht2 (by simpa [Nat.sub_sub_self ht.2.le] using ht1) d + · exact rectangle_endpoint_density_bound l t t ht.2 ht.1 ht.2 e (3/a) (by positivity) ht1 ht2 d + · exact rectangle_endpoint_density_bound l (l-u) (l-u) (by omega) (by omega) (by omega) e + (3/b) (by positivity) hu2 (by simpa [Nat.sub_sub_self hu.2.le] using hu1) d + · exact rectangle_endpoint_density_bound l u u hu.2 hu.1 hu.2 e (3/b) (by positivity) hu1 hu2 d + · exact rectangle_endpoint_density_bound l r (l-r) hr.2 hr.1 (by omega) e (2*m) (by positivity) + hr1 (by simpa [Nat.sub_sub_self hr.2.le] using hr1) d + +lemma sixLaw_second_moment (l t u r : ℕ) [NeZero l] + (ht : 0 < t ∧ t < l) (hu : 0 < u ∧ u < l) (hr : 0 < r ∧ r < l) + (a b m κ ρ σ τ I : ℝ) (ha : 0 < a) (hb : 0 < b) (hm : 0 < m) + (hρ : 0 ≤ ρ) (hσ : 0 ≤ σ) (hτ : 0 ≤ τ) + (htlo : (l : ℝ)*a/3 ≤ (t : ℝ)) (hthi : (t : ℝ) ≤ (l : ℝ)/2) + (hulo : (l : ℝ)*b/3 ≤ (u : ℝ)) (huhi : (u : ℝ) ≤ (l : ℝ)/2) + (hrlo : (l : ℝ)/(2*m) ≤ (r : ℝ)) (hrhi : (r : ℝ) ≤ (l : ℝ)/2) + (hρsq : ρ^2 = κ^2*a/m) (hσsq : σ^2 = κ^2*b/m) (hτsq : τ^2 ≤ I/m^2) + (hprob : 2*ENNReal.ofReal ρ+2*ENNReal.ofReal σ+ENNReal.ofReal τ ≤ 1) + (e : Bool) : + (l : ℝ) * ∑ d : Fin l, + ((sixLaw l t u r ht hu hr (ENNReal.ofReal ρ) (ENNReal.ofReal σ) (ENNReal.ofReal τ)).real + {ω | digitEndpoint e ω.2 = d})^2 ≤ 1+(60*κ^2+10*I)/m := by + have hh := mixture_endpoint_second_moment (sixWeights (ENNReal.ofReal ρ) (ENNReal.ofReal σ) (ENNReal.ofReal τ)) + (diagonal l) (components l t u r ht hu hr) (by simpa [sum_sixWeights] using hprob) + (digitEndpoint e) (digitEndpoint_measurable e) (by intro d; simpa using diagonal_endpoint_real l e d) + (![3/a,3/a,3/b,3/b,2*m]) + (by simpa using sixComponents_density_bound l t u r ht hu hr a b m ha hb hm htlo hthi hulo huhi hrlo hrhi e) + simp only [Fintype.card_fin,sum_sixWeights] at hh + change (l : ℝ) * ∑ d : Fin l, _ ≤ _ at hh + change (l : ℝ) * ∑ d : Fin l, _ ≤ _ + apply hh.trans + simp only [sixWeights,Fin.sum_univ_succ,Matrix.cons_val_zero,Matrix.cons_val_succ, + Fin.sum_univ_zero,add_zero,ENNReal.toReal_ofReal hρ, + ENNReal.toReal_ofReal hσ,ENNReal.toReal_ofReal hτ] + have heq : 1+(5 : ℝ)*(ρ^2*(3/a)+(ρ^2*(3/a)+(σ^2*(3/b)+(σ^2*(3/b)+τ^2*(2*m))))) = + 1+60*κ^2/m+10*m*τ^2 := by rw [hρsq,hσsq]; field_simp; ring + norm_num only [Nat.cast_ofNat] + rw [heq] + have hτ' := mul_le_mul_of_nonneg_left hτsq (by positivity : 0 ≤ 10*m) + have hid : 10*m*(I/m^2) = 10*I/m := by field_simp + rw [hid] at hτ' + calc + _ ≤ 1+60*κ^2/m+10*I/m := by linarith + _ = _ := by ring + +end +open MeasureTheory Set +open scoped ENNReal +section + +lemma fiber_failure_bound {Ω : Type uΩ} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F S : Set Ω) (hS : MeasurableSet S) + (c : ℝ) (_hc : 0 ≤ c) (hc' : c ≤ 1) + (hhit : c * μ.real F ≤ μ.real (F ∩ S)) : + μ (F ∩ Sᶜ) ≤ ENNReal.ofReal (1-c) * μ F := by + apply (ENNReal.toReal_le_toReal (measure_ne_top _ _) + (ENNReal.mul_ne_top ENNReal.ofReal_ne_top (measure_ne_top _ _))).mp + rw [ENNReal.toReal_mul, ENNReal.toReal_ofReal (sub_nonneg.mpr hc')] + change μ.real (F ∩ Sᶜ) ≤ (1-c) * μ.real F + have hsum := measureReal_sdiff_add_inter (μ := μ) (s := F) hS + rw [sdiff_eq] at hsum + nlinarith + +lemma fiber_failure_of_density_bounds {Ω : Type uΩ} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F S : Set Ω) (hS : MeasurableSet S) + (r B : ℝ) (hr : 0 ≤ r) (hB : 0 < B) (hrB : r ≤ B) + (htotal : μ.real F ≤ B) (hhit : r ≤ μ.real (F ∩ S)) : + μ (F ∩ Sᶜ) ≤ ENNReal.ofReal (1-r/B) * μ F := by + apply fiber_failure_bound μ F S hS (r/B) (div_nonneg hr hB.le) + ((div_le_one hB).mpr hrB) + exact (mul_le_mul_of_nonneg_left htotal (div_nonneg hr hB.le)).trans + (by simpa [div_mul_cancel₀ _ hB.ne'] using hhit) + +lemma fiber_failure_tenth {Ω : Type uΩ} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F S : Set Ω) (hS : MeasurableSet S) + (ρ l : ℝ) (hρ : 0 ≤ ρ) (hρ' : ρ ≤ 1) (hl : 0 < l) + (htotal : μ.real F ≤ 10/l) (hhit : ρ/l ≤ μ.real (F ∩ S)) : + μ (F ∩ Sᶜ) ≤ ENNReal.ofReal (1-ρ/10) * μ F := by + have h := fiber_failure_of_density_bounds μ F S hS (ρ/l) (10/l) + (div_nonneg hρ hl.le) (div_pos (by norm_num) hl) + (div_le_div_of_nonneg_right (by linarith : ρ ≤ 10) hl.le) htotal hhit + simpa [div_div_div_cancel_right₀ hl.ne'] using h +end + +lemma sixLaw_density_ten (l t u r : ℕ) [NeZero l] + (ht : 0 < t ∧ t < l) (hu : 0 < u ∧ u < l) (hr : 0 < r ∧ r < l) + (a b m κ ρ σ τ : ℝ) (ha : 0 < a) (hb : 0 < b) (hm : 0 < m) + (hκ : κ ≤ 1/100) (hρ : 0 ≤ ρ) (hσ : 0 ≤ σ) (hτ : 0 ≤ τ) + (htlo : (l : ℝ)*a/3 ≤ (t : ℝ)) (hthi : (t : ℝ) ≤ (l : ℝ)/2) + (hulo : (l : ℝ)*b/3 ≤ (u : ℝ)) (huhi : (u : ℝ) ≤ (l : ℝ)/2) + (hrlo : (l : ℝ)/(2*m) ≤ (r : ℝ)) (hrhi : (r : ℝ) ≤ (l : ℝ)/2) + (hρα : ρ/a ≤ κ) (hσb : σ/b ≤ κ) (hτm : τ ≤ 1/m) + (hprob : 2*ENNReal.ofReal ρ+2*ENNReal.ofReal σ+ENNReal.ofReal τ ≤ 1) + (e : Bool) (d : Fin l) : + (sixLaw l t u r ht hu hr (ENNReal.ofReal ρ) (ENNReal.ofReal σ) (ENNReal.ofReal τ)).real + {ω | digitEndpoint e ω.2 = d} ≤ 10/l := by + have hl : (0 : ℝ) < l := Nat.cast_pos.mpr (NeZero.pos l) + let M : Fin 5 → ℝ := ![3/a,3/a,3/b,3/b,2*m] + have hM := sixComponents_density_bound l t u r ht hu hr a b m ha hb hm + htlo hthi hulo huhi hrlo hrhi e + have hh := sixLaw_fiber_real_le l t u r ht hu hr (ENNReal.ofReal ρ) (ENNReal.ofReal σ) + (ENNReal.ofReal τ) hprob (digitEndpoint e) (digitEndpoint_measurable e) d + (diagonal_endpoint_real l e d) (fun i => M i/l) + (fun i => by apply (le_div_iff₀ hl).mpr; simpa [mul_comm,M] using hM i d) + apply hh.trans + simp only [M,sixWeights,Fin.sum_univ_succ,Matrix.cons_val_zero,Matrix.cons_val_succ, + Fin.sum_univ_zero,add_zero,ENNReal.toReal_ofReal hρ, + ENNReal.toReal_ofReal hσ,ENNReal.toReal_ofReal hτ] + have hτ' : τ*m ≤ 1 := by have := (le_div_iff₀ hm).mp hτm; nlinarith + have hsum : 1 + 6*(ρ/a)+6*(σ/b)+2*(τ*m) ≤ 10 := by linarith + calc + _ = (1+6*(ρ/a)+6*(σ/b)+2*(τ*m))/l := by ring + _ ≤ _ := div_le_div_of_nonneg_right hsum hl.le + +lemma sixLaw_top_t_failure (l t u r : ℕ) [NeZero l] + (ht : 0 scaledTail b d i < u i) +def selectedAbove (b : ℕ → ℕ) (I : Finset ℕ) (u : ℕ → ℝ) (d : Digits b) : Finset I := by + classical + exact Finset.univ.filter (fun i => u i ≤ scaledTail b d i) + +lemma crossing_top_domination {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) + (μ : ∀ i, Measure (Option (Fin 5) × (Fin (b i) × Fin (b i)))) + [∀ i, IsProbabilityMeasure (μ i)] (I : Finset ℕ) (t : ℕ → ℕ) (u w : ℕ → ℝ) + (top : Fin 5) (ρ m : ℝ) (hρ : 0≤ρ) (hρ1 : ρ≤1) + (ht : ∀ i ∈ I, t i ≤ b i) (hw : ∀ i ∈ I, 0 (ω i).2.1)).card:ℝ)) + (hsupport : ∀ ω ∈ H, ∀ i ∈ I, (ω i).1=some top → b i-t i ≤ (ω i).2.2.val) + (hnocross : ∀ ω ∈ H, ∀ i ∈ I, ¬(scaledTail b (fun i => (ω i).2.1) i < u i ∧ + u i ≤ scaledTail b (fun i => (ω i).2.2) i)) : + Measure.map (fun ω => endpoint b (fun i => (ω i).2.1)) ((Measure.infinitePi μ).restrict H) ≤ + ENNReal.ofReal (Real.exp (-m*ρ/400)) • + Measure.map (fun ω => endpoint b (fun i => (ω i).2.1)) (Measure.infinitePi μ) := by + classical + apply infinite_selected_failures μ I (fun _ z => z.2.1) (fun _ => by fun_prop) + (endpoint b) (measurable_endpoint b) H hH + (fun _ => {z | z.1=some top}ᶜ) (selectedBelow b I u) + (fun _ => ENNReal.ofReal (1-ρ/10)) + · intro d i hi + have hi' : scaledTail b d i < u i := (Finset.mem_filter.mp hi).2 + have hh := hlocal i i.property (d i) (digit_below_threshold + (by have := hb i; omega) (ht i i.property) (hw i i.property) + (hround i i.property) (hu i i.property) (digit_interval_weak hb d i).1 hi') + simpa only [Set.preimage,Set.mem_singleton_iff] using hh + · intro ω hω + rw [Finset.prod_const] + exact failure_power_exponential ρ m _ hρ hρ1 (hcard ω hω) + · intro ω hω i hi hlabel + have hx : scaledTail b (fun i => (ω i).2.1) i < u i := (Finset.mem_filter.mp hi).2 + apply hnocross ω hω i i.property + refine ⟨hx,le_of_lt ?_⟩ + exact top_forces_above (by have := hb i; omega) (ht i i.property) (hw i i.property) + (hround i i.property) (hu i i.property) (digit_interval_weak hb (fun i => (ω i).2.2) i).1 + (hsupport ω hω i i.property hlabel) + +lemma crossing_bottom_domination {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) + (μ : ∀ i, Measure (Option (Fin 5) × (Fin (b i) × Fin (b i)))) + [∀ i, IsProbabilityMeasure (μ i)] (I : Finset ℕ) (t : ℕ → ℕ) (u w : ℕ → ℝ) + (bottom : Fin 5) (ρ m : ℝ) (hρ : 0≤ρ) (hρ1 : ρ≤1) + (hw : ∀ i ∈ I, 0 (ω i).2.2)).card:ℝ)) + (hsupport : ∀ ω ∈ H, ∀ i ∈ I, (ω i).1=some bottom → (ω i).2.1.val (ω i).2.1) i < u i ∧ + u i ≤ scaledTail b (fun i => (ω i).2.2) i)) : + Measure.map (fun ω => endpoint b (fun i => (ω i).2.2)) ((Measure.infinitePi μ).restrict H) ≤ + ENNReal.ofReal (Real.exp (-m*ρ/400)) • + Measure.map (fun ω => endpoint b (fun i => (ω i).2.2)) (Measure.infinitePi μ) := by + classical + apply infinite_selected_failures μ I (fun _ z => z.2.2) (fun _ => by fun_prop) + (endpoint b) (measurable_endpoint b) H hH + (fun _ => {z | z.1=some bottom}ᶜ) (selectedAbove b I u) + (fun _ => ENNReal.ofReal (1-ρ/10)) + · intro d i hi + have hi' : u i ≤ scaledTail b d i := (Finset.mem_filter.mp hi).2 + have hh := hlocal i i.property (d i) (digit_above_threshold + (by have := hb i; omega) (hw i i.property) + (hround i i.property) (hu i i.property) (digit_interval_weak hb d i).2 hi') + simpa only [Set.preimage,Set.mem_singleton_iff] using hh + · intro ω hω + rw [Finset.prod_const] + exact failure_power_exponential ρ m _ hρ hρ1 (hcard ω hω) + · intro ω hω i hi hlabel + have hy : u i ≤ scaledTail b (fun i => (ω i).2.2) i := (Finset.mem_filter.mp hi).2 + apply hnocross ω hω i i.property + refine ⟨?_,hy⟩ + exact bottom_forces_below (by have := hb i; omega) (hw i i.property) + (hround i i.property) (hu i i.property) (digit_interval_weak hb (fun i => (ω i).2.1) i).2 + (hsupport ω hω i i.property hlabel) +end +open CircleDigits +lemma measurable_selectedBelow_card (b : ℕ → ℕ) (I : Finset ℕ) (u : ℕ → ℝ) : + Measurable (fun d : Digits b => (selectedBelow b I u d).card) := by + classical + have he : (fun d : Digits b => (selectedBelow b I u d).card) = + fun d => ∑ i : I, if scaledTail b d i < u i then 1 else 0 := by + funext d + simp only [selectedBelow,Finset.card_filter] + rw [he] + apply Finset.measurable_sum + intro i _ + exact Measurable.ite (measurableSet_lt (measurable_scaledTail b i) measurable_const) + measurable_const measurable_const + +def noCross (b : ℕ → ℕ) (I : Finset ℕ) (u : ℕ → ℝ) : Set (LabelledDigits b) := + {ω | ∀ i ∈ I, ¬(scaledTail b (fun k => (ω k).2.1) i < u i ∧ + u i ≤ scaledTail b (fun k => (ω k).2.2) i)} +lemma measurableSet_noCross (b : ℕ → ℕ) (I : Finset ℕ) (u : ℕ → ℝ) : + MeasurableSet (noCross b I u) := by + simp only [noCross,Set.ofPred_forall] + apply MeasurableSet.iInter + intro i + apply MeasurableSet.iInter + intro _ + exact ((measurableSet_lt ((measurable_scaledTail b i).comp (by fun_prop)) measurable_const).inter + (measurableSet_le measurable_const ((measurable_scaledTail b i).comp (by fun_prop)))).compl + +lemma selected_card_sum {b : ℕ → ℕ} (I : Finset ℕ) (u : ℕ → ℝ) (ω : LabelledDigits b) + (horder : ∀ i ∈ I, scaledTail b (fun k => (ω k).2.1) i ≤ scaledTail b (fun k => (ω k).2.2) i) + (hno : ω ∈ noCross b I u) : + (selectedBelow b I u (fun k => (ω k).2.1)).card + + (selectedAbove b I u (fun k => (ω k).2.2)).card = I.card := by + classical + have he : selectedAbove b I u (fun k => (ω k).2.2) = + Finset.univ.filter (fun i : I => ¬scaledTail b (fun k => (ω k).2.1) i < u i) := by + ext i + simp only [selectedAbove,Finset.mem_filter,Finset.mem_univ,true_and,not_lt] + constructor + · intro hi + by_contra hh + exact hno i i.property ⟨lt_of_not_ge hh,hi⟩ + · intro hi + exact hi.trans (horder i i.property) + rw [he] + simpa only [selectedBelow,Finset.card_univ,Fintype.card_coe] using + Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset I)) + (p := fun i => scaledTail b (fun k => (ω k).2.1) i < u i) + +lemma crossing_split {b : ℕ → ℕ} (I : Finset ℕ) (u : ℕ → ℝ) (m : ℝ) + (hI : m/20 ≤ (I.card:ℝ)) (G : Set (LabelledDigits b)) (hG : MeasurableSet G) + (horder : ∀ ω ∈ G, ∀ i ∈ I, + scaledTail b (fun k => (ω k).2.1) i ≤ scaledTail b (fun k => (ω k).2.2) i) : + ∃ H₁ H₂ : Set (LabelledDigits b), MeasurableSet H₁ ∧ MeasurableSet H₂ ∧ + Disjoint H₁ H₂ ∧ H₁ ∪ H₂ = noCross b I u ∩ G ∧ + (∀ ω ∈ H₁, m/40 ≤ ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ)) ∧ + (∀ ω ∈ H₂, m/40 ≤ ((selectedAbove b I u (fun k => (ω k).2.2)).card:ℝ)) := by + classical + let A : Set (LabelledDigits b) := {ω | (I.card:ℝ)/2 ≤ + ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ)} + have hA : MeasurableSet A := measurableSet_le measurable_const + ((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp + ((measurable_selectedBelow_card b I u).comp (show Measurable (fun ω : LabelledDigits b => fun k => (ω k).2.1) from by fun_prop))) + let N := noCross b I u ∩ G + refine ⟨N ∩ A,N \ A,((measurableSet_noCross b I u).inter hG).inter hA, + ((measurableSet_noCross b I u).inter hG).diff hA,disjoint_left.mpr (by + intro ω h₁ h₂; exact h₂.2 h₁.2),?_,?_,?_⟩ + · exact Set.inter_union_sdiff N A + · intro ω hω + have ha : (I.card:ℝ)/2 ≤ ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ) := hω.2 + linarith + · intro ω hω + have ha : ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ) < (I.card:ℝ)/2 := + lt_of_not_ge hω.2 + have hs := selected_card_sum I u ω (horder ω hω.1.2) hω.1.1 + have hs' : ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ) + + ((selectedAbove b I u (fun k => (ω k).2.2)).card:ℝ) = I.card := by exact_mod_cast hs + linarith +end +open CircleDigits + +lemma conditional_crossing_estimates {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) + (μ : ∀ i, Measure (Option (Fin 5) × (Fin (b i) × Fin (b i)))) + [∀ i, IsProbabilityMeasure (μ i)] (I : Finset ℕ) (t : ℕ → ℕ) (u w : ℕ → ℝ) + (top bottom : Fin 5) (ρ m : ℝ) (hρ : 0≤ρ) (hρ1 : ρ≤1) + (hI : m/20 ≤ (I.card:ℝ)) (ht : ∀ i ∈ I, t i ≤ b i) (hw : ∀ i ∈ I, 0 (ω k).2.1) i ≤ scaledTail b (fun k => (ω k).2.2) i) + (hst : ∀ ω ∈ G, ∀ i ∈ I, (ω i).1=some top → b i-t i ≤ (ω i).2.2.val) + (hsb : ∀ ω ∈ G, ∀ i ∈ I, (ω i).1=some bottom → (ω i).2.1.val (ω i).2.1)).card:ℝ)} ∧ + Measure.map (fun ω => endpoint b (fun i => (ω i).2.1)) ((Measure.infinitePi μ).restrict H₁) ≤ + ENNReal.ofReal (Real.exp (-m*ρ/400)) • + Measure.map (fun ω => endpoint b (fun i => (ω i).2.1)) (Measure.infinitePi μ) ∧ + Measure.map (fun ω => endpoint b (fun i => (ω i).2.2)) ((Measure.infinitePi μ).restrict H₂) ≤ + ENNReal.ofReal (Real.exp (-m*ρ/400)) • + Measure.map (fun ω => endpoint b (fun i => (ω i).2.2)) (Measure.infinitePi μ) := by + classical + let A : Set (LabelledDigits b) := {ω | (I.card:ℝ)/2 ≤ + ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ)} + have hA : MeasurableSet A := measurableSet_le measurable_const + ((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp + ((measurable_selectedBelow_card b I u).comp (show Measurable (fun ω : LabelledDigits b => fun k => (ω k).2.1) from by fun_prop))) + let N := noCross b I u + have hN := measurableSet_noCross b I u + let H₁ := N ∩ A + let H₂ := N \ A + have h₁ : MeasurableSet H₁ := hN.inter hA + have h₂ : MeasurableSet H₂ := hN.diff hA + have he (H : Set (LabelledDigits b)) : + (Measure.infinitePi μ).restrict H = (Measure.infinitePi μ).restrict (H ∩ G) := by + apply Measure.restrict_congr_set + filter_upwards [hae] with ω hω + change (ω ∈ H) = (ω ∈ H ∩ G) + apply propext + exact ⟨fun h => ⟨h,hω⟩,fun h => h.1⟩ + refine ⟨H₁,H₂,h₁,h₂,disjoint_left.mpr (by intro ω h₁ h₂; exact h₂.2 h₁.2), + Set.inter_union_sdiff N A,rfl,?_,?_⟩ + · rw [he] + apply crossing_top_domination hb μ I t u w top ρ m hρ hρ1 ht hw hround + (fun i hi => (hu i hi).2) htop (H₁ ∩ G) (h₁.inter hG) + · intro ω hω + have ha : (I.card:ℝ)/2 ≤ ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ) := hω.1.2 + linarith + · intro ω hω i hi + exact hst ω hω.2 i hi + · intro ω hω + exact hω.1.1 + · rw [he] + apply crossing_bottom_domination hb μ I t u w bottom ρ m hρ hρ1 hw hround + (fun i hi => (hu i hi).1) hbottom (H₂ ∩ G) (h₂.inter hG) + · intro ω hω + have ha : ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ) < (I.card:ℝ)/2 := + lt_of_not_ge hω.1.2 + have hs := selected_card_sum I u ω (horder ω hω.2) hω.1.1 + have hs' : ((selectedBelow b I u (fun k => (ω k).2.1)).card:ℝ) + + ((selectedAbove b I u (fun k => (ω k).2.2)).card:ℝ) = I.card := by exact_mod_cast hs + linarith + · intro ω hω i hi + exact hsb ω hω.2 i hi + · intro ω hω + exact hω.1.1 +end +namespace CoordinateParameters +variable (P : CoordinateParameters) +def width (e : Bool) : ℝ := if e then P.b else P.a +def prob (e : Bool) : ℝ := if e then P.σ else P.ρ +def topLabel (e : Bool) : Fin 5 := if e then 2 else 0 +def bottomLabel (e : Bool) : Fin 5 := if e then 3 else 1 +lemma width_pos (e : Bool) : 0 first | exact P.a_pos | exact P.b_pos +lemma width_round (e : Bool) : 0 < roundedWidth P.l (P.width e) ∧ roundedWidth P.l (P.width e) < P.l ∧ + (P.l:ℝ)*P.width e/3 ≤ roundedWidth P.l (P.width e) ∧ + (roundedWidth P.l (P.width e):ℝ) ≤ (P.l:ℝ)*P.width e/2 := by + cases e <;> first | exact P.width_a | exact P.width_b +lemma prob_nonneg (e : Bool) : 0≤P.prob e := by cases e <;> first | exact P.ρ_nonneg | exact P.σ_nonneg +lemma prob_le_one (e : Bool) : P.prob e≤1 := by cases e <;> first | exact P.ρ_le_one | exact P.σ_le_one +lemma top_failure (tagged e : Bool) (d : Fin P.l) + (hd : d.val < P.l-roundedWidth P.l (P.width e)) : + P.law tagged ({z | z.2.1=d} ∩ {z | z.1=some (topLabel e)}ᶜ) ≤ + ENNReal.ofReal (1-P.prob e/10)*P.law tagged {z | z.2.1=d} := by + cases e + · exact P.top_a_failure tagged d hd + · exact P.top_b_failure tagged d hd +lemma bottom_failure (tagged e : Bool) (d : Fin P.l) + (hd : roundedWidth P.l (P.width e) ≤ d.val) : + P.law tagged ({z | z.2.2=d} ∩ {z | z.1=some (bottomLabel e)}ᶜ) ≤ + ENNReal.ofReal (1-P.prob e/10)*P.law tagged {z | z.2.2=d} := by + cases e + · exact P.bottom_a_failure tagged d hd + · exact P.bottom_b_failure tagged d hd +lemma top_support (e : Bool) (z : P.Sample) + (hz : supportCondition P.l (roundedWidth P.l P.a) (roundedWidth P.l P.b) (roundedTag P.l P.m) z) + (hlabel : z.1=some (topLabel e)) : P.l-roundedWidth P.l (P.width e) ≤ z.2.2.val := by + cases e <;> simp only [topLabel,Bool.false_eq_true,↓reduceIte] at hlabel + · have h := hz + simp [supportCondition,hlabel] at h + change P.l - roundedWidth P.l P.a ≤ _ + omega + · have h := hz + simp [supportCondition,hlabel] at h + change P.l - roundedWidth P.l P.b ≤ _ + omega +lemma bottom_support (e : Bool) (z : P.Sample) + (hz : supportCondition P.l (roundedWidth P.l P.a) (roundedWidth P.l P.b) (roundedTag P.l P.m) z) + (hlabel : z.1=some (bottomLabel e)) : z.2.1.val < roundedWidth P.l (P.width e) := by + cases e <;> simp only [bottomLabel,Bool.false_eq_true,↓reduceIte] at hlabel + · have h := hz + simp [supportCondition,hlabel] at h + exact h.1 + · have h := hz + simp [supportCondition,hlabel] at h + exact h.1 +end CoordinateParameters +namespace DigitSystem +open CircleDigits CoordinateParameters +variable (S : DigitSystem) +def crossingWidth (e : Bool) : ℕ → ℝ | 0 => 1 | n+1 => (S.coord n).width e +def crossingDigit (e : Bool) : ℕ → ℕ | 0 => 0 | n+1 => roundedWidth (S.coord n).l ((S.coord n).width e) +def supported : Set S.Samples := {ω | (∀ i, (ω i).2.1 ≤ (ω i).2.2) ∧ ∀ n, + supportCondition (S.coord n).l (roundedWidth (S.coord n).l (S.coord n).a) + (roundedWidth (S.coord n).l (S.coord n).b) (roundedTag (S.coord n).l (S.coord n).m) (ω (n+1))} +lemma measurableSet_supported : MeasurableSet S.supported := by + simp only [supported,Set.ofPred_and,Set.ofPred_forall] + apply MeasurableSet.inter + · exact MeasurableSet.iInter (fun n => ((Set.to_countable {z : S.Sample n | z.2.1 ≤ z.2.2}).measurableSet).preimage (measurable_pi_apply n)) + · exact MeasurableSet.iInter (fun n => ((Set.to_countable {z : S.Sample (n+1) | supportCondition (S.coord n).l (roundedWidth (S.coord n).l (S.coord n).a) (roundedWidth (S.coord n).l (S.coord n).b) (roundedTag (S.coord n).l (S.coord n).m) z}).measurableSet).preimage (measurable_pi_apply (n+1))) +lemma ae_supported (tagged : ℕ → Bool) : ∀ᵐ ω ∂S.probability tagged, ω ∈ S.supported := by + have hs : ∀ᵐ ω ∂S.probability tagged, ∀ n, + supportCondition (S.coord n).l (roundedWidth (S.coord n).l (S.coord n).a) + (roundedWidth (S.coord n).l (S.coord n).b) (roundedTag (S.coord n).l (S.coord n).m) (ω (n+1)) := by + rw [ae_all_iff] + intro n + exact (measurePreserving_eval_infinitePi (S.law tagged) (n+1)).quasiMeasurePreserving.ae + ((S.coord n).law_support (tagged n)) + filter_upwards [S.ae_digit_order tagged,hs] with ω hω hs + exact ⟨hω,hs⟩ +end DigitSystem +end CircleCoupling +namespace CircleCoupling.DigitSystem +open CircleDigits CoordinateParameters +variable (S : DigitSystem) + +lemma actual_crossing_estimates (tagged : ℕ → Bool) (e : Bool) (I : Finset ℕ) + (h0 : 0 ∉ I) (u : ℕ → ℝ) (m ρ : ℝ) (hρ : 0≤ρ) (hρ1 : ρ≤1) + (hI : m/20 ≤ (I.card:ℝ)) + (hcommon : ∀ n, n+1 ∈ I → (S.coord n).prob e=ρ) + (hu : ∀ i ∈ I, S.crossingWidth e i ≤ u i ∧ u i ≤ 1-S.crossingWidth e i) : + ∃ H₁ H₂ : Set S.Samples, MeasurableSet H₁ ∧ MeasurableSet H₂ ∧ + Disjoint H₁ H₂ ∧ H₁ ∪ H₂ = noCross S.radix I u ∧ + H₁ = noCross S.radix I u ∩ {ω | (I.card:ℝ)/2 ≤ + ((selectedBelow S.radix I u (fun i => (ω i).2.1)).card:ℝ)} ∧ + Measure.map (S.endpoint (fun _ => false)) ((S.probability tagged).restrict H₁) ≤ + ENNReal.ofReal (Real.exp (-m*ρ/400)) • + Measure.map (S.endpoint (fun _ => false)) (S.probability tagged) ∧ + Measure.map (S.endpoint (fun _ => true)) ((S.probability tagged).restrict H₂) ≤ + ENNReal.ofReal (Real.exp (-m*ρ/400)) • + Measure.map (S.endpoint (fun _ => true)) (S.probability tagged) := by + apply conditional_crossing_estimates S.radix_ge_two (S.law tagged) I + (S.crossingDigit e) u (S.crossingWidth e) (topLabel e) (bottomLabel e) ρ m hρ hρ1 hI + · intro i hi + cases i with + | zero => exact False.elim (h0 hi) + | succ n => exact (S.coord n).width_round e |>.2.1.le + · intro i hi + cases i with + | zero => exact False.elim (h0 hi) + | succ n => exact (S.coord n).width_pos e + · intro i hi + cases i with + | zero => exact False.elim (h0 hi) + | succ n => exact (S.coord n).width_round e |>.2.2.2 + · exact hu + · intro i hi d hd + cases i with + | zero => exact False.elim (h0 hi) + | succ n => + have hh := (S.coord n).top_failure (tagged n) e d hd + rw [hcommon n hi] at hh + exact hh + · intro i hi d hd + cases i with + | zero => exact False.elim (h0 hi) + | succ n => + have hh := (S.coord n).bottom_failure (tagged n) e d hd + rw [hcommon n hi] at hh + exact hh + · exact S.measurableSet_supported + · exact S.ae_supported tagged + · intro ω hω i _ + exact scaledTail_mono S.radix_ge_two hω.1 i + · intro ω hω i hi hlabel + cases i with + | zero => exact False.elim (h0 hi) + | succ n => exact (S.coord n).top_support e _ (hω.2 n) hlabel + · intro ω hω i hi hlabel + cases i with + | zero => exact False.elim (h0 hi) + | succ n => exact (S.coord n).bottom_support e _ (hω.2 n) hlabel +end CircleCoupling.DigitSystem + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Decomposable.lean b/lean/OAI/Analysis/RotationWeights/Decomposable.lean new file mode 100644 index 0000000000000000000000000000000000000000..284b7e01efcedeea94c6e4f9fabd465ca32814dc --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Decomposable.lean @@ -0,0 +1,231 @@ +import OAI.Analysis.RotationWeights.FieldExtraction + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uX uE + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace + +section +variable {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [InnerProductSpace ℂ E] +lemma fieldMulL2_indicator (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) + (C : ℝ) (hC : ∀ᵐ x ∂μ, ‖T x‖ ≤ C) (s : Set X) (hs : MeasurableSet s) + (f : Lp E 2 μ) : + fieldMulL2 μ T hT C hC (indicatorV2 μ s hs f) = + indicatorV2 μ s hs (fieldMulL2 μ T hT C hC f) := by + apply Lp.ext + filter_upwards [fieldMulL2_coe μ T hT C hC (indicatorV2 μ s hs f), + indicatorV2_coe μ s hs f, indicatorV2_coe μ s hs (fieldMulL2 μ T hT C hC f), + fieldMulL2_coe μ T hT C hC f] with x h1 h2 h3 h4 + rw [h1,h2,h3] + by_cases hx : x∈s + · simpa only [indicator_of_mem hx] using h4.symm + · simp only [indicator_of_notMem hx, map_zero] + +variable [IsFiniteMeasure μ] + +lemma indicatorConstLp_eq_indicatorV2 (c : E) (s : Set X) (hs : MeasurableSet s) + (hμs : μ s ≠ ∞) : + indicatorConstLp 2 hs hμs c = indicatorV2 μ s hs (Lp.const 2 μ c) := by + apply Lp.ext + filter_upwards [indicatorConstLp_coeFn (p := 2) (hs := hs) (hμs := hμs) (c := c), + indicatorV2_coe μ s hs (Lp.const 2 μ c), Lp.coeFn_const 2 μ c] with x h1 h2 h3 + rw [h1,h2] + by_cases hx : x∈s + · simp only [indicator_of_mem hx, h3, Function.const_apply] + · simp only [indicator_of_notMem hx] + +theorem commutes_indicators_decomposable [CompleteSpace E] [TopologicalSpace.SeparableSpace E] + (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) + (hA : ∀ s (hs : MeasurableSet s), A.comp (indicatorV2 μ s hs) = + (indicatorV2 μ s hs).comp A) : + ∃ T : X → (E →L[ℂ] E), (∀ x, ‖T x‖ ≤ ‖A‖) ∧ + (∀ u : E, AEStronglyMeasurable (fun x ↦ T x u) μ) ∧ + (∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) := by + obtain ⟨v,hv⟩ := TopologicalSpace.exists_dense_seq E + obtain ⟨T,hT,heq⟩ := extract_bounded_field μ A + (commutes_indicator_pointwise_bound μ A hA) v hv + have hm (u : E) : AEStronglyMeasurable (fun x ↦ T x u) μ := + (Lp.aestronglyMeasurable (A (Lp.const 2 μ u))).congr (EventuallyEq.symm (heq u)) + let B := fieldMulL2 μ T hm ‖A‖ (Eventually.of_forall hT) + have hconst (u : E) : B (Lp.const 2 μ u) = A (Lp.const 2 μ u) := by + apply Lp.ext + filter_upwards [fieldMulL2_coe μ T hm ‖A‖ (Eventually.of_forall hT) (Lp.const 2 μ u), + Lp.coeFn_const 2 μ u, heq u] with x h1 h2 h3 + rw [h1,h2] + exact h3 + have hAB : A = B := by + apply ContinuousLinearMap.ext + intro f + apply Lp.induction (by norm_num : (2:ℝ≥0∞) ≠ ∞) (fun f ↦ A f = B f) _ _ _ f + · intro c s hs hμs + rw [Lp.simpleFunc.coe_indicatorConst, indicatorConstLp_eq_indicatorV2 μ c s hs] + change A _ = fieldMulL2 μ T hm ‖A‖ (Eventually.of_forall hT) _ + rw [fieldMulL2_indicator] + change A _ = indicatorV2 μ s hs (B (Lp.const 2 μ c)) + rw [hconst] + exact congrArg (fun F : Lp E 2 μ →L[ℂ] Lp E 2 μ ↦ F (Lp.const 2 μ c)) (hA s hs) + · intro f g _ _ _ hf hg + simp only [map_add,hf,hg] + · exact isClosed_eq A.continuous B.continuous + refine ⟨T,hT,hm,fun f ↦ ?_⟩ + rw [hAB] + exact fieldMulL2_coe μ T hm ‖A‖ (Eventually.of_forall hT) f +end + +section +variable {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + +lemma inner_indicatorV2 (s : Set X) (hs : MeasurableSet s) (f g : Lp E 2 μ) : + inner ℂ f (indicatorV2 μ s hs g) = ∫ x in s, inner ℂ (f x) (g x) ∂μ := by + rw [L2.inner_def, ← integral_indicator hs] + apply integral_congr_ae + filter_upwards [indicatorV2_coe μ s hs g] with x hx + rw [hx] + by_cases hxs : x∈s <;> simp [hxs] + +variable [IsFiniteMeasure μ] + +lemma decomposable_const (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) + (T : X → (E →L[ℂ] E)) + (hA : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) (u : E) : + ∀ᵐ x ∂μ, (A (Lp.const 2 μ u)) x = T x u := by + filter_upwards [hA (Lp.const 2 μ u), Lp.coeFn_const 2 μ u] with x h1 h2 + simpa only [h2,Function.const_apply] using h1 + +omit [IsFiniteMeasure μ] in +lemma ae_field_eq_of_dense [TopologicalSpace.SeparableSpace E] + (T R : X → (E →L[ℂ] E)) (h : ∀ u, ∀ᵐ x ∂μ, T x u = R x u) : + ∀ᵐ x ∂μ, T x = R x := by + obtain ⟨v,hv⟩ := TopologicalSpace.exists_dense_seq E + have hh : ∀ᵐ x ∂μ, ∀ n : ℕ, T x (v n) = R x (v n) := ae_all_iff.mpr (fun n ↦ h (v n)) + filter_upwards [hh] with x hx + apply ContinuousLinearMap.ext + exact congrFun (hv.equalizer (T x).continuous (R x).continuous (funext hx)) + +omit [IsFiniteMeasure μ] in +lemma decomposable_mul (A B : Lp E 2 μ →L[ℂ] Lp E 2 μ) + (T R : X → (E →L[ℂ] E)) + (hA : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) + (hB : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (B f) x = R x (f x)) + (f : Lp E 2 μ) : ∀ᵐ x ∂μ, ((A*B) f) x = (T x*R x) (f x) := by + filter_upwards [hA (B f),hB f] with x h1 h2 + simpa only [mul_apply_eq_comp,h2] using h1 + +lemma decomposable_eq [TopologicalSpace.SeparableSpace E] + (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) (T R : X → (E →L[ℂ] E)) + (hT : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) + (hR : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = R x (f x)) : + ∀ᵐ x ∂μ, T x = R x := by + apply ae_field_eq_of_dense μ T R + intro u + exact EventuallyEq.trans (EventuallyEq.symm (decomposable_const μ A T hT u)) + (decomposable_const μ A R hR u) + +lemma decomposable_idempotent [TopologicalSpace.SeparableSpace E] + (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) (T : X → (E →L[ℂ] E)) + (hT : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) (hA : A*A=A) : + ∀ᵐ x ∂μ, T x*T x=T x := by + apply decomposable_eq μ A (fun x ↦ T x*T x) T _ hT + intro f + simpa only [hA] using decomposable_mul μ A A T T hT hT f + +lemma decomposable_selfAdjoint [CompleteSpace E] [TopologicalSpace.SeparableSpace E] + (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) (T : X → (E →L[ℂ] E)) + (hT : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) + (hc : ∀ s (hs : MeasurableSet s), A.comp (indicatorV2 μ s hs) = + (indicatorV2 μ s hs).comp A) (hA : IsSelfAdjoint A) : + ∀ᵐ x ∂μ, IsSelfAdjoint (T x) := by + have hsymmetric := ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mp hA + have hinner (u v : E) : ∀ᵐ x ∂μ, inner ℂ (T x u) v = inner ℂ u (T x v) := by + let fu := Lp.const 2 μ u + let fv := Lp.const 2 μ v + have he : (fun x ↦ inner ℂ ((A fu) x) (fv x)) =ᵐ[μ] + (fun x ↦ inner ℂ (fu x) ((A fv) x)) := by + apply Integrable.ae_eq_of_forall_setIntegral_eq _ _ (L2.integrable_inner _ _) + (L2.integrable_inner _ _) + intro s hs _ + rw [← inner_indicatorV2 μ s hs, ← inner_indicatorV2 μ s hs] + change inner ℂ (A.toLinearMap fu) _ = _ + rw [hsymmetric] + have hcomm := congrArg (fun B : Lp E 2 μ →L[ℂ] Lp E 2 μ ↦ B fv) (hc s hs) + exact congrArg (inner ℂ fu) hcomm + filter_upwards [he,decomposable_const μ A T hT u,decomposable_const μ A T hT v, + Lp.coeFn_const 2 μ u,Lp.coeFn_const 2 μ v] with x h1 h2 h3 h4 h5 + change inner ℂ ((A fu) x) (fv x) = inner ℂ (fu x) ((A fv) x) at h1 + simpa only [fu,fv,h2,h3,h4,h5,Function.const_apply] using h1 + obtain ⟨v,hv⟩ := TopologicalSpace.exists_dense_seq E + have hh : ∀ᵐ x ∂μ, ∀ n m : ℕ, inner ℂ (T x (v n)) (v m) = inner ℂ (v n) (T x (v m)) := + ae_all_iff.mpr (fun n ↦ ae_all_iff.mpr (fun m ↦ hinner (v n) (v m))) + filter_upwards [hh] with x hx + apply ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mpr + intro u w + change inner ℂ (T x u) w = inner ℂ u (T x w) + refine hv.induction_on₂ ?_ hx u w + exact isClosed_eq (by fun_prop) (by fun_prop) +end + +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +variable {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + +def shiftedL2 (σ : X → X) (hσ : MeasurePreserving σ μ μ) (S : E →L[ℂ] E) : + Lp E 2 μ →L[ℂ] Lp E 2 μ := + (S.compLpL 2 μ).comp (Lp.compMeasurePreservingₗᵢ ℂ σ hσ).toContinuousLinearMap + +lemma shiftedL2_coe (σ : X → X) (hσ : MeasurePreserving σ μ μ) (S : E →L[ℂ] E) + (f : Lp E 2 μ) : shiftedL2 μ σ hσ S f =ᵐ[μ] fun x ↦ S (f (σ x)) := by + filter_upwards [S.coeFn_compLpL (Lp.compMeasurePreserving σ hσ f), + Lp.coeFn_compMeasurePreserving f hσ] with x h1 h2 + exact h1.trans (congrArg S h2) + +variable [IsFiniteMeasure μ] +lemma shiftedL2_const (σ : X → X) (hσ : MeasurePreserving σ μ μ) (S : E →L[ℂ] E) + (u : E) : shiftedL2 μ σ hσ S (Lp.const 2 μ u) = Lp.const 2 μ (S u) := by + apply Lp.ext + filter_upwards [shiftedL2_coe μ σ hσ S (Lp.const 2 μ u), + hσ.quasiMeasurePreserving.ae (Lp.coeFn_const 2 μ u), + Lp.coeFn_const 2 μ (S u)] with x h1 h2 h3 + simp only [h1,h2,h3,Function.const_apply] + +lemma decomposable_covariance [TopologicalSpace.SeparableSpace E] + (σ : X → X) (hσ : MeasurePreserving σ μ μ) (S : E →L[ℂ] E) + (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) (T : X → (E →L[ℂ] E)) + (hT : ∀ f : Lp E 2 μ, ∀ᵐ x ∂μ, (A f) x = T x (f x)) + (hAS : A * shiftedL2 μ σ hσ S = shiftedL2 μ σ hσ S * A) : + ∀ᵐ x ∂μ, T x * S = S * T (σ x) := by + apply ae_field_eq_of_dense μ + intro u + have he : A (Lp.const 2 μ (S u)) = shiftedL2 μ σ hσ S (A (Lp.const 2 μ u)) := by + have := congrArg (fun B : Lp E 2 μ →L[ℂ] Lp E 2 μ ↦ B (Lp.const 2 μ u)) hAS + simpa only [mul_apply_eq_comp,shiftedL2_const] using this + filter_upwards [decomposable_const μ A T hT (S u), + shiftedL2_coe μ σ hσ S (A (Lp.const 2 μ u)), + hσ.quasiMeasurePreserving.ae (decomposable_const μ A T hT u)] with x h1 h2 h3 + change T x (S u) = S (T (σ x) u) + rw [← h1,he,h2,h3] + + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/DigitCouplings.lean b/lean/OAI/Analysis/RotationWeights/DigitCouplings.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c07f7debfb6bf01d4a6d2ef79687f684323f9c4 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/DigitCouplings.lean @@ -0,0 +1,405 @@ +import OAI.Analysis.RotationWeights.ProjectionIdentity + +namespace OAI + +noncomputable section + +namespace CircleCoupling + +universe uκ uD + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace + +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +section + +instance labelMeasurableSpace {κ : Type uκ} : MeasurableSpace (Option κ) := ⊤ +instance labelMeasurableSingleton {κ : Type uκ} : MeasurableSingletonClass (Option κ) := ⟨by intro a; trivial⟩ + +def uniformOn {D : Type uD} [MeasurableSpace D] (S : Finset D) (hs : S.Nonempty) : Measure D := + (PMF.uniformOfFinset S hs).toMeasure +instance {D : Type uD} [MeasurableSpace D] (S : Finset D) (hs : S.Nonempty) : + IsProbabilityMeasure (uniformOn S hs) := by unfold uniformOn; infer_instance + +lemma uniformOn_singleton {D : Type uD} [MeasurableSpace D] [MeasurableSingletonClass D] + (S : Finset D) (hs : S.Nonempty) (d : D) : + uniformOn S hs {d} = if d ∈ S then (S.card : ℝ≥0∞)⁻¹ else 0 := by + classical + simp [uniformOn, PMF.toMeasure_apply_singleton, PMF.uniformOfFinset_apply] + +def labelled {κ : Type uκ} {D : Type uD} [MeasurableSpace κ] [MeasurableSpace D] + (a : Option κ) (μ : Measure (D × D)) : Measure (Option κ × (D × D)) := + Measure.map (fun z => (a,z)) μ + +def mixture {κ : Type uκ} {D : Type uD} [Fintype κ] [MeasurableSpace κ] [MeasurableSpace D] + (p : κ → ℝ≥0∞) (p₀ : ℝ≥0∞) (μ₀ : Measure (D × D)) + (μ : κ → Measure (D × D)) : Measure (Option κ × (D × D)) := + p₀ • labelled none μ₀ + ∑ a, p a • labelled (some a) (μ a) + +lemma labelled_univ {κ : Type uκ} {D : Type uD} [MeasurableSpace κ] [MeasurableSpace D] + (a : Option κ) (μ : Measure (D × D)) : labelled a μ univ = μ univ := by + rw [labelled, Measure.map_apply (show Measurable (fun z : D × D => (a,z)) from measurable_const.prodMk measurable_id) MeasurableSet.univ] + simp + +lemma mixture_probability {κ : Type uκ} {D : Type uD} [Fintype κ] [MeasurableSpace κ] [MeasurableSpace D] + (p : κ → ℝ≥0∞) (p₀ : ℝ≥0∞) (μ₀ : Measure (D × D)) + (μ : κ → Measure (D × D)) [IsProbabilityMeasure μ₀] [∀ a, IsProbabilityMeasure (μ a)] + (hp : p₀ + ∑ a, p a = 1) : IsProbabilityMeasure (mixture p p₀ μ₀ μ) := by + constructor + simpa [mixture, Measure.add_apply, Measure.sum_apply, Measure.smul_apply, labelled_univ, + measure_univ] using hp + +lemma labelled_fiber {κ : Type uκ} {D : Type uD} [MeasurableSpace κ] [MeasurableSpace D] + [MeasurableSingletonClass D] (a : Option κ) (μ : Measure (D × D)) + (f : D × D → D) (hf : Measurable f) (d : D) : + labelled a μ {ω | f ω.2 = d} = μ (f ⁻¹' {d}) := by + change labelled a μ ((fun ω => f ω.2) ⁻¹' {d}) = _ + unfold labelled + exact Measure.map_apply (show Measurable (fun z : D × D => (a,z)) from + measurable_const.prodMk measurable_id) ((hf.comp measurable_snd) (measurableSet_singleton d)) + +lemma labelled_fiber_label {κ : Type uκ} {D : Type uD} [MeasurableSpace κ] [MeasurableSpace D] + [MeasurableSingletonClass κ] [MeasurableSingletonClass D] + (a b : Option κ) (μ : Measure (D × D)) + (f : D × D → D) (hf : Measurable f) (d : D) : + labelled a μ {ω | f ω.2 = d ∧ ω.1 = b} = if a = b then μ (f ⁻¹' {d}) else 0 := by + classical + have hm : MeasurableSet {ω : Option κ × (D × D) | f ω.2 = d ∧ ω.1 = b} := + ((hf.comp measurable_snd) (measurableSet_singleton d)).inter + (measurable_fst (measurableSet_singleton b)) + rw [labelled, Measure.map_apply (show Measurable (fun z : D × D => (a,z)) from measurable_const.prodMk measurable_id) hm] + by_cases hab : a = b + · simp only [hab, ↓reduceIte] + congr 1 + ext z + simp + · simp only [hab, ↓reduceIte] + have : (fun z => (a,z)) ⁻¹' {ω : Option κ × (D × D) | f ω.2 = d ∧ ω.1 = b} = ∅ := by + ext z; simp [hab] + rw [this,measure_empty] + +lemma mixture_fiber {κ : Type uκ} {D : Type uD} [Fintype κ] [MeasurableSpace κ] [MeasurableSpace D] + [MeasurableSingletonClass D] + (p : κ → ℝ≥0∞) (p₀ : ℝ≥0∞) (μ₀ : Measure (D × D)) + (μ : κ → Measure (D × D)) (f : D × D → D) (hf : Measurable f) (d : D) : + mixture p p₀ μ₀ μ {ω | f ω.2 = d} = + p₀ * μ₀ (f ⁻¹' {d}) + ∑ a, p a * μ a (f ⁻¹' {d}) := by + simp [mixture,Measure.add_apply,Measure.smul_apply, + labelled_fiber _ _ f hf d] + +lemma mixture_fiber_label {κ : Type uκ} {D : Type uD} [Fintype κ] [MeasurableSpace κ] [MeasurableSpace D] + [MeasurableSingletonClass κ] [MeasurableSingletonClass D] + (p : κ → ℝ≥0∞) (p₀ : ℝ≥0∞) (μ₀ : Measure (D × D)) + (μ : κ → Measure (D × D)) (f : D × D → D) (hf : Measurable f) (d : D) (a : κ) : + mixture p p₀ μ₀ μ {ω | f ω.2 = d ∧ ω.1 = some a} = p a * μ a (f ⁻¹' {d}) := by + classical + simp [mixture,Measure.add_apply,Measure.smul_apply, + labelled_fiber_label _ _ _ f hf d] + +lemma prod_fiber_fst {D : Type uD} [MeasurableSpace D] [MeasurableSingletonClass D] + (μ ν : Measure D) [IsProbabilityMeasure ν] (d : D) : + (μ.prod ν) (Prod.fst ⁻¹' {d}) = μ {d} := by + rw [show Prod.fst ⁻¹' {d} = ({d} : Set D) ×ˢ univ by ext z; simp, + Measure.prod_prod,measure_univ,mul_one] + +lemma prod_fiber_snd {D : Type uD} [MeasurableSpace D] [MeasurableSingletonClass D] + (μ ν : Measure D) [IsProbabilityMeasure μ] [SFinite ν] (d : D) : + (μ.prod ν) (Prod.snd ⁻¹' {d}) = ν {d} := by + rw [show Prod.snd ⁻¹' {d} = (univ : Set D) ×ˢ {d} by ext z; simp, + Measure.prod_prod,measure_univ,one_mul] + + +def lowerDigits (l a : ℕ) (ha : a < l) : Finset (Fin l) := Finset.Iio ⟨a,ha⟩ +def upperDigits (l b : ℕ) (hb : b < l) : Finset (Fin l) := Finset.Ici ⟨b,hb⟩ + +lemma lowerDigits_nonempty (l a : ℕ) (ha : a < l) (hpos : 0 < a) : + (lowerDigits l a ha).Nonempty := by + exact ⟨⟨0,lt_trans hpos ha⟩,by simpa [lowerDigits,Fin.lt_def] using hpos⟩ +lemma upperDigits_nonempty (l b : ℕ) (hb : b < l) : + (upperDigits l b hb).Nonempty := by + exact ⟨⟨b,hb⟩,by simp [upperDigits]⟩ + +@[simp] lemma card_lowerDigits (l a : ℕ) (ha : a < l) : (lowerDigits l a ha).card = a := by + simp [lowerDigits] +@[simp] lemma card_upperDigits (l b : ℕ) (hb : b < l) : (upperDigits l b hb).card = l-b := by + simp [upperDigits] +@[simp] lemma mem_lowerDigits (l a : ℕ) (ha : a < l) (d : Fin l) : + d ∈ lowerDigits l a ha ↔ d.val < a := by simp [lowerDigits,Fin.lt_def] +@[simp] lemma mem_upperDigits (l b : ℕ) (hb : b < l) (d : Fin l) : + d ∈ upperDigits l b hb ↔ b ≤ d.val := by simp [upperDigits,Fin.le_def] + +def rectangle (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) : + Measure (Fin l × Fin l) := + (uniformOn (lowerDigits l a ha) (lowerDigits_nonempty l a ha hp)).prod + (uniformOn (upperDigits l b hb) (upperDigits_nonempty l b hb)) +instance rectangle_probability (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) : + IsProbabilityMeasure (rectangle l a b ha hp hb) := by unfold rectangle; infer_instance + +lemma rectangle_fst_singleton (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) (d : Fin l) : + rectangle l a b ha hp hb (Prod.fst ⁻¹' {d}) = if d.val < a then (a : ℝ≥0∞)⁻¹ else 0 := by + simp [rectangle,prod_fiber_fst,uniformOn_singleton] +lemma rectangle_snd_singleton (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) (d : Fin l) : + rectangle l a b ha hp hb (Prod.snd ⁻¹' {d}) = if b ≤ d.val then ((l-b : ℕ) : ℝ≥0∞)⁻¹ else 0 := by + simp [rectangle,prod_fiber_snd,uniformOn_singleton] + +lemma uniformOn_ae_mem {D : Type uD} [MeasurableSpace D] [MeasurableSingletonClass D] + (S : Finset D) (hs : S.Nonempty) : ∀ᵐ d ∂uniformOn S hs, d ∈ S := by + apply ae_iff.mpr + change (uniformOn S hs) (↑S)ᶜ = 0 + rw [uniformOn,(PMF.uniformOfFinset S hs).toMeasure_apply_eq_zero_iff (S.measurableSet.compl), + PMF.support_uniformOfFinset] + exact disjoint_compl_right + +lemma rectangle_ae (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) : + ∀ᵐ z ∂rectangle l a b ha hp hb, z.1.val < a ∧ b ≤ z.2.val := by + have hx := uniformOn_ae_mem (lowerDigits l a ha) (lowerDigits_nonempty l a ha hp) + have hy := uniformOn_ae_mem (upperDigits l b hb) (upperDigits_nonempty l b hb) + unfold rectangle + apply (Measure.ae_prod_iff_ae_ae (by measurability)).mpr + filter_upwards [hx] with x hxx + filter_upwards [hy] with y hyy + exact ⟨(mem_lowerDigits _ _ _ _).mp hxx,(mem_upperDigits _ _ _ _).mp hyy⟩ + +def diagonal (l : ℕ) [NeZero l] : Measure (Fin l × Fin l) := + Measure.map (fun d => (d,d)) (PMF.uniformOfFintype (Fin l)).toMeasure +instance diagonal_probability (l : ℕ) [NeZero l] : IsProbabilityMeasure (diagonal l) := by + unfold diagonal + infer_instance + +lemma diagonal_fiber_fst (l : ℕ) [NeZero l] (d : Fin l) : + diagonal l (Prod.fst ⁻¹' {d}) = (l : ℝ≥0∞)⁻¹ := by + rw [diagonal,Measure.map_apply (by fun_prop) (measurable_fst (measurableSet_singleton d))] + change (PMF.uniformOfFintype (Fin l)).toMeasure {d} = _ + simp [PMF.uniformOfFintype_apply] +lemma diagonal_fiber_snd (l : ℕ) [NeZero l] (d : Fin l) : + diagonal l (Prod.snd ⁻¹' {d}) = (l : ℝ≥0∞)⁻¹ := by + rw [diagonal,Measure.map_apply (by fun_prop) (measurable_snd (measurableSet_singleton d))] + change (PMF.uniformOfFintype (Fin l)).toMeasure {d} = _ + simp [PMF.uniformOfFintype_apply] + +def components (l t u r : ℕ) (ht : 0 dsimp [components] <;> infer_instance + +def sixWeights (p q τ : ℝ≥0∞) : Fin 5 → ℝ≥0∞ := ![p,p,q,q,τ] +lemma sum_sixWeights (p q τ : ℝ≥0∞) : ∑ a, sixWeights p q τ a = 2*p+2*q+τ := by + simp [sixWeights,Fin.sum_univ_succ] + ring + +def sixLaw (l t u r : ℕ) [NeZero l] (ht : 0 (0 : Fin l)) measurable_const 0 (4 : Fin 5) + simpa [sixLaw,sixWeights,measure_univ] using h +end + +lemma mixture_fiber_real {κ : Type uκ} {D : Type uD} [Fintype κ] [MeasurableSpace κ] [MeasurableSpace D] + [MeasurableSingletonClass D] + (p : κ → ℝ≥0∞) (p₀ : ℝ≥0∞) (μ₀ : Measure (D × D)) + (μ : κ → Measure (D × D)) [IsFiniteMeasure μ₀] [∀ i, IsFiniteMeasure (μ i)] + (hp : ∀ i, p i ≠ ∞) (hp₀ : p₀ ≠ ∞) + (f : D × D → D) (hf : Measurable f) (d : D) : + (mixture p p₀ μ₀ μ).real {ω | f ω.2 = d} = + p₀.toReal * μ₀.real (f ⁻¹' {d}) + ∑ a, (p a).toReal * (μ a).real (f ⁻¹' {d}) := by + rw [measureReal_def,mixture_fiber _ _ _ _ f hf] + rw [ENNReal.toReal_add (ENNReal.mul_ne_top hp₀ (measure_ne_top _ _)) + (ENNReal.sum_ne_top.mpr (fun i _ => ENNReal.mul_ne_top (hp i) (measure_ne_top _ _))), + ENNReal.toReal_sum (fun i _ => ENNReal.mul_ne_top (hp i) (measure_ne_top _ _))] + simp [ENNReal.toReal_mul,measureReal_def] + +lemma rectangle_fst_real (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) (d : Fin l) : + (rectangle l a b ha hp hb).real (Prod.fst ⁻¹' {d}) = + if d.val < a then (a : ℝ)⁻¹ else 0 := by + rw [measureReal_def,rectangle_fst_singleton] + split_ifs <;> simp only [ENNReal.toReal_inv, ENNReal.toReal_natCast, ENNReal.toReal_zero] +lemma rectangle_snd_real (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) (d : Fin l) : + (rectangle l a b ha hp hb).real (Prod.snd ⁻¹' {d}) = + if b ≤ d.val then ((l-b : ℕ) : ℝ)⁻¹ else 0 := by + rw [measureReal_def,rectangle_snd_singleton] + split_ifs <;> simp only [ENNReal.toReal_inv, ENNReal.toReal_natCast, ENNReal.toReal_zero] + +lemma rectangle_fst_real_le (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) (d : Fin l) : + (rectangle l a b ha hp hb).real (Prod.fst ⁻¹' {d}) ≤ (a : ℝ)⁻¹ := by + rw [rectangle_fst_real] + split_ifs + · exact le_rfl + · positivity +lemma rectangle_snd_real_le (l a b : ℕ) (ha : a < l) (hp : 0 < a) (hb : b < l) (d : Fin l) : + (rectangle l a b ha hp hb).real (Prod.snd ⁻¹' {d}) ≤ ((l-b : ℕ) : ℝ)⁻¹ := by + rw [rectangle_snd_real] + split_ifs + · exact le_rfl + · positivity + +lemma sixLaw_fiber_real_le (l t u r : ℕ) [NeZero l] (ht : 0 bot_le) (Finset.mem_univ _)) + rwa [sum_sixWeights] + have hrem : 1-(2*p+2*q+τ) ≤ (1 : ℝ≥0∞) := tsub_le_self + rw [sixLaw,mixture_fiber_real _ _ _ _ + (fun i => ne_top_of_le_ne_top ENNReal.one_ne_top (hweight i)) + (ne_top_of_le_ne_top ENNReal.one_ne_top hrem) f hf,hdiag] + apply add_le_add + · have hrem' : (1-(2*p+2*q+τ)).toReal ≤ 1 := by + simpa using ENNReal.toReal_mono ENNReal.one_ne_top hrem + convert mul_le_mul_of_nonneg_right hrem' (by positivity : 0 ≤ (l : ℝ)⁻¹) using 1; ring + · exact Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (hM i) ENNReal.toReal_nonneg) + +lemma twoWidth_density_numerical (l t u r : ℕ) (hl : 0 < l) + (ht : 0 < t ∧ t < l) (hu : 0 < u ∧ u < l) (hr : 0 < r ∧ r < l) + (a b m κ ρ σ τ : ℝ) (ha : 0 < a) (hb : 0 < b) (hm : 0 < m) + (_ha' : a ≤ 1) (_hb' : b ≤ 1) (hκ : 0 ≤ κ) (hκ' : κ ≤ 1/100) + (hρ : 0 ≤ ρ) (hσ : 0 ≤ σ) (_hτ : 0 ≤ τ) + (htlo : (l : ℝ)*a/3 ≤ (t : ℝ)) (hthi : (t : ℝ) ≤ (l : ℝ)/2) + (hulo : (l : ℝ)*b/3 ≤ (u : ℝ)) (huhi : (u : ℝ) ≤ (l : ℝ)/2) + (hrlo : (l : ℝ)/(2*m) ≤ (r : ℝ)) (_hrhi : (r : ℝ) ≤ (l : ℝ)/2) + (hρα : ρ/a ≤ κ) (hσb : σ/b ≤ κ) (hτm : τ ≤ 1/m) : + (l : ℝ)⁻¹ + ρ*((t : ℝ)⁻¹+((l-t : ℕ) : ℝ)⁻¹) + + σ*((u : ℝ)⁻¹+((l-u : ℕ) : ℝ)⁻¹) + τ*(r : ℝ)⁻¹ ≤ 10/(l : ℝ) := by + have hlr : (0 : ℝ) < l := by exact_mod_cast hl + have htr : (0 : ℝ) < t := by exact_mod_cast ht.1 + have hur : (0 : ℝ) < u := by exact_mod_cast hu.1 + have hrr : (0 : ℝ) < r := by exact_mod_cast hr.1 + have hlt : (0 : ℝ) < (l-t : ℕ) := by exact_mod_cast (Nat.sub_pos_of_lt ht.2) + have hlu : (0 : ℝ) < (l-u : ℕ) := by exact_mod_cast (Nat.sub_pos_of_lt hu.2) + have hrt : (l : ℝ)*a/3 ≤ ((l-t : ℕ) : ℝ) := by + rw [Nat.cast_sub ht.2.le]; nlinarith + have hru : (l : ℝ)*b/3 ≤ ((l-u : ℕ) : ℝ) := by + rw [Nat.cast_sub hu.2.le]; nlinarith + have bound (w z v : ℝ) (hw : 0 < w) (hz : 0 < z) (_hv : 0 ≤ v) + (hzw : (l : ℝ)*w/3 ≤ z) (hvw : v/w ≤ κ) : v*z⁻¹ ≤ 3*κ/(l : ℝ) := by + have hp : v ≤ κ*w := (div_le_iff₀ hw).mp hvw + rw [← div_eq_mul_inv,div_le_iff₀ hz] + rw [div_mul_eq_mul_div,le_div_iff₀ hlr] + nlinarith [mul_le_mul_of_nonneg_left hp hlr.le, mul_le_mul_of_nonneg_left hzw hκ] + have ht1 := bound a t ρ ha htr hρ htlo hρα + have ht2 := bound a (l-t : ℕ) ρ ha hlt hρ hrt hρα + have hu1 := bound b u σ hb hur hσ hulo hσb + have hu2 := bound b (l-u : ℕ) σ hb hlu hσ hru hσb + have hr1 : τ*(r : ℝ)⁻¹ ≤ 2/(l : ℝ) := by + rw [← div_eq_mul_inv,div_le_iff₀ hrr] + rw [div_mul_eq_mul_div,le_div_iff₀ hlr] + have hrlo' := (div_le_iff₀ (by positivity : 0 < 2*m)).mp hrlo + have hτm' := (le_div_iff₀ hm).mp hτm + have hτl : τ*(l : ℝ) ≤ (l : ℝ)/m := by + have hh := mul_le_mul_of_nonneg_left hτm hlr.le + simpa only [mul_one_div,mul_comm] using hh + have hrl : (l : ℝ)/m ≤ 2*(r : ℝ) := by + rw [div_le_iff₀ hm] + nlinarith [hrlo'] + exact hτl.trans hrl + have hk : 12*κ/(l : ℝ) ≤ (7 : ℝ)/(l : ℝ) := by + apply div_le_div_of_nonneg_right _ hlr.le + linarith + simp only [div_eq_mul_inv] at ht1 ht2 hu1 hu2 hr1 hk ⊢ + nlinarith + + +end CircleCoupling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Discrepancy.lean b/lean/OAI/Analysis/RotationWeights/Discrepancy.lean new file mode 100644 index 0000000000000000000000000000000000000000..6aac14823cc8aa157b82e13690ff1a77ed96beac --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Discrepancy.lean @@ -0,0 +1,439 @@ +import OAI.Analysis.RotationWeights.PhaseWeights + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uX uY uΩ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate + +section +def negLower (α s : ℝ) : ℝ := max 0 (s-1+α) +def negUpper (ℓ α s : ℝ) : ℝ := + min 1 (min (s-α) (min (ℓ*s/(1+ℓ)) (ℓ*(1-s)/(1-ℓ)))) + +lemma neg_support_strict {ℓ α s t : ℝ} (hℓ : 0<ℓ) (hℓ1 : ℓ<1) : + (0 nlinarith + · rintro ⟨⟨ht0,ha⟩,ht1,hb,hc,hd⟩ + refine ⟨ht0,ht1,⟨by linarith,by linarith⟩,?_,?_⟩ <;> nlinarith + +def negArcLeft (ℓ α s r : ℝ) : Set ℝ := + Ioo (negLower α s) (min (negUpper ℓ α s) (min (s-1+1/(ℓ*r)) (s-1/2))) +def negArcRight (ℓ α s r : ℝ) : Set ℝ := + Ioo (max (negLower α s) (max (s-1/(ℓ*r)) (s-1/2))) (negUpper ℓ α s) + +lemma negative_superlevel_intervals {ℓ α s t r : ℝ} + (hℓ : 0<ℓ) (hℓ1 : ℓ<1) (hα : 0<α) (hr : 0 intro h <;> nlinarith + have hw : r linarith [ht.1, ht.2] + · intro hx + obtain ⟨t⟩ := x + change (t : CircleX) ∈ Metric.ball (((a+b)/2 : ℝ) : CircleX) ((b-a)/2) at hx + change (t : CircleX) ∈ ((↑) : ℝ → CircleX) '' Ioo a b + rw [Metric.mem_ball, dist_eq_norm, ← AddCircle.coe_sub, AddCircle.norm_eq] at hx + simp only [inv_one, one_mul, mul_one] at hx + let u : ℝ := t - (round (t - (a+b)/2) : ℤ) + refine ⟨u, ?_, ?_⟩ + · rw [mem_Ioo] + have hu : |u - (a+b)/2| < (b-a)/2 := by + convert! hx using 1 + congr 1 + dsimp [u] + ring + rw [abs_lt] at hu + dsimp [u] at * + constructor <;> linarith [hu.1, hu.2] + · dsimp [u] + have hz (z : ℤ) : ((z : ℝ) : CircleX) = 0 := by + apply (AddCircle.coe_eq_zero_iff 1).mpr + exact ⟨z, by simp⟩ + rw [hz, sub_zero] + +def IsTwoArcs (A : Set CircleX) : Prop := + ∃ (c d : CircleX) (r q : ℝ), + Disjoint (Metric.ball c r) (Metric.ball d q) ∧ + A =ᵐ[volume] (Metric.ball c r ∪ Metric.ball d q : Set CircleX) + +lemma uNeg_isTwoArcs {ℓ α r : ℝ} (hℓ : 0<ℓ) (hℓ1 : ℓ<1) + (hα : 0<α) (hr : 0 linarith + +end + +variable {Ω : Type uΩ} [MeasurableSpace Ω] {μ : Measure Ω} + +lemma boundedLayercake {f : Ω → ℝ} {B : ℝ} + (hfi : Integrable f μ) + (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) : + ∫ x, f x ∂μ = ∫ t in Ioc 0 B, μ.real {x | t < f x} := by + rw [hfi.integral_eq_integral_meas_lt (Filter.Eventually.of_forall hf0)] + apply setIntegral_eq_of_subset_of_ae_sdiff_eq_zero nullMeasurableSet_Ioi + Ioc_subset_Ioi_self + apply Filter.Eventually.of_forall + intro t ht + have hBt : B < t := lt_of_not_ge (fun h ↦ ht.2 ⟨ht.1, h⟩) + have he : {x | t < f x} = ∅ := by + ext x + simp only [mem_ofPred_eq, mem_empty_iff_false, iff_false] + exact not_lt.mpr (le_trans (hfB x) (le_of_lt hBt)) + simp [he] + +lemma boundedLayercake_weighted [IsFiniteMeasure μ] {f g : Ω → ℝ} {B : ℝ} + (hf : Measurable f) (hg : Measurable g) + (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) + (hg0 : ∀ x, 0 ≤ g x) (hgB : ∀ x, g x ≤ B) : + ∫ x, f x * g x ∂μ = + ∫ s in Ioc 0 B, ∫ x in {x | s < f x}, g x ∂μ := by + have hi : Integrable (fun z : ℝ × Ω ↦ + if z.1 < f z.2 then g z.2 else 0) + ((volume.restrict (Ioc 0 B)).prod μ) := + Integrable.of_bound + ((hg.comp measurable_snd).ite + (measurableSet_lt measurable_fst (hf.comp measurable_snd)) measurable_const).aestronglyMeasurable B (Filter.Eventually.of_forall fun z ↦ by + split_ifs + · simpa only [Real.norm_eq_abs, abs_of_nonneg (hg0 z.2)] using hgB z.2 + · simp only [norm_zero] + by_cases h : Nonempty Ω + · exact le_trans (hg0 (Classical.choice h)) (hgB (Classical.choice h)) + · exact False.elim (h ⟨z.2⟩)) + have he : (fun s : ℝ ↦ ∫ x in {x | s < f x}, g x ∂μ) = + (fun s ↦ ∫ x, (if s < f x then g x else 0) ∂μ) := by + funext s + rw [← integral_indicator (measurableSet_lt measurable_const hf)] + rfl + rw [he, integral_integral_swap hi] + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro x + have hset : (Ioc 0 B ∩ Iio (f x)) = Ioo 0 (f x) := by + ext s + simp only [mem_inter_iff, mem_Ioc, mem_Iio, mem_Ioo] + constructor + · exact fun h ↦ ⟨h.1.1, h.2⟩ + · exact fun h ↦ ⟨⟨h.1, le_trans (le_of_lt h.2) (hfB x)⟩, h.2⟩ + have hid : (fun s : ℝ ↦ if s < f x then g x else 0) = + (Iio (f x)).indicator (fun _ ↦ g x) := rfl + change f x * g x = ∫ s in Ioc 0 B, if s < f x then g x else 0 + rw [hid, integral_indicator measurableSet_Iio, Measure.restrict_restrict measurableSet_Iio, + inter_comm, hset, integral_const] + simp only [Measure.real, Measure.restrict_apply_univ, Real.volume_Ioo, sub_zero, ENNReal.toReal_ofReal (hf0 x), + smul_eq_mul] + +lemma boundedLayercake_product [IsFiniteMeasure μ] {f g : Ω → ℝ} {B : ℝ} + (hf : Measurable f) (hg : Measurable g) + (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) + (hg0 : ∀ x, 0 ≤ g x) (hgB : ∀ x, g x ≤ B) : + ∫ x, f x * g x ∂μ = + ∫ s in Ioc 0 B, ∫ t in Ioc 0 B, μ.real {x | s < f x ∧ t < g x} := by + rw [boundedLayercake_weighted hf hg hf0 hfB hg0 hgB] + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro s + have hgi : Integrable g (μ.restrict {x | s < f x}) := + Integrable.of_bound hg.aestronglyMeasurable B + (Filter.Eventually.of_forall fun x ↦ by + simpa only [Real.norm_eq_abs, abs_of_nonneg (hg0 x)] using hgB x) + dsimp only + rw [boundedLayercake hgi hg0 hgB] + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro t + simp only [Measure.real, Measure.restrict_apply (measurableSet_lt measurable_const hg)] + congr 2 + ext x + exact and_comm + +lemma integrable_superlevel_measure [IsFiniteMeasure μ] + {f g : Ω → ℝ} (hf : Measurable f) (hg : Measurable g) (B : ℝ) : + Integrable (fun z : ℝ × ℝ ↦ μ.real {x | z.1 < f x ∧ z.2 < g x}) + ((volume.restrict (Ioc 0 B)).prod (volume.restrict (Ioc 0 B))) := by + have hm : Measurable (fun z : ℝ × ℝ ↦ μ {x | z.1 < f x ∧ z.2 < g x}) := + measurable_measure_prodMk_left + ((measurableSet_lt (measurable_fst.comp measurable_fst) + (hf.comp measurable_snd)).inter + (measurableSet_lt (measurable_snd.comp measurable_fst) + (hg.comp measurable_snd))) + exact Integrable.of_bound hm.ennreal_toReal.aestronglyMeasurable (μ.real univ) + (Filter.Eventually.of_forall fun z ↦ by + rw [Real.norm_eq_abs, abs_of_nonneg measureReal_nonneg] + exact measureReal_mono (subset_univ _)) + +lemma superlevel_discrepancy [IsFiniteMeasure μ] {ν : Measure Ω} [IsFiniteMeasure ν] + {f g : Ω → ℝ} {B ε : ℝ} (hB : 0 ≤ B) + (hf : Measurable f) (hg : Measurable g) + (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) + (hg0 : ∀ x, 0 ≤ g x) (hgB : ∀ x, g x ≤ B) + (hdisc : ∀ s ∈ Ioc 0 B, ∀ t ∈ Ioc 0 B, + |μ.real {x | s < f x ∧ t < g x} - ν.real {x | s < f x ∧ t < g x}| ≤ ε) : + |(∫ x, f x * g x ∂μ) - (∫ x, f x * g x ∂ν)| ≤ B ^ 2 * ε := by + rw [boundedLayercake_product hf hg hf0 hfB hg0 hgB, + boundedLayercake_product hf hg hf0 hfB hg0 hgB] + have hiμ := integrable_superlevel_measure (μ := μ) hf hg B + have hiν := integrable_superlevel_measure (μ := ν) hf hg B + rw [integral_integral hiμ, integral_integral hiν, ← integral_sub hiμ hiν, + ← Real.norm_eq_abs] + have hb : ∀ᵐ z : ℝ × ℝ ∂((volume.restrict (Ioc 0 B)).prod + (volume.restrict (Ioc 0 B))), + ‖μ.real {x | z.1 < f x ∧ z.2 < g x} - + ν.real {x | z.1 < f x ∧ z.2 < g x}‖ ≤ ε := by + have hm : ∀ᵐ z : ℝ × ℝ ∂((volume.restrict (Ioc 0 B)).prod + (volume.restrict (Ioc 0 B))), z ∈ Ioc 0 B ×ˢ Ioc 0 B := by + rw [Measure.ae_prod_mem_iff_ae_ae_mem (measurableSet_Ioc.prod measurableSet_Ioc)] + filter_upwards [ae_restrict_mem measurableSet_Ioc] with s hs + filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht + exact ⟨hs, ht⟩ + filter_upwards [hm] with z hz + exact hdisc z.1 hz.1 z.2 hz.2 + convert! norm_integral_le_of_norm_le (integrable_const ε) hb using 1 + simp [Measure.prod_apply, Measure.real, Real.volume_Ioc, hB, pow_two, mul_assoc] + + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/EndpointMoments.lean b/lean/OAI/Analysis/RotationWeights/EndpointMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..56af6415eeeddef6bffb29822de266eef2590630 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/EndpointMoments.lean @@ -0,0 +1,350 @@ +import OAI.Analysis.RotationWeights.RadixDigits + +namespace OAI + +noncomputable section + +universe uX uι uD uΩ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology + +open Set MeasureTheory Topology +open scoped symmDiff +namespace CircleCoupling + +section + +section + +lemma continuous_measureReal_of_le {X : Type uX} [MeasurableSpace X] + (μ ν : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure ν] (hμν : μ ≤ ν) : + Continuous (fun s : MeasuredSets ν ↦ μ.real (s : Set X)) := by + apply LipschitzWith.continuous (K := 1) + apply LipschitzWith.of_dist_le_mul + intro s t + simp only [Real.dist_eq, NNReal.coe_one, one_mul, MeasuredSets.dist_def] + apply (abs_measureReal_sub_le_measureReal_symmDiff s.2.nullMeasurableSet t.2.nullMeasurableSet).trans + exact ENNReal.toReal_mono (measure_ne_top _ _) (hμν _) + +lemma sq_measure_bound_of_generating_ring {X : Type uX} [mX : MeasurableSpace X] + (μ ν : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure ν] + {C : Set (Set X)} (hC : IsSetRing C) (hU : univ ∈ C) + (hgen : mX = MeasurableSpace.generateFrom C) (H : ℝ) + (hfinite : ∀ A∈C, (ν.real A)^2 ≤ H * μ.real A) : + ∀ A, MeasurableSet A → (ν.real A)^2 ≤ H * μ.real A := by + let τ := μ+ν + have hμ : Continuous (fun s : MeasuredSets τ ↦ μ.real (s : Set X)) := + continuous_measureReal_of_le μ τ (Measure.le_add_right le_rfl) + have hν : Continuous (fun s : MeasuredSets τ ↦ ν.real (s : Set X)) := + continuous_measureReal_of_le ν τ (Measure.le_add_left le_rfl) + have hd : Dense ((SetLike.coe : MeasuredSets τ → Set X) ⁻¹' C) := + dense_of_generateFrom_isSetRing hC ⟨{univ}, by simp, by simpa, by simp⟩ hgen + have hc : IsClosed {s : MeasuredSets τ | (ν.real (s : Set X))^2 ≤ H*μ.real (s : Set X)} := + isClosed_le (hν.pow 2) (continuous_const.mul hμ) + have hh : closure ((SetLike.coe : MeasuredSets τ → Set X) ⁻¹' C) ⊆ + {s : MeasuredSets τ | (ν.real (s : Set X))^2 ≤ H*μ.real (s : Set X)} := + closure_minimal (fun s hs ↦ hfinite s hs) hc + rw [hd.closure_eq] at hh + intro A hA + exact hh (show (⟨A,hA⟩ : MeasuredSets τ) ∈ univ from mem_univ _) + +lemma sqrt_measure_bound_of_generating_ring {X : Type uX} [mX : MeasurableSpace X] + (μ ν : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure ν] + {C : Set (Set X)} (hC : IsSetRing C) (hU : univ ∈ C) + (hgen : mX = MeasurableSpace.generateFrom C) {H : ℝ} (hH : 0 ≤ H) + (hfinite : ∀ A∈C, ν.real A ≤ H * Real.sqrt (μ.real A)) : + ∀ A, MeasurableSet A → ν.real A ≤ H * Real.sqrt (μ.real A) := by + have h : ∀ A, MeasurableSet A → (ν.real A)^2 ≤ H^2 * μ.real A := + sq_measure_bound_of_generating_ring μ ν hC hU hgen (H^2) (by + intro A hA + have hsq := sq_le_sq₀ (show 0≤ν.real A from measureReal_nonneg) + (mul_nonneg hH (Real.sqrt_nonneg _)) |>.mpr (hfinite A hA) + rwa [mul_pow, Real.sq_sqrt measureReal_nonneg] at hsq) + intro A hA + apply (sq_le_sq₀ measureReal_nonneg (mul_nonneg hH (Real.sqrt_nonneg _))).mp + simpa [mul_pow,Real.sq_sqrt measureReal_nonneg] using h A hA + +lemma infinitePi_sqrt_bound {ι : Type uι} {X : ι → Type uX} + [∀ i, MeasurableSpace (X i)] (μ ν : ∀ i, Measure (X i)) + [∀ i, IsProbabilityMeasure (μ i)] [∀ i, IsProbabilityMeasure (ν i)] + {H : ℝ} (hH : 0≤H) + (hfinite : ∀ I : Finset ι, ∀ A, MeasurableSet A → + (Measure.pi (fun i : I ↦ ν i)).real A ≤ + H * Real.sqrt ((Measure.pi (fun i : I ↦ μ i)).real A)) : + ∀ A, MeasurableSet A → (Measure.infinitePi ν).real A ≤ + H * Real.sqrt ((Measure.infinitePi μ).real A) := by + have hU : (univ : Set (∀ i, X i)) ∈ measurableCylinders (α := X) := by + rw [← cylinder_univ (∅ : Finset ι)] + exact cylinder_mem_measurableCylinders _ _ MeasurableSet.univ + apply sqrt_measure_bound_of_generating_ring (Measure.infinitePi μ) (Measure.infinitePi ν) + isSetRing_measurableCylinders hU generateFrom_measurableCylinders.symm hH + intro A hA + obtain ⟨I,B,hB,rfl⟩ := (mem_measurableCylinders _).mp hA + have hν : (Measure.infinitePi ν) (cylinder I B) = + (Measure.pi (fun i : I ↦ ν i)) B := by + exact Measure.infinitePi_cylinder _ hB + have hμ : (Measure.infinitePi μ) (cylinder I B) = + (Measure.pi (fun i : I ↦ μ i)) B := by + exact Measure.infinitePi_cylinder _ hB + simp only [Measure.real,hν,hμ] + exact hfinite I B hB + + +lemma infinitePi_l2_bound {ι : Type uι} {D : ι → Type uD} + [∀ i, Fintype (D i)] [∀ i, Nonempty (D i)] [∀ i, MeasurableSpace (D i)] + [∀ i, MeasurableSingletonClass (D i)] (ν : ∀ i, Measure (D i)) + [∀ i, IsProbabilityMeasure (ν i)] (e : ι → ℝ) (he : ∀ i, 0 ≤ e i) + (hs : Summable e) + (hm : ∀ i, (Fintype.card (D i) : ℝ) * ∑ d, ((ν i).real {d})^2 ≤ 1+e i) + (A : Set (∀ i, D i)) (hA : MeasurableSet A) : + (Measure.infinitePi ν).real A ≤ Real.exp ((∑' i, e i)/2) * + Real.sqrt ((Measure.infinitePi (fun i => (PMF.uniformOfFintype (D i)).toMeasure)).real A) := by + classical + apply infinitePi_sqrt_bound _ ν (Real.exp_pos _).le _ A hA + intro I B _hB + apply uniform_l2_set_bound _ _ (fun d => by simpa using pi_uniform_singleton_real d) (Real.exp_pos _).le _ B + rw [pi_second_moment (fun i : I => ν i)] + calc + (∏ i : I, (Fintype.card (D i) : ℝ) * ∑ d, ((ν i).real {d})^2) ≤ ∏ i : I, Real.exp (e i) := by + apply Finset.prod_le_prod₀ + · intro i _; positivity + · intro i _; exact (hm i).trans (by simpa [add_comm] using Real.add_one_le_exp (e i)) + _ = Real.exp (∑ i : I, e i) := (Real.exp_sum _ _).symm + _ ≤ Real.exp (∑' i, e i) := by + apply Real.exp_le_exp.mpr + rw [Finset.sum_coe_sort] + exact hs.sum_le_tsum I (fun i _ => he i) + _ = Real.exp ((∑' i, e i)/2)^2 := by rw [← Real.exp_nat_mul]; congr 1; ring + +open CircleDigits + +lemma observedDigits_sqrt_bound {Ω : ℕ → Type uΩ} [∀ i, MeasurableSpace (Ω i)] + (μ : ∀ i, Measure (Ω i)) [∀ i, IsProbabilityMeasure (μ i)] + {b : ℕ → ℕ} [∀ i, NeZero (b i)] (f : ∀ i, Ω i → Fin (b i)) + (hf : ∀ i, Measurable (f i)) (e : ℕ → ℝ) (he : ∀ i, 0 ≤ e i) (hs : Summable e) + (hm : ∀ i, (b i : ℝ)* ∑ d, ((μ i).real (f i ⁻¹' {d}))^2 ≤ 1+e i) + (A : Set (Digits b)) (hA : MeasurableSet A) : + (Measure.infinitePi μ).real ((fun ω i => f i (ω i)) ⁻¹' A) ≤ + Real.exp ((∑' i, e i)/2) * Real.sqrt ((uniformDigits b).real A) := by + let ν : ∀ i, Measure (Fin (b i)) := fun i => Measure.map (f i) (μ i) + have hν : ∀ i, IsProbabilityMeasure (ν i) := fun _ => inferInstance + have hmoment (i : ℕ) : (Fintype.card (Fin (b i)) : ℝ) * ∑ d, ((ν i).real {d})^2 ≤ 1+e i := by + convert hm i using 1 + simp only [Fintype.card_fin,Measure.real,ν,Measure.map_apply (hf i) (measurableSet_singleton _)] + have hh := infinitePi_l2_bound ν e he hs hmoment A hA + rw [← Measure.infinitePi_map_pi μ hf] at hh + have hobs : Measurable (fun ω : ∀ i, Ω i => fun i => f i (ω i)) := + Measurable.of_eval (fun i => (hf i).comp (measurable_pi_apply i)) + simp only [Measure.real] at hh ⊢ + rw [Measure.map_apply hobs hA] at hh + exact hh + +lemma hybridEndpoint_sqrt_bound {Ω : ℕ → Type uΩ} [∀ i, MeasurableSpace (Ω i)] + (μ : ∀ i, Measure (Ω i)) [∀ i, IsProbabilityMeasure (μ i)] + {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) [∀ i, NeZero (b i)] + (f : ∀ i, Ω i → Fin (b i)) (hf : ∀ i, Measurable (f i)) + (e : ℕ → ℝ) (he : ∀ i, 0 ≤ e i) (hs : Summable e) + (hm : ∀ i, (b i : ℝ)* ∑ d, ((μ i).real (f i ⁻¹' {d}))^2 ≤ 1+e i) + (A : Set CircleDigits.CircleX) (hA : MeasurableSet A) : + (Measure.infinitePi μ).real ((fun ω => endpoint b (fun i => f i (ω i))) ⁻¹' A) ≤ + Real.exp ((∑' i, e i)/2) * Real.sqrt (volume.real A) := by + have hh := observedDigits_sqrt_bound μ f hf e he hs hm ((endpoint b) ⁻¹' A) + ((measurable_endpoint b) hA) + have hp := (endpoint_measurePreserving hb).measure_preimage hA.nullMeasurableSet + simp only [Measure.real,hp] at hh + exact hh + +end +open CircleDigits + +lemma hybridEndpoint_absolutelyContinuous {Ω : ℕ → Type uΩ} [∀ i, MeasurableSpace (Ω i)] + (μ : ∀ i, Measure (Ω i)) [∀ i, IsProbabilityMeasure (μ i)] + {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) [∀ i, NeZero (b i)] + (f : ∀ i, Ω i → Fin (b i)) (hf : ∀ i, Measurable (f i)) + (e : ℕ → ℝ) (he : ∀ i, 0 ≤ e i) (hs : Summable e) + (hm : ∀ i, (b i : ℝ)* ∑ d, ((μ i).real (f i ⁻¹' {d}))^2 ≤ 1+e i) : + Measure.map (fun ω => endpoint b (fun i => f i (ω i))) (Measure.infinitePi μ) ≪ volume := by + have hobs : Measurable (fun ω : ∀ i, Ω i => endpoint b (fun i => f i (ω i))) := + (measurable_endpoint b).comp (Measurable.of_eval (fun i => (hf i).comp (measurable_pi_apply i))) + apply Measure.AbsolutelyContinuous.mk + intro A hA hzero + rw [Measure.map_apply hobs hA] + apply le_antisymm _ bot_le + apply (ENNReal.toReal_le_toReal (measure_ne_top _ _) ENNReal.zero_ne_top).mp + have hh := hybridEndpoint_sqrt_bound μ hb f hf e he hs hm A hA + simpa only [Measure.real,hzero,ENNReal.toReal_zero,Real.sqrt_zero,mul_zero] using hh + +end +open CircleDigits + +structure DigitSystem where + b₀ : ℕ + hb₀ : 2 ≤ b₀ + coord : ℕ → CoordinateParameters +namespace DigitSystem +variable (S : DigitSystem) +def radix : ℕ → ℕ | 0 => S.b₀ | n+1 => (S.coord n).l +lemma radix_ge_two (n : ℕ) : 2 ≤ S.radix n := by + cases n with + | zero => exact S.hb₀ + | succ n => have := (S.coord n).hl; have := (S.coord n).hm; change 2 ≤ (S.coord n).l; omega +instance (n : ℕ) : NeZero (S.radix n) := ⟨by have := S.radix_ge_two n; omega⟩ +abbrev Sample (n : ℕ) := Option (Fin 5) × (Fin (S.radix n) × Fin (S.radix n)) +abbrev Samples := ∀ n, S.Sample n + +def law (tagged : ℕ → Bool) : (n : ℕ) → Measure (S.Sample n) + | 0 => labelled none (diagonal (S.radix 0)) + | n+1 => (S.coord n).law (tagged n) +instance (tagged : ℕ → Bool) (n : ℕ) : IsProbabilityMeasure (S.law tagged n) := by + cases n with + | zero => change IsProbabilityMeasure (Measure.map _ _); infer_instance + | succ n => exact (show IsProbabilityMeasure ((S.coord n).law (tagged n)) from inferInstance) +def probability (tagged : ℕ → Bool) : Measure S.Samples := Measure.infinitePi (S.law tagged) +instance (tagged : ℕ → Bool) : IsProbabilityMeasure (S.probability tagged) := by unfold probability; infer_instance + +def observe (e : ℕ → Bool) (ω : S.Samples) : Digits S.radix := fun i => digitEndpoint (e i) (ω i).2 +def endpoint (e : ℕ → Bool) (ω : S.Samples) : CircleDigits.CircleX := CircleDigits.endpoint S.radix (S.observe e ω) +lemma measurable_observe (e : ℕ → Bool) : Measurable (S.observe e) := by + apply Measurable.of_eval + intro i + exact (digitEndpoint_measurable (e i)).comp (measurable_snd.comp (measurable_pi_apply i)) +lemma measurable_endpoint (e : ℕ → Bool) : Measurable (S.endpoint e) := + (CircleDigits.measurable_endpoint _).comp (S.measurable_observe e) + +def error (tagged : ℕ → Bool) : ℕ → ℝ + | 0 => 0 + | n+1 => (60*(S.coord n).κ^2+10*(if tagged n then 1 else 0))/(S.coord n).m +lemma error_nonneg (tagged : ℕ → Bool) (n : ℕ) : 0 ≤ S.error tagged n := by + cases n with + | zero => exact le_refl 0 + | succ n => dsimp [error]; split <;> positivity +lemma moment (tagged : ℕ → Bool) (n : ℕ) (e : Bool) : + (S.radix n:ℝ)*∑ d : Fin (S.radix n), ((S.law tagged n).real {ω | digitEndpoint e ω.2=d})^2 ≤ + 1+S.error tagged n := by + cases n with + | zero => + have h (d : Fin (S.radix 0)) : (S.law tagged 0).real {ω | digitEndpoint e ω.2=d} = (S.radix 0:ℝ)⁻¹ := by + rw [Measure.real,law,labelled_fiber _ _ _ (digitEndpoint_measurable e)] + cases e + · change ((diagonal (S.radix 0)) {z | z.1=d}).toReal = _ + simpa only [Set.preimage,Set.mem_singleton_iff,ENNReal.toReal_inv,ENNReal.toReal_natCast] using congrArg ENNReal.toReal (diagonal_fiber_fst (S.radix 0) d) + · change ((diagonal (S.radix 0)) {z | z.2=d}).toReal = _ + simpa only [Set.preimage,Set.mem_singleton_iff,ENNReal.toReal_inv,ENNReal.toReal_natCast] using congrArg ENNReal.toReal (diagonal_fiber_snd (S.radix 0) d) + simp only [h,error,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,add_zero] + have hz : (S.radix 0:ℝ) ≠ 0 := by exact_mod_cast NeZero.ne (S.radix 0) + field_simp + norm_num + | succ n => exact (S.coord n).law_second_moment (tagged n) e + +lemma hybrid_sqrt_bound (tagged e : ℕ → Bool) (hs : Summable (S.error tagged)) + (A : Set CircleDigits.CircleX) (hA : MeasurableSet A) : + (S.probability tagged).real (S.endpoint e ⁻¹' A) ≤ + Real.exp ((∑' n, S.error tagged n)/2)*Real.sqrt (volume.real A) := + hybridEndpoint_sqrt_bound (S.law tagged) S.radix_ge_two + (fun i ω => digitEndpoint (e i) ω.2) (fun i => (digitEndpoint_measurable (e i)).comp measurable_snd) + (S.error tagged) (S.error_nonneg tagged) hs (fun i => S.moment tagged i (e i)) A hA + +lemma hybrid_ac (tagged e : ℕ → Bool) (hs : Summable (S.error tagged)) : + Measure.map (S.endpoint e) (S.probability tagged) ≪ volume := + hybridEndpoint_absolutelyContinuous (S.law tagged) S.radix_ge_two + (fun i ω => digitEndpoint (e i) ω.2) (fun i => (digitEndpoint_measurable (e i)).comp measurable_snd) + (S.error tagged) (S.error_nonneg tagged) hs (fun i => S.moment tagged i (e i)) + +lemma ae_hybrid_gridFree (tagged e : ℕ → Bool) (hs : Summable (S.error tagged)) : + ∀ᵐ ω ∂S.probability tagged, S.endpoint e ω ∈ gridFree S.radix := by + have h := (S.hybrid_ac tagged e hs).ae_le (ae_gridFree S.radix S.radix_ge_two) + exact (ae_map_iff (S.measurable_endpoint e).aemeasurable (by + unfold gridFree + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun n => ((measurable_const_smul (denominator S.radix n)) (measurableSet_singleton 0)).compl))).mp h + +lemma ae_digit_order (tagged : ℕ → Bool) : + ∀ᵐ ω ∂S.probability tagged, ∀ i, (ω i).2.1 ≤ (ω i).2.2 := by + rw [ae_all_iff] + intro i + have h : ∀ᵐ z ∂S.law tagged i, z.2.1 ≤ z.2.2 := by + cases i with + | zero => + apply ae_labelled _ _ _ (by measurability) + unfold diagonal + apply (ae_map_iff (by fun_prop) (by measurability)).mpr + exact ae_of_all _ (fun _ => le_rfl) + | succ n => exact (S.coord n).law_order (tagged n) + exact (measurePreserving_eval_infinitePi (S.law tagged) i).quasiMeasurePreserving.ae h + +lemma ae_coordinate_order (tagged : ℕ → Bool) (hs : Summable (S.error tagged)) : + ∀ᵐ ω ∂S.probability tagged, ∀ i, + ((AddCircle.measurableEquivIco 1 0 (denominator S.radix i • S.endpoint (fun _ => false) ω)).val : ℝ) ≤ + ((AddCircle.measurableEquivIco 1 0 (denominator S.radix i • S.endpoint (fun _ => true) ω)).val : ℝ) := by + filter_upwards [S.ae_digit_order tagged,S.ae_hybrid_gridFree tagged (fun _ => false) hs, + S.ae_hybrid_gridFree tagged (fun _ => true) hs] with ω hω hx hy + intro i + dsimp only [DigitSystem.endpoint] at hx hy ⊢ + rw [scaledTail_repr S.radix_ge_two _ hx,scaledTail_repr S.radix_ge_two _ hy] + exact scaledTail_mono S.radix_ge_two hω i +end DigitSystem +end CircleCoupling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/FiberActions.lean b/lean/OAI/Analysis/RotationWeights/FiberActions.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2f7278c1318779484eadae57e7f54fde6185670 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/FiberActions.lean @@ -0,0 +1,340 @@ +import OAI.Analysis.RotationWeights.TensorBasis + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uX + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace + +section +lemma continuous_bounded_lp_field {X : Type uX} [TopologicalSpace X] + (A : X → FiberOperator) {C : ℝ} (hC : 0 ≤ C) + (hb : ∀ x, ‖A x‖ ≤ C) + (hc : ∀ k : ℤ, Continuous (fun x ↦ A x (lp.single 2 k 1))) + (u : FiberHilbert) : Continuous (fun x ↦ A x u) := by + classical + let v : Finset ℤ → FiberHilbert := fun s ↦ ∑ k ∈ s, lp.single 2 k (u k) + have hv : Tendsto v atTop (𝓝 u) := lp.hasSum_single (by norm_num) u + have hunif : TendstoUniformly (fun s x ↦ A x (v s)) (fun x ↦ A x u) atTop := by + rw [Metric.tendstoUniformly_iff] + intro ε hε + have hε' : 0 < ε/(C+1) := div_pos hε (by linarith) + filter_upwards [Metric.tendsto_nhds.mp hv _ hε'] with s hs x + rw [dist_eq_norm, ← map_sub] + have ht := (A x).le_opNorm (u-v s) + have hn : ‖u-v s‖ < ε/(C+1) := by simpa [dist_eq_norm, norm_sub_rev] using hs + calc + _ ≤ C * ‖u-v s‖ := ht.trans (mul_le_mul_of_nonneg_right (hb x) (norm_nonneg _)) + _ ≤ (C+1) * ‖u-v s‖ := mul_le_mul_of_nonneg_right (by linarith) (norm_nonneg _) + _ < (C+1) * (ε/(C+1)) := mul_lt_mul_of_pos_left hn (by linarith) + _ = ε := mul_div_cancel₀ _ (by linarith) + apply hunif.continuous + apply Filter.Eventually.frequently + exact Filter.Eventually.of_forall fun s ↦ by + simp only [v, map_sum] + apply continuous_finsetSum + intro k _ + have he : lp.single (E := fun _ : ℤ ↦ ℂ) 2 k (u k) = (u k) • lp.single 2 k (1 : ℂ) := by + simpa using (lp.single_smul (E := fun _ : ℤ ↦ ℂ) 2 k (u k) (1 : ℂ)) + simp only [he, map_smul] + exact (hc k).const_smul (u k) + +lemma lpDiagonal_norm_le {a : ℤ → ℂ} (B : ℝ≥0) (ha : ∀ k, ‖a k‖ ≤ B) : + ‖lpDiagonal a B ha‖ ≤ B := by + refine (lpDiagonal a B ha).opNorm_le_bound B.coe_nonneg ?_ + intro u + calc + _ ≤ ‖(B : ℂ) • u‖ := lp.norm_mono (by norm_num) (by + intro k + simp only [lpDiagonal_apply, lp.coeFn_smul, Pi.smul_apply, smul_eq_mul, + norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg B.coe_nonneg] + exact mul_le_mul_of_nonneg_right (ha k) (norm_nonneg _)) + _ = (B : ℝ) * ‖u‖ := by rw [norm_smul]; simp + +abbrev CircleFiberL2 := Lp FiberHilbert 2 (AddCircle.haarAddCircle (T := (1:ℝ))) +abbrev CircleFiberOperator := CircleFiberL2 →L[ℂ] CircleFiberL2 +def fiberBasis : HilbertBasis ℤ ℂ FiberHilbert := + HilbertBasis.ofRepr (LinearIsometryEquiv.refl ℂ FiberHilbert) +@[simp] lemma fiberBasis_apply (a : ℤ) : fiberBasis a = lp.single 2 a 1 := by + simpa [fiberBasis] using (fiberBasis.repr_self a) + +def circleFiberBasis : HilbertBasis (ℤ×ℤ) ℂ CircleFiberL2 := + tensorL2Basis AddCircle.haarAddCircle fiberBasis fourierBasis + +lemma circleFiberBasis_coe (a b : ℤ) : + circleFiberBasis (a,b) =ᵐ[AddCircle.haarAddCircle] fun x ↦ + fourier b x • lp.single 2 a 1 := by + simp only [circleFiberBasis,tensorL2Basis_apply] + filter_upwards [pureL2_coe (AddCircle.haarAddCircle (T := (1:ℝ))) (fourierBasis b) (fiberBasis a), + coeFn_fourierLp (T := (1:ℝ)) 2 b] with x h1 h2 + simpa only [coe_fourierBasis,h2,fiberBasis_apply] using h1 + +def continuousPiField (θ : CircleX) (g : C(CircleX,ℂ)) (x : CircleX) : FiberOperator := + lpDiagonal (fun k ↦ g (x+k•θ)) ⟨‖g‖,norm_nonneg g⟩ + (fun k ↦ ContinuousMap.norm_coe_le_norm g (x+k•θ)) + +@[simp] lemma continuousPiField_apply (θ : CircleX) (g : C(CircleX,ℂ)) + (x : CircleX) (v : FiberHilbert) (k : ℤ) : + continuousPiField θ g x v k = g (x+k•θ)*v k := rfl + +lemma continuousPiField_bound (θ : CircleX) (g : C(CircleX,ℂ)) (x : CircleX) : + ‖continuousPiField θ g x‖ ≤ ‖g‖ := by + exact lpDiagonal_norm_le ⟨‖g‖,norm_nonneg g⟩ _ + +lemma continuousPiField_continuous (θ : CircleX) (g : C(CircleX,ℂ)) (v : FiberHilbert) : + Continuous (fun x ↦ continuousPiField θ g x v) := by + apply continuous_bounded_lp_field _ (norm_nonneg g) (continuousPiField_bound θ g) _ v + intro k + have he : (fun x ↦ continuousPiField θ g x (lp.single 2 k 1)) = + (fun x ↦ g (x+k•θ) • lp.single 2 k 1) := by + funext x + ext j + simp only [continuousPiField_apply,lp.coeFn_smul,Pi.smul_apply,smul_eq_mul] + by_cases h : j=k + · subst j; rfl + · simp [lp.single_apply,Pi.single_eq_of_ne h] + rw [he] + exact (g.continuous.comp (continuous_id.add continuous_const)).smul continuous_const + +def continuousPi (θ : CircleX) (g : C(CircleX,ℂ)) : CircleFiberOperator := + fieldMulL2 AddCircle.haarAddCircle (continuousPiField θ g) + (fun v ↦ (continuousPiField_continuous θ g v).aestronglyMeasurable) + ‖g‖ (Eventually.of_forall (continuousPiField_bound θ g)) + +lemma continuousPi_coe (θ : CircleX) (g : C(CircleX,ℂ)) (f : CircleFiberL2) : + continuousPi θ g f =ᵐ[AddCircle.haarAddCircle] fun x ↦ continuousPiField θ g x (f x) := + fieldMulL2_coe _ _ _ _ _ _ + +lemma continuousPi_norm_le (θ : CircleX) (g : C(CircleX,ℂ)) : + ‖continuousPi θ g‖ ≤ ‖g‖ := + fieldMulL2_norm_le _ _ _ _ _ (norm_nonneg _) + +lemma continuousPi_add (θ : CircleX) (g h : C(CircleX,ℂ)) : + continuousPi θ (g+h) = continuousPi θ g + continuousPi θ h := by + apply ContinuousLinearMap.ext + intro f + apply Lp.ext + filter_upwards [continuousPi_coe θ (g+h) f,continuousPi_coe θ g f, + continuousPi_coe θ h f,Lp.coeFn_add (continuousPi θ g f) (continuousPi θ h f)] with x h1 h2 h3 h4 + change (continuousPi θ (g+h) f) x = ((continuousPi θ g f)+(continuousPi θ h f)) x + rw [h1,h4] + simp only [Pi.add_apply,h2,h3] + ext k + simp only [continuousPiField_apply,ContinuousMap.add_apply,lp.coeFn_add,Pi.add_apply,add_mul] + +lemma continuousPi_mul (θ : CircleX) (g h : C(CircleX,ℂ)) : + continuousPi θ (g*h) = continuousPi θ g * continuousPi θ h := by + apply ContinuousLinearMap.ext + intro f + apply Lp.ext + filter_upwards [continuousPi_coe θ (g*h) f,continuousPi_coe θ h f, + continuousPi_coe θ g (continuousPi θ h f)] with x h1 h2 h3 + change (continuousPi θ (g*h) f) x = (continuousPi θ g (continuousPi θ h f)) x + rw [h1,h3,h2] + ext k + simp only [continuousPiField_apply,ContinuousMap.mul_apply,mul_assoc] + +lemma continuousPi_one (θ : CircleX) : continuousPi θ 1 = 1 := by + apply ContinuousLinearMap.ext + intro f + apply Lp.ext + filter_upwards [continuousPi_coe θ 1 f] with x hx + rw [hx] + ext k + simp only [continuousPiField_apply,ContinuousMap.one_apply,one_mul] + rfl + +lemma continuousPi_zero (θ : CircleX) : continuousPi θ 0 = 0 := by + apply ContinuousLinearMap.ext + intro f + apply Lp.ext + filter_upwards [continuousPi_coe θ 0 f,Lp.coeFn_zero FiberHilbert 2 AddCircle.haarAddCircle] with x hx hz + change (continuousPi θ 0 f) x = (0 : CircleFiberL2) x + rw [hx,hz] + ext k + simp only [continuousPiField_apply,ContinuousMap.zero_apply,zero_mul,Pi.zero_apply,lp.coeFn_zero] + +lemma continuousPi_smul (θ : CircleX) (g : C(CircleX,ℂ)) (c : ℂ) : + continuousPi θ (c•g) = c•continuousPi θ g := by + apply ContinuousLinearMap.ext + intro f + apply Lp.ext + filter_upwards [continuousPi_coe θ (c•g) f,continuousPi_coe θ g f, + Lp.coeFn_smul c (continuousPi θ g f)] with x h1 h2 h3 + change (continuousPi θ (c•g) f) x = (c•continuousPi θ g f) x + rw [h1,h3] + simp only [Pi.smul_apply,h2] + ext k + simp only [continuousPiField_apply,ContinuousMap.smul_apply,lp.coeFn_smul, + Pi.smul_apply,smul_eq_mul,mul_assoc] + +lemma continuousPiField_inner_star (θ : CircleX) (g : C(CircleX,ℂ)) (x : CircleX) + (u v : FiberHilbert) : + inner ℂ (continuousPiField θ (star g) x u) v = inner ℂ u (continuousPiField θ g x v) := by + simp only [lp.inner_eq_tsum] + apply tsum_congr + intro k + simp only [continuousPiField_apply,RCLike.inner_apply,ContinuousMap.star_apply,map_mul, + starRingEnd_apply,star_star] + ring + +lemma continuousPi_star (θ : CircleX) (g : C(CircleX,ℂ)) : + continuousPi θ (star g) = star (continuousPi θ g) := by + apply ContinuousLinearMap.ext + intro f + apply ext_inner_right ℂ + intro h + change inner ℂ (continuousPi θ (star g) f) h = + inner ℂ ((continuousPi θ g).adjoint f) h + rw [ContinuousLinearMap.adjoint_inner_left,L2.inner_def,L2.inner_def] + apply integral_congr_ae + filter_upwards [continuousPi_coe θ (star g) f,continuousPi_coe θ g h] with x h1 h2 + rw [h1,h2] + exact continuousPiField_inner_star θ g x (f x) (h x) + +def continuousPiHom (θ : CircleX) : C(CircleX,ℂ) →⋆ₐ[ℂ] CircleFiberOperator where + toFun := continuousPi θ + map_zero' := continuousPi_zero θ + map_one' := continuousPi_one θ + map_add' := continuousPi_add θ + map_mul' := continuousPi_mul θ + commutes' := by + intro c + simp only [Algebra.algebraMap_eq_smul_one,continuousPi_smul,continuousPi_one] + map_star' := continuousPi_star θ + +lemma continuous_continuousPiHom (θ : CircleX) : Continuous (continuousPiHom θ) := by + exact (LinearMap.mkContinuous (continuousPiHom θ).toLinearMap 1 + (by + intro g + change ‖continuousPi θ g‖ ≤ 1 * ‖g‖ + simpa only [one_mul] using continuousPi_norm_le θ g)).continuous + +end + + +def fiberShiftL2 (n : ℤ) : CircleFiberOperator := + (fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap.compLpL 2 AddCircle.haarAddCircle + +lemma fiberShiftL2_coe (n : ℤ) (f : CircleFiberL2) : + fiberShiftL2 n f =ᵐ[AddCircle.haarAddCircle] fun x ↦ fiberShift n (f x) := + (fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap.coeFn_compLpL f + +lemma fiberShift_single (n a : ℤ) (c : ℂ) : + fiberShift n (lp.single 2 a c) = lp.single 2 (n+a) c := by + ext k + simp only [fiberShift_apply,lp.single_apply,Pi.single_apply] + have he : k-n=a ↔ k=n+a := by omega + simp only [he] + +lemma fiberShiftL2_basis (n a b : ℤ) : + fiberShiftL2 n (circleFiberBasis (a,b)) = circleFiberBasis (n+a,b) := by + apply Lp.ext + filter_upwards [fiberShiftL2_coe n (circleFiberBasis (a,b)), + circleFiberBasis_coe a b,circleFiberBasis_coe (n+a) b] with x h1 h2 h3 + rw [h1,h2,h3,map_smul,fiberShift_single] + +lemma circleFiberBasis_ext {A B : CircleFiberOperator} + (h : ∀ a b, A (circleFiberBasis (a,b)) = B (circleFiberBasis (a,b))) : A=B := by + have he : A.comp circleFiberBasis.repr.symm.toContinuousLinearEquiv.toContinuousLinearMap = + B.comp circleFiberBasis.repr.symm.toContinuousLinearEquiv.toContinuousLinearMap := by + apply lp.ext_continuousLinearMap (by norm_num) + intro k + apply ContinuousLinearMap.ext + intro c + change A (circleFiberBasis.repr.symm (lp.single 2 k c)) = + B (circleFiberBasis.repr.symm (lp.single 2 k c)) + have hc : lp.single (E := fun _ : ℤ×ℤ ↦ ℂ) 2 k c = c•lp.single 2 k 1 := by + simpa using lp.single_smul (E := fun _ : ℤ×ℤ ↦ ℂ) 2 k c 1 + rw [hc,map_smul,map_smul,map_smul,HilbertBasis.repr_symm_single,h k.1 k.2] + apply ContinuousLinearMap.ext + intro f + simpa only [ContinuousLinearMap.comp_apply, + LinearIsometryEquiv.coe_toContinuousLinearEquiv,ContinuousLinearEquiv.coe_coe, + LinearIsometryEquiv.symm_apply_apply] using + DFunLike.congr_fun he (circleFiberBasis.repr f) + +lemma regularShift_single (n a b : ℤ) (c : ℂ) : + regularShift n (lp.single 2 (a,b) c) = lp.single 2 (n+a,b) c := by + ext ⟨k,l⟩ + simp only [regularShift_apply,lp.single_apply,Pi.single_apply,Prod.mk.injEq] + have he : k-n=a ∧ l=b ↔ k=n+a ∧ l=b := by omega + simp only [he] + +lemma circleFiberBasis_conj_U : + circleFiberBasis.repr.symm.conjStarAlgEquiv (regularU : RegularOperator) = fiberShiftL2 1 := by + apply circleFiberBasis_ext + intro a b + simp only [LinearIsometryEquiv.conjStarAlgEquiv_apply_apply,LinearIsometryEquiv.symm_symm, + HilbertBasis.repr_self] + change circleFiberBasis.repr.symm (regularShift 1 (lp.single 2 (a,b) 1)) = _ + rw [regularShift_single,HilbertBasis.repr_symm_single,fiberShiftL2_basis] + +lemma continuousPi_basis (θ : CircleX) (a b : ℤ) : + continuousPi θ (fourier 1) (circleFiberBasis (a,b)) = + (fourier 1 (a•θ)) • circleFiberBasis (a,b+1) := by + apply Lp.ext + filter_upwards [continuousPi_coe θ (fourier 1) (circleFiberBasis (a,b)), + circleFiberBasis_coe a b,circleFiberBasis_coe a (b+1), + Lp.coeFn_smul (fourier 1 (a•θ)) (circleFiberBasis (a,b+1))] with x h1 h2 h3 h4 + rw [h1,h2,h4] + simp only [Pi.smul_apply,h3] + ext k + simp only [continuousPiField_apply,lp.coeFn_smul,Pi.smul_apply,smul_eq_mul] + by_cases hk : k=a + · subst k + simp only [lp.single_apply,Pi.single_eq_same,mul_one] + rw [fourier_add] + simp only [fourier_one, AddCircle.toCircle_add,Circle.coe_mul] + ring + · simp [lp.single_apply,Pi.single_eq_of_ne hk] + +lemma regularMagnetic_single (u : unitary ℂ) (a b : ℤ) (c : ℂ) : + regularMagnetic u 1 (lp.single 2 (a,b) c) = + ((u^a : unitary ℂ) : ℂ) • lp.single 2 (a,b+1) c := by + ext ⟨k,l⟩ + simp only [regularMagnetic_apply,one_mul,lp.coeFn_smul,Pi.smul_apply, + lp.single_apply,Pi.single_apply,Prod.mk.injEq] + have he : k=a ∧ l-1=b ↔ k=a ∧ l=b+1 := by omega + simp only [he] + split_ifs with h + · rcases h with ⟨rfl,rfl⟩; rfl + · simp + +lemma fourier_one_real (θ : ℝ) : fourier 1 (θ : CircleX) = (rotationScalar θ : ℂ) := by + simp only [fourier_one,AddCircle.toCircle_apply_mk,Circle.coe_exp,div_one] + simp only [rotationScalar,Complex.ofReal_mul,Complex.ofReal_ofNat] + +lemma fourier_one_zsmul_real (θ : ℝ) (a : ℤ) : + fourier 1 (a • (θ : CircleX)) = ((rotationScalar θ)^a : unitary ℂ) := by + rw [fourier_one, AddCircle.toCircle_zsmul, Circle.coe_zpow] + rw [← fourier_one, fourier_one_real, Unitary.coe_zpow] + +lemma circleFiberBasis_conj_V (θ : ℝ) : + circleFiberBasis.repr.symm.conjStarAlgEquiv (regularV (rotationScalar θ) : RegularOperator) = + continuousPi (θ : CircleX) (fourier 1) := by + apply circleFiberBasis_ext + intro a b + simp only [LinearIsometryEquiv.conjStarAlgEquiv_apply_apply,LinearIsometryEquiv.symm_symm, + HilbertBasis.repr_self] + change circleFiberBasis.repr.symm (regularMagnetic (rotationScalar θ) 1 + (lp.single 2 (a,b) 1)) = _ + rw [regularMagnetic_single,map_smul,HilbertBasis.repr_symm_single,continuousPi_basis, + fourier_one_zsmul_real] + + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Fibers.lean b/lean/OAI/Analysis/RotationWeights/Fibers.lean new file mode 100644 index 0000000000000000000000000000000000000000..b51f6f568a88751551a8457bf431b7a5d880d26d --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Fibers.lean @@ -0,0 +1,191 @@ +import OAI.Analysis.RotationWeights.Regular + +namespace OAI + +universe uι + +noncomputable section +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators + +namespace ContinuousCircleWeight +abbrev FiberHilbert := lp (fun _ : ℤ => ℂ) 2 +abbrev FiberOperator := FiberHilbert →L[ℂ] FiberHilbert + +def lpDiagonal {ι : Type uι} (a : ι → ℂ) (B : ℝ≥0) (ha : ∀ i, ‖a i‖ ≤ B) : + lp (fun _ : ι => ℂ) 2 →L[ℂ] lp (fun _ : ι => ℂ) 2 := + LinearMap.mkContinuous + { toFun := fun f => ⟨fun i => a i * f i, by + apply (((lp.memℓp f).norm).const_mul (B : ℝ)).mono + intro i + change ‖a i * f i‖ ≤ (B : ℝ) * ‖f i‖ + rw [norm_mul] + exact mul_le_mul_of_nonneg_right (ha i) (norm_nonneg _)⟩ + map_add' := by intro f g; ext i; exact mul_add _ _ _ + map_smul' := by intro c f; ext i; exact mul_left_comm _ _ _ } + B (by + intro f + calc + _ ≤ ‖(B : ℂ) • f‖ := lp.norm_mono (by norm_num) (by + intro i + change ‖a i * f i‖ ≤ ‖((B : ℝ) : ℂ) * f i‖ + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs] + simpa using mul_le_mul_of_nonneg_right (ha i) (norm_nonneg (f i)) +) + _ = (B : ℝ) * ‖f‖ := by + rw [norm_smul] + simp) + +@[simp] theorem lpDiagonal_apply {ι : Type uι} (a : ι → ℂ) (B : ℝ≥0) + (ha : ∀ i, ‖a i‖ ≤ B) (f : lp (fun _ : ι => ℂ) 2) (i : ι) : + lpDiagonal a B ha f i = a i * f i := rfl + +def fiberShift (n : ℤ) : FiberHilbert ≃ₗᵢ[ℂ] FiberHilbert := + lpPermute (Equiv.addLeft n) + +@[simp] theorem fiberShift_apply (n : ℤ) (f : FiberHilbert) (k : ℤ) : + fiberShift n f k = f (k-n) := by + change f (-n+k) = _ + apply congrArg f; omega + +@[simp] theorem fiberShift_add (m n : ℤ) : + fiberShift (m+n) = fiberShift m * fiberShift n := by + ext f k + change fiberShift (m+n) f k = fiberShift m (fiberShift n f) k + simp only [fiberShift_apply] + apply congrArg f; omega + +def fiberWeightedShift (w : ℤ → ℂ) (hw : ∀ k, ‖w k‖ ≤ 1) : FiberOperator := + (fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap * lpDiagonal w 1 hw + +@[simp] theorem fiberWeightedShift_apply (w : ℤ → ℂ) (hw : ∀ k, ‖w k‖ ≤ 1) + (f : FiberHilbert) (k : ℤ) : + fiberWeightedShift w hw f k = w (k-1) * f (k-1) := by + change fiberShift 1 (lpDiagonal w 1 hw f) k = _ + rw [fiberShift_apply] + rfl + +def fiberCocycleShift (F : ℤ → ℝ) (hF : ∀ k, 0 < F k) (hmono : Antitone F) : + FiberOperator := + fiberWeightedShift (fun k => ((F (k+1) / F k : ℝ) : ℂ)) (by + intro k + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_pos (div_pos (hF _) (hF _))] + exact (div_le_one (hF k)).mpr (hmono (by omega))) + +@[simp] theorem fiberCocycleShift_apply (F : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hmono : Antitone F) (f : FiberHilbert) (k : ℤ) : + fiberCocycleShift F hF hmono f k = (F k / F (k-1) : ℝ) * f (k-1) := by + simp [fiberCocycleShift] + +theorem fiberCocycleShift_pow_apply (F : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hmono : Antitone F) (n : ℕ) (f : FiberHilbert) (k : ℤ) : + (fiberCocycleShift F hF hmono ^ n) f k = + (F k / F (k-n) : ℝ) * f (k-n) := by + induction n generalizing f k with + | zero => simp [ne_of_gt (hF k)] + | succ n ih => + rw [pow_succ', mul_apply_eq_comp, fiberCocycleShift_apply, ih] + have hk : k - 1 - (n : ℤ) = k - ((n+1 : ℕ) : ℤ) := by omega + rw [hk, ← mul_assoc, ← Complex.ofReal_mul] + have hr : F k / F (k-1) * (F (k-1) / F (k - ((n+1 : ℕ) : ℤ))) = + F k / F (k - ((n+1 : ℕ) : ℤ)) := by + field_simp [ne_of_gt (hF (k-1))] + rw [hr] + +theorem invariant_fixed_vector {T q : FiberOperator} + (hinv : (1-q) * T * q = 0) {v : FiberHilbert} (hv : q v = v) : + q (T v) = T v := by + have h := congrArg (fun A : FiberOperator => A v) hinv + have heq : T v - q (T v) = 0 := by + simpa only [mul_apply_eq_comp, hv, sub_apply, + one_apply_eq_self, zero_apply] using h + exact (sub_eq_zero.mp heq).symm + +theorem invariant_fixed_vector_pow {T q : FiberOperator} + (hinv : (1-q) * T * q = 0) {v : FiberHilbert} (hv : q v = v) (n : ℕ) : + q ((T ^ n) v) = (T ^ n) v := by + induction n with + | zero => simpa using hv + | succ n ih => + rw [pow_succ', mul_apply_eq_comp] + exact invariant_fixed_vector hinv ih + +theorem projection_complement_inner {q : FiberOperator} (hq : IsStarProjection q) + {v : FiberHilbert} (hv : q v = v) (e : FiberHilbert) : + inner ℂ ((1-q) e) v = 0 := by + rw [← (hq.one_sub.isSelfAdjoint.adjoint_eq), + ContinuousLinearMap.adjoint_inner_left] + simp [hv] + +def cocycleRatioDiagonal (F G : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hG : ∀ k, 0 < G k) (horder : ∀ k, G k ≤ F k) : FiberOperator := + lpDiagonal (fun k => ((G k / F k : ℝ) : ℂ)) 1 (by + intro k + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_pos (div_pos (hG _) (hF _))] + exact (div_le_one (hF k)).mpr (horder k)) + +@[simp] theorem cocycleRatioDiagonal_apply (F G : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hG : ∀ k, 0 < G k) (horder : ∀ k, G k ≤ F k) (v : FiberHilbert) (k : ℤ) : + cocycleRatioDiagonal F G hF hG horder v k = (G k / F k : ℝ) * v k := rfl + +theorem cocycle_action_coordinate (F G : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hG : ∀ k, 0 < G k) (hmono : Antitone G) (horder : ∀ k, G k ≤ F k) + (ξ : FiberHilbert) (n : ℕ) (k : ℤ) : + ((fiberCocycleShift G hG hmono ^ n) + (cocycleRatioDiagonal F G hF hG horder ξ)) (n+k) = + (G (n+k) / F k : ℝ) * ξ k := by + rw [fiberCocycleShift_pow_apply] + simp only [add_sub_cancel_left, cocycleRatioDiagonal_apply] + rw [← mul_assoc, ← Complex.ofReal_mul] + congr 2 + field_simp [ne_of_gt (hG k)] + +theorem fiber_full_convolution (F G : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hG : ∀ k, 0 < G k) (hmono : Antitone G) (horder : ∀ k, G k ≤ F k) + (q : FiberOperator) (hq : IsStarProjection q) + (hinv : (1-q) * fiberCocycleShift G hG hmono * q = 0) + (ξ e : FiberHilbert) + (hξ : q (cocycleRatioDiagonal F G hF hG horder ξ) = + cocycleRatioDiagonal F G hF hG horder ξ) (n : ℕ) : + Summable (fun v : ℤ => (G (n+v) / F v : ℝ) * ξ v * + starRingEnd ℂ (((1-q) e) (n+v))) ∧ + (∑' v : ℤ, (G (n+v) / F v : ℝ) * ξ v * + starRingEnd ℂ (((1-q) e) (n+v))) = 0 := by + let η := (fiberCocycleShift G hG hmono ^ n) + (cocycleRatioDiagonal F G hF hG horder ξ) + let g := (1-q) e + have hcoord (k : ℤ) : inner ℂ (g (n+k)) (η (n+k)) = + (G (n+k) / F k : ℝ) * ξ k * starRingEnd ℂ (g (n+k)) := by + rw [RCLike.inner_apply] + rw [show η (n+k) = (G (n+k) / F k : ℝ) * ξ k from + cocycle_action_coordinate F G hF hG hmono horder ξ n k] + constructor + · have hs := (Equiv.addLeft (n : ℤ)).summable_iff.mpr (lp.summable_inner (𝕜 := ℂ) g η) + change Summable (fun k : ℤ => inner ℂ (g (n+k)) (η (n+k))) at hs + simpa only [hcoord] using hs + · have hzero : inner ℂ g η = 0 := projection_complement_inner hq + (invariant_fixed_vector_pow hinv hξ n) e + rw [lp.inner_eq_tsum] at hzero + rw [← (Equiv.addLeft (n : ℤ)).tsum_eq (fun k => inner ℂ (g k) (η k))] at hzero + change (∑' k : ℤ, inner ℂ (g (n+k)) (η (n+k))) = 0 at hzero + simpa only [hcoord] using hzero + +theorem cocycle_two_ratio_bounds (F G : ℤ → ℝ) (hF : ∀ k, 0 < F k) + (hG : ∀ k, 0 < G k) (hFmono : Antitone F) (hGmono : Antitone G) + (horder : ∀ k, G k ≤ F k) (n : ℕ) (k : ℤ) : + 0 < G (n+k) / F k ∧ + G (n+k) / F k ≤ G k / F k ∧ + G (n+k) / F k ≤ G (n+k) / F (n+k) ∧ + G k / F k ≤ 1 ∧ G (n+k) / F (n+k) ≤ 1 := by + have hkn : k ≤ (n : ℤ) + k := by omega + exact ⟨div_pos (hG _) (hF _), + div_le_div_of_nonneg_right (hGmono hkn) (hF _).le, + div_le_div_of_nonneg_left (hG _).le (hF _) (hFmono hkn), + (div_le_one (hF _)).mpr (horder _), + (div_le_one (hF _)).mpr (horder _)⟩ + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/FieldExtraction.lean b/lean/OAI/Analysis/RotationWeights/FieldExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..87cf254d84ee32222614c49590041ca204c200f4 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/FieldExtraction.lean @@ -0,0 +1,282 @@ +import OAI.Analysis.RotationWeights.TracialAction + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uX uE + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace + +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +section +variable {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [InnerProductSpace ℂ E] +abbrev VectorL2 := Lp E 2 μ + +def indicatorV2 (s : Set X) (hs : MeasurableSet s) : VectorL2 (E := E) μ →L[ℂ] VectorL2 (E := E) μ := + LinearMap.mkContinuous + { toFun := fun f ↦ ((Lp.memLp f).indicator hs).toLp (s.indicator f) + map_add' := by + intro f g + apply Lp.ext + filter_upwards [((Lp.memLp (f+g)).indicator hs).coeFn_toLp, + ((Lp.memLp f).indicator hs).coeFn_toLp, ((Lp.memLp g).indicator hs).coeFn_toLp, + Lp.coeFn_add f g, Lp.coeFn_add (((Lp.memLp f).indicator hs).toLp _) + (((Lp.memLp g).indicator hs).toLp _)] with x h1 h2 h3 h4 h5 + simp only [Pi.add_apply] at h4 h5 + rw [h1,h5,h2,h3] + by_cases hx : x∈s + · simp only [indicator_of_mem hx, h4] + · simp only [indicator_of_notMem hx, add_zero] + map_smul' := by + intro c f + apply Lp.ext + filter_upwards [((Lp.memLp (c•f)).indicator hs).coeFn_toLp, + ((Lp.memLp f).indicator hs).coeFn_toLp, Lp.coeFn_smul c f, + Lp.coeFn_smul c (((Lp.memLp f).indicator hs).toLp _)] with x h1 h2 h3 h4 + simp only [Pi.smul_apply] at h3 h4 + simp only [RingHom.id_apply] + rw [h1,h4,h2] + by_cases hx : x∈s + · simp only [indicator_of_mem hx, h3] + · simp only [indicator_of_notMem hx, smul_zero] } + 1 (by + intro f + change ‖((Lp.memLp f).indicator hs).toLp (s.indicator f)‖ ≤ 1*‖f‖ + apply Lp.norm_le_mul_norm_of_ae_le_mul + filter_upwards [((Lp.memLp f).indicator hs).coeFn_toLp] with x hx + rw [hx, one_mul] + by_cases hxs : x∈s + · simp only [indicator_of_mem hxs, le_refl] + · simp only [indicator_of_notMem hxs, norm_zero, norm_nonneg]) + +lemma indicatorV2_coe (s : Set X) (hs : MeasurableSet s) (f : VectorL2 (E := E) μ) : + indicatorV2 μ s hs f =ᵐ[μ] s.indicator f := + ((Lp.memLp f).indicator hs).coeFn_toLp + +lemma vectorL2_norm_sq_integral (f : VectorL2 (E := E) μ) : + ‖f‖^2 = ∫ x, ‖f x‖^2 ∂μ := by + rw [← inner_self_eq_norm_sq (𝕜 := ℂ), L2.inner_def, + ← integral_re (L2.integrable_inner f f)] + simp only [inner_self_eq_norm_sq] + +lemma indicatorV2_norm_sq (s : Set X) (hs : MeasurableSet s) (f : VectorL2 (E := E) μ) : + ‖indicatorV2 μ s hs f‖^2 = ∫ x in s, ‖f x‖^2 ∂μ := by + rw [vectorL2_norm_sq_integral, ← integral_indicator hs] + apply integral_congr_ae + filter_upwards [indicatorV2_coe μ s hs f] with x hx + rw [hx] + by_cases hxs : x∈s <;> simp [hxs] + +variable [IsFiniteMeasure μ] + +lemma commutes_indicator_pointwise_bound (A : VectorL2 (E := E) μ →L[ℂ] VectorL2 (E := E) μ) + (hA : ∀ s (hs : MeasurableSet s), A.comp (indicatorV2 μ s hs) = + (indicatorV2 μ s hs).comp A) (v : E) : + ∀ᵐ x ∂μ, ‖(A (Lp.const 2 μ v)) x‖ ≤ ‖A‖*‖v‖ := by + have hi : Integrable (fun x ↦ ‖(A (Lp.const 2 μ v)) x‖^2) μ := + (memLp_two_iff_integrable_sq_norm (Lp.aestronglyMeasurable _)).mp (Lp.memLp _) + have he : ∀ᵐ x ∂μ, ‖(A (Lp.const 2 μ v)) x‖^2 ≤ (‖A‖*‖v‖)^2 := by + apply ae_le_of_forall_setIntegral_le hi (integrable_const _) + intro s hs _ + rw [← indicatorV2_norm_sq μ s hs] + have hc : indicatorV2 μ s hs (A (Lp.const 2 μ v)) = + A (indicatorV2 μ s hs (Lp.const 2 μ v)) := + (congrArg (fun B : VectorL2 (E := E) μ →L[ℂ] VectorL2 (E := E) μ ↦ B (Lp.const 2 μ v)) (hA s hs)).symm + rw [hc] + calc + _ ≤ (‖A‖ * ‖indicatorV2 μ s hs (Lp.const 2 μ v)‖)^2 := + pow_le_pow_left₀ (norm_nonneg _) (A.le_opNorm _) _ + _ = ‖A‖^2 * ∫ x in s, ‖(Lp.const 2 μ v) x‖^2 ∂μ := by + rw [mul_pow, indicatorV2_norm_sq] + _ = _ := by + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [ae_restrict_of_ae (Lp.coeFn_const 2 μ v)] with x hx + rw [hx] + simp only [Function.const_apply, mul_pow] + filter_upwards [he] with x hx + nlinarith [norm_nonneg ((A (Lp.const 2 μ v)) x), mul_nonneg (norm_nonneg A) (norm_nonneg v)] + +end +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +variable {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℂ E] +local instance rationalNormedSpace : NormedSpace ℚ E := NormedSpace.restrictScalars ℚ ℂ E +local instance rationalTower : IsScalarTower ℚ ℂ E := IsScalarTower.restrictScalars ℚ ℂ E + +def complexOfRat (T : E →L[ℚ] E) (hI : ∀ v, T (Complex.I • v) = Complex.I • T v) : E →L[ℂ] E where + toFun := T + map_add' := T.map_add + map_smul' := by + intro c v + have hr : ∀ a : ℝ, T ((a : ℂ) • v) = (a : ℂ) • T v := by + intro a + refine (Rat.denseRange_cast : DenseRange ((↑) : ℚ → ℝ)).induction_on a ?_ ?_ + · exact isClosed_eq (by fun_prop) (by fun_prop) + · intro q + simp only [Complex.ofReal_ratCast, Rat.cast_smul_eq_qsmul ℂ q] + exact T.map_smul q v + have hrI : T ((c.im : ℂ) • (Complex.I • v)) = (c.im : ℂ) • T (Complex.I • v) := by + refine (Rat.denseRange_cast : DenseRange ((↑) : ℚ → ℝ)).induction_on c.im ?_ ?_ + · exact isClosed_eq (by fun_prop) (by fun_prop) + · intro q + simp only [Complex.ofReal_ratCast, Rat.cast_smul_eq_qsmul ℂ q] + exact T.map_smul q (Complex.I • v) + rw [← Complex.re_add_im c, add_smul, map_add, mul_smul, hr, hrI, hI] + simp only [RingHom.id_apply, add_smul, mul_smul] + cont := T.continuous + +lemma complexOfRat_apply (T : E →L[ℚ] E) (hI : ∀ v, T (Complex.I • v) = Complex.I • T v) (v : E) : + complexOfRat T hI v = T v := rfl + +lemma complexOfRat_norm_le (T : E →L[ℚ] E) (hI : ∀ v, T (Complex.I • v) = Complex.I • T v) : + ‖complexOfRat T hI‖ ≤ ‖T‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + exact T.le_opNorm + +def rationalCore (v : ℕ → E) : Submodule ℚ E := + Submodule.span ℚ (range v ∪ range (fun n ↦ Complex.I • v n)) + +instance rationalCore_countable (v : ℕ → E) : Countable (rationalCore v) := by + unfold rationalCore + have heq : range v ∪ range (fun n ↦ Complex.I • v n) = + range (Sum.elim v (fun n ↦ Complex.I • v n)) := by + ext x + simp + rw [heq] + infer_instance + +lemma rationalCore_I (v : ℕ → E) (u : rationalCore v) : + Complex.I • (u : E) ∈ rationalCore v := by + apply Submodule.span_induction (p := fun x _ ↦ Complex.I • x ∈ rationalCore v) + _ _ _ _ u.property + · intro x hx + rcases hx with ⟨n,rfl⟩ | ⟨n,rfl⟩ + · exact Submodule.subset_span (Or.inr ⟨n,rfl⟩) + · rw [smul_smul, Complex.I_mul_I, neg_smul, one_smul] + exact (rationalCore v).neg_mem (Submodule.subset_span (Or.inl ⟨n,rfl⟩)) + · simp only [smul_zero, Submodule.zero_mem] + · intro x y _ _ hx hy + simpa only [smul_add] using (rationalCore v).add_mem hx hy + · intro a x _ hx + rw [smul_comm] + exact (rationalCore v).smul_mem a hx + +lemma rationalCore_dense (v : ℕ → E) (hv : DenseRange v) : + DenseRange (rationalCore v).subtypeL := by + intro x + apply closure_mono (s := range v) _ (hv x) + rintro _ ⟨n,rfl⟩ + exact ⟨⟨v n, Submodule.subset_span (Or.inl ⟨n,rfl⟩)⟩,rfl⟩ + +variable {X : Type uX} [MeasurableSpace X] (μ : Measure X) + [CompleteSpace E] [IsFiniteMeasure μ] + +theorem extract_bounded_field (A : Lp E 2 μ →L[ℂ] Lp E 2 μ) + (hb : ∀ v : E, ∀ᵐ x ∂μ, ‖(A (Lp.const 2 μ v)) x‖ ≤ ‖A‖ * ‖v‖) + (v : ℕ → E) (hv : DenseRange v) : + ∃ T : X → (E →L[ℂ] E), (∀ x, ‖T x‖ ≤ ‖A‖) ∧ + (∀ u : E, ∀ᵐ x ∂μ, T x u = (A (Lp.const 2 μ u)) x) := by + classical + let D := rationalCore v + let G : E →L[ℂ] Lp E 2 μ := A.comp (Lp.constL 2 μ ℂ) + have hG (u : E) : G u = A (Lp.const 2 μ u) := rfl + have hgadd (u w : E) : (G (u+w) : X → E) =ᵐ[μ] fun x ↦ G u x + G w x := by + rw [map_add] + exact Lp.coeFn_add _ _ + have hgsmul (a : ℂ) (u : E) : (G (a•u) : X → E) =ᵐ[μ] fun x ↦ a • G u x := by + rw [map_smul] + exact Lp.coeFn_smul _ _ + have hgqsmul (a : ℚ) (u : E) : (G (a•u) : X → E) =ᵐ[μ] fun x ↦ a • G u x := by + simpa only [Rat.cast_smul_eq_qsmul] using hgsmul (a : ℂ) u + let Good : X → Prop := fun x ↦ + (∀ u w : D, G ((u:E)+(w:E)) x = G u x + G w x) ∧ + (∀ a : ℚ, ∀ u : D, G (a • (u:E)) x = a • G u x) ∧ + (∀ u : D, ‖G u x‖ ≤ ‖A‖ * ‖(u:E)‖) ∧ + (∀ u : D, G (Complex.I • (u:E)) x = Complex.I • G u x) + have hGood : ∀ᵐ x ∂μ, Good x := by + have h1 := ae_all_iff.mpr (fun u : D ↦ ae_all_iff.mpr (fun w : D ↦ hgadd u w)) + have h2 := ae_all_iff.mpr (fun a : ℚ ↦ ae_all_iff.mpr (fun u : D ↦ hgqsmul a u)) + have h3 := ae_all_iff.mpr (fun u : D ↦ hb (u:E)) + have h4 := ae_all_iff.mpr (fun u : D ↦ hgsmul Complex.I u) + filter_upwards [h1,h2,h3,h4] with x h1 h2 h3 h4 + exact ⟨h1,h2,h3,h4⟩ + let TD : X → (D →L[ℚ] E) := fun x ↦ if hx : Good x then + LinearMap.mkContinuous + { toFun := fun u ↦ G (u:E) x + map_add' := fun u w ↦ hx.1 u w + map_smul' := fun a u ↦ hx.2.1 a u } + ‖A‖ hx.2.2.1 + else 0 + let R : X → (E →L[ℚ] E) := fun x ↦ (TD x).extend D.subtypeL + have hd : DenseRange D.subtypeL := rationalCore_dense v hv + have hu : IsUniformInducing D.subtypeL := isometry_subtype_coe.isUniformInducing + have hTDnorm (x : X) : ‖TD x‖ ≤ ‖A‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro u + dsimp only [TD] + split_ifs with hx + · exact hx.2.2.1 u + · simp only [zero_apply, norm_zero] + positivity + have hRnorm (x : X) : ‖R x‖ ≤ ‖A‖ := by + have h := ContinuousLinearMap.opNorm_extend_le (TD x) (N := 1) hd + (fun u : D ↦ by simp) + have h' : ‖R x‖ ≤ ‖TD x‖ := by simpa only [NNReal.coe_one, one_mul] using h + exact h'.trans (hTDnorm x) + have hReq (x : X) (hx : Good x) (u : D) : R x (u:E) = G u x := by + change (TD x).extend D.subtypeL (D.subtypeL u) = _ + rw [ContinuousLinearMap.extend_eq _ hd hu] + simp only [TD, dite_eq_left hx] + rfl + have hRI (x : X) (u : E) : R x (Complex.I • u) = Complex.I • R x u := by + refine hd.induction_on u ?_ ?_ + · exact isClosed_eq (by fun_prop) (by fun_prop) + · intro w + by_cases hx : Good x + · rw [show D.subtypeL w = (w:E) from rfl] + let iw : D := ⟨Complex.I • (w:E), rationalCore_I v w⟩ + rw [show Complex.I • (w:E) = (iw:E) from rfl, hReq x hx iw, hReq x hx w] + exact hx.2.2.2 w + · have hz : TD x = 0 := by simp only [TD, dite_eq_right hx] + simp only [R, hz, ContinuousLinearMap.extend_zero hd hu, + zero_apply, smul_zero] + let T : X → (E →L[ℂ] E) := fun x ↦ complexOfRat (R x) (hRI x) + refine ⟨T, fun x ↦ (complexOfRat_norm_le _ _).trans (hRnorm x), ?_⟩ + intro u + have hdelta (w : D) : ∀ᵐ x ∂μ, ‖G w x - G u x‖ ≤ ‖A‖ * ‖(w:E)-u‖ := by + have he : (G ((w:E)-u) : X → E) =ᵐ[μ] fun x ↦ G w x - G u x := by + rw [map_sub] + exact Lp.coeFn_sub _ _ + filter_upwards [he, hb ((w:E)-u)] with x hx hb + rw [← hx] + exact hb + filter_upwards [hGood, ae_all_iff.mpr hdelta] with x hx hdelta + change R x u = G u x + have hbound : ∀ z : E, ‖R x z - G u x‖ ≤ ‖A‖ * ‖z-u‖ := by + intro z + refine hd.induction_on z ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · intro w + rw [show D.subtypeL w = (w:E) from rfl, hReq x hx w] + exact hdelta w + have hzero := hbound u + simpa only [sub_self, norm_zero, mul_zero, norm_le_zero_iff, sub_eq_zero] using hzero + + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/FiniteSampling.lean b/lean/OAI/Analysis/RotationWeights/FiniteSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..2cc68f6ee2db8d3bbb785aaee9dfce95b97bace8 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/FiniteSampling.lean @@ -0,0 +1,453 @@ +import OAI.Analysis.RotationWeights.TrialBounds + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uι uκ uP uτ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical + +section +open scoped Topology +lemma continuousAt_repr {x : CircleX} (hx : x ≠ 0) : ContinuousAt repr x := + continuous_subtype_val.continuousAt.comp (AddCircle.continuousAt_equivIco 1 0 (by simpa using hx)) +lemma continuous_delta : Continuous delta := by unfold delta; fun_prop +lemma repr_pos {x : CircleX} (hx : x ≠ 0) : 0 < repr x := by + apply (repr_mem x).1.lt_of_ne' + intro h + apply hx + rw [← coe_repr x,h] + simp + +lemma continuousAt_weight {ℓ α s t : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (hαs : α ≠ delta s) (ht : 0 < t) (hst : t ≠ ℓ*delta s) : + ContinuousAt (fun z : ℝ × ℝ => weight ℓ α z.1 z.2) (s,t) := by + have hd := (continuous_delta.comp continuous_fst).continuousAt (x:=(s,t)) + have ht' := continuous_snd.continuousAt (x:=(s,t)) + by_cases ha : α ≤ delta s + · have had : α < delta s := lt_of_le_of_ne ha hαs + have hea : ∀ᶠ z : ℝ × ℝ in 𝓝 (s,t), α ≤ delta z.1 := by + filter_upwards [hd.eventually (lt_mem_nhds had)] with z hz + exact hz.le + have het : ∀ᶠ z : ℝ × ℝ in 𝓝 (s,t), 0 < z.2 := ht'.eventually (lt_mem_nhds ht) + by_cases hb : t < ℓ*delta s + · have heb : ∀ᶠ z : ℝ × ℝ in 𝓝 (s,t), z.2 < ℓ*delta z.1 := + (ht'.sub (hd.const_mul ℓ)).eventually (gt_mem_nhds (by linarith : t-ℓ*delta s < 0)) + |>.mono fun z h => by change z.2-ℓ*delta z.1 < 0 at h; linarith + have heq : (fun z : ℝ × ℝ => weight ℓ α z.1 z.2) =ᶠ[𝓝 (s,t)] + (fun z => 1/(ℓ*delta z.1)) := by + filter_upwards [hea,het,heb] with z ha ht hb + simp only [weight,ha,ht,hb,and_self,ite_true] + exact (continuousAt_const.div (hd.const_mul ℓ) + (mul_pos hℓ (hα.trans_le ha)).ne').congr_of_eventuallyEq heq + · have hb' : ℓ*delta s < t := lt_of_le_of_ne (le_of_not_gt hb) (Ne.symm hst) + have heb : ∀ᶠ z : ℝ × ℝ in 𝓝 (s,t), ℓ*delta z.1 < z.2 := by + filter_upwards [(ht'.sub (hd.const_mul ℓ)).eventually (lt_mem_nhds (sub_pos.mpr hb'))] with z hz + exact sub_pos.mp hz + have heq : (fun z : ℝ × ℝ => weight ℓ α z.1 z.2) =ᶠ[𝓝 (s,t)] (fun _ => (0:ℝ)) := by + filter_upwards [heb] with z hz + simp [weight,not_lt_of_ge hz.le] + exact continuousAt_const.congr_of_eventuallyEq heq + · have ha' : delta s < α := lt_of_not_ge ha + have heq : (fun z : ℝ × ℝ => weight ℓ α z.1 z.2) =ᶠ[𝓝 (s,t)] (fun _ => (0:ℝ)) := by + filter_upwards [hd.eventually (gt_mem_nhds ha')] with z hz + change delta z.1 < α at hz + simp [weight,not_le_of_gt hz] + exact continuousAt_const.congr_of_eventuallyEq heq + +lemma ae_repr_ne (r : ℝ) : ∀ᵐ s : CircleX, repr s ≠ r := by + have he : ∀ᵐ s : CircleX, s ≠ (r:CircleX) := by + rw [ae_iff] + simpa only [not_not,Set.ofPred_eq_eq_singleton] using volume_singleton_zero (r:CircleX) + filter_upwards [he] with s hs heq + exact hs (by rw [← coe_repr s,heq]) +lemma ae_delta_ne (r : ℝ) : ∀ᵐ s : CircleX, delta (repr s) ≠ r := by + filter_upwards [ae_repr_ne r,ae_repr_ne (1-r)] with s hs ht h + unfold delta at h + rcases le_total (repr s) (1-repr s) with hle | hle + · exact hs (by rwa [min_eq_left hle] at h) + · exact ht (by rw [min_eq_right hle] at h; linarith) + +lemma ae_continuousAt_uPos {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + {t : CircleX} (ht : t ≠ 0) : + ∀ᵐ s : CircleX, ContinuousAt (Function.uncurry (uPos ℓ α)) (s,t) := by + have he : ∀ᵐ s : CircleX, s ≠ 0 := by + rw [ae_iff] + simpa only [not_not,Set.ofPred_eq_eq_singleton] using volume_singleton_zero (0:CircleX) + filter_upwards [he,ae_delta_ne α,ae_delta_ne (repr t/ℓ)] with s hs hαs hts + have hst : repr t ≠ ℓ*delta (repr s) := by + intro h + apply hts + apply (eq_div_iff hℓ.ne').mpr + linarith only [h] + have hcmap : ContinuousAt (fun z : CircleX × CircleX => (repr z.1,repr z.2)) (s,t) := + ((continuousAt_repr hs).comp (f:=Prod.fst) (x:=(s,t)) continuousAt_fst).prodMk + ((continuousAt_repr ht).comp (f:=Prod.snd) (x:=(s,t)) continuousAt_snd) + exact (continuousAt_weight hℓ hα hαs.symm (repr_pos ht) hst).comp (f:=fun z : CircleX × CircleX => (repr z.1,repr z.2)) (x:=(s,t)) hcmap + +lemma ae_continuousAt_uNeg {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + {t : CircleX} (ht : t ≠ 0) : + ∀ᵐ s : CircleX, ContinuousAt (Function.uncurry (uNeg ℓ α)) (s,t) := by + have h := (measurePreserving_sub_right volume t).quasiMeasurePreserving.ae (ae_continuousAt_uPos hℓ hα ht) + filter_upwards [h] with s hs + exact hs.comp (f:=fun z : CircleX × CircleX => (z.1-z.2,z.2)) (x:=(s,t)) + ((continuousAt_fst.sub continuousAt_snd).prodMk continuousAt_snd) +end + +section +open ContinuousCircleWeight ContinuousCircleWeight.Sampling Filter +open scoped Topology +variable {ι : Type uι} {κ : Type uκ} [Fintype ι] [Fintype κ] [Nonempty κ] +lemma ae_continuousAt_orientedWeight (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + {t : CircleX} (ht : t ≠ 0) : + ∀ᵐ s : CircleX, ContinuousAt (Function.uncurry (orientedWeight positive ℓ α)) (s,t) := by + cases positive + · exact ae_continuousAt_uNeg hℓ hα ht + · exact ae_continuousAt_uPos hℓ hα ht + +omit [Nonempty κ] in +lemma ae_continuousAt_idealAverage (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (γ : ι → ℝ) (hγ : ∀ n i, ((c n*γ i:ℝ):CircleX) ≠ 0) : + ∀ᵐ s : ι → CircleX ∂Measure.pi (fun _ => volume), + ContinuousAt (fun z : (ι → CircleX) × (ι → ℝ) => idealAverage positive ℓ α c z.1 z.2) (s,γ) := by + have hh : ∀ᵐ s : ι → CircleX ∂Measure.pi (fun _ => volume), ∀ n i, + ContinuousAt (Function.uncurry (orientedWeight positive ℓ α)) (s i,((c n*γ i:ℝ):CircleX)) := by + apply ae_all_iff.mpr + intro n + apply ae_all_iff.mpr + intro i + exact (measurePreserving_eval (fun _ : ι => (volume : Measure CircleX)) i).quasiMeasurePreserving.ae + (ae_continuousAt_orientedWeight positive hℓ hα (hγ n i)) + filter_upwards [hh] with s hs + unfold idealAverage + apply ContinuousAt.const_mul + apply tendsto_finsetSum + intro n _ + apply tendsto_finsetProd + intro i _ + have hm : Continuous (fun z : (ι → CircleX) × (ι → ℝ) => (z.1 i,((c n*z.2 i:ℝ):CircleX))) := by fun_prop + exact (hs n i).comp (f:=fun z : (ι → CircleX) × (ι → ℝ) => (z.1 i,((c n*z.2 i:ℝ):CircleX))) (x:=(s,γ)) hm.continuousAt + +lemma squared_ideal_test_bound (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (s : ι → CircleX) (γ : ι → ℝ) : + ‖Complex.ofReal ((idealAverage positive ℓ α c s γ-1)^2)‖ ≤ ((1/(ℓ*α))^(Fintype.card ι)+1)^2 := by + rw [Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _),← sq_abs (idealAverage positive ℓ α c s γ-1)] + apply (sq_le_sq₀ (abs_nonneg _) (by positivity)).mpr + rw [abs_le] + have h := idealAverage_bounds positive hℓ hα c s γ + constructor <;> linarith [pow_nonneg (by positivity : 0 ≤ 1/(ℓ*α)) (Fintype.card ι)] + +lemma ideal_sampling_tendsto {P : Type uP} [MetricSpace P] [CompactSpace P] + [MeasurableSpace P] [BorelSpace P] {r : ℕ} + (q : ℕ → ℕ → ℤ) (hq : ∀ n i, i < r → 0 < q n i) + (hsep : ∀ i, i+1 < r → Tendsto (fun n => (q n (i+1):ℝ)/q n i) atTop atTop) + {bs : ℕ → P} {b : P} (hb : Tendsto bs atTop (𝓝 b)) + (β : P → Fin r → ℝ) (hβ : Continuous β) + (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (hphase : ∀ n i, ((c n*β b i:ℝ):CircleX) ≠ 0) : + Tendsto (fun n => ∫ x : CircleX, + (idealAverage positive ℓ α c (characterCurve (fun i : Fin r => q n i) x) (β (bs n))-1)^2) + atTop (𝓝 (idealEnergy positive ℓ α c (β b))) := by + have hvol : (AddCircle.haarAddCircle : Measure CircleX) = volume := by + simpa using (AddCircle.volume_eq_smul_haarAddCircle (T:=(1:ℝ))).symm + have htorus : (torusHaar (ι:=Fin r) : Measure (Fin r → CircleX)) = Measure.pi (fun _ => volume) := by + change Measure.pi (fun _ => AddCircle.haarAddCircle) = _ + simp_rw [hvol] + let Φ := fun z : (Fin r → CircleX) × P => Complex.ofReal ((idealAverage positive ℓ α c z.1 (β z.2)-1)^2) + have hΦ : Measurable Φ := by + exact Complex.measurable_ofReal.comp + (((measurable_idealAverage positive ℓ α c).comp + (measurable_fst.prodMk (hβ.measurable.comp measurable_snd))).sub measurable_const |>.pow_const 2) + have hc : ∀ᵐ z ∂(withParameter (torusHaar (ι:=Fin r)) b : Measure _), ContinuousAt Φ z := by + rw [withParameter,ProbabilityMeasure.toMeasure_map] + apply ae_map_iff (measurable_id.prodMk measurable_const).aemeasurable (measurableSet_of_continuousAt Φ) |>.mpr + rw [htorus] + change ∀ᵐ s ∂Measure.pi (fun _ : Fin r => (volume : Measure CircleX)), ContinuousAt Φ (s,b) + filter_upwards [ae_continuousAt_idealAverage positive hℓ hα c (β b) hphase] with s hs + have hm := hs.comp (f:=fun z : (Fin r → CircleX) × P => (z.1,β z.2)) (x:=(s,b)) + (continuous_fst.prodMk (hβ.comp continuous_snd)).continuousAt + exact Complex.continuous_ofReal.continuousAt.comp ((hm.sub continuousAt_const).pow 2) + have ht := circle_approximation_with_parameters q hq hsep hb Φ hΦ hc + (((1/(ℓ*α))^r+1)^2) (fun z => by simpa only [Φ,Fintype.card_fin] using squared_ideal_test_bound positive hℓ hα c z.1 (β z.2)) + have ht' := Complex.continuous_re.continuousAt.tendsto.comp ht + simpa only [Function.comp_def,Φ,integral_complex_ofReal,Complex.ofReal_re,idealEnergy,htorus,hvol] using ht' +end + +open Filter +open scoped Topology +section +lemma finite_accuracy_of_sequential {P : Type uP} [MetricSpace P] + {r : ℕ} (b : P) (T : (ℕ → ℤ) → P → ℝ) {L η : ℝ} (hL : L < η) + (hseq : ∀ (q : ℕ → ℕ → ℤ), (∀ n i, i < r → 0 < q n i) → + (∀ i, i+1 < r → Tendsto (fun n => (q n (i+1):ℝ)/q n i) atTop atTop) → + ∀ (bs : ℕ → P), Tendsto bs atTop (𝓝 b) → + Tendsto (fun n => T (q n) (bs n)) atTop (𝓝 L)) : + ∃ M : ℕ, ∃ δ : ℝ, 0 < δ ∧ ∀ (q : ℕ → ℤ) (β : P), + (∀ i, i < r → 0 < q i) → + (∀ i, i+1 < r → (M:ℝ) ≤ (q (i+1):ℝ)/q i) → + dist β b < δ → T q β < η := by + classical + by_contra! h + have hex (n : ℕ) : ∃ (q : ℕ → ℤ) (β : P), + (∀ i, i < r → 0 < q i) ∧ + (∀ i, i+1 < r → (n:ℝ) ≤ (q (i+1):ℝ)/q i) ∧ + dist β b < 1/((n:ℝ)+1) ∧ η ≤ T q β := by + exact h n (1/((n:ℝ)+1)) (by positivity) + choose q bs hq hsep hdist hbad using hex + have hq' : ∀ i, i+1 < r → Tendsto (fun n => (q n (i+1):ℝ)/q n i) atTop atTop := by + intro i hi + exact tendsto_atTop_mono (fun n => hsep n i hi) tendsto_natCast_atTop_atTop + have hb : Tendsto bs atTop (𝓝 b) := by + apply tendsto_iff_dist_tendsto_zero.mpr + apply squeeze_zero (fun _ => dist_nonneg) (fun n => (hdist n).le) + simpa only [one_div,Function.comp_def] using tendsto_inv_atTop_zero.comp + (tendsto_atTop_add_const_right atTop 1 tendsto_natCast_atTop_atTop) + have hh := (hseq q hq hq' bs hb).eventually (gt_mem_nhds hL) + obtain ⟨n,hn⟩ := hh.exists + exact (not_lt_of_ge (hbad n)) hn + +open ContinuousCircleWeight.Sampling +open scoped Topology +abbrev PhaseCube (r : ℕ) := Fin r → Set.Icc (0:ℝ) 1 +lemma sampling_finite_accuracy {r : ℕ} {κ : Type uκ} [Fintype κ] [Nonempty κ] + (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (γ : PhaseCube r) + (hphase : ∀ n i, ((c n*(γ i:ℝ):ℝ):CircleX) ≠ 0) + {η : ℝ} (hη : idealEnergy positive ℓ α c (fun i => (γ i:ℝ)) < η) : + ∃ M : ℕ, ∃ δ : ℝ, 0 < δ ∧ ∀ (q : ℕ → ℤ) (β : PhaseCube r), + (∀ i, i < r → 0 < q i) → + (∀ i, i+1 < r → (M:ℝ) ≤ (q (i+1):ℝ)/q i) → + dist β γ < δ → + (∫ x : CircleX, (idealAverage positive ℓ α c (characterCurve (fun i : Fin r => q i) x) + (fun i => (β i:ℝ))-1)^2) < η := by + apply finite_accuracy_of_sequential γ _ hη + intro q hq hsep bs hb + exact ideal_sampling_tendsto q hq hsep hb (fun β : PhaseCube r => fun i => (β i:ℝ)) + (by fun_prop) positive hℓ hα c hphase +end + +open Set Filter +open scoped Topology +section +lemma closed_interval_in_open {O : Set ℝ} (hO : IsOpen O) (hne : O.Nonempty) : + ∃ a b : ℝ, a < b ∧ Icc a b ⊆ O := by + obtain ⟨x,hx⟩ := hne + obtain ⟨a,b,⟨ha,hb⟩,hab⟩ := mem_nhds_iff_exists_Ioo_subset.mp (hO.mem_nhds hx) + refine ⟨(a+x)/2,(x+b)/2,by linarith,?_⟩ + intro y hy + apply hab + exact ⟨by linarith [hy.1],by linarith [hy.2]⟩ + +lemma fractional_interval {a b u v q : ℝ} (_hab : a < b) (hq : 0 < q) + (hlong : 2 < q*(b-a)) (hu : 0 ≤ u) (hv : v ≤ 1) (huv : u < v) : + ∃ c d : ℝ, c < d ∧ Icc c d ⊆ Ioo a b ∧ + ∀ x∈Icc c d, Int.fract (q*x) ∈ Ioo u v := by + let t := (u+v)/2 + have ht : t∈Ioo u v := ⟨by dsimp [t]; linarith,by dsimp [t]; linarith⟩ + have ht0 : 0 < t := lt_of_le_of_lt hu ht.1 + have ht1 : t < 1 := lt_of_lt_of_le ht.2 hv + let x := ((⌊q*a⌋:ℝ)+1+t)/q + have hqx : q*x = (⌊q*a⌋:ℝ)+1+t := by dsimp [x]; field_simp + have hxa : a < x := by + apply (lt_div_iff₀ hq).mpr + have h := Int.lt_floor_add_one (q*a) + nlinarith + have hxb : x < b := by + apply (div_lt_iff₀ hq).mpr + have h := Int.floor_le (q*a) + nlinarith + have hfract : Int.fract (q*x)=t := by + rw [hqx,add_comm _ t,← Int.cast_one,← Int.cast_add,Int.fract_add_intCast] + exact Int.fract_eq_self.mpr ⟨ht0.le,ht1⟩ + have hne : q*x ≠ (⌊q*x⌋:ℝ) := by + intro he + have hz : Int.fract (q*x)=0 := by rw [he,Int.fract_intCast] + linarith + have hc : ContinuousAt (fun z : ℝ => Int.fract (q*z)) x := + (continuousAt_fract hne).comp (by fun_prop) + have hU : Ioo a b ∩ (fun z : ℝ => Int.fract (q*z)) ⁻¹' Ioo u v ∈ 𝓝 x := + inter_mem (Ioo_mem_nhds hxa hxb) (hc.preimage_mem_nhds (by rw [hfract]; exact Ioo_mem_nhds ht.1 ht.2)) + obtain ⟨c,d,⟨hc,hd⟩,hsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hU + refine ⟨(c+x)/2,(x+d)/2,by linarith,?_,?_⟩ + · intro z hz + exact (hsub ⟨by linarith [hz.1],by linarith [hz.2]⟩).1 + · intro z hz + exact (hsub ⟨by linarith [hz.1],by linarith [hz.2]⟩).2 + +lemma divisible_frequency_interval {a b u v : ℝ} (hab : a < b) + (hu : 0 ≤ u) (hv : v ≤ 1) (huv : u < v) {p : ℕ} (hp : 0 < p) (M : ℝ) : + ∃ q : ℕ, 0 < q ∧ p ∣ q ∧ M < (q:ℝ)/p ∧ + ∃ c d : ℝ, c < d ∧ Icc c d ⊆ Ioo a b ∧ + ∀ x∈Icc c d, Int.fract ((q:ℝ)*x)∈Ioo u v := by + obtain ⟨L,hL⟩ := exists_nat_gt (max (max M 1) (2/((p:ℝ)*(b-a)))) + have hpR : 0 < (p:ℝ) := Nat.cast_pos.mpr hp + have hL1 : 1 < (L:ℝ) := lt_of_le_of_lt (le_trans (le_max_right M 1) (le_max_left _ _)) hL + have hL0 : 0 < L := by exact_mod_cast (lt_trans (by norm_num : (0:ℝ)<1) hL1) + have hM : M < (L:ℝ) := lt_of_le_of_lt (le_trans (le_max_left M 1) (le_max_left _ _)) hL + have hlong : 2 < (p*L:ℕ)* (b-a) := by + have h := lt_of_le_of_lt (le_max_right (max M 1) (2/((p:ℝ)*(b-a)))) hL + have hh := (div_lt_iff₀ (mul_pos hpR (sub_pos.mpr hab))).mp h + push_cast + nlinarith + obtain ⟨c,d,hcd,hsub,hfr⟩ := fractional_interval hab + (show 0 < ((p*L:ℕ):ℝ) by positivity) hlong hu hv huv + refine ⟨p*L,Nat.mul_pos hp hL0, dvd_mul_right p L,?_,c,d,hcd,hsub,hfr⟩ + simpa only [Nat.cast_mul,mul_div_cancel_left₀ _ hpR.ne'] using hM + +lemma finite_frequency_realization (m : ℕ) (u v : ℕ → ℝ) + (hu : ∀ i < m, 0 ≤ u i) (hv : ∀ i < m, v i ≤ 1) (huv : ∀ i < m, u i < v i) + {a b : ℝ} (hab : a < b) {p : ℕ} (hp : 0 < p) (M : ℝ) : + ∃ q : ℕ → ℕ, q 0=p ∧ (∀ i ≤ m, 0 < q i) ∧ + (∀ i < m, q i ∣ q (i+1) ∧ M < (q (i+1):ℝ)/q i) ∧ + ∃ c d : ℝ, c < d ∧ Icc c d ⊆ Ioo a b ∧ + ∀ i < m, ∀ x∈Icc c d, Int.fract ((q (i+1):ℝ)*x)∈Ioo (u i) (v i) := by + induction m with + | zero => + refine ⟨fun _ => p,rfl,fun _ _ => hp,by simp, (2*a+b)/3,(a+2*b)/3,by linarith,?_,by simp⟩ + intro x hx + exact ⟨by linarith [hx.1],by linarith [hx.2]⟩ + | succ m ih => + obtain ⟨q,hq0,hqp,hqM,c,d,hcd,hsub,hfr⟩ := + ih (fun i hi => hu i (by omega)) (fun i hi => hv i (by omega)) (fun i hi => huv i (by omega)) + obtain ⟨r,hr,hrdiv,hrM,e,f,hef,hefs,hphase⟩ := + divisible_frequency_interval hcd (hu m (by omega)) (hv m (by omega)) (huv m (by omega)) (hqp m le_rfl) M + refine ⟨Function.update q (m+1) r,?_,?_,?_,e,f,hef,?_,?_⟩ + · simpa using hq0 + · intro i hi + by_cases he : i=m+1 + · subst i; simpa + · rw [Function.update_of_ne he] + exact hqp i (by omega) + · intro i hi + by_cases he : i=m + · subst i + simpa [Function.update_of_ne (show m ≠ m+1 by omega)] using And.intro hrdiv hrM + · rw [Function.update_of_ne (show i≠m+1 by omega),Function.update_of_ne (show i+1≠m+1 by omega)] + exact hqM i (by omega) + · exact fun x hx => hsub ⟨(hefs hx).1.le,(hefs hx).2.le⟩ + · intro i hi x hx + by_cases he : i=m + · subst i + simpa using hphase x hx + · rw [Function.update_of_ne (show i+1≠m+1 by omega)] + exact hfr i (by omega) x ⟨(hefs hx).1.le,(hefs hx).2.le⟩ + +def fractionalCube (m : ℕ) (q : ℕ → ℕ) (θ : ℝ) : Fin m → Set.Icc (0:ℝ) 1 := + fun i => ⟨Int.fract ((q (i+1):ℝ)*θ),Int.fract_nonneg _,(Int.fract_lt_one _).le⟩ + +lemma realize_phase_neighborhood {m : ℕ} (γ : Fin m → Set.Icc (0:ℝ) 1) + (hγ : ∀ i, (γ i:ℝ)∈Ioo 0 1) {U : Set (Fin m → Set.Icc (0:ℝ) 1)} (hU : U∈𝓝 γ) + {a b : ℝ} (hab : a < b) {p : ℕ} (hp : 0 < p) (M : ℝ) : + ∃ q : ℕ → ℕ, q 0=p ∧ (∀ i ≤ m, 0 < q i) ∧ + (∀ i < m, q i ∣ q (i+1) ∧ M < (q (i+1):ℝ)/q i) ∧ + ∃ c d : ℝ, c < d ∧ Icc c d ⊆ Ioo a b ∧ + ∀ θ∈Icc c d, fractionalCube m q θ ∈ U := by + obtain ⟨δ,hδ,hdU⟩ := Metric.mem_nhds_iff.mp hU + let g : ℕ → ℝ := fun i => if hi : i < m then (γ ⟨i,hi⟩:ℝ) else 1/2 + let u : ℕ → ℝ := fun i => max 0 (g i-δ/2) + let v : ℕ → ℝ := fun i => min 1 (g i+δ/2) + have hg (i : ℕ) (hi : i < m) : g i∈Ioo 0 1 := by simpa [g,hi] using hγ ⟨i,hi⟩ + have huv (i : ℕ) (hi : i < m) : u i < v i := by + dsimp [u,v] + rw [max_lt_iff,lt_min_iff,lt_min_iff] + constructor <;> constructor <;> linarith [(hg i hi).1,(hg i hi).2] + obtain ⟨q,hq0,hqp,hqM,c,d,hcd,hsub,hfr⟩ := finite_frequency_realization m u v + (fun i _ => le_max_left _ _) (fun i _ => min_le_left _ _) huv hab hp M + refine ⟨q,hq0,hqp,hqM,c,d,hcd,hsub,?_⟩ + intro θ hθ + apply hdU + rw [Metric.mem_ball,dist_pi_lt_iff hδ] + intro i + rw [Subtype.dist_eq,Real.dist_eq,abs_lt] + have h := hfr i i.isLt θ hθ + have hl := lt_of_le_of_lt (le_max_right 0 (g i-δ/2)) h.1 + have hh := lt_of_lt_of_le h.2 (min_le_right 1 (g i+δ/2)) + simp only [g,i.isLt,↓reduceDIte,Fin.eta] at hl hh + change -δ < Int.fract ((q (i+1):ℝ)*θ)-(γ i:ℝ) ∧ Int.fract ((q (i+1):ℝ)*θ)-(γ i:ℝ) < δ + constructor <;> linarith +end + +open ContinuousCircleWeight.Sampling +open scoped Topology +lemma realize_finite_sampling {m : ℕ} {τ : Type uτ} [Fintype τ] + {κ : τ → Type uκ} [∀ t, Fintype (κ t)] [∀ t, Nonempty (κ t)] + (positive : τ → Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : ∀ t, κ t → ℝ) (γ : PhaseCube m) + (hγ : ∀ i, (γ i:ℝ)∈Set.Ioo 0 1) + (hphase : ∀ t n i, ((c t n*(γ i:ℝ):ℝ):CircleX) ≠ 0) + {η : ℝ} (hE : ∀ t, idealEnergy (positive t) ℓ α (c t) (fun i => (γ i:ℝ)) < η) + {U : Set (PhaseCube m)} (hU : U∈𝓝 γ) + {a b : ℝ} (hab : a < b) {p : ℕ} (hp : 0 < p) (M : ℝ) : + ∃ q : ℕ → ℕ, q 0=p ∧ (∀ i ≤ m, 0 < q i) ∧ + (∀ i < m, q i ∣ q (i+1) ∧ M < (q (i+1):ℝ)/q i) ∧ + ∃ d e : ℝ, d < e ∧ Set.Icc d e ⊆ Set.Ioo a b ∧ + ∀ θ∈Set.Icc d e, fractionalCube m q θ∈U ∧ + ∀ t, (∫ x : CircleX, (idealAverage (positive t) ℓ α (c t) + (characterCurve (fun i : Fin m => (q (i+1):ℤ)) x) + (fun i => Int.fract ((q (i+1):ℝ)*θ))-1)^2) < η := by + classical + choose Mt δ hδ hacc using fun t => sampling_finite_accuracy (positive t) hℓ hα (c t) γ (hphase t) (hE t) + let K := Finset.univ.sup Mt + have hK (t : τ) : Mt t ≤ K := Finset.le_sup (f:=Mt) (Finset.mem_univ t) + have hboth : (U∩{β : PhaseCube m | ∀ t, dist β γ < δ t})∈𝓝 γ := by + apply Filter.inter_mem hU + exact Filter.eventually_all.mpr (fun t => Metric.ball_mem_nhds γ (hδ t)) + obtain ⟨q,hq0,hqp,hqM,d,e,hde,hsub,hβ⟩ := realize_phase_neighborhood γ hγ hboth hab hp (max M (K:ℝ)) + refine ⟨q,hq0,hqp,?_,d,e,hde,hsub,?_⟩ + · intro i hi + exact ⟨(hqM i hi).1,lt_of_le_of_lt (le_max_left _ _) (hqM i hi).2⟩ + · intro θ hθ + refine ⟨(hβ θ hθ).1,?_⟩ + intro t + apply hacc t (fun i => (q (i+1):ℤ)) (fractionalCube m q θ) + · intro i hi + exact_mod_cast hqp (i+1) (by omega) + · intro i hi + push_cast + calc + (Mt t:ℝ) ≤ K := Nat.cast_le.mpr (hK t) + _ ≤ max M (K:ℝ) := le_max_right _ _ + _ ≤ (q (i+1+1):ℝ)/q (i+1) := (hqM (i+1) (by omega)).2.le + · exact (hβ θ hθ).2 t + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/FourierSampling.lean b/lean/OAI/Analysis/RotationWeights/FourierSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..46debc3357587820736b644b748521cf326c4c45 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/FourierSampling.lean @@ -0,0 +1,815 @@ +import OAI.Analysis.RotationWeights.WeakSampling + +namespace OAI + +noncomputable section + +universe uι uκ uE + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace + +namespace ContinuousCircleWeight +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +namespace Sampling + +def geometricFourierSum (H : ℕ) : C(CircleX, ℂ) := ∑ p ∈ Finset.range H, fourier (p : ℤ) + +def fejerKernel (H : ℕ) : C(CircleX, ℝ) := + ⟨fun x => ‖geometricFourierSum H x‖ ^ 2 / H, by fun_prop⟩ + +@[simp] lemma geometricFourierSum_apply (H : ℕ) (x : CircleX) : + geometricFourierSum H x = ∑ p ∈ Finset.range H, fourier (p : ℤ) x := by + simp [geometricFourierSum] + +@[simp] lemma fejerKernel_apply (H : ℕ) (x : CircleX) : + fejerKernel H x = ‖geometricFourierSum H x‖ ^ 2 / H := by + rfl + +lemma fejerKernel_nonneg (H : ℕ) (x : CircleX) : 0 ≤ fejerKernel H x := by + rw [fejerKernel_apply]; positivity + +lemma integral_fourier_exact (n : ℤ) : + (∫ x : CircleX, fourier n x ∂AddCircle.haarAddCircle) = if n = 0 then 1 else 0 := by + have h := congrFun (fourierCoeff_fourier (T := (1 : ℝ)) n) 0 + simpa [fourierCoeff, Pi.single_apply, eq_comm] using h + +lemma fejerKernel_complex_expansion (H : ℕ) (x : CircleX) : + (fejerKernel H x : ℂ) = (H : ℂ)⁻¹ * + ∑ p ∈ Finset.range H, ∑ q ∈ Finset.range H, fourier ((p : ℤ) - q) x := by + rw [fejerKernel_apply, Complex.ofReal_div, Complex.ofReal_pow, + ← Complex.mul_conj', geometricFourierSum_apply] + simp only [map_sum] + rw [Finset.sum_mul_sum] + simp_rw [← fourier_neg, ← fourier_add, ← sub_eq_add_neg] + simp only [Complex.ofReal_natCast, div_eq_mul_inv, mul_comm] + +lemma integral_fejerKernel {H : ℕ} (hH : 0 < H) : + (∫ x : CircleX, fejerKernel H x ∂AddCircle.haarAddCircle) = 1 := by + apply Complex.ofReal_injective + rw [← integral_complex_ofReal] + simp_rw [fejerKernel_complex_expansion] + have hi (n : ℤ) : Integrable (fun x : CircleX => fourier n x) AddCircle.haarAddCircle := + Integrable.of_bound (fourier _).continuous.aestronglyMeasurable 1 + (ae_of_all _ (fun x => by simp [fourier_apply, Circle.norm_coe])) + have hs (p : ℕ) : Integrable (fun x : CircleX => ∑ q ∈ Finset.range H, + fourier ((p : ℤ) - q) x) AddCircle.haarAddCircle := + integrable_finsetSum _ (fun _ _ => hi _) + rw [integral_const_mul, integral_finsetSum _ (fun _ _ => hs _)] + simp_rw [integral_finsetSum _ (fun _ _ => hi _), integral_fourier_exact] + simp only [sub_eq_zero, Int.natCast_inj] + simp + rw [Finset.filter_eq_self.mpr (fun a ha => Finset.mem_range.mp ha)] + simp [hH.ne'] + +lemma fourier_nat_eq_pow (p : ℕ) (x : CircleX) : + fourier (p : ℤ) x = fourier 1 x ^ p := by + induction p with + | zero => simp + | succ p ih => rw [Nat.cast_add, Nat.cast_one, fourier_add, ih, pow_succ] + +lemma geometricFourierSum_mul (H : ℕ) (x : CircleX) : + geometricFourierSum H x * (fourier 1 x - 1) = fourier (H : ℤ) x - 1 := by + simp_rw [geometricFourierSum_apply, fourier_nat_eq_pow] + exact geom_sum_mul _ _ + +lemma fejerKernel_mul_chord_sq_le (H : ℕ) (x : CircleX) : + fejerKernel H x * ‖fourier 1 x - 1‖ ^ 2 ≤ 4 / H := by + have h := congrArg norm (geometricFourierSum_mul H x) + rw [norm_mul] at h + have hn : ‖fourier (H : ℤ) x - 1‖ ≤ 2 := by + simpa only [fourier_apply, Circle.norm_coe, norm_one, one_add_one_eq_two] using norm_sub_le (fourier (H : ℤ) x) (1 : ℂ) + rw [fejerKernel_apply] + have hs : ‖geometricFourierSum H x‖ ^ 2 * ‖fourier 1 x - 1‖ ^ 2 ≤ 4 := by + rw [← mul_pow, h] + nlinarith [norm_nonneg (fourier (H : ℤ) x - 1)] + simpa only [div_mul_eq_mul_div] using div_le_div_of_nonneg_right hs (Nat.cast_nonneg H : (0 : ℝ) ≤ H) + +lemma fourier_one_chord_lower (x : CircleX) : + 4 * ‖x‖ ≤ ‖fourier 1 x - 1‖ := by + let y : ℝ := (AddCircle.equivIco (1 : ℝ) (-(1 / 2 : ℝ)) x).val + have hy : |y| ≤ 1 / 2 := by + have he := (AddCircle.equivIco (1 : ℝ) (-(1 / 2 : ℝ)) x).property + change -(1 / 2 : ℝ) ≤ y ∧ y < -(1 / 2 : ℝ) + 1 at he + rw [abs_le]; constructor <;> linarith [he.1, he.2] + have hc : (y : CircleX) = x := AddCircle.coe_equivIco + have hn : ‖(y : CircleX)‖ = |y| := + (AddCircle.norm_coe_eq_abs_iff (1 : ℝ) (by norm_num)).mpr (by simpa using hy) + rw [← hc, hn, fourier_coe_apply] + have he : (2 * Real.pi * Complex.I * (1 : ℤ) * y / (1 : ℝ) : ℂ) = + Complex.I * (2 * Real.pi * y : ℝ) := by push_cast; ring + rw [he, Complex.norm_exp_I_mul_ofReal_sub_one] + have hyπ : 0 ≤ Real.pi * |y| := mul_nonneg Real.pi_pos.le (abs_nonneg y) + have hle : Real.pi * |y| ≤ Real.pi / 2 := by nlinarith [Real.pi_pos] + have hs := Real.mul_le_sin hyπ hle + have hs' : 2 * |y| ≤ Real.sin (Real.pi * |y|) := by + convert hs using 1; field_simp + have ha : |Real.pi * y| ≤ Real.pi := by + rw [abs_mul, abs_of_pos Real.pi_pos] + nlinarith [Real.pi_pos] + have he' : 2 * Real.pi * y / 2 = Real.pi * y := by ring + rw [he', Real.norm_eq_abs, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2), + Real.abs_sin_eq_sin_abs_of_abs_le_pi ha, abs_mul, abs_of_pos Real.pi_pos] + linarith + +lemma fejerKernel_le_of_norm_ge {H : ℕ} (hH : 0 < H) + {δ : ℝ} (hδ : 0 < δ) {x : CircleX} (hx : δ ≤ ‖x‖) : + fejerKernel H x ≤ 1 / (4 * H * δ ^ 2) := by + have hc := fourier_one_chord_lower x + have hk := fejerKernel_mul_chord_sq_le H x + have hn := fejerKernel_nonneg H x + have hH' : (0 : ℝ) < H := Nat.cast_pos.mpr hH + have hs : 16 * δ ^ 2 ≤ ‖fourier 1 x - 1‖ ^ 2 := by + nlinarith [norm_nonneg x, norm_nonneg (fourier 1 x - 1)] + have hprod : fejerKernel H x * (16 * δ ^ 2) ≤ 4 / H := + (mul_le_mul_of_nonneg_left hs hn).trans hk + apply (le_div_iff₀ (by positivity : 0 < 4 * (H : ℝ) * δ ^ 2)).mpr + have hm := (le_div_iff₀ hH').mp hprod + nlinarith + +lemma fourier_eval_sub (n : ℤ) (x t : CircleX) : + fourier n (x - t) = fourier n x * fourier (-n) t := by + simp only [fourier_apply, sub_eq_add_neg, zsmul_add, zsmul_neg, neg_zsmul, + AddCircle.toCircle_add, Circle.coe_mul] + +lemma fejerKernel_le (H : ℕ) (x : CircleX) : fejerKernel H x ≤ H := by + have hs : ‖geometricFourierSum H x‖ ≤ H := by + rw [geometricFourierSum_apply] + calc + _ ≤ ∑ p ∈ Finset.range H, ‖fourier (p : ℤ) x‖ := norm_sum_le _ _ + _ = H := by simp [fourier_apply, Circle.norm_coe] + by_cases hH : H = 0 + · simp [hH] + · rw [fejerKernel_apply, div_le_iff₀ (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hH))] + nlinarith [norm_nonneg (geometricFourierSum H x)] + +lemma integrable_fejer_mul (H : ℕ) {f : CircleX → ℝ} + (hf : Integrable f AddCircle.haarAddCircle) (x : CircleX) : + Integrable (fun t => fejerKernel H (x - t) * f t) AddCircle.haarAddCircle := by + apply hf.bdd_mul (c := (H : ℝ)) (by fun_prop : Continuous (fun t : CircleX => fejerKernel H (x - t))).aestronglyMeasurable + exact ae_of_all _ (fun t => by + simpa only [Real.norm_eq_abs, abs_of_nonneg (fejerKernel_nonneg H _)] using + fejerKernel_le H (x - t)) + +def fejerApprox (H : ℕ) (f : CircleX → ℝ) (x : CircleX) : ℝ := + ∫ t, fejerKernel H (x - t) * f t ∂AddCircle.haarAddCircle + +lemma fejerApprox_complex_expansion (H : ℕ) {f : CircleX → ℝ} + (hf : Integrable f AddCircle.haarAddCircle) (x : CircleX) : + (fejerApprox H f x : ℂ) = (H : ℂ)⁻¹ * + ∑ p ∈ Finset.range H, ∑ q ∈ Finset.range H, + fourier ((p : ℤ) - q) x * fourierCoeff (fun t => (f t : ℂ)) ((p : ℤ) - q) := by + have hf' : Integrable (fun t => (f t : ℂ)) AddCircle.haarAddCircle := hf.ofReal + have hi (n : ℤ) : Integrable (fun t => fourier n (x - t) * (f t : ℂ)) + AddCircle.haarAddCircle := by + apply hf'.bdd_mul (c := 1) (by fun_prop : Continuous (fun t : CircleX => fourier n (x - t))).aestronglyMeasurable + exact ae_of_all _ (fun t => by simp [fourier_apply, Circle.norm_coe]) + have he (n : ℤ) : (∫ t, fourier n (x - t) * (f t : ℂ) ∂AddCircle.haarAddCircle) = + fourier n x * fourierCoeff (fun t => (f t : ℂ)) n := by + simp_rw [fourier_eval_sub, mul_assoc] + rw [integral_const_mul] + rfl + rw [fejerApprox, ← integral_complex_ofReal] + simp_rw [Complex.ofReal_mul, fejerKernel_complex_expansion, + mul_assoc, Finset.sum_mul] + rw [integral_const_mul, integral_finsetSum (Finset.range H) (fun p _ => + integrable_finsetSum (Finset.range H) (fun q _ => hi ((p : ℤ) - q)))] + simp_rw [integral_finsetSum (Finset.range H) (fun q _ => hi _), he] + +lemma fejerApprox_nonneg (H : ℕ) {f : CircleX → ℝ} (hf : ∀ t, 0 ≤ f t) + (x : CircleX) : 0 ≤ fejerApprox H f x := by + exact integral_nonneg (fun t => mul_nonneg (fejerKernel_nonneg H _) (hf t)) + +lemma fejerApprox_le_one {H : ℕ} (hH : 0 < H) {f : CircleX → ℝ} + (hf : Integrable f AddCircle.haarAddCircle) (hf1 : ∀ t, f t ≤ 1) (x : CircleX) : + fejerApprox H f x ≤ 1 := by + have hk : Integrable (fun t : CircleX => fejerKernel H t) AddCircle.haarAddCircle := + Integrable.of_bound (fejerKernel H).continuous.aestronglyMeasurable H + (ae_of_all _ (fun t => by + simpa only [Real.norm_eq_abs, abs_of_nonneg (fejerKernel_nonneg H _)] using + fejerKernel_le H t)) + calc + _ ≤ ∫ t : CircleX, fejerKernel H (x - t) ∂AddCircle.haarAddCircle := + integral_mono (integrable_fejer_mul H hf x) (hk.comp_sub_left x) + (fun t => by simpa using mul_le_mul_of_nonneg_left (hf1 t) (fejerKernel_nonneg H _)) + _ = 1 := by rw [integral_sub_left_eq_self, integral_fejerKernel hH] + +lemma fejerApprox_local_error {H : ℕ} (hH : 0 < H) {δ : ℝ} (hδ : 0 < δ) + {f : CircleX → ℝ} (hf : Integrable f AddCircle.haarAddCircle) + (hbound : ∀ t, 0 ≤ f t ∧ f t ≤ 1) (x : CircleX) + (hloc : ∀ t, ‖x - t‖ < δ → f t = f x) : + |fejerApprox H f x - f x| ≤ 1 / (4 * H * δ ^ 2) := by + have hk : Integrable (fun t : CircleX => fejerKernel H t) AddCircle.haarAddCircle := + Integrable.of_bound (fejerKernel H).continuous.aestronglyMeasurable H + (ae_of_all _ (fun t => by + simpa only [Real.norm_eq_abs, abs_of_nonneg (fejerKernel_nonneg H _)] using + fejerKernel_le H t)) + have he : fejerApprox H f x - f x = + ∫ t, fejerKernel H (x - t) * (f t - f x) ∂AddCircle.haarAddCircle := by + simp_rw [mul_sub] + rw [integral_sub (integrable_fejer_mul H hf x) ((hk.comp_sub_left x).mul_const _), + integral_mul_const, integral_sub_left_eq_self, integral_fejerKernel hH, one_mul] + rfl + rw [he, ← Real.norm_eq_abs] + apply (norm_integral_le_integral_norm _).trans + have hb (t : CircleX) : ‖fejerKernel H (x - t) * (f t - f x)‖ ≤ + 1 / (4 * H * δ ^ 2) := by + by_cases ht : ‖x - t‖ < δ + · rw [hloc t ht, sub_self, mul_zero, norm_zero]; positivity + · have hd : |f t - f x| ≤ 1 := by rw [abs_le]; constructor <;> linarith [(hbound t).1, (hbound t).2, (hbound x).1, (hbound x).2] + rw [norm_mul, Real.norm_eq_abs, abs_of_nonneg (fejerKernel_nonneg H _), Real.norm_eq_abs] + exact (mul_le_mul_of_nonneg_left hd (fejerKernel_nonneg H _)).trans + (by simpa using fejerKernel_le_of_norm_ge hH hδ (le_of_not_gt ht)) + calc + _ ≤ ∫ _t : CircleX, 1 / (4 * (H : ℝ) * δ ^ 2) ∂AddCircle.haarAddCircle := + integral_mono ((integrable_fejer_mul H (hf.sub (integrable_const _)) x).norm) + (integrable_const _) hb + _ = _ := by simp + +def doubleFourier (v w : ℤ) (z : CircleX × CircleX) : ℂ := + fourier v z.1 * fourier w z.2 + +lemma doubleFourier_norm (v w : ℤ) (z : CircleX × CircleX) : + ‖doubleFourier v w z‖ = 1 := by + simp [doubleFourier, fourier_apply, Circle.norm_coe] + +lemma integrable_doubleFourier (v w : ℤ) (η : Measure (CircleX × CircleX)) + [IsFiniteMeasure η] : Integrable (doubleFourier v w) η := by + apply Integrable.of_bound (by unfold doubleFourier; fun_prop : Continuous (doubleFourier v w)).aestronglyMeasurable 1 + exact ae_of_all _ (fun z => (doubleFourier_norm v w z).le) + +lemma finite_doubleFourier_error {ι : Type uι} (s : Finset ι) (c : ι → ℂ) + (v w : ι → ℤ) (η : Measure (CircleX × CircleX)) [IsFiniteMeasure η] + (ε : ℝ) (hmom : ∀ i ∈ s, + ‖(∫ z, doubleFourier (v i) (w i) z ∂η) - + (if v i = 0 ∧ w i = 0 then 1 else 0)‖ ≤ ε) : + ‖(∫ z, ∑ i ∈ s, c i * doubleFourier (v i) (w i) z ∂η) - + ∑ i ∈ s, (if v i = 0 ∧ w i = 0 then c i else 0)‖ ≤ + ε * ∑ i ∈ s, ‖c i‖ := by + classical + rw [integral_finsetSum s (fun i _ => (integrable_doubleFourier _ _ η).const_mul _)] + simp_rw [integral_const_mul] + have he : (∑ i ∈ s, c i * ∫ z, doubleFourier (v i) (w i) z ∂η) - + ∑ i ∈ s, (if v i = 0 ∧ w i = 0 then c i else 0) = + ∑ i ∈ s, c i * ((∫ z, doubleFourier (v i) (w i) z ∂η) - + (if v i = 0 ∧ w i = 0 then 1 else 0)) := by + simp_rw [mul_sub, Finset.sum_sub_distrib, mul_ite, mul_one, mul_zero] + rw [he] + calc + _ ≤ ∑ i ∈ s, ‖c i * ((∫ z, doubleFourier (v i) (w i) z ∂η) - + (if v i = 0 ∧ w i = 0 then 1 else 0))‖ := norm_sum_le _ _ + _ ≤ ∑ i ∈ s, ‖c i‖ * ε := Finset.sum_le_sum (fun i hi => by + rw [norm_mul]; exact mul_le_mul_of_nonneg_left (hmom i hi) (norm_nonneg _)) + _ = _ := by rw [← Finset.sum_mul, mul_comm] + +lemma finite_product_fourier_error {ι : Type uι} {κ : Type uκ} (s : Finset ι) (t : Finset κ) + (a : ι → ℂ) (b : κ → ℂ) (v : ι → ℤ) (w : κ → ℤ) + (η : Measure (CircleX × CircleX)) [IsFiniteMeasure η] + (ε : ℝ) (hmom : ∀ i ∈ s, ∀ k ∈ t, + ‖(∫ z, doubleFourier (v i) (w k) z ∂η) - + (if v i = 0 ∧ w k = 0 then 1 else 0)‖ ≤ ε) : + ‖(∫ z, (∑ i ∈ s, a i * fourier (v i) z.1) * + (∑ k ∈ t, b k * fourier (w k) z.2) ∂η) - + (∑ i ∈ s, if v i = 0 then a i else 0) * + (∑ k ∈ t, if w k = 0 then b k else 0)‖ ≤ + ε * (∑ i ∈ s, ‖a i‖) * ∑ k ∈ t, ‖b k‖ := by + classical + have h := finite_doubleFourier_error (s.product t) (fun ik => a ik.1 * b ik.2) + (fun ik => v ik.1) (fun ik => w ik.2) η ε + (fun ik hik => hmom ik.1 (Finset.mem_product.mp hik).1 ik.2 (Finset.mem_product.mp hik).2) + have hi (i : ι) (k : κ) (z : CircleX × CircleX) : + (a i * b k) * doubleFourier (v i) (w k) z = + (a i * fourier (v i) z.1) * (b k * fourier (w k) z.2) := by + unfold doubleFourier; ring + have hz (i : ι) (k : κ) : + (if v i = 0 ∧ w k = 0 then a i * b k else 0) = + (if v i = 0 then a i else 0) * (if w k = 0 then b k else 0) := by + split_ifs <;> simp_all + simp only [hi, hz, norm_mul] at h + simp only [Finset.product_eq_sprod, Finset.sum_product] at h + simp_rw [← Finset.sum_mul_sum] at h + simpa only [mul_assoc] using h + +lemma fourierCoeff_norm_le_one {f : CircleX → ℂ} + (hf : Integrable f AddCircle.haarAddCircle) (hb : ∀ x, ‖f x‖ ≤ 1) (n : ℤ) : + ‖fourierCoeff f n‖ ≤ 1 := by + unfold fourierCoeff + calc + _ ≤ ∫ x, ‖fourier (-n) x • f x‖ ∂AddCircle.haarAddCircle := norm_integral_le_integral_norm _ + _ ≤ ∫ _x : CircleX, (1 : ℝ) ∂AddCircle.haarAddCircle := + integral_mono ((hf.fourier_smul _).norm) (integrable_const _) (fun x => by + simpa only [norm_smul, fourier_apply, Circle.norm_coe, one_mul] using hb x) + _ = 1 := by simp + +def fejerFrequency {H : ℕ} (i : Fin H × Fin H) : ℤ := (i.1 : ℕ) - (i.2 : ℕ) + +def fejerCoefficient (H : ℕ) (f : CircleX → ℝ) (i : Fin H × Fin H) : ℂ := + (H : ℂ)⁻¹ * fourierCoeff (fun t => (f t : ℂ)) (fejerFrequency i) + +lemma fejerApprox_fin_expansion (H : ℕ) {f : CircleX → ℝ} + (hf : Integrable f AddCircle.haarAddCircle) (x : CircleX) : + (fejerApprox H f x : ℂ) = ∑ i : Fin H × Fin H, + fejerCoefficient H f i * fourier (fejerFrequency i) x := by + rw [fejerApprox_complex_expansion H hf] + simp only [Fintype.sum_prod_type, fejerCoefficient, fejerFrequency] + simp_rw [mul_assoc, mul_comm (fourierCoeff _ _) (fourier _ _), ← Finset.mul_sum] + congr 1 + have hs (p : ℕ) : (∑ q : Fin H, fourier ((p : ℤ) - (q : ℕ)) x * + fourierCoeff (fun t => (f t : ℂ)) ((p : ℤ) - (q : ℕ))) = + ∑ q ∈ Finset.range H, fourier ((p : ℤ) - q) x * + fourierCoeff (fun t => (f t : ℂ)) ((p : ℤ) - q) := + Fin.sum_univ_eq_sum_range (fun q : ℕ => fourier ((p : ℤ) - q) x * + fourierCoeff (fun t => (f t : ℂ)) ((p : ℤ) - q)) H + simp_rw [hs] + exact (Fin.sum_univ_eq_sum_range (fun p : ℕ => ∑ q ∈ Finset.range H, + fourier ((p : ℤ) - q) x * fourierCoeff (fun t => (f t : ℂ)) ((p : ℤ) - q)) H).symm + +lemma fejerCoefficient_zero_sum {H : ℕ} (hH : 0 < H) (f : CircleX → ℝ) : + (∑ i : Fin H × Fin H, if fejerFrequency i = 0 then fejerCoefficient H f i else 0) = + ∫ t, (f t : ℂ) ∂AddCircle.haarAddCircle := by + simp only [Fintype.sum_prod_type, fejerFrequency, fejerCoefficient, sub_eq_zero, + Int.natCast_inj, Fin.val_inj] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true, sub_self, + Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + rw [← mul_assoc, mul_inv_cancel₀ (by exact_mod_cast hH.ne'), one_mul] + simp [fourierCoeff] + +lemma fejerCoefficient_norm_sum_le {H : ℕ} (hH : 0 < H) {f : CircleX → ℝ} + (hf : Integrable f AddCircle.haarAddCircle) (hb : ∀ t, |f t| ≤ 1) : + (∑ i : Fin H × Fin H, ‖fejerCoefficient H f i‖) ≤ H := by + have hf' : Integrable (fun t => (f t : ℂ)) AddCircle.haarAddCircle := hf.ofReal + have hcoef (i : Fin H × Fin H) : ‖fejerCoefficient H f i‖ ≤ (H : ℝ)⁻¹ := by + unfold fejerCoefficient + rw [norm_mul, norm_inv, Complex.norm_natCast] + simpa using mul_le_mul_of_nonneg_left (fourierCoeff_norm_le_one hf' + (fun t => by simpa using hb t) (fejerFrequency i)) (inv_nonneg.mpr (Nat.cast_nonneg H)) + calc + _ ≤ ∑ _i : Fin H × Fin H, (H : ℝ)⁻¹ := Finset.sum_le_sum (fun i _ => hcoef i) + _ = (H : ℝ) := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_prod, + Fintype.card_fin, nsmul_eq_mul, Nat.cast_mul] + rw [mul_assoc, mul_inv_cancel₀ (by exact_mod_cast hH.ne'), mul_one] + +lemma fejerFrequency_abs_lt {H : ℕ} (i : Fin H × Fin H) : |fejerFrequency i| < H := by + have hp := i.1.isLt + have hq := i.2.isLt + rw [fejerFrequency, abs_lt] + constructor <;> omega + +lemma fejer_product_fourier_error {H : ℕ} (hH : 0 < H) + {f g : CircleX → ℝ} (hf : Integrable f AddCircle.haarAddCircle) + (hg : Integrable g AddCircle.haarAddCircle) + (hfb : ∀ x, |f x| ≤ 1) (hgb : ∀ x, |g x| ≤ 1) + (η : Measure (CircleX × CircleX)) [IsProbabilityMeasure η] + {ε : ℝ} (hε : 0 ≤ ε) + (hmom : ∀ v w : ℤ, |v| < H → |w| < H → ¬(v = 0 ∧ w = 0) → + ‖∫ z, doubleFourier v w z ∂η‖ ≤ ε) : + ‖(∫ z, (fejerApprox H f z.1 : ℂ) * (fejerApprox H g z.2 : ℂ) ∂η) - + (∫ t, (f t : ℂ) ∂AddCircle.haarAddCircle) * + (∫ t, (g t : ℂ) ∂AddCircle.haarAddCircle)‖ ≤ H ^ 2 * ε := by + classical + have hm (i k : Fin H × Fin H) : + ‖(∫ z, doubleFourier (fejerFrequency i) (fejerFrequency k) z ∂η) - + (if fejerFrequency i = 0 ∧ fejerFrequency k = 0 then 1 else 0)‖ ≤ ε := by + by_cases hz : fejerFrequency i = 0 ∧ fejerFrequency k = 0 + · simpa [hz.1, hz.2, doubleFourier, fourier_zero, measure_univ] using hε + · simpa [hz] using hmom _ _ (fejerFrequency_abs_lt i) (fejerFrequency_abs_lt k) hz + have h := finite_product_fourier_error Finset.univ Finset.univ + (fejerCoefficient H f) (fejerCoefficient H g) fejerFrequency fejerFrequency η ε + (fun i _ k _ => hm i k) + simp_rw [← fejerApprox_fin_expansion H hf, ← fejerApprox_fin_expansion H hg, + fejerCoefficient_zero_sum hH] at h + refine h.trans ?_ + calc + _ ≤ ε * (H : ℝ) * H := mul_le_mul + (mul_le_mul_of_nonneg_left (fejerCoefficient_norm_sum_le hH hf hfb) hε) + (fejerCoefficient_norm_sum_le hH hg hgb) + (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) (by positivity) + _ = _ := by ring + +lemma continuous_fejerApprox (H : ℕ) {f : CircleX → ℝ} + (hf : Integrable f AddCircle.haarAddCircle) : Continuous (fejerApprox H f) := by + have he : fejerApprox H f = fun x => + (∑ i : Fin H × Fin H, fejerCoefficient H f i * fourier (fejerFrequency i) x).re := by + funext x + rw [← fejerApprox_fin_expansion H hf x] + rfl + rw [he] + exact Complex.continuous_re.comp (continuous_finsetSum _ + (fun i _ => continuous_const.mul (fourier (fejerFrequency i)).continuous)) + +lemma fejer_unsmoothed_error {H : ℕ} (hH : 0 < H) {δ : ℝ} (hδ : 0 < δ) + {f g : CircleX → ℝ} (hf : Measurable f) (hg : Measurable g) + (hfb : ∀ x, 0 ≤ f x ∧ f x ≤ 1) (hgb : ∀ x, 0 ≤ g x ∧ g x ≤ 1) + (Bf Bg : Set CircleX) (hBf : MeasurableSet Bf) (hBg : MeasurableSet Bg) + (hfloc : ∀ x ∉ Bf, ∀ t, ‖x - t‖ < δ → f t = f x) + (hgloc : ∀ x ∉ Bg, ∀ t, ‖x - t‖ < δ → g t = g x) + (η : Measure (CircleX × CircleX)) [IsProbabilityMeasure η] : + |(∫ z, f z.1 * g z.2 ∂η) - + (∫ z, fejerApprox H f z.1 * fejerApprox H g z.2 ∂η)| ≤ + η.real (Prod.fst ⁻¹' Bf) + η.real (Prod.snd ⁻¹' Bg) + 2 / (4 * H * δ ^ 2) := by + have hfi : Integrable f AddCircle.haarAddCircle := + Integrable.of_bound hf.aestronglyMeasurable 1 + (ae_of_all _ (fun x => by simpa [Real.norm_eq_abs, abs_of_nonneg (hfb x).1] using (hfb x).2)) + have hgi : Integrable g AddCircle.haarAddCircle := + Integrable.of_bound hg.aestronglyMeasurable 1 + (ae_of_all _ (fun x => by simpa [Real.norm_eq_abs, abs_of_nonneg (hgb x).1] using (hgb x).2)) + have hF (x : CircleX) : 0 ≤ fejerApprox H f x ∧ fejerApprox H f x ≤ 1 := + ⟨fejerApprox_nonneg H (fun t => (hfb t).1) x, + fejerApprox_le_one hH hfi (fun t => (hfb t).2) x⟩ + have hG (x : CircleX) : 0 ≤ fejerApprox H g x ∧ fejerApprox H g x ≤ 1 := + ⟨fejerApprox_nonneg H (fun t => (hgb t).1) x, + fejerApprox_le_one hH hgi (fun t => (hgb t).2) x⟩ + have hir : Integrable (fun z : CircleX × CircleX => f z.1 * g z.2) η := + Integrable.of_bound ((hf.comp measurable_fst).mul (hg.comp measurable_snd)).aestronglyMeasurable 1 + (ae_of_all _ (fun z => by + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (hfb z.1).1 (hgb z.2).1)] + exact (mul_le_of_le_one_left (hgb z.2).1 (hfb z.1).2).trans (hgb z.2).2)) + have his : Integrable (fun z : CircleX × CircleX => + fejerApprox H f z.1 * fejerApprox H g z.2) η := + Integrable.of_bound (((continuous_fejerApprox H hfi).comp continuous_fst).mul + ((continuous_fejerApprox H hgi).comp continuous_snd)).aestronglyMeasurable 1 + (ae_of_all _ (fun z => by + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (hF z.1).1 (hG z.2).1)] + exact (mul_le_of_le_one_left (hG z.2).1 (hF z.1).2).trans (hG z.2).2)) + have hdefect (u : CircleX → ℝ) (hu : Integrable u AddCircle.haarAddCircle) + (hb : ∀ x, 0 ≤ u x ∧ u x ≤ 1) (B : Set CircleX) + (hloc : ∀ x ∉ B, ∀ t, ‖x-t‖ < δ → u t = u x) (x : CircleX) : + |u x - fejerApprox H u x| ≤ B.indicator (fun _ => (1 : ℝ)) x + + 1 / (4 * H * δ ^ 2) := by + by_cases hx : x ∈ B + · rw [Set.indicator_of_mem hx] + have hnonneg := fejerApprox_nonneg H (fun t => (hb t).1) x + have hone := fejerApprox_le_one hH hu (fun t => (hb t).2) x + have : |u x - fejerApprox H u x| ≤ 1 := by rw [abs_le]; constructor <;> linarith [(hb x).1, (hb x).2] + exact this.trans (le_add_of_nonneg_right (by positivity)) + · rw [Set.indicator_of_notMem hx, zero_add, abs_sub_comm] + exact fejerApprox_local_error hH hδ hu hb x (hloc x hx) + have hpoint (z : CircleX × CircleX) : + |f z.1 * g z.2 - fejerApprox H f z.1 * fejerApprox H g z.2| ≤ + (Prod.fst ⁻¹' Bf).indicator (fun _ => (1 : ℝ)) z + + (Prod.snd ⁻¹' Bg).indicator (fun _ => (1 : ℝ)) z + 2 / (4 * H * δ ^ 2) := by + have he : f z.1 * g z.2 - fejerApprox H f z.1 * fejerApprox H g z.2 = + (f z.1 - fejerApprox H f z.1) * g z.2 + + fejerApprox H f z.1 * (g z.2 - fejerApprox H g z.2) := by ring + have hb := abs_add_le ((f z.1 - fejerApprox H f z.1) * g z.2) + (fejerApprox H f z.1 * (g z.2 - fejerApprox H g z.2)) + rw [← he, abs_mul, abs_mul, abs_of_nonneg (hgb z.2).1, + abs_of_nonneg (hF z.1).1] at hb + have hb1 := mul_le_mul_of_nonneg_left (hgb z.2).2 (abs_nonneg (f z.1 - fejerApprox H f z.1)) + have hb2 := mul_le_mul_of_nonneg_right (hF z.1).2 (abs_nonneg (g z.2 - fejerApprox H g z.2)) + have h1 := hdefect f hfi hfb Bf hfloc z.1 + have h2 := hdefect g hgi hgb Bg hgloc z.2 + change |f z.1 * g z.2 - fejerApprox H f z.1 * fejerApprox H g z.2| ≤ + Bf.indicator (fun _ => (1 : ℝ)) z.1 + Bg.indicator (fun _ => (1 : ℝ)) z.2 + + 2 / (4 * H * δ ^ 2) + have hsum := hb.trans (add_le_add hb1 hb2) + simp only [mul_one, one_mul] at hsum + exact hsum.trans (by convert add_le_add h1 h2 using 1; ring) + have hi1 : Integrable ((Prod.fst ⁻¹' Bf).indicator (fun _ => (1 : ℝ))) η := + (integrable_const _).indicator (hBf.preimage measurable_fst) + have hi2 : Integrable ((Prod.snd ⁻¹' Bg).indicator (fun _ => (1 : ℝ))) η := + (integrable_const _).indicator (hBg.preimage measurable_snd) + rw [← integral_sub hir his] + refine (abs_integral_le_integral_abs).trans ((integral_mono + (hir.sub his).norm ((hi1.add hi2).add (integrable_const _)) hpoint).trans ?_) + rw [integral_add' (hi1.add hi2) (integrable_const _), integral_add' hi1 hi2] + rw [integral_indicator_const 1 (hBf.preimage measurable_fst), + integral_indicator_const 1 (hBg.preimage measurable_snd)] + simp only [Measure.real, integral_const, measure_univ, + ENNReal.toReal_one, smul_eq_mul, mul_one, one_mul, le_refl] + +def arcBoundary (c : CircleX) (r δ : ℝ) : Set CircleX := + Metric.closedBall c (r + δ) \ Metric.ball c (r - δ) + +lemma measurableSet_arcBoundary (c : CircleX) (r δ : ℝ) : + MeasurableSet (arcBoundary c r δ) := + Metric.isClosed_closedBall.measurableSet.diff Metric.isOpen_ball.measurableSet + +lemma haarAddCircle_one_eq_volume : + (AddCircle.haarAddCircle : Measure CircleX) = volume := by + simpa using (AddCircle.volume_eq_smul_haarAddCircle (T := (1 : ℝ))).symm + +lemma arcBoundary_measure_le (c : CircleX) (r : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) : + (AddCircle.haarAddCircle : Measure CircleX).real (arcBoundary c r δ) ≤ 4 * δ := by + rw [haarAddCircle_one_eq_volume, arcBoundary, measureReal_sdiff + (Metric.ball_subset_closedBall.trans (Metric.closedBall_subset_closedBall (by linarith))) + Metric.isOpen_ball.measurableSet] + rw [← measureReal_congr (AddCircle.closedBall_ae_eq_ball (x := c) (ε := r - δ))] + simp only [Measure.real, AddCircle.volume_closedBall, ENNReal.toReal_ofReal'] + simp only [min_def, max_def] + split_ifs <;> linarith + +lemma arc_indicator_locally_constant (c : CircleX) (r : ℝ) {δ : ℝ} (hδ : 0 < δ) + (x : CircleX) (hx : x ∉ arcBoundary c r δ) (t : CircleX) (ht : ‖x - t‖ < δ) : + (Metric.ball c r).indicator (fun _ => (1 : ℝ)) t = + (Metric.ball c r).indicator (fun _ => (1 : ℝ)) x := by + classical + rw [← dist_eq_norm] at ht + have hd := abs_dist_sub_le x t c + rw [abs_le] at hd + by_cases hi : dist x c < r - δ + · have hix : x ∈ Metric.ball c r := by rw [Metric.mem_ball]; linarith + have hit : t ∈ Metric.ball c r := by rw [Metric.mem_ball]; linarith [hd.2] + rw [Set.indicator_of_mem hix, Set.indicator_of_mem hit] + · have ho : r + δ < dist x c := by + simp only [arcBoundary, Set.mem_sdiff, Metric.mem_closedBall, Metric.mem_ball, + not_and, not_lt] at hx + exact lt_of_not_ge (fun h => hi (lt_of_not_ge (hx h))) + have hox : x ∉ Metric.ball c r := by rw [Metric.mem_ball, not_lt]; linarith + have hot : t ∉ Metric.ball c r := by rw [Metric.mem_ball, not_lt]; linarith [hd.2] + rw [Set.indicator_of_notMem hox, Set.indicator_of_notMem hot] + +lemma arc_rectangle_discrepancy {H : ℕ} (hH : 0 < H) {δ : ℝ} (hδ : 0 < δ) + (c d : CircleX) (r s : ℝ) (η : Measure (CircleX × CircleX)) + [IsProbabilityMeasure η] {C ε : ℝ} (hC : 0 ≤ C) (hε : 0 ≤ ε) + (hfst : ∀ B : Set CircleX, MeasurableSet B → + η.real (Prod.fst ⁻¹' B) ≤ C * AddCircle.haarAddCircle.real B) + (hsnd : ∀ B : Set CircleX, MeasurableSet B → + η.real (Prod.snd ⁻¹' B) ≤ C * AddCircle.haarAddCircle.real B) + (hmom : ∀ v w : ℤ, |v| < H → |w| < H → ¬(v = 0 ∧ w = 0) → + ‖∫ z, doubleFourier v w z ∂η‖ ≤ ε) : + |η.real (Metric.ball c r ×ˢ Metric.ball d s) - + AddCircle.haarAddCircle.real (Metric.ball c r) * + AddCircle.haarAddCircle.real (Metric.ball d s)| ≤ + 8 * C * δ + 2 / (4 * H * δ ^ 2) + H ^ 2 * ε := by + classical + let f := (Metric.ball c r).indicator (fun _ => (1 : ℝ)) + let g := (Metric.ball d s).indicator (fun _ => (1 : ℝ)) + have hf : Measurable f := measurable_const.indicator Metric.isOpen_ball.measurableSet + have hg : Measurable g := measurable_const.indicator Metric.isOpen_ball.measurableSet + have hfb (x) : 0 ≤ f x ∧ f x ≤ 1 := by + dsimp [f, Set.indicator]; split_ifs <;> norm_num + have hgb (x) : 0 ≤ g x ∧ g x ≤ 1 := by + dsimp [g, Set.indicator]; split_ifs <;> norm_num + have hfi : Integrable f AddCircle.haarAddCircle := + (integrable_const _).indicator Metric.isOpen_ball.measurableSet + have hgi : Integrable g AddCircle.haarAddCircle := + (integrable_const _).indicator Metric.isOpen_ball.measurableSet + have h1 := fejer_unsmoothed_error hH hδ hf hg hfb hgb + (arcBoundary c r δ) (arcBoundary d s δ) (measurableSet_arcBoundary ..) + (measurableSet_arcBoundary ..) (arc_indicator_locally_constant c r hδ) + (arc_indicator_locally_constant d s hδ) η + have h2 := fejer_product_fourier_error hH hfi hgi + (fun x => by rw [abs_of_nonneg (hfb x).1]; exact (hfb x).2) + (fun x => by rw [abs_of_nonneg (hgb x).1]; exact (hgb x).2) η hε hmom + simp only [← Complex.ofReal_mul, integral_complex_ofReal, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] at h2 + have hm1 := (hfst _ (measurableSet_arcBoundary c r δ)).trans + (mul_le_mul_of_nonneg_left (arcBoundary_measure_le c r hδ.le) hC) + have hm2 := (hsnd _ (measurableSet_arcBoundary d s δ)).trans + (mul_le_mul_of_nonneg_left (arcBoundary_measure_le d s hδ.le) hC) + have hsum := (abs_sub_le (∫ z, f z.1 * g z.2 ∂η) + (∫ z, fejerApprox H f z.1 * fejerApprox H g z.2 ∂η) + ((∫ t, f t ∂AddCircle.haarAddCircle) * ∫ t, g t ∂AddCircle.haarAddCircle)).trans + (add_le_add h1 h2) + have hprod : (fun z : CircleX × CircleX => f z.1 * g z.2) = + (Metric.ball c r ×ˢ Metric.ball d s).indicator (fun _ => (1 : ℝ)) := by + funext z + by_cases hzc : z.1 ∈ Metric.ball c r <;> + by_cases hzd : z.2 ∈ Metric.ball d s <;> simp [f, g, hzc, hzd] + rw [hprod, integral_indicator_const 1 (Metric.isOpen_ball.measurableSet.prod Metric.isOpen_ball.measurableSet)] at hsum + dsimp [f, g] at hsum + rw [integral_indicator_const 1 Metric.isOpen_ball.measurableSet, + integral_indicator_const 1 Metric.isOpen_ball.measurableSet] at hsum + simp only [smul_eq_mul, mul_one] at hsum + linarith + +lemma periodic_integral_bounds {f : ℝ → ℝ} (hp : Function.Periodic f 1) + (hi : ∀ a b, IntervalIntegrable f volume a b) (hn : ∀ x, 0 ≤ f x) + {a b : ℝ} (hab : a ≤ b) : + (b - a - 1) * (∫ x in a..a+1, f x) ≤ ∫ x in a..b, f x ∧ + (∫ x in a..b, f x) ≤ (b - a + 1) * (∫ x in a..a+1, f x) := by + let n : ℕ := ⌊b - a⌋₊ + have hnl : (n : ℝ) ≤ b - a := Nat.floor_le (sub_nonneg.mpr hab) + have hnu : b - a < (n : ℝ) + 1 := Nat.lt_floor_add_one _ + have hm : 0 ≤ ∫ x in a..a+1, f x := + intervalIntegral.integral_nonneg (by linarith) (fun x _ => hn x) + have he (k : ℕ) : (∫ x in a..a+k, f x) = k * ∫ x in a..a+1, f x := by + simpa using hp.intervalIntegral_add_zsmul_eq (k : ℤ) a hi + have hlo : (∫ x in a..a+n, f x) ≤ ∫ x in a..b, f x := + intervalIntegral.integral_mono_interval le_rfl (by have := Nat.cast_nonneg (α := ℝ) n; linarith) (by linarith) + (ae_of_all _ hn) (hi a b) + have hup : (∫ x in a..b, f x) ≤ ∫ x in a..a+(n+1 : ℕ), f x := + intervalIntegral.integral_mono_interval le_rfl hab (by push_cast; linarith) + (ae_of_all _ hn) (hi a _) + rw [he n] at hlo + rw [he (n+1)] at hup + push_cast at hup + constructor + · exact le_trans (mul_le_mul_of_nonneg_right (by linarith) hm) hlo + · exact le_trans hup (mul_le_mul_of_nonneg_right (by linarith) hm) + +def intervalLaw (a b : ℝ) : Measure ℝ := + (ENNReal.ofReal (b-a))⁻¹ • volume.restrict (Ioc a b) + +lemma intervalLaw_probability {a b : ℝ} (hab : a < b) : + IsProbabilityMeasure (intervalLaw a b) := by + constructor + simp only [intervalLaw, Measure.smul_apply, Measure.restrict_apply_univ, + Real.volume_Ioc, smul_eq_mul] + exact ENNReal.inv_mul_cancel (by simpa using sub_pos.mpr hab) ENNReal.ofReal_ne_top + +lemma integral_intervalLaw {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : ℝ → E) {a b : ℝ} (hab : a ≤ b) : + (∫ x, f x ∂intervalLaw a b) = (b-a)⁻¹ • ∫ x in a..b, f x := by + rw [intervalLaw, integral_smul_measure, ENNReal.toReal_inv, + ENNReal.toReal_ofReal (sub_nonneg.mpr hab), intervalIntegral.integral_of_le hab] + +lemma intervalIntegrable_circle_comp {f : CircleX → ℝ} + (hf : Integrable f (volume : Measure CircleX)) (a b : ℝ) : + IntervalIntegrable (fun x : ℝ => f x) volume a b := by + have hp : Function.Periodic (fun x : ℝ => f x) 1 := by + intro x + simp only [AddCircle.coe_add_period] + apply hp.intervalIntegrable₀ (by norm_num) + rw [intervalIntegrable_iff_integrableOn_Ioc_of_le (by norm_num : (0 : ℝ) ≤ 1)] + have hmp := AddCircle.measurePreserving_mk (1 : ℝ) 0 + simpa only [zero_add, Function.comp_def, IntegrableOn] using + (hmp.integrable_comp hf.aestronglyMeasurable).mpr hf + +lemma circle_scaled_integral_bounds {f : CircleX → ℝ} + (hf : Integrable f (volume : Measure CircleX)) (hn : ∀ x, 0 ≤ f x) + {a b c : ℝ} (hab : a < b) (hc : 0 < c) : + (1 - 1/(c*(b-a))) * (∫ x, f x) ≤ + (∫ x, f ((c*x : ℝ) : CircleX) ∂intervalLaw a b) ∧ + (∫ x, f ((c*x : ℝ) : CircleX) ∂intervalLaw a b) ≤ + (1 + 1/(c*(b-a))) * (∫ x, f x) := by + have hlen : 0 < b-a := sub_pos.mpr hab + have hp : Function.Periodic (fun x : ℝ => f x) 1 := by + intro x + simp only [AddCircle.coe_add_period] + have h := periodic_integral_bounds hp (intervalIntegrable_circle_comp hf) + (fun x => hn x) (mul_le_mul_of_nonneg_left hab.le hc.le) + rw [AddCircle.intervalIntegral_preimage] at h + rw [integral_intervalLaw _ hab.le, + intervalIntegral.integral_comp_mul_left (fun x : ℝ => f (x : CircleX)) hc.ne'] + simp only [smul_eq_mul] + constructor + · have ht := mul_le_mul_of_nonneg_left h.1 (by positivity : 0 ≤ (b-a)⁻¹*c⁻¹) + convert! ht using 1 <;> field_simp + · have ht := mul_le_mul_of_nonneg_left h.2 (by positivity : 0 ≤ (b-a)⁻¹*c⁻¹) + convert! ht using 1 <;> field_simp + +def phasePair (c d : ℝ) (t : ℝ) : CircleX × CircleX := + (((c*t : ℝ) : CircleX), ((d*t : ℝ) : CircleX)) + +def phasePairLaw (a b c d : ℝ) : Measure (CircleX × CircleX) := + (intervalLaw a b).map (phasePair c d) + +lemma continuous_phasePair (c d : ℝ) : Continuous (phasePair c d) := by + unfold phasePair + fun_prop + +lemma phasePairLaw_probability {a b : ℝ} (hab : a < b) (c d : ℝ) : + IsProbabilityMeasure (phasePairLaw a b c d) := by + let := intervalLaw_probability hab + unfold phasePairLaw + infer_instance + +lemma integral_phasePairLaw {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : CircleX × CircleX → E) {a b c d : ℝ} + (hf : AEStronglyMeasurable f (phasePairLaw a b c d)) : + (∫ z, f z ∂phasePairLaw a b c d) = ∫ t, f (phasePair c d t) ∂intervalLaw a b := by + exact integral_map (continuous_phasePair c d).aemeasurable hf + +lemma phasePairLaw_marginal_fst {a b c d : ℝ} (hab : a < b) (hc : 0 < c) + (B : Set CircleX) (hB : MeasurableSet B) : + (phasePairLaw a b c d).real (Prod.fst ⁻¹' B) ≤ + (1 + 1/(c*(b-a))) * (volume : Measure CircleX).real B := by + classical + let f := B.indicator (fun _ => (1 : ℝ)) + have hfi : Integrable f (volume : Measure CircleX) := (integrable_const _).indicator hB + have hfn : ∀ x, 0 ≤ f x := by intro x; dsimp [f, Set.indicator]; split_ifs <;> norm_num + have h := (circle_scaled_integral_bounds hfi hfn hab hc).2 + have he : (∫ z, (Prod.fst ⁻¹' B).indicator (fun _ => (1 : ℝ)) z + ∂phasePairLaw a b c d) = ∫ t, f ((c*t : ℝ) : CircleX) ∂intervalLaw a b := by + rw [integral_phasePairLaw _ ((measurable_const.indicator (hB.preimage measurable_fst)).aestronglyMeasurable)] + rfl + rw [integral_indicator_const 1 (hB.preimage measurable_fst)] at he + dsimp [f] at h + rw [integral_indicator_const 1 hB] at h + simp only [smul_eq_mul, mul_one] at he h + rw [he] + exact h + +lemma phasePairLaw_marginal_snd {a b c d : ℝ} (hab : a < b) (hd : 0 < d) + (B : Set CircleX) (hB : MeasurableSet B) : + (phasePairLaw a b c d).real (Prod.snd ⁻¹' B) ≤ + (1 + 1/(d*(b-a))) * (volume : Measure CircleX).real B := by + classical + let f := B.indicator (fun _ => (1 : ℝ)) + have hfi : Integrable f (volume : Measure CircleX) := (integrable_const _).indicator hB + have hfn : ∀ x, 0 ≤ f x := by intro x; dsimp [f, Set.indicator]; split_ifs <;> norm_num + have h := (circle_scaled_integral_bounds hfi hfn hab hd).2 + have he : (∫ z, (Prod.snd ⁻¹' B).indicator (fun _ => (1 : ℝ)) z + ∂phasePairLaw a b c d) = ∫ t, f ((d*t : ℝ) : CircleX) ∂intervalLaw a b := by + rw [integral_phasePairLaw _ ((measurable_const.indicator (hB.preimage measurable_snd)).aestronglyMeasurable)] + rfl + rw [integral_indicator_const 1 (hB.preimage measurable_snd)] at he + dsimp [f] at h + rw [integral_indicator_const 1 hB] at h + simp only [smul_eq_mul, mul_one] at he h + rw [he] + exact h + +lemma phasePair_fourier (c d t : ℝ) (v w : ℤ) : + fourier v (phasePair c d t).1 * fourier w (phasePair c d t).2 = + Complex.exp ((2 * Real.pi * ((v : ℝ)*c+(w : ℝ)*d) : ℝ) * Complex.I * t) := by + simp only [phasePair, fourier_coe_apply, Complex.ofReal_one, div_one, ← Complex.exp_add] + congr 1 + push_cast + ring + +lemma intervalLaw_exponential_bound {a b ω : ℝ} (hab : a < b) (hω : ω ≠ 0) : + ‖∫ t : ℝ, Complex.exp ((2 * Real.pi * ω : ℝ) * Complex.I * t) + ∂intervalLaw a b‖ ≤ 1/(Real.pi*|ω| *(b-a)) := by + have hc : (2 * Real.pi * ω : ℂ) * Complex.I ≠ 0 := by + exact mul_ne_zero (by exact_mod_cast mul_ne_zero (mul_ne_zero (by norm_num) Real.pi_ne_zero) hω) Complex.I_ne_zero + rw [integral_intervalLaw _ hab.le] + simp_rw [Complex.ofReal_mul, Complex.ofReal_ofNat] + rw [integral_exp_mul_complex hc, norm_smul, norm_div] + have hn (x : ℝ) : ‖Complex.exp (2 * (Real.pi : ℂ) * ω * Complex.I * x)‖ = 1 := by + have he : 2 * (Real.pi : ℂ) * ω * Complex.I * x = + ((2 * Real.pi * ω * x : ℝ) : ℂ) * Complex.I := by push_cast; ring + rw [he, Complex.norm_exp_ofReal_mul_I] + have hnum := (norm_sub_le (Complex.exp (2 * (Real.pi : ℂ) * ω * Complex.I * b)) + (Complex.exp (2 * (Real.pi : ℂ) * ω * Complex.I * a))) + rw [hn b, hn a] at hnum + simp only [norm_mul, Complex.norm_ofNat, Complex.norm_real, + Complex.norm_I, mul_one, Real.norm_eq_abs, abs_of_pos Real.pi_pos, + norm_inv, Real.norm_eq_abs, abs_of_pos (sub_pos.mpr hab)] + calc + _ ≤ (b-a)⁻¹ * ((1+1)/(2*Real.pi*|ω|)) := + mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right hnum (by positivity)) (by positivity) + _ = _ := by field_simp; ring + +lemma phasePairLaw_fourier_bound {a b c d : ℝ} (hab : a < b) (v w : ℤ) + (hfreq : (v : ℝ)*c+(w : ℝ)*d ≠ 0) : + ‖∫ z, fourier v z.1 * fourier w z.2 ∂phasePairLaw a b c d‖ ≤ + 1/(Real.pi*|(v : ℝ)*c+(w : ℝ)*d| *(b-a)) := by + rw [integral_phasePairLaw _ (by fun_prop)] + simp_rw [phasePair_fourier] + exact intervalLaw_exponential_bound hab hfreq + +lemma separated_phase_rectangle_bound {a b c d C R : ℝ} + (hab : a < b) (hc : 0 < c) (hd : 0 < d) (hR : 0 < R) + (hC0 : 0 ≤ C) (hCc : 1 + 1/(c*(b-a)) ≤ C) + (hCd : 1 + 1/(d*(b-a)) ≤ C) {H : ℕ} (hH : 0 < H) + (hsep : ∀ v w : ℤ, |v| < H → |w| < H → ¬(v = 0 ∧ w = 0) → + R ≤ |(v : ℝ)*c + (w : ℝ)*d|) + {δ : ℝ} (hδ : 0 < δ) (x y : CircleX) (r s : ℝ) : + |(phasePairLaw a b c d).real (Metric.ball x r ×ˢ Metric.ball y s) - + volume.real (Metric.ball x r) * volume.real (Metric.ball y s)| ≤ + 8*C*δ + 2/(4*H*δ^2) + H^2/(Real.pi*R*(b-a)) := by + let := phasePairLaw_probability hab c d + have hε : 0 ≤ 1/(Real.pi*R*(b-a)) := by positivity + have hfst (B : Set CircleX) (hB : MeasurableSet B) : + (phasePairLaw a b c d).real (Prod.fst ⁻¹' B) ≤ + C*AddCircle.haarAddCircle.real B := by + rw [haarAddCircle_one_eq_volume] + exact (phasePairLaw_marginal_fst hab hc B hB).trans + (mul_le_mul_of_nonneg_right hCc ENNReal.toReal_nonneg) + have hsnd (B : Set CircleX) (hB : MeasurableSet B) : + (phasePairLaw a b c d).real (Prod.snd ⁻¹' B) ≤ + C*AddCircle.haarAddCircle.real B := by + rw [haarAddCircle_one_eq_volume] + exact (phasePairLaw_marginal_snd hab hd B hB).trans + (mul_le_mul_of_nonneg_right hCd ENNReal.toReal_nonneg) + have hmom (v w : ℤ) (hv : |v| < H) (hw : |w| < H) (hne : ¬(v=0 ∧ w=0)) : + ‖∫ z, doubleFourier v w z ∂phasePairLaw a b c d‖ ≤ + 1/(Real.pi*R*(b-a)) := by + have hfpos : 0 < |(v : ℝ)*c+(w : ℝ)*d| := hR.trans_le (hsep v w hv hw hne) + exact (phasePairLaw_fourier_bound hab v w (abs_pos.mp hfpos)).trans + (one_div_le_one_div_of_le (by positivity) + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hsep v w hv hw hne) + Real.pi_pos.le) (sub_nonneg.mpr hab.le))) + have h := arc_rectangle_discrepancy hH hδ x y r s (phasePairLaw a b c d) + hC0 hε hfst hsnd hmom + rw [haarAddCircle_one_eq_volume] at h + simpa only [mul_one_div] using h + +end Sampling +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/FunctionalCalculus.lean b/lean/OAI/Analysis/RotationWeights/FunctionalCalculus.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0b17183c7e2bcce28bb947384bc8d88ece965f6 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/FunctionalCalculus.lean @@ -0,0 +1,304 @@ +import OAI.Analysis.RotationWeights.FiberActions + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uX uι uE uA + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace + +section +open Set Filter +open scoped Topology + +lemma lp_diagonal_stronglyMeasurable {X : Type uX} [MeasurableSpace X] + (d : X → ℤ → ℂ) (C : ℝ≥0) (hd : ∀ x k, ‖d x k‖≤C) + (hm : ∀ k, Measurable (fun x => d x k)) (u : FiberHilbert) : + StronglyMeasurable (fun x => lpDiagonal (d x) C (hd x) u) := by + let v : Finset ℤ → FiberHilbert := fun s => ∑ k∈s,lp.single 2 k (u k) + have hv : Tendsto v atTop (𝓝 u) := lp.hasSum_single (by norm_num) u + apply stronglyMeasurable_of_tendsto atTop (f:=fun s x => lpDiagonal (d x) C (hd x) (v s)) + · intro s + have he : (fun x => lpDiagonal (d x) C (hd x) (v s)) = + (fun x => ∑ k∈s,(d x k*u k) • lp.single 2 k 1) := by + funext x + simp only [v,map_sum] + apply Finset.sum_congr rfl + intro k _ + ext j + by_cases hj : j=k + · subst j; simp [lpDiagonal,lp.single_apply] + · simp [lpDiagonal,lp.single_apply,hj] + rw [he] + convert Finset.stronglyMeasurable_sum s (fun k _ => ((hm k).mul_const (u k)).stronglyMeasurable.smul_const (lp.single 2 k 1 : FiberHilbert)) using 1 + ext x; simp only [Finset.sum_apply] + · rw [tendsto_pi_nhds] + intro x + exact ((lpDiagonal (d x) C (hd x)).continuous.tendsto u).comp hv + +def boundedPiField (θ : CircleX) (g : CircleX → ℂ) (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) + (x : CircleX) : FiberOperator := lpDiagonal (fun k => g (x+k•θ)) C (fun _k => hg _) +@[simp] lemma boundedPiField_apply (θ : CircleX) (g : CircleX → ℂ) (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) + (x : CircleX) (u : FiberHilbert) (k : ℤ) : boundedPiField θ g C hg x u k=g (x+k•θ)*u k := rfl +lemma boundedPiField_bound (θ : CircleX) (g : CircleX → ℂ) (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) (x : CircleX) : + ‖boundedPiField θ g C hg x‖ ≤ C := lpDiagonal_norm_le _ _ +lemma boundedPiField_measurable (θ : CircleX) (g : CircleX → ℂ) (hm : Measurable g) + (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) (u : FiberHilbert) : + StronglyMeasurable (fun x => boundedPiField θ g C hg x u) := + lp_diagonal_stronglyMeasurable _ C (fun _x _k => hg _) (fun _k => hm.comp (measurable_id.add_const _)) u + +def boundedPi (θ : CircleX) (g : CircleX → ℂ) (hm : Measurable g) + (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) : CircleFiberOperator := + fieldMulL2 AddCircle.haarAddCircle (boundedPiField θ g C hg) + (fun u => (boundedPiField_measurable θ g hm C hg u).aestronglyMeasurable) + C (Eventually.of_forall (boundedPiField_bound θ g C hg)) +lemma boundedPi_coe (θ : CircleX) (g : CircleX → ℂ) (hm : Measurable g) + (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) (u : CircleFiberL2) : + boundedPi θ g hm C hg u =ᵐ[AddCircle.haarAddCircle] fun x => boundedPiField θ g C hg x (u x) := + fieldMulL2_coe _ _ _ _ _ _ +lemma boundedPi_norm_le (θ : CircleX) (g : CircleX → ℂ) (hm : Measurable g) + (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) : ‖boundedPi θ g hm C hg‖ ≤ C := + fieldMulL2_norm_le _ _ _ _ _ C.property + +lemma norm_tendsto_zero_of_sq {ι : Type uι} {E : Type uE} [NormedAddCommGroup E] {l : Filter ι} + (u : ι → E) (h : Tendsto (fun i => ‖u i‖^2) l (𝓝 0)) : Tendsto (fun i => ‖u i‖) l (𝓝 0) := by + simpa only [Function.comp_def,Real.sqrt_sq_eq_abs,abs_norm,Real.sqrt_zero] using (Real.continuous_sqrt.tendsto 0).comp h + +lemma lpDiagonal_tendsto (d : ℕ → ℤ → ℂ) (e : ℤ → ℂ) (C : ℝ≥0) + (hd : ∀ n k,‖d n k‖≤C) (he : ∀ k,‖e k‖≤C) + (hlim : ∀ k,Tendsto (fun n => d n k) atTop (𝓝 (e k))) (u : FiberHilbert) : + Tendsto (fun n => lpDiagonal (d n) C (hd n) u) atTop (𝓝 (lpDiagonal e C he u)) := by + rw [tendsto_iff_norm_sub_tendsto_zero] + apply norm_tendsto_zero_of_sq + have hs : Summable (fun k => (2*(C:ℝ))^2*‖u k‖^2) := by + have := (lp.memℓp u).summable (by norm_num : 0<(2:ℝ≥0∞).toReal) + simpa only [ENNReal.toReal_ofNat,Real.rpow_two] using this.mul_left ((2*(C:ℝ))^2) + have hh := tendsto_tsum_of_dominated_convergence hs (g:=fun _ : ℤ => (0:ℝ)) + (f:=fun n k => ‖(d n k-e k)*u k‖^2) (fun k => by simpa using (((hlim k).sub_const (e k)).mul_const (u k)).norm.pow 2) (Eventually.of_forall (fun n k => by + rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _),norm_mul,mul_pow] + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + apply pow_le_pow_left₀ (norm_nonneg _) ((norm_sub_le _ _).trans (by linarith [hd n k,he k])))) + simp only [tsum_zero] at hh + convert hh using 1 + funext n + have hn := lp.norm_rpow_eq_tsum (by norm_num : 0<(2:ℝ≥0∞).toReal) + (lpDiagonal (d n) C (hd n) u-lpDiagonal e C he u) + have hn' : ‖lpDiagonal (d n) C (hd n) u-lpDiagonal e C he u‖^2 = + ∑' k, ‖(lpDiagonal (d n) C (hd n) u-lpDiagonal e C he u) k‖^2 := by + simpa only [ENNReal.toReal_ofNat,Real.rpow_two] using hn + rw [hn'] + apply tsum_congr + intro k + change ‖d n k*u k-e k*u k‖^2=‖(d n k-e k)*u k‖^2 + rw [sub_mul] + +lemma L2_tendsto_of_dominated {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + (u : ℕ → Lp E 2 μ) (v : Lp E 2 μ) (b : X → ℝ) + (hb : Integrable (fun x => b x^2) μ) + (hu : ∀ n,∀ᵐ x ∂μ,‖u n x-v x‖≤b x) + (hl : ∀ᵐ x ∂μ,Tendsto (fun n => u n x) atTop (𝓝 (v x))) : + Tendsto u atTop (𝓝 v) := by + rw [tendsto_iff_norm_sub_tendsto_zero] + apply norm_tendsto_zero_of_sq + have he (n : ℕ) : ‖u n-v‖^2=∫ x,‖u n x-v x‖^2 ∂μ := by + rw [←inner_self_eq_norm_sq (𝕜:=ℂ),L2.inner_def,←integral_re (L2.integrable_inner _ _)] + apply integral_congr_ae + filter_upwards [Lp.coeFn_sub (u n) v] with x hx + simp only [hx,inner_self_eq_norm_sq,Pi.sub_apply] + simp_rw [he] + convert tendsto_integral_of_dominated_convergence (fun x => b x^2) + (fun n => ((Lp.aestronglyMeasurable (u n)).sub (Lp.aestronglyMeasurable v)).norm.pow 2) + hb (fun n => (hu n).mono (fun x hx => by + rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (norm_nonneg _) hx 2)) + (hl.mono (fun x hx => by simpa using (hx.sub_const (v x)).norm.pow 2)) using 1; simp + +lemma boundedPi_tendsto (θ : CircleX) (g : ℕ → CircleX → ℂ) (h : CircleX → ℂ) + (hm : ∀ n,Measurable (g n)) (hhm : Measurable h) (C : ℝ≥0) + (hg : ∀ n x,‖g n x‖≤C) (hh : ∀ x,‖h x‖≤C) + (hl : ∀ᵐ x ∂AddCircle.haarAddCircle,Tendsto (fun n => g n x) atTop (𝓝 (h x))) + (u : CircleFiberL2) : + Tendsto (fun n => boundedPi θ (g n) (hm n) C (hg n) u) atTop (𝓝 (boundedPi θ h hhm C hh u)) := by + have hl' : ∀ᵐ x ∂AddCircle.haarAddCircle,∀ k : ℤ,Tendsto (fun n => g n (x+k•θ)) atTop (𝓝 (h (x+k•θ))) := by + rw [ae_all_iff] + intro k + exact (measurePreserving_add_right AddCircle.haarAddCircle (k•θ)).quasiMeasurePreserving.ae + (p:=fun x : CircleX => Tendsto (fun n => g n x) atTop (𝓝 (h x))) hl + apply L2_tendsto_of_dominated (AddCircle.haarAddCircle : Measure CircleX) + (E:=FiberHilbert) (fun n => boundedPi θ (g n) (hm n) C (hg n) u) + (boundedPi θ h hhm C hh u) (fun x => 2*(C:ℝ)*‖u x‖) + · have hi : Integrable (fun x : CircleX => ‖u x‖^2) AddCircle.haarAddCircle := + (memLp_two_iff_integrable_sq_norm (Lp.aestronglyMeasurable u)).mp (Lp.memLp u) + have hj : Integrable (fun x : CircleX => (2*(C:ℝ))^2*‖u x‖^2) AddCircle.haarAddCircle := hi.const_mul _ + convert hj using 1 + funext x + exact mul_pow _ _ _ + · intro n + filter_upwards [boundedPi_coe θ (g n) (hm n) C (hg n) u,boundedPi_coe θ h hhm C hh u] with x h1 h2 + rw [h1,h2] + apply (norm_sub_le _ _).trans + have h3 := ((boundedPiField θ (g n) C (hg n) x).le_opNorm (u x)).trans + (mul_le_mul_of_nonneg_right (boundedPiField_bound θ (g n) C (hg n) x) (norm_nonneg _)) + have h4 := ((boundedPiField θ h C hh x).le_opNorm (u x)).trans + (mul_le_mul_of_nonneg_right (boundedPiField_bound θ h C hh x) (norm_nonneg _)) + linarith + · filter_upwards [ae_all_iff.mpr (fun n => boundedPi_coe θ (g n) (hm n) C (hg n) u),boundedPi_coe θ h hhm C hh u,hl'] with x h1 h2 hx + simp_rw [h1,h2] + exact lpDiagonal_tendsto _ _ C (fun n k => hg n _) (fun k => hh _) hx (u x) +end + +section +open Set Metric + +def complexCircleMap (f : C(CircleX,ℝ)) : C(CircleX,ℂ) := + ⟨fun x ↦ (f x : ℂ),Complex.continuous_ofReal.comp f.continuous⟩ + +lemma circleFunction_circle (f : C(CircleX,ℝ)) (z : Circle) : + circleFunction f z = (f (circleIdentification.symm z) : ℂ) := by + simp only [circleFunction,Circle.norm_coe,dite_eq_left] + congr 2 + +lemma circleFunction_fourier_one (f : C(CircleX,ℝ)) (x : CircleX) : + circleFunction f (fourier 1 x) = (f x : ℂ) := by + rw [fourier_one,circleFunction_circle] + have he : (AddCircle.toCircle x) = circleIdentification x := by + exact (AddCircle.homeomorphCircle_apply _ _).symm + rw [he,Homeomorph.symm_apply_apply] + +lemma circleFunction_continuousOn (f : C(CircleX,ℝ)) : + ContinuousOn (circleFunction f) (sphere (0:ℂ) 1) := by + rw [continuousOn_iff_continuous_domRestrict] + change Continuous (fun z : Circle ↦ circleFunction f z) + simp_rw [circleFunction_circle] + exact Complex.continuous_ofReal.comp (f.continuous.comp circleIdentification.symm.continuous) + +lemma circleFunction_continuousOn_spectrum (f : C(CircleX,ℝ)) : + ContinuousOn (circleFunction f) (spectrum ℂ (fourier (T := (1:ℝ)) 1)) := by + apply (circleFunction_continuousOn f).mono + rw [ContinuousMap.spectrum_eq_range] + rintro z ⟨x,rfl⟩ + rw [fourier_one] + exact (AddCircle.toCircle x).property + +lemma circle_cfc (f : C(CircleX,ℝ)) : + cfc (circleFunction f) (fourier (T := (1:ℝ)) 1) = complexCircleMap f := by + ext x + have he := (ContinuousMap.evalStarAlgHom ℂ ℂ x).map_cfc (circleFunction f) + (fourier (T := (1:ℝ)) 1) (circleFunction_continuousOn_spectrum f) + change cfc (circleFunction f) (fourier (T := (1:ℝ)) 1) x = (f x : ℂ) + change (cfc (circleFunction f) (fourier (T := (1:ℝ)) 1)) x = cfc (circleFunction f) (fourier 1 x) at he + rw [he] + have hz : cfc (circleFunction f) (fourier 1 x) = circleFunction f (fourier 1 x) := by + simpa only [Algebra.algebraMap_self_apply] using + (cfc_algebraMap (A := ℂ) (fourier 1 x) (circleFunction f)) + exact hz.trans (circleFunction_fourier_one f x) + +variable {A : Type uA} [CStarAlgebra A] +lemma circle_cfc_hom (φ : C(CircleX,ℂ) →⋆ₐ[ℂ] A) (hφ : Continuous φ) + (f : C(CircleX,ℝ)) : + φ (complexCircleMap f) = cfc (circleFunction f) (φ (fourier 1)) := by + have hn : IsStarNormal (φ (fourier 1)) := by + constructor + change star (φ _) * φ _ = φ _ * star (φ _) + rw [← map_star,← map_mul,← map_mul,mul_comm] + rw [← circle_cfc f] + exact φ.map_cfc _ _ (circleFunction_continuousOn_spectrum f) hφ +end + +open Set Filter +open scoped Topology + +lemma bounded_real_continuous_approx (g : CircleX → ℝ) (hm : Measurable g) + (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) : + ∃ f : ℕ → C(CircleX,ℝ), (∀ n x,‖f n x‖≤C) ∧ + ∀ᵐ x ∂AddCircle.haarAddCircle,Tendsto (fun n => f n x) atTop (𝓝 (g x)) := by + let μ : Measure CircleX := AddCircle.haarAddCircle + have hgLp : MemLp g 2 μ := MemLp.of_bound hm.aestronglyMeasurable C (Eventually.of_forall hg) + have hd := ContinuousMap.toLp_denseRange ℝ μ ℝ (p:=2) (by norm_num) + obtain ⟨u,hu,hl⟩ := mem_closure_iff_seq_limit.mp (hd (hgLp.toLp g)) + choose f hf using hu + have hfl : Tendsto (fun n => ContinuousMap.toLp 2 μ ℝ (f n)) atTop (𝓝 (hgLp.toLp g)) := by + simpa only [hf] using hl + obtain ⟨ns,_hns,hns⟩ := (tendstoInMeasure_of_tendsto_Lp hfl).exists_seq_tendsto_ae + let clip : ℝ → ℝ := fun t => max (-(C:ℝ)) (min (C:ℝ) t) + have hclip : Continuous clip := continuous_const.max (continuous_const.min continuous_id) + let F : ℕ → C(CircleX,ℝ) := fun n => ⟨clip ∘ f (ns n),hclip.comp (f (ns n)).continuous⟩ + refine ⟨F,?_,?_⟩ + · intro n x + rw [Real.norm_eq_abs,abs_le] + exact ⟨le_max_left _ _,max_le (by linarith [C.property]) (min_le_left _ _)⟩ + · filter_upwards [hns,ae_all_iff.mpr (fun n => ContinuousMap.coeFn_toLp μ (p:=2) (𝕜:=ℝ) (f (ns n))),hgLp.coeFn_toLp] with x hx hf hxg + have hcg : clip (g x)=g x := by + have h := abs_le.mp (hg x) + exact max_eq_right (h.1.trans_eq (min_eq_right h.2).symm) |>.trans (min_eq_right h.2) + have hh : Tendsto (fun n => f (ns n) x) atTop (𝓝 (g x)) := by + simpa only [hf,hxg] using hx + simpa only [F,ContinuousMap.coe_mk,Function.comp_def,hcg] using (hclip.tendsto (g x)).comp hh + +lemma boundedPi_eq_continuousPi (θ : CircleX) (g : C(CircleX,ℂ)) (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) : + boundedPi θ g g.continuous.measurable C hg=continuousPi θ g := by + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [boundedPi_coe θ g g.continuous.measurable C hg u,continuousPi_coe θ g u] with x h1 h2 + rw [h1,h2] + ext k + rfl + +lemma boundedPi_congr (θ : CircleX) (g h : CircleX → ℂ) (hgm : Measurable g) (hhm : Measurable h) + (C D : ℝ≥0) (hg : ∀ x,‖g x‖≤C) (hh : ∀ x,‖h x‖≤D) + (he : g=ᵐ[AddCircle.haarAddCircle] h) : boundedPi θ g hgm C hg=boundedPi θ h hhm D hh := by + have he' : ∀ᵐ x ∂AddCircle.haarAddCircle,∀ k : ℤ,g (x+k•θ)=h (x+k•θ) := by + rw [ae_all_iff] + intro k + exact (measurePreserving_add_right AddCircle.haarAddCircle (k•θ)).quasiMeasurePreserving.ae + (p:=fun x : CircleX => g x=h x) he + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [boundedPi_coe θ g hgm C hg u,boundedPi_coe θ h hhm D hh u,he'] with x h1 h2 hx + rw [h1,h2] + ext k + simp only [boundedPiField_apply,hx] + +lemma commute_boundedPi_real (θ : CircleX) (B : CircleFiberOperator) + (hB : ∀ f : C(CircleX,ℝ),Commute (continuousPi θ (complexCircleMap f)) B) + (g : CircleX → ℝ) (hm : Measurable g) (C : ℝ≥0) (hg : ∀ x,‖g x‖≤C) : + Commute (boundedPi θ (fun x => (g x:ℂ)) (Complex.measurable_ofReal.comp hm) C + (fun x => by simpa using hg x)) B := by + obtain ⟨f,hf,hl⟩ := bounded_real_continuous_approx g hm C hg + let F : ℕ → C(CircleX,ℂ) := fun n => complexCircleMap (f n) + have hF (n : ℕ) (x : CircleX) : ‖F n x‖≤C := by simpa [F,complexCircleMap] using hf n x + have hgl (x : CircleX) : ‖(g x:ℂ)‖≤C := by simpa using hg x + have hlim (u : CircleFiberL2) : Tendsto (fun n => continuousPi θ (F n) u) atTop + (𝓝 (boundedPi θ (fun x => (g x:ℂ)) (Complex.measurable_ofReal.comp hm) C hgl u)) := by + have h := boundedPi_tendsto θ (fun n x => F n x) (fun x => (g x:ℂ)) + (fun n => (F n).continuous.measurable) (Complex.measurable_ofReal.comp hm) C hF hgl + (hl.mono (fun x hx => Complex.continuous_ofReal.continuousAt.tendsto.comp hx)) u + simpa only [boundedPi_eq_continuousPi] using h + change _ * B = B * _ + apply ContinuousLinearMap.ext + intro u + exact tendsto_nhds_unique (hlim (B u)) + (by + have he : (fun n => continuousPi θ (F n) (B u)) = (fun n => B (continuousPi θ (F n) u)) := by + funext n + exact DFunLike.congr_fun (hB (f n)).eq u + rw [he] + exact (B.continuous.tendsto _).comp (hlim u)) + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/GraphTransfer.lean b/lean/OAI/Analysis/RotationWeights/GraphTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9024e8c050d37a79a03a32f17d2edf434868747 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/GraphTransfer.lean @@ -0,0 +1,615 @@ +import OAI.Analysis.RotationWeights.RationalGraphs + +namespace OAI + +noncomputable section + +universe uX uY uι uE + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction + +namespace CircleSampling + +section +open MeasureTheory Set Filter +open scoped Topology ENNReal BoundedContinuousFunction +variable {X : Type uX} [MetricSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] + +lemma graph_restriction_convergence + (μ : ProbabilityMeasure X) (ν : ℕ → FiniteMeasure (X×X)) + (f g : ℕ → X → ℝ) (hf : ∀ j, MemLp (f j) 2 (μ:Measure X)) + (hg : ∀ j, MemLp (g j) 2 (μ:Measure X)) + (hfm : ∀ j, Measurable (f j)) (_hgm : ∀ j, Measurable (g j)) + (hfn : ∀ j x, 0 ≤ f j x) (hgn : ∀ j x, 0 ≤ g j x) + (hfst : ∀ j, Measure.map Prod.fst (ν j : Measure (X×X))=weightedMeasure (μ:Measure X) (f j)) + (hsnd : ∀ j, Measure.map Prod.snd (ν j : Measure (X×X))=weightedMeasure (μ:Measure X) (g j)) + (δ : ℕ → ℝ) (hδ : Tendsto δ atTop (𝓝 0)) (hδb : ∀ j, 0 ≤ δ j ∧ δ j ≤ 1) + (hfe : ∀ j, (∫ x, (f j x-1)^2 ∂(μ:Measure X)) ≤ (δ j)^2) + (hge : ∀ j, (∫ x, (g j x-1)^2 ∂(μ:Measure X)) ≤ (δ j)^2) + (A : ℕ → Set X) (hA : ∀ j, MeasurableSet (A j)) + (hAlim : Tendsto (fun j => (μ:Measure X).real (A j)) atTop (𝓝 0)) + (T : C(X,X)) (r : ℕ → ℝ) (hr : Tendsto r atTop (𝓝 0)) + (hsupport : ∀ j, ∀ᵐ z ∂(ν j:Measure (X×X)), dist z.2 (T z.1) ≤ r j) : + let ν' := fun j => (ν j).restrict (Prod.fst ⁻¹' (A j)ᶜ) + Tendsto ν' atTop (𝓝 ((μ.toFiniteMeasure).map (fun x => (x,T x)))) ∧ + (∀ ε : ℝ≥0∞, ε ≠ 0 → ∃ d : ℝ≥0∞, d ≠ 0 ∧ + ∀ B : Set X, (μ:Measure X) B < d → ∀ j, + (ν' j : Measure (X×X)) (Prod.fst ⁻¹' B) ≤ ε ∧ + (ν' j : Measure (X×X)) (Prod.snd ⁻¹' B) ≤ ε) := by + let ν' := fun j => (ν j).restrict (Prod.fst ⁻¹' (A j)ᶜ) + have hf2 (j) : (∫ x, (f j x)^2 ∂(μ:Measure X)) ≤ 2^2 := by + exact (integral_sq_le_of_error _ (hf j) (hδb j).1 (hfe j)).trans (by nlinarith [(hδb j).1,(hδb j).2]) + have hg2 (j) : (∫ x, (g j x)^2 ∂(μ:Measure X)) ≤ 2^2 := by + exact (integral_sq_le_of_error _ (hg j) (hδb j).1 (hge j)).trans (by nlinarith [(hδb j).1,(hδb j).2]) + have hfle (j) (B : Set X) (hB : MeasurableSet B) : + (ν' j:Measure (X×X)).real (Prod.fst ⁻¹' B) ≤ 2*Real.sqrt ((μ:Measure X).real B) := by + have hm : (ν' j:Measure (X×X)) (Prod.fst ⁻¹' B) ≤ (ν j:Measure (X×X)) (Prod.fst ⁻¹' B) := Measure.restrict_le_self _ + apply le_trans (ENNReal.toReal_mono (measure_ne_top _ _) hm) + change ((ν j:Measure (X×X)) (Prod.fst ⁻¹' B)).toReal ≤ _ + rw [←Measure.map_apply measurable_fst hB,hfst j] + exact weightedMeasure_le_sqrt _ (hf j) (hfn j) (by norm_num) (hf2 j) B hB + have hgle (j) (B : Set X) (hB : MeasurableSet B) : + (ν' j:Measure (X×X)).real (Prod.snd ⁻¹' B) ≤ 2*Real.sqrt ((μ:Measure X).real B) := by + have hm : (ν' j:Measure (X×X)) (Prod.snd ⁻¹' B) ≤ (ν j:Measure (X×X)) (Prod.snd ⁻¹' B) := Measure.restrict_le_self _ + apply le_trans (ENNReal.toReal_mono (measure_ne_top _ _) hm) + change ((ν j:Measure (X×X)) (Prod.snd ⁻¹' B)).toReal ≤ _ + rw [←Measure.map_apply measurable_snd hB,hsnd j] + exact weightedMeasure_le_sqrt _ (hg j) (hgn j) (by norm_num) (hg2 j) B hB + constructor + · have hmap (j) : Measure.map Prod.fst (ν' j:Measure (X×X))= + (weightedMeasure (μ:Measure X) (f j)).restrict (A j)ᶜ := by + rw [←hfst j,Measure.restrict_map measurable_fst (hA j).compl] + rfl + apply tendsto_graph_of_fst ν' μ.toFiniteMeasure T r hr (by norm_num : (0:ℝ) ≤ 2) ?_ ?_ ?_ + · intro j + simpa using hfle j univ MeasurableSet.univ + · intro j + exact ae_restrict_of_ae (hsupport j) + · apply FiniteMeasure.tendsto_iff_forall_integral_tendsto.mpr + intro φ + have hbound (j) : |(∫ x, φ x ∂((ν' j).map Prod.fst : Measure X))-(∫ x, φ x ∂(μ:Measure X))| ≤ + ‖φ‖*(δ j+2*Real.sqrt ((μ:Measure X).real (A j))) := by + change |(∫ x, φ x ∂Measure.map Prod.fst (ν' j:Measure (X×X)))-_| ≤ _ + rw [hmap j] + calc + _ ≤ |(∫ x, φ x ∂(weightedMeasure (μ:Measure X) (f j)).restrict (A j)ᶜ)- + (∫ x, φ x ∂weightedMeasure (μ:Measure X) (f j))|+ + |(∫ x, φ x ∂weightedMeasure (μ:Measure X) (f j))-(∫ x, φ x ∂(μ:Measure X))| := abs_sub_le _ _ _ + _ ≤ ‖φ‖*(weightedMeasure (μ:Measure X) (f j)).real (A j)+ + ‖φ‖*Real.sqrt (∫ x, (f j x-1)^2 ∂(μ:Measure X)) := + add_le_add (weightedMeasure_test_restrict _ ((hf j).integrable (by norm_num)) (hfm j) (hfn j) _ (hA j) φ) + (weightedMeasure_l1_test _ (hf j) (hfm j) (hfn j) φ) + _ ≤ ‖φ‖*(2*Real.sqrt ((μ:Measure X).real (A j)))+‖φ‖*δ j := by + gcongr + · exact weightedMeasure_le_sqrt _ (hf j) (hfn j) (by norm_num) (hf2 j) _ (hA j) + · exact (Real.sqrt_le_left (hδb j).1).mpr (hfe j) + _ = _ := by ring + have ht : Tendsto (fun j => ‖φ‖*(δ j+2*Real.sqrt ((μ:Measure X).real (A j)))) atTop (𝓝 0) := by + simpa using (hδ.add (hAlim.sqrt.const_mul 2)).const_mul ‖φ‖ + exact tendsto_iff_norm_sub_tendsto_zero.mpr (squeeze_zero (fun _ => abs_nonneg _) hbound ht) + · intro ε hε + obtain ⟨d,hd,hdf⟩ := finiteMeasure_sqrt_uc (μ:Measure X) (fun j => (ν' j:Measure (X×X))) Prod.fst measurable_fst (by norm_num : (0:ℝ)<2) hfle ε hε + obtain ⟨e,he,heg⟩ := finiteMeasure_sqrt_uc (μ:Measure X) (fun j => (ν' j:Measure (X×X))) Prod.snd measurable_snd (by norm_num : (0:ℝ)<2) hgle ε hε + exact ⟨min d e,ne_of_gt (lt_min (pos_iff_ne_zero.mpr hd) (pos_iff_ne_zero.mpr he)), + fun B hB j => ⟨hdf B (hB.trans_le (min_le_left _ _)) j,heg B (hB.trans_le (min_le_right _ _)) j⟩⟩ +end +open MeasureTheory Set Filter +open scoped ENNReal Topology + +def orbitEquiv (n : ℤ) : CircleX ≃ᵐ CircleX := MeasurableEquiv.addRight (n•modelAngle) +lemma orbitEquiv_apply (n : ℤ) (x : CircleX) : orbitEquiv n x=CircleModel.shift modelAngle n x := rfl +lemma orbitEquiv_symm_apply (n : ℤ) (x : CircleX) : (orbitEquiv n).symm x=CircleModel.shift modelAngle (-n) x := by + simp [orbitEquiv,CircleModel.shift] +lemma orbitEquiv_preserving (n : ℤ) : MeasurePreserving (orbitEquiv n) volume volume := measurePreserving_add_right volume _ + +def stageGraph (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : FiniteMeasure (CircleX×CircleX) := + ⟨finiteGraphAverage volume (fun n : (scaleStep j).samples t => stageWeight true j n.val) + (fun n => orbitEquiv n.val), finiteGraphAverage_finite _ _ _ + (fun n => (stageWeight_memLp true j n.val).integrable (by norm_num)) + (fun n x => (stageWeight_bounds true j n.val x).1)⟩ +lemma stageGraph_fst (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + Measure.map Prod.fst (stageGraph j t : Measure (CircleX×CircleX))=weightedMeasure volume (stageDensity true j t) := + finiteGraphAverage_fst _ _ _ (fun n => stageWeight_measurable true j n.val) (fun n x => (stageWeight_bounds true j n.val x).1) + (fun n => (orbitEquiv n.val).measurable) +lemma stageGraph_snd (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + Measure.map Prod.snd (stageGraph j t : Measure (CircleX×CircleX))=weightedMeasure volume (stageDensity false j t) := by + have he := finiteGraphAverage_snd volume (fun n : (scaleStep j).samples t => orbitEquiv n.val) + (fun n => orbitEquiv_preserving n.val) (fun n => stageWeight true j n.val) + (fun n => stageWeight_measurable true j n.val) (fun n x => (stageWeight_bounds true j n.val x).1) + change Measure.map Prod.snd (stageGraph j t : Measure (CircleX×CircleX))=_ at he + rw [he] + congr 1 + funext x + apply congrArg ((Fintype.card ((scaleStep j).samples t):ℝ)⁻¹ * ·) + apply Finset.sum_congr rfl + intro n _ + change stageWeight true j n.val ((orbitEquiv n.val).symm x)=stageWeight false j n.val x + rw [orbitEquiv_symm_apply,stageWeight_negative] + +def translation (h : CircleX) : C(CircleX,CircleX) := ⟨fun x => x+h,continuous_id.add continuous_const⟩ +lemma quotient_norm_le (δ : ℝ) : ‖(δ:CircleX)‖ ≤ |δ| := by + exact QuotientAddGroup.norm_mk_le_norm +lemma stageGraph_support (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + ∀ᵐ z ∂(stageGraph j t:Measure (CircleX×CircleX)), + dist z.2 (translation (gridPoint (scaleState j).1 t) z.1) ≤ gridTolerance j (scaleState j).1 := by + have hP : MeasurableSet {z : CircleX×CircleX | dist z.2 (translation (gridPoint (scaleState j).1 t) z.1) ≤ gridTolerance j (scaleState j).1} := + measurableSet_le (measurable_snd.dist ((translation (gridPoint (scaleState j).1 t)).continuous.measurable.comp measurable_fst)) measurable_const + apply finiteGraphAverage_ae volume + (fun n : (scaleStep j).samples t => stageWeight true j n.val) + (fun n => orbitEquiv n.val) (fun n => stageWeight_measurable true j n.val) + (fun n => (orbitEquiv n.val).measurable) _ hP + intro n + apply ae_of_all + intro x _ + obtain ⟨δ,hδ,he⟩ := (scaleStep j).orbits parameterAngle (parameterAngle_spec.2.2.2 j) t n.val n.property + have hn : n.val•modelAngle=gridPoint (scaleState j).1 t+(δ:CircleX) := by + change (δ:CircleX)=n.val•modelAngle-gridPoint (scaleState j).1 t at he + exact (sub_eq_iff_eq_add.mp he.symm).trans (add_comm _ _) + change dist (x+n.val•modelAngle) (x+gridPoint (scaleState j).1 t) ≤ _ + rw [hn,←add_assoc,dist_eq_norm,add_sub_cancel_left] + exact ((quotient_norm_le δ).trans_eq (abs_of_pos hδ.1)).trans hδ.2.le +lemma gridTolerance_bound (j : ℕ) : 0 < gridTolerance j (scaleState j).1 ∧ + gridTolerance j (scaleState j).1 ≤ 1/((j:ℝ)+1) := by + have hj : 0 < (j:ℝ)+1 := by positivity + have hq : (1:ℝ) ≤ (scaleState j).1.q (scaleState j).1.d := by exact_mod_cast (scaleState j).2.qpos _ le_rfl + have hd : 1 ≤ 1+((scaleState j).1.d:ℝ) := le_add_of_nonneg_right (Nat.cast_nonneg _) + constructor + · unfold gridTolerance; positivity + · unfold gridTolerance + apply one_div_le_one_div_of_le hj + calc + _ ≤ 10*((j:ℝ)+1)^2 := by nlinarith [sq_nonneg (j:ℝ)] + _ ≤ 10*((j:ℝ)+1)^2*(1+((scaleState j).1.d:ℝ)) := le_mul_of_one_le_right (by positivity) hd + _ ≤ _ := le_mul_of_one_le_right (by positivity) hq +lemma gridTolerance_tendsto : Tendsto (fun j => gridTolerance j (scaleState j).1) atTop (𝓝 0) := + squeeze_zero (fun j => (gridTolerance_bound j).1.le) (fun j => (gridTolerance_bound j).2) + tendsto_one_div_add_atTop_nhds_zero_nat + +def rationalPoint (D : ℕ) (a : Fin (frequency (D+1))) : CircleX := (((a.val:ℝ)/(frequency (D+1):ℝ):ℝ):CircleX) +def rationalIndex (D : ℕ) (a : Fin (frequency (D+1))) (j : ℕ) : + Fin ((scaleState (D+1+j)).1.q (scaleState (D+1+j)).1.d) := + (rational_stage_index D (D+1+j) a (le_trans (by omega) (blockEnd_ge _))).choose +lemma rationalIndex_spec (D : ℕ) (a : Fin (frequency (D+1))) (j : ℕ) : + gridPoint (scaleState (D+1+j)).1 (rationalIndex D a j)=rationalPoint D a := + (rational_stage_index D (D+1+j) a (le_trans (by omega) (blockEnd_ge _))).choose_spec + +def rationalGraph (D : ℕ) (a : Fin (frequency (D+1))) (j : ℕ) : FiniteMeasure (CircleX×CircleX) := + (stageGraph (D+1+j) (rationalIndex D a j)).restrict (Prod.fst ⁻¹' (graphBad (D+1+j))ᶜ) + +def circleProbability : ProbabilityMeasure CircleX := ⟨volume,inferInstance⟩ +lemma rationalGraph_convergence (D : ℕ) (a : Fin (frequency (D+1))) : + Tendsto (rationalGraph D a) atTop (𝓝 (circleProbability.toFiniteMeasure.map (fun x => (x,translation (rationalPoint D a) x)))) ∧ + (∀ ε : ℝ≥0∞, ε≠0 → ∃ d : ℝ≥0∞, d≠0 ∧ ∀ B : Set CircleX, volume B D+1+j) atTop atTop := by simpa only [Nat.add_comm] using tendsto_add_atTop_nat (D+1) + apply graph_restriction_convergence circleProbability + (fun j => stageGraph (D+1+j) (rationalIndex D a j)) + (fun j => stageDensity true (D+1+j) (rationalIndex D a j)) + (fun j => stageDensity false (D+1+j) (rationalIndex D a j)) + (fun j => stageDensity_memLp _ _ _) (fun j => stageDensity_memLp _ _ _) + (fun j => stageDensity_measurable _ _ _) (fun j => stageDensity_measurable _ _ _) + (fun j => stageDensity_nonneg _ _ _) (fun j => stageDensity_nonneg _ _ _) + (fun j => stageGraph_fst _ _) (fun j => stageGraph_snd _ _) + (fun j => 1/(((D+1+j:ℕ):ℝ)+1)) ?_ ?_ ?_ ?_ + (fun j => graphBad (D+1+j)) (fun j => graphBad_measurable _) (graphBad_tendsto.comp hs) + (translation (rationalPoint D a)) (fun j => gridTolerance (D+1+j) (scaleState (D+1+j)).1) + (gridTolerance_tendsto.comp hs) ?_ + · exact (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℝ)).comp hs + · intro j + refine ⟨by positivity, ?_⟩ + simpa using (one_div_le_one_div_of_le (by norm_num : (0:ℝ)<1) (le_add_of_nonneg_left (Nat.cast_nonneg (D+1+j)))) + · intro j + simpa only [one_div_pow,circleProbability,ProbabilityMeasure.coe_mk] using (stageDensity_energy true (D+1+j) (rationalIndex D a j)).le + · intro j + simpa only [one_div_pow,circleProbability,ProbabilityMeasure.coe_mk] using (stageDensity_energy false (D+1+j) (rationalIndex D a j)).le + · intro j + simpa only [rationalIndex_spec] using stageGraph_support (D+1+j) (rationalIndex D a j) +end CircleSampling + +open MeasureTheory Set Filter Topology TopologicalSpace +namespace ContinuousCircleWeight + +section + +theorem continuousOn_compact_graph {X : Type uX} {Y : Type uY} [TopologicalSpace X] + [TopologicalSpace Y] [T2Space X] (f : X → Y) {K : Set (X × Y)} + (hK : IsCompact K) (hgraph : ∀ p ∈ K, p.2 = f p.1) : + ContinuousOn f (Prod.fst '' K) := by + let E : Set X := Prod.fst '' K + have hpoint : ∀ x ∈ E, (x, f x) ∈ K := by + rintro x ⟨p, hp, rfl⟩ + simpa only [← hgraph p hp, Prod.eta] using hp + let e : K ≃ E := + { toFun := fun p => ⟨p.1.1, ⟨p.1, p.2, rfl⟩⟩ + invFun := fun x => ⟨(x.1, f x.1), hpoint x.1 x.2⟩ + left_inv := by + intro p + apply Subtype.ext + exact Prod.ext rfl (hgraph p.1 p.2).symm + right_inv := by intro x; rfl } + let : CompactSpace K := isCompact_iff_compactSpace.mp hK + have he : Continuous e := (continuous_fst.comp continuous_subtype_val).subtype_mk _ + have he' : Continuous e.symm := he.continuous_symm_of_equiv_compact_to_t2 + rw [continuousOn_iff_continuous_domRestrict] + exact continuous_snd.comp (continuous_subtype_val.comp he') + +theorem measurable_lusin_compact {X : Type uX} {Y : Type uY} [TopologicalSpace X] + [TopologicalSpace Y] [PolishSpace X] [PolishSpace Y] + [MeasurableSpace X] [MeasurableSpace Y] [BorelSpace X] [BorelSpace Y] + {μ : Measure X} [IsFiniteMeasure μ] {f : X → Y} (hf : Measurable f) + {ε : ℝ≥0∞} (hε : ε ≠ 0) : + ∃ E : Set X, IsCompact E ∧ μ Eᶜ < ε ∧ ContinuousOn f E := by + let g : X → X × Y := fun x => (x, f x) + have hg : Measurable g := measurable_id.prodMk hf + let G : Set (X × Y) := {p | p.2 = f p.1} + have hG : MeasurableSet G := measurableSet_eq_fun measurable_snd (hf.comp measurable_fst) + let ν := μ.map g + obtain ⟨K, hKG, hK, hsmall⟩ := hG.exists_isCompact_sdiff_lt (measure_ne_top ν G) hε + have hpre : g ⁻¹' (G \ K) = (Prod.fst '' K)ᶜ := by + ext x + simp only [mem_preimage, Set.mem_sdiff, mem_ofPred_eq, g, G, mem_compl_iff, + true_and] + constructor + · intro hx hproj + obtain ⟨p, hp, hpx⟩ := hproj + apply hx + convert hp using 1 + exact Prod.ext hpx.symm (by simpa only [mem_ofPred_eq, G, hpx] using (hKG hp).symm) + · intro hx hxp + exact hx ⟨(x, f x), hxp, rfl⟩ + rw [Measure.map_apply hg (hG.diff hK.isClosed.measurableSet), hpre] at hsmall + refine ⟨Prod.fst '' K, hK.image continuous_fst, hsmall, ?_⟩ + exact continuousOn_compact_graph f hK (fun _ hp => hKG hp) + +theorem finiteMeasure_compl_le_of_tendsto {X : Type uX} [TopologicalSpace X] + [MeasurableSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] + {ν : FiniteMeasure X} {νs : ℕ → FiniteMeasure X} + (hlim : Tendsto νs atTop (𝓝 ν)) {K : Set X} (hK : IsClosed K) + {ε : ℝ≥0∞} (hsmall : ∀ n, (νs n : Measure X) Kᶜ ≤ ε) : + (ν : Measure X) Kᶜ ≤ ε := by + have hmass : Tendsto (fun n => (νs n : Measure X) univ) atTop + (𝓝 ((ν : Measure X) univ)) := by + simpa only [← FiniteMeasure.ennreal_mass, Function.comp_def] using + (ENNReal.continuous_coe.tendsto ν.mass).comp hlim.mass + have hpoint : ∀ n, (νs n : Measure X) univ ≤ (νs n : Measure X) K + ε := by + intro n + calc + _ = (νs n : Measure X) K + (νs n : Measure X) Kᶜ := + (measure_add_measure_compl hK.measurableSet).symm + _ ≤ _ := add_le_add le_rfl (hsmall n) + have hbound : (ν : Measure X) univ ≤ (ν : Measure X) K + ε := by + calc + _ = atTop.limsup (fun n => (νs n : Measure X) univ) := hmass.limsup_eq.symm + _ ≤ atTop.limsup (fun n => (νs n : Measure X) K + ε) := + limsup_le_limsup (Eventually.of_forall hpoint) + _ = atTop.limsup (fun n => (νs n : Measure X) K) + ε := + limsup_add_const _ _ _ (by isBoundedDefault) (by isBoundedDefault) + _ ≤ _ := add_le_add + (FiniteMeasure.limsup_measure_closed_le_of_tendsto hlim hK) le_rfl + rw [measure_compl hK.measurableSet (measure_ne_top _ _)] + exact tsub_le_iff_right.mpr (by simpa only [add_comm] using hbound) + +theorem isCompact_all_zeros {X : Type uX} {Y : Type uY} {ι : Type uι} [TopologicalSpace X] + [TopologicalSpace Y] [T1Space Y] [Zero Y] {E : Set X} (hE : IsCompact E) + {f : ι → X → Y} (hf : ∀ i, ContinuousOn (f i) E) : + IsCompact {x | x ∈ E ∧ ∀ i, f i x = 0} := by + have hc : ContinuousOn (fun x i => f i x) E := continuousOn_pi.mpr hf + obtain ⟨C, hC, heq⟩ := continuousOn_iff_isClosed.mp hc {0} isClosed_singleton + have hset : {x | x ∈ E ∧ ∀ i, f i x = 0} = C ∩ E := by + rw [← heq] + ext x + simp only [mem_ofPred_eq, mem_inter_iff, mem_preimage, mem_singleton_iff, + funext_iff, Pi.zero_apply, and_comm] + rw [hset] + exact hE.inter_left hC + +theorem compact_relation_transfer {X : Type uX} [TopologicalSpace X] [T2Space X] + [MeasurableSpace X] [BorelSpace X] [SecondCountableTopology X] [HasOuterApproxClosed (X × X)] + {μ : Measure X} {ν : FiniteMeasure (X × X)} {νs : ℕ → FiniteMeasure (X × X)} + (hlim : Tendsto νs atTop (𝓝 ν)) {Z : Set (X × X)} + (hgood : ∀ n, (νs n : Measure (X × X)) Zᶜ = 0) + (huc : ∀ ε : ℝ≥0∞, ε ≠ 0 → ∃ δ : ℝ≥0∞, δ ≠ 0 ∧ + ∀ A : Set X, μ A < δ → ∀ n, + (νs n : Measure (X × X)) (Prod.fst ⁻¹' A) ≤ ε ∧ + (νs n : Measure (X × X)) (Prod.snd ⁻¹' A) ≤ ε) + (happrox : ∀ δ : ℝ≥0∞, δ ≠ 0 → ∃ E : Set X, + μ Eᶜ < δ ∧ IsCompact ((E ×ˢ E) ∩ Z)) : + (ν : Measure (X × X)) Zᶜ = 0 := by + apply le_antisymm ?_ bot_le + apply ENNReal.le_of_forall_pos_le_add + intro ε hε _ + have heps : (ε : ℝ≥0∞) / 2 ≠ 0 := + (ENNReal.half_pos (ENNReal.coe_ne_zero.mpr hε.ne.symm)).ne.symm + obtain ⟨δ, hδ, hδsmall⟩ := huc ((ε : ℝ≥0∞) / 2) heps + obtain ⟨E, hEμ, hEK⟩ := happrox δ hδ + let K := (E ×ˢ E) ∩ Z + have hKsmall : ∀ n, (νs n : Measure (X × X)) Kᶜ ≤ ε := by + intro n + have hsub : Kᶜ ⊆ (Prod.fst ⁻¹' Eᶜ) ∪ (Prod.snd ⁻¹' Eᶜ) ∪ Zᶜ := by + intro p hp + simp only [K, mem_compl_iff, mem_inter_iff, mem_prod] at hp + simp only [mem_union, mem_preimage, mem_compl_iff] + tauto + calc + _ ≤ (νs n : Measure (X × X)) + ((Prod.fst ⁻¹' Eᶜ) ∪ (Prod.snd ⁻¹' Eᶜ) ∪ Zᶜ) := measure_mono hsub + _ ≤ (νs n : Measure (X × X)) ((Prod.fst ⁻¹' Eᶜ) ∪ (Prod.snd ⁻¹' Eᶜ)) + + (νs n : Measure (X × X)) Zᶜ := measure_union_le _ _ + _ ≤ ((νs n : Measure (X × X)) (Prod.fst ⁻¹' Eᶜ) + + (νs n : Measure (X × X)) (Prod.snd ⁻¹' Eᶜ)) + 0 := + add_le_add (measure_union_le _ _) (hgood n).le + _ ≤ ((ε : ℝ≥0∞) / 2 + (ε : ℝ≥0∞) / 2) + 0 := + add_le_add (add_le_add (hδsmall Eᶜ hEμ n).1 (hδsmall Eᶜ hEμ n).2) le_rfl + _ = ε := by simp + have hlimK := finiteMeasure_compl_le_of_tendsto hlim hEK.isClosed hKsmall + simpa only [ENNReal.bot_eq_zero, zero_add] using (measure_mono (compl_subset_compl.mpr + (show K ⊆ Z from inter_subset_right))).trans hlimK + +lemma continuous_bounded_field_apply {X : Type uX} [TopologicalSpace X] + {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℂ E] + (A : X → (E →L[ℂ] E)) {C : ℝ} (_hC : 0 ≤ C) + (hb : ∀ x, ‖A x‖ ≤ C) (hA : ∀ u, Continuous (fun x ↦ A x u)) + {v : X → E} (hv : Continuous v) : Continuous (fun x ↦ A x (v x)) := by + rw [continuous_iff_continuousAt] + intro x + have hzero : Tendsto (fun y ↦ A y (v y-v x)) (𝓝 x) (𝓝 0) := by + apply squeeze_zero_norm (a := fun y ↦ C * ‖v y-v x‖) + · intro y + exact (A y).le_opNorm _ |>.trans (mul_le_mul_of_nonneg_right (hb y) (norm_nonneg _)) + · have ht : Tendsto (fun y ↦ ‖v y-v x‖) (𝓝 x) (𝓝 0) := by + simpa only [sub_self, norm_zero] using ((hv.tendsto x).sub_const (v x)).norm + simpa only [mul_zero] using tendsto_const_nhds.mul ht + have hsum := hzero.add (hA (v x)).continuousAt + change Tendsto (fun y ↦ A y (v y)) (𝓝 x) (𝓝 (A x (v x))) + simpa only [map_sub, sub_add_cancel, zero_add] using hsum + +def cappedRatio {X : Type uX} (F : ℤ → X → ℝ) (B : ℝ≥0) (x y : X) (k : ℤ) : ℝ := + min (B : ℝ) (max 0 (F k y / F k x)) + +lemma cappedRatio_bounds {X : Type uX} (F : ℤ → X → ℝ) (B : ℝ≥0) + (x y : X) (k : ℤ) : 0 ≤ cappedRatio F B x y k ∧ cappedRatio F B x y k ≤ B := + ⟨le_min B.coe_nonneg (le_max_left _ _), min_le_left _ _⟩ + +def cappedDiagonal {X : Type uX} (F : ℤ → X → ℝ) (B : ℝ≥0) (x y : X) : FiberOperator := + lpDiagonal (fun k ↦ (cappedRatio F B x y k : ℂ)) B (fun k ↦ by + simpa only [Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (cappedRatio_bounds F B x y k).1] using (cappedRatio_bounds F B x y k).2) + +lemma continuous_cappedDiagonal {X : Type uX} [TopologicalSpace X] + (F : ℤ → X → ℝ) (hF : ∀ k, Continuous (F k)) (hp : ∀ k x, 0 < F k x) + (B : ℝ≥0) (u : FiberHilbert) : + Continuous (fun z : X × X ↦ cappedDiagonal F B z.1 z.2 u) := by + apply continuous_bounded_lp_field _ B.coe_nonneg (fun _ ↦ lpDiagonal_norm_le _ _) _ u + intro k + have he : (fun z : X × X ↦ cappedDiagonal F B z.1 z.2 (lp.single 2 k 1)) = + (fun z ↦ (cappedRatio F B z.1 z.2 k : ℂ) • lp.single 2 k 1) := by + funext z + ext i + simp only [cappedDiagonal, lpDiagonal_apply, lp.coeFn_smul, Pi.smul_apply, smul_eq_mul] + by_cases hi : i=k + · subst i; simp + · simp [lp.single_apply, hi] + change Continuous (fun z : X × X ↦ cappedDiagonal F B z.1 z.2 (lp.single 2 k 1)) + rw [he] + have hr : Continuous (fun z : X × X ↦ cappedRatio F B z.1 z.2 k) := + continuous_const.min (continuous_const.max + (((hF k).comp continuous_snd).div ((hF k).comp continuous_fst) (fun z ↦ (hp k z.1).ne'))) + exact (Complex.continuous_ofReal.comp hr).smul + (continuous_const : Continuous (fun _ : X × X ↦ (lp.single 2 k 1 : FiberHilbert))) + +instance fiberSeparable : SeparableSpace FiberHilbert := by + let b := HilbertBasis.ofRepr (LinearIsometryEquiv.refl ℂ FiberHilbert) + apply isSeparable_univ_iff.mp + have hs := ((countable_range (b : ℤ → FiberHilbert)).isSeparable.span (R := ℂ)).closure + rw [← Submodule.topologicalClosure_coe, b.dense_span] at hs + exact hs + +local instance fiberMeasurable : MeasurableSpace FiberHilbert := borel FiberHilbert +local instance fiberBorel : BorelSpace FiberHilbert := ⟨rfl⟩ + +def cappedPairRelation {X : Type uX} (p : X → FiberOperator) (F : ℤ → X → ℝ) + (B : ℝ≥0) : Set (X × X) := + {z | ∀ k : ℤ, (1-p z.2) (cappedDiagonal F B z.1 z.2 (p z.1 (lp.single 2 k 1)))=0} + +lemma cappedPairRelation_iff {X : Type uX} (p : X → FiberOperator) (F : ℤ → X → ℝ) + (B : ℝ≥0) (x y : X) : + (x,y) ∈ cappedPairRelation p F B ↔ (1-p y)*cappedDiagonal F B x y*p x=0 := by + constructor + · intro h + apply lp.ext_continuousLinearMap (by norm_num) + intro k + apply ContinuousLinearMap.ext + intro a + have he : lp.single (E := fun _ : ℤ ↦ ℂ) 2 k a = a • lp.single 2 k (1 : ℂ) := by + simpa using (lp.single_smul (E := fun _ : ℤ ↦ ℂ) 2 k a (1 : ℂ)) + change (1-p y) (cappedDiagonal F B x y (p x (lp.single 2 k a))) = 0 + simp only [he, map_smul] + change a • ((1-p y) (cappedDiagonal F B x y (p x (lp.single 2 k 1)))) = 0 + rw [h k, smul_zero] + · intro h k + have he := congrArg (fun a : FiberOperator ↦ a (lp.single 2 k 1)) h + exact he + +lemma cappedPairRelation_compact_approx {X : Type uX} [TopologicalSpace X] [PolishSpace X] + [MeasurableSpace X] [BorelSpace X] {μ : Measure X} [IsFiniteMeasure μ] + (p : X → FiberOperator) (hp : ∀ x, ‖p x‖ ≤ 1) + (hpm : ∀ k : ℤ, Measurable (fun x ↦ p x (lp.single 2 k 1))) + (F : ℤ → X → ℝ) (hFm : ∀ k, Measurable (F k)) (hFp : ∀ k x, 0 < F k x) + (B : ℝ≥0) {δ : ℝ≥0∞} (hδ : δ ≠ 0) : + ∃ E : Set X, μ Eᶜ < δ ∧ IsCompact ((E ×ˢ E) ∩ cappedPairRelation p F B) := by + let f : X → (ℤ → FiberHilbert) × (ℤ → ℝ) := + fun x ↦ ((fun k ↦ p x (lp.single 2 k 1)), fun k ↦ F k x) + have hfm : Measurable f := (Measurable.of_eval hpm).prodMk (Measurable.of_eval hFm) + obtain ⟨E,hEc,hEμ,hEf⟩ := measurable_lusin_compact hfm (μ := μ) hδ + refine ⟨E,hEμ,?_⟩ + let : CompactSpace E := isCompact_iff_compactSpace.mp hEc + have hfc : Continuous (fun x : E ↦ f x) := continuousOn_iff_continuous_domRestrict.mp hEf + have hpc : ∀ k, Continuous (fun x : E ↦ p x (lp.single 2 k 1)) := + fun k ↦ (continuous_apply k).comp hfc.fst + have hFc : ∀ k, Continuous (fun x : E ↦ F k x) := + fun k ↦ (continuous_apply k).comp hfc.snd + have hpstrong : ∀ u : FiberHilbert, Continuous (fun x : E ↦ p x u) := + continuous_bounded_lp_field (fun x : E ↦ p x) zero_le_one (fun x ↦ hp x) hpc + have hDc : ∀ u : FiberHilbert, Continuous (fun z : E × E ↦ cappedDiagonal F B z.1 z.2 u) := + continuous_cappedDiagonal (fun k (x : E) ↦ F k x) hFc (fun k x ↦ hFp k x) B + have hqc : ∀ u : FiberHilbert, Continuous (fun z : E × E ↦ (1-p z.2) u) := by + intro u + change Continuous (fun z : E × E ↦ u-p z.2 u) + exact continuous_const.sub ((hpstrong u).comp continuous_snd) + have hqb : ∀ z : E × E, ‖1-p z.2‖ ≤ 2 := by + intro z + calc + ‖1-p z.2‖ ≤ ‖(1 : FiberOperator)‖ + ‖p z.2‖ := norm_sub_le _ _ + _ ≤ 1 + 1 := add_le_add (ContinuousLinearMap.norm_id_le) (hp z.2) + _ = 2 := by norm_num + let T : ℤ → E × E → FiberHilbert := + fun k z ↦ (1-p z.2) (cappedDiagonal F B z.1 z.2 (p z.1 (lp.single 2 k 1))) + have hTc : ∀ k, Continuous (T k) := by + intro k + apply continuous_bounded_field_apply (fun z : E × E ↦ 1-p z.2) (by norm_num) hqb hqc + apply continuous_bounded_field_apply (fun z : E × E ↦ cappedDiagonal F B z.1 z.2) + B.coe_nonneg (fun _ ↦ lpDiagonal_norm_le _ _) hDc + exact (hpc k).comp continuous_fst + have hK : IsCompact {z : E × E | ∀ k, T k z=0} := by + have hc : IsClosed {z : E × E | ∀ k, T k z=0} := by + simpa only [funext_iff, Pi.zero_apply] using + (isClosed_eq (continuous_pi hTc) + (continuous_const : Continuous (fun _ : E × E ↦ (0 : ℤ → FiberHilbert)))) + exact hc.isCompact + let e : E × E → X × X := fun z ↦ (z.1.val,z.2.val) + have he : Continuous e := + (continuous_subtype_val.comp continuous_fst).prodMk (continuous_subtype_val.comp continuous_snd) + have hset : (E ×ˢ E) ∩ cappedPairRelation p F B = e '' {z : E × E | ∀ k,T k z=0} := by + ext z + constructor + · rintro ⟨⟨hx,hy⟩,hz⟩ + exact ⟨(⟨z.1,hx⟩,⟨z.2,hy⟩),hz,rfl⟩ + · rintro ⟨⟨x,y⟩,hxy,rfl⟩ + exact ⟨⟨x.property,y.property⟩,hxy⟩ + rw [hset] + exact hK.image he + +theorem capped_pair_identity_transfer {X : Type uX} [TopologicalSpace X] [PolishSpace X] + [MeasurableSpace X] [BorelSpace X] {μ : Measure X} [IsFiniteMeasure μ] + (p : X → FiberOperator) (hp : ∀ x, ‖p x‖ ≤ 1) + (hpm : ∀ k : ℤ, Measurable (fun x ↦ p x (lp.single 2 k 1))) + (F : ℤ → X → ℝ) (hFm : ∀ k, Measurable (F k)) (hFp : ∀ k x, 0 < F k x) + (B : ℝ≥0) {ν : FiniteMeasure (X × X)} {νs : ℕ → FiniteMeasure (X × X)} + (hlim : Tendsto νs atTop (𝓝 ν)) + (hgood : ∀ n, ∀ᵐ z ∂(νs n : Measure (X × X)), + (1-p z.2)*cappedDiagonal F B z.1 z.2*p z.1=0) + (huc : ∀ ε : ℝ≥0∞, ε ≠ 0 → ∃ δ : ℝ≥0∞, δ ≠ 0 ∧ + ∀ A : Set X, μ A < δ → ∀ n, + (νs n : Measure (X × X)) (Prod.fst ⁻¹' A) ≤ ε ∧ + (νs n : Measure (X × X)) (Prod.snd ⁻¹' A) ≤ ε) : + ∀ᵐ z ∂(ν : Measure (X × X)), (1-p z.2)*cappedDiagonal F B z.1 z.2*p z.1=0 := by + have hr : (ν : Measure (X × X)) (cappedPairRelation p F B)ᶜ=0 := by + apply compact_relation_transfer hlim (μ := μ) ?_ huc + (fun _ hδ ↦ cappedPairRelation_compact_approx p hp hpm F hFm hFp B hδ) + intro n + have hg : ∀ᵐ z ∂(νs n : Measure (X × X)), z ∈ cappedPairRelation p F B := + (hgood n).mono fun z hz ↦ (cappedPairRelation_iff p F B z.1 z.2).mpr hz + exact ae_iff.mp hg + have hg : ∀ᵐ z ∂(ν : Measure (X × X)), z ∈ cappedPairRelation p F B := ae_iff.mpr hr + exact hg.mono fun z hz ↦ (cappedPairRelation_iff p F B z.1 z.2).mp hz + +end + +open MeasureTheory Set +open scoped ComplexConjugate + +lemma cappedDiagonal_apply_of_bound {X : Type uX} (F : ℤ → X → ℝ) (hF : ∀ k x, 0 < F k x) + (B : ℝ≥0) (x y : X) (hb : ∀ k, F k y/F k x ≤ B) (v : FiberHilbert) (k : ℤ) : + cappedDiagonal F B x y v k=(F k y/F k x:ℝ)*v k := by + change (cappedRatio F B x y k:ℂ)*v k=_ + rw [cappedRatio,max_eq_right (div_pos (hF k y) (hF k x)).le,min_eq_right (hb k)] + +lemma positive_orbit_capped_pair {X : Type uX} (F : ℤ → X → ℝ) (hF : ∀ k x,0 < F k x) + (hmono : ∀ x,Antitone (fun k => F k x)) (x y : X) (n : ℕ) + (hrel : ∀ k, F (k+n) x=F k y*F n x) + (p q : FiberOperator) (hp : IsStarProjection p) + (hinv : (1-p)*fiberCocycleShift (fun k => F k x) (fun k => hF k x) (hmono x)*p=0) + (hcov : p*(fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap= + (fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap*q) + (B : ℝ≥0) (hb : ∀ k,F k y/F k x ≤ B) : + (1-q)*cappedDiagonal F B x y*p=0 := by + have he (v : FiberHilbert) : fiberShift n (cappedDiagonal F B x y v)= + ((F n x)⁻¹:ℂ) • (fiberCocycleShift (fun k => F k x) (fun k => hF k x) (hmono x)^n) v := by + apply lp.ext + funext k + rw [fiberShift_apply,cappedDiagonal_apply_of_bound F hF B x y hb,lp.coeFn_smul,Pi.smul_apply,smul_eq_mul, + fiberCocycleShift_pow_apply] + have hr := hrel (k-n) + rw [sub_add_cancel] at hr + rw [hr] + push_cast + field_simp [Complex.ofReal_ne_zero.mpr (hF (n:ℤ) x).ne', Complex.ofReal_ne_zero.mpr (hF (k-n) x).ne'] + apply ContinuousLinearMap.ext + intro v + change cappedDiagonal F B x y (p v)-q (cappedDiagonal F B x y (p v))=0 + apply sub_eq_zero.mpr + apply (fiberShift n).injective + have hv : p (p v)=p v := by + have h := congrArg (fun A : FiberOperator => A v) hp.isIdempotentElem + exact h + have hfix := invariant_fixed_vector_pow hinv hv n + have hc := congrArg (fun A : FiberOperator => A (cappedDiagonal F B x y (p v))) hcov + change p (fiberShift n (cappedDiagonal F B x y (p v)))= + fiberShift n (q (cappedDiagonal F B x y (p v))) at hc + rw [he,map_smul,hfix] at hc + exact (he (p v)).trans hc +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/LaurentCoefficients.lean b/lean/OAI/Analysis/RotationWeights/LaurentCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..64cc4fbdabb08fc85d5f551b1ce96daee545afea --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/LaurentCoefficients.lean @@ -0,0 +1,325 @@ +import OAI.Analysis.RotationWeights.TailBounds + +namespace OAI + +noncomputable section + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal + +namespace ContinuousCircleWeight + +section +open MeasureTheory +open scoped ENNReal + +lemma fiber_squares (ξ : FiberHilbert) : (∑' i,‖ξ i‖ₑ^2)=ENNReal.ofReal (‖ξ‖^2) := by + have hs : HasSum (fun i => ‖ξ i‖^2) (‖ξ‖^2) := by + simpa using lp.hasSum_norm (show (0:ℝ)<(2:ℝ≥0∞).toReal by norm_num) ξ + rw [←hs.tsum_eq,ENNReal.ofReal_tsum_of_nonneg (fun i => sq_nonneg _) hs.summable] + apply tsum_congr + intro i + rw [ENNReal.ofReal_pow (norm_nonneg _),ofReal_norm] +lemma fiber_squares_le {ξ : FiberHilbert} (hξ : ‖ξ‖ ≤ 1) : (∑' i,‖ξ i‖ₑ^2) ≤ 1 := by + rw [fiber_squares] + have hh : ‖ξ‖^2 ≤ (1:ℝ) := by nlinarith [norm_nonneg ξ] + exact (ENNReal.ofReal_le_ofReal hh).trans_eq (by simp) +lemma fiber_product_le {ξ η : FiberHilbert} (hξ : ‖ξ‖ ≤ 1) (hη : ‖η‖ ≤ 1) : + (∑' i,‖ξ i‖ₑ*‖η i‖ₑ) ≤ 1 := by + have hc : (2:ℝ≥0∞).toReal.HolderConjugate (2:ℝ≥0∞).toReal := by norm_num [Real.holderConjugate_iff] + have hh := lp.tsum_mul_le_mul_norm hc ξ η + have ht : ∑' i,‖ξ i‖*‖η i‖ ≤ 1 := hh.2.trans (by nlinarith [norm_nonneg ξ,norm_nonneg η]) + have he : (∑' i,‖ξ i‖ₑ*‖η i‖ₑ)=ENNReal.ofReal (∑' i,‖ξ i‖*‖η i‖) := by + rw [ENNReal.ofReal_tsum_of_nonneg (fun i => mul_nonneg (norm_nonneg _) (norm_nonneg _)) hh.1] + simp only [ENNReal.ofReal_mul (norm_nonneg _),ofReal_norm] + rw [he] + exact (ENNReal.ofReal_le_ofReal ht).trans_eq (by simp) +lemma projection_vector_norm (q : FiberOperator) (hq : IsStarProjection q) (k : ℤ) : + ‖q (lp.single 2 k 1)‖ ≤ 1 := by + have hh := q.le_opNorm (lp.single 2 k 1) + have he : ‖(lp.single 2 k (1:ℂ):FiberHilbert)‖=1 := by simp + rw [he,mul_one] at hh + exact hh.trans (hq.norm_le q) +end + +open scoped BigOperators + +def laurentArray (K : ℕ) (a : ℤ → ℂ) (i : Fin (2*K+1)) : ℂ := a ((i.val:ℤ)-(K:ℤ)) +def retainedIndices (K n : ℕ) : Finset ℤ := Finset.Icc (-(K:ℤ)) ((K:ℤ)-(n:ℤ)) +lemma mem_retainedIndices (K n : ℕ) (v : ℤ) : v∈retainedIndices K n ↔ |v| ≤ (K:ℤ) ∧ |(n:ℤ)+v| ≤ (K:ℤ) := by + simp only [retainedIndices,Finset.mem_Icc,abs_le] + omega +lemma laurent_coeff (K : ℕ) (a : ℤ → ℂ) (i : ℕ) (hi : i ≤ 2*K) : + (shiftedPolynomial K (laurentArray K a)).coeff i=a ((i:ℤ)-(K:ℤ)) := by + exact coeff_shiftedPolynomial K (laurentArray K a) ⟨i,by omega⟩ +lemma lowProduct_convolution (K : ℕ) (a b : ℤ → ℂ) (t : Fin (2*K+1)) : + lowProduct K (laurentArray K a,laurentArray K b) t = + ∑ v∈retainedIndices K (2*K-t.val), a v*b (-((2*K-t.val:ℕ):ℤ)-v) := by + classical + unfold lowProduct + rw [Polynomial.coeff_mul,Finset.Nat.sum_antidiagonal_eq_sum_range_succ_mk] + have ht := t.isLt + have hs : (∑ i∈Finset.range (t.val+1), + (shiftedPolynomial K (laurentArray K a)).coeff i*(shiftedPolynomial K (laurentArray K b)).coeff (t.val-i)) = + ∑ i∈Finset.range (t.val+1), a ((i:ℤ)-(K:ℤ))*b (((t.val-i:ℕ):ℤ)-(K:ℤ)) := by + apply Finset.sum_congr rfl + intro i hi + have hh := Finset.mem_range.mp hi + rw [laurent_coeff K a i (by omega),laurent_coeff K b (t.val-i) (by omega)] + rw [hs] + apply Finset.sum_bij (fun (i:ℕ) _ => (i:ℤ)-(K:ℤ)) + · intro i hi + simp only [retainedIndices,Finset.mem_Icc] + have hh := Finset.mem_range.mp hi + omega + · intro i hi k hk he + omega + · intro v hv + have hv' := Finset.mem_Icc.mp hv + refine ⟨(v+(K:ℤ)).toNat,?_,?_⟩ + · simp only [Finset.mem_range] + omega + · omega + · intro i hi + have hh := Finset.mem_range.mp hi + congr 2 + omega +end ContinuousCircleWeight + +namespace CircleSampling + +section + +section +open MeasureTheory Set Filter ContinuousCircleWeight +open scoped Topology ENNReal ComplexInnerProductSpace BigOperators +local instance : MeasurableSpace FiberHilbert := borel FiberHilbert +local instance : BorelSpace FiberHilbert := ⟨rfl⟩ + +def modelColumn (P : ModelProjectionField) (x : CircleX) : FiberHilbert := P.p x (lp.single 2 0 1) +def modelComplement (P : ModelProjectionField) (x : CircleX) : FiberHilbert := (1-P.p x) (lp.single 2 0 1) +def modelDiagonal (P : ModelProjectionField) (x : CircleX) : ℝ := (modelColumn P x 0).re +lemma modelColumn_norm (P : ModelProjectionField) (x : CircleX) : ‖modelColumn P x‖ ≤ 1 := projection_vector_norm _ (P.projection x) 0 +lemma modelComplement_norm (P : ModelProjectionField) (x : CircleX) : ‖modelComplement P x‖ ≤ 1 := projection_vector_norm _ (P.projection x).one_sub 0 +lemma modelColumn_measurable (P : ModelProjectionField) : Measurable (modelColumn P) := P.measurable 0 +lemma modelComplement_measurable (P : ModelProjectionField) : Measurable (modelComplement P) := + (measurable_const.sub (modelColumn_measurable P) : Measurable (fun x => (lp.single 2 0 1: FiberHilbert)-modelColumn P x)) +lemma modelColumn_coordinate (P : ModelProjectionField) (k : ℤ) : Measurable (fun x => modelColumn P x k) := + (lp.evalCLM ℂ (fun _ : ℤ => ℂ) (2:ℝ≥0∞) k).continuous.measurable.comp (modelColumn_measurable P) +lemma modelComplement_coordinate (P : ModelProjectionField) (k : ℤ) : Measurable (fun x => modelComplement P x k) := + (lp.evalCLM ℂ (fun _ : ℤ => ℂ) (2:ℝ≥0∞) k).continuous.measurable.comp (modelComplement_measurable P) +lemma modelDiagonal_measurable (P : ModelProjectionField) : Measurable (modelDiagonal P) := (modelColumn_coordinate P 0).re + +def modelTerm (P : ModelProjectionField) (n : ℕ) (v : ℤ) (ω : ActualSamples) : ℂ := + (modelF ((n:ℤ)+v) (lastEndpoint ω)/modelF v (firstEndpoint ω):ℝ)*modelColumn P (firstEndpoint ω) v*starRingEnd ℂ (modelComplement P (lastEndpoint ω) ((n:ℤ)+v)) +def modelRetained (P : ModelProjectionField) (j n : ℕ) (ω : ActualSamples) : ℂ := + ∑ v∈retainedIndices (polynomialWindow j) n,modelTerm P n v ω +lemma modelTerm_measurable (P : ModelProjectionField) (n : ℕ) (v : ℤ) : Measurable (modelTerm P n v) := by + exact (((((modelF_measurable _).comp lastEndpoint_measurable).div + ((modelF_measurable v).comp firstEndpoint_measurable)).complex_ofReal.mul + ((modelColumn_coordinate P v).comp firstEndpoint_measurable)).mul + (Complex.continuous_conj.measurable.comp ((modelComplement_coordinate P _).comp lastEndpoint_measurable))) + +lemma modelRetained_measurable (P : ModelProjectionField) (j n : ℕ) : Measurable (modelRetained P j n) := + Finset.measurable_sum _ (fun v _ => modelTerm_measurable P n v) + +lemma regular_model_order {ω : ActualSamples} (hω : ω∈regularSamples) (k : ℤ) : + modelF k (lastEndpoint ω) ≤ modelF k (firstEndpoint ω) := + (div_le_one (modelF_pos _ _)).mp (modelF_ratio_ordered hω.2.1 hω.2.2.1 (regular_order hω) k) +lemma model_pair_convolution (P : ModelProjectionField) {ω : ActualSamples} (hω : ω∈regularSamples) + (hpair : (1-P.p (lastEndpoint ω))*cappedDiagonal modelF 1 (firstEndpoint ω) (lastEndpoint ω)*P.p (firstEndpoint ω)=0) + (hinv : (1-P.p (lastEndpoint ω))*fiberCocycleShift (fun k => modelF k (lastEndpoint ω)) + (fun k => modelF_pos k (lastEndpoint ω)) (modelF_antitone (lastEndpoint ω))*P.p (lastEndpoint ω)=0) (n : ℕ) : + Summable (fun v => modelTerm P n v ω) ∧ (∑' v,modelTerm P n v ω)=0 := by + let x := firstEndpoint ω + let y := lastEndpoint ω + have ho : ∀ k,modelF k y ≤ modelF k x := regular_model_order hω + have hd : cappedDiagonal modelF 1 x y=cocycleRatioDiagonal (fun k => modelF k x) (fun k => modelF k y) + (fun k => modelF_pos k x) (fun k => modelF_pos k y) ho := by + ext u k + rw [cappedDiagonal_apply_of_bound modelF modelF_pos 1 x y (fun k => (div_le_one (modelF_pos _ _)).mpr (ho k)),cocycleRatioDiagonal_apply] + have hf : P.p y (cocycleRatioDiagonal (fun k => modelF k x) (fun k => modelF k y) + (fun k => modelF_pos k x) (fun k => modelF_pos k y) ho (modelColumn P x))= + cocycleRatioDiagonal (fun k => modelF k x) (fun k => modelF k y) + (fun k => modelF_pos k x) (fun k => modelF_pos k y) ho (modelColumn P x) := by + have hh := congrArg (fun A : FiberOperator => A (lp.single 2 0 1)) hpair + change cappedDiagonal modelF 1 x y (modelColumn P x)-P.p y (cappedDiagonal modelF 1 x y (modelColumn P x))=0 at hh + rw [hd] at hh + exact (sub_eq_zero.mp hh).symm + exact fiber_full_convolution (fun k => modelF k x) (fun k => modelF k y) (fun k => modelF_pos k x) + (fun k => modelF_pos k y) (modelF_antitone y) ho (P.p y) (P.projection y) hinv (modelColumn P x) (lp.single 2 0 1) hf n +lemma model_convolution_ae (P : ModelProjectionField) (j : ℕ) : + ∀ᵐ ω ∂actualSystem.probability (stageTagged j),ω∈regularSamples ∧ ∀ n : ℕ, + Summable (fun v => modelTerm P n v ω) ∧ (∑' v,modelTerm P n v ω)=0 := by + have hi : ∀ᵐ ω ∂actualSystem.probability (stageTagged j), + (1-P.p (lastEndpoint ω))*fiberCocycleShift (fun k => modelF k (lastEndpoint ω)) (fun k => modelF_pos k (lastEndpoint ω)) (modelF_antitone (lastEndpoint ω))*P.p (lastEndpoint ω)=0 := + ae_of_ae_map lastEndpoint_measurable.aemeasurable ((actualSystem.hybrid_ac (stageTagged j) (fun _ => true) (summable_actual_error j)).ae_le P.invariant) + filter_upwards [ae_regularSamples j,actual_pair_identity P j,hi] with ω hω hp hi + exact ⟨hω,fun n => model_pair_convolution P hω hp hi n⟩ + +def modelCoefficientPair (P : ModelProjectionField) (j : ℕ) (ω : ActualSamples) : CoefficientPair (polynomialWindow j) := + (laurentArray (polynomialWindow j) (fun v => (1/modelF v (firstEndpoint ω):ℝ)*modelColumn P (firstEndpoint ω) v), + laurentArray (polynomialWindow j) (fun v => (modelF (-v) (lastEndpoint ω):ℂ)*starRingEnd ℂ (modelComplement P (lastEndpoint ω) (-v)))) +lemma modelCoefficient_identity (P : ModelProjectionField) (j : ℕ) (ω : ActualSamples) (t : Fin (2*polynomialWindow j+1)) : + lowProduct (polynomialWindow j) (modelCoefficientPair P j ω) t=modelRetained P j (2*polynomialWindow j-t.val) ω := by + rw [modelCoefficientPair,lowProduct_convolution] + apply Finset.sum_congr rfl + intro v _ + simp only [neg_sub,modelTerm] + push_cast + ring_nf +end + +open MeasureTheory Set Filter ContinuousCircleWeight +open scoped ENNReal ComplexInnerProductSpace BigOperators + +lemma modelColumn_coordinate_bound (P : ModelProjectionField) (x : CircleX) (v : ℤ) : + ‖modelColumn P x v‖ ≤ 1 := (lp.norm_apply_le_norm (by norm_num) _ _).trans (modelColumn_norm P x) +lemma modelComplement_coordinate_bound (P : ModelProjectionField) (x : CircleX) (v : ℤ) : + ‖modelComplement P x v‖ ≤ 1 := (lp.norm_apply_le_norm (by norm_num) _ _).trans (modelComplement_norm P x) +lemma modelComplement_zero_re (P : ModelProjectionField) (x : CircleX) : + (modelComplement P x 0).re=1-modelDiagonal P x := by + change (((lp.single 2 0 1: FiberHilbert)-modelColumn P x) 0).re=_ + simp [modelDiagonal] + +lemma modelCoefficient_bounds (P : ModelProjectionField) (j : ℕ) {ω : ActualSamples} + (hω : ω∈regularSamples) (he : ω∈projectionEvent (modelDiagonal P) j) : + (∀ i,‖(modelCoefficientPair P j ω).1 i‖ ≤ coefficientCap j) ∧ + (∀ i,‖(modelCoefficientPair P j ω).2 i‖ ≤ coefficientCap j) := by + constructor + · intro i + have hi : |(i.val:ℤ)-(polynomialWindow j:ℤ)| ≤ (polynomialWindow j:ℤ) := by + rw [abs_le]; have hh := i.isLt; omega + have hh := (event_window_bounds j hω he _ hi).1 + change ‖((1/modelF _ (firstEndpoint ω):ℝ):ℂ)*modelColumn P (firstEndpoint ω) _‖ ≤ _ + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs,abs_of_pos (one_div_pos.mpr (modelF_pos _ _))] + exact (mul_le_mul_of_nonneg_left (modelColumn_coordinate_bound P _ _) ((one_div_pos.mpr (modelF_pos _ _)).le)).trans (by simpa using hh) + · intro i + have hi : |(i.val:ℤ)-(polynomialWindow j:ℤ)| ≤ (polynomialWindow j:ℤ) := by + rw [abs_le]; have hh := i.isLt; omega + have hh := (event_window_bounds j hω he _ hi).2 + change ‖(modelF _ (lastEndpoint ω):ℂ)*starRingEnd ℂ (modelComplement P (lastEndpoint ω) _)‖ ≤ _ + rw [norm_mul,Complex.norm_conj,Complex.norm_real,Real.norm_eq_abs,abs_of_pos (modelF_pos _ _)] + exact (mul_le_mul_of_nonneg_left (modelComplement_coordinate_bound P _ _) (modelF_pos _ _).le).trans (by simpa using hh) + +lemma modelCoefficient_centers (P : ModelProjectionField) (j : ℕ) {ω : ActualSamples} + (he : ω∈projectionEvent (modelDiagonal P) j) : + 1/((j:ℝ)+1) ≤ ‖(modelCoefficientPair P j ω).1 (centerIndex (polynomialWindow j))‖ ∧ + 1/((j:ℝ)+1) ≤ ‖(modelCoefficientPair P j ω).2 (centerIndex (polynomialWindow j))‖ := by + have hh := projectionEvent_mem he + have ha : (modelCoefficientPair P j ω).1 (centerIndex (polynomialWindow j))=modelColumn P (firstEndpoint ω) 0 := by + simp [modelCoefficientPair,laurentArray,centerIndex,modelF_zero] + have hb : (modelCoefficientPair P j ω).2 (centerIndex (polynomialWindow j))=starRingEnd ℂ (modelComplement P (lastEndpoint ω) 0) := by + simp [modelCoefficientPair,laurentArray,centerIndex,modelF_zero] + rw [ha,hb,Complex.norm_conj] + exact ⟨hh.2.2.2.1.trans (Complex.re_le_norm _),hh.2.2.2.2.trans (by rw [←modelComplement_zero_re]; exact Complex.re_le_norm _)⟩ + +lemma model_coefficient_lower (P : ModelProjectionField) (j : ℕ) {ω : ActualSamples} + (hω : ω∈regularSamples) (he : ω∈projectionEvent (modelDiagonal P) j) : + ∃ t : Fin (2*polynomialWindow j+1), (scaleStep j).ε ≤ ‖modelRetained P j (2*polynomialWindow j-t.val) ω‖ := by + have hb := modelCoefficient_bounds P j hω he + have hc := modelCoefficient_centers P j he + obtain ⟨t,ht⟩ := (scaleStep j).coefficients (modelCoefficientPair P j ω) hb.1 hb.2 hc.1 hc.2 + change Fin (2*polynomialWindow j+1) at t + change (scaleStep j).ε ≤ ‖lowProduct (polynomialWindow j) (modelCoefficientPair P j ω) t‖ at ht + rw [modelCoefficient_identity] at ht + exact ⟨t,ht⟩ +end + +open MeasureTheory Set Filter CircleCoupling CircleDigits +open scoped ENNReal + +lemma all_masks (j : ℕ) (k : ℤ) (hk : (polynomialWindow j:ℝ)< |(k:ℝ)|) : + ∃ H₁ H₂ : Set ActualSamples,MeasurableSet H₁ ∧ MeasurableSet H₂ ∧ + Measure.map firstEndpoint ((actualSystem.probability (stageTagged j)).restrict H₁) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map firstEndpoint (actualSystem.probability (stageTagged j)) ∧ + Measure.map lastEndpoint ((actualSystem.probability (stageTagged j)).restrict H₂) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map lastEndpoint (actualSystem.probability (stageTagged j)) ∧ + ∀ ω∈regularSamples,ω∈stageTagEvent j → ω∉H₁ → ω∉H₂ → modelF k (lastEndpoint ω)/modelF k (firstEndpoint ω) ≤ Real.exp (-crossingBudget j) := by + by_cases hh : blockScale j/4< |(k:ℝ)| + · obtain ⟨H₁,H₂,hm₁,hm₂,hd₁,hd₂,hc⟩ := large_masks j k hh + exact ⟨H₁,H₂,hm₁,hm₂,hd₁,hd₂,fun ω hω _ h₁ h₂ => hc ω hω h₁ h₂⟩ + · refine ⟨∅,∅,MeasurableSet.empty,MeasurableSet.empty,by simp; exact bot_le,by simp; exact bot_le,?_⟩ + exact fun ω hω ht _ _ => short_ratio j k hk (le_of_not_gt hh) hω ht + +def longIndex (j n : ℕ) (v : ℤ) : ℤ := if (polynomialWindow j:ℤ)< |v| then v else (n:ℤ)+v +lemma longIndex_long (j n : ℕ) (v : ℤ) (hv : v∉ContinuousCircleWeight.retainedIndices (polynomialWindow j) n) : + (polynomialWindow j:ℝ)< |((longIndex j n v):ℝ)| := by + rw [ContinuousCircleWeight.mem_retainedIndices] at hv + have hh : (polynomialWindow j:ℤ)< |longIndex j n v| := by + unfold longIndex + split_ifs with h + · exact h + · push Not at hv + exact hv (le_of_not_gt h) + exact_mod_cast hh +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/LogarithmicDrops.lean b/lean/OAI/Analysis/RotationWeights/LogarithmicDrops.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd5737541d189bc6fd9a2576406f828be376be2e --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/LogarithmicDrops.lean @@ -0,0 +1,316 @@ +import OAI.Analysis.RotationWeights.ContinuousWeight + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uι + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators +open MeasureTheory Filter Set +open scoped Topology ENNReal BigOperators + +section +open CircleModel CircleRounding CircleConcentration ContinuousCircleWeight +open Set Filter MeasureTheory +open scoped Topology BigOperators ENNReal + +def roundingWidth (j : ℕ) : ℝ := 1/(10*(blockLength j:ℝ)*polynomialWindow j) +lemma roundingWidth_pos (j : ℕ) : 0 concentratedDrop_continuous j i) +lemma blockH_nonneg (j : ℕ) (x : CircleModel.CircleX) : 0 ≤ blockH j x := Finset.sum_nonneg (fun i _ => concentratedDrop_nonneg j i x) +lemma blockW_measurable (j : ℕ) : Measurable (blockW j) := Finset.measurable_sum _ (fun i _ => totalCorrection_measurable j i) +lemma blockH_support (j : ℕ) (x : CircleModel.CircleX) (hx : supportRadius modelAngle j≤dist x 0) : blockH j x=0 := + Finset.sum_eq_zero (fun _i _ => movedDrop_zero_off _ _ _ _ hx) +lemma blockH_locallyFinite : LocallyFiniteOff blockH 0 := by + apply locallyFiniteOff_of_shrinking_supports blockH 0 (supportRadius modelAngle) _ blockH_support + apply supportRadius_tendsto + rw [←denseRange_zsmul_iff_nsmul] + simpa only [div_one,modelAngle] using (AddCircle.denseRange_zsmul_coe_iff (p := (1:ℝ))).mpr (by simpa using parameterAngle_spec.2.2.1) + +lemma smoothDrop_coboundary (j : ℕ) (i : Fin (blockLength j)) (x : CircleModel.CircleX) : + smoothDrop j i x-integerDrop j i x=smoothCorrection j i (x+modelAngle)-smoothCorrection j i x := by + have hp := phase_orbit (blocks.equiv ⟨j,i⟩) 1 + simp only [one_smul,Int.cast_one,one_mul] at hp + unfold smoothDrop integerDrop smoothCorrection floorTerm + rw [model_beta] + simp only [Int.cast_one,one_mul] + change roundedDrop _ _ _ _ - dropSize j * (⌊CircleRounding.repr _+_⌋:ℝ)=_ + rw [roundedDrop_coboundary,nsmul_add,hp] +lemma totalCorrection_coboundary (j : ℕ) (i : Fin (blockLength j)) (x : CircleModel.CircleX) : + concentratedDrop j i x-integerDrop j i x=totalCorrection j i (x+modelAngle)-totalCorrection j i x := by + have h1 := smoothDrop_coboundary j i x + have h2 := moveCorrection_coboundary modelAngle j (smoothDrop j i) x + unfold totalCorrection concentratedDrop + linarith +lemma block_coboundary (j : ℕ) (x : CircleModel.CircleX) : + blockH j x-blockG j x=blockW j (x+modelAngle)-blockW j x := by + unfold blockH blockG blockW + simp only [←Finset.sum_sub_distrib,totalCorrection_coboundary] + +lemma smoothDrop_zero (j : ℕ) (i : Fin (blockLength j)) : smoothDrop j i 0=dropSize j/2 := by + unfold smoothDrop + rw [smul_zero] + exact roundedDrop_zero (roundingWidth_pos j) (roundingWidth_lt_one j) (phase_width_bounds j i).1 (phase_width_bounds j i).2 _ +lemma blockH_zero_lower (j : ℕ) : (blockLength j:ℝ)*dropSize j/(2*((j:ℝ)+1))≤blockH j 0 := by + calc + _ = ∑ _i : Fin (blockLength j),(dropSize j/2)/((j:ℝ)+1) := by simp; field_simp + _ ≤ _ := Finset.sum_le_sum (fun i _ => by + change _ ≤ movedDrop modelAngle j (smoothDrop j i) 0 + rw [←smoothDrop_zero j i] + exact movedDrop_zero_lower modelAngle j (smoothDrop_nonneg j i)) + +lemma smoothDrop_integral (j : ℕ) (i : Fin (blockLength j)) : + (∫ x : CircleModel.CircleX,smoothDrop j i x)=dropSize j*coordinatePhase (blocks.equiv ⟨j,i⟩) := by + have hm := measurePreserving_XiMap (q:=modelFrequency) (fun i => (frequency_pos (i+1)).ne') (blocks.equiv ⟨j,i⟩) + let f := roundedDrop (roundingWidth j) (coordinatePhase (blocks.equiv ⟨j,i⟩)) (dropSize j) + have hf : AEStronglyMeasurable f volume := (roundedDrop_continuous (roundingWidth_pos j) (roundingWidth_lt_one j) _ _).aestronglyMeasurable + calc + _ = ∫ x : CircleModel.CircleX,f x ∂Measure.map (fun x => modelFrequency (blocks.equiv ⟨j,i⟩) • x) volume := by + rw [integral_map hm.aemeasurable (by rwa [hm.map_eq])]; rfl + _ = ∫ x : CircleModel.CircleX,f x := by rw [hm.map_eq] + _ = _ := roundedDrop_integral (roundingWidth_pos j) (roundingWidth_lt_one j) _ _ +lemma blockH_integral_lower (j : ℕ) : (polynomialWindow j:ℝ)≤∫ x : CircleModel.CircleX,blockH j x := by + have he : (∫ x : CircleModel.CircleX,blockH j x)=∑ i : Fin (blockLength j),dropSize j*coordinatePhase (blocks.equiv ⟨j,i⟩) := by + unfold blockH + rw [integral_finsetSum _ (fun i _ => (concentratedDrop_continuous j i).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _))] + apply Finset.sum_congr rfl + intro i _ + exact (movedDrop_integral modelAngle j (smoothDrop_continuous j i)).trans (smoothDrop_integral j i) + rw [he] + simpa only [coordinateDrop,block_number_equiv] using phase_drop_block_lower j +end +open CircleModel CircleRounding CircleConcentration ContinuousCircleWeight +open Set Filter MeasureTheory +open scoped Topology BigOperators ENNReal + +lemma measure_nonzero_sum {ι : Type uι} [Fintype ι] (f : ι → CircleModel.CircleX → ℝ) : + volume {x | (∑ i,f i x)≠0} ≤ ∑ i,volume {x | f i x≠0} := by + classical + apply (measure_mono (show {x | (∑ i,f i x)≠0} ⊆ ⋃ i,{x | f i x≠0} from ?_)).trans (measure_iUnion_fintype_le _ _) + intro x hx + by_contra! hh + simp only [mem_iUnion,mem_ofPred_eq,not_exists,not_not] at hh + exact hx (Finset.sum_eq_zero (fun i _ => hh i)) +lemma measure_nonzero_add (f g : CircleModel.CircleX → ℝ) : + volume {x | f x+g x≠0}≤volume {x | f x≠0}+volume {x | g x≠0} := by + apply (measure_mono (show {x | f x+g x≠0}⊆{x | f x≠0}∪{x | g x≠0} from ?_)).trans (measure_union_le _ _) + intro x hx + by_contra! hh + simp only [mem_union,mem_ofPred_eq,not_or,not_not] at hh + exact hx (by rw [hh.1,hh.2,add_zero]) +lemma smoothCorrection_measure (j : ℕ) (i : Fin (blockLength j)) : + volume {x | smoothCorrection j i x≠0}≤ENNReal.ofReal (2*roundingWidth j) := by + have hm := measurePreserving_XiMap (q:=modelFrequency) (fun i => (frequency_pos (i+1)).ne') (blocks.equiv ⟨j,i⟩) + change volume ((fun x : CircleModel.CircleX => modelFrequency (blocks.equiv ⟨j,i⟩) • x) ⁻¹' {x | correction (roundingWidth j) (dropSize j) x≠0}) ≤ _ + have he := hm.measure_preimage ((correction_measurable (roundingWidth j) (dropSize j)) (measurableSet_singleton 0).compl).nullMeasurableSet + change volume ((fun x : CircleModel.CircleX => modelFrequency (blocks.equiv ⟨j,i⟩) • x) ⁻¹' {x | correction (roundingWidth j) (dropSize j) x≠0}) = _ at he + exact he.le.trans (correction_measure (roundingWidth_pos j)) +lemma smoothDrop_measure (j : ℕ) (i : Fin (blockLength j)) : + volume {x | smoothDrop j i x≠0}≤ENNReal.ofReal (coordinatePhase (blocks.equiv ⟨j,i⟩)+2*roundingWidth j) := by + have hm := measurePreserving_XiMap (q:=modelFrequency) (fun i => (frequency_pos (i+1)).ne') (blocks.equiv ⟨j,i⟩) + change volume ((fun x : CircleModel.CircleX => modelFrequency (blocks.equiv ⟨j,i⟩) • x) ⁻¹' {x | roundedDrop (roundingWidth j) (coordinatePhase (blocks.equiv ⟨j,i⟩)) (dropSize j) x≠0}) ≤ _ + have he := hm.measure_preimage (((roundedDrop_continuous (roundingWidth_pos j) (roundingWidth_lt_one j) (coordinatePhase (blocks.equiv ⟨j,i⟩)) (dropSize j)).measurable) (measurableSet_singleton 0).compl).nullMeasurableSet + change volume ((fun x : CircleModel.CircleX => modelFrequency (blocks.equiv ⟨j,i⟩) • x) ⁻¹' {x | roundedDrop (roundingWidth j) (coordinatePhase (blocks.equiv ⟨j,i⟩)) (dropSize j) x≠0}) = _ at he + exact he.le.trans (roundedDrop_measure (roundingWidth_pos j) (coordinatePhase_pos _).le) +lemma integerDrop_measure (j : ℕ) (i : Fin (blockLength j)) : + volume {x | integerDrop j i x≠0}≤ENNReal.ofReal (2*coordinatePhase (blocks.equiv ⟨j,i⟩)) := by + have hs : {x | integerDrop j i x≠0}⊆{x | floorTerm modelFrequency modelAngle 1 x (blocks.equiv ⟨j,i⟩)≠0} := by + intro x hx hh + exact hx (by simp [integerDrop,hh]) + apply (measure_mono hs).trans + simpa only [model_beta,Int.cast_one,abs_one,mul_one] using floorTerm_event_bound (q:=modelFrequency) (fun i => (frequency_pos (i+1)).ne') modelAngle 1 (blocks.equiv ⟨j,i⟩) +lemma totalCorrection_measure (j : ℕ) (i : Fin (blockLength j)) : + volume {x | totalCorrection j i x≠0}≤ENNReal.ofReal (2*roundingWidth j+(j:ℝ)*(coordinatePhase (blocks.equiv ⟨j,i⟩)+2*roundingWidth j)) := by + have hδ := (roundingWidth_pos j).le + have hβ := (coordinatePhase_pos (blocks.equiv ⟨j,i⟩)).le + calc + _ ≤ volume {x | smoothCorrection j i x≠0}+volume {x | moveCorrection modelAngle j (smoothDrop j i) x≠0} := measure_nonzero_add _ _ + _ ≤ ENNReal.ofReal (2*roundingWidth j)+(j:ℝ≥0∞)*ENNReal.ofReal (coordinatePhase (blocks.equiv ⟨j,i⟩)+2*roundingWidth j) := + add_le_add (smoothCorrection_measure j i) ((moveCorrection_measure modelAngle j (smoothDrop_continuous j i).measurable).trans (mul_le_mul_right (smoothDrop_measure j i) _)) + _ = _ := by + rw [←ENNReal.ofReal_natCast,←ENNReal.ofReal_mul (Nat.cast_nonneg j),←ENNReal.ofReal_add (by positivity : 0≤2*roundingWidth j) (by positivity)] + +lemma blockG_measure (j : ℕ) : volume {x | blockG j x≠0}≤ENNReal.ofReal (4/(polynomialWindow j:ℝ)) := by + calc + _ ≤ ∑ i : Fin (blockLength j),volume {x | integerDrop j i x≠0} := measure_nonzero_sum _ + _ ≤ ∑ i : Fin (blockLength j),ENNReal.ofReal (2*coordinatePhase (blocks.equiv ⟨j,i⟩)) := Finset.sum_le_sum (fun i _ => integerDrop_measure j i) + _ = ENNReal.ofReal (2*∑ i : Fin (blockLength j),coordinatePhase (blocks.equiv ⟨j,i⟩)) := by + rw [Finset.mul_sum,ENNReal.ofReal_sum_of_nonneg (fun i _ => mul_nonneg (by norm_num) (coordinatePhase_pos _).le)] + _ ≤ _ := ENNReal.ofReal_le_ofReal (by + calc + _ ≤ 2*(2/(polynomialWindow j:ℝ)) := mul_le_mul_of_nonneg_left (sum_phase_block j) (by norm_num) + _ = _ := by ring) +lemma blockW_measure (j : ℕ) : volume {x | blockW j x≠0}≤ENNReal.ofReal ((1+3*(j:ℝ))/(polynomialWindow j:ℝ)) := by + have hm : 0<(blockLength j:ℝ) := Nat.cast_pos.mpr (scaleStep j).mpos + have hK : 0<(polynomialWindow j:ℝ) := Nat.cast_pos.mpr (polynomialWindow_pos j) + have hs := sum_phase_block j + calc + _ ≤ ∑ i : Fin (blockLength j),volume {x | totalCorrection j i x≠0} := measure_nonzero_sum _ + _ ≤ ∑ i : Fin (blockLength j),ENNReal.ofReal (2*roundingWidth j+(j:ℝ)*(coordinatePhase (blocks.equiv ⟨j,i⟩)+2*roundingWidth j)) := Finset.sum_le_sum (fun i _ => totalCorrection_measure j i) + _ = ENNReal.ofReal (∑ i : Fin (blockLength j),(2*roundingWidth j+(j:ℝ)*(coordinatePhase (blocks.equiv ⟨j,i⟩)+2*roundingWidth j))) := + (ENNReal.ofReal_sum_of_nonneg (fun i _ => by have := (coordinatePhase_pos (blocks.equiv ⟨j,i⟩)).le; have := (roundingWidth_pos j).le; positivity)).symm + _ ≤ _ := by + apply ENNReal.ofReal_le_ofReal + simp only [mul_add,Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,←Finset.mul_sum] + have hn : (0:ℝ)≤j := Nat.cast_nonneg j + have hh := mul_le_mul_of_nonneg_left hs hn + have he : (blockLength j:ℝ)*(2*roundingWidth j)=1/(5*(polynomialWindow j:ℝ)) := by unfold roundingWidth; field_simp; ring + rw [show (blockLength j:ℝ)*((j:ℝ)*(2*roundingWidth j))=(j:ℝ)*((blockLength j:ℝ)*(2*roundingWidth j)) by ring,he] + calc + _ ≤ 1/(5*(polynomialWindow j:ℝ))+(j:ℝ)*(2/(polynomialWindow j:ℝ))+(j:ℝ)*(1/(5*(polynomialWindow j:ℝ))) := by linarith + _ = (1+11*(j:ℝ))/(5*(polynomialWindow j:ℝ)) := by ring + _ ≤ _ := (div_le_div_iff₀ (by positivity : 0<5*(polynomialWindow j:ℝ)) hK).mpr (by nlinarith) + +lemma summable_blockW_bound : Summable (fun j : ℕ => (1+3*(j:ℝ))/(polynomialWindow j:ℝ)) := by + have hgeom : Summable (fun j : ℕ => (j:ℝ)*(1/2:ℝ)^j) := by + simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_one 1 (by norm_num : ‖(1/2:ℝ)‖<1) + have hs : Summable (fun j : ℕ => (1+3*(j:ℝ))*((1/(polynomialWindow 0:ℝ))*(1/2:ℝ)^j)) := by + have h1 := (summable_geometric_of_norm_lt_one (by norm_num : ‖(1/2:ℝ)‖<1)).mul_left (1/(polynomialWindow 0:ℝ)) + have h2 := hgeom.mul_left (3/(polynomialWindow 0:ℝ)) + apply (h1.add h2).congr + intro j + ring + apply Summable.of_nonneg_of_le (fun j => by positivity) _ hs + intro j + have hh := mul_le_mul_of_nonneg_left (window_inverse_bound 0 j) (show 0≤1+3*(j:ℝ) by positivity) + simpa only [Nat.zero_add,mul_one_div] using hh +lemma blockG_support_sum : (∑' j,volume {x | blockG j x≠0})≠∞ := by + apply ne_of_lt ((ENNReal.tsum_le_tsum blockG_measure).trans_lt _) + have hs : Summable (fun j : ℕ => 4/(polynomialWindow j:ℝ)) := by + simpa only [Nat.zero_add,mul_one_div] using (summable_window_inverse 0).mul_left 4 + rw [←ENNReal.ofReal_tsum_of_nonneg (fun j => by positivity) hs] + exact ENNReal.ofReal_lt_top +lemma blockW_support_sum : (∑' j,volume {x | blockW j x≠0})≠∞ := by + apply ne_of_lt ((ENNReal.tsum_le_tsum blockW_measure).trans_lt _) + rw [←ENNReal.ofReal_tsum_of_nonneg (fun j => by positivity) summable_blockW_bound] + exact ENNReal.ofReal_lt_top + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Main.lean b/lean/OAI/Analysis/RotationWeights/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..69f65730a76acd65900642806d75214f12663493 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Main.lean @@ -0,0 +1,293 @@ +import OAI.Analysis.RotationWeights.LogarithmicDrops + +namespace OAI + +noncomputable section + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators +open MeasureTheory Filter Set +open scoped Topology ENNReal BigOperators +namespace CircleSampling + +section +open CircleModel CircleRounding CircleConcentration ContinuousCircleWeight +open Set Filter MeasureTheory +open scoped Topology BigOperators ENNReal + +lemma blockLength_ge_index (j : ℕ) : j+1≤blockLength j := by + induction j with + | zero => exact (by norm_num : 1≤200).trans (blockLength_ge 0) + | succ j ih => exact (by omega : j+1+1 ≤ blockLength j+1).trans (blockLength_strictMono (Nat.lt_succ_self j)) +lemma blockH_zero_half (j : ℕ) : (1/2:ℝ)≤blockH j 0 := by + have hm : (j:ℝ)+1≤blockLength j := by exact_mod_cast blockLength_ge_index j + have hK : (1:ℝ)≤polynomialWindow j := by exact_mod_cast polynomialWindow_pos j + have hc : 1≤dropSize j := by nlinarith [dropSize_ge_window_sq j] + have hj : 0<(j:ℝ)+1 := by positivity + calc + _ ≤ (blockLength j:ℝ)*dropSize j/(2*((j:ℝ)+1)) := by + apply (le_div_iff₀ (by positivity)).mpr + nlinarith [mul_le_mul hm hc (by positivity) (by positivity)] + _ ≤ _ := blockH_zero_lower j +lemma blockH_diverges_zero : ∀ B : ℝ, ∃ s : Finset ℕ,B<∑ j∈s,blockH j 0 := by + intro B + obtain ⟨N,hN⟩ := exists_nat_gt (2*B) + refine ⟨Finset.range N,?_⟩ + calc + B < (N:ℝ)*(1/2) := by linarith + _ = ∑ _j∈Finset.range N,(1/2:ℝ) := by simp + _ ≤ _ := Finset.sum_le_sum (fun j _ => blockH_zero_half j) + +def finalWeight : C(CircleModel.CircleX,ℝ) := + ⟨concentratedWeight blockH 0,continuous_concentratedWeight blockH 0 blockH_continuous blockH_nonneg blockH_locallyFinite blockH_diverges_zero⟩ +lemma finalWeight_bounds (x : CircleModel.CircleX) : 0 ≤ finalWeight x ∧ finalWeight x≤1 := + concentratedWeight_bounds _ _ blockH_nonneg x +lemma finalWeight_zero (x : CircleModel.CircleX) : finalWeight x=0 ↔ x=0 := concentratedWeight_eq_zero _ _ _ +lemma finalWeight_log : (∫⁻ x : CircleModel.CircleX,negativeLog (finalWeight x))=∞ := by + change (∫⁻ x : CircleModel.CircleX,negativeLog (concentratedWeight blockH 0 x))=_ + rw [lintegral_negativeLog_concentratedWeight volume blockH 0 blockH_continuous blockH_nonneg blockH_locallyFinite blockH_diverges_zero] + apply top_unique + calc + ∞ = ∑' _j : ℕ,(1:ℝ≥0∞) := (ENNReal.tsum_const_eq_top_of_ne_zero one_ne_zero).symm + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro j + have hi : Integrable (blockH j) (volume : Measure CircleModel.CircleX) := (blockH_continuous j).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + rw [←ofReal_integral_eq_lintegral_ofReal hi (Eventually.of_forall (blockH_nonneg j))] + rw [←ENNReal.ofReal_one] + apply ENNReal.ofReal_le_ofReal + have hK : (1:ℝ)≤polynomialWindow j := by exact_mod_cast polynomialWindow_pos j + exact hK.trans (blockH_integral_lower j) +lemma blockG_exponent {x : CircleModel.CircleX} (hx : x∈modelGood) : + (∑' j,blockG j x)=exponent modelFrequency modelAngle coordinateDrop 1 x := by + let f : ℕ → ℝ := fun i => coordinateDrop i*(floorTerm modelFrequency modelAngle 1 x i:ℝ) + have hs : Summable f := summable_exponent coordinateDrop 1 hx + calc + _ = ∑' j,∑' i : Fin (blocks.m j),f (blocks.equiv ⟨j,i⟩) := by + apply tsum_congr + intro j + rw [tsum_fintype] + apply Finset.sum_congr rfl + intro i _ + change dropSize j*_ = dropSize (coordinateBlock (blocks.equiv ⟨j,i⟩))*_ + rw [block_number_equiv] + _ = ∑' ji : Σ j,Fin (blocks.m j),f (blocks.equiv ji) := (blocks.equiv.summable_iff.mpr hs).tsum_sigma.symm + _ = _ := blocks.equiv.tsum_eq f +lemma finalWeight_coboundary : ∃ a : CircleModel.CircleX → ℝ, Measurable a ∧ (∀ x,0 x+modelAngle) (measurePreserving_add_right volume modelAngle) blockH blockG blockW 0 h0 + blockW_measurable blockG_support_sum blockW_support_sum (Eventually.of_forall (fun x j => block_coboundary j x)) + refine ⟨a,ham,hapos,?_⟩ + filter_upwards [ha,model_good_ae] with x hax hx + change concentratedWeight blockH 0 x=_ + rw [hax,blockG_exponent hx] + simp only [modelWeight,modelF,cocycle,ite_eq_left (show x ∈ good modelFrequency modelAngle from hx)] +end + +open MeasureTheory Set Filter ContinuousCircleWeight +open scoped ComplexInnerProductSpace ENNReal +local instance : MeasurableSpace FiberHilbert := borel FiberHilbert +local instance : BorelSpace FiberHilbert := ⟨rfl⟩ + +def modelBorel : RealBorel where + f := modelWeight + measurable := modelF_measurable 1 + bound := 1 + norm_le x := by + simpa only [Real.norm_eq_abs,abs_of_pos (modelWeight_bounds x).1,NNReal.coe_one] using (modelWeight_bounds x).2 + +lemma modelBorel_field (x : CircleX) : borelWeightedField modelAngle modelBorel x= + fiberCocycleShift (fun k => modelF k x) (fun k => modelF_pos k x) (modelF_antitone x) := by + ext u k + change fiberShift 1 (realPiField modelAngle modelBorel x u) k=_ + rw [fiberShift_apply,realPiField_apply,fiberCocycleShift_apply] + congr 1 + apply congrArg Complex.ofReal + change modelF 1 (x+(k-1)•modelAngle)=modelF k x/modelF (k-1) x + apply (eq_div_iff (ne_of_gt (modelF_pos _ _))).mpr + simpa only [CircleModel.shift,sub_add_cancel] using (modelF_add (k-1) 1 x).symm + +lemma modelAngle_ergodic : Ergodic (fun x : CircleX => x+modelAngle) AddCircle.haarAddCircle := by + rw [Sampling.haarAddCircle_one_eq_volume] + apply AddCircle.ergodic_add_right.mpr + apply AddCircle.denseRange_zsmul_iff.mp + simpa only [div_one,modelAngle] using (AddCircle.denseRange_zsmul_coe_iff (p:=(1:ℝ))).mpr (by simpa using parameterAngle_spec.2.2.1) + +theorem modelOperator_no_projection (p : CircleFiberOperator) (hp : IsStarProjection p) + (hcomm : ∀ B∈fiberCommutant parameterAngle,Commute p B) + (hinv : (1-p)*(fiberShiftL2 1*realPi modelAngle modelBorel)*p=0) : p=0 ∨ p=1 := by + by_cases hp0 : p=0 + · exact Or.inl hp0 + by_cases hp1 : p=1 + · exact Or.inr hp1 + exfalso + obtain ⟨P,hPproj,hPbound,hPmeas,hP,hcov⟩ := extract_projection_field parameterAngle p hp hcomm + let Q : ModelProjectionField := + { p := P + projection := hPproj + norm_le := hPbound + measurable := hPmeas + invariant := by + have h := decomposable_invariant p P hP modelAngle modelBorel hinv + simpa only [Sampling.haarAddCircle_one_eq_volume,modelBorel_field] using h + covariance := by + intro n + simpa only [Sampling.haarAddCircle_one_eq_volume,CircleModel.shift,modelAngle] using hcov n } + apply model_no_strict_projection Q + have hs := borel_invariant_diagonal_strict parameterAngle modelAngle_ergodic p P hP hPproj hcov modelBorel + (fun x => ne_of_gt (modelWeight_bounds x).1) hinv hp0 hp1 + simpa only [Sampling.haarAddCircle_one_eq_volume,lp.inner_single_left,RCLike.inner_apply,map_one,mul_one, + modelDiagonal,modelColumn,Q] using hs + +theorem continuousOperator_no_projection (p : CircleFiberOperator) (hp : IsStarProjection p) + (hcomm : ∀ B∈fiberCommutant parameterAngle,Commute p B) + (hinv : (1-p)*(fiberShiftL2 1*realPi modelAngle (RealBorel.ofContinuous finalWeight))*p=0) : p=0 ∨ p=1 := by + by_cases hp0 : p=0 + · exact Or.inl hp0 + by_cases hp1 : p=1 + · exact Or.inr hp1 + exfalso + obtain ⟨a,ham,hapos,ha⟩ := finalWeight_coboundary + have he : ∀ᵐ x ∂AddCircle.haarAddCircle,RealBorel.ofContinuous finalWeight x*a (x+modelAngle)=modelBorel x*a x := by + rw [Sampling.haarAddCircle_one_eq_volume] + filter_upwards [ha] with x hx + exact (eq_div_iff (ne_of_gt (hapos _))).mp hx + obtain ⟨q,hq,hqc,hq0,hq1,hqi⟩ := borel_weight_transport parameterAngle (RealBorel.ofContinuous finalWeight) modelBorel a ham hapos he p hp hcomm hp0 hp1 hinv + exact (modelOperator_no_projection q hq hqc hqi).elim hq0 hq1 +end CircleSampling + +namespace ContinuousCircleWeight + +section +open MeasureTheory +open scoped ENNReal ComplexInnerProductSpace + +lemma regular_isTracialRotation (θ : ℝ) : + IsTracialRotation θ regularU (regularV (rotationScalar θ)) regularVacuum where + relation := regular_relation (rotationScalar θ) + moments := regular_moments (rotationScalar θ) + cyclic := regular_cyclic (rotationScalar θ) + +lemma fiberConjugacy_cfc (θ : ℝ) (f : C(CircleX,ℝ)) : + fiberConjugacy (cfc (circleFunction f) (regularV (rotationScalar θ) : RegularOperator)) = + realPi (θ:CircleX) (RealBorel.ofContinuous f) := by + rw [realPi_continuous] + have h := fiberConjugacy.toStarAlgHom.map_cfc (circleFunction f) + (regularV (rotationScalar θ) : RegularOperator) + ((circleFunction_continuousOn f).mono (Unitary.spectrum_subset_circle _)) + (StarAlgEquiv.isometry fiberConjugacy).continuous + change fiberConjugacy _ = cfc (circleFunction f) + (fiberConjugacy (regularV (rotationScalar θ) : RegularOperator)) at h + rw [h,fiberConjugacy_V] + exact (circle_cfc_hom (continuousPiHom (θ:CircleX)) (continuous_continuousPiHom _) f).symm + +lemma fiberConjugacy_weighted (θ : ℝ) (f : C(CircleX,ℝ)) : + fiberConjugacy (weightedRotation regularU (regularV (rotationScalar θ)) f) = + fiberShiftL2 1 * realPi (θ:CircleX) (RealBorel.ofContinuous f) := by + rw [weightedRotation,map_mul,fiberConjugacy_U,fiberConjugacy_cfc] + +end + +open MeasureTheory CircleSampling +open scoped ENNReal ComplexInnerProductSpace + +theorem main_theorem : MainStatement := by + refine ⟨parameterAngle, finalWeight, regularU, regularV (rotationScalar parameterAngle), + regularVacuum, parameterAngle_spec.1, parameterAngle_spec.2.1, + parameterAngle_spec.2.2.1, regular_isTracialRotation parameterAngle, + finalWeight_bounds, ⟨0, finalWeight_zero⟩, finalWeight_log, ?_⟩ + intro p hp hppr hinv + have hi : (1-fiberConjugacy p)* + (fiberShiftL2 1*realPi modelAngle (RealBorel.ofContinuous finalWeight))*fiberConjugacy p=0 := by + have h := congrArg fiberConjugacy hinv + simpa only [map_mul,map_sub,map_one,map_zero,fiberConjugacy_weighted,modelAngle] using h + have hq := continuousOperator_no_projection (fiberConjugacy p) (hppr.map fiberConjugacy) + (fiber_commutes_of_regularAlgebra parameterAngle p hp) hi + rcases hq with hq|hq + · left + apply fiberConjugacy.injective + change fiberConjugacy p=fiberConjugacy 0 + simpa only [map_zero] using hq + · right + apply fiberConjugacy.injective + change fiberConjugacy p=fiberConjugacy 1 + simpa only [map_one] using hq + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/MaskedEstimates.lean b/lean/OAI/Analysis/RotationWeights/MaskedEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8b83ab7ea68a889ab2fd8688df64a24373958cc --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/MaskedEstimates.lean @@ -0,0 +1,243 @@ +import OAI.Analysis.RotationWeights.LaurentCoefficients + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uΩ uX uι uY + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal + +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators + +theorem endpoint_mask_integral_le {Ω : Type uΩ} {X : Type uX} [MeasurableSpace Ω] + [MeasurableSpace X] (μ : Measure Ω) (x : Ω → X) (hx : Measurable x) + (H : Set Ω) (hH : MeasurableSet H) (δ : ℝ≥0∞) + (hdom : Measure.map x (μ.restrict H) ≤ δ • Measure.map x μ) + (a : X → ℝ≥0∞) (ha : Measurable a) : + (∫⁻ ω, H.indicator (fun ω => a (x ω)) ω ∂μ) ≤ + δ * ∫⁻ ω, a (x ω) ∂μ := by + rw [lintegral_indicator hH, ← lintegral_map ha hx] + calc + _ ≤ ∫⁻ z, a z ∂δ • Measure.map x μ := lintegral_mono' hdom le_rfl + _ = _ := by rw [lintegral_smul_measure, lintegral_map ha hx]; rfl + +theorem endpoint_masked_squares {Ω : Type uΩ} {X : Type uX} {ι : Type uι} [MeasurableSpace Ω] + [MeasurableSpace X] [Countable ι] (μ : Measure Ω) [IsProbabilityMeasure μ] + (x : Ω → X) (hx : Measurable x) + (H : ι → Set Ω) (hH : ∀ i, MeasurableSet (H i)) (δ : ℝ≥0∞) + (hdom : ∀ i, Measure.map x (μ.restrict (H i)) ≤ δ • Measure.map x μ) + (a : ι → X → ℝ≥0∞) (ha : ∀ i, Measurable (a i)) + (hsq : ∀ᵐ ω ∂μ, (∑' i, a i (x ω) ^ 2) ≤ 1) : + (∫⁻ ω, ∑' i, (H i).indicator (fun ω => a i (x ω) ^ 2) ω ∂μ) ≤ δ := by + have hm (i : ι) : Measurable (fun ω => (H i).indicator + (fun ω => a i (x ω) ^ 2) ω) := + (((ha i).comp hx).pow_const 2).indicator (hH i) + rw [lintegral_tsum (fun i => (hm i).aemeasurable)] + calc + _ ≤ ∑' i, δ * ∫⁻ ω, a i (x ω) ^ 2 ∂μ := + ENNReal.tsum_le_tsum (fun i => endpoint_mask_integral_le μ x hx (H i) (hH i) + δ (hdom i) (fun z => a i z ^ 2) ((ha i).pow_const 2)) + _ = δ * ∫⁻ ω, ∑' i, a i (x ω) ^ 2 ∂μ := by + rw [ENNReal.tsum_mul_left] + congr 1 + exact (lintegral_tsum (fun i => show AEMeasurable + (fun ω => a i (x ω) ^ 2) μ from + (((ha i).comp hx).pow_const 2).aemeasurable)).symm + _ ≤ δ * 1 := mul_le_mul' le_rfl (by simpa using lintegral_mono_ae hsq) + _ = δ := mul_one δ + +theorem masked_product_integral_le {Ω : Type uΩ} {ι : Type uι} [MeasurableSpace Ω] + [MeasurableSpace ι] [MeasurableSingletonClass ι] [Countable ι] + (μ : Measure Ω) [SFinite μ] + (a b : ι → Ω → ℝ≥0∞) (ha : ∀ i, Measurable (a i)) + (hb : ∀ i, Measurable (b i)) (H : ι → Set Ω) + (hH : ∀ i, MeasurableSet (H i)) (δ : ℝ≥0∞) + (hfirst : (∫⁻ ω, ∑' i, (H i).indicator (fun ω => a i ω ^ 2) ω ∂μ) ≤ δ) + (hsecond : (∫⁻ ω, ∑' i, b i ω ^ 2 ∂μ) ≤ 1) : + (∫⁻ ω, ∑' i, (H i).indicator (fun ω => a i ω * b i ω) ω ∂μ) ≤ + δ ^ (1 / 2 : ℝ) := by + let A : ι × Ω → ℝ≥0∞ := fun z => (H z.1).indicator (a z.1) z.2 + let B : ι × Ω → ℝ≥0∞ := fun z => b z.1 z.2 + have hA : Measurable A := measurable_from_prod_countable_right + (fun i => (ha i).indicator (hH i)) + have hB : Measurable B := measurable_from_prod_countable_right hb + have hApow (z : ι × Ω) : A z ^ (2 : ℝ) = + (H z.1).indicator (fun ω => a z.1 ω ^ 2) z.2 := by + rw [ENNReal.rpow_two] + by_cases hz : z.2 ∈ H z.1 <;> simp [A, hz] + have hAB (z : ι × Ω) : (A * B) z = + (H z.1).indicator (fun ω => a z.1 ω * b z.1 ω) z.2 := by + by_cases hz : z.2 ∈ H z.1 <;> simp [A, B, hz] + have hcs := ENNReal.lintegral_mul_le_Lp_mul_Lq (Measure.count.prod μ) + (show Real.HolderConjugate 2 2 from by norm_num [Real.holderConjugate_iff]) + hA.aemeasurable hB.aemeasurable + have hiA : (∫⁻ z, A z ^ (2 : ℝ) ∂Measure.count.prod μ) ≤ δ := by + rw [lintegral_prod _ (hA.pow_const (2 : ℝ)).aemeasurable, lintegral_count] + simp_rw [hApow] + rwa [← lintegral_tsum (fun i => ((ha i).pow_const 2).indicator (hH i) |>.aemeasurable)] + have hiB : (∫⁻ z, B z ^ (2 : ℝ) ∂Measure.count.prod μ) ≤ 1 := by + rw [lintegral_prod _ (hB.pow_const (2 : ℝ)).aemeasurable, lintegral_count] + simpa only [B, ENNReal.rpow_two, + ← lintegral_tsum (fun i => ((hb i).pow_const 2).aemeasurable)] using hsecond + have hiAB : (∫⁻ z, (A * B) z ∂Measure.count.prod μ) = + (∫⁻ ω, ∑' i, (H i).indicator (fun ω => a i ω * b i ω) ω ∂μ) := by + rw [lintegral_prod _ (hA.mul hB).aemeasurable, lintegral_count] + simp_rw [hAB] + exact (lintegral_tsum (fun i => show AEMeasurable + (fun ω => (H i).indicator (fun ω => a i ω * b i ω) ω) μ from + (((ha i).mul (hb i)).indicator (hH i)).aemeasurable)).symm + rw [hiAB] at hcs + exact hcs.trans (by + calc + _ ≤ δ ^ (1 / 2 : ℝ) * (1 : ℝ≥0∞) ^ (1 / 2 : ℝ) := + mul_le_mul' (ENNReal.rpow_le_rpow hiA (by norm_num)) + (ENNReal.rpow_le_rpow hiB (by norm_num)) + _ = _ := by simp) + +theorem retained_sum_enorm_le {ι : Type uι} (z : ι → ℂ) (s : Finset ι) + (hz : Summable z) (hzero : ∑' i, z i = 0) (a : ι → ℝ≥0∞) + (ha : ∀ i ∉ s, ‖z i‖ₑ ≤ a i) : + ‖∑ i ∈ s, z i‖ₑ ≤ ∑' i, a i := by + classical + have heq := hz.sum_add_tsum_compl (s := s) + rw [hzero] at heq + have hret : (∑ i ∈ s, z i) = -(∑' i : {i // i ∉ s}, z i) := + eq_neg_of_add_eq_zero_left heq + rw [hret, enorm_neg] + exact enorm_tsum_le_tsum_enorm.trans + ((ENNReal.tsum_le_tsum (fun i : {i // i ∉ s} => ha i i.property)).trans + (ENNReal.tsum_comp_le_tsum_of_injective Subtype.val_injective a)) + +theorem convolution_cut_bound {ι : Type uι} (z : ι → ℂ) (s : Finset ι) + (hz : Summable z) (hzero : ∑' i, z i = 0) + (a b h₁ h₂ : ι → ℝ≥0∞) (r : ℝ≥0∞) + (hprod : ∑' i, a i * b i ≤ 1) + (hbound : ∀ i ∉ s, ‖z i‖ₑ ≤ a i * b i * (r + h₁ i + h₂ i)) : + ‖∑ i ∈ s, z i‖ₑ ≤ r + (∑' i, a i * b i * h₁ i) + + (∑' i, a i * b i * h₂ i) := by + apply (retained_sum_enorm_le z s hz hzero _ hbound).trans + simp_rw [mul_add] + rw [ENNReal.tsum_add, ENNReal.tsum_add, ENNReal.tsum_mul_right] + exact add_le_add (add_le_add (by simpa only [one_mul] using + (mul_le_mul' hprod (le_rfl : r ≤ r))) le_rfl) le_rfl + +theorem two_endpoint_error_bound {Ω : Type uΩ} {X : Type uX} {Y : Type uY} {ι : Type uι} [MeasurableSpace Ω] + [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace ι] + [MeasurableSingletonClass ι] [Countable ι] + (μ : Measure Ω) [IsProbabilityMeasure μ] + (x : Ω → X) (y : Ω → Y) (hx : Measurable x) (hy : Measurable y) + (a : ι → X → ℝ≥0∞) (b : ι → Y → ℝ≥0∞) + (ha : ∀ i, Measurable (a i)) (hb : ∀ i, Measurable (b i)) + (H₁ H₂ : ι → Set Ω) (hH₁ : ∀ i, MeasurableSet (H₁ i)) + (hH₂ : ∀ i, MeasurableSet (H₂ i)) (δ r : ℝ≥0∞) + (hdom₁ : ∀ i, Measure.map x (μ.restrict (H₁ i)) ≤ δ • Measure.map x μ) + (hdom₂ : ∀ i, Measure.map y (μ.restrict (H₂ i)) ≤ δ • Measure.map y μ) + (hsq₁ : ∀ᵐ ω ∂μ, ∑' i, a i (x ω) ^ 2 ≤ 1) + (hsq₂ : ∀ᵐ ω ∂μ, ∑' i, b i (y ω) ^ 2 ≤ 1) + (c : Ω → ℝ≥0∞) + (hc : ∀ᵐ ω ∂μ, c ω ≤ r + + (∑' i, (H₁ i).indicator (fun ω => a i (x ω) * b i (y ω)) ω) + + (∑' i, (H₂ i).indicator (fun ω => a i (x ω) * b i (y ω)) ω)) : + (∫⁻ ω, c ω ∂μ) ≤ r + δ ^ (1 / 2 : ℝ) + δ ^ (1 / 2 : ℝ) := by + have hi₁ := endpoint_masked_squares μ x hx H₁ hH₁ δ hdom₁ a ha hsq₁ + have hi₂ := endpoint_masked_squares μ y hy H₂ hH₂ δ hdom₂ b hb hsq₂ + have hbint : (∫⁻ ω, ∑' i, b i (y ω) ^ 2 ∂μ) ≤ 1 := by + simpa using lintegral_mono_ae hsq₂ + have haint : (∫⁻ ω, ∑' i, a i (x ω) ^ 2 ∂μ) ≤ 1 := by + simpa using lintegral_mono_ae hsq₁ + have hfirst := masked_product_integral_le μ (fun i ω => a i (x ω)) + (fun i ω => b i (y ω)) (fun i => (ha i).comp hx) (fun i => (hb i).comp hy) + H₁ hH₁ δ hi₁ hbint + have hsecond := masked_product_integral_le μ (fun i ω => b i (y ω)) + (fun i ω => a i (x ω)) (fun i => (hb i).comp hy) (fun i => (ha i).comp hx) + H₂ hH₂ δ hi₂ haint + simp_rw [mul_comm (b _ _) (a _ _)] at hsecond + have hm₁ : Measurable (fun ω => ∑' i, + (H₁ i).indicator (fun ω => a i (x ω) * b i (y ω)) ω) := + Measurable.tsum (fun i => (((ha i).comp hx).mul ((hb i).comp hy)).indicator (hH₁ i)) + apply (lintegral_mono_ae hc).trans + have hm : Measurable (fun ω => r + ∑' i, + (H₁ i).indicator (fun ω => a i (x ω) * b i (y ω)) ω) := measurable_const.add hm₁ + rw [lintegral_add_left hm, lintegral_add_left + (measurable_const : Measurable (fun _ : Ω => r))] + simpa using add_le_add (add_le_add le_rfl hfirst) hsecond + + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/MeasurableWeight.lean b/lean/OAI/Analysis/RotationWeights/MeasurableWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e8319146648033dcd95f0a550dbfff9543f1503 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/MeasurableWeight.lean @@ -0,0 +1,411 @@ +import OAI.Analysis.RotationWeights.Parameters + +namespace OAI + +noncomputable section + +namespace CircleModel + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set + +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +section +abbrev CircleX := AddCircle (1:ℝ) +def repr (x : CircleX) : ℝ := (AddCircle.measurableEquivIco 1 0 x).val +lemma repr_mem (x : CircleX) : repr x ∈ Ico 0 1 := by + simpa [repr] using (AddCircle.measurableEquivIco 1 0 x).property +lemma repr_mk (x : ℝ) : repr (x : CircleX) = Int.fract x := by + change (AddCircle.equivIco 1 0 (x : CircleX)).val = _ + simpa only [div_one,mul_one] using AddCircle.coe_equivIco_mk_apply (p := (1:ℝ)) x +lemma repr_coe (x : CircleX) : ((repr x : ℝ) : CircleX) = x := by + exact (AddCircle.measurableEquivIco 1 0).symm_apply_apply x +lemma measurable_repr : Measurable repr := + measurable_subtype_coe.comp (AddCircle.measurableEquivIco 1 0).measurable + +def Xi (q : ℕ → ℕ) (i : ℕ) (x : CircleX) : ℝ := repr (q i • x) +def beta (q : ℕ → ℕ) (θ : CircleX) (i : ℕ) : ℝ := Xi q i θ +def shift (θ : CircleX) (k : ℤ) (x : CircleX) : CircleX := x+k•θ + +lemma Xi_shift (q : ℕ → ℕ) (θ : CircleX) (k : ℤ) (i : ℕ) (x : CircleX) : + Xi q i (shift θ k x) = Int.fract (Xi q i x + k*beta q θ i) := by + rw [← repr_mk] + have hk : (((k:ℝ)*repr (q i • θ) : ℝ) : CircleX) = k • (q i • θ) := by + rw [← zsmul_eq_mul,AddCircle.coe_zsmul,repr_coe] + change repr (q i • (x+k•θ)) = repr ((repr (q i • x)+(k:ℝ)*repr (q i • θ) : ℝ) : CircleX) + rw [AddCircle.coe_add,repr_coe,hk,nsmul_add,smul_comm] + +lemma floor_cocycle (x a : ℝ) (k n : ℤ) : + ⌊x+(k+n)*a⌋ = ⌊x+k*a⌋ + ⌊Int.fract (x+k*a)+n*a⌋ := by + have h : x+(k+n)*a = Int.fract (x+k*a)+n*a+(⌊x+k*a⌋:ℝ) := by + rw [Int.fract]; ring + rw [h,Int.floor_add_intCast] + omega + +def floorTerm (q : ℕ → ℕ) (θ : CircleX) (k : ℤ) (x : CircleX) (i : ℕ) : ℤ := + ⌊Xi q i x + k*beta q θ i⌋ + +def good0 (q : ℕ → ℕ) (θ : CircleX) : Set CircleX := + {x | ∀ k : ℤ, (Function.support (floorTerm q θ k x)).Finite} + +def good (q : ℕ → ℕ) (θ : CircleX) : Set CircleX := + {x | ∀ a : ℤ, shift θ a x ∈ good0 q θ} + +lemma shift_add (θ : CircleX) (k n : ℤ) (x : CircleX) : + shift θ n (shift θ k x) = shift θ (k+n) x := by + simp [shift,add_zsmul,add_assoc] +lemma shift_zero (θ : CircleX) (x : CircleX) : shift θ 0 x=x := by simp [shift] +lemma good_shift (q : ℕ → ℕ) (θ : CircleX) (k : ℤ) (x : CircleX) : + shift θ k x ∈ good q θ ↔ x ∈ good q θ := by + constructor + · intro h a + have := h (a-k) + simpa [shift_add] using this + · intro h a + simpa [shift_add] using h (k+a) + +lemma good_subset_good0 (q : ℕ → ℕ) (θ : CircleX) : good q θ ⊆ good0 q θ := by + intro x hx + simpa [shift_zero] using hx 0 + +lemma floorTerm_add (q : ℕ → ℕ) (θ : CircleX) (k n : ℤ) (x : CircleX) (i : ℕ) : + floorTerm q θ (k+n) x i = floorTerm q θ k x i + floorTerm q θ n (shift θ k x) i := by + simp only [floorTerm,Xi_shift,floor_cocycle,Int.cast_add] + +lemma floorTerm_zero (q : ℕ → ℕ) (θ : CircleX) (x : CircleX) (i : ℕ) : + floorTerm q θ 0 x i = 0 := by + simp only [floorTerm,Int.cast_zero,zero_mul,add_zero] + exact Int.floor_eq_iff.mpr (by simpa [Xi] using repr_mem (q i • x)) + +lemma floorTerm_mono (q : ℕ → ℕ) (θ : CircleX) (x : CircleX) (i : ℕ) : + Monotone fun k : ℤ ↦ floorTerm q θ k x i := by + intro k l h + apply Int.floor_mono + gcongr + exact (repr_mem _).1 + +def exponent (q : ℕ → ℕ) (θ : CircleX) (c : ℕ → ℝ) (k : ℤ) (x : CircleX) : ℝ := + ∑' i, c i * (floorTerm q θ k x i : ℝ) + +def cocycle (q : ℕ → ℕ) (θ : CircleX) (c : ℕ → ℝ) (k : ℤ) (x : CircleX) : ℝ := + if x ∈ good q θ then Real.exp (-exponent q θ c k x) else 1 + +lemma summable_exponent {q : ℕ → ℕ} {θ : CircleX} (c : ℕ → ℝ) (k : ℤ) {x : CircleX} + (hx : x∈good q θ) : Summable (fun i ↦ c i*(floorTerm q θ k x i:ℝ)) := by + apply summable_of_hasFiniteSupport + apply (good_subset_good0 q θ hx k).subset + intro i hi + contrapose! hi + simp only [Function.mem_support] at * + simp [hi] + +lemma exponent_add {q : ℕ → ℕ} {θ : CircleX} (c : ℕ → ℝ) (k n : ℤ) {x : CircleX} + (hx : x∈good q θ) : + exponent q θ c (k+n) x = exponent q θ c n (shift θ k x)+exponent q θ c k x := by + simp only [exponent,floorTerm_add,Int.cast_add,mul_add] + rw [(summable_exponent c k hx).tsum_add (summable_exponent c n ((good_shift q θ k x).mpr hx)),add_comm] + +lemma cocycle_add (q : ℕ → ℕ) (θ : CircleX) (c : ℕ → ℝ) (k n : ℤ) (x : CircleX) : + cocycle q θ c (k+n) x = cocycle q θ c n (shift θ k x)*cocycle q θ c k x := by + unfold cocycle + by_cases hx : x∈good q θ + · rw [ite_eq_left hx,ite_eq_left hx,ite_eq_left ((good_shift q θ k x).mpr hx),exponent_add c k n hx,neg_add,Real.exp_add] + · rw [ite_eq_right hx,ite_eq_right hx,ite_eq_right (mt (good_shift q θ k x).mp hx),one_mul] + +lemma cocycle_pos (q : ℕ → ℕ) (θ : CircleX) (c : ℕ → ℝ) (k : ℤ) (x : CircleX) : + 0 push_cast <;> linarith + have h1 : volume {x : CircleX | Xi q i x if i hxy i) + +lemma floor_crossing {s t a : ℝ} (hs : s∈Ico 0 1) (ht : t∈Ico 0 1) + (hlo : s<1-Int.fract a) (hhi : 1-Int.fract a≤t) : ⌊t+a⌋=⌊s+a⌋+1 := by + have ha : a=Int.fract a+(⌊a⌋:ℝ) := by rw [Int.fract]; ring + have hs0 : ⌊s+Int.fract a⌋=0 := Int.floor_eq_iff.mpr (by + push_cast; constructor <;> linarith [Int.fract_nonneg a,hs.1]) + have ht1 : ⌊t+Int.fract a⌋=1 := Int.floor_eq_iff.mpr (by + push_cast; constructor <;> linarith [Int.fract_lt_one a,ht.2]) + rw [ha,←add_assoc,←add_assoc,Int.floor_add_intCast,Int.floor_add_intCast,hs0,ht1] + omega + +lemma cocycle_ratio_crossing {q : ℕ → ℕ} {θ : CircleX} (c : ℕ → ℝ) (hc : ∀ i,0≤c i) + (k : ℤ) {x y : CircleX} (hx : x∈good q θ) (hy : y∈good q θ) + (hxy : ∀ i,Xi q i x≤Xi q i y) (i : ℕ) + (hlo : Xi q i x<1-Int.fract ((k:ℝ)*beta q θ i)) + (hhi : 1-Int.fract ((k:ℝ)*beta q θ i)≤Xi q i y) : + cocycle q θ c k y/cocycle q θ c k x ≤ Real.exp (-c i) := by + have hcross : floorTerm q θ k y i=floorTerm q θ k x i+1 := + floor_crossing (repr_mem _) (repr_mem _) hlo hhi + have hs : Summable (fun a => c a*((floorTerm q θ k y a:ℝ)-(floorTerm q θ k x a:ℝ))) := by + simpa only [mul_sub] using (summable_exponent c k hy).sub (summable_exponent c k hx) + have hn : ∀ a,0≤c a*((floorTerm q θ k y a:ℝ)-(floorTerm q θ k x a:ℝ)) := by + intro a + exact mul_nonneg (hc a) (sub_nonneg.mpr (Int.cast_le.mpr (floorTerm_ordered k (hxy a)))) + have hb := hs.le_tsum i (fun a _ => hn a) + have he : (∑' a,c a*((floorTerm q θ k y a:ℝ)-(floorTerm q θ k x a:ℝ))) = + exponent q θ c k y-exponent q θ c k x := by + simp only [mul_sub,exponent,(summable_exponent c k hy).tsum_sub (summable_exponent c k hx)] + rw [he,hcross,Int.cast_add,Int.cast_one] at hb + rw [cocycle_ratio_exp c k hx hy] + exact Real.exp_le_exp.mpr (by nlinarith) + + +end CircleModel + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Model.lean b/lean/OAI/Analysis/RotationWeights/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7a592bca109081eed5db8365e1df4136da9c0da --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Model.lean @@ -0,0 +1,53 @@ +import Mathlib + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped ENNReal ComplexInnerProductSpace +namespace ContinuousCircleWeight + +abbrev CircleX := AddCircle (1:ℝ) + +abbrev TracialHilbert := lp (fun _ : ℤ × ℤ => ℂ) 2 +abbrev Operator := TracialHilbert →L[ℂ] TracialHilbert + +def circleIdentification : CircleX ≃ₜ Circle := + AddCircle.homeomorphCircle (by norm_num) +def circleFunction (f : C(CircleX, ℝ)) (z : ℂ) : ℂ := + if hz : ‖z‖ = 1 then f (circleIdentification.symm ⟨z, mem_sphere_zero_iff_norm.mpr hz⟩) else 0 + +def negativeLog (t : ℝ) : ℝ≥0∞ := + if t = 0 then ∞ else ENNReal.ofReal (-Real.log t) + +structure IsTracialRotation (θ : ℝ) (U V : unitary Operator) + (e : TracialHilbert) : Prop where + relation : (V : Operator) * (U : Operator) = + Complex.exp (2 * Real.pi * θ * Complex.I) • ((U : Operator) * (V : Operator)) + moments : ∀ m n : ℤ, + inner ℂ e (((U ^ m * V ^ n : unitary Operator) : Operator) e) = + if m = 0 ∧ n = 0 then 1 else 0 + cyclic : (Submodule.span ℂ + (Set.range (fun mn : ℤ × ℤ => + ((U ^ mn.1 * V ^ mn.2 : unitary Operator) : Operator) e))).topologicalClosure = ⊤ + +def rotationAlgebra (U V : unitary Operator) : Set Operator := + Set.centralizer (Set.centralizer ({(U : Operator), (V : Operator)} : Set Operator)) + +def weightedRotation (U V : unitary Operator) (f : C(CircleX, ℝ)) : Operator := + (U : Operator) * cfc (circleFunction f) (V : Operator) + +def MainStatement : Prop := + ∃ (θ : ℝ) (f : C(CircleX, ℝ)) (U V : unitary Operator) (e : TracialHilbert), + 0 < θ ∧ θ < 1 ∧ Irrational θ ∧ + IsTracialRotation θ U V e ∧ + (∀ x, 0 ≤ f x ∧ f x ≤ 1) ∧ + (∃ z : CircleX, ∀ x, f x = 0 ↔ x = z) ∧ + (∫⁻ x, negativeLog (f x) ∂(volume : Measure CircleX)) = ∞ ∧ + ∀ p : Operator, p ∈ rotationAlgebra U V → IsStarProjection p → + (1 - p) * weightedRotation U V f * p = 0 → p = 0 ∨ p = 1 + +end ContinuousCircleWeight +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/NestedAngles.lean b/lean/OAI/Analysis/RotationWeights/NestedAngles.lean new file mode 100644 index 0000000000000000000000000000000000000000..fee4725389b029a58a40c2d637b92798f4024a41 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/NestedAngles.lean @@ -0,0 +1,441 @@ +import OAI.Analysis.RotationWeights.SamplingStage + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uS + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators + +open Set +section + +def enumeratedRat (n : ℕ) : ℝ := ((Encodable.decode (α := ℚ) n).getD 0:ℚ) +lemma enumeratedRat_encode (r : ℚ) : enumeratedRat (Encodable.encode r) = (r:ℝ) := by + simp [enumeratedRat,Encodable.encodek] + +lemma closed_interval_avoiding (r : ℝ) {a b : ℝ} (hab : a linarith [hx.1,hx.2] + · intro hr'; linarith [hr'.1] + · refine ⟨(7*a+b)/8,(3*a+b)/4,by linarith,?_,?_⟩ + · intro x hx; constructor <;> linarith [hx.1,hx.2] + · intro hr'; linarith [hr'.2] + +lemma irrational_in_nested_intervals (a b : ℕ → ℝ) + (hab : ∀ n, a n < b n) (hnest : ∀ n, Icc (a (n+1)) (b (n+1)) ⊆ Ioo (a n) (b n)) + (havoid : ∀ n, enumeratedRat n ∉ Icc (a (n+1)) (b (n+1))) : + ∃ θ : ℝ, Irrational θ ∧ (∀ n, θ∈Icc (a n) (b n)) ∧ θ∈Ioo (a 0) (b 0) := by + obtain ⟨θ,hθ⟩ := IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed + (fun n => Icc (a n) (b n)) (fun n => (hnest n).trans Ioo_subset_Icc_self) + (fun n => nonempty_Icc.mpr (hab n).le) isCompact_Icc (fun _ => isClosed_Icc) + have hm : ∀ n, θ∈Icc (a n) (b n) := Set.mem_iInter.mp hθ + refine ⟨θ,?_,hm,hnest 0 (hm 1)⟩ + rintro ⟨r,hr⟩ + apply havoid (Encodable.encode r) + rw [enumeratedRat_encode,hr] + exact hm _ + +lemma exists_recursive_chain {S : Type uS} (V : ℕ → S → Prop) (R : ℕ → S → S → Prop) + (s0 : S) (h0 : V 0 s0) + (step : ∀ n s, V n s → ∃ t, V (n+1) t ∧ R n s t) : + ∃ s : ℕ → S, s 0=s0 ∧ (∀ n,V n (s n)) ∧ ∀ n,R n (s n) (s (n+1)) := by + let next (n : ℕ) (s : {s // V n s}) : {s // V (n+1) s} := + ⟨(step n s.1 s.2).choose,(step n s.1 s.2).choose_spec.1⟩ + let seq : (n : ℕ) → {s // V n s} := Nat.rec ⟨s0,h0⟩ next + refine ⟨fun n => (seq n).1,rfl,fun n => (seq n).2,?_⟩ + intro n + exact (step n (seq n).1 (seq n).2).choose_spec.2 + +lemma prefix_persistent (d : ℕ → ℕ) (q : ℕ → ℕ → ℕ) + (hd : Monotone d) (hq : ∀ j i, i≤d j → q (j+1) i=q j i) + {j n i : ℕ} (hjn : j≤n) (hi : i≤d j) : q n i=q j i := by + induction n,hjn using Nat.le_induction with + | base => rfl + | succ n hjn ih => rw [hq n i (hi.trans (hd hjn)),ih] + +lemma diagonal_prefix_eq (d : ℕ → ℕ) (q : ℕ → ℕ → ℕ) + (hd : Monotone d) (hlen : ∀ j,j≤d j) (hq : ∀ j i, i≤d j → q (j+1) i=q j i) + {j i : ℕ} (hi : i≤d j) : q i i=q j i := by + rcases le_total j i with hji|hij + · exact prefix_persistent d q hd hq hji hi + · exact (prefix_persistent d q hd hq hij (hlen i)).symm + +lemma endpoints_sum (m : ℕ → ℕ) (d : ℕ → ℕ) (h0 : d 0=0) + (hs : ∀ j,d (j+1)=d j+m j) (j : ℕ) : d j=∑ s∈Finset.range j,m s := by + induction j with + | zero => simpa using h0 + | succ j ih => rw [hs,Finset.sum_range_succ,ih] + +lemma endpoints_growth (m d : ℕ → ℕ) (hm : ∀ j, 0 < m j) (hs : ∀ j,d (j+1)=d j+m j) : + StrictMono d ∧ ∀ j,j≤d j := by + have hd : StrictMono d := strictMono_nat_of_lt_succ (fun j => by rw [hs]; exact Nat.lt_add_of_pos_right (hm j)) + refine ⟨hd,?_⟩ + intro j + induction j with + | zero => omega + | succ j ih => exact Nat.succ_le_of_lt (lt_of_le_of_lt ih (hd (Nat.lt_succ_self j))) + + +def extendPrefix (d : ℕ) (old block : ℕ → ℕ) (i : ℕ) : ℕ := + if i≤ d then old i else block (i-d) +lemma extendPrefix_old (d : ℕ) (old block : ℕ → ℕ) {i : ℕ} (hi : i≤ d) : + extendPrefix d old block i=old i := ite_eq_left hi +lemma extendPrefix_block (d : ℕ) (old block : ℕ → ℕ) (h0 : block 0=old d) (k : ℕ) : + extendPrefix d old block (d+k)=block k := by + by_cases hk : k=0 + · subst k; simp [extendPrefix,h0] + · rw [extendPrefix,ite_eq_right (by omega),Nat.add_sub_cancel_left] +lemma extendPrefix_pos (d m : ℕ) (old block : ℕ → ℕ) + (ho : ∀ i≤ d,0< old i) (hb : ∀ i≤ m,0< block i) {i : ℕ} (hi : i≤ d+m) : + 0< extendPrefix d old block i := by + by_cases h : i≤ d + · rw [extendPrefix_old d old block h]; exact ho i h + · rw [extendPrefix,ite_eq_right h]; exact hb _ (by omega) +lemma extendPrefix_dvd (d m : ℕ) (old block : ℕ → ℕ) (h0 : block 0=old d) + (ho : ∀ i< d,old i∣old (i+1)) (hb : ∀ i< m,block i∣block (i+1)) {i : ℕ} (hi : i< d+m) : + extendPrefix d old block i∣extendPrefix d old block (i+1) := by + by_cases h : i< d + · rw [extendPrefix_old d old block (by omega),extendPrefix_old d old block (by omega)] + exact ho i h + · have he : i=d+(i-d) := by omega + rw [he,extendPrefix_block d old block h0] + rw [show d+(i-d)+1=d+((i-d)+1) by omega,extendPrefix_block d old block h0] + exact hb _ (by omega) +lemma extendPrefix_lt (d m : ℕ) (old block : ℕ → ℕ) (h0 : block 0=old d) + (ho : ∀ i< d,old i< old (i+1)) (hb : ∀ i< m,block i< block (i+1)) {i : ℕ} (hi : i< d+m) : + extendPrefix d old block i< extendPrefix d old block (i+1) := by + by_cases h : i< d + · rw [extendPrefix_old d old block (by omega),extendPrefix_old d old block (by omega)] + exact ho i h + · have he : i=d+(i-d) := by omega + rw [he,extendPrefix_block d old block h0] + rw [show d+(i-d)+1=d+((i-d)+1) by omega,extendPrefix_block d old block h0] + exact hb _ (by omega) +end + +open Set +section +def positiveArc (h : CircleX) (r : ℝ) : Set CircleX := + {x | x-h ∈ ((↑) : ℝ → CircleX) '' Ioo 0 r} +lemma positiveArc_open (h : CircleX) (r : ℝ) : IsOpen (positiveArc h r) := by + exact (QuotientAddGroup.isOpenMap_coe (Ioo 0 r) isOpen_Ioo).preimage (continuous_id.sub continuous_const) +lemma positiveArc_nonempty (h : CircleX) {r : ℝ} (hr : 0 + Int.fract ((q (i+1):ℝ)*θ) ∉ phaseFailure ((m:ℝ)^(-(19:ℝ)/20)) k).card:ℝ) + orbits : ∀ θ∈Icc a b, ∀ t n, n∈samples t → n•(θ:CircleX)∈positiveArc (gridPoint s t) (gridTolerance j s) + energies : ∀ θ∈Icc a b, ∀ t (positive : Bool), + (∫ x : CircleX, (idealAverage positive (scaleEll m) (scaleAlpha m) + (fun n : samples t => (n.val:ℝ)) + (characterCurve (fun i : Fin m => (q (i+1):ℤ)) x) + (fun i => Int.fract ((q (i+1):ℝ)*θ))-1)^2) < 1/((j:ℝ)+1)^2 + +def ScaleStep.C {j : ℕ} {s : ScaleState} (t : ScaleStep j s) : ℝ := max t.L ((s.K:ℝ)^2) + +def ScaleStep.next {j : ℕ} {s : ScaleState} (t : ScaleStep j s) : ScaleState where + K := nextWindow t.m + d := s.d+t.m + G := t.Gnext + E := s.E+t.C*t.m + Lprev := t.L + a := t.a + b := t.b + q := extendPrefix s.d s.q t.q + +lemma ScaleStep.mpos {j : ℕ} {s : ScaleState} (t : ScaleStep j s) : 0 < t.m := + lt_of_lt_of_le (by norm_num) t.numeric.1 + +lemma ScaleStep.qstrict {j : ℕ} {s : ScaleState} (t : ScaleStep j s) {i : ℕ} (hi : i< t.m) : + t.q i< t.q (i+1) := by + have hp : 0 < (t.q i:ℝ) := Nat.cast_pos.mpr (t.qpos i hi.le) + have hm : 1 ≤ (t.m:ℝ) := by exact_mod_cast t.mpos + have hh : 1 < (t.q (i+1):ℝ)/t.q i := by linarith [(t.qratio i hi).2] + have hh' : (t.q i:ℝ)< t.q (i+1) := by simpa using (lt_div_iff₀ hp).mp hh + exact_mod_cast hh' + +lemma ScaleStep.next_valid {j : ℕ} {s : ScaleState} (t : ScaleStep j s) (hs : s.Valid) : t.next.Valid := by + refine ⟨?_,t.Gge,?_,t.Lge,?_,?_,?_,?_,t.ab⟩ + · have hh := t.numeric.2.2.2.2.2.2.1 + change 0 < nextWindow t.m + omega + · change 0≤ s.E+t.C*t.m + have hC : 0 ≤ t.C := by + change 0 ≤ max t.L ((s.K:ℝ)^2) + exact le_trans (show (0:ℝ) ≤ t.L by linarith [t.Lge]) (le_max_left t.L ((s.K:ℝ)^2)) + exact add_nonneg hs.Ege (mul_nonneg hC (Nat.cast_nonneg _)) + · change extendPrefix s.d s.q t.q 0=1 + rw [extendPrefix_old _ _ _ (Nat.zero_le _),hs.qzero] + · intro i hi + exact extendPrefix_pos s.d t.m s.q t.q hs.qpos t.qpos hi + · intro i hi + exact extendPrefix_dvd s.d t.m s.q t.q t.qzero hs.qdvd (fun i hi => (t.qratio i hi).1) hi + · intro i hi + exact extendPrefix_lt s.d t.m s.q t.q t.qzero hs.qlt (fun _ hi => t.qstrict hi) hi + +lemma exists_scale_step (j : ℕ) (s : ScaleState) (hs : s.Valid) : Nonempty (ScaleStep j s) := by + have hδ : 0 < 1/((j:ℝ)+1) := by positivity + obtain ⟨ε,hε,hcoeff⟩ := finite_coefficient_bound s.K _ (Real.exp (((s.K:ℝ)+1)*s.E)) hδ (Real.exp_pos _).le + obtain ⟨L,hL,hLp,hLb⟩ := exists_exponential_budget j s.K hε s.Lprev + obtain ⟨G,hG,hGb⟩ := exists_bridge_budget j L + have hr : 0 < gridTolerance j s := by + unfold gridTolerance + have hq : 0 < (s.q s.d:ℝ) := Nat.cast_pos.mpr (hs.qpos s.d le_rfl) + positivity + obtain ⟨m,hm,_,S,hSn,hSb,q,hq0,hqp,hqr,a,b,hab,hsub,hstage⟩ := exists_sampling_stage + (fun t : Fin (s.q s.d) => positiveArc (gridPoint s t) (gridTolerance j s)) + (fun _ => positiveArc_open _ _) (fun _ => positiveArc_nonempty _ hr) + hs.Kpos (show 0 < 1/((j:ℝ)+1)^2 by positivity) + (StageNumerics j s.K s.G L G) (eventually_StageNumerics j s.K s.G L G) + hs.ab (hs.qpos s.d le_rfl) (fun m => 100*(m:ℝ)) + obtain ⟨a',b',hab',hsub',havoid⟩ := closed_interval_avoiding (enumeratedRat j) hab + have hinc : Icc a' b' ⊆ Icc a b := hsub'.trans Ioo_subset_Icc_self + exact ⟨{ + ε := ε, L := L, Gnext := G, εpos := hε, coefficients := hcoeff, + Lge := hL, Lprev := hLp, exponential := hLb, Gge := hG, bridge := hGb, + m := m, numeric := hm, samples := S, samples_nonempty := hSn, samples_bounds := hSb, + q := q, qzero := hq0, qpos := hqp, qratio := hqr, + a := a', b := b', ab := hab', interval := hinc.trans hsub, avoid := havoid, + phases := fun θ hθ => (hstage θ (hinc hθ)).1, + cover := fun θ hθ => (hstage θ (hinc hθ)).2.1, + orbits := fun θ hθ => (hstage θ (hinc hθ)).2.2.1, + energies := fun θ hθ => (hstage θ (hinc hθ)).2.2.2 }⟩ + +def initialScaleState : ScaleState where + K := 100 + d := 0 + G := 1 + E := 0 + Lprev := 1 + a := 0 + b := 1 + q := fun _ => 1 +lemma initialScaleState_valid : initialScaleState.Valid := by + constructor <;> simp [initialScaleState] + +def chosenScaleStep (j : ℕ) (s : {s : ScaleState // s.Valid}) : ScaleStep j s.1 := + Classical.choice (exists_scale_step j s.1 s.2) +def scaleState : ℕ → {s : ScaleState // s.Valid} := + Nat.rec ⟨initialScaleState,initialScaleState_valid⟩ + (fun j s => ⟨(chosenScaleStep j s).next,(chosenScaleStep j s).next_valid s.2⟩) +def scaleStep (j : ℕ) : ScaleStep j (scaleState j).1 := chosenScaleStep j (scaleState j) +lemma scaleState_succ (j : ℕ) : (scaleState (j+1)).1=(scaleStep j).next := rfl + +lemma exists_global_angle : ∃ θ : ℝ, 0< θ ∧ θ<1 ∧ Irrational θ ∧ + ∀ j,θ∈Icc (scaleStep j).a (scaleStep j).b := by + obtain ⟨θ,hθ,hmem,h01⟩ := irrational_in_nested_intervals + (fun j => (scaleState j).1.a) (fun j => (scaleState j).1.b) + (fun j => (scaleState j).2.ab) + (fun j => (scaleStep j).interval) (fun j => (scaleStep j).avoid) + refine ⟨θ,h01.1,h01.2,hθ,?_⟩ + intro j + exact hmem (j+1) +end + +open Set + +structure BlockPartition where + m : ℕ → ℕ + d : ℕ → ℕ + zero : d 0=0 + step : ∀ j,d (j+1)=d j+m j + positive : ∀ j,0 < m j + +lemma BlockPartition.strictMono (B : BlockPartition) : StrictMono B.d := + strictMono_nat_of_lt_succ (fun j => by rw [B.step]; exact Nat.lt_add_of_pos_right (B.positive j)) +lemma BlockPartition.ge (B : BlockPartition) (j : ℕ) : j≤ B.d j := by + induction j with + | zero => omega + | succ j ih => exact Nat.succ_le_of_lt (lt_of_le_of_lt ih (B.strictMono (Nat.lt_succ_self j))) + +lemma BlockPartition.exists_unique (B : BlockPartition) (i : ℕ) : + ∃! j, B.d j≤ i ∧ i< B.d (j+1) := by + have hex : ∃ j,i< B.d (j+1) := ⟨i,(Nat.lt_succ_self i).trans_le (B.ge (i+1))⟩ + let j := Nat.find hex + have hj : i< B.d (j+1) := Nat.find_spec hex + have hlo : B.d j≤ i := by + by_cases h0 : j=0 + · rw [h0,B.zero]; omega + · have hfalse : ¬ i< B.d ((j-1)+1) := Nat.find_min hex (by omega : j-1< j) + have he : j-1+1=j := by omega + rw [he] at hfalse + omega + refine ⟨j,⟨hlo,hj⟩,?_⟩ + intro k hk + apply le_antisymm + · by_contra hn + have hd := B.strictMono.monotone (show j+1≤ k by omega) + omega + · by_contra hn + have hd := B.strictMono.monotone (show k+1≤ j by omega) + omega + +def BlockPartition.number (B : BlockPartition) (i : ℕ) : ℕ := (B.exists_unique i).choose +lemma BlockPartition.number_spec (B : BlockPartition) (i : ℕ) : + B.d (B.number i)≤ i ∧ i< B.d (B.number i+1) := (B.exists_unique i).choose_spec.1 +lemma BlockPartition.number_eq (B : BlockPartition) {i j : ℕ} (hlo : B.d j≤ i) (hhi : i< B.d (j+1)) : + B.number i=j := ((B.exists_unique i).choose_spec.2 j ⟨hlo,hhi⟩).symm + +def BlockPartition.position (B : BlockPartition) (i : ℕ) : Fin (B.m (B.number i)) := + ⟨i-B.d (B.number i),by have hh := B.number_spec i; rw [B.step] at hh; omega⟩ + +def BlockPartition.equiv (B : BlockPartition) : (Σ j,Fin (B.m j)) ≃ ℕ where + toFun x := B.d x.1+x.2.val + invFun i := ⟨B.number i,B.position i⟩ + left_inv x := by + have hn : B.number (B.d x.1+x.2.val)=x.1 := by + apply B.number_eq (by omega) + rw [B.step] + exact Nat.add_lt_add_left x.2.isLt _ + apply Sigma.ext hn + apply (Fin.heq_ext_iff (congrArg B.m hn)).mpr + simp [position,hn] + right_inv i := by + change B.d (B.number i)+(i-B.d (B.number i))=i + exact Nat.add_sub_of_le (B.number_spec i).1 + +lemma BlockPartition.equiv_apply (B : BlockPartition) (j : ℕ) (k : Fin (B.m j)) : + B.equiv ⟨j,k⟩ = B.d j+k.val := rfl +lemma BlockPartition.number_mono (B : BlockPartition) : Monotone B.number := by + intro i k hik + by_contra hh + have hn : B.number k+1≤ B.number i := by omega + have hd := B.strictMono.monotone hn + have hi := B.number_spec i + have hk := B.number_spec k + omega + +lemma BlockPartition.number_tendsto (B : BlockPartition) : Filter.Tendsto B.number Filter.atTop Filter.atTop := by + apply Filter.tendsto_atTop_atTop.mpr + intro j + refine ⟨B.d j,fun i hi => ?_⟩ + by_contra hh + have hn : B.number i+1≤ j := by omega + have hd := B.strictMono.monotone hn + have hh' := B.number_spec i + omega + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/OrbitBounds.lean b/lean/OAI/Analysis/RotationWeights/OrbitBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..48c5793a5ade9fd0cec26d9229244f96f17dc04b --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/OrbitBounds.lean @@ -0,0 +1,452 @@ +import OAI.Analysis.RotationWeights.MeasurableWeight + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uX uY uι + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical + +section +open CircleModel Set Filter MeasureTheory +open scoped Topology BigOperators + +def modelAngle : CircleModel.CircleX := (parameterAngle : CircleModel.CircleX) +def modelGood : Set CircleModel.CircleX := CircleModel.good modelFrequency modelAngle +def modelF (k : ℤ) : CircleModel.CircleX → ℝ := CircleModel.cocycle modelFrequency modelAngle coordinateDrop k +def modelWeight : CircleModel.CircleX → ℝ := modelF 1 + +lemma model_beta (i : ℕ) : CircleModel.beta modelFrequency modelAngle i=coordinatePhase i := by + unfold CircleModel.beta CircleModel.Xi modelAngle coordinatePhase + rw [←AddCircle.coe_nsmul, nsmul_eq_mul,CircleModel.repr_mk] +lemma model_beta_sum : Summable (CircleModel.beta modelFrequency modelAngle) := by + have he : CircleModel.beta modelFrequency modelAngle = coordinatePhase := funext model_beta + rw [he] + exact summable_coordinatePhase +lemma model_good_ae : ∀ᵐ x : CircleModel.CircleX, x∈modelGood := + CircleModel.ae_good (fun i => (frequency_pos (i+1)).ne') modelAngle model_beta_sum +lemma modelGood_measurable : MeasurableSet modelGood := CircleModel.measurableSet_good _ _ +lemma modelF_measurable (k : ℤ) : Measurable (modelF k) := CircleModel.measurable_cocycle _ _ _ _ +lemma modelF_pos (k : ℤ) (x : CircleModel.CircleX) : 0 < modelF k x := CircleModel.cocycle_pos _ _ _ _ _ +lemma modelF_zero (x : CircleModel.CircleX) : modelF 0 x=1 := CircleModel.cocycle_zero _ _ _ _ +lemma modelF_antitone (x : CircleModel.CircleX) : Antitone (fun k => modelF k x) := + CircleModel.cocycle_antitone _ _ _ (fun i => dropSize_nonneg (coordinateBlock i)) x +lemma modelWeight_bounds (x : CircleModel.CircleX) : 0 < modelWeight x ∧ modelWeight x≤1 := by + exact ⟨modelF_pos 1 x,by simpa only [modelWeight, modelF_zero] using modelF_antitone x (show (0:ℤ)≤1 by norm_num)⟩ +lemma modelF_add (k n : ℤ) (x : CircleModel.CircleX) : + modelF (k+n) x=modelF n (CircleModel.shift modelAngle k x)*modelF k x := + CircleModel.cocycle_add _ _ _ _ _ _ +lemma modelGood_shift (k : ℤ) (x : CircleModel.CircleX) : CircleModel.shift modelAngle k x∈modelGood ↔ x∈modelGood := + CircleModel.good_shift _ _ _ _ +lemma modelF_ratio_ordered {x y : CircleModel.CircleX} (hx : x∈modelGood) (hy : y∈modelGood) + (hxy : ∀ i,CircleModel.Xi modelFrequency i x≤CircleModel.Xi modelFrequency i y) (k : ℤ) : + modelF k y/modelF k x≤1 := + CircleModel.cocycle_ratio_ordered coordinateDrop (fun i => dropSize_nonneg (coordinateBlock i)) k hx hy hxy +lemma modelF_ratio_tail {x y : CircleModel.CircleX} (D : ℕ) (hx : x∈modelGood) (hy : y∈modelGood) + (hxy : ∀ i,D ≤ i → CircleModel.Xi modelFrequency i x≤CircleModel.Xi modelFrequency i y) (k : ℤ) : + modelF k y/modelF k x≤Real.exp (∑ i∈Finset.range D,coordinateDrop i) := + CircleModel.cocycle_ratio_tail_bound coordinateDrop (fun i => dropSize_nonneg (coordinateBlock i)) D k hx hy hxy + +lemma phase_orbit (i : ℕ) (n : ℤ) : + modelFrequency i • (n•modelAngle)=((n*coordinatePhase i:ℝ):CircleModel.CircleX) := by + rw [smul_comm,←model_beta] + unfold CircleModel.beta CircleModel.Xi + rw [←zsmul_eq_mul,AddCircle.coe_zsmul,CircleModel.repr_coe] + +lemma model_coordinate_shift (i : ℕ) (n : ℤ) (x : CircleModel.CircleX) : + CircleModel.Xi modelFrequency i (CircleModel.shift modelAngle n x)= + Int.fract (CircleModel.Xi modelFrequency i x+n*coordinatePhase i) := by + rw [CircleModel.Xi_shift,model_beta] +end + +open MeasureTheory Set Filter +open scoped ENNReal Topology +section + +def weightedMeasure {X : Type uX} [MeasurableSpace X] (μ : Measure X) (f : X → ℝ) : Measure X := + μ.withDensity (fun x => ENNReal.ofReal (f x)) +lemma weightedMeasure_finite {X : Type uX} [MeasurableSpace X] (μ : Measure X) {f : X → ℝ} + (hf : Integrable f μ) (hn : ∀ x,0≤f x) : IsFiniteMeasure (weightedMeasure μ f) := by + apply isFiniteMeasure_withDensity + rw [←ofReal_integral_eq_lintegral_ofReal hf (ae_of_all _ hn)] + exact ENNReal.ofReal_ne_top +lemma weightedMeasure_real_apply {X : Type uX} [MeasurableSpace X] (μ : Measure X) {f : X → ℝ} + (hf : Integrable f μ) (hn : ∀ x,0≤f x) {A : Set X} (hA : MeasurableSet A) : + (weightedMeasure μ f).real A=∫ x in A,f x ∂μ := by + rw [Measure.real,weightedMeasure,withDensity_apply _ hA, + ←ofReal_integral_eq_lintegral_ofReal hf.restrict (ae_of_all _ hn),ENNReal.toReal_ofReal] + exact integral_nonneg hn +lemma weightedMeasure_integral {X : Type uX} [MeasurableSpace X] (μ : Measure X) {f : X → ℝ} + (hf : Measurable f) (hn : ∀ x,0≤f x) (g : X → ℝ) : + (∫ x,g x ∂weightedMeasure μ f)=∫ x,f x*g x ∂μ := by + rw [weightedMeasure,integral_withDensity_eq_integral_toReal_smul hf.ennreal_ofReal + (ae_of_all _ (fun _ => ENNReal.ofReal_lt_top))] + simp only [ENNReal.toReal_ofReal (hn _),smul_eq_mul] + +lemma weightedMeasure_map_equiv {X : Type uX} [MeasurableSpace X] (μ : Measure X) + (T : X ≃ᵐ X) (hT : MeasurePreserving T μ μ) (f : X → ℝ) (hf : Measurable f) : + Measure.map T (weightedMeasure μ f)=weightedMeasure μ (fun y => f (T.symm y)) := by + ext A hA + rw [Measure.map_apply T.measurable hA,weightedMeasure,weightedMeasure, + withDensity_apply _ (T.measurable hA),withDensity_apply _ hA] + have hgm : Measurable (A.indicator (fun y => ENNReal.ofReal (f (T.symm y)))) := + (hf.ennreal_ofReal.comp T.symm.measurable).indicator hA + rw [←lintegral_indicator (T.measurable hA),←lintegral_indicator hA] + calc + _ = ∫⁻ x, A.indicator (fun y => ENNReal.ofReal (f (T.symm y))) (T x) ∂μ := by + apply lintegral_congr + intro x + by_cases hx : T x∈A <;> simp [hx] + _ = ∫⁻ y, A.indicator (fun y => ENNReal.ofReal (f (T.symm y))) y ∂Measure.map T μ := + (lintegral_map' hgm.aemeasurable T.measurable.aemeasurable).symm + _ = _ := by rw [hT.map_eq] + +def weightedGraph {X : Type uX} {Y : Type uY} [MeasurableSpace X] [MeasurableSpace Y] + (μ : Measure X) (f : X → ℝ) (T : X → Y) : Measure (X×Y) := + Measure.map (fun x => (x,T x)) (weightedMeasure μ f) +lemma weightedGraph_fst {X : Type uX} {Y : Type uY} [MeasurableSpace X] [MeasurableSpace Y] + (μ : Measure X) (f : X → ℝ) (T : X → Y) (hT : Measurable T) : + Measure.map Prod.fst (weightedGraph μ f T)=weightedMeasure μ f := by + rw [weightedGraph,Measure.map_map measurable_fst (show Measurable (fun x => (x,T x)) from measurable_id.prodMk hT)] + exact Measure.map_id +lemma weightedGraph_snd {X : Type uX} [MeasurableSpace X] (μ : Measure X) + (T : X ≃ᵐ X) (hT : MeasurePreserving T μ μ) (f : X → ℝ) (hf : Measurable f) : + Measure.map Prod.snd (weightedGraph μ f T)=weightedMeasure μ (fun y => f (T.symm y)) := by + rw [weightedGraph,Measure.map_map measurable_snd (show Measurable (fun x => (x,T x)) from measurable_id.prodMk T.measurable)] + exact weightedMeasure_map_equiv μ T hT f hf + +open MeasureTheory Set Filter +open scoped ENNReal Topology BigOperators + +lemma weightedMeasure_add {X : Type uX} [MeasurableSpace X] (μ : Measure X) {f g : X → ℝ} + (hf : Measurable f) (hfn : ∀ x,0≤f x) (hgn : ∀ x,0≤g x) : + weightedMeasure μ (fun x => f x+g x)=weightedMeasure μ f+weightedMeasure μ g := by + unfold weightedMeasure + simp only [ENNReal.ofReal_add (hfn _) (hgn _)] + exact withDensity_add_left hf.ennreal_ofReal _ +lemma weightedMeasure_mul {X : Type uX} [MeasurableSpace X] (μ : Measure X) (f : X → ℝ) + (hf : Measurable f) {c : ℝ} (hc : 0≤c) : + weightedMeasure μ (fun x => c*f x)=ENNReal.ofReal c • weightedMeasure μ f := by + unfold weightedMeasure + simp only [ENNReal.ofReal_mul hc] + exact withDensity_smul _ hf.ennreal_ofReal +lemma weightedMeasure_sum {X : Type uX} {ι : Type uι} [MeasurableSpace X] (μ : Measure X) + (s : Finset ι) (f : ι → X → ℝ) (hf : ∀ i∈s,Measurable (f i)) + (hn : ∀ i∈s,∀ x,0≤f i x) : + weightedMeasure μ (fun x => ∑ i∈s,f i x)=∑ i∈s,weightedMeasure μ (f i) := by + classical + induction s using Finset.induction_on with + | empty => simp [weightedMeasure] + | @insert i s hi ih => + simp only [Finset.mem_insert] at hf hn + simp only [Finset.sum_insert hi] + rw [weightedMeasure_add μ (hf i (Or.inl rfl)) (hn i (Or.inl rfl)) + (fun x => Finset.sum_nonneg (fun k hk => hn k (Or.inr hk) x))] + rw [ih (fun k hk => hf k (Or.inr hk)) (fun k hk => hn k (Or.inr hk))] + +lemma map_finsetSum {X : Type uX} {Y : Type uY} {ι : Type uι} [MeasurableSpace X] [MeasurableSpace Y] + (s : Finset ι) (μ : ι → Measure X) {T : X → Y} (hT : Measurable T) : + Measure.map T (∑ i∈s,μ i)=∑ i∈s,Measure.map T (μ i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => simp only [Finset.sum_insert hi,Measure.map_add _ _ hT,ih] + +def finiteGraphAverage {X : Type uX} {ι : Type uι} [MeasurableSpace X] [Fintype ι] + (μ : Measure X) (w : ι → X → ℝ) (T : ι → X → X) : Measure (X×X) := + ENNReal.ofReal ((Fintype.card ι:ℝ)⁻¹) • ∑ i,weightedGraph μ (w i) (T i) +def finiteAverage {X : Type uX} {ι : Type uι} [Fintype ι] (w : ι → X → ℝ) (x : X) : ℝ := + (Fintype.card ι:ℝ)⁻¹ * ∑ i,w i x + +lemma finiteGraphAverage_fst {X : Type uX} {ι : Type uι} [MeasurableSpace X] [Fintype ι] + (μ : Measure X) (w : ι → X → ℝ) (T : ι → X → X) + (hw : ∀ i,Measurable (w i)) (hn : ∀ i x,0≤w i x) (hT : ∀ i,Measurable (T i)) : + Measure.map Prod.fst (finiteGraphAverage μ w T)=weightedMeasure μ (finiteAverage w) := by + rw [finiteGraphAverage,Measure.map_smul _ measurable_fst.aemeasurable, + map_finsetSum _ _ measurable_fst] + simp_rw [weightedGraph_fst μ _ _ (hT _)] + change _ = weightedMeasure μ (fun x => (Fintype.card ι:ℝ)⁻¹ * ∑ i, w i x) + rw [weightedMeasure_mul _ _ (by fun_prop) (by positivity), + weightedMeasure_sum _ _ _ (fun i _ => hw i) (fun i _ => hn i)] +lemma finiteGraphAverage_snd {X : Type uX} {ι : Type uι} [MeasurableSpace X] [Fintype ι] + (μ : Measure X) (T : ι → X ≃ᵐ X) (hT : ∀ i,MeasurePreserving (T i) μ μ) + (w : ι → X → ℝ) (hw : ∀ i,Measurable (w i)) (hn : ∀ i x,0≤w i x) : + Measure.map Prod.snd (finiteGraphAverage μ w (fun i => T i))= + weightedMeasure μ (finiteAverage (fun i y => w i ((T i).symm y))) := by + rw [finiteGraphAverage,Measure.map_smul _ measurable_snd.aemeasurable, + map_finsetSum _ _ measurable_snd] + simp_rw [weightedGraph_snd μ _ (hT _) _ (hw _)] + change _ = weightedMeasure μ (fun y => (Fintype.card ι:ℝ)⁻¹ * ∑ i, w i ((T i).symm y)) + rw [weightedMeasure_mul _ _ (by fun_prop) (by positivity), + weightedMeasure_sum μ Finset.univ (fun i y => w i ((T i).symm y)) (fun i _ => (hw i).comp (T i).symm.measurable) (fun i _ x => hn i _)] + +lemma finiteGraphAverage_finite {X : Type uX} {ι : Type uι} [MeasurableSpace X] [Fintype ι] + (μ : Measure X) (w : ι → X → ℝ) (T : ι → X → X) + (hw : ∀ i,Integrable (w i) μ) (hn : ∀ i x,0≤w i x) : + IsFiniteMeasure (finiteGraphAverage μ w T) := by + have (i : ι) : IsFiniteMeasure (weightedMeasure μ (w i)) := weightedMeasure_finite μ (hw i) (hn i) + have (i : ι) : IsFiniteMeasure (weightedGraph μ (w i) (T i)) := by unfold weightedGraph; infer_instance + unfold finiteGraphAverage + exact Measure.smul_finite _ ENNReal.ofReal_ne_top + +lemma finiteGraphAverage_ae {X : Type uX} {ι : Type uι} [MeasurableSpace X] [Fintype ι] + (μ : Measure X) (w : ι → X → ℝ) (T : ι → X → X) + (hw : ∀ i,Measurable (w i)) (hT : ∀ i,Measurable (T i)) + (P : X×X → Prop) (hP : MeasurableSet {z | P z}) + (hp : ∀ i,∀ᵐ x ∂μ,w i x≠0 → P (x,T i x)) : + ∀ᵐ z ∂finiteGraphAverage μ w T,P z := by + unfold finiteGraphAverage + apply Measure.ae_smul_measure + apply ae_finsetSum_measure_iff.mpr + intro i _ + rw [weightedGraph] + apply (ae_map_iff (show Measurable (fun x => (x,T i x)) from measurable_id.prodMk (hT i)).aemeasurable hP).mpr + rw [weightedMeasure,ae_withDensity_iff (hw i).ennreal_ofReal] + filter_upwards [hp i] with x hx hne + apply hx + intro hz + exact hne (by simp [hz]) +end + +section +open ContinuousCircleWeight.Sampling MeasureTheory Set CircleModel +open scoped BigOperators + +lemma stageEll_pos (j : ℕ) : 0 < scaleEll (blockLength j) := + Real.rpow_pos_of_pos (Nat.cast_pos.mpr (scaleStep j).mpos) _ +lemma stageEll_lt (j : ℕ) : scaleEll (blockLength j) < 1 := by + apply Real.rpow_lt_one_of_one_lt_of_neg + · exact_mod_cast (by have := blockLength_ge j; omega : 1 < blockLength j) + · norm_num +lemma stageAlpha_pos (j : ℕ) : 0 < scaleAlpha (blockLength j) := + Real.rpow_pos_of_pos (Nat.cast_pos.mpr (scaleStep j).mpos) _ + +def stageFactor (positive : Bool) (j : ℕ) (n : ℤ) (i : Fin (blockLength j)) (x : CircleModel.CircleX) : ℝ := + orientedWeight positive (scaleEll (blockLength j)) (scaleAlpha (blockLength j)) + (((scaleStep j).q (i+1):ℤ) • x) + (((n:ℝ)*Int.fract (((scaleStep j).q (i+1):ℝ)*parameterAngle):ℝ):CircleModel.CircleX) +def stageWeight (positive : Bool) (j : ℕ) (n : ℤ) (x : CircleModel.CircleX) : ℝ := + ∏ i : Fin (blockLength j), stageFactor positive j n i x + +lemma stageFactor_measurable (positive : Bool) (j : ℕ) (n : ℤ) (i : Fin (blockLength j)) : + Measurable (stageFactor positive j n i) := + (measurable_orientedWeight _ _ _).comp ((continuous_id.zsmul _).measurable.prodMk measurable_const) +lemma stageFactor_bounds (positive : Bool) (j : ℕ) (n : ℤ) (i : Fin (blockLength j)) (x : CircleModel.CircleX) : + 0 ≤ stageFactor positive j n i x ∧ + stageFactor positive j n i x ≤ 1/(scaleEll (blockLength j)*scaleAlpha (blockLength j)) := + orientedWeight_bounds positive (stageEll_pos j) (stageAlpha_pos j) _ _ +lemma stageWeight_measurable (positive : Bool) (j : ℕ) (n : ℤ) : Measurable (stageWeight positive j n) := by + unfold stageWeight + exact Finset.measurable_prod _ (fun i _ => stageFactor_measurable _ _ _ i) +lemma stageWeight_bounds (positive : Bool) (j : ℕ) (n : ℤ) (x : CircleModel.CircleX) : + 0 ≤ stageWeight positive j n x ∧ stageWeight positive j n x ≤ + (1/(scaleEll (blockLength j)*scaleAlpha (blockLength j)))^(blockLength j) := by + constructor + · exact Finset.prod_nonneg (fun i _ => (stageFactor_bounds positive j n i x).1) + · have h := Finset.prod_le_prod₀ (s:=Finset.univ) (fun i _ => (stageFactor_bounds positive j n i x).1) + (fun i _ => (stageFactor_bounds positive j n i x).2) + simpa [stageWeight] using h +lemma stageWeight_memLp (positive : Bool) (j : ℕ) (n : ℤ) : MemLp (stageWeight positive j n) 2 := by + apply MemLp.of_bound (stageWeight_measurable positive j n).aestronglyMeasurable + ((1/(scaleEll (blockLength j)*scaleAlpha (blockLength j)))^(blockLength j)) + exact ae_of_all _ (fun x => by rw [Real.norm_of_nonneg (stageWeight_bounds positive j n x).1]; exact (stageWeight_bounds positive j n x).2) + +lemma stage_frequency (j : ℕ) (i : Fin (blockLength j)) : + modelFrequency (blocks.equiv ⟨j,i⟩)=(scaleStep j).q (i+1) := by + change frequency (blockEnd j+i.val+1)=_ + rw [show blockEnd j+i.val+1=blockEnd j+(i.val+1) by omega,frequency_block j (by omega)] +lemma stage_phase (j : ℕ) (i : Fin (blockLength j)) : + coordinatePhase (blocks.equiv ⟨j,i⟩) = Int.fract (((scaleStep j).q (i+1):ℝ)*parameterAngle) := by + unfold coordinatePhase + rw [stage_frequency] +lemma stageFactor_model (positive : Bool) (j : ℕ) (n : ℤ) (i : Fin (blockLength j)) (x : CircleModel.CircleX) : + stageFactor positive j n i x = orientedWeight positive (scaleEll (blockLength j)) (scaleAlpha (blockLength j)) + (modelFrequency (blocks.equiv ⟨j,i⟩) • x) (modelFrequency (blocks.equiv ⟨j,i⟩) • (n • modelAngle)) := by + rw [phase_orbit,stage_phase,stage_frequency] + rfl +lemma stageWeight_negative (j : ℕ) (n : ℤ) (x : CircleModel.CircleX) : + stageWeight false j n x = stageWeight true j n (CircleModel.shift modelAngle (-n) x) := by + apply Finset.prod_congr rfl + intro i _ + simp only [stageFactor_model,orientedWeight,Bool.false_eq_true,↓reduceIte,uNeg,CircleModel.shift,neg_smul] + rw [smul_add,smul_neg,sub_eq_add_neg] + +instance stageSample_nonempty (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + Nonempty ((scaleStep j).samples t) := (scaleStep j).samples_nonempty t |>.coe_sort + +def stageDensity (positive : Bool) (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : CircleModel.CircleX → ℝ := + finiteAverage (fun n : (scaleStep j).samples t => stageWeight positive j n.val) +lemma stageDensity_measurable (positive : Bool) (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + Measurable (stageDensity positive j t) := by + unfold stageDensity finiteAverage + exact (Finset.measurable_sum _ (fun n _ => stageWeight_measurable positive j n.val)).const_mul _ +lemma stageDensity_nonneg (positive : Bool) (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) (x : CircleModel.CircleX) : + 0 ≤ stageDensity positive j t x := by + apply mul_nonneg (by positivity) + exact Finset.sum_nonneg (fun n _ => (stageWeight_bounds positive j n.val x).1) +lemma stageDensity_memLp (positive : Bool) (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + MemLp (stageDensity positive j t) 2 := by + have h : MemLp (fun x => ∑ n : (scaleStep j).samples t, stageWeight positive j n.val x) 2 := + memLp_finsetSum Finset.univ (fun n _ => stageWeight_memLp positive j n.val) + exact h.const_mul _ +lemma stageDensity_energy (positive : Bool) (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) : + (∫ x, (stageDensity positive j t x-1)^2) < 1/((j:ℝ)+1)^2 := by + exact (scaleStep j).energies parameterAngle (parameterAngle_spec.2.2.2 j) t positive +end + +open CircleModel Set MeasureTheory +open scoped BigOperators + +def sampleBound (j : ℕ) : ℝ := (blockLength j:ℝ)^((7:ℝ)/10*blockLength j) +def oldGraphBad (j : ℕ) : Set CircleX := + ⋃ i : Fin (blockEnd j), {x | 1-(modelFrequency i:ℝ)*gridTolerance j (scaleState j).1 ≤ CircleModel.Xi modelFrequency i x} +def tailGraphBad (j : ℕ) : Set CircleX := + ⋃ i : {i : ℕ // blockEnd (j+1) ≤ i}, {x | 1-sampleBound j*coordinatePhase i ≤ CircleModel.Xi modelFrequency i x} +def graphBad (j : ℕ) : Set CircleX := oldGraphBad j ∪ tailGraphBad j +lemma graphBad_measurable (j : ℕ) : MeasurableSet (graphBad j) := + (MeasurableSet.iUnion (fun _ => measurableSet_le measurable_const (CircleModel.measurable_Xi _ _))).union + (MeasurableSet.iUnion (fun _ => measurableSet_le measurable_const (CircleModel.measurable_Xi _ _))) +lemma sampleBound_pos (j : ℕ) : 0 < sampleBound j := + Real.rpow_pos_of_pos (Nat.cast_pos.mpr (scaleStep j).mpos) _ +lemma sample_bound (j : ℕ) {t : Fin ((scaleState j).1.q (scaleState j).1.d)} {n : ℤ} + (hn : n∈(scaleStep j).samples t) : 0 < n ∧ (n:ℝ) ≤ sampleBound j := by + have h := (scaleStep j).samples_bounds t n hn + refine ⟨?_,h.2⟩ + have hh : (0:ℝ) < n := lt_of_lt_of_le (half_pos (sampleBound_pos j)) h.1 + exact_mod_cast hh +lemma coordinate_add_nowrap (q : ℕ) (x y : CircleX) (t : ℝ) + (he : q•y=(t:CircleX)) (ht : 0 ≤ t) + (hu : CircleModel.repr (q•x)+t < 1) : + CircleModel.repr (q • (x+y))=CircleModel.repr (q•x)+t := by + have he' : q • (x+y)=((CircleModel.repr (q • x)+t:ℝ):CircleX) := by + rw [nsmul_add,he,AddCircle.coe_add,CircleModel.repr_coe] + rw [he',CircleModel.repr_mk] + exact Int.fract_eq_self.mpr ⟨add_nonneg (CircleModel.repr_mem _).1 ht,hu⟩ +lemma positive_weight_order {ℓ α : ℝ} (hℓ : ℓ < 1) (hα : 0 < α) (s t : CircleX) + (hw : uPos ℓ α s t ≠ 0) : CircleModel.repr s ≤ CircleModel.repr (s+t) := by + have hh : α ≤ delta (repr s) ∧ 0 < repr t ∧ repr t < ℓ*delta (repr s) := by + by_cases hh : α ≤ delta (repr s) ∧ 0 < repr t ∧ repr t < ℓ*delta (repr s) + · exact hh + · exact False.elim (hw (by simp only [uPos,weight,ite_eq_right hh])) + have hd : 0 < delta (repr s) := lt_of_lt_of_le hα hh.1 + have hst : repr s+repr t < 1 := by + have : ℓ*delta (repr s) < delta (repr s) := (mul_lt_iff_lt_one_left hd).mpr hℓ + have := min_le_right (repr s) (1-repr s) + unfold delta at * + linarith [hh.2.2] + have he : CircleModel.repr (s+t)=CircleModel.repr s+CircleModel.repr t := by + simpa only [one_nsmul] using coordinate_add_nowrap 1 s t (CircleModel.repr t) + (by simpa using (CircleModel.repr_coe t).symm) hh.2.1.le (by simpa only [one_nsmul,repr,CircleModel.repr] using hst) + rw [he] + exact le_add_of_nonneg_right hh.2.1.le +lemma stageWeight_order (j : ℕ) (n : ℤ) (x : CircleX) + (hw : stageWeight true j n x ≠ 0) (i : Fin (blockLength j)) : + CircleModel.Xi modelFrequency (blocks.equiv ⟨j,i⟩) x ≤ + CircleModel.Xi modelFrequency (blocks.equiv ⟨j,i⟩) (CircleModel.shift modelAngle n x) := by + have hfactor : stageFactor true j n i x ≠ 0 := (Finset.prod_ne_zero_iff.mp hw) i (Finset.mem_univ _) + rw [stageFactor_model] at hfactor + change uPos _ _ _ _ ≠ 0 at hfactor + have h := positive_weight_order (stageEll_lt j) (stageAlpha_pos j) _ _ hfactor + simpa only [CircleModel.Xi,CircleModel.shift,nsmul_add] using h + +lemma restricted_orbit_order (j D : ℕ) (h : CircleX) + (hperiod : ∀ i, D ≤ i → modelFrequency i•h=0) + (t : Fin ((scaleState j).1.q (scaleState j).1.d)) + (ht : gridPoint (scaleState j).1 t=h) + (n : ℤ) (hn : n∈(scaleStep j).samples t) (x : CircleX) + (hx : x∉graphBad j) (hw : stageWeight true j n x ≠ 0) : + ∀ i, D ≤ i → CircleModel.Xi modelFrequency i x ≤ + CircleModel.Xi modelFrequency i (CircleModel.shift modelAngle n x) := by + have ho := (scaleStep j).orbits parameterAngle (parameterAngle_spec.2.2.2 j) t n hn + rw [ht] at ho + obtain ⟨δ,hδ,hδeq⟩ := ho + have hδn : n•modelAngle=h+(δ:CircleX) := by + change (δ:CircleX)=n•modelAngle-h at hδeq + exact (sub_eq_iff_eq_add.mp hδeq.symm).trans (add_comm _ _) + intro i hi + by_cases hold : i < blockEnd j + · have hbad : CircleModel.Xi modelFrequency i x < 1-(modelFrequency i:ℝ)*gridTolerance j (scaleState j).1 := by + by_contra! hh + exact hx (Or.inl (mem_iUnion.mpr ⟨⟨i,hold⟩,hh⟩)) + have he : modelFrequency i•(n•modelAngle)=(((modelFrequency i:ℝ)*δ:ℝ):CircleX) := by + rw [hδn,nsmul_add,hperiod i hi,zero_add,←AddCircle.coe_nsmul,nsmul_eq_mul] + have hval := coordinate_add_nowrap (modelFrequency i) x (n•modelAngle) + ((modelFrequency i:ℝ)*δ) he (mul_nonneg (Nat.cast_nonneg _) hδ.1.le) + (by change CircleModel.Xi modelFrequency i x+_ < 1 + have hdiff : (modelFrequency i:ℝ)*δ < (modelFrequency i:ℝ)*gridTolerance j (scaleState j).1 := + mul_lt_mul_of_pos_left hδ.2 (Nat.cast_pos.mpr (frequency_pos (i+1))) + linarith) + change CircleModel.Xi modelFrequency i x ≤ CircleModel.repr (modelFrequency i•(x+n•modelAngle)) + rw [hval] + exact le_add_of_nonneg_right (mul_nonneg (Nat.cast_nonneg _) hδ.1.le) + · by_cases htail : blockEnd (j+1) ≤ i + · have hbad : CircleModel.Xi modelFrequency i x < 1-sampleBound j*coordinatePhase i := by + by_contra! hh + exact hx (Or.inr (mem_iUnion.mpr ⟨⟨i,htail⟩,hh⟩)) + have hn0 : 0 ≤ (n:ℝ) := by exact_mod_cast (sample_bound j hn).1.le + have hval := coordinate_add_nowrap (modelFrequency i) x (n•modelAngle) + ((n:ℝ)*coordinatePhase i) (phase_orbit i n) + (mul_nonneg hn0 (coordinatePhase_pos i).le) + (by change CircleModel.Xi modelFrequency i x+_ < 1 + nlinarith [mul_le_mul_of_nonneg_right (sample_bound j hn).2 (coordinatePhase_pos i).le]) + change CircleModel.Xi modelFrequency i x ≤ CircleModel.repr (modelFrequency i•(x+n•modelAngle)) + rw [hval] + exact le_add_of_nonneg_right (mul_nonneg hn0 (coordinatePhase_pos i).le) + · have hem : blockEnd (j+1)=blockEnd j+blockLength j := rfl + let k : Fin (blockLength j) := ⟨i-blockEnd j,by omega⟩ + have he : blocks.equiv ⟨j,k⟩=i := by change blockEnd j+(i-blockEnd j)=i; omega + simpa only [he] using stageWeight_order j n x hw k + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Parameters.lean b/lean/OAI/Analysis/RotationWeights/Parameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..d251b20d4def4c6f4639b1cc887b3151b9d48c5c --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Parameters.lean @@ -0,0 +1,276 @@ +import OAI.Analysis.RotationWeights.NestedAngles + +namespace OAI + +noncomputable section + +namespace CircleSampling + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set + +section +open Set Filter MeasureTheory ContinuousCircleWeight.Sampling +open scoped Topology + +def blockLength (j : ℕ) : ℕ := (scaleStep j).m +def blockEnd (j : ℕ) : ℕ := (scaleState j).1.d +def polynomialWindow (j : ℕ) : ℕ := (scaleState j).1.K +def dropSize (j : ℕ) : ℝ := (scaleStep j).C +def crossingBudget (j : ℕ) : ℝ := (scaleStep j).L +def bridgeSize (j : ℕ) : ℝ := (scaleState j).1.G +def frequency (i : ℕ) : ℕ := (scaleState i).1.q i + +def blocks : BlockPartition where + m := blockLength + d := blockEnd + zero := rfl + step := fun _ => rfl + positive := fun j => (scaleStep j).mpos + +lemma blockEnd_strictMono : StrictMono blockEnd := blocks.strictMono +lemma blockEnd_ge (j : ℕ) : j≤blockEnd j := blocks.ge j +lemma state_prefix (j i : ℕ) (hi : i≤blockEnd j) : (scaleState (j+1)).1.q i=(scaleState j).1.q i := + extendPrefix_old _ _ _ hi +lemma frequency_eq_state {j i : ℕ} (hi : i≤blockEnd j) : frequency i=(scaleState j).1.q i := + diagonal_prefix_eq blockEnd (fun j => (scaleState j).1.q) + blockEnd_strictMono.monotone blockEnd_ge state_prefix hi + +lemma frequency_block (j : ℕ) {k : ℕ} (hk : k≤blockLength j) : + frequency (blockEnd j+k)=(scaleStep j).q k := by + rw [frequency_eq_state (j:=j+1) (show blockEnd j+k≤blockEnd (j+1) by + change blockEnd j+k≤blockEnd j+blockLength j; omega)] + exact extendPrefix_block _ _ _ (scaleStep j).qzero k +lemma frequency_zero : frequency 0=1 := rfl +lemma frequency_pos (i : ℕ) : 0 < frequency i := (scaleState i).2.qpos i (blockEnd_ge i) +lemma frequency_dvd (i : ℕ) : frequency i∣frequency (i+1) := by + rw [frequency_eq_state (j:=i+1) (by have := blockEnd_ge (i+1); omega),frequency_eq_state (j:=i+1) (blockEnd_ge _)] + exact (scaleState (i+1)).2.qdvd i (by change i (polynomialWindow_gt_length j).trans_le (polynomialWindow_le_length (j+1)) +lemma blockLength_ge (j : ℕ) : 200≤blockLength j := (scaleStep j).numeric.1 +lemma crossingBudget_mono : Monotone crossingBudget := + monotone_nat_of_le_succ fun j => (scaleStep (j+1)).Lprev +lemma dropSize_ge_budget (j : ℕ) : crossingBudget j≤dropSize j := le_max_left _ _ +lemma dropSize_nonneg (j : ℕ) : 0≤dropSize j := + (by change 0≤(scaleStep j).L; linarith [(scaleStep j).Lge] : 0≤crossingBudget j).trans (dropSize_ge_budget j) +lemma exponent_prefix (j : ℕ) : (scaleState j).1.E=∑ t∈Finset.range j,dropSize t*blockLength t := by + induction j with + | zero => simp [scaleState,initialScaleState] + | succ j ih => + change (scaleState j).1.E+dropSize j*blockLength j=_ + rw [Finset.sum_range_succ,ih] + +lemma polynomialWindow_geometric (j n : ℕ) : 2^n*polynomialWindow j≤polynomialWindow (j+n) := by + induction n with + | zero => simp + | succ n ih => + have hg := (polynomialWindow_growth (j+n)).le + calc + 2^(n+1)*polynomialWindow j = 2*(2^n*polynomialWindow j) := by ring + _ ≤ 2*polynomialWindow (j+n) := Nat.mul_le_mul_left _ ih + _ ≤ polynomialWindow (j+(n+1)) := by simpa only [Nat.add_assoc] using hg + +lemma frequency_block_ratio (j : ℕ) {k : ℕ} (hk : k 1/(polynomialWindow (j+n):ℝ)) := by + apply Summable.of_nonneg_of_le (fun _ => by positivity) (window_inverse_bound j) + exact (summable_geometric_of_norm_lt_one (x:=(1/2:ℝ)) (by norm_num)).mul_left _ + +lemma tsum_window_inverse (j : ℕ) : + (∑' n,1/(polynomialWindow (j+n):ℝ)) ≤ 2/(polynomialWindow j:ℝ) := by + have hs := (summable_geometric_of_norm_lt_one (x:=(1/2:ℝ)) (by norm_num)).mul_left (1/(polynomialWindow j:ℝ)) + calc + _ ≤ ∑' n,(1/(polynomialWindow j:ℝ))*(1/2:ℝ)^n := + (summable_window_inverse j).tsum_le_tsum (window_inverse_bound j) hs + _ = 2/(polynomialWindow j:ℝ) := by + rw [tsum_mul_left,tsum_geometric_of_norm_lt_one (by norm_num : ‖(1/2:ℝ)‖<1)] + ring + +lemma sum_phase_block (j : ℕ) : + (∑ i : Fin (blockLength j), coordinatePhase (blocks.equiv ⟨j,i⟩)) ≤ 2/(polynomialWindow j:ℝ) := by + have hm : (blockLength j:ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (scaleStep j).mpos.ne' + calc + _ ≤ ∑ _i : Fin (blockLength j),2/((blockLength j:ℝ)*polynomialWindow j) := + Finset.sum_le_sum (fun i _ => (coordinatePhase_block j i).2.le) + _ = 2/(polynomialWindow j:ℝ) := by simp; field_simp + +lemma summable_coordinatePhase : Summable coordinatePhase := by + have hs : Summable (fun j => 2/(polynomialWindow j:ℝ)) := by + simpa only [Nat.zero_add,div_eq_mul_inv,one_mul] using (summable_window_inverse 0).mul_left 2 + have ht : Summable (fun j => ∑ i : Fin (blockLength j), coordinatePhase (blocks.equiv ⟨j,i⟩)) := + Summable.of_nonneg_of_le (fun _ => Finset.sum_nonneg (fun _ _ => (coordinatePhase_pos _).le)) + sum_phase_block hs + apply blocks.equiv.summable_iff.mp + apply (summable_sigma_of_nonneg (fun x : Σ j, Fin (blocks.m j) => (coordinatePhase_pos (blocks.equiv x)).le)).mpr + refine ⟨fun _ => Summable.of_finite,?_⟩ + convert ht using 1 + ext j + rw [tsum_fintype] + rfl + +lemma block_number_equiv (j : ℕ) (i : Fin (blockLength j)) : + coordinateBlock (blocks.equiv ⟨j,i⟩)=j := by + exact blocks.number_eq (by change blockEnd j≤blockEnd j+i.val; omega) + (by change blockEnd j+i.val 1/(blockLength j:ℝ)) := by + apply Summable.of_nonneg_of_le (fun _ => by positivity) + (fun j => one_div_le_one_div_of_le (Nat.cast_pos.mpr (polynomialWindow_pos j)) + (Nat.cast_le.mpr (polynomialWindow_le_length j))) + simpa using summable_window_inverse 0 + +lemma dropSize_ge_window_sq (j : ℕ) : (polynomialWindow j:ℝ)^2≤dropSize j := le_max_right _ _ + +lemma phase_drop_block_lower (j : ℕ) : + (polynomialWindow j:ℝ) ≤ ∑ i : Fin (blockLength j), + coordinateDrop (blocks.equiv ⟨j,i⟩)*coordinatePhase (blocks.equiv ⟨j,i⟩) := by + have hK : 0<(polynomialWindow j:ℝ) := Nat.cast_pos.mpr (polynomialWindow_pos j) + have hm : 0<(blockLength j:ℝ) := Nat.cast_pos.mpr (scaleStep j).mpos + calc + _ = (blockLength j:ℝ)*((polynomialWindow j:ℝ)^2/((blockLength j:ℝ)*polynomialWindow j)) := by field_simp + _ = ∑ _i : Fin (blockLength j),(polynomialWindow j:ℝ)^2/((blockLength j:ℝ)*polynomialWindow j) := by simp + _ ≤ _ := by + apply Finset.sum_le_sum + intro i _ + change _≤dropSize (coordinateBlock (blocks.equiv ⟨j,i⟩))*_ + rw [block_number_equiv] + calc + _ = (polynomialWindow j:ℝ)^2*(1/((blockLength j:ℝ)*polynomialWindow j)) := by ring + _ ≤ dropSize j*coordinatePhase (blocks.equiv ⟨j,i⟩) := by + exact mul_le_mul (dropSize_ge_window_sq j) (coordinatePhase_block j i).1.le (by positivity) (dropSize_nonneg j) + +lemma not_summable_phase_drop : ¬Summable (fun i => coordinateDrop i*coordinatePhase i) := by + intro hs + have hn : ∀ i,0≤coordinateDrop i*coordinatePhase i := + fun i => mul_nonneg (dropSize_nonneg _) (coordinatePhase_pos i).le + have ht := (summable_sigma_of_nonneg (fun x => hn (blocks.equiv x))).mp (blocks.equiv.summable_iff.mpr hs) + have hone : Summable (fun _j : ℕ => (1:ℝ)) := by + apply Summable.of_nonneg_of_le (fun _ => by norm_num) (fun j => ?_) ht.2 + calc + 1 ≤ (polynomialWindow j:ℝ) := by exact_mod_cast polynomialWindow_pos j + _ ≤ ∑' i : Fin (blockLength j), coordinateDrop (blocks.equiv ⟨j,i⟩)*coordinatePhase (blocks.equiv ⟨j,i⟩) := by + simpa only [tsum_fintype] using phase_drop_block_lower j + have hzero := (summable_const_iff (1:ℝ)).mp hone + norm_num at hzero + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/PhaseWeights.lean b/lean/OAI/Analysis/RotationWeights/PhaseWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d66f819a57d386bc9ef55e10d57764efc23fdfc --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/PhaseWeights.lean @@ -0,0 +1,521 @@ +import OAI.Analysis.RotationWeights.FourierSampling + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uE + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate + +abbrev CircleX := AddCircle (1 : ℝ) + +instance : IsProbabilityMeasure (volume : Measure CircleX) := by + rw [AddCircle.volume_eq_smul_haarAddCircle] + norm_num + infer_instance + +lemma volume_singleton_zero (s : CircleX) : volume ({s} : Set CircleX) = 0 := by + rw [← Metric.closedBall_zero, AddCircle.volume_closedBall] + norm_num + +def repr (x : CircleX) : ℝ := (AddCircle.measurableEquivIco 1 0 x).val +lemma measurable_repr : Measurable repr := + measurable_subtype_coe.comp (AddCircle.measurableEquivIco 1 0).measurable +lemma repr_mem (x : CircleX) : repr x ∈ Ico 0 1 := by + simpa only [repr, zero_add] using (AddCircle.measurableEquivIco 1 0 x).property +lemma repr_coe {s : ℝ} (hs : s ∈ Ico 0 1) : repr (s : CircleX) = s := by + exact congrArg Subtype.val (AddCircle.equivIco_coe_eq (by simpa using hs)) +lemma coe_repr (x : CircleX) : (repr x : CircleX) = x := + AddCircle.coe_equivIco + +lemma integral_repr {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : ℝ → E) : ∫ x : CircleX, f (repr x) = ∫ s in Ioc 0 1, f s := by + rw [← AddCircle.integral_preimage (1 : ℝ) 0] + simp only [zero_add] + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioc, + ae_restrict_of_ae (show ∀ᵐ s : ℝ, s ≠ 1 from by simp [ae_iff])] with s hs hne + rw [repr_coe ⟨le_of_lt hs.1, lt_of_le_of_ne hs.2 hne⟩] + +def delta (s : ℝ) : ℝ := min s (1-s) +def weight (ℓ α s t : ℝ) : ℝ := + if α ≤ delta s ∧ 0 < t ∧ t < ℓ * delta s then 1 / (ℓ * delta s) else 0 +def uPos (ℓ α : ℝ) (s t : CircleX) : ℝ := weight ℓ α (repr s) (repr t) +def uNeg (ℓ α : ℝ) (s t : CircleX) : ℝ := uPos ℓ α (s-t) t + +lemma measurable_delta : Measurable delta := by unfold delta; fun_prop +lemma measurable_weight (ℓ α : ℝ) : Measurable (fun z : ℝ × ℝ ↦ weight ℓ α z.1 z.2) := by + unfold weight + exact Measurable.ite ((measurableSet_le measurable_const (measurable_delta.comp measurable_fst)).inter + ((measurableSet_lt measurable_const measurable_snd).inter + (measurableSet_lt measurable_snd (measurable_const.mul (measurable_delta.comp measurable_fst))))) + (measurable_const.div (measurable_const.mul (measurable_delta.comp measurable_fst))) measurable_const +lemma measurable_uPos (ℓ α : ℝ) : Measurable (Function.uncurry (uPos ℓ α)) := + (measurable_weight ℓ α).comp ((measurable_repr.comp measurable_fst).prodMk + (measurable_repr.comp measurable_snd)) +lemma measurable_uNeg (ℓ α : ℝ) : Measurable (Function.uncurry (uNeg ℓ α)) := + (measurable_uPos ℓ α).comp ((measurable_fst.sub measurable_snd).prodMk measurable_snd) + +lemma weight_bounds {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) (s t : ℝ) : + 0 ≤ weight ℓ α s t ∧ weight ℓ α s t ≤ 1 / (ℓ * α) := by + unfold weight + split_ifs with h + · have hd : 0 < ℓ * delta s := mul_pos hℓ (lt_of_lt_of_le hα h.1) + exact ⟨le_of_lt (one_div_pos.mpr hd), + one_div_le_one_div_of_le (mul_pos hℓ hα) (mul_le_mul_of_nonneg_left h.1 hℓ.le)⟩ + · exact ⟨le_rfl, (one_div_pos.mpr (mul_pos hℓ hα)).le⟩ + +lemma delta_lipschitz (s t : ℝ) : |delta s - delta t| ≤ |s-t| := by + rw [abs_le] + have h1 := le_abs_self (s-t) + have h2 := neg_abs_le (s-t) + unfold delta + simp only [min_def] + split_ifs <;> constructor <;> linarith +lemma delta_pos {s : ℝ} (hs : s ∈ Ioo 0 1) : 0 < delta s := by + exact lt_min hs.1 (sub_pos.mpr hs.2) +lemma delta_le_half (s : ℝ) : delta s ≤ 1/2 := by + unfold delta + rcases le_total s (1/2) with h | h + · exact le_trans (min_le_left _ _) h + · exact le_trans (min_le_right _ _) (by linarith) + +lemma weight_integral_t {ℓ α s : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) (hα : 0 < α) : + (∫ t in Ioc 0 1, weight ℓ α s t) = if α ≤ delta s then 1 else 0 := by + by_cases h : α ≤ delta s + · have hd : 0 < ℓ * delta s := mul_pos hℓ (lt_of_lt_of_le hα h) + have hd1 : ℓ * delta s < 1 := by + have := delta_le_half s + nlinarith + have he : (fun t ↦ weight ℓ α s t) = (Ioo 0 (ℓ * delta s)).indicator + (fun _ ↦ 1 / (ℓ * delta s)) := by + ext t + simp only [weight, h, true_and, indicator, mem_Ioo] + rw [he, integral_indicator measurableSet_Ioo, Measure.restrict_restrict measurableSet_Ioo] + have hs : Ioo 0 (ℓ * delta s) ∩ Ioc 0 1 = Ioo 0 (ℓ * delta s) := by + apply inter_eq_left.mpr + intro t ht + exact ⟨ht.1, le_of_lt (lt_trans ht.2 hd1)⟩ + rw [hs, integral_const] + simp only [Measure.real, Measure.restrict_apply_univ, Real.volume_Ioo, sub_zero, + ENNReal.toReal_ofReal hd.le, smul_eq_mul, ite_eq_left h] + exact mul_one_div_cancel hd.ne' + · simp [weight, h] + +lemma uPos_integral_t {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) (hα : 0 < α) + (s : CircleX) : (∫ t, uPos ℓ α s t) = if α ≤ delta (repr s) then 1 else 0 := by + change (∫ t : CircleX, weight ℓ α (repr s) (repr t)) = _ + rw [integral_repr] + exact weight_integral_t hℓ hℓ1 hα + +lemma integral_uPos {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hα2 : α ≤ 1/2) : + (∫ s : CircleX, ∫ t : CircleX, uPos ℓ α s t) = 1 - 2 * α := by + simp_rw [uPos_integral_t hℓ hℓ1 hα] + change (∫ s : CircleX, (fun r ↦ if α ≤ delta r then (1 : ℝ) else 0) (repr s)) = _ + rw [integral_repr (fun r : ℝ ↦ if α ≤ delta r then (1 : ℝ) else 0)] + have he : (fun s : ℝ ↦ if α ≤ delta s then (1 : ℝ) else 0) = (Icc α (1-α)).indicator (fun _ ↦ 1) := by + ext s + simp [delta, indicator, mem_Icc, le_sub_comm] + rw [he, integral_indicator measurableSet_Icc, Measure.restrict_restrict measurableSet_Icc] + have hs : Icc α (1-α) ∩ Ioc 0 1 = Icc α (1-α) := by + apply inter_eq_left.mpr + intro s hs + exact ⟨lt_of_lt_of_le hα hs.1, le_trans hs.2 (by linarith)⟩ + rw [hs, integral_const] + simp [Measure.real, Real.volume_Icc, show 0 ≤ (1-α)-α by linarith] + ring + +lemma integrable_uPos {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) : + Integrable (Function.uncurry (uPos ℓ α)) (volume.prod volume) := by + apply Integrable.of_bound (measurable_uPos ℓ α).aestronglyMeasurable (1 / (ℓ * α)) + filter_upwards [] with z + rcases weight_bounds hℓ hα (repr z.1) (repr z.2) with ⟨h0, hB⟩ + simpa only [Function.uncurry, uPos, Real.norm_eq_abs, abs_of_nonneg h0] using hB + +lemma integrable_uNeg {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) : + Integrable (Function.uncurry (uNeg ℓ α)) (volume.prod volume) := by + apply Integrable.of_bound (measurable_uNeg ℓ α).aestronglyMeasurable (1 / (ℓ * α)) + filter_upwards [] with z + rcases weight_bounds hℓ hα (repr (z.1-z.2)) (repr z.2) with ⟨h0, hB⟩ + simpa only [Function.uncurry, uNeg, uPos, Real.norm_eq_abs, abs_of_nonneg h0] using hB + +lemma integral_uNeg {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hα2 : α ≤ 1/2) : + (∫ s : CircleX, ∫ t : CircleX, uNeg ℓ α s t) = 1 - 2 * α := by + rw [integral_integral_swap (integrable_uNeg hℓ hα)] + have he (t : CircleX) : (∫ s : CircleX, uNeg ℓ α s t) = ∫ s : CircleX, uPos ℓ α s t := + integral_sub_right_eq_self (fun s ↦ uPos ℓ α s t) t + simp_rw [he] + rw [← integral_integral_swap (integrable_uPos hℓ hα)] + exact integral_uPos hℓ hℓ1 hα hα2 + +lemma weight_sq_integral_t {ℓ α s : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) (hα : 0 < α) : + (∫ t in Ioc 0 1, (weight ℓ α s t)^2) = + if α ≤ delta s then 1 / (ℓ * delta s) else 0 := by + have he : (fun t ↦ (weight ℓ α s t)^2) = + (fun t ↦ (1 / (ℓ * delta s)) * weight ℓ α s t) := by + ext t + unfold weight + split_ifs <;> ring + rw [he, integral_const_mul, weight_integral_t hℓ hℓ1 hα] + split_ifs <;> simp + +lemma integral_inv_delta {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) (hα2 : α ≤ 1/2) : + (∫ s in Icc α (1-α), 1 / (ℓ * delta s)) = + (2 / ℓ) * Real.log (1 / (2*α)) := by + have hab : α ≤ 1-α := by linarith + have hc : ContinuousOn (fun s : ℝ ↦ 1 / (ℓ * delta s)) (Icc α (1-α)) := by + apply continuousOn_const.div (continuousOn_const.mul ((continuous_id.min (continuous_const.sub continuous_id)).continuousOn)) + intro s hs + change ℓ * min s (1-s) ≠ 0 + exact ne_of_gt (mul_pos hℓ (lt_min (lt_of_lt_of_le hα hs.1) (by linarith [hs.2]))) + have hi : IntervalIntegrable (fun s : ℝ ↦ 1 / (ℓ * delta s)) volume α (1-α) := + (intervalIntegrable_iff_integrableOn_Icc_of_le hab).mpr hc.integrableOn_Icc + rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hab, + ← intervalIntegral.integral_add_adjacent_intervals + (hi.mono_set (by rw [uIcc_of_le hα2, uIcc_of_le hab]; exact Icc_subset_Icc le_rfl (by linarith))) + (hi.mono_set (by rw [uIcc_of_le (by linarith : (1:ℝ)/2 ≤ 1-α), uIcc_of_le hab]; exact Icc_subset_Icc hα2 le_rfl))] + have he1 : (∫ s in α..(1:ℝ)/2, 1 / (ℓ * delta s)) = + (1/ℓ) * (∫ s in α..(1:ℝ)/2, 1/s) := by + rw [← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro s hs + rw [uIcc_of_le hα2] at hs + simp only [delta, min_eq_left (by linarith [hs.2] : s ≤ 1-s)] + simp [one_div, mul_inv_rev, mul_comm] + have he2 : (∫ s in (1:ℝ)/2..1-α, 1 / (ℓ * delta s)) = + (1/ℓ) * (∫ s in α..(1:ℝ)/2, 1/s) := by + calc + _ = ∫ s in (1:ℝ)/2..1-α, (1/ℓ) * (1/(1-s)) := by + apply intervalIntegral.integral_congr + intro s hs + rw [uIcc_of_le (by linarith : (1:ℝ)/2 ≤ 1-α)] at hs + simp only [delta, min_eq_right (by linarith [hs.1] : 1-s ≤ s)] + simp [one_div, mul_inv_rev, mul_comm] + _ = _ := by + rw [intervalIntegral.integral_const_mul, intervalIntegral.integral_comp_sub_left] + congr 2 <;> ring + rw [he1, he2, integral_one_div_of_pos hα (by norm_num)] + rw [show (1:ℝ)/2/α = 1/(2*α) by ring] + ring + +lemma integral_uPos_sq {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hα2 : α ≤ 1/2) : + (∫ s : CircleX, ∫ t : CircleX, (uPos ℓ α s t)^2) = + (2 / ℓ) * Real.log (1 / (2*α)) := by + simp_rw [uPos] + have he (s : ℝ) : (∫ t : CircleX, (weight ℓ α s (repr t))^2) = + if α ≤ delta s then 1/(ℓ*delta s) else 0 := by + rw [integral_repr (fun t ↦ (weight ℓ α s t)^2), weight_sq_integral_t hℓ hℓ1 hα] + simp_rw [he] + rw [integral_repr (fun s : ℝ ↦ if α ≤ delta s then 1/(ℓ*delta s) else 0)] + have hf : (fun s : ℝ ↦ if α ≤ delta s then 1/(ℓ*delta s) else 0) = + (Icc α (1-α)).indicator (fun s ↦ 1/(ℓ*delta s)) := by + ext s + simp [delta, indicator, mem_Icc, le_sub_comm] + rw [hf, integral_indicator measurableSet_Icc, Measure.restrict_restrict measurableSet_Icc, + inter_eq_left.mpr (show Icc α (1-α) ⊆ Ioc 0 1 from fun s hs ↦ + ⟨lt_of_lt_of_le hα hs.1, le_trans hs.2 (by linarith)⟩)] + exact integral_inv_delta hℓ hα hα2 + +lemma integral_uNeg_sq {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hα2 : α ≤ 1/2) : + (∫ s : CircleX, ∫ t : CircleX, (uNeg ℓ α s t)^2) = + (2 / ℓ) * Real.log (1 / (2*α)) := by + have hip : Integrable (fun z : CircleX × CircleX ↦ (uPos ℓ α z.1 z.2)^2) (volume.prod volume) := by + apply Integrable.of_bound ((measurable_uPos ℓ α).pow_const 2).aestronglyMeasurable ((1/(ℓ*α))^2) + exact ae_of_all _ fun z ↦ by + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (weight_bounds hℓ hα _ _).1 (weight_bounds hℓ hα _ _).2 2 + have hin : Integrable (fun z : CircleX × CircleX ↦ (uNeg ℓ α z.1 z.2)^2) (volume.prod volume) := by + apply Integrable.of_bound ((measurable_uNeg ℓ α).pow_const 2).aestronglyMeasurable ((1/(ℓ*α))^2) + exact ae_of_all _ fun z ↦ by + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (weight_bounds hℓ hα _ _).1 (weight_bounds hℓ hα _ _).2 2 + rw [integral_integral_swap hin] + have he (t : CircleX) : (∫ s : CircleX, (uNeg ℓ α s t)^2) = ∫ s : CircleX, (uPos ℓ α s t)^2 := + integral_sub_right_eq_self (fun s ↦ (uPos ℓ α s t)^2) t + simp_rw [he] + rw [← integral_integral_swap hip] + exact integral_uPos_sq hℓ hℓ1 hα hα2 + +lemma uNeg_unwrapped {ℓ α a b : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) (hα : 0 < α) + (ha : a ∈ Ico 0 1) (hb : b ∈ Ico 0 1) : + uNeg ℓ α (a : CircleX) (b : CircleX) = weight ℓ α (a-b) b := by + unfold uNeg uPos + rw [repr_coe hb, ← AddCircle.coe_sub] + by_cases hba : b ≤ a + · rw [repr_coe ⟨sub_nonneg.mpr hba, by linarith [ha.2, hb.1]⟩] + · have hab : a < b := lt_of_not_ge hba + have hr : repr ((a-b : ℝ) : CircleX) = a-b+1 := by + rw [← AddCircle.coe_add_period 1 (a-b), repr_coe ⟨by linarith [ha.1, hb.2], by linarith⟩] + rw [hr] + have hn1 : ¬(α ≤ delta (a-b) ∧ 0 < b ∧ b < ℓ * delta (a-b)) := by + intro h + have := min_le_left (a-b) (1-(a-b)) + change delta (a-b) ≤ a-b at this + linarith [h.1] + have hn2 : ¬(α ≤ delta (a-b+1) ∧ 0 < b ∧ b < ℓ * delta (a-b+1)) := by + intro h + have hd : delta (a-b+1) ≤ b-a := by + exact (min_le_right _ _).trans_eq (by ring) + have := mul_le_mul_of_nonneg_left hd hℓ.le + have := mul_le_mul_of_nonneg_left (show b-a ≤ b by linarith [ha.1]) hℓ.le + nlinarith [h.2.1, h.2.2] + simp only [weight, ite_eq_right hn1, ite_eq_right hn2] + +lemma uNeg_integral_real {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) (hα : 0 < α) + (s : CircleX) : (∫ t : CircleX, uNeg ℓ α s t) = + ∫ t in Ioc 0 1, weight ℓ α (repr s-t) t := by + rw [← AddCircle.integral_preimage (1 : ℝ) 0] + simp only [zero_add] + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioc, + ae_restrict_of_ae (show ∀ᵐ t : ℝ, t ≠ 1 from by simp [ae_iff])] with t ht hne + nth_rw 1 [← coe_repr s] + exact uNeg_unwrapped hℓ hℓ1 hα (repr_mem s) ⟨le_of_lt ht.1, lt_of_le_of_ne ht.2 hne⟩ + +lemma negative_weight_upper {ℓ α s : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hs : 0 < delta s) (t : ℝ) : + weight ℓ α (s-t) t ≤ (Ioo 0 (ℓ * delta s / (1-ℓ))).indicator + (fun _ ↦ (1+ℓ) / (ℓ * delta s)) t := by + unfold weight + split_ifs with h + · have hd : 0 < delta (s-t) := lt_of_lt_of_le hα h.1 + have hlip := delta_lipschitz s (s-t) + rw [show s-(s-t)=t by ring, abs_of_pos h.2.1, abs_le] at hlip + have ht : t < ℓ * delta s / (1-ℓ) := by + apply (lt_div_iff₀ (sub_pos.mpr hℓ1)).mpr + nlinarith [mul_le_mul_of_nonneg_left hlip.1 hℓ.le, h.2.2] + rw [indicator_of_mem (show t ∈ Ioo 0 (ℓ * delta s / (1-ℓ)) from ⟨h.2.1, ht⟩)] + apply (div_le_div_iff₀ (mul_pos hℓ hd) (mul_pos hℓ hs)).mpr + nlinarith [mul_le_mul_of_nonneg_left hlip.2 hℓ.le, + mul_lt_mul_of_pos_left h.2.2 hℓ] + · apply indicator_nonneg + intro _ _ + exact div_nonneg (by linarith) (mul_nonneg hℓ.le hs.le) + +lemma negative_weight_lower {ℓ α s : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hs : 0 < delta s) (hcut : (1+ℓ)*α ≤ delta s) (t : ℝ) : + (Ioo 0 (ℓ * delta s / (1+ℓ))).indicator + (fun _ ↦ (1-ℓ) / (ℓ * delta s)) t ≤ weight ℓ α (s-t) t := by + by_cases ht : t ∈ Ioo 0 (ℓ * delta s / (1+ℓ)) + · rw [indicator_of_mem ht] + have hb : t * (1+ℓ) < ℓ * delta s := (lt_div_iff₀ (by linarith : 0 < 1+ℓ)).mp ht.2 + have hlip := delta_lipschitz s (s-t) + rw [show s-(s-t)=t by ring, abs_of_pos ht.1, abs_le] at hlip + have hct : α ≤ delta (s-t) := by nlinarith + have hd : 0 < delta (s-t) := lt_of_lt_of_le hα hct + have hsup : t < ℓ * delta (s-t) := by nlinarith + rw [weight, ite_eq_left ⟨hct, ht.1, hsup⟩] + apply (div_le_div_iff₀ (mul_pos hℓ hs) (mul_pos hℓ hd)).mpr + have hbound : (1-ℓ)*delta (s-t) ≤ delta s := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left hbound hℓ.le] + · rw [indicator_of_notMem ht] + exact (weight_bounds hℓ hα _ _).1 + +lemma integrable_negative_weight {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) (s : ℝ) : + IntegrableOn (fun t ↦ weight ℓ α (s-t) t) (Ioc 0 1) := by + apply Integrable.of_bound ((measurable_weight ℓ α).comp + ((measurable_const.sub measurable_id).prodMk measurable_id)).aestronglyMeasurable (1/(ℓ*α)) + exact ae_of_all _ fun t ↦ by + change ‖weight ℓ α (s-t) t‖ ≤ 1/(ℓ*α) + rw [Real.norm_eq_abs, abs_of_nonneg (weight_bounds hℓ hα _ _).1] + exact (weight_bounds hℓ hα _ _).2 + +lemma negative_density_upper {ℓ α s : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hs : 0 < delta s) : + (∫ t in Ioc 0 1, weight ℓ α (s-t) t) ≤ (1+ℓ)/(1-ℓ) := by + let R := ℓ * delta s / (1-ℓ) + let C := (1+ℓ)/(ℓ*delta s) + have hR : 0 < R := div_pos (mul_pos hℓ hs) (sub_pos.mpr hℓ1) + have hC : 0 ≤ C := div_nonneg (by linarith) (mul_nonneg hℓ.le hs.le) + have hi : Integrable ((Ioo 0 R).indicator (fun _ : ℝ ↦ C)) := + (integrableOn_const (μ := volume) (s := Ioo 0 R) (C := C) (by rw [Real.volume_Ioo]; exact ENNReal.ofReal_ne_top)).integrable_indicator measurableSet_Ioo + calc + _ ≤ ∫ t in Ioc 0 1, (Ioo 0 R).indicator (fun _ : ℝ ↦ C) t := + integral_mono (integrable_negative_weight hℓ hα s) hi.restrict + (negative_weight_upper hℓ hℓ1 hα hs) + _ ≤ ∫ t : ℝ, (Ioo 0 R).indicator (fun _ : ℝ ↦ C) t := + integral_mono_measure Measure.restrict_le_self + (ae_of_all _ (indicator_nonneg fun _ _ ↦ hC)) hi + _ = _ := by + rw [integral_indicator measurableSet_Ioo, integral_const] + simp only [Measure.real, Measure.restrict_apply_univ, Real.volume_Ioo, sub_zero, + ENNReal.toReal_ofReal hR.le, smul_eq_mul] + dsimp [R, C] + field_simp + +lemma negative_density_lower {ℓ α s : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hs : 0 < delta s) (hcut : (1+ℓ)*α ≤ delta s) : + (1-ℓ)/(1+ℓ) ≤ ∫ t in Ioc 0 1, weight ℓ α (s-t) t := by + let R := ℓ * delta s / (1+ℓ) + let C := (1-ℓ)/(ℓ*delta s) + have hR : 0 < R := div_pos (mul_pos hℓ hs) (by linarith) + have hR1 : R ≤ 1 := by + apply (div_le_one (by linarith : 0 < 1+ℓ)).mpr + nlinarith [delta_le_half s] + have hi : Integrable ((Ioo 0 R).indicator (fun _ : ℝ ↦ C)) := + (integrableOn_const (μ := volume) (s := Ioo 0 R) (C := C) (by rw [Real.volume_Ioo]; exact ENNReal.ofReal_ne_top)).integrable_indicator measurableSet_Ioo + calc + _ = ∫ t in Ioc 0 1, (Ioo 0 R).indicator (fun _ : ℝ ↦ C) t := by + rw [integral_indicator measurableSet_Ioo, Measure.restrict_restrict measurableSet_Ioo, + inter_eq_left.mpr (show Ioo 0 R ⊆ Ioc 0 1 from fun _ ht ↦ ⟨ht.1, ht.2.le.trans hR1⟩), + integral_const] + simp only [Measure.real, Measure.restrict_apply_univ, Real.volume_Ioo, sub_zero, + ENNReal.toReal_ofReal hR.le, smul_eq_mul] + dsimp [R, C] + field_simp + _ ≤ _ := integral_mono hi.restrict (integrable_negative_weight hℓ hα s) + (negative_weight_lower hℓ hℓ1 hα hs hcut) + +lemma integral_delta_small {r : ℝ} (hr : 0 < r) : + (∫ s : CircleX, if delta (repr s) < r then (1 : ℝ) else 0) ≤ 2*r := by + have hm : Measurable (fun s : CircleX ↦ if delta (repr s) < r then (1 : ℝ) else 0) := + Measurable.ite (measurableSet_lt (measurable_delta.comp measurable_repr) measurable_const) + measurable_const measurable_const + have hm' : Measurable (fun s : CircleX ↦ if r ≤ delta (repr s) then (1 : ℝ) else 0) := + Measurable.ite (measurableSet_le measurable_const (measurable_delta.comp measurable_repr)) + measurable_const measurable_const + have hi' : Integrable (fun s : CircleX ↦ if r ≤ delta (repr s) then (1 : ℝ) else 0) := by + apply Integrable.of_bound hm'.aestronglyMeasurable 1 + exact ae_of_all _ fun s ↦ by split_ifs <;> norm_num + by_cases hr2 : r ≤ 1/2 + · have he := integral_uPos (ℓ := 1/2) (α := r) (by norm_num) (by norm_num) hr hr2 + simp_rw [uPos_integral_t (ℓ := 1/2) (α := r) (by norm_num) (by norm_num) hr] at he + have hf : (fun s : CircleX ↦ if delta (repr s) < r then (1 : ℝ) else 0) = + (fun s ↦ 1 - (if r ≤ delta (repr s) then (1 : ℝ) else 0)) := by + funext s + by_cases h : r ≤ delta (repr s) <;> simp [h, not_lt_of_ge, lt_of_not_ge] + rw [hf, integral_sub (integrable_const 1) hi', he] + simp only [integral_const, Measure.real, measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul] + linarith + · have hi : Integrable (fun s : CircleX ↦ if delta (repr s) < r then (1 : ℝ) else 0) := by + apply Integrable.of_bound hm.aestronglyMeasurable 1 + exact ae_of_all _ fun s ↦ by split_ifs <;> norm_num + have hu := integral_mono hi (integrable_const (1 : ℝ)) (fun s ↦ by split_ifs <;> norm_num) + simp only [integral_const, Measure.real, measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul] at hu + linarith + +lemma uNeg_mean_bounds {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) (s : CircleX) : + 0 ≤ (∫ t : CircleX, uNeg ℓ α s t) ∧ + (∫ t : CircleX, uNeg ℓ α s t) ≤ 1/(ℓ*α) := by + have hm : Measurable (fun t ↦ uNeg ℓ α s t) := + (measurable_uNeg ℓ α).comp (measurable_const.prodMk measurable_id) + have hi : Integrable (fun t ↦ uNeg ℓ α s t) := by + apply Integrable.of_bound hm.aestronglyMeasurable (1/(ℓ*α)) + exact ae_of_all _ fun t ↦ by + change ‖weight ℓ α (repr (s-t)) (repr t)‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (weight_bounds hℓ hα _ _).1] + exact (weight_bounds hℓ hα _ _).2 + refine ⟨integral_nonneg (fun t ↦ (weight_bounds hℓ hα _ _).1), ?_⟩ + simpa only [integral_const, Measure.real, measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul] using + integral_mono hi (integrable_const (1/(ℓ*α))) (fun t ↦ (weight_bounds hℓ hα _ _).2) + +lemma integral_uNeg_mean_sq {ℓ α : ℝ} (hℓ : 0 < ℓ) (hℓ1 : ℓ < 1) + (hα : 0 < α) (hα2 : α ≤ 1/2) : + (∫ s : CircleX, (∫ t : CircleX, uNeg ℓ α s t)^2) ≤ + 1 + (2*ℓ/(1-ℓ))^2 + 2*(1+ℓ)*α := by + let g : CircleX → ℝ := fun s ↦ ∫ t : CircleX, uNeg ℓ α s t + let C : ℝ := 2*ℓ/(1-ℓ) + let r : ℝ := (1+ℓ)*α + let b : CircleX → ℝ := fun s ↦ if delta (repr s) < r then 1 else 0 + have hC : 0 ≤ C := div_nonneg (by positivity) (by linarith) + have hr : 0 < r := mul_pos (by linarith) hα + have hgi : Integrable g := (integrable_uNeg hℓ hα).integral_prod_left + have hgb (s : CircleX) := uNeg_mean_bounds hℓ hα s + have hgs : Integrable (fun s ↦ (g s)^2) := by + apply Integrable.of_bound (hgi.aestronglyMeasurable.pow 2) ((1/(ℓ*α))^2) + exact ae_of_all _ fun s ↦ by + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (hgb s).1 (hgb s).2 2 + have hbi : Integrable b := by + have hm : Measurable b := Measurable.ite + (measurableSet_lt (measurable_delta.comp measurable_repr) measurable_const) + measurable_const measurable_const + apply Integrable.of_bound hm.aestronglyMeasurable 1 + exact ae_of_all _ fun s ↦ by dsimp [b]; split_ifs <;> norm_num + have hv : (fun s ↦ (g s-1)^2) = (fun s ↦ (g s)^2 - 2*g s + 1) := by + funext s; ring + have hvi : Integrable (fun s ↦ (g s-1)^2) := by + rw [hv] + exact (hgs.sub (hgi.const_mul 2)).add (integrable_const 1) + have hbound : ∀ᵐ s : CircleX, (g s-1)^2 ≤ C^2 + b s := by + filter_upwards [show ∀ᵐ s : CircleX, s ≠ 0 from by simpa [ae_iff] using volume_singleton_zero (0 : CircleX)] with s hs + have hsp : 0 < repr s := by + by_contra! h + have hz : repr s = 0 := le_antisymm h (repr_mem s).1 + have := coe_repr s + simp only [hz, AddCircle.coe_zero] at this + exact hs this.symm + have hd : 0 < delta (repr s) := delta_pos ⟨hsp, (repr_mem s).2⟩ + have hu := negative_density_upper hℓ hℓ1 hα hd + rw [← uNeg_integral_real hℓ hℓ1 hα s] at hu + change g s ≤ _ at hu + have heU : (1+ℓ)/(1-ℓ) = 1+C := by dsimp [C]; field_simp [ne_of_gt (sub_pos.mpr hℓ1)]; ring + rw [heU] at hu + by_cases hb : delta (repr s) < r + · simp only [b, ite_eq_left hb] + rcases le_total (g s) 1 with hl | hl + · nlinarith [(hgb s).1, sq_nonneg C] + · nlinarith + · simp only [b, ite_eq_right hb, add_zero] + have hl := negative_density_lower hℓ hℓ1 hα hd (le_of_not_gt hb) + rw [← uNeg_integral_real hℓ hℓ1 hα s] at hl + change _ ≤ g s at hl + have hL : 1-C ≤ (1-ℓ)/(1+ℓ) := by + have hc : 2*ℓ/(1+ℓ) ≤ C := by + exact div_le_div_of_nonneg_left (by positivity) (by linarith) (by linarith) + have he : (1-ℓ)/(1+ℓ) = 1 - 2*ℓ/(1+ℓ) := by + field_simp [ne_of_gt (show 0 < 1+ℓ by linarith)] + ring + rw [he] + linarith + have hlo := hL.trans hl + nlinarith [sq_nonneg (g s-1-C), sq_nonneg (g s-1+C)] + have hive := integral_mono_ae hvi ((integrable_const (C^2)).add hbi) hbound + change (∫ s : CircleX, (g s-1)^2) ≤ ∫ s : CircleX, C^2+b s at hive + rw [integral_add (integrable_const (C^2)) hbi, + integral_const, Measure.real, measure_univ, ENNReal.toReal_one, one_smul] at hive + have hbmass : ∫ s : CircleX, b s ≤ 2*r := integral_delta_small hr + have hgm : ∫ s : CircleX, g s = 1-2*α := integral_uNeg hℓ hℓ1 hα hα2 + rw [hv] at hive + rw [integral_add (show Integrable (fun s : CircleX ↦ (g s)^2 - 2*g s) volume from + hgs.sub (hgi.const_mul 2)) (integrable_const 1), + integral_sub hgs (hgi.const_mul 2), integral_const_mul, hgm, + integral_const, Measure.real, measure_univ, ENNReal.toReal_one, one_smul] at hive + change (∫ s : CircleX, (g s)^2) ≤ _ + dsimp [C, r] at hive hbmass + linarith + + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Polar.lean b/lean/OAI/Analysis/RotationWeights/Polar.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b48cfef8728a7208f269c9f394d3d99859165d4 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Polar.lean @@ -0,0 +1,273 @@ +import OAI.Analysis.RotationWeights.ProjectionFields + +namespace OAI + +noncomputable section + +namespace CirclePolar + +universe uH + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set + +open Set +open scoped ComplexInnerProductSpace +section +variable {H : Type uH} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] +abbrev Op := H →L[ℂ] H + +def absOp (A : Op (H := H)) : Op (H := H) := CFC.sqrt (star A * A) + +lemma absOp_selfAdjoint (A : Op (H := H)) : IsSelfAdjoint (absOp A) := + IsSelfAdjoint.of_nonneg (CFC.sqrt_nonneg _) + +lemma absOp_square (A : Op (H := H)) : absOp A * absOp A = star A * A := + CFC.sqrt_mul_sqrt_self _ + +lemma norm_absOp (A : Op (H := H)) (x : H) : ‖absOp A x‖ = ‖A x‖ := by + have he : inner ℂ (absOp A x) (absOp A x) = inner ℂ (A x) (A x) := by + rw [← ContinuousLinearMap.adjoint_inner_right, ← ContinuousLinearMap.adjoint_inner_right] + change inner ℂ x ((star (absOp A) * absOp A) x) = inner ℂ x ((star A * A) x) + rw [(absOp_selfAdjoint A).star_eq,absOp_square] + rw [inner_self_eq_norm_sq_to_K,inner_self_eq_norm_sq_to_K] at he + have h : ‖absOp A x‖^2 = ‖A x‖^2 := by exact_mod_cast he + nlinarith [norm_nonneg (absOp A x),norm_nonneg (A x)] + +def closedRange (A : Op (H := H)) : Submodule ℂ H := A.toLinearMap.range.topologicalClosure + +instance (A : Op (H := H)) : CompleteSpace (closedRange A) := + inferInstanceAs (CompleteSpace A.toLinearMap.range.topologicalClosure) + +def intoRange (A : Op (H := H)) : H →ₗ[ℂ] closedRange A := + A.toLinearMap.codRestrict _ (fun x ↦ A.toLinearMap.range.le_topologicalClosure ⟨x,rfl⟩) + +omit [CompleteSpace H] in +lemma intoRange_dense (A : Op (H := H)) : DenseRange (intoRange A) := by + intro x + rw [closure_subtype] + change x.val ∈ closure (Subtype.val '' Set.range (intoRange A)) + rw [← Set.range_comp] + exact x.property + +def polarCore (A : Op (H := H)) : closedRange (absOp A) →L[ℂ] H := + A.toLinearMap.extendOfNorm (intoRange (absOp A)) + +lemma polarCore_abs (A : Op (H := H)) (x : H) : + polarCore A (intoRange (absOp A) x) = A x := by + apply LinearMap.extendOfNorm_eq (intoRange_dense _) + refine ⟨1,fun x ↦ ?_⟩ + change ‖A x‖ ≤ 1*‖absOp A x‖ + rw [one_mul,norm_absOp] + +lemma polarCore_norm (A : Op (H := H)) (x : closedRange (absOp A)) : + ‖polarCore A x‖ = ‖x‖ := by + refine (intoRange_dense (absOp A)).induction_on (p := fun x ↦ ‖polarCore A x‖ = ‖x‖) x + (isClosed_eq ((polarCore A).continuous.norm) continuous_norm) ?_ + intro y + rw [polarCore_abs] + exact (norm_absOp A y).symm + +def polar (A : Op (H := H)) : Op (H := H) := + (polarCore A).comp (closedRange (absOp A)).orthogonalProjectionOnto + +lemma polar_abs (A : Op (H := H)) : polar A * absOp A = A := by + ext x + change polarCore A ((closedRange (absOp A)).orthogonalProjectionOnto (absOp A x)) = A x + have h := Submodule.orthogonalProjectionOnto_mem_subspace_eq_self (intoRange (absOp A) x) + rw [show (closedRange (absOp A)).orthogonalProjectionOnto (absOp A x) = intoRange (absOp A) x from h] + exact polarCore_abs A x + +lemma polar_norm (A : Op (H := H)) (x : H) : + ‖polar A x‖ = ‖(closedRange (absOp A)).starProjection x‖ := by + change ‖polarCore A ((closedRange (absOp A)).orthogonalProjectionOnto x)‖ = _ + rw [polarCore_norm] + rfl + +def polarCoreIsometry (A : Op (H := H)) : closedRange (absOp A) →ₗᵢ[ℂ] H where + toLinearMap := (polarCore A).toLinearMap + norm_map' := polarCore_norm A + +lemma polar_star_mul (A : Op (H := H)) : + star (polar A) * polar A = (closedRange (absOp A)).starProjection := by + ext x + apply ext_inner_left ℂ + intro y + change inner ℂ y ((ContinuousLinearMap.adjoint (polar A)) (polar A x)) = _ + rw [ContinuousLinearMap.adjoint_inner_right] + change inner ℂ (polarCoreIsometry A ((closedRange (absOp A)).orthogonalProjectionOnto y)) + (polarCoreIsometry A ((closedRange (absOp A)).orthogonalProjectionOnto x)) = _ + rw [(polarCoreIsometry A).inner_map_map] + exact Submodule.inner_orthogonalProjectionOnto_eq_of_mem_right (K := closedRange (absOp A)) + ((closedRange (absOp A)).orthogonalProjectionOnto x) y + +lemma ker_absOp (A : Op (H := H)) : (absOp A).ker = A.ker := by + ext x + change absOp A x=0 ↔ A x=0 + simpa only [norm_eq_zero] using (show ‖absOp A x‖=0 ↔ ‖A x‖=0 by rw [norm_absOp]) + +lemma closedRange_absOp (A : Op (H := H)) : closedRange (absOp A) = A.kerᗮ := by + rw [← ker_absOp A,ContinuousLinearMap.orthogonal_ker] + have hs : ContinuousLinearMap.adjoint (absOp A) = absOp A := (absOp_selfAdjoint A).star_eq + rw [hs] + rfl + +lemma polar_eq_zero_iff (A : Op (H := H)) (x : H) : polar A x=0 ↔ A x=0 := by + rw [← norm_eq_zero,polar_norm,norm_eq_zero,Submodule.starProjection_apply_eq_zero_iff, + closedRange_absOp,Submodule.orthogonal_orthogonal] + rfl + +lemma commute_absOp {A B : Op (H := H)} (h : Commute A B) (hs : Commute (star A) B) : + Commute (absOp A) B := by + exact (hs.mul_left h).cfcₙ_nnreal NNReal.sqrt + +lemma commute_polar {A B : Op (H := H)} (h : Commute A B) (hs : Commute (star A) B) : + Commute (polar A) B := by + have hS := commute_absOp h hs + have hg (x : H) (hx : x ∈ closedRange (absOp A)) : polar A (B x) = B (polar A x) := by + apply closure_minimal (s := Set.range (absOp A)) _ + (isClosed_eq ((polar A).continuous.comp B.continuous) (B.continuous.comp (polar A).continuous)) hx + rintro _ ⟨y,rfl⟩ + have h1 := DFunLike.congr_fun hS.eq y + have h2 := DFunLike.congr_fun h.eq y + have h3 z := DFunLike.congr_fun (polar_abs A) z + change polar A (B (absOp A y)) = B (polar A (absOp A y)) + change absOp A (B y)=B (absOp A y) at h1 + change A (B y)=B (A y) at h2 + change ∀ z, polar A (absOp A z)=A z at h3 + rw [← h1,h3,h3,h2] + have hk (x : H) (hx : x ∈ (closedRange (absOp A))ᗮ) : polar A (B x)=B (polar A x) := by + rw [closedRange_absOp,Submodule.orthogonal_orthogonal] at hx + change A x=0 at hx + have hb : A (B x)=0 := by + have he := DFunLike.congr_fun h.eq x + change A (B x)=B (A x) at he + rw [he,hx,map_zero] + rw [(polar_eq_zero_iff A _).mpr hb,(polar_eq_zero_iff A _).mpr hx,map_zero] + change polar A*B=B*polar A + ext x + let P := (closedRange (absOp A)).starProjection + have hd : x=P x+(x-P x) := by abel + change polar A (B x)=B (polar A x) + conv_lhs => rw [hd] + conv_rhs => rw [hd] + simp only [map_add] + rw [hg _ (Submodule.starProjection_apply_mem _ _), + hk _ (Submodule.sub_starProjection_mem_orthogonal (K := closedRange (absOp A)) _)] + + +lemma polar_norm_le (A : Op (H := H)) (x : H) : ‖polar A x‖ ≤ ‖x‖ := by + rw [polar_norm] + exact Submodule.norm_orthogonalProjectionOnto_apply_le _ x + +lemma polar_opNorm_le (A : Op (H := H)) : ‖polar A‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ zero_le_one + simpa using polar_norm_le A + +lemma polar_range (A : Op (H := H)) (x : H) : polar A x ∈ closedRange A := by + have hwithin (y : H) (hy : y ∈ closedRange (absOp A)) : polar A y ∈ closedRange A := by + apply closure_minimal (s := Set.range (absOp A)) _ + ((Submodule.isClosed_topologicalClosure _).preimage (polar A).continuous) hy + rintro _ ⟨z,rfl⟩ + change (polar A * absOp A) z ∈ closedRange A + rw [polar_abs] + exact A.toLinearMap.range.le_topologicalClosure ⟨z,rfl⟩ + let P := (closedRange (absOp A)).starProjection + have hk : A (x-P x)=0 := by + have hh := Submodule.sub_starProjection_mem_orthogonal (K := closedRange (absOp A)) x + change x-P x ∈ (closedRange (absOp A))ᗮ at hh + rw [closedRange_absOp,Submodule.orthogonal_orthogonal] at hh + exact hh + have he := (polar_eq_zero_iff A (x-P x)).mpr hk + rw [map_sub,sub_eq_zero] at he + rw [he] + exact hwithin _ (Submodule.starProjection_apply_mem _ _) + +lemma polar_range_le {A : Op (H := H)} {K : Submodule ℂ H} (hK : IsClosed (K : Set H)) + (hA : ∀ x, A x ∈ K) (x : H) : polar A x ∈ K := by + have hle : closedRange A ≤ K := by + apply Submodule.topologicalClosure_minimal _ _ hK + rintro _ ⟨z,rfl⟩ + exact hA z + exact hle (polar_range A x) + +lemma polar_adjoint_annihilates {A : Op (H := H)} {K : Submodule ℂ H} + (hK : IsClosed (K : Set H)) (hA : ∀ x, A x ∈ K) {z : H} (hz : z ∈ Kᗮ) : + (star (polar A)) z = 0 := by + apply ext_inner_left ℂ + intro y + change inner ℂ y ((ContinuousLinearMap.adjoint (polar A)) z) = inner ℂ y 0 + rw [ContinuousLinearMap.adjoint_inner_right,inner_zero_right] + exact (Submodule.mem_orthogonal _ _).mp hz _ (polar_range_le hK hA y) + +end +variable {H : Type uH} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] + +lemma disjoint_norm_bound (P E : Submodule ℂ H) [CompleteSpace P] [CompleteSpace E] + (v : H) (hd : Disjoint P E) + (htrace : ‖(star (polar (Eᗮ.starProjection * P.starProjection))) v‖ = + ‖polar (Eᗮ.starProjection * P.starProjection) v‖) : + ‖P.starProjection v‖ ≤ ‖Eᗮ.starProjection v‖ := by + let A := Eᗮ.starProjection * P.starProjection + have hker : A.ker = Pᗮ := by + ext x + change Eᗮ.starProjection (P.starProjection x)=0 ↔ x∈Pᗮ + rw [Submodule.starProjection_apply_eq_zero_iff,Submodule.orthogonal_orthogonal] + constructor + · intro hx + have hp := (Submodule.disjoint_def.mp hd) _ (P.starProjection_apply_mem x) hx + exact (P.starProjection_apply_eq_zero_iff).mp hp + · intro hx + rw [(P.starProjection_apply_eq_zero_iff).mpr hx] + exact E.zero_mem + have hr : closedRange (absOp A) = P := by + rw [closedRange_absOp,hker,Submodule.orthogonal_orthogonal] + have hA (x : H) : A x ∈ Eᗮ := Eᗮ.starProjection_apply_mem _ + have hzero : (star (polar A)) (E.starProjection v)=0 := + polar_adjoint_annihilates E.isClosed_orthogonal hA (by + rw [Submodule.orthogonal_orthogonal] + exact E.starProjection_apply_mem v) + have hid : (star (polar A)) v = (star (polar A)) (Eᗮ.starProjection v) := by + rw [E.starProjection_orthogonal] + simp only [sub_apply,ContinuousLinearMap.id_apply,map_sub,hzero,sub_zero] + have hnorm : ‖polar A v‖ = ‖P.starProjection v‖ := by + rw [polar_norm] + congr 1 + simp only [hr] + calc + _ = ‖polar A v‖ := hnorm.symm + _ = ‖(star (polar A)) v‖ := htrace.symm + _ = ‖(star (polar A)) (Eᗮ.starProjection v)‖ := congrArg norm hid + _ ≤ ‖star (polar A)‖ * ‖Eᗮ.starProjection v‖ := (star (polar A)).le_opNorm _ + _ ≤ 1 * ‖Eᗮ.starProjection v‖ := by rw [norm_star]; gcongr; exact polar_opNorm_le A + _ = _ := one_mul _ + +lemma exists_intersection_of_norm_lt (P E : Submodule ℂ H) [CompleteSpace P] [CompleteSpace E] + (v : H) (htrace : ‖(star (polar (Eᗮ.starProjection * P.starProjection))) v‖ = + ‖polar (Eᗮ.starProjection * P.starProjection) v‖) + (hlt : ‖Eᗮ.starProjection v‖ < ‖P.starProjection v‖) : + ∃ x : H, x∈P ∧ x∈E ∧ x≠0 := by + by_contra! h + have hd : Disjoint P E := Submodule.disjoint_def.mpr h + exact (not_lt_of_ge (disjoint_norm_bound P E v hd htrace)) hlt + + + +end CirclePolar + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/ProductSampling.lean b/lean/OAI/Analysis/RotationWeights/ProductSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..49071d9e3975e7dae5796c9943f1c9fb917bb9f6 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/ProductSampling.lean @@ -0,0 +1,499 @@ +import OAI.Analysis.RotationWeights.Discrepancy + +namespace OAI + +noncomputable section + +universe uΩ uι uκ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate + +namespace ContinuousCircleWeight.Sampling + +lemma phasePairLaw_fst_ac {a b c d : ℝ} (hab : a0, CircleSampling.IsTwoArcs {t | r first | exact measurable_uNeg ℓ α | exact measurable_uPos ℓ α + +lemma orientedWeight_bounds (positive : Bool) {ℓ α : ℝ} (hℓ : 0<ℓ) (hα : 0<α) + (s t : CircleX) : 0≤orientedWeight positive ℓ α s t ∧ + orientedWeight positive ℓ α s t≤1/(ℓ*α) := by + cases positive <;> exact weight_bounds hℓ hα _ _ + +lemma orientedWeight_isTwoArcs (positive : Bool) {ℓ α r : ℝ} (hℓ : 0<ℓ) + (hℓ1 : ℓ<1) (hα : 0<α) (s : CircleX) (hr : 0 norm_num + change (∫ s : CircleX, (∫ t : CircleX, uPos ℓ α s t)^2) ≤ _ + rw [he,integral_uPos hℓ hℓ1 hα hα2] + nlinarith [sq_nonneg (2*ℓ/(1-ℓ))] + +lemma bounded_integrable {Ω : Type uΩ} [MeasurableSpace Ω] (μ : Measure Ω) + [IsFiniteMeasure μ] {f : Ω → ℝ} (hf : Measurable f) {B : ℝ} + (hb : ∀ x, 0≤f x ∧ f x≤B) : Integrable f μ := by + apply Integrable.of_bound hf.aestronglyMeasurable B + exact ae_of_all _ fun x ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (hb x).1]; exact (hb x).2 + +lemma bounded_sq_integrable {Ω : Type uΩ} [MeasurableSpace Ω] (μ : Measure Ω) + [IsFiniteMeasure μ] {f : Ω → ℝ} (hf : Measurable f) {B : ℝ} + (hb : ∀ x, 0≤f x ∧ f x≤B) : Integrable (fun x ↦ (f x)^2) μ := by + apply bounded_integrable μ (hf.pow_const 2) + exact fun x ↦ ⟨sq_nonneg _,pow_le_pow_left₀ (hb x).1 (hb x).2 2⟩ + +lemma bounded_pair_integrable {Ω : Type uΩ} [MeasurableSpace Ω] (μ : Measure Ω) + [IsFiniteMeasure μ] {f g : Ω → ℝ} (hf : Measurable f) (hg : Measurable g) {B : ℝ} + (hB : 0≤B) (hfb : ∀ x, 0≤f x ∧ f x≤B) (hgb : ∀ x, 0≤g x ∧ g x≤B) : + Integrable (fun x ↦ f x*g x) μ := by + apply bounded_integrable μ (hf.mul hg) + exact fun x ↦ ⟨mul_nonneg (hfb x).1 (hgb x).1, + (mul_le_mul (hfb x).2 (hgb x).2 (hgb x).1 hB).trans_eq (pow_two B).symm⟩ + +lemma trial_mean_lower {a b c ℓ α A : ℝ} (hab : a T x (lp.single 2 k 1)) AddCircle.haarAddCircle) + (hp : ∀ᵐ x ∂AddCircle.haarAddCircle,IsStarProjection (T x)) : + ∃ P : CircleX → FiberOperator, P=ᵐ[AddCircle.haarAddCircle] T ∧ + (∀ x,IsStarProjection (P x)) ∧ (∀ x,‖P x‖≤1) ∧ + ∀ k : ℤ,Measurable (fun x => P x (lp.single 2 k 1)) := by + classical + let F : ℤ → CircleX → FiberHilbert := fun k => (hm k).mk (fun x => T x (lp.single 2 k 1)) + have hgood : ∀ᵐ x ∂AddCircle.haarAddCircle,(∀ k : ℤ,T x (lp.single 2 k 1)=F k x) ∧ IsStarProjection (T x) := by + filter_upwards [ae_all_iff.mpr (fun k => (hm k).ae_eq_mk),hp] with x hx hpx + exact ⟨hx,hpx⟩ + obtain ⟨N,hN,hmN,hzN⟩ := exists_measurable_superset_of_null (ae_iff.mp hgood) + have hn (x : CircleX) (hx : x∉N) : (∀ k : ℤ,T x (lp.single 2 k 1)=F k x) ∧ IsStarProjection (T x) := by + by_contra h + exact hx (hN h) + let P : CircleX → FiberOperator := fun x => if x∈N then 0 else T x + have hPP (x : CircleX) : IsStarProjection (P x) := by + by_cases hx : x∈N + · simp only [P,ite_eq_left hx]; exact IsStarProjection.zero _ + · simpa only [P,ite_eq_right hx] using (hn x hx).2 + refine ⟨P,?_,hPP,fun x => (hPP x).norm_le,?_⟩ + · filter_upwards [(show ∀ᵐ x ∂AddCircle.haarAddCircle,x∉N from (ae_iff.mpr (by simpa only [not_not, Set.ofPred_mem_eq] using hzN)))] with x hx + exact ite_eq_right hx + · intro k + have he : (fun x => P x (lp.single 2 k 1))=(fun x => if x∈N then 0 else F k x) := by + funext x + by_cases hx : x∈N + · simp [P,hx] + · simpa only [P,ite_eq_right hx] using (hn x hx).1 k + rw [he] + exact Measurable.ite hmN measurable_const (hm k).measurable_mk + +lemma fiber_commutes_indicators (θ : ℝ) (A : CircleFiberOperator) + (hA : ∀ B∈fiberCommutant θ,Commute A B) (s : Set CircleX) (hs : MeasurableSet s) : + A.comp (indicatorV2 AddCircle.haarAddCircle s hs)=(indicatorV2 AddCircle.haarAddCircle s hs).comp A := by + have h := regular_doubleCentralizer_indicators θ (fiberConjugacy.symm A) (regularAlgebra_of_commutes θ A hA) s hs + change fiberConjugacy (fiberConjugacy.symm A)*_=_*fiberConjugacy (fiberConjugacy.symm A) at h + change A*indicatorV2 AddCircle.haarAddCircle s hs=indicatorV2 AddCircle.haarAddCircle s hs*A + simpa only [fiberConjugacy.apply_symm_apply] using h +lemma fiber_commutes_circleJ (θ : ℝ) (A : CircleFiberOperator) + (hA : ∀ B∈fiberCommutant θ,Commute A B) (n : ℤ) : A*circleJ (θ:CircleX) n=circleJ (θ:CircleX) n*A := by + have h := regular_doubleCentralizer_circleJ θ (fiberConjugacy.symm A) (regularAlgebra_of_commutes θ A hA) n + change fiberConjugacy (fiberConjugacy.symm A)*_=_*fiberConjugacy (fiberConjugacy.symm A) at h + simpa only [fiberConjugacy.apply_symm_apply] using h + +theorem extract_projection_field (θ : ℝ) (A : CircleFiberOperator) (hA : IsStarProjection A) + (hcomm : ∀ B∈fiberCommutant θ,Commute A B) : + ∃ P : CircleX → FiberOperator, + (∀ x,IsStarProjection (P x)) ∧ (∀ x,‖P x‖≤1) ∧ + (∀ k : ℤ,Measurable (fun x => P x (lp.single 2 k 1))) ∧ + (∀ u : CircleFiberL2,∀ᵐ x ∂AddCircle.haarAddCircle,(A u) x=P x (u x)) ∧ + ∀ n : ℤ,∀ᵐ x ∂AddCircle.haarAddCircle, + P x*(fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap= + (fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap*P (x+n•(θ:CircleX)) := by + obtain ⟨T,_hbound,hm,hT⟩ := commutes_indicators_decomposable AddCircle.haarAddCircle A (fiber_commutes_indicators θ A hcomm) + have hTproj : ∀ᵐ x ∂AddCircle.haarAddCircle,IsStarProjection (T x) := by + filter_upwards [decomposable_idempotent AddCircle.haarAddCircle A T hT hA.isIdempotentElem, + decomposable_selfAdjoint AddCircle.haarAddCircle A T hT (fiber_commutes_indicators θ A hcomm) hA.isSelfAdjoint] with x h1 h2 + exact ⟨h1,h2⟩ + obtain ⟨P,hPT,hPproj,hPbound,hPmeas⟩ := measurable_projection_version T (fun k => hm _) hTproj + have hP (u : CircleFiberL2) : ∀ᵐ x ∂AddCircle.haarAddCircle,(A u) x=P x (u x) := by + filter_upwards [hT u,hPT] with x hx hpx + rw [hpx]; exact hx + refine ⟨P,hPproj,hPbound,hPmeas,hP,fun n => ?_⟩ + exact decomposable_covariance AddCircle.haarAddCircle (fun x : CircleX => x+n•(θ:CircleX)) + (measurePreserving_add_right AddCircle.haarAddCircle (n•(θ:CircleX))) _ A P hP (fiber_commutes_circleJ θ A hcomm n) + +def borelWeightedField (θ : CircleX) (g : RealBorel) (x : CircleX) : FiberOperator := + (fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap * realPiField θ g x +lemma borelWeightedField_coe (θ : CircleX) (g : RealBorel) (u : CircleFiberL2) : + (fiberShiftL2 1*realPi θ g) u=ᵐ[AddCircle.haarAddCircle] fun x => borelWeightedField θ g x (u x) := by + filter_upwards [fiberShiftL2_coe 1 (realPi θ g u),realPi_coe θ g u] with x h1 h2 + change (fiberShiftL2 1 (realPi θ g u)) x=_ + rw [h1,h2] + rfl +lemma decomposable_one_sub (A : CircleFiberOperator) (P : CircleX → FiberOperator) + (hP : ∀ u : CircleFiberL2,∀ᵐ x ∂AddCircle.haarAddCircle,(A u) x=P x (u x)) + (u : CircleFiberL2) : ∀ᵐ x ∂AddCircle.haarAddCircle,((1-A) u) x=(1-P x) (u x) := by + filter_upwards [Lp.coeFn_sub u (A u),hP u] with x h1 h2 + change (u-A u) x=_ + rw [h1] + simp only [Pi.sub_apply,h2] + rfl +lemma decomposable_invariant (A : CircleFiberOperator) (P : CircleX → FiberOperator) + (hP : ∀ u : CircleFiberL2,∀ᵐ x ∂AddCircle.haarAddCircle,(A u) x=P x (u x)) + (θ : CircleX) (g : RealBorel) (hinv : (1-A)*(fiberShiftL2 1*realPi θ g)*A=0) : + ∀ᵐ x ∂AddCircle.haarAddCircle,(1-P x)*borelWeightedField θ g x*P x=0 := by + apply ae_field_eq_of_dense AddCircle.haarAddCircle + intro u + have h := decomposable_mul AddCircle.haarAddCircle ((1-A)*(fiberShiftL2 1*realPi θ g)) A + (fun x => (1-P x)*borelWeightedField θ g x) P + (decomposable_mul AddCircle.haarAddCircle _ _ _ _ (decomposable_one_sub A P hP) (borelWeightedField_coe θ g)) hP + have hc := decomposable_const AddCircle.haarAddCircle _ _ h u + filter_upwards [hc,Lp.coeFn_zero FiberHilbert 2 AddCircle.haarAddCircle] with x hx hz + rw [hinv] at hx + exact hx.symm.trans hz + +lemma realPiField_proj_eigen (θ : CircleX) (g : RealBorel) (x : CircleX) : + realPiField θ g x (lp.single 2 0 1)=(g x:ℂ)•lp.single 2 0 1 ∧ + (star (realPiField θ g x)) (lp.single 2 0 1)=(g x:ℂ)•lp.single 2 0 1 := by + have h1 : realPiField θ g x (lp.single 2 0 1)=(g x:ℂ)•lp.single 2 0 1 := by + ext k + by_cases hk : k=0 + · subst k; simp only [realPiField_apply,zero_zsmul,add_zero,lp.coeFn_smul,Pi.smul_apply,smul_eq_mul,lp.single_apply,Pi.single_eq_same,mul_one] + · simp only [realPiField_apply,lp.coeFn_smul,Pi.smul_apply,smul_eq_mul,lp.single_apply,Pi.single_eq_of_ne hk,mul_zero] + refine ⟨h1,?_⟩ + have hs : IsSelfAdjoint (realPiField θ g x) := ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mpr (realPiField_symmetric θ g x) + rw [hs.star_eq] + exact h1 +lemma weighted_invariant_diagonal (P Q D : FiberOperator) + (hcov : P*(fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap= + (fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap*Q) + (hinv : (1-P)*((fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap*D)*P=0) : + (1-Q)*D*P=0 := by + have he : (1-P)*((fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap*D)*P= + (fiberShift 1).toContinuousLinearEquiv.toContinuousLinearMap*((1-Q)*D*P) := by + simp only [sub_mul,mul_sub,one_mul,mul_assoc] + rw [←mul_assoc P, hcov, mul_assoc] + rw [he] at hinv + apply ContinuousLinearMap.ext + intro u + apply (fiberShift 1).injective + exact (DFunLike.congr_fun hinv u).trans (map_zero _).symm + +lemma borel_invariant_diagonal_strict (θ : ℝ) + (hθ : Ergodic (fun x : CircleX => x+(θ:CircleX)) AddCircle.haarAddCircle) + (A : CircleFiberOperator) (P : CircleX → FiberOperator) + (hP : ∀ u : CircleFiberL2,∀ᵐ x ∂AddCircle.haarAddCircle,(A u) x=P x (u x)) + (hproj : ∀ x,IsStarProjection (P x)) + (hcov : ∀ n : ℤ,∀ᵐ x ∂AddCircle.haarAddCircle,P x*(fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap= + (fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap*P (x+n•(θ:CircleX))) + (g : RealBorel) (hg : ∀ x,g x≠0) + (hinv : (1-A)*(fiberShiftL2 1*realPi (θ:CircleX) g)*A=0) (hA0 : A≠0) (hA1 : A≠1) : + ∀ᵐ x ∂AddCircle.haarAddCircle,0<(inner ℂ (lp.single 2 0 1) (P x (lp.single 2 0 1))).re ∧ + (inner ℂ (lp.single 2 0 1) (P x (lp.single 2 0 1))).re<1 := by + apply invariant_covariant_diagonal_strict (θ:CircleX) hθ A P hP (Eventually.of_forall hproj) hcov + (realPiField (θ:CircleX) g) (fun x => (g x:ℂ)) + (Eventually.of_forall (fun x => Complex.ofReal_ne_zero.mpr (hg x))) + (Eventually.of_forall (realPiField_proj_eigen (θ:CircleX) g)) _ hA0 hA1 + filter_upwards [decomposable_invariant A P hP (θ:CircleX) g hinv,hcov 1] with x hi hc + rw [one_zsmul] at hc + exact weighted_invariant_diagonal _ _ _ hc hi + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/ProjectionIdentity.lean b/lean/OAI/Analysis/RotationWeights/ProjectionIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b25284ca73dc8b65c8aed2c696bb0394e5cb5f9 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/ProjectionIdentity.lean @@ -0,0 +1,223 @@ +import OAI.Analysis.RotationWeights.GraphTransfer + +namespace OAI + +noncomputable section + +universe uX uE + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace + +namespace CircleSampling +open MeasureTheory Set Filter ContinuousCircleWeight +open scoped ComplexInnerProductSpace Topology ENNReal +local instance : MeasurableSpace FiberHilbert := borel FiberHilbert +local instance : BorelSpace FiberHilbert := ⟨rfl⟩ + +structure ModelProjectionField where + p : CircleX → FiberOperator + projection : ∀ x,IsStarProjection (p x) + norm_le : ∀ x,‖p x‖ ≤ 1 + measurable : ∀ k : ℤ,Measurable (fun x => p x (lp.single 2 k 1)) + invariant : ∀ᵐ x, (1-p x)*fiberCocycleShift (fun k => modelF k x) + (fun k => modelF_pos k x) (modelF_antitone x)*p x=0 + covariance : ∀ n : ℤ, ∀ᵐ x, p x*(fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap= + (fiberShift n).toContinuousLinearEquiv.toContinuousLinearMap*p (CircleModel.shift modelAngle n x) + +def rationalCap (D : ℕ) : ℝ≥0 := ⟨Real.exp (∑ i∈Finset.range D,coordinateDrop i),(Real.exp_pos _).le⟩ +lemma rationalCap_ge_one (D : ℕ) : (1:ℝ) ≤ rationalCap D := by + apply Real.one_le_exp_iff.mpr + exact Finset.sum_nonneg (fun i _ => dropSize_nonneg _) + +lemma stageGraph_ae (j : ℕ) (t : Fin ((scaleState j).1.q (scaleState j).1.d)) + (P : CircleX×CircleX → Prop) + (hP : ∀ n : (scaleStep j).samples t, ∀ᵐ x,stageWeight true j n.val x≠0 → P (x,orbitEquiv n.val x)) : + ∀ᵐ z ∂(stageGraph j t:Measure (CircleX×CircleX)), P z := by + change ∀ᵐ z ∂finiteGraphAverage volume (fun n : (scaleStep j).samples t => stageWeight true j n.val) (fun n => orbitEquiv n.val), P z + unfold finiteGraphAverage + apply Measure.ae_smul_measure + apply ae_finsetSum_measure_iff.mpr + intro n _ + rw [weightedGraph] + have he : MeasurableEmbedding (fun x : CircleX => (x,orbitEquiv n.val x)) := + (measurable_id.prodMk (orbitEquiv n.val).measurable).measurableEmbedding (fun _ _ h => congrArg Prod.fst h) + apply he.ae_map_iff.mpr + rw [weightedMeasure,ae_withDensity_iff (stageWeight_measurable true j n.val).ennreal_ofReal] + filter_upwards [hP n] with x hx hn + apply hx + intro hz + exact hn (by simp [hz]) + +lemma rationalGraph_pair (P : ModelProjectionField) (D : ℕ) (a : Fin (frequency (D+1))) (j : ℕ) : + ∀ᵐ z ∂(rationalGraph D a j:Measure (CircleX×CircleX)), + (1-P.p z.2)*cappedDiagonal modelF (rationalCap D) z.1 z.2*P.p z.1=0 := by + let N := D+1+j + let t := rationalIndex D a j + have hg : ∀ᵐ z ∂(stageGraph N t:Measure (CircleX×CircleX)), z.1∉graphBad N → + (1-P.p z.2)*cappedDiagonal modelF (rationalCap D) z.1 z.2*P.p z.1=0 := by + apply stageGraph_ae N t + intro n + filter_upwards [model_good_ae,P.invariant,P.covariance n.val] with x hx hi hc hw hbad + have hn : (n.val.toNat:ℤ)=n.val := Int.toNat_of_nonneg (sample_bound N n.property).1.le + have hb (k : ℤ) : modelF k (CircleModel.shift modelAngle n.val x)/modelF k x ≤ rationalCap D := + modelF_ratio_tail D hx ((modelGood_shift n.val x).mpr hx) + (restricted_orbit_order N D (rationalPoint D a) (rational_tail_period D a) t + (rationalIndex_spec D a j) n.val n.property x hbad hw) k + have hr (k : ℤ) : modelF (k+(n.val.toNat:ℤ)) x=modelF k (CircleModel.shift modelAngle (n.val.toNat:ℤ) x)*modelF (n.val.toNat:ℤ) x := by + simpa only [add_comm k] using modelF_add (n.val.toNat:ℤ) k x + have hh := positive_orbit_capped_pair modelF modelF_pos modelF_antitone x (CircleModel.shift modelAngle n.val x) n.val.toNat + (by simpa only [hn] using hr) (P.p x) (P.p (CircleModel.shift modelAngle n.val x)) (P.projection x) hi + (by simpa only [hn] using hc) (rationalCap D) hb + exact hh + change ∀ᵐ z ∂(stageGraph N t:Measure (CircleX×CircleX)).restrict (Prod.fst ⁻¹' (graphBad N)ᶜ), _ + rw [ae_restrict_iff' ((graphBad_measurable N).compl.preimage measurable_fst)] + exact hg + +lemma rational_pair_graph (P : ModelProjectionField) (D : ℕ) (a : Fin (frequency (D+1))) : + ∀ᵐ z ∂(circleProbability.toFiniteMeasure.map (fun x => (x,translation (rationalPoint D a) x)) : Measure (CircleX×CircleX)), + (1-P.p z.2)*cappedDiagonal modelF (rationalCap D) z.1 z.2*P.p z.1=0 := by + exact capped_pair_identity_transfer (μ := volume) (νs := rationalGraph D a) P.p P.norm_le P.measurable modelF modelF_measurable modelF_pos + (rationalCap D) (rationalGraph_convergence D a).1 (rationalGraph_pair P D a) (rationalGraph_convergence D a).2 + +lemma rational_pair (P : ModelProjectionField) (D : ℕ) (a : Fin (frequency (D+1))) : + ∀ᵐ x, (1-P.p (x+rationalPoint D a))*cappedDiagonal modelF (rationalCap D) x (x+rationalPoint D a)*P.p x=0 := by + have hh := rational_pair_graph P D a + change ∀ᵐ z ∂Measure.map (fun x : CircleX => (x,x+rationalPoint D a)) volume, _ at hh + exact ae_of_ae_map (p := fun z : CircleX×CircleX => + (1-P.p z.2)*cappedDiagonal modelF (rationalCap D) z.1 z.2*P.p z.1=0) (show AEMeasurable (fun x : CircleX => (x,x+rationalPoint D a)) volume from + (measurable_id.prodMk (measurable_id.add_const _)).aemeasurable) hh +end CircleSampling + +namespace ContinuousCircleWeight +open MeasureTheory Filter Set +open scoped Topology ComplexInnerProductSpace +local instance : MeasurableSpace FiberHilbert := borel FiberHilbert +local instance : BorelSpace FiberHilbert := ⟨rfl⟩ + +lemma stronglyMeasurable_lp_field {X : Type uX} [MeasurableSpace X] + (A : X → FiberOperator) + (hc : ∀ k : ℤ, Measurable (fun x ↦ A x (lp.single 2 k 1))) + (u : FiberHilbert) : StronglyMeasurable (fun x ↦ A x u) := by + classical + let v : Finset ℤ → FiberHilbert := fun s ↦ ∑ k ∈ s, lp.single 2 k (u k) + have hv : Tendsto v atTop (𝓝 u) := lp.hasSum_single (by norm_num) u + apply stronglyMeasurable_of_tendsto atTop (f := fun s x => A x (v s)) + · intro s + simp only [v,map_sum] + apply Finset.stronglyMeasurable_fun_sum + intro k _ + have he : lp.single (E := fun _ : ℤ ↦ ℂ) 2 k (u k) = (u k) • lp.single 2 k (1 : ℂ) := by + simpa using (lp.single_smul (E := fun _ : ℤ ↦ ℂ) 2 k (u k) (1 : ℂ)) + simp only [he,map_smul] + exact (hc k).stronglyMeasurable.const_smul (u k) + · exact tendsto_pi_nhds.mpr (fun x => (A x).continuous.tendsto u |>.comp hv) + +lemma stronglyMeasurable_field_simple {X : Type uX} {E : Type uE} [MeasurableSpace X] + [NormedAddCommGroup E] [NormedSpace ℂ E] + (T : X → (E →L[ℂ] E)) (hT : ∀ v, StronglyMeasurable (fun x ↦ T x v)) (s : SimpleFunc X E) : + StronglyMeasurable (fun x ↦ T x (s x)) := by + classical + have he : (fun x ↦ T x (s x)) = ∑ a ∈ s.range, (s ⁻¹' {a}).indicator (fun x ↦ T x a) := by + funext x + simp [Set.indicator, s.mem_range_self] + rw [he] + exact s.range.stronglyMeasurable_sum fun a _ ↦ (hT a).indicator (s.measurableSet_fiber a) + +lemma stronglyMeasurable_field_apply {X : Type uX} {E : Type uE} [MeasurableSpace X] + [NormedAddCommGroup E] [NormedSpace ℂ E] + (T : X → (E →L[ℂ] E)) (hT : ∀ v, StronglyMeasurable (fun x ↦ T x v)) + (f : X → E) (hf : StronglyMeasurable f) : StronglyMeasurable (fun x ↦ T x (f x)) := by + apply stronglyMeasurable_of_tendsto atTop + (fun n ↦ stronglyMeasurable_field_simple T hT (hf.approx n)) + exact tendsto_pi_nhds.mpr fun x ↦ ((T x).continuous.tendsto (f x)).comp (hf.tendsto_approx x) + +lemma measurable_cappedDiagonal {X : Type uX} [MeasurableSpace X] + (F : ℤ → X → ℝ) (hF : ∀ k,Measurable (F k)) + (B : ℝ≥0) (u : FiberHilbert) : + Measurable (fun z : X×X => cappedDiagonal F B z.1 z.2 u) := by + apply (stronglyMeasurable_lp_field _ ?_ u).measurable + intro k + have he : (fun z : X × X ↦ cappedDiagonal F B z.1 z.2 (lp.single 2 k 1)) = + (fun z ↦ (cappedRatio F B z.1 z.2 k : ℂ) • lp.single 2 k 1) := by + funext z + ext i + simp only [cappedDiagonal,lpDiagonal_apply,lp.coeFn_smul,Pi.smul_apply,smul_eq_mul] + by_cases hi : i=k + · subst i; simp + · simp [lp.single_apply,hi] + rw [he] + have hr : Measurable (fun z : X×X => cappedRatio F B z.1 z.2 k) := + measurable_const.min (measurable_const.max (((hF k).comp measurable_snd).div ((hF k).comp measurable_fst))) + exact hr.complex_ofReal.smul measurable_const + +lemma measurableSet_cappedPairRelation {X : Type uX} [MeasurableSpace X] + (p : X → FiberOperator) (hp : ∀ k : ℤ,Measurable (fun x => p x (lp.single 2 k 1))) + (F : ℤ → X → ℝ) (hF : ∀ k,Measurable (F k)) (B : ℝ≥0) : + MeasurableSet (cappedPairRelation p F B) := by + unfold cappedPairRelation + simp only [Set.ofPred_forall] + apply MeasurableSet.iInter + intro k + have hp' : ∀ u,StronglyMeasurable (fun z : X×X => p z.2 u) := fun u => + (stronglyMeasurable_lp_field p hp u).comp_measurable measurable_snd + have hD : ∀ u,StronglyMeasurable (fun z : X×X => cappedDiagonal F B z.1 z.2 u) := fun u => + (measurable_cappedDiagonal F hF B u).stronglyMeasurable + have hu : StronglyMeasurable (fun z : X×X => cappedDiagonal F B z.1 z.2 (p z.1 (lp.single 2 k 1))) := + stronglyMeasurable_field_apply _ hD _ ((hp k).comp measurable_fst).stronglyMeasurable + have hd := hu.sub (stronglyMeasurable_field_apply _ hp' _ hu) + exact measurableSet_eq_fun hd.measurable measurable_const +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/RadixDigits.lean b/lean/OAI/Analysis/RotationWeights/RadixDigits.lean new file mode 100644 index 0000000000000000000000000000000000000000..51d2222fec22d2d90feeac026e3b86e45e90dfbe --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/RadixDigits.lean @@ -0,0 +1,540 @@ +import OAI.Analysis.RotationWeights.CoordinateLaws + +namespace OAI + +noncomputable section + +namespace CircleDigits + +universe uι uX + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal + +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +section +abbrev CircleX := AddCircle (1 : ℝ) + +def denominator (b : ℕ → ℕ) (n : ℕ) : ℕ := ∏ i∈Finset.range n, b i + +@[simp] lemma denominator_zero (b : ℕ → ℕ) : denominator b 0 = 1 := by simp [denominator] +@[simp] lemma denominator_succ (b : ℕ → ℕ) (n : ℕ) : + denominator b (n+1) = denominator b n * b n := by simp [denominator,Finset.prod_range_succ] + +lemma denominator_pos {b : ℕ → ℕ} (hb : ∀ i, 2≤b i) (n : ℕ) : 0 simp + | succ n hn => rw [denominator_succ,pow_succ]; exact Nat.mul_le_mul hn (hb n) + +lemma denominator_inv_bound {b : ℕ → ℕ} (hb : ∀ i, 2≤b i) (n : ℕ) : + (denominator b n : ℝ)⁻¹ ≤ (1/2 : ℝ)^n := by + rw [one_div,inv_pow] + apply (inv_le_inv₀ (by exact_mod_cast denominator_pos hb n) (by positivity)).mpr + exact_mod_cast denominator_geometric hb n + +lemma denominator_inv_tendsto {b : ℕ → ℕ} (hb : ∀ i, 2≤b i) : + Tendsto (fun n ↦ (denominator b n : ℝ)⁻¹) atTop (𝓝 0) := by + apply squeeze_zero (fun n ↦ by positivity) (denominator_inv_bound hb) + exact tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num) + +abbrev Digits (b : ℕ → ℕ) := ∀ i, Fin (b i) + +def digitTerm (b : ℕ → ℕ) (d : Digits b) (i : ℕ) : ℝ := (d i : ℝ)/denominator b (i+1) + +def expansion (b : ℕ → ℕ) (d : Digits b) : ℝ := ∑' i, digitTerm b d i + +def endpoint (b : ℕ → ℕ) (d : Digits b) : CircleX := (expansion b d : CircleX) + +lemma digitTerm_nonneg (b : ℕ → ℕ) (d : Digits b) (i : ℕ) : 0≤digitTerm b d i := by + unfold digitTerm; positivity + +lemma digitTerm_le_inverse {b : ℕ → ℕ} (hb : ∀ i, 2≤b i) (d : Digits b) (i : ℕ) : + digitTerm b d i ≤ (denominator b i : ℝ)⁻¹ := by + have hq : (0:ℝ) simp + | insert i s hi ih => rw [Finset.sum_insert hi,Finset.prod_insert hi,AddChar.map_add_eq_mul,ih] + +lemma integral_digitPartial {b : ℕ → ℕ} [∀ i, NeZero (b i)] (k : ℤ) (n : ℕ) : + (∫ d : Digits b, character k ((∑ i∈Finset.range n, digitTerm b d i : ℝ) : CircleX) + ∂uniformDigits b) = + ∏ i∈Finset.range n, ∫ d : Fin (b i), character k ((d/(denominator b (i+1) : ℕ) : ℝ) : CircleX) + ∂digitLaw b i := by + classical + have hcoe (d : Digits b) : + ((∑ i∈Finset.range n, digitTerm b d i : ℝ) : CircleX) = + ∑ i∈Finset.range n, (digitTerm b d i : CircleX) := by + exact map_sum (QuotientAddGroup.mk' (AddSubgroup.zmultiples (1:ℝ))) _ _ + simp_rw [hcoe,character_sum] + let f := fun (d : ∀ i : Finset.range n, Fin (b i)) ↦ + ∏ i : Finset.range n, character k ((d i/(denominator b (i.val+1) : ℕ) : ℝ) : CircleX) + have hf : Measurable f := measurable_of_finite _ + have h := integral_restrict_infinitePi (fun i ↦ digitLaw b i) hf.aestronglyMeasurable + change (∫ d, f ((Finset.range n).restrict d) ∂uniformDigits b) = _ at h + simp only [f,Finset.restrict_def] at h + change (∫ d : Digits b, ∏ i∈Finset.range n, + character k ((d i/(denominator b (i+1) : ℕ) : ℝ) : CircleX) ∂uniformDigits b) = _ + have hp := integral_fintype_prod_eq_prod (𝕜 := ℂ) + (fun (i : Finset.range n) (d : Fin (b i)) ↦ + character k ((d/(denominator b (i.val+1) : ℕ) : ℝ) : CircleX)) + (μ := fun i ↦ digitLaw b i) + calc + _ = ∫ d : Digits b, ∏ i : Finset.range n, + character k ((d i/(denominator b (i.val+1) : ℕ) : ℝ) : CircleX) ∂uniformDigits b := by + apply integral_congr_ae + exact ae_of_all _ fun d ↦ (Finset.prod_coe_sort (Finset.range n) + (fun i ↦ character k ((d i/(denominator b (i+1) : ℕ) : ℝ) : CircleX))).symm + _ = ∏ i : Finset.range n, ∫ d : Fin (b i), character k + ((d/(denominator b (i.val+1) : ℕ) : ℝ) : CircleX) ∂digitLaw b i := h.trans hp + _ = _ := Finset.prod_coe_sort (Finset.range n) + (fun i ↦ ∫ d : Fin (b i), character k + ((d/(denominator b (i+1) : ℕ) : ℝ) : CircleX) ∂digitLaw b i) + +lemma integral_endpoint_character {b : ℕ → ℕ} (hb : ∀ i, 2≤b i) + [∀ i, NeZero (b i)] (k : ℤ) : + (∫ d : Digits b, character k (endpoint b d) ∂uniformDigits b) = if k=0 then 1 else 0 := by + classical + by_cases hk : k=0 + · subst k + change (∫ d : Digits b, fourier 0 (endpoint b d) ∂uniformDigits b) = _ + simp + rw [ite_eq_right hk] + let F := fun n (d : Digits b) ↦ + character k ((∑ i∈Finset.range n, digitTerm b d i : ℝ) : CircleX) + have hmeas (n : ℕ) : Measurable (F n) := + (fourier k).continuous.measurable.comp ((AddCircle.continuous_mk' 1).measurable.comp + (Finset.measurable_sum _ fun i _ ↦ measurable_digitTerm b i)) + have hlim := tendsto_integral_of_dominated_convergence (μ := uniformDigits b) (fun _ ↦ (1:ℝ)) + (fun n ↦ (hmeas n).aestronglyMeasurable) (integrable_const 1) + (fun n ↦ ae_of_all _ fun d ↦ by exact (Circle.norm_coe _).le) + (ae_of_all _ fun d ↦ ((fourier k).continuous.continuousAt.tendsto.comp + ((AddCircle.continuous_mk' 1).continuousAt.tendsto.comp + (digitTerm_summable hb d).hasSum.tendsto_sum_nat))) + obtain ⟨i,hdiv,hnot⟩ := exists_nondividing_digit hb hk + have hzero : ∀ᶠ n in atTop, (∫ d, F n d ∂uniformDigits b) = (0:ℂ) := by + filter_upwards [eventually_gt_atTop i] with n hn + rw [show (∫ d, F n d ∂uniformDigits b) = _ from integral_digitPartial k n] + exact Finset.prod_eq_zero (Finset.mem_range.mpr hn) (integral_digitLaw_character_zero hb i k hdiv hnot) + exact tendsto_nhds_unique hlim (tendsto_const_nhds.congr' (hzero.mono fun _ h ↦ h.symm)) + +lemma continuous_integral {X : Type uX} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] + [BorelSpace X] (μ : Measure X) [IsProbabilityMeasure μ] : + Continuous (fun f : C(X,ℂ) ↦ ∫ x, f x ∂μ) := by + apply LipschitzWith.continuous (K := 1) + rw [lipschitzWith_iff_dist_le_mul] + intro f g + simp only [NNReal.coe_one,one_mul,dist_eq_norm] + have hi (f : C(X,ℂ)) : Integrable f μ := + Integrable.of_bound f.continuous.aestronglyMeasurable ‖f‖ (ae_of_all _ f.norm_coe_le_norm) + rw [← integral_sub (hi f) (hi g)] + simpa using norm_integral_le_of_norm_le_const (μ := μ) (ae_of_all _ fun x ↦ (f-g).norm_coe_le_norm x) + +lemma circle_measure_eq_of_fourier (μ ν : Measure CircleX) [IsProbabilityMeasure μ] + [IsProbabilityMeasure ν] + (h : ∀ k : ℤ, (∫ x, fourier k x ∂μ) = ∫ x, fourier k x ∂ν) : μ=ν := by + have hi (m : Measure CircleX) [IsProbabilityMeasure m] (f : C(CircleX,ℂ)) : Integrable f m := + Integrable.of_bound f.continuous.aestronglyMeasurable ‖f‖ (ae_of_all _ f.norm_coe_le_norm) + have hc : IsClosed {f : C(CircleX,ℂ) | (∫ x, f x ∂μ) = ∫ x, f x ∂ν} := + isClosed_eq (continuous_integral μ) (continuous_integral ν) + have hs : (↑(Submodule.span ℂ (Set.range (fourier (T := (1:ℝ))))) : Set C(CircleX,ℂ)) ⊆ + {f | (∫ x, f x ∂μ) = ∫ x, f x ∂ν} := by + intro f hf + induction hf using Submodule.span_induction with + | mem f hf => obtain ⟨k,rfl⟩ := hf; exact h k + | zero => simp + | add f g _ _ hf hg => + change (∫ x, f x+g x ∂μ) = ∫ x, f x+g x ∂ν + rw [integral_add (hi μ f) (hi μ g),integral_add (hi ν f) (hi ν g),hf,hg] + | smul a f _ hf => + change (∫ x, a • f x ∂μ) = ∫ x, a • f x ∂ν + rw [integral_smul,integral_smul,hf] + have hall := closure_minimal hs hc + rw [← Submodule.topologicalClosure_coe,span_fourier_closure_eq_top,Submodule.top_coe] at hall + apply ext_of_forall_integral_eq_of_IsFiniteMeasure + intro f + let g : C(CircleX,ℂ) := ⟨fun x ↦ (f x:ℂ), Complex.continuous_ofReal.comp f.continuous⟩ + have hfg := hall (a := g) (Set.mem_univ _) + change (∫ x, (f x:ℂ) ∂μ) = ∫ x, (f x:ℂ) ∂ν at hfg + simpa only [integral_complex_ofReal,Complex.ofReal_inj] using hfg + +lemma endpoint_measurePreserving {b : ℕ → ℕ} (hb : ∀ i, 2≤b i) + [∀ i, NeZero (b i)] : MeasurePreserving (endpoint b) (uniformDigits b) volume := by + let : IsProbabilityMeasure (volume : Measure CircleX) := by + rw [AddCircle.volume_eq_smul_haarAddCircle] + norm_num + infer_instance + refine ⟨measurable_endpoint b,?_⟩ + have : IsProbabilityMeasure ((uniformDigits b).map (endpoint b)) := + inferInstance + apply circle_measure_eq_of_fourier + intro k + rw [integral_map (measurable_endpoint b).aemeasurable (fourier k).continuous.aestronglyMeasurable] + change (∫ d, character k (endpoint b d) ∂uniformDigits b) = _ + rw [integral_endpoint_character hb] + have hh := congrFun (fourierCoeff_fourier (T := (1:ℝ)) k) 0 + have hm : (AddCircle.haarAddCircle : Measure CircleX) = volume := by + rw [AddCircle.volume_eq_smul_haarAddCircle]; norm_num + simpa [fourierCoeff,Pi.single_apply,eq_comm,hm] using hh.symm + +end + + +def prefixNumeral (b : ℕ → ℕ) (d : Digits b) : ℕ → ℕ + | 0 => 0 + | n+1 => b n * prefixNumeral b d n + d n + +def scaledTail (b : ℕ → ℕ) (d : Digits b) (n : ℕ) : ℝ := + denominator b n * expansion b d - prefixNumeral b d n + +def gridFree (b : ℕ → ℕ) : Set CircleX := {x | ∀ n, denominator b n • x ≠ 0} + +lemma prefixNumeral_sum {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) (d : Digits b) (n : ℕ) : + ∑ i∈Finset.range n, digitTerm b d i = prefixNumeral b d n / (denominator b n : ℝ) := by + induction n with + | zero => simp [prefixNumeral] + | succ n hn => + rw [Finset.sum_range_succ,hn] + simp only [prefixNumeral,denominator_succ,digitTerm,Nat.cast_add,Nat.cast_mul] + have hq : (denominator b n : ℝ) ≠ 0 := by exact_mod_cast (denominator_pos hb n).ne' + have hb' : (b n : ℝ) ≠ 0 := by exact_mod_cast (lt_of_lt_of_le (by norm_num : 0<2) (hb n)).ne' + field_simp + +lemma scaledTail_bounds {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) (d : Digits b) (n : ℕ) : + 0 ≤ scaledTail b d n ∧ scaledTail b d n ≤ 1 := by + have h := expansion_tail_bound hb d n + rw [prefixNumeral_sum hb] at h + have hq : (0:ℝ) x ≠ 0) hz + +lemma scaledTail_lt_one {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) (d : Digits b) + (hd : endpoint b d ∈ gridFree b) (n : ℕ) : scaledTail b d n<1 := by + apply lt_of_le_of_ne (scaledTail_bounds hb d n).2 + intro he + apply hd n + rw [← scaledTail_coe d n,he] + exact_mod_cast (AddCircle.coe_period (1:ℝ)) + +lemma scaledTail_repr {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) (d : Digits b) + (hd : endpoint b d ∈ gridFree b) (n : ℕ) : + ((AddCircle.measurableEquivIco 1 0 (denominator b n • endpoint b d)).val : ℝ) = + scaledTail b d n := by + rw [← scaledTail_coe d n] + change (AddCircle.equivIco 1 0 ((scaledTail b d n : ℝ) : CircleX)).val = _ + rw [AddCircle.coe_equivIco_mk_apply] + simp only [div_one,mul_one] + exact Int.fract_eq_self.mpr ⟨(scaledTail_bounds hb d n).1,scaledTail_lt_one hb d hd n⟩ + +lemma scaledTail_recurrence (b : ℕ → ℕ) (d : Digits b) (n : ℕ) : + (b n : ℝ)*scaledTail b d n = (d n : ℝ)+scaledTail b d (n+1) := by + simp only [scaledTail,prefixNumeral,denominator_succ,Nat.cast_add,Nat.cast_mul] + ring + +lemma digit_interval {b : ℕ → ℕ} (hb : ∀ i, 2 ≤ b i) (d : Digits b) + (hd : endpoint b d ∈ gridFree b) (n : ℕ) : + (d n : ℝ)/(b n : ℝ) ≤ scaledTail b d n ∧ + scaledTail b d n < ((d n : ℝ)+1)/(b n : ℝ) := by + have hpos : (0:ℝ) measurableSet_le measurable_const (measurable_Xi q i)) +lemma measurableSet_lowerExceptional (q : ℕ → ℕ) (r : ℕ → ℝ) : MeasurableSet (lowerExceptional q r) := + MeasurableSet.iUnion (fun i => measurableSet_lt (measurable_Xi q i) measurable_const) +lemma measure_Xi_upper {q : ℕ → ℕ} (hq : ∀ i, q i≠0) (i : ℕ) (r : ℝ) : + volume {x : CircleX | 1-r ≤ Xi q i x} ≤ ENNReal.ofReal r := by + change volume ((fun x : CircleX => q i • x) ⁻¹' (repr ⁻¹' Ici (1-r))) ≤ _ + rw [(measurePreserving_XiMap hq i).measure_preimage (measurable_repr measurableSet_Ici).nullMeasurableSet] + exact measure_repr_upper +lemma measure_Xi_lower {q : ℕ → ℕ} (hq : ∀ i, q i≠0) (i : ℕ) (r : ℝ) : + volume {x : CircleX | Xi q i x < r} ≤ ENNReal.ofReal r := by + change volume ((fun x : CircleX => q i • x) ⁻¹' (repr ⁻¹' Iio r)) ≤ _ + rw [(measurePreserving_XiMap hq i).measure_preimage (measurable_repr measurableSet_Iio).nullMeasurableSet] + exact measure_repr_lower +lemma measure_upperExceptional {q : ℕ → ℕ} (hq : ∀ i, q i≠0) (r : ℕ → ℝ) + (hr : ∀ i, 0 ≤ r i) (hs : Summable r) : + volume.real (upperExceptional q r) ≤ ∑' i, r i := by + have hh : volume (upperExceptional q r) ≤ ENNReal.ofReal (∑' i, r i) := by + calc + _ ≤ ∑' i, volume {x : CircleX | 1-r i ≤ Xi q i x} := measure_iUnion_le _ + _ ≤ ∑' i, ENNReal.ofReal (r i) := ENNReal.tsum_le_tsum (fun i => measure_Xi_upper hq i (r i)) + _ = _ := (ENNReal.ofReal_tsum_of_nonneg hr hs).symm + exact ENNReal.toReal_le_of_le_ofReal (tsum_nonneg hr) hh +lemma measure_lowerExceptional {q : ℕ → ℕ} (hq : ∀ i, q i≠0) (r : ℕ → ℝ) + (hr : ∀ i, 0 ≤ r i) (hs : Summable r) : + volume.real (lowerExceptional q r) ≤ ∑' i, r i := by + have hh : volume (lowerExceptional q r) ≤ ENNReal.ofReal (∑' i, r i) := by + calc + _ ≤ ∑' i, volume {x : CircleX | Xi q i x < r i} := measure_iUnion_le _ + _ ≤ ∑' i, ENNReal.ofReal (r i) := ENNReal.tsum_le_tsum (fun i => measure_Xi_lower hq i (r i)) + _ = _ := (ENNReal.ofReal_tsum_of_nonneg hr hs).symm + exact ENNReal.toReal_le_of_le_ofReal (tsum_nonneg hr) hh +end CircleModel + +namespace CircleSampling + +section +open CircleModel Set MeasureTheory Filter +open scoped ENNReal Topology BigOperators + +lemma graphTolerance_pos (j : ℕ) : 0 < gridTolerance j (scaleState j).1 := by + unfold gridTolerance + have := (scaleState j).2.qpos (scaleState j).1.d le_rfl + positivity +lemma oldGraphBad_bound (j : ℕ) : + volume.real (oldGraphBad j) ≤ 1/(10*((j:ℝ)+1)^2) := by + have htol := (graphTolerance_pos j).le + have hq : 0 < ((scaleState j).1.q (scaleState j).1.d:ℝ) := Nat.cast_pos.mpr ((scaleState j).2.qpos _ le_rfl) + calc + _ ≤ ∑ i : Fin (blockEnd j), volume.real {x : CircleX | 1-(modelFrequency i:ℝ)*gridTolerance j (scaleState j).1 ≤ CircleModel.Xi modelFrequency i x} := measureReal_iUnion_fintype_le _ + _ ≤ ∑ i : Fin (blockEnd j), (modelFrequency i:ℝ)*gridTolerance j (scaleState j).1 := by + apply Finset.sum_le_sum + intro i _ + exact ENNReal.toReal_le_of_le_ofReal (mul_nonneg (Nat.cast_nonneg _) htol) + (CircleModel.measure_Xi_upper (fun i => (frequency_pos (i+1)).ne') i _) + _ ≤ ∑ _i : Fin (blockEnd j), ((scaleState j).1.q (scaleState j).1.d:ℝ)*gridTolerance j (scaleState j).1 := by + apply Finset.sum_le_sum + intro i _ + apply mul_le_mul_of_nonneg_right _ htol + have hf := frequency_strictMono.monotone (show i.val+1 ≤ blockEnd j by omega) + rw [frequency_eq_state (j:=j) le_rfl] at hf + exact_mod_cast hf + _ = (blockEnd j:ℝ)*(((scaleState j).1.q (scaleState j).1.d:ℝ)*gridTolerance j (scaleState j).1) := by simp + _ ≤ _ := by + unfold gridTolerance blockEnd + have hd : 0 ≤ ((scaleState j).1.d:ℝ) := Nat.cast_nonneg _ + have hj : 0 < (j:ℝ)+1 := by positivity + field_simp + nlinarith [sq_pos_of_pos hj] + +lemma measure_iUnion_le_ofReal_tsum {ι : Type uι} {X : Type uX} [Countable ι] [MeasurableSpace X] + (μ : Measure X) (A : ι → Set X) (b : ι → ℝ) (hb : ∀ i, 0 ≤ b i) + (hs : Summable b) (h : ∀ i, μ (A i) ≤ ENNReal.ofReal (b i)) : + μ (⋃ i, A i) ≤ ENNReal.ofReal (∑' i, b i) := by + calc + _ ≤ ∑' i, μ (A i) := measure_iUnion_le _ + _ ≤ ∑' i, ENNReal.ofReal (b i) := ENNReal.tsum_le_tsum h + _ = _ := (ENNReal.ofReal_tsum_of_nonneg hb hs).symm +lemma tailGraphBad_subset (j : ℕ) : tailGraphBad j ⊆ + ⋃ s : ℕ, ⋃ k : Fin (blockLength (j+1+s)), + {x | 1-sampleBound j*coordinatePhase (blocks.equiv ⟨j+1+s,k⟩) ≤ CircleModel.Xi modelFrequency (blocks.equiv ⟨j+1+s,k⟩) x} := by + rintro x hx + obtain ⟨i,hi⟩ := mem_iUnion.mp hx + obtain ⟨⟨b,k⟩,he⟩ := blocks.equiv.surjective i.val + have hi' : i.val < blockEnd (b+1) := by + rw [←he] + change blockEnd b+k.val < blockEnd b+blockLength b + exact Nat.add_lt_add_left k.isLt _ + have hb : j+1 ≤ b := by + by_contra! hb + have := blockEnd_strictMono.monotone (show b+1 ≤ j+1 by omega) + omega + have heq : j+1+(b-(j+1))=b := by omega + apply mem_iUnion.mpr + refine ⟨b-(j+1),?_⟩ + rw [heq] + exact mem_iUnion.mpr ⟨k,by simpa only [he] using hi⟩ +lemma tailGraphBad_bound (j : ℕ) : + volume.real (tailGraphBad j) ≤ 4*sampleBound j/(polynomialWindow (j+1):ℝ) := by + have hQ := (sampleBound_pos j).le + have hq : ∀ i, modelFrequency i ≠ 0 := fun i => (frequency_pos (i+1)).ne' + have hs : Summable (fun s => 2*sampleBound j/(polynomialWindow (j+1+s):ℝ)) := by + simpa only [div_eq_mul_inv,one_mul] using (summable_window_inverse (j+1)).mul_left (2*sampleBound j) + have hblock (s : ℕ) : volume (⋃ k : Fin (blockLength (j+1+s)), + {x : CircleX | 1-sampleBound j*coordinatePhase (blocks.equiv ⟨j+1+s,k⟩) ≤ CircleModel.Xi modelFrequency (blocks.equiv ⟨j+1+s,k⟩) x}) ≤ + ENNReal.ofReal (2*sampleBound j/(polynomialWindow (j+1+s):ℝ)) := by + apply (measure_iUnion_le_ofReal_tsum volume _ _ (fun k => mul_nonneg (sampleBound_pos j).le (coordinatePhase_pos _).le) + (Summable.of_finite) (fun k => CircleModel.measure_Xi_upper hq _ _)).trans + apply ENNReal.ofReal_le_ofReal + rw [tsum_fintype,←Finset.mul_sum] + calc + _ ≤ sampleBound j*(2/(polynomialWindow (j+1+s):ℝ)) := + mul_le_mul_of_nonneg_left (sum_phase_block _) (sampleBound_pos j).le + _ = _ := by ring + have hm : volume (tailGraphBad j) ≤ ENNReal.ofReal (∑' s, 2*sampleBound j/(polynomialWindow (j+1+s):ℝ)) := + (measure_mono (tailGraphBad_subset j)).trans (measure_iUnion_le_ofReal_tsum volume _ _ (fun _ => by positivity) hs hblock) + apply (ENNReal.toReal_le_of_le_ofReal (tsum_nonneg (fun _ => by positivity)) hm).trans + simp_rw [div_eq_mul_inv] + rw [tsum_mul_left] + calc + _ ≤ 2*sampleBound j*(2/(polynomialWindow (j+1):ℝ)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + simpa only [one_div] using tsum_window_inverse (j+1) + _ = _ := by ring + +lemma sampleBound_div_window (j : ℕ) : sampleBound j/(polynomialWindow (j+1):ℝ) ≤ 1/(blockLength j:ℝ) := by + have hm : 0 < (blockLength j:ℝ) := Nat.cast_pos.mpr (scaleStep j).mpos + have hm1 : 1 ≤ (blockLength j:ℝ) := by exact_mod_cast (scaleStep j).mpos + have hm20 : (20:ℝ) ≤ blockLength j := by exact_mod_cast (show 20 ≤ blockLength j from (by have := blockLength_ge j; omega)) + have hk : (blockLength j:ℝ)^((3:ℝ)/4*blockLength j) ≤ (polynomialWindow (j+1):ℝ) := Nat.le_ceil _ + calc + _ ≤ sampleBound j/((blockLength j:ℝ)^((3:ℝ)/4*blockLength j)) := + div_le_div_of_nonneg_left (sampleBound_pos j).le (Real.rpow_pos_of_pos hm _) hk + _ = (blockLength j:ℝ)^(-(1:ℝ)/20*blockLength j) := by + rw [sampleBound,←Real.rpow_sub hm] + congr 1 + ring + _ ≤ (blockLength j:ℝ)^(-(1:ℝ)) := Real.rpow_le_rpow_of_exponent_le hm1 (by linarith) + _ = _ := by rw [Real.rpow_neg_one,one_div] +lemma graphBad_bound (j : ℕ) : volume.real (graphBad j) ≤ 1/(10*((j:ℝ)+1)^2)+4/(blockLength j:ℝ) := by + calc + _ ≤ volume.real (oldGraphBad j)+volume.real (tailGraphBad j) := measureReal_union_le _ _ + _ ≤ 1/(10*((j:ℝ)+1)^2)+4*sampleBound j/(polynomialWindow (j+1):ℝ) := add_le_add (oldGraphBad_bound j) (tailGraphBad_bound j) + _ ≤ _ := by + have h := mul_le_mul_of_nonneg_left (sampleBound_div_window j) (by norm_num : (0:ℝ) ≤ 4) + apply add_le_add le_rfl + simpa only [div_eq_mul_inv,mul_one,one_mul,mul_assoc] using h +lemma graphBad_tendsto : Tendsto (fun j => volume.real (graphBad j)) atTop (𝓝 0) := by + have ha : Tendsto (fun j : ℕ => 1/(10*((j:ℝ)+1)^2)) atTop (𝓝 0) := by + have h := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℝ)).pow 2 + convert h.div_const 10 using 1 + · ext j + field_simp + · norm_num + have hb : Tendsto (fun j => 4/(blockLength j:ℝ)) atTop (𝓝 0) := by + simpa only [div_eq_mul_inv,one_mul,mul_zero,Function.comp_def] using ((tendsto_one_div_atTop_nhds_zero_nat (𝕜:=ℝ)).comp blockLength_strictMono.tendsto_atTop).const_mul 4 + exact squeeze_zero (fun _ => measureReal_nonneg) graphBad_bound (by simpa using ha.add hb) +end +open Set +lemma frequency_dvd_of_le {a b : ℕ} (h : a ≤ b) : frequency a ∣ frequency b := by + induction b, h using Nat.le_induction with + | base => exact dvd_rfl + | succ b h ih => exact ih.trans (frequency_dvd b) +lemma circle_nat_zero (a : ℕ) : ((a:ℝ):CircleX)=0 := by + rw [←mul_one (a:ℝ),←nsmul_eq_mul,AddCircle.coe_nsmul,AddCircle.coe_period,nsmul_zero] +lemma rational_annihilated {N P : ℕ} (hN : 0 < N) (hNP : N ∣ P) (a : ℕ) : + P • (((a:ℝ)/(N:ℝ):ℝ):CircleX)=0 := by + obtain ⟨c,rfl⟩ := hNP + rw [←AddCircle.coe_nsmul,nsmul_eq_mul] + have he : ((N*c:ℕ):ℝ)*((a:ℝ)/(N:ℝ))=((c*a:ℕ):ℝ) := by + push_cast + field_simp + rw [he,circle_nat_zero] +lemma rational_grid_lift {N P : ℕ} (hN : 0 < N) (hP : 0 < P) (hNP : N ∣ P) + (a : Fin N) : ∃ t : Fin P, ((t.val:ℝ)/(P:ℝ):ℝ) = (a.val:ℝ)/(N:ℝ) := by + obtain ⟨c,rfl⟩ := hNP + have hc : 0 < c := Nat.pos_of_mul_pos_left hP + refine ⟨⟨a.val*c,Nat.mul_lt_mul_of_pos_right a.isLt hc⟩,?_⟩ + dsimp + push_cast + field_simp +lemma rational_stage_index (D j : ℕ) (a : Fin (frequency (D+1))) (hj : D+1 ≤ blockEnd j) : + ∃ t : Fin ((scaleState j).1.q (scaleState j).1.d), + gridPoint (scaleState j).1 t=(((a.val:ℝ)/(frequency (D+1):ℝ):ℝ):CircleX) := by + have hq : frequency (blockEnd j)=(scaleState j).1.q (scaleState j).1.d := frequency_eq_state (j:=j) le_rfl + have hdiv := frequency_dvd_of_le hj + rw [hq] at hdiv + obtain ⟨t,ht⟩ := rational_grid_lift (frequency_pos (D+1)) ((scaleState j).2.qpos _ le_rfl) hdiv a + exact ⟨t,congrArg (fun x : ℝ => (x:CircleX)) ht⟩ +lemma rational_tail_period (D : ℕ) (a : Fin (frequency (D+1))) (i : ℕ) (hi : D ≤ i) : + modelFrequency i • (((a.val:ℝ)/(frequency (D+1):ℝ):ℝ):CircleX)=0 := + rational_annihilated (frequency_pos (D+1)) (frequency_dvd_of_le (Nat.add_le_add_right hi 1)) _ +end CircleSampling + +open MeasureTheory Set +namespace CircleSampling + +section + +lemma integral_norm_le_sqrt {X : Type uX} [MeasurableSpace X] (μ : Measure X) + [IsProbabilityMeasure μ] {f : X → ℝ} (hf : MemLp f 2 μ) : + (∫ x, ‖f x‖ ∂μ) ≤ Real.sqrt (∫ x, (f x)^2 ∂μ) := by + have hh := integral_mul_norm_le_Lp_mul_Lq + (show Real.HolderConjugate 2 2 by norm_num [Real.holderConjugate_iff]) + (by simpa using hf) (show MemLp (fun _ : X => (1:ℝ)) (ENNReal.ofReal 2) μ from memLp_const 1) + simpa [Real.rpow_two,Real.sqrt_eq_rpow,Real.norm_eq_abs,sq_abs] using hh + +lemma setIntegral_norm_le_sqrt {X : Type uX} [MeasurableSpace X] (μ : Measure X) + [IsFiniteMeasure μ] {f : X → ℝ} (hf : MemLp f 2 μ) (A : Set X) (hA : MeasurableSet A) : + (∫ x in A, ‖f x‖ ∂μ) ≤ Real.sqrt (∫ x, (f x)^2 ∂μ)*Real.sqrt (μ.real A) := by + have hi := (memLp_const (1:ℝ) (μ:=μ) (p:=2)).indicator hA + have hh := integral_mul_norm_le_Lp_mul_Lq + (show Real.HolderConjugate 2 2 by norm_num [Real.holderConjugate_iff]) + (by simpa using hf) (by simpa using hi) + have he (x : X) : ‖f x‖*‖A.indicator (fun _ => (1:ℝ)) x‖ = A.indicator (fun x => ‖f x‖) x := by + by_cases hx : x∈A <;> simp [hx] + have he2 (x : X) : ‖A.indicator (fun _ => (1:ℝ)) x‖^(2:ℝ) = A.indicator (fun _ => (1:ℝ)) x := by + by_cases hx : x∈A <;> simp [hx] + have hl : (∫ x, ‖f x‖*‖A.indicator (fun _ => (1:ℝ)) x‖ ∂μ) = ∫ x in A, ‖f x‖ ∂μ := by + simp_rw [he] + exact integral_indicator hA + have hr : (∫ x, ‖A.indicator (fun _ => (1:ℝ)) x‖^(2:ℝ) ∂μ) = μ.real A := by + simp_rw [he2] + rw [integral_indicator hA] + simp + rw [hl,hr] at hh + simpa only [Real.rpow_two,Real.norm_eq_abs,sq_abs,Real.sqrt_eq_rpow,one_div] using hh + +lemma setIntegral_nonneg_le_sqrt {X : Type uX} [MeasurableSpace X] (μ : Measure X) + [IsFiniteMeasure μ] {f : X → ℝ} (hf : MemLp f 2 μ) (hn : ∀ x,0≤f x) + (A : Set X) (hA : MeasurableSet A) : + (∫ x in A, f x ∂μ) ≤ Real.sqrt (∫ x, (f x)^2 ∂μ)*Real.sqrt (μ.real A) := by + simpa only [Real.norm_of_nonneg (hn _)] using setIntegral_norm_le_sqrt μ hf A hA + +lemma integral_sq_le_of_error {X : Type uX} [MeasurableSpace X] (μ : Measure X) + [IsProbabilityMeasure μ] {f : X → ℝ} (hf : MemLp f 2 μ) {ε : ℝ} + (hε : 0≤ε) (he : (∫ x,(f x-1)^2 ∂μ) ≤ ε^2) : + (∫ x,(f x)^2 ∂μ) ≤ (1+ε)^2 := by + have hg : MemLp (fun x => f x-1) 2 μ := hf.sub (memLp_const 1) + have hin : Integrable f μ := hf.integrable (by norm_num) + have hgs := hg.integrable_sq + have hL := integral_norm_le_sqrt μ hg + have herr : (∫ x,f x-1 ∂μ) ≤ ε := by + calc + _ ≤ ∫ x,‖f x-1‖ ∂μ := integral_mono (hg.integrable (by norm_num)) (hg.norm.integrable (by norm_num)) (fun _ => le_abs_self _) + _ ≤ Real.sqrt (∫ x,(f x-1)^2 ∂μ) := hL + _ ≤ ε := (Real.sqrt_le_left hε).mpr he + have hid : (∫ x,(f x)^2 ∂μ) = (∫ x,(f x-1)^2 ∂μ)+2*(∫ x,f x-1 ∂μ)+1 := by + have hp (x : X) : (f x)^2=(f x-1)^2+2*(f x-1)+1 := by ring + simp_rw [hp] + have hmid : Integrable (fun x => (f x-1)^2+2*(f x-1)) μ := hgs.add ((hg.integrable (by norm_num)).const_mul 2) + rw [integral_add hmid (integrable_const 1)] + rw [integral_add hgs ((hg.integrable (by norm_num)).const_mul 2),integral_const_mul] + simp + rw [hid] + nlinarith + +open MeasureTheory Set Filter +open scoped Topology ENNReal BoundedContinuousFunction +variable {X : Type uX} [MeasurableSpace X] + +lemma weightedMeasure_le_sqrt (μ : Measure X) [IsFiniteMeasure μ] + {f : X → ℝ} (hf : MemLp f 2 μ) (hn : ∀ x, 0 ≤ f x) {C : ℝ} + (hC : 0 ≤ C) (hb : (∫ x, (f x)^2 ∂μ) ≤ C^2) + (A : Set X) (hA : MeasurableSet A) : + (weightedMeasure μ f).real A ≤ C*Real.sqrt (μ.real A) := by + rw [weightedMeasure_real_apply μ (hf.integrable (by norm_num)) hn hA] + exact (setIntegral_nonneg_le_sqrt μ hf hn A hA).trans + (mul_le_mul_of_nonneg_right ((Real.sqrt_le_left hC).mpr hb) (Real.sqrt_nonneg _)) + +lemma finiteMeasure_sqrt_uc {Y : Type uY} [MeasurableSpace Y] + (μ : Measure X) [IsFiniteMeasure μ] (ν : ℕ → Measure Y) [∀ j, IsFiniteMeasure (ν j)] + (T : Y → X) (_hT : Measurable T) {C : ℝ} (hC : 0 < C) + (hb : ∀ j A, MeasurableSet A → (ν j).real (T ⁻¹' A) ≤ C*Real.sqrt (μ.real A)) : + ∀ ε : ℝ≥0∞, ε ≠ 0 → ∃ δ : ℝ≥0∞, δ ≠ 0 ∧ + ∀ A : Set X, μ A < δ → ∀ j, ν j (T ⁻¹' A) ≤ ε := by + intro ε hε + by_cases htop : ε=⊤ + · exact ⟨1,by norm_num,fun _ _ _ => htop.symm ▸ le_top⟩ + have he : 0 < ε.toReal := ENNReal.toReal_pos hε htop + refine ⟨ENNReal.ofReal ((ε.toReal/C)^2), ENNReal.ofReal_ne_zero_iff.mpr (sq_pos_of_pos (div_pos he hC)), ?_⟩ + intro A hA j + let B := toMeasurable μ A + have hB : MeasurableSet B := measurableSet_toMeasurable μ A + have hμ : μ B=μ A := measure_toMeasurable A + have hBr : μ.real B ≤ (ε.toReal/C)^2 := by + apply (ENNReal.toReal_le_of_le_ofReal (sq_nonneg _)) + rw [hμ] + exact hA.le + apply le_trans (measure_mono (preimage_mono (subset_toMeasurable μ A))) + apply (ENNReal.toReal_le_toReal (measure_ne_top _ _) htop).mp + calc + _ ≤ C*Real.sqrt (μ.real B) := hb j B hB + _ ≤ C*(ε.toReal/C) := mul_le_mul_of_nonneg_left ((Real.sqrt_le_left (div_pos he hC).le).mpr hBr) hC.le + _ = ε.toReal := mul_div_cancel₀ _ hC.ne' + +lemma weightedMeasure_l1_test [TopologicalSpace X] [BorelSpace X] + (μ : Measure X) [IsProbabilityMeasure μ] {f : X → ℝ} + (hf : MemLp f 2 μ) (hm : Measurable f) (hn : ∀ x, 0 ≤ f x) + (φ : X →ᵇ ℝ) : + |(∫ x, φ x ∂weightedMeasure μ f)-(∫ x, φ x ∂μ)| ≤ + ‖φ‖*Real.sqrt (∫ x, (f x-1)^2 ∂μ) := by + have hfi := hf.integrable (by norm_num) + have hfg : Integrable (fun x => f x*φ x) μ := hfi.mul_bdd φ.continuous.aestronglyMeasurable (ae_of_all _ φ.norm_coe_le_norm) + have hg : MemLp (fun x => f x-1) 2 μ := hf.sub (memLp_const 1) + rw [weightedMeasure_integral μ hm hn φ, ←integral_sub hfg (φ.integrable μ)] + have he : (fun x => f x*φ x-φ x) = (fun x => (f x-1)*φ x) := by ext x; ring + rw [he] + calc + _ ≤ ∫ x, ‖(f x-1)*φ x‖ ∂μ := norm_integral_le_integral_norm _ + _ ≤ ∫ x, ‖φ‖*‖f x-1‖ ∂μ := by + apply integral_mono ((hfg.sub (φ.integrable μ)).congr (ae_of_all _ (fun x => by dsimp; ring))).norm + ((hg.norm.integrable (by norm_num)).const_mul ‖φ‖) + intro x + dsimp only + rw [norm_mul,mul_comm] + exact mul_le_mul_of_nonneg_right (φ.norm_coe_le_norm x) (norm_nonneg _) + _ = ‖φ‖*(∫ x, ‖f x-1‖ ∂μ) := integral_const_mul _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left (integral_norm_le_sqrt μ hg) (norm_nonneg _) + +lemma weightedMeasure_test_restrict [TopologicalSpace X] [BorelSpace X] + (μ : Measure X) [IsFiniteMeasure μ] {f : X → ℝ} + (hf : Integrable f μ) (_hm : Measurable f) (hn : ∀ x, 0 ≤ f x) + (A : Set X) (hA : MeasurableSet A) (φ : X →ᵇ ℝ) : + |(∫ x, φ x ∂(weightedMeasure μ f).restrict Aᶜ)-(∫ x, φ x ∂weightedMeasure μ f)| ≤ + ‖φ‖*(weightedMeasure μ f).real A := by + have := weightedMeasure_finite μ hf hn + have hi : Integrable φ (weightedMeasure μ f) := φ.integrable _ + have he := integral_add_compl hA hi + have hsub : (∫ x, φ x ∂(weightedMeasure μ f).restrict Aᶜ)-(∫ x, φ x ∂weightedMeasure μ f) = + -(∫ x in A, φ x ∂weightedMeasure μ f) := by linarith [he] + rw [hsub,abs_neg] + calc + _ ≤ ∫ x in A, ‖φ x‖ ∂weightedMeasure μ f := norm_integral_le_integral_norm _ + _ ≤ ∫ _x in A, ‖φ‖ ∂weightedMeasure μ f := integral_mono hi.restrict.norm (integrable_const _) φ.norm_coe_le_norm + _ = _ := by simp [mul_comm] +end + +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction + +lemma tendsto_integral_graph_error {X : Type uX} [PseudoMetricSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] + (ν : ℕ → FiniteMeasure (X×X)) (T : C(X,X)) (r : ℕ → ℝ) + (hr : Tendsto r atTop (𝓝 0)) {M : ℝ} (hM : 0≤M) + (hmass : ∀ j, (ν j : Measure (X×X)).real univ≤M) + (hsupport : ∀ j, ∀ᵐ z ∂(ν j : Measure (X×X)), dist z.2 (T z.1)≤r j) + (φ : (X×X) →ᵇ ℝ) : + Tendsto (fun j => ∫ z, φ z-φ (z.1,T z.1) ∂(ν j : Measure (X×X))) atTop (𝓝 0) := by + apply Metric.tendsto_atTop.mpr + intro ε hε + have he : 0<ε/(M+1) := div_pos hε (by linarith) + obtain ⟨δ,hδ,hclose⟩ := Metric.uniformContinuous_iff.mp (CompactSpace.uniformContinuous_of_continuous φ.continuous) (ε/(M+1)) he + obtain ⟨N,hN⟩ := (eventually_atTop.mp (hr.eventually_lt_const hδ)) + refine ⟨N,fun n hn => ?_⟩ + have hb : ∀ᵐ z ∂(ν n : Measure (X×X)), ‖φ z-φ (z.1,T z.1)‖≤ε/(M+1) := by + filter_upwards [hsupport n] with z hz + have hd : dist z (z.1,T z.1)<δ := by + simpa only [Prod.dist_eq,dist_self, max_eq_right (dist_nonneg)] using hz.trans_lt (hN n hn) + simpa only [dist_eq_norm] using (hclose hd).le + calc + _ = ‖∫ z, φ z-φ (z.1,T z.1) ∂(ν n : Measure (X×X))‖ := dist_zero_right _ + _ ≤ (ε/(M+1))*(ν n : Measure (X×X)).real univ := norm_integral_le_of_norm_le_const hb + _ ≤ (ε/(M+1))*M := mul_le_mul_of_nonneg_left (hmass n) he.le + _ < ε := by + have hh : (ε/(M+1))*(M+1)=ε := div_mul_cancel₀ _ (by linarith) + nlinarith + +lemma tendsto_graph_of_fst {X : Type uX} [MetricSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] + (ν : ℕ → FiniteMeasure (X×X)) (μ : FiniteMeasure X) (T : C(X,X)) (r : ℕ → ℝ) + (hr : Tendsto r atTop (𝓝 0)) {M : ℝ} (hM : 0≤M) + (hmass : ∀ j, (ν j : Measure (X×X)).real univ≤M) + (hsupport : ∀ j, ∀ᵐ z ∂(ν j : Measure (X×X)), dist z.2 (T z.1)≤r j) + (hfst : Tendsto (fun j => (ν j).map Prod.fst) atTop (𝓝 μ)) : + Tendsto ν atTop (𝓝 (μ.map (fun x => (x,T x)))) := by + apply FiniteMeasure.tendsto_iff_forall_integral_tendsto.mpr + intro φ + let ψ : X →ᵇ ℝ := BoundedContinuousFunction.mkOfCompact ⟨fun x => φ (x,T x),by fun_prop⟩ + have hf := FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp hfst ψ + have hcomp : ∀ j, (∫ x, ψ x ∂((ν j).map Prod.fst : Measure X))= + ∫ z, φ (z.1,T z.1) ∂(ν j : Measure (X×X)) := by + intro j + exact integral_map measurable_fst.aemeasurable ψ.continuous.measurable.aestronglyMeasurable + have htgt : (∫ z, φ z ∂(μ.map (fun x => (x,T x)) : Measure (X×X)))=∫ x, ψ x ∂(μ : Measure X) := by + exact integral_map (by fun_prop) φ.continuous.measurable.aestronglyMeasurable + simp_rw [hcomp] at hf + rw [htgt] + have hd := tendsto_integral_graph_error ν T r hr hM hmass hsupport φ + have hi2 (j : ℕ) : Integrable (fun z : X×X => φ (z.1,T z.1)) (ν j : Measure (X×X)) := + (show Continuous (fun z : X×X => φ (z.1,T z.1)) by fun_prop).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + have hid (j : ℕ) : (∫ z,φ z-φ (z.1,T z.1) ∂(ν j : Measure (X×X)))+ + (∫ z,φ (z.1,T z.1) ∂(ν j : Measure (X×X)))=∫ z,φ z ∂(ν j : Measure (X×X)) := by + rw [integral_sub (φ.integrable _) (hi2 j)] + ring + simpa only [hid,zero_add] using hd.add hf +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Regular.lean b/lean/OAI/Analysis/RotationWeights/Regular.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab53e1c2195df4d37be7763fe66a411715c103f0 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Regular.lean @@ -0,0 +1,233 @@ +import OAI.Analysis.RotationWeights.Model + +namespace OAI + +universe uι + +noncomputable section +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +namespace ContinuousCircleWeight + +def lpPermute {ι : Type uι} (e : Equiv.Perm ι) : + lp (fun _ : ι => ℂ) 2 ≃ₗᵢ[ℂ] lp (fun _ : ι => ℂ) 2 where + toFun f := ⟨fun i => f (e.symm i), by + apply memℓp_gen + exact e.symm.summable_iff.mpr ((lp.memℓp f).summable (by norm_num))⟩ + invFun f := ⟨fun i => f (e i), by + apply memℓp_gen + exact e.summable_iff.mpr ((lp.memℓp f).summable (by norm_num))⟩ + left_inv f := by ext i; simp + right_inv f := by ext i; simp + map_add' f g := by ext i; rfl + map_smul' c f := by ext i; rfl + norm_map' f := by + rw [lp.norm_eq_tsum_rpow (by norm_num), lp.norm_eq_tsum_rpow (by norm_num)] + congr 1 + exact e.symm.tsum_eq (fun i => ‖f i‖ ^ (2 : ℝ≥0∞).toReal) + +@[simp] theorem lpPermute_apply {ι : Type uι} (e : Equiv.Perm ι) + (f : lp (fun _ : ι => ℂ) 2) (i : ι) : lpPermute e f i = f (e.symm i) := rfl + +@[simp] theorem lpPermute_one {ι : Type uι} : lpPermute (1 : Equiv.Perm ι) = 1 := by + ext f i + rfl + +@[simp] theorem lpPermute_mul {ι : Type uι} (e d : Equiv.Perm ι) : + lpPermute (e * d) = lpPermute e * lpPermute d := by + ext f i + rfl + +def lpPermuteHom {ι : Type uι} : Equiv.Perm ι →* (lp (fun _ : ι => ℂ) 2 ≃ₗᵢ[ℂ] + lp (fun _ : ι => ℂ) 2) where + toFun := lpPermute + map_one' := lpPermute_one + map_mul' := lpPermute_mul + +def lpPhase {ι : Type uι} (u : ι → unitary ℂ) : + lp (fun _ : ι => ℂ) 2 ≃ₗᵢ[ℂ] lp (fun _ : ι => ℂ) 2 where + toFun f := ⟨fun i => (u i : ℂ) * f i, by + apply memℓp_gen + simpa only [norm_mul, CStarRing.norm_coe_unitary, one_mul] using + (lp.memℓp f).summable (by norm_num)⟩ + invFun f := ⟨fun i => (↑(u i)⁻¹ : ℂ) * f i, by + apply memℓp_gen + simpa only [norm_mul, CStarRing.norm_coe_unitary, one_mul] using + (lp.memℓp f).summable (by norm_num)⟩ + left_inv f := by ext i; simp [← mul_assoc, ← Submonoid.coe_mul] + right_inv f := by ext i; simp [← mul_assoc, ← Submonoid.coe_mul] + map_add' f g := by ext i; exact mul_add _ _ _ + map_smul' c f := by ext i; exact mul_left_comm _ _ _ + norm_map' f := by + rw [lp.norm_eq_tsum_rpow (by norm_num), lp.norm_eq_tsum_rpow (by norm_num)] + congr 1 + change (∑' i, ‖(u i : ℂ) * f i‖ ^ _) = _ + simp only [norm_mul, CStarRing.norm_coe_unitary, one_mul] + +@[simp] theorem lpPhase_apply {ι : Type uι} (u : ι → unitary ℂ) + (f : lp (fun _ : ι => ℂ) 2) (i : ι) : lpPhase u f i = (u i : ℂ) * f i := rfl + +def rotationScalar (θ : ℝ) : unitary ℂ := + ⟨Complex.exp (2 * Real.pi * θ * Complex.I), by + have hn : ‖Complex.exp (2 * Real.pi * θ * Complex.I)‖ = 1 := by + simpa only [Complex.ofReal_mul, Complex.ofReal_ofNat] using + Complex.norm_exp_ofReal_mul_I (2 * Real.pi * θ) + have hs := Complex.sq_norm (Complex.exp (2 * Real.pi * θ * Complex.I)) + rw [hn, one_pow] at hs + rw [Unitary.mem_iff] + constructor + · rw [mul_comm] + simp only [RCLike.star_def, Complex.mul_conj, ← hs, Complex.ofReal_one] + · simp only [RCLike.star_def, Complex.mul_conj, ← hs, Complex.ofReal_one]⟩ + +abbrev RegularHilbert := lp (fun _ : ℤ × ℤ => ℂ) 2 +abbrev RegularOperator := RegularHilbert →L[ℂ] RegularHilbert + +def regularShift (m : ℤ) : RegularHilbert ≃ₗᵢ[ℂ] RegularHilbert := + lpPermute (Equiv.addLeft (m, 0)) + +@[simp] theorem regularShift_apply (m : ℤ) (f : RegularHilbert) (a b : ℤ) : + regularShift m f (a,b) = f (a - m,b) := by + change f (-m + a, 0 + b) = _ + apply congrArg f + ext <;> dsimp <;> omega + +def regularMagnetic (u : unitary ℂ) (n : ℤ) : RegularHilbert ≃ₗᵢ[ℂ] RegularHilbert := + lpPhase (fun i : ℤ × ℤ => u ^ (n * i.1)) * lpPermute (Equiv.addLeft (0,n)) + +@[simp] theorem regularMagnetic_apply (u : unitary ℂ) (n : ℤ) + (f : RegularHilbert) (a b : ℤ) : + regularMagnetic u n f (a,b) = (↑(u ^ (n * a)) : ℂ) * f (a,b-n) := by + change _ * f (0 + a, -n + b) = _ + rw [zero_add, show -n + b = b - n by omega] + +@[simp] theorem regularShift_zero : regularShift 0 = 1 := by + ext f ⟨a,b⟩ + simp + +@[simp] theorem regularShift_add (m n : ℤ) : + regularShift (m+n) = regularShift m * regularShift n := by + ext f ⟨a,b⟩ + change regularShift (m+n) f (a,b) = regularShift m (regularShift n f) (a,b) + simp only [regularShift_apply] + apply congrArg f + ext <;> dsimp; omega + +@[simp] theorem regularMagnetic_zero (u : unitary ℂ) : regularMagnetic u 0 = 1 := by + ext f ⟨a,b⟩ + simp + +@[simp] theorem regularMagnetic_add (u : unitary ℂ) (m n : ℤ) : + regularMagnetic u (m+n) = regularMagnetic u m * regularMagnetic u n := by + ext f ⟨a,b⟩ + change regularMagnetic u (m+n) f (a,b) = regularMagnetic u m (regularMagnetic u n f) (a,b) + simp only [regularMagnetic_apply, add_mul, zpow_add, Submonoid.coe_mul, mul_assoc] + rw [show b - (m+n) = b-m-n by omega] + +def regularShiftHom : Multiplicative ℤ →* (RegularHilbert ≃ₗᵢ[ℂ] RegularHilbert) where + toFun m := regularShift m.toAdd + map_one' := regularShift_zero + map_mul' m n := regularShift_add m.toAdd n.toAdd + +def regularMagneticHom (u : unitary ℂ) : + Multiplicative ℤ →* (RegularHilbert ≃ₗᵢ[ℂ] RegularHilbert) where + toFun n := regularMagnetic u n.toAdd + map_one' := regularMagnetic_zero u + map_mul' m n := regularMagnetic_add u m.toAdd n.toAdd + +@[simp] theorem regularShift_zpow (m : ℤ) : regularShift 1 ^ m = regularShift m := by + symm + simpa only [regularShiftHom, MonoidHom.coe_mk, OneHom.coe_mk, toAdd_zpow, + toAdd_ofAdd, zsmul_eq_mul, Int.cast_id, mul_one] using + map_zpow regularShiftHom (Multiplicative.ofAdd 1) m + +@[simp] theorem regularMagnetic_zpow (u : unitary ℂ) (n : ℤ) : + regularMagnetic u 1 ^ n = regularMagnetic u n := by + symm + simpa only [regularMagneticHom, MonoidHom.coe_mk, OneHom.coe_mk, toAdd_zpow, + toAdd_ofAdd, zsmul_eq_mul, Int.cast_id, mul_one] using + map_zpow (regularMagneticHom u) (Multiplicative.ofAdd 1) n + +def regularU : unitary RegularOperator := + Unitary.linearIsometryEquiv.symm (regularShift 1) + +def regularV (u : unitary ℂ) : unitary RegularOperator := + Unitary.linearIsometryEquiv.symm (regularMagnetic u 1) + +@[simp] theorem regularU_zpow_apply (m : ℤ) (f : RegularHilbert) (a b : ℤ) : + ((regularU ^ m : unitary RegularOperator) : RegularOperator) f (a,b) = f (a-m,b) := by + rw [regularU, ← map_zpow, regularShift_zpow] + exact regularShift_apply m f a b + +@[simp] theorem regularV_zpow_apply (u : unitary ℂ) (n : ℤ) + (f : RegularHilbert) (a b : ℤ) : + ((regularV u ^ n : unitary RegularOperator) : RegularOperator) f (a,b) = + (↑(u ^ (n*a)) : ℂ) * f (a,b-n) := by + rw [regularV, ← map_zpow, regularMagnetic_zpow] + exact regularMagnetic_apply u n f a b + +@[simp] theorem regularU_apply (f : RegularHilbert) (a b : ℤ) : + (regularU : RegularOperator) f (a,b) = f (a-1,b) := by + exact regularShift_apply 1 f a b + +@[simp] theorem regularV_apply (u : unitary ℂ) (f : RegularHilbert) (a b : ℤ) : + (regularV u : RegularOperator) f (a,b) = (↑(u ^ a) : ℂ) * f (a,b-1) := by + change regularMagnetic u 1 f (a,b) = _ + simpa only [one_mul] using regularMagnetic_apply u 1 f a b + +theorem regular_relation (u : unitary ℂ) : + (regularV u : RegularOperator) * (regularU : RegularOperator) = + (u : ℂ) • ((regularU : RegularOperator) * (regularV u : RegularOperator)) := by + ext f ⟨a,b⟩ + change (regularV u : RegularOperator) ((regularU : RegularOperator) f) (a,b) = + (u : ℂ) * ((regularU : RegularOperator) ((regularV u : RegularOperator) f) (a,b)) + simp only [regularV_apply, regularU_apply, ← mul_assoc] + congr 1 + change (↑(u ^ a) : ℂ) = ↑(u * u ^ (a-1)) + congr 1 + calc u ^ a = u ^ (1 + (a-1)) := by congr 1; omega + _ = u * u ^ (a-1) := by rw [zpow_add, zpow_one] + +def regularVacuum : RegularHilbert := lp.single 2 (0,0) 1 + +theorem regular_monomial (u : unitary ℂ) (m n : ℤ) : + ((regularU ^ m * regularV u ^ n : unitary RegularOperator) : RegularOperator) regularVacuum = + lp.single 2 (m,n) 1 := by + ext ⟨a,b⟩ + change ((regularU ^ m : unitary RegularOperator) : RegularOperator) + (((regularV u ^ n : unitary RegularOperator) : RegularOperator) regularVacuum) (a,b) = _ + simp only [regularU_zpow_apply, regularV_zpow_apply, regularVacuum, lp.single_apply] + by_cases ha : a=m + · subst a + by_cases hb : b=n + · subst b; simp + · simp [hb, sub_eq_zero, Prod.mk.injEq] + · have ham : a-m ≠ 0 := sub_ne_zero.mpr ha + simp [ham, Prod.mk.injEq, Ne.symm ha] + +theorem regular_moments (u : unitary ℂ) (m n : ℤ) : + inner ℂ regularVacuum + (((regularU ^ m * regularV u ^ n : unitary RegularOperator) : RegularOperator) regularVacuum) = + if m=0 ∧ n=0 then 1 else 0 := by + rw [regular_monomial, regularVacuum, lp.inner_single_left] + simp [lp.single_apply, Pi.single_apply, Prod.mk.injEq, eq_comm] + +theorem regular_cyclic (u : unitary ℂ) : + (Submodule.span ℂ (Set.range (fun mn : ℤ × ℤ => + ((regularU ^ mn.1 * regularV u ^ mn.2 : unitary RegularOperator) : RegularOperator) + regularVacuum))).topologicalClosure = ⊤ := by + simp_rw [regular_monomial] + have heq : (fun mn : ℤ × ℤ => lp.single 2 (mn.1,mn.2) (1 : ℂ)) = + (HilbertBasis.ofRepr (LinearIsometryEquiv.refl ℂ RegularHilbert) : ℤ × ℤ → RegularHilbert) := by + funext mn + rw [← (HilbertBasis.ofRepr (LinearIsometryEquiv.refl ℂ RegularHilbert)).repr_symm_single mn] + ext i + simp [LinearIsometryEquiv.symm, LinearIsometryEquiv.refl, lp.single_apply] + rw [heq] + exact (HilbertBasis.ofRepr (LinearIsometryEquiv.refl ℂ RegularHilbert)).dense_span + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/ReturnSamples.lean b/lean/OAI/Analysis/RotationWeights/ReturnSamples.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ed7feb92ddd139730e5e729fbd370dfae3e3923 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/ReturnSamples.lean @@ -0,0 +1,442 @@ +import OAI.Analysis.RotationWeights.FiniteSampling + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uV + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology + +section +open scoped Topology +lemma phase_success_eventually {m : ℕ} (γ : PhaseCube m) {k : ℤ} {i : Fin m} {b : ℝ} + (hne : ((k*(γ i:ℝ):ℝ):CircleX) ≠ 0) (hgood : (γ i:ℝ) ∉ phaseFailure b k) : + ∀ᶠ β : PhaseCube m in 𝓝 γ, (β i:ℝ) ∉ phaseFailure b k := by + have heval : ContinuousAt (fun β : PhaseCube m => (β i:ℝ)) γ := + continuous_subtype_val.continuousAt.comp (continuous_apply i).continuousAt + have hc : ContinuousAt (fun β : PhaseCube m => repr ((k*(β i:ℝ):ℝ):CircleX)) γ := + (continuousAt_repr hne).comp (f:=fun β : PhaseCube m => ((k*(β i:ℝ):ℝ):CircleX)) + ((AddCircle.continuous_mk' 1).continuousAt.comp (continuousAt_const.mul heval)) + have hh : b < 1-repr ((k*(γ i:ℝ):ℝ):CircleX) ∧ 1-repr ((k*(γ i:ℝ):ℝ):CircleX) < 1-b := + by simpa [phaseFailure] using hgood + have hc' : ContinuousAt (fun β : PhaseCube m => 1-repr ((k*(β i:ℝ):ℝ):CircleX)) γ := continuousAt_const.sub hc + filter_upwards [hc'.eventually (Ioo_mem_nhds hh.1 hh.2)] with β hβ + simpa [phaseFailure] using hβ + +lemma phase_cover_eventually {m : ℕ} (γ : PhaseCube m) (S : Finset ℤ) (b : ℝ) + (hphase : ∀ k∈S, ∀ i, ((k*(γ i:ℝ):ℝ):CircleX) ≠ 0) : + ∀ᶠ β : PhaseCube m in 𝓝 γ, ∀ k∈S, + (Finset.univ.filter fun i => (γ i:ℝ) ∉ phaseFailure b k).card ≤ + (Finset.univ.filter fun i => (β i:ℝ) ∉ phaseFailure b k).card := by + classical + have hs : ∀ k∈S, ∀ᶠ β : PhaseCube m in 𝓝 γ, + ∀ i, (γ i:ℝ) ∉ phaseFailure b k → (β i:ℝ) ∉ phaseFailure b k := by + intro k hk + apply Filter.eventually_all.mpr + intro i + by_cases hi : (γ i:ℝ) ∉ phaseFailure b k + · exact (phase_success_eventually γ (hphase k hk i) hi).mono (fun β hb _ => hb) + · exact Filter.Eventually.of_forall (fun _ hi' => (hi hi').elim) + filter_upwards [(Filter.eventually_all_finite S.finite_toSet).mpr hs] with β hβ k hk + apply Finset.card_le_card + intro i hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hβ k hk i (Finset.mem_filter.mp hi).2⟩ + +lemma cube_interval_eventually {m : ℕ} (γ : PhaseCube m) {a b : ℝ} + (hγ : ∀ i, (γ i:ℝ)∈Set.Ioo a b) : + ∀ᶠ β : PhaseCube m in 𝓝 γ, ∀ i, (β i:ℝ)∈Set.Ioo a b := by + apply Filter.eventually_all.mpr + intro i + exact (continuous_subtype_val.continuousAt.comp (continuous_apply i).continuousAt : ContinuousAt (fun β : PhaseCube m => (β i:ℝ)) γ).eventually + (Ioo_mem_nhds (hγ i).1 (hγ i).2) +end + +section +open scoped BigOperators + +def phaseRange (N R : ℝ) : Finset ℤ := + (Finset.Icc (-⌊R⌋) ⌊R⌋).filter (fun k => N/4 ≤ |(k:ℝ)|) +lemma mem_phaseRange {N R : ℝ} {k : ℤ} (hk : N/4 ≤ |(k:ℝ)|) (hkR : |(k:ℝ)| ≤ R) : + k∈phaseRange N R := by + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_Icc.mpr ⟨?_,?_⟩,hk⟩ + · have h : (-k:ℝ) ≤ R := by linarith [(abs_le.mp hkR).1] + have hh : -k ≤ ⌊R⌋ := Int.le_floor.mpr (by simpa using h) + omega + · exact Int.le_floor.mpr (abs_le.mp hkR).2 +lemma phaseRange_bound {N R : ℝ} (hR : 1 ≤ R) : (phaseRange N R).card ≤ 3*R := by + have hR0 : 0 ≤ ⌊R⌋ := Int.floor_nonneg.mpr (by linarith) + calc + ((phaseRange N R).card:ℝ) ≤ ((Finset.Icc (-⌊R⌋) ⌊R⌋).card:ℝ) := + Nat.cast_le.mpr (Finset.card_filter_le _ _) + _ = 2*(⌊R⌋:ℝ)+1 := by + rw [Int.card_Icc] + have hh : 0 ≤ ⌊R⌋+1-(-⌊R⌋) := by omega + rw [← Int.cast_natCast,Int.toNat_of_nonneg hh] + push_cast + ring + _ ≤ 3*R := by have := Int.floor_le R; linarith +lemma phaseRange_lower {N R : ℝ} {k : ℤ} (hk : k∈phaseRange N R) : N/4 ≤ |(k:ℝ)| := + (Finset.mem_filter.mp hk).2 +end + +open Set Topology +section + +lemma rotation_syndetic {θ : ℝ} (hθ : Irrational θ) {O : Set CircleX} + (hO : IsOpen O) (hne : O.Nonempty) : + ∃ L : ℕ, 0 < L ∧ ∀ a : ℤ, ∃ n : ℤ, + a ≤ n ∧ n < a+L ∧ n • (θ:CircleX) ∈ O := by + classical + have hd : DenseRange (fun n : ℤ => n • (θ:CircleX)) := + AddCircle.denseRange_zsmul_coe_iff.mpr (by simpa using hθ) + let U : ℤ → Set CircleX := fun n => (fun x => x+n•(θ:CircleX)) ⁻¹' O + have hU : ∀ n, IsOpen (U n) := fun n => hO.preimage (by fun_prop) + have hc : (univ : Set CircleX) ⊆ ⋃ n, U n := by + intro x _ + obtain ⟨y,hy⟩ := hne + have ho : IsOpen ((fun z : CircleX => x+z) ⁻¹' O) := hO.preimage (by fun_prop) + obtain ⟨n,hn⟩ := hd.exists_mem_open ho ⟨y-x,by simpa using hy⟩ + exact mem_iUnion.mpr ⟨n,hn⟩ + obtain ⟨S,hS⟩ := isCompact_univ.elim_finite_subcover U hU hc + let B : ℕ := S.sup Int.natAbs + refine ⟨2*B+1,by omega,?_⟩ + intro a + obtain ⟨k,hk,hx⟩ := mem_iUnion₂.mp (hS (mem_univ ((a+B)•(θ:CircleX)))) + have hb : k.natAbs ≤ B := Finset.le_sup (f := Int.natAbs) hk + have hkle : k ≤ (B:ℤ) := (Int.le_natAbs (a:=k)).trans (by exact_mod_cast hb) + have hkge : -(B:ℤ) ≤ k := by + have hab : |k| ≤ (B:ℤ) := by + simpa only [Int.natCast_natAbs] using (show (k.natAbs:ℤ) ≤ B by exact_mod_cast hb) + exact (abs_le.mp hab).1 + refine ⟨a+B+k,by omega,by push_cast; omega,?_⟩ + simpa only [U,mem_preimage,add_zsmul] using hx + +lemma return_samples {θ : ℝ} (hθ : Irrational θ) {O : Set CircleX} + (hO : IsOpen O) (hne : O.Nonempty) : + ∃ L : ℕ, 0 < L ∧ ∀ (a : ℤ) (P : ℕ), ∃ S : Finset ℤ, + S.card=P ∧ ∀ n ∈ S, a ≤ n ∧ n < a+P*L ∧ n•(θ:CircleX) ∈ O := by + classical + obtain ⟨L,hL,hret⟩ := rotation_syndetic hθ hO hne + refine ⟨L,hL,?_⟩ + intro a P + choose n hn using (fun j : Fin P => hret (a+(j:ℤ)*L)) + have hinj : Function.Injective n := by + intro j k he + apply Fin.ext + by_contra hne + rcases lt_or_gt_of_ne hne with hjk | hkj + · have hcast : (j:ℤ)+1 ≤ (k:ℤ) := by exact_mod_cast hjk + have hmul := mul_le_mul_of_nonneg_right hcast (show (0:ℤ) ≤ L by positivity) + have hj := (hn j).2.1 + have hk := (hn k).1 + rw [he] at hj + nlinarith + · have hcast : (k:ℤ)+1 ≤ (j:ℤ) := by exact_mod_cast hkj + have hmul := mul_le_mul_of_nonneg_right hcast (show (0:ℤ) ≤ L by positivity) + have hj := (hn j).1 + have hk := (hn k).2.1 + rw [he] at hj + nlinarith + refine ⟨Finset.univ.image n,by simp [Finset.card_image_of_injective _ hinj],?_⟩ + intro k hk + obtain ⟨j,_,rfl⟩ := Finset.mem_image.mp hk + refine ⟨?_,?_,(hn j).2.2⟩ + · have hz : (0:ℤ) ≤ (j:ℤ)*L := by positivity + exact le_trans (by omega) (hn j).1 + · have hcast : (j:ℤ)+1 ≤ (P:ℤ) := by exact_mod_cast j.isLt + have hmul := mul_le_mul_of_nonneg_right hcast (show (0:ℤ) ≤ L by positivity) + have hj := (hn j).2.1 + nlinarith +end + +open scoped BigOperators +section + +lemma finite_separated_subset {V : Type uV} [DecidableEq V] (C : Finset V) (R : V → V → Prop) [DecidableRel R] + (hsym : ∀ ⦃a b⦄, R a b → R b a) (hrefl : ∀ a, R a a) (D : ℕ) + (hdeg : ∀ a∈C, (C.filter (R a)).card ≤ D) : + ∃ S : Finset V, S⊆C ∧ (∀ a∈S, ∀ b∈S, a≠b → ¬R a b) ∧ C.card ≤ S.card*D := by + classical + let A := C.powerset.filter (fun S ↦ ∀ a∈S, ∀ b∈S, a≠b → ¬R a b) + have hA : A.Nonempty := ⟨∅,by simp [A]⟩ + obtain ⟨S,hS,hmax⟩ := Finset.exists_max_image A Finset.card hA + simp only [A, Finset.mem_filter, Finset.mem_powerset] at hS + obtain ⟨hSC, hsep⟩ := hS + have hcover : C⊆S.biUnion (fun a ↦ C.filter (R a)) := by + intro b hb + by_contra hnot + have hno : ∀ a∈S, ¬R a b := by + intro a ha hab + exact hnot (Finset.mem_biUnion.mpr ⟨a,ha,Finset.mem_filter.mpr ⟨hb,hab⟩⟩) + have hbS : b∉S := fun h ↦ hno b h (hrefl b) + have hins : insert b S∈A := by + simp only [A, Finset.mem_filter, Finset.mem_powerset] + refine ⟨Finset.insert_subset hb hSC,?_⟩ + intro a ha c hc hac + by_cases hab : a=b + · subst a + have hcS : c∈S := Finset.mem_of_mem_insert_of_ne hc (Ne.symm hac) + exact fun h ↦ hno c hcS (hsym h) + · have haS : a∈S := Finset.mem_of_mem_insert_of_ne ha hab + by_cases hcb : c=b + · subst c + exact hno a haS + · have hcS : c∈S := Finset.mem_of_mem_insert_of_ne hc hcb + exact hsep a haS c hcS hac + have hle := hmax (insert b S) hins + rw [Finset.card_insert_of_notMem hbS] at hle + omega + refine ⟨S,hSC,hsep,?_⟩ + calc + C.card ≤ (S.biUnion (fun a ↦ C.filter (R a))).card := Finset.card_le_card hcover + _ ≤ ∑ a∈S, (C.filter (R a)).card := Finset.card_biUnion_le + _ ≤ ∑ _a∈S, D := Finset.sum_le_sum fun a ha ↦ hdeg a (hSC ha) + _ = S.card*D := by simp + + +open Finset +lemma linear_filter_card (C : Finset ℤ) (a b : ℤ) (hb : b ≠ 0) (R : ℕ) : + (C.filter (fun n => |a+b*n| ≤ (R:ℤ))).card ≤ 2*R+1 := by + classical + let S := C.filter (fun n => |a+b*n| ≤ (R:ℤ)) + have hinj : Function.Injective (fun n : ℤ => a+b*n) := by + intro m n h + exact mul_left_cancel₀ hb (add_left_cancel h) + calc + S.card = (S.image (fun n => a+b*n)).card := (Finset.card_image_of_injective S hinj).symm + _ ≤ (Finset.Icc (-(R:ℤ)) R).card := by + apply Finset.card_le_card + intro k hk + obtain ⟨n,hn,rfl⟩ := Finset.mem_image.mp hk + exact Finset.mem_Icc.mpr (abs_le.mp (Finset.mem_filter.mp hn).2) + _ = 2*R+1 := by simp; omega + +lemma separated_integer_samples (C : Finset ℤ) (H R : ℕ) + (hC : ∀ n ∈ C, (R:ℤ) < |n|) : + ∃ S : Finset ℤ, S ⊆ C ∧ + (∀ n ∈ S, ∀ n' ∈ S, n ≠ n' → ∀ v v' : ℤ, + |v| ≤ H → |v'| ≤ H → (v ≠ 0 ∨ v' ≠ 0) → (R:ℤ) < |v*n+v'*n'|) ∧ + C.card ≤ S.card*(1+(2*H+1)^2*(2*R+1)) := by + classical + let V : Finset ℤ := (Finset.Icc (-(H:ℤ)) H).erase 0 + let E : ℤ → ℤ → Prop := fun n n' => n=n' ∨ ∃ v ∈ V, ∃ v' ∈ V, |v*n+v'*n'| ≤ (R:ℤ) + have hsym : ∀ ⦃n n'⦄, E n n' → E n' n := by + intro n n' h + rcases h with h | ⟨v,hv,v',hv',hh⟩ + · exact Or.inl h.symm + · exact Or.inr ⟨v',hv',v,hv,by simpa [add_comm] using hh⟩ + have hcardV : V.card ≤ 2*H+1 := by + exact (card_erase_le).trans (by simp; omega) + have hdeg : ∀ n ∈ C, (C.filter (E n)).card ≤ 1+(2*H+1)^2*(2*R+1) := by + intro n _ + have hsub : C.filter (E n) ⊆ {n} ∪ V.biUnion (fun v => V.biUnion (fun v' => + C.filter (fun n' => |v*n+v'*n'| ≤ (R:ℤ)))) := by + intro n' hn' + obtain ⟨hh,h⟩ := Finset.mem_filter.mp hn' + rcases h with he | ⟨v,hv,v',hv',hne⟩ + · exact mem_union_left _ (mem_singleton.mpr he.symm) + · exact mem_union_right _ (mem_biUnion.mpr ⟨v,hv,mem_biUnion.mpr ⟨v',hv',Finset.mem_filter.mpr ⟨hh,hne⟩⟩⟩) + calc + _ ≤ ({n} ∪ V.biUnion (fun v => V.biUnion (fun v' => C.filter (fun n' => |v*n+v'*n'| ≤ (R:ℤ))))).card := Finset.card_le_card hsub + _ ≤ 1+V.card*(V.card*(2*R+1)) := by + apply (Finset.card_union_le _ _).trans + simp only [Finset.card_singleton] + apply Nat.add_le_add_left + apply card_biUnion_le.trans + calc + _ ≤ ∑ v ∈ V, (V.card*(2*R+1)) := by + apply sum_le_sum + intro v _ + apply card_biUnion_le.trans + calc + _ ≤ ∑ _ ∈ V, (2*R+1) := sum_le_sum (fun v' hv' => + linear_filter_card C (v*n) v' (ne_of_mem_erase hv') R) + _ = _ := by simp + _ = _ := by simp + _ ≤ _ := by nlinarith [Nat.mul_self_le_mul_self hcardV] + obtain ⟨S,hSC,hs,hcard⟩ := finite_separated_subset C E hsym (fun _ => Or.inl rfl) _ hdeg + refine ⟨S,hSC,?_,hcard⟩ + intro n hn n' hn' hne v v' hv hv' hnonzero + by_cases hz : v=0 + · subst v + have hv'0 : v' ≠ 0 := hnonzero.resolve_left (not_ne_iff.mpr rfl) + have hge : (1:ℤ) ≤ |v'| := by exact Int.one_le_abs hv'0 + have hh := hC n' (hSC hn') + simpa only [zero_mul,zero_add,abs_mul] using hh.trans_le (by nlinarith [abs_nonneg n']) + by_cases hz' : v'=0 + · subst v' + have hge : (1:ℤ) ≤ |v| := Int.one_le_abs hz + have hh := hC n (hSC hn) + simpa only [zero_mul,add_zero,abs_mul] using hh.trans_le (by nlinarith [abs_nonneg n]) + by_contra hh + apply hs n hn n' hn' hne + exact Or.inr ⟨v,Finset.mem_erase.mpr ⟨hz,Finset.mem_Icc.mpr (abs_le.mp hv)⟩, + v',Finset.mem_erase.mpr ⟨hz',Finset.mem_Icc.mpr (abs_le.mp hv')⟩,le_of_not_gt hh⟩ +end + +section +open Set Filter +open scoped Topology + +lemma separated_return_samples {θ : ℝ} (hθ : Irrational θ) {O : Set CircleX} + (hO : IsOpen O) (hne : O.Nonempty) : + ∃ L : ℕ, 0 < L ∧ ∀ (H R : ℕ) (Q T : ℝ), + (R:ℝ) < Q/2 → + (⌈Q/2⌉:ℝ) + (⌈T*(1+(2*H+1)^2*(2*R+1))⌉₊:ℝ)*L ≤ Q → + ∃ S : Finset ℤ, T ≤ (S.card:ℝ) ∧ + (∀ n ∈ S, Q/2 ≤ (n:ℝ) ∧ (n:ℝ) ≤ Q ∧ n•(θ:CircleX) ∈ O) ∧ + (∀ n ∈ S, ∀ n' ∈ S, n ≠ n' → ∀ v v' : ℤ, + |v| ≤ H → |v'| ≤ H → (v ≠ 0 ∨ v' ≠ 0) → (R:ℤ) < |v*n+v'*n'|) := by + classical + obtain ⟨L,hL,hret⟩ := return_samples hθ hO hne + refine ⟨L,hL,?_⟩ + intro H R Q T hQR hlen + let D := 1+(2*H+1)^2*(2*R+1) + let P := ⌈T*(D:ℝ)⌉₊ + obtain ⟨C,hC,hmem⟩ := hret ⌈Q/2⌉ P + have ha : Q/2 ≤ (⌈Q/2⌉:ℝ) := Int.le_ceil _ + have hn (n : ℤ) (hn : n∈C) : Q/2 ≤ (n:ℝ) ∧ (n:ℝ) ≤ Q ∧ n•(θ:CircleX)∈O := by + obtain ⟨hlo,hhi,ho⟩ := hmem n hn + refine ⟨ha.trans (by exact_mod_cast hlo),?_,ho⟩ + apply le_trans _ hlen + exact_mod_cast hhi.le + have hcR : ∀ n∈C, (R:ℤ) < |n| := by + intro n hn' + have hh : (R:ℝ)<(n:ℝ) := hQR.trans_le (hn n hn').1 + exact lt_of_lt_of_le (by exact_mod_cast hh) (le_abs_self n) + obtain ⟨S,hSC,hsep,hcard⟩ := separated_integer_samples C H R hcR + refine ⟨S,?_,fun n hn' => hn n (hSC hn'),hsep⟩ + have hp : T*(D:ℝ) ≤ (P:ℝ) := Nat.le_ceil _ + have hcount : (P:ℝ) ≤ (S.card:ℝ)*D := by exact_mod_cast (hC ▸ hcard) + have hD : (0:ℝ) omega + _ = 1+27*m^1602 := by ring + _ ≤ 28*m^1602 := by omega + +lemma eventually_sampling_length (L K : ℕ) (hL : 0 < L) : + ∀ᶠ m : ℕ in atTop, + (m*K*m^1000:ℝ) < (m:ℝ)^((7:ℝ)/10*m)/2 ∧ + (⌈(m:ℝ)^((7:ℝ)/10*m)/2⌉:ℝ) + + (⌈(m:ℝ)^((69:ℝ)/100*m)*(1+(2*m^300+1)^2*(2*(m*K*m^1000)+1))⌉₊:ℝ)*L ≤ + (m:ℝ)^((7:ℝ)/10*m) := by + have hg := eventually_rpow_linear_gap (7/10) (69/100) (168*L) 1602 (by norm_num) + filter_upwards [hg,eventually_ge_atTop (max 1 K)] with m hg hmK + have hm : 1 ≤ m := (le_max_left _ _).trans hmK + have hK : K ≤ m := (le_max_right _ _).trans hmK + have hx : (1:ℝ) ≤ m := by exact_mod_cast hm + have hx0 : (0:ℝ) < m := lt_of_lt_of_le zero_lt_one hx + let T : ℝ := (m:ℝ)^((69:ℝ)/100*m) + let Q : ℝ := (m:ℝ)^((7:ℝ)/10*m) + let D : ℝ := 1+(2*(m:ℝ)^300+1)^2*(2*((m:ℝ)*K*(m:ℝ)^1000)+1) + have hT : 1 ≤ T := Real.one_le_rpow hx (by positivity) + have hD : 1 ≤ D := by dsimp [D]; exact le_add_of_nonneg_right (by positivity) + have hL' : (1:ℝ) ≤ L := by exact_mod_cast hL + have hdegree : D ≤ 28*(m:ℝ)^1602 := by + have hh : ((1+(2*m^300+1)^2*(2*(m*K*m^1000)+1):ℕ):ℝ) ≤ ((28*m^1602:ℕ):ℝ) := Nat.cast_le.mpr (greedy_degree_bound hm hK) + simpa only [D, Nat.cast_add, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat, Nat.cast_one] using hh + have hg' : 168*(L:ℝ)*(m:ℝ)^1602*T ≤ Q := by + simpa only [Real.rpow_ofNat] using hg + have hTDL : 6*(T*D*L) ≤ Q := by + calc + 6*(T*D*L) ≤ 6*(T*(28*(m:ℝ)^1602)*L) := by gcongr + _ = 168*(L:ℝ)*(m:ℝ)^1602*T := by ring + _ ≤ Q := hg' + have hR : (m:ℝ)*K*(m:ℝ)^1000 ≤ (m:ℝ)^1602 := by + have hK' : (K:ℝ) ≤ m := Nat.cast_le.mpr hK + calc + (m:ℝ)*K*(m:ℝ)^1000 ≤ (m:ℝ)*(m:ℝ)*(m:ℝ)^1000 := by gcongr + _ = (m:ℝ)^1002 := by ring + _ ≤ (m:ℝ)^1602 := pow_le_pow_right₀ hx (by omega) + have hp : (0:ℝ) < (m:ℝ)^1602 := by positivity + have hQ : 6*(m:ℝ)^1602 ≤ Q := by + calc + 6*(m:ℝ)^1602 ≤ 168*(L:ℝ)*(m:ℝ)^1602*1 := by nlinarith + _ ≤ 168*(L:ℝ)*(m:ℝ)^1602*T := by gcongr + _ ≤ Q := hg' + refine ⟨by dsimp [Q] at hQ; nlinarith,?_⟩ + change (⌈Q/2⌉:ℝ)+(⌈T*D⌉₊:ℝ)*L ≤ Q + have hceilQ : (⌈Q/2⌉:ℝ) ≤ Q/2+1 := (Int.ceil_lt_add_one _).le + have hceilT : (⌈T*D⌉₊:ℝ) ≤ T*D+1 := (Nat.ceil_lt_add_one (show 0 ≤ T*D by positivity)).le + have hTD : 1 ≤ T*D := one_le_mul_of_one_le_of_one_le hT hD + have hTDL1 : (L:ℝ) ≤ T*D*L := by nlinarith + have hbound := mul_le_mul_of_nonneg_right hceilT (show (0:ℝ) ≤ L by positivity) + nlinarith + +lemma eventually_separated_returns {θ : ℝ} (hθ : Irrational θ) {O : Set CircleX} + (hO : IsOpen O) (hne : O.Nonempty) (K : ℕ) : + ∀ᶠ m : ℕ in atTop, ∃ S : Finset ℤ, + (m:ℝ)^((69:ℝ)/100*m) ≤ (S.card:ℝ) ∧ + (∀ n ∈ S, (m:ℝ)^((7:ℝ)/10*m)/2 ≤ (n:ℝ) ∧ + (n:ℝ) ≤ (m:ℝ)^((7:ℝ)/10*m) ∧ n•(θ:CircleX)∈O) ∧ + (∀ n ∈ S, ∀ n' ∈ S, n ≠ n' → ∀ v v' : ℤ, + |v| ≤ m^300 → |v'| ≤ m^300 → (v ≠ 0 ∨ v' ≠ 0) → + (m*K*m^1000:ℤ) < |v*n+v'*n'|) := by + obtain ⟨L,hL,hs⟩ := separated_return_samples hθ hO hne + filter_upwards [eventually_sampling_length L K hL] with m hm + have hh := hs (m^300) (m*K*m^1000) ((m:ℝ)^((7:ℝ)/10*m)) ((m:ℝ)^((69:ℝ)/100*m)) + (by simpa only [Nat.cast_mul, Nat.cast_pow] using hm.1) + (by simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_pow, Nat.cast_ofNat] using hm.2) + simpa only [Nat.cast_mul, Nat.cast_pow] using hh + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Rounding.lean b/lean/OAI/Analysis/RotationWeights/Rounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac936fc3843eba0189c91f32002700755751b022 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Rounding.lean @@ -0,0 +1,271 @@ +import OAI.Analysis.RotationWeights.Convolution + +namespace OAI + +noncomputable section + +namespace CircleRounding + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal BigOperators + +section +open Set MeasureTheory +open scoped ENNReal +abbrev X := AddCircle (1:ℝ) +def repr (x : X) : ℝ := (AddCircle.measurableEquivIco 1 0 x).val +lemma repr_mem (x : X) : repr x∈Ico 0 1 := by + simpa [repr] using (AddCircle.measurableEquivIco 1 0 x).property +lemma coe_repr (x : X) : (repr x:X)=x := by + exact (AddCircle.measurableEquivIco 1 0).symm_apply_apply x +lemma repr_measurable : Measurable repr := measurable_subtype_coe.comp (AddCircle.measurableEquivIco 1 0).measurable +lemma repr_mk (t : ℝ) : repr (t:X)=Int.fract t := by + change (AddCircle.equivIco 1 0 (t:X)).val=_ + simpa only [div_one,mul_one] using AddCircle.coe_equivIco_mk_apply (p:=(1:ℝ)) t +lemma repr_zero : repr 0=0 := by simpa using repr_mk 0 + +def intervalRamp (δ s : ℝ) : ℝ := min 0 ((s-δ)/(2*δ))+max 0 ((s-(1-δ))/(2*δ)) +lemma intervalRamp_continuous (δ : ℝ) : Continuous (intervalRamp δ) := by + unfold intervalRamp + fun_prop +lemma intervalRamp_monotone {δ : ℝ} (hδ : 0<δ) : Monotone (intervalRamp δ) := by + intro s t hst + apply add_le_add + · exact min_le_min le_rfl (div_le_div_of_nonneg_right (sub_le_sub_right hst δ) (by positivity)) + · exact max_le_max le_rfl (div_le_div_of_nonneg_right (sub_le_sub_right hst (1-δ)) (by positivity)) +lemma intervalRamp_zero {δ : ℝ} (hδ : 0<δ) (hδ1 : δ<1) : intervalRamp δ 0=-(1/2:ℝ) := by + unfold intervalRamp + rw [min_eq_right (by apply div_nonpos_of_nonpos_of_nonneg <;> linarith),max_eq_left (by apply div_nonpos_of_nonpos_of_nonneg <;> linarith)] + field_simp + ring +lemma intervalRamp_one {δ : ℝ} (hδ : 0<δ) (hδ1 : δ<1) : intervalRamp δ 1=(1/2:ℝ) := by + unfold intervalRamp + rw [min_eq_left (by apply div_nonneg <;> linarith),max_eq_right (by apply div_nonneg <;> linarith)] + field_simp + ring +lemma intervalRamp_bounds {δ s : ℝ} (hδ : 0<δ) (hδ1 : δ<1) (hs : s∈Icc 0 1) : + -(1/2:ℝ) ≤ intervalRamp δ s ∧ intervalRamp δ s ≤ 1/2 := by + rw [←intervalRamp_zero hδ hδ1,←intervalRamp_one hδ hδ1] + exact ⟨intervalRamp_monotone hδ hs.1,intervalRamp_monotone hδ hs.2⟩ +lemma intervalRamp_middle {δ s : ℝ} (hδ : 0<δ) (hs : δ ≤ s ∧ s ≤ 1-δ) : intervalRamp δ s=0 := by + unfold intervalRamp + rw [min_eq_left (div_nonneg (sub_nonneg.mpr hs.1) (by positivity)),max_eq_left (div_nonpos_of_nonpos_of_nonneg (sub_nonpos.mpr hs.2) (by positivity))] + ring + +def periodicCorrector (δ : ℝ) : X → ℝ := AddCircle.liftIco 1 0 (fun s => intervalRamp δ s-s) +lemma periodicCorrector_continuous {δ : ℝ} (hδ : 0<δ) (hδ1 : δ<1) : Continuous (periodicCorrector δ) := by + apply AddCircle.liftIco_zero_continuous + · simp only [intervalRamp_zero hδ hδ1,intervalRamp_one hδ hδ1]; ring + · exact ((intervalRamp_continuous δ).sub continuous_id).continuousOn +lemma periodicCorrector_repr (δ : ℝ) (x : X) : periodicCorrector δ x=intervalRamp δ (repr x)-repr x := by + conv_lhs => rw [←coe_repr x] + exact AddCircle.liftIco_zero_coe_apply (repr_mem x) + +def roundedFloor (δ t : ℝ) : ℝ := t+periodicCorrector δ (t:X) +lemma roundedFloor_continuous {δ : ℝ} (hδ : 0<δ) (hδ1 : δ<1) : Continuous (roundedFloor δ) := + continuous_id.add ((periodicCorrector_continuous hδ hδ1).comp (AddCircle.continuous_mk' 1)) +lemma roundedFloor_add_one (δ t : ℝ) : roundedFloor δ (t+1)=roundedFloor δ t+1 := by + simp only [roundedFloor,AddCircle.coe_add,AddCircle.coe_period,add_zero] + ring + +def roundedDrop (δ β c : ℝ) (x : X) : ℝ := c*(β+periodicCorrector δ (x+(β:X))-periodicCorrector δ x) +def correction (δ c : ℝ) (x : X) : ℝ := c*intervalRamp δ (repr x) +lemma roundedDrop_continuous {δ : ℝ} (hδ : 0<δ) (hδ1 : δ<1) (β c : ℝ) : Continuous (roundedDrop δ β c) := by + unfold roundedDrop + exact continuous_const.mul ((continuous_const.add ((periodicCorrector_continuous hδ hδ1).comp (continuous_id.add continuous_const))).sub (periodicCorrector_continuous hδ hδ1)) +lemma correction_measurable (δ c : ℝ) : Measurable (correction δ c) := + measurable_const.mul ((intervalRamp_continuous δ).measurable.comp repr_measurable) +lemma repr_add (x : X) (β : ℝ) : repr (x+(β:X))=Int.fract (repr x+β) := by + calc + _ = repr ((repr x+β:ℝ):X) := by rw [AddCircle.coe_add,coe_repr] + _ = _ := repr_mk _ + +lemma roundedDrop_formula (δ β c : ℝ) (x : X) : + roundedDrop δ β c x=c*((Int.floor (repr x+β):ℤ)+intervalRamp δ (repr (x+(β:X)))-intervalRamp δ (repr x)) := by + rw [roundedDrop,periodicCorrector_repr,periodicCorrector_repr] + have hh := repr_add x β + rw [Int.fract] at hh + congr 1 + linarith +lemma roundedDrop_coboundary (δ β c : ℝ) (x : X) : + roundedDrop δ β c x-c*(Int.floor (repr x+β):ℤ)=correction δ c (x+(β:X))-correction δ c x := by + rw [roundedDrop_formula,correction,correction] + ring +lemma roundedDrop_nonneg {δ β c : ℝ} (hδ : 0<δ) (hδ1 : δ<1) (hβ : 0 ≤ β) (hβ1 : β<1) (hc : 0 ≤ c) (x : X) : + 0 ≤ roundedDrop δ β c x := by + rw [roundedDrop_formula] + apply mul_nonneg hc + have hx := repr_mem x + have hy := repr_mem (x+(β:X)) + have hf0 : 0 ≤ Int.floor (repr x+β) := Int.floor_nonneg.mpr (by linarith [hx.1]) + have hf1 : Int.floor (repr x+β) ≤ 1 := by + rw [Int.floor_le_iff]; norm_num; linarith [hx.2] + have hb := intervalRamp_bounds hδ hδ1 ⟨hx.1,hx.2.le⟩ + have hb' := intervalRamp_bounds hδ hδ1 ⟨hy.1,hy.2.le⟩ + rcases (show Int.floor (repr x+β)=0 ∨ Int.floor (repr x+β)=1 by omega) with he | he + · have hxy : repr x ≤ repr (x+(β:X)) := by rw [repr_add,Int.fract,he]; norm_num; linarith + have hh := intervalRamp_monotone hδ hxy + rw [he]; norm_num; linarith + · rw [he]; norm_num; linarith +end + +open Set MeasureTheory +open scoped ENNReal +lemma roundedDrop_zero {δ β : ℝ} (hδ : 0<δ) (hδ1 : δ<1) (hβ : δ ≤ β) (hβ1 : β ≤ 1-δ) (c : ℝ) : + roundedDrop δ β c 0=c/2 := by + have hb0 : 0 ≤ β := hδ.le.trans hβ + have hb1 : β<1 := by linarith + rw [roundedDrop_formula,repr_zero,zero_add,Int.floor_eq_zero_iff.mpr ⟨hb0,hb1⟩] + simp only [Int.cast_zero,zero_add] + rw [repr_mk,Int.fract_eq_self.mpr ⟨hb0,hb1⟩,intervalRamp_middle hδ ⟨hβ,hβ1⟩,intervalRamp_zero hδ hδ1] + ring +lemma correction_support {δ c : ℝ} (hδ : 0<δ) : + {x : X | correction δ c x≠0} ⊆ {x | repr x<δ} ∪ {x | 1-δ ≤ repr x} := by + intro x hx + by_contra! hh + have hh' : δ ≤ repr x ∧ repr x<1-δ := by simpa only [Set.mem_union,Set.mem_ofPred_eq,not_or,not_lt,not_le] using hh + apply hx + rw [correction,intervalRamp_middle hδ ⟨hh'.1,hh'.2.le⟩,mul_zero] +lemma roundedDrop_support {δ β c : ℝ} (hδ : 0<δ) (hβ : 0 ≤ β) : + {x : X | roundedDrop δ β c x≠0} ⊆ {x | repr x<δ} ∪ {x | 1-(β+δ) ≤ repr x} := by + intro x hx + by_contra! hh + have hh' : δ ≤ repr x ∧ repr x<1-(β+δ) := by simpa only [Set.mem_union,Set.mem_ofPred_eq,not_or,not_lt,not_le] using hh + have ht : repr x+β∈Ico 0 1 := ⟨by linarith [hh'.1],by linarith [hh'.2]⟩ + apply hx + rw [roundedDrop_formula,Int.floor_eq_zero_iff.mpr ht,repr_add,Int.fract_eq_self.mpr ht, + intervalRamp_middle hδ ⟨by linarith [hh'.1],by linarith [hh'.2]⟩, + intervalRamp_middle hδ ⟨hh'.1,by linarith [hh'.2]⟩] + simp +lemma measure_repr_lower {r : ℝ} : volume {x : X | repr x < r} ≤ ENNReal.ofReal r := by + change volume (repr ⁻¹' Iio r) ≤ _ + rw [AddCircle.add_projection_respects_measure 1 0 (repr_measurable measurableSet_Iio)] + have hs : ((↑) : ℝ → X) ⁻¹' {x | repr x < r} ∩ Ioc 0 (0+1) ⊆ Ioo 0 r ∪ {1} := by + rintro s ⟨hs,hsI⟩ + by_cases he : s=1 + · exact Or.inr (by simpa using he) + · left + refine ⟨hsI.1,?_⟩ + change repr (s : X) x+(β:X)) volume volume := measurePreserving_add_right volume _ + have hq' : Integrable (fun x : X => periodicCorrector δ (x+(β:X))) volume := hσ.integrable_comp_of_integrable hq + have hi : (∫ x : X,periodicCorrector δ (x+(β:X)))=∫ x : X,periodicCorrector δ x := hσ.integral_comp (Homeomorph.addRight (β:X)).isClosedEmbedding.measurableEmbedding _ + simp only [roundedDrop,integral_const_mul] + have hs : Integrable (fun x : X => β+periodicCorrector δ (x+(β:X))) volume := (integrable_const β).add hq' + rw [integral_sub hs hq,integral_add (integrable_const β) hq',hi] + simp [AddCircle.volume_eq_smul_haarAddCircle] + + +end CircleRounding + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/SamplingBounds.lean b/lean/OAI/Analysis/RotationWeights/SamplingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8cc899becbcd5df94846e070f95cb8ed7874fd0 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/SamplingBounds.lean @@ -0,0 +1,529 @@ +import OAI.Analysis.RotationWeights.ProductSampling + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uκ uι + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +section + +def scaleEll (m : ℕ) : ℝ := (m:ℝ)^(-(3:ℝ)/5) +def scaleAlpha (m : ℕ) : ℝ := (m:ℝ)^(-(2:ℝ)) +def scaleDiscrepancy (m : ℕ) : ℝ := 18*(m:ℝ)^(-(70:ℝ)) +def offError (m : ℕ) : ℝ := (2*scaleEll m/(1-scaleEll m))^2 + + 2*(1+scaleEll m)*scaleAlpha m + 4*(1/(scaleEll m*scaleAlpha m))^2*scaleDiscrepancy m + +def samplingError (m : ℕ) : ℝ := (1+offError m)^m+(1/2:ℝ)^m - + 2*(1-3*scaleAlpha m)^m+1 + +lemma rpow_scale_mul (x : ℝ) (hx : 0 < x) (a b : ℝ) : x^a*x^b=x^(a+b) := + (Real.rpow_add hx _ _).symm +lemma rpow_scale_sq (x : ℝ) (hx : 0≤x) (a : ℝ) : (x^a)^2=x^(a*2) := by + rw [← Real.rpow_natCast,← Real.rpow_mul hx]; norm_num +lemma scale_product {m : ℕ} (hm : 0 < m) : scaleEll m*scaleAlpha m=(m:ℝ)^(-(13:ℝ)/5) := by + have hx : (0:ℝ) < m := by exact_mod_cast hm + rw [scaleEll,scaleAlpha,rpow_scale_mul _ hx]; norm_num +lemma mass_offError {m : ℕ} (hm : 0 < m) : + (m:ℝ)*offError m = + 4*(m:ℝ)^(-(1:ℝ)/5)/(1-scaleEll m)^2 + + 2*(1+scaleEll m)*(m:ℝ)^(-(1:ℝ)) + 72*(m:ℝ)^(-(319:ℝ)/5) := by + have hx : (0:ℝ) < m := by exact_mod_cast hm + have h₁ : (m:ℝ)*(scaleEll m)^2=(m:ℝ)^(-(1:ℝ)/5) := by + rw [scaleEll,rpow_scale_sq _ hx.le] + conv_lhs => arg 1; rw [← Real.rpow_one (m:ℝ)] + rw [rpow_scale_mul _ hx]; norm_num + have h₂ : (m:ℝ)*scaleAlpha m=(m:ℝ)^(-(1:ℝ)) := by + rw [scaleAlpha] + conv_lhs => arg 1; rw [← Real.rpow_one (m:ℝ)] + rw [rpow_scale_mul _ hx]; norm_num + have h₃ : (m:ℝ)*(1/(scaleEll m*scaleAlpha m))^2*(m:ℝ)^(-(70:ℝ)) = + (m:ℝ)^(-(319:ℝ)/5) := by + rw [scale_product hm,one_div,← Real.rpow_neg hx.le,rpow_scale_sq _ hx.le] + conv_lhs => arg 1; arg 1; rw [← Real.rpow_one (m:ℝ)] + rw [rpow_scale_mul _ hx,rpow_scale_mul _ hx]; norm_num + calc + (m:ℝ)*offError m = 4*((m:ℝ)*(scaleEll m)^2)/(1-scaleEll m)^2 + + 2*(1+scaleEll m)*((m:ℝ)*scaleAlpha m) + + 72*((m:ℝ)*(1/(scaleEll m*scaleAlpha m))^2*(m:ℝ)^(-(70:ℝ))) := by + unfold offError scaleDiscrepancy + simp only [div_pow] + ring + _ = _ := by rw [h₁,h₂,h₃] + +lemma tendsto_nat_rpow_neg {a : ℝ} (ha : 0 < a) : + Tendsto (fun m : ℕ => (m:ℝ)^(-a)) atTop (𝓝 0) := + (tendsto_rpow_neg_atTop ha).comp tendsto_natCast_atTop_atTop +lemma tendsto_scaleEll : Tendsto scaleEll atTop (𝓝 0) := by + change Tendsto (fun m : ℕ => (m:ℝ)^(-(3:ℝ)/5)) atTop (𝓝 0) + simpa only [neg_div] using tendsto_nat_rpow_neg (a:=3/5) (by norm_num) +lemma tendsto_scaleAlpha : Tendsto scaleAlpha atTop (𝓝 0) := + tendsto_nat_rpow_neg (by norm_num : (0:ℝ)<2) +lemma tendsto_mass_offError : Tendsto (fun m : ℕ => (m:ℝ)*offError m) atTop (𝓝 0) := by + have ha := tendsto_nat_rpow_neg (by norm_num : (0:ℝ)<1/5) + have hb := tendsto_nat_rpow_neg (by norm_num : (0:ℝ)<1) + have hc := tendsto_nat_rpow_neg (by norm_num : (0:ℝ)<319/5) + have h₁ : Tendsto (fun m : ℕ => 4*(m:ℝ)^(-(1:ℝ)/5)/(1-scaleEll m)^2) atTop (𝓝 0) := by + convert (ha.const_mul (4:ℝ)).div ((tendsto_const_nhds.sub tendsto_scaleEll).pow 2) + (by norm_num : (1-(0:ℝ))^2 ≠ 0) using 1 + · ext m; simp only [Pi.div_apply, neg_div] + · norm_num + have h₂ : Tendsto (fun m : ℕ => 2*(1+scaleEll m)*(m:ℝ)^(-(1:ℝ))) atTop (𝓝 0) := by + simpa only [mul_zero] using ((tendsto_const_nhds.add tendsto_scaleEll).const_mul 2).mul hb + have h₃ : Tendsto (fun m : ℕ => 72*(m:ℝ)^(-(319:ℝ)/5)) atTop (𝓝 0) := by + simpa only [neg_div,mul_zero] using hc.const_mul 72 + have h := (h₁.add h₂).add h₃ + simp only [zero_add] at h + apply h.congr' + filter_upwards [eventually_gt_atTop (0:ℕ)] with m hm + simpa only [neg_div] using (mass_offError hm).symm +lemma tendsto_mass_alpha : Tendsto (fun m : ℕ => (m:ℝ)*scaleAlpha m) atTop (𝓝 0) := by + apply (tendsto_nat_rpow_neg (by norm_num : (0:ℝ)<1)).congr' + filter_upwards [eventually_gt_atTop (0:ℕ)] with m hm + have hx : (0:ℝ) < m := by exact_mod_cast hm + rw [scaleAlpha] + conv_rhs => arg 1; rw [← Real.rpow_one (m:ℝ)] + rw [rpow_scale_mul _ hx]; norm_num +lemma tendsto_samplingError : Tendsto samplingError atTop (𝓝 0) := by + have ho := Real.tendsto_one_add_pow_exp_of_tendsto tendsto_mass_offError + have ha : Tendsto (fun m : ℕ => (m:ℝ)*(-3*scaleAlpha m)) atTop (𝓝 0) := by + simpa only [mul_assoc,mul_comm,mul_left_comm,mul_zero,zero_mul] using tendsto_mass_alpha.const_mul (-3) + have hl := Real.tendsto_one_add_pow_exp_of_tendsto ha + have hd := tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0:ℝ)≤1/2) + (by norm_num : (1/2:ℝ)<1) + have hh := ((ho.add hd).sub (hl.const_mul 2)).add_const 1 + change Tendsto (fun m => (1+offError m)^m+(1/2:ℝ)^m - 2*(1-3*scaleAlpha m)^m+1) atTop (𝓝 0) + convert hh using 1 + · ext m; congr 3; ring + · norm_num +end +open Filter Set +open scoped Topology +section +lemma eventually_rpow_linear_gap (a b C d : ℝ) (hab : b (m:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have he : Tendsto (fun m : ℕ => (a-b)*(m:ℝ)) atTop atTop := + hm.const_mul_atTop (sub_pos.mpr hab) + filter_upwards [hm.eventually_ge_atTop (max 1 C),he.eventually_ge_atTop (d+1)] with m hmin hd + have hm1 : 1 ≤ (m:ℝ) := (le_max_left _ _).trans hmin + have hm0 : 0 < (m:ℝ) := lt_of_lt_of_le zero_lt_one hm1 + have hc : C ≤ (m:ℝ) := (le_max_right _ _).trans hmin + have hpos : 0 ≤ (m:ℝ)^d*(m:ℝ)^(b*(m:ℝ)) := by positivity + calc + C*(m:ℝ)^d*(m:ℝ)^(b*(m:ℝ)) ≤ (m:ℝ)*(m:ℝ)^d*(m:ℝ)^(b*(m:ℝ)) := by + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hc (by positivity)) (by positivity) + _ = (m:ℝ)^(1+d+b*(m:ℝ)) := by rw [Real.rpow_add hm0,Real.rpow_add hm0,Real.rpow_one] + _ ≤ (m:ℝ)^(a*(m:ℝ)) := Real.rpow_le_rpow_of_exponent_le hm1 (by nlinarith) +open Filter Set +open scoped Topology +lemma inv_scaleEll {m : ℕ} (hm : 0 < m) : (scaleEll m)⁻¹ = (m:ℝ)^((3:ℝ)/5) := by + have hx : (0:ℝ) < m := by exact_mod_cast hm + rw [scaleEll, ← Real.rpow_neg hx.le] + congr 1 + ring +lemma inv_scaleAlpha {m : ℕ} (hm : 0 < m) : (scaleAlpha m)⁻¹ = (m:ℝ)^2 := by + have hx : (0:ℝ) < m := by exact_mod_cast hm + rw [scaleAlpha, ← Real.rpow_neg hx.le, neg_neg, Real.rpow_ofNat] +lemma scaleAlpha_pos {m : ℕ} (hm : 0 < m) : 0 < scaleAlpha m := by + unfold scaleAlpha + positivity +lemma diagonal_estimate {m : ℕ} (hm : 2 ≤ m) : + 2*((2/scaleEll m)*Real.log (1/(2*scaleAlpha m))) ≤ + 8*(m:ℝ)^((3:ℝ)/5)*Real.log m := by + have hm0 : 0 < m := by omega + have hx : (0:ℝ) < m := by exact_mod_cast hm0 + have ha := scaleAlpha_pos hm0 + have ht : 0 < 1/(2*scaleAlpha m) := by positivity + have harg : 1/(2*scaleAlpha m) ≤ (m:ℝ)^2 := by + rw [one_div,mul_inv_rev, inv_scaleAlpha hm0] + nlinarith [sq_nonneg (m:ℝ)] + have hl := Real.log_le_log ht harg + rw [Real.log_pow] at hl + norm_num only [Nat.cast_ofNat] at hl + rw [div_eq_mul_inv,inv_scaleEll hm0] + calc + 2*(2*(m:ℝ)^((3:ℝ)/5)*Real.log (1/(2*scaleAlpha m))) ≤ + 2*(2*(m:ℝ)^((3:ℝ)/5)*(2*Real.log m)) := by gcongr + _ = _ := by ring +lemma eventually_diagonal_small : ∀ᶠ m : ℕ in atTop, + 2*((2/scaleEll m)*Real.log (1/(2*scaleAlpha m))) ≤ + (1/2)*(m:ℝ)^((69:ℝ)/100) := by + have hlim : Tendsto (fun m : ℕ => Real.log (m:ℝ)/(m:ℝ)^((9:ℝ)/100)) atTop (𝓝 0) := + (isLittleO_log_rpow_atTop (by norm_num : (0:ℝ) < 9/100)).tendsto_div_nhds_zero.comp + tendsto_natCast_atTop_atTop + filter_upwards [hlim.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1/16)), + eventually_ge_atTop (2:ℕ)] with m hratio hm + have hm0 : 0 < m := by omega + have hx : (0:ℝ) < m := by exact_mod_cast hm0 + have hp : 0 < (m:ℝ)^((9:ℝ)/100) := Real.rpow_pos_of_pos hx _ + have hlog := (div_lt_iff₀ hp).mp hratio + apply (diagonal_estimate hm).trans + calc + 8*(m:ℝ)^((3:ℝ)/5)*Real.log m ≤ + 8*(m:ℝ)^((3:ℝ)/5)*((1/16)*(m:ℝ)^((9:ℝ)/100)) := by gcongr + _ = (1/2)*((m:ℝ)^((3:ℝ)/5)*(m:ℝ)^((9:ℝ)/100)) := by ring + _ = _ := by rw [rpow_scale_mul _ hx]; norm_num +end +section +open ContinuousCircleWeight.Sampling +open Filter Set MeasureTheory +open scoped Topology +lemma sampling_discrepancy_numeric {m : ℕ} (hm : 1 ≤ m) {N : ℝ} (hN : 0 < N) : + 8*2*scaleDiscrepancy m/18 + 2/(4*((m^300:ℕ):ℝ)*((m:ℝ)^(-(70:ℝ)))^2) + + ((m^300:ℕ):ℝ)^2/(Real.pi*(N*(m:ℝ)^1000)*(2/N-1/N)) ≤ scaleDiscrepancy m := by + have hx1 : (1:ℝ) ≤ m := by exact_mod_cast hm + have hx : (0:ℝ) < m := zero_lt_one.trans_le hx1 + have he2 : 2/(4*((m^300:ℕ):ℝ)*((m:ℝ)^(-(70:ℝ)))^2) = + (1/2)*(m:ℝ)^(-(160:ℝ)) := by + rw [Nat.cast_pow, ← Real.rpow_natCast (m:ℝ) 300, rpow_scale_sq _ hx.le] + norm_num only [Nat.cast_ofNat] + have hprod : (m:ℝ)^(300:ℝ)*(m:ℝ)^(-(70:ℝ)*2)=(m:ℝ)^(160:ℝ) := by + rw [rpow_scale_mul _ hx]; norm_num + have hexp : -(70:ℝ)*2 = -(140:ℝ) := by norm_num + rw [hexp] at hprod + rw [mul_assoc, hprod, div_mul_eq_div_div, div_eq_mul_inv, ← Real.rpow_neg hx.le] + ring + have he3 : ((m^300:ℕ):ℝ)^2/(Real.pi*(N*(m:ℝ)^1000)*(2/N-1/N)) = + (1/Real.pi)*(m:ℝ)^(-(400:ℝ)) := by + have hden : Real.pi*(N*(m:ℝ)^1000)*(2/N-1/N) = Real.pi*(m:ℝ)^1000 := by + field_simp + ring + rw [hden,Nat.cast_pow,← Real.rpow_natCast (m:ℝ) 300, rpow_scale_sq _ hx.le] + rw [← Real.rpow_natCast (m:ℝ) 1000] + norm_num only [Nat.cast_ofNat] + calc + (m:ℝ)^(600:ℝ)/(Real.pi*(m:ℝ)^(1000:ℝ)) = + (1/Real.pi)*((m:ℝ)^(600:ℝ)/(m:ℝ)^(1000:ℝ)) := by ring + _ = _ := by rw [← Real.rpow_sub hx]; norm_num + have hle2 : (m:ℝ)^(-(160:ℝ)) ≤ (m:ℝ)^(-(70:ℝ)) := + Real.rpow_le_rpow_of_exponent_le hx1 (by norm_num) + have hle3 : (m:ℝ)^(-(400:ℝ)) ≤ (m:ℝ)^(-(70:ℝ)) := + Real.rpow_le_rpow_of_exponent_le hx1 (by norm_num) + have hpi : 1/Real.pi ≤ 1 := (div_le_one Real.pi_pos).mpr (by linarith [Real.pi_gt_three] : (1:ℝ) ≤ Real.pi) + rw [he2,he3] + have hp : 0 ≤ (m:ℝ)^(-(400:ℝ)) := Real.rpow_nonneg hx.le _ + have hmul := mul_le_mul_of_nonneg_right hpi hp + unfold scaleDiscrepancy + nlinarith [Real.rpow_nonneg hx.le (-(70:ℝ))] + +lemma sampling_phase_discrepancy {m : ℕ} (hm : 1 ≤ m) {N c d : ℝ} + (hN : 0 < N) (hc : 0 < c) (hd : 0 < d) + (hmc : 1+1/(c*(2/N-1/N)) ≤ 2) (hmd : 1+1/(d*(2/N-1/N)) ≤ 2) + (hsep : ∀ v w : ℤ, |v| ≤ (m^300:ℕ) → |w| ≤ (m^300:ℕ) → + (v ≠ 0 ∨ w ≠ 0) → N*(m:ℝ)^1000 ≤ |(v:ℝ)*c+(w:ℝ)*d|) + (x y : CircleX) (r s : ℝ) : + |(phasePairLaw (1/N) (2/N) c d).real (Metric.ball x r ×ˢ Metric.ball y s) - + volume.real (Metric.ball x r)*volume.real (Metric.ball y s)| ≤ scaleDiscrepancy m := by + have hx : (0:ℝ) < m := Nat.cast_pos.mpr (by omega) + have hab : 1/N < 2/N := (div_lt_div_iff_of_pos_right hN).mpr (by norm_num) + have hh := separated_phase_rectangle_bound hab hc hd (by positivity : 0 < N*(m:ℝ)^1000) + (by norm_num : (0:ℝ) ≤ 2) hmc hmd (H:=m^300) (by positivity) + (fun v w hv hw hne => hsep v w hv.le hw.le (not_and_or.mp hne)) + (δ:=(m:ℝ)^(-(70:ℝ))) (by positivity) x y r s + apply hh.trans + have hn := sampling_discrepancy_numeric hm hN + unfold scaleDiscrepancy at hn ⊢ + linarith only [hn] +end +section +open Filter Set +open scoped Topology +lemma eventually_sampling_marginal (K : ℕ) : ∀ᶠ m : ℕ in atTop, + ∀ c : ℝ, (m:ℝ)^((7:ℝ)/10*m)/2 ≤ c → + 0 < c ∧ 1/(c*(2/((m:ℝ)*K)-1/((m:ℝ)*K))) ≤ scaleAlpha m := by + by_cases hK : K = 0 + · subst K + filter_upwards [eventually_ge_atTop (1:ℕ)] with m hm c hc + have hx : (0:ℝ) < m := Nat.cast_pos.mpr (by omega) + refine ⟨(by positivity : 0 < (m:ℝ)^((7:ℝ)/10*m)/2).trans_le hc,?_⟩ + simpa using (scaleAlpha_pos (by omega : 0 < m)).le + have hKpos : (0:ℝ) < K := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hK) + have hg := eventually_rpow_linear_gap (7/10) 0 (2*K) 3 (by norm_num) + filter_upwards [hg,eventually_ge_atTop (1:ℕ)] with m hg hm c hc + have hm0 : 0 < m := by omega + have hx : (0:ℝ) < m := Nat.cast_pos.mpr hm0 + have ha := scaleAlpha_pos hm0 + have hQ : 0 < (m:ℝ)^((7:ℝ)/10*m)/2 := by positivity + have hcpos := hQ.trans_le hc + refine ⟨hcpos,?_⟩ + have hg' : 2*(K:ℝ)*(m:ℝ)^3 ≤ (m:ℝ)^((7:ℝ)/10*m) := by + simpa only [zero_mul,Real.rpow_zero,mul_one,Real.rpow_ofNat] using hg + have hwidth : 2/((m:ℝ)*K)-1/((m:ℝ)*K) = 1/((m:ℝ)*K) := by ring + rw [hwidth] + apply (div_le_iff₀ (by positivity : 0 < c*(1/((m:ℝ)*K)))).mpr + have hinv := inv_scaleAlpha hm0 + have hmul : scaleAlpha m*(m:ℝ)^2 = 1 := by rw [← hinv]; exact mul_inv_cancel₀ ha.ne' + have hlarge : (m:ℝ)*K ≤ scaleAlpha m*c := by + have hh := mul_le_mul_of_nonneg_left hg' ha.le + have hhh := mul_le_mul_of_nonneg_left hc ha.le + have hid : scaleAlpha m*(2*(K:ℝ)*(m:ℝ)^3) = 2*((m:ℝ)*K) := by + calc + _ = 2*((m:ℝ)*K)*(scaleAlpha m*(m:ℝ)^2) := by ring + _ = _ := by rw [hmul,mul_one] + rw [hid] at hh + nlinarith + have hh : (1:ℝ) ≤ (scaleAlpha m*c)/((m:ℝ)*K) := (le_div_iff₀ (mul_pos hx hKpos)).mpr (by simpa only [one_mul] using hlarge) + simpa only [div_eq_mul_inv, mul_assoc, one_mul] using hh +end +section +open ContinuousCircleWeight.Sampling +open Filter Set MeasureTheory +open scoped Topology + +def IdealNumerics (K m : ℕ) : Prop := + 2 ≤ m ∧ scaleEll m < 1 ∧ scaleAlpha m ≤ 1/3 ∧ + 2*((2/scaleEll m)*Real.log (1/(2*scaleAlpha m))) ≤ (1/2)*(m:ℝ)^((69:ℝ)/100) ∧ + ∀ c : ℝ, (m:ℝ)^((7:ℝ)/10*m)/2 ≤ c → + 0 < c ∧ 1/(c*(2/((m:ℝ)*K)-1/((m:ℝ)*K))) ≤ scaleAlpha m + +lemma eventually_IdealNumerics (K : ℕ) : ∀ᶠ m : ℕ in atTop, IdealNumerics K m := by + filter_upwards [eventually_ge_atTop (2:ℕ), + tendsto_scaleEll.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1)), + tendsto_scaleAlpha.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1/3)), + eventually_diagonal_small,eventually_sampling_marginal K] with m hm hℓ hα hd hmean + exact ⟨hm,hℓ,hα.le,hd,hmean⟩ + +lemma ideal_stage_error {m K : ℕ} (hK : 0 < K) (hn : IdealNumerics K m) + {κ : Type uκ} [Fintype κ] [Nonempty κ] (positive : Bool) (c : κ → ℝ) + (hcard : (m:ℝ)^((69:ℝ)/100*m) ≤ (Fintype.card κ:ℝ)) + (hc : ∀ n, (m:ℝ)^((7:ℝ)/10*m)/2 ≤ c n) + (hsep : ∀ n k, n ≠ k → ∀ v w : ℤ, + |v| ≤ (m^300:ℕ) → |w| ≤ (m^300:ℕ) → (v ≠ 0 ∨ w ≠ 0) → + ((m:ℝ)*K)*(m:ℝ)^1000 ≤ |(v:ℝ)*c n+(w:ℝ)*c k|) : + (∫ γ : Fin m → ℝ, ∫ s : Fin m → CircleX, + (idealAverage positive (scaleEll m) (scaleAlpha m) c s γ-1)^2 + ∂Measure.pi (fun _ ↦ volume) + ∂Measure.pi (fun _ ↦ intervalLaw (1/((m:ℝ)*K)) (2/((m:ℝ)*K)))) ≤ samplingError m := by + obtain ⟨hm,hℓ1,hα3,hd,hmean⟩ := hn + have hm0 : 0 < m := by omega + have hx : (0:ℝ) < m := Nat.cast_pos.mpr hm0 + have hN : 0 < (m:ℝ)*K := mul_pos hx (Nat.cast_pos.mpr hK) + have hℓ : 0 < scaleEll m := Real.rpow_pos_of_pos hx _ + have hα := scaleAlpha_pos hm0 + have hα2 : scaleAlpha m ≤ 1/2 := by linarith + have hab : 1/((m:ℝ)*K) < 2/((m:ℝ)*K) := (div_lt_div_iff_of_pos_right hN).mpr (by norm_num) + have hcm (n : κ) := hmean (c n) (hc n) + have hD (n : κ) : 1+1/(c n*(2/((m:ℝ)*K)-1/((m:ℝ)*K))) ≤ 2 := by + linarith [(hcm n).2] + have hdisc (n k : κ) (hnk : n ≠ k) (x y : CircleX) (r s : ℝ) := + sampling_phase_discrepancy (by omega : 1 ≤ m) hN (hcm n).1 (hcm k).1 + (hD n) (hD k) (hsep n k hnk) x y r s + have he := ideal_error_bound (ι:=Fin m) hab hℓ hℓ1 hα hα2 + (by linarith : 0 ≤ 1-scaleAlpha m) (by norm_num : (0:ℝ) ≤ 2) + (by unfold scaleDiscrepancy; positivity) positive c (fun n => (hcm n).1) + (fun n => by linarith [(hcm n).2]) hD hdisc + simp only [Fintype.card_fin] at he + have hdiag0 : 0 ≤ 2*((2/scaleEll m)*Real.log (1/(2*scaleAlpha m))) := by + apply mul_nonneg (by norm_num) + apply mul_nonneg (by positivity) + exact Real.log_nonneg ((le_div_iff₀ (by positivity)).mpr (by linarith)) + have hdiag : (Fintype.card κ:ℝ)⁻¹ * (2*((2/scaleEll m)*Real.log (1/(2*scaleAlpha m))))^m ≤ (1/2:ℝ)^m := by + have hpow : ((m:ℝ)^((69:ℝ)/100))^m = (m:ℝ)^((69:ℝ)/100*m) := by + rw [← Real.rpow_natCast,← Real.rpow_mul hx.le] + have hcpos : (0:ℝ) < Fintype.card κ := Nat.cast_pos.mpr Fintype.card_pos + rw [mul_comm ((Fintype.card κ:ℝ)⁻¹), ← div_eq_mul_inv] + apply (div_le_iff₀ hcpos).mpr + calc + (2*((2/scaleEll m)*Real.log (1/(2*scaleAlpha m))))^m ≤ + ((1/2)*(m:ℝ)^((69:ℝ)/100))^m := pow_le_pow_left₀ hdiag0 hd m + _ = (1/2:ℝ)^m*(m:ℝ)^((69:ℝ)/100*m) := by rw [mul_pow,hpow] + _ ≤ (1/2:ℝ)^m*(Fintype.card κ:ℝ) := by gcongr + have hbase : 0 ≤ 1-3*scaleAlpha m := by linarith + have hmeanpow : (1-3*scaleAlpha m)^m ≤ ((1-scaleAlpha m)*(1-2*scaleAlpha m))^m := by + apply pow_le_pow_left₀ hbase _ m + nlinarith [sq_nonneg (scaleAlpha m)] + unfold samplingError + have hoff : 1+(2*scaleEll m/(1-scaleEll m))^2+2*(1+scaleEll m)*scaleAlpha m+ + 4*(1/(scaleEll m*scaleAlpha m))^2*scaleDiscrepancy m = 1+offError m := by + unfold offError + ring + rw [hoff] at he + linarith +end +section +open ContinuousCircleWeight.Sampling +variable {ι : Type uι} {κ : Type uκ} [Fintype ι] [Fintype κ] [Nonempty κ] +omit [Nonempty κ] in +lemma measurable_idealAverage (positive : Bool) (ℓ α : ℝ) (c : κ → ℝ) : + Measurable (fun z : (ι → CircleX) × (ι → ℝ) => idealAverage positive ℓ α c z.1 z.2) := by + unfold idealAverage + apply Measurable.const_mul + apply Finset.measurable_sum + intro n _ + apply Finset.measurable_prod + intro i _ + have hm : Measurable (fun z : (ι → CircleX) × (ι → ℝ) => + (z.1 i, ((c n*z.2 i:ℝ):CircleX))) := by fun_prop + exact (measurable_orientedWeight positive ℓ α).comp hm + +lemma idealAverage_bounds (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (s : ι → CircleX) (γ : ι → ℝ) : + 0 ≤ idealAverage positive ℓ α c s γ ∧ + idealAverage positive ℓ α c s γ ≤ (1/(ℓ*α))^(Fintype.card ι) := by + have hw i n := orientedWeight_bounds positive hℓ hα (s i) ((c n*γ i:ℝ):CircleX) + have hcp : (0:ℝ) < Fintype.card κ := Nat.cast_pos.mpr Fintype.card_pos + unfold idealAverage + constructor + · exact mul_nonneg (inv_nonneg.mpr hcp.le) (Finset.sum_nonneg fun n _ => Finset.prod_nonneg fun i _ => (hw i n).1) + · calc + _ ≤ (Fintype.card κ:ℝ)⁻¹ * ∑ _n : κ, (1/(ℓ*α))^(Fintype.card ι) := by + gcongr + calc + _ ≤ ∏ _i : ι, (1/(ℓ*α)) := Finset.prod_le_prod₀ (fun i _ => (hw i _).1) (fun i _ => (hw i _).2) + _ = _ := by simp + _ = _ := by simp [nsmul_eq_mul,hcp.ne'] + +def idealEnergy (positive : Bool) (ℓ α : ℝ) (c : κ → ℝ) (γ : ι → ℝ) : ℝ := + ∫ s : ι → CircleX, (idealAverage positive ℓ α c s γ-1)^2 ∂Measure.pi (fun _ => volume) + +omit [Nonempty κ] in +lemma idealEnergy_nonneg (positive : Bool) (ℓ α : ℝ) (c : κ → ℝ) (γ : ι → ℝ) : + 0 ≤ idealEnergy positive ℓ α c γ := integral_nonneg fun _ => sq_nonneg _ + +omit [Nonempty κ] in +lemma measurable_idealEnergy (positive : Bool) (ℓ α : ℝ) (c : κ → ℝ) : + Measurable (idealEnergy (ι:=ι) positive ℓ α c) := by + unfold idealEnergy + exact ((((measurable_idealAverage positive ℓ α c).comp measurable_swap).sub measurable_const).pow_const 2).stronglyMeasurable.integral_prod_right.measurable + +lemma idealEnergy_le (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (γ : ι → ℝ) : + idealEnergy (ι:=ι) positive ℓ α c γ ≤ ((1/(ℓ*α))^(Fintype.card ι)+1)^2 := by + have hb (s : ι → CircleX) : (idealAverage positive ℓ α c s γ-1)^2 ≤ + ((1/(ℓ*α))^(Fintype.card ι)+1)^2 := by + have h := idealAverage_bounds positive hℓ hα c s γ + rw [← sq_abs (idealAverage positive ℓ α c s γ-1)] + apply (sq_le_sq₀ (abs_nonneg _) (by positivity)).mpr + rw [abs_le] + constructor <;> linarith [pow_nonneg (by positivity : 0 ≤ 1/(ℓ*α)) (Fintype.card ι)] + have h := integral_mono_of_nonneg (Filter.Eventually.of_forall fun s => sq_nonneg (idealAverage positive ℓ α c s γ-1)) + (integrable_const (μ:=Measure.pi (fun _ : ι => (volume : Measure CircleX))) (((1/(ℓ*α))^(Fintype.card ι)+1)^2)) (Filter.Eventually.of_forall hb) + simpa [idealEnergy] using h + +lemma idealEnergy_integrable (positive : Bool) {ℓ α : ℝ} (hℓ : 0 < ℓ) (hα : 0 < α) + (c : κ → ℝ) (μ : Measure (ι → ℝ)) [IsFiniteMeasure μ] : + Integrable (idealEnergy (ι:=ι) positive ℓ α c) μ := by + apply Integrable.of_bound (measurable_idealEnergy positive ℓ α c).aestronglyMeasurable + (((1/(ℓ*α))^(Fintype.card ι)+1)^2) + filter_upwards [] with γ + rw [Real.norm_eq_abs,abs_of_nonneg (idealEnergy_nonneg positive ℓ α c γ)] + exact idealEnergy_le positive hℓ hα c γ +end +open ContinuousCircleWeight.Sampling +open Set MeasureTheory + +def phaseFailure (b : ℝ) (c : ℝ) : Set ℝ := + {γ | ¬ (b < 1-repr ((c*γ:ℝ):CircleX) ∧ 1-repr ((c*γ:ℝ):CircleX) < 1-b)} +lemma measurableSet_phaseFailure (b c : ℝ) : MeasurableSet (phaseFailure b c) := by + apply MeasurableSet.compl + exact (measurableSet_lt measurable_const (measurable_const.sub + (measurable_repr.comp ((AddCircle.continuous_mk' 1).measurable.comp (measurable_const.mul measurable_id))))).inter + (measurableSet_lt (measurable_const.sub + (measurable_repr.comp ((AddCircle.continuous_mk' 1).measurable.comp (measurable_const.mul measurable_id)))) measurable_const) + +lemma phaseFailure_norm (b c γ : ℝ) (hγ : γ ∈ phaseFailure b c) : + ‖((c*γ:ℝ):CircleX)‖ ≤ b := by + let x : CircleX := ((c*γ:ℝ):CircleX) + have h1 : ‖x‖ ≤ repr x := by + calc + ‖x‖ = ‖((repr x:ℝ):CircleX)‖ := by rw [coe_repr] + _ ≤ ‖repr x‖ := QuotientAddGroup.norm_mk_le_norm + _ = repr x := Real.norm_of_nonneg (repr_mem x).1 + have hx : ((repr x-1:ℝ):CircleX)=x := by + rw [AddCircle.coe_sub,coe_repr] + simp + have h2 : ‖x‖ ≤ 1-repr x := by + calc + ‖x‖ = ‖((repr x-1:ℝ):CircleX)‖ := by rw [hx] + _ ≤ ‖repr x-1‖ := QuotientAddGroup.norm_mk_le_norm + _ = 1-repr x := by + rw [Real.norm_eq_abs,abs_of_nonpos (by linarith [(repr_mem x).2])]; ring + change ¬ (b < 1-repr x ∧ 1-repr x < 1-b) at hγ + by_contra hb + have hb' : b < ‖x‖ := lt_of_not_ge hb + exact hγ ⟨hb'.trans_le h2,by linarith [hb'.trans_le h1]⟩ + +lemma interval_phase_ball_bound {a b c r : ℝ} (hab : a < b) (hc : 0 < c) + (hr : 0 ≤ r) : + (intervalLaw a b).real {γ | ‖((c*γ:ℝ):CircleX)‖ ≤ r} ≤ + (1+1/(c*(b-a)))*(2*r) := by + have h := phasePairLaw_marginal_fst (d:=0) hab hc (Metric.closedBall (0:CircleX) r) + measurableSet_closedBall + rw [Measure.real,phasePairLaw,Measure.map_apply (continuous_phasePair c 0).measurable + (measurableSet_closedBall.preimage measurable_fst)] at h + have heq : (phasePair c 0 ⁻¹' (Prod.fst ⁻¹' Metric.closedBall (0:CircleX) r)) = + {γ | ‖((c*γ:ℝ):CircleX)‖ ≤ r} := by ext γ; simp [phasePair,Metric.mem_closedBall,dist_zero_right] + rw [heq] at h + apply h.trans + gcongr + rw [Measure.real,AddCircle.volume_closedBall] + rw [ENNReal.toReal_ofReal (le_min (by norm_num : (0:ℝ) ≤ 1) (mul_nonneg (by norm_num) hr))] + exact min_le_right _ _ + +lemma phase_failure_probability {N b c : ℝ} (hN : 0 < N) (hb : 0 ≤ b) + (hc : N/4 ≤ |c|) : + intervalLaw (1/N) (2/N) (phaseFailure b c) ≤ ENNReal.ofReal (10*b) := by + have hab : 1/N < 2/N := (div_lt_div_iff_of_pos_right hN).mpr (by norm_num) + let := intervalLaw_probability hab + have hc0 : 0 < |c| := (by positivity : 0 < N/4).trans_le hc + have hnorm (γ : ℝ) : ‖((c*γ:ℝ):CircleX)‖=‖((|c| *γ:ℝ):CircleX)‖ := by + rcases le_total 0 c with h | h + · rw [abs_of_nonneg h] + · rw [abs_of_nonpos h,neg_mul,AddCircle.coe_neg,norm_neg] + have hsub : phaseFailure b c ⊆ {γ | ‖((|c| *γ:ℝ):CircleX)‖ ≤ b} := by + intro γ hγ + rw [Set.mem_ofPred_eq,← hnorm] + exact phaseFailure_norm b c γ hγ + have hC : 1+1/(|c| *(2/N-1/N)) ≤ 5 := by + have hh : 2/N-1/N = 1/N := by ring + rw [hh] + have hden : (1/4:ℝ) ≤ |c| *(1/N) := by + have hh : (1/4:ℝ) ≤ |c| /N := (le_div_iff₀ hN).mpr (by linarith only [hc]) + simpa only [div_eq_mul_inv, mul_comm, mul_one, one_mul] using hh + have hle := one_div_le_one_div_of_le (by norm_num : (0:ℝ) < 1/4) hden + norm_num only [one_div_div, div_one] at hle + linarith only [hle] + have hμ : (intervalLaw (1/N) (2/N)).real (phaseFailure b c) ≤ 10*b := by + calc + _ ≤ (intervalLaw (1/N) (2/N)).real {γ | ‖((|c| *γ:ℝ):CircleX)‖ ≤ b} := + ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono hsub) + _ ≤ (1+1/(|c| *(2/N-1/N)))*(2*b) := interval_phase_ball_bound hab hc0 hb + _ ≤ 5*(2*b) := mul_le_mul_of_nonneg_right hC (by positivity) + _ = 10*b := by ring + rw [← ENNReal.ofReal_toReal (measure_ne_top (intervalLaw (1/N) (2/N)) (phaseFailure b c))] + exact ENNReal.ofReal_le_ofReal hμ + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/SamplingStage.lean b/lean/OAI/Analysis/RotationWeights/SamplingStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..84ff59ded91e714129fc3fc64a1ca2f4b4131b08 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/SamplingStage.lean @@ -0,0 +1,345 @@ +import OAI.Analysis.RotationWeights.ReturnSamples + +namespace OAI + +noncomputable section + +universe uτ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators + +namespace CircleSampling +open Set Filter MeasureTheory ContinuousCircleWeight.Sampling +open scoped Topology + +lemma exists_sampling_stage {τ : Type uτ} [Fintype τ] + (O : τ → Set CircleX) (hO : ∀ t, IsOpen (O t)) (hne : ∀ t, (O t).Nonempty) + {K : ℕ} (hK : 0 < K) {η : ℝ} (hη : 0 < η) + (P : ℕ → Prop) (hP : ∀ᶠ m : ℕ in atTop, P m) + {a b : ℝ} (hab : a < b) {p : ℕ} (hp : 0 < p) (M : ℕ → ℝ) : + ∃ m : ℕ, P m ∧ 3 ≤ m ∧ ∃ S : τ → Finset ℤ, + (∀ t, (S t).Nonempty) ∧ + (∀ t n, n∈S t → (m:ℝ)^((7:ℝ)/10*m)/2 ≤ (n:ℝ) ∧ (n:ℝ) ≤ (m:ℝ)^((7:ℝ)/10*m)) ∧ + ∃ q : ℕ → ℕ, q 0=p ∧ (∀ i ≤ m, 0 < q i) ∧ + (∀ i < m, q i ∣ q (i+1) ∧ M m < (q (i+1):ℝ)/q i) ∧ + ∃ d e : ℝ, d < e ∧ Icc d e ⊆ Ioo a b ∧ ∀ θ∈Icc d e, + (∀ i : Fin m, Int.fract ((q (i+1):ℝ)*θ) ∈ Ioo (1/((m:ℝ)*K)) (2/((m:ℝ)*K))) ∧ + (∀ k : ℤ, ((m:ℝ)*K)/4 ≤ |(k:ℝ)| → |(k:ℝ)| ≤ (m:ℝ)^((4:ℝ)/5*m) → + (m:ℝ)/20 ≤ ((Finset.univ.filter fun i : Fin m => + Int.fract ((q (i+1):ℝ)*θ) ∉ phaseFailure ((m:ℝ)^(-(19:ℝ)/20)) k).card:ℝ)) ∧ + (∀ t n, n∈S t → n•(θ:CircleX)∈O t) ∧ + ∀ t (positive : Bool), + (∫ x : CircleX, (idealAverage positive (scaleEll m) (scaleAlpha m) + (fun n : S t => (n.val:ℝ)) (characterCurve (fun i : Fin m => (q (i+1):ℤ)) x) + (fun i => Int.fract ((q (i+1):ℝ)*θ))-1)^2) < η := by + classical + obtain ⟨θ0,hθirr,hθa,hθb⟩ := exists_irrational_btwn hab + have hs : ∀ᶠ m : ℕ in atTop, ∀ t, ∃ S : Finset ℤ, + (m:ℝ)^((69:ℝ)/100*m) ≤ (S.card:ℝ) ∧ + (∀ n∈S, (m:ℝ)^((7:ℝ)/10*m)/2 ≤ (n:ℝ) ∧ (n:ℝ) ≤ (m:ℝ)^((7:ℝ)/10*m) ∧ n•(θ0:CircleX)∈O t) ∧ + (∀ n∈S, ∀ n'∈S, n≠n' → ∀ v v' : ℤ, |v| ≤ m^300 → |v'| ≤ m^300 → + (v≠0 ∨ v'≠0) → (m*K*m^1000:ℤ) < |v*n+v'*n'|) := + Filter.eventually_all.mpr (fun t => eventually_separated_returns hθirr (hO t) (hne t) K) + obtain ⟨m,hmP,hm3,hmnum,hbudget,hps,hmS⟩ := + (hP.and ((eventually_ge_atTop (3:ℕ)).and ((eventually_IdealNumerics K).and + ((eventually_trial_budget (Fintype.card (τ×Bool)) hη).and (eventually_phase_failure_small.and hs))))).exists + have hm0 : 0 < m := by omega + have hmR : 0 < (m:ℝ) := Nat.cast_pos.mpr hm0 + choose S hSc hSbounds hSsep using hmS + have hSnon (t : τ) : (S t).Nonempty := by + apply Finset.card_pos.mp + have hh : (0:ℝ) < ((S t).card:ℝ) := (Real.rpow_pos_of_pos hmR _).trans_le (hSc t) + exact_mod_cast hh + let (t : τ) : Nonempty (S t) := (hSnon t).to_subtype + have hcpos (t : τ) (n : S t) : (0:ℝ) < (n.val:ℝ) := + (div_pos (Real.rpow_pos_of_pos hmR _) (by norm_num)).trans_le (hSbounds t n n.property).1 + have hN2 : 2 < (m:ℝ)*K := by + have hm3R : (3:ℝ) ≤ m := Nat.cast_le.mpr hm3 + have hKR : (1:ℝ) ≤ K := by exact_mod_cast (show (1:ℕ) ≤ K by omega) + nlinarith + have hN : 0 < (m:ℝ)*K := by linarith + let R := (m:ℝ)^((4:ℝ)/5*m) + have hR1 : 1 ≤ R := Real.one_le_rpow (by exact_mod_cast (show 1 ≤ m by omega)) (by positivity) + obtain ⟨g,hg,hgphase,hgcover,hgE⟩ := exists_ideal_trial (κ:=fun t : τ×Bool => S t.1) + hK hmnum Prod.snd (fun t n => (n.val:ℝ)) + (fun t => by simpa using hSc t.1) + (fun t n => (hSbounds t.1 n n.property).1) + (by + intro t n n' hnn v w hv hw hvw + have hne' : n.val≠n'.val := fun he => hnn (Subtype.ext he) + have hv' : |v| ≤ (m:ℤ)^300 := by simpa only [Nat.cast_pow] using hv + have hw' : |w| ≤ (m:ℤ)^300 := by simpa only [Nat.cast_pow] using hw + have hh := (hSsep t.1 n n.property n' n'.property hne' v w hv' hw' hvw).le + simpa only [Int.cast_add, Int.cast_mul, Int.cast_natCast, Int.cast_pow, Int.cast_abs] using + (Int.cast_le (R := ℝ)).mpr hh) + hps (phaseRange ((m:ℝ)*K) R) (phaseRange_bound hR1) + (fun _ hk => phaseRange_lower hk) hη hbudget + have hg01 (i : Fin m) : g i∈Ioo 0 1 := by + refine ⟨lt_trans (one_div_pos.mpr hN) (hg i).1,lt_trans (hg i).2 ?_⟩ + exact (div_lt_one hN).mpr hN2 + let γ : PhaseCube m := fun i => ⟨g i,(hg01 i).1.le,(hg01 i).2.le⟩ + have hγ : ∀ i, (γ i:ℝ)∈Ioo 0 1 := hg01 + have hcover : ∀ᶠ β : PhaseCube m in 𝓝 γ, ∀ k∈phaseRange ((m:ℝ)*K) R, + (m:ℝ)/20 ≤ ((Finset.univ.filter fun i => (β i:ℝ)∉phaseFailure ((m:ℝ)^(-(19:ℝ)/20)) k).card:ℝ) := by + have hneK (k : ℤ) (hk : k∈phaseRange ((m:ℝ)*K) R) : k≠0 := by + intro he + have hh := phaseRange_lower hk + rw [he] at hh + norm_num at hh + linarith + filter_upwards [phase_cover_eventually γ (phaseRange ((m:ℝ)*K) R) ((m:ℝ)^(-(19:ℝ)/20)) + (fun k hk i => hgphase k (hneK k hk) i)] with β hβ k hk + exact (hgcover k hk).trans (Nat.cast_le.mpr (hβ k hk)) + have hinterval : ∀ᶠ β : PhaseCube m in 𝓝 γ, ∀ i, (β i:ℝ)∈Ioo (1/((m:ℝ)*K)) (2/((m:ℝ)*K)) := + cube_interval_eventually γ hg + have horbit : ∀ᶠ θ : ℝ in 𝓝 θ0, ∀ t n, n∈S t → n•(θ:CircleX)∈O t := by + apply Filter.eventually_all.mpr + intro t + apply (Filter.eventually_all_finite (S t).finite_toSet).mpr + intro n hn + exact (show ContinuousAt (fun θ : ℝ => n•(θ:CircleX)) θ0 by fun_prop).eventually + ((hO t).mem_nhds (hSbounds t n hn).2.2) + obtain ⟨a',b',hθint,hsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp (Filter.inter_mem (Ioo_mem_nhds hθa hθb) horbit) + obtain ⟨q,hq0,hqp,hqM,d,e,hde,hdeSub,hreal⟩ := realize_finite_sampling (κ:=fun t : τ×Bool => S t.1) + Prod.snd (Real.rpow_pos_of_pos hmR _) (scaleAlpha_pos hm0) (fun t n => (n.val:ℝ)) γ hγ + (fun t n i => hgphase n (by exact_mod_cast (hcpos t.1 n).ne') i) hgE + (hinterval.and hcover) (lt_trans hθint.1 hθint.2) hp (M m) + refine ⟨m,hmP,hm3,S,hSnon,(fun t n hn => ⟨(hSbounds t n hn).1,(hSbounds t n hn).2.1⟩), + q,hq0,hqp,hqM,d,e,hde,?_,?_⟩ + · exact fun θ hθ => (hsub (hdeSub hθ)).1 + · intro θ hθ + refine ⟨(hreal θ hθ).1.1,?_,(hsub (hdeSub hθ)).2,?_⟩ + · intro k hk hkR + exact (hreal θ hθ).1.2 k (mem_phaseRange hk hkR) + · intro t positive + exact (hreal θ hθ).2 (t,positive) +end CircleSampling + +open scoped BigOperators +namespace ContinuousCircleWeight + +theorem exists_nonzero_low_product_coefficient (K : ℕ) (A B : Polynomial ℂ) + (hA : A.coeff K ≠ 0) (hB : B.coeff K ≠ 0) : + ∃ n ≤ 2 * K, (A * B).coeff n ≠ 0 := by + have hA0 : A ≠ 0 := by contrapose! hA; simp [hA] + have hB0 : B ≠ 0 := by contrapose! hB; simp [hB] + refine ⟨(A * B).natTrailingDegree, ?_, + Polynomial.coeff_natTrailingDegree_ne_zero.mpr (mul_ne_zero hA0 hB0)⟩ + rw [Polynomial.natTrailingDegree_mul hA0 hB0] + have ha := Polynomial.natTrailingDegree_le_of_ne_zero hA + have hb := Polynomial.natTrailingDegree_le_of_ne_zero hB + omega + +def shiftedPolynomial (K : ℕ) (a : Fin (2 * K + 1) → ℂ) : Polynomial ℂ := + ∑ i, Polynomial.monomial i.val (a i) + +@[simp] theorem coeff_shiftedPolynomial (K : ℕ) (a : Fin (2 * K + 1) → ℂ) + (i : Fin (2 * K + 1)) : (shiftedPolynomial K a).coeff i = a i := by + classical + simp only [shiftedPolynomial, Polynomial.finsetSum_coeff, Polynomial.coeff_monomial] + simp only [Fin.val_inj] + simp + +theorem continuous_coeff_shiftedPolynomial (K n : ℕ) : + Continuous (fun a : Fin (2 * K + 1) → ℂ => (shiftedPolynomial K a).coeff n) := by + classical + simp only [shiftedPolynomial, Polynomial.finsetSum_coeff, Polynomial.coeff_monomial] + apply continuous_finsetSum + intro i _ + split_ifs <;> fun_prop + +abbrev CoefficientPair (K : ℕ) := + (Fin (2 * K + 1) → ℂ) × (Fin (2 * K + 1) → ℂ) + +def lowProduct (K : ℕ) (a : CoefficientPair K) : Fin (2 * K + 1) → ℂ := + fun n => (shiftedPolynomial K a.1 * shiftedPolynomial K a.2).coeff n + +theorem continuous_lowProduct (K : ℕ) : Continuous (lowProduct K) := by + apply continuous_pi + intro n + simp only [lowProduct, Polynomial.coeff_mul] + apply continuous_finsetSum + intro x _ + exact ((continuous_coeff_shiftedPolynomial K x.1).comp continuous_fst).mul + ((continuous_coeff_shiftedPolynomial K x.2).comp continuous_snd) + +def centerIndex (K : ℕ) : Fin (2 * K + 1) := ⟨K, by omega⟩ + +theorem lowProduct_ne_zero (K : ℕ) (a : CoefficientPair K) + (hA : a.1 (centerIndex K) ≠ 0) (hB : a.2 (centerIndex K) ≠ 0) : + lowProduct K a ≠ 0 := by + have hA' : (shiftedPolynomial K a.1).coeff K ≠ 0 := by + change (shiftedPolynomial K a.1).coeff (centerIndex K) ≠ 0 + simpa only [coeff_shiftedPolynomial] using hA + have hB' : (shiftedPolynomial K a.2).coeff K ≠ 0 := by + change (shiftedPolynomial K a.2).coeff (centerIndex K) ≠ 0 + simpa only [coeff_shiftedPolynomial] using hB + obtain ⟨n, hn, hcoeff⟩ := exists_nonzero_low_product_coefficient K _ _ hA' hB' + intro hzero + have := congr_fun hzero (⟨n, by omega⟩ : Fin (2 * K + 1)) + exact hcoeff this + +theorem finite_coefficient_bound (K : ℕ) (δ D : ℝ) (hδ : 0 < δ) (hD : 0 ≤ D) : + ∃ ε > 0, ∀ a : CoefficientPair K, + (∀ i, ‖a.1 i‖ ≤ D) → (∀ i, ‖a.2 i‖ ≤ D) → + δ ≤ ‖a.1 (centerIndex K)‖ → δ ≤ ‖a.2 (centerIndex K)‖ → + ∃ n : Fin (2 * K + 1), ε ≤ ‖lowProduct K a n‖ := by + let S : Set (CoefficientPair K) := + Metric.closedBall 0 D ∩ + {a | δ ≤ ‖a.1 (centerIndex K)‖} ∩ {a | δ ≤ ‖a.2 (centerIndex K)‖} + have hSc : IsCompact S := by + apply IsCompact.inter_right + · apply IsCompact.inter_right (isCompact_closedBall _ _) + exact isClosed_le continuous_const (by fun_prop) + · exact isClosed_le continuous_const (by fun_prop) + have hpositive : ∀ a ∈ S, 0 < ‖lowProduct K a‖ := by + intro a ha + apply norm_pos_iff.mpr + apply lowProduct_ne_zero + · intro hz + have : δ ≤ ‖a.1 (centerIndex K)‖ := ha.1.2 + simp only [hz, norm_zero] at this + linarith + · intro hz + have : δ ≤ ‖a.2 (centerIndex K)‖ := ha.2 + simp only [hz, norm_zero] at this + linarith + obtain ⟨ε, hε, hlower⟩ := hSc.exists_forall_le' + (continuous_lowProduct K).norm.continuousOn hpositive + refine ⟨ε, hε, ?_⟩ + intro a ha hb hca hcb + have haS : a ∈ S := by + refine ⟨⟨?_, hca⟩, hcb⟩ + rw [Metric.mem_closedBall, dist_zero_right, Prod.norm_def, max_le_iff] + exact ⟨(pi_norm_le_iff_of_nonneg hD).mpr ha, (pi_norm_le_iff_of_nonneg hD).mpr hb⟩ + obtain ⟨n, _, hn⟩ := Finset.exists_max_image Finset.univ (fun n => ‖lowProduct K a n‖) + Finset.univ_nonempty + refine ⟨n, (hlower a haS).trans ?_⟩ + rw [pi_norm_le_iff_of_nonneg (norm_nonneg _)] + exact fun i => hn i (Finset.mem_univ i) + +end ContinuousCircleWeight + +namespace CircleSampling +open Filter Set +open scoped Topology + +def nextWindow (m : ℕ) : ℕ := ⌈(m:ℝ)^((3:ℝ)/4*m)⌉₊ +def kappa (j : ℕ) : ℝ := 1/(100*((j:ℝ)+1)) + +lemma kappa_pos (j : ℕ) : 0 < kappa j := by unfold kappa; positivity +lemma kappa_le (j : ℕ) : kappa j ≤ (1:ℝ)/100 := by + unfold kappa + apply one_div_le_one_div_of_le (by norm_num) + nlinarith [Nat.cast_nonneg (α:=ℝ) j] + +lemma exists_exponential_budget (j K : ℕ) {ε : ℝ} (hε : 0 < ε) (L0 : ℝ) : + ∃ L : ℝ, 1 ≤ L ∧ L0 ≤ L ∧ (2*(K:ℝ)+1)*3*Real.exp (-L/10000) ≤ ε/((j:ℝ)+1) := by + have ht : Tendsto (fun L : ℝ => (2*(K:ℝ)+1)*3*Real.exp (-L/10000)) atTop (𝓝 0) := by + have he := Real.tendsto_exp_neg_atTop_nhds_zero.comp + (tendsto_id.atTop_div_const (show (0:ℝ)<10000 by norm_num)) + simpa only [Function.comp_def, id_eq, neg_div, mul_zero] using he.const_mul ((2*(K:ℝ)+1)*3) + have hpos : 0 < ε/((j:ℝ)+1) := div_pos hε (by positivity) + obtain ⟨L,h1,h2,hb⟩ := ((eventually_ge_atTop (1:ℝ)).and + ((eventually_ge_atTop L0).and (ht.eventually_lt_const hpos))).exists + exact ⟨L,h1,h2,hb.le⟩ + +lemma exists_bridge_budget (j : ℕ) (L : ℝ) : + ∃ G : ℝ, 1 ≤ G ∧ L ≤ kappa (j+1)*Real.sqrt G := by + have ht : Tendsto (fun G : ℝ => kappa (j+1)*Real.sqrt G) atTop atTop := + Real.tendsto_sqrt_atTop.const_mul_atTop (kappa_pos _) + obtain ⟨G,hG,hL⟩ := ((eventually_ge_atTop (1:ℝ)).and (ht.eventually_ge_atTop L)).exists + exact ⟨G,hG,hL⟩ + +lemma eventually_nextWindow_superlinear (C : ℝ) : + ∀ᶠ m : ℕ in atTop, C*(m:ℝ) < nextWindow m := by + filter_upwards [eventually_rpow_linear_gap ((3:ℝ)/4) 0 (C+1) 1 (by norm_num), + eventually_ge_atTop (1:ℕ)] with m hg hm + have hmR : 0 < (m:ℝ) := by exact_mod_cast hm + have hh : (C+1)*(m:ℝ) ≤ (m:ℝ)^((3:ℝ)/4*m) := by simpa using hg + exact (by nlinarith : C*(m:ℝ)<(m:ℝ)^((3:ℝ)/4*m)).trans_le (Nat.le_ceil _) + +lemma eventually_nextWindow_overlap (G : ℝ) : + ∀ᶠ m : ℕ in atTop, G*(nextWindow m:ℝ) < (m:ℝ)^((4:ℝ)/5*m) := by + filter_upwards [eventually_rpow_linear_gap ((4:ℝ)/5) ((3:ℝ)/4) (2*|G|+1) 0 (by norm_num), + eventually_ge_atTop (1:ℕ)] with m hg hm + have hm1 : (1:ℝ) ≤ m := by exact_mod_cast hm + have hr : 1 ≤ (m:ℝ)^((3:ℝ)/4*m) := Real.one_le_rpow hm1 (by positivity) + have hc : (nextWindow m:ℝ) < (m:ℝ)^((3:ℝ)/4*m)+1 := Nat.ceil_lt_add_one (by positivity) + have hc0 : 0 ≤ (nextWindow m:ℝ) := Nat.cast_nonneg _ + have habs := le_abs_self G + have hh : (2*|G|+1)*(m:ℝ)^((3:ℝ)/4*m) ≤ (m:ℝ)^((4:ℝ)/5*m) := by simpa using hg + have hc' : (nextWindow m:ℝ) ≤ 2*(m:ℝ)^((3:ℝ)/4*m) := by linarith + calc + G*(nextWindow m:ℝ) ≤ |G| *(nextWindow m:ℝ) := mul_le_mul_of_nonneg_right habs hc0 + _ ≤ |G| *(2*(m:ℝ)^((3:ℝ)/4*m)) := mul_le_mul_of_nonneg_left hc' (abs_nonneg G) + _ < (2*|G|+1)*(m:ℝ)^((3:ℝ)/4*m) := by nlinarith + _ ≤ (m:ℝ)^((4:ℝ)/5*m) := hh + +def StageNumerics (j K : ℕ) (G L Gnext : ℝ) (m : ℕ) : Prop := + 200 ≤ m ∧ 2^(j+1) ≤ m ∧ K ≤ m ∧ 4*G ≤ (m:ℝ) ∧ + L ≤ kappa j*(m:ℝ)^((1:ℝ)/40) ∧ + Gnext*(nextWindow m:ℝ) < (m:ℝ)^((4:ℝ)/5*m) ∧ + 2*K < nextWindow m ∧ m < nextWindow m ∧ + (m:ℝ)^(-(19:ℝ)/20) ≤ 1/4 + +lemma eventually_StageNumerics (j K : ℕ) (G L Gnext : ℝ) : + ∀ᶠ m : ℕ in atTop, StageNumerics j K G L Gnext m := by + have ht : Tendsto (fun m : ℕ => (m:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have hp : Tendsto (fun m : ℕ => kappa j*(m:ℝ)^((1:ℝ)/40)) atTop atTop := + ((tendsto_rpow_atTop (by norm_num : (0:ℝ)<1/40)).comp ht).const_mul_atTop (kappa_pos j) + have hb : Tendsto (fun m : ℕ => (m:ℝ)^(-(19:ℝ)/20)) atTop (𝓝 0) := by + simpa only [Function.comp_def, neg_div] using (tendsto_rpow_neg_atTop (by norm_num : (0:ℝ)<19/20)).comp ht + filter_upwards [eventually_ge_atTop (max 200 (max (2^(j+1)) K)), ht.eventually_ge_atTop (4*G), + hp.eventually_ge_atTop L, eventually_nextWindow_overlap Gnext, eventually_nextWindow_superlinear 2, + hb.eventually_lt_const (by norm_num : (0:ℝ)<1/4)] with m hm hG hL hov hnext hb + have hK : K ≤ m := (le_max_right _ _).trans ((le_max_right _ _).trans hm) + have hm0 : 0 ≤ (m:ℝ) := Nat.cast_nonneg _ + refine ⟨(le_max_left _ _).trans hm,(le_max_left _ _).trans ((le_max_right _ _).trans hm),hK,hG,hL,hov,?_,?_,hb.le⟩ + · have : 2*(K:ℝ) < nextWindow m := lt_of_le_of_lt (by exact_mod_cast Nat.mul_le_mul_left 2 hK) hnext + exact_mod_cast this + · have : (m:ℝ) < nextWindow m := by linarith + exact_mod_cast this +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/TaggedEvents.lean b/lean/OAI/Analysis/RotationWeights/TaggedEvents.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8d92aba68fa29deaa1f607fda2cd9de3685d3ef --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/TaggedEvents.lean @@ -0,0 +1,420 @@ +import OAI.Analysis.RotationWeights.ActualDigits + +namespace OAI + +noncomputable section + +universe uι uX uΩ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal + +open MeasureTheory Set +open scoped BigOperators ENNReal +namespace CircleCoupling + +lemma independent_one_tag_bound {ι : Type uι} [DecidableEq ι] {X : ι → Type uX} + [∀ i,MeasurableSpace (X i)] (μ : (i : ι) → Measure (X i)) [∀ i,IsProbabilityMeasure (μ i)] + (s : Finset ι) (tag good : (i : ι) → Set (X i)) + (htag : ∀ i,MeasurableSet (tag i)) (hgood : ∀ i,MeasurableSet (good i)) + (hdis : ∀ i∈s,Disjoint (tag i) (good i)) {p a : ℝ} (hp : 0≤p) (ha : 0≤a) + (ht : ∀ i∈s,p≤(μ i).real (tag i)) (hg : ∀ i∈s,a≤(μ i).real (good i)) : + (s.card:ℝ)*p*a^(s.card-1) ≤ + (Measure.infinitePi μ).real (⋃ i∈s, Set.pi (s:Set ι) (fun k => if k=i then tag k else good k)) := by + classical + let A (i : ι) : Set (∀ k,X k) := Set.pi (s:Set ι) (fun k => if k=i then tag k else good k) + have hA (i : ι) : MeasurableSet (A i) := by + apply MeasurableSet.pi s.countable_toSet + intro k _ + by_cases h:k=i <;> simp only [h,ite_true,ite_false] <;> first | exact htag k | exact hgood k + have hd : (s:Set ι).PairwiseDisjoint A := by + intro i hi j hj hij + apply Set.disjoint_left.mpr + intro ω hωi hωj + have hx : ω i∈tag i := by simpa [A] using hωi i hi + have hy : ω i∈good i := by simpa [A,hij] using hωj i hi + exact Set.disjoint_left.mp (hdis i hi) hx hy + change _≤(Measure.infinitePi μ).real (⋃ i∈s,A i) + rw [measureReal_biUnion_finset hd (fun i _ => hA i)] + calc + _ = ∑ _i∈s,p*a^(s.card-1) := by simp; ring + _ ≤ _ := by + apply Finset.sum_le_sum + intro i hi + have he : (Measure.infinitePi μ).real (A i)= + ∏ k∈s, (μ k).real (if k=i then tag k else good k) := by + unfold Measure.real A + rw [Measure.infinitePi_pi μ (by + intro k _; by_cases h:k=i <;> simp only [h,ite_true,ite_false] <;> first | exact htag k | exact hgood k)] + exact ENNReal.toReal_prod _ _ + rw [he] + have hv : (∏ k∈s,if k=i then p else a)=p*a^(s.card-1) := by + rw [←Finset.mul_prod_erase s (fun k => if k=i then p else a) hi] + simp only [ite_true] + have hn : ∀ k∈s.erase i,k≠i := fun k hk => (Finset.mem_erase.mp hk).1 + simp only [Finset.mem_erase] at hn + simp_rw [Finset.prod_congr rfl (fun k hk => ite_eq_right ((Finset.mem_erase.mp hk).1))] + simp [Finset.card_erase_of_mem hi] + rw [←hv] + apply Finset.prod_le_prod₀ + · intro k _; split <;> assumption + · intro k hk + by_cases h:k=i <;> simp only [h,ite_true,ite_false] <;> first | exact ht k hk | exact hg k hk + +lemma log_one_sub_lower {t : ℝ} (ht : 0≤t) (ht1 : t≤1/2) : -2*t≤Real.log (1-t) := by + have hp : 0<1-t := by linarith + have hh := Real.one_sub_inv_le_log_of_pos hp + have he : 1-(1-t)⁻¹= -t/(1-t) := by field_simp; ring + rw [he] at hh + apply le_trans _ hh + rw [le_div_iff₀ hp] + nlinarith + +lemma one_tag_survival (m : ℕ) (hm : 200 ≤ m) : Real.exp (-86)≤(1-43/(m:ℝ))^(m-1) := by + have hm0 : 0<(m:ℝ) := by exact_mod_cast (show 0 < m by omega) + have ht : 0≤43/(m:ℝ) := by positivity + have ht1 : 43/(m:ℝ) ≤ 1/2 := by + rw [div_le_iff₀ hm0] + have hh : (200:ℝ) ≤ m := by exact_mod_cast hm + linarith + have hb : 0<1-43/(m:ℝ) := by linarith + rw [←Real.exp_log (pow_pos hb _),Real.log_pow,Real.exp_le_exp] + calc + -(86:ℝ) ≤ ((m-1:ℕ):ℝ)*(-2*(43/(m:ℝ))) := by + rw [Nat.cast_sub (by omega : 1 ≤ m),Nat.cast_one] + field_simp + nlinarith + _ ≤ _ := mul_le_mul_of_nonneg_left (log_one_sub_lower ht ht1) (Nat.cast_nonneg _) + +open MeasureTheory Set +open scoped BigOperators ENNReal + +lemma count_fin_lower (l : ℕ) {a : ℝ} (ha : 0 ≤ a) : + ((Finset.univ.filter fun d : Fin l => (d.val:ℝ) (d.val:ℝ) hB d) + _ = _ := by simp + +lemma finite_lower_fiber_mass {Ω : Type uΩ} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + {l : ℕ} (f : Ω → Fin l) (hf : Measurable f) {B : ℝ} (hB0 : 0 ≤ B) + (hB : ∀ d,μ.real {ω | f ω=d} ≤ B) {a : ℝ} (ha : 0 ≤ a) : + μ.real {ω | ((f ω).val:ℝ) (d.val:ℝ) digitEndpoint e z.2) + ((digitEndpoint_measurable e).comp measurable_snd) (by positivity : 0 ≤ 10/(P.l:ℝ)) + (P.law_density_ten tagged e) (mul_nonneg ht hl.le) + simp_rw [div_lt_iff₀ hl] + convert hh using 1; field_simp + +lemma law_upper_digit (tagged e : Bool) {t : ℝ} (ht : 0 ≤ t) : + (P.law tagged).real {z | 1-t<((digitEndpoint e z.2).val+1:ℝ)/(P.l:ℝ)} ≤ 10*(t+1/(P.l:ℝ)) := by + have hl : (0:ℝ) intro h + · simpa using congrArg Fin.rev h + · rw [h]; simp + rw [he] + exact P.law_density_ten tagged e d.rev + have hh := finite_lower_fiber_mass (P.law tagged) (fun z => (digitEndpoint e z.2).rev) + (by measurability) (by positivity : 0 ≤ 10/(P.l:ℝ)) hf (mul_nonneg ht hl.le) + have he : {z : P.Sample | 1-t<((digitEndpoint e z.2).val+1:ℝ)/(P.l:ℝ)}= + {z : P.Sample | (((digitEndpoint e z.2).rev).val:ℝ) intro h <;> linarith + rw [he] + convert hh using 1; field_simp + +lemma law_untagged_margin_mass : 1-43/(P.m:ℝ) ≤ (P.law true).real P.untaggedMargin := by + have hl : (0:ℝ) ∅ + | n+1 => (S.coord n).tagEvent + +def coordinateMargin : (n : ℕ) → Set (S.Sample n) + | 0 => Set.univ + | n+1 => (S.coord n).marginEvent + +def coordinateUntaggedMargin (n : ℕ) : Set (S.Sample n) := + (S.coordinateTag n)ᶜ ∩ S.coordinateMargin n + +lemma measurableSet_coordinateTag (n : ℕ) : MeasurableSet (S.coordinateTag n) := by + cases n <;> measurability +lemma measurableSet_coordinateMargin (n : ℕ) : MeasurableSet (S.coordinateMargin n) := by + cases n <;> measurability +lemma measurableSet_coordinateUntaggedMargin (n : ℕ) : MeasurableSet (S.coordinateUntaggedMargin n) := + (S.measurableSet_coordinateTag n).compl.inter (S.measurableSet_coordinateMargin n) + +def oneTagEvent (I : Finset ℕ) : Set S.Samples := + ⋃ i∈I, Set.pi (I:Set ℕ) (fun k => if k=i then S.coordinateTag k else S.coordinateUntaggedMargin k) +lemma measurableSet_oneTagEvent (I : Finset ℕ) : MeasurableSet (S.oneTagEvent I) := by + apply MeasurableSet.biUnion (Set.to_countable _) + intro i _ + apply MeasurableSet.pi I.countable_toSet + intro k _ + by_cases h:k=i <;> simp only [h,ite_true,ite_false] <;> + first | exact S.measurableSet_coordinateTag k | exact S.measurableSet_coordinateUntaggedMargin k + +lemma oneTagEvent_mass (tagged : ℕ → Bool) (I : Finset ℕ) (m : ℕ) + (hm : 200 ≤ m) (hc : I.card=m) (hzero : 0∉I) + (hmI : ∀ n, n+1∈I → (S.coord n).m=m) + (htI : ∀ n, n+1∈I → tagged n=true) : + Real.exp (-86) ≤ (S.probability tagged).real (S.oneTagEvent I) := by + have hm0 : 0 < (m:ℝ) := by exact_mod_cast (by omega : 0 < m) + have ha : 0 ≤ 1-43/(m:ℝ) := by + have hh : (200:ℝ) ≤ m := by exact_mod_cast hm + have hd : 43/(m:ℝ) ≤ 1 := (div_le_one hm0).mpr (by linarith) + linarith + have hh := independent_one_tag_bound (S.law tagged) I S.coordinateTag S.coordinateUntaggedMargin + S.measurableSet_coordinateTag S.measurableSet_coordinateUntaggedMargin + (fun i _ => Set.disjoint_left.mpr (fun _ ht hg => hg.1 ht)) + (by positivity : 0 ≤ 1/(m:ℝ)) ha (fun i hi => ?_) (fun i hi => ?_) + · change _ ≤ (S.probability tagged).real (S.oneTagEvent I) at hh + rw [hc] at hh + have hid : (m:ℝ)*(1/(m:ℝ))=1 := by field_simp + rw [hid,one_mul] at hh + exact (one_tag_survival m hm).trans hh + · cases i with + | zero => exact False.elim (hzero hi) + | succ n => + change 1/(m:ℝ) ≤ ((S.coord n).law (tagged n)).real (S.coord n).tagEvent + rw [htI n hi,(S.coord n).law_tag_mass,hmI n hi] + · cases i with + | zero => exact False.elim (hzero hi) + | succ n => + change 1-43/(m:ℝ) ≤ ((S.coord n).law (tagged n)).real (S.coord n).untaggedMargin + rw [htI n hi,←hmI n hi] + exact (S.coord n).law_untagged_margin_mass + +lemma oneTagEvent_margins {I : Finset ℕ} {ω : S.Samples} + (hw : ω∈S.supported) (hω : ω∈S.oneTagEvent I) : + (∃ i∈I, ω i∈S.coordinateTag i) ∧ ∀ i∈I, ω i∈S.coordinateMargin i := by + obtain ⟨a,ha,h⟩ := Set.mem_iUnion₂.mp hω + have hat : ω a∈S.coordinateTag a := by simpa using h a ha + refine ⟨⟨a,ha,hat⟩,?_⟩ + intro i hi + by_cases hia : i=a + · subst i + cases a with + | zero => exact Set.mem_univ _ + | succ n => exact (S.coord n).tag_forces_margin (hw.2 n) hat + · have hg : ω i∈S.coordinateUntaggedMargin i := by simpa [hia] using h i hi + exact hg.2 +end CircleCoupling.DigitSystem + +namespace CircleSampling +open MeasureTheory Set CircleCoupling +open scoped BigOperators ENNReal + +def blockCoordinates (j : ℕ) : Finset ℕ := Finset.Ico (blockEnd j+1) (blockEnd (j+1)+1) +lemma blockCoordinates_card (j : ℕ) : (blockCoordinates j).card=blockLength j := by + rw [blockCoordinates,Nat.card_Ico] + have h := blocks.step j + change blockEnd (j+1)=blockEnd j+blockLength j at h + omega +lemma blockCoordinates_zero (j : ℕ) : 0 ∉ blockCoordinates j := by simp [blockCoordinates] +lemma blockCoordinates_block (j n : ℕ) (hn : n+1 ∈ blockCoordinates j) : coordinateBlock n=j := by + have hh := Finset.mem_Ico.mp hn + exact blocks.number_eq (by change blockEnd j ≤ n; omega) (by change n exact False.elim (blockCoordinates_zero j hi) + | succ n => exact ⟨n,hi,hit⟩ + · intro n hn + have hh := hm (n+1) hn + change (((ω (n+1)).2.1.val:ℝ)+1)/(coordinateRadix n:ℝ) ≤ 1-2/(blockLength (coordinateBlock n):ℝ) ∧ + 2/(blockLength (coordinateBlock n):ℝ) ≤ ((ω (n+1)).2.2.val:ℝ)/(coordinateRadix n:ℝ) at hh + rwa [blockCoordinates_block j n hn] at hh +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/TailBounds.lean b/lean/OAI/Analysis/RotationWeights/TailBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bc177a57e55fa34e3c2ac5ca7592f7662ee40db --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/TailBounds.lean @@ -0,0 +1,378 @@ +import OAI.Analysis.RotationWeights.Thresholds + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uX + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal + +section +open CircleModel Set +open scoped BigOperators + +lemma sum_drop_prefix (j : ℕ) : (∑ i∈Finset.range (blockEnd j),coordinateDrop i)=(scaleState j).1.E := by + induction j with + | zero => rfl + | succ j ih => + change (∑ i∈Finset.range (blockEnd j+blockLength j),coordinateDrop i)=(scaleState j).1.E+dropSize j*blockLength j + rw [Finset.sum_range_add,ih] + congr 1 + have he (i : ℕ) (hi : i∈Finset.range (blockLength j)) : coordinateDrop (blockEnd j+i)=dropSize j := by + change dropSize (blocks.number (blockEnd j+i))=dropSize j + congr 1 + apply blocks.number_eq (by change blockEnd j ≤ blockEnd j+i; omega) + change blockEnd j+i (frequency_pos (i+1)).ne' + have hblock (s : ℕ) : volume (⋃ a : Fin (blockLength (j+1+s)), + {x : CircleX | if e then Xi modelFrequency (blocks.equiv ⟨j+1+s,a⟩) x < 2*(polynomialWindow j:ℝ)/blockScale (j+1+s) + else 1-2*(polynomialWindow j:ℝ)/blockScale (j+1+s) ≤ Xi modelFrequency (blocks.equiv ⟨j+1+s,a⟩) x}) ≤ ENNReal.ofReal (2*(polynomialWindow j:ℝ)/(polynomialWindow (j+1+s):ℝ)) := by + have hm : (blockLength (j+1+s):ℝ)≠0 := (Nat.cast_pos.mpr (scaleStep (j+1+s)).mpos).ne' + apply (measure_iUnion_le_ofReal_tsum volume _ (fun _ => 2*(polynomialWindow j:ℝ)/blockScale (j+1+s)) + (fun _ => div_nonneg (by positivity) (blockScale_pos _).le) (Summable.of_finite) ?_).trans + · apply ENNReal.ofReal_le_ofReal + rw [tsum_fintype] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,blockScale] + field_simp + rfl + · intro a + cases e + · exact measure_Xi_upper hq _ _ + · exact measure_Xi_lower hq _ _ + have hs : Summable (fun s => 2*(polynomialWindow j:ℝ)/(polynomialWindow (j+1+s):ℝ)) := by + simpa only [div_eq_mul_inv,one_mul] using (summable_window_inverse (j+1)).mul_left (2*(polynomialWindow j:ℝ)) + have hm := measure_iUnion_le_ofReal_tsum volume _ _ (fun s => by positivity) hs hblock + apply (ENNReal.toReal_le_of_le_ofReal (tsum_nonneg (fun _ => by positivity)) hm).trans + simp_rw [div_eq_mul_inv] + rw [tsum_mul_left] + calc + _ ≤ 2*(polynomialWindow j:ℝ)*(2/(polynomialWindow (j+1):ℝ)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + simpa only [one_div] using tsum_window_inverse (j+1) + _ = _ := by ring +lemma window_div_next (j : ℕ) : (polynomialWindow j:ℝ)/(polynomialWindow (j+1):ℝ) ≤ 1/(blockLength j:ℝ) := by + apply le_trans _ (sampleBound_div_window j) + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + have hm : (1:ℝ) ≤ blockLength j := by exact_mod_cast (scaleStep j).mpos + have hm200 : (200:ℝ) ≤ blockLength j := by exact_mod_cast blockLength_ge j + apply (Nat.cast_le.mpr (polynomialWindow_le_length j)).trans + calc + (blockLength j:ℝ) = (blockLength j:ℝ)^(1:ℝ) := (Real.rpow_one _).symm + _ ≤ sampleBound j := Real.rpow_le_rpow_of_exponent_le hm (by linarith) +lemma futureBad_tendsto (e : Bool) : Tendsto (fun j => volume.real (futureBad j e)) atTop (𝓝 0) := by + have hupper (j : ℕ) : volume.real (futureBad j e) ≤ 4/(blockLength j:ℝ) := by + apply (futureBad_bound j e).trans + have h := mul_le_mul_of_nonneg_left (window_div_next j) (by norm_num : (0:ℝ) ≤ 4) + simpa only [div_eq_mul_inv,mul_assoc,mul_one,one_mul] using h + apply squeeze_zero (fun _ => measureReal_nonneg) hupper + simpa only [div_eq_mul_inv,one_mul,mul_zero,Function.comp_def] using + ((tendsto_one_div_atTop_nhds_zero_nat (𝕜:=ℝ)).comp blockLength_strictMono.tendsto_atTop).const_mul 4 + +lemma measure_small_positive_tendsto {X : Type uX} [MeasurableSpace X] (μ : Measure X) [IsFiniteMeasure μ] + (r : X → ℝ) (hr : Measurable r) (hp : ∀ᵐ x ∂μ,0 μ.real {x | r x<1/((j:ℝ)+1)}) atTop (𝓝 0) := by + have hm : Antitone (fun j : ℕ => {x | r x<1/((j:ℝ)+1)}) := by + intro j k hjk x hx + change r x<1/((k:ℝ)+1) at hx + change r x<1/((j:ℝ)+1) + exact hx.trans_le (one_div_le_one_div_of_le (by positivity) (by exact_mod_cast Nat.add_le_add_right hjk 1)) + have hi : μ (⋂ j : ℕ,{x | r x<1/((j:ℝ)+1)})=0 := by + apply measure_mono_null _ (ae_iff.mp hp) + intro x hx + simp only [mem_iInter,mem_ofPred_eq] at hx ⊢ + by_contra! hp' + have he : ∀ᶠ j : ℕ in atTop,1/((j:ℝ)+1) (measurableSet_lt hr measurable_const).nullMeasurableSet) hm ⟨0,measure_ne_top _ _⟩ + rw [hi] at hh + simpa only [Function.comp_def,ENNReal.toReal_zero,Measure.real] using (ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp hh +end + +section +open MeasureTheory Set Filter CircleCoupling +open scoped Topology ENNReal + +def endpointBad (r : CircleX → ℝ) (j : ℕ) (e : Bool) : Set CircleX := + futureBad j e ∪ {x | (if e then 1-r x else r x)<1/((j:ℝ)+1)} +def projectionEvent (r : CircleX → ℝ) (j : ℕ) : Set ActualSamples := + stageTagEvent j \ (firstEndpoint ⁻¹' endpointBad r j false ∪ lastEndpoint ⁻¹' endpointBad r j true) +lemma endpointBad_measurable {r : CircleX → ℝ} (hr : Measurable r) (j : ℕ) (e : Bool) : MeasurableSet (endpointBad r j e) := by + apply (futureBad_measurable j e).union + apply measurableSet_lt _ measurable_const + cases e + · exact hr + · exact measurable_const.sub hr +lemma projectionEvent_measurable {r : CircleX → ℝ} (hr : Measurable r) (j : ℕ) : MeasurableSet (projectionEvent r j) := + (stageTagEvent_measurable j).diff (((endpointBad_measurable hr j false).preimage firstEndpoint_measurable).union + ((endpointBad_measurable hr j true).preimage lastEndpoint_measurable)) +lemma endpointBad_tendsto {r : CircleX → ℝ} (hr : Measurable r) (hp : ∀ᵐ x,0 volume.real (endpointBad r j e)) atTop (𝓝 0) := by + have hpos : ∀ᵐ x,0<(if e then 1-r x else r x) := by + filter_upwards [hp] with x hx + cases e <;> simp only [Bool.false_eq_true,↓reduceIte] <;> linarith [hx.1,hx.2] + have hm : Measurable (fun x => if e then 1-r x else r x) := by cases e <;> first | exact hr | exact measurable_const.sub hr + apply squeeze_zero (fun _ => measureReal_nonneg) (fun j => measureReal_union_le _ _) ?_ + simpa using (futureBad_tendsto e).add (measure_small_positive_tendsto volume _ hm hpos) +lemma endpointBad_loss_tendsto {r : CircleX → ℝ} (hr : Measurable r) (hp : ∀ᵐ x,0 (actualSystem.probability (stageTagged j)).real ((actualSystem.endpoint (fun _ => e)) ⁻¹' endpointBad r j e)) atTop (𝓝 0) := by + apply squeeze_zero (fun _ => measureReal_nonneg) (fun j => actual_hybrid_bound j (fun _ => e) _ (endpointBad_measurable hr j e)) ?_ + simpa using ((Real.continuous_sqrt.tendsto 0).comp (endpointBad_tendsto hr hp e)).const_mul marginalConstant +lemma projectionEvent_mass {r : CircleX → ℝ} (hr : Measurable r) (hp : ∀ᵐ x,0 (actualSystem.probability (stageTagged j)).real (firstEndpoint ⁻¹' endpointBad r j false)+ + (actualSystem.probability (stageTagged j)).real (lastEndpoint ⁻¹' endpointBad r j true)) atTop (𝓝 0) := by + simpa only [add_zero,firstEndpoint,lastEndpoint] using (endpointBad_loss_tendsto hr hp false).add (endpointBad_loss_tendsto hr hp true) + have he := hl.eventually (gt_mem_nhds (by positivity : (0:ℝ) simpa only [Bool.false_eq_true,↓reduceIte,not_lt,not_le] using hh + +lemma event_tail_margins {r : CircleX → ℝ} (j : ℕ) {ω : ActualSamples} + (hω : ω∈regularSamples) (he : ω∈projectionEvent r j) (s : ℕ) (hjs : j ≤ s) (a : Fin (blockLength s)) : + Xi modelFrequency (blocks.equiv ⟨s,a⟩) (firstEndpoint ω)<1-2*(polynomialWindow j:ℝ)/blockScale s ∧ + 2*(polynomialWindow j:ℝ)/blockScale s ≤ Xi modelFrequency (blocks.equiv ⟨s,a⟩) (lastEndpoint ω) := by + have hh := projectionEvent_mem he + rcases hjs.eq_or_lt with rfl | hjs + · have hi : blocks.equiv ⟨j,a⟩+1∈blockCoordinates j := by + simp only [blockCoordinates,Finset.mem_Ico] + change blockEnd j+1 ≤ blockEnd j+a.val+1 ∧ blockEnd j+a.val+1 (ω i).2.1) hω.2.2.2.1 (blocks.equiv ⟨j,a⟩+1)).2 + have hy := (digit_interval actualSystem.radix_ge_two (fun i => (ω i).2.2) hω.2.2.2.2 (blocks.equiv ⟨j,a⟩+1)).1 + rw [(actual_Xi_tail hω _).1,(actual_Xi_tail hω _).2] + have hr : 2*(polynomialWindow j:ℝ)/blockScale j=2/(blockLength j:ℝ) := by + have hK : (polynomialWindow j:ℝ)≠0 := (Nat.cast_pos.mpr (polynomialWindow_pos j)).ne' + unfold blockScale; field_simp + rw [hr] + exact ⟨hx.trans_le hm.1,hm.2.trans hy⟩ + · exact ⟨not_futureBad_iff j s hjs a _ false hh.2.1,not_futureBad_iff j s hjs a _ true hh.2.2.1⟩ + +lemma event_floor_tail {r : CircleX → ℝ} (j : ℕ) {ω : ActualSamples} + (hω : ω∈regularSamples) (he : ω∈projectionEvent r j) (k : ℤ) + (hk0 : 0 ≤ k) (hk : k ≤ (polynomialWindow j:ℤ)) (n : ℕ) (hn : blockEnd j ≤ n) : + floorTerm modelFrequency modelAngle k (firstEndpoint ω) n=0 ∧ + floorTerm modelFrequency modelAngle (-k) (lastEndpoint ω) n=0 := by + obtain ⟨⟨s,a⟩,rfl⟩ := blocks.equiv.surjective n + change Fin (blockLength s) at a + have hjs : j ≤ s := by + by_contra! hsj + have hs := blocks.strictMono.monotone (by omega : s+1 ≤ j) + have ha := a.isLt + have ht := blocks.step s + change blockEnd (s+1) ≤ blockEnd j at hs + change blockEnd (s+1)=blockEnd s+blockLength s at ht + change blockEnd j ≤ blockEnd s+a.val at hn + omega + have hm := event_tail_margins j hω he s hjs a + have hb := coordinatePhase_bounds (blocks.equiv ⟨s,a⟩) + rw [block_number_equiv s a] at hb + have hk0' : (0:ℝ) ≤ k := by exact_mod_cast hk0 + have hk' : (k:ℝ) ≤ polynomialWindow j := by exact_mod_cast hk + have hmul0 : 0 ≤ (k:ℝ)*coordinatePhase (blocks.equiv ⟨s,a⟩) := mul_nonneg hk0' (coordinatePhase_pos _).le + have hmul : (k:ℝ)*coordinatePhase (blocks.equiv ⟨s,a⟩) ≤ 2*(polynomialWindow j:ℝ)/blockScale s := by + calc + _ ≤ (polynomialWindow j:ℝ)*(2/blockScale s) := mul_le_mul hk' hb.2.le (coordinatePhase_pos _).le (Nat.cast_nonneg _) + _ = _ := by ring + have hx := repr_mem (modelFrequency (blocks.equiv ⟨s,a⟩) • firstEndpoint ω) + have hy := repr_mem (modelFrequency (blocks.equiv ⟨s,a⟩) • lastEndpoint ω) + change 0 ≤ Xi modelFrequency _ (firstEndpoint ω) ∧ Xi modelFrequency _ (firstEndpoint ω)<1 at hx + change 0 ≤ Xi modelFrequency _ (lastEndpoint ω) ∧ Xi modelFrequency _ (lastEndpoint ω)<1 at hy + simp only [floorTerm,model_beta,Int.cast_neg] + constructor <;> apply Int.floor_eq_iff.mpr <;> norm_num only [Int.cast_zero,zero_add] <;> + constructor <;> nlinarith [hm.1,hm.2] + +lemma event_window_bounds {r : CircleX → ℝ} (j : ℕ) {ω : ActualSamples} + (hω : ω∈regularSamples) (he : ω∈projectionEvent r j) (k : ℤ) + (hk : |k| ≤ (polynomialWindow j:ℤ)) : + 1/modelF k (firstEndpoint ω) ≤ coefficientCap j ∧ modelF (-k) (lastEndpoint ω) ≤ coefficientCap j := by + have hk' : |(k:ℝ)| ≤ (polynomialWindow j:ℝ) := by exact_mod_cast hk + by_cases hk0 : 0 ≤ k + · have hb := event_floor_tail j hω he k hk0 (le_trans (le_abs_self _) hk) + exact ⟨(modelF_prefix_bound j k hω.2.1 hk' (fun i hi => (hb i hi).1)).2, + (modelF_prefix_bound j (-k) hω.2.2.1 (by simpa using hk') (fun i hi => (hb i hi).2)).1⟩ + · have hx : 1 ≤ modelF k (firstEndpoint ω) := by + rw [←modelF_zero (firstEndpoint ω)] + exact modelF_antitone _ (by omega) + have hy : modelF (-k) (lastEndpoint ω) ≤ 1 := by + rw [←modelF_zero (lastEndpoint ω)] + exact modelF_antitone _ (by omega) + exact ⟨((div_le_one (modelF_pos _ _)).mpr hx).trans (coefficientCap_ge_one j),hy.trans (coefficientCap_ge_one j)⟩ + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/TensorBasis.lean b/lean/OAI/Analysis/RotationWeights/TensorBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f12d6722f13777c9a79170577dacd8c03e546b3 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/TensorBasis.lean @@ -0,0 +1,197 @@ +import OAI.Analysis.RotationWeights.Fibers + +namespace OAI + +noncomputable section + +namespace ContinuousCircleWeight + +universe uX uE uι uκ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators + +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +section +variable {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + +def pureL2 (f : Lp ℂ 2 μ) (u : E) : Lp E 2 μ := + (ContinuousLinearMap.toSpanSingleton ℂ u).compLp f + +lemma pureL2_coe (f : Lp ℂ 2 μ) (u : E) : + pureL2 μ f u =ᵐ[μ] fun x ↦ f x • u := + (ContinuousLinearMap.toSpanSingleton ℂ u).coeFn_compLp f + +lemma pureL2_inner (f g : Lp ℂ 2 μ) (u v : E) : + inner ℂ (pureL2 μ f u) (pureL2 μ g v) = inner ℂ f g * inner ℂ u v := by + rw [L2.inner_def, L2.inner_def, ← integral_mul_const] + apply integral_congr_ae + filter_upwards [pureL2_coe μ f u,pureL2_coe μ g v] with x h1 h2 + rw [h1,h2,inner_smul_left,inner_smul_right] + simp only [RCLike.inner_apply, mul_assoc, mul_comm (g x)] + +def coordinateL2 (u : E) : Lp E 2 μ →L[ℂ] Lp ℂ 2 μ := + (innerSL ℂ u).compLpL 2 μ + +lemma coordinateL2_coe (u : E) (g : Lp E 2 μ) : + coordinateL2 μ u g =ᵐ[μ] fun x ↦ inner ℂ u (g x) := + (innerSL ℂ u).coeFn_compLpL g + +lemma pureL2_inner_coordinate (f : Lp ℂ 2 μ) (u : E) (g : Lp E 2 μ) : + inner ℂ (pureL2 μ f u) g = inner ℂ f (coordinateL2 μ u g) := by + rw [L2.inner_def,L2.inner_def] + apply integral_congr_ae + filter_upwards [pureL2_coe μ f u,coordinateL2_coe μ u g] with x h1 h2 + rw [h1,h2,inner_smul_left] + simp only [RCLike.inner_apply,mul_comm] + +variable {ι : Type uι} {κ : Type uκ} + +lemma hilbertBasis_ext (b : HilbertBasis ι ℂ E) {u v : E} + (h : ∀ i, inner ℂ (b i) u = inner ℂ (b i) v) : u=v := by + apply b.repr.injective + ext i + simpa only [b.repr_apply_apply] using h i + +lemma orthonormal_pureL2 (b : HilbertBasis ι ℂ E) (c : HilbertBasis κ ℂ (Lp ℂ 2 μ)) : + Orthonormal ℂ (fun z : ι × κ ↦ pureL2 μ (c z.2) (b z.1)) := by + classical + rw [orthonormal_iff_ite] + intro i j + rw [pureL2_inner,orthonormal_iff_ite.mp c.orthonormal, + orthonormal_iff_ite.mp b.orthonormal] + by_cases h1 : i.1=j.1 <;> by_cases h2 : i.2=j.2 <;> simp [h1,h2,Prod.ext_iff] + +lemma pureL2_orthogonal_eq_bot [Countable ι] (b : HilbertBasis ι ℂ E) + (c : HilbertBasis κ ℂ (Lp ℂ 2 μ)) : + (span ℂ (range (fun z : ι × κ ↦ pureL2 μ (c z.2) (b z.1))))ᗮ = ⊥ := by + apply eq_bot_iff.mpr + intro f hf + have hcoord (a : ι) : coordinateL2 μ (b a) f = 0 := by + apply hilbertBasis_ext c + intro n + rw [inner_zero_right,← pureL2_inner_coordinate] + exact (mem_orthogonal _ _).mp hf _ (subset_span ⟨(a,n),rfl⟩) + have hh : ∀ᵐ x ∂μ, ∀ a : ι, inner ℂ (b a) (f x) = 0 := by + apply ae_all_iff.mpr + intro a + filter_upwards [coordinateL2_coe μ (b a) f,Lp.coeFn_zero ℂ 2 μ] with x h1 h2 + rw [hcoord a,h2] at h1 + exact h1.symm + have he : f=0 := by + apply Lp.ext + filter_upwards [hh,Lp.coeFn_zero E 2 μ] with x hx hz + rw [hz] + apply hilbertBasis_ext b + intro a + simpa only [Pi.zero_apply,inner_zero_right] using hx a + simp only [he,zero_mem] + +variable [CompleteSpace E] + +def tensorL2Basis [Countable ι] (b : HilbertBasis ι ℂ E) + (c : HilbertBasis κ ℂ (Lp ℂ 2 μ)) : HilbertBasis (ι×κ) ℂ (Lp E 2 μ) := + HilbertBasis.mkOfOrthogonalEqBot (orthonormal_pureL2 μ b c) (pureL2_orthogonal_eq_bot μ b c) + +@[simp] lemma tensorL2Basis_apply [Countable ι] (b : HilbertBasis ι ℂ E) + (c : HilbertBasis κ ℂ (Lp ℂ 2 μ)) (z : ι×κ) : + tensorL2Basis μ b c z = pureL2 μ (c z.2) (b z.1) := by + simp only [tensorL2Basis,HilbertBasis.coe_mkOfOrthogonalEqBot] +end + +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +variable {X : Type uX} {E : Type uE} [MeasurableSpace X] (μ : Measure X) + [NormedAddCommGroup E] [NormedSpace ℂ E] + +lemma aestronglyMeasurable_field_simple (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) (s : SimpleFunc X E) : + AEStronglyMeasurable (fun x ↦ T x (s x)) μ := by + classical + have he : (fun x ↦ T x (s x)) = + ∑ a ∈ s.range, (s ⁻¹' {a}).indicator (fun x ↦ T x a) := by + funext x + simp [Set.indicator, s.mem_range_self] + rw [he] + exact s.range.aestronglyMeasurable_sum fun a _ ↦ (hT a).indicator (s.measurableSet_fiber a) + +lemma aestronglyMeasurable_field_apply (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) + (f : X → E) (hf : AEStronglyMeasurable f μ) : + AEStronglyMeasurable (fun x ↦ T x (f x)) μ := by + let f₀ := hf.mk f + have hf₀ : StronglyMeasurable f₀ := hf.stronglyMeasurable_mk + have hm : AEStronglyMeasurable (fun x ↦ T x (f₀ x)) μ := by + apply aestronglyMeasurable_of_tendsto_ae atTop + (fun n ↦ aestronglyMeasurable_field_simple μ T hT (hf₀.approx n)) + exact Eventually.of_forall fun x ↦ ((T x).continuous.tendsto (f₀ x)).comp + (hf₀.tendsto_approx x) + apply hm.congr + exact hf.ae_eq_mk.symm.mono fun x hx ↦ congrArg (T x) hx + +lemma bounded_field_memL2 (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) + (C : ℝ) (hC : ∀ᵐ x ∂μ, ‖T x‖ ≤ C) (f : Lp E 2 μ) : + MemLp (fun x ↦ T x (f x)) 2 μ := by + apply (Lp.memLp f).of_le_mul (c := C) + (aestronglyMeasurable_field_apply μ T hT f (Lp.aestronglyMeasurable f)) + filter_upwards [hC] with x hx + exact ((T x).le_opNorm _).trans (mul_le_mul_of_nonneg_right hx (norm_nonneg _)) + +def fieldMulL2 (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) + (C : ℝ) (hC : ∀ᵐ x ∂μ, ‖T x‖ ≤ C) : Lp E 2 μ →L[ℂ] Lp E 2 μ := + LinearMap.mkContinuous + { toFun := fun f ↦ (bounded_field_memL2 μ T hT C hC f).toLp (fun x ↦ T x (f x)) + map_add' := by + intro f g + apply Lp.ext + filter_upwards [(bounded_field_memL2 μ T hT C hC (f+g)).coeFn_toLp, + (bounded_field_memL2 μ T hT C hC f).coeFn_toLp, + (bounded_field_memL2 μ T hT C hC g).coeFn_toLp, + Lp.coeFn_add f g, Lp.coeFn_add ((bounded_field_memL2 μ T hT C hC f).toLp _) + ((bounded_field_memL2 μ T hT C hC g).toLp _)] with x h1 h2 h3 h4 h5 + simp only [Pi.add_apply] at h4 h5 + rw [h1,h5,h2,h3,h4,map_add] + map_smul' := by + intro c f + apply Lp.ext + filter_upwards [(bounded_field_memL2 μ T hT C hC (c•f)).coeFn_toLp, + (bounded_field_memL2 μ T hT C hC f).coeFn_toLp, Lp.coeFn_smul c f, + Lp.coeFn_smul c ((bounded_field_memL2 μ T hT C hC f).toLp _)] with x h1 h2 h3 h4 + simp only [Pi.smul_apply] at h3 h4 + simp only [RingHom.id_apply] + rw [h1,h4,h2,h3,map_smul] } + C (by + intro f + change ‖(bounded_field_memL2 μ T hT C hC f).toLp _‖ ≤ C*‖f‖ + apply Lp.norm_le_mul_norm_of_ae_le_mul + filter_upwards [(bounded_field_memL2 μ T hT C hC f).coeFn_toLp,hC] with x hx hc + rw [hx] + exact ((T x).le_opNorm _).trans (mul_le_mul_of_nonneg_right hc (norm_nonneg _))) + +lemma fieldMulL2_coe (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) + (C : ℝ) (hC : ∀ᵐ x ∂μ, ‖T x‖ ≤ C) (f : Lp E 2 μ) : + fieldMulL2 μ T hT C hC f =ᵐ[μ] fun x ↦ T x (f x) := + (bounded_field_memL2 μ T hT C hC f).coeFn_toLp + +lemma fieldMulL2_norm_le (T : X → (E →L[ℂ] E)) + (hT : ∀ v, AEStronglyMeasurable (fun x ↦ T x v) μ) + (C : ℝ) (hC : ∀ᵐ x ∂μ, ‖T x‖ ≤ C) (hC0 : 0 ≤ C) : + ‖fieldMulL2 μ T hT C hC‖ ≤ C := by + apply ContinuousLinearMap.opNorm_le_bound _ hC0 + intro f + apply Lp.norm_le_mul_norm_of_ae_le_mul + filter_upwards [fieldMulL2_coe μ T hT C hC f,hC] with x hx hc + rw [hx] + exact ((T x).le_opNorm _).trans (mul_le_mul_of_nonneg_right hc (norm_nonneg _)) + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Thresholds.lean b/lean/OAI/Analysis/RotationWeights/Thresholds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cdb0cc10a389a93a18f8b7d75a6c191cce7c75d --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Thresholds.lean @@ -0,0 +1,412 @@ +import OAI.Analysis.RotationWeights.TaggedEvents + +namespace OAI + +noncomputable section + +namespace CircleSampling + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +open Filter Set +open scoped Topology +open Set MeasureTheory +open scoped ENNReal Classical +open Filter +open scoped Topology +open Set Filter +open scoped Topology +open Set Topology +open scoped BigOperators +open scoped BigOperators +open Set +open Set +open Set +open Set MeasureTheory Filter +open scoped BigOperators ENNReal Topology Classical +open MeasureTheory Set Filter +open scoped ENNReal Topology +open MeasureTheory Set +open MeasureTheory Filter Set +open scoped Topology BoundedContinuousFunction +open MeasureTheory Set Filter Topology TopologicalSpace +open MeasureTheory Set +open scoped ENNReal BigOperators Classical +open MeasureTheory Set +open scoped BigOperators ENNReal Classical +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped ENNReal NNReal +open MeasureTheory Set Filter +open scoped BigOperators ENNReal Topology +open Set MeasureTheory Topology +open scoped symmDiff +open MeasureTheory Set +open scoped ENNReal BigOperators +open MeasureTheory Set +open scoped ENNReal +open MeasureTheory Set +open scoped BigOperators ENNReal + +section +open Set Filter +open scoped Topology + +def blockScale (s : ℕ) : ℝ := (blockLength s:ℝ)*polynomialWindow s +def blockRange (s : ℕ) : ℝ := (blockLength s:ℝ)^((4:ℝ)/5*blockLength s) +lemma blockScale_pos (s : ℕ) : 0 exact Or.inl ⟨j,le_rfl,ht.le,by simpa [hn] using htop⟩ + | succ a => + have hprev : blockRange (j+a) simp only [CoordinateParameters.prob,CoordinateParameters.ρ,CoordinateParameters.σ, + actualSystem,actualCoordinate,stageCrossingProbability,stageCrossingWidth,Bool.false_eq_true,↓reduceIte,blockCoordinates_block s n hn] +lemma stageCrossingWidth_eq (s n : ℕ) (hn : n+1 ∈ blockCoordinates s) (e : Bool) : + actualSystem.crossingWidth e (n+1)=stageCrossingWidth s e := by + cases e <;> simp only [DigitSystem.crossingWidth,CoordinateParameters.width, + actualSystem,actualCoordinate,stageCrossingWidth,Bool.false_eq_true,↓reduceIte,blockCoordinates_block s n hn] +lemma stageCrossingProbability_nonneg (s : ℕ) (e : Bool) : 0 ≤ stageCrossingProbability s e := + crossingProbability_nonneg (kappa_pos s).le +lemma stageCrossingProbability_le_one (s : ℕ) (e : Bool) : stageCrossingProbability s e ≤ 1 := by + have hi : blockEnd s+1 ∈ blockCoordinates s := Finset.mem_Ico.mpr ⟨le_rfl,by have hm : 0 < blockLength s := (scaleStep s).mpos; change blockEnd s+1 arg 1; rhs; rw [←Real.rpow_one (blockLength s:ℝ)] + rw [←Real.rpow_sub hm,←Real.rpow_mul hm.le] + norm_num + have he : (blockLength s:ℝ)*stageCrossingProbability s true=kappa s*(blockLength s:ℝ)^((1:ℝ)/40) := by + change (blockLength s:ℝ)*(kappa s*Real.sqrt (rangeWidth s/(blockLength s:ℝ)))=_ + rw [hroot] + calc + _ = kappa s*((blockLength s:ℝ)^(1:ℝ)*(blockLength s:ℝ)^(-(39:ℝ)/40)) := by rw [Real.rpow_one]; ring + _ = _ := by rw [←Real.rpow_add hm]; norm_num + rw [he] + exact (scaleStep s).numeric.2.2.2.2.1 +lemma stage_bridge_strength (s : ℕ) : crossingBudget s ≤ (blockLength (s+1):ℝ)*stageCrossingProbability (s+1) false := by + have hm : 0<(blockLength (s+1):ℝ) := Nat.cast_pos.mpr (scaleStep (s+1)).mpos + have hroot : Real.sqrt (bridgeWidth (s+1)/(blockLength (s+1):ℝ))=Real.sqrt (bridgeSize (s+1))/(blockLength (s+1):ℝ) := by + rw [bridgeWidth,div_div,←pow_two,Real.sqrt_div (le_trans (by norm_num) (bridgeSize_ge_one _)),Real.sqrt_sq hm.le] + have he : (blockLength (s+1):ℝ)*stageCrossingProbability (s+1) false=kappa (s+1)*Real.sqrt (bridgeSize (s+1)) := by + change (blockLength (s+1):ℝ)*(kappa (s+1)*Real.sqrt (bridgeWidth (s+1)/(blockLength (s+1):ℝ)))=_ + rw [hroot]; field_simp + rw [he] + exact (scaleStep s).bridge + +lemma threshold_bounds_of_abs {k : ℤ} {β a : ℝ} (ha : 0 linarith + · have hk' : (k:ℝ)<0 := (by exact_mod_cast (lt_of_not_ge hk)) + rw [abs_of_neg hk'] at hat ht hp + have hf : Int.fract (-((k:ℝ)*β))=-((k:ℝ)*β) := Int.fract_eq_self.mpr ⟨by nlinarith,by nlinarith⟩ + have hne : Int.fract (-((k:ℝ)*β))≠0 := by rw [hf]; nlinarith + have hn := Int.fract_neg hne + rw [neg_neg,hf] at hn + rw [hn] + constructor <;> nlinarith + +lemma bridge_thresholds (s : ℕ) (k : ℤ) + (hklo : bridgeSize s*(polynomialWindow s:ℝ)≤|(k:ℝ)|) (hkhi : |(k:ℝ)| ≤blockScale s/4) : + ∀ i∈blockCoordinates s, bridgeWidth s ≤ crossingThreshold k i ∧ crossingThreshold k i≤1-bridgeWidth s := by + intro i hi + have hi0 : i ≠ 0 := by intro hz; subst i; exact blockCoordinates_zero s hi + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero hi0 + have hn := blockCoordinates_block s n hi + have hβ := coordinatePhase_bounds n + rw [hn] at hβ + have hm : 0<(blockLength s:ℝ) := Nat.cast_pos.mpr (scaleStep s).mpos + have hK : 0<(polynomialWindow s:ℝ) := Nat.cast_pos.mpr (polynomialWindow_pos s) + have hN := blockScale_pos s + have hG : 0 blockEnd s+i.val+1,by intro a b h; apply Fin.ext; dsimp at h; omega⟩ + let J := Finset.univ.filter fun i : Fin (blockLength s) => coordinatePhase (blockEnd s+i.val) ∉ phaseFailure (rangeWidth s) k + refine ⟨J.map emb,?_,?_,?_⟩ + · intro i hi + obtain ⟨a,ha,rfl⟩ := Finset.mem_map.mp hi + exact Finset.mem_Ico.mpr ⟨by change blockEnd s+1≤blockEnd s+a.val+1; omega,by change blockEnd s+a.val+1 Int.fract (((scaleStep s).q (i+1):ℝ)*parameterAngle) ∉ phaseFailure (rangeWidth s) k) := by + ext i + simp only [J,Finset.mem_filter,Finset.mem_univ,true_and] + change (Int.fract (((frequency (blockEnd s+i.val+1)):ℝ)*parameterAngle) ∉ _) ↔ _ + rw [show blockEnd s+i.val+1=blockEnd s+(i.val+1) by omega,frequency_block s (by omega)] + rw [hJ] + exact hc + · intro i hi + obtain ⟨a,ha,rfl⟩ := Finset.mem_map.mp hi + have hh := (Finset.mem_filter.mp ha).2 + have hh' : rangeWidth s < 1-Int.fract ((k:ℝ)*coordinatePhase (blockEnd s+a.val)) ∧ + 1-Int.fract ((k:ℝ)*coordinatePhase (blockEnd s+a.val))<1-rangeWidth s := by + have hr (x : ℝ) : repr (x:CircleX)=Int.fract x := by + change (AddCircle.equivIco 1 0 (x:CircleX)).val=_ + simpa only [div_one,mul_one] using AddCircle.coe_equivIco_mk_apply (p:=(1:ℝ)) x + simpa only [phaseFailure,Set.mem_ofPred_eq,not_not,hr] using hh + change rangeWidth s ≤ 1-Int.fract ((k:ℝ)*coordinatePhase (blockEnd s+a.val+1-1)) ∧ 1-Int.fract ((k:ℝ)*coordinatePhase (blockEnd s+a.val+1-1))≤1-rangeWidth s + simpa only [Nat.add_sub_cancel] using And.intro hh'.1.le hh'.2.le +end + +section +open MeasureTheory Set Filter CircleCoupling CircleDigits +open scoped ENNReal + +def regularSamples : Set ActualSamples := {ω | ω∈actualSystem.supported ∧ + firstEndpoint ω∈modelGood ∧ lastEndpoint ω∈modelGood ∧ + firstEndpoint ω∈gridFree actualSystem.radix ∧ lastEndpoint ω∈gridFree actualSystem.radix} +lemma ae_regularSamples (j : ℕ) : ∀ᵐ ω ∂actualSystem.probability (stageTagged j),ω∈regularSamples := by + filter_upwards [actualSystem.ae_supported (stageTagged j),ae_endpoint_good j (fun _ => false), + ae_endpoint_good j (fun _ => true),actualSystem.ae_hybrid_gridFree (stageTagged j) (fun _ => false) (summable_actual_error j), + actualSystem.ae_hybrid_gridFree (stageTagged j) (fun _ => true) (summable_actual_error j)] with ω hs hx hy hfx hfy + exact ⟨hs,hx,hy,hfx,hfy⟩ +lemma actual_Xi_tail {ω : ActualSamples} (hω : ω∈regularSamples) (n : ℕ) : + CircleModel.Xi modelFrequency n (firstEndpoint ω)=scaledTail actualSystem.radix (fun i => (ω i).2.1) (n+1) ∧ + CircleModel.Xi modelFrequency n (lastEndpoint ω)=scaledTail actualSystem.radix (fun i => (ω i).2.2) (n+1) := by + constructor + · change (AddCircle.measurableEquivIco 1 0 (frequency (n+1) • firstEndpoint ω)).val=_ + rw [←actual_denominator] + exact scaledTail_repr actualSystem.radix_ge_two _ hω.2.2.2.1 _ + · change (AddCircle.measurableEquivIco 1 0 (frequency (n+1) • lastEndpoint ω)).val=_ + rw [←actual_denominator] + exact scaledTail_repr actualSystem.radix_ge_two _ hω.2.2.2.2 _ +lemma regular_order {ω : ActualSamples} (hω : ω∈regularSamples) (n : ℕ) : + CircleModel.Xi modelFrequency n (firstEndpoint ω) ≤ CircleModel.Xi modelFrequency n (lastEndpoint ω) := by + rw [(actual_Xi_tail hω n).1,(actual_Xi_tail hω n).2] + exact scaledTail_mono actualSystem.radix_ge_two hω.1.1 _ +lemma crossing_decay {ω : ActualSamples} (hω : ω∈regularSamples) (k : ℤ) (n : ℕ) + (hlo : scaledTail actualSystem.radix (fun i => (ω i).2.1) (n+1) (ω i).2.2) (n+1)) : + modelF k (lastEndpoint ω)/modelF k (firstEndpoint ω) ≤ Real.exp (-coordinateDrop n) := by + apply CircleModel.cocycle_ratio_crossing coordinateDrop (fun i => dropSize_nonneg (coordinateBlock i)) k hω.2.1 hω.2.2.1 (regular_order hω) n + · simpa only [model_beta,(actual_Xi_tail hω n).1,crossingThreshold,Nat.add_sub_cancel] using hlo + · simpa only [model_beta,(actual_Xi_tail hω n).2,crossingThreshold,Nat.add_sub_cancel] using hhi + +lemma stage_masks (j s : ℕ) (hjs : j ≤ s) (e : Bool) (k : ℤ) (I : Finset ℕ) + (hI : I⊆blockCoordinates s) (hcard : (blockLength s:ℝ)/20 ≤ (I.card:ℝ)) + (hstrength : crossingBudget j ≤ (blockLength s:ℝ)*stageCrossingProbability s e) + (hu : ∀ i∈I,stageCrossingWidth s e ≤ crossingThreshold k i ∧ crossingThreshold k i ≤ 1-stageCrossingWidth s e) : + ∃ H₁ H₂ : Set ActualSamples,MeasurableSet H₁ ∧ MeasurableSet H₂ ∧ + Measure.map firstEndpoint ((actualSystem.probability (stageTagged j)).restrict H₁) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map firstEndpoint (actualSystem.probability (stageTagged j)) ∧ + Measure.map lastEndpoint ((actualSystem.probability (stageTagged j)).restrict H₂) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map lastEndpoint (actualSystem.probability (stageTagged j)) ∧ + ∀ ω∈regularSamples,ω∉H₁ → ω∉H₂ → modelF k (lastEndpoint ω)/modelF k (firstEndpoint ω) ≤ Real.exp (-crossingBudget j) := by + have hzero : 0∉I := fun h => blockCoordinates_zero s (hI h) + have hwidth : ∀ i∈I,actualSystem.crossingWidth e i ≤ crossingThreshold k i ∧ crossingThreshold k i ≤ 1-actualSystem.crossingWidth e i := by + intro i hi + have hi0 : i≠0 := fun hz => hzero (hz ▸ hi) + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero hi0 + rw [stageCrossingWidth_eq s n (hI hi) e] + exact hu _ hi + obtain ⟨H₁,H₂,hm₁,hm₂,hd,he,_,hd₁,hd₂⟩ := actualSystem.actual_crossing_estimates (stageTagged j) e I hzero (crossingThreshold k) + (blockLength s) (stageCrossingProbability s e) (stageCrossingProbability_nonneg s e) (stageCrossingProbability_le_one s e) + hcard (fun n hn => stageCrossingProbability_eq s n (hI hn) e) hwidth + have hδ : ENNReal.ofReal (Real.exp (-(blockLength s:ℝ)*stageCrossingProbability s e/400)) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) := by + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + linarith + refine ⟨H₁,H₂,hm₁,hm₂,hd₁.trans (by gcongr; exact le_rfl),hd₂.trans (by gcongr; exact le_rfl),?_⟩ + intro ω hω h₁ h₂ + have hn : ω∉noCross actualSystem.radix I (crossingThreshold k) := by rw [←he]; exact fun h => h.elim h₁ h₂ + simp only [noCross,Set.mem_ofPred_eq,not_forall,Classical.not_not] at hn + obtain ⟨i,hi,hcross⟩ := hn + have hi0 : i≠0 := fun hz => hzero (hz ▸ hi) + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero hi0 + have hc := crossing_decay hω k n hcross.1 hcross.2 + apply hc.trans + apply Real.exp_le_exp.mpr + change -dropSize (coordinateBlock n) ≤ -crossingBudget j + rw [blockCoordinates_block s n (hI hi)] + exact neg_le_neg ((crossingBudget_mono hjs).trans (dropSize_ge_budget s)) + +lemma large_masks (j : ℕ) (k : ℤ) (hk : blockScale j/4< |(k:ℝ)|) : + ∃ H₁ H₂ : Set ActualSamples,MeasurableSet H₁ ∧ MeasurableSet H₂ ∧ + Measure.map firstEndpoint ((actualSystem.probability (stageTagged j)).restrict H₁) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map firstEndpoint (actualSystem.probability (stageTagged j)) ∧ + Measure.map lastEndpoint ((actualSystem.probability (stageTagged j)).restrict H₂) ≤ ENNReal.ofReal (Real.exp (-crossingBudget j/400)) • Measure.map lastEndpoint (actualSystem.probability (stageTagged j)) ∧ + ∀ ω∈regularSamples,ω∉H₁ → ω∉H₂ → modelF k (lastEndpoint ω)/modelF k (firstEndpoint ω) ≤ Real.exp (-crossingBudget j) := by + rcases exists_large_range j hk with ⟨s,hjs,hlo,hhi⟩ | ⟨s,hjs,hlo,hhi⟩ + · obtain ⟨I,hI,hcard,hu⟩ := large_thresholds s k hlo hhi + exact stage_masks j s hjs true k I hI hcard ((crossingBudget_mono hjs).trans (stage_range_strength s)) hu + · have hs0 : s≠0 := by omega + obtain ⟨a,rfl⟩ := Nat.exists_eq_succ_of_ne_zero hs0 + apply stage_masks j (a+1) (by omega) false k (blockCoordinates (a+1)) (fun _ h => h) + · rw [blockCoordinates_card]; nlinarith [show (0:ℝ) ≤ blockLength (a+1) from Nat.cast_nonneg _] + · exact (crossingBudget_mono (by omega : j ≤ a)).trans (stage_bridge_strength a) + · exact bridge_thresholds (a+1) k hlo hhi +end + +open MeasureTheory Set CircleCoupling CircleDigits +open scoped ENNReal + +lemma tagged_coordinate_extreme {ω : ActualSamples} (hω : ω∈regularSamples) {n : ℕ} + (ht : (ω (n+1)).1=some (4:Fin 5)) : + scaledTail actualSystem.radix (fun i => (ω i).2.1) (n+1)<1/(blockLength (coordinateBlock n):ℝ) ∧ + 1-1/(blockLength (coordinateBlock n):ℝ) ≤ scaledTail actualSystem.radix (fun i => (ω i).2.2) (n+1) := by + let P := actualSystem.coord n + have hs := hω.1.2 n + change supportCondition P.l (roundedWidth P.l P.a) (roundedWidth P.l P.b) (roundedTag P.l P.m) (ω (n+1)) at hs + simp only [supportCondition,ht] at hs + norm_num at hs + have hl : (0:ℝ) (ω i).2.1) hω.2.2.2.1 (n+1)).2 + have hy := (digit_interval actualSystem.radix_ge_two (fun i => (ω i).2.2) hω.2.2.2.2 (n+1)).1 + change _ < (((ω (n+1)).2.1.val:ℝ)+1)/(P.l:ℝ) at hx + change ((ω (n+1)).2.2.val:ℝ)/(P.l:ℝ) ≤ _ at hy + have ha : ((ω (n+1)).2.1.val:ℝ)+1 ≤ roundedTag P.l P.m := by exact_mod_cast hs.1 + have hb : (P.l:ℝ)-(roundedTag P.l P.m:ℝ) ≤ ((ω (n+1)).2.2.val:ℝ) := by + have hh : (P.l:ℝ) ≤ ((ω (n+1)).2.2.val:ℝ)+(roundedTag P.l P.m:ℝ) := by + exact_mod_cast (show P.l ≤ (ω (n+1)).2.2.val+roundedTag P.l P.m from hs.2) + linarith + have hr := P.tag_bounds.2.2.2 + change (roundedTag P.l P.m:ℝ) ≤ (P.l:ℝ)/P.m at hr + constructor + · change _ < 1/(P.m:ℝ) + apply hx.trans_le + rw [div_le_iff₀ hl] + convert ha.trans hr using 1; ring + · change 1-1/(P.m:ℝ) ≤ _ + apply le_trans _ hy + rw [le_div_iff₀ hl] + calc + _ = (P.l:ℝ)-(P.l:ℝ)/P.m := by ring + _ ≤ (P.l:ℝ)-(roundedTag P.l P.m:ℝ) := sub_le_sub_left hr _ + _ ≤ _ := hb + +lemma short_ratio (j : ℕ) (k : ℤ) (hklo : (polynomialWindow j:ℝ)< |(k:ℝ)|) (hkhi : |(k:ℝ)| ≤ blockScale j/4) + {ω : ActualSamples} (hω : ω∈regularSamples) (htag : ω∈stageTagEvent j) : + modelF k (lastEndpoint ω)/modelF k (firstEndpoint ω) ≤ Real.exp (-crossingBudget j) := by + obtain ⟨⟨n,hn,ht⟩,_⟩ := stageTagEvent_margins j hω.1 htag + have hphase := coordinatePhase_bounds n + have hblock := blockCoordinates_block j n hn + rw [hblock] at hphase + have hm : (0:ℝ) dsimp <;> omega + +def rightOperator (u : unitary ℂ) (m n : ℤ) : RegularOperator := + (rightTranslate u m n).toLinearIsometry.toContinuousLinearMap + +lemma rightOperator_vacuum (u : unitary ℂ) (m n : ℤ) : + rightOperator u m n regularVacuum = lp.single 2 (m,n) (1:ℂ) := by + ext ⟨a,b⟩ + change rightTranslate u m n regularVacuum (a,b)=_ + rw [rightTranslate_apply] + simp only [regularVacuum,lp.single_apply] + by_cases ha : a=m + · subst a + by_cases hb : b=n + · subst b; simp + · simp [hb,sub_eq_zero,Prod.mk.injEq] + · have ham : a-m≠0 := sub_ne_zero.mpr ha + simp [ham,Prod.mk.injEq,Ne.symm ha] + +lemma rightOperator_U (u : unitary ℂ) (m n : ℤ) : + Commute (regularU : RegularOperator) (rightOperator u m n) := by + change _*_= _*_ + ext f ⟨a,b⟩ + change (regularU : RegularOperator) (rightTranslate u m n f) (a,b)= + rightTranslate u m n ((regularU : RegularOperator) f) (a,b) + simp only [regularU_apply,rightTranslate_apply] + congr 2 + exact congrArg (fun i : ℤ × ℤ => f i) (Prod.ext (by dsimp; omega) rfl) + +lemma rightOperator_V (u : unitary ℂ) (m n : ℤ) : + Commute (regularV u : RegularOperator) (rightOperator u m n) := by + change _*_= _*_ + ext f ⟨a,b⟩ + change (regularV u : RegularOperator) (rightTranslate u m n f) (a,b)= + rightTranslate u m n ((regularV u : RegularOperator) f) (a,b) + simp only [regularV_apply,rightTranslate_apply] + rw [← mul_assoc,← mul_assoc,← Submonoid.coe_mul,← Submonoid.coe_mul,← zpow_add,← zpow_add] + congr 2 + · exact congrArg (fun z : ℤ => u^z) (by ring) + · exact congrArg (fun i : ℤ × ℤ => f i) (Prod.ext rfl (by dsimp; ring)) + +def regularAlgebra (u : unitary ℂ) : Set RegularOperator := + Set.centralizer (Set.centralizer ({(regularU : RegularOperator),(regularV u : RegularOperator)} : Set RegularOperator)) + +lemma in_regularAlgebra_commutes (u : unitary ℂ) {A : RegularOperator} + (hA : A∈regularAlgebra u) (m n : ℤ) : Commute A (rightOperator u m n) := by + have hr : rightOperator u m n ∈ Set.centralizer ({(regularU : RegularOperator),(regularV u : RegularOperator)} : Set RegularOperator) := by + intro B hB + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hB + rcases hB with rfl|rfl + · exact (rightOperator_U u m n).eq + · exact (rightOperator_V u m n).eq + exact (hA _ hr).symm + +lemma regular_column (u : unitary ℂ) {A : RegularOperator} (hA : A∈regularAlgebra u) + (m n : ℤ) : A (lp.single 2 (m,n) (1:ℂ)) = rightOperator u m n (A regularVacuum) := by + rw [← rightOperator_vacuum u m n] + exact DFunLike.congr_fun (in_regularAlgebra_commutes u hA m n).eq regularVacuum + +lemma regular_adjoint_coefficient (u : unitary ℂ) {A : RegularOperator} (hA : A∈regularAlgebra u) + (m n : ℤ) : (star A) regularVacuum (m,n) = + star ((↑(u^(-(m*n))) : ℂ) * (A regularVacuum) (-m,-n)) := by + have he := ContinuousLinearMap.adjoint_inner_left A (lp.single 2 (m,n) (1:ℂ)) regularVacuum + change inner ℂ ((star A) regularVacuum) (lp.single 2 (m,n) (1:ℂ))= + inner ℂ regularVacuum (A (lp.single 2 (m,n) (1:ℂ))) at he + rw [regular_column u hA,lp.inner_single_right,regularVacuum,lp.inner_single_left] at he + simp only [RCLike.inner_apply'] at he + change star ((star A) regularVacuum (m,n))*1=star (1:ℂ)*(rightTranslate u m n (A regularVacuum) (0,0)) at he + simp only [mul_one,star_one,one_mul,rightTranslate_apply,zero_sub,mul_neg] at he + have hh := congrArg star he + simpa only [star_star] using hh + +lemma regular_adjoint_norm_vacuum (u : unitary ℂ) {A : RegularOperator} (hA : A∈regularAlgebra u) : + ‖(star A) regularVacuum‖=‖A regularVacuum‖ := by + rw [lp.norm_eq_tsum_rpow (by norm_num),lp.norm_eq_tsum_rpow (by norm_num)] + congr 1 + calc + (∑' i : ℤ×ℤ, ‖(star A) regularVacuum i‖^(2:ℝ≥0∞).toReal) = + ∑' i : ℤ×ℤ, ‖A regularVacuum (-i.1,-i.2)‖^(2:ℝ≥0∞).toReal := by + congr 1 + funext ⟨m,n⟩ + rw [regular_adjoint_coefficient u hA,norm_star,norm_mul,CStarRing.norm_coe_unitary,one_mul] + _ = _ := (Equiv.neg (ℤ×ℤ)).tsum_eq (fun i ↦ ‖A regularVacuum i‖^(2:ℝ≥0∞).toReal) + +lemma regular_vacuum_separating (u : unitary ℂ) {A : RegularOperator} (hA : A∈regularAlgebra u) + (hzero : A regularVacuum=0) : A=0 := by + have hc : (Submodule.span ℂ (Set.range (fun i : ℤ×ℤ ↦ lp.single 2 i (1:ℂ)))).topologicalClosure = ⊤ := by + have hh := regular_cyclic u + simpa only [regular_monomial,Prod.eta] using hh + have hk : Submodule.span ℂ (Set.range (fun i : ℤ×ℤ ↦ lp.single 2 i (1:ℂ))) ≤ A.ker := by + apply Submodule.span_le.mpr + rintro _ ⟨⟨m,n⟩,rfl⟩ + change A (lp.single 2 (m,n) (1:ℂ))=0 + rw [regular_column u hA,hzero,map_zero] + have hk' := Submodule.topologicalClosure_minimal _ hk A.isClosed_ker + rw [hc,top_le_iff] at hk' + apply ContinuousLinearMap.ext + intro x + exact show x ∈ A.ker from hk'.symm ▸ Submodule.mem_top + +end + +open Set + +def fiberConjugacy : RegularOperator ≃⋆ₐ[ℂ] CircleFiberOperator := + circleFiberBasis.repr.symm.conjStarAlgEquiv +lemma fiberConjugacy_apply (A : RegularOperator) (x : RegularHilbert) : + fiberConjugacy A (circleFiberBasis.repr.symm x)=circleFiberBasis.repr.symm (A x) := by + change circleFiberBasis.repr.symm (A (circleFiberBasis.repr (circleFiberBasis.repr.symm x)))=_ + rw [LinearIsometryEquiv.apply_symm_apply] +lemma fiberConjugacy_U : fiberConjugacy (regularU : RegularOperator)=fiberShiftL2 1 := circleFiberBasis_conj_U +lemma fiberConjugacy_V (θ : ℝ) : fiberConjugacy (regularV (rotationScalar θ) : RegularOperator)=continuousPi (θ:CircleX) (fourier 1) := circleFiberBasis_conj_V θ + +def regularCommutant (θ : ℝ) : StarSubalgebra ℂ RegularOperator := + StarSubalgebra.centralizer ℂ ({(regularU:RegularOperator),(regularV (rotationScalar θ):RegularOperator)} : Set RegularOperator) +def fiberCommutant (θ : ℝ) : StarSubalgebra ℂ CircleFiberOperator := + (regularCommutant θ).map fiberConjugacy.toStarAlgHom + +lemma commute_star_unitary {A : Type uA} [Monoid A] [StarMul A] (u : unitary A) (b : A) + (h : Commute (u:A) b) : Commute (star (u:A)) b := by + change star (u:A)*b=b*star (u:A) + calc + star (u:A)*b = star (u:A)*(b*(u:A))*star (u:A) := by simp [mul_assoc] + _ = star (u:A)*((u:A)*b)*star (u:A) := by rw [h.eq] + _ = b*star (u:A) := by simp [←mul_assoc] + +lemma mem_regularCommutant (θ : ℝ) {B : RegularOperator} + (hB : B∈Set.centralizer ({(regularU:RegularOperator),(regularV (rotationScalar θ):RegularOperator)} : Set RegularOperator)) : + B∈regularCommutant θ := by + apply (StarSubalgebra.mem_centralizer_iff ℂ).mpr + intro a ha + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at ha + rcases ha with rfl|rfl + · exact ⟨hB _ (by simp), (commute_star_unitary regularU B (hB _ (by simp))).eq⟩ + · exact ⟨hB _ (by simp), (commute_star_unitary (regularV (rotationScalar θ)) B (hB _ (by simp))).eq⟩ + +lemma regularAlgebra_of_commutes (θ : ℝ) (A : CircleFiberOperator) + (hA : ∀ B∈fiberCommutant θ,Commute A B) : + fiberConjugacy.symm A∈regularAlgebra (rotationScalar θ) := by + intro B hB + have hh : Commute A (fiberConjugacy B) := hA _ ⟨B,mem_regularCommutant θ hB,rfl⟩ + apply fiberConjugacy.injective + change fiberConjugacy (B*fiberConjugacy.symm A)=fiberConjugacy (fiberConjugacy.symm A*B) + simpa only [map_mul,fiberConjugacy.apply_symm_apply] using hh.symm.eq + +lemma fiber_commutes_of_regularAlgebra (θ : ℝ) (p : RegularOperator) + (hp : p∈regularAlgebra (rotationScalar θ)) : + ∀ B∈fiberCommutant θ,Commute (fiberConjugacy p) B := by + rintro B ⟨b,hb,rfl⟩ + have hb' : b∈Set.centralizer ({(regularU:RegularOperator),(regularV (rotationScalar θ):RegularOperator)} : Set RegularOperator) := + fun a ha => ((StarSubalgebra.mem_centralizer_iff ℂ).mp hb a ha).1 + change fiberConjugacy p*fiberConjugacy b=fiberConjugacy b*fiberConjugacy p + simpa only [map_mul] using congrArg fiberConjugacy (hp b hb').symm + +lemma realPi_fiberCommutant (θ : ℝ) (g : RealBorel) : + ∀ B∈fiberCommutant θ,Commute (realPi (θ:CircleX) g) B := by + rintro B ⟨b,hb,rfl⟩ + apply realPi_commutes + intro f + change Commute (continuousPiHom (θ:CircleX) (complexCircleMap f)) (fiberConjugacy b) + rw [circle_cfc_hom (continuousPiHom (θ:CircleX)) (continuous_continuousPiHom _) f] + have hv := (StarSubalgebra.mem_centralizer_iff ℂ).mp hb (regularV (rotationScalar θ)) (by simp) + have h1 : Commute (continuousPi (θ:CircleX) (fourier 1)) (fiberConjugacy b) := by + rw [←fiberConjugacy_V] + change fiberConjugacy _*fiberConjugacy b=fiberConjugacy b*fiberConjugacy _ + simpa only [map_mul] using congrArg fiberConjugacy hv.1 + have h2 : Commute (star (continuousPi (θ:CircleX) (fourier 1))) (fiberConjugacy b) := by + have conjugacy_star (operator : RegularOperator) : + fiberConjugacy (star operator) = star (fiberConjugacy operator) := + fiberConjugacy.map_star' operator + rw [←fiberConjugacy_V,←conjugacy_star] + change fiberConjugacy _*fiberConjugacy b=fiberConjugacy b*fiberConjugacy _ + simpa only [map_mul] using congrArg fiberConjugacy hv.2 + exact h1.cfc h2 (circleFunction f) + +def fiberVacuum : CircleFiberL2 := circleFiberBasis.repr.symm regularVacuum +lemma fiber_vacuum_trace (θ : ℝ) (A : CircleFiberOperator) + (hA : ∀ B∈fiberCommutant θ,Commute A B) : ‖star A fiberVacuum‖=‖A fiberVacuum‖ := by + have h := regular_adjoint_norm_vacuum (rotationScalar θ) (regularAlgebra_of_commutes θ A hA) + have h1 : A fiberVacuum = circleFiberBasis.repr.symm (fiberConjugacy.symm A regularVacuum) := by + simpa only [fiberConjugacy.apply_symm_apply,fiberVacuum] using fiberConjugacy_apply (fiberConjugacy.symm A) regularVacuum + have h2 : star A fiberVacuum = circleFiberBasis.repr.symm (star (fiberConjugacy.symm A) regularVacuum) := by + have conjugacy_star (operator : RegularOperator) : + fiberConjugacy (star operator) = star (fiberConjugacy operator) := + fiberConjugacy.map_star' operator + simpa only [conjugacy_star,fiberConjugacy.apply_symm_apply,fiberVacuum] using fiberConjugacy_apply (star (fiberConjugacy.symm A)) regularVacuum + rw [h1,h2,LinearIsometryEquiv.norm_map,LinearIsometryEquiv.norm_map] + exact h +lemma fiber_vacuum_faithful (θ : ℝ) (A : CircleFiberOperator) + (hA : ∀ B∈fiberCommutant θ,Commute A B) (hz : A fiberVacuum=0) : A=0 := by + have h1 := fiberConjugacy_apply (fiberConjugacy.symm A) regularVacuum + simp only [fiberConjugacy.apply_symm_apply] at h1 + have h2 : fiberConjugacy.symm A regularVacuum=0 := by + apply circleFiberBasis.repr.symm.injective + simpa only [map_zero] using h1.symm.trans hz + have h3 := regular_vacuum_separating (rotationScalar θ) (regularAlgebra_of_commutes θ A hA) h2 + simpa only [fiberConjugacy.apply_symm_apply,map_zero] using congrArg fiberConjugacy h3 + + +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/Transport.lean b/lean/OAI/Analysis/RotationWeights/Transport.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd1496c9ce054e3e5c7c5d123f04cb58d6042478 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/Transport.lean @@ -0,0 +1,321 @@ +import OAI.Analysis.RotationWeights.Polar + +namespace OAI + +noncomputable section + +namespace CircleTransport + +universe uH + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +section +variable {H : Type uH} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] +abbrev Op := H →L[ℂ] H + +lemma commute_projection_of_reducing (P : Submodule ℂ H) [CompleteSpace P] + (B : Op (H := H)) (hB : ∀ x ∈ P, B x ∈ P) + (hs : ∀ x ∈ P, (star B) x ∈ P) : Commute P.starProjection B := by + have ho (x : H) (hx : x∈Pᗮ) : B x∈Pᗮ := by + apply (Submodule.mem_orthogonal _ _).mpr + intro y hy + rw [← ContinuousLinearMap.adjoint_inner_left] + exact (Submodule.mem_orthogonal _ _).mp hx _ (hs y hy) + ext x + change P.starProjection (B x) = B (P.starProjection x) + have hx : x=P.starProjection x+(x-P.starProjection x) := by abel + conv_lhs => rw [hx] + rw [map_add,map_add, + P.starProjection_mem_subspace_eq_self ⟨_,hB _ (P.starProjection_apply_mem x)⟩, + P.starProjection_apply_eq_zero_iff.mpr (ho _ (P.sub_starProjection_mem_orthogonal x)),add_zero] + +omit [CompleteSpace H] in +lemma invariant_closure (P : Submodule ℂ H) (B : Op (H := H)) + (hB : ∀ x∈P, B x∈P) : ∀ x∈P.topologicalClosure, B x∈P.topologicalClosure := by + intro x hx + apply closure_minimal (s := (P : Set H)) _ + ((Submodule.isClosed_topologicalClosure P).preimage B.continuous) hx + intro y hy + exact P.le_topologicalClosure (hB y hy) + +lemma commutes_star_centralizer (C : StarSubalgebra ℂ (Op (H := H))) + {A : Op (H := H)} (hA : ∀ B∈C, Commute A B) : ∀ B∈C, Commute (star A) B := by + intro B hB + have h := (hA (star B) (star_mem hB)).star_star + simpa using h + + +lemma projection_mem_centralizer (C : StarSubalgebra ℂ (Op (H := H))) + (P : Submodule ℂ H) [CompleteSpace P] + (hP : ∀ B∈C, ∀ x∈P, B x∈P) : ∀ B∈C, Commute P.starProjection B := by + intro B hB + exact commute_projection_of_reducing P B (hP B hB) (hP (star B) (star_mem hB)) + +lemma polar_mem_centralizer (C : StarSubalgebra ℂ (Op (H := H))) + {A : Op (H := H)} (hA : ∀ B∈C, Commute A B) : + ∀ B∈C, Commute (CirclePolar.polar A) B := by + intro B hB + exact CirclePolar.commute_polar (hA B hB) (commutes_star_centralizer C hA B hB) + +lemma exists_cutoff_intersection (C : StarSubalgebra ℂ (Op (H := H))) + (v : H) (htrace : ∀ A : Op (H := H), (∀ B∈C, Commute A B) → ‖star A v‖=‖A v‖) + (P : Submodule ℂ H) [CompleteSpace P] (hP : ∀ B∈C, Commute P.starProjection B) + (hPv : P.starProjection v≠0) (E : ℕ → Submodule ℂ H) [∀ n, CompleteSpace (E n)] + (hE : ∀ n, ∀ B∈C, Commute (E n).starProjection B) + (hlim : Filter.Tendsto (fun n => (E n).starProjection v) Filter.atTop (nhds v)) : + ∃ n, ∃ x : H, x∈P ∧ x∈E n ∧ x≠0 := by + have ht : Filter.Tendsto (fun n => ‖(E n)ᗮ.starProjection v‖) Filter.atTop (nhds 0) := by + simp_rw [Submodule.starProjection_orthogonal,sub_apply,ContinuousLinearMap.id_apply] + simpa using ((tendsto_const_nhds (x := v)).sub hlim).norm + have he : ∀ᶠ n in Filter.atTop, ‖(E n)ᗮ.starProjection v‖ < ‖P.starProjection v‖ := + (tendsto_order.1 ht).2 _ (norm_pos_iff.mpr hPv) + obtain ⟨n,hn⟩ := he.exists + refine ⟨n,CirclePolar.exists_intersection_of_norm_lt P (E n) v ?_ hn⟩ + apply htrace + apply polar_mem_centralizer C + intro B hB + apply Commute.mul_left _ (hP B hB) + rw [Submodule.starProjection_orthogonal] + exact (Commute.one_left B).sub_left (hE n B hB) + +def transportedRange (D P : Submodule ℂ H) (A : D →ₗ[ℂ] H) : Submodule ℂ H := + ((P.comap D.subtype).map A).topologicalClosure + +instance (D P : Submodule ℂ H) (A : D →ₗ[ℂ] H) : CompleteSpace (transportedRange D P A) := + inferInstanceAs (CompleteSpace ((P.comap D.subtype).map A).topologicalClosure) + +omit [CompleteSpace H] in +lemma transportedRange_invariant (D P : Submodule ℂ H) (A : D →ₗ[ℂ] H) + (T S : Op (H := H)) (hT : ∀ x∈P, T x∈P) (hD : ∀ x∈D, T x∈D) + (hAS : ∀ x : D, A ⟨T x,hD x x.property⟩ = S (A x)) : + ∀ x∈transportedRange D P A, S x∈transportedRange D P A := by + apply invariant_closure + rintro y ⟨x,hx,rfl⟩ + refine ⟨⟨T x,hD x x.property⟩,hT x hx,?_⟩ + exact hAS x + +lemma transportedRange_mem_centralizer (C : StarSubalgebra ℂ (Op (H := H))) + (D P : Submodule ℂ H) (A : D →ₗ[ℂ] H) + (hP : ∀ B∈C, ∀ x∈P, B x∈P) + (hD : ∀ B∈C, ∀ x∈D, B x∈D) + (hA : ∀ B, ∀ hB : B∈C, ∀ x : D, A ⟨B x,hD B hB x x.property⟩ = B (A x)) : + ∀ B∈C, Commute (transportedRange D P A).starProjection B := by + apply projection_mem_centralizer + intro B hB + exact transportedRange_invariant D P A B B (hP B hB) (hD B hB) (hA B hB) + +omit [CompleteSpace H] in +lemma transportedRange_ne_bot (D P : Submodule ℂ H) (A : D →ₗ[ℂ] H) + (hA : Function.Injective A) (E : Submodule ℂ H) (hE : E≤D) + (x : H) (hxP : x∈P) (hxE : x∈E) (hx0 : x≠0) : transportedRange D P A ≠ ⊥ := by + let z : D := ⟨x,hE hxE⟩ + have hz : A z ∈ transportedRange D P A := + Submodule.le_topologicalClosure _ ⟨z,hxP,rfl⟩ + intro hh + rw [hh,Submodule.mem_bot] at hz + have : z=0 := hA (by simpa using hz) + exact hx0 (congrArg Subtype.val this) + +omit [CompleteSpace H] in +lemma transportedRange_ne_top (D P : Submodule ℂ H) (A : D →ₗ[ℂ] H) + (hsym : ∀ x y : D, inner ℂ (A x) (y : H) = inner ℂ (x : H) (A y)) + (η : H) (hη : η∈Pᗮ) (hη0 : η≠0) (hηA : η∈LinearMap.range A) : + transportedRange D P A ≠ ⊤ := by + obtain ⟨χ,hχ⟩ := hηA + have hχ0 : (χ : H)≠0 := by + intro h + have : χ=0 := Subtype.ext h + exact hη0 (hχ.symm.trans (by rw [this,map_zero])) + have horth : (χ : H)∈(transportedRange D P A)ᗮ := by + rw [transportedRange,Submodule.orthogonal_closure] + apply (Submodule.mem_orthogonal _ _).mpr + rintro y ⟨x,hx,rfl⟩ + rw [hsym,hχ] + exact (Submodule.mem_orthogonal _ _).mp hη _ hx + intro hh + rw [hh,Submodule.top_orthogonal_eq_bot,Submodule.mem_bot] at horth + exact hχ0 horth + + +omit [CompleteSpace H] in +lemma projection_ne_zero_of_ne_bot (P : Submodule ℂ H) [CompleteSpace P] (hP : P≠⊥) : + P.starProjection≠0 := by + intro hh + apply hP + have h := Submodule.range_starProjection P + rw [hh] at h + simpa using h.symm + +omit [CompleteSpace H] in +lemma projection_ne_one_of_ne_top (P : Submodule ℂ H) [CompleteSpace P] (hP : P≠⊤) : + P.starProjection≠1 := by + intro hh + apply hP + apply top_unique + intro x _ + rw [← Submodule.starProjection_eq_self_iff,hh] + rfl + +omit [CompleteSpace H] in +lemma invariant_projection (P : Submodule ℂ H) [CompleteSpace P] (S : Op (H := H)) + (hS : ∀ x∈P, S x∈P) : (1-P.starProjection)*S*P.starProjection=0 := by + ext x + change S (P.starProjection x)-P.starProjection (S (P.starProjection x))=0 + exact sub_eq_zero.mpr (Submodule.starProjection_eq_self_iff.mpr (hS _ (P.starProjection_apply_mem x))).symm + +theorem affiliated_transport (C : StarSubalgebra ℂ (Op (H := H))) (v : H) + (htrace : ∀ A : Op (H := H), (∀ B∈C, Commute A B) → ‖star A v‖=‖A v‖) + (hfaith : ∀ A : Op (H := H), (∀ B∈C, Commute A B) → A v=0 → A=0) + (D : Submodule ℂ H) (A : D →ₗ[ℂ] H) (hAinj : Function.Injective A) + (hsym : ∀ x y : D, inner ℂ (A x) (y : H)=inner ℂ (x : H) (A y)) + (hD : ∀ B∈C, ∀ x∈D, B x∈D) + (hA : ∀ B, ∀ hB : B∈C, ∀ x : D, A ⟨B x,hD B hB x x.property⟩=B (A x)) + (E F : ℕ → Submodule ℂ H) [∀ n, CompleteSpace (E n)] [∀ n, CompleteSpace (F n)] + (hE : ∀ n, ∀ B∈C, Commute (E n).starProjection B) + (hF : ∀ n, ∀ B∈C, Commute (F n).starProjection B) + (hED : ∀ n, E n≤D) (hFA : ∀ n, F n≤LinearMap.range A) + (hElim : Filter.Tendsto (fun n => (E n).starProjection v) Filter.atTop (nhds v)) + (hFlim : Filter.Tendsto (fun n => (F n).starProjection v) Filter.atTop (nhds v)) + (P : Submodule ℂ H) [CompleteSpace P] (hPC : ∀ B∈C, Commute P.starProjection B) + (hP0 : P≠⊥) (hP1 : P≠⊤) + (T S : Op (H := H)) (hTP : ∀ x∈P, T x∈P) (hTD : ∀ x∈D, T x∈D) + (hAS : ∀ x : D, A ⟨T x,hTD x x.property⟩=S (A x)) : + ∃ q : Op (H := H), IsStarProjection q ∧ (∀ B∈C, Commute q B) ∧ + q≠0 ∧ q≠1 ∧ (1-q)*S*q=0 := by + have hP (B : Op (H := H)) (hB : B∈C) (x : H) (hx : x∈P) : B x∈P := by + rw [← Submodule.starProjection_eq_self_iff] + have hh := DFunLike.congr_fun (hPC B hB).eq x + change P.starProjection (B x)=B (P.starProjection x) at hh + rw [hh,Submodule.starProjection_eq_self_iff.mpr hx] + have hPv : P.starProjection v≠0 := by + intro hh + exact projection_ne_zero_of_ne_bot P hP0 (hfaith _ hPC hh) + have hQc : ∀ B∈C, Commute Pᗮ.starProjection B := by + intro B hB + rw [Submodule.starProjection_orthogonal] + exact (Commute.one_left B).sub_left (hPC B hB) + have hQ0 : Pᗮ ≠ ⊥ := by + intro hh + have hh' := congrArg (fun Q : Submodule ℂ H => Qᗮ) hh + rw [Submodule.orthogonal_orthogonal,Submodule.bot_orthogonal_eq_top] at hh' + exact hP1 hh' + have hQv : Pᗮ.starProjection v≠0 := by + intro hh + exact projection_ne_zero_of_ne_bot Pᗮ hQ0 (hfaith _ hQc hh) + obtain ⟨n,x,hxP,hxE,hx0⟩ := exists_cutoff_intersection C v htrace P hPC hPv E hE hElim + obtain ⟨m,η,hηP,hηF,hη0⟩ := exists_cutoff_intersection C v htrace Pᗮ hQc hQv F hF hFlim + let W := transportedRange D P A + refine ⟨W.starProjection,?_,transportedRange_mem_centralizer C D P A hP hD hA, + projection_ne_zero_of_ne_bot W (transportedRange_ne_bot D P A hAinj (E n) (hED n) x hxP hxE hx0), + projection_ne_one_of_ne_top W (transportedRange_ne_top D P A hsym η hηP hη0 (hFA m hηF)), + invariant_projection W S (transportedRange_invariant D P A T S hTP hTD hAS)⟩ + exact isStarProjection_starProjection +end +open ContinuousLinearMap +variable {H : Type uH} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] + +def fractionMap (b c : Op (H:=H)) (hb : Function.Injective b) : + LinearMap.range b.toLinearMap →ₗ[ℂ] H := + c.toLinearMap.comp (LinearEquiv.ofInjective b.toLinearMap hb).symm.toLinearMap +omit [CompleteSpace H] in +lemma fractionMap_apply (b c : Op (H:=H)) (hb : Function.Injective b) (x : H) : + fractionMap b c hb ⟨b x,⟨x,rfl⟩⟩=c x := by + change c ((LinearEquiv.ofInjective b.toLinearMap hb).symm ((LinearEquiv.ofInjective b.toLinearMap hb) x))=c x + rw [LinearEquiv.symm_apply_apply] +omit [CompleteSpace H] in +lemma fractionMap_injective (b c : Op (H:=H)) (hb : Function.Injective b) (hc : Function.Injective c) : + Function.Injective (fractionMap b c hb) := hc.comp (LinearEquiv.ofInjective b.toLinearMap hb).symm.injective +omit [CompleteSpace H] in +lemma fractionMap_range (b c : Op (H:=H)) (hb : Function.Injective b) : + LinearMap.range (fractionMap b c hb)=LinearMap.range c.toLinearMap := by + ext y + constructor + · rintro ⟨x,rfl⟩ + exact ⟨_,rfl⟩ + · rintro ⟨x,rfl⟩ + exact ⟨⟨b x,⟨x,rfl⟩⟩,fractionMap_apply b c hb x⟩ +lemma fractionMap_symmetric (b c : Op (H:=H)) (hb : Function.Injective b) + (hsb : IsSelfAdjoint b) (hsc : IsSelfAdjoint c) (hbc : Commute b c) + (x y : LinearMap.range b.toLinearMap) : + inner ℂ (fractionMap b c hb x) (y:H)=inner ℂ (x:H) (fractionMap b c hb y) := by + obtain ⟨u,hu⟩ := x.property + obtain ⟨v,hv⟩ := y.property + have hx : x=⟨b u,⟨u,rfl⟩⟩ := Subtype.ext hu.symm + have hy : y=⟨b v,⟨v,rfl⟩⟩ := Subtype.ext hv.symm + rw [hx,hy,fractionMap_apply,fractionMap_apply] + have hb' := ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mp hsb + have hc' := ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mp hsc + change inner ℂ (c u) (b v)=inner ℂ (b u) (c v) + change inner ℂ (c.toLinearMap u) (b.toLinearMap v)=inner ℂ (b.toLinearMap u) (c.toLinearMap v) + rw [hc',hb'] + exact congrArg (fun z => inner ℂ u z) (DFunLike.congr_fun hbc.eq v).symm + +omit [CompleteSpace H] in +lemma fraction_domain_map (b T L : Op (H:=H)) (h : T*b=b*L) : + ∀ x∈LinearMap.range b.toLinearMap,T x∈LinearMap.range b.toLinearMap := by + rintro x ⟨y,rfl⟩ + exact ⟨L y,(DFunLike.congr_fun h y).symm⟩ +omit [CompleteSpace H] in +lemma fractionMap_intertwine (b c T S L : Op (H:=H)) (hb : Function.Injective b) + (hT : T*b=b*L) (hS : S*c=c*L) (x : LinearMap.range b.toLinearMap) : + fractionMap b c hb ⟨T x,fraction_domain_map b T L hT x x.property⟩=S (fractionMap b c hb x) := by + obtain ⟨y,hy⟩ := x.property + have hx : x=⟨b y,⟨y,rfl⟩⟩ := Subtype.ext hy.symm + subst x + rw [fractionMap_apply] + have he : (⟨T (b y),fraction_domain_map b T L hT _ ⟨y,rfl⟩⟩ : LinearMap.range b.toLinearMap)=⟨b (L y),⟨L y,rfl⟩⟩ := + Subtype.ext (DFunLike.congr_fun hT y) + rw [he,fractionMap_apply] + exact (DFunLike.congr_fun hS y).symm + +theorem bounded_fraction_transport (C : StarSubalgebra ℂ (Op (H:=H))) (v : H) + (htrace : ∀ A : Op (H:=H),(∀ B∈C,Commute A B)→‖star A v‖=‖A v‖) + (hfaith : ∀ A : Op (H:=H),(∀ B∈C,Commute A B)→A v=0→A=0) + (b c : Op (H:=H)) (hb : Function.Injective b) (hc : Function.Injective c) + (hsb : IsSelfAdjoint b) (hsc : IsSelfAdjoint c) (hbc : Commute b c) + (hbC : ∀ B∈C,Commute b B) (hcC : ∀ B∈C,Commute c B) + (E F : ℕ → Submodule ℂ H) [∀ n,CompleteSpace (E n)] [∀ n,CompleteSpace (F n)] + (hE : ∀ n,∀ B∈C,Commute (E n).starProjection B) + (hF : ∀ n,∀ B∈C,Commute (F n).starProjection B) + (hEb : ∀ n,E n≤LinearMap.range b.toLinearMap) + (hFc : ∀ n,F n≤LinearMap.range c.toLinearMap) + (hElim : Filter.Tendsto (fun n => (E n).starProjection v) Filter.atTop (nhds v)) + (hFlim : Filter.Tendsto (fun n => (F n).starProjection v) Filter.atTop (nhds v)) + (P : Submodule ℂ H) [CompleteSpace P] (hPC : ∀ B∈C,Commute P.starProjection B) + (hP0 : P≠⊥) (hP1 : P≠⊤) + (T S L : Op (H:=H)) (hTP : ∀ x∈P,T x∈P) (hT : T*b=b*L) (hS : S*c=c*L) : + ∃ q : Op (H:=H),IsStarProjection q ∧ (∀ B∈C,Commute q B) ∧ q≠0 ∧ q≠1 ∧ (1-q)*S*q=0 := by + apply affiliated_transport C v htrace hfaith (LinearMap.range b.toLinearMap) (fractionMap b c hb) + (fractionMap_injective b c hb hc) (fractionMap_symmetric b c hb hsb hsc hbc) + (fun B hB => fraction_domain_map b B B (hbC B hB).symm.eq) + (fun B hB x => fractionMap_intertwine b c B B B hb (hbC B hB).symm.eq (hcC B hB).symm.eq x) + E F hE hF hEb _ hElim hFlim P hPC hP0 hP1 T S hTP + (fraction_domain_map b T L hT) (fractionMap_intertwine b c T S L hb hT hS) + intro n + rw [fractionMap_range] + exact hFc n + + +end CircleTransport + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/TrialBounds.lean b/lean/OAI/Analysis/RotationWeights/TrialBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..d50cfe73037b9fd9150064d84c8fbe8bd86152e0 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/TrialBounds.lean @@ -0,0 +1,381 @@ +import OAI.Analysis.RotationWeights.SamplingBounds + +namespace OAI + +noncomputable section + +namespace CircleSampling + +universe uι uX uκ uτ + +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace +open MeasureTheory Set Filter Topology +open scoped BigOperators ComplexConjugate +open MeasureTheory Set Filter +open scoped BigOperators ENNReal +open Filter Set +open scoped Topology +open Filter Set +open scoped Topology + +open Set MeasureTheory +open scoped BigOperators ENNReal Classical +section + +lemma product_many_failures_bound {ι : Type uι} {X : ι → Type uX} + [∀ i, MeasurableSpace (X i)] (μ : ∀ i, Measure (X i)) + [∀ i, IsProbabilityMeasure (μ i)] (I : Finset ι) (A : ∀ i, Set (X i)) + (hA : ∀ i, MeasurableSet (A i)) (q : ℕ) (p : ℝ≥0∞) + (hp : ∀ i∈I, μ i (A i) ≤ p) : + Measure.infinitePi μ {x | q ≤ (I.filter fun i ↦ x i ∈ A i).card} ≤ + (I.card.choose q : ℝ≥0∞) * p^q := by + classical + let S := I.powersetCard q + have hcover : {x | q ≤ (I.filter fun i ↦ x i∈A i).card} ⊆ + ⋃ J∈S, Set.pi (J : Set ι) A := by + intro x hx + obtain ⟨J,hJI,hJq⟩ := Finset.exists_subset_card_eq hx + refine mem_iUnion.mpr ⟨J,mem_iUnion.mpr ⟨?_,?_⟩⟩ + · exact Finset.mem_powersetCard.mpr ⟨hJI.trans (Finset.filter_subset _ _),hJq⟩ + · intro i hi + exact (Finset.mem_filter.mp (hJI hi)).2 + calc + Measure.infinitePi μ {x | q ≤ (I.filter fun i ↦ x i ∈ A i).card} ≤ + Measure.infinitePi μ (⋃ J∈S, Set.pi (J : Set ι) A) := measure_mono hcover + _ ≤ ∑ J∈S, Measure.infinitePi μ (Set.pi (J : Set ι) A) := measure_biUnion_finset_le _ _ + _ = ∑ J∈S, ∏ i∈J, μ i (A i) := by + apply Finset.sum_congr rfl + intro J hJ + exact Measure.infinitePi_pi μ (fun i _ ↦ hA i) + _ ≤ ∑ _J∈S, p^q := by + apply Finset.sum_le_sum + intro J hJ + obtain ⟨hJI,hJq⟩ := Finset.mem_powersetCard.mp hJ + calc + (∏ i∈J, μ i (A i)) ≤ ∏ _i∈J, p := Finset.prod_le_prod fun i hi ↦ hp i (hJI hi) + _ = p^q := by simp [hJq] + _ = _ := by simp [S,Finset.card_powersetCard,nsmul_eq_mul] + +lemma product_many_failures_exp_bound {ι : Type uι} {X : ι → Type uX} + [∀ i, MeasurableSpace (X i)] (μ : ∀ i, Measure (X i)) + [∀ i, IsProbabilityMeasure (μ i)] (I : Finset ι) (A : ∀ i, Set (X i)) + (hA : ∀ i, MeasurableSet (A i)) (q : ℕ) (p : ℝ≥0∞) + (hp : ∀ i∈I, μ i (A i) ≤ p) : + Measure.infinitePi μ {x | q ≤ (I.filter fun i ↦ x i ∈ A i).card} ≤ + (2 : ℝ≥0∞)^I.card * p^q := by + apply (product_many_failures_bound μ I A hA q p hp).trans + gcongr + exact_mod_cast Nat.choose_le_two_pow I.card q + +end +open Filter Set +open scoped Topology +section + +def phaseUnionBound (m : ℕ) : ℝ := + 3*(2*(10:ℝ)^((9:ℝ)/10)*(m:ℝ)^(-(11:ℝ)/200))^m + +lemma phase_failure_count_lower (m : ℕ) : (9:ℝ)/10*m ≤ ((m-m/20:ℕ):ℝ) := by + have hle : m/20 ≤ m := Nat.div_le_self _ _ + have hd : ((m/20:ℕ):ℝ) ≤ (m:ℝ)/20 := Nat.cast_div_le + rw [Nat.cast_sub hle] + nlinarith [show (0:ℝ) ≤ m by positivity] + +lemma phase_union_numeric {m : ℕ} (hm : 0 < m) + (hp : 10*(m:ℝ)^(-(19:ℝ)/20) ≤ 1) : + 3*(m:ℝ)^((4:ℝ)/5*m)*2^m*(10*(m:ℝ)^(-(19:ℝ)/20))^(m-m/20) ≤ + phaseUnionBound m := by + have hx : (0:ℝ) < m := Nat.cast_pos.mpr hm + have hp0 : 0 < 10*(m:ℝ)^(-(19:ℝ)/20) := by positivity + have hpow : (10*(m:ℝ)^(-(19:ℝ)/20))^(m-m/20) ≤ + (10*(m:ℝ)^(-(19:ℝ)/20))^((9:ℝ)/10*m) := by + rw [← Real.rpow_natCast] + exact Real.rpow_le_rpow_of_exponent_ge hp0 hp (phase_failure_count_lower m) + calc + _ ≤ 3*(m:ℝ)^((4:ℝ)/5*m)*2^m*(10*(m:ℝ)^(-(19:ℝ)/20))^((9:ℝ)/10*m) := by gcongr + _ = phaseUnionBound m := by + unfold phaseUnionBound + rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 10) (Real.rpow_nonneg hx.le _)] + rw [← Real.rpow_mul hx.le, ← Real.rpow_natCast (2:ℝ) m] + rw [← Real.rpow_natCast (2*(10:ℝ)^((9:ℝ)/10)*(m:ℝ)^(-(11:ℝ)/200)) m] + rw [Real.mul_rpow (by positivity) (by positivity), Real.mul_rpow (by positivity) (by positivity)] + rw [← Real.rpow_mul (by norm_num : (0:ℝ) ≤ 10), ← Real.rpow_mul hx.le] + have he : (m:ℝ)^((4:ℝ)/5*m)*(m:ℝ)^(-(19:ℝ)/20*((9:ℝ)/10*m)) = + (m:ℝ)^(-(11:ℝ)/200*m) := by + rw [← Real.rpow_add hx] + congr 1 + ring + calc + _ = 3*(2:ℝ)^(m:ℝ)*(10:ℝ)^((9:ℝ)/10*m)* + ((m:ℝ)^((4:ℝ)/5*m)*(m:ℝ)^(-(19:ℝ)/20*((9:ℝ)/10*m))) := by ring + _ = _ := by rw [he]; ring + +lemma tendsto_phaseUnionBound : Tendsto phaseUnionBound atTop (𝓝 0) := by + have hx : Tendsto (fun m : ℕ => (m:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have hb : Tendsto (fun m : ℕ => 2*(10:ℝ)^((9:ℝ)/10)*(m:ℝ)^(-(11:ℝ)/200)) atTop (𝓝 0) := by + simpa only [mul_zero, neg_div, Function.comp_apply] using (tendsto_rpow_neg_atTop (by norm_num : (0:ℝ) < 11/200)).comp hx |>.const_mul (2*(10:ℝ)^((9:ℝ)/10)) + apply squeeze_zero' (Eventually.of_forall (fun m => by unfold phaseUnionBound; positivity)) + (g := fun m => 3*(1/2:ℝ)^m) + · filter_upwards [hb.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1/2))] with m hm + unfold phaseUnionBound + gcongr + · simpa only [mul_zero] using (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0:ℝ) ≤ 1/2) + (by norm_num : (1/2:ℝ) < 1)).const_mul 3 + +lemma eventually_phase_failure_small : ∀ᶠ m : ℕ in atTop, 10*(m:ℝ)^(-(19:ℝ)/20) ≤ 1 := by + have hx : Tendsto (fun m : ℕ => (m:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have hb : Tendsto (fun m : ℕ => 10*(m:ℝ)^(-(19:ℝ)/20)) atTop (𝓝 0) := by + simpa only [mul_zero, neg_div, Function.comp_apply] using (tendsto_rpow_neg_atTop (by norm_num : (0:ℝ) < 19/20)).comp hx |>.const_mul 10 + filter_upwards [hb.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1))] with m hm + exact hm.le +open ContinuousCircleWeight.Sampling +open scoped Classical ENNReal + +lemma phase_few_successes_subset (m : ℕ) (b c : ℝ) : + {γ : Fin m → ℝ | (((Finset.univ.filter fun i => γ i ∉ phaseFailure b c).card:ℕ):ℝ) < (m:ℝ)/20} ⊆ + {γ | m-m/20 ≤ (Finset.univ.filter fun i => γ i ∈ phaseFailure b c).card} := by + intro γ hγ + have hsum := Finset.card_filter_add_card_filter_not (s:=Finset.univ) + (fun i : Fin m => γ i ∈ phaseFailure b c) + simp only [Finset.card_univ,Fintype.card_fin] at hsum + have hle : (Finset.univ.filter fun i : Fin m => γ i ∉ phaseFailure b c).card ≤ m/20 := by + apply (Nat.le_div_iff_mul_le (by norm_num : 0 < 20)).mpr + have hreal : ((Finset.univ.filter fun i : Fin m => γ i ∉ phaseFailure b c).card:ℝ)*20 ≤ (m:ℝ) := by + change ((Finset.univ.filter fun i : Fin m => γ i ∉ phaseFailure b c).card:ℝ) < (m:ℝ)/20 at hγ + linarith + exact_mod_cast hreal + change m-m/20 ≤ _ + omega + +lemma phase_cover_union_bound {m K : ℕ} (hm : 0 < m) (hK : 0 < K) + (hp : 10*(m:ℝ)^(-(19:ℝ)/20) ≤ 1) (S : Finset ℤ) + (hS : (S.card:ℝ) ≤ 3*(m:ℝ)^((4:ℝ)/5*m)) + (hc : ∀ k∈S, ((m:ℝ)*K)/4 ≤ |(k:ℝ)|) : + Measure.pi (fun _ : Fin m => intervalLaw (1/((m:ℝ)*K)) (2/((m:ℝ)*K))) + {γ | ∃ k∈S, (((Finset.univ.filter fun i => γ i ∉ phaseFailure ((m:ℝ)^(-(19:ℝ)/20)) k).card:ℕ):ℝ) < (m:ℝ)/20} + ≤ ENNReal.ofReal (phaseUnionBound m) := by + let N : ℝ := (m:ℝ)*K + let b : ℝ := (m:ℝ)^(-(19:ℝ)/20) + let μ : Measure ℝ := intervalLaw (1/N) (2/N) + have hN : 0 < N := mul_pos (Nat.cast_pos.mpr hm) (Nat.cast_pos.mpr hK) + have hb : 0 ≤ b := Real.rpow_nonneg (Nat.cast_nonneg _) _ + let : IsProbabilityMeasure μ := intervalLaw_probability ((div_lt_div_iff_of_pos_right hN).mpr (by norm_num)) + let A (k : ℤ) : Set (Fin m → ℝ) := + {γ | m-m/20 ≤ (Finset.univ.filter fun i => γ i ∈ phaseFailure b k).card} + have hbound (k : ℤ) (hk : k∈S) : Measure.pi (fun _ : Fin m => μ) (A k) ≤ + (2:ℝ≥0∞)^m*(ENNReal.ofReal (10*b))^(m-m/20) := by + have he := product_many_failures_exp_bound (fun _ : Fin m => μ) Finset.univ + (fun _ => phaseFailure b k) (fun _ => measurableSet_phaseFailure _ _) (m-m/20) + (ENNReal.ofReal (10*b)) (fun _ _ => phase_failure_probability hN hb (hc k hk)) + simpa only [Measure.infinitePi_eq_pi,Finset.card_univ,Fintype.card_fin] using he + have hcover : {γ : Fin m → ℝ | ∃ k∈S, + (((Finset.univ.filter fun i => γ i ∉ phaseFailure b k).card:ℕ):ℝ) < (m:ℝ)/20} ⊆ ⋃ k∈S, A k := by + rintro γ ⟨k,hk,hγ⟩ + exact mem_iUnion.mpr ⟨k,mem_iUnion.mpr ⟨hk,phase_few_successes_subset m b k hγ⟩⟩ + change Measure.pi (fun _ : Fin m => μ) _ ≤ _ + calc + _ ≤ Measure.pi (fun _ : Fin m => μ) (⋃ k∈S, A k) := measure_mono hcover + _ ≤ ∑ k∈S, Measure.pi (fun _ : Fin m => μ) (A k) := measure_biUnion_finset_le _ _ + _ ≤ ∑ _k∈S, (2:ℝ≥0∞)^m*(ENNReal.ofReal (10*b))^(m-m/20) := + Finset.sum_le_sum hbound + _ = ENNReal.ofReal ((S.card:ℝ)*2^m*(10*b)^(m-m/20)) := by + simp only [Finset.sum_const,nsmul_eq_mul] + have he : ENNReal.ofReal ((S.card:ℝ)*2^m*(10*b)^(m-m/20)) = + (S.card:ℝ≥0∞)*2^m*(ENNReal.ofReal (10*b))^(m-m/20) := by + conv_lhs => rw [ENNReal.ofReal_mul (by positivity)] + conv_lhs => lhs; rw [ENNReal.ofReal_mul (by positivity)] + rw [ENNReal.ofReal_natCast,ENNReal.ofReal_pow (by norm_num : (0:ℝ) ≤ 2), + ENNReal.ofReal_ofNat,ENNReal.ofReal_pow (by positivity)] + rw [he,mul_assoc] + _ ≤ ENNReal.ofReal (3*(m:ℝ)^((4:ℝ)/5*m)*2^m*(10*b)^(m-m/20)) := by + apply ENNReal.ofReal_le_ofReal + gcongr + _ ≤ ENNReal.ofReal (phaseUnionBound m) := ENNReal.ofReal_le_ofReal (phase_union_numeric hm hp) +end +section +open ContinuousCircleWeight.Sampling +open MeasureTheory Set +lemma intervalLaw_ae_inner (a b : ℝ) : ∀ᵐ x ∂intervalLaw a b, x ∈ Ioo a b := by + have h : ∀ᵐ x ∂volume.restrict (Ioc a b), x ∈ Ioo a b := by + filter_upwards [ae_restrict_mem measurableSet_Ioc,ae_restrict_of_ae (volume.ae_ne b)] with x hx hxb + exact ⟨hx.1,hx.2.lt_of_ne hxb⟩ + exact Measure.ae_smul_measure h _ +lemma intervalLaw_ae_phase {a b c : ℝ} (hc : c ≠ 0) : + ∀ᵐ x ∂intervalLaw a b, ((c*x:ℝ):CircleX) ≠ 0 := by + have h : ∀ᵐ x ∂(volume : Measure ℝ), ∀ k : ℤ, x ≠ (k:ℝ)/c := + ae_all_iff.mpr fun k => volume.ae_ne _ + have h' := Measure.ae_smul_measure (ae_restrict_of_ae (s:=Ioc a b) h) (ENNReal.ofReal (b-a))⁻¹ + filter_upwards [h'] with x hx heq + obtain ⟨k,hk⟩ := (AddCircle.coe_eq_zero_iff 1).mp heq + apply hx k + apply (eq_div_iff hc).mpr + simpa [zsmul_eq_mul,mul_comm] using hk.symm +lemma pi_intervalLaw_ae_good {ι : Type uι} {κ : Type uκ} [Fintype ι] [Fintype κ] + {a b : ℝ} (hab : a < b) (c : κ → ℝ) (hc : ∀ n, c n ≠ 0) : + ∀ᵐ γ : ι → ℝ ∂Measure.pi (fun _ => intervalLaw a b), + (∀ i, γ i ∈ Ioo a b) ∧ ∀ n i, ((c n*γ i:ℝ):CircleX) ≠ 0 := by + let := intervalLaw_probability hab + have h1 : ∀ᵐ γ : ι → ℝ ∂Measure.pi (fun _ => intervalLaw a b), ∀ i, γ i ∈ Ioo a b := by + apply ae_all_iff.mpr + intro i + exact (measurePreserving_eval (fun _ : ι => intervalLaw a b) i).quasiMeasurePreserving.ae + (intervalLaw_ae_inner a b) + have h2 : ∀ᵐ γ : ι → ℝ ∂Measure.pi (fun _ => intervalLaw a b), ∀ n i, ((c n*γ i:ℝ):CircleX) ≠ 0 := by + apply ae_all_iff.mpr + intro n + apply ae_all_iff.mpr + intro i + exact (measurePreserving_eval (fun _ : ι => intervalLaw a b) i).quasiMeasurePreserving.ae + (intervalLaw_ae_phase (hc n)) + exact h1.and h2 +end +section +open ContinuousCircleWeight.Sampling MeasureTheory Set +lemma pi_intervalLaw_ae_all_integerPhases {ι : Type uι} [Fintype ι] + {a b : ℝ} (hab : a < b) : + ∀ᵐ γ : ι → ℝ ∂Measure.pi (fun _ => intervalLaw a b), + (∀ i, γ i ∈ Ioo a b) ∧ ∀ k : ℤ, k ≠ 0 → ∀ i, ((k*γ i:ℝ):CircleX) ≠ 0 := by + let := intervalLaw_probability hab + have h1 : ∀ᵐ γ : ι → ℝ ∂Measure.pi (fun _ => intervalLaw a b), ∀ i, γ i ∈ Ioo a b := by + apply ae_all_iff.mpr + intro i + exact (measurePreserving_eval (fun _ : ι => intervalLaw a b) i).quasiMeasurePreserving.ae (intervalLaw_ae_inner a b) + have h2 : ∀ᵐ γ : ι → ℝ ∂Measure.pi (fun _ => intervalLaw a b), ∀ k : ℤ, k ≠ 0 → ∀ i, ((k*γ i:ℝ):CircleX) ≠ 0 := by + apply ae_all_iff.mpr + intro k + by_cases hk : k=0 + · exact Filter.Eventually.of_forall (by simp [hk]) + apply ae_all_iff.mpr + intro _ + apply ae_all_iff.mpr + intro i + exact (measurePreserving_eval (fun _ : ι => intervalLaw a b) i).quasiMeasurePreserving.ae + (intervalLaw_ae_phase (by exact_mod_cast hk)) + exact h1.and h2 +end +open Set MeasureTheory +open scoped ENNReal Classical +section +lemma finite_threshold_bound {X : Type uX} {τ : Type uτ} [MeasurableSpace X] [Fintype τ] + (μ : Measure X) [IsProbabilityMeasure μ] (E : τ → X → ℝ) + (hE0 : ∀ t x, 0 ≤ E t x) (hEi : ∀ t, Integrable (E t) μ) + {ε δ : ℝ} (hδ : 0 < δ) (hE : ∀ t, ∫ x, E t x ∂μ ≤ ε) : + μ {x | ∃ t, δ ≤ E t x} ≤ ENNReal.ofReal ((Fintype.card τ:ℝ)*(ε/δ)) := by + have hb (t : τ) : μ {x | δ ≤ E t x} ≤ ENNReal.ofReal (ε/δ) := by + have h := (mul_meas_ge_le_integral_of_nonneg (Filter.Eventually.of_forall (hE0 t)) (hEi t) δ).trans (hE t) + have h' : μ.real {x | δ ≤ E t x} ≤ ε/δ := (le_div_iff₀ hδ).mpr (by simpa only [mul_comm] using h) + rw [← ENNReal.ofReal_toReal (measure_ne_top _ _)] + exact ENNReal.ofReal_le_ofReal h' + calc + _ = μ (⋃ t, {x | δ ≤ E t x}) := by congr 1; ext x; simp + _ ≤ ∑ t, μ {x | δ ≤ E t x} := measure_iUnion_fintype_le _ _ + _ ≤ ∑ _t : τ, ENNReal.ofReal (ε/δ) := Finset.sum_le_sum (fun t _ => hb t) + _ = _ := by simp [ENNReal.ofReal_mul (Nat.cast_nonneg _),nsmul_eq_mul] + +lemma exists_good_finite_family {X : Type uX} {τ : Type uτ} [MeasurableSpace X] [Fintype τ] + (μ : Measure X) [IsProbabilityMeasure μ] (E : τ → X → ℝ) + (hE0 : ∀ t x, 0 ≤ E t x) (hEi : ∀ t, Integrable (E t) μ) + {ε δ B : ℝ} (hδ : 0 < δ) (hB : 0 ≤ B) + (hE : ∀ t, ∫ x, E t x ∂μ ≤ ε) (bad : Set X) (hbad : μ bad ≤ ENNReal.ofReal B) + (hbudget : B+(Fintype.card τ:ℝ)*(ε/δ) < 1) {P : X → Prop} (hP : ∀ᵐ x ∂μ, P x) : + ∃ x, P x ∧ x ∉ bad ∧ ∀ t, E t x < δ := by + have hε : 0 ≤ (Fintype.card τ:ℝ)*(ε/δ) := by + by_cases hn : Nonempty τ + · let := hn + have heps := (integral_nonneg (hE0 (Classical.choice hn))).trans (hE (Classical.choice hn)) + positivity + · have : IsEmpty τ := not_nonempty_iff.mp hn + simp + have hu := finite_threshold_bound μ E hE0 hEi hδ hE + have hsmall : μ (bad ∪ {x | ∃ t, δ ≤ E t x} ∪ {x | ¬P x}) < 1 := by + calc + _ ≤ μ bad + μ {x | ∃ t, δ ≤ E t x} + μ {x | ¬P x} := + (measure_union_le _ _).trans (add_le_add (measure_union_le _ _) le_rfl) + _ ≤ ENNReal.ofReal B + ENNReal.ofReal ((Fintype.card τ:ℝ)*(ε/δ)) + 0 := + add_le_add (add_le_add hbad hu) (le_of_eq (ae_iff.mp hP)) + _ < 1 := by + rw [add_zero,← ENNReal.ofReal_add hB hε] + exact (ENNReal.ofReal_lt_one).mpr hbudget + by_contra! h + have heq : bad ∪ {x | ∃ t, δ ≤ E t x} ∪ {x | ¬P x} = Set.univ := by + ext x + simp only [mem_union,mem_ofPred_eq,mem_univ,iff_true] + by_cases hp : P x + · by_cases hb : x∈bad + · exact Or.inl (Or.inl hb) + · exact Or.inl (Or.inr (h x hp hb)) + · exact Or.inr hp + rw [heq,measure_univ] at hsmall + exact (lt_irrefl _) hsmall +end +open ContinuousCircleWeight.Sampling Filter +open scoped Topology +lemma eventually_trial_budget (T : ℕ) {δ : ℝ} (_hδ : 0 < δ) : + ∀ᶠ m : ℕ in atTop, phaseUnionBound m+(T:ℝ)*(samplingError m/δ) < 1 := by + have h := tendsto_phaseUnionBound.add ((tendsto_samplingError.div_const δ).const_mul (T:ℝ)) + norm_num only [zero_div,mul_zero,add_zero] at h + exact h.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1)) + +lemma exists_ideal_trial {m K : ℕ} (hK : 0 < K) (hn : IdealNumerics K m) + {τ : Type uτ} [Fintype τ] {κ : τ → Type uκ} [∀ t, Fintype (κ t)] [∀ t, Nonempty (κ t)] + (positive : τ → Bool) (c : ∀ t, κ t → ℝ) + (hcard : ∀ t, (m:ℝ)^((69:ℝ)/100*m) ≤ (Fintype.card (κ t):ℝ)) + (hc : ∀ t n, (m:ℝ)^((7:ℝ)/10*m)/2 ≤ c t n) + (hsep : ∀ t n k, n ≠ k → ∀ v w : ℤ, + |v| ≤ (m^300:ℕ) → |w| ≤ (m^300:ℕ) → (v ≠ 0 ∨ w ≠ 0) → + ((m:ℝ)*K)*(m:ℝ)^1000 ≤ |(v:ℝ)*c t n+(w:ℝ)*c t k|) + (hp : 10*(m:ℝ)^(-(19:ℝ)/20) ≤ 1) (S : Finset ℤ) + (hS : (S.card:ℝ) ≤ 3*(m:ℝ)^((4:ℝ)/5*m)) + (hcS : ∀ k∈S, ((m:ℝ)*K)/4 ≤ |(k:ℝ)|) + {δ : ℝ} (hδ : 0 < δ) + (hbudget : phaseUnionBound m+(Fintype.card τ:ℝ)*(samplingError m/δ) < 1) : + ∃ γ : Fin m → ℝ, + (∀ i, γ i ∈ Set.Ioo (1/((m:ℝ)*K)) (2/((m:ℝ)*K))) ∧ + (∀ k : ℤ, k ≠ 0 → ∀ i, ((k*γ i:ℝ):CircleX) ≠ 0) ∧ + (∀ k∈S, (m:ℝ)/20 ≤ (((Finset.univ.filter fun i => γ i ∉ phaseFailure ((m:ℝ)^(-(19:ℝ)/20)) k).card:ℕ):ℝ)) ∧ + ∀ t, idealEnergy (positive t) (scaleEll m) (scaleAlpha m) (c t) γ < δ := by + have hm : 0 < m := by have := hn.1; omega + have hN : 0 < (m:ℝ)*K := mul_pos (Nat.cast_pos.mpr hm) (Nat.cast_pos.mpr hK) + have hab : 1/((m:ℝ)*K) < 2/((m:ℝ)*K) := (div_lt_div_iff_of_pos_right hN).mpr (by norm_num) + let μ := Measure.pi (fun _ : Fin m => intervalLaw (1/((m:ℝ)*K)) (2/((m:ℝ)*K))) + let := intervalLaw_probability hab + let E (t : τ) : (Fin m → ℝ) → ℝ := idealEnergy (κ:=κ t) (positive t) (scaleEll m) (scaleAlpha m) (c t) + let bad := {γ : Fin m → ℝ | ∃ k∈S, + (((Finset.univ.filter fun i => γ i ∉ phaseFailure ((m:ℝ)^(-(19:ℝ)/20)) k).card:ℕ):ℝ) < (m:ℝ)/20} + have hℓ : 0 < scaleEll m := Real.rpow_pos_of_pos (Nat.cast_pos.mpr hm) _ + have hα := scaleAlpha_pos hm + obtain ⟨γ,hγ,hgood,hE⟩ := exists_good_finite_family μ E + (fun t => idealEnergy_nonneg (positive t) _ _ (c t)) + (fun t => idealEnergy_integrable (positive t) hℓ hα (c t) μ) + hδ (by unfold phaseUnionBound; positivity) + (fun t => ideal_stage_error hK hn (positive t) (c t) (hcard t) (hc t) (hsep t)) + bad (phase_cover_union_bound hm hK hp S hS hcS) hbudget + (pi_intervalLaw_ae_all_integerPhases (ι:=Fin m) hab) + refine ⟨γ,hγ.1,hγ.2,?_,hE⟩ + intro k hk + exact le_of_not_gt (fun h => hgood ⟨k,hk,h⟩) + + +end CircleSampling + +end + +end OAI diff --git a/lean/OAI/Analysis/RotationWeights/WeakSampling.lean b/lean/OAI/Analysis/RotationWeights/WeakSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cfb54ab81f0f0c963b6835cf41b551423062024 --- /dev/null +++ b/lean/OAI/Analysis/RotationWeights/WeakSampling.lean @@ -0,0 +1,514 @@ +import OAI.Analysis.RotationWeights.BorelTransport + +namespace OAI + +noncomputable section + +universe uX uκ uP uι + +namespace ContinuousCircleWeight +open MeasureTheory +open scoped ENNReal NNReal ComplexInnerProductSpace BigOperators +open MeasureTheory Filter Set Submodule +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ENNReal NNReal Topology ComplexInnerProductSpace +open MeasureTheory Filter Set +open scoped ComplexInnerProductSpace +open MeasureTheory Filter Set +open Set +open scoped ComplexInnerProductSpace +open Set +open scoped ComplexInnerProductSpace + +open MeasureTheory Set Filter Topology Algebra Submodule +open scoped BigOperators ComplexConjugate + +variable {X : Type uX} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] + [BorelSpace X] + +theorem compactMap_integrable (μ : Measure X) [IsFiniteMeasure μ] (f : C(X, ℂ)) : + Integrable f μ := + Integrable.of_bound f.continuous.aestronglyMeasurable ‖f‖ + (ae_of_all _ f.norm_coe_le_norm) + +theorem probability_integral_lipschitz (μ : ProbabilityMeasure X) : + LipschitzWith 1 (fun f : C(X, ℂ) => ∫ x, f x ∂(μ : Measure X)) := by + rw [lipschitzWith_iff_dist_le_mul] + intro f g + simp only [NNReal.coe_one, one_mul, dist_eq_norm] + rw [← integral_sub (compactMap_integrable _ f) (compactMap_integrable _ g)] + simpa using (norm_integral_le_of_norm_le_const + (ae_of_all (μ : Measure X) (fun x => (f - g).norm_coe_le_norm x))) + +theorem probability_tendsto_of_dense_span {κ : Type uκ} (l : Filter κ) + (s : Set C(X, ℂ)) (hs : (span ℂ s).topologicalClosure = ⊤) + (μs : κ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (h : ∀ f ∈ s, Tendsto (fun j => ∫ x, f x ∂(μs j : Measure X)) l + (𝓝 (∫ x, f x ∂(μ : Measure X)))) : + Tendsto μs l (𝓝 μ) := by + have heq : Equicontinuous + (fun j (f : C(X, ℂ)) => ∫ x, f x ∂(μs j : Measure X)) := + (LipschitzWith.uniformEquicontinuous _ 1 + (fun j => probability_integral_lipschitz (μs j))).equicontinuous + have hc := heq.isClosed_setOfPred_tendsto (l := l) (probability_integral_lipschitz μ).continuous + have hspan : (↑(span ℂ s) : Set C(X, ℂ)) ⊆ + {f | Tendsto (fun j => ∫ x, f x ∂(μs j : Measure X)) l + (𝓝 (∫ x, f x ∂(μ : Measure X)))} := by + intro f hf + induction hf using Submodule.span_induction with + | mem f hf => exact h f hf + | zero => simpa using (tendsto_const_nhds (x := (0 : ℂ))) + | add f g _ _ hf hg => + have hw (ν : ProbabilityMeasure X) : + (∫ x, (f + g) x ∂(ν : Measure X)) = + (∫ x, f x ∂(ν : Measure X)) + ∫ x, g x ∂(ν : Measure X) := + integral_add (compactMap_integrable _ f) (compactMap_integrable _ g) + simpa only [Set.mem_ofPred_eq, hw] using hf.add hg + | smul a f _ hf => + have hw (ν : ProbabilityMeasure X) : + (∫ x, (a • f) x ∂(ν : Measure X)) = a • ∫ x, f x ∂(ν : Measure X) := + integral_smul a _ + simpa only [Set.mem_ofPred_eq, hw] using hf.const_smul a + have hall := closure_minimal hspan hc + rw [← Submodule.topologicalClosure_coe, hs, Submodule.top_coe] at hall + apply (ProbabilityMeasure.tendsto_iff_forall_integral_rclike_tendsto ℂ).mpr + intro f + exact hall (a := f.toContinuousMap) (mem_univ _) + +omit [MeasurableSpace X] [BorelSpace X] [CompactSpace X] in +lemma not_mem_frontier_ge_of_continuousAt {f : X → ℝ} {x : X} {t : ℝ} + (hc : ContinuousAt f x) (hne : f x ≠ t) : + x ∉ frontier {z | t ≤ f z} := by + rcases lt_or_gt_of_ne hne with hlt | hgt + · have he : ∀ᶠ z in 𝓝 x, f z < t := hc.eventually (gt_mem_nhds hlt) + intro h + have hd := h.1 + rw [mem_closure_iff_nhds] at hd + have := hd {z | f z < t} he + obtain ⟨z, hz, hzt⟩ := this + exact (not_le_of_gt (show f z < t from hz)) (show t ≤ f z from hzt) + · have he : {z | t ≤ f z} ∈ 𝓝 x := mem_of_superset (hc.eventually (lt_mem_nhds hgt)) + (fun z hz => show t ≤ f z from le_of_lt hz) + exact fun h => h.2 (mem_interior_iff_mem_nhds.mpr he) + +omit [BorelSpace X] [CompactSpace X] in +lemma ae_null_frontier_ge (μ : Measure X) [SFinite μ] {f : X → ℝ} + (hf : Measurable f) (hc : ∀ᵐ x ∂μ, ContinuousAt f x) : + ∀ᵐ t : ℝ, μ (frontier {x | t ≤ f x}) = 0 := by + have hcount := Measure.countable_meas_level_set_pos (μ := μ) hf + have hzero : ∀ᵐ t : ℝ, μ {x | f x = t} = 0 := by + have h := hcount.measure_zero (volume : Measure ℝ) + rw [measure_eq_zero_iff_ae_notMem] at h + simpa only [mem_ofPred_eq, not_lt, nonpos_iff_eq_zero] using h + filter_upwards [hzero] with t ht + rw [measure_eq_zero_iff_ae_notMem] at ht ⊢ + filter_upwards [hc, ht] with x hx hxt + exact not_mem_frontier_ge_of_continuousAt hx hxt + +omit [CompactSpace X] in + +theorem tendsto_integral_nn_of_weak_of_ae_continuous [HasOuterApproxClosed X] + {κ : Type uκ} {l : Filter κ} [l.IsCountablyGenerated] + (μs : κ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (hμ : Tendsto μs l (𝓝 μ)) (f : X → ℝ) + (hf : Measurable f) (hc : ∀ᵐ x ∂(μ : Measure X), ContinuousAt f x) + (hnn : ∀ x, 0 ≤ f x) (M : ℝ) (hb : ∀ x, f x ≤ M) : + Tendsto (fun n => ∫ x, f x ∂(μs n : Measure X)) l + (𝓝 (∫ x, f x ∂(μ : Measure X))) := by + have hfi (ν : ProbabilityMeasure X) : Integrable f (ν : Measure X) := + Integrable.of_bound hf.aestronglyMeasurable M + (ae_of_all _ (fun x => by simpa only [Real.norm_of_nonneg (hnn x)] using hb x)) + have heq (ν : ProbabilityMeasure X) : (∫ x, f x ∂(ν : Measure X)) = + ∫ t in Ioc 0 M, (ν : Measure X).real {x | t ≤ f x} := + (hfi ν).integral_eq_integral_Ioc_meas_le (ae_of_all _ hnn) (ae_of_all _ hb) + simp_rw [heq] + apply tendsto_integral_filter_of_dominated_convergence (fun _ => (1 : ℝ)) + · apply Eventually.of_forall + intro n + have hm : Antitone (fun t : ℝ => (μs n : Measure X) {x | t ≤ f x}) := by + intro s t hst + exact measure_mono (fun x hx => hst.trans hx) + exact hm.measurable.ennreal_toReal.aestronglyMeasurable + · exact Eventually.of_forall (fun n => ae_of_all _ (fun t => + by simpa only [Measure.real, Real.norm_of_nonneg ENNReal.toReal_nonneg] using + (measureReal_le_one (μ := (μs n : Measure X)) (s := {x | t ≤ f x})))) + · exact integrable_const _ + · filter_upwards [ae_restrict_of_ae (ae_null_frontier_ge (μ : Measure X) hf hc)] with t ht + exact (ENNReal.tendsto_toReal (measure_ne_top _ _)).comp + (ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto' hμ ht) + +omit [CompactSpace X] in + +theorem tendsto_integral_of_weak_of_ae_continuous [HasOuterApproxClosed X] + {κ : Type uκ} {l : Filter κ} [l.IsCountablyGenerated] + (μs : κ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (hμ : Tendsto μs l (𝓝 μ)) (f : X → ℝ) + (hf : Measurable f) (hc : ∀ᵐ x ∂(μ : Measure X), ContinuousAt f x) + (M : ℝ) (hb : ∀ x, ‖f x‖ ≤ M) : + Tendsto (fun n => ∫ x, f x ∂(μs n : Measure X)) l + (𝓝 (∫ x, f x ∂(μ : Measure X))) := by + have hb' (x : X) : -M ≤ f x ∧ f x ≤ M := abs_le.mp (hb x) + have hnn (x : X) : 0 ≤ f x + M := by linarith [(hb' x).1] + have hupper (x : X) : f x + M ≤ 2 * M := by linarith [(hb' x).2] + have hc' : ∀ᵐ x ∂(μ : Measure X), ContinuousAt (fun x => f x + M) x := + hc.mono (fun _ hx => hx.add continuousAt_const) + have h := tendsto_integral_nn_of_weak_of_ae_continuous μs μ hμ (fun x => f x + M) + (hf.add_const M) hc' hnn (2 * M) hupper + have heq (ν : ProbabilityMeasure X) : (∫ x, f x + M ∂(ν : Measure X)) = + (∫ x, f x ∂(ν : Measure X)) + M := by + rw [integral_add (Integrable.of_bound hf.aestronglyMeasurable M (ae_of_all _ hb)) + (integrable_const _)] + simp + simp_rw [heq] at h + simpa only [add_sub_cancel_right] using h.sub_const M + +omit [CompactSpace X] in +theorem tendsto_integral_complex_of_weak_of_ae_continuous [HasOuterApproxClosed X] + {κ : Type uκ} {l : Filter κ} [l.IsCountablyGenerated] + (μs : κ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (hμ : Tendsto μs l (𝓝 μ)) (f : X → ℂ) + (hf : Measurable f) (hc : ∀ᵐ x ∂(μ : Measure X), ContinuousAt f x) + (M : ℝ) (hb : ∀ x, ‖f x‖ ≤ M) : + Tendsto (fun n => ∫ x, f x ∂(μs n : Measure X)) l + (𝓝 (∫ x, f x ∂(μ : Measure X))) := by + have hfi (ν : ProbabilityMeasure X) : Integrable f (ν : Measure X) := + Integrable.of_bound hf.aestronglyMeasurable M (ae_of_all _ hb) + have hre := tendsto_integral_of_weak_of_ae_continuous μs μ hμ (fun x => (f x).re) + (Complex.measurable_re.comp hf) + (hc.mono (fun _ hx => Complex.continuous_re.continuousAt.comp hx)) M + (fun x => (Complex.abs_re_le_norm _).trans (hb x)) + have him := tendsto_integral_of_weak_of_ae_continuous μs μ hμ (fun x => (f x).im) + (Complex.measurable_im.comp hf) + (hc.mono (fun _ hx => Complex.continuous_im.continuousAt.comp hx)) M + (fun x => (Complex.abs_im_le_norm _).trans (hb x)) + simp_rw [show ∀ ν : ProbabilityMeasure X, + (∫ x, (f x).re ∂(ν : Measure X)) = (∫ x, f x ∂(ν : Measure X)).re from + fun ν => integral_re (hfi ν)] at hre + simp_rw [show ∀ ν : ProbabilityMeasure X, + (∫ x, (f x).im ∂(ν : Measure X)) = (∫ x, f x ∂(ν : Measure X)).im from + fun ν => integral_im (hfi ν)] at him + have hrec := Complex.continuous_ofReal.continuousAt.tendsto.comp hre + have himc := Complex.continuous_ofReal.continuousAt.tendsto.comp him + simpa only [Function.comp_apply, Complex.re_add_im] using hrec.add (himc.mul_const Complex.I) + +def withParameter {P : Type uP} [TopologicalSpace P] [MeasurableSpace P] + [BorelSpace P] (ν : ProbabilityMeasure X) (b : P) : ProbabilityMeasure (X × P) := + ν.map (fun x => (x, b)) + +omit [CompactSpace X] in +theorem integral_withParameter [SecondCountableTopology X] + {P : Type uP} [TopologicalSpace P] [SecondCountableTopology P] [MeasurableSpace P] + [BorelSpace P] (ν : ProbabilityMeasure X) (b : P) (f : C(X × P, ℂ)) : + (∫ z, f z ∂(withParameter ν b : Measure (X × P))) = + ∫ x, f (x, b) ∂(ν : Measure X) := by + exact integral_map (measurable_id.prodMk measurable_const).aemeasurable + f.continuous.aestronglyMeasurable + +theorem probability_tendsto_withParameter [SecondCountableTopology X] + {P : Type uP} [TopologicalSpace P] [SecondCountableTopology P] + [MeasurableSpace P] [BorelSpace P] + {κ : Type uκ} {l : Filter κ} {νs : κ → ProbabilityMeasure X} {ν : ProbabilityMeasure X} + (hν : Tendsto νs l (𝓝 ν)) {bs : κ → P} {b : P} (hb : Tendsto bs l (𝓝 b)) : + Tendsto (fun n => withParameter (νs n) (bs n)) l (𝓝 (withParameter ν b)) := by + apply (ProbabilityMeasure.tendsto_iff_forall_integral_rclike_tendsto ℂ).mpr + intro f + let g : C(P, C(X, ℂ)) := + (f.toContinuousMap.comp ⟨Prod.swap, continuous_swap⟩).curry + have hgb : Tendsto (fun n => g (bs n)) l (𝓝 (g b)) := g.continuous.continuousAt.tendsto.comp hb + have hfix : Tendsto (fun n => ∫ x, g b x ∂(νs n : Measure X)) l + (𝓝 (∫ x, g b x ∂(ν : Measure X))) := by + exact (ProbabilityMeasure.tendsto_iff_forall_integral_rclike_tendsto ℂ).mp hν + (BoundedContinuousFunction.mkOfCompact (g b)) + have hdist : Tendsto (fun n => dist (∫ x, g b x ∂(νs n : Measure X)) + (∫ x, g (bs n) x ∂(νs n : Measure X))) l (𝓝 0) := by + apply squeeze_zero (g := fun n => dist (g b) (g (bs n))) (fun _ => dist_nonneg) + (fun n => by simpa only [NNReal.coe_one, one_mul] using + (probability_integral_lipschitz (νs n)).dist_le_mul (g b) (g (bs n))) + simpa only [dist_comm] using (tendsto_iff_dist_tendsto_zero.mp hgb) + have h := tendsto_of_tendsto_of_dist hfix hdist + change Tendsto (fun n => ∫ z, f.toContinuousMap z ∂(withParameter (νs n) (bs n) : Measure (X × P))) l + (𝓝 (∫ z, f.toContinuousMap z ∂(withParameter ν b : Measure (X × P)))) + simpa only [integral_withParameter, g, ContinuousMap.curry_apply, + ContinuousMap.comp_apply, ContinuousMap.coe_mk, Prod.swap_prod_mk] using h + +namespace Sampling + +abbrev CircleX := AddCircle (1 : ℝ) +local instance : Fact (0 < (1 : ℝ)) := ⟨by norm_num⟩ + +variable {ι : Type uι} [Fintype ι] + +def torusFourier (a : ι → ℤ) : C(ι → CircleX, ℂ) where + toFun x := ∏ i, fourier (a i) (x i) + continuous_toFun := by fun_prop + +@[simp] theorem torusFourier_apply (a : ι → ℤ) (x : ι → CircleX) : + torusFourier a x = ∏ i, fourier (a i) (x i) := rfl + +@[simp] theorem torusFourier_zero : torusFourier (0 : ι → ℤ) = 1 := by + ext x + simp + +theorem torusFourier_add (a b : ι → ℤ) : + torusFourier (a + b) = torusFourier a * torusFourier b := by + ext x + simp only [torusFourier_apply, Pi.add_apply, fourier_add, ContinuousMap.mul_apply] + exact Finset.prod_mul_distrib + +theorem torusFourier_neg (a : ι → ℤ) : + torusFourier (-a) = star (torusFourier a) := by + ext x + change (∏ i, fourier (-a i) (x i)) = conj (∏ i, fourier (a i) (x i)) + simp only [fourier_neg, map_prod] + +def torusFourierSubalgebra : StarSubalgebra ℂ C(ι → CircleX, ℂ) where + toSubalgebra := Algebra.adjoin ℂ (range torusFourier) + star_mem' := by + change Algebra.adjoin ℂ (range (torusFourier (ι := ι))) ≤ + star (Algebra.adjoin ℂ (range (torusFourier (ι := ι)))) + refine adjoin_le ?_ + rintro - ⟨a, rfl⟩ + exact subset_adjoin ⟨-a, torusFourier_neg a⟩ + +theorem torusFourierSubalgebra_coe : + Subalgebra.toSubmodule (torusFourierSubalgebra (ι := ι)).toSubalgebra = + span ℂ (range (torusFourier (ι := ι))) := by + apply adjoin_eq_span_of_subset + refine Subset.trans ?_ Submodule.subset_span + intro x hx + refine Submonoid.closure_induction (fun _ => id) ⟨0, torusFourier_zero⟩ ?_ hx + rintro - - - - ⟨a, rfl⟩ ⟨b, rfl⟩ + exact ⟨a + b, torusFourier_add a b⟩ + +theorem torusFourier_single [DecidableEq ι] (i : ι) (x : ι → CircleX) : + torusFourier (Pi.single i (1 : ℤ)) x = fourier 1 (x i) := by + rw [torusFourier_apply, Finset.prod_eq_single i] + · simp + · intro b _ hb + simp [hb] + · simp + +theorem torusFourierSubalgebra_separatesPoints : + (torusFourierSubalgebra (ι := ι)).SeparatesPoints := by + classical + intro x y hxy + obtain ⟨i, hi⟩ := Function.ne_iff.mp hxy + refine ⟨_, ⟨torusFourier (Pi.single i 1), subset_adjoin ⟨_, rfl⟩, rfl⟩, ?_⟩ + change torusFourier (Pi.single i 1) x ≠ torusFourier (Pi.single i 1) y + rw [torusFourier_single, torusFourier_single, fourier_one, fourier_one] + intro h + apply hi + exact AddCircle.injective_toCircle (by norm_num) (Subtype.coe_injective h) + +theorem span_torusFourier_closure_eq_top : + (span ℂ (range (torusFourier (ι := ι)))).topologicalClosure = ⊤ := by + rw [← torusFourierSubalgebra_coe] + exact congrArg (Subalgebra.toSubmodule ∘ StarSubalgebra.toSubalgebra) + (ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints + torusFourierSubalgebra torusFourierSubalgebra_separatesPoints) + +theorem integral_fourier (n : ℤ) : + (∫ x : CircleX, fourier n x ∂AddCircle.haarAddCircle) = if n = 0 then 1 else 0 := by + have h := congrFun (fourierCoeff_fourier (T := (1 : ℝ)) n) 0 + simpa [fourierCoeff, Pi.single_apply, eq_comm] using h + +def circleHaar : ProbabilityMeasure CircleX := + ⟨AddCircle.haarAddCircle, inferInstance⟩ + +def torusHaar : ProbabilityMeasure (ι → CircleX) := + ⟨Measure.pi (fun _ => AddCircle.haarAddCircle), inferInstance⟩ + +theorem integral_torusFourier (a : ι → ℤ) : + (∫ x, torusFourier a x ∂(torusHaar (ι := ι) : Measure (ι → CircleX))) = + if a = 0 then 1 else 0 := by + classical + change (∫ x : ι → CircleX, ∏ i, fourier (a i) (x i) + ∂Measure.pi (fun _ => AddCircle.haarAddCircle)) = _ + rw [integral_fintype_prod_eq_prod] + simp_rw [integral_fourier] + split_ifs with ha + · subst a + simp + · obtain ⟨i, hi⟩ := Function.ne_iff.mp ha + apply Finset.prod_eq_zero (Finset.mem_univ i) + simpa using hi + +omit [Fintype ι] in +theorem fourier_sum (s : Finset ι) (a : ι → ℤ) (x : CircleX) : + fourier (∑ i ∈ s, a i) x = ∏ i ∈ s, fourier (a i) x := by + classical + induction s using Finset.induction_on with + | empty => simp + | insert i s hi ih => rw [Finset.sum_insert hi, Finset.prod_insert hi, fourier_add, ih] + +def characterCurve (q : ι → ℤ) : C(CircleX, ι → CircleX) where + toFun x i := q i • x + continuous_toFun := by fun_prop + +theorem torusFourier_curve (a q : ι → ℤ) (x : CircleX) : + torusFourier a (characterCurve q x) = fourier (∑ i, a i * q i) x := by + rw [fourier_sum] + apply Finset.prod_congr rfl + intro i _ + simp only [characterCurve, ContinuousMap.coe_mk, fourier_apply, mul_zsmul] + +def curveLaw (q : ι → ℤ) : ProbabilityMeasure (ι → CircleX) := + circleHaar.map (characterCurve q) + +theorem integral_curveLaw (q : ι → ℤ) (f : C(ι → CircleX, ℂ)) : + (∫ x, f x ∂(curveLaw q : Measure (ι → CircleX))) = + ∫ x : CircleX, f (characterCurve q x) ∂AddCircle.haarAddCircle := by + exact integral_map (characterCurve q).continuous.measurable.aemeasurable + f.continuous.aestronglyMeasurable + +theorem integral_curveLaw_torusFourier (q a : ι → ℤ) : + (∫ x, torusFourier a x ∂(curveLaw q : Measure (ι → CircleX))) = + if ∑ i, a i * q i = 0 then 1 else 0 := by + rw [integral_curveLaw] + simp_rw [torusFourier_curve] + exact integral_fourier _ + +theorem eventually_sum_ne_zero_of_separated [LinearOrder ι] + {κ : Type uκ} {l : Filter κ} (q : κ → ι → ℝ) + (hq : ∀ n i, q n i ≠ 0) + (hsep : ∀ i j, i < j → Tendsto (fun n => q n i / q n j) l (𝓝 0)) + (a : ι → ℝ) (ha : a ≠ 0) : + ∀ᶠ n in l, ∑ i, a i * q n i ≠ 0 := by + classical + let s : Finset ι := Finset.univ.filter (fun i => a i ≠ 0) + have hs : s.Nonempty := by + obtain ⟨i, hi⟩ := Function.ne_iff.mp ha + exact ⟨i, by simpa [s] using hi⟩ + let j := s.max' hs + have hj : a j ≠ 0 := (Finset.mem_filter.mp (Finset.max'_mem s hs)).2 + have hlim (i : ι) : Tendsto (fun n => a i * q n i / q n j) l + (𝓝 (if i = j then a j else 0)) := by + by_cases hi : i = j + · subst i + simpa [hq] using (tendsto_const_nhds (x := a j) (f := l)) + · rw [ite_eq_right hi] + by_cases hai : a i = 0 + · simpa [hai] using (tendsto_const_nhds (x := (0 : ℝ)) (f := l)) + · have his : i ∈ s := by simp [s, hai] + have hij : i < j := lt_of_le_of_ne (Finset.le_max' s i his) hi + simpa only [mul_zero, mul_div_assoc] using (hsep i j hij).const_mul (a i) + have hsum := tendsto_finsetSum Finset.univ (fun i _ => hlim i) + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true] at hsum + filter_upwards [hsum.eventually_ne hj] with n hn + intro he + apply hn + rw [← Finset.sum_div, he, zero_div] + +theorem curveLaw_tendsto_of_nonresonance {κ : Type uκ} {l : Filter κ} + {q : κ → ι → ℤ} + (h : ∀ a : ι → ℤ, a ≠ 0 → ∀ᶠ n in l, ∑ i, a i * q n i ≠ 0) : + Tendsto (fun n => curveLaw (q n)) l (𝓝 (torusHaar (ι := ι))) := by + apply probability_tendsto_of_dense_span l (Set.range torusFourier) + span_torusFourier_closure_eq_top + rintro _ ⟨a, rfl⟩ + simp_rw [integral_curveLaw_torusFourier, integral_torusFourier] + by_cases ha : a = 0 + · subst a + simpa using (tendsto_const_nhds (x := (1 : ℂ))) + · rw [ite_eq_right ha] + apply tendsto_const_nhds.congr' + filter_upwards [h a ha] with n hn + simp [hn] + +theorem curveLaw_tendsto_of_separated [LinearOrder ι] + {κ : Type uκ} {l : Filter κ} {q : κ → ι → ℤ} + (hq : ∀ n i, q n i ≠ 0) + (hsep : ∀ i j, i < j → + Tendsto (fun n => (q n i : ℝ) / q n j) l (𝓝 0)) : + Tendsto (fun n => curveLaw (q n)) l (𝓝 (torusHaar (ι := ι))) := by + apply curveLaw_tendsto_of_nonresonance + intro a ha + have har : (fun i => (a i : ℝ)) ≠ 0 := by + intro he + apply ha + ext i + have hh : (a i : ℝ) = 0 := congrFun he i + change a i = 0 + exact_mod_cast hh + have hqr : ∀ n i, (q n i : ℝ) ≠ 0 := by + intro n i + exact_mod_cast hq n i + filter_upwards [eventually_sum_ne_zero_of_separated + (fun n i => (q n i : ℝ)) hqr hsep (fun i => (a i : ℝ)) har] with n hn + exact_mod_cast hn + +theorem separated_of_successive {κ : Type uκ} {l : Filter κ} {r : ℕ} + (q : κ → ℕ → ℝ) (hq : ∀ n i, i < r → q n i ≠ 0) + (hsep : ∀ i, i + 1 < r → Tendsto (fun n => q n (i + 1) / q n i) l atTop) : + ∀ i j, i < j → j < r → Tendsto (fun n => q n i / q n j) l (𝓝 0) := by + intro i j + induction j with + | zero => omega + | succ j ih => + intro hij hjr + have hnext : Tendsto (fun n => q n j / q n (j + 1)) l (𝓝 0) := by + simpa only [Function.comp_def, inv_div] using + tendsto_inv_atTop_zero.comp (hsep j hjr) + by_cases heq : i = j + · simpa [heq] using hnext + · have hik : i < j := by omega + have hlim := (ih hik (by omega)).mul hnext + simp only [mul_zero] at hlim + convert hlim using 1 + ext n + field_simp [hq n j (by omega)] + +theorem curveLaw_tendsto_of_successiveRatios {κ : Type uκ} {l : Filter κ} {r : ℕ} + (q : κ → ℕ → ℤ) (hq : ∀ n i, i < r → 0 < q n i) + (hsep : ∀ i, i + 1 < r → + Tendsto (fun n => (q n (i + 1) : ℝ) / q n i) l atTop) : + Tendsto (fun n => curveLaw (fun i : Fin r => q n i)) l (𝓝 (torusHaar (ι := Fin r))) := by + apply curveLaw_tendsto_of_separated + · intro n i + exact ne_of_gt (hq n i i.isLt) + · intro i j hij + apply separated_of_successive (fun n i => (q n i : ℝ)) _ hsep i j hij j.isLt + intro n i hi + exact_mod_cast ne_of_gt (hq n i hi) + +theorem circle_approximation_with_parameters + {P : Type uP} [MetricSpace P] [CompactSpace P] [MeasurableSpace P] [BorelSpace P] + {κ : Type uκ} {l : Filter κ} [l.IsCountablyGenerated] {r : ℕ} + (q : κ → ℕ → ℤ) (hq : ∀ n i, i < r → 0 < q n i) + (hsep : ∀ i, i + 1 < r → + Tendsto (fun n => (q n (i + 1) : ℝ) / q n i) l atTop) + {bs : κ → P} {b : P} (hb : Tendsto bs l (𝓝 b)) + (Φ : ((Fin r → CircleX) × P) → ℂ) (hΦ : Measurable Φ) + (hc : ∀ᵐ z ∂(withParameter (torusHaar (ι := Fin r)) b : Measure _), ContinuousAt Φ z) + (M : ℝ) (hM : ∀ z, ‖Φ z‖ ≤ M) : + Tendsto (fun n => ∫ x : CircleX, Φ (characterCurve (fun i : Fin r => q n i) x, bs n) + ∂AddCircle.haarAddCircle) l + (𝓝 (∫ s, Φ (s, b) ∂(torusHaar (ι := Fin r) : Measure _))) := by + have hν := probability_tendsto_withParameter (curveLaw_tendsto_of_successiveRatios q hq hsep) hb + have h := tendsto_integral_complex_of_weak_of_ae_continuous + (fun n => withParameter (curveLaw (fun i : Fin r => q n i)) (bs n)) + (withParameter (torusHaar (ι := Fin r)) b) hν Φ hΦ hc M hM + have heq (ν : ProbabilityMeasure (Fin r → CircleX)) (b : P) : + (∫ z, Φ z ∂(withParameter ν b : Measure _)) = ∫ s, Φ (s, b) ∂(ν : Measure _) := + integral_map (measurable_id.prodMk measurable_const).aemeasurable hΦ.aestronglyMeasurable + simp_rw [heq] at h + have heq' (n : κ) : (∫ s, Φ (s, bs n) ∂(curveLaw (fun i : Fin r => q n i) : Measure _)) = + ∫ x : CircleX, Φ (characterCurve (fun i : Fin r => q n i) x, bs n) + ∂AddCircle.haarAddCircle := + integral_map (characterCurve _).continuous.measurable.aemeasurable + (hΦ.comp (measurable_id.prodMk measurable_const)).aestronglyMeasurable + simpa only [heq'] using h + +end Sampling +end ContinuousCircleWeight + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/AtomicBalls.lean b/lean/OAI/Analysis/SegmentLenses/AtomicBalls.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0f3f278536c505d985c613229b953b87ba3ec6a --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/AtomicBalls.lean @@ -0,0 +1,259 @@ +import OAI.Analysis.SegmentLenses.Pairing + +namespace OAI + +/-! +# Atomic polar descriptions of finite unit balls +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + +section FiniteBodies +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + +@[ext] theorem SegmentFamily.ext {F G : SegmentFamily V} (h : F.sets = G.sets) : F = G := by + have _ := decidableEqV + cases F + cases G + cases h + rfl + + +abbrev LocalFamily (K : Finset V) := {F : SegmentFamily V // ∀ S ∈ F.sets, S ⊆ K} + +instance localFamilyFinite (K : Finset V) : Finite (LocalFamily K) := by + let f : LocalFamily K → {s // s ∈ K.powerset.powerset} := fun F => + ⟨F.val.sets, Finset.mem_powerset.mpr (fun S hS => Finset.mem_powerset.mpr (F.property S hS))⟩ + exact Finite.of_injective f (fun F G h => Subtype.ext (SegmentFamily.ext + (congrArg Subtype.val h))) + +instance localFamilyFintype (K : Finset V) : Fintype (LocalFamily K) := Fintype.ofFinite _ + + +abbrev FamilyCoefficients (F : SegmentFamily V) := EuclideanSpace ℝ F.sets + + + +abbrev LocalCoefficients (K : Finset V) := (F : LocalFamily K) → FamilyCoefficients F.val + +def familyValue (F : SegmentFamily V) : FamilyCoefficients F →ₗ[ℝ] FullDual V where + toFun c := ∑ S, c S • segmentFunctional S.val + map_add' c d := by simp [add_smul, Finset.sum_add_distrib] + map_smul' a c := by simp [Finset.smul_sum, mul_smul] + +@[simp] theorem familyValue_apply (F : SegmentFamily V) (c : FamilyCoefficients F) (u : Test V) : + familyValue F c (u : Primal V) = ∑ S, c S * ∑ v ∈ S.val, u.coeff v := by + have _ := decidableEqV + simp only [familyValue, LinearMap.coe_mk, AddHom.coe_mk, _root_.sum_apply, + _root_.smul_apply, smul_eq_mul, segmentFunctional_apply] + +def localValue (K : Finset V) : LocalCoefficients K →ₗ[ℝ] FullDual V where + toFun c := ∑ F, familyValue F.val (c F) + map_add' c d := by simp [map_add, Finset.sum_add_distrib] + map_smul' a c := by simp [map_smul, Finset.smul_sum] + +def coefficientBudget (K : Finset V) (c : LocalCoefficients K) : ℝ := ∑ F, ‖c F‖ + +@[continuity, fun_prop] theorem continuous_coefficientBudget (K : Finset V) : + Continuous (coefficientBudget K) := by + unfold coefficientBudget + fun_prop + +theorem coefficientBudget_nonneg (K : Finset V) (c : LocalCoefficients K) : + 0 ≤ coefficientBudget K c := Finset.sum_nonneg (fun _ _ => norm_nonneg _) + +theorem norm_le_coefficientBudget (K : Finset V) (c : LocalCoefficients K) : + ‖c‖ ≤ coefficientBudget K c := by + apply (pi_norm_le_iff_of_nonneg (coefficientBudget_nonneg K c)).mpr + intro F + exact Finset.single_le_sum (fun _ _ => norm_nonneg _) (Finset.mem_univ F) + +theorem compact_coefficientBall (K : Finset V) {R : ℝ} (_hR : 0 ≤ R) : + IsCompact {c : LocalCoefficients K | coefficientBudget K c ≤ R} := by + apply (isCompact_closedBall (0 : LocalCoefficients K) R).of_isClosed_subset + (isClosed_le (continuous_coefficientBudget K) continuous_const) + intro c hc + simpa only [Metric.mem_closedBall, dist_zero_right] using (norm_le_coefficientBudget K c).trans hc + +theorem convex_coefficientBall (K : Finset V) (R : ℝ) : + Convex ℝ {c : LocalCoefficients K | coefficientBudget K c ≤ R} := by + intro c hc d hd a b ha hb hab + change (∑ F, ‖a • c F + b • d F‖) ≤ R + calc + (∑ F, ‖a • c F + b • d F‖) ≤ ∑ F, (a * ‖c F‖ + b * ‖d F‖) := by + apply Finset.sum_le_sum + intro F hF + simpa only [norm_smul, Real.norm_eq_abs, abs_of_nonneg ha, abs_of_nonneg hb] using + norm_add_le (a • c F) (b • d F) + _ = a * coefficientBudget K c + b * coefficientBudget K d := by + simp only [coefficientBudget, Finset.sum_add_distrib, Finset.mul_sum] + _ ≤ a * R + b * R := add_le_add (mul_le_mul_of_nonneg_left hc ha) + (mul_le_mul_of_nonneg_left hd hb) + _ = R := by rw [← add_mul, hab, one_mul] + + + +def atomicBody (K : Finset V) (R : ℝ) : Set (FullDual V) := + localValue K '' {c : LocalCoefficients K | coefficientBudget K c ≤ R} + +theorem compact_atomicBody (K : Finset V) {R : ℝ} (hR : 0 ≤ R) : + IsCompact (atomicBody K R) := + (compact_coefficientBall K hR).image (localValue K).continuous_of_finiteDimensional + +theorem convex_atomicBody (K : Finset V) (R : ℝ) : Convex ℝ (atomicBody K R) := + (convex_coefficientBall K R).linear_image (localValue K) + +theorem zero_mem_atomicBody (K : Finset V) {R : ℝ} (hR : 0 ≤ R) : + (0 : FullDual V) ∈ atomicBody K R := by + refine ⟨0, ?_, map_zero _⟩ + simpa [coefficientBudget] using hR + +theorem familyValue_mem_atomicBody (K : Finset V) (F : LocalFamily K) + (c : FamilyCoefficients F.val) {R : ℝ} (hc : ‖c‖ ≤ R) : + familyValue F.val c ∈ atomicBody K R := by + classical + refine ⟨Pi.single (M := fun F : LocalFamily K => FamilyCoefficients F.val) F c, ?_, ?_⟩ + · change (∑ G, ‖Pi.single (M := fun F : LocalFamily K => FamilyCoefficients F.val) F c G‖) ≤ R + have he : (fun G : LocalFamily K => ‖Pi.single (M := fun F : LocalFamily K => FamilyCoefficients F.val) F c G‖) = Pi.single F ‖c‖ := by + funext G + exact Pi.apply_single (fun G (c : FamilyCoefficients G.val) => ‖c‖) (fun _ => norm_zero) F c G + rw [he] + simpa [Pi.single_apply] using hc + · change (∑ G, familyValue G.val (Pi.single (M := fun F : LocalFamily K => FamilyCoefficients F.val) F c G)) = _ + have he : (fun G : LocalFamily K => familyValue G.val (Pi.single (M := fun F : LocalFamily K => FamilyCoefficients F.val) F c G)) = + Pi.single F (familyValue F.val c) := by + funext G + exact Pi.apply_single (fun G => familyValue G.val) (fun _ => map_zero _) F c G + rw [he] + simp [Pi.single_apply] + +end FiniteBodies + +section FinitePolar +variable {V : Type*} [decidableEqV : DecidableEq V] [segmentSystemV : SegmentSystem V] + + +def Test.ofFinite (K : Finset V) (a : V → ℝ) : Test V := + ∑ v ∈ K, a v • Test.ofFinsupp (Finsupp.single v 1) + +@[simp] theorem Test.coeff_ofFinite (K : Finset V) (a : V → ℝ) (v : V) : + (Test.ofFinite K a).coeff v = if v ∈ K then a v else 0 := by + have _ := segmentSystemV + change (∑ w ∈ K, a w • Finsupp.single w 1) v = _ + simp [Finsupp.smul_single, Finsupp.single_apply, eq_comm] + +theorem Test.support_ofFinite (K : Finset V) (a : V → ℝ) : + (Test.ofFinite K a).coeff.support ⊆ K := by + intro v hv + by_contra hn + exact Finsupp.mem_support_iff.mp hv (by simp [hn]) + +@[simp] theorem Test.coe_ofFinite (K : Finset V) (a : V → ℝ) : + ((Test.ofFinite K a : Test V) : Primal V) = ∑ v ∈ K, a v • unitVector v := by + have _ := decidableEqV + change (UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V) (Test.ofFinite K a) = _ + simp only [Test.ofFinite, map_sum, map_smul]; rfl + +@[simp] theorem dual_apply_ofFinite (K : Finset V) (a : V → ℝ) (z : FullDual V) : + z ((Test.ofFinite K a : Test V) : Primal V) = ∑ v ∈ K, a v * z (unitVector v) := by + rw [Test.coe_ofFinite] + simp only [map_sum, map_smul, smul_eq_mul] + +def polarTest (K : Finset V) (f : FullDual V →L[ℝ] ℝ) : Test V := + Test.ofFinite K (fun v => f (coordinate v)) + +theorem polarTest_pairing (K : Finset V) (f : FullDual V →L[ℝ] ℝ) (z : FullDual V) : + f (head K z) = z ((polarTest K f : Test V) : Primal V) := by + simp [head, polarTest, mul_comm] + +theorem polarTest_familyValue (K : Finset V) (f : FullDual V →L[ℝ] ℝ) + (F : LocalFamily K) (c : FamilyCoefficients F.val) : + f (familyValue F.val c) = ∑ S, c S * (F.val.test (polarTest K f).coeff) S := by + change f (∑ S, c S • segmentFunctional S.val) = _ + simp only [map_sum, map_smul, smul_eq_mul, SegmentFamily.test_apply] + apply Finset.sum_congr rfl + intro S hS + congr 1 + simp only [segmentFunctional, map_sum] + apply Finset.sum_congr rfl + intro v hv + simp [polarTest, F.property _ S.property hv] + +end FinitePolar + +section EuclideanNormalization +variable {ι : Type*} [Fintype ι] + +theorem norm_normalized_le (q : EuclideanSpace ℝ ι) : ‖‖q‖⁻¹ • q‖ ≤ 1 := by + by_cases hq : ‖q‖ = 0 + · simp [hq] + · rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (norm_nonneg q)), + inv_mul_cancel₀ hq] + +theorem normalized_pairing (q : EuclideanSpace ℝ ι) : + (∑ i, (‖q‖⁻¹ • q) i * q i) = ‖q‖ := by + have hs : (∑ i, q i ^ 2) = ‖q‖ ^ 2 := by + simp only [EuclideanSpace.norm_sq_eq, Real.norm_eq_abs, sq_abs] + simp only [PiLp.smul_apply, smul_eq_mul, mul_assoc, ← Finset.mul_sum] + simp_rw [← sq] + rw [hs] + by_cases hq : ‖q‖ = 0 + · simp [hq] + · field_simp + +end EuclideanNormalization + +section AtomicSeparation +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] + + + +theorem mem_atomicBody_of_norm_le_one {K : Finset V} (hK : Ancestral (· ≤ ·) K) + (z : FullDual V) (hz : head K z = z) (hn : ‖z‖ ≤ 1) : + z ∈ atomicBody K 1 := by + by_contra hnot + obtain ⟨f, a, hfa, haz⟩ := geometric_hahn_banach_closed_point + (convex_atomicBody K 1) (compact_atomicBody K (by norm_num : (0 : ℝ) ≤ 1)).isClosed hnot + let p := polarTest K f + have hp : p.coeff.support ⊆ K := Test.support_ofFinite K _ + have hpn : ‖p‖ ≤ a := by + change segmentSeminorm V p.coeff ≤ a + rw [segmentSeminorm_apply] + apply ciSup_le + intro F + let G : LocalFamily K := ⟨F.clip hK, F.clip_subset hK⟩ + let q := G.val.test p.coeff + have hm := familyValue_mem_atomicBody K G (‖q‖⁻¹ • q) (norm_normalized_le q) + have hf := hfa _ hm + rw [polarTest_familyValue, normalized_pairing] at hf + change G.val.seminorm p.coeff < a at hf + rw [show G.val = F.clip hK from rfl, F.clip_seminorm hK p.coeff hp] at hf + exact hf.le + have hpair := polarTest_pairing K f z + rw [hz] at hpair + have hop := z.le_opNorm (p : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at hop + have hle : f z ≤ a := calc + f z = z (p : Primal V) := hpair + _ ≤ |z (p : Primal V)| := le_abs_self _ + _ ≤ ‖z‖ * ‖p‖ := hop + _ ≤ ‖p‖ := mul_le_of_le_one_left (norm_nonneg _) hn + _ ≤ a := hpn + exact not_lt_of_ge hle haz + +end AtomicSeparation + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Averaged.lean b/lean/OAI/Analysis/SegmentLenses/Averaged.lean new file mode 100644 index 0000000000000000000000000000000000000000..e78c195060481e173448e6826e5effd4f75fa1b5 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Averaged.lean @@ -0,0 +1,308 @@ +import OAI.Analysis.SegmentLenses.Completed + +namespace OAI + +/-! +# All-radius averaged estimates and asymptotic moduli +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + +section AveragedFiniteHead +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + +theorem finite_head_average {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hx : head H x = x) (hxn : ‖x‖ = 1) + (hy : head H y = 0) (hyn : 1 ≤ ‖y‖) {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 ≤ + (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 := by + let R := max ‖x + t • y‖ ‖x - t • y‖ + have hR : 0 ≤ R := le_trans (norm_nonneg _) (le_max_left _ _) + have hp : ‖x + t • y‖ ≤ R := le_max_left _ _ + have hm : ‖x - t • y‖ ≤ R := le_max_right _ _ + have hc : 1 ≤ R := by simpa only [hxn] using norm_center_le x (t • y) R hp hm + have hty : tail H (t • y) = t • y := by + change t • y - headLinear H (t • y) = t • y + rw [map_smul, headLinear_apply, hy, smul_zero, sub_zero] + have htail := completed_main_tail hH x (t • y) hx R hR hp hm + rw [hty, norm_smul, Real.norm_eq_abs, abs_of_pos ht, hxn] at htail + have htn : t ≤ t * ‖y‖ := le_mul_of_one_le_right ht.le hyn + have hd : 0 ≤ R ^ 2 - 1 ^ 2 := by nlinarith + have hs := Real.sq_sqrt hd + have hroot : Real.sqrt (1 + t ^ 2 / 4) ≤ R := by + apply (Real.sqrt_le_iff).mpr + refine ⟨hR, ?_⟩ + nlinarith [Real.sqrt_nonneg (R ^ 2 - 1 ^ 2)] + have hph : head H (x + t • y) = x := by + change headLinear H (x + t • y) = x + simp only [map_add, map_smul, headLinear_apply, hx, hy, smul_zero, add_zero] + have hmh : head H (x - t • y) = x := by + change headLinear H (x - t • y) = x + simp only [map_sub, map_smul, headLinear_apply, hx, hy, smul_zero, sub_zero] + have hpl : 1 ≤ ‖x + t • y‖ := by + have h := norm_head_le hH (x + t • y) + rwa [hph, hxn] at h + have hml : 1 ≤ ‖x - t • y‖ := by + have h := norm_head_le hH (x - t • y) + rwa [hmh, hxn] at h + have hsum : R ≤ ‖x + t • y‖ + ‖x - t • y‖ - 1 := max_le (by linarith) (by linarith) + linarith + + +theorem predual_unit_approx (x : CoordinatePredual V) (hx : ‖x‖ = 1) + {ε : ℝ} (hε : 0 < ε) : + ∃ H : Finset V, Ancestral (· ≤ ·) H ∧ ∃ z : FullDual V, + head H z = z ∧ ‖z‖ = 1 ∧ ‖x.val - z‖ < ε := by + obtain ⟨H, hH, z, hz, he⟩ := predual_finite_approx x + (lt_min (half_pos hε) (by norm_num : (0 : ℝ) < 1 / 2)) + have he1 : ‖x.val - z‖ < 1 / 2 := he.trans_le (min_le_right _ _) + have heε : ‖x.val - z‖ < ε / 2 := he.trans_le (min_le_left _ _) + have hz0 : z ≠ 0 := by + intro h + rw [h, sub_zero, show ‖x.val‖ = 1 from hx] at he1 + norm_num at he1 + let q := ‖z‖⁻¹ • z + have hqn : ‖q‖ = 1 := by + simp only [q, norm_smul, norm_inv, norm_norm, inv_mul_cancel₀ (norm_ne_zero_iff.mpr hz0)] + have hzq : z = ‖z‖ • q := by + simp only [q, smul_smul, mul_inv_cancel₀ (norm_ne_zero_iff.mpr hz0), one_smul] + have hqz : ‖q - z‖ = |1 - ‖z‖| := by + calc + ‖q - z‖ = ‖(1 - ‖z‖) • q‖ := by + apply congrArg norm + calc q - z = q - ‖z‖ • q := congrArg (q - ·) hzq + _ = (1 - ‖z‖) • q := by module + _ = |1 - ‖z‖| := by rw [norm_smul, Real.norm_eq_abs, hqn, mul_one] + have hnorm : |1 - ‖z‖| ≤ ‖x.val - z‖ := by + simpa only [show ‖x.val‖ = 1 from hx] using abs_norm_sub_norm_le x.val z + refine ⟨H, hH, q, ?_, hqn, ?_⟩ + · change headLinear H (‖z‖⁻¹ • z) = ‖z‖⁻¹ • z + rw [map_smul, headLinear_apply, hz] + · have htriangle : ‖x.val - q‖ ≤ ‖x.val - z‖ + ‖z - q‖ := by + simpa only [dist_eq_norm] using dist_triangle x.val z q + rw [norm_sub_rev z q, hqz] at htriangle + linarith + + + +theorem predual_averaged_witness (x : CoordinatePredual V) (hx : ‖x‖ = 1) + {t ε : ℝ} (ht : 0 < t) (hε : 0 < ε) : + ∃ H : Finset V, Ancestral (· ≤ ·) H ∧ + ∀ y : CoordinatePredual V, head H y.val = 0 → 1 ≤ ‖y‖ → + (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 - ε ≤ + (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 := by + obtain ⟨H, hH, z, hz, hzn, he⟩ := predual_unit_approx x hx hε + refine ⟨H, hH, ?_⟩ + intro y hy hyn + have h := finite_head_average hH z y.val hz hzn hy hyn ht + have hp : ‖z + t • y.val‖ ≤ ‖x.val + t • y.val‖ + ‖x.val - z‖ := by + have heq : z + t • y.val = (x.val + t • y.val) + (z - x.val) := by module + rw [heq] + exact (norm_add_le _ _).trans_eq (by rw [norm_sub_rev z x.val]) + have hm : ‖z - t • y.val‖ ≤ ‖x.val - t • y.val‖ + ‖x.val - z‖ := by + have heq : z - t • y.val = (x.val - t • y.val) + (z - x.val) := by module + rw [heq] + exact (norm_add_le _ _).trans_eq (by rw [norm_sub_rev z x.val]) + change (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 - ε ≤ + (‖x.val + t • y.val‖ + ‖x.val - t • y.val‖) / 2 - 1 + linarith + +end AveragedFiniteHead + +section IndependentCoordinates +variable {V : Type*} [DecidableEq V] [SegmentSystem V] + +theorem coordinate_independent : LinearIndependent ℝ (coordinate (V := V)) := by + classical + rw [linearIndependent_iff'] + intro s a ha v hv + have h := congrArg (fun z : FullDual V => z (unitVector v)) ha + simpa [_root_.sum_apply, _root_.smul_apply, coordinate_unitVector, hv] using h + +theorem predualCoordinate_independent : LinearIndependent ℝ (predualCoordinate (V := V)) := + LinearIndependent.of_comp (coordinateSpan V).subtype coordinate_independent + +theorem predual_not_finite [Infinite V] : ¬ FiniteDimensional ℝ (CoordinatePredual V) := by + intro h + let := h + have : Finite V := predualCoordinate_independent.finite + exact not_finite V + +theorem fullDual_not_finite [Infinite V] : ¬ FiniteDimensional ℝ (FullDual V) := by + intro h + let := h + have : Finite V := coordinate_independent.finite + exact not_finite V + +end IndependentCoordinates + +instance : Infinite ForestVertex := by + let f : ℕ → ForestVertex := fun n => ⟨(1, [n]), by simp⟩ + apply Infinite.of_injective f + intro n m h + have he := congrArg (fun v : ForestVertex => v.val.2) h + simpa only [f, List.cons.injEq, and_true] using he + + +section Modulus +variable (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + + +structure CofiniteSubspace where + space : Submodule ℝ E + closed : IsClosed (space : Set E) + finite : FiniteDimensional ℝ (E ⧸ space) + +attribute [instance] CofiniteSubspace.finite + +abbrev SphereOne := {x : E // ‖x‖ = 1} +abbrev CofiniteSphere (F : CofiniteSubspace E) := {y : E // y ∈ F.space ∧ ‖y‖ = 1} + +variable {E} + +def CofiniteSubspace.ofMap {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] + [FiniteDimensional ℝ D] (f : E →L[ℝ] D) : CofiniteSubspace E where + space := f.toLinearMap.ker + closed := f.isClosed_ker + finite := FiniteDimensional.of_injective + f.toLinearMap.quotKerEquivRange.toLinearMap f.toLinearMap.quotKerEquivRange.injective + +instance : Nonempty (CofiniteSubspace E) := + ⟨CofiniteSubspace.ofMap (0 : E →L[ℝ] ℝ)⟩ + +theorem CofiniteSubspace.sphere_nonempty (hE : ¬ FiniteDimensional ℝ E) + (F : CofiniteSubspace E) : Nonempty (CofiniteSphere E F) := by + have hn : F.space ≠ ⊥ := by + intro he + exact hE (F.space.quotEquivOfEqBot he).finiteDimensional + let : Nontrivial F.space := Submodule.nontrivial_iff_ne_bot.mpr hn + obtain ⟨y, hy⟩ := exists_ne (0 : F.space) + have hy0 : (y : E) ≠ 0 := by + intro he + exact hy (Subtype.ext he) + refine ⟨⟨‖(y : E)‖⁻¹ • (y : E), F.space.smul_mem _ y.property, ?_⟩⟩ + simp only [norm_smul, norm_inv, norm_norm, inv_mul_cancel₀ (norm_ne_zero_iff.mpr hy0)] + +theorem sphereOne_nonempty (hE : ¬ FiniteDimensional ℝ E) : Nonempty (SphereOne E) := by + obtain ⟨y⟩ := (CofiniteSubspace.ofMap (0 : E →L[ℝ] ℝ)).sphere_nonempty hE + exact ⟨⟨y.val, y.property.2⟩⟩ + + +def averagedOn (x : SphereOne E) (t : ℝ) (F : CofiniteSubspace E) : ℝ := + ⨅ y : CofiniteSphere E F, (‖x.val + t • y.val‖ + ‖x.val - t • y.val‖) / 2 - 1 + +def averagedAt (x : SphereOne E) (t : ℝ) : ℝ := + ⨆ F : CofiniteSubspace E, averagedOn x t F + + +def averagedModulus (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] (t : ℝ) : ℝ := + ⨅ x : SphereOne E, averagedAt x t + +theorem average_bounds (x y : E) (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) + {t : ℝ} (ht : 0 ≤ t) : + 0 ≤ (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 ∧ + (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 ≤ t := by + have hsum := norm_add_le (x + t • y) (x - t • y) + have he : (x + t • y) + (x - t • y) = (2 : ℝ) • x := by module + rw [he, norm_smul, hx, mul_one] at hsum + have hp := norm_add_le x (t • y) + have hm := norm_sub_le x (t • y) + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht, hy, mul_one, hx] at hp hm + norm_num at hsum + constructor <;> linarith + +theorem averagedOn_bounds (hE : ¬ FiniteDimensional ℝ E) (x : SphereOne E) + {t : ℝ} (ht : 0 ≤ t) (F : CofiniteSubspace E) : + 0 ≤ averagedOn x t F ∧ averagedOn x t F ≤ t := by + have := F.sphere_nonempty hE + have hb : BddBelow (Set.range (fun y : CofiniteSphere E F => + (‖x.val + t • y.val‖ + ‖x.val - t • y.val‖) / 2 - 1)) := by + refine ⟨0, ?_⟩ + rintro _ ⟨y, rfl⟩ + exact (average_bounds _ _ x.property y.property.2 ht).1 + constructor + · exact le_ciInf (fun y => (average_bounds _ _ x.property y.property.2 ht).1) + · let y : CofiniteSphere E F := Classical.choice (F.sphere_nonempty hE) + exact (ciInf_le hb y).trans (average_bounds _ _ x.property y.property.2 ht).2 + +theorem averagedAt_bdd (hE : ¬ FiniteDimensional ℝ E) (x : SphereOne E) + {t : ℝ} (ht : 0 ≤ t) : + BddAbove (Set.range (fun F : CofiniteSubspace E => averagedOn x t F)) := by + refine ⟨t, ?_⟩ + rintro _ ⟨F, rfl⟩ + exact (averagedOn_bounds hE x ht F).2 + + + +theorem averagedModulus_lower (hE : ¬ FiniteDimensional ℝ E) {t c : ℝ} (ht : 0 ≤ t) + (hw : ∀ x : SphereOne E, ∀ ε : ℝ, 0 < ε → ∃ F : CofiniteSubspace E, + ∀ y : CofiniteSphere E F, + c - ε ≤ (‖x.val + t • y.val‖ + ‖x.val - t • y.val‖) / 2 - 1) : + c ≤ averagedModulus E t := by + have := sphereOne_nonempty hE + apply le_ciInf + intro x + apply le_of_forall_pos_le_add + intro ε hε + obtain ⟨F, hF⟩ := hw x ε hε + have := F.sphere_nonempty hE + have hon : c - ε ≤ averagedOn x t F := le_ciInf hF + have hs : averagedOn x t F ≤ averagedAt x t := le_ciSup (averagedAt_bdd hE x ht) F + linarith + +end Modulus + +section PredualModulus +variable {V : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + + +def predualHeadValues (H : Finset V) : CoordinatePredual V →L[ℝ] (H → ℝ) := + ContinuousLinearMap.pi (fun v => + (ContinuousLinearMap.apply ℝ ℝ (unitVector v.val)).comp (coordinateSpan V).subtypeL) + +theorem predualHeadValues_zero (H : Finset V) (y : CoordinatePredual V) + (hy : predualHeadValues H y = 0) : head H y.val = 0 := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + apply Finset.sum_eq_zero + intro v hv + have he := congrFun hy (⟨v, hv⟩ : H) + change y.val (unitVector v) = 0 at he + rw [he, zero_smul] + + +theorem predual_all_radius_average [Infinite V] {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 ≤ averagedModulus (CoordinatePredual V) t := by + apply averagedModulus_lower predual_not_finite ht.le + intro x ε hε + obtain ⟨H, hH, hw⟩ := predual_averaged_witness x.val x.property ht hε + refine ⟨CofiniteSubspace.ofMap (predualHeadValues H), ?_⟩ + intro y + exact hw y.val (predualHeadValues_zero H y.val y.property.1) y.property.2.ge + + +theorem infinite_all_radius_average {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 ≤ averagedModulus BInfinite t := by + classical + exact predual_all_radius_average ht + +end PredualModulus + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Basic.lean b/lean/OAI/Analysis/SegmentLenses/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbef929a4a3e301b521de65169a729c5833053de --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Basic.lean @@ -0,0 +1,568 @@ +import Mathlib + +namespace OAI + +/-! +# Segment tests, their completion, and coordinate functionals +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + + + + + + + + + + + + + +abbrev InfiniteVertex := List ℕ + + + +def ForestVertex := {p : ℕ × List ℕ // 1 ≤ p.1 ∧ p.2.length ≤ p.1} + + +def ForestAncestor (a b : ForestVertex) : Prop := + a.val.1 = b.val.1 ∧ a.val.2.IsPrefix b.val.2 + + +def IsInterval {V : Type*} (ancestor : V → V → Prop) (S : Finset V) : Prop := + ∃ a b, ancestor a b ∧ ∀ v, v ∈ S ↔ ancestor a v ∧ ancestor v b + + +def Ancestral {V : Type*} (ancestor : V → V → Prop) (H : Finset V) : Prop := + ∀ ⦃a b⦄, b ∈ H → ancestor a b → a ∈ H + + +class SegmentSystem (V : Type*) where + isSegment : Finset V → Prop + singleton : ∀ v, isSegment {v} + + + +structure SegmentFamily (V : Type*) [SegmentSystem V] where + sets : Finset (Finset V) + segment : ∀ S ∈ sets, SegmentSystem.isSegment S + disjoint : (sets : Set (Finset V)).PairwiseDisjoint id + +namespace SegmentFamily +variable {V : Type*} [SegmentSystem V] + +instance : Inhabited (SegmentFamily V) := ⟨⟨∅, by simp, by simp⟩⟩ + + +def column (F : SegmentFamily V) (v : V) : EuclideanSpace ℝ F.sets := + by classical exact WithLp.toLp 2 (fun S => if v ∈ S.val then 1 else 0) + +theorem norm_column_le (F : SegmentFamily V) (v : V) : ‖F.column v‖ ≤ 1 := by + classical + by_cases hv : ∃ S ∈ F.sets, v ∈ S + · obtain ⟨S, hS, hvS⟩ := hv + have he : F.column v = PiLp.single 2 (⟨S, hS⟩ : F.sets) (1 : ℝ) := by + ext T + change (if v ∈ T.val then (1 : ℝ) else 0) = _ + by_cases hTS : T = ⟨S, hS⟩ + · subst T + simp [hvS] + · have hn : v ∉ T.val := by + intro hvT + have hne : T.val ≠ S := fun h => hTS (Subtype.ext h) + exact Finset.disjoint_left.mp (F.disjoint T.property hS hne) hvT hvS + simp [hTS, hn] + rw [he, PiLp.norm_single] + norm_num + · have he : F.column v = 0 := by + ext S + have hn : v ∉ S.val := fun h => hv ⟨S.val, S.property, h⟩ + simp [column, hn] + rw [he, norm_zero] + norm_num + + +def test (F : SegmentFamily V) : (V →₀ ℝ) →ₗ[ℝ] EuclideanSpace ℝ F.sets := + Finsupp.linearCombination ℝ F.column + +theorem test_apply (F : SegmentFamily V) (u : V →₀ ℝ) (S : F.sets) : + F.test u S = ∑ v ∈ S.val, u v := by + classical + simp only [test, Finsupp.linearCombination_apply, Finsupp.sum, + WithLp.ofLp_sum, Finset.sum_apply, PiLp.smul_apply, column, + smul_eq_mul] + simp only [mul_ite, mul_one, mul_zero] + rw [← Finset.sum_filter] + apply Finset.sum_subset + · intro v hv + exact (Finset.mem_filter.mp hv).2 + · intro v hv hnv + have hnot : v ∉ u.support := by + intro hvs + exact hnv (Finset.mem_filter.mpr ⟨hvs, hv⟩) + exact Finsupp.notMem_support_iff.mp hnot + + +theorem norm_test_le (F : SegmentFamily V) (u : V →₀ ℝ) : + ‖F.test u‖ ≤ ∑ v ∈ u.support, |u v| := by + classical + rw [test, Finsupp.linearCombination_apply, Finsupp.sum] + calc + ‖∑ v ∈ u.support, u v • F.column v‖ ≤ + ∑ v ∈ u.support, ‖u v • F.column v‖ := norm_sum_le _ _ + _ ≤ ∑ v ∈ u.support, |u v| := by + apply Finset.sum_le_sum + intro v hv + rw [norm_smul, Real.norm_eq_abs] + exact mul_le_of_le_one_right (abs_nonneg _) (F.norm_column_le v) + + +def seminorm (F : SegmentFamily V) : Seminorm ℝ (V →₀ ℝ) := + (normSeminorm ℝ (EuclideanSpace ℝ F.sets)).comp F.test + +theorem seminorm_sq (F : SegmentFamily V) (u : V →₀ ℝ) : + F.seminorm u ^ 2 = ∑ S : F.sets, (∑ v ∈ S.val, u v) ^ 2 := by + change ‖F.test u‖ ^ 2 = _ + rw [EuclideanSpace.real_norm_sq_eq] + simp_rw [F.test_apply] + + +def singleton (v : V) : SegmentFamily V where + sets := {{v}} + segment := by + intro S h + have he : S = {v} := Finset.mem_singleton.mp h + rw [he] + exact SegmentSystem.singleton v + disjoint := by + intro S hS T hT hne + simp only [Finset.mem_coe, Finset.mem_singleton] at hS hT + exact False.elim (hne (hS.trans hT.symm)) + +theorem singleton_seminorm (v : V) (u : V →₀ ℝ) : + (singleton v).seminorm u = |u v| := by + have h := (singleton v).seminorm_sq u + have hh : (∑ S : (singleton v).sets, (∑ w ∈ S.val, u w) ^ 2) = u v ^ 2 := by + exact (Finset.sum_coe_sort (singleton v).sets + (fun S : Finset V => (∑ w ∈ S, u w) ^ 2)).trans (by simp [singleton]) + rw [hh] at h + have hn := apply_nonneg (singleton v).seminorm u + nlinarith [sq_abs (u v), abs_nonneg (u v)] + +end SegmentFamily + + + +def segmentSeminorm (V : Type*) [SegmentSystem V] : Seminorm ℝ (V →₀ ℝ) := + ⨆ F : SegmentFamily V, F.seminorm + +theorem segmentTests_bdd (V : Type*) [SegmentSystem V] : + BddAbove (Set.range (SegmentFamily.seminorm (V := V))) := by + rw [Seminorm.bddAbove_iff] + refine ⟨fun u => ∑ v ∈ u.support, |u v|, ?_⟩ + rintro _ ⟨p, ⟨F, rfl⟩, rfl⟩ u + exact F.norm_test_le u + +theorem segmentSeminorm_apply {V : Type*} [SegmentSystem V] (u : V →₀ ℝ) : + segmentSeminorm V u = ⨆ F : SegmentFamily V, F.seminorm u := + Seminorm.iSup_apply (segmentTests_bdd V) + +theorem le_segmentSeminorm {V : Type*} [SegmentSystem V] + (F : SegmentFamily V) (u : V →₀ ℝ) : F.seminorm u ≤ segmentSeminorm V u := by + have h := le_ciSup (f := fun G : SegmentFamily V => G.seminorm) (segmentTests_bdd V) F + exact Seminorm.le_def.mp h u + +theorem abs_coord_le {V : Type*} [SegmentSystem V] (u : V →₀ ℝ) (v : V) : + |u v| ≤ segmentSeminorm V u := by + rw [← SegmentFamily.singleton_seminorm v u] + exact le_segmentSeminorm _ _ + + +theorem segmentSeminorm_eq_zero {V : Type*} [SegmentSystem V] (u : V →₀ ℝ) : + segmentSeminorm V u = 0 ↔ u = 0 := by + constructor + · intro h + ext v + have hh := abs_coord_le u v + rw [h] at hh + simpa using hh + · rintro rfl + exact map_zero _ + + + +theorem indexed_test_bound {V ι : Type*} [SegmentSystem V] [Fintype ι] + (u : V →₀ ℝ) (S : ι → Finset V) + (hS : ∀ i, S i = ∅ ∨ SegmentSystem.isSegment (S i)) + (hd : Pairwise fun i j => Disjoint (S i) (S j)) : + ∑ i, (∑ v ∈ S i, u v) ^ 2 ≤ segmentSeminorm V u ^ 2 := by + classical + let F : SegmentFamily V := + { sets := (Finset.univ.image S).erase ∅ + segment := by + intro T hT + obtain ⟨hne, him⟩ := Finset.mem_erase.mp hT + obtain ⟨i, -, rfl⟩ := Finset.mem_image.mp him + exact (hS i).resolve_left hne + disjoint := by + intro A hA B hB hne + obtain ⟨i, -, rfl⟩ := Finset.mem_image.mp (Finset.mem_erase.mp hA).2 + obtain ⟨j, -, rfl⟩ := Finset.mem_image.mp (Finset.mem_erase.mp hB).2 + exact hd (fun hij => hne (congrArg S hij)) } + have he : F.seminorm u ^ 2 = ∑ i, (∑ v ∈ S i, u v) ^ 2 := by + rw [F.seminorm_sq] + rw [Finset.sum_coe_sort F.sets (fun T : Finset V => (∑ v ∈ T, u v) ^ 2)] + change (∑ T ∈ (Finset.univ.image S).erase ∅, (∑ v ∈ T, u v) ^ 2) = _ + rw [Finset.sum_erase _ (by simp)] + apply Finset.sum_image_of_pairwise_eq_zero + intro i hi j hj hij heq + have hempty : S i = ∅ := by + have hh : Disjoint (S i) (S j) := hd hij + rw [← heq] at hh + exact disjoint_self.mp hh + simp [hempty] + rw [← he] + exact (sq_le_sq₀ (apply_nonneg F.seminorm u) + (apply_nonneg (segmentSeminorm V) u)).mpr (le_segmentSeminorm F u) + + + +theorem refinement_test_bound {V ι : Type*} [SegmentSystem V] [Fintype ι] + (u : V →₀ ℝ) (S A B : ι → Finset V) + (hd : Pairwise fun i j => Disjoint (S i) (S j)) + (hA : ∀ i, A i ⊆ S i) (hB : ∀ i, B i ⊆ S i) + (hAB : ∀ i, Disjoint (A i) (B i)) + (hsA : ∀ i, A i = ∅ ∨ SegmentSystem.isSegment (A i)) + (hsB : ∀ i, B i = ∅ ∨ SegmentSystem.isSegment (B i)) : + ∑ i, ((∑ v ∈ A i, u v) ^ 2 + (∑ v ∈ B i, u v) ^ 2) ≤ + segmentSeminorm V u ^ 2 := by + classical + let pieces : ι × Bool → Finset V := fun j => if j.2 then B j.1 else A j.1 + have hp : ∀ j, pieces j = ∅ ∨ SegmentSystem.isSegment (pieces j) := by + rintro ⟨i, b⟩ + cases b + · exact hsA i + · exact hsB i + have hsub : ∀ j : ι × Bool, pieces j ⊆ S j.1 := by + rintro ⟨i, b⟩ + cases b + · exact hA i + · exact hB i + have hpd : Pairwise fun i j => Disjoint (pieces i) (pieces j) := by + rintro ⟨i, b⟩ ⟨j, c⟩ hne + by_cases hij : i = j + · subst j + cases b <;> cases c + · exact False.elim (hne rfl) + · exact hAB i + · exact (hAB i).symm + · exact False.elim (hne rfl) + · exact (hd hij).mono (hsub _) (hsub _) + have h := indexed_test_bound u pieces hp hpd + simpa [Fintype.sum_prod_type, pieces, Fintype.sum_bool, add_comm] using h + + + +def Test (V : Type*) := V →₀ ℝ + +namespace Test +variable {V : Type*} +instance : AddCommGroup (Test V) := inferInstanceAs (AddCommGroup (V →₀ ℝ)) +instance : Module ℝ (Test V) := inferInstanceAs (Module ℝ (V →₀ ℝ)) + +def coeff (u : Test V) : V →₀ ℝ := u + +def ofFinsupp (u : V →₀ ℝ) : Test V := u + +variable [SegmentSystem V] +instance : Norm (Test V) where norm u := segmentSeminorm V u.coeff + +theorem normCore : NormedSpace.Core ℝ (Test V) where + norm_nonneg u := apply_nonneg (segmentSeminorm V) u.coeff + norm_smul c u := map_smul_eq_mul (segmentSeminorm V) c u.coeff + norm_triangle u v := map_add_le_add (segmentSeminorm V) u.coeff v.coeff + norm_eq_zero_iff u := segmentSeminorm_eq_zero u.coeff + +instance : NormedAddCommGroup (Test V) := by + have norm_column_le {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (v : V) : ‖F.column v‖ ≤ 1 := by + classical + by_cases hv : ∃ S ∈ F.sets, v ∈ S + · obtain ⟨S, hS, hvS⟩ := hv + have he : F.column v = PiLp.single 2 (⟨S, hS⟩ : F.sets) (1 : ℝ) := by + ext T + change (if v ∈ T.val then (1 : ℝ) else 0) = _ + by_cases hTS : T = ⟨S, hS⟩ + · subst T + simp [hvS] + · have hn : v ∉ T.val := by + intro hvT + have hne : T.val ≠ S := fun h => hTS (Subtype.ext h) + exact Finset.disjoint_left.mp (F.disjoint T.property hS hne) hvT hvS + simp [hTS, hn] + rw [he, PiLp.norm_single] + norm_num + · have he : F.column v = 0 := by + ext S + have hn : v ∉ S.val := fun h => hv ⟨S.val, S.property, h⟩ + simp [SegmentFamily.column, hn] + rw [he, norm_zero] + norm_num + have test_apply {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (u : V →₀ ℝ) (S : F.sets) : + F.test u S = ∑ v ∈ S.val, u v := by + classical + simp only [SegmentFamily.test, Finsupp.linearCombination_apply, Finsupp.sum, + WithLp.ofLp_sum, Finset.sum_apply, PiLp.smul_apply, SegmentFamily.column, + smul_eq_mul] + simp only [mul_ite, mul_one, mul_zero] + rw [← Finset.sum_filter] + apply Finset.sum_subset + · intro v hv + exact (Finset.mem_filter.mp hv).2 + · intro v hv hnv + have hnot : v ∉ u.support := by + intro hvs + exact hnv (Finset.mem_filter.mpr ⟨hvs, hv⟩) + exact Finsupp.notMem_support_iff.mp hnot + have norm_test_le {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (u : V →₀ ℝ) : + ‖F.test u‖ ≤ ∑ v ∈ u.support, |u v| := by + classical + rw [SegmentFamily.test, Finsupp.linearCombination_apply, Finsupp.sum] + calc + ‖∑ v ∈ u.support, u v • F.column v‖ ≤ + ∑ v ∈ u.support, ‖u v • F.column v‖ := norm_sum_le _ _ + _ ≤ ∑ v ∈ u.support, |u v| := by + apply Finset.sum_le_sum + intro v hv + rw [norm_smul, Real.norm_eq_abs] + exact mul_le_of_le_one_right (abs_nonneg _) (norm_column_le F v) + have seminorm_sq {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (u : V →₀ ℝ) : + F.seminorm u ^ 2 = ∑ S : F.sets, (∑ v ∈ S.val, u v) ^ 2 := by + change ‖F.test u‖ ^ 2 = _ + rw [EuclideanSpace.real_norm_sq_eq] + apply Finset.sum_congr rfl + intro S _ + rw [test_apply] + have singleton_seminorm {V : Type _} [SegmentSystem V] (v : V) (u : V →₀ ℝ) : + (SegmentFamily.singleton v).seminorm u = |u v| := by + have h := seminorm_sq (SegmentFamily.singleton v) u + have hh : (∑ S : (SegmentFamily.singleton v).sets, (∑ w ∈ S.val, u w) ^ 2) = u v ^ 2 := by + exact (Finset.sum_coe_sort (SegmentFamily.singleton v).sets + (fun S : Finset V => (∑ w ∈ S, u w) ^ 2)).trans (by simp [SegmentFamily.singleton]) + rw [hh] at h + have hn := apply_nonneg (SegmentFamily.singleton v).seminorm u + nlinarith [sq_abs (u v), abs_nonneg (u v)] + have segmentTests_bdd (V : Type _) [SegmentSystem V] : + BddAbove (Set.range (SegmentFamily.seminorm (V := V))) := by + rw [Seminorm.bddAbove_iff] + refine ⟨fun u => ∑ v ∈ u.support, |u v|, ?_⟩ + rintro _ ⟨p, ⟨F, rfl⟩, rfl⟩ u + exact norm_test_le F u + have le_segmentSeminorm {V : Type _} [SegmentSystem V] + (F : SegmentFamily V) (u : V →₀ ℝ) : F.seminorm u ≤ segmentSeminorm V u := by + have h := le_ciSup (f := fun G : SegmentFamily V => G.seminorm) (segmentTests_bdd V) F + exact Seminorm.le_def.mp h u + have abs_coord_le {V : Type _} [SegmentSystem V] (u : V →₀ ℝ) (v : V) : + |u v| ≤ segmentSeminorm V u := by + rw [← singleton_seminorm v u] + exact le_segmentSeminorm _ _ + have segmentSeminorm_eq_zero {V : Type _} [SegmentSystem V] (u : V →₀ ℝ) : + segmentSeminorm V u = 0 ↔ u = 0 := by + constructor + · intro h + ext v + have hh := abs_coord_le u v + rw [h] at hh + simpa using hh + · rintro rfl + exact map_zero _ + exact NormedAddCommGroup.ofCore (𝕜 := ℝ) { + norm_nonneg u := apply_nonneg (segmentSeminorm V) u.coeff + norm_smul c u := map_smul_eq_mul (segmentSeminorm V) c u.coeff + norm_triangle u v := map_add_le_add (segmentSeminorm V) u.coeff v.coeff + norm_eq_zero_iff u := segmentSeminorm_eq_zero u.coeff } +instance : NormedSpace ℝ (Test V) where + norm_smul_le c u := le_of_eq (map_smul_eq_mul (segmentSeminorm V) c u.coeff) + + +def evaluation (v : V) : Test V →L[ℝ] ℝ := by + have norm_column_le {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (v : V) : ‖F.column v‖ ≤ 1 := by + classical + by_cases hv : ∃ S ∈ F.sets, v ∈ S + · obtain ⟨S, hS, hvS⟩ := hv + have he : F.column v = PiLp.single 2 (⟨S, hS⟩ : F.sets) (1 : ℝ) := by + ext T + change (if v ∈ T.val then (1 : ℝ) else 0) = _ + by_cases hTS : T = ⟨S, hS⟩ + · subst T + simp [hvS] + · have hn : v ∉ T.val := by + intro hvT + have hne : T.val ≠ S := fun h => hTS (Subtype.ext h) + exact Finset.disjoint_left.mp (F.disjoint T.property hS hne) hvT hvS + simp [hTS, hn] + rw [he, PiLp.norm_single] + norm_num + · have he : F.column v = 0 := by + ext S + have hn : v ∉ S.val := fun h => hv ⟨S.val, S.property, h⟩ + simp [SegmentFamily.column, hn] + rw [he, norm_zero] + norm_num + have test_apply {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (u : V →₀ ℝ) (S : F.sets) : + F.test u S = ∑ v ∈ S.val, u v := by + classical + simp only [SegmentFamily.test, Finsupp.linearCombination_apply, Finsupp.sum, + WithLp.ofLp_sum, Finset.sum_apply, PiLp.smul_apply, SegmentFamily.column, + smul_eq_mul] + simp only [mul_ite, mul_one, mul_zero] + rw [← Finset.sum_filter] + apply Finset.sum_subset + · intro v hv + exact (Finset.mem_filter.mp hv).2 + · intro v hv hnv + have hnot : v ∉ u.support := by + intro hvs + exact hnv (Finset.mem_filter.mpr ⟨hvs, hv⟩) + exact Finsupp.notMem_support_iff.mp hnot + have norm_test_le {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (u : V →₀ ℝ) : + ‖F.test u‖ ≤ ∑ v ∈ u.support, |u v| := by + classical + rw [SegmentFamily.test, Finsupp.linearCombination_apply, Finsupp.sum] + calc + ‖∑ v ∈ u.support, u v • F.column v‖ ≤ + ∑ v ∈ u.support, ‖u v • F.column v‖ := norm_sum_le _ _ + _ ≤ ∑ v ∈ u.support, |u v| := by + apply Finset.sum_le_sum + intro v hv + rw [norm_smul, Real.norm_eq_abs] + exact mul_le_of_le_one_right (abs_nonneg _) (norm_column_le F v) + have seminorm_sq {V : Type _} [SegmentSystem V] (F : SegmentFamily V) (u : V →₀ ℝ) : + F.seminorm u ^ 2 = ∑ S : F.sets, (∑ v ∈ S.val, u v) ^ 2 := by + change ‖F.test u‖ ^ 2 = _ + rw [EuclideanSpace.real_norm_sq_eq] + apply Finset.sum_congr rfl + intro S _ + rw [test_apply] + have singleton_seminorm {V : Type _} [SegmentSystem V] (v : V) (u : V →₀ ℝ) : + (SegmentFamily.singleton v).seminorm u = |u v| := by + have h := seminorm_sq (SegmentFamily.singleton v) u + have hh : (∑ S : (SegmentFamily.singleton v).sets, (∑ w ∈ S.val, u w) ^ 2) = u v ^ 2 := by + exact (Finset.sum_coe_sort (SegmentFamily.singleton v).sets + (fun S : Finset V => (∑ w ∈ S, u w) ^ 2)).trans (by simp [SegmentFamily.singleton]) + rw [hh] at h + have hn := apply_nonneg (SegmentFamily.singleton v).seminorm u + nlinarith [sq_abs (u v), abs_nonneg (u v)] + have segmentTests_bdd (V : Type _) [SegmentSystem V] : + BddAbove (Set.range (SegmentFamily.seminorm (V := V))) := by + rw [Seminorm.bddAbove_iff] + refine ⟨fun u => ∑ v ∈ u.support, |u v|, ?_⟩ + rintro _ ⟨p, ⟨F, rfl⟩, rfl⟩ u + exact norm_test_le F u + have le_segmentSeminorm {V : Type _} [SegmentSystem V] + (F : SegmentFamily V) (u : V →₀ ℝ) : F.seminorm u ≤ segmentSeminorm V u := by + have h := le_ciSup (f := fun G : SegmentFamily V => G.seminorm) (segmentTests_bdd V) F + exact Seminorm.le_def.mp h u + have abs_coord_le {V : Type _} [SegmentSystem V] (u : V →₀ ℝ) (v : V) : + |u v| ≤ segmentSeminorm V u := by + rw [← singleton_seminorm v u] + exact le_segmentSeminorm _ _ + exact let f : Test V →ₗ[ℝ] ℝ := + { toFun := fun u => u.coeff v + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + f.mkContinuous 1 (fun u => by + change |u.coeff v| ≤ 1 * segmentSeminorm V u.coeff + simpa only [one_mul] using abs_coord_le u.coeff v) + +end Test + + +abbrev Primal (V : Type*) [SegmentSystem V] := UniformSpace.Completion (Test V) + + + +abbrev FullDual (V : Type*) [SegmentSystem V] := StrongDual ℝ (Primal V) + + +def unitVector {V : Type*} [SegmentSystem V] (v : V) : Primal V := + (Test.ofFinsupp (Finsupp.single v 1) : Test V) + + +def coordinate {V : Type*} [SegmentSystem V] (v : V) : FullDual V := + (Test.evaluation v).extend UniformSpace.Completion.toComplL + + +def coordinateSpan (V : Type*) [SegmentSystem V] : Submodule ℝ (FullDual V) := + (Submodule.span ℝ (Set.range (coordinate (V := V)))).topologicalClosure + + +abbrev CoordinatePredual (V : Type*) [SegmentSystem V] : Type _ := ↥(coordinateSpan V) + + +def head {V : Type*} [SegmentSystem V] (H : Finset V) (x : FullDual V) : FullDual V := + ∑ v ∈ H, x (unitVector v) • coordinate v + + + +def tail {V : Type*} [SegmentSystem V] (H : Finset V) (x : FullDual V) : FullDual V := + x - head H x + +theorem prefix_antisymm {a b : List ℕ} + (hab : a.IsPrefix b) (hba : b.IsPrefix a) : a = b := + hab.eq_of_length (Nat.le_antisymm hab.length_le hba.length_le) + +instance infiniteSegments : SegmentSystem InfiniteVertex where + isSegment := IsInterval List.IsPrefix + singleton v := by + refine ⟨v, v, List.prefix_rfl, ?_⟩ + intro w + simp only [Finset.mem_singleton] + constructor + · rintro rfl; exact ⟨List.prefix_rfl, List.prefix_rfl⟩ + · rintro ⟨hvw, hwv⟩ + exact hwv.eq_of_length (Nat.le_antisymm hwv.length_le hvw.length_le) + +theorem forestAncestor_refl (v : ForestVertex) : ForestAncestor v v := + ⟨rfl, List.prefix_rfl⟩ + +theorem forestAncestor_antisymm {a b : ForestVertex} + (hab : ForestAncestor a b) (hba : ForestAncestor b a) : a = b := by + apply Subtype.ext + exact Prod.ext hab.1 (prefix_antisymm hab.2 hba.2) + +instance forestSegments : SegmentSystem ForestVertex where + isSegment := IsInterval ForestAncestor + singleton v := by + refine ⟨v, v, ⟨rfl, List.prefix_rfl⟩, ?_⟩ + intro w + simp only [Finset.mem_singleton] + constructor + · rintro rfl; exact ⟨⟨rfl, List.prefix_rfl⟩, ⟨rfl, List.prefix_rfl⟩⟩ + · rintro ⟨hvw, hwv⟩ + exact Subtype.ext (Prod.ext hwv.1 (hwv.2.eq_of_length (Nat.le_antisymm hwv.2.length_le hvw.2.length_le))) + + +abbrev J := Primal ForestVertex + +abbrev X := FullDual ForestVertex + +abbrev JInfinite := Primal InfiniteVertex + +abbrev BInfinite := CoordinatePredual InfiniteVertex + + +end SegmentLenses + + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Canonical.lean b/lean/OAI/Analysis/SegmentLenses/Canonical.lean new file mode 100644 index 0000000000000000000000000000000000000000..68d1568ed35edba98ca32ea4bfeb2e022d8dc51f --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Canonical.lean @@ -0,0 +1,288 @@ +import OAI.Analysis.SegmentLenses.ConeNorms + +namespace OAI + +/-! +# Endpoint vectors and canonical bidual identifications +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +section ConditionalGateL2 +variable {I : Type*} + + + +def dominatedL2 (m : lp (fun _ : I => ℝ) 2) (a : I → ℝ) + (ha : ∀ i, 0 ≤ a i) (hab : ∀ i, a i ≤ 2*m i) : lp (fun _ : I => ℝ) 2 := + ⟨a, (lp.memℓp ((2:ℝ) • m)).mono (fun i => by + rw [Real.norm_eq_abs,abs_of_nonneg (ha i)] + change a i ≤ 2*m i + exact hab i)⟩ + +@[simp] theorem dominatedL2_apply (m : lp (fun _ : I => ℝ) 2) (a : I → ℝ) + (ha : ∀ i, 0 ≤ a i) (hab : ∀ i, a i ≤ 2*m i) (i : I) : + dominatedL2 m a ha hab i = a i := rfl + +end ConditionalGateL2 + +section EndpointL2Vectors +open scoped Classical +variable {V ΩP ΩM : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + [Fintype ΩP] [Fintype ΩM] + + + +theorem endpoint_law_vectors {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (hK : Ancestral (· ≤ ·) K) (hHK : H ⊆ K) + (x y : FullDual V) (hx : head H x = x) {d : ℝ} (hd : 0 ≤ d) (hd1 : d < 1) + (hxn : 1-d ≤ ‖x‖) (hplus : ‖x+y‖ ≤ 1) (hminus : ‖x-y‖ ≤ 1) + (p : Test V) (hpH : p.coeff.support ⊆ H) (hp : ‖p‖ = 1) (hxp : x (p : Primal V) = ‖x‖) + (μP : FiniteLaw ΩP) (μM : FiniteLaw ΩM) + (AP : ΩP → Representation V) (AM : ΩM → Representation V) + (hAP : ∀ ω, (AP ω).energy ≤ 1) (hAM : ∀ ω, (AM ω).energy ≤ 1) + (hmeanP : μP.expect (fun ω => (AP ω).value) = head K (x+y)) + (hmeanM : μM.expect (fun ω => (AM ω).value) = head K (x-y)) : + (lawSlack μP AP p + lawError μP AP p ≤ 4*d) ∧ + (lawSlack μM AM p + lawError μM AM p ≤ 4*d) ∧ + μP.mean (fun ω => ‖(AP ω).value - ((AP ω).family.replacement p.coeff).value‖) ≤ 2*Real.sqrt d ∧ + μM.mean (fun ω => ‖(AM ω).value - ((AM ω).family.replacement p.coeff).value‖) ≤ 2*Real.sqrt d ∧ + ∃ mP mM m : lp (fun _ : {g // Gate H g} => ℝ) 2, + (∀ g, mP g = μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|)) ∧ + (∀ g, mM g = μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|)) ∧ + m = (1/2:ℝ) • (mP+mM) ∧ ‖m‖ ≤ Real.sqrt (6*d) ∧ + (∀ g, 0 ≤ mP g ∧ 0 ≤ mM g ∧ mP g ≤ 2*m g ∧ mM g ≤ 2*m g) := by + obtain ⟨h1,h2,h3,h4,m,hm,hmn,hdom⟩ := + endpoint_laws_global hH hK hHK x y hx hd hd1 hxn hplus hminus p hpH hp hxp + μP μM AP AM hAP hAM hmeanP hmeanM + let aP := fun g : {g // Gate H g} => μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) + let aM := fun g : {g // Gate H g} => μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|) + let mP := dominatedL2 m aP (fun g => (hdom g).1) (fun g => (hdom g).2.2.1) + let mM := dominatedL2 m aM (fun g => (hdom g).2.1) (fun g => (hdom g).2.2.2) + refine ⟨h1,h2,h3,h4,mP,mM,m,(fun _ => rfl),(fun _ => rfl),?_,hmn,hdom⟩ + apply lp.ext + funext g + change m g = (1/2:ℝ)*(aP g+aM g) + rw [hm] + ring + +end EndpointL2Vectors + + + +section FoundationWitnesses +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + + +theorem primal_coordinate_density : + (Submodule.span ℝ (Set.range (unitVector (V := V)))).topologicalClosure = ⊤ := by + have _ := decidableEqV + apply top_unique + intro x hx + have hsub : Set.range (fun u : Test V => (u : Primal V)) ⊆ + (Submodule.span ℝ (Set.range (unitVector (V := V)))) := by + rintro _ ⟨u,rfl⟩ + change (u : Primal V) ∈ Submodule.span ℝ (Set.range (unitVector (V := V))) + rw [test_as_sum u] + apply Submodule.sum_mem + intro v hv + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨v,rfl⟩) + exact (closure_mono hsub) (UniformSpace.Completion.denseRange_coe x) + + + +theorem coordinatePredual_complete : CompleteSpace (CoordinatePredual V) := by + have _ := decidableEqV + exact + (Submodule.isClosed_topologicalClosure (Submodule.span ℝ (Set.range (coordinate (V := V))))).completeSpace_coe + +@[simp] theorem primalHead_idempotent (H : Finset V) (x : Primal V) : + primalHead H (primalHead H x) = primalHead H x := by + refine UniformSpace.Completion.induction_on x + (isClosed_eq ((primalHead H).continuous.comp (primalHead H).continuous) + (primalHead H).continuous) ?_ + intro u + rw [primalHead_test,primalHead_test] + congr 1 + apply Finsupp.ext + intro v + change ((u.coeff.filter (· ∈ H)).filter (· ∈ H)) v = (u.coeff.filter (· ∈ H)) v + simp only [Finsupp.filter_apply] + split_ifs <;> rfl + +@[simp] theorem primalTail_idempotent (H : Finset V) (x : Primal V) : + primalTail H (primalTail H x) = primalTail H x := by + change (x-primalHead H x)-primalHead H (x-primalHead H x) = x-primalHead H x + rw [map_sub,primalHead_idempotent,sub_self,sub_zero] + +end FoundationWitnesses + +section CanonicalDualIdentification +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + + +def canonicalBidualEquiv (h : Reflexive E) : E ≃ₗᵢ[ℝ] StrongDual ℝ (StrongDual ℝ E) := + LinearIsometryEquiv.ofSurjective (NormedSpace.inclusionInDoubleDualLi ℝ) h + +@[simp] theorem canonicalBidualEquiv_apply (h : Reflexive E) (x : E) (f : StrongDual ℝ E) : + canonicalBidualEquiv h x f = f x := rfl + + +def forestCanonicalDual : J ≃ₗᵢ[ℝ] StrongDual ℝ X := canonicalBidualEquiv forest_primal_reflexive + +@[simp] theorem forestCanonicalDual_apply (u : J) (x : X) : forestCanonicalDual u x = x u := rfl + +end CanonicalDualIdentification + + + +theorem infinite_main_tail_internal (H : Finset InfiniteVertex) (hH : Ancestral List.IsPrefix H) + (x y : BInfinite) (hx : x = predualHead hH x) (R : ℝ) (hR : 0 ≤ R) + (hp : ‖x+y‖ ≤ R) (hm : ‖x-y‖ ≤ R) : + ‖predualTail hH y‖ ≤ 2*Real.sqrt (R^2-‖x‖^2) := by + classical + exact infinite_main_tail H hH x y (congrArg Subtype.val hx) R hR hp hm + + + +theorem forest_radial_tail (H : Finset ForestVertex) (hH : Ancestral ForestAncestor H) + (x y : X) (hx : x = head H x) (R : ℝ) + (hp : ‖x+y‖ ≤ R) (hm : ‖x-y‖ ≤ R) : + ‖tail H y‖ ≤ (Real.sqrt 2+Real.sqrt 6)*Real.sqrt (R*(R-‖x‖)) := by + classical + exact radial_tail_bound hH x y hx.symm R ((norm_nonneg _).trans hp) hp hm + + +theorem infinite_original_coefficient_average (H : Finset InfiniteVertex) + (hH : Ancestral List.IsPrefix H) (x z : BInfinite) + (hx : x = predualHead hH x) (hz : predualHead hH z = 0) : + ‖x‖ ≤ ‖x+z‖ ∧ ‖x‖ ≤ ‖x-z‖ ∧ + ‖z‖ ≤ (Real.sqrt 2+Real.sqrt 6)* + Real.sqrt (((‖x+z‖+‖x-z‖)/2)*((‖x+z‖+‖x-z‖)/2-‖x‖)) := by + classical + exact original_coefficient_average hH x.val z.val (congrArg Subtype.val hx).symm + (congrArg Subtype.val hz) + + + +namespace LevelForest +open scoped Classical + + + +abbrev Index := {n : ℕ // 1 ≤ n} +abbrev Vertex := IndexedForest.Vertex (fun n : Index => n.val-1) +abbrev J := Primal Vertex +abbrev X := FullDual Vertex + + +def shiftOrderEmbedding : Vertex ↪o Levels.Vertex where + toFun v := ⟨(v.val.1.val-1,v.val.2),v.property⟩ + inj' := by + intro v w he + have hi := congrArg (fun u : Levels.Vertex => u.val.1) he + have hw := congrArg (fun u : Levels.Vertex => u.val.2) he + have hv1 := v.val.1.property + have hw1 := w.val.1.property + apply Subtype.ext + apply Prod.ext + · apply Subtype.ext + change v.val.1.val-1 = w.val.1.val-1 at hi + omega + · exact hw + map_rel_iff' := by + intro v w + change (v.val.1.val-1 = w.val.1.val-1 ∧ v.val.2.IsPrefix w.val.2) ↔ + (v.val.1 = w.val.1 ∧ v.val.2.IsPrefix w.val.2) + constructor + · rintro ⟨hi,hw⟩ + refine ⟨Subtype.ext ?_,hw⟩ + have hv1 := v.val.1.property + have hw1 := w.val.1.property + omega + · rintro ⟨hi,hw⟩ + exact ⟨congrArg (fun n : Index => n.val-1) hi,hw⟩ + +theorem shiftOrderEmbedding_surjective : Function.Surjective shiftOrderEmbedding := by + intro v + let n : Index := ⟨v.val.1+1,by omega⟩ + let w : Vertex := ⟨(n,v.val.2),by simpa only [n,Nat.add_sub_cancel] using v.property⟩ + refine ⟨w,?_⟩ + apply Subtype.ext + exact Prod.ext (Nat.add_sub_cancel _ _) rfl + +def shiftEmbedding : SegmentEmbedding (V := Vertex) (W := Levels.Vertex) := + convexSegmentEmbedding shiftOrderEmbedding + (fun {_ _ v} _ _ _ _ => shiftOrderEmbedding_surjective v) + + + +def heightEquiv : J ≃ₗᵢ[ℝ] Levels.J := + shiftEmbedding.primalEquivOfSurjective shiftOrderEmbedding_surjective + + +def primalSplit : J ≃ₗᵢ[ℝ] RealSum2 SegmentLenses.J := heightEquiv.trans Levels.primalSplit + + +def dualSplit : X ≃ₗᵢ[ℝ] RealSum2 SegmentLenses.X := + (dualTransport heightEquiv).trans Levels.dualSplit + +@[simp] theorem shift_component (v : Vertex) : + (shiftOrderEmbedding v).val.1 = v.val.1.val-1 := rfl + +@[simp] theorem shift_word (v : Vertex) : + (shiftOrderEmbedding v).val.2 = v.val.2 := rfl + +end LevelForest + +namespace SingleTree + + +def IsLeaf {h : ℕ} (v : Vertex h) : Prop := ∀ w : Vertex h, v ≤ w → w = v + +theorem leaf_iff_full_height {h : ℕ} (v : Vertex h) : IsLeaf v ↔ v.val.length = h := by + constructor + · intro hv + apply le_antisymm v.property + by_contra! hlt + let w : Vertex h := ⟨v.val++[0],by simpa using Nat.succ_le_of_lt hlt⟩ + have hp : v ≤ w := by + change v.val.IsPrefix (v.val++[0]) + exact List.prefix_append _ _ + have he := congrArg (fun w : Vertex h => w.val.length) (hv w hp) + simp [w] at he + + · intro hv w hp + apply Subtype.ext + have hp' : v.val.IsPrefix w.val := hp + have hw := w.property + have he : v.val.length = w.val.length := by + have hle := hp'.length_le + omega + exact (hp'.eq_of_length he).symm + + + +theorem every_n_levels_leaf_steps {n : ℕ} (hn : 1 ≤ n) (v : Vertex (n-1)) + (hleaf : IsLeaf v) : extensionSteps v = n-1 ∧ extensionSteps v+1 = n := by + have he := (leaf_iff_full_height v).mp hleaf + change v.val.length = n-1 ∧ v.val.length+1 = n + exact ⟨he,by rw [he]; exact Nat.sub_add_cancel hn⟩ + +end SingleTree + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Completed.lean b/lean/OAI/Analysis/SegmentLenses/Completed.lean new file mode 100644 index 0000000000000000000000000000000000000000..c65fd08e19ee94a50cd42f443922c0ea70927cd6 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Completed.lean @@ -0,0 +1,299 @@ +import OAI.Analysis.SegmentLenses.TailBudget + +namespace OAI + +/-! +# Completed midpoint bounds and coordinate density +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + +instance infiniteLocallyFiniteBot : LocallyFiniteOrderBot InfiniteVertex := by + classical + exact LocallyFiniteOrderBot.ofIic InfiniteVertex (fun b => b.inits.toFinset) + (fun a x => by simp [List.mem_inits, LE.le]) + +instance forestLocallyFiniteBot : LocallyFiniteOrderBot ForestVertex := by + classical + have hf : ∀ b : ForestVertex, {v : ForestVertex | v ≤ b}.Finite := by + intro b + apply Set.Finite.of_injOn (f := fun v : ForestVertex => v.val.2) + (t := {w : List ℕ | w.IsPrefix b.val.2}) + · intro v hv + exact hv.2 + · intro v hv w hw he + apply Subtype.ext + exact Prod.ext (hv.1.trans hw.1.symm) he + · exact b.val.2.inits.finite_toSet.subset (by + intro w hw + exact (List.mem_inits w b.val.2).mpr hw) + exact LocallyFiniteOrderBot.ofIic ForestVertex (fun b => (hf b).toFinset) + (fun a x => by simp) + +section FiniteAncestry +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrderBot V] + +def ancestralHull (S : Finset V) : Finset V := S.biUnion Finset.Iic + +theorem subset_ancestralHull (S : Finset V) : S ⊆ ancestralHull S := by + intro v hv + exact Finset.mem_biUnion.mpr ⟨v, hv, Finset.mem_Iic.mpr le_rfl⟩ + +theorem ancestralHull_ancestral (S : Finset V) : Ancestral (· ≤ ·) (ancestralHull S) := by + intro v w hv hwv + obtain ⟨b, hb, hvb⟩ := Finset.mem_biUnion.mp hv + exact Finset.mem_biUnion.mpr ⟨b, hb, Finset.mem_Iic.mpr (hwv.trans (Finset.mem_Iic.mp hvb))⟩ + +end FiniteAncestry + +section LocalizingTests +variable {V : Type*} [DecidableEq V] [SegmentSystem V] + +theorem head_pairing_of_support (K : Finset V) (y : FullDual V) (u : Test V) + (hu : u.coeff.support ⊆ K) : head K y (u : Primal V) = y (u : Primal V) := by + rw [head_pairing] + have he : u.coeff.filter (· ∈ K) = u.coeff := by + ext v + by_cases hv : v ∈ K + · simp [hv] + · have hz : u.coeff v = 0 := Finsupp.notMem_support_iff.mp (fun h => hv (hu h)) + simp [hv, hz] + rw [he] + rfl + +theorem tail_head_pairing (H K : Finset V) (y : FullDual V) (u : Test V) + (hu : u.coeff.support ⊆ K) : tail H (head K y) (u : Primal V) = tail H y (u : Primal V) := by + rw [tail_pairing, tail_pairing] + apply head_pairing_of_support + change (u.coeff.filter (· ∉ H)).support ⊆ K + rw [Finsupp.support_filter] + exact (Finset.filter_subset _ _).trans hu + +end LocalizingTests + +section CompletedMain +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + + +theorem completed_main_tail {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hx : head H x = x) + (R : ℝ) (hR : 0 ≤ R) (hp : ‖x + y‖ ≤ R) (hm : ‖x - y‖ ≤ R) : + ‖tail H y‖ ≤ 2 * Real.sqrt (R ^ 2 - ‖x‖ ^ 2) := by + apply dual_norm_le _ (mul_nonneg (by norm_num) (Real.sqrt_nonneg _)) + intro u + let K := ancestralHull (H ∪ u.coeff.support) + have hK : Ancestral (· ≤ ·) K := ancestralHull_ancestral _ + have hHK : H ⊆ K := Finset.subset_union_left.trans (subset_ancestralHull _) + have huK : u.coeff.support ⊆ K := Finset.subset_union_right.trans (subset_ancestralHull _) + have hxK := head_eq_of_subset hHK x hx + have hpK : ‖x + head K y‖ ≤ R := by + have he : x + head K y = head K (x + y) := by + change x + headLinear K y = headLinear K (x + y) + simp only [map_add, headLinear_apply, hxK] + rw [he] + exact (norm_head_le hK (x + y)).trans hp + have hmK : ‖x - head K y‖ ≤ R := by + have he : x - head K y = head K (x - y) := by + change x - headLinear K y = headLinear K (x - y) + simp only [map_sub, headLinear_apply, hxK] + rw [he] + exact (norm_head_le hK (x - y)).trans hm + have hb := finite_main_tail hH hK hHK x (head K y) hx (head_head K y) R hR hpK hmK + rw [← tail_head_pairing H K y u huK] + have hop := (tail H (head K y)).le_opNorm (u : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at hop + exact hop.trans (mul_le_mul_of_nonneg_right hb (norm_nonneg u)) + +end CompletedMain + + +theorem forest_main_tail (H : Finset ForestVertex) (hH : Ancestral ForestAncestor H) + (x y : X) (hx : x = head H x) (R : ℝ) (hR : 0 ≤ R) + (hp : ‖x + y‖ ≤ R) (hm : ‖x - y‖ ≤ R) : + ‖tail H y‖ ≤ 2 * Real.sqrt (R ^ 2 - ‖x‖ ^ 2) := + by + classical + exact completed_main_tail hH x y hx.symm R hR hp hm + + + +theorem infinite_main_tail (H : Finset InfiniteVertex) (hH : Ancestral List.IsPrefix H) + (x y : BInfinite) (hx : x.val = head H x.val) (R : ℝ) (hR : 0 ≤ R) + (hp : ‖x + y‖ ≤ R) (hm : ‖x - y‖ ≤ R) : + ‖tail H y.val‖ ≤ 2 * Real.sqrt (R ^ 2 - ‖x‖ ^ 2) := + by + classical + exact completed_main_tail hH x.val y.val hx.symm R hR hp hm + +section CoordinateNorms +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + +theorem norm_test_unit (v : V) : ‖(Test.ofFinsupp (Finsupp.single v 1) : Test V)‖ = 1 := by + have _ := decidableEqV + apply le_antisymm + · change segmentSeminorm V (Finsupp.single v 1) ≤ 1 + rw [segmentSeminorm_apply] + apply ciSup_le + intro F + change ‖F.test (Finsupp.single v 1)‖ ≤ 1 + simpa [SegmentFamily.test, Finsupp.linearCombination_single] using F.norm_column_le v + · change 1 ≤ segmentSeminorm V (Finsupp.single v 1) + have h := abs_coord_le (Finsupp.single v (1 : ℝ)) v + simpa using h + +@[simp] theorem norm_unitVector (v : V) : ‖unitVector v‖ = 1 := by + rw [unitVector, UniformSpace.Completion.norm_coe, norm_test_unit] + +@[simp] theorem norm_coordinate (v : V) : ‖coordinate v‖ = 1 := by + apply le_antisymm + · apply dual_norm_le _ (by norm_num) + intro u + rw [coordinate_apply_test, one_mul] + exact abs_coord_le u.coeff v + · have h := (coordinate v).le_opNorm (unitVector v) + simpa [coordinate_unitVector] using h + +theorem coordinate_mem_span (v : V) : + coordinate v ∈ Submodule.span ℝ (Set.range (coordinate (V := V))) := by + have _ := decidableEqV + exact + Submodule.subset_span ⟨v, rfl⟩ + +theorem coordinate_mem (v : V) : coordinate v ∈ coordinateSpan V := + (Submodule.le_topologicalClosure _) (coordinate_mem_span v) + +theorem head_mem_span (H : Finset V) (x : FullDual V) : + head H x ∈ Submodule.span ℝ (Set.range (coordinate (V := V))) := by + apply Submodule.sum_mem + intro v hv + exact Submodule.smul_mem _ _ (coordinate_mem_span v) + +theorem head_mem (H : Finset V) (x : FullDual V) : head H x ∈ coordinateSpan V := + (Submodule.le_topologicalClosure _) (head_mem_span H x) + + +def predualCoordinate (v : V) : CoordinatePredual V := ⟨coordinate v, coordinate_mem v⟩ + +@[simp] theorem norm_predualCoordinate (v : V) : ‖predualCoordinate v‖ = 1 := norm_coordinate v + + +theorem span_finitely_supported (z : FullDual V) + (hz : z ∈ Submodule.span ℝ (Set.range (coordinate (V := V)))) : + ∃ H : Finset V, head H z = z := by + classical + induction hz using Submodule.span_induction with + | mem z hz => + obtain ⟨v, rfl⟩ := hz + refine ⟨{v}, (head_eq_iff _ _).mpr ?_⟩ + intro w hw + have hn : v ≠ w := by simpa only [Finset.mem_singleton, eq_comm] using hw + simp [coordinate_unitVector, hn] + | zero => exact ⟨∅, by simp [head]⟩ + | add z w hz hw hz' hw' => + obtain ⟨H, hH⟩ := hz' + obtain ⟨K, hK⟩ := hw' + refine ⟨H ∪ K, (head_eq_iff _ _).mpr ?_⟩ + intro v hv + rw [_root_.add_apply, (head_eq_iff _ _).mp hH v (fun h => hv (Finset.mem_union_left _ h)), + (head_eq_iff _ _).mp hK v (fun h => hv (Finset.mem_union_right _ h)), add_zero] + | smul a z hz hz' => + obtain ⟨H, hH⟩ := hz' + refine ⟨H, (head_eq_iff _ _).mpr ?_⟩ + intro v hv + simp only [_root_.smul_apply, smul_eq_mul, (head_eq_iff _ _).mp hH v hv, mul_zero] + +end CoordinateNorms + +section CoordinateDensity +variable {V : Type*} [DecidableEq V] [PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + + + +theorem predual_finite_approx (x : CoordinatePredual V) {ε : ℝ} (hε : 0 < ε) : + ∃ H : Finset V, Ancestral (· ≤ ·) H ∧ ∃ z : FullDual V, head H z = z ∧ ‖x.val - z‖ < ε := by + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + have hx : x.val ∈ closure ((Submodule.span ℝ (Set.range (coordinate (V := V)))) : Set (FullDual V)) := x.property + obtain ⟨z, hz, hdist⟩ := Metric.mem_closure_iff.mp hx ε hε + obtain ⟨H, hH⟩ := span_finitely_supported z hz + exact ⟨ancestralHull H, ancestralHull_ancestral H, z, + head_eq_of_subset (subset_ancestralHull H) z hH, by simpa only [dist_eq_norm] using hdist⟩ + + + +theorem predual_small_tail (x : CoordinatePredual V) (H : Finset V) {ε : ℝ} (hε : 0 < ε) : + ∃ K : Finset V, Ancestral (· ≤ ·) K ∧ H ⊆ K ∧ ‖tail K x.val‖ < ε := by + obtain ⟨L, hL, z, hz, he⟩ := predual_finite_approx x hε + let K := ancestralHull (H ∪ L) + have hK : Ancestral (· ≤ ·) K := ancestralHull_ancestral _ + have hHK : H ⊆ K := Finset.subset_union_left.trans (subset_ancestralHull _) + have hLK : L ⊆ K := Finset.subset_union_right.trans (subset_ancestralHull _) + have hzK := head_eq_of_subset hLK z hz + have heq : tail K x.val = tail K (x.val - z) := by + change tailLinear K x.val = tailLinear K (x.val - z) + simp only [map_sub, tailLinear_apply] + rw [show tail K z = 0 by simp [tail, hzK], sub_zero] + exact ⟨K, hK, hHK, by rw [heq]; exact (norm_tail_le hK _).trans_lt he⟩ + + +def predualHead {H : Finset V} (hH : Ancestral (· ≤ ·) H) : + CoordinatePredual V →L[ℝ] CoordinatePredual V := by + let f : CoordinatePredual V →ₗ[ℝ] CoordinatePredual V := + LinearMap.codRestrict (coordinateSpan V) + ((headLinear H).comp (coordinateSpan V).subtype) + (fun x : CoordinatePredual V => head_mem H x.val) + exact LinearMap.mkContinuous (𝕜 := ℝ) (𝕜₂ := ℝ) (E := CoordinatePredual V) + (F := CoordinatePredual V) f 1 (fun x => by + change ‖head H x.val‖ ≤ 1 * ‖x.val‖ + simpa only [one_mul] using norm_head_le hH x.val) + +def predualTail {H : Finset V} (hH : Ancestral (· ≤ ·) H) : + CoordinatePredual V →L[ℝ] CoordinatePredual V := by + let f : CoordinatePredual V →ₗ[ℝ] CoordinatePredual V := + LinearMap.codRestrict (coordinateSpan V) + ((tailLinear H).comp (coordinateSpan V).subtype) + (fun x : CoordinatePredual V => (coordinateSpan V).sub_mem x.property (head_mem H x.val)) + exact LinearMap.mkContinuous (𝕜 := ℝ) (𝕜₂ := ℝ) (E := CoordinatePredual V) + (F := CoordinatePredual V) f 1 (fun x => by + change ‖tail H x.val‖ ≤ 1 * ‖x.val‖ + simpa only [one_mul] using norm_tail_le hH x.val) + +@[simp] theorem predualHead_coe {H : Finset V} (hH : Ancestral (· ≤ ·) H) (x : CoordinatePredual V) : + (predualHead hH x).val = head H x.val := by + have _ := locallyFiniteOrderBotV + exact rfl + +@[simp] theorem predualTail_coe {H : Finset V} (hH : Ancestral (· ≤ ·) H) (x : CoordinatePredual V) : + (predualTail hH x).val = tail H x.val := by + have _ := locallyFiniteOrderBotV + exact rfl + +theorem norm_predualHead_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (x : CoordinatePredual V) : + ‖predualHead hH x‖ ≤ ‖x‖ := by + have _ := locallyFiniteOrderBotV + exact norm_head_le hH x.val + +theorem norm_predualTail_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (x : CoordinatePredual V) : + ‖predualTail hH x‖ ≤ ‖x‖ := by + have _ := locallyFiniteOrderBotV + exact norm_tail_le hH x.val + +end CoordinateDensity + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Components.lean b/lean/OAI/Analysis/SegmentLenses/Components.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2c30283e9b6a3d5156644d03fed34248b5a7bd4 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Components.lean @@ -0,0 +1,359 @@ +import OAI.Analysis.SegmentLenses.EndpointBounds + +namespace OAI + +/-! +# Component partitions and completion decompositions +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +section ComponentPartitions +variable {V I : Type*} [PartialOrder V] + + + +structure ComponentPartition where + index : V → I + comparable : ∀ {v w : V}, v ≤ w → index v = index w + +end ComponentPartitions + +namespace ComponentPartition +open scoped Classical +variable {V I : Type*} [decidableEqV : DecidableEq V] [decidableEqI : DecidableEq I] [PartialOrder V] + [locallyFiniteOrderV : LocallyFiniteOrder V] [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] + [segmentSystemV : SegmentSystem V] [intervalSegmentsV : IntervalSegments V] {p : ComponentPartition (V := V) (I := I)} + +section Blocks + + +def blockTest (h : I) : Test V →ₗ[ℝ] Test V where + toFun u := Test.ofFinsupp (u.coeff.filter (fun v => p.index v = h)) + map_add' _u _v := Finsupp.filter_add + map_smul' _c _u := Finsupp.filter_smul + +@[simp] theorem blockTest_apply (h : I) (u : Test V) (v : V) : + ((blockTest (p := p)) h u).coeff v = if p.index v = h then u.coeff v else 0 := by + have _ := decidableEqV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := segmentSystemV + have _ := intervalSegmentsV + exact Finsupp.filter_apply _ _ _ + +theorem norm_blockTest_le (h : I) (u : Test V) : ‖(blockTest (p := p)) h u‖ ≤ ‖u‖ := by + have _ := locallyFiniteOrderBotV + classical + apply norm_filter_le + intro a b v ha hb hav hvb + exact (p.comparable hav).symm.trans ha + + +theorem segment_same_index {S : Finset V} (hS : SegmentSystem.isSegment S) + {v w : V} (hv : v ∈ S) (hw : w ∈ S) : p.index v = p.index w := by + have _ := decidableEqV + have _ := decidableEqI + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + obtain ⟨a, b, hab, hs⟩ := (IntervalSegments.iff_interval _).mp hS + exact (p.comparable ((hs v).mp hv).1).symm.trans (p.comparable ((hs w).mp hw).1) + +def familyAtBlock (F : SegmentFamily V) (h : I) : + SegmentFamily V where + sets := F.sets.filter (fun S => ∀ v ∈ S, p.index v = h) + segment S hS := F.segment S (Finset.mem_filter.mp hS).1 + disjoint := by + intro S hS T hT hne + exact F.disjoint (Finset.mem_filter.mp hS).1 (Finset.mem_filter.mp hT).1 hne + +theorem atBlock_seminorm (F : SegmentFamily V) (h : I) (u : Test V) : + ((familyAtBlock (p := p)) F h).seminorm u.coeff = F.seminorm ((blockTest (p := p)) h u).coeff := by + have he : ((familyAtBlock (p := p)) F h).seminorm u.coeff ^ 2 = F.seminorm ((blockTest (p := p)) h u).coeff ^ 2 := by + rw [SegmentFamily.seminorm_sq, SegmentFamily.seminorm_sq] + rw [Finset.sum_coe_sort ((familyAtBlock (p := p)) F h).sets (fun S => (∑ v ∈ S, u.coeff v) ^ 2), + Finset.sum_coe_sort F.sets (fun S => (∑ v ∈ S, ((blockTest (p := p)) h u).coeff v) ^ 2)] + change (∑ S ∈ F.sets.filter _, _) = ∑ S ∈ F.sets, _ + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro S hS + split_ifs with hc + · congr 1 + apply Finset.sum_congr rfl + intro v hv + simp only [(blockTest_apply (p := p)), hc v hv, ite_true] + · have hz : ∀ v ∈ S, p.index v ≠ h := by + intro v hv heq + apply hc + intro w hw + exact ((segment_same_index (p := p)) (F.segment S hS) hw hv).trans heq + simp only [(blockTest_apply (p := p))] + simp only [Finset.sum_eq_zero (fun v hv => ite_eq_right (hz v hv)), zero_pow (by decide : 2 ≠ 0)] + nlinarith [apply_nonneg ((familyAtBlock (p := p)) F h).seminorm u.coeff, + apply_nonneg F.seminorm ((blockTest (p := p)) h u).coeff] + +end Blocks + +section NormDecomposition + +def testIndices (u : Test V) : Finset I := u.coeff.support.image p.index + +theorem blockTest_eq_zero {u : Test V} {h : I} (hh : h ∉ (testIndices (p := p)) u) : + (blockTest (p := p)) h u = 0 := by + apply Finsupp.ext + intro v + change ((blockTest (p := p)) h u).coeff v = 0 + rw [(blockTest_apply (p := p))] + split_ifs with hv + · apply Finsupp.notMem_support_iff.mp + intro hs + exact hh (Finset.mem_image.mpr ⟨v, hs, hv⟩) + · rfl + +theorem blockTest_idem (h : I) (u : Test V) : + (blockTest (p := p)) h ((blockTest (p := p)) h u) = (blockTest (p := p)) h u := by + apply Finsupp.ext + intro v + change ((blockTest (p := p)) h ((blockTest (p := p)) h u)).coeff v = ((blockTest (p := p)) h u).coeff v + by_cases hv : p.index v = h <;> simp [(blockTest_apply (p := p)), hv] + +theorem blockTest_ne {h k : I} (hk : h ≠ k) (u : Test V) : + (blockTest (p := p)) h ((blockTest (p := p)) k u) = 0 := by + apply Finsupp.ext + intro v + change ((blockTest (p := p)) h ((blockTest (p := p)) k u)).coeff v = 0 + simp only [(blockTest_apply (p := p))] + split_ifs with hv hv' + · exact (hk (hv.symm.trans hv')).elim + · rfl + · rfl + + +theorem norm_sq_decomposition (u : Test V) : + ‖u‖ ^ 2 = ∑ h ∈ (testIndices (p := p)) u, ‖(blockTest (p := p)) h u‖ ^ 2 := by + classical + apply le_antisymm + · obtain ⟨F, hF⟩ := exists_norming_family u + have he : F.seminorm u.coeff ^ 2 = + ∑ h ∈ (testIndices (p := p)) u, F.seminorm ((blockTest (p := p)) h u).coeff ^ 2 := by + simp_rw [F.seminorm_sq] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + obtain ⟨a, b, hab, hs⟩ := (IntervalSegments.iff_interval _).mp (F.segment S.val S.property) + have hc : ∀ v ∈ S.val, p.index v = p.index a := fun v hv => (p.comparable ((hs v).mp hv).1).symm + have hv : ∀ h, (∑ v ∈ S.val, ((blockTest (p := p)) h u).coeff v) ^ 2 = + if h = p.index a then (∑ v ∈ S.val, u.coeff v) ^ 2 else 0 := by + intro h + by_cases hh : h = p.index a + · subst h + simp only [(blockTest_apply (p := p)), Finset.sum_congr rfl (fun v hv => ite_eq_left (hc v hv)), ite_true] + · have hn : ∀ v ∈ S.val, p.index v ≠ h := fun v hv he => hh (he.symm.trans (hc v hv)) + simp only [(blockTest_apply (p := p)), Finset.sum_congr rfl (fun v hv => ite_eq_right (hn v hv)), Finset.sum_const_zero, + zero_pow (by decide : 2 ≠ 0), ite_eq_right hh] + simp_rw [hv] + by_cases ha : p.index a ∈ (testIndices (p := p)) u + · simp only [Finset.sum_ite_eq', ite_eq_left ha] + · have hz : ∑ v ∈ S.val, u.coeff v = 0 := by + apply Finset.sum_eq_zero + intro v hv + apply Finsupp.notMem_support_iff.mp + intro hvs + exact ha (Finset.mem_image.mpr ⟨v, hvs, hc v hv⟩) + simp [hz] + rw [← hF, he] + exact Finset.sum_le_sum (fun h _ => sq_le_sq₀ (apply_nonneg _ _) (norm_nonneg _) |>.mpr + (le_segmentSeminorm _ _)) + · have hex : ∀ h : (testIndices (p := p)) u, ∃ F : SegmentFamily V, + F.seminorm ((blockTest (p := p)) h.val u).coeff = ‖(blockTest (p := p)) h.val u‖ := + fun h => exists_norming_family _ + choose F hF using hex + let G : (testIndices (p := p)) u → SegmentFamily V := fun h => (familyAtBlock (p := p)) (F h) h.val + have hn : ∀ h, (G h).seminorm u.coeff = ‖(blockTest (p := p)) h.val u‖ := by + intro h + exact ((atBlock_seminorm (p := p)) (F h) h.val u).trans (hF h) + let pieces : (h : (testIndices (p := p)) u) × (G h).sets → Finset V := fun j => j.2.val + have hseg : ∀ j, pieces j = ∅ ∨ SegmentSystem.isSegment (pieces j) := fun j => + Or.inr ((G j.1).segment _ j.2.property) + have hd : Pairwise fun i j => Disjoint (pieces i) (pieces j) := by + intro i j hij + by_cases hh : i.1 = j.1 + · rcases i with ⟨i, S⟩ + rcases j with ⟨j, T⟩ + dsimp at hh + subst j + exact (G i).disjoint S.property T.property (fun he => hij (by cases Subtype.ext he; rfl)) + · apply Finset.disjoint_left.mpr + intro v hv hw + have hvh := (Finset.mem_filter.mp i.2.property).2 v hv + have hwh := (Finset.mem_filter.mp j.2.property).2 v hw + exact hh (Subtype.ext (hvh.symm.trans hwh)) + have hb := indexed_test_bound u.coeff pieces hseg hd + change (∑ j, (∑ v ∈ pieces j, u.coeff v) ^ 2) ≤ ‖u‖ ^ 2 at hb + rw [Fintype.sum_sigma] at hb + have he : (∑ h : (testIndices (p := p)) u, ∑ S : (G h).sets, (∑ v ∈ S.val, u.coeff v) ^ 2) = + ∑ h ∈ (testIndices (p := p)) u, ‖(blockTest (p := p)) h u‖ ^ 2 := by + rw [← Finset.sum_coe_sort ((testIndices (p := p)) u) (fun h => ‖(blockTest (p := p)) h u‖ ^ 2)] + apply Finset.sum_congr rfl + intro h hh + rw [← (G h).seminorm_sq, hn] + exact he ▸ hb + +end NormDecomposition + +def blockTests (h : I) : Submodule ℝ (Test V) := LinearMap.range ((blockTest (p := p)) h) + +theorem mem_blockTests {h : I} {u : Test V} : + u ∈ (blockTests (p := p)) h ↔ (blockTest (p := p)) h u = u := by + constructor + · rintro ⟨v, rfl⟩ + exact (blockTest_idem (p := p)) h v + · intro hu + exact ⟨u, hu⟩ + +abbrev BlockPrimal (h : I) := UniformSpace.Completion ((blockTests (p := p)) h) + +section CompletionIdentification + +local instance heightPrimalFamilyNormed : ∀ h, NormedAddCommGroup ((BlockPrimal (p := p)) h) := fun _h => inferInstance +local instance blockPrimalFamilySpace : ∀ h, NormedSpace ℝ ((BlockPrimal (p := p)) h) := fun _h => inferInstance +local instance : Module ℝ (Primal V) := (inferInstance : NormedSpace ℝ (Primal V)).toModule +local instance : Module ℝ (L2Sum (BlockPrimal (p := p))) := (inferInstance : NormedSpace ℝ (L2Sum (BlockPrimal (p := p)))).toModule +local instance : AddCommMonoid (L2Sum (BlockPrimal (p := p))) := + (inferInstance : NormedAddCommGroup (L2Sum (BlockPrimal (p := p)))).toAddCommMonoid + + +def completedBlockTest (h : I) : Test V →ₗ[ℝ] (BlockPrimal (p := p)) h := + (UniformSpace.Completion.toComplL : (blockTests (p := p)) h →L[ℝ] (BlockPrimal (p := p)) h).toLinearMap.comp + ((blockTest (p := p)) h).rangeRestrict + +@[simp] theorem norm_completedBlockTest (h : I) (u : Test V) : + ‖(completedBlockTest (p := p)) h u‖ = ‖(blockTest (p := p)) h u‖ := by + have _ := decidableEqV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + exact UniformSpace.Completion.norm_coe _ + +theorem completedBlockTest_zero {h : I} {u : Test V} (hz : (blockTest (p := p)) h u = 0) : + (completedBlockTest (p := p)) h u = 0 := by + apply norm_eq_zero.mp + exact ((norm_completedBlockTest (p := p)) h u).trans (by rw [hz, norm_zero]) + +def blockVector (u : Test V) : L2Sum (BlockPrimal (p := p)) := + ∑ h ∈ (testIndices (p := p)) u, lp.single 2 h ((completedBlockTest (p := p)) h u) + +@[simp] theorem blockVector_apply (u : Test V) (h : I) : + (blockVector (p := p)) u h = (completedBlockTest (p := p)) h u := by + classical + simp only [blockVector, lp.coeFn_sum, Finset.sum_apply] + rw [Finset.sum_eq_single h] + · exact lp.single_apply_self _ _ _ + · intro k hk hkh + exact lp.single_apply_ne _ _ _ hkh.symm + · intro hh + simp only [(completedBlockTest_zero (p := p)) ((blockTest_eq_zero (p := p)) hh), lp.single_zero, lp.coeFn_zero, Pi.zero_apply] + +def testBlocks : Test V →ₗ[ℝ] L2Sum (BlockPrimal (p := p)) where + toFun := (blockVector (p := p)) + map_add' u v := by + apply Subtype.ext + funext h + simp only [(blockVector_apply (p := p)), lp.coeFn_add, Pi.add_apply, map_add] + map_smul' c u := by + apply Subtype.ext + funext h + simp only [(blockVector_apply (p := p)), lp.coeFn_smul, Pi.smul_apply, map_smul, RingHom.id_apply] + +@[simp] theorem testBlocks_apply (u : Test V) (h : I) : + (testBlocks (p := p)) u h = (completedBlockTest (p := p)) h u := (blockVector_apply (p := p)) u h + +theorem norm_testBlocks (u : Test V) : ‖(testBlocks (p := p)) u‖ = ‖u‖ := by + have he : ‖(testBlocks (p := p)) u‖ ^ 2 = ‖u‖ ^ 2 := by + change ‖∑ h ∈ (testIndices (p := p)) u, lp.single 2 h ((completedBlockTest (p := p)) h u)‖ ^ 2 = _ + rw [l2_norm_sum_single_sq, (norm_sq_decomposition (p := p))] + simp only [(norm_completedBlockTest (p := p))] + exact (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp he + + + +theorem testBlocks_of_height (h : I) (u : (blockTests (p := p)) h) : + (testBlocks (p := p)) u.val = lp.single 2 h (u : (BlockPrimal (p := p)) h) := by + classical + apply Subtype.ext + funext k + rw [(testBlocks_apply (p := p))] + by_cases hk : k = h + · subst k + rw [lp.single_apply_self] + change ((⟨(blockTest (p := p)) h u.val, _⟩ : (blockTests (p := p)) h) : (BlockPrimal (p := p)) h) = _ + congr 1 + exact Subtype.ext ((mem_blockTests (p := p)).mp u.property) + · rw [lp.single_apply_ne _ _ _ hk] + apply (completedBlockTest_zero (p := p)) + rw [← (mem_blockTests (p := p)).mp u.property] + exact (blockTest_ne (p := p)) hk u.val + + + +theorem testBlocks_dense : DenseRange (testBlocks (p := p)) := by + classical + let M := (LinearMap.range (testBlocks (p := p))).topologicalClosure + have hclosed : IsClosed (M : Set (L2Sum (BlockPrimal (p := p)))) := Submodule.isClosed_topologicalClosure _ + have hs : ∀ h (x : (BlockPrimal (p := p)) h), lp.single 2 h x ∈ M := by + intro h x + refine UniformSpace.Completion.induction_on x + (p := fun x => lp.single 2 h x ∈ M) + (by exact hclosed.preimage (lp.singleContinuousLinearMap ℝ (BlockPrimal (p := p)) 2 h).continuous) ?_ + intro u + apply Submodule.le_topologicalClosure + exact ⟨u.val, (testBlocks_of_height (p := p)) h u⟩ + intro x + change x ∈ M + apply hclosed.mem_of_tendsto (lp.hasSum_single (by norm_num : (2 : ℝ≥0∞) ≠ ⊤) x) + exact Filter.Eventually.of_forall (fun s => M.sum_mem (fun h hh => hs h (x h))) + + +def l2Equiv : (Primal V) ≃ₗᵢ[ℝ] L2Sum (BlockPrimal (p := p)) := + (LinearEquiv.refl ℝ (Test V)).extendOfIsometry + (UniformSpace.Completion.toComplL : Test V →L[ℝ] (Primal V)).toLinearMap + (testBlocks (p := p)) UniformSpace.Completion.denseRange_coe (testBlocks_dense (p := p)) + (fun u => by + change ‖(testBlocks (p := p)) u‖ = ‖(u : (Primal V))‖ + rw [UniformSpace.Completion.norm_coe] + exact (norm_testBlocks (p := p)) u) + +@[simp] theorem l2Equiv_test (u : Test V) : + (l2Equiv (p := p)) (u : (Primal V)) = (testBlocks (p := p)) u := + by + change (l2Equiv (p := p)) ((UniformSpace.Completion.toComplL : Test V →L[ℝ] (Primal V)) u) = _ + unfold l2Equiv + exact + (LinearEquiv.extendOfIsometry_eq (LinearEquiv.refl ℝ (Test V)) + (UniformSpace.Completion.toComplL : Test V →L[ℝ] (Primal V)).toLinearMap + (testBlocks (p := p)) UniformSpace.Completion.denseRange_coe (testBlocks_dense (p := p)) + (fun u => by change ‖(testBlocks (p := p)) u‖ = ‖(u : (Primal V))‖; rw [UniformSpace.Completion.norm_coe]; exact (norm_testBlocks (p := p)) u) u) + + +end CompletionIdentification +end ComponentPartition + + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/ConeBlocks.lean b/lean/OAI/Analysis/SegmentLenses/ConeBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a802aa2d31deb06b1a3db45b8080801f16e01f4 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/ConeBlocks.lean @@ -0,0 +1,175 @@ +import OAI.Analysis.SegmentLenses.Gates + +namespace OAI + +/-! +# Component and cone decompositions +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +namespace SegmentEmbedding +variable {V W : Type*} [DecidableEq V] [DecidableEq W] [SegmentSystem V] [SegmentSystem W] + +theorem norm_testL2_map (e : SegmentEmbedding (V := V) (W := W)) (u : Test V) : + ‖testL2 (e.testMap u)‖ = ‖testL2 u‖ := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [norm_testL2_sq,norm_testL2_sq] + change (∑ w ∈ (u.coeff.embDomain e.toEmbedding).support, (e.testMap u).coeff w ^ 2) = _ + rw [Finsupp.support_embDomain,Finset.sum_map] + simp only [e.testMap_apply] + +end SegmentEmbedding + +namespace SingleTree +local instance (h : ℕ) : DecidableEq (Vertex h) := Classical.decEq _ + + +theorem component_estimate (h : ℕ) (u : Test (Vertex h)) : + ‖testL2 u‖ ≤ ‖u‖ ∧ ‖u‖ ≤ Real.sqrt (h+1) * ‖testL2 u‖ := by + classical + refine ⟨norm_testL2_le u,?_⟩ + let e := componentEmbedding (height := fun _ : Unit => h) () + have hs := IndexedForest.height_hilbert_upper (height := fun _ : Unit => h) () (e.testMap u) + (IndexedForest.mem_heightTests.mp (componentTestMap (height := fun _ : Unit => h) () u).property) + rw [← norm_testL2_sq, e.norm_testMap,e.norm_testL2_map] at hs + have hr : Real.sqrt (h+1) ^ 2 = (h+1 : ℝ) := Real.sq_sqrt (by positivity) + have hn : 0 ≤ Real.sqrt (h+1) * ‖testL2 u‖ := mul_nonneg (Real.sqrt_nonneg _) (norm_nonneg _) + apply (sq_le_sq₀ (norm_nonneg _) hn).mp + rw [mul_pow,hr] + exact hs + + +theorem levels_component_estimate {n : ℕ} (hn : 1 ≤ n) (u : Test (Vertex (n-1))) : + ‖testL2 u‖ ≤ ‖u‖ ∧ ‖u‖ ≤ Real.sqrt n * ‖testL2 u‖ := by + have h := component_estimate (n-1) u + have he : (n-1 : ℕ) + 1 = n := Nat.sub_add_cancel hn + have her : (↑(n-1) + 1 : ℝ) = n := by exact_mod_cast he + simpa only [her] using h + + + +def extensionSteps {h : ℕ} (v : Vertex h) : ℕ := v.val.length + +def root (h : ℕ) : Vertex h := ⟨[],by simp⟩ + +def zeroLeaf (h : ℕ) : Vertex h := ⟨List.replicate h 0,by simp⟩ + +@[simp] theorem root_steps (h : ℕ) : extensionSteps (root h) = 0 := rfl +@[simp] theorem leaf_steps (h : ℕ) : extensionSteps (zeroLeaf h) = h := List.length_replicate + +theorem child_steps {h : ℕ} (v w : Vertex h) (n : ℕ) (hw : w.val = v.val ++ [n]) : + extensionSteps w = extensionSteps v + 1 := by simp [extensionSteps,hw] + +theorem n_levels_path {n : ℕ} (hn : 1 ≤ n) : + extensionSteps (zeroLeaf (n-1)) = n-1 ∧ + extensionSteps (zeroLeaf (n-1)) + 1 = n := by + rw [leaf_steps] + exact ⟨rfl,Nat.sub_add_cancel hn⟩ + +end SingleTree + + +namespace ComponentPartition +open scoped Classical +variable {V I : Type*} [DecidableEq V] [DecidableEq I] [PartialOrder V] + [LocallyFiniteOrder V] [LocallyFiniteOrderBot V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] (p : ComponentPartition (V := V) (I := I)) +local instance : ∀ i, NormedAddCommGroup (BlockPrimal (p := p) i) := fun _i => inferInstance +local instance : ∀ i, NormedSpace ℝ (BlockPrimal (p := p) i) := fun _i => inferInstance + +@[simp] theorem regionL2Equiv_regionMap (i : I) (u : Primal (BlockVertex p i)) : + regionL2Equiv p ((regionEmbedding p i).primalMap u) = lp.single 2 i u := by + refine UniformSpace.Completion.induction_on u + (isClosed_eq ((regionL2Equiv p).continuous.comp (regionEmbedding p i).primalMap.continuous) + (lp.singleContinuousLinearMap ℝ (fun j => Primal (BlockVertex p j)) 2 i).continuous) ?_ + intro u + rw [SegmentEmbedding.primalMap_test] + change l2Congr (fun j => (regionPrimalEquiv p j).symm) + (l2Equiv (p := p) (((regionTestMap p i u).val) : Primal V)) = _ + rw [l2Equiv_test,testBlocks_of_height] + apply Subtype.ext + funext j + rw [l2Congr_apply] + by_cases hji : j=i + · subst j + rw [lp.single_apply_self,lp.single_apply_self,← regionPrimalEquiv_test, + LinearIsometryEquiv.symm_apply_apply] + · rw [lp.single_apply_ne _ _ _ hji,lp.single_apply_ne _ _ _ hji,map_zero] + +@[simp] theorem regionDualL2Equiv_apply (z : FullDual V) (i : I) (u : Primal (BlockVertex p i)) : + regionDualL2Equiv p z i u = z ((regionEmbedding p i).primalMap u) := by + change ((l2DualEquiv (fun j => Primal (BlockVertex p j))).symm + (dualTransport (regionL2Equiv p) z)) i u = _ + rw [l2DualEquiv_symm_apply] + change z ((regionL2Equiv p).symm (lp.single 2 i u)) = _ + rw [← regionL2Equiv_regionMap p i u,LinearIsometryEquiv.symm_apply_apply] + +end ComponentPartition + +section ConeDecomposition +open scoped Classical ENNReal +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + +abbrev ConeVertex (g : V) := Region.Vertex (fun v => g ≤ v) + +def coneEmbedding (g : V) : SegmentEmbedding (V := ConeVertex g) (W := V) := + Region.embedding (fun _a _b _v ha _hb hav _hvb => ha.trans hav) + + +def coneBlockOrderEmbedding (H : Finset V) (hH : Ancestral (· ≤ ·) H) (g : {g // Gate H g}) : + ConeVertex g.val ↪o ComponentPartition.BlockVertex (exteriorPartition H) g where + toFun v := ⟨⟨v.val,fun hv => g.property.1 (hH hv v.property)⟩, + (exteriorGate_eq_iff H _ g).mpr v.property⟩ + inj' := by + intro v w he + exact Subtype.ext (congrArg (fun q : ComponentPartition.BlockVertex (exteriorPartition H) g => q.val.val) he) + map_rel_iff' := Iff.rfl + +theorem coneBlockOrderEmbedding_surjective (H : Finset V) (hH : Ancestral (· ≤ ·) H) (g : {g // Gate H g}) : + Function.Surjective (coneBlockOrderEmbedding H hH g) := by + intro v + refine ⟨⟨v.val.val,(exteriorGate_eq_iff H v.val g).mp v.property⟩,?_⟩ + rfl + +def coneBlockEmbedding (H : Finset V) (hH : Ancestral (· ≤ ·) H) (g : {g // Gate H g}) : + SegmentEmbedding (V := ConeVertex g.val) + (W := ComponentPartition.BlockVertex (exteriorPartition H) g) := + convexSegmentEmbedding (coneBlockOrderEmbedding H hH g) + (fun {_ _ w} _ _ _ _ => coneBlockOrderEmbedding_surjective H hH g w) + +def coneBlockEquiv (H : Finset V) (hH : Ancestral (· ≤ ·) H) (g : {g // Gate H g}) : + Primal (ConeVertex g.val) ≃ₗᵢ[ℝ] Primal (ComponentPartition.BlockVertex (exteriorPartition H) g) := + (coneBlockEmbedding H hH g).primalEquivOfSurjective (coneBlockOrderEmbedding_surjective H hH g) + + + +def exteriorConeL2Equiv (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + Primal (ExteriorVertex H) ≃ₗᵢ[ℝ] L2Sum (fun g : {g // Gate H g} => Primal (ConeVertex g.val)) := + (ComponentPartition.regionL2Equiv (exteriorPartition H)).trans + (l2Congr (fun g => (coneBlockEquiv H hH g).symm)) + +def exteriorConeDualL2Equiv (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + FullDual (ExteriorVertex H) ≃ₗᵢ[ℝ] L2Sum (fun g : {g // Gate H g} => FullDual (ConeVertex g.val)) := + (ComponentPartition.regionDualL2Equiv (exteriorPartition H)).trans + (l2Congr (fun g => dualTransport (coneBlockEquiv H hH g).symm)) + +end ConeDecomposition + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/ConeNorms.lean b/lean/OAI/Analysis/SegmentLenses/ConeNorms.lean new file mode 100644 index 0000000000000000000000000000000000000000..4afc2ad0dfd0988eac94b356c89d4ff0dd955a00 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/ConeNorms.lean @@ -0,0 +1,320 @@ +import OAI.Analysis.SegmentLenses.ConeBlocks + +namespace OAI + +/-! +# Cone norms, separated families, and level forests +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +namespace SegmentEmbedding +variable {V W : Type*} [DecidableEq V] [DecidableEq W] [SegmentSystem V] [SegmentSystem W] + +theorem primalEquivOfSurjective_eq_map (e : SegmentEmbedding (V := V) (W := W)) + (he : Function.Surjective e.toEmbedding) (x : Primal V) : + e.primalEquivOfSurjective he x = e.primalMap x := by + refine UniformSpace.Completion.induction_on x + (isClosed_eq (e.primalEquivOfSurjective he).continuous e.primalMap.continuous) ?_ + intro u + rw [e.primalEquivOfSurjective_test,e.primalMap_test] + +end SegmentEmbedding + +section ConeNorms +open scoped Classical ENNReal +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + +def coneDual (g : V) (z : FullDual V) : FullDual (ConeVertex g) := + z.comp (coneEmbedding g).primalMap + + + +theorem cone_inclusion_composition (H : Finset V) (hH : Ancestral (· ≤ ·) H) + (g : {g // Gate H g}) (u : Primal (ConeVertex g.val)) : + (exteriorEmbedding H hH).primalMap + ((ComponentPartition.regionEmbedding (exteriorPartition H) g).primalMap + (coneBlockEquiv H hH g u)) = (coneEmbedding g.val).primalMap u := by + have he : coneBlockEquiv H hH g u = (coneBlockEmbedding H hH g).primalMap u := + SegmentEmbedding.primalEquivOfSurjective_eq_map _ _ _ + rw [he] + refine UniformSpace.Completion.induction_on u + (isClosed_eq ((exteriorEmbedding H hH).primalMap.continuous.comp + ((ComponentPartition.regionEmbedding (exteriorPartition H) g).primalMap.continuous.comp + (coneBlockEmbedding H hH g).primalMap.continuous)) (coneEmbedding g.val).primalMap.continuous) ?_ + intro v + rw [test_as_sum v] + simp only [map_sum,map_smul] + apply Finset.sum_congr rfl + intro w hw + rw [SegmentEmbedding.primalMap_unitVector, SegmentEmbedding.primalMap_unitVector, + SegmentEmbedding.primalMap_unitVector,SegmentEmbedding.primalMap_unitVector] + rfl + +@[simp] theorem exteriorConeDual_apply (H : Finset V) (hH : Ancestral (· ≤ ·) H) + (z : FullDual V) (g : {g // Gate H g}) : + exteriorConeDualL2Equiv H hH (exteriorDual H hH z) g = coneDual g.val z := by + apply ContinuousLinearMap.ext + intro u + change ComponentPartition.regionDualL2Equiv (exteriorPartition H) + (exteriorDual H hH z) g (coneBlockEquiv H hH g u) = _ + rw [ComponentPartition.regionDualL2Equiv_apply] + change z ((exteriorEmbedding H hH).primalMap + ((ComponentPartition.regionEmbedding (exteriorPartition H) g).primalMap + (coneBlockEquiv H hH g u))) = z ((coneEmbedding g.val).primalMap u) + rw [cone_inclusion_composition] + + + + +theorem complementary_cone_norm (H : Finset V) (hH : Ancestral (· ≤ ·) H) (z : FullDual V) : + ‖tail H z‖^2 = ∑' g : {g // Gate H g}, ‖coneDual g.val z‖^2 := by + have h := lp.norm_rpow_eq_tsum (p := 2) (by norm_num : 0 < (2 : ℝ≥0∞).toReal) + (exteriorConeDualL2Equiv H hH (exteriorDual H hH z)) + simpa only [ENNReal.toReal_ofNat, Real.rpow_two, LinearIsometryEquiv.norm_map, + norm_exteriorDual, exteriorConeDual_apply] using h + + + +theorem exterior_range_eq_tail (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + (exteriorEmbedding H hH).primalIsometry.range = (primalTail H).range := by + ext x + constructor + · rintro ⟨u,rfl⟩ + exact ⟨(exteriorEmbedding H hH).primalMap u,primalTail_exterior H hH u⟩ + · rintro ⟨u,rfl⟩ + exact ⟨(exteriorEmbedding H hH).primalRestriction u,exterior_primalTail H hH u⟩ + +def exteriorToTailEquiv (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + Primal (ExteriorVertex H) ≃ₗᵢ[ℝ] (primalTail H).range := + (exteriorEmbedding H hH).primalIsometry.equivRange.trans + (LinearIsometryEquiv.ofEq _ _ (exterior_range_eq_tail H hH)) + + + +def complementary_cone_isometry (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + (primalTail H).range ≃ₗᵢ[ℝ] L2Sum (fun g : {g // Gate H g} => Primal (ConeVertex g.val)) := + (exteriorToTailEquiv H hH).symm.trans (exteriorConeL2Equiv H hH) + +end ConeNorms + + + + + +theorem infinite_separated_family {D : ℝ} (hD : 1 ≤ D) : + ∃ c : ℝ, 0 < c ∧ ∀ (x : BInfinite) (z : ℕ → BInfinite), + 1 ≤ ‖x‖ → ‖x‖ ≤ D → (∀ i, ‖z i‖ ≤ 2*D) → + (∀ i j, i ≠ j → 1 ≤ ‖z i-z j‖) → + ∃ i, ‖x‖+c < max ‖x+z i‖ ‖x-z i‖ := by + classical + exact separated_predual_family (V := InfiniteVertex) hD + + + +theorem forest_separated_family {D : ℝ} (hD : 1 ≤ D) : + ∃ c : ℝ, 0 < c ∧ ∀ (x : X) (z : ℕ → X), + 1 ≤ ‖x‖ → ‖x‖ ≤ D → (∀ i, ‖z i‖ ≤ 2*D) → + (∀ i j, i ≠ j → 1 ≤ ‖z i-z j‖) → + ∃ i, ‖x‖+c < max ‖x+z i‖ ‖x-z i‖ := by + classical + obtain ⟨c,hc,h⟩ := separated_predual_family (V := ForestVertex) hD + refine ⟨c,hc,?_⟩ + intro x z hx hxD hz hsep + have hmem : ∀ w : X, w ∈ coordinateSpan ForestVertex := by + intro w + rw [forest_coordinateSpan_eq_top] + trivial + exact h ⟨x,hmem x⟩ (fun i => ⟨z i,hmem (z i)⟩) hx hxD hz hsep + + + +section SingletonPrimal +variable {V : Type*} [Unique V] [SegmentSystem V] + + +def singletonTestEquiv : Test V ≃ₗᵢ[ℝ] ℝ where + toFun u := u.coeff default + invFun c := Test.ofFinsupp (Finsupp.single default c) + left_inv u := by + apply Finsupp.ext + intro v + have hv : v = default := Subsingleton.elim _ _ + subst v + simp [Test.coeff,Test.ofFinsupp] + right_inv c := by simp [Test.coeff,Test.ofFinsupp] + map_add' u v := rfl + map_smul' c u := rfl + norm_map' u := by + change ‖u.coeff default‖ = ‖u‖ + have he : u = u.coeff default • Test.ofFinsupp (Finsupp.single default 1) := by + apply Finsupp.ext + intro v + change u.coeff v = (u.coeff default • Finsupp.single default 1 : V →₀ ℝ) v + have hv : v = default := Subsingleton.elim _ _ + subst v + change u.coeff default = u.coeff default * (Finsupp.single default (1:ℝ)) default + simp + conv_rhs => rw [he,norm_smul,norm_test_unit,mul_one] + +def singletonPrimalEquiv : Primal V ≃ₗᵢ[ℝ] ℝ := + (singletonTestEquiv (V := V)).toLinearEquiv.extendOfIsometry + (UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V).toLinearMap + (LinearMap.id : ℝ →ₗ[ℝ] ℝ) + UniformSpace.Completion.denseRange_coe (by exact denseRange_id) + (fun u => by + change ‖singletonTestEquiv u‖ = ‖(u : Primal V)‖ + rw [UniformSpace.Completion.norm_coe,LinearIsometryEquiv.norm_map]) + +@[simp] theorem singletonPrimalEquiv_test (u : Test V) : + singletonPrimalEquiv (u : Primal V) = u.coeff default := by + change singletonPrimalEquiv ((UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V) u) = _ + unfold singletonPrimalEquiv + exact LinearEquiv.extendOfIsometry_eq _ _ _ _ _ _ u + +end SingletonPrimal + + +def realDualEquiv : StrongDual ℝ ℝ ≃ₗᵢ[ℝ] ℝ where + toFun f := f 1 + invFun c := c • ContinuousLinearMap.id ℝ ℝ + left_inv f := by + apply ContinuousLinearMap.ext + intro x + have h := f.map_smul x (1:ℝ) + simpa [mul_comm] using h.symm + right_inv c := by simp + map_add' f g := rfl + map_smul' c f := rfl + norm_map' f := by + change ‖f 1‖ = ‖f‖ + apply le_antisymm + · simpa using f.le_opNorm (1:ℝ) + · apply f.opNorm_le_bound (norm_nonneg _) + intro x + have h := f.map_smul x (1:ℝ) + simp only [smul_eq_mul,mul_one] at h + rw [h,norm_mul,mul_comm] + + +def RealSum2Fiber (E : Type) : Bool → Type + | false => ℝ + | true => E + +instance realSum2FiberGroup (E : Type) [NormedAddCommGroup E] : + (b : Bool) → NormedAddCommGroup (RealSum2Fiber E b) + | false => inferInstanceAs (NormedAddCommGroup ℝ) + | true => inferInstanceAs (NormedAddCommGroup E) + +instance realSum2FiberSpace (E : Type) [NormedAddCommGroup E] [NormedSpace ℝ E] : + (b : Bool) → NormedSpace ℝ (RealSum2Fiber E b) + | false => inferInstanceAs (NormedSpace ℝ ℝ) + | true => inferInstanceAs (NormedSpace ℝ E) + +instance realSum2FiberComplete (E : Type) [NormedAddCommGroup E] [CompleteSpace E] : + (b : Bool) → CompleteSpace (RealSum2Fiber E b) + | false => inferInstanceAs (CompleteSpace ℝ) + | true => inferInstanceAs (CompleteSpace E) + + + +abbrev RealSum2 (E : Type) [NormedAddCommGroup E] := L2Sum (RealSum2Fiber E) + +theorem realSum2_norm_sq {E : Type} [NormedAddCommGroup E] (u : RealSum2 E) : + ‖u‖^2 = ‖u false‖^2 + ‖u true‖^2 := by + have h := lp.norm_rpow_eq_tsum (p := 2) (by norm_num : 0 < (2 : ℝ≥0∞).toReal) u + simpa only [ENNReal.toReal_ofNat,Real.rpow_two,tsum_fintype,Fintype.sum_bool,add_comm] using h + +namespace Levels +open scoped Classical + + + +abbrev Vertex := IndexedForest.Vertex (fun h : ℕ => h) +abbrev J := Primal Vertex +abbrev X := FullDual Vertex + +def partition : ComponentPartition (V := Vertex) (I := Bool) where + index v := decide (v.val.1 ≠ 0) + comparable := by intro v w hvw; simp only [hvw.1] + +abbrev RootBlock := ComponentPartition.BlockVertex partition false +abbrev ForestBlock := ComponentPartition.BlockVertex partition true + +def root : RootBlock := ⟨⟨(0,[]),by simp⟩,by simp [partition]⟩ + +instance : Unique RootBlock where + default := root + uniq v := by + have hi : v.val.val.1 = 0 := by + have h : decide (v.val.val.1 ≠ 0) = false := v.property + exact not_not.mp (of_decide_eq_false h) + have hw : v.val.val.2 = [] := by + have h := v.val.property + change v.val.val.2.length ≤ v.val.val.1 at h + rw [hi] at h + exact List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero h) + apply Subtype.ext + apply Subtype.ext + exact Prod.ext hi hw + + + +def forestOrderEmbedding : ForestVertex ↪o ForestBlock where + toFun v := ⟨⟨v.val,v.property.2⟩,by + change decide (v.val.1 ≠ 0) = true + have hh := v.property.1 + exact decide_eq_true (by omega : v.val.1 ≠ 0)⟩ + inj' := by intro v w h; exact Subtype.ext (congrArg (fun q : ForestBlock => q.val.val) h) + map_rel_iff' := Iff.rfl + +theorem forestOrderEmbedding_surjective : Function.Surjective forestOrderEmbedding := by + intro v + have hi : v.val.val.1 ≠ 0 := by + have h : decide (v.val.val.1 ≠ 0) = true := v.property + exact of_decide_eq_true h + refine ⟨⟨v.val.val,⟨by omega,v.val.property⟩⟩,?_⟩ + rfl + +def forestEmbedding : SegmentEmbedding (V := ForestVertex) (W := ForestBlock) := + convexSegmentEmbedding forestOrderEmbedding (fun {_ _ v} _ _ _ _ => forestOrderEmbedding_surjective v) + +def forestBlockEquiv : SegmentLenses.J ≃ₗᵢ[ℝ] Primal ForestBlock := + forestEmbedding.primalEquivOfSurjective forestOrderEmbedding_surjective + + +def primalSplit : J ≃ₗᵢ[ℝ] RealSum2 SegmentLenses.J := + (ComponentPartition.regionL2Equiv partition).trans + (l2Congr (fun b => by + cases b + · exact singletonPrimalEquiv (V := RootBlock) + · exact forestBlockEquiv.symm)) + + +def dualSplit : X ≃ₗᵢ[ℝ] RealSum2 SegmentLenses.X := + (ComponentPartition.regionDualL2Equiv partition).trans + (l2Congr (fun b => by + cases b + · exact (dualTransport (singletonPrimalEquiv (V := RootBlock))).trans realDualEquiv + · exact dualTransport forestBlockEquiv.symm)) + +end Levels + + + + +end SegmentLenses + + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Coordinates.lean b/lean/OAI/Analysis/SegmentLenses/Coordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9ce9eea21464a2bb6c67dfe03389f7374af3aaf --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Coordinates.lean @@ -0,0 +1,172 @@ +import OAI.Analysis.SegmentLenses.ForestDual + +namespace OAI + +/-! +# Coordinate identification and bounded multipliers +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +section PrimalCoordinateDensity +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + +theorem primal_small_tail (x : Primal V) (H : Finset V) {ε : ℝ} (hε : 0 < ε) : + ∃ K : Finset V, Ancestral (· ≤ ·) K ∧ H ⊆ K ∧ ‖primalTail K x‖ < ε := by + obtain ⟨_, ⟨u, rfl⟩, hu⟩ := Metric.mem_closure_iff.mp + (UniformSpace.Completion.denseRange_coe x) ε hε + let K := ancestralHull (H ∪ u.coeff.support) + have hK : Ancestral (· ≤ ·) K := ancestralHull_ancestral _ + have hs : u.coeff.support ⊆ K := Finset.subset_union_right.trans (subset_ancestralHull _) + have hfix : primalTail K (u : Primal V) = 0 := by + change (u : Primal V) - primalHead K u = 0 + rw [primalHead_fix _ u hs, sub_self] + refine ⟨K, hK, Finset.subset_union_left.trans (subset_ancestralHull _), ?_⟩ + have he : primalTail K x = primalTail K (x - u) := by rw [map_sub, hfix, sub_zero] + rw [he] + exact (norm_primalTail_le hK _).trans_lt (by simpa only [dist_eq_norm, norm_sub_rev] using hu) + +theorem primal_eq_zero_of_coordinates (x : Primal V) (hx : ∀ v, coordinate v x = 0) : x = 0 := by + apply norm_eq_zero.mp + apply le_antisymm _ (norm_nonneg _) + apply le_of_forall_pos_lt_add + intro ε hε + obtain ⟨K, hK, hsub, htail⟩ := primal_small_tail x ∅ hε + have hz : primalHead K x = 0 := by simp [primalHead_apply, hx] + simpa only [primalTail, sub_apply, ContinuousLinearMap.id_apply, hz, + sub_zero, zero_add] using htail + + + +theorem coordinateSpan_eq_top_of_reflexive (hV : Reflexive (Primal V)) : + coordinateSpan V = ⊤ := by + let M := coordinateSpan V + let : IsClosed (M : Set (FullDual V)) := Submodule.isClosed_topologicalClosure _ + let : NormedAddCommGroup (FullDual V ⧸ M) := Submodule.Quotient.normedAddCommGroup M + apply top_unique + intro x hx + by_contra hxm + have hqx : M.mkQL x ≠ 0 := by + intro hz + apply hxm + exact (Submodule.Quotient.mk_eq_zero M).mp hz + obtain ⟨g, hg, hgx⟩ := exists_dual_vector ℝ (M.mkQL x) (norm_ne_zero_iff.mpr hqx) + obtain ⟨p, hp⟩ := hV (g.comp M.mkQL) + have hpc : ∀ v, coordinate v p = 0 := by + intro v + have he := congrArg (fun f : StrongDual ℝ (FullDual V) => f (coordinate v)) hp + change coordinate v p = g (M.mkQL (coordinate v)) at he + rwa [show M.mkQL (coordinate v) = 0 by + exact (Submodule.Quotient.mk_eq_zero M).mpr (coordinate_mem v), map_zero] at he + have hp0 := primal_eq_zero_of_coordinates p hpc + have he := congrArg (fun f : StrongDual ℝ (FullDual V) => f x) hp + change x p = g (M.mkQL x) at he + rw [hp0, map_zero, hgx] at he + exact hqx (norm_eq_zero.mp he.symm) + +theorem fullDual_small_tail_of_reflexive (hV : Reflexive (Primal V)) + (x : FullDual V) (H : Finset V) {ε : ℝ} (hε : 0 < ε) : + ∃ K : Finset V, Ancestral (· ≤ ·) K ∧ H ⊆ K ∧ ‖tail K x‖ < ε := by + have hx : x ∈ coordinateSpan V := by rw [coordinateSpan_eq_top_of_reflexive hV]; trivial + exact predual_small_tail (⟨x, hx⟩ : CoordinatePredual V) H hε + + +theorem predual_head_tendsto (x : CoordinatePredual V) (H : ℕ → Finset V) + (hH : ∀ n, Ancestral (· ≤ ·) (H n)) (hmono : Monotone H) + (hex : ∀ v, ∃ n, v ∈ H n) : + Filter.Tendsto (fun n => head (H n) x.val) Filter.atTop (nhds x.val) := by + apply Metric.tendsto_atTop.mpr + intro ε hε + obtain ⟨K, hK, z, hz, he⟩ := predual_finite_approx x hε + have hevent : ∀ᶠ n in Filter.atTop, K ⊆ H n := by + apply (Finset.eventually_all _).mpr + intro v hv + obtain ⟨N, hN⟩ := hex v + exact Filter.eventually_atTop.mpr ⟨N, fun n hn => hmono hn hN⟩ + obtain ⟨N, hN⟩ := Filter.eventually_atTop.mp hevent + refine ⟨N, fun n hn => ?_⟩ + have hz' := head_eq_of_subset (hN n hn) z hz + have htail : tail (H n) x.val = tail (H n) (x.val - z) := by + change tailLinear (H n) x.val = tailLinear (H n) (x.val - z) + rw [map_sub] + simp only [tailLinear_apply, tail, hz', sub_self, sub_zero] + rw [dist_eq_norm, norm_sub_rev] + change ‖tail (H n) x.val‖ < ε + rw [htail] + exact (norm_tail_le (hH n) _).trans_lt he + +theorem fullDual_head_tendsto_of_reflexive (hV : Reflexive (Primal V)) + (x : FullDual V) (H : ℕ → Finset V) + (hH : ∀ n, Ancestral (· ≤ ·) (H n)) (hmono : Monotone H) + (hex : ∀ v, ∃ n, v ∈ H n) : + Filter.Tendsto (fun n => head (H n) x) Filter.atTop (nhds x) := by + have hx : x ∈ coordinateSpan V := by rw [coordinateSpan_eq_top_of_reflexive hV]; trivial + exact predual_head_tendsto (⟨x, hx⟩ : CoordinatePredual V) H hH hmono hex + + + +theorem fullDual_all_radius_average_of_reflexive [Infinite V] (hV : Reflexive (Primal V)) + {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 ≤ averagedModulus (FullDual V) t := by + apply averagedModulus_lower fullDual_not_finite ht.le + intro x ε hε + have hx : x.val ∈ coordinateSpan V := by rw [coordinateSpan_eq_top_of_reflexive hV]; trivial + obtain ⟨H, hH, hw⟩ := predual_averaged_witness (⟨x.val, hx⟩ : CoordinatePredual V) + x.property ht hε + let f : FullDual V →L[ℝ] (H → ℝ) := + ContinuousLinearMap.pi (fun v => ContinuousLinearMap.apply ℝ ℝ (unitVector v.val)) + refine ⟨CofiniteSubspace.ofMap f, ?_⟩ + intro y + have hy : y.val ∈ coordinateSpan V := by rw [coordinateSpan_eq_top_of_reflexive hV]; trivial + apply hw (⟨y.val, hy⟩ : CoordinatePredual V) _ y.property.2.ge + apply Finset.sum_eq_zero + intro v hv + have he := congrFun y.property.1 (⟨v, hv⟩ : H) + change y.val (unitVector v) = 0 at he + rw [he, zero_smul] + +end PrimalCoordinateDensity + +theorem forest_coordinateSpan_eq_top : coordinateSpan ForestVertex = ⊤ := by + classical + exact coordinateSpan_eq_top_of_reflexive forest_primal_reflexive + +theorem forest_all_radius_average {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) / 2 ≤ averagedModulus X t := by + classical + exact fullDual_all_radius_average_of_reflexive forest_primal_reflexive ht + +section Separability +variable {V : Type*} [SegmentSystem V] [Countable V] + +theorem coordinateSpan_isSeparable : TopologicalSpace.IsSeparable (coordinateSpan V : Set (FullDual V)) := + ((Set.countable_range (coordinate (V := V))).isSeparable.span).closure + +theorem fullDual_separable_of_coordinateSpan (hV : coordinateSpan V = ⊤) : TopologicalSpace.SeparableSpace (FullDual V) := by + have h := coordinateSpan_isSeparable (V := V) + rw [hV, Submodule.top_coe] at h + exact TopologicalSpace.isSeparable_univ_iff.mp h + +end Separability + +instance : Countable ForestVertex := by unfold ForestVertex; infer_instance + +theorem forest_separable : TopologicalSpace.SeparableSpace X := + fullDual_separable_of_coordinateSpan forest_coordinateSpan_eq_top + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/DualSums.lean b/lean/OAI/Analysis/SegmentLenses/DualSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dcc863c135ebf86f87457e7e1134b2b1e7567a3 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/DualSums.lean @@ -0,0 +1,257 @@ +import OAI.Analysis.SegmentLenses.Obstructions + +namespace OAI + +/-! +# Duality and reflexivity for Hilbertian sums +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + +open scoped ENNReal + + +def Reflexive (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] : Prop := + Function.Surjective (NormedSpace.inclusionInDoubleDual ℝ E) + +section L2Duality +variable {I : Type*} [decidableEqI : DecidableEq I] (E : I → Type*) [∀ i, NormedAddCommGroup (E i)] [iNormedSpaceEi : ∀ i, NormedSpace ℝ (E i)] + +abbrev L2Sum := lp E 2 + +def l2Restriction (F : StrongDual ℝ (L2Sum E)) (i : I) : StrongDual ℝ (E i) := + F.comp (lp.singleContinuousLinearMap ℝ E 2 i) + +@[simp] theorem l2Restriction_apply (F : StrongDual ℝ (L2Sum E)) (i : I) (x : E i) : + l2Restriction E F i x = F (lp.single 2 i x) := rfl + +theorem l2_norm_sum_single_sq (s : Finset I) (x : ∀ i, E i) : + ‖∑ i ∈ s, lp.single 2 i (x i)‖ ^ 2 = ∑ i ∈ s, ‖x i‖ ^ 2 := by + have _ := iNormedSpaceEi + simpa only [ENNReal.toReal_ofNat, Real.rpow_two] using + lp.norm_sum_single (p := 2) (by norm_num : 0 < (2 : ℝ≥0∞).toReal) x s + + + +theorem l2Restriction_square_sum (F : StrongDual ℝ (L2Sum E)) (s : Finset I) : + ∑ i ∈ s, ‖l2Restriction E F i‖ ^ 2 ≤ ‖F‖ ^ 2 := by + classical + let M : I → ℝ := fun i => ‖l2Restriction E F i‖ + let S := ∑ i ∈ s, M i ^ 2 + let A := ∑ i ∈ s, M i + have hM : ∀ i, 0 ≤ M i := fun i => norm_nonneg _ + have hS : 0 ≤ S := Finset.sum_nonneg (fun i _ => sq_nonneg _) + have hA : 0 ≤ A := Finset.sum_nonneg (fun i _ => hM i) + have hmain : S ≤ ‖F‖ * Real.sqrt S := by + apply le_of_forall_pos_le_add + intro ε hε + let δ := ε / (A + 1) + have hδ : 0 < δ := div_pos hε (by linarith) + have hex : ∀ i, ∃ x : E i, ‖x‖ < 1 ∧ M i - δ < ‖l2Restriction E F i x‖ := by + intro i + exact (l2Restriction E F i).exists_lt_apply_of_lt_opNorm (by dsimp only [M]; linarith) + choose x hxn hxe using hex + let y : ∀ i, E i := fun i => if 0 ≤ l2Restriction E F i (x i) then x i else -x i + have hyn : ∀ i, ‖y i‖ ≤ 1 := by + intro i + dsimp only [y] + split_ifs <;> simpa only [norm_neg] using (hxn i).le + have hye : ∀ i, l2Restriction E F i (y i) = ‖l2Restriction E F i (x i)‖ := by + intro i + dsimp only [y] + split_ifs with hi + · exact (abs_of_nonneg hi).symm + · rw [map_neg, Real.norm_eq_abs, abs_of_neg (lt_of_not_ge hi)] + let z : L2Sum E := ∑ i ∈ s, lp.single 2 i (M i • y i) + have hzn : ‖z‖ ≤ Real.sqrt S := by + apply Real.le_sqrt_of_sq_le + rw [l2_norm_sum_single_sq] + apply Finset.sum_le_sum + intro i hi + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (hM i)] + have hb : M i * ‖y i‖ ≤ M i := by nlinarith [hM i, hyn i] + nlinarith [mul_nonneg (hM i) (norm_nonneg (y i))] + have hze : F z = ∑ i ∈ s, M i * ‖l2Restriction E F i (x i)‖ := by + simp only [z, map_sum] + apply Finset.sum_congr rfl + intro i hi + change l2Restriction E F i (M i • y i) = _ + rw [map_smul, smul_eq_mul, hye] + have hlow : S - δ * A ≤ F z := by + rw [hze] + change (∑ i ∈ s, M i ^ 2) - δ * (∑ i ∈ s, M i) ≤ _ + rw [Finset.mul_sum, ← Finset.sum_sub_distrib] + apply Finset.sum_le_sum + intro i hi + have h := mul_le_mul_of_nonneg_left (hxe i).le (hM i) + nlinarith + have hhigh : F z ≤ ‖F‖ * Real.sqrt S := by + exact (le_abs_self _).trans ((F.le_opNorm z).trans + (mul_le_mul_of_nonneg_left hzn (norm_nonneg _))) + have hδε : δ * A < ε := by + dsimp only [δ] + rw [div_mul_eq_mul_div] + apply (div_lt_iff₀ (by linarith : 0 < A + 1)).mpr + nlinarith + linarith + change S ≤ ‖F‖ ^ 2 + have hs := Real.sq_sqrt hS + nlinarith [Real.sqrt_nonneg S, norm_nonneg F] + + +def l2DualRestrictions (F : StrongDual ℝ (L2Sum E)) : L2Sum (fun i => StrongDual ℝ (E i)) := + ⟨l2Restriction E F, memℓp_gen' (C := ‖F‖ ^ 2) (fun s => by + simpa only [ENNReal.toReal_ofNat, Real.rpow_two] using l2Restriction_square_sum E F s)⟩ + + +def l2DualPair : L2Sum (fun i => StrongDual ℝ (E i)) →L[ℝ] StrongDual ℝ (L2Sum E) := + lp.dualPairing 2 2 (fun i => ContinuousLinearMap.id ℝ (StrongDual ℝ (E i))) + (K := 1) (fun _ => ContinuousLinearMap.norm_id_le) + +@[simp] theorem l2DualPair_apply (f : L2Sum (fun i => StrongDual ℝ (E i))) (x : L2Sum E) : + l2DualPair E f x = ∑' i, f i (x i) := by + have _ := decidableEqI + exact rfl + +theorem l2DualPair_norm_le : ‖l2DualPair E‖ ≤ 1 := by + have _ := decidableEqI + exact + lp.norm_dualPairing _ _ + +@[simp] theorem l2DualPair_single (f : L2Sum (fun i => StrongDual ℝ (E i))) (i : I) (x : E i) : + l2DualPair E f (lp.single 2 i x) = f i x := by + classical + rw [l2DualPair_apply] + rw [tsum_eq_single i] + · rw [lp.single_apply_self] + · intro j hji + rw [lp.single_apply_ne 2 i x hji, map_zero] + +@[simp] theorem l2DualPair_restrictions (F : StrongDual ℝ (L2Sum E)) : + l2DualPair E (l2DualRestrictions E F) = F := by + apply ContinuousLinearMap.ext + intro x + have h1 := (l2DualPair E (l2DualRestrictions E F)).hasSum (lp.hasSum_single (by norm_num) x) + have h2 := F.hasSum (lp.hasSum_single (by norm_num) x) + simp only [l2DualPair_single, l2DualRestrictions, l2Restriction_apply] at h1 + exact h1.unique h2 + +@[simp] theorem l2DualRestrictions_pair (f : L2Sum (fun i => StrongDual ℝ (E i))) : + l2DualRestrictions E (l2DualPair E f) = f := by + apply Subtype.ext + funext i + apply ContinuousLinearMap.ext + intro x + exact l2DualPair_single E f i x + +theorem l2DualPair_surjective : Function.Surjective (l2DualPair E) := fun F => + ⟨l2DualRestrictions E F, l2DualPair_restrictions E F⟩ + +theorem l2DualRestrictions_norm_le (F : StrongDual ℝ (L2Sum E)) : + ‖l2DualRestrictions E F‖ ≤ ‖F‖ := by + apply lp.norm_le_of_forall_sum_le (by norm_num) (norm_nonneg _) + intro s + simpa only [ENNReal.toReal_ofNat, Real.rpow_two, l2DualRestrictions] using l2Restriction_square_sum E F s + +theorem l2DualPair_norm_map (f : L2Sum (fun i => StrongDual ℝ (E i))) : + ‖l2DualPair E f‖ = ‖f‖ := by + apply le_antisymm + · exact (l2DualPair E).le_of_opNorm_le (l2DualPair_norm_le E) f |>.trans_eq (one_mul _) + · simpa only [l2DualRestrictions_pair] using l2DualRestrictions_norm_le E (l2DualPair E f) + + +def l2DualEquiv : L2Sum (fun i => StrongDual ℝ (E i)) ≃ₗᵢ[ℝ] StrongDual ℝ (L2Sum E) := + LinearIsometryEquiv.ofSurjective + { toLinearMap := (l2DualPair E).toLinearMap, norm_map' := l2DualPair_norm_map E } + (l2DualPair_surjective E) + + +theorem l2Sum_reflexive (hE : ∀ i, Reflexive (E i)) : Reflexive (L2Sum E) := by + intro Φ + let G := Φ.comp (l2DualPair E) + let z := l2DualRestrictions (fun i => StrongDual ℝ (E i)) G + have hex : ∀ i, ∃ x : E i, NormedSpace.inclusionInDoubleDual ℝ (E i) x = z i := + fun i => hE i (z i) + choose x hx using hex + have hnorm : ∀ i, ‖x i‖ = ‖z i‖ := by + intro i + have h := (NormedSpace.inclusionInDoubleDualLi ℝ (E := E i)).norm_map (x i) + change ‖NormedSpace.inclusionInDoubleDual ℝ (E i) (x i)‖ = _ at h + rw [hx] at h + exact h.symm + let u : L2Sum E := ⟨x, memℓp_gen (by + simpa only [hnorm] using (lp.memℓp z).summable (by norm_num : 0 < (2 : ℝ≥0∞).toReal))⟩ + refine ⟨u, ?_⟩ + apply ContinuousLinearMap.ext + intro F + obtain ⟨f, rfl⟩ := l2DualPair_surjective E F + change l2DualPair E f u = Φ (l2DualPair E f) + have hG := l2DualPair_restrictions (fun i => StrongDual ℝ (E i)) G + have hh := congrArg (fun L => L f) hG + change (∑' i, z i (f i)) = Φ (l2DualPair E f) at hh + rw [← hh, l2DualPair_apply] + apply tsum_congr + intro i + have h := congrArg (fun φ => φ (f i)) (hx i) + exact h + +end L2Duality + +section ReflexivityTransport +variable {E D : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup D] [NormedSpace ℝ D] + +theorem Reflexive.of_equiv (hE : Reflexive E) (e : E ≃L[ℝ] D) : Reflexive D := by + intro Φ + let F := Φ.comp (e.symm.toContinuousLinearMap.precomp ℝ) + obtain ⟨x, hx⟩ := hE F + refine ⟨e x, ?_⟩ + apply ContinuousLinearMap.ext + intro g + have h := congrArg (fun L => L (g.comp e.toContinuousLinearMap)) hx + change g (e x) = Φ ((g.comp e.toContinuousLinearMap).comp e.symm.toContinuousLinearMap) at h + have he : (g.comp e.toContinuousLinearMap).comp e.symm.toContinuousLinearMap = g := by + ext y + simp only [ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, e.apply_symm_apply] + rw [he] at h + exact h + +theorem Reflexive.dual (hE : Reflexive E) : Reflexive (StrongDual ℝ E) := by + intro Φ + let x := Φ.comp (NormedSpace.inclusionInDoubleDual ℝ E) + refine ⟨x, ?_⟩ + apply ContinuousLinearMap.ext + intro f + obtain ⟨p, rfl⟩ := hE f + rfl + +end ReflexivityTransport + + +theorem hilbert_reflexive (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [CompleteSpace E] : Reflexive E := by + intro Φ + let j := InnerProductSpace.toDual ℝ E + let g := Φ.comp j.toContinuousLinearEquiv.toContinuousLinearMap + let y := j.symm g + refine ⟨y, ?_⟩ + apply ContinuousLinearMap.ext + intro f + obtain ⟨v, rfl⟩ := j.surjective f + change inner ℝ v y = Φ (j v) + rw [real_inner_comm] + exact InnerProductSpace.toDual_symm_apply + + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Embeddings.lean b/lean/OAI/Analysis/SegmentLenses/Embeddings.lean new file mode 100644 index 0000000000000000000000000000000000000000..c600827c7f00fe6e275e7ea7969000b5133e7633 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Embeddings.lean @@ -0,0 +1,273 @@ +import OAI.Analysis.SegmentLenses.Components + +namespace OAI + +/-! +# Segment embeddings and convex tree regions +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +section SegmentEmbeddings +variable {V W : Type*} [decidableEqV : DecidableEq V] [decidableEqW : DecidableEq W] [SegmentSystem V] [SegmentSystem W] + + + +structure SegmentEmbedding where + toEmbedding : V ↪ W + map_segment : ∀ S : Finset V, SegmentSystem.isSegment S → + SegmentSystem.isSegment (S.map toEmbedding) + preimage_segment : ∀ S : Finset W, SegmentSystem.isSegment S → + S.preimage toEmbedding toEmbedding.injective.injOn = ∅ ∨ + SegmentSystem.isSegment (S.preimage toEmbedding toEmbedding.injective.injOn) + +namespace SegmentEmbedding + +def testMap (e : SegmentEmbedding (V := V) (W := W)) : Test V →ₗ[ℝ] Test W where + toFun u := Test.ofFinsupp (u.coeff.embDomain e.toEmbedding) + map_add' u v := Finsupp.embDomain_add _ _ _ + map_smul' c u := by + apply Finsupp.ext + intro w + change Finsupp.embDomain e.toEmbedding (c • u.coeff) w = c • Finsupp.embDomain e.toEmbedding u.coeff w + rw [Finsupp.embDomain_apply, Finsupp.embDomain_apply] + split_ifs <;> simp + +@[simp] theorem testMap_apply (e : SegmentEmbedding (V := V) (W := W)) (u : Test V) (v : V) : + (e.testMap u).coeff (e.toEmbedding v) = u.coeff v := by + have _ := decidableEqV + have _ := decidableEqW + exact Finsupp.embDomain_apply_self _ _ _ + +theorem testMap_sum (e : SegmentEmbedding (V := V) (W := W)) (u : Test V) (S : Finset W) : + ∑ w ∈ S, (e.testMap u).coeff w = + ∑ v ∈ S.preimage e.toEmbedding e.toEmbedding.injective.injOn, u.coeff v := by + classical + have h := Finset.sum_preimage e.toEmbedding S e.toEmbedding.injective.injOn + (e.testMap u).coeff (fun w _ hn => Finsupp.embDomain_of_notMem_range e.toEmbedding u.coeff w hn) + simpa only [e.testMap_apply] using h.symm + + +theorem norm_testMap (e : SegmentEmbedding (V := V) (W := W)) (u : Test V) : + ‖e.testMap u‖ = ‖u‖ := by + classical + apply le_antisymm + · change segmentSeminorm W (e.testMap u).coeff ≤ _ + rw [segmentSeminorm_apply] + apply ciSup_le + intro F + let pieces : F.sets → Finset V := fun S => S.val.preimage e.toEmbedding e.toEmbedding.injective.injOn + have hp : ∀ S, pieces S = ∅ ∨ SegmentSystem.isSegment (pieces S) := + fun S => e.preimage_segment S.val (F.segment _ S.property) + have hd : Pairwise fun S T => Disjoint (pieces S) (pieces T) := by + intro S T hST + apply Finset.disjoint_left.mpr + intro v hv hw + exact Finset.disjoint_left.mp (F.disjoint S.property T.property (fun h => hST (Subtype.ext h))) + (Finset.mem_preimage.mp hv) (Finset.mem_preimage.mp hw) + have h := indexed_test_bound u.coeff pieces hp hd + have he : F.seminorm (e.testMap u).coeff ^ 2 = ∑ S, (∑ v ∈ pieces S, u.coeff v)^2 := by + rw [F.seminorm_sq] + simp_rw [e.testMap_sum] + rfl + rw [← he] at h + exact (sq_le_sq₀ (apply_nonneg _ _) (norm_nonneg u)).mp h + · change segmentSeminorm V u.coeff ≤ _ + rw [segmentSeminorm_apply] + apply ciSup_le + intro F + let pieces : F.sets → Finset W := fun S => S.val.map e.toEmbedding + have hp : ∀ S, pieces S = ∅ ∨ SegmentSystem.isSegment (pieces S) := + fun S => Or.inr (e.map_segment S.val (F.segment _ S.property)) + have hd : Pairwise fun S T => Disjoint (pieces S) (pieces T) := by + intro S T hST + apply Finset.disjoint_left.mpr + intro w hw hw' + obtain ⟨v,hv,rfl⟩ := Finset.mem_map.mp hw + obtain ⟨v',hv',he⟩ := Finset.mem_map.mp hw' + have he' := e.toEmbedding.injective he + subst v' + exact Finset.disjoint_left.mp (F.disjoint S.property T.property (fun h => hST (Subtype.ext h))) hv hv' + have h := indexed_test_bound (e.testMap u).coeff pieces hp hd + have he : F.seminorm u.coeff ^ 2 = ∑ S, (∑ w ∈ pieces S, (e.testMap u).coeff w)^2 := by + rw [F.seminorm_sq] + simp only [pieces, Finset.sum_map, e.testMap_apply] + rw [← he] at h + exact (sq_le_sq₀ (apply_nonneg _ _) (norm_nonneg (e.testMap u))).mp h + +def testIsometry (e : SegmentEmbedding (V := V) (W := W)) : Test V →ₗᵢ[ℝ] Test W := + ⟨e.testMap, e.norm_testMap⟩ + +end SegmentEmbedding +end SegmentEmbeddings + + +section ConvexTreeEmbeddings +variable {V W : Type*} [DecidableEq V] [DecidableEq W] + [PartialOrder V] [PartialOrder W] [LocallyFiniteOrder W] + [TreeOrder W] [SegmentSystem V] [SegmentSystem W] + [IntervalSegments V] [IntervalSegments W] + + + +def convexSegmentEmbedding (e : V ↪o W) + (hc : ∀ {a b w : W}, a ∈ Set.range e → b ∈ Set.range e → a ≤ w → w ≤ b → w ∈ Set.range e) : + SegmentEmbedding (V := V) (W := W) where + toEmbedding := e.toEmbedding + map_segment S hS := by + obtain ⟨a,b,hab,hs⟩ := (IntervalSegments.iff_interval S).mp hS + apply (IntervalSegments.iff_interval _).mpr + refine ⟨e a,e b,e.monotone hab,?_⟩ + intro w + constructor + · intro hw + obtain ⟨v,hv,rfl⟩ := Finset.mem_map.mp hw + exact ⟨e.monotone ((hs v).mp hv).1, e.monotone ((hs v).mp hv).2⟩ + · rintro ⟨haw,hwb⟩ + obtain ⟨v,rfl⟩ := hc ⟨a,rfl⟩ ⟨b,rfl⟩ haw hwb + exact Finset.mem_map.mpr ⟨v,(hs v).mpr ⟨e.le_iff_le.mp haw,e.le_iff_le.mp hwb⟩,rfl⟩ + preimage_segment S hS := by + classical + let T := S.filter (fun w => w ∈ Set.range e) + have ht : T = ∅ ∨ SegmentSystem.isSegment T := subinterval_isSegment hS (Finset.filter_subset _ _) (by + intro a ha b hb w haw hwb + exact Finset.mem_filter.mpr ⟨by + obtain ⟨l,r,hlr,hs⟩ := (IntervalSegments.iff_interval S).mp hS + exact (hs w).mpr ⟨((hs a).mp (Finset.mem_filter.mp ha).1).1.trans haw, + hwb.trans ((hs b).mp (Finset.mem_filter.mp hb).1).2⟩, + hc (Finset.mem_filter.mp ha).2 (Finset.mem_filter.mp hb).2 haw hwb⟩) + rcases ht with ht | ht + · left + apply Finset.eq_empty_iff_forall_notMem.mpr + intro v hv + have hm : e v ∈ T := Finset.mem_filter.mpr ⟨Finset.mem_preimage.mp hv,⟨v,rfl⟩⟩ + rw [ht] at hm + exact Finset.notMem_empty _ hm + · right + obtain ⟨a,b,hab,hs⟩ := (IntervalSegments.iff_interval T).mp ht + have ha := (hs a).mpr ⟨le_rfl,hab⟩ + have hb := (hs b).mpr ⟨hab,le_rfl⟩ + obtain ⟨a',rfl⟩ := (Finset.mem_filter.mp ha).2 + obtain ⟨b',rfl⟩ := (Finset.mem_filter.mp hb).2 + apply (IntervalSegments.iff_interval _).mpr + refine ⟨a',b',e.le_iff_le.mp hab,?_⟩ + intro v + rw [Finset.mem_preimage] + have he : e v ∈ S ↔ e v ∈ T := by simp only [T,Finset.mem_filter]; exact ⟨fun h => ⟨h,⟨v,rfl⟩⟩,And.left⟩ + change e v ∈ S ↔ a' ≤ v ∧ v ≤ b' + rw [he,hs] + exact and_congr e.le_iff_le e.le_iff_le + +end ConvexTreeEmbeddings + + + +namespace Region +variable {V : Type*} + + + +def Vertex (P : V → Prop) := {v : V // P v} + +variable {P : V → Prop} [PartialOrder V] +instance : PartialOrder (Vertex P) := inferInstanceAs (PartialOrder {v : V // P v}) +instance [TreeOrder V] : TreeOrder (Vertex P) where + lower_chain := fun {a b c} hab hbc => TreeOrder.lower_chain (V := V) (a := a.val) (b := b.val) (c := c.val) hab hbc + +instance : SegmentSystem (Vertex P) where + isSegment := IsInterval (· ≤ ·) + singleton v := by + refine ⟨v,v,le_rfl,?_⟩ + intro w + simp only [Finset.mem_singleton] + exact ⟨fun h => by subst w; exact ⟨le_rfl,le_rfl⟩, fun h => le_antisymm h.2 h.1⟩ +instance [TreeOrder V] : IntervalSegments (Vertex P) where + iff_interval _ := Iff.rfl + +instance [LocallyFiniteOrder V] : LocallyFiniteOrder (Vertex P) := + LocallyFiniteOrder.ofFiniteIcc (by + intro a b + apply Set.Finite.of_injOn (f := fun v : Vertex P => v.val) (t := Set.Icc a.val b.val) + · intro v hv; exact hv + · exact fun _ _ _ _ h => Subtype.ext h + · exact Set.finite_Icc _ _) + +instance [LocallyFiniteOrderBot V] : LocallyFiniteOrderBot (Vertex P) := by + classical + have hf : ∀ b : Vertex P, {v : Vertex P | v ≤ b}.Finite := by + intro b + apply Set.Finite.of_injOn (f := fun v : Vertex P => v.val) (t := Set.Iic b.val) + · intro v hv; exact hv + · exact fun _ _ _ _ h => Subtype.ext h + · exact Set.finite_Iic _ + exact LocallyFiniteOrderBot.ofIic (Vertex P) (fun b => (hf b).toFinset) (fun a x => by simp) + +instance [Countable V] : Countable (Vertex P) := by unfold Vertex; infer_instance + +def inclusion : Vertex P ↪o V where + toFun := Subtype.val + inj' := Subtype.val_injective + map_rel_iff' := Iff.rfl + +@[simp] theorem range_inclusion : Set.range (inclusion (P := P)) = {v | P v} := by + ext v + exact ⟨fun ⟨w,h⟩ => h ▸ w.property, fun hv => ⟨⟨v,hv⟩,rfl⟩⟩ + +variable [DecidableEq V] [LocallyFiniteOrder V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] +local instance : DecidableEq (Vertex P) := Classical.decEq _ + +def embedding (hc : ∀ a b v, P a → P b → a ≤ v → v ≤ b → P v) : + SegmentEmbedding (V := Vertex P) (W := V) := + convexSegmentEmbedding inclusion (by + intro a b w ha hb haw hwb + rw [range_inclusion] at ha hb ⊢ + exact hc a b w ha hb haw hwb) + +end Region + +namespace SegmentEmbedding +variable {V W : Type*} [DecidableEq V] [DecidableEq W] [SegmentSystem V] [SegmentSystem W] + +def primalMap (e : SegmentEmbedding (V := V) (W := W)) : Primal V →L[ℝ] Primal W := + ((UniformSpace.Completion.toComplL : Test W →L[ℝ] Primal W).comp e.testIsometry.toContinuousLinearMap).extend + UniformSpace.Completion.toComplL + +@[simp] theorem primalMap_test (e : SegmentEmbedding (V := V) (W := W)) (u : Test V) : + e.primalMap (u : Primal V) = (e.testMap u : Primal W) := + ContinuousLinearMap.extend_eq _ UniformSpace.Completion.denseRange_coe + (UniformSpace.Completion.isUniformInducing_coe _) u + +@[simp] theorem norm_primalMap (e : SegmentEmbedding (V := V) (W := W)) (x : Primal V) : + ‖e.primalMap x‖ = ‖x‖ := by + refine UniformSpace.Completion.induction_on x + (isClosed_eq (e.primalMap.continuous.norm) continuous_norm) ?_ + intro u + rw [e.primalMap_test, UniformSpace.Completion.norm_coe, UniformSpace.Completion.norm_coe, e.norm_testMap] + +def primalIsometry (e : SegmentEmbedding (V := V) (W := W)) : Primal V →ₗᵢ[ℝ] Primal W := + ⟨e.primalMap.toLinearMap, e.norm_primalMap⟩ + +theorem primalMap_unitVector (e : SegmentEmbedding (V := V) (W := W)) (v : V) : + e.primalMap (unitVector v) = unitVector (e.toEmbedding v) := by + rw [unitVector, e.primalMap_test] + congr 1 + change Finsupp.embDomain e.toEmbedding (Finsupp.single v 1) = Finsupp.single (e.toEmbedding v) 1 + exact Finsupp.embDomain_single _ _ _ + +end SegmentEmbedding + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/EndpointBounds.lean b/lean/OAI/Analysis/SegmentLenses/EndpointBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..46f63159d7acdaf12f955ba1167a268676612700 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/EndpointBounds.lean @@ -0,0 +1,320 @@ +import OAI.Analysis.SegmentLenses.Separated + +namespace OAI + +/-! +# Endpoint bounds, clipping, and gate coordinates +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +section EndpointGlobal +open scoped Classical +variable {V ΩP ΩM : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + [Fintype ΩP] [Fintype ΩM] + + + + +theorem endpoint_laws_on_gates {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (_hK : Ancestral (· ≤ ·) K) (hHK : H ⊆ K) + (x y : FullDual V) (hx : head H x = x) {d : ℝ} (hd : 0 ≤ d) (_hd1 : d < 1) + (hxn : 1 - d ≤ ‖x‖) (_hplus : ‖x + y‖ ≤ 1) (_hminus : ‖x - y‖ ≤ 1) + (p : Test V) (hpH : p.coeff.support ⊆ H) (hp : ‖p‖ = 1) (hxp : x (p : Primal V) = ‖x‖) + (μP : FiniteLaw ΩP) (μM : FiniteLaw ΩM) + (AP : ΩP → Representation V) (AM : ΩM → Representation V) + (hAP : ∀ ω, (AP ω).energy ≤ 1) (hAM : ∀ ω, (AM ω).energy ≤ 1) + (G : Finset V) (hG : ∀ g ∈ G, Gate H g) + (hmeanP : μP.expect (fun ω => (AP ω).value) = head K (x + y)) + (hmeanM : μM.expect (fun ω => (AM ω).value) = head K (x - y)) : + let mP := fun g : G => μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) + let mM := fun g : G => μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|) + let m := fun g => (mP g + mM g) / 2 + (lawSlack μP AP p + lawError μP AP p ≤ 4 * d) ∧ + (lawSlack μM AM p + lawError μM AM p ≤ 4 * d) ∧ + μP.mean (fun ω => ‖(AP ω).value - ((AP ω).family.replacement p.coeff).value‖) ≤ 2 * Real.sqrt d ∧ + μM.mean (fun ω => ‖(AM ω).value - ((AM ω).family.replacement p.coeff).value‖) ≤ 2 * Real.sqrt d ∧ + (∀ g, 0 ≤ mP g ∧ 0 ≤ mM g ∧ mP g ≤ 2 * m g ∧ mM g ≤ 2 * m g) ∧ + Real.sqrt (∑ g, m g ^ 2) ≤ Real.sqrt (6 * d) := by + classical + dsimp only + let μ := μP.pooled μM + let A := Sum.elim AP AM + have hA : ∀ ω, (A ω).energy ≤ 1 := by intro ω; cases ω with | inl ω => exact hAP ω | inr ω => exact hAM ω + have hmean : μ.expect (fun ω => (A ω).value) = x := by + have he : (fun ω => (A ω).value) = Sum.elim (fun ω => (AP ω).value) (fun ω => (AM ω).value) := by + funext ω; cases ω <;> rfl + rw [he, μP.pooled_expect μM, hmeanP, hmeanM] + change (1/2 : ℝ) • headLinear K (x + y) + (1/2 : ℝ) • headLinear K (x - y) = x + rw [map_add, map_sub, headLinear_apply, head_eq_of_subset hHK x hx] + module + have hdef : lawDeficit μ A p = 1 - ‖x‖ := by rw [lawDeficit, hmean, hxp] + have hdefsum : lawDeficit μP AP p + lawDeficit μM AM p = 2 * (1 - ‖x‖) := by + have he : μ.mean (fun ω => (A ω).value (p : Primal V)) = + (μP.mean (fun ω => (AP ω).value (p : Primal V)) + + μM.mean (fun ω => (AM ω).value (p : Primal V))) / 2 := by + have hf : (fun ω => (A ω).value (p : Primal V)) = + Sum.elim (fun ω => (AP ω).value (p : Primal V)) (fun ω => (AM ω).value (p : Primal V)) := by + funext ω; cases ω <;> rfl + rw [hf] + exact μP.pooled_mean μM _ _ + have he' : μ.mean (fun ω => (A ω).value (p : Primal V)) = ‖x‖ := by + rw [← μ.expect_apply, hmean, hxp] + simp only [lawDeficit, FiniteLaw.expect_apply] + linarith + have hdP := lawDeficit_nonneg μP AP hAP p hp.le + have hdM := lawDeficit_nonneg μM AM hAM p hp.le + have hbP : lawDeficit μP AP p ≤ 2 * d := by linarith + have hbM : lawDeficit μM AM p ≤ 2 * d := by linarith + have hrootP : Real.sqrt (2 * lawDeficit μP AP p) ≤ 2 * Real.sqrt d := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by positivity, ?_⟩ + nlinarith [Real.sq_sqrt hd] + have hrootM : Real.sqrt (2 * lawDeficit μM AM p) ≤ 2 * Real.sqrt d := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by positivity, ?_⟩ + nlinarith [Real.sq_sqrt hd] + refine ⟨?_, ?_, (mean_error_norm_le μP AP hAP p hp.le).trans hrootP, + (mean_error_norm_le μM AM hAM p hp.le).trans hrootM, ?_, ?_⟩ + · have h := (unit_law_budget μP AP hAP p hp.le).2.2 + linarith + · have h := (unit_law_budget μM AM hAM p hp.le).2.2 + linarith + · intro g + have hpos := μP.mean_nonneg (fun ω => abs_nonneg ((AP ω).family.boundary p.coeff g.val)) + have hneg := μM.mean_nonneg (fun ω => abs_nonneg ((AM ω).family.boundary p.coeff g.val)) + exact ⟨hpos, hneg, by linarith, by linarith⟩ + · apply Real.sqrt_le_sqrt + have h := law_absolute_mass_bound hH (G) + hG μ A hA p hp.le hpH + have ht : tail H x = 0 := by simp only [tail, hx, sub_self] + rw [hmean, ht, norm_zero, zero_add, hdef] at h + have hδ : 0 ≤ 1 - ‖x‖ := hdef ▸ lawDeficit_nonneg μ A hA p hp.le + rw [Real.sq_sqrt (mul_nonneg (by norm_num) hδ)] at h + have he : ∀ g : G, μ.mean (fun ω => |(A ω).family.boundary p.coeff g.val|) = + (μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) + + μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|)) / 2 := by + intro g + have hf : (fun ω => |(A ω).family.boundary p.coeff g.val|) = + Sum.elim (fun ω => |(AP ω).family.boundary p.coeff g.val|) + (fun ω => |(AM ω).family.boundary p.coeff g.val|) := by + funext ω; cases ω <;> rfl + rw [hf] + exact μP.pooled_mean μM _ _ + simp_rw [he] at h + linarith + +end EndpointGlobal + + +section LawWrappers +open scoped Classical +variable {V Ω : Type*} [DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] [Fintype Ω] + + + +def lawSupport (A : Ω → Representation V) : Finset V := + Finset.univ.biUnion (fun ω => (A ω).family.sets.biUnion id) + +theorem subset_lawSupport (A : Ω → Representation V) (ω : Ω) (S : Finset V) + (hS : S ∈ (A ω).family.sets) : S ⊆ lawSupport A := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + intro v hv + exact Finset.mem_biUnion.mpr ⟨ω, Finset.mem_univ _, Finset.mem_biUnion.mpr ⟨S,hS,hv⟩⟩ + + +theorem bounded_multiplier {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (A : Ω → Representation V) (hA : ∀ ω, (A ω).energy ≤ 1) + (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) : + ‖tail H (μ.expect (fun ω => σ ω • (A ω).value))‖ ≤ + Real.sqrt ((‖tail H (μ.expect (fun ω => (A ω).value))‖ + Real.sqrt (2 * lawDeficit μ A p)) ^ 2 + + 4 * lawDeficit μ A p) + Real.sqrt (2 * lawDeficit μ A p) ∧ + Real.sqrt ((‖tail H (μ.expect (fun ω => (A ω).value))‖ + Real.sqrt (2 * lawDeficit μ A p)) ^ 2 + + 4 * lawDeficit μ A p) + Real.sqrt (2 * lawDeficit μ A p) ≤ + ‖tail H (μ.expect (fun ω => (A ω).value))‖ + (2+2*Real.sqrt 2)*Real.sqrt (lawDeficit μ A p) := + ⟨represented_bounded_multiplier hH μ A hA (subset_lawSupport A) σ hσ p hp hpH, + stable_radical_linear (norm_nonneg _) (lawDeficit_nonneg μ A hA p hp)⟩ + +end LawWrappers + +namespace FiniteLaw + +def equalPair : FiniteLaw Bool where + weight _ := 1/2 + nonneg _ := by norm_num + total := by norm_num + +@[simp] theorem equalPair_expect {E : Type*} [AddCommMonoid E] [Module ℝ E] (z : Bool → E) : + equalPair.expect z = (1/2:ℝ) • z false + (1/2:ℝ) • z true := by + simp only [expect, equalPair, Fintype.sum_bool, add_comm] + +end FiniteLaw + +section EqualEndpointStability +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + +theorem nonzero_midpoint_bound {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (zp zm : FullDual V) (hpz : ‖zp‖ ≤ 1) (hmz : ‖zm‖ ≤ 1) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) : + let x := (1/2:ℝ) • zp + (1/2:ℝ) • zm + let δ := 1 - x (p : Primal V) + ∀ z ∈ ({zp,zm} : Set (FullDual V)), + ‖tail H z‖ ≤ 2 * Real.sqrt ((‖tail H x‖ + Real.sqrt (2*δ))^2 + 4*δ) + 2*Real.sqrt δ := by + classical + dsimp only + let Z : Bool → FullDual V := fun b => if b then zm else zp + have hZ : ∀ b, ‖Z b‖ ≤ 1 := by intro b; cases b <;> assumption + have hw : ∀ b, 0 < FiniteLaw.equalPair.weight b := by intro b; norm_num [FiniteLaw.equalPair] + have he : FiniteLaw.equalPair.expect Z = (1/2:ℝ)•zp+(1/2:ℝ)•zm := by + rw [FiniteLaw.equalPair_expect]; rfl + have hd := weighted_deficits (H := H) FiniteLaw.equalPair hw Z hZ p hp + have hδ : 0 ≤ 1 - (FiniteLaw.equalPair.expect Z) (p : Primal V) := by + rw [hd.2.1] + exact FiniteLaw.equalPair.mean_nonneg hd.1 + have hb : ∀ b, ‖tail H (Z b)‖ ≤ + 2 * Real.sqrt ((‖tail H (FiniteLaw.equalPair.expect Z)‖ + + Real.sqrt (2*(1-(FiniteLaw.equalPair.expect Z) (p : Primal V))))^2 + + 4*(1-(FiniteLaw.equalPair.expect Z) (p : Primal V))) + + 2*Real.sqrt (1-(FiniteLaw.equalPair.expect Z) (p : Primal V)) := by + intro b + have h := weighted_tail_bound hH FiniteLaw.equalPair hw Z hZ p hp hpH b + have hi := hd.2.2 b + have hweight : FiniteLaw.equalPair.weight b = (1/2:ℝ) := rfl + rw [hweight] at hi h + norm_num only [inv_div, inv_one, div_one] at h + rw [div_div_eq_mul_div, div_one] at hi + have hroot : Real.sqrt (2*(1-Z b (p : Primal V))) ≤ + 2*Real.sqrt (1-(FiniteLaw.equalPair.expect Z) (p : Primal V)) := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by positivity, ?_⟩ + nlinarith [Real.sq_sqrt hδ] + exact h.trans (add_le_add le_rfl hroot) + rw [he] at hb + intro z hz + rcases hz with rfl | rfl + · exact hb false + · exact hb true + +end EqualEndpointStability + + +section SubtypeL2 +open scoped ENNReal +variable {V : Type*} [decidableEqV : DecidableEq V] + + + +theorem subtype_l2_bound (P : V → Prop) (a : V → ℝ) {C : ℝ} (hC : 0 ≤ C) + (h : ∀ G : Finset V, (∀ g ∈ G, P g) → Real.sqrt (∑ g : G, a g.val ^ 2) ≤ C) : + ∃ m : lp (fun _ : {g // P g} => ℝ) 2, (∀ g, m g = a g.val) ∧ ‖m‖ ≤ C := by + have _ := decidableEqV + classical + have hs : ∀ s : Finset {g // P g}, ∑ g ∈ s, ‖a g.val‖^2 ≤ C^2 := by + intro s + let e : {g // P g} ↪ V := ⟨Subtype.val, Subtype.val_injective⟩ + let G := s.map e + have hG : ∀ g ∈ G, P g := by + intro g hg + obtain ⟨v,hv,rfl⟩ := Finset.mem_map.mp hg + exact v.property + have hb := h G hG + have hsq := (sq_le_sq₀ (Real.sqrt_nonneg _) hC).mpr hb + rw [Real.sq_sqrt (Finset.sum_nonneg (fun _ _ => sq_nonneg _))] at hsq + rw [Finset.sum_coe_sort G (fun g : V => a g ^ 2)] at hsq + simpa only [G, Finset.sum_map, e, Function.Embedding.coeFn_mk, Real.norm_eq_abs, sq_abs] using hsq + let m : lp (fun _ : {g // P g} => ℝ) 2 := ⟨fun g => a g.val, + memℓp_gen' (C := C^2) (fun s => by simpa only [ENNReal.toReal_ofNat, Real.rpow_two] using hs s)⟩ + refine ⟨m, fun _ => rfl, ?_⟩ + apply lp.norm_le_of_forall_sum_le (by norm_num) hC + intro s + simpa only [ENNReal.toReal_ofNat, Real.rpow_two, m] using hs s + +end SubtypeL2 + +section EndpointL2 +open scoped Classical +variable {V ΩP ΩM : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + [Fintype ΩP] [Fintype ΩM] + + + +theorem endpoint_laws_global {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (hK : Ancestral (· ≤ ·) K) (hHK : H ⊆ K) + (x y : FullDual V) (hx : head H x = x) {d : ℝ} (hd : 0 ≤ d) (hd1 : d < 1) + (hxn : 1 - d ≤ ‖x‖) (hplus : ‖x+y‖ ≤ 1) (hminus : ‖x-y‖ ≤ 1) + (p : Test V) (hpH : p.coeff.support ⊆ H) (hp : ‖p‖ = 1) (hxp : x (p : Primal V) = ‖x‖) + (μP : FiniteLaw ΩP) (μM : FiniteLaw ΩM) + (AP : ΩP → Representation V) (AM : ΩM → Representation V) + (hAP : ∀ ω, (AP ω).energy ≤ 1) (hAM : ∀ ω, (AM ω).energy ≤ 1) + (hmeanP : μP.expect (fun ω => (AP ω).value) = head K (x+y)) + (hmeanM : μM.expect (fun ω => (AM ω).value) = head K (x-y)) : + (lawSlack μP AP p + lawError μP AP p ≤ 4*d) ∧ + (lawSlack μM AM p + lawError μM AM p ≤ 4*d) ∧ + μP.mean (fun ω => ‖(AP ω).value - ((AP ω).family.replacement p.coeff).value‖) ≤ 2*Real.sqrt d ∧ + μM.mean (fun ω => ‖(AM ω).value - ((AM ω).family.replacement p.coeff).value‖) ≤ 2*Real.sqrt d ∧ + ∃ m : lp (fun _ : {g // Gate H g} => ℝ) 2, + (∀ g, m g = (μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) + + μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|))/2) ∧ + ‖m‖ ≤ Real.sqrt (6*d) ∧ + (∀ g, 0 ≤ μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) ∧ + 0 ≤ μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|) ∧ + μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) ≤ 2*m g ∧ + μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|) ≤ 2*m g) := by + classical + have h0 := endpoint_laws_on_gates hH hK hHK x y hx hd hd1 hxn hplus hminus p hpH hp hxp + μP μM AP AM hAP hAM ∅ (by simp) hmeanP hmeanM + refine ⟨h0.1,h0.2.1,h0.2.2.1,h0.2.2.2.1,?_⟩ + obtain ⟨m,hm,hmn⟩ := subtype_l2_bound (Gate H) + (fun g => (μP.mean (fun ω => |(AP ω).family.boundary p.coeff g|) + + μM.mean (fun ω => |(AM ω).family.boundary p.coeff g|))/2) + (Real.sqrt_nonneg (6*d)) (fun G hG => + (endpoint_laws_on_gates hH hK hHK x y hx hd hd1 hxn hplus hminus p hpH hp hxp + μP μM AP AM hAP hAM G hG hmeanP hmeanM).2.2.2.2.2) + refine ⟨m,hm,hmn,?_⟩ + intro g + rw [hm] + have hp0 := μP.mean_nonneg (fun ω => abs_nonneg ((AP ω).family.boundary p.coeff g.val)) + have hm0 := μM.mean_nonneg (fun ω => abs_nonneg ((AM ω).family.boundary p.coeff g.val)) + exact ⟨hp0,hm0,by linarith,by linarith⟩ + +end EndpointL2 + +section GateCoordinateL2 +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + +theorem gate_coordinate_l2 (H : Finset V) (z : FullDual V) : + ∃ m : lp (fun _ : {g // Gate H g} => ℝ) 2, + (∀ g, m g = z (unitVector g.val)) ∧ ‖m‖ ≤ ‖z‖ := by + apply subtype_l2_bound (Gate H) (fun g => z (unitVector g)) (norm_nonneg z) + intro G hG + apply (Real.sqrt_le_iff).mpr + exact ⟨norm_nonneg z, gate_coordinate_square_sum G hG z⟩ + +end GateCoordinateL2 + + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/EndpointLaws.lean b/lean/OAI/Analysis/SegmentLenses/EndpointLaws.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fd91592834bf6c5c6b3fa599fd036768a250505 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/EndpointLaws.lean @@ -0,0 +1,217 @@ +import OAI.Analysis.SegmentLenses.Stability + +namespace OAI + +/-! +# Independent endpoint laws and conditional recovery +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +namespace FiniteLaw +variable {Ω Ω' : Type*} [Fintype Ω] [Fintype Ω'] + +theorem pooled_mean (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') (f : Ω → ℝ) (g : Ω' → ℝ) : + (μ.pooled ν).mean (Sum.elim f g) = (μ.mean f + ν.mean g) / 2 := by + have h := μ.pooled_expect ν f g + simp only [expect_scalar, smul_eq_mul] at h + rw [h] + ring + +end FiniteLaw + +section EndpointLaws +open scoped Classical +variable {V ΩP ΩM : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + [Fintype ΩP] [Fintype ΩM] + + + + +theorem endpoint_laws {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (_hK : Ancestral (· ≤ ·) K) (hHK : H ⊆ K) + (x y : FullDual V) (hx : head H x = x) {d : ℝ} (hd : 0 ≤ d) (_hd1 : d < 1) + (hxn : 1 - d ≤ ‖x‖) (_hplus : ‖x + y‖ ≤ 1) (_hminus : ‖x - y‖ ≤ 1) + (p : Test V) (hpH : p.coeff.support ⊆ H) (hp : ‖p‖ = 1) (hxp : x (p : Primal V) = ‖x‖) + (μP : FiniteLaw ΩP) (μM : FiniteLaw ΩM) + (AP : ΩP → Representation V) (AM : ΩM → Representation V) + (hAP : ∀ ω, (AP ω).energy ≤ 1) (hAM : ∀ ω, (AM ω).energy ≤ 1) + (_hKP : ∀ ω S, S ∈ (AP ω).family.sets → S ⊆ K) + (_hKM : ∀ ω S, S ∈ (AM ω).family.sets → S ⊆ K) + (hmeanP : μP.expect (fun ω => (AP ω).value) = head K (x + y)) + (hmeanM : μM.expect (fun ω => (AM ω).value) = head K (x - y)) : + let mP := fun g : K.filter (Gate H) => μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) + let mM := fun g : K.filter (Gate H) => μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|) + let m := fun g => (mP g + mM g) / 2 + (lawSlack μP AP p + lawError μP AP p ≤ 4 * d) ∧ + (lawSlack μM AM p + lawError μM AM p ≤ 4 * d) ∧ + μP.mean (fun ω => ‖(AP ω).value - ((AP ω).family.replacement p.coeff).value‖) ≤ 2 * Real.sqrt d ∧ + μM.mean (fun ω => ‖(AM ω).value - ((AM ω).family.replacement p.coeff).value‖) ≤ 2 * Real.sqrt d ∧ + (∀ g, 0 ≤ mP g ∧ 0 ≤ mM g ∧ mP g ≤ 2 * m g ∧ mM g ≤ 2 * m g) ∧ + Real.sqrt (∑ g, m g ^ 2) ≤ Real.sqrt (6 * d) := by + classical + dsimp only + let μ := μP.pooled μM + let A := Sum.elim AP AM + have hA : ∀ ω, (A ω).energy ≤ 1 := by intro ω; cases ω with | inl ω => exact hAP ω | inr ω => exact hAM ω + have hmean : μ.expect (fun ω => (A ω).value) = x := by + have he : (fun ω => (A ω).value) = Sum.elim (fun ω => (AP ω).value) (fun ω => (AM ω).value) := by + funext ω; cases ω <;> rfl + rw [he, μP.pooled_expect μM, hmeanP, hmeanM] + change (1/2 : ℝ) • headLinear K (x + y) + (1/2 : ℝ) • headLinear K (x - y) = x + rw [map_add, map_sub, headLinear_apply, head_eq_of_subset hHK x hx] + module + have hdef : lawDeficit μ A p = 1 - ‖x‖ := by rw [lawDeficit, hmean, hxp] + have hdefsum : lawDeficit μP AP p + lawDeficit μM AM p = 2 * (1 - ‖x‖) := by + have he : μ.mean (fun ω => (A ω).value (p : Primal V)) = + (μP.mean (fun ω => (AP ω).value (p : Primal V)) + + μM.mean (fun ω => (AM ω).value (p : Primal V))) / 2 := by + have hf : (fun ω => (A ω).value (p : Primal V)) = + Sum.elim (fun ω => (AP ω).value (p : Primal V)) (fun ω => (AM ω).value (p : Primal V)) := by + funext ω; cases ω <;> rfl + rw [hf] + exact μP.pooled_mean μM _ _ + have he' : μ.mean (fun ω => (A ω).value (p : Primal V)) = ‖x‖ := by + rw [← μ.expect_apply, hmean, hxp] + simp only [lawDeficit, FiniteLaw.expect_apply] + linarith + have hdP := lawDeficit_nonneg μP AP hAP p hp.le + have hdM := lawDeficit_nonneg μM AM hAM p hp.le + have hbP : lawDeficit μP AP p ≤ 2 * d := by linarith + have hbM : lawDeficit μM AM p ≤ 2 * d := by linarith + have hrootP : Real.sqrt (2 * lawDeficit μP AP p) ≤ 2 * Real.sqrt d := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by positivity, ?_⟩ + nlinarith [Real.sq_sqrt hd] + have hrootM : Real.sqrt (2 * lawDeficit μM AM p) ≤ 2 * Real.sqrt d := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by positivity, ?_⟩ + nlinarith [Real.sq_sqrt hd] + refine ⟨?_, ?_, (mean_error_norm_le μP AP hAP p hp.le).trans hrootP, + (mean_error_norm_le μM AM hAM p hp.le).trans hrootM, ?_, ?_⟩ + · have h := (unit_law_budget μP AP hAP p hp.le).2.2 + linarith + · have h := (unit_law_budget μM AM hAM p hp.le).2.2 + linarith + · intro g + have hpos := μP.mean_nonneg (fun ω => abs_nonneg ((AP ω).family.boundary p.coeff g.val)) + have hneg := μM.mean_nonneg (fun ω => abs_nonneg ((AM ω).family.boundary p.coeff g.val)) + exact ⟨hpos, hneg, by linarith, by linarith⟩ + · apply Real.sqrt_le_sqrt + have h := law_absolute_mass_bound hH (K.filter (Gate H)) + (fun g hg => (Finset.mem_filter.mp hg).2) μ A hA p hp.le hpH + have ht : tail H x = 0 := by simp only [tail, hx, sub_self] + rw [hmean, ht, norm_zero, zero_add, hdef] at h + have hδ : 0 ≤ 1 - ‖x‖ := hdef ▸ lawDeficit_nonneg μ A hA p hp.le + rw [Real.sq_sqrt (mul_nonneg (by norm_num) hδ)] at h + have he : ∀ g : K.filter (Gate H), μ.mean (fun ω => |(A ω).family.boundary p.coeff g.val|) = + (μP.mean (fun ω => |(AP ω).family.boundary p.coeff g.val|) + + μM.mean (fun ω => |(AM ω).family.boundary p.coeff g.val|)) / 2 := by + intro g + have hf : (fun ω => |(A ω).family.boundary p.coeff g.val|) = + Sum.elim (fun ω => |(AP ω).family.boundary p.coeff g.val|) + (fun ω => |(AM ω).family.boundary p.coeff g.val|) := by + funext ω; cases ω <;> rfl + rw [hf] + exact μP.pooled_mean μM _ _ + simp_rw [he] at h + linarith + +end EndpointLaws + +section SymmetricStability +open scoped Classical +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + +theorem finite_symmetric_tail {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (hK : Ancestral (· ≤ ·) K) (x y : FullDual V) (hx : head K x = x) (hy : head K y = y) + (hpp : ‖x + y‖ ≤ 1) (hmm : ‖x - y‖ ≤ 1) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) : + ‖tail H y‖ ≤ ‖tail H x‖ + (2 + 2 * Real.sqrt 2) * Real.sqrt (1 - x (p : Primal V)) := by + have hpK : head K (x + y) = x + y := by + change headLinear K (x + y) = _ + simp only [map_add, headLinear_apply, hx, hy] + have hmK : head K (x - y) = x - y := by + change headLinear K (x - y) = _ + simp only [map_sub, headLinear_apply, hx, hy] + obtain ⟨μp, Ap, hpE, hpSupp, hpMean⟩ := exists_atomic_law hK (x + y) hpK (by norm_num : (0:ℝ)<1) hpp + obtain ⟨μm, Am, hmE, hmSupp, hmMean⟩ := exists_atomic_law hK (x - y) hmK (by norm_num : (0:ℝ)<1) hmm + let μ := μp.pooled μm + let A := Sum.elim Ap Am + let σ : Option (LocalFamily K) ⊕ Option (LocalFamily K) → ℝ := Sum.elim (fun _ => 1) (fun _ => -1) + have hσ : ∀ ω, |σ ω| ≤ 1 := by intro ω; cases ω <;> norm_num [σ] + have henergy : ∀ ω, (A ω).energy ≤ 1 := by + intro ω + cases ω with + | inl ω => simpa only [A, Sum.elim_inl, one_pow] using hpE ω + | inr ω => simpa only [A, Sum.elim_inr, one_pow] using hmE ω + have hsupp : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K := by + intro ω + cases ω with + | inl ω => exact hpSupp ω + | inr ω => exact hmSupp ω + have hmean : μ.expect (fun ω => (A ω).value) = x := by + have he : (fun ω => (A ω).value) = Sum.elim (fun ω => (Ap ω).value) (fun ω => (Am ω).value) := by + funext ω; cases ω <;> rfl + rw [he, μp.pooled_expect μm, hpMean, hmMean] + module + have hsigned : μ.expect (fun ω => σ ω • (A ω).value) = y := by + have he : (fun ω => σ ω • (A ω).value) = Sum.elim + (fun ω => (1:ℝ) • (Ap ω).value) (fun ω => (-1:ℝ) • (Am ω).value) := by + funext ω; cases ω <;> rfl + rw [he, μp.pooled_expect μm, μp.expect_smul, μm.expect_smul, hpMean, hmMean] + module + have hdef : lawDeficit μ A p = 1 - x (p : Primal V) := by rw [lawDeficit, hmean] + have hδ : 0 ≤ 1 - x (p : Primal V) := hdef ▸ lawDeficit_nonneg μ A henergy p hp + have h := represented_bounded_multiplier hH μ A henergy hsupp σ hσ p hp hpH + rw [hsigned, hmean, hdef] at h + exact h.trans (stable_radical_linear (norm_nonneg _) hδ) + + + +theorem symmetric_tail_bound {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hpp : ‖x + y‖ ≤ 1) (hmm : ‖x - y‖ ≤ 1) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) : + ‖tail H y‖ ≤ ‖tail H x‖ + (2 + 2 * Real.sqrt 2) * Real.sqrt (1 - x (p : Primal V)) := by + apply dual_norm_le _ (by positivity) + intro u + let K := ancestralHull (H ∪ u.coeff.support) + have hK := ancestralHull_ancestral (H ∪ u.coeff.support) + have hHK : H ⊆ K := Finset.subset_union_left.trans (subset_ancestralHull _) + have huK : u.coeff.support ⊆ K := Finset.subset_union_right.trans (subset_ancestralHull _) + have hppK : ‖head K x + head K y‖ ≤ 1 := by + have he : head K x + head K y = head K (x + y) := (map_add (headLinear K) x y).symm + rw [he] + exact (norm_head_le hK _).trans hpp + have hmmK : ‖head K x - head K y‖ ≤ 1 := by + have he : head K x - head K y = head K (x - y) := (map_sub (headLinear K) x y).symm + rw [he] + exact (norm_head_le hK _).trans hmm + have hη : ‖tail H (head K x)‖ ≤ ‖tail H x‖ := by rw [← head_tail_commute]; exact norm_head_le hK _ + have h := finite_symmetric_tail hH hK (head K x) (head K y) (head_head _ _) (head_head _ _) + hppK hmmK p hp hpH + rw [head_pairing_of_support K x p (hpH.trans hHK)] at h + have hb := h.trans (add_le_add hη le_rfl) + rw [← tail_head_pairing H K y u huK] + have hop := (tail H (head K y)).le_opNorm (u : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at hop + exact hop.trans (mul_le_mul_of_nonneg_right hb (norm_nonneg u)) + +end SymmetricStability + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/FiniteLaws.lean b/lean/OAI/Analysis/SegmentLenses/FiniteLaws.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e9a5c8daa27d39bfae1fcba66d85c05a5d9ad16 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/FiniteLaws.lean @@ -0,0 +1,123 @@ +import OAI.Analysis.SegmentLenses.TreeGeometry + +namespace OAI + +/-! +# Finite probability laws and joint square-root budgets +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + + +theorem joint_sqrt_bound {η θ : ℝ} (hη : 0 ≤ η) (hθ : 0 ≤ θ) : + Real.sqrt η + Real.sqrt (η + 2 * θ) ≤ 2 * Real.sqrt (η + θ) := by + have hηθ : 0 ≤ η + θ := by positivity + have hη2θ : 0 ≤ η + 2 * θ := by positivity + have h0 := Real.sqrt_nonneg η + have h1 := Real.sqrt_nonneg (η + 2 * θ) + have h2 := Real.sqrt_nonneg (η + θ) + have hs0 := Real.sq_sqrt hη + have hs1 := Real.sq_sqrt hη2θ + have hs2 := Real.sq_sqrt hηθ + have hprod : Real.sqrt η * Real.sqrt (η + 2 * θ) ≤ η + θ := by + nlinarith [sq_nonneg (Real.sqrt (η + 2 * θ) - Real.sqrt η)] + nlinarith + + +theorem joint_budget_tail {η θ R r t : ℝ} + (hη : 0 ≤ η) (hθ : 0 ≤ θ) + (hbudget : η + θ ≤ R ^ 2 - r ^ 2) + (htail : t ≤ Real.sqrt η + Real.sqrt (η + 2 * θ)) : + t ≤ 2 * Real.sqrt (R ^ 2 - r ^ 2) := by + calc + t ≤ Real.sqrt η + Real.sqrt (η + 2 * θ) := htail + _ ≤ 2 * Real.sqrt (η + θ) := joint_sqrt_bound hη hθ + _ ≤ 2 * Real.sqrt (R ^ 2 - r ^ 2) := by + gcongr + + +structure FiniteLaw (Ω : Type*) [Fintype Ω] where + weight : Ω → ℝ + nonneg : ∀ ω, 0 ≤ weight ω + total : ∑ ω, weight ω = 1 + +namespace FiniteLaw +variable {Ω : Type*} [Fintype Ω] + +def mean (μ : FiniteLaw Ω) (f : Ω → ℝ) : ℝ := ∑ ω, μ.weight ω * f ω + +@[simp] theorem mean_const (μ : FiniteLaw Ω) (c : ℝ) : μ.mean (fun _ => c) = c := by + simp [mean, ← Finset.sum_mul, μ.total] + +@[simp] theorem mean_add (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.mean (fun ω => f ω + g ω) = μ.mean f + μ.mean g := by + simp [mean, mul_add, Finset.sum_add_distrib] + +@[simp] theorem mean_sub (μ : FiniteLaw Ω) (f g : Ω → ℝ) : + μ.mean (fun ω => f ω - g ω) = μ.mean f - μ.mean g := by + simp [mean, mul_sub, Finset.sum_sub_distrib] + +@[simp] theorem mean_mul (μ : FiniteLaw Ω) (c : ℝ) (f : Ω → ℝ) : + μ.mean (fun ω => c * f ω) = c * μ.mean f := by + simp [mean, Finset.mul_sum, mul_left_comm] + +theorem mean_nonneg (μ : FiniteLaw Ω) {f : Ω → ℝ} (hf : ∀ ω, 0 ≤ f ω) : + 0 ≤ μ.mean f := Finset.sum_nonneg fun ω _ => mul_nonneg (μ.nonneg ω) (hf ω) + +theorem mean_mono (μ : FiniteLaw Ω) {f g : Ω → ℝ} (h : ∀ ω, f ω ≤ g ω) : + μ.mean f ≤ μ.mean g := + Finset.sum_le_sum fun ω _ => mul_le_mul_of_nonneg_left (h ω) (μ.nonneg ω) + + +theorem sq_mean_le (μ : FiniteLaw Ω) (f : Ω → ℝ) : + μ.mean f ^ 2 ≤ μ.mean (fun ω => f ω ^ 2) := by + have h := μ.mean_nonneg (fun ω => sq_nonneg (f ω - μ.mean f)) + have he : μ.mean (fun ω => (f ω - μ.mean f) ^ 2) = + μ.mean (fun ω => f ω ^ 2) - μ.mean f ^ 2 := by + have hfun : (fun ω => (f ω - μ.mean f) ^ 2) = + fun ω => f ω ^ 2 - (2 * μ.mean f) * f ω + μ.mean f ^ 2 := by + funext ω + ring + rw [hfun, mean_add, mean_sub, mean_mul, mean_const] + ring + rw [he] at h + linarith + + + + +theorem joint_identity (μ : FiniteLaw Ω) {ι : Ω → Type*} + [∀ ω, Fintype (ι ω)] (a b : (ω : Ω) → ι ω → ℝ) (r : ℝ) + (hpair : μ.mean (fun ω => ∑ i, a ω i * b ω i) = r ^ 2) : + μ.mean (fun ω => ∑ i, (a ω i - b ω i) ^ 2) + + μ.mean (fun ω => r ^ 2 - ∑ i, b ω i ^ 2) = + μ.mean (fun ω => ∑ i, a ω i ^ 2) - r ^ 2 := by + rw [← mean_add] + have he : (fun ω => (∑ i, (a ω i - b ω i) ^ 2) + + (r ^ 2 - ∑ i, b ω i ^ 2)) = + fun ω => (∑ i, a ω i ^ 2) - 2 * (∑ i, a ω i * b ω i) + r ^ 2 := by + funext ω + simp_rw [sub_sq, Finset.sum_add_distrib, Finset.sum_sub_distrib] + simp_rw [mul_assoc] + rw [← Finset.mul_sum] + ring + rw [he, mean_add, mean_sub, mean_mul, mean_const, hpair] + ring + +end FiniteLaw + + + +end SegmentLenses + + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/ForestBlocks.lean b/lean/OAI/Analysis/SegmentLenses/ForestBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c29f1cb0277eda5b4be8a0a9e062028bd5e3c75 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/ForestBlocks.lean @@ -0,0 +1,322 @@ +import OAI.Analysis.SegmentLenses.DualSums + +namespace OAI + +/-! +# The finite-height forest as a sum of reflexive blocks +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + + +local instance : DecidableEq ForestVertex := Classical.decEq _ + +section MaximalTests +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + +theorem exists_norming_family (u : Test V) : ∃ F : SegmentFamily V, + F.seminorm u.coeff = ‖u‖ := by + classical + let K := ancestralHull u.coeff.support + let F₀ : LocalFamily K := ⟨default, by intro S hS; exact False.elim (Finset.notMem_empty _ hS)⟩ + obtain ⟨F, hF, hmax⟩ := Finset.exists_max_image + (Finset.univ : Finset (LocalFamily K)) (fun F => F.val.seminorm u.coeff) + (Finset.univ_nonempty_iff.mpr ⟨F₀⟩) + refine ⟨F.val, le_antisymm (le_segmentSeminorm _ _) ?_⟩ + change segmentSeminorm V u.coeff ≤ _ + rw [segmentSeminorm_apply] + apply ciSup_le + intro G + rw [← G.clip_seminorm (ancestralHull_ancestral _) u.coeff (subset_ancestralHull _)] + exact hmax ⟨G.clip (ancestralHull_ancestral _), G.clip_subset (ancestralHull_ancestral _)⟩ + (Finset.mem_univ _) + +end MaximalTests + +section HeightBlocks + + +def heightTest (h : ℕ) : Test ForestVertex →ₗ[ℝ] Test ForestVertex where + toFun u := Test.ofFinsupp (u.coeff.filter (fun v => v.val.1 = h)) + map_add' _u _v := Finsupp.filter_add + map_smul' _c _u := Finsupp.filter_smul + +@[simp] theorem heightTest_apply (h : ℕ) (u : Test ForestVertex) (v : ForestVertex) : + (heightTest h u).coeff v = if v.val.1 = h then u.coeff v else 0 := Finsupp.filter_apply _ _ _ + +theorem norm_heightTest_le (h : ℕ) (u : Test ForestVertex) : ‖heightTest h u‖ ≤ ‖u‖ := by + classical + apply norm_filter_le + intro a b v ha hb hav hvb + exact hav.1.symm.trans ha + + +theorem segment_same_height {S : Finset ForestVertex} (hS : SegmentSystem.isSegment S) + {v w : ForestVertex} (hv : v ∈ S) (hw : w ∈ S) : v.val.1 = w.val.1 := by + obtain ⟨a, b, hab, hs⟩ := hS + exact ((hs v).mp hv).1.1.symm.trans ((hs w).mp hw).1.1 + + +theorem segment_level_injective {S : Finset ForestVertex} (hS : SegmentSystem.isSegment S) : + Set.InjOn (fun v : ForestVertex => v.val.2.length) S := by + obtain ⟨a, b, hab, hs⟩ := hS + intro v hv w hw he + have hvb := ((hs v).mp hv).2 + have hwb := ((hs w).mp hw).2 + apply Subtype.ext + refine Prod.ext (hvb.1.trans hwb.1.symm) ?_ + rcases List.prefix_or_prefix_of_prefix hvb.2 hwb.2 with h | h + · exact h.eq_of_length he + · exact (h.eq_of_length he.symm).symm + +theorem segment_card_bound {S : Finset ForestVertex} (hS : SegmentSystem.isSegment S) + {h : ℕ} (hc : ∀ v ∈ S, v.val.1 = h) : S.card ≤ h + 1 := by + classical + calc + S.card = (S.image (fun v => v.val.2.length)).card := + (Finset.card_image_of_injOn (segment_level_injective hS)).symm + _ ≤ (Finset.range (h + 1)).card := Finset.card_le_card (by + intro n hn + obtain ⟨v, hv, rfl⟩ := Finset.mem_image.mp hn + apply Finset.mem_range.mpr + have hh := v.property.2 + rw [hc v hv] at hh + omega) + _ = h + 1 := Finset.card_range _ + + +def SegmentFamily.atHeight (F : SegmentFamily ForestVertex) (h : ℕ) : + SegmentFamily ForestVertex where + sets := F.sets.filter (fun S => ∀ v ∈ S, v.val.1 = h) + segment S hS := F.segment S (Finset.mem_filter.mp hS).1 + disjoint := by + intro S hS T hT hne + exact F.disjoint (Finset.mem_filter.mp hS).1 (Finset.mem_filter.mp hT).1 hne + +theorem atHeight_seminorm (F : SegmentFamily ForestVertex) (h : ℕ) (u : Test ForestVertex) : + (F.atHeight h).seminorm u.coeff = F.seminorm (heightTest h u).coeff := by + have he : (F.atHeight h).seminorm u.coeff ^ 2 = F.seminorm (heightTest h u).coeff ^ 2 := by + rw [SegmentFamily.seminorm_sq, SegmentFamily.seminorm_sq] + rw [Finset.sum_coe_sort (F.atHeight h).sets (fun S => (∑ v ∈ S, u.coeff v) ^ 2), + Finset.sum_coe_sort F.sets (fun S => (∑ v ∈ S, (heightTest h u).coeff v) ^ 2)] + change (∑ S ∈ F.sets.filter _, _) = ∑ S ∈ F.sets, _ + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro S hS + split_ifs with hc + · congr 1 + apply Finset.sum_congr rfl + intro v hv + simp only [heightTest_apply, hc v hv, ite_true] + · have hz : ∀ v ∈ S, v.val.1 ≠ h := by + intro v hv heq + apply hc + intro w hw + exact (segment_same_height (F.segment S hS) hw hv).trans heq + simp only [heightTest_apply] + simp only [Finset.sum_eq_zero (fun v hv => ite_eq_right (hz v hv)), zero_pow (by decide : 2 ≠ 0)] + nlinarith [apply_nonneg (F.atHeight h).seminorm u.coeff, + apply_nonneg F.seminorm (heightTest h u).coeff] + + + +theorem height_hilbert_upper (h : ℕ) (u : Test ForestVertex) + (hu : heightTest h u = u) : + ‖u‖ ^ 2 ≤ (h + 1 : ℝ) * ∑ v ∈ u.coeff.support, u.coeff v ^ 2 := by + classical + obtain ⟨F, hF⟩ := exists_norming_family u + let G := F.atHeight h + have hG : G.seminorm u.coeff = ‖u‖ := by rw [atHeight_seminorm, hu, hF] + rw [← hG, G.seminorm_sq] + have hlocal : ∀ S : G.sets, (∑ v ∈ S.val, u.coeff v) ^ 2 ≤ + (h + 1 : ℝ) * ∑ v ∈ S.val, u.coeff v ^ 2 := by + intro S + have hcs : (∑ v ∈ S.val, u.coeff v) ^ 2 ≤ + (S.val.card : ℝ) * ∑ v ∈ S.val, u.coeff v ^ 2 := by + simpa using Finset.sum_mul_sq_le_sq_mul_sq S.val (fun _ => (1 : ℝ)) (fun v => u.coeff v) + have hc := segment_card_bound (G.segment _ S.property) + (Finset.mem_filter.mp S.property).2 + have hcr : (S.val.card : ℝ) ≤ h + 1 := by exact_mod_cast hc + exact hcs.trans (mul_le_mul_of_nonneg_right hcr (Finset.sum_nonneg (fun _ _ => sq_nonneg _))) + calc + (∑ S : G.sets, (∑ v ∈ S.val, u.coeff v) ^ 2) ≤ + ∑ S : G.sets, (h + 1 : ℝ) * ∑ v ∈ S.val, u.coeff v ^ 2 := Finset.sum_le_sum (fun S _ => hlocal S) + _ = (h + 1 : ℝ) * ∑ S : G.sets, ∑ v ∈ S.val, u.coeff v ^ 2 := (Finset.mul_sum ..).symm + _ ≤ (h + 1 : ℝ) * ∑ v ∈ u.coeff.support, u.coeff v ^ 2 := by + gcongr + rw [Finset.sum_coe_sort G.sets (fun S => ∑ v ∈ S, u.coeff v ^ 2)] + have hs : (∑ v ∈ G.sets.biUnion id, u.coeff v ^ 2) = + ∑ S ∈ G.sets, ∑ v ∈ S, u.coeff v ^ 2 := by + simpa only [id_eq] using Finset.sum_biUnion (f := fun v => u.coeff v ^ 2) G.disjoint + rw [← hs] + have he : (∑ v ∈ G.sets.biUnion id, u.coeff v ^ 2) = + ∑ v ∈ G.sets.biUnion id ∩ u.coeff.support, u.coeff v ^ 2 := by + symm + apply Finset.sum_subset Finset.inter_subset_left + intro v hv hnv + have hn : v ∉ u.coeff.support := fun hs => hnv (Finset.mem_inter.mpr ⟨hv, hs⟩) + simp only [Finsupp.notMem_support_iff.mp hn, zero_pow (by decide : 2 ≠ 0)] + rw [he] + exact Finset.sum_le_sum_of_subset_of_nonneg Finset.inter_subset_right (fun _ _ _ => sq_nonneg _) + +end HeightBlocks + +section ForestNormDecomposition + +def testHeights (u : Test ForestVertex) : Finset ℕ := u.coeff.support.image (fun v => v.val.1) + +theorem heightTest_eq_zero {u : Test ForestVertex} {h : ℕ} (hh : h ∉ testHeights u) : + heightTest h u = 0 := by + apply Finsupp.ext + intro v + change (heightTest h u).coeff v = 0 + rw [heightTest_apply] + split_ifs with hv + · apply Finsupp.notMem_support_iff.mp + intro hs + exact hh (Finset.mem_image.mpr ⟨v, hs, hv⟩) + · rfl + +theorem heightTest_idem (h : ℕ) (u : Test ForestVertex) : + heightTest h (heightTest h u) = heightTest h u := by + apply Finsupp.ext + intro v + change (heightTest h (heightTest h u)).coeff v = (heightTest h u).coeff v + by_cases hv : v.val.1 = h <;> simp [heightTest_apply, hv] + +theorem heightTest_ne {h k : ℕ} (hk : h ≠ k) (u : Test ForestVertex) : + heightTest h (heightTest k u) = 0 := by + apply Finsupp.ext + intro v + change (heightTest h (heightTest k u)).coeff v = 0 + simp only [heightTest_apply] + split_ifs with hv hv' + · exact (hk (hv.symm.trans hv')).elim + · rfl + · rfl + + +theorem forest_norm_sq_decomposition (u : Test ForestVertex) : + ‖u‖ ^ 2 = ∑ h ∈ testHeights u, ‖heightTest h u‖ ^ 2 := by + classical + apply le_antisymm + · obtain ⟨F, hF⟩ := exists_norming_family u + have he : F.seminorm u.coeff ^ 2 = + ∑ h ∈ testHeights u, F.seminorm (heightTest h u).coeff ^ 2 := by + simp_rw [F.seminorm_sq] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + obtain ⟨a, b, hab, hs⟩ := F.segment S.val S.property + have hc : ∀ v ∈ S.val, v.val.1 = a.val.1 := fun v hv => ((hs v).mp hv).1.1.symm + have hv : ∀ h, (∑ v ∈ S.val, (heightTest h u).coeff v) ^ 2 = + if h = a.val.1 then (∑ v ∈ S.val, u.coeff v) ^ 2 else 0 := by + intro h + by_cases hh : h = a.val.1 + · subst h + simp only [heightTest_apply, Finset.sum_congr rfl (fun v hv => ite_eq_left (hc v hv)), ite_true] + · have hn : ∀ v ∈ S.val, v.val.1 ≠ h := fun v hv he => hh (he.symm.trans (hc v hv)) + simp only [heightTest_apply, Finset.sum_congr rfl (fun v hv => ite_eq_right (hn v hv)), Finset.sum_const_zero, + zero_pow (by decide : 2 ≠ 0), ite_eq_right hh] + simp_rw [hv] + by_cases ha : a.val.1 ∈ testHeights u + · simp only [Finset.sum_ite_eq', ite_eq_left ha] + · have hz : ∑ v ∈ S.val, u.coeff v = 0 := by + apply Finset.sum_eq_zero + intro v hv + apply Finsupp.notMem_support_iff.mp + intro hvs + exact ha (Finset.mem_image.mpr ⟨v, hvs, hc v hv⟩) + simp [hz] + rw [← hF, he] + exact Finset.sum_le_sum (fun h _ => sq_le_sq₀ (apply_nonneg _ _) (norm_nonneg _) |>.mpr + (le_segmentSeminorm _ _)) + · have hex : ∀ h : testHeights u, ∃ F : SegmentFamily ForestVertex, + F.seminorm (heightTest h.val u).coeff = ‖heightTest h.val u‖ := + fun h => exists_norming_family _ + choose F hF using hex + let G : testHeights u → SegmentFamily ForestVertex := fun h => (F h).atHeight h.val + have hn : ∀ h, (G h).seminorm u.coeff = ‖heightTest h.val u‖ := by + intro h + exact (atHeight_seminorm (F h) h.val u).trans (hF h) + let pieces : (h : testHeights u) × (G h).sets → Finset ForestVertex := fun j => j.2.val + have hseg : ∀ j, pieces j = ∅ ∨ SegmentSystem.isSegment (pieces j) := fun j => + Or.inr ((G j.1).segment _ j.2.property) + have hd : Pairwise fun i j => Disjoint (pieces i) (pieces j) := by + intro i j hij + by_cases hh : i.1 = j.1 + · rcases i with ⟨i, S⟩ + rcases j with ⟨j, T⟩ + dsimp at hh + subst j + exact (G i).disjoint S.property T.property (fun he => hij (by cases Subtype.ext he; rfl)) + · apply Finset.disjoint_left.mpr + intro v hv hw + have hvh := (Finset.mem_filter.mp i.2.property).2 v hv + have hwh := (Finset.mem_filter.mp j.2.property).2 v hw + exact hh (Subtype.ext (hvh.symm.trans hwh)) + have hb := indexed_test_bound u.coeff pieces hseg hd + change (∑ j, (∑ v ∈ pieces j, u.coeff v) ^ 2) ≤ ‖u‖ ^ 2 at hb + rw [Fintype.sum_sigma] at hb + have he : (∑ h : testHeights u, ∑ S : (G h).sets, (∑ v ∈ S.val, u.coeff v) ^ 2) = + ∑ h ∈ testHeights u, ‖heightTest h u‖ ^ 2 := by + rw [← Finset.sum_coe_sort (testHeights u) (fun h => ‖heightTest h u‖ ^ 2)] + apply Finset.sum_congr rfl + intro h hh + rw [← (G h).seminorm_sq, hn] + exact he ▸ hb + +end ForestNormDecomposition + +section TestHilbertEmbedding +variable {V : Type*} [DecidableEq V] [segmentSystemV : SegmentSystem V] + + + +def testL2 : Test V →ₗ[ℝ] lp (fun _ : V => ℝ) 2 := + (Finsupp.linearCombination ℝ (fun v => lp.single 2 v (1 : ℝ))).comp + ({ toFun := Test.coeff, map_add' := fun _ _ => rfl, map_smul' := fun _ _ => rfl } : + Test V →ₗ[ℝ] (V →₀ ℝ)) + +theorem testL2_eq_sum (u : Test V) : + testL2 u = ∑ v ∈ u.coeff.support, lp.single 2 v (u.coeff v) := by + have _ := segmentSystemV + change (∑ v ∈ u.coeff.support, u.coeff v • lp.single 2 v (1 : ℝ)) = _ + simp only [← lp.single_smul, smul_eq_mul, mul_one] + +@[simp] theorem testL2_apply (u : Test V) (v : V) : testL2 u v = u.coeff v := by + classical + rw [testL2_eq_sum] + simp only [lp.coeFn_sum, Finset.sum_apply] + rw [Finset.sum_eq_single v] + · exact lp.single_apply_self _ _ _ + · intro w hw hwv + exact lp.single_apply_ne _ _ _ hwv.symm + · intro hv + rw [lp.single_apply_self, Finsupp.notMem_support_iff.mp hv] + +theorem norm_testL2_sq (u : Test V) : ‖testL2 u‖ ^ 2 = ∑ v ∈ u.coeff.support, u.coeff v ^ 2 := by + rw [testL2_eq_sum] + simpa only [Real.norm_eq_abs, sq_abs] using + l2_norm_sum_single_sq (fun _ : V => ℝ) u.coeff.support (fun v => u.coeff v) + +theorem norm_testL2_le (u : Test V) : ‖testL2 u‖ ≤ ‖u‖ := by + have h := singleton_square_sum_le u.coeff.support u + rw [← norm_testL2_sq] at h + exact (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).mp h + +end TestHilbertEmbedding + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/ForestDual.lean b/lean/OAI/Analysis/SegmentLenses/ForestDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..c21ac38a1eeb2347edb8126bea12813d3aa87bb0 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/ForestDual.lean @@ -0,0 +1,254 @@ +import OAI.Analysis.SegmentLenses.ForestBlocks + +namespace OAI + +/-! +# Full-forest reflexivity and coordinate identification +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +section HeightHilbertEquivalence + + + +def heightTests (h : ℕ) : Submodule ℝ (Test ForestVertex) := LinearMap.range (heightTest h) + +theorem mem_heightTests {h : ℕ} {u : Test ForestVertex} : + u ∈ heightTests h ↔ heightTest h u = u := by + constructor + · rintro ⟨v, rfl⟩ + exact heightTest_idem h v + · intro hu + exact ⟨u, hu⟩ + +abbrev HeightPrimal (h : ℕ) := UniformSpace.Completion (heightTests h) + +def heightHilbert (h : ℕ) : Submodule ℝ (lp (fun _ : ForestVertex => ℝ) 2) where + carrier := {x | ∀ v : ForestVertex, v.val.1 ≠ h → x v = 0} + zero_mem' := by intro v hv; rfl + add_mem' := by intro x y hx hy v hv; simp only [lp.coeFn_add, Pi.add_apply, hx v hv, hy v hv, add_zero] + smul_mem' := by intro c x hx v hv; simp only [lp.coeFn_smul, Pi.smul_apply, hx v hv, smul_zero] + +theorem heightHilbert_closed (h : ℕ) : IsClosed (heightHilbert h : Set (lp (fun _ : ForestVertex => ℝ) 2)) := by + change IsClosed {x : lp (fun _ : ForestVertex => ℝ) 2 | ∀ v, v.val.1 ≠ h → x v = 0} + simp only [Set.ofPred_forall] + apply isClosed_iInter + intro v + apply isClosed_iInter + intro hv + exact isClosed_eq (lp.evalCLM ℝ (fun _ : ForestVertex => ℝ) 2 v).continuous continuous_const + +instance (h : ℕ) : CompleteSpace (heightHilbert h) := (heightHilbert_closed h).completeSpace_coe + + +def heightToHilbert (h : ℕ) : heightTests h →ₗ[ℝ] heightHilbert h where + toFun u := ⟨testL2 u.val, by + intro v hv + rw [testL2_apply, ← mem_heightTests.mp u.property] + exact ite_eq_right hv⟩ + map_add' u v := Subtype.ext (testL2.map_add u.val v.val) + map_smul' c u := Subtype.ext (testL2.map_smul c u.val) + +@[simp] theorem heightToHilbert_apply (h : ℕ) (u : heightTests h) (v : ForestVertex) : + (heightToHilbert h u).val v = u.val.coeff v := testL2_apply _ _ + + +theorem heightToHilbert_dense (h : ℕ) : DenseRange (heightToHilbert h) := by + classical + intro x + let u : Finset ForestVertex → heightTests h := fun s => + ⟨heightTest h (Test.ofFinite s (fun v => x.val v)), ⟨_, rfl⟩⟩ + have he : ∀ s, (heightToHilbert h (u s)).val = ∑ v ∈ s, lp.single 2 v (x.val v) := by + intro s + apply Subtype.ext + funext v + simp only [heightToHilbert_apply, u, heightTest_apply] + rw [Test.coeff_ofFinite] + have hs : (∑ w ∈ s, lp.single 2 w (x.val w)) v = if v ∈ s then x.val v else 0 := by + simp only [lp.coeFn_sum, Finset.sum_apply] + by_cases hv : v ∈ s + · rw [Finset.sum_eq_single v] + · simp only [lp.single_apply_self, ite_eq_left hv] + · intro w hw hwv; exact lp.single_apply_ne _ _ _ hwv.symm + · exact fun hn => (hn hv).elim + · rw [ite_eq_right hv] + apply Finset.sum_eq_zero + intro w hw + exact lp.single_apply_ne _ _ _ (fun he => hv (he ▸ hw)) + rw [hs] + by_cases hv : v.val.1 = h + · simp [hv] + · simp [hv, x.property v hv] + have ht : Filter.Tendsto (fun s => heightToHilbert h (u s)) Filter.atTop (nhds x) := by + apply tendsto_subtype_rng.mpr + simpa only [HasSum, SummationFilter.unconditional_filter, he] using (lp.hasSum_single (by norm_num : (2 : ℝ≥0∞) ≠ ⊤) x.val) + exact isClosed_closure.mem_of_tendsto ht (Filter.Eventually.of_forall (fun s => + subset_closure ⟨u s, rfl⟩)) + + +def heightHilbertEquiv (h : ℕ) : HeightPrimal h ≃L[ℝ] heightHilbert h := + (LinearEquiv.refl ℝ (heightTests h)).extend + (UniformSpace.Completion.toComplL : heightTests h →L[ℝ] HeightPrimal h).toLinearMap + (heightToHilbert h) + UniformSpace.Completion.denseRange_coe + ⟨1, fun u => by + change ‖testL2 u.val‖ ≤ 1 * ‖(u : HeightPrimal h)‖ + rw [one_mul, UniformSpace.Completion.norm_coe] + exact norm_testL2_le u.val⟩ + (heightToHilbert_dense h) + ⟨Real.sqrt (h + 1), fun u => by + change ‖(u : HeightPrimal h)‖ ≤ Real.sqrt (h + 1) * ‖testL2 u.val‖ + rw [UniformSpace.Completion.norm_coe] + have hb := height_hilbert_upper h u.val (mem_heightTests.mp u.property) + change ‖u.val‖ ≤ _ + rw [← norm_testL2_sq] at hb + have hs := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ h + 1) + nlinarith [norm_nonneg u, norm_nonneg (testL2 u.val), Real.sqrt_nonneg (h + 1), + mul_nonneg (Real.sqrt_nonneg (h + 1)) (norm_nonneg (testL2 u.val))]⟩ + +theorem heightPrimal_reflexive (h : ℕ) : Reflexive (HeightPrimal h) := + (hilbert_reflexive (heightHilbert h)).of_equiv (heightHilbertEquiv h).symm + +end HeightHilbertEquivalence + +section ForestCompletionIdentification + +local instance heightPrimalFamilyNormed : ∀ h, NormedAddCommGroup (HeightPrimal h) := fun _h => inferInstance +local instance heightPrimalFamilySpace : ∀ h, NormedSpace ℝ (HeightPrimal h) := fun _h => inferInstance +local instance : Module ℝ J := (inferInstance : NormedSpace ℝ J).toModule +local instance : Module ℝ (L2Sum HeightPrimal) := (inferInstance : NormedSpace ℝ (L2Sum HeightPrimal)).toModule +local instance : AddCommMonoid (L2Sum HeightPrimal) := + (inferInstance : NormedAddCommGroup (L2Sum HeightPrimal)).toAddCommMonoid + + +def heightBlockTest (h : ℕ) : Test ForestVertex →ₗ[ℝ] HeightPrimal h := + (UniformSpace.Completion.toComplL : heightTests h →L[ℝ] HeightPrimal h).toLinearMap.comp + (heightTest h).rangeRestrict + +@[simp] theorem norm_heightBlockTest (h : ℕ) (u : Test ForestVertex) : + ‖heightBlockTest h u‖ = ‖heightTest h u‖ := UniformSpace.Completion.norm_coe _ + +theorem heightBlockTest_zero {h : ℕ} {u : Test ForestVertex} (hz : heightTest h u = 0) : + heightBlockTest h u = 0 := by + apply norm_eq_zero.mp + exact (norm_heightBlockTest h u).trans (by rw [hz, norm_zero]) + +def forestBlockVector (u : Test ForestVertex) : L2Sum HeightPrimal := + ∑ h ∈ testHeights u, lp.single 2 h (heightBlockTest h u) + +@[simp] theorem forestBlockVector_apply (u : Test ForestVertex) (h : ℕ) : + forestBlockVector u h = heightBlockTest h u := by + classical + simp only [forestBlockVector, lp.coeFn_sum, Finset.sum_apply] + rw [Finset.sum_eq_single h] + · exact lp.single_apply_self _ _ _ + · intro k hk hkh + exact lp.single_apply_ne _ _ _ hkh.symm + · intro hh + simp only [heightBlockTest_zero (heightTest_eq_zero hh), lp.single_zero, lp.coeFn_zero, Pi.zero_apply] + +def forestTestBlocks : Test ForestVertex →ₗ[ℝ] L2Sum HeightPrimal where + toFun := forestBlockVector + map_add' u v := by + apply Subtype.ext + funext h + simp only [forestBlockVector_apply, lp.coeFn_add, Pi.add_apply, map_add] + map_smul' c u := by + apply Subtype.ext + funext h + simp only [forestBlockVector_apply, lp.coeFn_smul, Pi.smul_apply, map_smul, RingHom.id_apply] + +@[simp] theorem forestTestBlocks_apply (u : Test ForestVertex) (h : ℕ) : + forestTestBlocks u h = heightBlockTest h u := forestBlockVector_apply u h + +theorem norm_forestTestBlocks (u : Test ForestVertex) : ‖forestTestBlocks u‖ = ‖u‖ := by + have he : ‖forestTestBlocks u‖ ^ 2 = ‖u‖ ^ 2 := by + change ‖∑ h ∈ testHeights u, lp.single 2 h (heightBlockTest h u)‖ ^ 2 = _ + rw [l2_norm_sum_single_sq, forest_norm_sq_decomposition] + simp only [norm_heightBlockTest] + exact (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp he + + + +theorem forestTestBlocks_of_height (h : ℕ) (u : heightTests h) : + forestTestBlocks u.val = lp.single 2 h (u : HeightPrimal h) := by + classical + apply Subtype.ext + funext k + rw [forestTestBlocks_apply] + by_cases hk : k = h + · subst k + rw [lp.single_apply_self] + change ((⟨heightTest h u.val, _⟩ : heightTests h) : HeightPrimal h) = _ + congr 1 + exact Subtype.ext (mem_heightTests.mp u.property) + · rw [lp.single_apply_ne _ _ _ hk] + apply heightBlockTest_zero + rw [← mem_heightTests.mp u.property] + exact heightTest_ne hk u.val + + + +theorem forestTestBlocks_dense : DenseRange forestTestBlocks := by + classical + let M := (LinearMap.range forestTestBlocks).topologicalClosure + have hclosed : IsClosed (M : Set (L2Sum HeightPrimal)) := Submodule.isClosed_topologicalClosure _ + have hs : ∀ h (x : HeightPrimal h), lp.single 2 h x ∈ M := by + intro h x + refine UniformSpace.Completion.induction_on x + (p := fun x => lp.single 2 h x ∈ M) + (by exact hclosed.preimage (lp.singleContinuousLinearMap ℝ HeightPrimal 2 h).continuous) ?_ + intro u + apply Submodule.le_topologicalClosure + exact ⟨u.val, forestTestBlocks_of_height h u⟩ + intro x + change x ∈ M + apply hclosed.mem_of_tendsto (lp.hasSum_single (by norm_num : (2 : ℝ≥0∞) ≠ ⊤) x) + exact Filter.Eventually.of_forall (fun s => M.sum_mem (fun h hh => hs h (x h))) + + +def forestL2Equiv : J ≃ₗᵢ[ℝ] L2Sum HeightPrimal := + (LinearEquiv.refl ℝ (Test ForestVertex)).extendOfIsometry + (UniformSpace.Completion.toComplL : Test ForestVertex →L[ℝ] J).toLinearMap + forestTestBlocks UniformSpace.Completion.denseRange_coe forestTestBlocks_dense + (fun u => by + change ‖forestTestBlocks u‖ = ‖(u : J)‖ + rw [UniformSpace.Completion.norm_coe] + exact norm_forestTestBlocks u) + +@[simp] theorem forestL2Equiv_test (u : Test ForestVertex) : + forestL2Equiv (u : J) = forestTestBlocks u := + by + change forestL2Equiv ((UniformSpace.Completion.toComplL : Test ForestVertex →L[ℝ] J) u) = _ + unfold forestL2Equiv + exact + (LinearEquiv.extendOfIsometry_eq (LinearEquiv.refl ℝ (Test ForestVertex)) + (UniformSpace.Completion.toComplL : Test ForestVertex →L[ℝ] J).toLinearMap + forestTestBlocks UniformSpace.Completion.denseRange_coe forestTestBlocks_dense + (fun u => by change ‖forestTestBlocks u‖ = ‖(u : J)‖; rw [UniformSpace.Completion.norm_coe]; exact norm_forestTestBlocks u) u) + + +theorem forest_primal_reflexive : Reflexive J := + (l2Sum_reflexive HeightPrimal heightPrimal_reflexive).of_equiv + forestL2Equiv.symm.toContinuousLinearEquiv + + +theorem forest_dual_reflexive : Reflexive X := forest_primal_reflexive.dual + +end ForestCompletionIdentification + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/GateRecovery.lean b/lean/OAI/Analysis/SegmentLenses/GateRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..9faa2a421a37c17d77120a92a613c5ac207e7aa9 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/GateRecovery.lean @@ -0,0 +1,339 @@ +import OAI.Analysis.SegmentLenses.HeadTests + +namespace OAI + +/-! +# Gate coefficients, cone recovery, and energy budgets +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + +section ProjectionAlgebra +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + +def headLinear (H : Finset V) : FullDual V →ₗ[ℝ] FullDual V where + toFun := head H + map_add' := by intros; simp [head, add_smul, Finset.sum_add_distrib] + map_smul' := by intros; simp [head, mul_smul, Finset.smul_sum] + +def tailLinear (H : Finset V) : FullDual V →ₗ[ℝ] FullDual V := + LinearMap.id - headLinear H + +@[simp] theorem headLinear_apply (H : Finset V) (x : FullDual V) : + headLinear H x = head H x := by + have _ := decidableEqV + exact rfl + +@[simp] theorem tailLinear_apply (H : Finset V) (x : FullDual V) : + tailLinear H x = tail H x := by + have _ := decidableEqV + exact rfl + +@[simp] theorem tail_unitVector (H : Finset V) (x : FullDual V) (v : V) : + tail H x (unitVector v) = if v ∈ H then 0 else x (unitVector v) := by + simp only [tail, _root_.sub_apply, head_unitVector] + split_ifs <;> simp + +@[simp] theorem tail_segmentFunctional (H S : Finset V) : + tail H (segmentFunctional S) = segmentFunctional (S \ H) := by + apply dual_ext_test + intro u + rw [tail_pairing, segmentFunctional_apply, segmentFunctional_apply] + change (∑ v ∈ S, (u.coeff.filter (· ∉ H)) v) = _ + simp only [Finsupp.filter_apply] + rw [← Finset.sum_filter] + congr 1 + ext v + simp + +namespace SegmentFamily + +def replacement (F : SegmentFamily V) (p : V →₀ ℝ) : Representation V := + ⟨F, fun S => ∑ v ∈ S.val, p v⟩ + +@[simp] theorem replacement_energy (F : SegmentFamily V) (p : V →₀ ℝ) : + (F.replacement p).energy = F.seminorm p ^ 2 := by + have _ := decidableEqV + exact (F.seminorm_sq p).symm + +@[simp] theorem replacement_gate [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [IntervalSegments V] (F : SegmentFamily V) (p : V →₀ ℝ) (g : V) : + (F.replacement p).value (unitVector g) = F.boundary p g := by + rw [Representation.apply_unitVector] + exact Finset.sum_coe_sort F.sets (fun S => if g ∈ S then ∑ v ∈ S, p v else 0) + +end SegmentFamily + +namespace Representation + +def error (A : Representation V) (p : V →₀ ℝ) : Representation V := + ⟨A.family, fun S => A.coeff S - ∑ v ∈ S.val, p v⟩ + +@[simp] theorem error_value (A : Representation V) (p : V →₀ ℝ) : + (A.error p).value = A.value - (A.family.replacement p).value := by + apply dual_ext_test + intro u + rw [_root_.sub_apply, Representation.apply_test, Representation.apply_test, + Representation.apply_test] + change (∑ S : A.family.sets, (A.coeff S - ∑ v ∈ S.val, p v) * + (∑ v ∈ S.val, u.coeff v)) = + (∑ S : A.family.sets, A.coeff S * ∑ v ∈ S.val, u.coeff v) - + (∑ S : A.family.sets, (∑ v ∈ S.val, p v) * ∑ v ∈ S.val, u.coeff v) + simp only [sub_mul, Finset.sum_sub_distrib] + +@[simp] theorem error_energy (A : Representation V) (p : V →₀ ℝ) : + (A.error p).energy = ∑ S : A.family.sets, (A.coeff S - ∑ v ∈ S.val, p v) ^ 2 := by + have _ := decidableEqV + exact rfl + +theorem error_slack_identity (A : Representation V) (p : V →₀ ℝ) (r : ℝ) : + (A.error p).energy + (r ^ 2 - A.family.seminorm p ^ 2) = + A.energy - 2 * (∑ S : A.family.sets, A.coeff S * ∑ v ∈ S.val, p v) + r ^ 2 := by + rw [error_energy, SegmentFamily.seminorm_sq] + unfold energy + simp_rw [sub_sq, Finset.sum_add_distrib, Finset.sum_sub_distrib, mul_assoc] + rw [← Finset.mul_sum] + ring + +theorem energy_nonneg (A : Representation V) : 0 ≤ A.energy := by + have _ := decidableEqV + exact + Finset.sum_nonneg (fun _ _ => sq_nonneg _) + +end Representation +end ProjectionAlgebra + +section GateTails +variable {V : Type*} [DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [treeOrderV : TreeOrder V] + [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + +namespace SegmentFamily + +theorem member_unique (F : SegmentFamily V) {S T : F.sets} {v : V} + (hS : v ∈ S.val) (hT : v ∈ T.val) : S = T := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + by_contra hn + exact Finset.disjoint_left.mp + (F.disjoint S.property T.property (fun he => hn (Subtype.ext he))) hS hT + + +def gateTail (F : SegmentFamily V) (H : Finset V) (g : V) : Finset V := + if h : ∃ S : F.sets, g ∈ S.val then (Classical.choose h).val \ H else ∅ + +theorem gateTail_of_mem (F : SegmentFamily V) (H : Finset V) (S : F.sets) + {g : V} (hg : g ∈ S.val) : F.gateTail H g = S.val \ H := by + classical + have hex : ∃ T : F.sets, g ∈ T.val := ⟨S, hg⟩ + rw [gateTail, dite_eq_left hex] + rw [F.member_unique (Classical.choose_spec hex) hg] + +theorem gateTail_segment (F : SegmentFamily V) {H : Finset V} + (hH : Ancestral (· ≤ ·) H) (g : V) : + F.gateTail H g = ∅ ∨ SegmentSystem.isSegment (F.gateTail H g) := by + classical + unfold gateTail + split_ifs with h + · let S := Classical.choose h + apply subinterval_isSegment (F.segment S.val S.property) Finset.sdiff_subset + intro a ha b hb v hav hvb + have hS : v ∈ S.val := by + rw [F.repr S] at ha hb ⊢ + have ha' := (Finset.mem_sdiff.mp ha).1 + have hb' := (Finset.mem_sdiff.mp hb).1 + exact Finset.mem_Icc.mpr ⟨(Finset.mem_Icc.mp ha').1.trans hav, + hvb.trans (Finset.mem_Icc.mp hb').2⟩ + exact Finset.mem_sdiff.mpr ⟨hS, fun hv => (Finset.mem_sdiff.mp ha).2 (hH hv hav)⟩ + · exact Or.inl rfl + +theorem gateTail_cone (F : SegmentFamily V) {H : Finset V} {g v : V} + (hg : Gate H g) (hv : v ∈ F.gateTail H g) : g ≤ v := by + classical + unfold gateTail at hv + split_ifs at hv with h + · let S := Classical.choose h + have hgm : g ∈ S.val := Classical.choose_spec h + have hvS := (Finset.mem_sdiff.mp hv).1 + rw [F.repr S] at hgm hvS + rcases TreeOrder.lower_chain (Finset.mem_Icc.mp hgm).2 + (Finset.mem_Icc.mp hvS).2 with hle | hle + · exact hle + · by_contra hn + exact (Finset.mem_sdiff.mp hv).2 (hg.2 v (lt_of_le_not_ge hle hn)) + · exact False.elim (Finset.notMem_empty _ hv) + +theorem exists_gate_of_crossing (F : SegmentFamily V) {H : Finset V} + (hH : Ancestral (· ≤ ·) H) (p : V →₀ ℝ) (hp : p.support ⊆ H) + (S : F.sets) (hpS : (∑ v ∈ S.val, p v) ≠ 0) + (hne : (S.val \ H).Nonempty) : ∃ g ∈ S.val, Gate H g := by + classical + have ha : F.first S ∈ H := by + by_contra hn + apply hpS + apply Finset.sum_eq_zero + intro v hv + rw [F.repr S] at hv + exact head_zero_above hH hp hn (Finset.mem_Icc.mp hv).1 + obtain ⟨g, hg, hmin⟩ := Finset.exists_minimal hne + refine ⟨g, (Finset.mem_sdiff.mp hg).1, (Finset.mem_sdiff.mp hg).2, ?_⟩ + intro v hvg + have hm : g ∈ Finset.Icc (F.first S) (F.last S) := by + rw [← F.repr S]; exact (Finset.mem_sdiff.mp hg).1 + rcases TreeOrder.lower_chain hvg.le (Finset.mem_Icc.mp hm).1 with hle | hle + · exact hH ha hle + · by_contra hv + have hvS : v ∈ S.val \ H := Finset.mem_sdiff.mpr ⟨by + rw [F.repr S] + exact Finset.mem_Icc.mpr ⟨hle, hvg.le.trans (Finset.mem_Icc.mp hm).2⟩, hv⟩ + exact not_le_of_gt hvg (hmin hvS hvg.le) + +end SegmentFamily +end GateTails + +section GateRecovery +open scoped Classical +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] + +namespace SegmentFamily + +theorem boundary_tail_expansion (F : SegmentFamily V) (H : Finset V) + (p : V →₀ ℝ) (g : V) : + F.boundary p g • segmentFunctional (F.gateTail H g) = + ∑ S : F.sets, if g ∈ S.val then (∑ v ∈ S.val, p v) • + segmentFunctional (S.val \ H) else 0 := by + classical + rw [boundary, Finset.sum_smul, ← Finset.sum_coe_sort] + apply Finset.sum_congr rfl + intro S hS + by_cases hg : g ∈ S.val + · simp only [hg, ite_true, F.gateTail_of_mem H S hg] + · simp only [hg, ite_false, zero_smul] + + + +theorem tail_replacement (F : SegmentFamily V) {H K : Finset V} + (hH : Ancestral (· ≤ ·) H) (p : V →₀ ℝ) (hp : p.support ⊆ H) + (hK : ∀ S ∈ F.sets, S ⊆ K) : + tail H (F.replacement p).value = + ∑ g : K.filter (Gate H), F.boundary p g.val • segmentFunctional (F.gateTail H g.val) := by + classical + change tailLinear H (∑ S : F.sets, (∑ v ∈ S.val, p v) • segmentFunctional S.val) = _ + rw [map_sum] + simp only [map_smul, tailLinear_apply, tail_segmentFunctional, F.boundary_tail_expansion] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + by_cases hz : (∑ v ∈ S.val, p v) = 0 + · simp [hz] + by_cases he : S.val \ H = ∅ + · simp [he, segmentFunctional] + obtain ⟨g, hgS, hg⟩ := F.exists_gate_of_crossing hH p hp S hz (Finset.nonempty_iff_ne_empty.mpr he) + have hgK : g ∈ K.filter (Gate H) := Finset.mem_filter.mpr ⟨hK S.val S.property hgS, hg⟩ + rw [Finset.sum_eq_single (⟨g, hgK⟩ : K.filter (Gate H))] + · simp [hgS] + · intro g' hg' hne + have hn : g'.val ∉ S.val := by + intro hm + apply hne + apply Subtype.ext + exact F.gate_unique S (Finset.mem_filter.mp g'.property).2 hg hm hgS + simp [hn] + · simp + +end SegmentFamily +end GateRecovery + +section ScaledLaws +variable {V : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [treeOrderV : TreeOrder V] + [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + +namespace Representation + +def scale (A : Representation V) (t : ℝ) : Representation V := + ⟨A.family, fun S => t * A.coeff S⟩ + +@[simp] theorem scale_value (t : ℝ) (A : Representation V) : + (A.scale t).value = t • A.value := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + change (∑ S : A.family.sets, (t * A.coeff S) • segmentFunctional S.val) = + t • (∑ S : A.family.sets, A.coeff S • segmentFunctional S.val) + simp only [Finset.smul_sum, mul_smul] + +@[simp] theorem scale_energy (t : ℝ) (A : Representation V) : + (A.scale t).energy = t ^ 2 * A.energy := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + change (∑ S : A.family.sets, (t * A.coeff S) ^ 2) = t ^ 2 * ∑ S, A.coeff S ^ 2 + simp only [mul_pow, Finset.mul_sum] + +end Representation + +theorem exists_atomic_law {K : Finset V} (hK : Ancestral (· ≤ ·) K) + (z : FullDual V) (hz : head K z = z) {R : ℝ} (hR : 0 < R) (hn : ‖z‖ ≤ R) : + ∃ μ : FiniteLaw (Option (LocalFamily K)), + ∃ A : Option (LocalFamily K) → Representation V, + (∀ ω, (A ω).energy ≤ R ^ 2) ∧ + (∀ ω S, S ∈ (A ω).family.sets → S ⊆ K) ∧ + μ.expect (fun ω => (A ω).value) = z := by + classical + have hzh : head K (R⁻¹ • z) = R⁻¹ • z := by + change headLinear K (R⁻¹ • z) = _ + rw [map_smul, headLinear_apply, hz] + have hzn : ‖R⁻¹ • z‖ ≤ 1 := by + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr hR.le)] + exact (inv_mul_le_iff₀ hR).mpr (by simpa using hn) + obtain ⟨c, hc, hcz⟩ := mem_atomicBody_of_norm_le_one hK (R⁻¹ • z) hzh hzn + let μ := coefficientLaw K c hc + let A := fun ω => (coefficientAtoms K c ω).scale R + refine ⟨μ, A, ?_, ?_, ?_⟩ + · intro ω + change ((coefficientAtoms K c ω).scale R).energy ≤ R ^ 2 + rw [Representation.scale_energy] + exact mul_le_of_le_one_right (sq_nonneg R) (coefficientAtoms_energy K c ω) + · intro ω S hS + cases ω with + | none => exact False.elim (Finset.notMem_empty _ hS) + | some F => exact F.property S hS + · change μ.expect (fun ω => ((coefficientAtoms K c ω).scale R).value) = z + simp only [Representation.scale_value] + rw [μ.expect_smul, coefficientLaw_mean, hcz, smul_smul, mul_inv_cancel₀ hR.ne', one_smul] + +end ScaledLaws + +namespace FiniteLaw +variable {Ω : Type*} [Fintype Ω] + +@[simp] theorem expect_apply {V : Type*} [SegmentSystem V] (μ : FiniteLaw Ω) + (f : Ω → FullDual V) (u : Primal V) : + (μ.expect f) u = μ.mean (fun ω => f ω u) := by + simp only [expect, mean, _root_.sum_apply, _root_.smul_apply, smul_eq_mul] + +@[simp] theorem expect_sum {E ι : Type*} [AddCommMonoid E] [Module ℝ E] [Fintype ι] + (μ : FiniteLaw Ω) (f : Ω → ι → E) : + μ.expect (fun ω => ∑ i, f ω i) = ∑ i, μ.expect (fun ω => f ω i) := by + simp only [expect, Finset.smul_sum] + exact Finset.sum_comm + +end FiniteLaw + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Gates.lean b/lean/OAI/Analysis/SegmentLenses/Gates.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ce8f0ce770ddbe6397a250b99b24ae8759f36fc --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Gates.lean @@ -0,0 +1,146 @@ +import OAI.Analysis.SegmentLenses.Identifications + +namespace OAI + +/-! +# Exterior gates and disjoint cone regions +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +section ExteriorGates +variable {V : Type*} [DecidableEq V] [PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [segmentSystemV : SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + + + +theorem exists_gate_below (H : Finset V) {v : V} (hv : v ∉ H) : + ∃ g, Gate H g ∧ g ≤ v := by + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := segmentSystemV + have _ := intervalSegmentsV + classical + let S := Finset.Iic v \ H + obtain ⟨g,hg,hmin⟩ := Finset.exists_minimal (s := S) + (show S.Nonempty from ⟨v, Finset.mem_sdiff.mpr ⟨Finset.mem_Iic.mpr le_rfl,hv⟩⟩) + have hgS := Finset.mem_sdiff.mp hg + refine ⟨g,⟨hgS.2,?_⟩,Finset.mem_Iic.mp hgS.1⟩ + intro w hw + by_contra hn + have hwS : w ∈ S := Finset.mem_sdiff.mpr + ⟨Finset.mem_Iic.mpr (hw.le.trans (Finset.mem_Iic.mp hgS.1)),hn⟩ + exact (not_le_of_gt hw) (hmin hwS hw.le) + +theorem gate_below_unique {H : Finset V} {g k v : V} (hg : Gate H g) (hk : Gate H k) + (hgv : g ≤ v) (hkv : k ≤ v) : g=k := by + have _ := locallyFiniteOrderBotV + rcases TreeOrder.lower_chain hgv hkv with h | h + · exact gates_incomparable hg hk h + · exact (gates_incomparable hk hg h).symm + +abbrev ExteriorVertex (H : Finset V) := Region.Vertex (fun v => v ∉ H) +local instance (H : Finset V) : DecidableEq (ExteriorVertex H) := Classical.decEq _ + +def exteriorGate (H : Finset V) (v : ExteriorVertex H) : {g // Gate H g} := + ⟨(exists_gate_below H v.property).choose,(exists_gate_below H v.property).choose_spec.1⟩ + +theorem exteriorGate_le (H : Finset V) (v : ExteriorVertex H) : + (exteriorGate H v).val ≤ v.val := (exists_gate_below H v.property).choose_spec.2 + +def exteriorPartition (H : Finset V) : ComponentPartition (V := ExteriorVertex H) (I := {g // Gate H g}) where + index := exteriorGate H + comparable := by + intro v w hvw + apply Subtype.ext + exact gate_below_unique (exteriorGate H v).property (exteriorGate H w).property + ((exteriorGate_le H v).trans hvw) (exteriorGate_le H w) + + +theorem exteriorGate_eq_iff (H : Finset V) (v : ExteriorVertex H) (g : {g // Gate H g}) : + exteriorGate H v = g ↔ g.val ≤ v.val := by + constructor + · intro he; rw [← he]; exact exteriorGate_le H v + · intro hgv + apply Subtype.ext + exact gate_below_unique (exteriorGate H v).property g.property (exteriorGate_le H v) hgv + +def exteriorEmbedding (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + SegmentEmbedding (V := ExteriorVertex H) (W := V) := + Region.embedding (fun _a _b _v ha _hb hav _hvb hv => ha (hH hv hav)) + +@[simp] theorem exteriorEmbedding_range (H : Finset V) (hH : Ancestral (· ≤ ·) H) : + Set.range (exteriorEmbedding H hH).toEmbedding = {v | v ∉ H} := by + have _ := locallyFiniteOrderBotV + exact + Region.range_inclusion + +theorem exterior_testTail (H : Finset V) (hH : Ancestral (· ≤ ·) H) (u : Test V) : + (exteriorEmbedding H hH).testMap ((exteriorEmbedding H hH).testRestriction u) = + Test.ofFinsupp (u.coeff.filter (· ∉ H)) := by + classical + apply Finsupp.ext + intro v + change ((exteriorEmbedding H hH).testMap ((exteriorEmbedding H hH).testRestriction u)).coeff v = + (u.coeff.filter (· ∉ H)) v + rw [Finsupp.filter_apply] + by_cases hv : v ∉ H + · rw [ite_eq_left hv] + exact (exteriorEmbedding H hH).testMap_apply _ (⟨v,hv⟩ : ExteriorVertex H) + · rw [ite_eq_right hv] + apply Finsupp.embDomain_of_notMem_range + simpa only [exteriorEmbedding_range, Set.mem_ofPred_eq] using hv + +theorem exterior_primalTail (H : Finset V) (hH : Ancestral (· ≤ ·) H) (x : Primal V) : + (exteriorEmbedding H hH).primalMap ((exteriorEmbedding H hH).primalRestriction x) = primalTail H x := by + refine UniformSpace.Completion.induction_on x + (isClosed_eq ((exteriorEmbedding H hH).primalMap.continuous.comp + (exteriorEmbedding H hH).primalRestriction.continuous) (primalTail H).continuous) ?_ + intro u + rw [SegmentEmbedding.primalRestriction_test,SegmentEmbedding.primalMap_test, + exterior_testTail,primalTail_test] + +theorem primalTail_exterior (H : Finset V) (hH : Ancestral (· ≤ ·) H) (x : Primal (ExteriorVertex H)) : + primalTail H ((exteriorEmbedding H hH).primalMap x) = (exteriorEmbedding H hH).primalMap x := by + rw [← exterior_primalTail H hH, SegmentEmbedding.primalRestriction_primalMap] + + +def exteriorDual (H : Finset V) (hH : Ancestral (· ≤ ·) H) (z : FullDual V) : FullDual (ExteriorVertex H) := + z.comp (exteriorEmbedding H hH).primalMap + + + +theorem norm_exteriorDual (H : Finset V) (hH : Ancestral (· ≤ ·) H) (z : FullDual V) : + ‖exteriorDual H hH z‖ = ‖tail H z‖ := by + apply le_antisymm + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro u + have he : exteriorDual H hH z u = tail H z ((exteriorEmbedding H hH).primalMap u) := by + rw [tail_adjoint,primalTail_exterior] + rfl + rw [he] + simpa only [SegmentEmbedding.norm_primalMap] using + (tail H z).le_opNorm ((exteriorEmbedding H hH).primalMap u) + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro u + rw [tail_adjoint,← exterior_primalTail H hH u] + have h := (exteriorDual H hH z).le_opNorm ((exteriorEmbedding H hH).primalRestriction u) + exact h.trans (mul_le_mul_of_nonneg_left + ((exteriorEmbedding H hH).norm_primalRestriction_le u) (norm_nonneg _)) + +end ExteriorGates + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/HeadRanges.lean b/lean/OAI/Analysis/SegmentLenses/HeadRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d9c28c96833d3a700e00abecbe4c9eb44714238 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/HeadRanges.lean @@ -0,0 +1,173 @@ +import OAI.Analysis.SegmentLenses.Subtrees + +namespace OAI + +/-! +# Finite-head ranges, dimensions, and outside-head density +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +section HeadRange +variable {V : Type*} [DecidableEq V] [SegmentSystem V] + + +theorem primalHead_range (H : Finset V) : + (primalHead H).range = Submodule.span ℝ (unitVector '' (H : Set V)) := by + apply le_antisymm + · rintro _ ⟨x,rfl⟩ + change primalHead H x ∈ _ + rw [primalHead_apply] + apply Submodule.sum_mem + intro v hv + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨v,hv,rfl⟩) + · apply Submodule.span_le.mpr + rintro _ ⟨v,hv,rfl⟩ + change v ∈ H at hv + refine ⟨unitVector v,?_⟩ + change primalHead H (unitVector v) = unitVector v + rw [primalHead_apply] + simp [coordinate_unitVector,hv] + + + +theorem dualHead_range (H : Finset V) : + (headLinear H).range = Submodule.span ℝ (coordinate '' (H : Set V)) := by + apply le_antisymm + · rintro _ ⟨x,rfl⟩ + change head H x ∈ _ + unfold head + apply Submodule.sum_mem + intro v hv + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨v,hv,rfl⟩) + · apply Submodule.span_le.mpr + rintro _ ⟨v,hv,rfl⟩ + refine ⟨coordinate v,?_⟩ + change head H (coordinate v) = coordinate v + apply (head_eq_iff _ _).mpr + intro w hw + have hn : v ≠ w := fun he => hw (he ▸ hv) + simp [coordinate_unitVector,hn] + +theorem primalHead_finiteDimensional (H : Finset V) : + FiniteDimensional ℝ (primalHead H).range := by + rw [primalHead_range] + exact FiniteDimensional.span_of_finite ℝ (H.finite_toSet.image _) + +theorem dualHead_finiteDimensional (H : Finset V) : + FiniteDimensional ℝ (headLinear H).range := by + rw [dualHead_range] + exact FiniteDimensional.span_of_finite ℝ (H.finite_toSet.image _) + +end HeadRange + +section OutsideHeadDensity +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + +local instance : AddCommGroup (CoordinatePredual V) := + (inferInstance : NormedAddCommGroup (CoordinatePredual V)).toAddCommGroup +local instance : Module ℝ (CoordinatePredual V) := + (inferInstance : NormedSpace ℝ (CoordinatePredual V)).toModule + + + +theorem predualHead_finiteDimensional {H : Finset V} (hH : Ancestral (· ≤ ·) H) : + FiniteDimensional ℝ (predualHead hH).range := by + have _ := locallyFiniteOrderBotV + let := dualHead_finiteDimensional (V := V) H + let f : (predualHead hH).range →ₗ[ℝ] (headLinear H).range := + { toFun := fun x => ⟨x.val.val,by + obtain ⟨y,hy⟩ := x.property + exact ⟨y.val,congrArg Subtype.val hy⟩⟩ + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + apply FiniteDimensional.of_injective (V₂ := (headLinear H).range) f + intro x y he + apply Subtype.ext + apply Subtype.ext + exact congrArg (fun z : (headLinear H).range => z.val) he + + + + +theorem predual_kernel_finite_approx {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x : CoordinatePredual V) (hx : predualHead hH x = 0) + {ε : ℝ} (hε : 0 < ε) : + ∃ K : Finset V, Disjoint K H ∧ ∃ z : CoordinatePredual V, + head K z.val = z.val ∧ predualHead hH z = 0 ∧ ‖x-z‖ < ε := by + classical + obtain ⟨L,hL,z,hz,he⟩ := predual_finite_approx x hε + let w := tail H z + have hw : head (L \ H) w = w := by + apply (head_eq_iff _ _).mpr + intro v hv + rw [tail_unitVector] + by_cases hvH : v ∈ H + · simp [hvH] + · have hvL : v ∉ L := fun h => hv (Finset.mem_sdiff.mpr ⟨h,hvH⟩) + simp [hvH,(head_eq_iff L z).mp hz v hvL] + have hwm : w ∈ coordinateSpan V := by rw [← hw]; exact head_mem _ _ + refine ⟨L \ H,Finset.sdiff_disjoint,⟨w,hwm⟩,hw,?_,?_⟩ + · apply Subtype.ext + apply dual_ext_coordinates + intro v + by_cases hv : v ∈ H <;> simp [w,head_unitVector,tail_unitVector,hv] + · have hx0 : head H x.val = 0 := congrArg Subtype.val hx + have heq : x.val-w = tail H (x.val-z) := by + change x.val-tailLinear H z = tailLinear H (x.val-z) + rw [map_sub] + change x.val-tail H z = (x.val-head H x.val)-tail H z + rw [hx0,sub_zero] + change ‖x.val-w‖ < ε + rw [heq] + exact (norm_tail_le hH _).trans_lt he + +end OutsideHeadDensity + + +section CompletedHeadTests +variable {V : Type*} [DecidableEq V] [SegmentSystem V] + + + + +theorem exists_test_of_primalHead_eq (H : Finset V) (p : Primal V) + (hp : primalHead H p = p) : + ∃ q : Test V, q.coeff.support ⊆ H ∧ (q : Primal V) = p ∧ ‖q‖ = ‖p‖ := by + classical + let q : Test V := ∑ v ∈ H, coordinate v p • Test.ofFinsupp (Finsupp.single v 1) + have hq : (q : Primal V) = p := by + rw [← hp, primalHead_apply] + change (UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V) + (∑ v ∈ H, coordinate v p • Test.ofFinsupp (Finsupp.single v 1)) = _ + simp only [map_sum,map_smul] + rfl + refine ⟨q,?_,hq,?_⟩ + · intro v hv + by_contra hn + have hz : q.coeff v = 0 := by + change Test.evaluation v q = 0 + simp only [q,map_sum,map_smul] + apply Finset.sum_eq_zero + intro w hw + change coordinate w p * Finsupp.single w (1 : ℝ) v = 0 + simp [show w ≠ v by rintro rfl; exact hn hw] + exact (Finsupp.mem_support_iff.mp hv) hz + · rw [← hq, UniformSpace.Completion.norm_coe] + +end CompletedHeadTests + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/HeadTests.lean b/lean/OAI/Analysis/SegmentLenses/HeadTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..97e2a4da39474e4c257a4ac9cfc3602fece0cd3f --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/HeadTests.lean @@ -0,0 +1,222 @@ +import OAI.Analysis.SegmentLenses.LawRecovery + +namespace OAI + +/-! +# Common finite norming tests and head localization +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + + + +theorem exists_norming_unitBall {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] (f : E →L[ℝ] ℝ) : + ∃ p : E, ‖p‖ ≤ 1 ∧ f p = ‖f‖ := by + obtain ⟨p, hp, hmax⟩ := (isCompact_closedBall (0 : E) (1 : ℝ)).exists_isMaxOn + (by exact ⟨0, by simp⟩) f.continuous.continuousOn + have hpn : ‖p‖ ≤ 1 := by simpa only [Metric.mem_closedBall, dist_zero_right] using hp + have hpos : 0 ≤ f p := by + have h := hmax (by simp : (0 : E) ∈ Metric.closedBall 0 1) + simpa only [Set.mem_ofPred_eq, map_zero] using h + have hupper : ‖f‖ ≤ f p := by + apply ContinuousLinearMap.opNorm_le_of_unit_norm hpos + intro v hv + rw [Real.norm_eq_abs] + apply abs_le.mpr + constructor + · have h := hmax (show -v ∈ Metric.closedBall (0 : E) 1 by + simp only [Metric.mem_closedBall, dist_zero_right, norm_neg, hv, le_refl]) + change f (-v) ≤ f p at h + rw [map_neg] at h + linarith + · exact hmax (by simpa only [Metric.mem_closedBall, dist_zero_right, hv] using le_rfl) + have hlower : f p ≤ ‖f‖ := calc + f p ≤ |f p| := le_abs_self _ + _ ≤ ‖f‖ * ‖p‖ := f.le_opNorm p + _ ≤ ‖f‖ := mul_le_of_le_one_right (norm_nonneg _) hpn + exact ⟨p, hpn, le_antisymm hlower hupper⟩ + +section HeadTests +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + + +def headTestSpace (H : Finset V) : Submodule ℝ (Test V) where + carrier := {u | ∀ v ∉ H, u.coeff v = 0} + zero_mem' := by intro v hv; rfl + add_mem' := by intro u v hu hv w hw; exact (show u.coeff w + v.coeff w = 0 by rw [hu w hw, hv w hw, add_zero]) + smul_mem' := by intro a u hu w hw; exact (show a * u.coeff w = 0 by rw [hu w hw, mul_zero]) + +instance headTestFinite (H : Finset V) : FiniteDimensional ℝ (headTestSpace H) := by + let e : headTestSpace H →ₗ[ℝ] (H → ℝ) := + { toFun := fun u v => u.val.coeff v.val + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + apply FiniteDimensional.of_injective e + intro u v huv + apply Subtype.ext + change u.val.coeff = v.val.coeff + ext w + by_cases hw : w ∈ H + · exact congrFun huv ⟨w, hw⟩ + · rw [u.property w hw, v.property w hw] + +def restrictDual (H : Finset V) (x : FullDual V) : headTestSpace H →L[ℝ] ℝ := + x.comp ((UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V).comp (headTestSpace H).subtypeL) + +theorem norm_restrictDual_le (H : Finset V) (x : FullDual V) : ‖restrictDual H x‖ ≤ ‖x‖ := by + have _ := decidableEqV + apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro u + have h := x.le_opNorm (u.val : Primal V) + change ‖x (u.val : Primal V)‖ ≤ ‖x‖ * ‖u.val‖ + simpa only [UniformSpace.Completion.norm_coe] using h + +end HeadTests + +section NormingTest +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] + +theorem norm_restrictDual_eq {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x : FullDual V) (hx : head H x = x) : ‖restrictDual H x‖ = ‖x‖ := by + apply le_antisymm (norm_restrictDual_le H x) + apply dual_norm_le x (norm_nonneg (restrictDual H x)) + intro u + let v : headTestSpace H := ⟨Test.ofFinsupp (u.coeff.filter (· ∈ H)), by + intro w hw + exact Finsupp.filter_apply _ _ _ |>.trans (ite_eq_right hw)⟩ + have he : x (u : Primal V) = restrictDual H x v := by + calc + x (u : Primal V) = head H x (u : Primal V) := congrArg (fun z : FullDual V => z (u : Primal V)) hx.symm + _ = x ((Test.ofFinsupp (u.coeff.filter (· ∈ H)) : Test V) : Primal V) := head_pairing H x u + _ = restrictDual H x v := rfl + rw [he] + have h := (restrictDual H x).le_opNorm v + rw [Real.norm_eq_abs] at h + exact h.trans (mul_le_mul_of_nonneg_left (norm_headTest_le hH u.coeff) (norm_nonneg (restrictDual H x))) + + +theorem exists_norming_head {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x : FullDual V) (hx : head H x = x) (hne : x ≠ 0) : + ∃ p : Test V, p.coeff.support ⊆ H ∧ ‖p‖ = 1 ∧ x (p : Primal V) = ‖x‖ := by + obtain ⟨p, hp, hpx⟩ := exists_norming_unitBall (restrictDual H x) + rw [norm_restrictDual_eq hH x hx] at hpx + change ‖p.val‖ ≤ 1 at hp + have hs : p.val.coeff.support ⊆ H := by + intro v hv + by_contra hn + exact Finsupp.mem_support_iff.mp hv (p.property v hn) + have hnorm : ‖p.val‖ = 1 := by + have h := x.le_opNorm (p.val : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe, + show x (p.val : Primal V) = ‖x‖ from hpx, + abs_of_nonneg (norm_nonneg x)] at h + have hxpos := norm_pos_iff.mpr hne + apply le_antisymm hp + nlinarith + exact ⟨p.val, hs, hnorm, hpx⟩ + +end NormingTest + +namespace FiniteLaw +variable {Ω : Type*} [Fintype Ω] + +theorem nonempty (μ : FiniteLaw Ω) : Nonempty Ω := by + by_contra hn + let : IsEmpty Ω := ⟨fun ω => hn ⟨ω⟩⟩ + have ht := μ.total + simp at ht + +theorem abs_mean_le (μ : FiniteLaw Ω) (f : Ω → ℝ) : + |μ.mean f| ≤ μ.mean (fun ω => |f ω|) := by + simpa only [expect_scalar, Real.norm_eq_abs] using μ.norm_expect_le f + +theorem mean_mul_right (μ : FiniteLaw Ω) (f : Ω → ℝ) (c : ℝ) : + μ.mean (fun ω => f ω * c) = μ.mean f * c := by + simpa only [mul_comm] using μ.mean_mul c f + +end FiniteLaw + +section ConeReconstruction +variable {V Ω : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] [Fintype Ω] + + + +theorem cone_reconstruction {H : Finset V} (G : Finset V) (hG : ∀ g ∈ G, Gate H g) + (μ : FiniteLaw Ω) (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) + (b : Ω → G → ℝ) (J : G → Ω → Finset V) + (hJ : ∀ g ω, J g ω = ∅ ∨ SegmentSystem.isSegment (J g ω)) + (hcone : ∀ g ω v, v ∈ J g ω → g.val ≤ v) : + ‖∑ g : G, μ.expect (fun ω => (σ ω * b ω g) • segmentFunctional (J g ω))‖ ≤ + Real.sqrt (∑ g : G, μ.mean (fun ω => |b ω g|) ^ 2) := by + classical + let : Nonempty Ω := μ.nonempty + apply dual_norm_le _ (Real.sqrt_nonneg _) + intro u + have hmax : ∀ g : G, ∃ w : Ω, ∀ ω, |∑ v ∈ J g ω, u.coeff v| ≤ + |∑ v ∈ J g w, u.coeff v| := by + intro g + obtain ⟨w, hw, hm⟩ := Finset.exists_max_image Finset.univ + (fun ω => |∑ v ∈ J g ω, u.coeff v|) Finset.univ_nonempty + exact ⟨w, fun ω => hm ω (Finset.mem_univ _)⟩ + choose choice hc using hmax + let M : G → ℝ := fun g => |∑ v ∈ J g (choice g), u.coeff v| + have hd : Pairwise fun g g' : G => Disjoint (J g (choice g)) (J g' (choice g')) := by + intro g g' hne + apply Finset.disjoint_left.mpr + intro v hv hv' + rcases TreeOrder.lower_chain (hcone g (choice g) v hv) (hcone g' (choice g') v hv') with h | h + · exact hne (Subtype.ext (gates_incomparable (hG _ g.property) (hG _ g'.property) h)) + · exact hne (Subtype.ext (gates_incomparable (hG _ g'.property) (hG _ g.property) h).symm) + have hsq : (∑ g : G, M g ^ 2) ≤ ‖u‖ ^ 2 := by + change (∑ g : G, M g ^ 2) ≤ segmentSeminorm V u.coeff ^ 2 + simpa only [M, sq_abs] using indexed_test_bound u.coeff + (fun g => J g (choice g)) (fun g => hJ g (choice g)) hd + have hM : Real.sqrt (∑ g : G, M g ^ 2) ≤ ‖u‖ := by + have h := Real.sqrt_le_sqrt hsq + rwa [Real.sqrt_sq (norm_nonneg _)] at h + have he : (∑ g : G, μ.expect (fun ω => (σ ω * b ω g) • segmentFunctional (J g ω))) + (u : Primal V) = ∑ g : G, μ.mean (fun ω => σ ω * b ω g * ∑ v ∈ J g ω, u.coeff v) := by + simp only [_root_.sum_apply, FiniteLaw.expect, FiniteLaw.mean, _root_.smul_apply, + smul_eq_mul, segmentFunctional_apply, mul_assoc] + rw [he] + calc + |∑ g : G, μ.mean (fun ω => σ ω * b ω g * ∑ v ∈ J g ω, u.coeff v)| ≤ + ∑ g : G, |μ.mean (fun ω => σ ω * b ω g * ∑ v ∈ J g ω, u.coeff v)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ g : G, μ.mean (fun ω => |b ω g|) * M g := by + apply Finset.sum_le_sum + intro g hg + calc + |μ.mean (fun ω => σ ω * b ω g * ∑ v ∈ J g ω, u.coeff v)| ≤ + μ.mean (fun ω => |σ ω * b ω g * ∑ v ∈ J g ω, u.coeff v|) := μ.abs_mean_le _ + _ ≤ μ.mean (fun ω => |b ω g| * M g) := by + apply μ.mean_mono + intro ω + simp only [abs_mul] + have hsb : |σ ω| * |b ω g| ≤ |b ω g| := + mul_le_of_le_one_left (abs_nonneg _) (hσ ω) + exact mul_le_mul hsb (hc g ω) (abs_nonneg _) (abs_nonneg _) + _ = μ.mean (fun ω => |b ω g|) * M g := μ.mean_mul_right _ _ + _ ≤ Real.sqrt (∑ g : G, μ.mean (fun ω => |b ω g|) ^ 2) * + Real.sqrt (∑ g : G, M g ^ 2) := Real.sum_mul_le_sqrt_mul_sqrt _ _ _ + _ ≤ Real.sqrt (∑ g : G, μ.mean (fun ω => |b ω g|) ^ 2) * ‖u‖ := + mul_le_mul_of_nonneg_left hM (Real.sqrt_nonneg _) + +end ConeReconstruction + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Identifications.lean b/lean/OAI/Analysis/SegmentLenses/Identifications.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fb9619e378bd10cad4acd0a5df3d242c14784df --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Identifications.lean @@ -0,0 +1,259 @@ +import OAI.Analysis.SegmentLenses.Subspaces + +namespace OAI + +/-! +# Hilbertian congruences and forest identifications +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +section L2Congruence +open scoped ENNReal +variable {I : Type*} {E F : I → Type*} [∀ i, NormedAddCommGroup (E i)] + [∀ i, NormedAddCommGroup (F i)] [∀ i, NormedSpace ℝ (E i)] [∀ i, NormedSpace ℝ (F i)] + + +def l2Congr (e : ∀ i, E i ≃ₗᵢ[ℝ] F i) : L2Sum E ≃ₗᵢ[ℝ] L2Sum F where + toFun x := ⟨fun i => e i (x i), x.property.mono' (fun i => (e i).norm_map (x i) |>.le)⟩ + invFun y := ⟨fun i => (e i).symm (y i), y.property.mono' (fun i => (e i).symm.norm_map (y i) |>.le)⟩ + left_inv x := by apply Subtype.ext; funext i; exact (e i).symm_apply_apply _ + right_inv y := by apply Subtype.ext; funext i; exact (e i).apply_symm_apply _ + map_add' x y := by apply Subtype.ext; funext i; exact (e i).map_add _ _ + map_smul' c x := by apply Subtype.ext; funext i; exact (e i).map_smul c _ + norm_map' x := by + apply le_antisymm + · exact lp.norm_mono (by norm_num : (2 : ℝ≥0∞) ≠ 0) (fun i => (e i).norm_map (x i) |>.le) + · exact lp.norm_mono (by norm_num : (2 : ℝ≥0∞) ≠ 0) (fun i => (e i).norm_map (x i) |>.ge) + +@[simp] theorem l2Congr_apply (e : ∀ i, E i ≃ₗᵢ[ℝ] F i) (x : L2Sum E) (i : I) : + l2Congr e x i = e i (x i) := rfl + +end L2Congruence + +namespace SegmentEmbedding +variable {V W : Type*} [DecidableEq V] [DecidableEq W] [SegmentSystem V] [SegmentSystem W] + + + +def testEquivOfSurjective (e : SegmentEmbedding (V := V) (W := W)) + (he : Function.Surjective e.toEmbedding) : Test V ≃ₗᵢ[ℝ] Test W := + LinearIsometryEquiv.ofSurjective e.testIsometry (fun u => ⟨e.testRestriction u, + e.testMap_testRestriction u (fun w hw => False.elim (hw (he w)))⟩) + +def primalEquivOfSurjective (e : SegmentEmbedding (V := V) (W := W)) + (he : Function.Surjective e.toEmbedding) : Primal V ≃ₗᵢ[ℝ] Primal W := + completionIsometry (e.testEquivOfSurjective he) + +@[simp] theorem primalEquivOfSurjective_test (e : SegmentEmbedding (V := V) (W := W)) + (he : Function.Surjective e.toEmbedding) (u : Test V) : + e.primalEquivOfSurjective he (u : Primal V) = (e.testMap u : Primal W) := + completionIsometry_coe _ _ + +end SegmentEmbedding + +namespace ComponentPartition +open scoped Classical +variable {V I : Type*} [DecidableEq V] [decidableEqI : DecidableEq I] [PartialOrder V] + [LocallyFiniteOrder V] [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] (p : ComponentPartition (V := V) (I := I)) + +abbrev BlockVertex (i : I) := Region.Vertex (fun v => p.index v = i) +local instance (i : I) : DecidableEq (BlockVertex p i) := Classical.decEq _ + +def regionEmbedding (i : I) : SegmentEmbedding (V := BlockVertex p i) (W := V) := + Region.embedding (fun _a _b _v ha _hb hav _hvb => (p.comparable hav).symm.trans ha) + +@[simp] theorem regionEmbedding_range (i : I) : + Set.range (regionEmbedding p i).toEmbedding = {v | p.index v = i} := by + have _ := decidableEqI + have _ := locallyFiniteOrderBotV + exact + Region.range_inclusion + + + +def regionTestMap (i : I) : Test (BlockVertex p i) →ₗᵢ[ℝ] blockTests (p := p) i where + toLinearMap := (regionEmbedding p i).testMap.codRestrict (blockTests (p := p) i) (by + intro u + apply mem_blockTests.mpr + apply Finsupp.ext + intro v + change (blockTest (p := p) i ((regionEmbedding p i).testMap u)).coeff v = + ((regionEmbedding p i).testMap u).coeff v + rw [blockTest_apply] + split_ifs with hv + · rfl + · symm + apply Finsupp.embDomain_of_notMem_range + simpa only [regionEmbedding_range, Set.mem_ofPred_eq] using hv) + norm_map' u := (regionEmbedding p i).norm_testMap u + +theorem regionTestMap_surjective (i : I) : Function.Surjective (regionTestMap p i) := by + intro u + refine ⟨(regionEmbedding p i).testRestriction u.val, Subtype.ext ?_⟩ + apply (regionEmbedding p i).testMap_testRestriction + intro v hv + have hn : p.index v ≠ i := by simpa only [regionEmbedding_range, Set.mem_ofPred_eq] using hv + have h := congrArg (fun u : Test V => u.coeff v) (mem_blockTests.mp u.property) + rw [blockTest_apply, ite_eq_right hn] at h + exact h.symm + +def regionTestEquiv (i : I) : Test (BlockVertex p i) ≃ₗᵢ[ℝ] blockTests (p := p) i := + LinearIsometryEquiv.ofSurjective (regionTestMap p i) (regionTestMap_surjective p i) + +def regionPrimalEquiv (i : I) : Primal (BlockVertex p i) ≃ₗᵢ[ℝ] BlockPrimal (p := p) i := + completionIsometry (regionTestEquiv p i) + +@[simp] theorem regionPrimalEquiv_test (i : I) (u : Test (BlockVertex p i)) : + regionPrimalEquiv p i (u : Primal (BlockVertex p i)) = + ((regionTestMap p i u) : BlockPrimal (p := p) i) := + completionIsometry_coe _ _ + + +def regionL2Equiv : Primal V ≃ₗᵢ[ℝ] L2Sum (fun i => Primal (BlockVertex p i)) := + (l2Equiv (p := p)).trans (l2Congr (fun i => (regionPrimalEquiv p i).symm)) + + + +def regionDualL2Equiv : FullDual V ≃ₗᵢ[ℝ] L2Sum (fun i => FullDual (BlockVertex p i)) := + (dualTransport (regionL2Equiv p)).trans + (l2DualEquiv (fun i => Primal (BlockVertex p i))).symm + +end ComponentPartition + + + +namespace SingleTree + +def Vertex (h : ℕ) := Region.Vertex (fun w : InfiniteVertex => w.length ≤ h) +instance (h : ℕ) : PartialOrder (Vertex h) := inferInstanceAs (PartialOrder (Region.Vertex _)) +instance (h : ℕ) : TreeOrder (Vertex h) := inferInstanceAs (TreeOrder (Region.Vertex _)) +instance (h : ℕ) : SegmentSystem (Vertex h) := inferInstanceAs (SegmentSystem (Region.Vertex _)) +instance (h : ℕ) : IntervalSegments (Vertex h) := inferInstanceAs (IntervalSegments (Region.Vertex _)) +instance (h : ℕ) : LocallyFiniteOrder (Vertex h) := inferInstanceAs (LocallyFiniteOrder (Region.Vertex _)) +instance (h : ℕ) : LocallyFiniteOrderBot (Vertex h) := inferInstanceAs (LocallyFiniteOrderBot (Region.Vertex _)) +instance (h : ℕ) : Countable (Vertex h) := inferInstanceAs (Countable (Region.Vertex _)) +local instance (h : ℕ) : DecidableEq (Vertex h) := Classical.decEq _ + + +abbrev J (h : ℕ) := Primal (Vertex h) +abbrev X (h : ℕ) := FullDual (Vertex h) + +variable {I : Type*} [decidableEqI : DecidableEq I] {height : I → ℕ} +local instance : DecidableEq (IndexedForest.Vertex height) := Classical.decEq _ + +def componentOrderEmbedding (i : I) : Vertex (height i) ↪o IndexedForest.Vertex height where + toFun w := ⟨(i,w.val),w.property⟩ + inj' := by intro v w h; exact Subtype.ext (congrArg (fun u : IndexedForest.Vertex height => u.val.2) h) + map_rel_iff' := by intro v w; change (i=i ∧ v.val.IsPrefix w.val) ↔ v.val.IsPrefix w.val; simp + +@[simp] theorem componentEmbedding_range (i : I) : + Set.range (componentOrderEmbedding (height := height) i) = {v | v.val.1 = i} := by + have _ := decidableEqI + ext v + constructor + · rintro ⟨w,rfl⟩; rfl + · intro hv + change v.val.1 = i at hv + refine ⟨⟨v.val.2,?_⟩,?_⟩ + · simpa only [← hv] using v.property + · exact Subtype.ext (Prod.ext hv.symm rfl) + +def componentEmbedding (i : I) : + SegmentEmbedding (V := Vertex (height i)) (W := IndexedForest.Vertex height) := + convexSegmentEmbedding (componentOrderEmbedding i) (by + intro a b v ha hb hav hvb + rw [componentEmbedding_range] at ha hb ⊢ + exact hav.1.symm.trans ha) + +@[simp] theorem componentEmbedding_apply (i : I) (w : Vertex (height i)) : + (componentEmbedding (height := height) i).toEmbedding w = ⟨(i,w.val),w.property⟩ := rfl + +def componentTestMap (i : I) : Test (Vertex (height i)) →ₗᵢ[ℝ] IndexedForest.heightTests (height := height) i where + toLinearMap := (componentEmbedding i).testMap.codRestrict (IndexedForest.heightTests i) (by + intro u + apply IndexedForest.mem_heightTests.mpr + apply Finsupp.ext + intro v + change (IndexedForest.heightTest i ((componentEmbedding i).testMap u)).coeff v = + ((componentEmbedding i).testMap u).coeff v + rw [IndexedForest.heightTest_apply] + split_ifs with hv + · rfl + · symm + apply Finsupp.embDomain_of_notMem_range + change v ∉ Set.range (componentOrderEmbedding i) + simpa only [componentEmbedding_range,Set.mem_ofPred_eq] using hv) + norm_map' u := (componentEmbedding i).norm_testMap u + +theorem componentTestMap_surjective (i : I) : Function.Surjective (componentTestMap (height := height) i) := by + intro u + refine ⟨(componentEmbedding i).testRestriction u.val, Subtype.ext ?_⟩ + apply (componentEmbedding i).testMap_testRestriction + intro v hv + have hn : v.val.1 ≠ i := by + change v ∉ Set.range (componentOrderEmbedding i) at hv + simpa only [componentEmbedding_range,Set.mem_ofPred_eq] using hv + have he := congrArg (fun k : Test (IndexedForest.Vertex height) => k.coeff v) + (IndexedForest.mem_heightTests.mp u.property) + rw [IndexedForest.heightTest_apply,ite_eq_right hn] at he + exact he.symm + +def componentTestEquiv (i : I) : Test (Vertex (height i)) ≃ₗᵢ[ℝ] IndexedForest.heightTests (height := height) i := + LinearIsometryEquiv.ofSurjective (componentTestMap i) (componentTestMap_surjective i) + + + +def componentPrimalEquiv (i : I) : J (height i) ≃ₗᵢ[ℝ] IndexedForest.HeightPrimal (height := height) i := + completionIsometry (componentTestEquiv i) + +@[simp] theorem componentPrimalEquiv_test (i : I) (u : Test (Vertex (height i))) : + componentPrimalEquiv (height := height) i (u : J (height i)) = + ((componentTestMap i u) : IndexedForest.HeightPrimal (height := height) i) := + completionIsometry_coe _ _ + +end SingleTree + +namespace IndexedForest +variable {I : Type*} [DecidableEq I] {height : I → ℕ} +local instance : DecidableEq (Vertex height) := Classical.decEq _ +local instance : ∀ i, NormedAddCommGroup (HeightPrimal (height := height) i) := fun _i => inferInstance +local instance : ∀ i, NormedSpace ℝ (HeightPrimal (height := height) i) := fun _i => inferInstance + + +def singleTreeL2Equiv : J height ≃ₗᵢ[ℝ] L2Sum (fun i => SingleTree.J (height i)) := + (forestL2Equiv (height := height)).trans + (l2Congr (fun i => (SingleTree.componentPrimalEquiv (height := height) i).symm)) + + +def singleTreeDualL2Equiv : X height ≃ₗᵢ[ℝ] L2Sum (fun i => SingleTree.X (height i)) := + (dualL2Equiv (height := height)).trans + (l2Congr (fun i => dualTransport (SingleTree.componentPrimalEquiv (height := height) i).symm)) + + +@[simp] theorem singleTreeDualL2Equiv_on_test (f : X height) (i : I) + (u : Test (SingleTree.Vertex (height i))) : + singleTreeDualL2Equiv f i (u : SingleTree.J (height i)) = + f ((SingleTree.componentEmbedding (height := height) i).testMap u : J height) := by + change dualL2Equiv f i (SingleTree.componentPrimalEquiv i (u : SingleTree.J (height i))) = _ + rw [SingleTree.componentPrimalEquiv_test,dualL2Equiv_on_test] + rfl + +end IndexedForest + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/IndexedDual.lean b/lean/OAI/Analysis/SegmentLenses/IndexedDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f6266578846a2ab816961a5776049781ccab0f3 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/IndexedDual.lean @@ -0,0 +1,213 @@ +import OAI.Analysis.SegmentLenses.IndexedForest + +namespace OAI + +/-! +# Indexed forest duals and unbounded-height obstructions +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +section DualIsometries +variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] + + +def dualTransport (e : E ≃ₗᵢ[ℝ] F) : StrongDual ℝ E ≃ₗᵢ[ℝ] StrongDual ℝ F where + toLinearEquiv := (e.toContinuousLinearEquiv.arrowCongr (ContinuousLinearEquiv.refl ℝ ℝ)).toLinearEquiv + norm_map' f := by + let g := e.toContinuousLinearEquiv.arrowCongr (ContinuousLinearEquiv.refl ℝ ℝ) f + change ‖g‖ = ‖f‖ + apply le_antisymm + · apply g.opNorm_le_bound (norm_nonneg f) + intro y + change ‖f (e.symm y)‖ ≤ _ + simpa only [e.symm.norm_map] using f.le_opNorm (e.symm y) + · apply f.opNorm_le_bound (norm_nonneg g) + intro x + have h := g.le_opNorm (e x) + change ‖f (e.symm (e x))‖ ≤ ‖g‖ * ‖e x‖ at h + simpa only [e.symm_apply_apply, e.norm_map] using h + +@[simp] theorem dualTransport_apply (e : E ≃ₗᵢ[ℝ] F) (f : StrongDual ℝ E) (y : F) : + dualTransport e f y = f (e.symm y) := rfl + +end DualIsometries + +section L2DualInverse +variable {I : Type*} [DecidableEq I] (E : I → Type*) [∀ i, NormedAddCommGroup (E i)] + [∀ i, NormedSpace ℝ (E i)] + +@[simp] theorem l2DualEquiv_symm_apply (f : StrongDual ℝ (L2Sum E)) : + (l2DualEquiv E).symm f = l2DualRestrictions E f := by + apply (l2DualEquiv E).injective + rw [(l2DualEquiv E).apply_symm_apply] + exact (l2DualPair_restrictions E f).symm + +end L2DualInverse + +namespace IndexedForest +variable {I : Type*} [DecidableEq I] {height : I → ℕ} +local instance : DecidableEq (Vertex height) := Classical.decEq _ +local instance : ∀ i, NormedAddCommGroup (HeightPrimal (height := height) i) := fun _i => inferInstance +local instance : ∀ i, NormedSpace ℝ (HeightPrimal (height := height) i) := fun _i => inferInstance + + +def dualL2Equiv : X height ≃ₗᵢ[ℝ] L2Sum (fun i => StrongDual ℝ (HeightPrimal (height := height) i)) := + (dualTransport (forestL2Equiv (height := height))).trans (l2DualEquiv (HeightPrimal (height := height))).symm + +@[simp] theorem dualL2Equiv_apply (f : X height) (i : I) (u : HeightPrimal (height := height) i) : + dualL2Equiv f i u = f ((forestL2Equiv (height := height)).symm (lp.single 2 i u)) := by + change ((l2DualEquiv (HeightPrimal (height := height))).symm + (dualTransport (forestL2Equiv (height := height)) f)) i u = _ + rw [l2DualEquiv_symm_apply] + rfl + +@[simp] theorem dualL2Equiv_on_test (f : X height) (i : I) (u : heightTests (height := height) i) : + dualL2Equiv f i (u : HeightPrimal (height := height) i) = f (u.val : J height) := by + rw [dualL2Equiv_apply] + congr 1 + apply (forestL2Equiv (height := height)).injective + rw [(forestL2Equiv (height := height)).apply_symm_apply, forestL2Equiv_test, + forestTestBlocks_of_height] + + +theorem coordinateSpan_eq_top : coordinateSpan (Vertex height) = ⊤ := + coordinateSpan_eq_top_of_reflexive (forest_primal_reflexive (height := height)) + +theorem separable [Countable I] : TopologicalSpace.SeparableSpace (X height) := + fullDual_separable_of_coordinateSpan coordinateSpan_eq_top + +end IndexedForest + +namespace IndexedForest +variable {I : Type*} [decidableEqI : DecidableEq I] {height : I → ℕ} +local instance : DecidableEq (Vertex height) := Classical.decEq _ +section ForestPaths + +def forestRoot (h : I) : (Vertex height) := ⟨(h, []), by simp⟩ +def forestNode (h : I) (v : List ℕ) (hv : v.length ≤ height h) : (Vertex height) := + ⟨(h, v), hv⟩ + +theorem forest_iic_segment (v : (Vertex height)) : SegmentSystem.isSegment (Finset.Iic v) := by + have _ := decidableEqI + apply (IntervalSegments.iff_interval _).mpr + refine ⟨forestRoot (height := height) v.val.1, v, ⟨rfl, List.nil_prefix⟩, ?_⟩ + intro w + simp only [Finset.mem_Iic] + constructor + · intro h + exact ⟨⟨h.1.symm, List.nil_prefix⟩, h⟩ + · exact And.right + + + +def forestPath (h : I) (v : List ℕ) : X height := + if hv : v.length ≤ height h then segmentFunctional (Finset.Iic (forestNode h v hv)) else 0 + +@[simp] theorem norm_forestPath (h : I) (v : List ℕ) (hv : v.length ≤ height h) : + ‖forestPath (height := height) h v‖ = 1 := by + classical + rw [forestPath, dite_eq_left hv] + exact norm_segmentFunctional _ (forest_iic_segment _) ⟨_, Finset.mem_Iic.mpr le_rfl⟩ + +theorem forestPath_child (h : I) (v : List ℕ) (hv : v.length < height h) (n : ℕ) : + forestPath h (v ++ [n]) = forestPath h v + + coordinate (forestNode h (v ++ [n]) (by simp; omega)) := by + have _ := decidableEqI + classical + let a := forestNode h v hv.le + let b := forestNode h (v ++ [n]) (by simp; omega) + have he : Finset.Iic b = insert b (Finset.Iic a) := by + ext w + simp only [Finset.mem_Iic, Finset.mem_insert] + change (w.val.1 = h ∧ w.val.2.IsPrefix (v ++ [n])) ↔ + w = b ∨ (w.val.1 = h ∧ w.val.2.IsPrefix v) + rw [prefix_append_single_iff] + constructor + · rintro ⟨hc, hw | hw⟩ + · exact Or.inr ⟨hc, hw⟩ + · exact Or.inl (Subtype.ext (Prod.ext hc hw)) + · rintro (rfl | ⟨hc, hw⟩) + · exact ⟨rfl, Or.inr rfl⟩ + · exact ⟨hc, Or.inl hw⟩ + have hn : b ∉ Finset.Iic a := by + intro hx + have hl := (Finset.mem_Iic.mp hx).2.length_le + change (v ++ [n]).length ≤ v.length at hl + simp at hl + rw [forestPath, dite_eq_left (by simp; omega), forestPath, dite_eq_left hv.le] + change segmentFunctional (Finset.Iic b) = segmentFunctional (Finset.Iic a) + coordinate b + rw [he, segmentFunctional, Finset.sum_insert hn, add_comm] + rfl + +theorem forestPath_children_weakly_null (h : I) (v : List ℕ) (hv : v.length < height h) : + WeaklyNull (fun n => forestPath (height := height) h (v ++ [n]) - forestPath h v) := by + classical + have hw := fullDual_distinct_coordinates_weakly_null + (fun n => forestNode h (v ++ [n]) (by simp; omega)) (by + intro n m hn + have hlist := congrArg (fun w : (Vertex height) => w.val.2) hn + simpa only [forestNode, List.append_cancel_left_eq, List.singleton_inj] using hlist) + convert hw using 1 + funext n + rw [forestPath_child h v hv n, add_sub_cancel_left] + +end ForestPaths + + +theorem unbounded_unit_finite_paths (hunbounded : ∀ n : ℕ, ∃ i : I, n ≤ height i) : + UnitFinitePaths (X height) := by + intro n hn + obtain ⟨i, hi⟩ := hunbounded n + refine ⟨forestPath i, ?_, ?_, ?_⟩ + · intro v hv + exact norm_forestPath i v (hv.trans hi) + · intro v hv + exact forestPath_children_weakly_null i v (hv.trans_le hi) + · intro v hv k + rw [forestPath_child i v (hv.trans_le hi) k, add_sub_cancel_left, norm_coordinate] + +theorem unbounded_vertices_infinite (hunbounded : ∀ n : ℕ, ∃ i : I, n ≤ height i) : + Infinite (Vertex height) := by + have _ := decidableEqI + obtain ⟨i, hi⟩ := hunbounded 1 + let f : ℕ → Vertex height := fun n => ⟨(i,[n]), by simpa using hi⟩ + apply Infinite.of_injective f + intro n m h + have he := congrArg (fun v : Vertex height => v.val.2) h + simpa only [f, List.singleton_inj] using he + + +theorem unbounded_equivalent_modulus_zero (hunbounded : ∀ n : ℕ, ∃ i : I, n ≤ height i) + {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] (e : X height ≃L[ℝ] D) + {a b r : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : X height, a * ‖x‖ ≤ ‖e x‖) + (hupper : ∀ x : X height, ‖e x‖ ≤ b * ‖x‖) + (hr : 0 < r) (hrab : r ≤ a/b) : oneSidedModulus D r = 0 := by + let := unbounded_vertices_infinite hunbounded + exact equivalent_paths_modulus_zero fullDual_not_finite (unbounded_unit_finite_paths hunbounded) + e ha hab hlower hupper hr hrab + +theorem unbounded_no_equivalent_AUC (hunbounded : ∀ n : ℕ, ∃ i : I, n ≤ height i) + {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] (e : X height ≃L[ℝ] D) : ¬ AUC D := by + let := unbounded_vertices_infinite hunbounded + exact equivalent_paths_not_auc fullDual_not_finite (unbounded_unit_finite_paths hunbounded) e + +end IndexedForest + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/IndexedForest.lean b/lean/OAI/Analysis/SegmentLenses/IndexedForest.lean new file mode 100644 index 0000000000000000000000000000000000000000..70497e293dc6b078d121289e3ea1d44094db262d --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/IndexedForest.lean @@ -0,0 +1,569 @@ +import OAI.Analysis.SegmentLenses.EndpointLaws + +namespace OAI + +/-! +# Arbitrarily indexed finite-height forests +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +namespace IndexedForest +variable {I : Type*} + +def Vertex (height : I → ℕ) := {p : I × List ℕ // p.2.length ≤ height p.1} + +def Ancestor {height : I → ℕ} (a b : Vertex height) : Prop := + a.val.1 = b.val.1 ∧ a.val.2.IsPrefix b.val.2 + +variable {height : I → ℕ} + +theorem ancestor_refl (v : Vertex height) : Ancestor v v := ⟨rfl, List.prefix_rfl⟩ +theorem ancestor_antisymm {a b : Vertex height} (ha : Ancestor a b) (hb : Ancestor b a) : a=b := + Subtype.ext (Prod.ext ha.1 (prefix_antisymm ha.2 hb.2)) + +instance : SegmentSystem (Vertex height) where + isSegment := IsInterval Ancestor + singleton v := by + refine ⟨v, v, ancestor_refl _, ?_⟩ + intro w + simp only [Finset.mem_singleton] + constructor + · rintro rfl; exact ⟨ancestor_refl _, ancestor_refl _⟩ + · rintro ⟨hvw, hwv⟩ + exact ancestor_antisymm hwv hvw + +instance : PartialOrder (Vertex height) where + le := Ancestor + lt := fun a b => Ancestor a b ∧ ¬ Ancestor b a + le_refl := ancestor_refl + le_trans := fun _ _ _ hab hbc => ⟨hab.1.trans hbc.1, hab.2.trans hbc.2⟩ + le_antisymm := fun _ _ => ancestor_antisymm + +instance : TreeOrder (Vertex height) where + lower_chain := by + intro a b c hac hbc + rcases List.prefix_or_prefix_of_prefix hac.2 hbc.2 with hab | hba + · exact Or.inl ⟨hac.1.trans hbc.1.symm, hab⟩ + · exact Or.inr ⟨hbc.1.trans hac.1.symm, hba⟩ + +instance : IntervalSegments (Vertex height) where + iff_interval _ := Iff.rfl + +instance : LocallyFiniteOrder (Vertex height) := + LocallyFiniteOrder.ofFiniteIcc (by + intro a b + apply Set.Finite.of_injOn (f := fun v : Vertex height => v.val.2) + (t := {w : List ℕ | w.IsPrefix b.val.2}) + · intro v hv; exact hv.2.2 + · intro v hv w hw he + exact Subtype.ext (Prod.ext (hv.2.1.trans hw.2.1.symm) he) + · exact b.val.2.inits.finite_toSet.subset (by + intro w hw; exact (List.mem_inits w b.val.2).mpr hw)) + +instance : LocallyFiniteOrderBot (Vertex height) := by + classical + have hf : ∀ b : Vertex height, {v : Vertex height | v ≤ b}.Finite := by + intro b + apply Set.Finite.of_injOn (f := fun v : Vertex height => v.val.2) + (t := {w : List ℕ | w.IsPrefix b.val.2}) + · intro v hv; exact hv.2 + · intro v hv w hw he + exact Subtype.ext (Prod.ext (hv.1.trans hw.1.symm) he) + · exact b.val.2.inits.finite_toSet.subset (by + intro w hw; exact (List.mem_inits w b.val.2).mpr hw) + exact LocallyFiniteOrderBot.ofIic (Vertex height) (fun b => (hf b).toFinset) + (fun a x => by simp) + +instance [Countable I] : Countable (Vertex height) := by unfold Vertex; infer_instance + +abbrev J (height : I → ℕ) := Primal (Vertex height) +abbrev X (height : I → ℕ) := FullDual (Vertex height) + +variable [decidableEqI : DecidableEq I] +local instance : DecidableEq (Vertex height) := Classical.decEq _ +section HeightBlocks + + +def heightTest (h : I) : Test (Vertex height) →ₗ[ℝ] Test (Vertex height) where + toFun u := Test.ofFinsupp (u.coeff.filter (fun v => v.val.1 = h)) + map_add' _u _v := Finsupp.filter_add + map_smul' _c _u := Finsupp.filter_smul + +@[simp] theorem heightTest_apply (h : I) (u : Test (Vertex height)) (v : (Vertex height)) : + ((heightTest (height := height)) h u).coeff v = if v.val.1 = h then u.coeff v else 0 := Finsupp.filter_apply _ _ _ + +theorem norm_heightTest_le (h : I) (u : Test (Vertex height)) : ‖(heightTest (height := height)) h u‖ ≤ ‖u‖ := by + classical + apply norm_filter_le + intro a b v ha hb hav hvb + exact hav.1.symm.trans ha + + +theorem segment_same_height {S : Finset (Vertex height)} (hS : SegmentSystem.isSegment S) + {v w : (Vertex height)} (hv : v ∈ S) (hw : w ∈ S) : v.val.1 = w.val.1 := by + have _ := decidableEqI + obtain ⟨a, b, hab, hs⟩ := hS + exact ((hs v).mp hv).1.1.symm.trans ((hs w).mp hw).1.1 + + +theorem segment_level_injective {S : Finset (Vertex height)} (hS : SegmentSystem.isSegment S) : + Set.InjOn (fun v : (Vertex height) => v.val.2.length) S := by + have _ := decidableEqI + obtain ⟨a, b, hab, hs⟩ := hS + intro v hv w hw he + have hvb := ((hs v).mp hv).2 + have hwb := ((hs w).mp hw).2 + apply Subtype.ext + refine Prod.ext (hvb.1.trans hwb.1.symm) ?_ + rcases List.prefix_or_prefix_of_prefix hvb.2 hwb.2 with h | h + · exact h.eq_of_length he + · exact (h.eq_of_length he.symm).symm + +theorem segment_card_bound {S : Finset (Vertex height)} (hS : SegmentSystem.isSegment S) + {h : I} (hc : ∀ v ∈ S, v.val.1 = h) : S.card ≤ height h + 1 := by + classical + calc + S.card = (S.image (fun v => v.val.2.length)).card := + (Finset.card_image_of_injOn ((segment_level_injective (height := height)) hS)).symm + _ ≤ (Finset.range (height h + 1)).card := Finset.card_le_card (by + intro n hn + obtain ⟨v, hv, rfl⟩ := Finset.mem_image.mp hn + apply Finset.mem_range.mpr + have hh := v.property + rw [hc v hv] at hh + omega) + _ = height h + 1 := Finset.card_range _ + + +def familyAtHeight (F : SegmentFamily (Vertex height)) (h : I) : + SegmentFamily (Vertex height) where + sets := F.sets.filter (fun S => ∀ v ∈ S, v.val.1 = h) + segment S hS := F.segment S (Finset.mem_filter.mp hS).1 + disjoint := by + intro S hS T hT hne + exact F.disjoint (Finset.mem_filter.mp hS).1 (Finset.mem_filter.mp hT).1 hne + +theorem atHeight_seminorm (F : SegmentFamily (Vertex height)) (h : I) (u : Test (Vertex height)) : + ((familyAtHeight (height := height)) F h).seminorm u.coeff = F.seminorm ((heightTest (height := height)) h u).coeff := by + have he : ((familyAtHeight (height := height)) F h).seminorm u.coeff ^ 2 = F.seminorm ((heightTest (height := height)) h u).coeff ^ 2 := by + rw [SegmentFamily.seminorm_sq, SegmentFamily.seminorm_sq] + rw [Finset.sum_coe_sort ((familyAtHeight (height := height)) F h).sets (fun S => (∑ v ∈ S, u.coeff v) ^ 2), + Finset.sum_coe_sort F.sets (fun S => (∑ v ∈ S, ((heightTest (height := height)) h u).coeff v) ^ 2)] + change (∑ S ∈ F.sets.filter _, _) = ∑ S ∈ F.sets, _ + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro S hS + split_ifs with hc + · congr 1 + apply Finset.sum_congr rfl + intro v hv + simp only [(heightTest_apply (height := height)), hc v hv, ite_true] + · have hz : ∀ v ∈ S, v.val.1 ≠ h := by + intro v hv heq + apply hc + intro w hw + exact ((segment_same_height (height := height)) (F.segment S hS) hw hv).trans heq + simp only [(heightTest_apply (height := height))] + simp only [Finset.sum_eq_zero (fun v hv => ite_eq_right (hz v hv)), zero_pow (by decide : 2 ≠ 0)] + nlinarith [apply_nonneg ((familyAtHeight (height := height)) F h).seminorm u.coeff, + apply_nonneg F.seminorm ((heightTest (height := height)) h u).coeff] + + + +theorem height_hilbert_upper (h : I) (u : Test (Vertex height)) + (hu : (heightTest (height := height)) h u = u) : + ‖u‖ ^ 2 ≤ (height h + 1 : ℝ) * ∑ v ∈ u.coeff.support, u.coeff v ^ 2 := by + classical + obtain ⟨F, hF⟩ := exists_norming_family u + let G := (familyAtHeight (height := height)) F h + have hG : G.seminorm u.coeff = ‖u‖ := by rw [(atHeight_seminorm (height := height)), hu, hF] + rw [← hG, G.seminorm_sq] + have hlocal : ∀ S : G.sets, (∑ v ∈ S.val, u.coeff v) ^ 2 ≤ + (height h + 1 : ℝ) * ∑ v ∈ S.val, u.coeff v ^ 2 := by + intro S + have hcs : (∑ v ∈ S.val, u.coeff v) ^ 2 ≤ + (S.val.card : ℝ) * ∑ v ∈ S.val, u.coeff v ^ 2 := by + simpa using Finset.sum_mul_sq_le_sq_mul_sq S.val (fun _ => (1 : ℝ)) (fun v => u.coeff v) + have hc := (segment_card_bound (height := height)) (G.segment _ S.property) + (Finset.mem_filter.mp S.property).2 + have hcr : (S.val.card : ℝ) ≤ height h + 1 := by exact_mod_cast hc + exact hcs.trans (mul_le_mul_of_nonneg_right hcr (Finset.sum_nonneg (fun _ _ => sq_nonneg _))) + calc + (∑ S : G.sets, (∑ v ∈ S.val, u.coeff v) ^ 2) ≤ + ∑ S : G.sets, (height h + 1 : ℝ) * ∑ v ∈ S.val, u.coeff v ^ 2 := Finset.sum_le_sum (fun S _ => hlocal S) + _ = (height h + 1 : ℝ) * ∑ S : G.sets, ∑ v ∈ S.val, u.coeff v ^ 2 := (Finset.mul_sum ..).symm + _ ≤ (height h + 1 : ℝ) * ∑ v ∈ u.coeff.support, u.coeff v ^ 2 := by + gcongr + rw [Finset.sum_coe_sort G.sets (fun S => ∑ v ∈ S, u.coeff v ^ 2)] + have hs : (∑ v ∈ G.sets.biUnion id, u.coeff v ^ 2) = + ∑ S ∈ G.sets, ∑ v ∈ S, u.coeff v ^ 2 := by + simpa only [id_eq] using Finset.sum_biUnion (f := fun v => u.coeff v ^ 2) G.disjoint + rw [← hs] + have he : (∑ v ∈ G.sets.biUnion id, u.coeff v ^ 2) = + ∑ v ∈ G.sets.biUnion id ∩ u.coeff.support, u.coeff v ^ 2 := by + symm + apply Finset.sum_subset Finset.inter_subset_left + intro v hv hnv + have hn : v ∉ u.coeff.support := fun hs => hnv (Finset.mem_inter.mpr ⟨hv, hs⟩) + simp only [Finsupp.notMem_support_iff.mp hn, zero_pow (by decide : 2 ≠ 0)] + rw [he] + exact Finset.sum_le_sum_of_subset_of_nonneg Finset.inter_subset_right (fun _ _ _ => sq_nonneg _) + +end HeightBlocks + +section ForestNormDecomposition + +def testHeights (u : Test (Vertex height)) : Finset I := u.coeff.support.image (fun v => v.val.1) + +theorem heightTest_eq_zero {u : Test (Vertex height)} {h : I} (hh : h ∉ (testHeights (height := height)) u) : + (heightTest (height := height)) h u = 0 := by + apply Finsupp.ext + intro v + change ((heightTest (height := height)) h u).coeff v = 0 + rw [(heightTest_apply (height := height))] + split_ifs with hv + · apply Finsupp.notMem_support_iff.mp + intro hs + exact hh (Finset.mem_image.mpr ⟨v, hs, hv⟩) + · rfl + +theorem heightTest_idem (h : I) (u : Test (Vertex height)) : + (heightTest (height := height)) h ((heightTest (height := height)) h u) = (heightTest (height := height)) h u := by + apply Finsupp.ext + intro v + change ((heightTest (height := height)) h ((heightTest (height := height)) h u)).coeff v = ((heightTest (height := height)) h u).coeff v + by_cases hv : v.val.1 = h <;> simp [(heightTest_apply (height := height)), hv] + +theorem heightTest_ne {h k : I} (hk : h ≠ k) (u : Test (Vertex height)) : + (heightTest (height := height)) h ((heightTest (height := height)) k u) = 0 := by + apply Finsupp.ext + intro v + change ((heightTest (height := height)) h ((heightTest (height := height)) k u)).coeff v = 0 + simp only [(heightTest_apply (height := height))] + split_ifs with hv hv' + · exact (hk (hv.symm.trans hv')).elim + · rfl + · rfl + + +theorem forest_norm_sq_decomposition (u : Test (Vertex height)) : + ‖u‖ ^ 2 = ∑ h ∈ (testHeights (height := height)) u, ‖(heightTest (height := height)) h u‖ ^ 2 := by + classical + apply le_antisymm + · obtain ⟨F, hF⟩ := exists_norming_family u + have he : F.seminorm u.coeff ^ 2 = + ∑ h ∈ (testHeights (height := height)) u, F.seminorm ((heightTest (height := height)) h u).coeff ^ 2 := by + simp_rw [F.seminorm_sq] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + obtain ⟨a, b, hab, hs⟩ := F.segment S.val S.property + have hc : ∀ v ∈ S.val, v.val.1 = a.val.1 := fun v hv => ((hs v).mp hv).1.1.symm + have hv : ∀ h, (∑ v ∈ S.val, ((heightTest (height := height)) h u).coeff v) ^ 2 = + if h = a.val.1 then (∑ v ∈ S.val, u.coeff v) ^ 2 else 0 := by + intro h + by_cases hh : h = a.val.1 + · subst h + simp only [(heightTest_apply (height := height)), Finset.sum_congr rfl (fun v hv => ite_eq_left (hc v hv)), ite_true] + · have hn : ∀ v ∈ S.val, v.val.1 ≠ h := fun v hv he => hh (he.symm.trans (hc v hv)) + simp only [(heightTest_apply (height := height)), Finset.sum_congr rfl (fun v hv => ite_eq_right (hn v hv)), Finset.sum_const_zero, + zero_pow (by decide : 2 ≠ 0), ite_eq_right hh] + simp_rw [hv] + by_cases ha : a.val.1 ∈ (testHeights (height := height)) u + · simp only [Finset.sum_ite_eq', ite_eq_left ha] + · have hz : ∑ v ∈ S.val, u.coeff v = 0 := by + apply Finset.sum_eq_zero + intro v hv + apply Finsupp.notMem_support_iff.mp + intro hvs + exact ha (Finset.mem_image.mpr ⟨v, hvs, hc v hv⟩) + simp [hz] + rw [← hF, he] + exact Finset.sum_le_sum (fun h _ => sq_le_sq₀ (apply_nonneg _ _) (norm_nonneg _) |>.mpr + (le_segmentSeminorm _ _)) + · have hex : ∀ h : (testHeights (height := height)) u, ∃ F : SegmentFamily (Vertex height), + F.seminorm ((heightTest (height := height)) h.val u).coeff = ‖(heightTest (height := height)) h.val u‖ := + fun h => exists_norming_family _ + choose F hF using hex + let G : (testHeights (height := height)) u → SegmentFamily (Vertex height) := fun h => (familyAtHeight (height := height)) (F h) h.val + have hn : ∀ h, (G h).seminorm u.coeff = ‖(heightTest (height := height)) h.val u‖ := by + intro h + exact ((atHeight_seminorm (height := height)) (F h) h.val u).trans (hF h) + let pieces : (h : (testHeights (height := height)) u) × (G h).sets → Finset (Vertex height) := fun j => j.2.val + have hseg : ∀ j, pieces j = ∅ ∨ SegmentSystem.isSegment (pieces j) := fun j => + Or.inr ((G j.1).segment _ j.2.property) + have hd : Pairwise fun i j => Disjoint (pieces i) (pieces j) := by + intro i j hij + by_cases hh : i.1 = j.1 + · rcases i with ⟨i, S⟩ + rcases j with ⟨j, T⟩ + dsimp at hh + subst j + exact (G i).disjoint S.property T.property (fun he => hij (by cases Subtype.ext he; rfl)) + · apply Finset.disjoint_left.mpr + intro v hv hw + have hvh := (Finset.mem_filter.mp i.2.property).2 v hv + have hwh := (Finset.mem_filter.mp j.2.property).2 v hw + exact hh (Subtype.ext (hvh.symm.trans hwh)) + have hb := indexed_test_bound u.coeff pieces hseg hd + change (∑ j, (∑ v ∈ pieces j, u.coeff v) ^ 2) ≤ ‖u‖ ^ 2 at hb + rw [Fintype.sum_sigma] at hb + have he : (∑ h : (testHeights (height := height)) u, ∑ S : (G h).sets, (∑ v ∈ S.val, u.coeff v) ^ 2) = + ∑ h ∈ (testHeights (height := height)) u, ‖(heightTest (height := height)) h u‖ ^ 2 := by + rw [← Finset.sum_coe_sort ((testHeights (height := height)) u) (fun h => ‖(heightTest (height := height)) h u‖ ^ 2)] + apply Finset.sum_congr rfl + intro h hh + rw [← (G h).seminorm_sq, hn] + exact he ▸ hb + +end ForestNormDecomposition + +section HeightHilbertEquivalence + + + +def heightTests (h : I) : Submodule ℝ (Test (Vertex height)) := LinearMap.range ((heightTest (height := height)) h) + +theorem mem_heightTests {h : I} {u : Test (Vertex height)} : + u ∈ (heightTests (height := height)) h ↔ (heightTest (height := height)) h u = u := by + constructor + · rintro ⟨v, rfl⟩ + exact (heightTest_idem (height := height)) h v + · intro hu + exact ⟨u, hu⟩ + +abbrev HeightPrimal (h : I) := UniformSpace.Completion ((heightTests (height := height)) h) + +def heightHilbert (h : I) : Submodule ℝ (lp (fun _ : (Vertex height) => ℝ) 2) where + carrier := {x | ∀ v : (Vertex height), v.val.1 ≠ h → x v = 0} + zero_mem' := by intro v hv; rfl + add_mem' := by intro x y hx hy v hv; simp only [lp.coeFn_add, Pi.add_apply, hx v hv, hy v hv, add_zero] + smul_mem' := by intro c x hx v hv; simp only [lp.coeFn_smul, Pi.smul_apply, hx v hv, smul_zero] + +theorem heightHilbert_closed (h : I) : IsClosed ((heightHilbert (height := height)) h : Set (lp (fun _ : (Vertex height) => ℝ) 2)) := by + have _ := decidableEqI + change IsClosed {x : lp (fun _ : (Vertex height) => ℝ) 2 | ∀ v, v.val.1 ≠ h → x v = 0} + simp only [Set.ofPred_forall] + apply isClosed_iInter + intro v + apply isClosed_iInter + intro hv + exact isClosed_eq (lp.evalCLM ℝ (fun _ : (Vertex height) => ℝ) 2 v).continuous continuous_const + +instance (h : I) : CompleteSpace ((heightHilbert (height := height)) h) := ((heightHilbert_closed (height := height)) h).completeSpace_coe + + +def heightToHilbert (h : I) : (heightTests (height := height)) h →ₗ[ℝ] (heightHilbert (height := height)) h where + toFun u := ⟨testL2 u.val, by + intro v hv + rw [testL2_apply, ← (mem_heightTests (height := height)).mp u.property] + exact ite_eq_right hv⟩ + map_add' u v := Subtype.ext (testL2.map_add u.val v.val) + map_smul' c u := Subtype.ext (testL2.map_smul c u.val) + +@[simp] theorem heightToHilbert_apply (h : I) (u : (heightTests (height := height)) h) (v : (Vertex height)) : + ((heightToHilbert (height := height)) h u).val v = u.val.coeff v := testL2_apply _ _ + + +theorem heightToHilbert_dense (h : I) : DenseRange ((heightToHilbert (height := height)) h) := by + classical + intro x + let u : Finset (Vertex height) → (heightTests (height := height)) h := fun s => + ⟨(heightTest (height := height)) h (Test.ofFinite s (fun v => x.val v)), ⟨_, rfl⟩⟩ + have he : ∀ s, ((heightToHilbert (height := height)) h (u s)).val = ∑ v ∈ s, lp.single 2 v (x.val v) := by + intro s + apply Subtype.ext + funext v + simp only [(heightToHilbert_apply (height := height)), u, (heightTest_apply (height := height))] + rw [Test.coeff_ofFinite] + have hs : (∑ w ∈ s, lp.single 2 w (x.val w)) v = if v ∈ s then x.val v else 0 := by + simp only [lp.coeFn_sum, Finset.sum_apply] + by_cases hv : v ∈ s + · rw [Finset.sum_eq_single v] + · simp only [lp.single_apply_self, ite_eq_left hv] + · intro w hw hwv; exact lp.single_apply_ne _ _ _ hwv.symm + · exact fun hn => (hn hv).elim + · rw [ite_eq_right hv] + apply Finset.sum_eq_zero + intro w hw + exact lp.single_apply_ne _ _ _ (fun he => hv (he ▸ hw)) + rw [hs] + by_cases hv : v.val.1 = h + · simp [hv] + · simp [hv, x.property v hv] + have ht : Filter.Tendsto (fun s => (heightToHilbert (height := height)) h (u s)) Filter.atTop (nhds x) := by + apply tendsto_subtype_rng.mpr + simpa only [HasSum, SummationFilter.unconditional_filter, he] using (lp.hasSum_single (by norm_num : (2 : ℝ≥0∞) ≠ ⊤) x.val) + exact isClosed_closure.mem_of_tendsto ht (Filter.Eventually.of_forall (fun s => + subset_closure ⟨u s, rfl⟩)) + + +def heightHilbertEquiv (h : I) : (HeightPrimal (height := height)) h ≃L[ℝ] (heightHilbert (height := height)) h := + (LinearEquiv.refl ℝ ((heightTests (height := height)) h)).extend + (UniformSpace.Completion.toComplL : (heightTests (height := height)) h →L[ℝ] (HeightPrimal (height := height)) h).toLinearMap + ((heightToHilbert (height := height)) h) + UniformSpace.Completion.denseRange_coe + ⟨1, fun u => by + change ‖testL2 u.val‖ ≤ 1 * ‖(u : (HeightPrimal (height := height)) h)‖ + rw [one_mul, UniformSpace.Completion.norm_coe] + exact norm_testL2_le u.val⟩ + ((heightToHilbert_dense (height := height)) h) + ⟨Real.sqrt (height h + 1), fun u => by + change ‖(u : (HeightPrimal (height := height)) h)‖ ≤ Real.sqrt (height h + 1) * ‖testL2 u.val‖ + rw [UniformSpace.Completion.norm_coe] + have hb := (height_hilbert_upper (height := height)) h u.val ((mem_heightTests (height := height)).mp u.property) + change ‖u.val‖ ≤ _ + rw [← norm_testL2_sq] at hb + have hs := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ height h + 1) + nlinarith [norm_nonneg u, norm_nonneg (testL2 u.val), Real.sqrt_nonneg (height h + 1), + mul_nonneg (Real.sqrt_nonneg (height h + 1)) (norm_nonneg (testL2 u.val))]⟩ + +theorem heightPrimal_reflexive (h : I) : Reflexive ((HeightPrimal (height := height)) h) := + (hilbert_reflexive ((heightHilbert (height := height)) h)).of_equiv ((heightHilbertEquiv (height := height)) h).symm + +end HeightHilbertEquivalence + +section ForestCompletionIdentification + +local instance heightPrimalFamilyNormed : ∀ h, NormedAddCommGroup ((HeightPrimal (height := height)) h) := fun _h => inferInstance +local instance heightPrimalFamilySpace : ∀ h, NormedSpace ℝ ((HeightPrimal (height := height)) h) := fun _h => inferInstance +local instance : Module ℝ (J height) := (inferInstance : NormedSpace ℝ (J height)).toModule +local instance : Module ℝ (L2Sum (HeightPrimal (height := height))) := (inferInstance : NormedSpace ℝ (L2Sum (HeightPrimal (height := height)))).toModule +local instance : AddCommMonoid (L2Sum (HeightPrimal (height := height))) := + (inferInstance : NormedAddCommGroup (L2Sum (HeightPrimal (height := height)))).toAddCommMonoid + + +def heightBlockTest (h : I) : Test (Vertex height) →ₗ[ℝ] (HeightPrimal (height := height)) h := + (UniformSpace.Completion.toComplL : (heightTests (height := height)) h →L[ℝ] (HeightPrimal (height := height)) h).toLinearMap.comp + ((heightTest (height := height)) h).rangeRestrict + +@[simp] theorem norm_heightBlockTest (h : I) (u : Test (Vertex height)) : + ‖(heightBlockTest (height := height)) h u‖ = ‖(heightTest (height := height)) h u‖ := UniformSpace.Completion.norm_coe _ + +theorem heightBlockTest_zero {h : I} {u : Test (Vertex height)} (hz : (heightTest (height := height)) h u = 0) : + (heightBlockTest (height := height)) h u = 0 := by + apply norm_eq_zero.mp + exact ((norm_heightBlockTest (height := height)) h u).trans (by rw [hz, norm_zero]) + +def forestBlockVector (u : Test (Vertex height)) : L2Sum (HeightPrimal (height := height)) := + ∑ h ∈ (testHeights (height := height)) u, lp.single 2 h ((heightBlockTest (height := height)) h u) + +@[simp] theorem forestBlockVector_apply (u : Test (Vertex height)) (h : I) : + (forestBlockVector (height := height)) u h = (heightBlockTest (height := height)) h u := by + classical + simp only [forestBlockVector, lp.coeFn_sum, Finset.sum_apply] + rw [Finset.sum_eq_single h] + · exact lp.single_apply_self _ _ _ + · intro k hk hkh + exact lp.single_apply_ne _ _ _ hkh.symm + · intro hh + simp only [(heightBlockTest_zero (height := height)) ((heightTest_eq_zero (height := height)) hh), lp.single_zero, lp.coeFn_zero, Pi.zero_apply] + +def forestTestBlocks : Test (Vertex height) →ₗ[ℝ] L2Sum (HeightPrimal (height := height)) where + toFun := (forestBlockVector (height := height)) + map_add' u v := by + apply Subtype.ext + funext h + simp only [(forestBlockVector_apply (height := height)), lp.coeFn_add, Pi.add_apply, map_add] + map_smul' c u := by + apply Subtype.ext + funext h + simp only [(forestBlockVector_apply (height := height)), lp.coeFn_smul, Pi.smul_apply, map_smul, RingHom.id_apply] + +@[simp] theorem forestTestBlocks_apply (u : Test (Vertex height)) (h : I) : + (forestTestBlocks (height := height)) u h = (heightBlockTest (height := height)) h u := (forestBlockVector_apply (height := height)) u h + +theorem norm_forestTestBlocks (u : Test (Vertex height)) : ‖(forestTestBlocks (height := height)) u‖ = ‖u‖ := by + have he : ‖(forestTestBlocks (height := height)) u‖ ^ 2 = ‖u‖ ^ 2 := by + change ‖∑ h ∈ (testHeights (height := height)) u, lp.single 2 h ((heightBlockTest (height := height)) h u)‖ ^ 2 = _ + rw [l2_norm_sum_single_sq, (forest_norm_sq_decomposition (height := height))] + simp only [(norm_heightBlockTest (height := height))] + exact (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp he + + + +theorem forestTestBlocks_of_height (h : I) (u : (heightTests (height := height)) h) : + (forestTestBlocks (height := height)) u.val = lp.single 2 h (u : (HeightPrimal (height := height)) h) := by + classical + apply Subtype.ext + funext k + rw [(forestTestBlocks_apply (height := height))] + by_cases hk : k = h + · subst k + rw [lp.single_apply_self] + change ((⟨(heightTest (height := height)) h u.val, _⟩ : (heightTests (height := height)) h) : (HeightPrimal (height := height)) h) = _ + congr 1 + exact Subtype.ext ((mem_heightTests (height := height)).mp u.property) + · rw [lp.single_apply_ne _ _ _ hk] + apply (heightBlockTest_zero (height := height)) + rw [← (mem_heightTests (height := height)).mp u.property] + exact (heightTest_ne (height := height)) hk u.val + + + +theorem forestTestBlocks_dense : DenseRange (forestTestBlocks (height := height)) := by + classical + let M := (LinearMap.range (forestTestBlocks (height := height))).topologicalClosure + have hclosed : IsClosed (M : Set (L2Sum (HeightPrimal (height := height)))) := Submodule.isClosed_topologicalClosure _ + have hs : ∀ h (x : (HeightPrimal (height := height)) h), lp.single 2 h x ∈ M := by + intro h x + refine UniformSpace.Completion.induction_on x + (p := fun x => lp.single 2 h x ∈ M) + (by exact hclosed.preimage (lp.singleContinuousLinearMap ℝ (HeightPrimal (height := height)) 2 h).continuous) ?_ + intro u + apply Submodule.le_topologicalClosure + exact ⟨u.val, (forestTestBlocks_of_height (height := height)) h u⟩ + intro x + change x ∈ M + apply hclosed.mem_of_tendsto (lp.hasSum_single (by norm_num : (2 : ℝ≥0∞) ≠ ⊤) x) + exact Filter.Eventually.of_forall (fun s => M.sum_mem (fun h hh => hs h (x h))) + + +def forestL2Equiv : (J height) ≃ₗᵢ[ℝ] L2Sum (HeightPrimal (height := height)) := + (LinearEquiv.refl ℝ (Test (Vertex height))).extendOfIsometry + (UniformSpace.Completion.toComplL : Test (Vertex height) →L[ℝ] (J height)).toLinearMap + (forestTestBlocks (height := height)) UniformSpace.Completion.denseRange_coe (forestTestBlocks_dense (height := height)) + (fun u => by + change ‖(forestTestBlocks (height := height)) u‖ = ‖(u : (J height))‖ + rw [UniformSpace.Completion.norm_coe] + exact (norm_forestTestBlocks (height := height)) u) + +@[simp] theorem forestL2Equiv_test (u : Test (Vertex height)) : + (forestL2Equiv (height := height)) (u : (J height)) = (forestTestBlocks (height := height)) u := + by + change (forestL2Equiv (height := height)) ((UniformSpace.Completion.toComplL : Test (Vertex height) →L[ℝ] (J height)) u) = _ + unfold forestL2Equiv + exact + (LinearEquiv.extendOfIsometry_eq (LinearEquiv.refl ℝ (Test (Vertex height))) + (UniformSpace.Completion.toComplL : Test (Vertex height) →L[ℝ] (J height)).toLinearMap + (forestTestBlocks (height := height)) UniformSpace.Completion.denseRange_coe (forestTestBlocks_dense (height := height)) + (fun u => by change ‖(forestTestBlocks (height := height)) u‖ = ‖(u : (J height))‖; rw [UniformSpace.Completion.norm_coe]; exact (norm_forestTestBlocks (height := height)) u) u) + + +theorem forest_primal_reflexive : Reflexive (J height) := + (l2Sum_reflexive (HeightPrimal (height := height)) (heightPrimal_reflexive (height := height))).of_equiv + (forestL2Equiv (height := height)).symm.toContinuousLinearEquiv + + +theorem forest_dual_reflexive : Reflexive (X height) := (forest_primal_reflexive (height := height)).dual + +end ForestCompletionIdentification + +end IndexedForest + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/LawRecovery.lean b/lean/OAI/Analysis/SegmentLenses/LawRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c7775f68730bcd080b76a5987bb9f1bfb90a763 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/LawRecovery.lean @@ -0,0 +1,311 @@ +import OAI.Analysis.SegmentLenses.AtomicBalls + +namespace OAI + +/-! +# Exact finite-law recovery and coefficient representations +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + +namespace FiniteLaw +variable {Ω : Type*} [Fintype Ω] + + +def expect (μ : FiniteLaw Ω) {E : Type*} [AddCommMonoid E] [Module ℝ E] (f : Ω → E) : E := + ∑ ω, μ.weight ω • f ω + +@[simp] theorem expect_const (μ : FiniteLaw Ω) {E : Type*} [AddCommMonoid E] [Module ℝ E] + (c : E) : μ.expect (fun _ => c) = c := by + simp only [expect, ← Finset.sum_smul, μ.total, one_smul] + +@[simp] theorem expect_add (μ : FiniteLaw Ω) {E : Type*} [AddCommMonoid E] [Module ℝ E] + (f g : Ω → E) : μ.expect (fun ω => f ω + g ω) = μ.expect f + μ.expect g := by + simp only [expect, smul_add, Finset.sum_add_distrib] + +@[simp] theorem expect_sub (μ : FiniteLaw Ω) {E : Type*} [AddCommGroup E] [Module ℝ E] + (f g : Ω → E) : μ.expect (fun ω => f ω - g ω) = μ.expect f - μ.expect g := by + simp only [expect, smul_sub, Finset.sum_sub_distrib] + +@[simp] theorem expect_smul (μ : FiniteLaw Ω) {E : Type*} [AddCommMonoid E] [Module ℝ E] + (a : ℝ) (f : Ω → E) : μ.expect (fun ω => a • f ω) = a • μ.expect f := by + simp only [expect, Finset.smul_sum] + apply Finset.sum_congr rfl + intro ω hω + exact smul_comm _ _ _ + +@[simp] theorem expect_map (μ : FiniteLaw Ω) {E F : Type*} [AddCommMonoid E] [Module ℝ E] + [AddCommMonoid F] [Module ℝ F] (T : E →ₗ[ℝ] F) (f : Ω → E) : + μ.expect (fun ω => T (f ω)) = T (μ.expect f) := by + simp only [expect, map_sum, map_smul] + +@[simp] theorem expect_scalar (μ : FiniteLaw Ω) (f : Ω → ℝ) : μ.expect f = μ.mean f := rfl + +@[simp] theorem mean_sum (μ : FiniteLaw Ω) {ι : Type*} [Fintype ι] (f : Ω → ι → ℝ) : + μ.mean (fun ω => ∑ i, f ω i) = ∑ i, μ.mean (fun ω => f ω i) := by + simp only [mean, Finset.mul_sum] + exact Finset.sum_comm + +theorem norm_expect_le (μ : FiniteLaw Ω) {E : Type*} [SeminormedAddCommGroup E] + [NormedSpace ℝ E] (f : Ω → E) : ‖μ.expect f‖ ≤ μ.mean (fun ω => ‖f ω‖) := by + calc + ‖μ.expect f‖ ≤ ∑ ω, ‖μ.weight ω • f ω‖ := norm_sum_le _ _ + _ = μ.mean (fun ω => ‖f ω‖) := by + simp only [mean, norm_smul, Real.norm_eq_abs, abs_of_nonneg (μ.nonneg _)] + +theorem mean_sqrt_le (μ : FiniteLaw Ω) (f : Ω → ℝ) (hf : ∀ ω, 0 ≤ f ω) : + μ.mean (fun ω => Real.sqrt (f ω)) ≤ Real.sqrt (μ.mean f) := by + have h := μ.sq_mean_le (fun ω => Real.sqrt (f ω)) + simp only [Real.sq_sqrt (hf _)] at h + have hs := Real.sq_sqrt (μ.mean_nonneg hf) + nlinarith [Real.sqrt_nonneg (μ.mean f)] + + +def product {Ω' : Type*} [Fintype Ω'] (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') : + FiniteLaw (Ω × Ω') where + weight ω := μ.weight ω.1 * ν.weight ω.2 + nonneg ω := mul_nonneg (μ.nonneg _) (ν.nonneg _) + total := by simp [Fintype.sum_prod_type, ← Finset.mul_sum, μ.total, ν.total] + +theorem product_mean {Ω' : Type*} [Fintype Ω'] (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') + (f : Ω × Ω' → ℝ) : + (μ.product ν).mean f = μ.mean (fun ω => ν.mean (fun ω' => f (ω, ω'))) := by + simp only [mean, product, Fintype.sum_prod_type, Finset.mul_sum, mul_assoc] + +theorem product_mul {Ω' : Type*} [Fintype Ω'] (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') + (f : Ω → ℝ) (g : Ω' → ℝ) : + (μ.product ν).mean (fun ω => f ω.1 * g ω.2) = μ.mean f * ν.mean g := by + rw [product_mean] + simp only [mean_mul] + simp only [mean, Finset.sum_mul] + apply Finset.sum_congr rfl + intro ω hω + ring + + +def pooled {Ω' : Type*} [Fintype Ω'] (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') : + FiniteLaw (Ω ⊕ Ω') where + weight := Sum.elim (fun ω => μ.weight ω / 2) (fun ω => ν.weight ω / 2) + nonneg := fun ω => by cases ω <;> apply div_nonneg <;> first | exact μ.nonneg _ | exact ν.nonneg _ | norm_num + total := by norm_num [Fintype.sum_sum_type, ← Finset.sum_div, μ.total, ν.total] + +theorem pooled_expect {Ω' E : Type*} [Fintype Ω'] [AddCommMonoid E] [Module ℝ E] + (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') (f : Ω → E) (g : Ω' → E) : + (μ.pooled ν).expect (Sum.elim f g) = (1/2 : ℝ) • μ.expect f + (1/2 : ℝ) • ν.expect g := by + simp only [expect, pooled, Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr, + Finset.smul_sum, smul_smul] + congr 1 <;> apply Finset.sum_congr rfl <;> intro ω hω <;> congr 1 <;> ring + +end FiniteLaw + +section LawRecovery +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + + +def representation (F : SegmentFamily V) (c : FamilyCoefficients F) : Representation V := ⟨F, c⟩ + +@[simp] theorem representation_value (F : SegmentFamily V) (c : FamilyCoefficients F) : + (representation F c).value = familyValue F c := by + have _ := decidableEqV + exact rfl + +@[simp] theorem representation_energy (F : SegmentFamily V) (c : FamilyCoefficients F) : + (representation F c).energy = ‖c‖ ^ 2 := by + have _ := decidableEqV + change (∑ S : F.sets, c S ^ 2) = ‖c‖ ^ 2 + rw [EuclideanSpace.norm_sq_eq] + simp only [Real.norm_eq_abs, sq_abs] + + +def coefficientLaw (K : Finset V) (c : LocalCoefficients K) (hc : coefficientBudget K c ≤ 1) : + FiniteLaw (Option (LocalFamily K)) where + weight ω := ω.elim (1 - coefficientBudget K c) (fun F => ‖c F‖) + nonneg ω := by cases ω with + | none => exact sub_nonneg.mpr hc + | some F => exact norm_nonneg _ + total := by simp [Fintype.sum_option, coefficientBudget] + +def coefficientAtoms (K : Finset V) (c : LocalCoefficients K) : + Option (LocalFamily K) → Representation V := + fun ω => ω.elim (representation default 0) + (fun F => representation F.val (‖c F‖⁻¹ • c F)) + +theorem coefficientAtoms_energy (K : Finset V) (c : LocalCoefficients K) + (ω : Option (LocalFamily K)) : (coefficientAtoms K c ω).energy ≤ 1 := by + cases ω with + | none => simp [coefficientAtoms] + | some F => + change (representation F.val (‖c F‖⁻¹ • c F)).energy ≤ 1 + rw [representation_energy] + nlinarith [norm_normalized_le (c F), norm_nonneg (‖c F‖⁻¹ • c F)] + +theorem coefficientLaw_mean (K : Finset V) (c : LocalCoefficients K) + (hc : coefficientBudget K c ≤ 1) : + (coefficientLaw K c hc).expect (fun ω => (coefficientAtoms K c ω).value) = localValue K c := by + simp only [FiniteLaw.expect, coefficientLaw, Fintype.sum_option, coefficientAtoms, + Option.elim_none, Option.elim_some, representation_value, map_zero, smul_zero, zero_add] + change (∑ F, ‖c F‖ • familyValue F.val (‖c F‖⁻¹ • c F)) = ∑ F, familyValue F.val (c F) + apply Finset.sum_congr rfl + intro F hF + rw [← map_smul, smul_smul] + by_cases hz : ‖c F‖ = 0 + · have hc0 : c F = 0 := norm_eq_zero.mp hz + simp [hc0] + · rw [mul_inv_cancel₀ hz, one_smul] + +end LawRecovery + +namespace FiniteLaw +variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + + + +theorem absolute_mass_identity (μ : FiniteLaw Ω) (b : Ω → Γ → ℝ) : + (∑ g, μ.mean (fun ω => |b ω g|) ^ 2) - + (∑ g, μ.mean (fun ω => b ω g) ^ 2) = + (μ.product μ).mean (fun ω => ∑ g, (|b ω.1 g * b ω.2 g| - b ω.1 g * b ω.2 g)) := by + have ha : ∀ g, (μ.product μ).mean (fun ω => |b ω.1 g| * |b ω.2 g|) = + μ.mean (fun ω => |b ω g|) ^ 2 := fun g => by + rw [μ.product_mul μ (fun ω => |b ω g|) (fun ω => |b ω g|), sq] + have hb : ∀ g, (μ.product μ).mean (fun ω => b ω.1 g * b ω.2 g) = + μ.mean (fun ω => b ω g) ^ 2 := fun g => by + rw [μ.product_mul μ (fun ω => b ω g) (fun ω => b ω g), sq] + simp only [mean_sum, mean_sub, abs_mul, ha, hb, Finset.sum_sub_distrib] + +theorem absolute_mass_bound (μ : FiniteLaw Ω) (b : Ω → Γ → ℝ) (L : Ω → ℝ) + (h : ∀ ω ω', (∑ g, (|b ω g * b ω' g| - b ω g * b ω' g)) ≤ L ω + L ω') : + (∑ g, μ.mean (fun ω => |b ω g|) ^ 2) ≤ + (∑ g, μ.mean (fun ω => b ω g) ^ 2) + 2 * μ.mean L := by + have hm := (μ.product μ).mean_mono (fun ω => h ω.1 ω.2) + rw [← absolute_mass_identity] at hm + have he : (μ.product μ).mean (fun ω => L ω.1 + L ω.2) = 2 * μ.mean L := by + rw [product_mean] + simp only [mean_add, mean_const] + ring + rw [he] at hm + linarith + + + +theorem signed_mass_bound (μ : FiniteLaw Ω) (b W : Ω → Γ → ℝ) (V : Ω → ℝ) + (hzero : ∀ g, μ.mean (fun ω => b ω g + W ω g) = 0) + (hW : ∀ ω, (∑ g, W ω g ^ 2) ≤ V ω) : + (∑ g, μ.mean (fun ω => b ω g) ^ 2) ≤ μ.mean V := by + calc + (∑ g, μ.mean (fun ω => b ω g) ^ 2) = ∑ g, μ.mean (fun ω => W ω g) ^ 2 := by + apply Finset.sum_congr rfl + intro g hg + have h := hzero g + rw [mean_add] at h + have he : μ.mean (fun ω => b ω g) = - μ.mean (fun ω => W ω g) := by linarith only [h] + rw [he, neg_sq] + _ ≤ ∑ g, μ.mean (fun ω => W ω g ^ 2) := + Finset.sum_le_sum (fun g _ => μ.sq_mean_le (fun ω => W ω g)) + _ = μ.mean (fun ω => ∑ g, W ω g ^ 2) := (μ.mean_sum _).symm + _ ≤ μ.mean V := μ.mean_mono hW + + + +theorem joint_mass_bound (μ : FiniteLaw Ω) (b W : Ω → Γ → ℝ) (V L : Ω → ℝ) + (hzero : ∀ g, μ.mean (fun ω => b ω g + W ω g) = 0) + (hW : ∀ ω, (∑ g, W ω g ^ 2) ≤ V ω) + (hc : ∀ ω ω', (∑ g, (|b ω g * b ω' g| - b ω g * b ω' g)) ≤ L ω + L ω') : + (∑ g, μ.mean (fun ω => |b ω g|) ^ 2) ≤ μ.mean V + 2 * μ.mean L := + (μ.absolute_mass_bound b L hc).trans (add_le_add (μ.signed_mass_bound b W V hzero hW) le_rfl) + +end FiniteLaw + +section RepresentationGates +variable {V : Type*} [DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [treeOrderV : TreeOrder V] + [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + +@[simp] theorem segmentFunctional_unitVector (S : Finset V) (g : V) : + segmentFunctional S (unitVector g) = if g ∈ S then 1 else 0 := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + simp [segmentFunctional, coordinate_unitVector, eq_comm] + +@[simp] theorem Representation.apply_unitVector (A : Representation V) (g : V) : + A.value (unitVector g) = ∑ S : A.family.sets, if g ∈ S.val then A.coeff S else 0 := by + simp [Representation.value, segmentFunctional_unitVector, mul_ite] + +theorem Representation.apply_of_mem (A : Representation V) (S : A.family.sets) + {g : V} (hg : g ∈ S.val) : A.value (unitVector g) = A.coeff S := by + rw [A.apply_unitVector, Finset.sum_eq_single S] + · simp [hg] + · intro T hT hne + have hn : g ∉ T.val := fun ht => Finset.disjoint_left.mp + (A.family.disjoint T.property S.property (fun he => hne (Subtype.ext he))) ht hg + simp [hn] + · simp + +theorem Representation.apply_nonzero (A : Representation V) {g : V} + (hg : A.value (unitVector g) ≠ 0) : ∃ S : A.family.sets, g ∈ S.val := by + rw [A.apply_unitVector] at hg + by_contra h + apply hg + apply Finset.sum_eq_zero + intro S hS + have hn : g ∉ S.val := fun hS => h ⟨S, hS⟩ + simp [hn] + + + +theorem Representation.gate_energy_le (A : Representation V) {H : Finset V} + (G : Finset V) (hG : ∀ g ∈ G, Gate H g) : + (∑ g : G, A.value (unitVector g.val) ^ 2) ≤ A.energy := by + classical + let active : G → Prop := fun g => A.value (unitVector g.val) ≠ 0 + let Γ := {g : G // active g} + have hS : ∀ g : Γ, ∃ S : A.family.sets, g.val.val ∈ S.val := + fun g => A.apply_nonzero g.property + let select : Γ → A.family.sets := fun g => Classical.choose (hS g) + have hmem : ∀ g : Γ, g.val.val ∈ (select g).val := fun g => Classical.choose_spec (hS g) + have hinj : Function.Injective select := by + intro g g' he + apply Subtype.ext + apply Subtype.ext + have hm' := hmem g' + rw [← he] at hm' + exact A.family.gate_unique (select g) (hG _ g.val.property) (hG _ g'.val.property) + (hmem g) hm' + have hsum : (∑ g : G, A.value (unitVector g.val) ^ 2) = + ∑ g : Γ, A.coeff (select g) ^ 2 := by + have he : (∑ g : G, A.value (unitVector g.val) ^ 2) = + ∑ g : G, if active g then A.value (unitVector g.val) ^ 2 else 0 := by + apply Finset.sum_congr rfl + intro g hg + by_cases hne : active g + · simp [hne] + · have hz : A.value (unitVector g.val) = 0 := not_ne_iff.mp hne + simp [hne, hz] + rw [he, ← Finset.sum_filter, + Finset.sum_subtype (p := active) _ (fun g => by simp)] + apply Finset.sum_congr rfl + intro g hg + rw [A.apply_of_mem (select g) (hmem g)] + rw [hsum] + calc + (∑ g : Γ, A.coeff (select g) ^ 2) = + ∑ S ∈ Finset.univ.image select, A.coeff S ^ 2 := (Finset.sum_image (s := Finset.univ) (g := select) + (f := fun S => A.coeff S ^ 2) hinj.injOn).symm + _ ≤ ∑ S, A.coeff S ^ 2 := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun i _ _ => sq_nonneg _) + +end RepresentationGates + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Main.lean b/lean/OAI/Analysis/SegmentLenses/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..6db5916a4f7b42f26b8066b3bfc99fa8837baef9 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Main.lean @@ -0,0 +1,20 @@ +import OAI.Analysis.SegmentLenses.Completed + +namespace OAI + +namespace SegmentLenses + +theorem midpoint_lens_main : + (∀ (H : Finset ForestVertex) (_ : Ancestral ForestAncestor H) + (x y : X) (_ : x = head H x) (R : ℝ) (_ : 0 ≤ R) + (_ : ‖x + y‖ ≤ R) (_ : ‖x - y‖ ≤ R), + ‖tail H y‖ ≤ 2 * Real.sqrt (R ^ 2 - ‖x‖ ^ 2)) ∧ + (∀ (H : Finset InfiniteVertex) (_ : Ancestral List.IsPrefix H) + (x y : BInfinite) (_ : x.val = head H x.val) (R : ℝ) (_ : 0 ≤ R) + (_ : ‖x + y‖ ≤ R) (_ : ‖x - y‖ ≤ R), + ‖tail H y.val‖ ≤ 2 * Real.sqrt (R ^ 2 - ‖x‖ ^ 2)) := + ⟨forest_main_tail, infinite_main_tail⟩ + +end SegmentLenses + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Obstructions.lean b/lean/OAI/Analysis/SegmentLenses/Obstructions.lean new file mode 100644 index 0000000000000000000000000000000000000000..36cdfaa8713165bc1b7b89b29d6efdc656522cbf --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Obstructions.lean @@ -0,0 +1,627 @@ +import OAI.Analysis.SegmentLenses.Projections + +namespace OAI + +/-! +# Equivalent-norm obstructions from weakly null paths +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + +section OneSidedModulus +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + + +def oneSidedOn (x : SphereOne E) (t : ℝ) (F : CofiniteSubspace E) : ℝ := + ⨅ y : CofiniteSphere E F, ‖x.val + t • y.val‖ - 1 + +def oneSidedAt (x : SphereOne E) (t : ℝ) : ℝ := + ⨆ F : CofiniteSubspace E, oneSidedOn x t F + +def oneSidedModulus (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] (t : ℝ) : ℝ := + ⨅ x : SphereOne E, oneSidedAt x t + +def AUC (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] : Prop := + ∀ t : ℝ, 0 < t → 0 < oneSidedModulus E t + +theorem oneSidedOn_bddBelow (x : SphereOne E) (t : ℝ) (F : CofiniteSubspace E) : + BddBelow (Set.range (fun y : CofiniteSphere E F => ‖x.val + t • y.val‖ - 1)) := by + refine ⟨-1, ?_⟩ + rintro _ ⟨y, rfl⟩ + linarith [norm_nonneg (x.val + t • y.val)] + +theorem oneSidedAt_bdd (hE : ¬ FiniteDimensional ℝ E) (x : SphereOne E) + {t : ℝ} (ht : 0 ≤ t) : + BddAbove (Set.range (fun F : CofiniteSubspace E => oneSidedOn x t F)) := by + refine ⟨t, ?_⟩ + rintro _ ⟨F, rfl⟩ + let y : CofiniteSphere E F := Classical.choice (F.sphere_nonempty hE) + have hn := norm_add_le x.val (t • y.val) + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht, y.property.2, mul_one, x.property] at hn + exact (ciInf_le (oneSidedOn_bddBelow x t F) y).trans (by linarith) + +theorem oneSidedAt_nonneg (hE : ¬ FiniteDimensional ℝ E) (x : SphereOne E) + {t : ℝ} (ht : 0 ≤ t) : 0 ≤ oneSidedAt x t := by + obtain ⟨f, hfn, hfx⟩ := exists_dual_vector ℝ x.val (by rw [x.property]; norm_num) + let F := CofiniteSubspace.ofMap f + have := F.sphere_nonempty hE + have hF : 0 ≤ oneSidedOn x t F := by + apply le_ciInf + intro y + have hy : f y.val = 0 := y.property.1 + have he : f (x.val + t • y.val) = 1 := by + rw [map_add, map_smul, hy, smul_zero, add_zero, hfx, x.property]; rfl + have hn := f.le_opNorm (x.val + t • y.val) + rw [he, norm_one, hfn, one_mul] at hn + linarith + exact hF.trans (le_ciSup (oneSidedAt_bdd hE x ht) F) + +theorem oneSidedModulus_nonneg (hE : ¬ FiniteDimensional ℝ E) + {t : ℝ} (ht : 0 ≤ t) : 0 ≤ oneSidedModulus E t := by + have := sphereOne_nonempty hE + exact le_ciInf (fun x => oneSidedAt_nonneg hE x ht) + +theorem cofinite_gain (hE : ¬ FiniteDimensional ℝ E) {t d : ℝ} (ht : 0 ≤ t) + (hd : d < oneSidedModulus E t) (x : SphereOne E) : + ∃ F : CofiniteSubspace E, ∀ y : CofiniteSphere E F, + 1 + d < ‖x.val + t • y.val‖ := by + have hb : BddBelow (Set.range (fun x : SphereOne E => oneSidedAt x t)) := by + refine ⟨0, ?_⟩; rintro _ ⟨z, rfl⟩; exact oneSidedAt_nonneg hE z ht + have hx : d < oneSidedAt x t := hd.trans_le (ciInf_le hb x) + obtain ⟨F, hF⟩ := exists_lt_of_lt_ciSup hx + refine ⟨F, fun y => ?_⟩ + have hon := ciInf_le (oneSidedOn_bddBelow x t F) y + change oneSidedOn x t F ≤ _ at hon + linarith +end OneSidedModulus + +section WeakNullTransfer +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + + +def WeaklyNull (u : ℕ → E) : Prop := + ∀ L : StrongDual ℝ E, Filter.Tendsto (fun n => L (u n)) Filter.atTop (nhds 0) + +theorem WeaklyNull.map {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] + {u : ℕ → E} (hu : WeaklyNull u) (f : E →L[ℝ] D) : WeaklyNull (fun n => f (u n)) := by + intro L + exact hu (L.comp f) + +theorem WeaklyNull.finiteDimensional {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] + [FiniteDimensional ℝ D] {u : ℕ → D} (hu : WeaklyNull u) : + Filter.Tendsto u Filter.atTop (nhds 0) := by + let e := (Module.finBasis ℝ D).equivFunL + have hp : Filter.Tendsto (fun n => e (u n)) Filter.atTop (nhds 0) := by + apply tendsto_pi_nhds.mpr + intro i + exact hu ((ContinuousLinearMap.proj i).comp e.toContinuousLinearMap) + have h := e.symm.continuous.continuousAt.tendsto.comp hp + simpa only [Function.comp_def, e.symm_apply_apply, map_zero] using h + +theorem WeaklyNull.cofinite_approx {u : ℕ → E} (hu : WeaklyNull u) + (F : CofiniteSubspace E) {ε : ℝ} (hε : 0 < ε) : + ∃ n : ℕ, ∃ q ∈ F.space, ‖u n - q‖ < ε := by + let : IsClosed (F.space : Set E) := F.closed + have hq := (hu.map F.space.mkQL).finiteDimensional + have hnorm : Filter.Tendsto (fun n => ‖F.space.mkQL (u n)‖) Filter.atTop (nhds 0) := by + simpa using hq.norm + have hev := (tendsto_order.1 hnorm).2 (ε / 2) (by linarith) + obtain ⟨n, hn⟩ := hev.exists + obtain ⟨r, hr, hrn⟩ := Submodule.Quotient.norm_mk_lt (F.space.mkQL (u n)) (half_pos hε) + refine ⟨n, u n - r, ?_, ?_⟩ + · have he : F.space.mkQ (u n - r) = 0 := by + rw [map_sub]; change F.space.mkQL (u n) - Submodule.Quotient.mk r = 0 + rw [hr, sub_self] + exact (Submodule.Quotient.mk_eq_zero F.space).mp he + · have he : u n - (u n - r) = r := by abel + rw [he] + linarith + +theorem WeaklyNull.smul_bounded {u : ℕ → E} (hu : WeaklyNull u) (c : ℕ → ℝ) + {C : ℝ} (hc : ∀ n, |c n| ≤ C) : WeaklyNull (fun n => c n • u n) := by + intro L + have ht : Filter.Tendsto (fun n => C * ‖L (u n)‖) Filter.atTop (nhds 0) := by + simpa using tendsto_const_nhds.mul (hu L).norm + apply tendsto_zero_iff_norm_tendsto_zero.mpr + apply squeeze_zero (fun n => norm_nonneg _) _ ht + intro n + rw [map_smul, norm_smul, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hc n) (norm_nonneg _) + + +theorem unit_approx_normalize (u q : E) (hu : ‖u‖ = 1) (hq : q ≠ 0) : + ‖u - ‖q‖⁻¹ • q‖ ≤ 2 * ‖u - q‖ := by + have hqn : ‖q‖ ≠ 0 := norm_ne_zero_iff.mpr hq + have he : ‖q - ‖q‖⁻¹ • q‖ = |‖q‖ - 1| := by + rw [show q - ‖q‖⁻¹ • q = (1 - ‖q‖⁻¹) • q by module, + norm_smul, Real.norm_eq_abs] + calc + |1 - ‖q‖⁻¹| * ‖q‖ = |1 - ‖q‖⁻¹| * |‖q‖| := by rw [abs_of_nonneg (norm_nonneg q)] + _ = |(1 - ‖q‖⁻¹) * ‖q‖| := (abs_mul _ _).symm + _ = |‖q‖ - 1| := by congr 1; field_simp + have hd : |‖q‖ - 1| ≤ ‖u - q‖ := by + rw [← hu, norm_sub_rev u q] + exact abs_norm_sub_norm_le q u + have h := norm_add_le (u - q) (q - ‖q‖⁻¹ • q) + rw [sub_add_sub_cancel] at h + rw [he] at h + linarith + +theorem WeaklyNull.cofinite_unit_approx {u : ℕ → E} (hu : WeaklyNull u) + (hn : ∀ n, ‖u n‖ = 1) (F : CofiniteSubspace E) {ε : ℝ} (hε : 0 < ε) : + ∃ n : ℕ, ∃ w : CofiniteSphere E F, ‖u n - w.val‖ < ε := by + obtain ⟨n, q, hqF, he⟩ := hu.cofinite_approx F (lt_min (half_pos hε) (by norm_num : (0:ℝ)<1)) + have hq0 : q ≠ 0 := by + intro hz; rw [hz, sub_zero, hn] at he + exact (lt_of_lt_of_le he (min_le_right _ _)).false + refine ⟨n, ⟨‖q‖⁻¹ • q, F.space.smul_mem _ hqF, ?_⟩, ?_⟩ + · simp only [norm_smul, norm_inv, norm_norm, inv_mul_cancel₀ (norm_ne_zero_iff.mpr hq0)] + · exact (unit_approx_normalize (u n) q (hn n) hq0).trans_lt (by + have := lt_of_lt_of_le he (min_le_left _ _); linarith) +end WeakNullTransfer + +section RayAndPath +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + + +theorem ray_budget (x v : E) (hx : ‖x‖ = 1) {r s : ℝ} (hr : 0 ≤ r) (hrs : r ≤ s) : + s * (‖x + r • v‖ - 1) ≤ r * (‖x + s • v‖ - 1) := by + have hs : 0 ≤ s := hr.trans hrs + have he : s • (x + r • v) = r • (x + s • v) + (s - r) • x := by module + have hn := norm_add_le (r • (x + s • v)) ((s - r) • x) + rw [← he, norm_smul, norm_smul, norm_smul, hx, mul_one, + Real.norm_eq_abs, Real.norm_eq_abs, Real.norm_eq_abs, + abs_of_nonneg hs, abs_of_nonneg hr, abs_of_nonneg (sub_nonneg.mpr hrs)] at hn + nlinarith + +theorem ray_strict_gain (x v : E) (hx : ‖x‖ = 1) {r s d : ℝ} + (hr : 0 < r) (hrs : r ≤ s) (hd : 0 ≤ d) (hg : 1 + d < ‖x + r • v‖) : + 1 + d < ‖x + s • v‖ := by + have hb := ray_budget x v hx hr.le hrs + have hmul := mul_lt_mul_of_pos_left hg (hr.trans_le hrs) + nlinarith [mul_nonneg (sub_nonneg.mpr hrs) hd] + + + +theorem cofinite_child_growth (hE : ¬ FiniteDimensional ℝ E) + {a b r d : ℝ} (ha : 0 < a) (hab : a ≤ b) (hr : 0 < r) (hrab : r ≤ a / b) + (hd : 0 < d) (hmod : d < oneSidedModulus E r) + (z : E) (hza : a ≤ ‖z‖) (hzb : ‖z‖ ≤ b) + (e : ℕ → E) (he : WeaklyNull e) (hea : ∀ n, a ≤ ‖e n‖) : + ∃ n, (1 + d / 2) * ‖z‖ < ‖z + e n‖ := by + have hb : 0 < b := ha.trans_le hab + have hz : 0 < ‖z‖ := ha.trans_le hza + have hen : ∀ n, 0 < ‖e n‖ := fun n => ha.trans_le (hea n) + let x : SphereOne E := ⟨‖z‖⁻¹ • z, by + simp only [norm_smul, norm_inv, norm_norm, inv_mul_cancel₀ hz.ne']⟩ + let u : ℕ → E := fun n => ‖e n‖⁻¹ • e n + have hu : WeaklyNull u := he.smul_bounded (fun n => ‖e n‖⁻¹) (C := a⁻¹) (by + intro n + rw [abs_of_nonneg (inv_nonneg.mpr (norm_nonneg _))] + exact inv_anti₀ ha (hea n)) + have hun : ∀ n, ‖u n‖ = 1 := by + intro n + simp only [u, norm_smul, norm_inv, norm_norm, inv_mul_cancel₀ (hen n).ne'] + obtain ⟨F, hF⟩ := cofinite_gain hE hr.le hmod x + obtain ⟨n, w, hw⟩ := hu.cofinite_unit_approx hun F (div_pos hd (by positivity : 0 < 2*r)) + have hwgain := hF w + have hn := norm_sub_norm_le (x.val + r • w.val) (x.val + r • u n) + rw [add_sub_add_left_eq_sub, ← smul_sub, norm_smul, + Real.norm_eq_abs, abs_of_pos hr, norm_sub_rev w.val (u n)] at hn + have herr : r * ‖u n - w.val‖ < d / 2 := by + have := (lt_div_iff₀ (by positivity : 0 < 2*r)).mp hw + nlinarith + have hfixed : 1 + d / 2 < ‖x.val + r • u n‖ := by linarith + let s := ‖e n‖ / ‖z‖ + have hrs : r ≤ s := by + apply (le_div_iff₀ hz).mpr + have hrb := (le_div_iff₀ hb).mp hrab + exact (mul_le_mul_of_nonneg_left hzb hr.le).trans (hrb.trans (hea n)) + have hactual := ray_strict_gain x.val (u n) x.property hr hrs (by positivity) hfixed + have hid : ‖z‖ • (x.val + s • u n) = z + e n := by + dsimp only [x, s, u] + simp only [smul_add, smul_smul] + rw [mul_inv_cancel₀ hz.ne', one_smul] + congr 1 + rw [show ‖z‖ * (‖e n‖ / ‖z‖ * ‖e n‖⁻¹) = 1 by field_simp [hz.ne', (hen n).ne'], one_smul] + refine ⟨n, ?_⟩ + have h := mul_lt_mul_of_pos_left hactual hz + rw [mul_comm (1 + d/2), ← hid, norm_smul, Real.norm_eq_abs, abs_of_pos hz] + exact h + + + + +theorem bounded_finite_paths_modulus_zero (hE : ¬ FiniteDimensional ℝ E) + {a b r : ℝ} (ha : 0 < a) (hab : a ≤ b) (hr : 0 < r) (hrab : r ≤ a / b) + (paths : ∀ h : ℕ, 1 ≤ h → ∃ z : List ℕ → E, + (∀ v, v.length ≤ h → a ≤ ‖z v‖ ∧ ‖z v‖ ≤ b) ∧ + (∀ v, v.length < h → WeaklyNull (fun n => z (v ++ [n]) - z v)) ∧ + (∀ v, v.length < h → ∀ n, a ≤ ‖z (v ++ [n]) - z v‖)) : + oneSidedModulus E r = 0 := by + apply le_antisymm _ (oneSidedModulus_nonneg hE hr.le) + by_contra hnot + have hm : 0 < oneSidedModulus E r := lt_of_not_ge hnot + let d := oneSidedModulus E r / 2 + have hd : 0 < d := half_pos hm + have hdmod : d < oneSidedModulus E r := half_lt_self hm + let c := a * (d / 2) + have hc : 0 < c := mul_pos ha (half_pos hd) + obtain ⟨h, hh⟩ := exists_nat_gt (max 1 (b / c)) + have hh1 : 1 ≤ h := by + have ht : (1:ℝ) < h := (le_max_left _ _).trans_lt hh + exact_mod_cast ht.le + have hhc : b < (h : ℝ) * c := (div_lt_iff₀ hc).mp ((le_max_right _ _).trans_lt hh) + obtain ⟨z, hz, hw, he⟩ := paths h hh1 + have step : ∀ k : ℕ, k ≤ h → ∃ v : List ℕ, + v.length = k ∧ a + (k : ℝ) * c ≤ ‖z v‖ := by + intro k + induction k with + | zero => + intro hk + exact ⟨[], rfl, by simpa using (hz [] (by simp)).1⟩ + | succ k ih => + intro hk + obtain ⟨v, hv, hvn⟩ := ih (by omega) + have hvl : v.length < h := by omega + obtain ⟨n, hn⟩ := cofinite_child_growth hE ha hab hr hrab hd hdmod + (z v) (hz v hvl.le).1 (hz v hvl.le).2 _ (hw v hvl) (he v hvl) + rw [add_sub_cancel] at hn + refine ⟨v ++ [n], by simp [hv], ?_⟩ + have hza := (hz v hvl.le).1 + have hinc : c ≤ (d / 2) * ‖z v‖ := by + dsimp only [c] + nlinarith + push_cast + nlinarith + obtain ⟨v, hv, hvn⟩ := step h le_rfl + have hvb := (hz v hv.le).2 + linarith +end RayAndPath + + +section EuclideanWeakNull +variable {E I : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +theorem euclidean_family_weakly_null (c : I → E) + (hc : ∀ (s : Finset I) (a : I → ℝ), + ‖∑ i ∈ s, a i • c i‖ ≤ Real.sqrt (∑ i ∈ s, a i ^ 2)) + (v : ℕ → I) (hv : Function.Injective v) : WeaklyNull (fun n => c (v n)) := by + intro L + have hbound : ∀ s : Finset I, ∑ i ∈ s, L (c i) ^ 2 ≤ ‖L‖ ^ 2 := by + intro s + let q := ∑ i ∈ s, L (c i) • c i + let S := ∑ i ∈ s, L (c i) ^ 2 + have hS : 0 ≤ S := Finset.sum_nonneg (fun _ _ => sq_nonneg _) + have hp : L q = S := by simp only [q, S, map_sum, map_smul, smul_eq_mul, pow_two] + have hq : ‖q‖ ≤ Real.sqrt S := hc s _ + have h := L.le_opNorm q + rw [hp, Real.norm_eq_abs, abs_of_nonneg hS] at h + have h' := h.trans (mul_le_mul_of_nonneg_left hq (norm_nonneg _)) + have hs := Real.sq_sqrt hS + nlinarith [Real.sqrt_nonneg S, norm_nonneg L] + have hs : Summable (fun i => L (c i) ^ 2) := summable_of_sum_le (fun _ => sq_nonneg _) hbound + have ht := Real.continuous_sqrt.continuousAt.tendsto.comp (hs.comp_injective hv).tendsto_atTop_zero + have hn : Filter.Tendsto (fun n => ‖L (c (v n))‖) Filter.atTop (nhds 0) := by + simpa only [Function.comp_def, Real.sqrt_sq_eq_abs, Real.sqrt_zero, Real.norm_eq_abs] using ht + exact tendsto_zero_iff_norm_tendsto_zero.mpr hn +end EuclideanWeakNull + +section EquivalentPathObstruction +variable (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + + + +def UnitFinitePaths : Prop := ∀ h : ℕ, 1 ≤ h → ∃ z : List ℕ → E, + (∀ v, v.length ≤ h → ‖z v‖ = 1) ∧ + (∀ v, v.length < h → WeaklyNull (fun n => z (v ++ [n]) - z v)) ∧ + (∀ v, v.length < h → ∀ n, ‖z (v ++ [n]) - z v‖ = 1) + +variable {E} {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] + + + +theorem equivalent_paths_modulus_zero (hE : ¬ FiniteDimensional ℝ E) + (hpaths : UnitFinitePaths E) (e : E ≃L[ℝ] D) + {a b r : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : E, a * ‖x‖ ≤ ‖e x‖) (hupper : ∀ x : E, ‖e x‖ ≤ b * ‖x‖) + (hr : 0 < r) (hrab : r ≤ a / b) : oneSidedModulus D r = 0 := by + have hD : ¬ FiniteDimensional ℝ D := by + intro hfin + let := hfin + exact hE (FiniteDimensional.of_injective e.toLinearMap e.injective) + apply bounded_finite_paths_modulus_zero hD ha hab hr hrab + intro h hh + obtain ⟨z, hz, hw, hn⟩ := hpaths h hh + refine ⟨fun v => e (z v), ?_, ?_, ?_⟩ + · intro v hv + have hl := hlower (z v) + have hu := hupper (z v) + rw [hz v hv, mul_one] at hl hu + exact ⟨hl, hu⟩ + · intro v hv + simpa only [map_sub, ContinuousLinearEquiv.coe_coe] using (hw v hv).map e.toContinuousLinearMap + · intro v hv n + simpa only [map_sub, hn v hv n, mul_one] using hlower (z (v ++ [n]) - z v) + +theorem equivalent_paths_not_auc (hE : ¬ FiniteDimensional ℝ E) + (hpaths : UnitFinitePaths E) (e : E ≃L[ℝ] D) : ¬ AUC D := by + let C := ‖e.symm.toContinuousLinearMap‖ + 1 + let a := C⁻¹ + let b := ‖e.toContinuousLinearMap‖ + 1 + have hC : 0 < C := by dsimp [C]; positivity + have ha : 0 < a := inv_pos.mpr hC + have hb : 0 < b := by dsimp [b]; positivity + have ha1 : a ≤ 1 := by + apply (inv_le_one₀ hC).mpr + dsimp [C]; linarith [norm_nonneg e.symm.toContinuousLinearMap] + have hb1 : 1 ≤ b := by dsimp [b]; linarith [norm_nonneg e.toContinuousLinearMap] + have hab : a ≤ b := ha1.trans hb1 + have hl : ∀ x : E, a * ‖x‖ ≤ ‖e x‖ := by + intro x + have h := e.symm.toContinuousLinearMap.le_opNorm (e x) + simp only [ContinuousLinearEquiv.coe_coe, e.symm_apply_apply] at h + have hh : ‖x‖ ≤ C * ‖e x‖ := by + dsimp [C] + nlinarith [norm_nonneg (e x)] + dsimp only [a] + exact (inv_mul_le_iff₀ hC).mpr hh + have hu : ∀ x : E, ‖e x‖ ≤ b * ‖x‖ := by + intro x + have h := e.toContinuousLinearMap.le_opNorm x + simp only [ContinuousLinearEquiv.coe_coe] at h + dsimp only [b] + nlinarith [norm_nonneg x] + have hz := equivalent_paths_modulus_zero hE hpaths e ha hab hl hu (div_pos ha hb) le_rfl + intro hauc + have hp := hauc (a/b) (div_pos ha hb) + rw [hz] at hp + exact hp.false +end EquivalentPathObstruction + +section RootPathCertificates +variable {V : Type*} [DecidableEq V] [SegmentSystem V] + + +theorem norm_segmentFunctional (S : Finset V) (hS : SegmentSystem.isSegment S) + (hne : S.Nonempty) : ‖segmentFunctional S‖ = 1 := by + apply le_antisymm + · apply dual_norm_le _ (by norm_num) + intro u + rw [segmentFunctional_apply, one_mul] + have hb := indexed_test_bound u.coeff (fun _ : Unit => S) + (fun _ => Or.inr hS) (by intro i j hij; exact (hij (Subsingleton.elim _ _)).elim) + simp only [Finset.univ_unique, Finset.sum_singleton] at hb + change (∑ v ∈ S, u.coeff v) ^ 2 ≤ ‖u‖ ^ 2 at hb + nlinarith [norm_nonneg u, sq_abs (∑ v ∈ S, u.coeff v)] + · obtain ⟨v, hv⟩ := hne + have he : segmentFunctional S (unitVector v) = 1 := by + simp [segmentFunctional, coordinate_unitVector, hv] + have hn := (segmentFunctional S).le_opNorm (unitVector v) + simpa [he] using hn + +def predualSegment (S : Finset V) : CoordinatePredual V := + ⟨segmentFunctional S, Submodule.sum_mem _ (fun v _ => coordinate_mem v)⟩ + +@[simp] theorem norm_predualSegment (S : Finset V) (hS : SegmentSystem.isSegment S) + (hne : S.Nonempty) : ‖predualSegment S‖ = 1 := norm_segmentFunctional S hS hne + +theorem fullDual_distinct_coordinates_weakly_null (v : ℕ → V) (hv : Function.Injective v) : + WeaklyNull (fun n => coordinate (v n)) := + euclidean_family_weakly_null coordinate norm_coordinate_sum_le v hv + +end RootPathCertificates + + +theorem prefix_append_single_iff (w v : List ℕ) (n : ℕ) : + w.IsPrefix (v ++ [n]) ↔ w.IsPrefix v ∨ w = v ++ [n] := by + constructor + · intro hw + have hv : v.IsPrefix (v ++ [n]) := ⟨[n], rfl⟩ + rcases List.prefix_or_prefix_of_prefix hw hv with h | h + · exact Or.inl h + · by_cases he : w = v ++ [n] + · exact Or.inr he + · have hl : w.length ≤ v.length := by + have hwl := hw.length_le + have hne : w.length ≠ (v ++ [n]).length := fun heq => he (hw.eq_of_length heq) + simp only [List.length_append, List.length_singleton] at hwl hne + omega + have heq : v = w := h.eq_of_length (Nat.le_antisymm h.length_le hl) + simpa only [← heq] using (Or.inl (List.prefix_refl v) : v.IsPrefix v ∨ v = v ++ [n]) + · rintro (h | rfl) + · exact h.trans ⟨[n], rfl⟩ + · exact List.prefix_refl _ + +section InfinitePaths +local instance : AddCommMonoid BInfinite := + (inferInstance : NormedAddCommGroup BInfinite).toAddCommMonoid +local instance : TopologicalSpace BInfinite := + (inferInstance : NormedAddCommGroup BInfinite).toUniformSpace.toTopologicalSpace +local instance : Module ℝ BInfinite := (inferInstance : NormedSpace ℝ BInfinite).toModule + + +def infinitePath (v : InfiniteVertex) : BInfinite := predualSegment (Finset.Iic v) + +theorem infinitePath_isSegment (v : InfiniteVertex) : + SegmentSystem.isSegment (Finset.Iic v) := by + apply (IntervalSegments.iff_interval _).mpr + refine ⟨[], v, List.nil_prefix, ?_⟩ + intro w + simp only [Finset.mem_Iic] + change w.IsPrefix v ↔ [].IsPrefix w ∧ w.IsPrefix v + simp + +@[simp] theorem norm_infinitePath (v : InfiniteVertex) : ‖infinitePath v‖ = 1 := + norm_predualSegment _ (infinitePath_isSegment v) ⟨v, Finset.mem_Iic.mpr le_rfl⟩ + +theorem infinitePath_child (v : InfiniteVertex) (n : ℕ) : + infinitePath (v ++ [n]) = infinitePath v + predualCoordinate (v ++ [n]) := by + classical + apply Subtype.ext + change segmentFunctional (Finset.Iic (v ++ [n])) = + segmentFunctional (Finset.Iic v) + coordinate (v ++ [n]) + have he : Finset.Iic (v ++ [n]) = insert (v ++ [n]) (Finset.Iic v) := by + ext w + simp only [Finset.mem_Iic, Finset.mem_insert] + exact (prefix_append_single_iff w v n).trans (or_comm ..) + have hn : v ++ [n] ∉ Finset.Iic v := by + intro h + have hl := (Finset.mem_Iic.mp h : (v ++ [n]).IsPrefix v).length_le + simp at hl + rw [he, segmentFunctional, Finset.sum_insert hn, add_comm] + rfl + +theorem infinitePath_child_sub (v : InfiniteVertex) (n : ℕ) : + infinitePath (v ++ [n]) - infinitePath v = predualCoordinate (v ++ [n]) := by + rw [infinitePath_child] + apply Subtype.ext + change (infinitePath v).val + coordinate (v ++ [n]) - (infinitePath v).val = coordinate (v ++ [n]) + abel + +theorem infinitePath_children_weakly_null (v : InfiniteVertex) : + WeaklyNull (fun n => infinitePath (v ++ [n]) - infinitePath v) := by + intro L + simpa only [infinitePath_child_sub] using distinct_coordinates_weakly_null + (V := InfiniteVertex) (fun n => v ++ [n]) (by + intro n m h + simpa only [List.append_cancel_left_eq, List.singleton_inj] using h) L + +end InfinitePaths + +section ForestPaths + +def forestRoot (h : ℕ) (hh : 1 ≤ h) : ForestVertex := ⟨(h, []), hh, by simp⟩ +def forestNode (h : ℕ) (hh : 1 ≤ h) (v : List ℕ) (hv : v.length ≤ h) : ForestVertex := + ⟨(h, v), hh, hv⟩ + +theorem forest_iic_segment (v : ForestVertex) : SegmentSystem.isSegment (Finset.Iic v) := by + apply (IntervalSegments.iff_interval _).mpr + refine ⟨forestRoot v.val.1 v.property.1, v, ⟨rfl, List.nil_prefix⟩, ?_⟩ + intro w + simp only [Finset.mem_Iic] + constructor + · intro h + exact ⟨⟨h.1.symm, List.nil_prefix⟩, h⟩ + · exact And.right + + + +def forestPath (h : ℕ) (hh : 1 ≤ h) (v : List ℕ) : X := + if hv : v.length ≤ h then segmentFunctional (Finset.Iic (forestNode h hh v hv)) else 0 + +@[simp] theorem norm_forestPath (h : ℕ) (hh : 1 ≤ h) (v : List ℕ) (hv : v.length ≤ h) : + ‖forestPath h hh v‖ = 1 := by + classical + rw [forestPath, dite_eq_left hv] + exact norm_segmentFunctional _ (forest_iic_segment _) ⟨_, Finset.mem_Iic.mpr le_rfl⟩ + +theorem forestPath_child (h : ℕ) (hh : 1 ≤ h) (v : List ℕ) (hv : v.length < h) (n : ℕ) : + forestPath h hh (v ++ [n]) = forestPath h hh v + + coordinate (forestNode h hh (v ++ [n]) (by simp; omega)) := by + classical + let a := forestNode h hh v hv.le + let b := forestNode h hh (v ++ [n]) (by simp; omega) + have he : Finset.Iic b = insert b (Finset.Iic a) := by + ext w + simp only [Finset.mem_Iic, Finset.mem_insert] + change (w.val.1 = h ∧ w.val.2.IsPrefix (v ++ [n])) ↔ + w = b ∨ (w.val.1 = h ∧ w.val.2.IsPrefix v) + rw [prefix_append_single_iff] + constructor + · rintro ⟨hc, hw | hw⟩ + · exact Or.inr ⟨hc, hw⟩ + · exact Or.inl (Subtype.ext (Prod.ext hc hw)) + · rintro (rfl | ⟨hc, hw⟩) + · exact ⟨rfl, Or.inr rfl⟩ + · exact ⟨hc, Or.inl hw⟩ + have hn : b ∉ Finset.Iic a := by + intro hx + have hl := (Finset.mem_Iic.mp hx).2.length_le + change (v ++ [n]).length ≤ v.length at hl + simp at hl + rw [forestPath, dite_eq_left (by simp; omega), forestPath, dite_eq_left hv.le] + change segmentFunctional (Finset.Iic b) = segmentFunctional (Finset.Iic a) + coordinate b + rw [he, segmentFunctional, Finset.sum_insert hn, add_comm] + rfl + +theorem forestPath_children_weakly_null (h : ℕ) (hh : 1 ≤ h) (v : List ℕ) (hv : v.length < h) : + WeaklyNull (fun n => forestPath h hh (v ++ [n]) - forestPath h hh v) := by + classical + have hw := fullDual_distinct_coordinates_weakly_null + (fun n => forestNode h hh (v ++ [n]) (by simp; omega)) (by + intro n m hn + have hlist := congrArg (fun w : ForestVertex => w.val.2) hn + simpa only [forestNode, List.append_cancel_left_eq, List.singleton_inj] using hlist) + convert hw using 1 + funext n + rw [forestPath_child h hh v hv n, add_sub_cancel_left] + +end ForestPaths + +section FinalObstructions + +theorem infinite_unit_finite_paths : UnitFinitePaths BInfinite := by + intro h hh + refine ⟨infinitePath, ?_, ?_, ?_⟩ + · intro v hv; exact norm_infinitePath v + · intro v hv; exact infinitePath_children_weakly_null v + · intro v hv n + rw [infinitePath_child_sub, norm_predualCoordinate] + +theorem forest_unit_finite_paths : UnitFinitePaths X := by + classical + intro h hh + refine ⟨forestPath h hh, ?_, ?_, ?_⟩ + · exact norm_forestPath h hh + · exact forestPath_children_weakly_null h hh + · intro v hv n + rw [forestPath_child h hh v hv n, add_sub_cancel_left, norm_coordinate] + +variable {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] + + + +theorem infinite_equivalent_modulus_zero (e : BInfinite ≃L[ℝ] D) + {a b r : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : BInfinite, a * ‖x‖ ≤ ‖e x‖) + (hupper : ∀ x : BInfinite, ‖e x‖ ≤ b * ‖x‖) + (hr : 0 < r) (hrab : r ≤ a / b) : oneSidedModulus D r = 0 := by + classical + exact equivalent_paths_modulus_zero predual_not_finite infinite_unit_finite_paths e + ha hab hlower hupper hr hrab + + + +theorem forest_equivalent_modulus_zero (e : X ≃L[ℝ] D) + {a b r : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : X, a * ‖x‖ ≤ ‖e x‖) + (hupper : ∀ x : X, ‖e x‖ ≤ b * ‖x‖) + (hr : 0 < r) (hrab : r ≤ a / b) : oneSidedModulus D r = 0 := by + classical + exact equivalent_paths_modulus_zero fullDual_not_finite forest_unit_finite_paths e + ha hab hlower hupper hr hrab + + +theorem infinite_no_equivalent_AUC (e : BInfinite ≃L[ℝ] D) : ¬ AUC D := by + classical + exact equivalent_paths_not_auc predual_not_finite infinite_unit_finite_paths e + + +theorem forest_no_equivalent_AUC (e : X ≃L[ℝ] D) : ¬ AUC D := by + classical + exact equivalent_paths_not_auc fullDual_not_finite forest_unit_finite_paths e + +end FinalObstructions + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Pairing.lean b/lean/OAI/Analysis/SegmentLenses/Pairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..647ef37389cbfd85680e7ed6e0033588415b673c --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Pairing.lean @@ -0,0 +1,352 @@ +import OAI.Analysis.SegmentLenses.FiniteLaws + +namespace OAI + +/-! +# Finite heads and the completion–dual pairing +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + +section Restrictions +variable {V : Type*} [decidableEqV : DecidableEq V] [PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] + + +theorem subinterval_isSegment {S T : Finset V} + (hS : SegmentSystem.isSegment S) (hTS : T ⊆ S) + (hc : ∀ a ∈ T, ∀ b ∈ T, ∀ v, a ≤ v → v ≤ b → v ∈ T) : + T = ∅ ∨ SegmentSystem.isSegment T := by + have _ := decidableEqV + have _ := locallyFiniteOrderV + classical + rcases T.eq_empty_or_nonempty with he | hn + · exact Or.inl he + right + obtain ⟨a, b, hab, hS⟩ := (IntervalSegments.iff_interval S).mp hS + obtain ⟨c, hcT, hcmin⟩ := Finset.exists_minimal hn + obtain ⟨d, hdT, hdmax⟩ := Finset.exists_maximal hn + have hchain : ∀ v ∈ T, ∀ w ∈ T, v ≤ w ∨ w ≤ v := by + intro v hv w hw + exact TreeOrder.lower_chain ((hS v).mp (hTS hv)).2 ((hS w).mp (hTS hw)).2 + have hmin : ∀ v ∈ T, c ≤ v := by + intro v hv + exact (hchain c hcT v hv).elim id (hcmin hv) + have hmax : ∀ v ∈ T, v ≤ d := by + intro v hv + exact (hchain v hv d hdT).elim id (hdmax hv) + apply (IntervalSegments.iff_interval T).mpr + refine ⟨c, d, hmin d hdT, ?_⟩ + intro v + exact ⟨fun hv => ⟨hmin v hv, hmax v hv⟩, + fun hv => hc c hcT d hdT v hv.1 hv.2⟩ + +theorem norm_filter_le (u : V →₀ ℝ) (P : V → Prop) [DecidablePred P] + (hP : ∀ a b v, P a → P b → a ≤ v → v ≤ b → P v) : + segmentSeminorm V (u.filter P) ≤ segmentSeminorm V u := by + classical + rw [segmentSeminorm_apply] + apply ciSup_le + intro F + have h := indexed_test_bound u (fun S : F.sets => S.val.filter P) + (fun S => subinterval_isSegment (F.segment _ S.property) (Finset.filter_subset _ _) + (by + intro a ha b hb v hav hvb + apply Finset.mem_filter.mpr + obtain ⟨l, r, hlr, hs⟩ := (IntervalSegments.iff_interval S.val).mp + (F.segment _ S.property) + exact ⟨(hs v).mpr ⟨le_trans ((hs a).mp (Finset.mem_filter.mp ha).1).1 hav, + le_trans hvb ((hs b).mp (Finset.mem_filter.mp hb).1).2⟩, + hP a b v (Finset.mem_filter.mp ha).2 (Finset.mem_filter.mp hb).2 hav hvb⟩)) + (by + intro S T hne + exact (F.disjoint S.property T.property (fun he => hne (Subtype.ext he))).mono + (Finset.filter_subset _ _) (Finset.filter_subset _ _)) + have he : F.seminorm (u.filter P) ^ 2 = + ∑ S : F.sets, (∑ v ∈ S.val.filter P, u v) ^ 2 := by + rw [F.seminorm_sq] + simp only [Finsupp.filter_apply, Finset.sum_filter] + rw [← he] at h + nlinarith [apply_nonneg F.seminorm (u.filter P), apply_nonneg (segmentSeminorm V) u] + +theorem norm_headTest_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (u : V →₀ ℝ) : + segmentSeminorm V (u.filter (· ∈ H)) ≤ segmentSeminorm V u := + norm_filter_le u _ (fun _ _ _ _ hb _ hvb => hH hb hvb) + +theorem norm_tailTest_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (u : V →₀ ℝ) : + segmentSeminorm V (u.filter (· ∉ H)) ≤ segmentSeminorm V u := + norm_filter_le u _ (fun _ _ _ ha _ hav _ hv => ha (hH hv hav)) + +end Restrictions + +section Pairing +variable {V : Type*} [SegmentSystem V] + +@[simp] theorem coordinate_apply_test (v : V) (u : Test V) : + coordinate v (u : Primal V) = u.coeff v := by + exact ContinuousLinearMap.extend_eq _ UniformSpace.Completion.denseRange_coe + (UniformSpace.Completion.isUniformInducing_coe _) u + +@[simp] theorem coordinate_unitVector [DecidableEq V] (v w : V) : + coordinate v (unitVector w) = if v = w then 1 else 0 := by + classical + rw [unitVector, coordinate_apply_test] + simp [Test.coeff, Test.ofFinsupp, Finsupp.single_apply, eq_comm] + + +theorem dual_norm_le (x : FullDual V) {M : ℝ} (hM : 0 ≤ M) + (h : ∀ u : Test V, |x (u : Primal V)| ≤ M * ‖u‖) : ‖x‖ ≤ M := by + apply x.opNorm_le_bound hM + intro u + refine UniformSpace.Completion.induction_on u (p := fun u => ‖x u‖ ≤ M * ‖u‖) + (isClosed_le (x.continuous.norm) (continuous_const.mul continuous_norm)) ?_ + intro u + simpa only [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] using h u + +theorem test_as_sum (u : Test V) : + (u : Primal V) = ∑ v ∈ u.coeff.support, u.coeff v • unitVector v := by + classical + have he : u = ∑ v ∈ u.coeff.support, u.coeff v • Test.ofFinsupp (Finsupp.single v 1) := by + change u.coeff = ∑ v ∈ u.coeff.support, u.coeff v • Finsupp.single v 1 + simpa only [Finsupp.smul_single, smul_eq_mul, mul_one, Finsupp.sum] using + (Finsupp.sum_single u.coeff).symm + calc + (u : Primal V) = ((∑ v ∈ u.coeff.support, + u.coeff v • Test.ofFinsupp (Finsupp.single v 1) : Test V) : Primal V) := + congrArg (fun v : Test V => (v : Primal V)) he + _ = ∑ v ∈ u.coeff.support, u.coeff v • unitVector v := by + change (UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V) (∑ v ∈ u.coeff.support, + u.coeff v • Test.ofFinsupp (Finsupp.single v 1)) = _ + simp only [map_sum, map_smul]; rfl + + +theorem dual_apply_test (x : FullDual V) (u : Test V) : + x (u : Primal V) = ∑ v ∈ u.coeff.support, u.coeff v * x (unitVector v) := by + rw [test_as_sum] + simp only [map_sum, map_smul, smul_eq_mul] + +@[simp] theorem head_apply_test (H : Finset V) (x : FullDual V) (u : Test V) : + head H x (u : Primal V) = ∑ v ∈ H, x (unitVector v) * u.coeff v := by + simp [head, coordinate_apply_test] + + +def segmentFunctional (S : Finset V) : FullDual V := ∑ v ∈ S, coordinate v + +@[simp] theorem segmentFunctional_apply (S : Finset V) (u : Test V) : + segmentFunctional S (u : Primal V) = ∑ v ∈ S, u.coeff v := by + simp [segmentFunctional] + + +structure Representation (V : Type*) [SegmentSystem V] where + family : SegmentFamily V + coeff : family.sets → ℝ + +def Representation.value (A : Representation V) : FullDual V := + ∑ S : A.family.sets, A.coeff S • segmentFunctional S.val + +def Representation.energy (A : Representation V) : ℝ := ∑ S, A.coeff S ^ 2 + +@[simp] theorem Representation.apply_test (A : Representation V) (u : Test V) : + A.value (u : Primal V) = ∑ S, A.coeff S * ∑ v ∈ S.val, u.coeff v := by + simp [Representation.value] + + +theorem Representation.norm_le (A : Representation V) : + ‖A.value‖ ≤ Real.sqrt A.energy := by + apply dual_norm_le _ (Real.sqrt_nonneg _) + intro u + rw [A.apply_test] + have h := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ + (fun S => |A.coeff S|) (fun S => |∑ v ∈ S.val, u.coeff v|) + simp only [sq_abs, ← A.family.seminorm_sq, Real.sqrt_sq (apply_nonneg _ _)] at h + calc + |∑ S, A.coeff S * ∑ v ∈ S.val, u.coeff v| ≤ + ∑ S, |A.coeff S| * |∑ v ∈ S.val, u.coeff v| := by + simpa only [abs_mul] using Finset.abs_sum_le_sum_abs + (fun S => A.coeff S * ∑ v ∈ S.val, u.coeff v) Finset.univ + _ ≤ Real.sqrt A.energy * A.family.seminorm u.coeff := h + _ ≤ Real.sqrt A.energy * ‖u‖ := + mul_le_mul_of_nonneg_left (le_segmentSeminorm _ _) (Real.sqrt_nonneg _) + +end Pairing + +section MorePairing +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + +theorem dual_ext_test {x y : FullDual V} + (h : ∀ u : Test V, x (u : Primal V) = y (u : Primal V)) : x = y := by + have _ := decidableEqV + ext u + exact UniformSpace.Completion.induction_on u + (isClosed_eq x.continuous y.continuous) h + +@[simp] theorem head_unitVector (H : Finset V) (x : FullDual V) (v : V) : + head H x (unitVector v) = if v ∈ H then x (unitVector v) else 0 := by + simp [head, coordinate_unitVector, eq_comm] + +@[simp] theorem head_head (H : Finset V) (x : FullDual V) : head H (head H x) = head H x := by + simp only [head, _root_.sum_apply, smul_apply, smul_eq_mul, + coordinate_unitVector] + apply Finset.sum_congr rfl + intro v hv + simp [hv, eq_comm] + + +theorem head_pairing (H : Finset V) (x : FullDual V) (u : Test V) : + head H x (u : Primal V) = + x ((Test.ofFinsupp (u.coeff.filter (· ∈ H)) : Test V) : Primal V) := by + rw [head_apply_test, dual_apply_test] + change (∑ v ∈ H, x (unitVector v) * u.coeff v) = + ∑ v ∈ (u.coeff.filter (· ∈ H)).support, + (u.coeff.filter (· ∈ H)) v * x (unitVector v) + have hsub : (u.coeff.filter (· ∈ H)).support ⊆ H := by + intro v hv + exact (Finsupp.mem_support_iff.mp hv |> fun h => by + by_contra hn + exact h (by simp [hn])) + rw [Finset.sum_subset hsub (by + intro v hv hnv + have hz := Finsupp.notMem_support_iff.mp hnv + rw [hz, zero_mul])] + apply Finset.sum_congr rfl + intro v hv + simp [hv, mul_comm] + +theorem tail_pairing (H : Finset V) (x : FullDual V) (u : Test V) : + tail H x (u : Primal V) = + x ((Test.ofFinsupp (u.coeff.filter (· ∉ H)) : Test V) : Primal V) := by + have he : u - Test.ofFinsupp (u.coeff.filter (· ∈ H)) = + Test.ofFinsupp (u.coeff.filter (· ∉ H)) := by + change u.coeff - u.coeff.filter (· ∈ H) = u.coeff.filter (· ∉ H) + ext v + by_cases hv : v ∈ H <;> simp [hv] + change x (u : Primal V) - head H x (u : Primal V) = _ + rw [head_pairing, ← map_sub, ← UniformSpace.Completion.coe_sub, he] + +end MorePairing + +section DualRestrictions +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] + +theorem norm_head_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (x : FullDual V) : + ‖head H x‖ ≤ ‖x‖ := by + apply dual_norm_le _ (norm_nonneg _) + intro u + rw [head_pairing] + have h := x.le_opNorm ((Test.ofFinsupp (u.coeff.filter (· ∈ H)) : Test V) : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at h + exact h.trans (mul_le_mul_of_nonneg_left (norm_headTest_le hH _) (norm_nonneg _)) + +theorem norm_tail_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (x : FullDual V) : + ‖tail H x‖ ≤ ‖x‖ := by + apply dual_norm_le _ (norm_nonneg _) + intro u + rw [tail_pairing] + have h := x.le_opNorm ((Test.ofFinsupp (u.coeff.filter (· ∉ H)) : Test V) : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at h + exact h.trans (mul_le_mul_of_nonneg_left (norm_tailTest_le hH _) (norm_nonneg _)) + +end DualRestrictions + +section IndexedFamilies +variable {V ι : Type*} [DecidableEq V] [SegmentSystem V] [Fintype ι] + + +def SegmentFamily.ofPieces (S : ι → Finset V) + (hS : ∀ i, S i = ∅ ∨ SegmentSystem.isSegment (S i)) + (hd : Pairwise fun i j => Disjoint (S i) (S j)) : SegmentFamily V where + sets := (Finset.univ.image S).erase ∅ + segment := by + intro T hT + obtain ⟨hne, him⟩ := Finset.mem_erase.mp hT + obtain ⟨i, -, rfl⟩ := Finset.mem_image.mp him + exact (hS i).resolve_left hne + disjoint := by + intro A hA B hB hne + obtain ⟨i, -, rfl⟩ := Finset.mem_image.mp (Finset.mem_erase.mp hA).2 + obtain ⟨j, -, rfl⟩ := Finset.mem_image.mp (Finset.mem_erase.mp hB).2 + exact hd (fun hij => hne (congrArg S hij)) + +theorem SegmentFamily.ofPieces_sq (S : ι → Finset V) + (hS : ∀ i, S i = ∅ ∨ SegmentSystem.isSegment (S i)) + (hd : Pairwise fun i j => Disjoint (S i) (S j)) (p : V →₀ ℝ) : + (ofPieces S hS hd).seminorm p ^ 2 = ∑ i, (∑ v ∈ S i, p v) ^ 2 := by + classical + rw [seminorm_sq, Finset.sum_coe_sort (ofPieces S hS hd).sets + (fun T : Finset V => (∑ v ∈ T, p v) ^ 2)] + change (∑ T ∈ (Finset.univ.image S).erase ∅, (∑ v ∈ T, p v) ^ 2) = _ + rw [Finset.sum_erase _ (by simp)] + apply Finset.sum_image_of_pairwise_eq_zero + intro i hi j hj hij heq + have hempty : S i = ∅ := by + have hh : Disjoint (S i) (S j) := hd hij + rw [← heq] at hh + exact disjoint_self.mp hh + simp [hempty] + +end IndexedFamilies + +section ClipFamilies +variable {V : Type*} [DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [treeOrderV : TreeOrder V] + [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + +theorem clip_segment {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (F : SegmentFamily V) (S : F.sets) : + S.val ∩ H = ∅ ∨ SegmentSystem.isSegment (S.val ∩ H) := by + apply subinterval_isSegment (F.segment _ S.property) Finset.inter_subset_left + intro a ha b hb v hav hvb + rw [F.repr S] at ha hb ⊢ + exact Finset.mem_inter.mpr ⟨Finset.mem_Icc.mpr + ⟨le_trans (Finset.mem_Icc.mp (Finset.mem_inter.mp ha).1).1 hav, + le_trans hvb (Finset.mem_Icc.mp (Finset.mem_inter.mp hb).1).2⟩, + hH (Finset.mem_inter.mp hb).2 hvb⟩ + +theorem clip_disjoint (H : Finset V) (F : SegmentFamily V) : + Pairwise fun S T : F.sets => Disjoint (S.val ∩ H) (T.val ∩ H) := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + intro S T hne + exact (F.disjoint S.property T.property (fun he => hne (Subtype.ext he))).mono + Finset.inter_subset_left Finset.inter_subset_left + +def SegmentFamily.clip {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (F : SegmentFamily V) : SegmentFamily V := + ofPieces (fun S : F.sets => S.val ∩ H) (clip_segment hH F) (clip_disjoint H F) + +theorem SegmentFamily.clip_subset {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (F : SegmentFamily V) : ∀ S ∈ (F.clip hH).sets, S ⊆ H := by + intro S hS + obtain ⟨T, -, rfl⟩ := Finset.mem_image.mp (Finset.mem_erase.mp hS).2 + exact Finset.inter_subset_right + +theorem SegmentFamily.clip_seminorm {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (F : SegmentFamily V) (p : V →₀ ℝ) (hp : p.support ⊆ H) : + (F.clip hH).seminorm p = F.seminorm p := by + have he : (F.clip hH).seminorm p ^ 2 = F.seminorm p ^ 2 := by + rw [clip, ofPieces_sq, F.seminorm_sq] + apply Finset.sum_congr rfl + intro S hS + congr 1 + apply Finset.sum_subset Finset.inter_subset_left + intro v hv hnv + apply Finsupp.notMem_support_iff.mp + intro hvs + exact hnv (Finset.mem_inter.mpr ⟨hv, hp hvs⟩) + nlinarith [apply_nonneg (F.clip hH).seminorm p, apply_nonneg F.seminorm p] + +end ClipFamilies + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Projections.lean b/lean/OAI/Analysis/SegmentLenses/Projections.lean new file mode 100644 index 0000000000000000000000000000000000000000..d429d9b2f305d9d86a1067c6e7f364919794a525 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Projections.lean @@ -0,0 +1,202 @@ +import OAI.Analysis.SegmentLenses.Averaged + +namespace OAI + +/-! +# Primal projections and Euclidean coordinate bounds +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + +section PrimalProjections +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + +def primalHead (H : Finset V) : Primal V →L[ℝ] Primal V := + ∑ v ∈ H, (coordinate v).smulRight (unitVector v) + +def primalTail (H : Finset V) : Primal V →L[ℝ] Primal V := + ContinuousLinearMap.id ℝ (Primal V) - primalHead H + +@[simp] theorem primalHead_apply (H : Finset V) (u : Primal V) : + primalHead H u = ∑ v ∈ H, coordinate v u • unitVector v := by + have _ := decidableEqV + simp [primalHead] + +theorem primalHead_test (H : Finset V) (u : Test V) : + primalHead H (u : Primal V) = (Test.ofFinsupp (u.coeff.filter (· ∈ H)) : Test V) := by + rw [primalHead_apply] + conv_rhs => rw [test_as_sum] + simp only [coordinate_apply_test, Test.coeff, Test.ofFinsupp] + symm + calc + (∑ v ∈ (u.coeff.filter (· ∈ H)).support, (u.coeff.filter (· ∈ H)) v • unitVector v) = + ∑ v ∈ H, (u.coeff.filter (· ∈ H)) v • unitVector v := by + apply Finset.sum_subset + · intro v hv + exact (Finset.mem_filter.mp (by simpa only [Finsupp.support_filter] using hv)).2 + · intro v hv hnv + rw [Finsupp.notMem_support_iff.mp hnv, zero_smul] + _ = ∑ v ∈ H, u.coeff v • unitVector v := by + apply Finset.sum_congr rfl + intro v hv + rw [Finsupp.filter_apply, ite_eq_left hv] + +theorem primalTail_test (H : Finset V) (u : Test V) : + primalTail H (u : Primal V) = (Test.ofFinsupp (u.coeff.filter (· ∉ H)) : Test V) := by + change (u : Primal V) - primalHead H (u : Primal V) = _ + rw [primalHead_test] + have he : u - Test.ofFinsupp (u.coeff.filter (· ∈ H)) = + Test.ofFinsupp (u.coeff.filter (· ∉ H)) := by + change u.coeff - u.coeff.filter (· ∈ H) = u.coeff.filter (· ∉ H) + ext v + by_cases hv : v ∈ H <;> simp [hv] + exact (map_sub (UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V) _ _).symm.trans + (congrArg (fun u : Test V => (u : Primal V)) he) + + +theorem head_adjoint (H : Finset V) (x : FullDual V) (u : Primal V) : + head H x u = x (primalHead H u) := by + simp only [head, primalHead_apply, _root_.sum_apply, + _root_.smul_apply, map_sum, map_smul, smul_eq_mul] + apply Finset.sum_congr rfl + intro v hv + ring + +theorem tail_adjoint (H : Finset V) (x : FullDual V) (u : Primal V) : + tail H x u = x (primalTail H u) := by + change x u - head H x u = x (u - primalHead H u) + rw [map_sub, head_adjoint] + +@[simp] theorem coordinate_primalHead (H : Finset V) (v : V) (u : Primal V) : + coordinate v (primalHead H u) = if v ∈ H then coordinate v u else 0 := by + simp [primalHead_apply, coordinate_unitVector] + +theorem primalHead_fix (H : Finset V) (u : Test V) (hu : u.coeff.support ⊆ H) : + primalHead H (u : Primal V) = u := by + rw [primalHead_test] + congr 1 + change u.coeff.filter (· ∈ H) = u.coeff + ext v + by_cases hv : v ∈ H + · simp [hv] + · have hz : u.coeff v = 0 := Finsupp.notMem_support_iff.mp (fun h => hv (hu h)) + simp [hv, hz] + +variable [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] [IntervalSegments V] + +theorem norm_primalHead_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (u : Primal V) : + ‖primalHead H u‖ ≤ ‖u‖ := by + refine UniformSpace.Completion.induction_on u + (p := fun u => ‖primalHead H u‖ ≤ ‖u‖) + (isClosed_le (primalHead H).continuous.norm continuous_norm) ?_ + intro u + rw [primalHead_test, UniformSpace.Completion.norm_coe, UniformSpace.Completion.norm_coe] + exact norm_headTest_le hH u.coeff + +theorem norm_primalTail_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) (u : Primal V) : + ‖primalTail H u‖ ≤ ‖u‖ := by + refine UniformSpace.Completion.induction_on u + (p := fun u => ‖primalTail H u‖ ≤ ‖u‖) + (isClosed_le (primalTail H).continuous.norm continuous_norm) ?_ + intro u + rw [primalTail_test, UniformSpace.Completion.norm_coe, UniformSpace.Completion.norm_coe] + exact norm_tailTest_le hH u.coeff + +end PrimalProjections + + +section CoordinateEuclidean +variable {V : Type*} [decidableEqV : DecidableEq V] [SegmentSystem V] + + +theorem singleton_square_sum_le (s : Finset V) (u : Test V) : + ∑ v ∈ s, u.coeff v ^ 2 ≤ ‖u‖ ^ 2 := by + have _ := decidableEqV + have h := indexed_test_bound u.coeff (fun v : s => ({v.val} : Finset V)) + (fun v => Or.inr (SegmentSystem.singleton v.val)) + (fun v w hvw => Finset.disjoint_singleton.mpr (fun h => hvw (Subtype.ext h))) + simp only [Finset.sum_singleton] at h + rw [Finset.sum_coe_sort s (fun v => u.coeff v ^ 2)] at h + exact h + +theorem norm_coordinate_sum_le (s : Finset V) (a : V → ℝ) : + ‖∑ v ∈ s, a v • coordinate v‖ ≤ Real.sqrt (∑ v ∈ s, a v ^ 2) := by + apply dual_norm_le _ (Real.sqrt_nonneg _) + intro u + have hcs := Real.sum_mul_le_sqrt_mul_sqrt s (fun v => |a v|) (fun v => |u.coeff v|) + have hsing := singleton_square_sum_le s u + have hs : Real.sqrt (∑ v ∈ s, u.coeff v ^ 2) ≤ ‖u‖ := + (Real.sqrt_le_iff).mpr ⟨norm_nonneg _, hsing⟩ + calc + |(∑ v ∈ s, a v • coordinate v) (u : Primal V)| = + |∑ v ∈ s, a v * u.coeff v| := by + simp only [_root_.sum_apply, _root_.smul_apply, coordinate_apply_test, smul_eq_mul] + _ ≤ ∑ v ∈ s, |a v| * |u.coeff v| := by + simpa only [abs_mul] using Finset.abs_sum_le_sum_abs (fun v => a v * u.coeff v) s + _ ≤ Real.sqrt (∑ v ∈ s, a v ^ 2) * Real.sqrt (∑ v ∈ s, u.coeff v ^ 2) := by + simpa only [sq_abs] using hcs + _ ≤ Real.sqrt (∑ v ∈ s, a v ^ 2) * ‖u‖ := + mul_le_mul_of_nonneg_left hs (Real.sqrt_nonneg _) + +theorem norm_predualCoordinate_sum_le (s : Finset V) (a : V → ℝ) : + ‖∑ v ∈ s, a v • predualCoordinate v‖ ≤ Real.sqrt (∑ v ∈ s, a v ^ 2) := by + have he : ((∑ v ∈ s, a v • predualCoordinate v : CoordinatePredual V) : FullDual V) = + ∑ v ∈ s, a v • coordinate v := by simp [predualCoordinate] + change ‖((∑ v ∈ s, a v • predualCoordinate v : CoordinatePredual V) : FullDual V)‖ ≤ _ + rw [he] + exact norm_coordinate_sum_le s a + + + +local instance predualACM : AddCommMonoid (CoordinatePredual V) := + (inferInstance : NormedAddCommGroup (CoordinatePredual V)).toAddCommMonoid +local instance predualTop : TopologicalSpace (CoordinatePredual V) := + (inferInstance : NormedAddCommGroup (CoordinatePredual V)).toUniformSpace.toTopologicalSpace +local instance predualModule : Module ℝ (CoordinatePredual V) := + (inferInstance : NormedSpace ℝ (CoordinatePredual V)).toModule + + +theorem functional_coordinate_square_sum (L : StrongDual ℝ (CoordinatePredual V)) (s : Finset V) : + ∑ v ∈ s, L (predualCoordinate v) ^ 2 ≤ ‖L‖ ^ 2 := by + let q := ∑ v ∈ s, L (predualCoordinate v) • predualCoordinate v + let S := ∑ v ∈ s, L (predualCoordinate v) ^ 2 + have hS : 0 ≤ S := Finset.sum_nonneg (fun _ _ => sq_nonneg _) + have hp : L q = S := by simp only [q, S, map_sum, map_smul, smul_eq_mul, pow_two] + have hq : ‖q‖ ≤ Real.sqrt S := norm_predualCoordinate_sum_le s _ + have h := L.le_opNorm q + rw [hp, Real.norm_eq_abs, abs_of_nonneg hS] at h + have h' := h.trans (mul_le_mul_of_nonneg_left hq (norm_nonneg _)) + have hs := Real.sq_sqrt hS + nlinarith [Real.sqrt_nonneg S, norm_nonneg L] + + +theorem functional_coordinates_summable_sq (L : StrongDual ℝ (CoordinatePredual V)) : + Summable (fun v => L (predualCoordinate v) ^ 2) := + summable_of_sum_le (fun _ => sq_nonneg _) (functional_coordinate_square_sum L) + + + +theorem distinct_coordinates_weakly_null (v : ℕ → V) (hv : Function.Injective v) + (L : StrongDual ℝ (CoordinatePredual V)) : + Filter.Tendsto (fun n => L (predualCoordinate (v n))) Filter.atTop (nhds 0) := by + have hs : Summable (fun n => L (predualCoordinate (v n)) ^ 2) := + (functional_coordinates_summable_sq L).comp_injective hv + have ht := Real.continuous_sqrt.continuousAt.tendsto.comp hs.tendsto_atTop_zero + have hn : Filter.Tendsto (fun n => ‖L (predualCoordinate (v n))‖) Filter.atTop (nhds 0) := by + simpa only [Function.comp_def, Real.sqrt_sq_eq_abs, Real.sqrt_zero, Real.norm_eq_abs] using ht + exact tendsto_zero_iff_norm_tendsto_zero.mpr hn + +end CoordinateEuclidean + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Radial.lean b/lean/OAI/Analysis/SegmentLenses/Radial.lean new file mode 100644 index 0000000000000000000000000000000000000000..c71514a2a7eb08982db45675bba51bebcbbe2d7a --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Radial.lean @@ -0,0 +1,346 @@ +import OAI.Analysis.SegmentLenses.Coordinates + +namespace OAI + +/-! +# Radial midpoint estimates and endpoint asymmetry +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +namespace FiniteLaw +variable {Ω Ω' : Type*} [Fintype Ω] [Fintype Ω'] + +def blend (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') (a b : ℝ) + (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) : FiniteLaw (Ω ⊕ Ω') where + weight := Sum.elim (fun ω => a * μ.weight ω) (fun ω => b * ν.weight ω) + nonneg ω := by cases ω <;> exact mul_nonneg (by assumption) (by apply FiniteLaw.nonneg) + total := by simp only [Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr, + ← Finset.mul_sum, μ.total, ν.total, mul_one, hab] + +theorem blend_expect (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') (a b : ℝ) + (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) + {E : Type*} [AddCommMonoid E] [Module ℝ E] (f : Ω → E) (g : Ω' → E) : + (μ.blend ν a b ha hb hab).expect (Sum.elim f g) = a • μ.expect f + b • ν.expect g := by + simp only [expect, blend, Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr, + Finset.smul_sum, mul_smul] + +end FiniteLaw + + +theorem norm_center_average {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (x y : E) : ‖x‖ ≤ (‖x + y‖ + ‖x - y‖) / 2 := by + have he : (2 : ℝ) • x = (x + y) + (x - y) := by module + have h := norm_add_le (x + y) (x - y) + rw [← he, norm_smul, Real.norm_eq_abs, abs_of_pos (by norm_num : (0 : ℝ) < 2)] at h + linarith + +theorem norm_displacement_average {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (x y : E) : ‖y‖ ≤ (‖x + y‖ + ‖x - y‖) / 2 := by + simpa only [add_comm y x, norm_sub_rev y x] using norm_center_average y x + +section UnequalRadii +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + + + +theorem finite_unequal_radius_tail {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (hK : Ancestral (· ≤ ·) K) (hHK : H ⊆ K) + (x y : FullDual V) (hx : head H x = x) (hy : head K y = y) + (Rp Rm : ℝ) (hRp : 0 < Rp) (hRm : 0 < Rm) + (hp : ‖x + y‖ ≤ Rp) (hm : ‖x - y‖ ≤ Rm) : + ‖tail H y‖ ≤ 2 * Real.sqrt (((Rp + Rm) / 2) ^ 2 - ‖x‖ ^ 2) := by + classical + let L := (Rp + Rm) / 2 + have hL : 0 < L := by dsimp [L]; positivity + by_cases hx0 : x = 0 + · have hn := (norm_displacement_average x y).trans (by dsimp [L]; linarith : + (‖x + y‖ + ‖x - y‖) / 2 ≤ L) + rw [hx0, norm_zero, zero_pow (by decide : 2 ≠ 0), sub_zero, Real.sqrt_sq hL.le] + exact (norm_tail_le hH y).trans (hn.trans (by linarith)) + have hxK := head_eq_of_subset hHK x hx + have hpK : head K (x + y) = x + y := by + change headLinear K (x + y) = _ + simp only [map_add, headLinear_apply, hxK, hy] + have hmK : head K (x - y) = x - y := by + change headLinear K (x - y) = _ + simp only [map_sub, headLinear_apply, hxK, hy] + obtain ⟨μp, Ap, hpE, hpSupp, hpMean⟩ := exists_atomic_law hK (x + y) hpK hRp hp + obtain ⟨μm, Am, hmE, hmSupp, hmMean⟩ := exists_atomic_law hK (x - y) hmK hRm hm + let a := Rp / (2 * L) + let b := Rm / (2 * L) + have ha : 0 ≤ a := by dsimp [a]; positivity + have hb : 0 ≤ b := by dsimp [b]; positivity + have hab : a + b = 1 := by + dsimp [a, b, L] + field_simp + let μ := μp.blend μm a b ha hb hab + let A := Sum.elim (fun ω => (Ap ω).scale (L / Rp)) (fun ω => (Am ω).scale (L / Rm)) + let σ : Option (LocalFamily K) ⊕ Option (LocalFamily K) → ℝ := Sum.elim (fun _ => 1) (fun _ => -1) + have hσ : ∀ ω, |σ ω| ≤ 1 := by intro ω; cases ω <;> norm_num [σ] + have heRp : (L / Rp) ^ 2 * Rp ^ 2 = L ^ 2 := by field_simp + have heRm : (L / Rm) ^ 2 * Rm ^ 2 = L ^ 2 := by field_simp + have henergy : ∀ ω, (A ω).energy ≤ L ^ 2 := by + intro ω + cases ω with + | inl ω => exact (by + change ((Ap ω).scale (L / Rp)).energy ≤ _ + rw [Representation.scale_energy] + exact (mul_le_mul_of_nonneg_left (hpE ω) (sq_nonneg _)).trans_eq heRp) + | inr ω => exact (by + change ((Am ω).scale (L / Rm)).energy ≤ _ + rw [Representation.scale_energy] + exact (mul_le_mul_of_nonneg_left (hmE ω) (sq_nonneg _)).trans_eq heRm) + have hsupp : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K := by + intro ω + cases ω with + | inl ω => exact hpSupp ω + | inr ω => exact hmSupp ω + have hac : a * (L / Rp) = 1 / 2 := by dsimp [a]; field_simp + have hbc : b * (L / Rm) = 1 / 2 := by dsimp [b]; field_simp + have hmean : μ.expect (fun ω => (A ω).value) = x := by + have hf : (fun ω => (A ω).value) = Sum.elim + (fun ω => (L / Rp) • (Ap ω).value) (fun ω => (L / Rm) • (Am ω).value) := by + funext ω; cases ω <;> exact Representation.scale_value _ _ + rw [hf, μp.blend_expect μm, μp.expect_smul, μm.expect_smul, hpMean, hmMean, smul_smul, + smul_smul, hac, hbc] + module + have hsigned : μ.expect (fun ω => σ ω • (A ω).value) = y := by + have hf : (fun ω => σ ω • (A ω).value) = Sum.elim + (fun ω => (L / Rp) • (Ap ω).value) (fun ω => (-(L / Rm)) • (Am ω).value) := by + funext ω + cases ω with + | inl ω => simp only [σ, A, Sum.elim_inl, Representation.scale_value, one_smul] + | inr ω => + simp only [σ, A, Sum.elim_inr, Representation.scale_value, smul_smul] + congr 1 + ring + rw [hf, μp.blend_expect μm, μp.expect_smul, μm.expect_smul, hpMean, hmMean, + smul_smul, smul_smul, mul_neg, hac, hbc] + module + obtain ⟨p, hpSupport, hpn, hpx⟩ := exists_norming_head hH x hx hx0 + let q : Test V := ‖x‖ • p + have hqSupport : q.coeff.support ⊆ H := Finsupp.support_smul.trans hpSupport + have hqn : ‖q‖ = ‖x‖ := by + change ‖‖x‖ • p‖ = ‖x‖ + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (norm_nonneg _), hpn, mul_one] + have hxq : x (q : Primal V) = ‖x‖ ^ 2 := by + change x ((‖x‖ • p : Test V) : Primal V) = _ + rw [UniformSpace.Completion.coe_smul, map_smul, smul_eq_mul, hpx, sq] + exact represented_joint_bound hH μ σ hσ A hsupp x y hx hmean hsigned q hqSupport + ‖x‖ L hqn hxq henergy + +variable [LocallyFiniteOrderBot V] + +theorem completed_unequal_radius_tail {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hx : head H x = x) + (Rp Rm : ℝ) (hRp : 0 < Rp) (hRm : 0 < Rm) (hp : ‖x + y‖ ≤ Rp) (hm : ‖x - y‖ ≤ Rm) : + ‖tail H y‖ ≤ 2 * Real.sqrt (((Rp + Rm) / 2) ^ 2 - ‖x‖ ^ 2) := by + apply dual_norm_le _ (by positivity) + intro u + let K := ancestralHull (H ∪ u.coeff.support) + have hK := ancestralHull_ancestral (H ∪ u.coeff.support) + have hHK : H ⊆ K := Finset.subset_union_left.trans (subset_ancestralHull _) + have huK : u.coeff.support ⊆ K := Finset.subset_union_right.trans (subset_ancestralHull _) + have hxK := head_eq_of_subset hHK x hx + have hpK : ‖x + head K y‖ ≤ Rp := by + have he : x + head K y = head K (x + y) := by + change x + headLinear K y = headLinear K (x + y) + simp only [map_add, headLinear_apply, hxK] + rw [he] + exact (norm_head_le hK _).trans hp + have hmK : ‖x - head K y‖ ≤ Rm := by + have he : x - head K y = head K (x - y) := by + change x - headLinear K y = headLinear K (x - y) + simp only [map_sub, headLinear_apply, hxK] + rw [he] + exact (norm_head_le hK _).trans hm + have hb := finite_unequal_radius_tail hH hK hHK x (head K y) hx (head_head _ _) + Rp Rm hRp hRm hpK hmK + rw [← tail_head_pairing H K y u huK] + have hop := (tail H (head K y)).le_opNorm (u : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at hop + exact hop.trans (mul_le_mul_of_nonneg_right hb (norm_nonneg u)) + + +theorem averaged_tail_bound {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hx : head H x = x) : + ‖tail H y‖ ≤ 2 * Real.sqrt (((‖x + y‖ + ‖x - y‖) / 2) ^ 2 - ‖x‖ ^ 2) := by + by_cases hp0 : x + y = 0 + · have hy : y = -x := eq_neg_of_add_eq_zero_right hp0 + have ht : tail H y = 0 := by + rw [hy] + change tailLinear H (-x) = 0 + rw [map_neg, tailLinear_apply] + simp only [tail, hx, sub_self, neg_zero] + rw [ht, norm_zero] + positivity + by_cases hm0 : x - y = 0 + · have hy : y = x := (sub_eq_zero.mp hm0).symm + have ht : tail H y = 0 := by simp only [hy, tail, hx, sub_self] + rw [ht, norm_zero] + positivity + exact completed_unequal_radius_tail hH x y hx ‖x + y‖ ‖x - y‖ + (norm_pos_iff.mpr hp0) (norm_pos_iff.mpr hm0) le_rfl le_rfl + +end UnequalRadii + +section StrongConsequences +variable {V : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + +theorem norm_center_le_average (x y : FullDual V) : + ‖x‖ ≤ (‖x + y‖ + ‖x - y‖) / 2 := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + have h := norm_add_le (x + y) (x - y) + have he : (x + y) + (x - y) = (2 : ℝ) • x := by module + rw [he, norm_smul] at h + norm_num at h + linarith + +theorem sharp_radial_comparison {R r : ℝ} (hr : 0 ≤ r) (hR : r ≤ R) : + 2 * Real.sqrt (R ^ 2 - r ^ 2) ≤ + (Real.sqrt 2 + Real.sqrt 6) * Real.sqrt (R * (R - r)) := by + have hR0 : 0 ≤ R := hr.trans hR + have hd : 0 ≤ R * (R - r) := mul_nonneg hR0 (sub_nonneg.mpr hR) + have hs : R ^ 2 - r ^ 2 ≤ 2 * (R * (R - r)) := by nlinarith [sq_nonneg (R-r)] + have h := Real.sqrt_le_sqrt hs + rw [Real.sqrt_mul (by norm_num : (0:ℝ) ≤ 2)] at h + have hc : Real.sqrt 2 ≤ Real.sqrt 6 := Real.sqrt_le_sqrt (by norm_num) + nlinarith [Real.sqrt_nonneg (R * (R-r))] + + +theorem radial_tail_bound {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hx : head H x = x) (R : ℝ) (hR : 0 ≤ R) + (hp : ‖x+y‖ ≤ R) (hm : ‖x-y‖ ≤ R) : + ‖tail H y‖ ≤ (Real.sqrt 2 + Real.sqrt 6) * Real.sqrt (R * (R - ‖x‖)) := + (completed_main_tail hH x y hx R hR hp hm).trans + (sharp_radial_comparison (norm_nonneg x) (norm_center_le x y R hp hm)) + + +theorem original_coefficient_average {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x z : FullDual V) (hx : head H x = x) (hz : head H z = 0) : + ‖x‖ ≤ ‖x+z‖ ∧ ‖x‖ ≤ ‖x-z‖ ∧ + ‖z‖ ≤ (Real.sqrt 2 + Real.sqrt 6) * + Real.sqrt (((‖x+z‖ + ‖x-z‖)/2) * ((‖x+z‖ + ‖x-z‖)/2 - ‖x‖)) := by + have hp : head H (x+z) = x := by + change headLinear H (x+z) = x + simp only [map_add, headLinear_apply, hx, hz, add_zero] + have hm : head H (x-z) = x := by + change headLinear H (x-z) = x + simp only [map_sub, headLinear_apply, hx, hz, sub_zero] + refine ⟨?_, ?_, ?_⟩ + · simpa only [hp] using norm_head_le hH (x+z) + · simpa only [hm] using norm_head_le hH (x-z) + · have h := averaged_tail_bound hH x z hx + rw [tail, hz, sub_zero] at h + exact h.trans (sharp_radial_comparison (norm_nonneg x) (norm_center_le_average x z)) + +theorem strong_finite_head_average {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (x y : FullDual V) (hx : head H x = x) (hxn : ‖x‖ = 1) + (hy : head H y = 0) (hyn : 1 ≤ ‖y‖) {t : ℝ} (ht : 0 < t) : + Real.sqrt (1 + t ^ 2 / 4) - 1 ≤ + (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 := by + let L := (‖x+t•y‖+‖x-t•y‖)/2 + have hL : 1 ≤ L := by simpa only [hxn] using norm_center_le_average x (t•y) + have hL0 : 0 ≤ L := by linarith + have hty : tail H (t • y) = t • y := by + change t • y - headLinear H (t • y) = t • y + rw [map_smul, headLinear_apply, hy, smul_zero, sub_zero] + have htail := averaged_tail_bound hH x (t•y) hx + rw [hty, norm_smul, Real.norm_eq_abs, abs_of_pos ht, hxn] at htail + change t * ‖y‖ ≤ 2 * Real.sqrt (L^2-1^2) at htail + have htn : t ≤ t * ‖y‖ := le_mul_of_one_le_right ht.le hyn + have hd : 0 ≤ L^2-1^2 := by nlinarith + have hs := Real.sq_sqrt hd + have hroot : Real.sqrt (1+t^2/4) ≤ L := by + apply (Real.sqrt_le_iff).mpr + refine ⟨hL0, ?_⟩ + nlinarith [Real.sqrt_nonneg (L^2-1^2)] + exact sub_le_sub_right hroot 1 + +theorem strong_predual_averaged_witness (x : CoordinatePredual V) (hx : ‖x‖ = 1) + {t ε : ℝ} (ht : 0 < t) (hε : 0 < ε) : + ∃ H : Finset V, Ancestral (· ≤ ·) H ∧ + ∀ y : CoordinatePredual V, head H y.val = 0 → 1 ≤ ‖y‖ → + (Real.sqrt (1 + t ^ 2 / 4) - 1) - ε ≤ + (‖x + t • y‖ + ‖x - t • y‖) / 2 - 1 := by + obtain ⟨H, hH, z, hz, hzn, he⟩ := predual_unit_approx x hx hε + refine ⟨H, hH, ?_⟩ + intro y hy hyn + have h := strong_finite_head_average hH z y.val hz hzn hy hyn ht + have hp : ‖z + t • y.val‖ ≤ ‖x.val + t • y.val‖ + ‖x.val - z‖ := by + have heq : z + t • y.val = (x.val + t • y.val) + (z - x.val) := by module + rw [heq] + exact (norm_add_le _ _).trans_eq (by rw [norm_sub_rev z x.val]) + have hm : ‖z - t • y.val‖ ≤ ‖x.val - t • y.val‖ + ‖x.val - z‖ := by + have heq : z - t • y.val = (x.val - t • y.val) + (z - x.val) := by module + rw [heq] + exact (norm_add_le _ _).trans_eq (by rw [norm_sub_rev z x.val]) + change (Real.sqrt (1 + t ^ 2 / 4) - 1) - ε ≤ + (‖x.val + t • y.val‖ + ‖x.val - t • y.val‖) / 2 - 1 + linarith + + +end StrongConsequences + +section StrongModulus +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] {infiniteV : Infinite V} +include infiniteV + +theorem strong_predual_all_radius_average [Infinite V] {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) ≤ averagedModulus (CoordinatePredual V) t := by + have _ := infiniteV + apply averagedModulus_lower predual_not_finite ht.le + intro x ε hε + obtain ⟨H, hH, hw⟩ := strong_predual_averaged_witness x.val x.property ht hε + refine ⟨CofiniteSubspace.ofMap (predualHeadValues H), ?_⟩ + intro y + exact hw y.val (predualHeadValues_zero H y.val y.property.1) y.property.2.ge + +theorem strong_fullDual_all_radius_average_of_reflexive [Infinite V] (hV : Reflexive (Primal V)) + {t : ℝ} (ht : 0 < t) : + (Real.sqrt (1 + t ^ 2 / 4) - 1) ≤ averagedModulus (FullDual V) t := by + have _ := infiniteV + apply averagedModulus_lower fullDual_not_finite ht.le + intro x ε hε + have hx : x.val ∈ coordinateSpan V := by rw [coordinateSpan_eq_top_of_reflexive hV]; trivial + obtain ⟨H, hH, hw⟩ := strong_predual_averaged_witness (⟨x.val, hx⟩ : CoordinatePredual V) + x.property ht hε + let f : FullDual V →L[ℝ] (H → ℝ) := + ContinuousLinearMap.pi (fun v => ContinuousLinearMap.apply ℝ ℝ (unitVector v.val)) + refine ⟨CofiniteSubspace.ofMap f, ?_⟩ + intro y + have hy : y.val ∈ coordinateSpan V := by rw [coordinateSpan_eq_top_of_reflexive hV]; trivial + apply hw (⟨y.val, hy⟩ : CoordinatePredual V) _ y.property.2.ge + apply Finset.sum_eq_zero + intro v hv + have he := congrFun y.property.1 (⟨v, hv⟩ : H) + change y.val (unitVector v) = 0 at he + rw [he, zero_smul] + +end StrongModulus + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Separated.lean b/lean/OAI/Analysis/SegmentLenses/Separated.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee950241d7d95733d16677a2c529110d4ed4c708 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Separated.lean @@ -0,0 +1,286 @@ +import OAI.Analysis.SegmentLenses.IndexedDual + +namespace OAI + +/-! +# Separated families and uniform positive gaps +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +section SeparatedFamilies +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + + +theorem finite_head_close_pair {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (z : ℕ → FullDual V) (B : ℝ) (hz : ∀ n, ‖z n‖ ≤ B) {ε : ℝ} (hε : 0 < ε) : + ∃ i j : ℕ, i ≠ j ∧ ‖head H (z i) - head H (z j)‖ < ε := by + have _ := locallyFiniteOrderBotV + classical + let E : Submodule ℝ (FullDual V) := Submodule.span ℝ (coordinate '' (H : Set V)) + have : FiniteDimensional ℝ E := FiniteDimensional.span_of_finite ℝ + (Set.Finite.image coordinate (Finset.finite_toSet H)) + have hmem : ∀ n, head H (z n) ∈ E := by + intro n + apply Submodule.sum_mem + intro v hv + exact E.smul_mem _ (Submodule.subset_span ⟨v, hv, rfl⟩) + let w : ℕ → E := fun n => ⟨head H (z n), hmem n⟩ + have hw : ∀ n, w n ∈ Metric.closedBall (0 : E) B := by + intro n + rw [Metric.mem_closedBall] + change dist (head H (z n)) 0 ≤ B + rw [dist_zero_right] + exact (norm_head_le hH (z n)).trans (hz n) + obtain ⟨a, ha, φ, hφ, ht⟩ := tendsto_subseq_of_bounded (Metric.isBounded_closedBall) hw + obtain ⟨N, hN⟩ := Metric.tendsto_atTop.mp ht (ε/2) (half_pos hε) + refine ⟨φ N, φ (N+1), ne_of_lt (hφ (Nat.lt_succ_self N)), ?_⟩ + have hn := hN N le_rfl + have hn' := hN (N+1) (Nat.le_succ N) + have hd := dist_triangle (w (φ N)) a (w (φ (N+1))) + rw [dist_comm a] at hd + change ‖head H (z (φ N)) - head H (z (φ (N+1)))‖ < ε + have he : dist (w (φ N)) (w (φ (N+1))) = + ‖head H (z (φ N)) - head H (z (φ (N+1)))‖ := by + change dist (head H (z (φ N))) (head H (z (φ (N+1)))) = _ + exact dist_eq_norm _ _ + rw [he] at hd + dsimp only [Function.comp_apply] at hn hn' + linarith + +theorem separated_predual_family {D : ℝ} (hD : 1 ≤ D) : + ∃ c : ℝ, 0 < c ∧ ∀ (x : CoordinatePredual V) (z : ℕ → CoordinatePredual V), + 1 ≤ ‖x‖ → ‖x‖ ≤ D → (∀ i, ‖z i‖ ≤ 2*D) → + (∀ i j, i ≠ j → 1 ≤ ‖z i - z j‖) → + ∃ i, ‖x‖ + c < max ‖x+z i‖ ‖x-z i‖ := by + let c : ℝ := 1 / (4096 * (D+1)) + have hD0 : 0 ≤ D := by linarith + have hc : 0 < c := by dsimp [c]; positivity + have hc1 : c ≤ 1/4096 := by + dsimp [c] + apply (div_le_iff₀ (by positivity : 0 < 4096*(D+1))).mpr + nlinarith + have hcD : D*c ≤ 1/4096 := by + dsimp [c] + rw [mul_one_div] + apply (div_le_iff₀ (by positivity : 0 < 4096*(D+1))).mpr + nlinarith + refine ⟨c, hc, ?_⟩ + intro x z hx1 hxD hz hsep + by_contra! hbad + obtain ⟨H, hH, u, hu, he⟩ := predual_finite_approx x hc + let R := ‖x‖ + 2*c + have hR : 0 ≤ R := by dsimp [R]; positivity + have huNorm : ‖x‖-c ≤ ‖u‖ := by + have hn := norm_sub_norm_le x.val u + change ‖x.val-u‖ < c at he + change ‖x.val‖-c ≤ ‖u‖ + linarith + have htails : ∀ i, ‖tail H (z i).val‖ ≤ 1/4 := by + intro i + have hp : ‖u+(z i).val‖ ≤ R := by + have ht : ‖u+(z i).val‖ ≤ ‖x.val+(z i).val‖ + ‖x.val-u‖ := by + have heq : u+(z i).val = (x.val+(z i).val)+(u-x.val) := by module + rw [heq] + exact (norm_add_le _ _).trans_eq (by rw [norm_sub_rev u x.val]) + have hb := (le_max_left ‖x+z i‖ ‖x-z i‖).trans (hbad i) + change ‖x.val+(z i).val‖ ≤ ‖x.val‖ + c at hb + dsimp [R] + change ‖x.val-u‖ < c at he + linarith + have hm : ‖u-(z i).val‖ ≤ R := by + have ht : ‖u-(z i).val‖ ≤ ‖x.val-(z i).val‖ + ‖x.val-u‖ := by + have heq : u-(z i).val = (x.val-(z i).val)+(u-x.val) := by module + rw [heq] + exact (norm_add_le _ _).trans_eq (by rw [norm_sub_rev u x.val]) + have hb := (le_max_right ‖x+z i‖ ‖x-z i‖).trans (hbad i) + change ‖x.val-(z i).val‖ ≤ ‖x.val‖ + c at hb + dsimp [R] + change ‖x.val-u‖ < c at he + linarith + have ht := completed_main_tail hH u (z i).val hu R hR hp hm + have hq : R^2-‖u‖^2 ≤ 1/64 := by + have hu0 : 0 ≤ ‖x‖-c := by linarith + have husq : (‖x‖-c)^2 ≤ ‖u‖^2 := sq_le_sq₀ hu0 (norm_nonneg u) |>.mpr huNorm + have hxc : ‖x‖*c ≤ D*c := mul_le_mul_of_nonneg_right hxD hc.le + have hcc : c^2 ≤ c := by nlinarith + change (‖x‖+2*c)^2-‖u‖^2 ≤ 1/64 + nlinarith + have hs : Real.sqrt (R^2-‖u‖^2) ≤ 1/8 := by + exact (Real.sqrt_le_iff).mpr ⟨by norm_num, by nlinarith⟩ + linarith + obtain ⟨i, j, hij, hh⟩ := finite_head_close_pair hH (fun i => (z i).val) (2*D) hz (by norm_num : (0:ℝ)<1/2) + have ht : ‖(z i).val-(z j).val‖ ≤ + ‖head H (z i).val-head H (z j).val‖ + ‖tail H (z i).val‖ + ‖tail H (z j).val‖ := by + have heq : (z i).val-(z j).val = + (head H (z i).val-head H (z j).val)+tail H (z i).val-tail H (z j).val := by + simp only [tail]; module + rw [heq] + exact (norm_sub_le _ _).trans (add_le_add (norm_add_le _ _) le_rfl) + have hlow := hsep i j hij + change 1 ≤ ‖(z i).val-(z j).val‖ at hlow + linarith [htails i, htails j] + +end SeparatedFamilies + + +section LargerDirections +variable (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + +abbrev CofiniteLargeSphere (F : CofiniteSubspace E) := {y : E // y ∈ F.space ∧ 1 ≤ ‖y‖} + +def averagedLargeOn (x : SphereOne E) (t : ℝ) (F : CofiniteSubspace E) : ℝ := + ⨅ y : CofiniteLargeSphere E F, (‖x.val+t•y.val‖+‖x.val-t•y.val‖)/2-1 + +def averagedLargeAt (x : SphereOne E) (t : ℝ) : ℝ := + ⨆ F : CofiniteSubspace E, averagedLargeOn E x t F + +def averagedLargeModulus (t : ℝ) : ℝ := ⨅ x : SphereOne E, averagedLargeAt E x t + +variable {E} + +theorem average_nonneg_all (x y : E) (hx : ‖x‖ = 1) (t : ℝ) : + 0 ≤ (‖x+t•y‖+‖x-t•y‖)/2-1 := by + have he : (x+t•y)+(x-t•y) = (2:ℝ)•x := by module + have h := norm_add_le (x+t•y) (x-t•y) + rw [he, norm_smul, hx, mul_one] at h + norm_num at h + linarith + +theorem averagedLargeOn_bounds (hE : ¬ FiniteDimensional ℝ E) (x : SphereOne E) + {t : ℝ} (ht : 0 ≤ t) (F : CofiniteSubspace E) : + 0 ≤ averagedLargeOn E x t F ∧ averagedLargeOn E x t F ≤ t := by + let u : CofiniteSphere E F := Classical.choice (F.sphere_nonempty hE) + let y : CofiniteLargeSphere E F := ⟨u.val, u.property.1, u.property.2.ge⟩ + let : Nonempty (CofiniteLargeSphere E F) := ⟨y⟩ + have hb : BddBelow (Set.range (fun y : CofiniteLargeSphere E F => + (‖x.val+t•y.val‖+‖x.val-t•y.val‖)/2-1)) := by + refine ⟨0, ?_⟩ + rintro _ ⟨v,rfl⟩ + exact average_nonneg_all x.val v.val x.property t + exact ⟨le_ciInf (fun v => average_nonneg_all x.val v.val x.property t), + (ciInf_le hb y).trans (average_bounds x.val u.val x.property u.property.2 ht).2⟩ + +theorem averagedLargeModulus_lower (hE : ¬ FiniteDimensional ℝ E) {t c : ℝ} (ht : 0 ≤ t) + (hw : ∀ x : SphereOne E, ∀ ε : ℝ, 0 < ε → ∃ F : CofiniteSubspace E, + ∀ y : CofiniteLargeSphere E F, + c - ε ≤ (‖x.val+t•y.val‖+‖x.val-t•y.val‖)/2-1) : + c ≤ averagedLargeModulus E t := by + have := sphereOne_nonempty hE + apply le_ciInf + intro x + apply le_of_forall_pos_le_add + intro ε hε + obtain ⟨F,hF⟩ := hw x ε hε + have hb : BddAbove (Set.range (fun F : CofiniteSubspace E => averagedLargeOn E x t F)) := by + refine ⟨t, ?_⟩ + rintro _ ⟨G,rfl⟩ + exact (averagedLargeOn_bounds hE x ht G).2 + let u : CofiniteSphere E F := Classical.choice (F.sphere_nonempty hE) + let : Nonempty (CofiniteLargeSphere E F) := ⟨⟨u.val,u.property.1,u.property.2.ge⟩⟩ + have he : c-ε ≤ averagedLargeOn E x t F := le_ciInf hF + have h := he.trans (le_ciSup hb F) + change c - ε ≤ averagedLargeAt E x t at h + linarith + +end LargerDirections + +section AveragedRefinementConsequences +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + +theorem predual_strong_large_average [Infinite V] {t : ℝ} (ht : 0 < t) : + Real.sqrt (1+t^2/4)-1 ≤ averagedLargeModulus (CoordinatePredual V) t := by + apply averagedLargeModulus_lower predual_not_finite ht.le + intro x ε hε + obtain ⟨H,hH,hw⟩ := strong_predual_averaged_witness x.val x.property ht hε + refine ⟨CofiniteSubspace.ofMap (predualHeadValues H), ?_⟩ + intro y + exact hw y.val (predualHeadValues_zero H y.val y.property.1) y.property.2 + +theorem clipping_scalar {t : ℝ} : Real.sqrt (1+t^2/12)-1 ≤ Real.sqrt (1+t^2/4)-1 := by + apply sub_le_sub_right + apply Real.sqrt_le_sqrt + nlinarith [sq_nonneg t] + + +theorem infinite_paired_clipping {t : ℝ} (ht : 0 < t) : + Real.sqrt (1+t^2/12)-1 ≤ averagedModulus BInfinite t := by + classical + exact clipping_scalar.trans (strong_predual_all_radius_average (infiniteV := inferInstance) ht) + + +theorem forest_paired_clipping {t : ℝ} (ht : 0 < t) : + Real.sqrt (1+t^2/12)-1 ≤ averagedModulus X t := by + classical + exact clipping_scalar.trans (strong_fullDual_all_radius_average_of_reflexive (infiniteV := inferInstance) forest_primal_reflexive ht) + +def radialConstant : ℝ := Real.sqrt 2 + Real.sqrt 6 + +theorem radialConstant_ge : 2 ≤ radialConstant := by + have h2 : 1 ≤ Real.sqrt 2 := by exact (Real.le_sqrt (by norm_num) (by norm_num)).mpr (by norm_num) + have h6 : 1 ≤ Real.sqrt 6 := by exact (Real.le_sqrt (by norm_num) (by norm_num)).mpr (by norm_num) + dsimp [radialConstant] + linarith + +def originalOmega (t : ℝ) : ℝ := (Real.sqrt (1+4*(t/radialConstant)^2)-1)/2 + +theorem originalOmega_positive {t : ℝ} (ht : 0 < t) : 0 < originalOmega t := by + have hc : 0 < radialConstant := lt_of_lt_of_le (by norm_num : (0:ℝ)<2) radialConstant_ge + have hq : 0 < (t/radialConstant)^2 := sq_pos_of_pos (div_pos ht hc) + have hs : 1 < Real.sqrt (1+4*(t/radialConstant)^2) := by + apply (Real.lt_sqrt (by norm_num)).mpr + nlinarith + dsimp [originalOmega] + linarith + +theorem originalOmega_comparison {t : ℝ} (ht : 0 < t) : + originalOmega t / 2 ≤ Real.sqrt (1+t^2/4)-1 := by + have hc : 0 < radialConstant := lt_of_lt_of_le (by norm_num : (0:ℝ)<2) radialConstant_ge + have hratio : t/radialConstant ≤ t/2 := by + apply (div_le_iff₀ hc).mpr + have h := mul_le_mul_of_nonneg_left radialConstant_ge ht.le + nlinarith + have hratio0 : 0 ≤ t/radialConstant := (div_pos ht hc).le + let a := Real.sqrt (1+t^2/4) + have ha0 : 0 ≤ a := Real.sqrt_nonneg _ + have ha : 1 ≤ a := by + apply (Real.le_sqrt (by norm_num) (by positivity)).mpr + nlinarith [sq_nonneg t] + have hasq : a^2 = 1+t^2/4 := Real.sq_sqrt (by positivity) + have hs : Real.sqrt (1+4*(t/radialConstant)^2) ≤ 4*a-3 := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by linarith, ?_⟩ + nlinarith [sq_nonneg (a-1)] + dsimp [originalOmega] + change (Real.sqrt (1+4*(t/radialConstant)^2)-1)/2/2 ≤ a-1 + linarith + + + +theorem infinite_original_modulus {t : ℝ} (ht : 0 < t) : + 0 < originalOmega t/2 ∧ originalOmega t/2 ≤ averagedModulus BInfinite t ∧ + originalOmega t/2 ≤ averagedLargeModulus BInfinite t := by + classical + exact ⟨half_pos (originalOmega_positive ht), + (originalOmega_comparison ht).trans (strong_predual_all_radius_average (infiniteV := inferInstance) ht), + (originalOmega_comparison ht).trans (predual_strong_large_average ht)⟩ + +end AveragedRefinementConsequences + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Stability.lean b/lean/OAI/Analysis/SegmentLenses/Stability.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cc72aa3a161c7ab740e473d6ce03bcc1cf4229a --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Stability.lean @@ -0,0 +1,438 @@ +import OAI.Analysis.SegmentLenses.Radial + +namespace OAI + +/-! +# Weighted stability and original-coordinate estimates +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +section GateContraction +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] + + + +theorem gate_coordinate_square_sum {H : Finset V} (G : Finset V) + (hG : ∀ g ∈ G, Gate H g) (z : FullDual V) : + ∑ g : G, z (unitVector g.val) ^ 2 ≤ ‖z‖ ^ 2 := by + by_cases hz : z = 0 + · simp [hz] + have hr : 0 < ‖z‖ := norm_pos_iff.mpr hz + let K := ancestralHull G + have hK := ancestralHull_ancestral G + obtain ⟨μ, A, hA, hAK, hmean⟩ := exists_atomic_law hK (head K z) (head_head K z) + hr (norm_head_le hK z) + have hc : ∀ g : G, z (unitVector g.val) = μ.mean (fun ω => (A ω).value (unitVector g.val)) := by + intro g + rw [← μ.expect_apply, hmean, head_unitVector, + ite_eq_left (subset_ancestralHull G g.property)] + calc + (∑ g : G, z (unitVector g.val) ^ 2) = + ∑ g : G, μ.mean (fun ω => (A ω).value (unitVector g.val)) ^ 2 := by simp_rw [hc] + _ ≤ ∑ g : G, μ.mean (fun ω => (A ω).value (unitVector g.val) ^ 2) := + Finset.sum_le_sum (fun g _ => μ.sq_mean_le _) + _ = μ.mean (fun ω => ∑ g : G, (A ω).value (unitVector g.val) ^ 2) := (μ.mean_sum _).symm + _ ≤ μ.mean (fun ω => (A ω).energy) := μ.mean_mono (fun ω => (A ω).gate_energy_le G hG) + _ ≤ ‖z‖ ^ 2 := (μ.mean_mono hA).trans_eq (μ.mean_const _) + +end GateContraction + +section LawStability +variable {V Ω : Type*} [DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] [Fintype Ω] + + +def lawDeficit (μ : FiniteLaw Ω) (A : Ω → Representation V) (p : Test V) : ℝ := + 1 - (μ.expect (fun ω => (A ω).value)) (p : Primal V) + +def lawError (μ : FiniteLaw Ω) (A : Ω → Representation V) (p : Test V) : ℝ := + μ.mean (fun ω => ((A ω).error p.coeff).energy) + +def lawSlack (μ : FiniteLaw Ω) (A : Ω → Representation V) (p : Test V) : ℝ := + μ.mean (fun ω => 1 - (A ω).family.seminorm p.coeff ^ 2) + +theorem unit_law_budget (μ : FiniteLaw Ω) (A : Ω → Representation V) + (hA : ∀ ω, (A ω).energy ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) : + 0 ≤ lawError μ A p ∧ 0 ≤ lawSlack μ A p ∧ + lawError μ A p + lawSlack μ A p ≤ 2 * lawDeficit μ A p := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + have he : 0 ≤ lawError μ A p := μ.mean_nonneg (fun ω => (A ω).error p.coeff |>.energy_nonneg) + have hd : ∀ ω, 0 ≤ 1 - (A ω).family.seminorm p.coeff ^ 2 := by + intro ω + have hf := (le_segmentSeminorm (A ω).family p.coeff).trans hp + have hn := apply_nonneg ((A ω).family.seminorm) p.coeff + nlinarith + refine ⟨he, μ.mean_nonneg hd, ?_⟩ + change μ.mean _ + μ.mean _ ≤ _ + rw [← μ.mean_add] + calc + μ.mean (fun ω => ((A ω).error p.coeff).energy + (1 - (A ω).family.seminorm p.coeff ^ 2)) ≤ + μ.mean (fun ω => 2 * (1 - (A ω).value (p : Primal V))) := by + apply μ.mean_mono + intro ω + have heq := (A ω).error_slack_identity p.coeff 1 + rw [← Representation.apply_test] at heq + norm_num only [one_pow] at heq + linarith [hA ω] + _ = 2 * lawDeficit μ A p := by + rw [μ.mean_mul, μ.mean_sub, μ.mean_const, lawDeficit, μ.expect_apply] + +theorem lawDeficit_nonneg (μ : FiniteLaw Ω) (A : Ω → Representation V) + (hA : ∀ ω, (A ω).energy ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) : + 0 ≤ lawDeficit μ A p := by + obtain ⟨he, hd, hb⟩ := unit_law_budget μ A hA p hp + linarith + + + +theorem mean_error_norm_le (μ : FiniteLaw Ω) (A : Ω → Representation V) + (hA : ∀ ω, (A ω).energy ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) : + μ.mean (fun ω => ‖(A ω).value - ((A ω).family.replacement p.coeff).value‖) ≤ + Real.sqrt (2 * lawDeficit μ A p) := by + obtain ⟨he, hd, hb⟩ := unit_law_budget μ A hA p hp + calc + μ.mean (fun ω => ‖(A ω).value - ((A ω).family.replacement p.coeff).value‖) = + μ.mean (fun ω => ‖((A ω).error p.coeff).value‖) := by simp only [Representation.error_value] + _ ≤ μ.mean (fun ω => Real.sqrt ((A ω).error p.coeff).energy) := μ.mean_mono (fun ω => ((A ω).error p.coeff).norm_le) + _ ≤ Real.sqrt (lawError μ A p) := μ.mean_sqrt_le _ (fun ω => ((A ω).error p.coeff).energy_nonneg) + _ ≤ Real.sqrt (2 * lawDeficit μ A p) := Real.sqrt_le_sqrt (by linarith) + +theorem signed_law_error_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (A : Ω → Representation V) (hA : ∀ ω, (A ω).energy ≤ 1) + (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) : + ‖tail H (μ.expect (fun ω => σ ω • ((A ω).error p.coeff).value))‖ ≤ + Real.sqrt (2 * lawDeficit μ A p) := by + apply (norm_signed_tail_expect_le hH μ σ hσ _).trans + simpa only [Representation.error_value] using mean_error_norm_le μ A hA p hp + + +theorem law_absolute_mass_bound {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (G : Finset V) (hG : ∀ g ∈ G, Gate H g) + (μ : FiniteLaw Ω) (A : Ω → Representation V) (hA : ∀ ω, (A ω).energy ≤ 1) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) : + (∑ g : G, μ.mean (fun ω => |(A ω).family.boundary p.coeff g.val|) ^ 2) ≤ + (‖tail H (μ.expect (fun ω => (A ω).value))‖ + Real.sqrt (2 * lawDeficit μ A p)) ^ 2 + + 4 * lawDeficit μ A p := by + let x := μ.expect (fun ω => (A ω).value) + let z := μ.expect (fun ω => ((A ω).family.replacement p.coeff).value) + let e := μ.expect (fun ω => ((A ω).error p.coeff).value) + have hxe : z = x - e := by + dsimp [z, x, e] + simp only [Representation.error_value, μ.expect_sub] + abel + have he : ‖tail H e‖ ≤ Real.sqrt (2 * lawDeficit μ A p) := by + simpa only [one_smul] using signed_law_error_le hH μ A hA (fun _ => 1) (by simp) p hp + have hz : ‖tail H z‖ ≤ ‖tail H x‖ + Real.sqrt (2 * lawDeficit μ A p) := by + rw [hxe] + change ‖tailLinear H (x - e)‖ ≤ _ + rw [map_sub] + change ‖tail H x - tail H e‖ ≤ _ + exact (norm_sub_le (tail H x) (tail H e)).trans (add_le_add (le_refl ‖tail H x‖) he) + have hgate : ∀ g : G, μ.mean (fun ω => (A ω).family.boundary p.coeff g.val) = + tail H z (unitVector g.val) := by + intro g + rw [tail_unitVector, ite_eq_right (hG g.val g.property).1] + dsimp [z] + rw [μ.expect_apply] + congr 1 + funext ω + exact ((A ω).family.replacement_gate p.coeff g.val).symm + have hv : (∑ g : G, μ.mean (fun ω => (A ω).family.boundary p.coeff g.val) ^ 2) ≤ + (‖tail H x‖ + Real.sqrt (2 * lawDeficit μ A p)) ^ 2 := by + simp_rw [hgate] + apply (gate_coordinate_square_sum G hG (tail H z)).trans + exact sq_le_sq₀ (norm_nonneg _) (by positivity) |>.mpr hz + have hc : ∀ ω ω', (∑ g : G, + (|(A ω).family.boundary p.coeff g.val * (A ω').family.boundary p.coeff g.val| - + (A ω).family.boundary p.coeff g.val * (A ω').family.boundary p.coeff g.val)) ≤ + (1 - (A ω).family.seminorm p.coeff ^ 2) + (1 - (A ω').family.seminorm p.coeff ^ 2) := by + intro ω ω' + have hb := opposite_crossing (A ω).family (A ω').family hH p.coeff hpH G hG + change _ ≤ (‖p‖ ^ 2 - _) + (‖p‖ ^ 2 - _) at hb + have hn := norm_nonneg p + nlinarith + have hm := μ.absolute_mass_bound (fun ω (g : G) => (A ω).family.boundary p.coeff g.val) + (fun ω => 1 - (A ω).family.seminorm p.coeff ^ 2) hc + obtain ⟨hE, hD, hb⟩ := unit_law_budget μ A hA p hp + change _ ≤ _ + 2 * lawSlack μ A p at hm + change _ ≤ (‖tail H x‖ + _) ^ 2 + _ + linarith + + +theorem represented_bounded_multiplier {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (A : Ω → Representation V) (hA : ∀ ω, (A ω).energy ≤ 1) + (hK : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K) + (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) : + ‖tail H (μ.expect (fun ω => σ ω • (A ω).value))‖ ≤ + Real.sqrt ((‖tail H (μ.expect (fun ω => (A ω).value))‖ + Real.sqrt (2 * lawDeficit μ A p)) ^ 2 + + 4 * lawDeficit μ A p) + Real.sqrt (2 * lawDeficit μ A p) := by + classical + let B := (‖tail H (μ.expect (fun ω => (A ω).value))‖ + Real.sqrt (2 * lawDeficit μ A p)) ^ 2 + + 4 * lawDeficit μ A p + have hrep := (norm_signed_replacement_le hH μ σ hσ A hK p.coeff hpH).trans + (Real.sqrt_le_sqrt (law_absolute_mass_bound hH (K.filter (Gate H)) + (fun g hg => (Finset.mem_filter.mp hg).2) μ A hA p hp hpH)) + have he := signed_law_error_le hH μ A hA σ hσ p hp + have hsplit : μ.expect (fun ω => σ ω • (A ω).value) = + μ.expect (fun ω => σ ω • ((A ω).family.replacement p.coeff).value) + + μ.expect (fun ω => σ ω • ((A ω).error p.coeff).value) := by + rw [← μ.expect_add] + congr 1 + funext ω + rw [← smul_add, Representation.error_value] + congr 1 + abel + rw [hsplit] + change ‖tailLinear H (_ + _)‖ ≤ _ + rw [map_add] + exact (norm_add_le _ _).trans (add_le_add hrep he) + +end LawStability + + + +theorem stable_radical_linear {η δ : ℝ} (hη : 0 ≤ η) (hδ : 0 ≤ δ) : + Real.sqrt ((η + Real.sqrt (2 * δ)) ^ 2 + 4 * δ) + Real.sqrt (2 * δ) ≤ + η + (2 + 2 * Real.sqrt 2) * Real.sqrt δ := by + have hs : Real.sqrt (2 * δ) = Real.sqrt 2 * Real.sqrt δ := Real.sqrt_mul (by norm_num) _ + have hδs := Real.sq_sqrt hδ + have h2s := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2) + have hb : Real.sqrt ((η + Real.sqrt (2 * δ)) ^ 2 + 4 * δ) ≤ + η + Real.sqrt (2 * δ) + 2 * Real.sqrt δ := by + apply (Real.sqrt_le_iff).mpr + constructor + · positivity + · nlinarith [mul_nonneg (Real.sqrt_nonneg δ) (show 0 ≤ η + Real.sqrt (2 * δ) by positivity)] + rw [hs] at hb ⊢ + linarith + +namespace FiniteLaw +variable {I Ω : Type*} [Fintype I] [Fintype Ω] + +def mixture (w : FiniteLaw I) (μ : I → FiniteLaw Ω) : FiniteLaw (I × Ω) where + weight iω := w.weight iω.1 * (μ iω.1).weight iω.2 + nonneg iω := mul_nonneg (w.nonneg _) ((μ _).nonneg _) + total := by + simp only [Fintype.sum_prod_type, ← Finset.mul_sum, fun i => (μ i).total, mul_one, w.total] + +@[simp] theorem mixture_mean (w : FiniteLaw I) (μ : I → FiniteLaw Ω) (f : I × Ω → ℝ) : + (w.mixture μ).mean f = w.mean (fun i => (μ i).mean (fun ω => f (i, ω))) := by + simp only [mean, mixture, Fintype.sum_prod_type, mul_assoc, Finset.mul_sum] + +@[simp] theorem mixture_expect (w : FiniteLaw I) (μ : I → FiniteLaw Ω) + {E : Type*} [AddCommMonoid E] [Module ℝ E] (f : I × Ω → E) : + (w.mixture μ).expect f = w.expect (fun i => (μ i).expect (fun ω => f (i, ω))) := by + simp only [expect, mixture, Fintype.sum_prod_type, mul_smul, Finset.smul_sum] + +theorem weight_mul_mean_le (w : FiniteLaw I) (f : I → ℝ) (hf : ∀ i, 0 ≤ f i) (i : I) : + w.weight i * f i ≤ w.mean f := Finset.single_le_sum (fun j _ => mul_nonneg (w.nonneg j) (hf j)) + (Finset.mem_univ i) + +end FiniteLaw + +section ConditionalLaws +variable {V I Ω : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + [Fintype I] [Fintype Ω] + +theorem mixture_deficit (w : FiniteLaw I) (μ : I → FiniteLaw Ω) + (A : I → Ω → Representation V) (p : Test V) : + lawDeficit (w.mixture μ) (fun iω => A iω.1 iω.2) p = + w.mean (fun i => lawDeficit (μ i) (A i) p) := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + simp only [lawDeficit, FiniteLaw.mixture_expect, FiniteLaw.expect_apply, + FiniteLaw.mean_sub, FiniteLaw.mean_const] + + +theorem represented_weighted_tail {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (w : FiniteLaw I) (hw : ∀ i, 0 < w.weight i) (μ : I → FiniteLaw Ω) + (A : I → Ω → Representation V) (hA : ∀ i ω, (A i ω).energy ≤ 1) + (hK : ∀ i ω S, S ∈ (A i ω).family.sets → S ⊆ K) + (p : Test V) (hp : ‖p‖ ≤ 1) (hpH : p.coeff.support ⊆ H) (i : I) : + ‖tail H ((μ i).expect (fun ω => (A i ω).value))‖ ≤ + (w.weight i)⁻¹ * Real.sqrt + ((‖tail H (w.expect (fun j => (μ j).expect (fun ω => (A j ω).value)))‖ + + Real.sqrt (2 * w.mean (fun j => lawDeficit (μ j) (A j) p))) ^ 2 + + 4 * w.mean (fun j => lawDeficit (μ j) (A j) p)) + + Real.sqrt (2 * lawDeficit (μ i) (A i) p) := by + classical + have hi : 0 ≤ (w.weight i)⁻¹ := inv_nonneg.mpr (hw i).le + let ν := w.mixture μ + let B : I × Ω → Representation V := fun iω => A iω.1 iω.2 + let G := K.filter (Gate H) + let m : I → G → ℝ := fun j g => (μ j).mean (fun ω => |(A j ω).family.boundary p.coeff g.val|) + let M : G → ℝ := fun g => ν.mean (fun iω => |(B iω).family.boundary p.coeff g.val|) + let d := w.mean (fun j => lawDeficit (μ j) (A j) p) + let η := ‖tail H (w.expect (fun j => (μ j).expect (fun ω => (A j ω).value)))‖ + let C := Real.sqrt ((η + Real.sqrt (2 * d)) ^ 2 + 4 * d) + have hd : 0 ≤ d := w.mean_nonneg (fun j => lawDeficit_nonneg (μ j) (A j) (hA j) p hp) + have hM : (∑ g : G, M g ^ 2) ≤ C ^ 2 := by + have h := law_absolute_mass_bound hH G (fun g hg => (Finset.mem_filter.mp hg).2) + ν B (fun iω => hA iω.1 iω.2) p hp hpH + change (∑ g : G, M g ^ 2) ≤ _ at h + have hdef : lawDeficit ν B p = d := mixture_deficit w μ A p + have hmean : ν.expect (fun iω => (B iω).value) = + w.expect (fun j => (μ j).expect (fun ω => (A j ω).value)) := w.mixture_expect μ _ + rw [hdef, hmean] at h + change _ ≤ (η + Real.sqrt (2 * d)) ^ 2 + 4 * d at h + simpa only [C, Real.sq_sqrt (show 0 ≤ (η + Real.sqrt (2 * d)) ^ 2 + 4 * d by positivity)] using h + have hm0 : ∀ j g, 0 ≤ m j g := fun j g => (μ j).mean_nonneg (fun ω => abs_nonneg _) + have hM0 : ∀ g, 0 ≤ M g := fun g => ν.mean_nonneg (fun ω => abs_nonneg _) + have hmM : ∀ g, m i g ≤ (w.weight i)⁻¹ * M g := by + intro g + have he : M g = w.mean (fun j => m j g) := w.mixture_mean μ _ + have h := w.weight_mul_mean_le (fun j => m j g) (fun j => hm0 j g) i + rw [← he] at h + exact (le_inv_mul_iff₀ (hw i)).mpr h + have hm : Real.sqrt (∑ g : G, m i g ^ 2) ≤ (w.weight i)⁻¹ * C := by + apply (Real.sqrt_le_iff).mpr + refine ⟨mul_nonneg (inv_nonneg.mpr (hw i).le) (Real.sqrt_nonneg _), ?_⟩ + calc + (∑ g : G, m i g ^ 2) ≤ ∑ g : G, ((w.weight i)⁻¹ * M g) ^ 2 := by + apply Finset.sum_le_sum + intro g hg + exact (sq_le_sq₀ (hm0 i g) (mul_nonneg hi (hM0 g))).mpr (hmM g) + _ = (w.weight i)⁻¹ ^ 2 * ∑ g : G, M g ^ 2 := by simp only [mul_pow, Finset.mul_sum] + _ ≤ (w.weight i)⁻¹ ^ 2 * C ^ 2 := mul_le_mul_of_nonneg_left hM (sq_nonneg _) + _ = ((w.weight i)⁻¹ * C) ^ 2 := (mul_pow _ _ _).symm + have hrep : ‖tail H ((μ i).expect (fun ω => ((A i ω).family.replacement p.coeff).value))‖ ≤ + (w.weight i)⁻¹ * C := by + apply (show ‖tail H ((μ i).expect (fun ω => ((A i ω).family.replacement p.coeff).value))‖ ≤ + Real.sqrt (∑ g : G, m i g ^ 2) by + simpa only [one_smul] using norm_signed_replacement_le hH (μ i) (fun _ => 1) + (by simp) (A i) (hK i) p.coeff hpH).trans hm + have he : ‖tail H ((μ i).expect (fun ω => ((A i ω).error p.coeff).value))‖ ≤ + Real.sqrt (2 * lawDeficit (μ i) (A i) p) := by + simpa only [one_smul] using signed_law_error_le hH (μ i) (A i) (hA i) (fun _ => 1) (by simp) p hp + have hsplit : (μ i).expect (fun ω => (A i ω).value) = + (μ i).expect (fun ω => ((A i ω).family.replacement p.coeff).value) + + (μ i).expect (fun ω => ((A i ω).error p.coeff).value) := by + simp only [Representation.error_value, FiniteLaw.expect_sub] + abel + rw [hsplit] + change ‖tailLinear H (_ + _)‖ ≤ _ + rw [map_add] + exact (norm_add_le _ _).trans (add_le_add hrep he) + +end ConditionalLaws + +section WeightedCompleted +variable {V I : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] + [locallyFiniteOrderBotV : LocallyFiniteOrderBot V] [treeOrderV : TreeOrder V] [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] [Fintype I] + +theorem head_tail_commute (H K : Finset V) (z : FullDual V) : + head K (tail H z) = tail H (head K z) := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + apply dual_ext_coordinates + intro v + simp only [head_unitVector, tail_unitVector] + split_ifs <;> rfl + + + + +theorem weighted_tail_bound {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (w : FiniteLaw I) (hw : ∀ i, 0 < w.weight i) (z : I → FullDual V) + (hz : ∀ i, ‖z i‖ ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) + (hpH : p.coeff.support ⊆ H) (i : I) : + ‖tail H (z i)‖ ≤ (w.weight i)⁻¹ * Real.sqrt + ((‖tail H (w.expect z)‖ + Real.sqrt (2 * (1 - (w.expect z) (p : Primal V)))) ^ 2 + + 4 * (1 - (w.expect z) (p : Primal V))) + Real.sqrt (2 * (1 - z i (p : Primal V))) := by + classical + have hi : 0 ≤ (w.weight i)⁻¹ := inv_nonneg.mpr (hw i).le + apply dual_norm_le _ (by positivity) + intro u + let K := ancestralHull (H ∪ u.coeff.support) + have hK := ancestralHull_ancestral (H ∪ u.coeff.support) + have hHK : H ⊆ K := Finset.subset_union_left.trans (subset_ancestralHull _) + have huK : u.coeff.support ⊆ K := Finset.subset_union_right.trans (subset_ancestralHull _) + have hzi : ∀ j, ∃ μ : FiniteLaw (Option (LocalFamily K)), ∃ A : Option (LocalFamily K) → Representation V, + (∀ ω, (A ω).energy ≤ 1) ∧ (∀ ω S, S ∈ (A ω).family.sets → S ⊆ K) ∧ + μ.expect (fun ω => (A ω).value) = head K (z j) := by + intro j + simpa only [one_pow] using exists_atomic_law hK (head K (z j)) (head_head _ _) + (by norm_num : (0 : ℝ) < 1) ((norm_head_le hK _).trans (hz j)) + choose μ A hA hAK hmean using hzi + have hd : ∀ j, lawDeficit (μ j) (A j) p = 1 - z j (p : Primal V) := by + intro j + rw [lawDeficit, hmean, head_pairing_of_support K (z j) p (hpH.trans hHK)] + have hdmean : w.mean (fun j => lawDeficit (μ j) (A j) p) = + 1 - (w.expect z) (p : Primal V) := by + simp_rw [hd] + rw [w.mean_sub, w.mean_const, w.expect_apply] + have hmeanK : w.expect (fun j => (μ j).expect (fun ω => (A j ω).value)) = head K (w.expect z) := by + simp_rw [hmean] + exact w.expect_map (headLinear K) z + have hη : ‖tail H (head K (w.expect z))‖ ≤ ‖tail H (w.expect z)‖ := by + rw [← head_tail_commute] + exact norm_head_le hK _ + have hc := represented_weighted_tail hH w hw μ A hA hAK p hp hpH i + rw [hmean, hmeanK, hdmean, hd] at hc + have hc' : ‖tail H (head K (z i))‖ ≤ (w.weight i)⁻¹ * Real.sqrt + ((‖tail H (w.expect z)‖ + Real.sqrt (2 * (1 - (w.expect z) (p : Primal V)))) ^ 2 + + 4 * (1 - (w.expect z) (p : Primal V))) + Real.sqrt (2 * (1 - z i (p : Primal V))) := by + apply hc.trans + gcongr + rw [← tail_head_pairing H K (z i) u huK] + have hop := (tail H (head K (z i))).le_opNorm (u : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at hop + exact hop.trans (mul_le_mul_of_nonneg_right hc' (norm_nonneg _)) + +theorem weighted_deficits {H : Finset V} (w : FiniteLaw I) (hw : ∀ i, 0 < w.weight i) + (z : I → FullDual V) (hz : ∀ i, ‖z i‖ ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) : + (∀ i, 0 ≤ 1 - z i (p : Primal V)) ∧ + 1 - (w.expect z) (p : Primal V) = w.mean (fun i => 1 - z i (p : Primal V)) ∧ + ∀ i, 1 - z i (p : Primal V) ≤ (1 - (w.expect z) (p : Primal V)) / w.weight i := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := locallyFiniteOrderBotV + have _ := treeOrderV + have _ := intervalSegmentsV + have _ := H + have hδ : ∀ i, 0 ≤ 1 - z i (p : Primal V) := by + intro i + have hn := (z i).le_opNorm (p : Primal V) + rw [UniformSpace.Completion.norm_coe] at hn + have he : z i (p : Primal V) ≤ 1 := (le_abs_self _).trans (hn.trans + ((mul_le_of_le_one_left (norm_nonneg p) (hz i)).trans hp)) + linarith + have he : 1 - (w.expect z) (p : Primal V) = w.mean (fun i => 1 - z i (p : Primal V)) := by + rw [w.mean_sub, w.mean_const, w.expect_apply] + refine ⟨hδ, he, fun i => ?_⟩ + rw [he] + apply (le_div_iff₀ (hw i)).mpr + simpa only [mul_comm] using w.weight_mul_mean_le _ hδ i + +end WeightedCompleted + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Subspaces.lean b/lean/OAI/Analysis/SegmentLenses/Subspaces.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7db4e9426b7f42ac7c38194249bb3ef147ae8b7 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Subspaces.lean @@ -0,0 +1,243 @@ +import OAI.Analysis.SegmentLenses.Embeddings + +namespace OAI + +/-! +# Primal isometries and coordinate completions +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + +namespace SegmentEmbedding +variable {V W : Type*} [decidableEqV : DecidableEq V] [decidableEqW : DecidableEq W] [SegmentSystem V] [SegmentSystem W] + + +def testRestriction (e : SegmentEmbedding (V := V) (W := W)) : Test W →ₗ[ℝ] Test V where + toFun u := Test.ofFinsupp (u.coeff.comapDomain e.toEmbedding e.toEmbedding.injective.injOn) + map_add' u v := by apply Finsupp.ext; intro w; rfl + map_smul' c u := by apply Finsupp.ext; intro w; rfl + +@[simp] theorem testRestriction_apply (e : SegmentEmbedding (V := V) (W := W)) (u : Test W) (v : V) : + (e.testRestriction u).coeff v = u.coeff (e.toEmbedding v) := by + have _ := decidableEqV + have _ := decidableEqW + exact rfl + +@[simp] theorem testRestriction_testMap (e : SegmentEmbedding (V := V) (W := W)) (u : Test V) : + e.testRestriction (e.testMap u) = u := by + apply Finsupp.ext + intro v + exact e.testMap_apply u v + +theorem testMap_testRestriction (e : SegmentEmbedding (V := V) (W := W)) (u : Test W) + (hu : ∀ w, w ∉ Set.range e.toEmbedding → u.coeff w = 0) : + e.testMap (e.testRestriction u) = u := by + have _ := decidableEqV + have _ := decidableEqW + change Finsupp.embDomain e.toEmbedding (u.coeff.comapDomain e.toEmbedding _) = u.coeff + apply Finsupp.embDomain_comapDomain + intro w hw + by_contra hn + exact Finsupp.mem_support_iff.mp hw (hu w hn) + + + +theorem norm_testRestriction_le (e : SegmentEmbedding (V := V) (W := W)) (u : Test W) : + ‖e.testRestriction u‖ ≤ ‖u‖ := by + have _ := decidableEqV + have _ := decidableEqW + classical + change segmentSeminorm V (e.testRestriction u).coeff ≤ _ + rw [segmentSeminorm_apply] + apply ciSup_le + intro F + let pieces : F.sets → Finset W := fun S => S.val.map e.toEmbedding + have hp : ∀ S, pieces S = ∅ ∨ SegmentSystem.isSegment (pieces S) := + fun S => Or.inr (e.map_segment S.val (F.segment _ S.property)) + have hd : Pairwise fun S T => Disjoint (pieces S) (pieces T) := by + intro S T hST + apply Finset.disjoint_left.mpr + intro w hw hw' + obtain ⟨v,hv,rfl⟩ := Finset.mem_map.mp hw + obtain ⟨v',hv',he⟩ := Finset.mem_map.mp hw' + have he' := e.toEmbedding.injective he + subst v' + exact Finset.disjoint_left.mp (F.disjoint S.property T.property (fun h => hST (Subtype.ext h))) hv hv' + have h := indexed_test_bound u.coeff pieces hp hd + have he : F.seminorm (e.testRestriction u).coeff ^ 2 = ∑ S, (∑ w ∈ pieces S, u.coeff w)^2 := by + rw [F.seminorm_sq] + simp only [pieces, Finset.sum_map, testRestriction_apply] + rw [← he] at h + exact (sq_le_sq₀ (apply_nonneg _ _) (norm_nonneg u)).mp h + +def primalRestriction (e : SegmentEmbedding (V := V) (W := W)) : Primal W →L[ℝ] Primal V := + ((UniformSpace.Completion.toComplL : Test V →L[ℝ] Primal V).comp + (e.testRestriction.mkContinuous 1 (fun u => by simpa only [one_mul] using e.norm_testRestriction_le u))).extend + UniformSpace.Completion.toComplL + +@[simp] theorem primalRestriction_test (e : SegmentEmbedding (V := V) (W := W)) (u : Test W) : + e.primalRestriction (u : Primal W) = (e.testRestriction u : Primal V) := + ContinuousLinearMap.extend_eq _ UniformSpace.Completion.denseRange_coe + (UniformSpace.Completion.isUniformInducing_coe _) u + +@[simp] theorem primalRestriction_primalMap (e : SegmentEmbedding (V := V) (W := W)) (x : Primal V) : + e.primalRestriction (e.primalMap x) = x := by + refine UniformSpace.Completion.induction_on x + (isClosed_eq (e.primalRestriction.continuous.comp e.primalMap.continuous) continuous_id) ?_ + intro u + rw [e.primalMap_test, e.primalRestriction_test, e.testRestriction_testMap] + +theorem norm_primalRestriction_le (e : SegmentEmbedding (V := V) (W := W)) (x : Primal W) : + ‖e.primalRestriction x‖ ≤ ‖x‖ := by + refine UniformSpace.Completion.induction_on x + (isClosed_le e.primalRestriction.continuous.norm continuous_norm) ?_ + intro u + rw [e.primalRestriction_test, UniformSpace.Completion.norm_coe, UniformSpace.Completion.norm_coe] + exact e.norm_testRestriction_le u + +end SegmentEmbedding + +section CompletionIsometries +variable {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] + [NormedSpace ℝ E] [NormedSpace ℝ F] + + + +def completionIsometry (e : E ≃ₗᵢ[ℝ] F) : + UniformSpace.Completion E ≃ₗᵢ[ℝ] UniformSpace.Completion F := + e.toLinearEquiv.extendOfIsometry + (UniformSpace.Completion.toComplL : E →L[ℝ] UniformSpace.Completion E).toLinearMap + (UniformSpace.Completion.toComplL : F →L[ℝ] UniformSpace.Completion F).toLinearMap + UniformSpace.Completion.denseRange_coe UniformSpace.Completion.denseRange_coe + (fun x => by + change ‖(e x : UniformSpace.Completion F)‖ = ‖(x : UniformSpace.Completion E)‖ + rw [UniformSpace.Completion.norm_coe, UniformSpace.Completion.norm_coe, e.norm_map]) + +@[simp] theorem completionIsometry_coe (e : E ≃ₗᵢ[ℝ] F) (x : E) : + completionIsometry e (x : UniformSpace.Completion E) = (e x : UniformSpace.Completion F) := by + change completionIsometry e ((UniformSpace.Completion.toComplL : E →L[ℝ] UniformSpace.Completion E) x) = _ + unfold completionIsometry + exact LinearEquiv.extendOfIsometry_eq _ _ _ _ _ _ x + +end CompletionIsometries + + +section ClosureCompletion +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [completeSpaceE : CompleteSpace E] + + +theorem closureInclusion_dense (S : Submodule ℝ E) : + DenseRange (Submodule.inclusion S.le_topologicalClosure) := by + have _ := completeSpaceE + rw [Metric.denseRange_iff] + intro x ε hε + obtain ⟨y,hy,hd⟩ := Metric.mem_closure_iff.mp x.property ε hε + refine ⟨⟨y,hy⟩, ?_⟩ + exact hd + + + +def completionClosureEquiv (S : Submodule ℝ E) : + UniformSpace.Completion S ≃ₗᵢ[ℝ] S.topologicalClosure := by + letI : CompleteSpace S.topologicalClosure := S.isClosed_topologicalClosure.completeSpace_coe + exact (LinearEquiv.refl ℝ S).extendOfIsometry + (UniformSpace.Completion.toComplL : S →L[ℝ] UniformSpace.Completion S).toLinearMap + (Submodule.inclusion S.le_topologicalClosure) + UniformSpace.Completion.denseRange_coe (closureInclusion_dense S) + (fun x => by + change ‖x‖ = ‖(x : UniformSpace.Completion S)‖ + rw [UniformSpace.Completion.norm_coe]) + +@[simp] theorem completionClosureEquiv_coe (S : Submodule ℝ E) (x : S) : + completionClosureEquiv S (x : UniformSpace.Completion S) = Submodule.inclusion S.le_topologicalClosure x := by + let : CompleteSpace S.topologicalClosure := S.isClosed_topologicalClosure.completeSpace_coe + change completionClosureEquiv S ((UniformSpace.Completion.toComplL : S →L[ℝ] UniformSpace.Completion S) x) = _ + unfold completionClosureEquiv + exact LinearEquiv.extendOfIsometry_eq _ _ _ _ _ _ x + +end ClosureCompletion + +section CoordinateCompletion +variable {V : Type*} [SegmentSystem V] + + + +abbrev FiniteCoordinates (V : Type*) [SegmentSystem V] := + ↥(Submodule.span ℝ (Set.range (coordinate (V := V)))) + + + + +local instance : UniformSpace (FiniteCoordinates V) := + (inferInstance : NormedAddCommGroup (FiniteCoordinates V)).toUniformSpace +local instance : AddCommGroup (FiniteCoordinates V) := + (inferInstance : NormedAddCommGroup (FiniteCoordinates V)).toAddCommGroup +local instance : Module ℝ (FiniteCoordinates V) := + (inferInstance : NormedSpace ℝ (FiniteCoordinates V)).toModule + + +def coordinateCompletionEquiv : UniformSpace.Completion (FiniteCoordinates V) ≃ₗᵢ[ℝ] CoordinatePredual V := + completionClosureEquiv (Submodule.span ℝ (Set.range (coordinate (V := V)))) + +@[simp] theorem coordinateCompletionEquiv_coe (x : FiniteCoordinates V) : + (coordinateCompletionEquiv (x : UniformSpace.Completion (FiniteCoordinates V))).val = x.val := by + exact congrArg (fun y : (Submodule.span ℝ (Set.range (coordinate (V := V)))).topologicalClosure => + (y : FullDual V)) (completionClosureEquiv_coe + (Submodule.span ℝ (Set.range (coordinate (V := V)))) x) + + + +theorem polar_norm (z : FullDual V) : + ‖z‖ = ⨆ u : {u : Test V // ‖u‖ ≤ 1}, |z (u.val : Primal V)| := by + let : Nonempty {u : Test V // ‖u‖ ≤ 1} := ⟨⟨0,by simp⟩⟩ + let S : Set ℝ := Set.range (fun u : {u : Test V // ‖u‖ ≤ 1} => |z (u.val : Primal V)|) + have hb : BddAbove S := by + refine ⟨‖z‖, ?_⟩ + rintro _ ⟨u,rfl⟩ + have h := z.le_opNorm (u.val : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at h + exact h.trans (mul_le_of_le_one_right (norm_nonneg z) u.property) + have h0 : (0:ℝ) ≤ ⨆ u : {u : Test V // ‖u‖ ≤ 1}, |z (u.val : Primal V)| := by + have h := le_ciSup hb (⟨0, by simp⟩ : {u : Test V // ‖u‖ ≤ 1}) + change |z (0 : Primal V)| ≤ _ at h + simpa only [map_zero,abs_zero] using h + apply le_antisymm + · apply dual_norm_le z h0 + intro u + by_cases hu : u = 0 + · subst u + change |z (0 : Primal V)| ≤ _ + simp + have hn : 0 < ‖u‖ := norm_pos_iff.mpr hu + let v : {u : Test V // ‖u‖ ≤ 1} := ⟨‖u‖⁻¹ • u, by + rw [norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hn), inv_mul_cancel₀ hn.ne']⟩ + have h := le_ciSup hb v + have he : |z (v.val : Primal V)| = ‖u‖⁻¹ * |z (u : Primal V)| := by + change |z ((‖u‖⁻¹ • u : Test V) : Primal V)| = _ + rw [UniformSpace.Completion.coe_smul, map_smul, smul_eq_mul, abs_mul, abs_of_pos (inv_pos.mpr hn)] + rw [he] at h + have hm := mul_le_mul_of_nonneg_left h hn.le + field_simp at hm + simpa only [mul_comm] using hm + · apply ciSup_le + intro u + have h := z.le_opNorm (u.val : Primal V) + rw [Real.norm_eq_abs, UniformSpace.Completion.norm_coe] at h + exact h.trans (mul_le_of_le_one_right (norm_nonneg z) u.property) + +end CoordinateCompletion + + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/Subtrees.lean b/lean/OAI/Analysis/SegmentLenses/Subtrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b56608c5994183e70f1781b99cfdb0cd14b9610 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/Subtrees.lean @@ -0,0 +1,211 @@ +import OAI.Analysis.SegmentLenses.Canonical + +namespace OAI + +/-! +# Subtree projections and exact weighted radii +-/ + +noncomputable section + +open scoped BigOperators ENNReal +open Finset + +namespace SegmentLenses + +attribute [local instance] instDecidableEqForestVertex + + +namespace SegmentEmbedding +variable {V W : Type*} [DecidableEq V] [DecidableEq W] [SegmentSystem V] [SegmentSystem W] + + + + +theorem primal_range_coordinateClosure (e : SegmentEmbedding (V := V) (W := W)) : + e.primalIsometry.range = + (Submodule.span ℝ (Set.range (fun v => unitVector (e.toEmbedding v)))).topologicalClosure := by + let S := Submodule.span ℝ (Set.range (fun v => unitVector (e.toEmbedding v))) + apply le_antisymm + · rintro _ ⟨x,rfl⟩ + change e.primalMap x ∈ S.topologicalClosure + refine UniformSpace.Completion.induction_on x + (S.isClosed_topologicalClosure.preimage e.primalMap.continuous) ?_ + intro u + rw [test_as_sum u] + simp only [map_sum,map_smul] + apply S.topologicalClosure.sum_mem + intro v hv + rw [e.primalMap_unitVector] + exact S.topologicalClosure.smul_mem _ + (S.le_topologicalClosure (Submodule.subset_span ⟨v,rfl⟩)) + · apply S.topologicalClosure_minimal + · apply Submodule.span_le.mpr + rintro _ ⟨v,rfl⟩ + exact ⟨unitVector v,e.primalMap_unitVector v⟩ + · exact e.primalIsometry.isometry.isClosedEmbedding.isClosed_range + + + +def primalProjection (e : SegmentEmbedding (V := V) (W := W)) : Primal W →L[ℝ] Primal W := + e.primalMap.comp e.primalRestriction + +@[simp] theorem primalProjection_apply (e : SegmentEmbedding (V := V) (W := W)) (x : Primal W) : + e.primalProjection x = e.primalMap (e.primalRestriction x) := rfl + +theorem norm_primalProjection_le (e : SegmentEmbedding (V := V) (W := W)) (x : Primal W) : + ‖e.primalProjection x‖ ≤ ‖x‖ := by + rw [e.primalProjection_apply,e.norm_primalMap] + exact e.norm_primalRestriction_le x + +@[simp] theorem primalProjection_idempotent (e : SegmentEmbedding (V := V) (W := W)) (x : Primal W) : + e.primalProjection (e.primalProjection x) = e.primalProjection x := by + simp only [e.primalProjection_apply,e.primalRestriction_primalMap] + +@[simp] theorem primalProjection_unitVector (e : SegmentEmbedding (V := V) (W := W)) (v : V) : + e.primalProjection (unitVector (e.toEmbedding v)) = unitVector (e.toEmbedding v) := by + rw [← e.primalMap_unitVector,e.primalProjection_apply,e.primalRestriction_primalMap] + +@[simp] theorem primalProjection_unitVector_outside (e : SegmentEmbedding (V := V) (W := W)) + (w : W) (hw : w ∉ Set.range e.toEmbedding) : e.primalProjection (unitVector w) = 0 := by + have hr : e.testRestriction (Test.ofFinsupp (Finsupp.single w 1)) = 0 := by + apply Finsupp.ext + intro v + change (Finsupp.single w (1:ℝ)) (e.toEmbedding v) = 0 + have hn : w ≠ e.toEmbedding v := fun he => hw ⟨v,he.symm⟩ + simp [hn] + rw [e.primalProjection_apply,unitVector,e.primalRestriction_test,hr] + simp + + +def dualRestriction (e : SegmentEmbedding (V := V) (W := W)) (z : FullDual W) : FullDual V := + z.comp e.primalMap + + + +def dualProjection (e : SegmentEmbedding (V := V) (W := W)) (z : FullDual W) : FullDual W := + z.comp e.primalProjection + +theorem norm_dualProjection_le (e : SegmentEmbedding (V := V) (W := W)) (z : FullDual W) : + ‖e.dualProjection z‖ ≤ ‖z‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro x + change ‖z (e.primalProjection x)‖ ≤ _ + exact (z.le_opNorm _).trans (mul_le_mul_of_nonneg_left (e.norm_primalProjection_le x) (norm_nonneg _)) + + + +theorem norm_dualRestriction_eq (e : SegmentEmbedding (V := V) (W := W)) (z : FullDual W) : + ‖e.dualRestriction z‖ = ‖e.dualProjection z‖ := by + apply le_antisymm + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro x + have he : e.dualRestriction z x = e.dualProjection z (e.primalMap x) := by + change z (e.primalMap x) = z (e.primalMap (e.primalRestriction (e.primalMap x))) + rw [e.primalRestriction_primalMap] + rw [he] + exact ((e.dualProjection z).le_opNorm _).trans_eq (by rw [e.norm_primalMap]) + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro x + change ‖(e.dualRestriction z) (e.primalRestriction x)‖ ≤ _ + exact ((e.dualRestriction z).le_opNorm _).trans + (mul_le_mul_of_nonneg_left (e.norm_primalRestriction_le x) (norm_nonneg _)) + +@[simp] theorem dualProjection_coordinate (e : SegmentEmbedding (V := V) (W := W)) + (z : FullDual W) (v : V) : e.dualProjection z (unitVector (e.toEmbedding v)) = z (unitVector (e.toEmbedding v)) := by + change z (e.primalProjection (unitVector _)) = _ + rw [e.primalProjection_unitVector] + +@[simp] theorem dualProjection_coordinate_outside (e : SegmentEmbedding (V := V) (W := W)) + (z : FullDual W) (w : W) (hw : w ∉ Set.range e.toEmbedding) : e.dualProjection z (unitVector w) = 0 := by + change z (e.primalProjection (unitVector w)) = 0 + rw [e.primalProjection_unitVector_outside w hw,map_zero] + +end SegmentEmbedding + + + +section ExactWeightedStatement +variable {V I : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] + [LocallyFiniteOrderBot V] [TreeOrder V] [SegmentSystem V] [IntervalSegments V] [Fintype I] + + + +theorem weighted_stability {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (w : FiniteLaw I) (hw : ∀ i, 0 < w.weight i) (z : I → FullDual V) + (hz : ∀ i, ‖z i‖ ≤ 1) (p : Test V) (hp : ‖p‖ ≤ 1) + (hpH : p.coeff.support ⊆ H) : + let δ := 1-(w.expect z) (p : Primal V) + let δi := fun i => 1-z i (p : Primal V) + let η := ‖tail H (w.expect z)‖ + δ = w.mean δi ∧ 0 ≤ δ ∧ ∀ i, + 0 ≤ δi i ∧ δi i ≤ δ / w.weight i ∧ + ‖tail H (z i)‖ ≤ (w.weight i)⁻¹ * Real.sqrt ((η+Real.sqrt (2*δ))^2+4*δ) + + Real.sqrt (2*δi i) := by + dsimp only + have hd := weighted_deficits (H := H) w hw z hz p hp + refine ⟨hd.2.1,?_,fun i => ⟨hd.1 i,hd.2.2 i,weighted_tail_bound hH w hw z hz p hp hpH i⟩⟩ + rw [hd.2.1] + exact w.mean_nonneg hd.1 + +end ExactWeightedStatement + +section ExactObstructionRadii +variable {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] + +private theorem safety_radius_le {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + 0 < a/(2*b) ∧ a/(2*b) ≤ a/b := by + have hb : 0 < b := ha.trans_le hab + constructor + · positivity + · apply div_le_div_of_nonneg_left ha.le hb + linarith + + +theorem infinite_obstruction_radii (e : BInfinite ≃L[ℝ] D) {a b : ℝ} + (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : BInfinite, a*‖x‖ ≤ ‖e x‖) + (hupper : ∀ x : BInfinite, ‖e x‖ ≤ b*‖x‖) : + oneSidedModulus D (a/b) = 0 ∧ oneSidedModulus D (a/(2*b)) = 0 := by + have hs := safety_radius_le ha hab + exact ⟨infinite_equivalent_modulus_zero e ha hab hlower hupper + (div_pos ha (ha.trans_le hab)) le_rfl, + infinite_equivalent_modulus_zero e ha hab hlower hupper hs.1 hs.2⟩ + + +theorem forest_obstruction_radii (e : X ≃L[ℝ] D) {a b : ℝ} + (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : X, a*‖x‖ ≤ ‖e x‖) (hupper : ∀ x : X, ‖e x‖ ≤ b*‖x‖) : + oneSidedModulus D (a/b) = 0 ∧ oneSidedModulus D (a/(2*b)) = 0 := by + have hs := safety_radius_le ha hab + exact ⟨forest_equivalent_modulus_zero e ha hab hlower hupper + (div_pos ha (ha.trans_le hab)) le_rfl, + forest_equivalent_modulus_zero e ha hab hlower hupper hs.1 hs.2⟩ + +end ExactObstructionRadii + +namespace IndexedForest +variable {I : Type*} [DecidableEq I] {height : I → ℕ} + + +theorem unbounded_obstruction_radii (hunbounded : ∀ n : ℕ, ∃ i : I, n ≤ height i) + {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] (e : X height ≃L[ℝ] D) + {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hlower : ∀ x : X height, a*‖x‖ ≤ ‖e x‖) (hupper : ∀ x : X height, ‖e x‖ ≤ b*‖x‖) : + oneSidedModulus D (a/b) = 0 ∧ oneSidedModulus D (a/(2*b)) = 0 := by + have hs := safety_radius_le ha hab + exact ⟨unbounded_equivalent_modulus_zero hunbounded e ha hab hlower hupper + (div_pos ha (ha.trans_le hab)) le_rfl, + unbounded_equivalent_modulus_zero hunbounded e ha hab hlower hupper hs.1 hs.2⟩ + +end IndexedForest + + + + +end SegmentLenses + + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/TailBudget.lean b/lean/OAI/Analysis/SegmentLenses/TailBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..b282b9f28340ec259f9e27c3699dbbb3c2c38ba8 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/TailBudget.lean @@ -0,0 +1,292 @@ +import OAI.Analysis.SegmentLenses.GateRecovery + +namespace OAI + +/-! +# Signed-product recovery and the finite midpoint tail bound +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + +section SignedRecovery +open scoped Classical +variable {V Ω : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [treeOrderV : TreeOrder V] + [SegmentSystem V] [intervalSegmentsV : IntervalSegments V] [Fintype Ω] + +theorem tail_expect_smul (H : Finset V) (μ : FiniteLaw Ω) (σ : Ω → ℝ) (f : Ω → FullDual V) : + tail H (μ.expect (fun ω => σ ω • f ω)) = μ.expect (fun ω => σ ω • tail H (f ω)) := by + have _ := decidableEqV + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + simpa only [map_smul, tailLinear_apply] using + (μ.expect_map (tailLinear H) (fun ω => σ ω • f ω)).symm + +theorem norm_signed_tail_expect_le {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) (f : Ω → FullDual V) : + ‖tail H (μ.expect (fun ω => σ ω • f ω))‖ ≤ μ.mean (fun ω => ‖f ω‖) := by + rw [tail_expect_smul] + apply (μ.norm_expect_le _).trans + apply μ.mean_mono + intro ω + rw [norm_smul, Real.norm_eq_abs] + exact (mul_le_of_le_one_left (norm_nonneg _) (hσ ω)).trans (norm_tail_le hH (f ω)) + +theorem signed_replacement_recovery {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (σ : Ω → ℝ) (A : Ω → Representation V) + (hK : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K) + (p : V →₀ ℝ) (hp : p.support ⊆ H) : + tail H (μ.expect (fun ω => σ ω • ((A ω).family.replacement p).value)) = + ∑ g : K.filter (Gate H), μ.expect (fun ω => + (σ ω * (A ω).family.boundary p g.val) • segmentFunctional ((A ω).family.gateTail H g.val)) := by + rw [tail_expect_smul] + calc + μ.expect (fun ω => σ ω • tail H ((A ω).family.replacement p).value) = + μ.expect (fun ω => ∑ g : K.filter (Gate H), + (σ ω * (A ω).family.boundary p g.val) • segmentFunctional ((A ω).family.gateTail H g.val)) := by + congr 1 + funext ω + rw [(A ω).family.tail_replacement hH p hp (hK ω)] + simp only [Finset.smul_sum, smul_smul] + _ = _ := μ.expect_sum _ + +theorem norm_signed_replacement_le {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) (A : Ω → Representation V) + (hK : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K) + (p : V →₀ ℝ) (hp : p.support ⊆ H) : + ‖tail H (μ.expect (fun ω => σ ω • ((A ω).family.replacement p).value))‖ ≤ + Real.sqrt (∑ g : K.filter (Gate H), μ.mean (fun ω => |(A ω).family.boundary p g.val|) ^ 2) := by + rw [signed_replacement_recovery hH μ σ A hK p hp] + apply cone_reconstruction (K.filter (Gate H)) (fun g hg => (Finset.mem_filter.mp hg).2) μ σ hσ + · intro g ω + exact (A ω).family.gateTail_segment hH g.val + · intro g ω v hv + exact (A ω).family.gateTail_cone (Finset.mem_filter.mp g.property).2 hv + +end SignedRecovery + +section JointLawBound +open scoped Classical +variable {V Ω : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] [Fintype Ω] + + + +theorem represented_joint_bound {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (μ : FiniteLaw Ω) (σ : Ω → ℝ) (hσ : ∀ ω, |σ ω| ≤ 1) + (A : Ω → Representation V) (hK : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K) + (x y : FullDual V) (hx : head H x = x) + (hmean : μ.expect (fun ω => (A ω).value) = x) + (hsigned : μ.expect (fun ω => σ ω • (A ω).value) = y) + (q : Test V) (hq : q.coeff.support ⊆ H) (r R : ℝ) + (hqr : ‖q‖ = r) (hxq : x (q : Primal V) = r ^ 2) + (hR : ∀ ω, (A ω).energy ≤ R ^ 2) : + ‖tail H y‖ ≤ 2 * Real.sqrt (R ^ 2 - r ^ 2) := by + classical + let G := K.filter (Gate H) + have hG : ∀ g ∈ G, Gate H g := fun g hg => (Finset.mem_filter.mp hg).2 + let err := fun ω => (A ω).error q.coeff + let slack := fun ω => r ^ 2 - (A ω).family.seminorm q.coeff ^ 2 + let η := μ.mean (fun ω => (err ω).energy) + let θ := μ.mean slack + have hnormq : segmentSeminorm V q.coeff = r := hqr + have herr : ∀ ω, 0 ≤ (err ω).energy := fun ω => (err ω).energy_nonneg + have hslack : ∀ ω, 0 ≤ slack ω := by + intro ω + have hf := le_segmentSeminorm (A ω).family q.coeff + rw [hnormq] at hf + have hn := apply_nonneg ((A ω).family.seminorm) q.coeff + dsimp [slack] + nlinarith + have hη : 0 ≤ η := μ.mean_nonneg herr + have hθ : 0 ≤ θ := μ.mean_nonneg hslack + have hpair : μ.mean (fun ω => ∑ S : (A ω).family.sets, + (A ω).coeff S * (∑ v ∈ S.val, q.coeff v)) = r ^ 2 := by + simp_rw [← Representation.apply_test] + rw [← μ.expect_apply (fun ω => (A ω).value) (q : Primal V), hmean, hxq] + have hidentity : η + θ = μ.mean (fun ω => (A ω).energy) - r ^ 2 := by + change μ.mean (fun ω => (err ω).energy) + μ.mean slack = _ + rw [← μ.mean_add] + have he : (fun ω => (err ω).energy + slack ω) = fun ω => + (A ω).energy - 2 * (∑ S : (A ω).family.sets, (A ω).coeff S * ∑ v ∈ S.val, q.coeff v) + r ^ 2 := by + funext ω + exact (A ω).error_slack_identity q.coeff r + rw [he, μ.mean_add, μ.mean_sub, μ.mean_mul, μ.mean_const, hpair] + ring + have hbudget : η + θ ≤ R ^ 2 - r ^ 2 := by + rw [hidentity] + apply sub_le_sub_right + exact (μ.mean_mono hR).trans_eq (μ.mean_const (R ^ 2)) + let b : Ω → G → ℝ := fun ω g => (A ω).family.boundary q.coeff g.val + let W : Ω → G → ℝ := fun ω g => (err ω).value (unitVector g.val) + have hzero : ∀ g, μ.mean (fun ω => b ω g + W ω g) = 0 := by + intro g + have he : (fun ω => b ω g + W ω g) = fun ω => (A ω).value (unitVector g.val) := by + funext ω + dsimp [b, W, err] + rw [Representation.error_value, _root_.sub_apply, SegmentFamily.replacement_gate] + ring + rw [he, ← μ.expect_apply (fun ω => (A ω).value) (unitVector g.val), hmean] + rw [← hx, head_unitVector, ite_eq_right (hG _ g.property).1] + have hW : ∀ ω, (∑ g : G, W ω g ^ 2) ≤ (err ω).energy := + fun ω => (err ω).gate_energy_le G hG + have hcross : ∀ ω ω', (∑ g : G, (|b ω g * b ω' g| - b ω g * b ω' g)) ≤ + slack ω + slack ω' := by + intro ω ω' + simpa only [b, slack, hnormq] using + opposite_crossing (A ω).family (A ω').family hH q.coeff hq G hG + have hmass : (∑ g : G, μ.mean (fun ω => |b ω g|) ^ 2) ≤ η + 2 * θ := + μ.joint_mass_bound b W (fun ω => (err ω).energy) slack hzero hW hcross + have he_bound : ‖tail H (μ.expect (fun ω => σ ω • (err ω).value))‖ ≤ Real.sqrt η := by + calc + ‖tail H (μ.expect (fun ω => σ ω • (err ω).value))‖ ≤ + μ.mean (fun ω => ‖(err ω).value‖) := norm_signed_tail_expect_le hH μ σ hσ _ + _ ≤ μ.mean (fun ω => Real.sqrt (err ω).energy) := μ.mean_mono (fun ω => (err ω).norm_le) + _ ≤ Real.sqrt η := μ.mean_sqrt_le _ herr + have hr_bound : ‖tail H (μ.expect (fun ω => σ ω • ((A ω).family.replacement q.coeff).value))‖ ≤ + Real.sqrt (η + 2 * θ) := by + exact (norm_signed_replacement_le hH μ σ hσ A hK q.coeff hq).trans + (Real.sqrt_le_sqrt hmass) + have hy : y = μ.expect (fun ω => σ ω • (err ω).value) + + μ.expect (fun ω => σ ω • ((A ω).family.replacement q.coeff).value) := by + rw [← hsigned, ← μ.expect_add] + congr 1 + funext ω + rw [← smul_add] + dsimp [err] + rw [Representation.error_value, sub_add_cancel] + have hytail : tail H y = tail H (μ.expect (fun ω => σ ω • (err ω).value)) + + tail H (μ.expect (fun ω => σ ω • ((A ω).family.replacement q.coeff).value)) := by + rw [hy] + exact (tailLinear H).map_add _ _ + apply joint_budget_tail hη hθ hbudget + rw [hytail] + exact (norm_add_le _ _).trans (add_le_add he_bound hr_bound) + +end JointLawBound + +section HeadSupport +variable {V : Type*} [DecidableEq V] [SegmentSystem V] + +theorem dual_ext_coordinates {x y : FullDual V} + (h : ∀ v, x (unitVector v) = y (unitVector v)) : x = y := by + apply dual_ext_test + intro u + simp only [dual_apply_test, h] + +theorem head_eq_iff (H : Finset V) (x : FullDual V) : + head H x = x ↔ ∀ v ∉ H, x (unitVector v) = 0 := by + constructor + · intro hx v hv + rw [← hx, head_unitVector, ite_eq_right hv] + · intro hx + apply dual_ext_coordinates + intro v + rw [head_unitVector] + by_cases hv : v ∈ H + · simp [hv] + · simp [hv, hx v hv] + +theorem head_eq_of_subset {H K : Finset V} (hHK : H ⊆ K) + (x : FullDual V) (hx : head H x = x) : head K x = x := by + apply (head_eq_iff K x).mpr + intro v hv + exact (head_eq_iff H x).mp hx v (fun hvH => hv (hHK hvH)) + +end HeadSupport + + +theorem norm_center_le {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (x y : E) (R : ℝ) (hp : ‖x + y‖ ≤ R) (hm : ‖x - y‖ ≤ R) : ‖x‖ ≤ R := by + have he : x = (1 / 2 : ℝ) • ((x + y) + (x - y)) := by module + calc + ‖x‖ = ‖(1 / 2 : ℝ) • ((x + y) + (x - y))‖ := congrArg norm he + _ = (1 / 2 : ℝ) * ‖(x + y) + (x - y)‖ := by rw [norm_smul]; norm_num + _ ≤ (1 / 2 : ℝ) * (‖x + y‖ + ‖x - y‖) := + mul_le_mul_of_nonneg_left (norm_add_le _ _) (by norm_num) + _ ≤ R := by linarith + +section FiniteMain +variable {V : Type*} [DecidableEq V] [PartialOrder V] [LocallyFiniteOrder V] [TreeOrder V] + [SegmentSystem V] [IntervalSegments V] + + + +theorem finite_main_tail {H K : Finset V} (hH : Ancestral (· ≤ ·) H) + (hK : Ancestral (· ≤ ·) K) (hHK : H ⊆ K) + (x y : FullDual V) (hx : head H x = x) (hy : head K y = y) + (R : ℝ) (hR : 0 ≤ R) (hp : ‖x + y‖ ≤ R) (hm : ‖x - y‖ ≤ R) : + ‖tail H y‖ ≤ 2 * Real.sqrt (R ^ 2 - ‖x‖ ^ 2) := by + classical + by_cases hx0 : x = 0 + · subst x + simp only [zero_add] at hp + simpa only [norm_zero, zero_pow (by decide : 2 ≠ 0), sub_zero, Real.sqrt_sq hR] using + (norm_tail_le hH y).trans (hp.trans (by linarith : R ≤ 2 * R)) + have hc := norm_center_le x y R hp hm + have hRp : 0 < R := (norm_pos_iff.mpr hx0).trans_le hc + have hxK := head_eq_of_subset hHK x hx + have hpK : head K (x + y) = x + y := by + change headLinear K (x + y) = _ + rw [map_add, headLinear_apply, headLinear_apply, hxK, hy] + have hmK : head K (x - y) = x - y := by + change headLinear K (x - y) = _ + rw [map_sub, headLinear_apply, headLinear_apply, hxK, hy] + obtain ⟨μp, Ap, hpE, hpSupp, hpMean⟩ := exists_atomic_law hK (x + y) hpK hRp hp + obtain ⟨μm, Am, hmE, hmSupp, hmMean⟩ := exists_atomic_law hK (x - y) hmK hRp hm + let μ := μp.pooled μm + let A := Sum.elim Ap Am + let σ : Option (LocalFamily K) ⊕ Option (LocalFamily K) → ℝ := Sum.elim (fun _ => 1) (fun _ => -1) + have hσ : ∀ ω, |σ ω| ≤ 1 := by intro ω; cases ω <;> norm_num [σ] + have henergy : ∀ ω, (A ω).energy ≤ R ^ 2 := by + intro ω + cases ω with + | inl ω => exact hpE ω + | inr ω => exact hmE ω + have hsupp : ∀ ω S, S ∈ (A ω).family.sets → S ⊆ K := by + intro ω + cases ω with + | inl ω => exact hpSupp ω + | inr ω => exact hmSupp ω + have hmean : μ.expect (fun ω => (A ω).value) = x := by + have he : (fun ω => (A ω).value) = Sum.elim (fun ω => (Ap ω).value) (fun ω => (Am ω).value) := by + funext ω; cases ω <;> rfl + rw [he] + change (μp.pooled μm).expect (Sum.elim (fun ω => (Ap ω).value) (fun ω => (Am ω).value)) = x + rw [FiniteLaw.pooled_expect, hpMean, hmMean] + module + have hsigned : μ.expect (fun ω => σ ω • (A ω).value) = y := by + have he : (fun ω => σ ω • (A ω).value) = + Sum.elim (fun ω => (1 : ℝ) • (Ap ω).value) (fun ω => (-1 : ℝ) • (Am ω).value) := by + funext ω; cases ω <;> rfl + rw [he] + change (μp.pooled μm).expect _ = y + rw [FiniteLaw.pooled_expect, μp.expect_smul, μm.expect_smul, hpMean, hmMean] + module + obtain ⟨p, hpSupport, hpn, hpx⟩ := exists_norming_head hH x hx hx0 + let q : Test V := ‖x‖ • p + have hqSupport : q.coeff.support ⊆ H := + Finsupp.support_smul.trans hpSupport + have hqn : ‖q‖ = ‖x‖ := by + change ‖‖x‖ • p‖ = ‖x‖ + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (norm_nonneg _), hpn, mul_one] + have hxq : x (q : Primal V) = ‖x‖ ^ 2 := by + change x ((‖x‖ • p : Test V) : Primal V) = _ + rw [UniformSpace.Completion.coe_smul, map_smul, smul_eq_mul, hpx, sq] + exact represented_joint_bound hH μ σ hσ A hsupp x y hx hmean hsigned q hqSupport + ‖x‖ R hqn hxq henergy + +end FiniteMain + + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SegmentLenses/TreeGeometry.lean b/lean/OAI/Analysis/SegmentLenses/TreeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..1101fb77cf70479a3642be0e409d8bf666b81368 --- /dev/null +++ b/lean/OAI/Analysis/SegmentLenses/TreeGeometry.lean @@ -0,0 +1,512 @@ +import OAI.Analysis.SegmentLenses.Basic + +namespace OAI + +/-! +# Ancestry, segment splitting, and opposite crossings +-/ + +noncomputable section + +open scoped BigOperators +open Finset + +namespace SegmentLenses + + + + + +class TreeOrder (V : Type*) [PartialOrder V] : Prop where + lower_chain : ∀ {a b c : V}, a ≤ c → b ≤ c → a ≤ b ∨ b ≤ a + + +class IntervalSegments (V : Type*) [PartialOrder V] [SegmentSystem V] : Prop where + iff_interval : ∀ S : Finset V, SegmentSystem.isSegment S ↔ IsInterval (· ≤ ·) S + +instance infiniteOrder : PartialOrder InfiniteVertex where + le := List.IsPrefix + lt := fun a b => a.IsPrefix b ∧ ¬b.IsPrefix a + le_refl := List.prefix_refl + le_trans := fun _ _ _ => List.IsPrefix.trans + le_antisymm := fun _ _ => prefix_antisymm + +instance infiniteTreeOrder : TreeOrder InfiniteVertex where + lower_chain := List.prefix_or_prefix_of_prefix + +instance infiniteIntervalSegments : IntervalSegments InfiniteVertex where + iff_interval _ := Iff.rfl + +instance infiniteLocallyFinite : LocallyFiniteOrder InfiniteVertex := by + classical + exact LocallyFiniteOrder.ofIcc InfiniteVertex + (fun a b => b.inits.toFinset.filter (fun v => a.IsPrefix v)) + (fun a b v => by simp [List.mem_inits, and_comm, LE.le]) + +instance forestOrder : PartialOrder ForestVertex where + le := ForestAncestor + lt := fun a b => ForestAncestor a b ∧ ¬ForestAncestor b a + le_refl := forestAncestor_refl + le_trans := fun _ _ _ hab hbc => ⟨hab.1.trans hbc.1, hab.2.trans hbc.2⟩ + le_antisymm := fun _ _ => forestAncestor_antisymm + +instance forestTreeOrder : TreeOrder ForestVertex where + lower_chain := by + intro a b c hac hbc + rcases List.prefix_or_prefix_of_prefix hac.2 hbc.2 with hab | hba + · exact Or.inl ⟨hac.1.trans hbc.1.symm, hab⟩ + · exact Or.inr ⟨hbc.1.trans hac.1.symm, hba⟩ + +instance forestIntervalSegments : IntervalSegments ForestVertex where + iff_interval _ := Iff.rfl + +instance forestLocallyFinite : LocallyFiniteOrder ForestVertex := + LocallyFiniteOrder.ofFiniteIcc (by + intro a b + apply Set.Finite.of_injOn (f := fun v : ForestVertex => v.val.2) + (t := {w : List ℕ | w.IsPrefix b.val.2}) + · intro v hv + exact hv.2.2 + · intro v hv w hw he + apply Subtype.ext + exact Prod.ext (hv.2.1.trans hw.2.1.symm) he + · exact b.val.2.inits.finite_toSet.subset (by + intro w hw + exact (List.mem_inits w b.val.2).mpr hw)) + +section TreeGeometry +variable {V : Type*} [decidableEqV : DecidableEq V] [partialOrderV : PartialOrder V] [locallyFiniteOrderV : LocallyFiniteOrder V] [treeOrderV : TreeOrder V] + [segmentSystemV : SegmentSystem V] [intervalSegmentsV : IntervalSegments V] + +theorem interval_isSegment {a b : V} (hab : a ≤ b) : + SegmentSystem.isSegment (Finset.Icc a b) := by + have _ := decidableEqV + have _ := treeOrderV + apply (IntervalSegments.iff_interval _).mpr + exact ⟨a, b, hab, fun v => Finset.mem_Icc⟩ + + + +theorem halfOpen_isSegment (a c : V) : + Finset.Ico a c = ∅ ∨ SegmentSystem.isSegment (Finset.Ico a c) := by + classical + by_cases hac : a < c + · right + have hne : (Finset.Ico a c).Nonempty := ⟨a, Finset.mem_Ico.mpr ⟨le_rfl, hac⟩⟩ + obtain ⟨z, hz⟩ := Finset.exists_maximal hne + have hzac := Finset.mem_Ico.mp hz.1 + have hmax : ∀ v ∈ Finset.Ico a c, v ≤ z := by + intro v hv + have hvac := Finset.mem_Ico.mp hv + rcases TreeOrder.lower_chain hvac.2.le hzac.2.le with hvz | hzv + · exact hvz + · exact hz.2 hv hzv + have he : Finset.Ico a c = Finset.Icc a z := by + ext v + constructor + · intro hv + exact Finset.mem_Icc.mpr ⟨(Finset.mem_Ico.mp hv).1, hmax v hv⟩ + · intro hv + have hh := Finset.mem_Icc.mp hv + exact Finset.mem_Ico.mpr ⟨hh.1, lt_of_le_of_lt hh.2 hzac.2⟩ + rw [he] + exact interval_isSegment hzac.1 + · left + apply Finset.eq_empty_iff_forall_notMem.mpr + intro v hv + have hh := Finset.mem_Ico.mp hv + exact hac (lt_of_le_of_lt hh.1 hh.2) + + +theorem split_interval {a c b : V} (hac : a ≤ c) (hcb : c ≤ b) : + Finset.Ico a c ∪ Finset.Icc c b = Finset.Icc a b := by + have _ := segmentSystemV + have _ := intervalSegmentsV + classical + ext v + simp only [Finset.mem_union, Finset.mem_Ico, Finset.mem_Icc] + constructor + · rintro (⟨hav, hvc⟩ | ⟨hcv, hvb⟩) + · exact ⟨hav, le_trans hvc.le hcb⟩ + · exact ⟨le_trans hac hcv, hvb⟩ + · rintro ⟨hav, hvb⟩ + rcases TreeOrder.lower_chain hvb hcb with hvc | hcv + · rcases lt_or_eq_of_le hvc with hlt | rfl + · exact Or.inl ⟨hav, hlt⟩ + · exact Or.inr ⟨le_rfl, hcb⟩ + · exact Or.inr ⟨hcv, hvb⟩ + +theorem split_disjoint (a c b : V) : Disjoint (Finset.Ico a c) (Finset.Icc c b) := by + have _ := decidableEqV + have _ := treeOrderV + have _ := segmentSystemV + have _ := intervalSegmentsV + refine Finset.disjoint_left.mpr ?_ + intro v hv hv' + exact (not_lt_of_ge (Finset.mem_Icc.mp hv').1) (Finset.mem_Ico.mp hv).2 + + +theorem head_zero_above {H : Finset V} (hH : Ancestral (· ≤ ·) H) + {p : V →₀ ℝ} (hp : p.support ⊆ H) {g v : V} (hg : g ∉ H) (hgv : g ≤ v) : + p v = 0 := by + have _ := decidableEqV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := segmentSystemV + have _ := intervalSegmentsV + apply Finsupp.notMem_support_iff.mp + intro hv + exact hg (hH (hp hv) hgv) + + + +theorem segment_sum_eq_head {H : Finset V} (hH : Ancestral (· ≤ ·) H) + {p : V →₀ ℝ} (hp : p.support ⊆ H) {a g b : V} + (hag : a ≤ g) (hgb : g ≤ b) (hg : g ∉ H) : + (∑ v ∈ Finset.Icc a b, p v) = ∑ v ∈ Finset.Ico a g, p v := by + classical + rw [← split_interval hag hgb, Finset.sum_union (split_disjoint _ _ _)] + have hz : (∑ v ∈ Finset.Icc g b, p v) = 0 := by + apply Finset.sum_eq_zero + intro v hv + exact head_zero_above hH hp hg (Finset.mem_Icc.mp hv).1 + rw [hz, add_zero] + + + +theorem split_suffix_sum {H : Finset V} (hH : Ancestral (· ≤ ·) H) + {p : V →₀ ℝ} (hp : p.support ⊆ H) {c g b b' : V} + (hcg : c ≤ g) (hgb : g ≤ b) (hgb' : g ≤ b') (hg : g ∉ H) : + (∑ v ∈ Finset.Icc c b, p v) = ∑ v ∈ Finset.Icc c b', p v := by + rw [segment_sum_eq_head hH hp hcg hgb hg, + segment_sum_eq_head hH hp hcg hgb' hg] + + + +theorem opposite_split_gain {H : Finset V} (hH : Ancestral (· ≤ ·) H) + {p : V →₀ ℝ} (hp : p.support ⊆ H) {a c g b b' : V} + (hac : a ≤ c) (hcg : c ≤ g) (hgb : g ≤ b) (hgb' : g ≤ b') + (hg : g ∉ H) + (hop : (∑ v ∈ Finset.Icc a b, p v) * (∑ v ∈ Finset.Icc c b', p v) < 0) : + 2 * |(∑ v ∈ Finset.Icc a b, p v) * (∑ v ∈ Finset.Icc c b', p v)| ≤ + (∑ v ∈ Finset.Ico a c, p v) ^ 2 + (∑ v ∈ Finset.Icc c b, p v) ^ 2 - + (∑ v ∈ Finset.Icc a b, p v) ^ 2 := by + classical + have he := split_suffix_sum hH hp hcg hgb hgb' hg + have hsum : (∑ v ∈ Finset.Icc a b, p v) = + (∑ v ∈ Finset.Ico a c, p v) + (∑ v ∈ Finset.Icc c b, p v) := by + rw [← split_interval hac (le_trans hcg hgb), + Finset.sum_union (split_disjoint _ _ _)] + rw [abs_of_neg hop, ← he, hsum] + nlinarith [sq_nonneg (∑ v ∈ Finset.Icc c b, p v)] + + + +theorem selected_split_budget {ι Γ : Type*} [Fintype ι] [Fintype Γ] + (p : V →₀ ℝ) (a b : ι → V) (hab : ∀ i, a i ≤ b i) + (hd : Pairwise fun i j => Disjoint (Finset.Icc (a i) (b i)) (Finset.Icc (a j) (b j))) + (select : Γ → ι) (hinj : Function.Injective select) (cut : Γ → V) + (hcut : ∀ g, a (select g) ≤ cut g ∧ cut g ≤ b (select g)) + (cost : Γ → ℝ) (hcost : ∀ g, 0 ≤ cost g) + (hgain : ∀ g, cost g ≤ + (∑ v ∈ Finset.Ico (a (select g)) (cut g), p v) ^ 2 + + (∑ v ∈ Finset.Icc (cut g) (b (select g)), p v) ^ 2 - + (∑ v ∈ Finset.Icc (a (select g)) (b (select g)), p v) ^ 2) : + ∑ g, cost g ≤ segmentSeminorm V p ^ 2 - + ∑ i, (∑ v ∈ Finset.Icc (a i) (b i), p v) ^ 2 := by + classical + let c := Function.extend select cut a + have hc : ∀ i, a i ≤ c i ∧ c i ≤ b i := by + intro i + by_cases hi : ∃ g, select g = i + · obtain ⟨g, rfl⟩ := hi + rw [show c (select g) = cut g from hinj.extend_apply cut a g] + exact hcut g + · rw [show c i = a i from Function.extend_apply' cut a i hi] + exact ⟨le_rfl, hab i⟩ + let gain : ι → ℝ := fun i => + (∑ v ∈ Finset.Ico (a i) (c i), p v) ^ 2 + + (∑ v ∈ Finset.Icc (c i) (b i), p v) ^ 2 - + (∑ v ∈ Finset.Icc (a i) (b i), p v) ^ 2 + have hgselect : ∀ g, cost g ≤ gain (select g) := by + intro g + dsimp [gain] + rw [show c (select g) = cut g from hinj.extend_apply cut a g] + exact hgain g + have hgn : ∀ i, 0 ≤ gain i := by + intro i + by_cases hi : ∃ g, select g = i + · obtain ⟨g, rfl⟩ := hi + exact (hcost g).trans (hgselect g) + · dsimp [gain] + rw [show c i = a i from Function.extend_apply' cut a i hi] + simp + have hs : ∑ g, cost g ≤ ∑ i, gain i := by + calc + ∑ g, cost g ≤ ∑ g, gain (select g) := Finset.sum_le_sum fun g _ => hgselect g + _ = ∑ i ∈ Finset.univ.image select, gain i := + (Finset.sum_image hinj.injOn).symm + _ ≤ ∑ i, gain i := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun i _ _ => hgn i) + have he := refinement_test_bound p + (fun i => Finset.Icc (a i) (b i)) + (fun i => Finset.Ico (a i) (c i)) (fun i => Finset.Icc (c i) (b i)) hd + (fun i => by + intro v hv + have hh := Finset.mem_Ico.mp hv + exact Finset.mem_Icc.mpr ⟨hh.1, le_trans hh.2.le (hc i).2⟩) + (fun i => by + intro v hv + have hh := Finset.mem_Icc.mp hv + exact Finset.mem_Icc.mpr ⟨le_trans (hc i).1 hh.1, hh.2⟩) + (fun i => split_disjoint _ _ _) + (fun i => halfOpen_isSegment _ _) + (fun i => Or.inr (interval_isSegment (hc i).2)) + have hsum : (∑ i, gain i) = + (∑ i, ((∑ v ∈ Finset.Ico (a i) (c i), p v) ^ 2 + + (∑ v ∈ Finset.Icc (c i) (b i), p v) ^ 2)) - + ∑ i, (∑ v ∈ Finset.Icc (a i) (b i), p v) ^ 2 := by + simp [gain, Finset.sum_sub_distrib] + rw [hsum] at hs + linarith + + + + +theorem matched_opposite_crossing {ι κ Γ : Type*} [Fintype ι] [Fintype κ] [Fintype Γ] + {H : Finset V} (hH : Ancestral (· ≤ ·) H) + (p : V →₀ ℝ) (hp : p.support ⊆ H) + (a b : ι → V) (a' b' : κ → V) + (hab : ∀ i, a i ≤ b i) (hab' : ∀ j, a' j ≤ b' j) + (hd : Pairwise fun i j => Disjoint (Finset.Icc (a i) (b i)) (Finset.Icc (a j) (b j))) + (hd' : Pairwise fun i j => Disjoint (Finset.Icc (a' i) (b' i)) (Finset.Icc (a' j) (b' j))) + (gate : Γ → V) (left : Γ → ι) (right : Γ → κ) + (hl : Function.Injective left) (hr : Function.Injective right) + (hgate : ∀ g, gate g ∉ H) + (hmem : ∀ g, a (left g) ≤ gate g ∧ gate g ≤ b (left g)) + (hmem' : ∀ g, a' (right g) ≤ gate g ∧ gate g ≤ b' (right g)) + (hop : ∀ g, (∑ v ∈ Finset.Icc (a (left g)) (b (left g)), p v) * + (∑ v ∈ Finset.Icc (a' (right g)) (b' (right g)), p v) < 0) : + 2 * ∑ g, |(∑ v ∈ Finset.Icc (a (left g)) (b (left g)), p v) * + (∑ v ∈ Finset.Icc (a' (right g)) (b' (right g)), p v)| ≤ + (segmentSeminorm V p ^ 2 - ∑ i, (∑ v ∈ Finset.Icc (a i) (b i), p v) ^ 2) + + (segmentSeminorm V p ^ 2 - ∑ j, (∑ v ∈ Finset.Icc (a' j) (b' j), p v) ^ 2) := by + classical + let longer : Γ → Prop := fun g => a (left g) ≤ a' (right g) + let cost : Γ → ℝ := fun g => 2 * + |(∑ v ∈ Finset.Icc (a (left g)) (b (left g)), p v) * + (∑ v ∈ Finset.Icc (a' (right g)) (b' (right g)), p v)| + have hc : ∀ g, 0 ≤ cost g := fun g => mul_nonneg (by norm_num) (abs_nonneg _) + have h₁ := selected_split_budget p a b hab hd + (fun g : {g // longer g} => left g.val) (hl.comp Subtype.val_injective) + (fun g => a' (right g.val)) + (fun g => ⟨g.property, le_trans (hmem' g.val).1 (hmem g.val).2⟩) + (fun g => cost g.val) (fun g => hc g.val) + (fun g => opposite_split_gain hH hp g.property (hmem' g.val).1 + (hmem g.val).2 (hmem' g.val).2 (hgate g.val) (hop g.val)) + have h₂ := selected_split_budget p a' b' hab' hd' + (fun g : {g // ¬longer g} => right g.val) (hr.comp Subtype.val_injective) + (fun g => a (left g.val)) + (fun g => ⟨(TreeOrder.lower_chain (hmem g.val).1 (hmem' g.val).1).resolve_left g.property, + le_trans (hmem g.val).1 (hmem' g.val).2⟩) + (fun g => cost g.val) (fun g => hc g.val) (fun g => by + have hstart := (TreeOrder.lower_chain (hmem g.val).1 (hmem' g.val).1).resolve_left g.property + have ho : (∑ v ∈ Finset.Icc (a' (right g.val)) (b' (right g.val)), p v) * + (∑ v ∈ Finset.Icc (a (left g.val)) (b (left g.val)), p v) < 0 := by + simpa [mul_comm] using hop g.val + simpa only [cost, mul_comm] using opposite_split_gain hH hp hstart + (hmem g.val).1 (hmem' g.val).2 (hmem g.val).2 (hgate g.val) ho) + have hs := Fintype.sum_subtype_add_sum_subtype longer cost + have he : (∑ g, cost g) = + 2 * ∑ g, |(∑ v ∈ Finset.Icc (a (left g)) (b (left g)), p v) * + (∑ v ∈ Finset.Icc (a' (right g)) (b' (right g)), p v)| := by + simp [cost, Finset.mul_sum] + linarith + + + +def Gate (H : Finset V) (g : V) : Prop := + g ∉ H ∧ ∀ v, v < g → v ∈ H + +theorem gates_incomparable {H : Finset V} {g g' : V} + (hg : Gate H g) (hg' : Gate H g') (h : g ≤ g') : g = g' := by + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := segmentSystemV + have _ := intervalSegmentsV + by_contra hne + exact hg.1 (hg'.2 g (lt_of_le_of_ne h hne)) + +theorem gate_unique_in_interval {H : Finset V} {g g' a b : V} + (hg : Gate H g) (hg' : Gate H g') + (hm : g ∈ Finset.Icc a b) (hm' : g' ∈ Finset.Icc a b) : g = g' := by + rcases TreeOrder.lower_chain (Finset.mem_Icc.mp hm).2 (Finset.mem_Icc.mp hm').2 with h | h + · exact gates_incomparable hg hg' h + · exact (gates_incomparable hg' hg h).symm + +namespace SegmentFamily + + +def presentation (F : SegmentFamily V) (S : F.sets) : + {q : V × V // q.1 ≤ q.2 ∧ S.val = Finset.Icc q.1 q.2} := by + classical + have hs := (IntervalSegments.iff_interval S.val).mp (F.segment S.val S.property) + apply Classical.choice + obtain ⟨a, b, hab, hs⟩ := hs + exact ⟨⟨(a, b), hab, Finset.ext (fun v => by simpa only [Finset.mem_Icc] using hs v)⟩⟩ + +def first (F : SegmentFamily V) (S : F.sets) : V := (F.presentation S).val.1 + +def last (F : SegmentFamily V) (S : F.sets) : V := (F.presentation S).val.2 + +theorem first_le_last (F : SegmentFamily V) (S : F.sets) : F.first S ≤ F.last S := by + have _ := decidableEqV + have _ := treeOrderV + exact + (F.presentation S).property.1 + +theorem repr (F : SegmentFamily V) (S : F.sets) : + S.val = Finset.Icc (F.first S) (F.last S) := by + have _ := decidableEqV + have _ := treeOrderV + exact (F.presentation S).property.2 + +theorem repr_disjoint (F : SegmentFamily V) : + Pairwise fun S T : F.sets => + Disjoint (Finset.Icc (F.first S) (F.last S)) (Finset.Icc (F.first T) (F.last T)) := by + intro S T hne + rw [← F.repr S, ← F.repr T] + exact F.disjoint S.property T.property (fun h => hne (Subtype.ext h)) + + + +def boundary (F : SegmentFamily V) (p : V →₀ ℝ) (g : V) : ℝ := + ∑ S ∈ F.sets, if g ∈ S then ∑ v ∈ S, p v else 0 + +theorem boundary_of_mem (F : SegmentFamily V) (p : V →₀ ℝ) + {g : V} (S : F.sets) (hg : g ∈ S.val) : + F.boundary p g = ∑ v ∈ S.val, p v := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + classical + unfold boundary + rw [Finset.sum_eq_single S.val] + · simp [hg] + · intro T hT hne + have hn : g ∉ T := fun h => + Finset.disjoint_left.mp (F.disjoint hT S.property hne) h hg + simp [hn] + · intro hn + exact False.elim (hn S.property) + +theorem boundary_nonzero (F : SegmentFamily V) (p : V →₀ ℝ) + {g : V} (hne : F.boundary p g ≠ 0) : ∃ S : F.sets, g ∈ S.val := by + have _ := partialOrderV + have _ := locallyFiniteOrderV + have _ := treeOrderV + have _ := intervalSegmentsV + classical + by_contra h + apply hne + apply Finset.sum_eq_zero + intro S hS + have hn : g ∉ S := fun hs => h ⟨⟨S, hS⟩, hs⟩ + simp [hn] + +theorem gate_unique {H : Finset V} (F : SegmentFamily V) (S : F.sets) + {g g' : V} (hg : Gate H g) (hg' : Gate H g') (hm : g ∈ S.val) (hm' : g' ∈ S.val) : + g = g' := by + rw [F.repr S] at hm hm' + exact gate_unique_in_interval hg hg' hm hm' + +end SegmentFamily + + + +theorem opposite_crossing (F F' : SegmentFamily V) {H : Finset V} + (hH : Ancestral (· ≤ ·) H) (p : V →₀ ℝ) (hp : p.support ⊆ H) + (G : Finset V) (hG : ∀ g ∈ G, Gate H g) : + (∑ g : G, (|F.boundary p g.val * F'.boundary p g.val| - + F.boundary p g.val * F'.boundary p g.val)) ≤ + (segmentSeminorm V p ^ 2 - F.seminorm p ^ 2) + + (segmentSeminorm V p ^ 2 - F'.seminorm p ^ 2) := by + classical + let opposite : G → Prop := fun g => F.boundary p g.val * F'.boundary p g.val < 0 + let Γ := {g : G // opposite g} + have hleft : ∀ g : Γ, ∃ S : F.sets, g.val.val ∈ S.val := by + intro g + apply F.boundary_nonzero p + intro hz + have ho := g.property + change F.boundary p g.val.val * F'.boundary p g.val.val < 0 at ho + rw [hz, zero_mul] at ho + exact lt_irrefl _ ho + have hright : ∀ g : Γ, ∃ S : F'.sets, g.val.val ∈ S.val := by + intro g + apply F'.boundary_nonzero p + intro hz + have ho := g.property + change F.boundary p g.val.val * F'.boundary p g.val.val < 0 at ho + rw [hz, mul_zero] at ho + exact lt_irrefl _ ho + let left : Γ → F.sets := fun g => Classical.choose (hleft g) + let right : Γ → F'.sets := fun g => Classical.choose (hright g) + have hlmem : ∀ g : Γ, g.val.val ∈ (left g).val := fun g => Classical.choose_spec (hleft g) + have hrmem : ∀ g : Γ, g.val.val ∈ (right g).val := fun g => Classical.choose_spec (hright g) + have hl : Function.Injective left := by + intro g g' he + apply Subtype.ext + apply Subtype.ext + have hg' := hlmem g' + rw [← he] at hg' + exact F.gate_unique (left g) (hG _ g.val.property) (hG _ g'.val.property) (hlmem g) hg' + have hr : Function.Injective right := by + intro g g' he + apply Subtype.ext + apply Subtype.ext + have hg' := hrmem g' + rw [← he] at hg' + exact F'.gate_unique (right g) (hG _ g.val.property) (hG _ g'.val.property) (hrmem g) hg' + have heL : ∀ g : Γ, (∑ v ∈ Finset.Icc (F.first (left g)) (F.last (left g)), p v) = + F.boundary p g.val.val := by + intro g + rw [← F.repr (left g)] + exact (F.boundary_of_mem p (left g) (hlmem g)).symm + have heR : ∀ g : Γ, (∑ v ∈ Finset.Icc (F'.first (right g)) (F'.last (right g)), p v) = + F'.boundary p g.val.val := by + intro g + rw [← F'.repr (right g)] + exact (F'.boundary_of_mem p (right g) (hrmem g)).symm + have h := matched_opposite_crossing hH p hp F.first F.last F'.first F'.last + F.first_le_last F'.first_le_last F.repr_disjoint F'.repr_disjoint + (fun g : Γ => g.val.val) left right hl hr + (fun g => (hG _ g.val.property).1) + (fun g => Finset.mem_Icc.mp ((F.repr (left g)) ▸ hlmem g)) + (fun g => Finset.mem_Icc.mp ((F'.repr (right g)) ▸ hrmem g)) + (fun g => by rw [heL, heR]; exact g.property) + simp_rw [heL, heR, ← F.repr, ← F'.repr] at h + rw [← F.seminorm_sq p, ← F'.seminorm_sq p] at h + have hsum : (∑ g : G, (|F.boundary p g.val * F'.boundary p g.val| - + F.boundary p g.val * F'.boundary p g.val)) = + 2 * ∑ g : Γ, |F.boundary p g.val.val * F'.boundary p g.val.val| := by + have he : ∀ z : ℝ, |z| - z = if z < 0 then 2 * |z| else 0 := by + intro z + by_cases hz : z < 0 + · simp [hz, abs_of_neg hz]; ring + · simp [hz, abs_of_nonneg (le_of_not_gt hz)] + simp_rw [he] + rw [← Finset.sum_filter] + rw [Finset.sum_subtype (p := opposite) _ (fun g => by simp [opposite])] + rw [← Finset.mul_sum] + rw [hsum] + exact h + +end TreeGeometry + +end SegmentLenses + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/AdjointSurjectivity.lean b/lean/OAI/Analysis/SeparableQuotients/AdjointSurjectivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..c557208cb8a77620200c51db19a4bfee798b208c --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/AdjointSurjectivity.lean @@ -0,0 +1,171 @@ +import OAI.Analysis.SeparableQuotients.QuotientPerturbation + +namespace OAI + +namespace SeparableQuotient +open Set Metric +open scoped Topology + +universe u v + +section RealAdjoint +variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] +variable {F : Type v} [NormedAddCommGroup F] [NormedSpace ℝ F] + +/-- Hahn–Banach ball inclusion with a quantitative lower bound. -/ +theorem ball_image_closure_of_adjoint_bound + (T : E →L[ℝ] F) (c : ℝ) (_hc : 0 < c) + (hT : ∀ g : StrongDual ℝ F, c * ‖g‖ ≤ ‖g.comp T‖) : + closedBall (0 : F) c ⊆ closure (T '' closedBall (0 : E) 1) := by + intro y hy + simp only [mem_closedBall, dist_zero_right] at hy + by_contra hn + have hconv : Convex ℝ (closure (T '' closedBall (0 : E) 1)) := + ((convex_closedBall (0 : E) 1).linear_image T.toLinearMap).closure + obtain ⟨g, a, hga, hay⟩ := geometric_hahn_banach_closed_point hconv isClosed_closure hn + have ha : 0 < a := by + have := hga (T 0) (subset_closure ⟨0, by simp, rfl⟩) + simpa using this + have hnorm : ‖g.comp T‖ ≤ a := by + apply ContinuousLinearMap.opNorm_le_of_unit_norm ha.le + intro x hx + have hx' : x ∈ closedBall (0 : E) 1 := by simp [mem_closedBall, hx] + have hnx' : -x ∈ closedBall (0 : E) 1 := by simp [mem_closedBall, hx] + have hp := hga (T x) (subset_closure ⟨x, hx', rfl⟩) + have hm := hga (T (-x)) (subset_closure ⟨-x, hnx', rfl⟩) + simp only [map_neg] at hm + change |g (T x)| ≤ a + exact abs_le.mpr ⟨by linarith, hp.le⟩ + have hgy : g y ≤ ‖g‖ * c := + (le_abs_self _).trans ((g.le_opNorm y).trans + (mul_le_mul_of_nonneg_left hy (norm_nonneg g))) + have hb := hT g + nlinarith + +/-- Approximate lifting with a quantitative norm bound. -/ +theorem approximate_lift_of_adjoint_bound + (T : E →L[ℝ] F) (c : ℝ) (hc : 0 < c) + (hT : ∀ g : StrongDual ℝ F, c * ‖g‖ ≤ ‖g.comp T‖) (y : F) : + ∃ x : E, ‖y - T x‖ ≤ (1 / 2 : ℝ) * ‖y‖ ∧ ‖x‖ ≤ c⁻¹ * ‖y‖ := by + by_cases hy : y = 0 + · subst y + exact ⟨0, by simp, by simp⟩ + have hn : 0 < ‖y‖ := norm_pos_iff.mpr hy + have hmem : (c / ‖y‖) • y ∈ closedBall (0 : F) c := by + simp only [mem_closedBall, dist_zero_right, norm_smul, Real.norm_eq_abs, + abs_of_pos (div_pos hc hn)] + exact le_of_eq (div_mul_cancel₀ c (ne_of_gt hn)) + have hcl := ball_image_closure_of_adjoint_bound T c hc hT hmem + obtain ⟨w, ⟨z, hz, rfl⟩, hw⟩ := Metric.mem_closure_iff.mp hcl (c / 2) (by positivity) + refine ⟨(‖y‖ / c) • z, ?_, ?_⟩ + · have heq : y - T ((‖y‖ / c) • z) = + (‖y‖ / c) • ((c / ‖y‖) • y - T z) := by + rw [smul_sub, smul_smul, map_smul] + have : ‖y‖ / c * (c / ‖y‖) = 1 := by field_simp + rw [this, one_smul] + rw [heq, norm_smul, Real.norm_eq_abs, abs_of_pos (div_pos hn hc)] + rw [dist_eq_norm] at hw + calc + ‖y‖ / c * ‖(c / ‖y‖) • y - T z‖ ≤ ‖y‖ / c * (c / 2) := + mul_le_mul_of_nonneg_left hw.le (div_pos hn hc).le + _ = (1 / 2 : ℝ) * ‖y‖ := by field_simp + · simp only [mem_closedBall, dist_zero_right] at hz + rw [norm_smul, Real.norm_eq_abs, abs_of_pos (div_pos hn hc)] + calc + ‖y‖ / c * ‖z‖ ≤ ‖y‖ / c * 1 := mul_le_mul_of_nonneg_left hz (div_pos hn hc).le + _ = c⁻¹ * ‖y‖ := by ring + +/-- The elementary completion argument, with no open-mapping assumption. -/ +theorem exact_lift_of_approximate [CompleteSpace E] + (T : E →L[ℝ] F) (C : ℝ) (hC : 0 ≤ C) + (ha : ∀ y : F, ∃ x : E, ‖y - T x‖ ≤ (1 / 2 : ℝ) * ‖y‖ ∧ ‖x‖ ≤ C * ‖y‖) + (y : F) : ∃ x : E, T x = y ∧ ‖x‖ ≤ 2 * C * ‖y‖ := by + classical + choose g hg using ha + let h (z : F) := z - T (g z) + have hle : ∀ z, ‖h z‖ ≤ (1 / 2 : ℝ) * ‖z‖ := fun z => (hg z).1 + have hnle : ∀ n : ℕ, ‖h^[n] y‖ ≤ (1 / 2 : ℝ) ^ n * ‖y‖ := by + intro n + induction n with + | zero => simp + | succ n ih => + rw [Function.iterate_succ'] + apply (hle _).trans + rw [pow_succ', mul_assoc] + gcongr + let u (n : ℕ) := g (h^[n] y) + have ule : ∀ n, ‖u n‖ ≤ (1 / 2 : ℝ) ^ n * (C * ‖y‖) := by + intro n + apply (hg _).2.trans + calc + C * ‖h^[n] y‖ ≤ C * ((1 / 2 : ℝ) ^ n * ‖y‖) := by gcongr; exact hnle n + _ = (1 / 2 : ℝ) ^ n * (C * ‖y‖) := by ring + have sNu : Summable (fun n => ‖u n‖) := by + refine .of_nonneg_of_le (fun n => norm_nonneg _) ule ?_ + exact Summable.mul_right _ summable_geometric_two + have su : Summable u := sNu.of_norm + have xineq : ‖∑' n, u n‖ ≤ 2 * C * ‖y‖ := by + calc + ‖∑' n, u n‖ ≤ ∑' n, ‖u n‖ := norm_tsum_le_tsum_norm sNu + _ ≤ ∑' n, (1 / 2 : ℝ) ^ n * (C * ‖y‖) := + sNu.tsum_le_tsum ule (Summable.mul_right _ summable_geometric_two) + _ = (∑' n, (1 / 2 : ℝ) ^ n) * (C * ‖y‖) := tsum_mul_right + _ = 2 * C * ‖y‖ := by rw [tsum_geometric_two, mul_assoc] + have fsumeq : ∀ n : ℕ, T (∑ i ∈ Finset.range n, u i) = y - h^[n] y := by + intro n + induction n with + | zero => simp + | succ n ih => + rw [Finset.sum_range_succ, T.map_add, ih, Function.iterate_succ_apply', sub_add] + have L₁ : Filter.Tendsto (fun n => T (∑ i ∈ Finset.range n, u i)) + Filter.atTop (𝓝 (T (∑' n, u n))) := + (T.continuous.tendsto _).comp su.hasSum.tendsto_sum_nat + simp only [fsumeq] at L₁ + have L₂ : Filter.Tendsto (fun n => y - h^[n] y) Filter.atTop (𝓝 (y - 0)) := by + refine tendsto_const_nhds.sub ?_ + rw [tendsto_iff_norm_sub_tendsto_zero] + simp only [sub_zero] + refine squeeze_zero (fun _ => norm_nonneg _) hnle ?_ + rw [← zero_mul ‖y‖] + exact (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 1 / 2) + (by norm_num)).mul tendsto_const_nhds + exact ⟨∑' n, u n, by simpa using tendsto_nhds_unique L₁ L₂, xineq⟩ + +/-- Adjoint lower bounds force surjectivity. -/ +theorem surjective_of_adjoint_bound [CompleteSpace E] + (T : E →L[ℝ] F) (c : ℝ) (hc : 0 < c) + (hT : ∀ g : StrongDual ℝ F, c * ‖g‖ ≤ ‖g.comp T‖) : + Function.Surjective T := by + intro y + obtain ⟨x, hx, _⟩ := exact_lift_of_approximate T c⁻¹ (inv_nonneg.mpr hc.le) + (approximate_lift_of_adjoint_bound T c hc hT) y + exact ⟨x, hx⟩ + +end RealAdjoint +section RCLikeAdjoint +variable {𝕜 : Type*} [RCLike 𝕜] +variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [CompleteSpace E] +variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] + +/-- The surjectivity test over either original scalar field. -/ +theorem surjective_of_adjoint_bound_rclike + (T : E →L[𝕜] F) (c : ℝ) (hc : 0 < c) + (hT : ∀ g : StrongDual 𝕜 F, c * ‖g‖ ≤ ‖g.comp T‖) : + Function.Surjective T := by + let : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E + let : NormedSpace ℝ F := NormedSpace.restrictScalars ℝ 𝕜 F + have hb : ∀ g : StrongDual ℝ F, c * ‖g‖ ≤ ‖g.comp (T.restrictScalars ℝ)‖ := by + intro g + have heq : StrongDual.extendRCLike (g.comp (T.restrictScalars ℝ)) = + (g.extendRCLike : StrongDual 𝕜 F).comp T := by + ext x + simp [StrongDual.extendRCLike_apply] + have h := hT g.extendRCLike + rw [StrongDual.norm_extendRCLike, ← heq, StrongDual.norm_extendRCLike] at h + exact h + exact surjective_of_adjoint_bound (T.restrictScalars ℝ) c hc hb + +end RCLikeAdjoint +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/BlockApproximation.lean b/lean/OAI/Analysis/SeparableQuotients/BlockApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3619c2c869f4fab92518fa87811a2cec8659e2e --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/BlockApproximation.lean @@ -0,0 +1,335 @@ +import OAI.Analysis.SeparableQuotients.BranchReduction + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Singular +open Set +lemma exists_unit {𝕜 Y : Type*} [RCLike 𝕜] [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] + (hI : ¬ FiniteDimensional 𝕜 Y) : ∃ x : Y, ‖x‖ = 1 := by + let : Nontrivial Y := not_subsingleton_iff_nontrivial.mp (by + intro hs + let : Subsingleton Y := hs + exact hI inferInstance) + obtain ⟨x,hx⟩ := exists_ne (0 : Y) + refine ⟨(↑‖x‖ : 𝕜)⁻¹ • x,?_⟩ + simp only [norm_smul,norm_inv,RCLike.norm_ofReal,abs_of_nonneg (norm_nonneg x), + inv_mul_cancel₀ (norm_ne_zero_iff.mpr hx)] +end SeparableQuotient.Singular + +namespace SeparableQuotient.ActualSpace +open Norming Singular Set +open scoped Classical Topology + +lemma familyP_initial (γ : Cut) (f : Family) (x : E) : + initialP γ (familyP γ f x) = familyP γ f x := by + cases f with + | mixed => exact initialP_initialP le_rfl x + | pure k => + change initialP γ (colorP k (initialP γ x)) = colorP k (initialP γ x) + rw [initialP_colorP,initialP_initialP le_rfl] + +lemma familyP_color (γ : Cut) (k : ℕ) (x : E) : + colorP k (familyP γ (.pure k) x) = familyP γ (.pure k) x := + colorP_colorP k _ + +variable {F : Submodule ℝ E} (R : BranchReduction F) + +lemma BranchReduction.initial_fixed (x : R.H) : initialP R.cut (x : E) = x := by + simpa only [R.lift] using familyP_initial R.cut R.family (R.U x) + +lemma BranchReduction.color_fixed (k : ℕ) (hk : R.family = .pure k) (x : R.H) : + colorP k (x : E) = x := by + have hl : familyP R.cut (.pure k) (R.U x) = x := by simpa only [hk] using R.lift x + simpa only [hl] using familyP_color R.cut k (R.U x) + +lemma BranchReduction.coordinate_zero_of_cut (x : R.H) (a : Γ) (ha : ¬ (a : Cut) < R.cut) : + coordinate a (x : E) = 0 := by + have h := congrArg (coordinate a) (R.initial_fixed x) + simpa only [coordinate_initialP,ha,ite_false,eq_comm] using h + +lemma BranchReduction.coordinate_zero_of_color (k : ℕ) (hk : R.family = .pure k) + (x : R.H) (a : Γ) (ha : Colors.color a ≠ k) : coordinate a (x : E) = 0 := by + have h := congrArg (coordinate a) (R.color_fixed k hk x) + simpa only [coordinate_colorP,ha,ite_false,eq_comm] using h + +lemma BranchReduction.cut_nonempty : ∃ a : Γ, (a : Cut) < R.cut := by + obtain ⟨x,hx⟩ := Singular.exists_unit R.infinite + have hn : (x : E) ≠ 0 := by + intro hh + have hh0 : ‖x‖ = 0 := by + change ‖(x : E)‖ = 0 + rw [hh,norm_zero] + linarith + have he : ∃ a : Γ, coordinate a (x : E) ≠ 0 := by + by_contra hh + push Not at hh + apply hn + exact norming.coordinate_ext (fun a => (hh a).trans (map_zero _).symm) + obtain ⟨a,ha⟩ := he + exact ⟨a,by by_contra hh; exact ha (R.coordinate_zero_of_cut x a hh)⟩ + +lemma BranchReduction.beyond_finite (s : Finset Γ) (hs : ∀ a ∈ s, (a : Cut) < R.cut) : + ∃ β : Γ, (β : Cut) < R.cut ∧ ∀ a ∈ s, a < β := by + by_cases hn : s.Nonempty + · obtain ⟨β,hβ,hβc⟩ := R.noLast (s.max' hn) (hs _ (s.max'_mem hn)) + exact ⟨β,hβc,fun a ha => (s.le_max' a ha).trans_lt hβ⟩ + · obtain ⟨a,ha⟩ := R.cut_nonempty + exact ⟨a,ha,by simp only [Finset.not_nonempty_iff_eq_empty.mp hn,Finset.notMem_empty,false_implies,implies_true]⟩ + +def blockCrop (γ : Cut) (f : Family) (β : Γ) (l : ℕ) : Crop where + ordinal := initialSet γ ∩ Set.Ici β + ordinal_convex := (initialSet_connected γ).inter Set.ordConnected_Ici + colors := match f with | .pure k => {k} | .mixed => Set.Ici l + colors_convex := by cases f <;> first | exact Set.ordConnected_singleton | exact Set.ordConnected_Ici + +lemma blockCrop_mem (γ : Cut) (f : Family) (β a : Γ) (l : ℕ) : + a ∈ (blockCrop γ f β l).set .mixed ↔ (a : Cut) < γ ∧ β ≤ a ∧ + (match f with | .pure k => Colors.color a = k | .mixed => l ≤ Colors.color a) := by + cases f <;> simp only [blockCrop,Crop.set,Set.mem_inter_iff,initialSet,Set.mem_ofPred_eq, + Set.mem_Ici,Set.mem_preimage,Set.mem_singleton_iff,and_assoc] + +lemma BranchReduction.crop_difference_pure (k : ℕ) (hk : R.family = .pure k) + (β : Γ) (l : ℕ) (x : R.H) : + (x : E)-projection (blockCrop R.cut R.family β l) x = initialP (β : Cut) x := by + apply norming.coordinate_ext + intro a + by_cases hg : (a : Cut) < R.cut + · by_cases hb : β ≤ a + · by_cases hc : Colors.color a = k + · simp only [map_sub,coordinate_projection,blockCrop_mem,hg,hb,hk,hc,and_self, + ite_true,sub_self,coordinate_initialP,WithTop.coe_lt_coe,not_lt_of_ge hb,ite_false] + · have hz := R.coordinate_zero_of_color k hk x a hc + simp only [map_sub,coordinate_projection,blockCrop_mem,hg,hb,hk,hc,and_false, + sub_zero,coordinate_initialP,hz,ite_self] + · have hab : a < β := lt_of_not_ge hb + simp only [map_sub,coordinate_projection,blockCrop_mem,hb,and_false,false_and, + ite_false,sub_zero,coordinate_initialP,WithTop.coe_lt_coe,hab,ite_true] + · have hz := R.coordinate_zero_of_cut x a hg + simp only [map_sub,coordinate_projection,blockCrop_mem,hg,false_and,sub_zero, + coordinate_initialP,hz,ite_self] + +lemma BranchReduction.crop_difference_mixed (hm : R.family = .mixed) + (β : Γ) (l : ℕ) (x : R.H) : + (x : E)-projection (blockCrop R.cut R.family β l) x = initialP (β : Cut) x + + intervalProjection (Set.Ici β) Set.ordConnected_Ici (projection (Crop.colorsBelow l) x) := by + apply norming.coordinate_ext + intro a + have hz : ¬ (a : Cut) < R.cut → coordinate a (x : E) = 0 := R.coordinate_zero_of_cut x a + simp only [map_sub,map_add,coordinate_projection,blockCrop_mem,hm,coordinate_initialP, + intervalProjection,Crop.ordinalSet_set,Crop.colorsBelow_set,Set.mem_ofPred_eq,Set.mem_Ici, + WithTop.coe_lt_coe] + by_cases hg : (a : Cut) < R.cut <;> by_cases hb : β ≤ a <;> by_cases hc : l ≤ Colors.color a + all_goals simp only [hg,hb,hc,lt_iff_not_ge,not_true_eq_false,not_false_eq_true, + and_self,and_true,and_false,ite_true,ite_false] + all_goals try abel_nf + all_goals exact hz hg + +lemma exists_crop_approx (A : Crop) (x : E) (ε : ℝ) (hε : 0 < ε) : + ∃ v : Γ →₀ ℝ, (∀ a ∈ v.support, a ∈ A.set .mixed) ∧ + ‖projection A x-norming.includeFinite v‖ < ε := by + obtain ⟨w,hw⟩ := norming.denseRange_includeFinite.exists_dist_lt x hε + refine ⟨w.filter (· ∈ A.set .mixed),?_,?_⟩ + · intro a ha + exact (Finsupp.mem_support_iff.mp ha |> fun h => of_not_not (fun hn => h (by simp [hn]))) + · have he : norming.includeFinite (w.filter (· ∈ A.set .mixed)) = projection A (norming.includeFinite w) := + (norming.projection_includeFinite (A.set .mixed) (cropStable A) w).symm + rw [he,← map_sub] + exact (norm_projection_le A _).trans_lt (by simpa only [dist_eq_norm] using hw) + +lemma BranchReduction.exists_tail_small (β : Γ) (hβ : (β : Cut) < R.cut) + (l : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ x : R.H, ‖x‖ = 1 ∧ ‖initialP (β : Cut) (x : E)‖ ≤ δ ∧ + (R.family = .mixed → ∑ k ∈ Finset.range l, ‖colorP k (x : E)‖ ≤ (l : ℝ)*δ) := by + let D : Finset (R.H →L[ℝ] E) := insert ((initialP (β : Cut)).comp R.H.subtypeL) + (if R.family = .mixed then (Finset.range l).image (fun k => (colorP k).comp R.H.subtypeL) else ∅) + have hD : ∀ T ∈ D, StrictlySingular T := by + intro T hT + rcases Finset.mem_insert.mp hT with rfl | hT + · exact R.earlier _ hβ + · by_cases hm : R.family = .mixed + · rw [ite_eq_left hm] at hT + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp hT + exact R.mixed hm k + · simp only [ite_eq_right hm,Finset.notMem_empty] at hT + obtain ⟨N,_,hNc,hNi,hN⟩ := exists_small_restriction_finite D hD ⊤ isClosed_univ + (Singular.top_infinite R.infinite) δ hδ + obtain ⟨u,hu⟩ := Singular.exists_unit hNi + let x : R.H := u + have hxn : ‖x‖ = 1 := hu + have hi : ‖initialP (β : Cut) (x : E)‖ ≤ δ := by + have h := hN _ (Finset.mem_insert_self _ _) x u.property + change ‖initialP (β : Cut) (x : E)‖ ≤ δ*‖x‖ at h + rwa [hxn,mul_one] at h + have hcolor (hm : R.family = .mixed) : ∑ k ∈ Finset.range l, ‖colorP k (x : E)‖ ≤ (l : ℝ)*δ := by + calc + _ ≤ ∑ _k ∈ Finset.range l, δ := by + apply Finset.sum_le_sum + intro k hk + have hmem : (colorP k).comp R.H.subtypeL ∈ D := Finset.mem_insert_of_mem (by + rw [ite_eq_left hm]; exact Finset.mem_image.mpr ⟨k,hk,rfl⟩) + have h := hN _ hmem x u.property + change ‖colorP k (x : E)‖ ≤ δ*‖x‖ at h + rwa [hxn,mul_one] at h + _ = _ := by simp + exact ⟨x,hxn,hi,hcolor⟩ + +lemma BranchReduction.crop_error_bound (β : Γ) (l : ℕ) (δ : ℝ) (hδ : 0 ≤ δ) + (x : R.H) (hi : ‖initialP (β : Cut) (x : E)‖ ≤ δ) + (hc : R.family = .mixed → ∑ k ∈ Finset.range l, ‖colorP k (x : E)‖ ≤ (l : ℝ)*δ) : + ‖(x : E)-projection (blockCrop R.cut R.family β l) x‖ ≤ (1+(l : ℝ))*δ := by + cases hf : R.family with + | pure k => + rw [← hf,R.crop_difference_pure k hf] + exact hi.trans (by nlinarith [(Nat.cast_nonneg l : (0:ℝ) ≤ l)]) + | mixed => + rw [← hf,R.crop_difference_mixed hf] + calc + _ ≤ ‖initialP (β : Cut) (x : E)‖ + + ‖intervalProjection (Set.Ici β) Set.ordConnected_Ici (projection (Crop.colorsBelow l) x)‖ := norm_add_le _ _ + _ ≤ δ + ‖projection (Crop.colorsBelow l) x‖ := add_le_add hi (norm_projection_le _ _) + _ ≤ δ + (l : ℝ)*δ := by + apply add_le_add_right + rw [projection_colorsBelow_sum] + exact (norm_sum_le _ _).trans (hc hf) + _ = _ := by ring + +/-- A unit vector in the reduced subspace can be approximated in any prescribed ordinal and color tail. -/ +lemma BranchReduction.exists_next_block (β : Γ) (hβ : (β : Cut) < R.cut) + (l : ℕ) (ε : ℝ) (hε : 0 < ε) (hε1 : ε ≤ 1/2) : + ∃ (x : R.H) (v : Γ →₀ ℝ), ‖x‖ = 1 ∧ v ≠ 0 ∧ + (∀ a ∈ v.support, a ∈ (blockCrop R.cut R.family β l).set .mixed) ∧ + ‖(x : E)-norming.includeFinite v‖ < ε := by + let δ := ε/(6*((l : ℝ)+1)) + have hδ : 0 < δ := div_pos hε (by positivity) + obtain ⟨x,hxn,hi,hc⟩ := R.exists_tail_small β hβ l δ hδ + have hδb : (1+(l : ℝ))*δ ≤ ε/3 := by + dsimp only [δ] + field_simp + nlinarith [hε] + have herr := (R.crop_error_bound β l δ hδ.le x hi hc).trans hδb + obtain ⟨v,hv,herr'⟩ := exists_crop_approx (blockCrop R.cut R.family β l) x (ε/3) (by positivity) + have he : ‖(x : E)-norming.includeFinite v‖ < ε := by + have ht := norm_sub_le_norm_sub_add_norm_sub ((x : E)) (projection (blockCrop R.cut R.family β l) x) (norming.includeFinite v) + linarith + refine ⟨x,v,hxn,?_,hv,he⟩ + intro hv0 + have hh : ‖(x : E)-norming.includeFinite v‖ = 1 := by rw [hv0,map_zero,sub_zero]; exact hxn + rw [hh] at he + linarith + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming Singular Set +open scoped Classical +variable {F : Submodule ℝ E} (R : BranchReduction F) +namespace BlockApprox + +def error (n : ℕ) : ℝ := (1/64000)*(1/2)^n +lemma error_pos (n : ℕ) : 0 < error n := by unfold error; positivity +lemma error_le (n : ℕ) : error n ≤ 1/2 := by + have h : (1/2 : ℝ)^n ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) + unfold error + nlinarith +lemma error_sum (s : Finset ℕ) : ∑ n ∈ s, error n ≤ 1/32000 := by + have h : (∑ n ∈ s, (1/2 : ℝ)^n) ≤ 2 := by + simpa only [tsum_geometric_two] using summable_geometric_two.sum_le_tsum s (fun n _ => by positivity) + simp only [error,← Finset.mul_sum] + linarith + +structure State where + ordinal : Γ + below : (ordinal : Cut) < R.cut + color : ℕ + +structure Step (s : State R) (n : ℕ) where + x : R.H + vector : Γ →₀ ℝ + unit : ‖x‖ = 1 + nonzero : vector ≠ 0 + support : ∀ a ∈ vector.support, a ∈ (blockCrop R.cut R.family s.ordinal s.color).set .mixed + approx : ‖(x : E)-norming.includeFinite vector‖ < error n + next : Γ + next_below : (next : Cut) < R.cut + before_next : ∀ a ∈ vector.support, a < next + +lemma exists_step (s : State R) (n : ℕ) : Nonempty (Step R s n) := by + obtain ⟨x,v,hx,hv,hvs,he⟩ := R.exists_next_block s.ordinal s.below s.color (error n) (error_pos n) (error_le n) + have hs : ∀ a ∈ v.support, (a : Cut) < R.cut := fun a ha => ((blockCrop_mem _ _ _ _ _).mp (hvs a ha)).1 + obtain ⟨β,hβ,hβv⟩ := R.beyond_finite v.support hs + exact ⟨⟨x,v,hx,hv,hvs,he,β,hβ,hβv⟩⟩ + +def step (s : State R) (n : ℕ) : Step R s n := (exists_step R s n).some + +def nextState (s : State R) (n : ℕ) : State R where + ordinal := (step R s n).next + below := (step R s n).next_below + color := max s.color ((step R s n).vector.support.sup Colors.color + 1) + +def state : ℕ → State R + | 0 => ⟨R.cut_nonempty.choose,R.cut_nonempty.choose_spec,0⟩ + | n+1 => nextState R (state n) n + +def node (n : ℕ) := step R (state R n) n + +lemma state_ordinal_strict : StrictMono (fun n => (state R n).ordinal) := by + apply strictMono_nat_of_lt_succ + intro n + obtain ⟨a,ha⟩ := Finsupp.support_nonempty_iff.mpr (node R n).nonzero + have hs := ((blockCrop_mem _ _ _ _ _).mp ((node R n).support a ha)).2.1 + exact hs.trans_lt ((node R n).before_next a ha) + +lemma state_color_mono : Monotone (fun n => (state R n).color) := by + apply monotone_nat_of_le_succ + intro n + exact le_max_left _ _ + +lemma support_after {n : ℕ} {a : Γ} (ha : a ∈ (node R n).vector.support) : + (state R n).ordinal ≤ a ∧ (a : Cut) < R.cut ∧ + (R.family = .mixed → (state R n).color ≤ Colors.color a) := by + have h := (blockCrop_mem _ _ _ _ _).mp ((node R n).support a ha) + refine ⟨h.2.1,h.1,?_⟩ + intro hf + simpa only [hf] using h.2.2 + +lemma support_color_next {n : ℕ} {a : Γ} (ha : a ∈ (node R n).vector.support) : + Colors.color a < (state R (n+1)).color := by + have h := Finset.le_sup (f := Colors.color) ha + exact (Nat.lt_succ_of_le h).trans_le (le_max_right _ _) + +/-- A block sequence approximating unit vectors in the reduced closed subspace, in the selected pure or mixed family. -/ +def blocks : BlockSequence R.family where + vector n := (node R n).vector + nonzero n := (node R n).nonzero + successive i j hij a ha b hb := by + have hβ : a < (state R (i+1)).ordinal := (node R i).before_next a ha + have hj := support_after R hb + refine ⟨hβ.trans_le (((state_ordinal_strict R).monotone (Nat.succ_le_iff.mpr hij)).trans hj.1),?_⟩ + intro hm + exact (support_color_next R ha).trans_le + ((state_color_mono R (Nat.succ_le_iff.mpr hij)).trans (hj.2.2 hm)) + pure_color k hk n a ha := by + have h := ((blockCrop_mem _ _ _ _ _).mp ((node R n).support a ha)).2.2 + simpa only [hk] using h + +lemma blocks_norm (n : ℕ) : (1/2:ℝ) ≤ ‖(blocks R).embed n‖ := by + have he := (node R n).approx + have hu := (node R n).unit + have h := norm_sub_norm_le ((node R n).x : E) ((blocks R).embed n) + change ‖(node R n).x‖ - ‖(blocks R).embed n‖ ≤ _ at h + rw [hu] at h + have hε := error_le n + change ‖((node R n).x : E)-((blocks R).embed n)‖ < error n at he + linarith + +lemma blocks_below (n : ℕ) (a : Γ) (ha : a ∈ ((blocks R).vector n).support) : + (a : Cut) < R.cut := (support_after R ha).2.1 + +end BlockApprox +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/BlockEstimates.lean b/lean/OAI/Analysis/SeparableQuotients/BlockEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7f16ec5dcb56880cd64ffe0675a0961828a9cc7 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/BlockEstimates.lean @@ -0,0 +1,407 @@ +import OAI.Analysis.SeparableQuotients.PartitionBlocks + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.RecordGrowth +open Filter +open scoped Topology + +/-- The logarithmic parameter limit implies unboundedness above every smaller power. -/ +lemma div_rpow_tendsto_atTop {a b : ℕ → ℝ} {p e : ℝ} + (ha : ∀ n, 1 < a n) (hb : ∀ n, 0 < b n) + (hA : Tendsto a atTop atTop) + (hlog : Tendsto (fun n => Real.log (b n) / Real.log (a n)) atTop (𝓝 p)) + (he : e < p) : Tendsto (fun n => b n / (a n)^e) atTop atTop := by + let δ := (p-e)/2 + have hδ : 0 < δ := by dsimp [δ]; linarith + have hep : e+δ < p := by dsimp [δ]; linarith + have hev := hlog.eventually (eventually_gt_nhds hep) + refine tendsto_atTop_mono' atTop (f₁ := fun n => (a n)^δ) ?_ + ((tendsto_rpow_atTop hδ).comp hA) + filter_upwards [hev] with n hn + apply (le_div_iff₀ (Real.rpow_pos_of_pos (by linarith [ha n]) e)).mpr + rw [← Real.rpow_add (by linarith [ha n])] + apply (Real.rpow_le_iff_le_log (by linarith [ha n]) (hb n)).mpr + have := (lt_div_iff₀ (Real.log_pos (ha n))).mp hn + nlinarith + +/-- A record ratio over a finite initial segment, with a prescribed large +value of a(k), precisely as in the partition-block argument. -/ +lemma exists_record (a : ℕ → ℝ) (e M : ℝ) (he : 0 ≤ e) (hM : 0 ≤ M) + (hunbounded : ∀ R : ℝ, ∃ k : ℕ, 1 ≤ k ∧ R < a k / (k : ℝ)^e) : + ∃ k : ℕ, 1 ≤ k ∧ M ≤ a k ∧ + ∀ l : ℕ, 1 ≤ l → l ≤ k → a l ≤ a k * ((l : ℝ)/(k : ℝ))^e := by + obtain ⟨n, hn, hAn⟩ := hunbounded M + obtain ⟨k, hk, hmax⟩ := (Finset.Icc 1 n).exists_max_image + (fun l => a l / (l : ℝ)^e) ⟨n, Finset.mem_Icc.mpr ⟨hn, le_rfl⟩⟩ + obtain ⟨hk1, hkn⟩ := Finset.mem_Icc.mp hk + have hk0 : (0 : ℝ) < k := by exact_mod_cast hk1 + have hpow : 1 ≤ (k : ℝ)^e := Real.one_le_rpow (by exact_mod_cast hk1) he + have hAk : M < a k / (k : ℝ)^e := + hAn.trans_le (hmax n (Finset.mem_Icc.mpr ⟨hn, le_rfl⟩)) + have hMk : M ≤ a k := by + have hmul := (lt_div_iff₀ (Real.rpow_pos_of_pos hk0 e)).mp hAk + exact (le_mul_of_one_le_right hM hpow).trans hmul.le + refine ⟨k, hk1, hMk, ?_⟩ + intro l hl hlk + have hl0 : (0 : ℝ) < l := by exact_mod_cast hl + have hrat := hmax l (Finset.mem_Icc.mpr ⟨hl, hlk.trans hkn⟩) + rw [Real.div_rpow hl0.le hk0.le] + apply (div_le_iff₀ (Real.rpow_pos_of_pos hl0 e)).mp hrat |>.trans_eq + ring + +/-- A slightly smaller reciprocal exponent can be chosen uniformly for all +of the finitely many partition sizes under consideration. -/ +lemma choose_exponent (s N : ℝ) (hs : 1 < s) (hN : 1 ≤ N) : + ∃ e : ℝ, 0 < e ∧ e < 1/s ∧ + ∀ d : ℝ, 1 ≤ d → d ≤ N → d^(1-e) ≤ 2*d^(1-1/s) := by + let δ := min (1/(2*s)) (Real.log 2 / (Real.log N+1)) + have hs0 : 0 < s := by linarith + have hln : 0 ≤ Real.log N := Real.log_nonneg hN + have hδ : 0 < δ := lt_min (by positivity) (by positivity [Real.log_pos (by norm_num : (1:ℝ)<2)]) + have hδs : δ ≤ 1/(2*s) := min_le_left _ _ + have hδN : δ ≤ Real.log 2 / (Real.log N+1) := min_le_right _ _ + have hs2 : 1/(2*s) = (1/s)/2 := by ring + have hinv : 0 < 1/s := one_div_pos.mpr hs0 + refine ⟨1/s-δ, by linarith, by linarith, ?_⟩ + intro d hd hdN + have hd0 : 0 < d := by linarith + have hld : 0 ≤ Real.log d := Real.log_nonneg hd + have hdδ : d^δ ≤ 2 := by + apply (Real.rpow_le_iff_le_log hd0 (by norm_num)).mpr + have hm := (le_div_iff₀ (by linarith : 0 < Real.log N+1)).mp hδN + have hmn := mul_le_mul_of_nonneg_left (Real.log_le_log hd0 hdN) hδ.le + nlinarith + calc + d^(1-(1/s-δ)) = d^δ * d^(1-1/s) := by + rw [← Real.rpow_add hd0]; congr 1; ring + _ ≤ 2*d^(1-1/s) := mul_le_mul_of_nonneg_right hdδ (Real.rpow_nonneg hd0.le _) + +/-- The finite concave power bound (Hölder) in the unit-block partition proof. -/ +lemma sum_rpow_le_card {ι : Type*} [Fintype ι] (w : ι → ℝ) (e : ℝ) + (he : 0 < e) (he1 : e < 1) (hw : ∀ i, 0 ≤ w i) (hs : ∑ i, w i ≤ 1) : + ∑ i, (w i)^e ≤ (Fintype.card ι : ℝ)^(1-e) := by + have hpq : Real.HolderConjugate (1/e) (1/(1-e)) := { + inv_add_inv_eq_inv := by simp + left_pos := by positivity + right_pos := by positivity } + have hh := Real.inner_le_Lp_mul_Lq_of_nonneg Finset.univ (f := fun i => (w i)^e) + (g := fun _ => (1 : ℝ)) hpq (fun i _ => Real.rpow_nonneg (hw i) e) (fun _ _ => zero_le_one) + have hpow (i : ι) : ((w i)^e)^(1/e) = w i := by + rw [← Real.rpow_mul (hw i), mul_one_div_cancel he.ne', Real.rpow_one] + simp only [mul_one, hpow, Real.one_rpow, Finset.sum_const, Finset.card_univ, + nsmul_eq_mul, mul_one, one_div_one_div] at hh + have hs0 : 0 ≤ ∑ i, w i := Finset.sum_nonneg (fun i _ => hw i) + have hle : (∑ i, w i)^e ≤ 1 := by + simpa only [Real.one_rpow] using Real.rpow_le_rpow hs0 hs he.le + exact hh.trans ((mul_le_mul_of_nonneg_right hle + (Real.rpow_nonneg (Nat.cast_nonneg _) _)).trans_eq (one_mul _)) + +end SeparableQuotient.RecordGrowth + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +lemma blockSumSup_div_rpow_unbounded {f : Family} (z : BlockSequence f) (a : ℕ) + (e : ℝ) (he : e < 1/(f.s : ℝ)) : + ∀ R : ℝ, ∃ k : ℕ, 1 ≤ k ∧ R < blockSumSup f (z.tailSpan a) k / (k : ℝ)^e := by + have hL : Tendsto (fun n => (Parameters.L f.s n : ℝ)) atTop atTop := + tendsto_natCast_atTop_atTop.comp (Parameters.L_strict f.s_ge_two).tendsto_atTop + have hL1 (n : ℕ) : (1 : ℝ) < Parameters.L f.s n := by + have hn : 1 < Parameters.L f.s n := by + apply Nat.one_lt_pow + · positivity [Family.s_ge_two f, Parameters.t_pos f.s n] + · norm_num + exact_mod_cast hn + have hb (n : ℕ) : (0 : ℝ) < (Parameters.L f.s n : ℝ)/(Parameters.m f.s n : ℝ) := + div_pos (by exact_mod_cast Parameters.L_pos f.s n) (by exact_mod_cast Parameters.m_pos f.s n) + have hg := RecordGrowth.div_rpow_tendsto_atTop hL1 hb hL + (Parameters.parameter_growth f.s_ge_two) he + intro R + obtain ⟨n, hn⟩ := (hg.eventually (eventually_gt_atTop (2*R))).exists + refine ⟨f.L (n+1), f.L_pos _, ?_⟩ + have hlo := (z.unitBlocks a (f.L (n+1))).norm_sum_lower (n+1) (by omega) + have hsup := (z.unitBlocks a (f.L (n+1))).norm_sum_le_sup + change (2*R) < (f.L (n+1) : ℝ)/(f.m (n+1) : ℝ)/(f.L (n+1) : ℝ)^e at hn + have hp : 0 < (f.L (n+1) : ℝ)^e := Real.rpow_pos_of_pos (by exact_mod_cast f.L_pos _) e + have hle := (div_le_div_of_nonneg_right (hlo.trans hsup) hp.le) + have hid : (f.L (n+1) : ℝ)/(2*(f.m (n+1) : ℝ))/(f.L (n+1) : ℝ)^e = + ((f.L (n+1) : ℝ)/(f.m (n+1) : ℝ)/(f.L (n+1) : ℝ)^e)/2 := by ring + rw [hid] at hle + linarith + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.IntervalIncidence +open scoped Classical + +variable {α β γ : Type*} [LinearOrder α] [LinearOrder β] [LinearOrder γ] + +/-- Only the first and last members of a successive finite family can partly +intersect one order-convex interval. -/ +lemma partial_intersections_le_two (s : Finset α) (F : α → Finset β) + (hF : ∀ i j, i < j → ∀ a ∈ F i, ∀ b ∈ F j, a < b) + (I : Set β) (hI : Set.OrdConnected I) : + (s.filter (fun i => (∃ a ∈ F i, a ∈ I) ∧ ¬ (↑(F i) : Set β) ⊆ I)).card ≤ 2 := by + let t := s.filter (fun i => (∃ a ∈ F i, a ∈ I) ∧ ¬ (↑(F i) : Set β) ⊆ I) + change t.card ≤ 2 + by_cases ht : t.Nonempty + · have hsub : t ⊆ {t.min' ht, t.max' ht} := by + intro i hi + by_cases hmin : i = t.min' ht + · simp [hmin] + by_cases hmax : i = t.max' ht + · simp [hmax] + have h1 : t.min' ht < i := lt_of_le_of_ne (t.min'_le i hi) (Ne.symm hmin) + have h2 : i < t.max' ht := lt_of_le_of_ne (t.le_max' i hi) hmax + obtain ⟨a, ha, haI⟩ := (Finset.mem_filter.mp (t.min'_mem ht)).2.1 + obtain ⟨b, hb, hbI⟩ := (Finset.mem_filter.mp (t.max'_mem ht)).2.1 + have hn := (Finset.mem_filter.mp hi).2.2 + exact (hn (fun c hc => hI.out haI hbI ⟨(hF _ _ h1 a ha c hc).le, (hF _ _ h2 c hc b hb).le⟩)).elim + exact (Finset.card_le_card hsub).trans (Finset.card_le_two) + · simp [Finset.not_nonempty_iff_eq_empty.mp ht] + +/-- A noncrossing incidence matrix has at most two multichild rows incident to each fixed child. -/ +lemma noncrossing_multichild_column_le_two (s : Finset α) (t : Finset β) (R : α → β → Prop) + (hR : ∀ i ∈ s, ∀ j ∈ s, i < j → ∀ a ∈ t, ∀ b ∈ t, R i a → R j b → a ≤ b) + (a : β) (ha : a ∈ t) : + (s.filter (fun i => R i a ∧ 2 ≤ (t.filter (R i)).card)).card ≤ 2 := by + let v := s.filter (fun i => R i a ∧ 2 ≤ (t.filter (R i)).card) + change v.card ≤ 2 + by_cases hv : v.Nonempty + · have hsub : v ⊆ {v.min' hv, v.max' hv} := by + intro i hi + by_cases hmin : i = v.min' hv + · simp [hmin] + by_cases hmax : i = v.max' hv + · simp [hmax] + have h1 : v.min' hv < i := lt_of_le_of_ne (v.min'_le i hi) (Ne.symm hmin) + have h2 : i < v.max' hv := lt_of_le_of_ne (v.le_max' i hi) hmax + have hi' := Finset.mem_filter.mp hi + have hm := Finset.mem_filter.mp (v.min'_mem hv) + have hx := Finset.mem_filter.mp (v.max'_mem hv) + have hs : t.filter (R i) ⊆ {a} := by + intro b hb + have hb' := Finset.mem_filter.mp hb + exact Finset.mem_singleton.mpr (le_antisymm + (hR _ hi'.1 _ hx.1 h2 b hb'.1 a ha hb'.2 hx.2.1) + (hR _ hm.1 _ hi'.1 h1 a ha b hb'.1 hm.2.1 hb'.2)) + have hc : (t.filter (R i)).card ≤ 1 := (Finset.card_le_card hs).trans (by simp) + omega + exact (Finset.card_le_card hsub).trans Finset.card_le_two + · simp [Finset.not_nonempty_iff_eq_empty.mp hv] + +lemma noncrossing_boundary_incidence (s : Finset α) (t : Finset β) (R : α → β → Prop) + (hR : ∀ i ∈ s, ∀ j ∈ s, i < j → ∀ a ∈ t, ∀ b ∈ t, R i a → R j b → a ≤ b) : + ∑ i ∈ s.filter (fun i => 2 ≤ (t.filter (R i)).card), (t.filter (R i)).card ≤ 2 * t.card := by + calc + _ = ∑ i ∈ s, ∑ a ∈ t, if R i a ∧ 2 ≤ (t.filter (R i)).card then 1 else 0 := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro i _ + by_cases hi : 2 ≤ (t.filter (R i)).card + · simp only [hi, ↓reduceIte, and_true] + rw [Finset.card_filter] + · simp only [hi, ↓reduceIte, and_false, Finset.sum_const_zero] + _ = ∑ a ∈ t, (s.filter (fun i => R i a ∧ 2 ≤ (t.filter (R i)).card)).card := by + rw [Finset.sum_comm] + simp only [Finset.card_filter] + _ ≤ ∑ a ∈ t, 2 := Finset.sum_le_sum (fun a ha => noncrossing_multichild_column_le_two s t R hR a ha) + _ = _ := by simp; omega + +end SeparableQuotient.IntervalIncidence + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +lemma intervalProjection_fixed (I : Set Γ) (hI : Set.OrdConnected I) (x : Γ →₀ ℝ) + (hx : (x.support : Set Γ) ⊆ I) : + intervalProjection I hI (norming.includeFinite x) = norming.includeFinite x := by + apply coordinate_ext + intro a + simp only [intervalProjection, coordinate_projection, Crop.ordinalSet_set, + norming.coordinate_includeFinite] + split_ifs with ha + · rfl + · exact (Finsupp.notMem_support_iff.mp (fun h => ha (hx h))).symm + +lemma intervalProjection_eq_zero (I : Set Γ) (hI : Set.OrdConnected I) (x : Γ →₀ ℝ) + (hx : ∀ a ∈ x.support, a ∉ I) : + intervalProjection I hI (norming.includeFinite x) = 0 := by + apply coordinate_ext + intro a + simp only [intervalProjection, coordinate_projection, Crop.ordinalSet_set, + norming.coordinate_includeFinite, map_zero] + split_ifs with ha + · exact Finsupp.notMem_support_iff.mp (fun h => hx a h ha) + · rfl + +lemma UnitBlocks.interval_norm_le {f S k} (v : UnitBlocks f S k) + (I : Set Γ) (hI : Set.OrdConnected I) : + ‖intervalProjection I hI (norming.includeFinite (∑ i, v.vector i))‖ ≤ + ‖norming.includeFinite (∑ i ∈ Finset.univ.filter (fun i => ((v.vector i).support : Set Γ) ⊆ I), v.vector i)‖ + 2 := by + let F := Finset.univ.filter (fun i => ((v.vector i).support : Set Γ) ⊆ I) + let B := Finset.univ.filter (fun i => (∃ a ∈ (v.vector i).support, a ∈ I) ∧ + ¬ ((v.vector i).support : Set Γ) ⊆ I) + have hB : B.card ≤ 2 := IntervalIncidence.partial_intersections_le_two _ (fun i => (v.vector i).support) + (fun i j hij a ha b hb => (v.successive i j hij a ha b hb).1) I hI + have heq : intervalProjection I hI (norming.includeFinite (∑ i, v.vector i)) = + norming.includeFinite (∑ i ∈ F, v.vector i) + + ∑ i ∈ B, intervalProjection I hI (norming.includeFinite (v.vector i)) := by + simp only [map_sum, F, B, Finset.sum_filter, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i _ + by_cases hi : ((v.vector i).support : Set Γ) ⊆ I + · simp only [hi, not_true_eq_false, and_false, ↓reduceIte, add_zero] + exact intervalProjection_fixed I hI _ hi + · by_cases hh : ∃ a ∈ (v.vector i).support, a ∈ I + · simp only [hi, hh, not_false_eq_true, true_and, ↓reduceIte, map_zero, zero_add] + · have hz : ∀ a ∈ (v.vector i).support, a ∉ I := by simpa only [not_exists, not_and] using hh + simp only [hi, hh, false_and, ↓reduceIte, map_zero, add_zero] + exact intervalProjection_eq_zero I hI _ hz + rw [heq] + apply (norm_add_le _ _).trans + apply add_le_add_right + calc + ‖∑ i ∈ B, intervalProjection I hI (norming.includeFinite (v.vector i))‖ ≤ + ∑ i ∈ B, ‖intervalProjection I hI (norming.includeFinite (v.vector i))‖ := norm_sum_le B _ + _ ≤ ∑ _i ∈ B, (1 : ℝ) := by + apply Finset.sum_le_sum + intro i _ + exact (norm_projection_le _ _).trans_eq (v.unit i) + _ = B.card := by simp + _ ≤ 2 := by exact_mod_cast hB + +lemma UnitBlocks.full_card_sum_le {f S k} (v : UnitBlocks f S k) (d : ℕ) + (I : Fin d → Set Γ) + (hIs : ∀ i j, i < j → ∀ a ∈ I i, ∀ b ∈ I j, a < b) : + ∑ b : Fin d, (Finset.univ.filter (fun i => ((v.vector i).support : Set Γ) ⊆ I b)).card ≤ k := by + let F := fun b : Fin d => Finset.univ.filter (fun i => ((v.vector i).support : Set Γ) ⊆ I b) + have hd : ((Finset.univ : Finset (Fin d)) : Set (Fin d)).PairwiseDisjoint F := by + intro b _ c _ hbc + apply Finset.disjoint_left.mpr + intro i hi hj + have hb := (Finset.mem_filter.mp hi).2 + have hc := (Finset.mem_filter.mp hj).2 + obtain ⟨a, ha⟩ := Finsupp.support_nonempty_iff.mpr (v.nonzero i) + rcases lt_or_gt_of_ne hbc with hbc | hcb + · exact (lt_irrefl a) (hIs b c hbc a (hb ha) a (hc ha)) + · exact (lt_irrefl a) (hIs c b hcb a (hc ha) a (hb ha)) + change ∑ b, (F b).card ≤ k + rw [← Finset.card_biUnion hd] + simpa using (Finset.card_le_univ (Finset.univ.biUnion F)) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +lemma UnitBlocks.subsum_record {f S k} (v : UnitBlocks f S k) (t : Finset (Fin k)) + (e : ℝ) (he : 0 < e) (_hk : 1 ≤ k) + (hrec : ∀ l : ℕ, 1 ≤ l → l ≤ k → + blockSumSup f S l ≤ blockSumSup f S k * ((l : ℝ)/(k : ℝ))^e) : + ‖norming.includeFinite (∑ i ∈ t, v.vector i)‖ ≤ blockSumSup f S k * ((t.card : ℝ)/(k : ℝ))^e := by + by_cases ht : t.Nonempty + · exact v.norm_subsum_le_sup t |>.trans (hrec t.card ht.card_pos (by simpa using t.card_le_univ)) + · rw [Finset.not_nonempty_iff_eq_empty.mp ht] + simp [Real.zero_rpow he.ne'] + +lemma UnitBlocks.partition_sum_record {f S k} (v : UnitBlocks f S k) + (e : ℝ) (he : 0 < e) (he1 : e < 1) (hk : 1 ≤ k) + (hrec : ∀ l : ℕ, 1 ≤ l → l ≤ k → + blockSumSup f S l ≤ blockSumSup f S k * ((l : ℝ)/(k : ℝ))^e) + (d : ℕ) (I : Fin d → Set Γ) (hI : ∀ b, Set.OrdConnected (I b)) + (hIs : ∀ i j, i < j → ∀ a ∈ I i, ∀ b ∈ I j, a < b) : + ∑ b, ‖intervalProjection (I b) (hI b) (norming.includeFinite (∑ i, v.vector i))‖ ≤ + blockSumSup f S k * (d : ℝ)^(1-e) + 2*d := by + let F := fun b : Fin d => Finset.univ.filter (fun i => ((v.vector i).support : Set Γ) ⊆ I b) + have ha : 0 ≤ blockSumSup f S k := blockSumSup_nonneg ⟨v⟩ + have hw0 (b : Fin d) : 0 ≤ ((F b).card : ℝ)/(k : ℝ) := by positivity + have hws : ∑ b, ((F b).card : ℝ)/(k : ℝ) ≤ 1 := by + rw [← Finset.sum_div, div_le_one (by exact_mod_cast hk : (0 : ℝ) < k)] + exact_mod_cast v.full_card_sum_le d I hIs + have hp := RecordGrowth.sum_rpow_le_card (fun b => ((F b).card : ℝ)/(k : ℝ)) e he he1 hw0 hws + simp only [Fintype.card_fin] at hp + calc + _ ≤ ∑ b, (blockSumSup f S k * (((F b).card : ℝ)/(k : ℝ))^e + 2) := by + apply Finset.sum_le_sum + intro b _ + exact (v.interval_norm_le (I b) (hI b)).trans (add_le_add_left (v.subsum_record (F b) e he hk hrec) 2) + _ = blockSumSup f S k * ∑ b, (((F b).card : ℝ)/(k : ℝ))^e + 2*d := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum] + simp; ring + _ ≤ _ := add_le_add_left (mul_le_mul_of_nonneg_left hp ha) _ + +lemma UnitBlocks.normalized_partition {f S k} (v : UnitBlocks f S k) + (N : ℕ) (hN : 1 ≤ N) (e : ℝ) (he : 0 < e) (he1 : e < 1) (hk : 1 ≤ k) + (hrec : ∀ l : ℕ, 1 ≤ l → l ≤ k → + blockSumSup f S l ≤ blockSumSup f S k * ((l : ℝ)/(k : ℝ))^e) + (hlarge : (N : ℝ) ≤ blockSumSup f S k) + (hnear : blockSumSup f S k / 2 < ‖norming.includeFinite (∑ i, v.vector i)‖) + (hexp : ∀ d : ℝ, 1 ≤ d → d ≤ N → d^(1-e) ≤ 2*d^(1/f.r)) : + PartitionBound (‖norming.includeFinite (∑ i, v.vector i)‖⁻¹ • norming.includeFinite (∑ i, v.vector i)) N 8 f.r := by + let x := norming.includeFinite (∑ i, v.vector i) + have hN0 : (0 : ℝ) < N := by exact_mod_cast hN + have hnearX : blockSumSup f S k / 2 < ‖x‖ := hnear + have hx : 0 < ‖x‖ := by linarith + intro d hd hdN I hI hIs + have hb : ∑ b, ‖intervalProjection (I b) (hI b) x‖ ≤ + blockSumSup f S k * (d : ℝ)^(1-e) + 2*d := v.partition_sum_record e he he1 hk hrec d I hI hIs + have hd0 : (1 : ℝ) ≤ d := by exact_mod_cast hd + have hdN' : (d : ℝ) ≤ N := by exact_mod_cast hdN + have hdexp := hexp d hd0 hdN' + have hpow : 1 ≤ (d : ℝ)^(1/f.r) := Real.one_le_rpow hd0 (one_div_nonneg.mpr f.r_pos.le) + have hm : 0 ≤ blockSumSup f S k := by linarith + have hprod : blockSumSup f S k * (d : ℝ)^(1-e) ≤ + 4*‖x‖*(d : ℝ)^(1/f.r) := by + have hh := mul_le_mul_of_nonneg_left hdexp hm + have hnear' : blockSumSup f S k ≤ 2*‖x‖ := by linarith + have hmul := mul_le_mul_of_nonneg_right hnear' (by positivity : 0 ≤ 2*(d : ℝ)^(1/f.r)) + nlinarith + have hdlarge : 2*(d : ℝ) ≤ 4*‖x‖ := by linarith + have hsum : ∑ b, ‖intervalProjection (I b) (hI b) x‖ ≤ 8*‖x‖*(d : ℝ)^(1/f.r) := by + have hnorm := mul_le_mul_of_nonneg_left hpow (by positivity : 0 ≤ 4*‖x‖) + nlinarith + simp only [map_smul, norm_smul, norm_inv, Real.norm_eq_abs, abs_norm, ← Finset.mul_sum] + change ‖x‖⁻¹ * (∑ b, ‖intervalProjection (I b) (hI b) x‖) ≤ _ + calc + _ ≤ ‖x‖⁻¹ * (8*‖x‖*(d : ℝ)^(1/f.r)) := mul_le_mul_of_nonneg_left hsum (inv_nonneg.mpr hx.le) + _ = _ := by field_simp + +/-- The constant-eight interval partition estimate in any prescribed algebraic tail of a block sequence. -/ +theorem BlockSequence.exists_partition_unit {f : Family} (z : BlockSequence f) + (a N : ℕ) (hN : 1 ≤ N) : + ∃ u : Γ →₀ ℝ, u ∈ z.tailSpan a ∧ ‖norming.includeFinite u‖ = 1 ∧ + PartitionBound (norming.includeFinite u) N 8 f.r := by + have hs : 1 < (f.s : ℝ) := by exact_mod_cast (show 1 < f.s from f.s_ge_two) + obtain ⟨e, he, hes, hexp⟩ := RecordGrowth.choose_exponent (f.s : ℝ) N hs (by exact_mod_cast hN) + have he1 : e < 1 := hes.trans ((div_lt_one (by linarith : (0 : ℝ) < f.s)).mpr hs) + obtain ⟨k, hk, hklarge, hkrec⟩ := RecordGrowth.exists_record + (blockSumSup f (z.tailSpan a)) e N he.le (Nat.cast_nonneg _) + (blockSumSup_div_rpow_unbounded z a e hes) + have hnon : Nonempty (UnitBlocks f (z.tailSpan a) k) := ⟨z.unitBlocks a k⟩ + have hak : 0 < blockSumSup f (z.tailSpan a) k := lt_of_lt_of_le (by exact_mod_cast hN) hklarge + obtain ⟨v, hv⟩ := unitBlocks_near_sup hnon hak + let w := ∑ i, v.vector i + have hvw : blockSumSup f (z.tailSpan a) k / 2 < ‖norming.includeFinite w‖ := hv + have hw : 0 < ‖norming.includeFinite w‖ := by linarith + refine ⟨‖norming.includeFinite w‖⁻¹ • w, Submodule.smul_mem _ _ (Submodule.sum_mem _ (fun i _ => v.mem i)), ?_, ?_⟩ + · rw [map_smul, norm_smul, norm_inv, Real.norm_eq_abs, abs_norm, inv_mul_cancel₀ hw.ne'] + · rw [map_smul] + apply v.normalized_partition N hN e he he1 hk hkrec hklarge hv + intro d hd hdN + have hconj := Parameters.s_r_conjugate f.s_ge_two + have heq : 1/f.r = 1 - 1/(f.s : ℝ) := (eq_sub_iff_add_eq).mpr + (by simpa only [Family.r, one_div] using hconj.symm.inv_add_inv_eq_one) + simpa only [heq] using hexp d hd hdN + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/BoundedCompleteness.lean b/lean/OAI/Analysis/SeparableQuotients/BoundedCompleteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..81a408900c814bd36a88a67a7f6e9f10165169f4 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/BoundedCompleteness.lean @@ -0,0 +1,439 @@ +import OAI.Analysis.SeparableQuotients.CoordinatePredual + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup4 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace4 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup4 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace4 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup4 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace4 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +/-- Coordinates of a proposed prefix or interval coincide with the fixed g. -/ +def IsPiece (g : StrongDual ℝ X₀) (S : Set Γ) (x : E) : Prop := + ∀ a, coordinate a x = if a ∈ S then g (coordinate₀ a) else 0 + +lemma IsPiece.zero_off {g : StrongDual ℝ X₀} {S : Set Γ} {x : E} + (h : IsPiece g S x) (a : Γ) (ha : a ∉ S) : coordinate a x = 0 := by + rw [h a, ite_eq_right ha] + +lemma IsPiece.projection {g : StrongDual ℝ X₀} {S : Set Γ} {x : E} + (h : IsPiece g S x) (A : Crop) : + IsPiece g (S ∩ A.set .mixed) (projection A x) := by + intro a + rw [coordinate_projection, h a] + by_cases ha : a ∈ S <;> by_cases hb : a ∈ A.set .mixed <;> simp [ha, hb] + +lemma IsPiece.eval_eq {g : StrongDual ℝ X₀} {S : Set Γ} {x : E} + (h : IsPiece g S x) (f : Array) (hf : (f.support : Set Γ) ⊆ S) : + g (norming.rationalPredual f) = norming.evaluateArray x f := by + apply predual_array_eq_evaluate + intro a ha + rw [h a, ite_eq_left (hf ha)] + +lemma exists_piece_normer (g : StrongDual ℝ X₀) (A : Crop) (x : E) + (hx : IsPiece g (A.set .mixed) x) (r : ℝ) (hr : 0 ≤ r) (hxr : r < ‖x‖) : + ∃ f ∈ Full, (f.support : Set Γ) ⊆ A.set .mixed ∧ + r < g (norming.rationalPredual f) := by + obtain ⟨f, hf, hfx⟩ := exists_full_normer x r hr hxr + let f' := restrict (A.set .mixed) f + have hs : (f'.support : Set Γ) ⊆ A.set .mixed := by + intro a ha + by_contra hn + have hz : f' a = 0 := by simp [f', hn] + exact Finsupp.mem_support_iff.mp ha hz + refine ⟨f', full_crop A f hf, hs, ?_⟩ + rw [hx.eval_eq f' hs, evaluateArray_crop_of_zero (A.set .mixed) x hx.zero_off] + exact hfx + +lemma exists_pure_piece_normer (g : StrongDual ℝ X₀) (I : Set Γ) + (hI : Set.OrdConnected I) (k : ℕ) (x : E) + (hx : IsPiece g (I ∩ colorSet k) x) (r : ℝ) (hr : 0 ≤ r) (hxr : r < ‖x‖) : + ∃ f ∈ Pure k, (f.support : Set Γ) ⊆ I ∧ + r < g (norming.rationalPredual f) := by + have hc : ∀ a, Colors.color a ≠ k → coordinate a x = 0 := by + intro a ha + apply hx.zero_off + simp [colorSet, ha] + obtain ⟨f, hf, hfx⟩ := exists_pure_normer k x hc r hr hxr + let f' := restrict I f + have hf' : f' ∈ Pure k := pure_crop k (Crop.ordinalSet I hI) f hf + have hs : (f'.support : Set Γ) ⊆ I := by + intro a ha + by_contra hn + exact Finsupp.mem_support_iff.mp ha (by simp [f', hn]) + have hs' : (f'.support : Set Γ) ⊆ I ∩ colorSet k := by + intro a ha + refine ⟨hs ha, ?_⟩ + by_contra hn + exact Finsupp.mem_support_iff.mp ha (pure_vanish k f' hf' a hn) + refine ⟨f', hf', hs, ?_⟩ + rw [hx.eval_eq f' hs', evaluateArray_crop_of_zero I x] + · exact hfx + · intro a ha + apply hx.zero_off + simp [ha] + +lemma projection_colorsBelow_sum (n : ℕ) (x : E) : + projection (Crop.colorsBelow n) x = ∑ k ∈ Finset.range n, projection (Crop.oneColor k) x := by + apply coordinate_ext + intro a + simp only [coordinate_projection, Crop.colorsBelow_set, Set.mem_ofPred_eq, map_sum, + Crop.oneColor_set, colorSet] + simp [eq_comm] + +lemma tendsto_low_colors {v : ℕ → E} + (h : ∀ k, Tendsto (fun i => projection (Crop.oneColor k) (v i)) atTop (𝓝 0)) (n : ℕ) : + Tendsto (fun i => projection (Crop.colorsBelow n) (v i)) atTop (𝓝 0) := by + simpa only [projection_colorsBelow_sum, Finset.sum_const_zero] using + (tendsto_finsetSum (Finset.range n) fun k _ => h k) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.OrderedCauchy +open Filter +open scoped Classical +universe u v +variable {ι : Type u} [LinearOrder ι] [Nonempty ι] +variable {Z : Type v} [PseudoMetricSpace Z] + +/-- Failure of the Cauchy condition on a linearly ordered directed set yields +successive separated pairs. This applies equally to countable ordinal prefixes +and to an uncountable limit; no countable cofinality is assumed. -/ +lemma separated_pairs_of_not_cauchy (u : ι → Z) (hu : ¬ CauchySeq u) : + ∃ ε : ℝ, 0 < ε ∧ ∃ a b : ℕ → ι, + (∀ i, a i < b i) ∧ (∀ i j, i < j → b i ≤ a j) ∧ + ∀ i, ε ≤ dist (u (b i)) (u (a i)) := by + rw [Metric.cauchySeq_iff] at hu + push Not at hu + obtain ⟨ε, hε, hu⟩ := hu + have hex : ∀ N : ι, ∃ a b : ι, N ≤ a ∧ a < b ∧ ε ≤ dist (u b) (u a) := by + intro N + obtain ⟨m, hm, n, hn, hmn⟩ := hu N + by_cases h : m ≤ n + · refine ⟨m, n, hm, lt_of_le_of_ne h ?_, ?_⟩ + · intro heq + rw [heq, dist_self] at hmn + exact (not_le_of_gt hε) hmn + · simpa only [dist_comm] using hmn + · exact ⟨n, m, hn, lt_of_not_ge h, hmn⟩ + choose a b hab hlt hdist using hex + let p : ℕ → ι × ι := fun n => Nat.rec + (a (Classical.arbitrary ι), b (Classical.arbitrary ι)) + (fun _ prev => (a prev.2, b prev.2)) n + have hp0 : ∀ n, (p n).1 < (p n).2 := by + intro n + cases n with + | zero => exact hlt _ + | succ n => exact hlt _ + have hp1 : ∀ n, (p n).2 ≤ (p (n+1)).1 := fun n => hab _ + have hp2 : Monotone (fun n => (p n).2) := monotone_nat_of_le_succ fun n => + (hp1 n).trans (hp0 (n+1)).le + refine ⟨ε, hε, (fun n => (p n).1), (fun n => (p n).2), hp0, ?_, ?_⟩ + · intro i j hij + obtain ⟨l, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : j ≠ 0) + exact (hp2 (by omega : i ≤ l)).trans (hp1 l) + · intro n + cases n <;> exact hdist _ + +end SeparableQuotient.OrderedCauchy + +namespace SeparableQuotient.OrderedCauchy +open Filter +open scoped Classical Topology +universe u +variable {Z : Type u} [SeminormedAddCommGroup Z] + +lemma norm_large_subsequence (v : ℕ → Z) (hv : ¬ Tendsto v atTop (𝓝 0)) : + ∃ ε : ℝ, 0 < ε ∧ ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ i, ε ≤ ‖v (φ i)‖ := by + rw [Metric.tendsto_atTop] at hv + push Not at hv + obtain ⟨ε, hε, hv⟩ := hv + obtain ⟨φ, hφ, hlarge⟩ := Nat.exists_strictMono_subsequence (P := fun i => ε ≤ ‖v i‖) (by + intro N + obtain ⟨n, hn, hdist⟩ := hv (N+1) + exact ⟨n, by omega, by simpa only [dist_zero_right] using hdist⟩) + exact ⟨ε, hε, φ, hφ, hlarge⟩ + +end SeparableQuotient.OrderedCauchy + +namespace SeparableQuotient.Norming +open scoped Classical + +def Crop.colorWindow (lo hi : ℕ) : Crop := Crop.colorSet (Set.Ico lo hi) Set.ordConnected_Ico + +@[simp] lemma Crop.colorWindow_set (lo hi : ℕ) : + (Crop.colorWindow lo hi).set .mixed = {a | lo ≤ Colors.color a ∧ Colors.color a < hi} := by + ext a + simp [Crop.colorWindow, Crop.colorSet, Crop.set] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup5 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace5 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup5 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace5 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup5 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace5 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma successive_pieces_color_tendsto (g : StrongDual ℝ X₀) (I : ℕ → Set Γ) + (hI : ∀ i, (I i).OrdConnected) (v : ℕ → E) (hv : ∀ i, IsPiece g (I i) (v i)) + (hord : ∀ i j, i < j → ∀ a ∈ I i, ∀ b ∈ I j, a < b) (k : ℕ) : + Tendsto (fun i => projection (Crop.oneColor k) (v i)) atTop (𝓝 0) := by + by_contra hn + obtain ⟨ε, hε, φ, hφ, hlarge⟩ := OrderedCauchy.norm_large_subsequence _ hn + have hp : ∀ i, IsPiece g (I (φ i) ∩ colorSet k) (projection (Crop.oneColor k) (v (φ i))) := by + intro i + simpa only [Crop.oneColor_set] using (hv (φ i)).projection (Crop.oneColor k) + have hex : ∀ i, ∃ f ∈ Pure k, (f.support : Set Γ) ⊆ I (φ i) ∧ + ε/2 < g (norming.rationalPredual f) := by + intro i + exact exists_pure_piece_normer g _ (hI _) k _ (hp i) _ (by positivity) + ((half_lt_self hε).trans_le (hlarge i)) + choose f hf hs he using hex + apply no_successive_positive_normers g (.pure k) f hf _ (ε/2) (by positivity) (fun i => (he i).le) + intro i j hij a ha b hb + exact ⟨hord (φ i) (φ j) (hφ hij) a (hs i ha) b (hs j hb), by simp⟩ + +lemma projection_colorWindow_eq (lo hi : ℕ) (h : lo ≤ hi) (x : E) : + projection (Crop.colorWindow lo hi) x = + projection (Crop.colorsBelow hi) x - projection (Crop.colorsBelow lo) x := by + apply coordinate_ext + intro a + simp only [map_sub, coordinate_projection, Crop.colorWindow_set, Crop.colorsBelow_set, + Set.mem_ofPred_eq] + by_cases hl : Colors.color a < lo + · have hh : Colors.color a < hi := hl.trans_le h + simp [hl, hh, not_le_of_gt hl] + · by_cases hh : Colors.color a < hi <;> simp [hl, hh, le_of_not_gt hl] + +lemma exists_large_colorWindow (v : ℕ → E) (δ : ℝ) (hδ : 0 < δ) + (hv : ∀ i, δ ≤ ‖v i‖) + (hc : ∀ k, Tendsto (fun i => projection (Crop.oneColor k) (v i)) atTop (𝓝 0)) + (lo N : ℕ) : ∃ n hi : ℕ, N < n ∧ lo < hi ∧ + δ/2 < ‖projection (Crop.colorWindow lo hi) (v n)‖ := by + obtain ⟨N₀, hN₀⟩ := Metric.tendsto_atTop.mp (tendsto_low_colors hc lo) (δ/4) (by positivity) + let n := max (N+1) N₀ + have hlow : ‖projection (Crop.colorsBelow lo) (v n)‖ < δ/4 := by + simpa only [dist_zero_right] using hN₀ n (le_max_right _ _) + obtain ⟨H, hH⟩ := Metric.tendsto_atTop.mp (tendsto_colorsBelow (v n)) (δ/4) (by positivity) + let hi := max (lo+1) H + have hhigh : ‖v n - projection (Crop.colorsBelow hi) (v n)‖ < δ/4 := by + rw [norm_sub_rev] + simpa only [dist_eq_norm] using hH hi (le_max_right _ _) + have hlohi : lo < hi := lt_of_lt_of_le (Nat.lt_succ_self lo) (le_max_left _ _) + refine ⟨n, hi, lt_of_lt_of_le (Nat.lt_succ_self N) (le_max_left _ _), hlohi, ?_⟩ + rw [projection_colorWindow_eq lo hi hlohi.le] + have hb : ‖v n‖ ≤ ‖v n - projection (Crop.colorsBelow hi) (v n)‖ + + ‖projection (Crop.colorsBelow hi) (v n) - projection (Crop.colorsBelow lo) (v n)‖ + + ‖projection (Crop.colorsBelow lo) (v n)‖ := by + calc + _ = ‖(v n - projection (Crop.colorsBelow hi) (v n)) + + (projection (Crop.colorsBelow hi) (v n) - projection (Crop.colorsBelow lo) (v n)) + + projection (Crop.colorsBelow lo) (v n)‖ := by congr 1; abel + _ ≤ _ := (norm_add_le _ _).trans (add_le_add (norm_add_le _ _) le_rfl) + have := hv n + linarith + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup6 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace6 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup6 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace6 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup6 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace6 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +/-- The limit-step contradiction for vector pieces, with normers cropped after norm approximation. -/ +lemma no_large_successive_pieces (g : StrongDual ℝ X₀) (I : ℕ → Set Γ) + (hI : ∀ i, (I i).OrdConnected) (v : ℕ → E) (hv : ∀ i, IsPiece g (I i) (v i)) + (hord : ∀ i j, i < j → ∀ a ∈ I i, ∀ b ∈ I j, a < b) + (δ : ℝ) (hδ : 0 < δ) (hlarge : ∀ i, δ ≤ ‖v i‖) : False := by + have hc := successive_pieces_color_tendsto g I hI v hv hord + have hex := exists_large_colorWindow v δ hδ hlarge hc + choose n h hn hh hw using hex + let p : ℕ → ℕ × ℕ := fun i => Nat.rec (0, 0) + (fun _ prev => (n prev.2 prev.1, h prev.2 prev.1)) i + have hp1 : StrictMono (fun i => (p i).1) := strictMono_nat_of_lt_succ fun i => hn _ _ + have hp2 : StrictMono (fun i => (p i).2) := strictMono_nat_of_lt_succ fun i => hh _ _ + let idx : ℕ → ℕ := fun i => (p (i+1)).1 + have hidx : StrictMono idx := fun i j hij => hp1 (Nat.add_lt_add_right hij 1) + let A : ℕ → Crop := fun i => { + ordinal := I (idx i) + ordinal_convex := hI (idx i) + colors := Set.Ico (p i).2 (p (i+1)).2 + colors_convex := Set.ordConnected_Ico } + let w : ℕ → E := fun i => projection (Crop.colorWindow (p i).2 (p (i+1)).2) (v (idx i)) + have hp : ∀ i, IsPiece g ((A i).set .mixed) (w i) := by + intro i + simpa only [w, A, Crop.set, Crop.colorWindow, Crop.colorSet, Set.univ_inter] using + (hv (idx i)).projection (Crop.colorWindow (p i).2 (p (i+1)).2) + have hl : ∀ i, δ/2 < ‖w i‖ := fun i => hw (p i).2 (p i).1 + have hex' : ∀ i, ∃ f ∈ Full, (f.support : Set Γ) ⊆ (A i).set .mixed ∧ + δ/4 < g (norming.rationalPredual f) := by + intro i + exact exists_piece_normer g (A i) (w i) (hp i) (δ/4) (by positivity) + (lt_trans (by linarith) (hl i)) + choose f hf hs he using hex' + apply no_successive_positive_normers g .mixed f hf _ (δ/4) (by positivity) (fun i => (he i).le) + intro i j hij a ha b hb + have ha' := hs i ha + have hb' := hs j hb + change a ∈ I (idx i) ∧ (p i).2 ≤ Colors.color a ∧ Colors.color a < (p (i+1)).2 at ha' + change b ∈ I (idx j) ∧ (p j).2 ≤ Colors.color b ∧ Colors.color b < (p (j+1)).2 at hb' + refine ⟨hord (idx i) (idx j) (hidx hij) a ha'.1 b hb'.1, fun _ => ?_⟩ + exact (ha'.2.2.trans_le (hp2.monotone (by omega : i+1 ≤ j))).trans_le hb'.2.1 + +lemma IsPiece.sub_Iic {g : StrongDual ℝ X₀} {a b : Γ} {x y : E} + (hx : IsPiece g (Set.Iic a) x) (hy : IsPiece g (Set.Iic b) y) (hab : a ≤ b) : + IsPiece g (Set.Ioc a b) (y-x) := by + intro c + rw [map_sub, hx c, hy c] + by_cases hca : c ≤ a + · have hcb : c ≤ b := hca.trans hab + simp [hca, hcb, not_lt_of_ge hca] + · by_cases hcb : c ≤ b <;> simp [hca, hcb, lt_of_not_ge hca] + +/-- The ordinal-prefix net is Cauchy at every limit. It also works at successor +limits and at ω₁, without any cofinality assumption. -/ +lemma prefixes_cauchy {ι : Type*} [LinearOrder ι] [Nonempty ι] + (g : StrongDual ℝ X₀) (a : ι ↪o Γ) (v : ι → E) + (hv : ∀ i, IsPiece g (Set.Iic (a i)) (v i)) : CauchySeq v := by + by_contra hn + obtain ⟨δ, hδ, b, c, hbc, hs, hdist⟩ := OrderedCauchy.separated_pairs_of_not_cauchy v hn + let I : ℕ → Set Γ := fun i => Set.Ioc (a (b i)) (a (c i)) + let w : ℕ → E := fun i => v (c i) - v (b i) + have hp : ∀ i, IsPiece g (I i) (w i) := fun i => + (hv (b i)).sub_Iic (hv (c i)) (a.monotone (hbc i).le) + apply no_large_successive_pieces g I (fun _ => Set.ordConnected_Ioc) w hp _ δ hδ + · intro i + simpa only [w, dist_eq_norm] using hdist i + · intro i j hij α hα β hβ + exact (hα.2.trans (a.monotone (hs i j hij))).trans_lt hβ.1 + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup7 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace7 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup7 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace7 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup7 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace7 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma coordinate_e (a b : Γ) : coordinate a (e b) = if a = b then 1 else 0 := by + simp [coordinate, e, NormingSet.generator, Finsupp.single_apply, eq_comm] + +lemma IsPiece.append {g : StrongDual ℝ X₀} {β : Γ} {x : E} + (hx : IsPiece g (Set.Iio β) x) : + IsPiece g (Set.Iic β) (x + g (coordinate₀ β) • e β) := by + intro a + rw [map_add, map_smul, hx a, coordinate_e] + by_cases ha : a = β + · subst a + simp + · by_cases hab : a < β + · simp [ha, hab, hab.le] + · have hba : ¬ a ≤ β := fun h => hab (lt_of_le_of_ne h ha) + simp [ha, hab, hba] + +/-- Every strict prefix is the limit of its already constructed inclusive +prefixes. This handles empty, successor, and limit initial segments uniformly. -/ +lemma exists_strict_prefix (g : StrongDual ℝ X₀) (β : Γ) + (h : ∀ a : Γ, a < β → ∃ x : E, IsPiece g (Set.Iic a) x) : + ∃ x : E, IsPiece g (Set.Iio β) x := by + by_cases hn : Nonempty (Set.Iio β) + · let := hn + choose v hv using (fun a : Set.Iio β => h a.val a.property) + obtain ⟨x, hx⟩ := cauchySeq_tendsto_of_complete + (prefixes_cauchy g (OrderEmbedding.subtype (· ∈ Set.Iio β)) v hv) + refine ⟨x, fun a => ?_⟩ + have ht := (coordinate a).continuous.tendsto x |>.comp hx + simp only [Set.mem_Iio] + by_cases ha : a < β + · rw [ite_eq_left ha] + have he : ∀ᶠ i : Set.Iio β in atTop, coordinate a (v i) = g (coordinate₀ a) := by + filter_upwards [eventually_ge_atTop (⟨a, ha⟩ : Set.Iio β)] with i hi + change a ≤ (i : Γ) at hi + rw [hv i a, Set.mem_Iic, ite_eq_left hi] + exact tendsto_nhds_unique ht (tendsto_const_nhds.congr' (he.mono fun _ h => h.symm)) + · rw [ite_eq_right ha] + have he : ∀ i : Set.Iio β, coordinate a (v i) = 0 := by + intro i + rw [hv i a, Set.mem_Iic, ite_eq_right (fun hai => ha (lt_of_le_of_lt hai i.property))] + exact tendsto_nhds_unique ht + (tendsto_const_nhds.congr' (Filter.Eventually.of_forall + (fun i : Set.Iio β => (he i).symm))) + · refine ⟨0, fun a => ?_⟩ + have ha : ¬ a < β := fun ha => hn ⟨⟨a, ha⟩⟩ + simp [ha] + +lemma exists_prefix (g : StrongDual ℝ X₀) (β : Γ) : + ∃ x : E, IsPiece g (Set.Iic β) x := by + refine (wellFounded_lt : WellFounded ((· < ·) : Γ → Γ → Prop)).induction (C := fun β => ∃ x : E, IsPiece g (Set.Iic β) x) β ?_ + intro β ih + obtain ⟨x, hx⟩ := exists_strict_prefix g β ih + exact ⟨_, hx.append⟩ + +lemma exists_all_coordinates (g : StrongDual ℝ X₀) : + ∃ x : E, ∀ a, coordinate a x = g (coordinate₀ a) := by + choose v hv using (fun a => exists_prefix g a) + obtain ⟨x, hx⟩ := cauchySeq_tendsto_of_complete + (prefixes_cauchy g ((OrderIso.refl Γ).toOrderEmbedding) v hv) + refine ⟨x, fun a => ?_⟩ + have ht := (coordinate a).continuous.tendsto x |>.comp hx + have he : ∀ᶠ i : Γ in atTop, coordinate a (v i) = g (coordinate₀ a) := by + filter_upwards [eventually_ge_atTop a] with i hi + rw [hv i a, Set.mem_Iic, ite_eq_left hi] + exact tendsto_nhds_unique ht (tendsto_const_nhds.congr' (he.mono fun _ h => h.symm)) + +lemma dense_span_coordinate₀ : Dense (Submodule.span ℝ (Set.range coordinate₀) : Set X₀) := by + have him : Subtype.val '' (Submodule.span ℝ (Set.range coordinate₀) : Set X₀) = + (Submodule.span ℝ (Set.range coordinate) : Set (StrongDual ℝ E)) := by + change ((Submodule.span ℝ (Set.range coordinate₀)).map X₀.subtype : Set (StrongDual ℝ E)) = _ + rw [Submodule.map_span] + congr 2 + rw [← Set.range_comp] + rfl + intro x + rw [Topology.IsEmbedding.subtypeVal.closure_eq_preimage_closure_image, him] + exact x.property + +lemma predual_dual_ext (g h : StrongDual ℝ X₀) + (he : ∀ a, g (coordinate₀ a) = h (coordinate₀ a)) : g = h := by + apply ContinuousLinearMap.ext_on dense_span_coordinate₀ + rintro _ ⟨a, rfl⟩ + exact he a + +/-- Evaluation onto the dual of the coordinate predual is surjective. -/ +lemma evaluation_surjective : Function.Surjective norming.evaluation := by + intro g + obtain ⟨x, hx⟩ := exists_all_coordinates g + refine ⟨x, predual_dual_ext _ _ (fun a => ?_)⟩ + exact hx a + +def predualIsometry : E ≃ₗᵢ[ℝ] StrongDual ℝ X₀ := + LinearIsometryEquiv.ofSurjective norming.evaluationIsometry evaluation_surjective + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/BranchPaths.lean b/lean/OAI/Analysis/SeparableQuotients/BranchPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed6bc19c0c669299214ebe98a980800658f4a354 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/BranchPaths.lean @@ -0,0 +1,390 @@ +import OAI.Analysis.SeparableQuotients.ExactPairs + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.BinaryNodes + +def child (n : ℕ) (b : Bool) : ℕ := 2*n+1+b.toNat + +def ancestors : ℕ → List ℕ + | 0 => [0] + | n+1 => ancestors (n/2) ++ [n+1] +termination_by n => n + +def branch (b : ℕ → Bool) : ℕ → ℕ + | 0 => 0 + | n+1 => child (branch b n) (b n) + +lemma child_pos (n : ℕ) (b : Bool) : 0 < child n b := by simp only [child]; omega +lemma lt_child (n : ℕ) (b : Bool) : n < child n b := by simp only [child]; omega +lemma child_parent (n : ℕ) (b : Bool) : (child n b-1)/2 = n := by + cases b <;> simp only [child,Bool.toNat_false,Bool.toNat_true] <;> omega + +lemma child_injective {n m : ℕ} {b c : Bool} (h : child n b = child m c) : n = m ∧ b = c := by + cases b <;> cases c <;> simp_all [child] <;> omega + +lemma ancestors_child (n : ℕ) (b : Bool) : ancestors (child n b) = ancestors n ++ [child n b] := by + have hpos := child_pos n b + obtain ⟨k,hk⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hpos) + rw [hk,ancestors] + congr 2 + have hp := child_parent n b + rw [hk] at hp + omega + +lemma ancestors_nonempty (n : ℕ) : ancestors n ≠ [] := by + cases n with + | zero => simp [ancestors] + | succ n => simp [ancestors] + +lemma ancestors_mem_le (n k : ℕ) (hk : k ∈ ancestors n) : k ≤ n := by + induction n using Nat.strong_induction_on with + | h n ih => + cases n with + | zero => simpa [ancestors] using hk + | succ n => + simp only [ancestors,List.mem_append,List.mem_singleton] at hk + rcases hk with hk | rfl + · exact (ih (n/2) (by omega) hk).trans (by omega) + · exact le_rfl + +lemma ancestors_branch (b : ℕ → Bool) (n : ℕ) : + ancestors (branch b n) = List.ofFn (fun i : Fin (n+1) => branch b i) := by + induction n with + | zero => simp [branch,ancestors] + | succ n ih => + rw [branch,ancestors_child,ih] + rw [List.ofFn_succ_last (f := fun i : Fin (n+2) => branch b i)] + simp only [Fin.val_castSucc,Fin.val_last] + rfl + +lemma ancestors_branch_length (b : ℕ → Bool) (n : ℕ) : (ancestors (branch b n)).length = n+1 := by + rw [ancestors_branch,List.length_ofFn] + +lemma branch_strict (b : ℕ → Bool) : StrictMono (branch b) := + strictMono_nat_of_lt_succ (fun _n => lt_child _ _) + +lemma branch_same_level {b c : ℕ → Bool} {n m : ℕ} (h : branch b n = branch c m) : n = m := by + have hh := congrArg (fun k => (ancestors k).length) h + simpa only [ancestors_branch_length,Nat.add_right_cancel_iff] using hh + +lemma exists_separating_node {b c : ℕ → Bool} (hbc : b ≠ c) : + ∃ n, ∀ m, branch b n ≠ branch c m := by + obtain ⟨i,hi⟩ := Function.ne_iff.mp hbc + refine ⟨i+1,fun m hm => ?_⟩ + have he := branch_same_level hm + subst m + exact hi (child_injective hm).2 + +end SeparableQuotient.BinaryNodes + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +lemma RawPath.code_congr_prefix {P Q : RawPath} {n : ℕ} + (hp : ∀ i ≤ n, P.piece i = Q.piece i) + (hw : ∀ i ≤ n, P.weight i = Q.weight i) + (hm : ∀ i ≤ n, P.metadata i = Q.metadata i) : P.code n = Q.code n := by + have hs : P.support n = Q.support n := by + unfold RawPath.support + exact Finset.biUnion_congr rfl (fun i hi => congrArg Finsupp.support (hp i (by simpa using hi))) + have he : P.endpoint n = Q.endpoint n := by simp only [RawPath.endpoint,hs] + have hc : P.closure n = Q.closure n := by rw [RawPath.closure,RawPath.closure,he,hm n le_rfl] + unfold RawPath.code + congr 1 + funext i + rw [hp i (by omega),hw i (by omega),hm i (by omega),hc] + +structure TreeNode {f : Family} (z : BlockSequence f) where + start : ℕ + weight : ℕ + weight_pos : 1 ≤ weight + pair : ExactPair z start weight + finish : ℕ + finish_ge : start ≤ finish + support : pair.vector.support ⊆ z.prefixSupport finish + metadata : ℕ + metadata_pos : 1 ≤ metadata + weight_le_metadata : weight ≤ metadata + +namespace TreeNode +variable {f : Family} (z : BlockSequence f) + +def initial : TreeNode z := by + let e := Classical.choice (z.exists_exactPair 0 1 (by omega)) + let hb := z.support_subset_prefix 0 e.mem_tail + exact ⟨0,1,by omega,e,hb.choose,hb.choose_spec.1,hb.choose_spec.2,1,by omega,by omega⟩ + +def lookup (l : List (TreeNode z)) (n : ℕ) : TreeNode z := l.getD n (initial z) + +def rawAlong (D : ℕ → TreeNode z) (v : ℕ → ℕ) : RawPath where + piece := fun n => (D (v n)).pair.piece.value + weight := fun n => (D (v n)).weight + metadata := fun n => (D (v n)).metadata + nonzero := fun n => (D (v n)).pair.piece.value_ne_zero + +def nodeCode (D : ℕ → TreeNode z) (n : ℕ) : Code := + (rawAlong z D (fun i => (BinaryNodes.ancestors n).getD i 0)).code + ((BinaryNodes.ancestors n).length-1) + +def requested (l : List (TreeNode z)) : ℕ := + if l.length = 0 then 1 else sigma (nodeCode z (lookup z l) ((l.length-1)/2)) + +lemma requested_pos (l : List (TreeNode z)) : 1 ≤ requested z l := by + unfold requested + split_ifs + · omega + · have := codeBound_lt_sigma (nodeCode z (lookup z l) ((l.length-1)/2)) + omega + +def listSupport (l : List (TreeNode z)) : Finset Γ := + l.toFinset.biUnion (fun d => d.pair.piece.value.support) + +lemma mem_listSupport (l : List (TreeNode z)) (α : Γ) : + α ∈ listSupport z l ↔ ∃ d ∈ l, α ∈ d.pair.piece.value.support := by + simp [listSupport] + +def nextStart (l : List (TreeNode z)) : ℕ := l.toFinset.sup (fun d => d.finish) + +def next (l : List (TreeNode z)) : TreeNode z := by + let e := Classical.choice (z.exists_exactPair (nextStart z l) (requested z l) (requested_pos z l)) + let hb := z.support_subset_prefix _ e.mem_tail + let S := listSupport z l ∪ e.piece.value.support + let R := S.sup (fun α => S.sup (fun β => rho α β)) + let p := 1 + requested z l + l.toFinset.sup (fun d => d.metadata) + R + exact ⟨nextStart z l,requested z l,requested_pos z l,e,hb.choose,hb.choose_spec.1,hb.choose_spec.2,p,by dsimp [p]; omega, + by dsimp [p]; omega⟩ + +lemma next_start (l : List (TreeNode z)) : (next z l).start = nextStart z l := rfl +lemma next_weight (l : List (TreeNode z)) : (next z l).weight = requested z l := rfl + +lemma next_metadata_gt (l : List (TreeNode z)) (d : TreeNode z) (hd : d ∈ l) : + d.metadata < (next z l).metadata := by + have h := Finset.le_sup (f := fun d : TreeNode z => d.metadata) (List.mem_toFinset.mpr hd) + change _ < 1 + requested z l + l.toFinset.sup (fun d => d.metadata) + _ + omega + +lemma next_rho (l : List (TreeNode z)) (α β : Γ) + (hα : α ∈ listSupport z l ∪ (next z l).pair.piece.value.support) + (hβ : β ∈ listSupport z l ∪ (next z l).pair.piece.value.support) : + rho α β ≤ (next z l).metadata := by + let S := listSupport z l ∪ (next z l).pair.piece.value.support + have h : rho α β ≤ S.sup (fun x => S.sup (fun y => rho x y)) := + (Finset.le_sup (s := S) (f := fun y => rho α y) hβ).trans + (Finset.le_sup (s := S) (f := fun x => S.sup (fun y => rho x y)) hα) + change _ ≤ 1 + requested z l + l.toFinset.sup (fun d => d.metadata) + S.sup (fun x => S.sup (fun y => rho x y)) + omega + +def state : ℕ → List (TreeNode z) + | 0 => [] + | n+1 => state n ++ [next z (state n)] + +def node (n : ℕ) : TreeNode z := next z (state z n) + +lemma state_eq_ofFn (n : ℕ) : state z n = List.ofFn (fun i : Fin n => node z i) := by + induction n with + | zero => simp [state] + | succ n ih => + rw [state,List.ofFn_succ_last (f := fun i : Fin (n+1) => node z i)] + change state z n ++ [node z n] = _ + rw [ih] + rfl + +lemma state_length (n : ℕ) : (state z n).length = n := by rw [state_eq_ofFn,List.length_ofFn] + +lemma lookup_state {n k : ℕ} (hk : k < n) : lookup z (state z n) k = node z k := by + simp [lookup,state_eq_ofFn,List.getD,hk] + +lemma mem_state {n k : ℕ} (hk : k < n) : node z k ∈ state z n := by + rw [state_eq_ofFn] + exact List.mem_ofFn.mpr ⟨⟨k,hk⟩,rfl⟩ + +lemma finish_le_start {n k : ℕ} (hk : k < n) : (node z k).finish ≤ (node z n).start := by + change _ ≤ (next z (state z n)).start + rw [next_start] + exact Finset.le_sup (List.mem_toFinset.mpr (mem_state z hk)) + +lemma metadata_strict : StrictMono (fun n => (node z n).metadata) := by + intro n k hnk + exact next_metadata_gt z (state z k) (node z n) (mem_state z hnk) + +lemma support_before {n k : ℕ} (hk : k ≤ n) {α : Γ} + (hα : α ∈ (node z k).pair.piece.value.support) : + α ∈ listSupport z (state z n) ∪ (node z n).pair.piece.value.support := by + rcases eq_or_lt_of_le hk with rfl | hk + · exact Finset.mem_union_right _ hα + · exact Finset.mem_union_left _ ((mem_listSupport z _ _).mpr ⟨node z k,mem_state z hk,hα⟩) + +lemma successive_vector {n k : ℕ} (hk : k < n) : + ∀ α ∈ (node z k).pair.vector.support, ∀ β ∈ (node z n).pair.vector.support, + α < β ∧ (f = .mixed → Colors.color α < Colors.color β) := + z.prefix_tail_successive _ (node z k).support + (z.tailSpan_mono (finish_le_start z hk) (node z n).pair.mem_tail) + +lemma successive_piece {n k : ℕ} (hk : k < n) : + Successive f (node z k).pair.piece.value (node z n).pair.piece.value := by + intro α hα β hβ + exact vectorCrop_successive _ _ (successive_vector z hk) + α ((node z k).pair.support α hα) β ((node z n).pair.support β hβ) + +lemma nodeCode_eq_branch (b : ℕ → Bool) (n : ℕ) : + nodeCode z (node z) (BinaryNodes.branch b n) = + (rawAlong z (node z) (BinaryNodes.branch b)).code n := by + unfold nodeCode + rw [BinaryNodes.ancestors_branch,List.length_ofFn] + simp only [Nat.add_sub_cancel] + apply RawPath.code_congr_prefix + all_goals + intro i hi + have hlen : i < (List.ofFn (fun j : Fin (n+1) => BinaryNodes.branch b j)).length := by + rw [List.length_ofFn]; omega + have he : (List.ofFn (fun j : Fin (n+1) => BinaryNodes.branch b j)).getD i 0 = BinaryNodes.branch b i := by + rw [List.getD_eq_getElem _ _ hlen,List.getElem_ofFn] + simp only [rawAlong] + rw [he] + +lemma nodeCode_lookup {n k : ℕ} (hk : k < n) : + nodeCode z (lookup z (state z n)) k = nodeCode z (node z) k := by + unfold nodeCode + apply RawPath.code_congr_prefix + all_goals + intro i hi + have hi' : i < (BinaryNodes.ancestors k).length := by + have := List.length_pos_iff.mpr (BinaryNodes.ancestors_nonempty k) + omega + have hm : (BinaryNodes.ancestors k).getD i 0 ∈ BinaryNodes.ancestors k := by + simpa only [List.getD_eq_getElem _ _ hi'] using List.getElem_mem hi' + have hle := BinaryNodes.ancestors_mem_le k _ hm + have he := lookup_state z (n := n) (k := (BinaryNodes.ancestors k).getD i 0) (hle.trans_lt hk) + simp only [rawAlong] + rw [he] + +lemma weight_rule (b : ℕ → Bool) (n : ℕ) : + (node z (BinaryNodes.branch b (n+1))).weight = + sigma ((rawAlong z (node z) (BinaryNodes.branch b)).code n) := by + let k := BinaryNodes.branch b (n+1) + have hk : 0 < k := BinaryNodes.child_pos _ _ + have hp : (k-1)/2 = BinaryNodes.branch b n := BinaryNodes.child_parent _ _ + change (next z (state z k)).weight = _ + rw [next_weight,requested,state_length,ite_eq_right (Nat.ne_of_gt hk),hp] + have hpk : BinaryNodes.branch b n < k := BinaryNodes.lt_child _ _ + rw [nodeCode_lookup z hpk,nodeCode_eq_branch] + +/-- The prescribed-weight exact-pair construction yields actual admissible +paths on all infinite binary branches; records include all original metadata. -/ +def branchPath (b : ℕ → Bool) : InfinitePath f where + raw := rawAlong z (node z) (BinaryNodes.branch b) + admissible := { + successive := fun i j hij α hα β hβ => (successive_piece z (BinaryNodes.branch_strict b hij) α hα β hβ).1 + metadata_strict := (metadata_strict z).comp (BinaryNodes.branch_strict b) + metadata_pos := fun i => (node z (BinaryNodes.branch b i)).metadata_pos + weight_pos := fun i => (node z (BinaryNodes.branch b i)).weight_pos + weight_le_metadata := fun i => (node z (BinaryNodes.branch b i)).weight_le_metadata + rho_bound := by + intro n α β hα hβ _hab + apply next_rho z (state z (BinaryNodes.branch b n)) + · obtain ⟨i,hi,hiα⟩ := (RawPath.mem_support_iff _ n α).mp hα + exact support_before z ((BinaryNodes.branch_strict b).monotone hi) hiα + · obtain ⟨i,hi,hiβ⟩ := (RawPath.mem_support_iff _ n β).mp hβ + exact support_before z ((BinaryNodes.branch_strict b).monotone hi) hiβ + rule := weight_rule z b } + piece := fun i => (node z (BinaryNodes.branch b i)).pair.piece + value_eq := fun _ => rfl + weight_eq := fun i => (node z (BinaryNodes.branch b i)).pair.weight_eq + successive := fun _i _j hij => successive_piece z (BinaryNodes.branch_strict b hij) + children_mem := fun i j => (node z (BinaryNodes.branch b i)).pair.child_mem j + +end TreeNode +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology +namespace TreeNode +variable {f : Family} (z : BlockSequence f) + +lemma cross_evaluate {i j : ℕ} (hij : i ≠ j) : + norming.evaluateArray (norming.includeFinite (node z j).pair.vector) (node z i).pair.piece.value = 0 := by + apply evaluateArray_finite_disjoint + apply Finset.disjoint_left.mpr + intro α hα hβ + rcases lt_or_gt_of_ne hij with hij | hji + · exact (lt_irrefl α) (vectorCrop_successive (node z i).pair.nonzero (node z j).pair.nonzero + (successive_vector z hij) α ((node z i).pair.support α hβ) + α (support_mem_vectorCrop f _ _ α hα)).1 + · exact (lt_irrefl α) (vectorCrop_successive (node z j).pair.nonzero (node z i).pair.nonzero + (successive_vector z hji) α (support_mem_vectorCrop f _ _ α hα) + α ((node z i).pair.support α hβ)).1 + +lemma pathPartial_node (b : ℕ → Bool) (n N : ℕ) (hn : n ≤ N) : + pathPartial (branchPath z b) N (norming.includeFinite (node z (BinaryNodes.branch b n)).pair.vector) = + norming.evaluateArray (norming.includeFinite (node z (BinaryNodes.branch b n)).pair.vector) + (node z (BinaryNodes.branch b n)).pair.piece.value := by + rw [pathPartial, ← norming.evaluateArray_eq_functional] + change norming.evaluateArray _ (∑ j : Fin (N+1), (node z (BinaryNodes.branch b j)).pair.piece.value) = _ + rw [map_sum] + apply Finset.sum_eq_single (⟨n,by omega⟩ : Fin (N+1)) + · intro j _ hj + exact cross_evaluate z (fun he => hj (Fin.ext ((BinaryNodes.branch_strict b).injective he))) + · simp + +lemma pathPartial_other (b : ℕ → Bool) (k : ℕ) (hk : ∀ j, BinaryNodes.branch b j ≠ k) (N : ℕ) : + pathPartial (branchPath z b) N (norming.includeFinite (node z k).pair.vector) = 0 := by + rw [pathPartial, ← norming.evaluateArray_eq_functional] + change norming.evaluateArray _ (∑ j : Fin (N+1), (node z (BinaryNodes.branch b j)).pair.piece.value) = 0 + rw [map_sum] + exact Finset.sum_eq_zero (fun j _ => cross_evaluate z (hk j)) + +lemma pathFunctional_node (b : ℕ → Bool) (n : ℕ) : + 1/2 ≤ pathFunctional (branchPath z b) (norming.includeFinite (node z (BinaryNodes.branch b n)).pair.vector) := by + let x := norming.includeFinite (node z (BinaryNodes.branch b n)).pair.vector + have he : pathFunctional (branchPath z b) x = norming.evaluateArray x + (node z (BinaryNodes.branch b n)).pair.piece.value := + tendsto_nhds_unique (pathPartial_tendsto (branchPath z b) x) + (tendsto_const_nhds.congr' ((eventually_ge_atTop n).mono (fun N hN => (pathPartial_node z b n N hN).symm))) + rw [he] + exact (node z (BinaryNodes.branch b n)).pair.eval_ge + +lemma pathFunctional_other (b : ℕ → Bool) (k : ℕ) (hk : ∀ j, BinaryNodes.branch b j ≠ k) : + pathFunctional (branchPath z b) (norming.includeFinite (node z k).pair.vector) = 0 := + tendsto_nhds_unique (pathPartial_tendsto (branchPath z b) _) + (tendsto_const_nhds.congr' (Eventually.of_forall (fun N => (pathPartial_other z b k hk N).symm))) + +lemma pair_mem_submodule (V : Submodule ℝ E) (hV : ∀ n, z.embed n ∈ V) (k : ℕ) : + norming.includeFinite (node z k).pair.vector ∈ V := by + have hspan : z.tailSpan (node z k).start ≤ V.comap norming.includeFinite := by + apply Submodule.span_le.mpr + rintro _ ⟨n,rfl⟩ + exact hV (n+(node z k).start) + exact hspan (node z k).pair.mem_tail + +/-- Path restrictions are uniformly separated on every subspace containing the block sequence, with separation constant 1/500. -/ +lemma restricted_separated (V : Submodule ℝ E) (hV : ∀ n, z.embed n ∈ V) + {b c : ℕ → Bool} (hbc : b ≠ c) : + (1/1000 : ℝ) ≤ ‖(pathFunctional (branchPath z b)).comp V.subtypeL - + (pathFunctional (branchPath z c)).comp V.subtypeL‖ := by + obtain ⟨n,hn⟩ := BinaryNodes.exists_separating_node hbc + let x := norming.includeFinite (node z (BinaryNodes.branch b n)).pair.vector + let v : V := ⟨x,pair_mem_submodule z V hV _⟩ + let T := (pathFunctional (branchPath z b)).comp V.subtypeL - + (pathFunctional (branchPath z c)).comp V.subtypeL + have hv : ‖v‖ ≤ 500 := (node z (BinaryNodes.branch b n)).pair.norm_le + have he : 1/2 ≤ T v := by + change 1/2 ≤ pathFunctional (branchPath z b) x - pathFunctional (branchPath z c) x + rw [pathFunctional_other z c _ (fun j => (hn j).symm),sub_zero] + exact pathFunctional_node z b n + have hb := (T.le_opNorm v).trans (mul_le_mul_of_nonneg_left hv (norm_nonneg T)) + rw [Real.norm_eq_abs] at hb + have hp := le_abs_self (T v) + change 1/1000 ≤ ‖T‖ + linarith + +end TreeNode +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/BranchReduction.lean b/lean/OAI/Analysis/SeparableQuotients/BranchReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e0a9a3796e454f6d3f69cde002d56c3eb48bab0 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/BranchReduction.lean @@ -0,0 +1,183 @@ +import OAI.Analysis.SeparableQuotients.StrictSingularity + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Singular +lemma top_infinite {𝕜 Y : Type*} [Field 𝕜] [AddCommGroup Y] [Module 𝕜 Y] + (hI : ¬ FiniteDimensional 𝕜 Y) : ¬ FiniteDimensional 𝕜 (⊤ : Submodule 𝕜 Y) := by + intro hh + let : FiniteDimensional 𝕜 (⊤ : Submodule 𝕜 Y) := hh + let e : (⊤ : Submodule 𝕜 Y) ≃ₗ[𝕜] Y := Submodule.topEquiv + exact hI (FiniteDimensional.of_injective e.symm.toLinearMap e.symm.injective) +end SeparableQuotient.Singular +namespace SeparableQuotient.ActualSpace +open Norming Singular Set +open scoped Classical Topology + +abbrev Cut := WithTop Γ + +def initialSet (γ : Cut) : Set Γ := {a | (a : Cut) < γ} + +lemma initialSet_connected (γ : Cut) : Set.OrdConnected (initialSet γ) := + Set.ordConnected_Iio.preimage_mono (WithTop.coe_mono) + +def initialCrop (γ : Cut) := Crop.ordinalSet (initialSet γ) (initialSet_connected γ) + +def initialP (γ : Cut) : E →L[ℝ] E := projection (initialCrop γ) + +def colorP (k : ℕ) : E →L[ℝ] E := projection (Crop.oneColor k) + +@[simp] lemma coordinate_initialP (γ : Cut) (x : E) (a : Γ) : + coordinate a (initialP γ x) = if (a : Cut) < γ then coordinate a x else 0 := by + simp only [initialP,coordinate_projection,initialCrop,Crop.ordinalSet_set,initialSet,Set.mem_ofPred_eq] + +@[simp] lemma coordinate_colorP (k : ℕ) (x : E) (a : Γ) : + coordinate a (colorP k x) = if Colors.color a = k then coordinate a x else 0 := by + simp only [colorP,coordinate_projection,Crop.oneColor_set,Norming.colorSet,Set.mem_ofPred_eq] + +@[simp] lemma initialP_top (x : E) : initialP ⊤ x = x := by + apply norming.coordinate_ext + intro a + simp + +lemma initialP_initialP {β γ : Cut} (h : β ≤ γ) (x : E) : + initialP β (initialP γ x) = initialP β x := by + apply norming.coordinate_ext + intro a + by_cases ha : (a : Cut) < β + · simp [ha,lt_of_lt_of_le ha h] + · simp [ha] + +lemma initialP_colorP (γ : Cut) (k : ℕ) (x : E) : + initialP γ (colorP k x) = colorP k (initialP γ x) := by + apply norming.coordinate_ext + intro a + simp only [coordinate_initialP,coordinate_colorP] + split_ifs <;> rfl + +lemma colorP_colorP (k : ℕ) (x : E) : colorP k (colorP k x) = colorP k x := by + apply norming.coordinate_ext + intro a + simp only [coordinate_colorP] + split_ifs <;> rfl + +/-- The least non-strictly-singular initial projection terminates at an actual +limit cut: every coordinate below it has a strictly larger coordinate below it. -/ +lemma exists_minimal_cut (F : Submodule ℝ E) (_hF : IsClosed (F : Set E)) + (hI : ¬ FiniteDimensional ℝ F) : + ∃ γ : Cut, (¬ StrictlySingular ((initialP γ).comp F.subtypeL)) ∧ + (∀ β < γ, StrictlySingular ((initialP β).comp F.subtypeL)) ∧ + (∀ a : Γ, (a : Cut) < γ → ∃ b : Γ, a < b ∧ (b : Cut) < γ) := by + have htop : ¬ StrictlySingular ((initialP ⊤).comp F.subtypeL) := by + rw [not_strictlySingular_iff] + refine ⟨⊤,isClosed_univ,?_,1,by norm_num,?_⟩ + · exact Singular.top_infinite hI + · intro x + simp only [ContinuousLinearMap.comp_apply,Submodule.coe_subtypeL,initialP_top,one_mul] + exact le_rfl + obtain ⟨γ,hγ,hmin⟩ := wellFounded_lt.has_min + {γ : Cut | ¬ StrictlySingular ((initialP γ).comp F.subtypeL)} ⟨⊤,htop⟩ + have hsmall (β : Cut) (hβ : β < γ) : StrictlySingular ((initialP β).comp F.subtypeL) := by + by_contra hh + exact hmin β hh hβ + refine ⟨γ,hγ,hsmall,?_⟩ + intro a ha + by_contra hh + have hup (b : Γ) (hb : (b : Cut) < γ) : b ≤ a := by + by_contra hn + exact hh ⟨b,lt_of_not_ge hn,hb⟩ + obtain ⟨M,hMc,hMi,c,hc,hcM⟩ := (not_strictlySingular_iff _).mp hγ + let d : F →L[ℝ] ℝ := (coordinate a).comp F.subtypeL + obtain ⟨N,hNM,hNc,hNi,hd⟩ := finite_annihilator M hMc hMi {d} + obtain ⟨x,hx⟩ := hsmall (a : Cut) ha N hNc hNi c hc + have hax : coordinate a ((x : F) : E) = 0 := hd x x.property d (Finset.mem_singleton_self _) + have heq : initialP (a : Cut) ((x : F) : E) = initialP γ ((x : F) : E) := by + apply norming.coordinate_ext + intro b + by_cases hb : (b : Cut) < γ + · have hba := hup b hb + rcases hba.eq_or_lt with rfl | hba + · simp only [coordinate_initialP,lt_self_iff_false,ite_false,hax,hb,ite_true] + · simp only [coordinate_initialP,hb,WithTop.coe_lt_coe.mpr hba,ite_true] + · have hn : ¬ b < a := fun hba => hb (lt_trans (WithTop.coe_lt_coe.mpr hba) ha) + simp only [coordinate_initialP,hb,WithTop.coe_lt_coe,hn,ite_false] + have hy := hcM (⟨x,hNM x.property⟩ : M) + change c*‖(x : F)‖ ≤ ‖initialP γ ((x : F) : E)‖ at hy + change ‖initialP (a : Cut) ((x : F) : E)‖ < c*‖(x : F)‖ at hx + rw [heq] at hx + exact (not_lt_of_ge hy) hx + +/-- Range reduction before the optional single-color reduction. -/ +lemma exists_initial_reduction (F : Submodule ℝ E) (hF : IsClosed (F : Set E)) + (hI : ¬ FiniteDimensional ℝ F) : + ∃ (γ : Cut) (H : Submodule ℝ E), IsClosed (H : Set E) ∧ + ¬ FiniteDimensional ℝ H ∧ + (∀ a : Γ, (a : Cut) < γ → ∃ b : Γ, a < b ∧ (b : Cut) < γ) ∧ + (∀ β < γ, StrictlySingular ((initialP β).comp H.subtypeL)) ∧ + ∃ U : H →L[ℝ] F, ∀ x : H, initialP γ (U x) = x := by + let : CompleteSpace F := hF.completeSpace_coe + obtain ⟨γ,hγ,hsmall,hlim⟩ := exists_minimal_cut F hF hI + obtain ⟨H,hH,hHi,U,hU⟩ := exists_lift_of_not_strictlySingular + ((initialP γ).comp F.subtypeL) hγ + let : CompleteSpace H := hH.completeSpace_coe + refine ⟨γ,H,hH,hHi,hlim,?_,U,hU⟩ + intro β hβ + have hh := (hsmall β hβ).comp_right _ U + have he : ((initialP β).comp F.subtypeL).comp U = (initialP β).comp H.subtypeL := by + apply ContinuousLinearMap.ext + intro x + have hu : initialP γ ((U x : F) : E) = x := hU x + change initialP β ((U x : F) : E) = initialP β (x : E) + rw [← hu,initialP_initialP hβ.le] + rwa [he] at hh + +def familyP (γ : Cut) : Family → E →L[ℝ] E + | .pure k => (colorP k).comp (initialP γ) + | .mixed => initialP γ + +structure BranchReduction (F : Submodule ℝ E) where + cut : Cut + family : Family + H : Submodule ℝ E + closed : IsClosed (H : Set E) + infinite : ¬ FiniteDimensional ℝ H + noLast : ∀ a : Γ, (a : Cut) < cut → ∃ b : Γ, a < b ∧ (b : Cut) < cut + earlier : ∀ β < cut, StrictlySingular ((initialP β).comp H.subtypeL) + mixed : family = .mixed → ∀ k, StrictlySingular ((colorP k).comp H.subtypeL) + U : H →L[ℝ] F + lift : ∀ x : H, familyP cut family (U x) = x + +/-- Ordinal and color projections reduce a closed infinite-dimensional subspace to a branch subspace. -/ +theorem exists_branchReduction (F : Submodule ℝ E) (hF : IsClosed (F : Set E)) + (hI : ¬ FiniteDimensional ℝ F) : Nonempty (BranchReduction F) := by + obtain ⟨γ,H,hH,hHi,hlim,hsmall,U,hU⟩ := exists_initial_reduction F hF hI + let : CompleteSpace H := hH.completeSpace_coe + by_cases hm : ∀ k, StrictlySingular ((colorP k).comp H.subtypeL) + · exact ⟨⟨γ,.mixed,H,hH,hHi,hlim,hsmall,fun _ => hm,U,hU⟩⟩ + · push Not at hm + obtain ⟨k,hk⟩ := hm + obtain ⟨H',hH',hH'i,V,hV⟩ := exists_lift_of_not_strictlySingular + ((colorP k).comp H.subtypeL) hk + let : CompleteSpace H' := hH'.completeSpace_coe + refine ⟨⟨γ,.pure k,H',hH',hH'i,hlim,?_,by simp,U.comp V,?_⟩⟩ + · intro β hβ + have hh := ((hsmall β hβ).comp_left _ (colorP k)).comp_right _ V + have he : ((colorP k).comp ((initialP β).comp H.subtypeL)).comp V = + (initialP β).comp H'.subtypeL := by + apply ContinuousLinearMap.ext + intro x + change colorP k (initialP β ((V x : H) : E)) = initialP β (x : E) + rw [← initialP_colorP,show colorP k ((V x : H) : E) = x from hV x] + rwa [he] at hh + · intro x + change colorP k (initialP γ ((U (V x) : F) : E)) = x + rw [hU] + exact hV x + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/BranchSeparation.lean b/lean/OAI/Analysis/SeparableQuotients/BranchSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..32469bab3678eb8a4c80dc5e217279fcb8cad4ac --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/BranchSeparation.lean @@ -0,0 +1,222 @@ +import OAI.Analysis.SeparableQuotients.BlockApproximation + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction +open scoped Classical +variable {f : Family} (z : BlockSequence f) + +lemma BlockSequence.blockProjection_embed (n j : ℕ) : + intervalProjection (ordinalHull (z.vector n).support (Finsupp.support_nonempty_iff.mpr (z.nonzero n))) + (ordinalHull_connected _ _) (z.embed j) = if j = n then z.embed n else 0 := by + by_cases hj : j = n + · subst j + rw [ite_eq_left rfl] + exact intervalProjection_fixed _ _ _ (fun _ ha => mem_ordinalHull _ ha) + · rw [ite_eq_right hj] + apply intervalProjection_eq_zero + intro a ha haI + rcases lt_or_gt_of_ne hj with hj | hj + · have hlt := (z.successive j n hj a ha _ ((z.vector n).support.min'_mem (Finsupp.support_nonempty_iff.mpr (z.nonzero n)))).1 + exact (not_lt_of_ge haI.1) hlt + · have hlt := (z.successive n j hj _ ((z.vector n).support.max'_mem (Finsupp.support_nonempty_iff.mpr (z.nonzero n))) a ha).1 + exact (not_lt_of_ge haI.2) hlt + +lemma BlockSequence.coefficient_bound (hz : ∀ n, (1/2 : ℝ) ≤ ‖z.embed n‖) + (c : ℕ →₀ ℝ) (n : ℕ) : |c n| ≤ 4*‖c.sum (fun i a => a • z.embed i)‖ := by + let P := intervalProjection + (ordinalHull (z.vector n).support (Finsupp.support_nonempty_iff.mpr (z.nonzero n))) + (ordinalHull_connected _ _) + have he : P (c.sum (fun i a => a • z.embed i)) = c n • z.embed n := by + rw [Finsupp.sum,map_sum] + simp only [map_smul,P,BlockSequence.blockProjection_embed] + by_cases hn : n ∈ c.support + · rw [Finset.sum_eq_single_of_mem n hn] + · simp + · intro j _ hj + simp [hj] + · have hc : c n = 0 := Finsupp.notMem_support_iff.mp hn + rw [hc,zero_smul] + apply Finset.sum_eq_zero + intro j hj + have hjn : j ≠ n := fun hh => hn (hh ▸ hj) + simp [hjn] + have hp : ‖P (c.sum (fun i a => a • z.embed i))‖ ≤ ‖c.sum (fun i a => a • z.embed i)‖ := + norm_projection_le _ _ + rw [he,norm_smul,Real.norm_eq_abs] at hp + have := mul_le_mul_of_nonneg_left (hz n) (abs_nonneg (c n)) + nlinarith [norm_nonneg (c.sum (fun i a => a • z.embed i))] + +/-- The small-perturbation inequality for finite block combinations. -/ +lemma BlockSequence.finite_perturbation (hz : ∀ n, (1/2 : ℝ) ≤ ‖z.embed n‖) + (h : ℕ → E) (ε : ℕ → ℝ) (_hε : ∀ n, 0 ≤ ε n) + (he : ∀ n, ‖h n-z.embed n‖ ≤ ε n) (B : ℝ) + (hs : ∀ s : Finset ℕ, ∑ n ∈ s, ε n ≤ B) (c : ℕ →₀ ℝ) : + ‖c.sum (fun i a => a • h i) - c.sum (fun i a => a • z.embed i)‖ ≤ + (4*B)*‖c.sum (fun i a => a • z.embed i)‖ := by + let x := c.sum (fun i a => a • z.embed i) + calc + _ = ‖∑ i ∈ c.support, c i • (h i-z.embed i)‖ := by + congr 1 + simp only [Finsupp.sum,smul_sub,Finset.sum_sub_distrib] + _ ≤ ∑ i ∈ c.support, |c i| *‖h i-z.embed i‖ := by + simpa only [norm_smul,Real.norm_eq_abs] using + norm_sum_le c.support (fun i => c i • (h i-z.embed i)) + _ ≤ ∑ i ∈ c.support, (4*‖x‖)*ε i := by + apply Finset.sum_le_sum + intro i _ + exact mul_le_mul (z.coefficient_bound hz c i) (he i) (norm_nonneg _) (by positivity) + _ = (4*‖x‖)*(∑ i ∈ c.support, ε i) := (Finset.mul_sum _ _ _).symm + _ ≤ (4*‖x‖)*B := mul_le_mul_of_nonneg_left (hs c.support) (by positivity) + _ = _ := by ring + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology +variable {F : Submodule ℝ E} (R : BranchReduction F) + +lemma evaluateArray_familyP (γ : Cut) (f : Family) (x : E) (d : Array) + (ho : ∀ a ∈ d.support, (a : Cut) < γ) + (hc : ∀ k, f = .pure k → ∀ a ∈ d.support, Colors.color a = k) : + norming.evaluateArray (familyP γ f x) d = norming.evaluateArray x d := by + simp only [norming.evaluateArray_eq] + apply Finset.sum_congr rfl + intro a ha + cases hf : f with + | mixed => simp only [familyP,coordinate_initialP,ho a ha,ite_true] + | pure k => + simp only [familyP,ContinuousLinearMap.comp_apply,coordinate_colorP,coordinate_initialP, + ho a ha,hc k hf a ha,ite_true] + +namespace BlockApprox + +lemma pair_below (i : ℕ) (a : Γ) + (ha : a ∈ (TreeNode.node (blocks R) i).pair.piece.value.support) : + (a : Cut) < R.cut := by + let e := (TreeNode.node (blocks R) i).pair + have hα : a ∈ (vectorCrop e.vector e.nonzero).ordinal := by + have h := e.support a ha + have hh (A : Crop) (f : Family) (hb : a ∈ A.set f) : a ∈ A.ordinal := by + cases f with + | pure k => exact hb + | mixed => exact hb.1 + exact hh _ _ h + have hb := (blocks R).support_mem_tail _ e.mem_tail + ((e.vector.support.max'_mem (Finsupp.support_nonempty_iff.mpr e.nonzero))) + obtain ⟨n,_,hn⟩ := hb + exact (WithTop.coe_le_coe.mpr hα.2).trans_lt (blocks_below R n _ hn) + +lemma pair_color (k : ℕ) (hk : R.family = .pure k) (i : ℕ) (a : Γ) + (ha : a ∈ (TreeNode.node (blocks R) i).pair.piece.value.support) : Colors.color a = k := by + have hm := (TreeNode.node (blocks R) i).pair.piece.mem_family + (TreeNode.node (blocks R) i).pair.child_mem + have hp : (TreeNode.node (blocks R) i).pair.piece.value ∈ Norming.Pure k := by + simpa only [hk,Family.norming,Family.base,Norming.Pure] using hm + by_contra hn + exact Finsupp.mem_support_iff.mp ha (pure_vanish k _ hp a hn) + +lemma pathPartial_familyP (b : ℕ → Bool) (n : ℕ) (x : E) : + pathPartial (TreeNode.branchPath (blocks R) b) n (familyP R.cut R.family x) = + pathPartial (TreeNode.branchPath (blocks R) b) n x := by + simp only [pathPartial,← norming.evaluateArray_eq_functional] + change norming.evaluateArray _ (∑ j : Fin (n+1), (TreeNode.node (blocks R) (BinaryNodes.branch b j)).pair.piece.value) = + norming.evaluateArray _ (∑ j : Fin (n+1), (TreeNode.node (blocks R) (BinaryNodes.branch b j)).pair.piece.value) + simp only [map_sum] + apply Finset.sum_congr rfl + intro j _ + exact evaluateArray_familyP R.cut R.family x _ (pair_below R _) (fun k hk => pair_color R k hk _) + +lemma pathFunctional_familyP (b : ℕ → Bool) (x : E) : + pathFunctional (TreeNode.branchPath (blocks R) b) (familyP R.cut R.family x) = + pathFunctional (TreeNode.branchPath (blocks R) b) x := + tendsto_nhds_unique (pathPartial_tendsto _ _) ((pathPartial_tendsto _ x).congr + (fun n => (pathPartial_familyP R b n x).symm)) + +lemma pair_coefficients (i : ℕ) : ∃ c : ℕ →₀ ℝ, + c.sum (fun n a => a • (blocks R).embed n) = + norming.includeFinite (TreeNode.node (blocks R) i).pair.vector := by + have hm := (blocks R).tailSpan_mono (Nat.zero_le _) (TreeNode.node (blocks R) i).pair.mem_tail + change _ ∈ Submodule.span ℝ (Set.range (fun n => (blocks R).vector (n+0))) at hm + simp only [Nat.add_zero] at hm + obtain ⟨c,hc⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp hm + refine ⟨c,?_⟩ + rw [← hc] + simp only [Finsupp.sum,map_sum,map_smul,BlockSequence.embed] + +lemma pair_approximation (i : ℕ) : ∃ h : R.H, + ‖h‖ ≤ 501 ∧ + ‖(h : E)-norming.includeFinite (TreeNode.node (blocks R) i).pair.vector‖ ≤ 1/16 := by + obtain ⟨c,hc⟩ := pair_coefficients R i + let h : R.H := c.sum (fun n a => a • (node R n).x) + have he : ‖(h : E)-norming.includeFinite (TreeNode.node (blocks R) i).pair.vector‖ ≤ 1/16 := by + have hp := (blocks R).finite_perturbation (blocks_norm R) + (fun n => ((node R n).x : E)) error (fun n => (error_pos n).le) + (fun n => (node R n).approx.le) (1/32000) error_sum c + have hh : (h : E) = c.sum (fun n a => a • ((node R n).x : E)) := by + simp only [h,Finsupp.sum,Submodule.coe_sum,Submodule.coe_smul_of_tower] + rw [← hh,hc] at hp + have hn := (TreeNode.node (blocks R) i).pair.norm_le + linarith + refine ⟨h,?_,he⟩ + have ht := norm_le_norm_sub_add ((h : E)) (norming.includeFinite (TreeNode.node (blocks R) i).pair.vector) + have hn := (TreeNode.node (blocks R) i).pair.norm_le + change ‖(h : E)‖ ≤ 501 + linarith + +lemma separated_on_reduction {b c : ℕ → Bool} (hbc : b ≠ c) : + ∃ h : R.H, ‖h‖ ≤ 501 ∧ 1/4 ≤ + pathFunctional (TreeNode.branchPath (blocks R) b) (h : E) - + pathFunctional (TreeNode.branchPath (blocks R) c) (h : E) := by + obtain ⟨n,hn⟩ := BinaryNodes.exists_separating_node hbc + let i := BinaryNodes.branch b n + let y := norming.includeFinite (TreeNode.node (blocks R) i).pair.vector + obtain ⟨h,hh,he⟩ := pair_approximation R i + let P := pathFunctional (TreeNode.branchPath (blocks R) b) + let Q := pathFunctional (TreeNode.branchPath (blocks R) c) + have hy : 1/2 ≤ P y - Q y := by + rw [show Q y = 0 from TreeNode.pathFunctional_other (blocks R) c _ (fun j => (hn j).symm),sub_zero] + exact TreeNode.pathFunctional_node (blocks R) b n + have hb : ‖P ((h : E)-y)‖ ≤ 1/16 := by + exact (P.le_opNorm _).trans ((mul_le_mul (norm_pathFunctional_le _) he (norm_nonneg _) (by norm_num)).trans_eq (one_mul _)) + have hc : ‖Q ((h : E)-y)‖ ≤ 1/16 := by + exact (Q.le_opNorm _).trans ((mul_le_mul (norm_pathFunctional_le _) he (norm_nonneg _) (by norm_num)).trans_eq (one_mul _)) + rw [map_sub,Real.norm_eq_abs] at hb hc + refine ⟨h,hh,?_⟩ + change 1/4 ≤ P (h : E)-Q (h : E) + have hb' := (abs_le.mp hb).1 + have hc' := (abs_le.mp hc).2 + linarith + +/-- Uniformly separated path restrictions on an arbitrary closed infinite-dimensional subspace. -/ +theorem restricted_separated {b c : ℕ → Bool} (hbc : b ≠ c) : + (1/(2004*(‖R.U‖+1)) : ℝ) ≤ + ‖(pathFunctional (TreeNode.branchPath (blocks R) b)).comp F.subtypeL - + (pathFunctional (TreeNode.branchPath (blocks R) c)).comp F.subtypeL‖ := by + obtain ⟨h,hh,he⟩ := separated_on_reduction R hbc + let T := (pathFunctional (TreeNode.branchPath (blocks R) b)).comp F.subtypeL - + (pathFunctional (TreeNode.branchPath (blocks R) c)).comp F.subtypeL + have hb (b : ℕ → Bool) : pathFunctional (TreeNode.branchPath (blocks R) b) (h : E) = + pathFunctional (TreeNode.branchPath (blocks R) b) (R.U h : E) := by + rw [← R.lift h,pathFunctional_familyP] + rw [hb b,hb c] at he + have hn : ‖R.U h‖ ≤ ‖R.U‖*501 := (R.U.le_opNorm h).trans (mul_le_mul_of_nonneg_left hh (norm_nonneg _)) + have hop := (T.le_opNorm (R.U h)).trans (mul_le_mul_of_nonneg_left hn (norm_nonneg T)) + have he' : 1/4 ≤ T (R.U h) := he + rw [Real.norm_eq_abs] at hop + have hp := le_abs_self (T (R.U h)) + have hd : 0 < 2004*(‖R.U‖+1) := by positivity + apply (div_le_iff₀ hd).mpr + change 1 ≤ ‖T‖*(2004*(‖R.U‖+1)) + nlinarith [norm_nonneg T] + +end BlockApprox +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/ChangedPredual.lean b/lean/OAI/Analysis/SeparableQuotients/ChangedPredual.lean new file mode 100644 index 0000000000000000000000000000000000000000..83d6b44adbbacb458b249224e6b9b08ed4572d3f --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/ChangedPredual.lean @@ -0,0 +1,190 @@ +import OAI.Analysis.SeparableQuotients.SeparableSubspaces + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter Set TopologicalSpace +open scoped Classical Topology + +@[reducible] local instance crDualGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance crDualSpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance crSubGroup (F : Submodule ℝ E) : NormedAddCommGroup F := inferInstance +@[reducible] local instance crSubSpace (F : Submodule ℝ E) : NormedSpace ℝ F := inferInstance +@[reducible] local instance crSubDualGroup (F : Submodule ℝ E) : NormedAddCommGroup (StrongDual ℝ F) := inferInstance +@[reducible] local instance crSubDualSpace (F : Submodule ℝ E) : NormedSpace ℝ (StrongDual ℝ F) := inferInstance + +def restrict (F : Submodule ℝ E) : StrongDual ℝ E →L[ℝ] StrongDual ℝ F := + ContinuousLinearMap.precomp ℝ F.subtypeL + +lemma coordinate_restriction_countable (F : Submodule ℝ E) [SeparableSpace F] : + Set.Countable {a | restrict F (coordinate a) ≠ 0} := by + let s : Set Γ := ⋃ n : ℕ, {a | coordinate a (denseSeq F n : E) ≠ 0} + have hs : s.Countable := countable_iUnion (fun n => support_countable (denseSeq F n : E)) + apply hs.mono + intro a ha + by_contra hn + apply ha + have hz : ∀ n, coordinate a (denseSeq F n : E) = 0 := by + intro n + by_contra h + exact hn (mem_iUnion.mpr ⟨n,h⟩) + apply DFunLike.coe_injective + exact (denseRange_denseSeq F).equalizer (restrict F (coordinate a)).continuous continuous_const + (funext hz) + +/-- Restrictions of the coordinate predual to a separable subspace form a norm-separable set. -/ +lemma predual_restriction_separable (F : Submodule ℝ E) [SeparableSpace F] : + IsSeparable (restrict F '' (X₀ : Set (StrongDual ℝ E))) := by + let s := {a | restrict F (coordinate a) ≠ 0} + let Z := (Submodule.span ℝ ((fun a => restrict F (coordinate a)) '' s)).topologicalClosure + have hZ : IsSeparable (Z : Set (StrongDual ℝ F)) := + ((coordinate_restriction_countable F).image _).isSeparable.span.closure + apply hZ.mono + rintro _ ⟨y,hy,rfl⟩ + have hc : IsClosed ((Z.comap (restrict F).toLinearMap) : Set (StrongDual ℝ E)) := + (Submodule.isClosed_topologicalClosure _).preimage (restrict F).continuous + have hin : Submodule.span ℝ (range coordinate) ≤ Z.comap (restrict F).toLinearMap := by + apply Submodule.span_le.mpr + rintro _ ⟨a,rfl⟩ + change restrict F (coordinate a) ∈ Z + by_cases h : restrict F (coordinate a) = 0 + · rw [h]; exact Z.zero_mem + · exact Submodule.le_topologicalClosure _ (Submodule.subset_span ⟨a,h,rfl⟩) + exact (Submodule.topologicalClosure_minimal _ hin hc) hy + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter Set TopologicalSpace +open scoped Classical Topology + +@[reducible] local instance atDualGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance atDualSpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +local instance atXClosed : IsClosed (X₀ : Set (StrongDual ℝ E)) := norming.predual_isClosed +@[reducible] local instance atWGroup : NormedAddCommGroup W := inferInstance +@[reducible] local instance atWSpace : NormedSpace ℝ W := inferInstance + +@[reducible] local instance atX0Group : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance atX0Space : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance atX0DualGroup : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance atX0DualSpace : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma eval0_isometry : Isometry (evalOn X₀) := norming.evaluationIsometry.isometry +lemma eval0_surjective : Function.Surjective (evalOn X₀) := evaluation_surjective + +variable (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) + +/-- The changed predual is the kernel of the perturbed quotient map. -/ +def X : Submodule ℝ (StrongDual ℝ E) := (X₀.mkQL - B hCH).ker +instance X_isClosed : IsClosed (X hCH : Set (StrongDual ℝ E)) := (X₀.mkQL - B hCH).isClosed_ker +instance X_complete : CompleteSpace (X hCH) := (X_isClosed hCH).completeSpace_coe + +lemma twist_data : + (∃ R : E ≃L[ℝ] StrongDual ℝ (X hCH), + ∀ (e : E) (x : X hCH), R e x = (x : StrongDual ℝ E) e) ∧ + ((X hCH).map (B hCH).toLinearMap).topologicalClosure = + (X₀.map (B hCH).toLinearMap).topologicalClosure := by + exact (twist X₀ eval0_isometry eval0_surjective (B hCH) (norm_B_le hCH) (B_adjoint hCH) + (B_range_mem_predual_closure hCH)).2 + +@[reducible] local instance atXGroup : NormedAddCommGroup (X hCH) := inferInstance +@[reducible] local instance atXSpace : NormedSpace ℝ (X hCH) := inferInstance +@[reducible] local instance atXDualGroup : NormedAddCommGroup (StrongDual ℝ (X hCH)) := inferInstance +@[reducible] local instance atXDualSpace : NormedSpace ℝ (StrongDual ℝ (X hCH)) := inferInstance + +def twistedIso : E ≃L[ℝ] StrongDual ℝ (X hCH) := (twist_data hCH).1.choose +@[simp] lemma twistedIso_apply (e : E) (x : X hCH) : + twistedIso hCH e x = (x : StrongDual ℝ E) e := (twist_data hCH).1.choose_spec e x + +lemma X_infinite : ¬ FiniteDimensional ℝ (X hCH) := by + intro hh + let := hh + have : FiniteDimensional ℝ (StrongDual ℝ (X hCH)) := inferInstance + exact infiniteDimensional (FiniteDimensional.of_injective (twistedIso hCH).toLinearMap (twistedIso hCH).injective) + +lemma quotient_eq_B_on_X (x : X hCH) : X₀.mkQL x = B hCH x := by + have h := x.property + change X₀.mkQL x - B hCH x = 0 at h + exact sub_eq_zero.mp h + +lemma X_quotient_image : (X hCH).map X₀.mkQ = (X hCH).map (B hCH).toLinearMap := by + apply le_antisymm + · rintro _ ⟨x,hx,rfl⟩ + exact ⟨x,hx,(quotient_eq_B_on_X hCH ⟨x,hx⟩).symm⟩ + · rintro _ ⟨x,hx,rfl⟩ + exact ⟨x,hx,quotient_eq_B_on_X hCH ⟨x,hx⟩⟩ + +lemma path_mem_twisted_sum {f : Family} (P : InfinitePath f) : + pathFunctional P ∈ ((X hCH) ⊔ X₀).topologicalClosure := by + apply quotient_closure_lift X₀ (X hCH) + rw [X_quotient_image, (twist_data hCH).2] + let p : PathIndex f := ⟨P.raw,⟨P,rfl⟩⟩ + have he : pathFunctional p.repr = pathFunctional P := pathFunctional_eq_of_raw p.repr_raw + have hm := pathCoset_mem_B_predual hCH f p + apply Submodule.le_topologicalClosure _ + simpa only [pathCoset,he] using hm + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter Set TopologicalSpace +open scoped Classical Topology + +@[reducible] local instance chDualGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance chDualSpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance chSubGroup (F : Submodule ℝ E) : NormedAddCommGroup F := inferInstance +@[reducible] local instance chSubSpace (F : Submodule ℝ E) : NormedSpace ℝ F := inferInstance +@[reducible] local instance chSubDualGroup (F : Submodule ℝ E) : NormedAddCommGroup (StrongDual ℝ F) := inferInstance +@[reducible] local instance chSubDualSpace (F : Submodule ℝ E) : NormedSpace ℝ (StrongDual ℝ F) := inferInstance + +variable (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) + +/-- The branch obstruction for the changed predual, using the open quotient map. -/ +lemma X_restriction_nonseparable (F : Submodule ℝ E) (hF : IsClosed (F : Set E)) + (hFi : ¬ FiniteDimensional ℝ F) [SeparableSpace F] : + ¬ IsSeparable (restrict F '' (X hCH : Set (StrongDual ℝ E))) := by + intro hsep + let s := restrict F '' (X hCH : Set (StrongDual ℝ E)) ∪ + restrict F '' (X₀ : Set (StrongDual ℝ E)) + let Z := (Submodule.span ℝ s).topologicalClosure + have hZ : IsSeparable (Z : Set (StrongDual ℝ F)) := + (hsep.union (predual_restriction_separable F)).span.closure + have hin : X hCH ⊔ X₀ ≤ Z.comap (restrict F).toLinearMap := by + apply sup_le + · intro y hy + exact Submodule.le_topologicalClosure _ (Submodule.subset_span (Or.inl ⟨y,hy,rfl⟩)) + · intro y hy + exact Submodule.le_topologicalClosure _ (Submodule.subset_span (Or.inr ⟨y,hy,rfl⟩)) + have hc : IsClosed ((Z.comap (restrict F).toLinearMap) : Set (StrongDual ℝ E)) := + (Submodule.isClosed_topologicalClosure _).preimage (restrict F).continuous + have hp {f : Family} (P : InfinitePath f) : restrict F (pathFunctional P) ∈ Z := + (Submodule.topologicalClosure_minimal _ hin hc) (path_mem_twisted_sum hCH P) + let R : BranchReduction F := Classical.choice (exists_branchReduction F hF hFi) + let ψ : (ℕ → Bool) → StrongDual ℝ F := fun b => + restrict F (pathFunctional (TreeNode.branchPath (BlockApprox.blocks R) b)) + have hsψ : IsSeparable (range ψ) := hZ.mono (by + rintro _ ⟨b,rfl⟩ + exact hp _) + apply boolSeq_uncountable + apply countable_of_separated_range ψ hsψ (1/(2004*(‖R.U‖+1))) (by positivity) + intro b c hbc + rw [dist_eq_norm] + exact BlockApprox.restricted_separated R hbc + +lemma X_no_separableQuotient : ¬ HasSeparableQuotient ℝ (X hCH) := by + intro hsq + obtain ⟨F,hF,hFi,hFs,hsep⟩ := separable_restriction_of_quotient + (twistedIso hCH) (X hCH).subtypeL (twistedIso_apply hCH) hsq + let := hFs.separableSpace + apply X_restriction_nonseparable hCH F hF hFi + apply hsep.mono + rintro _ ⟨x,hx,rfl⟩ + exact ⟨⟨x,hx⟩,rfl⟩ + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/CoherentClosures.lean b/lean/OAI/Analysis/SeparableQuotients/CoherentClosures.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7ba56888f7b8c7943a754958da121778b3c6e10 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/CoherentClosures.lean @@ -0,0 +1,329 @@ +import OAI.Analysis.SeparableQuotients.EvaluationCriterion + +namespace OAI + +namespace SeparableQuotient.CoherentClosures + +open Set +universe u +variable {Γ : Type u} [LinearOrder Γ] + +/-- Finite closures on the strict initial segment at β. -/ +abbrev PreSystem (β : Γ) := Set.Iio β → ℕ → Finset Γ + +/-- Coherence conditions below β. -/ +structure PreGood (β : Γ) (G : PreSystem β) : Prop where + lower : ∀ (a : Set.Iio β) n, ∀ x ∈ G a n, x ≤ a.val + self : ∀ (a : Set.Iio β) n, a.val ∈ G a n + mono : ∀ a : Set.Iio β, Monotone (G a) + exhaust : ∀ (a : Set.Iio β) x, x ≤ a.val → ∃ n, x ∈ G a n + coherent : ∀ (a b : Set.Iio β) n, b.val ∈ G a n → + G b n = (G a n).filter (fun x => x ≤ b.val) + +/-- The closure conditions at a new endpoint, relative to earlier closures. -/ +structure ExtensionGood (β : Γ) (G : PreSystem β) (H : ℕ → Finset Γ) : Prop where + lower : ∀ n, ∀ x ∈ H n, x ≤ β + self : ∀ n, β ∈ H n + mono : Monotone H + exhaust : ∀ x, x ≤ β → ∃ n, x ∈ H n + coherent : ∀ (a : Set.Iio β) n, a.val ∈ H n → + G a n = (H n).filter (fun x => x ≤ a.val) + +/-- A threshold beyond which two specified earlier coordinates are recorded. -/ +lemma exists_next_threshold {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (a b : Set.Iio β) (p : ℕ) : + ∃ q > p, a.val ∈ G (max a b) q ∧ b.val ∈ G (max a b) q := by + obtain ⟨i, hi⟩ := hg.exhaust (max a b) a.val (le_max_left _ _) + obtain ⟨j, hj⟩ := hg.exhaust (max a b) b.val (le_max_right _ _) + refine ⟨max (max i j) (p + 1), ?_, ?_, ?_⟩ + · exact lt_of_lt_of_le (Nat.lt_succ_self p) (le_max_right _ _) + · exact hg.mono (max a b) (le_trans (le_max_left _ _) (le_max_left _ _)) hi + · exact hg.mono (max a b) (le_trans (le_max_right _ _) (le_max_left _ _)) hj + +/-- Each stage of the endpoint construction keeps one earlier endpoint and an +activation threshold. The next endpoint is the maximum of the old endpoint +and the next enumerated predecessor. -/ +noncomputable def stage {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) : ℕ → Set.Iio β × ℕ + | 0 => (e 0, 0) + | n+1 => let v := stage hg e n + (max v.1 (e (n+1)), (exists_next_threshold hg v.1 (e (n+1)) v.2).choose) + +lemma stage_zero {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) : stage hg e 0 = (e 0, 0) := rfl + +lemma stage_succ_threshold {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (n : ℕ) : + (stage hg e n).2 < (stage hg e (n+1)).2 ∧ + (stage hg e n).1.val ∈ G (stage hg e (n+1)).1 (stage hg e (n+1)).2 ∧ + (e (n+1)).val ∈ G (stage hg e (n+1)).1 (stage hg e (n+1)).2 := by + exact (exists_next_threshold hg (stage hg e n).1 (e (n+1)) + (stage hg e n).2).choose_spec + +lemma stage_threshold_strictMono {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) : StrictMono (fun n => (stage hg e n).2) := + strictMono_nat_of_lt_succ fun n => (stage_succ_threshold hg e n).1 + +lemma stage_threshold_ge {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (n : ℕ) : n ≤ (stage hg e n).2 := + (stage_threshold_strictMono hg e).id_le n + +/-- The last activated stage at parameter p. -/ +noncomputable def active {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (p : ℕ) : ℕ := + Nat.findGreatest (fun n => (stage hg e n).2 ≤ p) p + +lemma active_threshold {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (p : ℕ) : (stage hg e (active hg e p)).2 ≤ p := by + exact Nat.findGreatest_spec (P := fun n => (stage hg e n).2 ≤ p) + (Nat.zero_le p) (show (stage hg e 0).2 ≤ p from Nat.zero_le p) + +lemma stage_le_active {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) {n p : ℕ} (h : (stage hg e n).2 ≤ p) : + n ≤ active hg e p := + Nat.le_findGreatest (le_trans (stage_threshold_ge hg e n) h) h + +lemma active_mono {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) : Monotone (active hg e) := by + intro p q hpq + exact stage_le_active hg e (le_trans (active_threshold hg e p) hpq) + +lemma active_at_threshold {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (n : ℕ) : active hg e (stage hg e n).2 = n := by + apply le_antisymm + · exact (stage_threshold_strictMono hg e).le_iff_le.mp (active_threshold hg e _) + · exact stage_le_active hg e le_rfl + +/-- Earlier stage closures embed in later ones once the later stage is active. -/ +lemma stage_subset_succ {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (n p : ℕ) (hp : (stage hg e (n+1)).2 ≤ p) : + G (stage hg e n).1 p ⊆ G (stage hg e (n+1)).1 p := by + have hm := hg.mono (stage hg e (n+1)).1 hp (stage_succ_threshold hg e n).2.1 + rw [hg.coherent (stage hg e (n+1)).1 (stage hg e n).1 p hm] + exact Finset.filter_subset _ _ + +lemma stage_subset {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) {n m p : ℕ} (hnm : n ≤ m) + (hp : (stage hg e m).2 ≤ p) : G (stage hg e n).1 p ⊆ G (stage hg e m).1 p := by + induction m, hnm using Nat.le_induction with + | base => exact le_rfl + | succ m hnm ih => + apply Finset.Subset.trans (ih ((stage_threshold_strictMono hg e).monotone + (Nat.le_succ m) |>.trans hp)) + exact stage_subset_succ hg e m p hp + +/-- The new closure: keep the activated earlier closure and append β. -/ +noncomputable def extended {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (p : ℕ) : Finset Γ := + insert β (G (stage hg e (active hg e p)).1 p) + +lemma extended_good {β : Γ} {G : PreSystem β} (hg : PreGood β G) + (e : ℕ → Set.Iio β) (he : Function.Surjective e) : + ExtensionGood β G (extended hg e) := by + classical + constructor + · intro n x hx + rcases Finset.mem_insert.mp hx with rfl | hx + · exact le_rfl + · exact (hg.lower _ _ _ hx).trans (stage hg e (active hg e n)).1.property.le + · intro n + exact Finset.mem_insert_self _ _ + · intro p q hpq + apply Finset.insert_subset_insert + exact (hg.mono _ hpq).trans + (stage_subset hg e (active_mono hg e hpq) (active_threshold hg e q)) + · intro x hx + rcases lt_or_eq_of_le hx with hx | rfl + · obtain ⟨i, hi⟩ := he ⟨x, hx⟩ + refine ⟨(stage hg e i).2, Finset.mem_insert_of_mem ?_⟩ + rw [active_at_threshold] + cases i with + | zero => simpa [stage_zero, hi] using hg.self (e 0) 0 + | succ i => simpa only [hi] using (stage_succ_threshold hg e i).2.2 + · exact ⟨0, Finset.mem_insert_self _ _⟩ + · intro a n ha + have hab : a.val ≠ β := ne_of_lt a.property + have ha' := (Finset.mem_insert.mp ha).resolve_left hab + rw [hg.coherent _ a n ha'] + apply Finset.ext + intro x + simp only [extended, Finset.mem_filter, Finset.mem_insert] + constructor + · rintro ⟨hx, hxa⟩; exact ⟨Or.inr hx, hxa⟩ + · rintro ⟨rfl | hx, hxa⟩ + · exact (not_le_of_gt a.property hxa).elim + · exact ⟨hx, hxa⟩ + +/-- Empty strict segments require no recursive information. -/ +lemma singleton_good {β : Γ} {G : PreSystem β} (h : IsEmpty (Set.Iio β)) : + ExtensionGood β G (fun _ => {β}) := by + classical + constructor + · intro n x hx; exact (Finset.mem_singleton.mp hx).le + · intro n; simp + · intro p q hpq; exact le_rfl + · intro x hx + have he : x = β := (lt_or_eq_of_le hx).resolve_left fun hlt => h.false ⟨x, hlt⟩ + subst x; exact ⟨0, by simp⟩ + · intro a; exact h.false a |>.elim + +/-- Countability of the strict segment suffices to extend the coherent system. -/ +lemma exists_extension {β : Γ} [Countable (Set.Iio β)] + {G : PreSystem β} (hg : PreGood β G) : + ∃ H : ℕ → Finset Γ, ExtensionGood β G H := by + classical + cases isEmpty_or_nonempty (Set.Iio β) with + | inl h => exact ⟨fun _ => {β}, singleton_good h⟩ + | inr h => + let := h + obtain ⟨e, he⟩ := exists_surjective_nat (Set.Iio β) + exact ⟨extended hg e, extended_good hg e he⟩ + +/-- Full endpoint property for a total system. -/ +structure GoodAt (F : Γ → ℕ → Finset Γ) (β : Γ) : Prop where + lower : ∀ n, ∀ x ∈ F β n, x ≤ β + self : ∀ n, β ∈ F β n + mono : Monotone (F β) + exhaust : ∀ x, x ≤ β → ∃ n, x ∈ F β n + coherent : ∀ α n, α ∈ F β n → F α n = (F β n).filter (fun x => x ≤ α) + +variable [WellFoundedLT Γ] [∀ β : Γ, Countable (Set.Iio β)] + +/-- The recursion step is defined even on bad predecessor data; the bad branch +is never used in the well-founded construction. -/ +noncomputable def next (β : Γ) (G : PreSystem β) : ℕ → Finset Γ := by + classical + exact if h : PreGood β G then (exists_extension h).choose else fun _ => {β} + +omit [WellFoundedLT Γ] in +lemma next_good (β : Γ) (G : PreSystem β) (h : PreGood β G) : + ExtensionGood β G (next β G) := by + classical + rw [next, dite_eq_left h] + exact (exists_extension h).choose_spec + +/-- The actual coherently nested finite closures on the well-order. -/ +noncomputable def system : Γ → ℕ → Finset Γ := + WellFounded.fix wellFounded_lt fun β rec => next β (fun a => rec a.val a.property) + +lemma system_eq (β : Γ) : system β = next β (fun a => system a.val) := by + rw [system, WellFounded.fix_eq] + +/-- Transfinite induction establishes the coherent closure properties. -/ +theorem system_goodAt (β : Γ) : GoodAt system β := by + classical + refine (wellFounded_lt : WellFounded ((· < ·) : Γ → Γ → Prop)).induction β ?_ + intro β ih + have hg : PreGood β (fun a => system a.val) := by + constructor + · intro a; exact (ih a.val (Set.mem_Iio.mp a.property)).lower + · intro a; exact (ih a.val (Set.mem_Iio.mp a.property)).self + · intro a; exact (ih a.val (Set.mem_Iio.mp a.property)).mono + · intro a; exact (ih a.val (Set.mem_Iio.mp a.property)).exhaust + · intro a b n hb; exact (ih a.val (Set.mem_Iio.mp a.property)).coherent b.val n hb + have he := next_good β (fun a => system a.val) hg + rw [← system_eq] at he + refine ⟨he.lower, he.self, he.mono, he.exhaust, ?_⟩ + intro α n hα + rcases lt_or_eq_of_le (he.lower n α hα) with hlt | rfl + · exact he.coherent ⟨α, hlt⟩ n hα + · exact (Finset.filter_eq_self.mpr fun x hx => he.lower n x hx).symm + +/-- Coherent finite closures on a well-order with countable initial segments, indexed from zero. -/ +theorem exists_coherent_closures : ∃ F : Γ → ℕ → Finset Γ, + (∀ β n, β ∈ F β n) ∧ + (∀ β n x, x ∈ F β n → x ≤ β) ∧ + (∀ β, Monotone (F β)) ∧ + (∀ β x, x ≤ β → ∃ n, x ∈ F β n) ∧ + (∀ β α n, α ∈ F β n → F α n = (F β n).filter (fun x => x ≤ α)) := by + refine ⟨system, ?_, ?_, ?_, ?_, ?_⟩ + · intro β; exact (system_goodAt β).self + · intro β; exact (system_goodAt β).lower + · intro β; exact (system_goodAt β).mono + · intro β; exact (system_goodAt β).exhaust + · intro β; exact (system_goodAt β).coherent + +end SeparableQuotient.CoherentClosures + +namespace SeparableQuotient.CoherentClosures + +open Set + +/-- The coordinate set of the negative construction is really ω₁. -/ +abbrev OmegaOne := (Cardinal.aleph 1).ord.ToType + +instance omegaOne_initialSegment_countable (β : OmegaOne) : Countable (Set.Iio β) := by + apply Cardinal.mk_le_aleph0_iff.mp + apply Cardinal.lt_aleph_one_iff.mp + have h := Cardinal.mk_Iio_lt β (by simp [OmegaOne]) + simpa [OmegaOne] using h + +/-- Positive-indexed finite closures. -/ +noncomputable def F (β : OmegaOne) (p : ℕ) : Finset OmegaOne := + system β (p - 1) + +lemma F_self (β : OmegaOne) (p : ℕ) : β ∈ F β p := + (system_goodAt β).self (p - 1) + +lemma F_lower (β : OmegaOne) (p : ℕ) (α : OmegaOne) (h : α ∈ F β p) : α ≤ β := + (system_goodAt β).lower (p - 1) α h + +lemma F_mono (β : OmegaOne) : Monotone (F β) := by + intro p q hpq + exact (system_goodAt β).mono (Nat.sub_le_sub_right hpq 1) + +lemma F_exhaust (β α : OmegaOne) (h : α ≤ β) : ∃ p ≥ 1, α ∈ F β p := by + obtain ⟨n, hn⟩ := (system_goodAt β).exhaust α h + exact ⟨n+1, by omega, by simpa [F] using hn⟩ + +lemma F_coherent (β α : OmegaOne) (p : ℕ) (h : α ∈ F β p) : + F α p = (F β p).filter (fun x => x ≤ α) := + (system_goodAt β).coherent α (p - 1) h + +/-- Two closures containing α have the same ordered initial segment through α. -/ +lemma shared_initial_segment (β γ α : OmegaOne) (p : ℕ) + (hβ : α ∈ F β p) (hγ : α ∈ F γ p) : + (F β p).filter (fun x => x ≤ α) = (F γ p).filter (fun x => x ≤ α) := by + rw [← F_coherent β α p hβ, ← F_coherent γ α p hγ] + +/-- The first positive parameter at which α enters the closure of β. The +irrelevant case α > β is set to zero. -/ +noncomputable def rho (α β : OmegaOne) : ℕ := by + classical + exact if h : α ≤ β then Nat.find ((system_goodAt β).exhaust α h) + 1 else 0 + +lemma rho_pos (α β : OmegaOne) (h : α ≤ β) : 1 ≤ rho α β := by + classical + simp only [rho, dite_eq_left h] + omega + +lemma mem_F_rho (α β : OmegaOne) (h : α ≤ β) : α ∈ F β (rho α β) := by + classical + simp only [rho, dite_eq_left h, F, Nat.add_sub_cancel] + exact Nat.find_spec ((system_goodAt β).exhaust α h) + +lemma rho_le_iff (α β : OmegaOne) (h : α ≤ β) (p : ℕ) (hp : 1 ≤ p) : + rho α β ≤ p ↔ α ∈ F β p := by + classical + constructor + · intro hr + exact F_mono β hr (mem_F_rho α β h) + · intro ha + have hn := Nat.find_min' ((system_goodAt β).exhaust α h) ha + simp only [rho, dite_eq_left h] + omega + +/-- A finite nonempty set is contained in a common closure of its largest +coordinate, with one positive parameter for all its elements. -/ +lemma finite_cover {A : Finset OmegaOne} (hA : A.Nonempty) : + ∃ p ≥ 1, A ⊆ F (A.max' hA) p := by + classical + let p := A.sup (fun α => rho α (A.max' hA)) + refine ⟨max 1 p, le_max_left _ _, ?_⟩ + intro α hα + apply (rho_le_iff α (A.max' hA) (Finset.le_max' _ _ hα) _ (le_max_left _ _)).mp + exact (Finset.le_sup (f := fun α => rho α (A.max' hA)) hα).trans (le_max_right _ _) + +end SeparableQuotient.CoherentClosures + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/ColorDecomposition.lean b/lean/OAI/Analysis/SeparableQuotients/ColorDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..95a4ba336eae4bb42c5c53d1aa3bedc88cf96bde --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/ColorDecomposition.lean @@ -0,0 +1,378 @@ +import OAI.Analysis.SeparableQuotients.FiniteLp + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma convex_sum_le_one {E : Type*} [AddCommGroup E] [Module ℚ E] + {S : Set E} (hS : Convex ℚ S) (h0 : (0 : E) ∈ S) + {ι : Type*} [Fintype ι] (a : ι → ℚ) (x : ι → E) + (ha : ∀ i, 0 ≤ a i) (hs : ∑ i, a i ≤ 1) (hx : ∀ i, x i ∈ S) : + (∑ i, a i • x i) ∈ S := by + let w : Option ι → ℚ := fun i => i.elim (1 - ∑ j, a j) a + let z : Option ι → E := fun i => i.elim 0 x + have hw : ∀ i ∈ (Finset.univ : Finset (Option ι)), 0 ≤ w i := by + rintro (_ | i) _ + · exact sub_nonneg.mpr hs + · exact ha i + have hs' : ∑ i, w i = 1 := by simp [w, Fintype.sum_option] + have hz : ∀ i ∈ (Finset.univ : Finset (Option ι)), z i ∈ S := by + rintro (_ | i) _ + · exact h0 + · exact hx i + simpa [w, z, Fintype.sum_option] using hS.sum_mem hw hs' hz + +lemma absConvex_sum_le_one {E : Type*} [AddCommGroup E] [Module ℚ E] + {S : Set E} (hS : AbsConvex ℚ S) (h0 : (0 : E) ∈ S) + {ι : Type*} [Fintype ι] (a : ι → ℚ) (x : ι → E) + (hs : ∑ i, |a i| ≤ 1) (hx : ∀ i, x i ∈ S) : + (∑ i, a i • x i) ∈ S := by + let z : ι → E := fun i => if 0 ≤ a i then x i else -x i + have hz : ∀ i, z i ∈ S := by + intro i + dsimp [z] + split_ifs + · exact hx i + · exact hS.1.neg_mem_iff.mpr (hx i) + have heq : ∀ i, |a i| • z i = a i • x i := by + intro i + by_cases hi : 0 ≤ a i + · simp [z, hi, abs_of_nonneg hi] + · simp [z, hi, abs_of_neg (lt_of_not_ge hi)] + simpa only [heq] using convex_sum_le_one hS.2 h0 (fun i => |a i|) z + (fun i => abs_nonneg _) hs hz + +def colorSet (k : ℕ) : Set Γ := {a | Colors.color a = k} + +def colorRestrict (k : ℕ) (A : Crop) (x : Array) : Array := + restrict (colorSet k) (restrict (A.set .mixed) x) + +lemma colorRestrict_eq (k : ℕ) (A : Crop) (x : Array) : + colorRestrict k A x = restrict (colorSet k ∩ A.set .mixed) x := + restrict_restrict _ _ _ + +lemma mixed_color_unique {n : ℕ} (v : Fin n → Array) + (h : ∀ i j, i < j → Successive .mixed (v i) (v j)) + (k : ℕ) (A : Crop) {i j : Fin n} + (hi : colorRestrict k A (v i) ≠ 0) (hj : colorRestrict k A (v j) ≠ 0) : i = j := by + have hex : ∀ x : Array, x ≠ 0 → ∃ a, x a ≠ 0 := by + intro x hx + by_contra hh + push Not at hh + exact hx (Finsupp.ext hh) + obtain ⟨a, ha⟩ := hex _ hi + obtain ⟨b, hb⟩ := hex _ hj + have ha' : a ∈ (v i).support ∧ Colors.color a = k := by + refine ⟨Finsupp.mem_support_iff.mpr ?_, ?_⟩ + · intro hz + simp [colorRestrict, hz] at ha + · by_contra hh + simp [colorRestrict, colorSet, hh] at ha + have hb' : b ∈ (v j).support ∧ Colors.color b = k := by + refine ⟨Finsupp.mem_support_iff.mpr ?_, ?_⟩ + · intro hz + simp [colorRestrict, hz] at hb + · by_contra hh + simp [colorRestrict, colorSet, hh] at hb + rcases lt_trichotomy i j with hij | hij | hij + · have hh := (h i j hij a ha'.1 b hb'.1).2 rfl + omega + · exact hij + · have hh := (h j i hij b hb'.1 a ha'.1).2 rfl + omega + +lemma colorRestrict_sum {n : ℕ} (v : Fin n → Array) + (h : ∀ i j, i < j → Successive .mixed (v i) (v j)) + (k : ℕ) (A : Crop) (i : Fin n) (hi : colorRestrict k A (v i) ≠ 0) : + colorRestrict k A (∑ j, v j) = colorRestrict k A (v i) := by + simp only [colorRestrict, restrict_sum] + apply Finset.sum_eq_single i + · intro j _ hji + by_contra hj + exact hji (mixed_color_unique v h k A hj hi) + · simp + +lemma colorRestrict_sum_zero {n : ℕ} (v : Fin n → Array) + (k : ℕ) (A : Crop) (h : ∀ i, colorRestrict k A (v i) = 0) : + colorRestrict k A (∑ j, v j) = 0 := by + simp only [colorRestrict, restrict_sum] at h ⊢ + simp only [h, Finset.sum_const_zero] + +lemma TypeI.color_decomposition (e : TypeI .mixed) (k : ℕ) (A : Crop) + {S : Set Array} (h0 : (0 : Array) ∈ S) + (h : ∀ i, colorRestrict k A (e.child i) ∈ S) : + ∃ g ∈ S, colorRestrict k A e.value = (1 / (Family.mixed.m e.weight : ℚ)) • g := by + by_cases hex : ∃ i, colorRestrict k A (e.child i) ≠ 0 + · obtain ⟨i, hi⟩ := hex + refine ⟨colorRestrict k A (e.child i), h i, ?_⟩ + simp only [TypeI.value, colorRestrict, restrict_smul] + congr 1 + exact colorRestrict_sum e.child e.successive k A i hi + · push Not at hex + refine ⟨0, h0, ?_⟩ + have hz := colorRestrict_sum_zero e.child k A hex + simp only [TypeI.value, colorRestrict, restrict_smul] at hz ⊢ + rw [hz, smul_zero] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma FinitePath.color_decomposition (P : FinitePath .mixed) (k : ℕ) (A : Crop) + {S : Set Array} (h0 : (0 : Array) ∈ S) + (h : ∀ i j, colorRestrict k A ((P.piece i).child j) ∈ S) : + ∃ (i : Fin P.length) (g : Array), g ∈ S ∧ + colorRestrict k A P.value = (1 / (Family.mixed.m (P.raw.weight i) : ℚ)) • g ∧ + (colorRestrict k A P.value ≠ 0 → P.raw.weight i ∈ P.active A) := by + by_cases hex : ∃ i : Fin P.length, colorRestrict k A (P.raw.piece i) ≠ 0 + · obtain ⟨i, hi⟩ := hex + obtain ⟨g, hg, heq⟩ := (P.piece i).color_decomposition k A h0 (h i) + have hv : colorRestrict k A P.value = colorRestrict k A (P.raw.piece i) := + colorRestrict_sum (fun i : Fin P.length => P.raw.piece i) P.mixed_successive k A i hi + refine ⟨i, g, hg, ?_, ?_⟩ + · rw [hv, ← P.value_eq, heq, P.weight_eq] + · intro _ + apply Finset.mem_image.mpr + refine ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, rfl⟩ + intro hz + apply hi + simp only [colorRestrict, hz, restrict_zero] + · push Not at hex + have hz : colorRestrict k A P.value = 0 := colorRestrict_sum_zero _ k A hex + exact ⟨⟨0, P.length_pos⟩, 0, h0, by simp [hz], by simp [hz]⟩ + +lemma TypeII.color_mem (e : TypeII .mixed) (k : ℕ) + {S : Set Array} (hS : AbsConvex ℚ S) (h0 : (0 : Array) ∈ S) + (h : ∀ b i j, colorRestrict k (e.crop b) (((e.path b).piece i).child j) ∈ S) : + restrict (colorSet k) e.value ∈ S := by + choose i g hg heq hact using fun b => + (e.path b).color_decomposition k (e.crop b) h0 (h b) + let active : Finset (Fin e.length) := Finset.univ.filter + (fun b => colorRestrict k (e.crop b) (e.path b).value ≠ 0) + let j (b : Fin e.length) : ℕ := (e.path b).raw.weight (i b) + let c (b : Fin e.length) : ℚ := + if b ∈ active then e.coefficient b / (Family.mixed.m (j b) : ℚ) else 0 + have jpos : ∀ b, 1 ≤ j b := fun b => (e.path b).valid.weight_pos _ (i b).isLt + have jinj : Set.InjOn (fun b => j b - 1) active := by + intro b hb d hd hbd + by_contra hne + have hb' := hact b (Finset.mem_filter.mp hb).2 + have hd' := hact d (Finset.mem_filter.mp hd).2 + have hsame : j b = j d := by + change j b - 1 = j d - 1 at hbd + have := jpos b + have := jpos d + omega + change j b ∈ _ at hb' + rw [hsame] at hb' + exact Finset.disjoint_left.mp (e.disjoint_active hne) hb' hd' + have hcR : ∑ b, |(c b : ℝ)| ≤ + ∑ b ∈ active, 1 / (Parameters.m Family.mixed.s (j b-1) : ℝ) := by + rw [Finset.sum_filter] + apply Finset.sum_le_sum + intro b _ + by_cases hb : b ∈ active + · have hm : 0 < (Family.mixed.m (j b) : ℝ) := by exact_mod_cast Family.mixed.m_pos _ + simp only [c, ite_eq_left hb, Rat.cast_div, Rat.cast_natCast, abs_div, abs_of_pos hm] + have hb' : colorRestrict k (e.crop b) (e.path b).value ≠ 0 := (Finset.mem_filter.mp hb).2 + simp only [ite_eq_left hb'] + exact div_le_div_of_nonneg_right (e.coefficient_le_one b) hm.le + · have hb' : ¬ colorRestrict k (e.crop b) (e.path b).value ≠ 0 := by + simpa only [active, Finset.mem_filter, Finset.mem_univ, true_and] using hb + simp [c, hb, hb'] + have hcsR : ∑ b, |(c b : ℝ)| ≤ 1 := by + calc + _ ≤ ∑ b ∈ active, 1 / (Parameters.m Family.mixed.s (j b-1) : ℝ) := hcR + _ = ∑ n ∈ active.image (fun b => j b-1), 1 / (Parameters.m Family.mixed.s n : ℝ) := by + rw [Finset.sum_image] + exact fun b hb d hd hbd => jinj hb hd hbd + _ ≤ ∑' n, 1 / (Parameters.m Family.mixed.s n : ℝ) := + Family.mixed.reciprocal_summable.sum_le_tsum _ (fun _ _ => by positivity) + _ ≤ 1 := (Parameters.reciprocal_sum_small Family.mixed.s_ge_two).le.trans (by norm_num) + have hcs : ∑ b, |c b| ≤ 1 := by exact_mod_cast hcsR + have hv : restrict (colorSet k) e.value = ∑ b, c b • g b := by + simp only [TypeII.value, restrict_sum, restrict_smul] + apply Finset.sum_congr rfl + intro b _ + change e.coefficient b • colorRestrict k (e.crop b) (e.path b).value = _ + by_cases hb : b ∈ active + · rw [heq b, smul_smul] + simp only [c, ite_eq_left hb, j, div_eq_mul_inv, one_mul] + · have hz : colorRestrict k (e.crop b) (e.path b).value = 0 := by + simpa only [active, Finset.mem_filter, Finset.mem_univ, true_and, not_not] using hb + simp [c, hb, hz] + rw [hv] + exact absConvex_sum_le_one hS h0 c g hcs hg + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped Classical + +def Crop.all : Crop := ⟨Set.univ, Set.ordConnected_univ, Set.univ, Set.ordConnected_univ⟩ + +@[simp] lemma Crop.all_set (f : Family) : Crop.all.set f = Set.univ := by + cases f <;> simp [Crop.all, Crop.set] + +@[simp] lemma restrict_univ (x : Array) : restrict Set.univ x = x := by + ext a + simp + +@[simp] lemma colorRestrict_all (k : ℕ) (x : Array) : + colorRestrict k Crop.all x = restrict (colorSet k) x := by + simp [colorRestrict] + +lemma pure_color_restrict (k l : ℕ) (x : Array) (hx : x ∈ Pure l) : + restrict (colorSet k) x = if k = l then x else 0 := by + ext a + by_cases hkl : k = l + · subst l + by_cases ha : Colors.color a = k + · simp [colorSet, ha] + · simp [colorSet, ha, pure_vanish k x hx a ha] + · by_cases ha : Colors.color a = k + · have hl : Colors.color a ≠ l := by omega + simp [colorSet, hkl, ha, pure_vanish l x hx a hl] + · simp [colorSet, hkl, ha] + +lemma mixedBase_crop (A : Crop) (x : Array) (hx : x ∈ ⋃ k, Pure k) : + restrict (A.set .mixed) x ∈ ⋃ k, Pure k := by + obtain ⟨k, hk⟩ := Set.mem_iUnion.mp hx + apply Set.mem_iUnion.mpr + refine ⟨k, ?_⟩ + rw [pure_mixed_crop k A x hk] + split_ifs + · exact pure_crop k A x hk + · exact pure_zero k + +lemma mixed_stage_crop (n : ℕ) (A : Crop) (x : Array) + (hx : x ∈ stage (⋃ k, Pure k) .mixed n) : + restrict (A.set .mixed) x ∈ stage (⋃ k, Pure k) .mixed n := + stage_crop .mixed (Set.mem_iUnion.mpr ⟨0, pure_zero 0⟩) mixedBase_crop n A x hx + +lemma mixed_stage_color_hull (k : ℕ) : + ∀ n x, x ∈ stage (⋃ l, Pure l) .mixed n → + restrict (colorSet k) x ∈ absConvexHull ℚ (Pure k) := by + have h0 : (0 : Array) ∈ absConvexHull ℚ (Pure k) := subset_absConvexHull (pure_zero k) + intro n + induction n with + | zero => + intro x hx + obtain ⟨l, hl⟩ := Set.mem_iUnion.mp hx + rw [pure_color_restrict k l x hl] + split_ifs with hkl + · subst l + exact subset_absConvexHull hl + · exact h0 + | succ n ih => + intro x hx + rcases hx with (hx | ⟨e, rfl, he⟩) | ⟨e, rfl, he⟩ + · exact ih x hx + · obtain ⟨g, hg, hv⟩ := e.color_decomposition k Crop.all h0 (fun i => by + simpa only [colorRestrict_all] using ih _ (he i)) + rw [colorRestrict_all] at hv + rw [hv] + apply (absConvex_absConvexHull (𝕜 := ℚ) (s := Pure k)).1.smul_mem ?_ hg + rw [norm_div, norm_one] + have hm : (1 : ℝ) ≤ Family.mixed.m e.weight := by exact_mod_cast Family.mixed.m_pos _ + simpa only [← Rat.norm_cast_real, Rat.cast_natCast, Real.norm_natCast, one_div, inv_one] using + (one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) hm) + · apply e.color_mem k absConvex_absConvexHull h0 + intro b i j + exact ih _ (mixed_stage_crop n (e.crop b) _ (he b i j)) + +/-- Every mixed-stage normer restricts to the absolute convex hull of the pure norming set. -/ +lemma full_color_hull (k : ℕ) (x : Array) (hx : x ∈ Full) : + restrict (colorSet k) x ∈ absConvexHull ℚ (Pure k) := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + exact mixed_stage_color_hull k n x hn + +end SeparableQuotient.Norming + +namespace SeparableQuotient.LpFinite +open scoped Classical ENNReal +universe u +variable {Γ : Type u} {p : ℝ≥0∞} [Fact (1 ≤ p)] + +lemma absConvex_norm_array : AbsConvex ℚ {f : Γ →₀ ℚ | ‖array p f‖ ≤ 1} := by + constructor + · intro a ha + rintro _ ⟨x, hx, rfl⟩ + change ‖array p (a • x)‖ ≤ 1 + rw [array_smul, norm_smul, Rat.norm_cast_real] + exact (mul_le_mul_of_nonneg_left hx (norm_nonneg a)).trans (by simpa using ha) + · intro x hx y hy a b ha hb hab + change ‖array p (a • x + b • y)‖ ≤ 1 + simp only [array_add, array_smul] + have ha' : (0 : ℝ) ≤ a := by exact_mod_cast ha + have hb' : (0 : ℝ) ≤ b := by exact_mod_cast hb + have hab' : (a : ℝ) + (b : ℝ) = 1 := by exact_mod_cast hab + calc + _ ≤ ‖(a : ℝ) • array p x‖ + ‖(b : ℝ) • array p y‖ := norm_add_le _ _ + _ = (a : ℝ) * ‖array p x‖ + (b : ℝ) * ‖array p y‖ := by + rw [norm_smul, norm_smul, Real.norm_of_nonneg ha', Real.norm_of_nonneg hb'] + _ ≤ (a : ℝ) * 1 + (b : ℝ) * 1 := add_le_add + (mul_le_mul_of_nonneg_left hx ha') (mul_le_mul_of_nonneg_left hy hb') + _ = 1 := by simpa using hab' + +end SeparableQuotient.LpFinite + +namespace SeparableQuotient.Norming +open scoped ENNReal Classical +open LpFinite + +/-- Full mixed normers retain the exact pure ℓr bound on each color. -/ +lemma full_color_lp_bound (k : ℕ) (f : Array) (hf : f ∈ Full) : + ‖array (Family.pure k).exponent (restrict (colorSet k) f)‖ ≤ 1 := + absConvexHull_min (fun x hx => pure_lp_bound k x hx) absConvex_norm_array + (full_color_hull k f hf) + +end SeparableQuotient.Norming + +namespace SeparableQuotient.LpFinite +open scoped Classical ENNReal +universe u +variable {Γ : Type u} + +/-- Real finitely supported vectors in the usual ℓp space. -/ +def realArray (p : ℝ≥0∞) (x : Γ →₀ ℝ) : lp (fun _ : Γ => ℝ) p := + ⟨fun a => x a, Memℓp.of_exponent_ge (memℓp_zero_iff.mpr x.hasFiniteSupport) (zero_le : 0 ≤ p)⟩ + +@[simp] lemma realArray_apply (p : ℝ≥0∞) (x : Γ →₀ ℝ) (a : Γ) : + realArray p x a = x a := rfl + +lemma pairing_le {p q : ℝ≥0∞} (hpq : p.toReal.HolderConjugate q.toReal) + (x : Γ →₀ ℝ) (f : Γ →₀ ℚ) : + |x.sum (fun a t => t * (f a : ℝ))| ≤ ‖realArray p x‖ * ‖array q f‖ := by + have h := lp.tsum_mul_le_mul_norm hpq (realArray p x) (array q f) + calc + _ ≤ ∑ a ∈ x.support, |x a * (f a : ℝ)| := Finset.abs_sum_le_sum_abs _ _ + _ = ∑ a ∈ x.support, ‖realArray p x a‖ * ‖array q f a‖ := by + simp only [realArray_apply, array_apply, Real.norm_eq_abs, abs_mul] + _ ≤ ∑' a, ‖realArray p x a‖ * ‖array q f a‖ := + h.1.sum_le_tsum _ (fun a _ => mul_nonneg (norm_nonneg _) (norm_nonneg _)) + _ ≤ _ := h.2 + +end SeparableQuotient.LpFinite + +namespace SeparableQuotient.Norming +open scoped ENNReal + +def Family.primalExponent (f : Family) : ℝ≥0∞ := f.s +instance Family.primalExponent_fact (f : Family) : Fact (1 ≤ f.primalExponent) := + ⟨by change (1 : ℝ≥0∞) ≤ (f.s : ℝ≥0∞); exact_mod_cast (f.s_ge_two.trans' (by omega : 1 ≤ 2))⟩ +@[simp] lemma Family.primalExponent_toReal (f : Family) : f.primalExponent.toReal = f.s := by + simp [Family.primalExponent] +lemma Family.conjugate (f : Family) : + f.primalExponent.toReal.HolderConjugate f.exponent.toReal := by + simpa only [Family.primalExponent_toReal, Family.exponent_toReal, Family.r] using + Parameters.s_r_conjugate f.s_ge_two +end SeparableQuotient.Norming + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Complexification.lean b/lean/OAI/Analysis/SeparableQuotients/Complexification.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e1cf6193f5056e693f165fbe9398cd84075fa70 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Complexification.lean @@ -0,0 +1,102 @@ +import OAI.Analysis.SeparableQuotients.NegativeReal + +namespace OAI + +noncomputable section + +/- Complexification by real-linear maps from ℂ with the operator norm and real coordinates f(1), f(i). -/ +namespace SeparableQuotient +open scoped Classical +universe u +variable (X : Type u) [NormedAddCommGroup X] [NormedSpace ℝ X] + +def Complexify := ℂ →L[ℝ] X +namespace Complexify +def toCLM (f : Complexify X) : ℂ →L[ℝ] X := f +instance : CoeFun (Complexify X) (fun _ => ℂ → X) := ⟨fun f => toCLM X f⟩ +@[ext] lemma ext {f g : Complexify X} (h : ∀ z, f z = g z) : f = g := ContinuousLinearMap.ext h + +instance : NormedAddCommGroup (Complexify X) := inferInstanceAs (NormedAddCommGroup (ℂ →L[ℝ] X)) +instance : NormedSpace ℝ (Complexify X) := inferInstanceAs (NormedSpace ℝ (ℂ →L[ℝ] X)) +instance [CompleteSpace X] : CompleteSpace (Complexify X) := inferInstanceAs (CompleteSpace (ℂ →L[ℝ] X)) + +@[simp] lemma add_apply (f g : Complexify X) (z : ℂ) : (f+g) z = f z + g z := rfl +@[simp] lemma zero_apply (z : ℂ) : (0 : Complexify X) z = 0 := rfl +@[simp] lemma apply_zero (f : Complexify X) : f 0 = 0 := (toCLM X f).map_zero +@[simp] lemma apply_add (f : Complexify X) (z w : ℂ) : f (z+w) = f z + f w := (toCLM X f).map_add _ _ +@[simp] lemma apply_smul (f : Complexify X) (r : ℝ) (z : ℂ) : f (r • z) = r • f z := (toCLM X f).map_smul _ _ + +def cmul (c : ℂ) (f : Complexify X) : Complexify X := (toCLM X f).comp ((ContinuousLinearMap.mul ℝ ℂ) c) +instance : SMul ℂ (Complexify X) := ⟨cmul X⟩ +@[simp] lemma smul_apply (c : ℂ) (f : Complexify X) (z : ℂ) : + (c • f : Complexify X) z = f (c*z) := rfl + +instance : Module ℂ (Complexify X) where + one_smul f := by ext z; simp + mul_smul c d f := by ext z; simp [mul_assoc,mul_left_comm] + smul_zero c := by ext z; rfl + smul_add c f g := by ext z; rfl + add_smul c d f := by ext z; simp [add_mul] + zero_smul f := by ext z; simp + +instance : NormedSpace ℂ (Complexify X) where + norm_smul_le c f := by + apply ContinuousLinearMap.opNorm_le_bound _ (by positivity) + intro z + change ‖f (c*z)‖ ≤ (‖c‖*‖f‖)*‖z‖ + calc + _ ≤ ‖f‖*‖c*z‖ := (toCLM X f).le_opNorm _ + _ = _ := by rw [norm_mul]; ring + +instance : IsScalarTower ℝ ℂ (Complexify X) where + smul_assoc r c f := by + ext z + change f ((r • c)*z) = r • f (c*z) + rw [smul_mul_assoc,apply_smul] + +instance : SMulCommClass ℝ ℂ (Complexify X) where + smul_comm r c f := by + ext z + change r • f (c*z) = (r • f : ℂ →L[ℝ] X) (c*z) + rfl + +def pairMap : Complexify X →L[ℝ] X × X := + (ContinuousLinearMap.apply ℝ X (1 : ℂ)).prod (ContinuousLinearMap.apply ℝ X Complex.I) + +def ofPair (p : X × X) : Complexify X := + Complex.reCLM.smulRight p.1 + Complex.imCLM.smulRight p.2 + +lemma pairMap_ofPair (p : X × X) : pairMap X (ofPair X p) = p := by + apply Prod.ext + · change ((Complex.reCLM.smulRight p.1 + Complex.imCLM.smulRight p.2) (1 : ℂ)) = p.1 + simp + · change ((Complex.reCLM.smulRight p.1 + Complex.imCLM.smulRight p.2) Complex.I) = p.2 + simp + +lemma ofPair_pairMap (f : Complexify X) : ofPair X (pairMap X f) = f := by + ext z + change z.re • f 1 + z.im • f Complex.I = f z + rw [← apply_smul,← apply_smul,← apply_add] + congr 1 + apply Complex.ext <;> simp + +def pairEquiv [CompleteSpace X] : Complexify X ≃L[ℝ] (X × X) := + (LinearEquiv.ofBijective (pairMap X).toLinearMap + ⟨Function.HasLeftInverse.injective ⟨ofPair X,ofPair_pairMap X⟩, + Function.HasRightInverse.surjective ⟨ofPair X,pairMap_ofPair X⟩⟩).toContinuousLinearEquivOfContinuous + (pairMap X).continuous + +lemma infinite [CompleteSpace X] (hX : ¬ FiniteDimensional ℝ X) : + ¬ FiniteDimensional ℂ (Complexify X) := by + intro hh + let := hh + let : FiniteDimensional ℝ (Complexify X) := FiniteDimensional.trans ℝ ℂ _ + let : FiniteDimensional ℝ (X × X) := FiniteDimensional.of_injective (pairEquiv X).symm.toLinearMap (pairEquiv X).symm.injective + exact hX (FiniteDimensional.of_injective (LinearMap.inl ℝ X X) (by intro x y h; exact Prod.mk.inj h |>.1)) + +end Complexify +end SeparableQuotient + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/CoordinateDual.lean b/lean/OAI/Analysis/SeparableQuotients/CoordinateDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..76e4f71abbef19c00acc7974f2f2f4116e3440fd --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/CoordinateDual.lean @@ -0,0 +1,261 @@ +import OAI.Analysis.SeparableQuotients.NormCompletion + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.NormConstruction.NormingSet +open scoped Topology Classical +universe u +variable {Γ : Type u} (K : NormingSet Γ) + +lemma includeFinite_injective : Function.Injective K.includeFinite := by + intro x y h + exact K.finiteMap_injective (congrArg Subtype.val h) + +lemma generator_independent : LinearIndependent ℝ K.generator := by + change LinearIndependent ℝ (fun a : Γ => K.includeFinite (Finsupp.single a 1)) + exact (Finsupp.linearIndependent_single_one (R := ℝ) (ι := Γ)).map_injOn + K.includeFinite K.includeFinite_injective.injOn + +lemma infiniteDimensional [Infinite Γ] : ¬ Module.Finite ℝ K.Space := by + intro h + let := h + exact Module.Finite.not_linearIndependent_of_infinite K.generator K.generator_independent + +@[reducible] local instance dualNormedGroup : NormedAddCommGroup (StrongDual ℝ K.Space) := inferInstance +@[reducible] local instance dualNormedSpace : NormedSpace ℝ (StrongDual ℝ K.Space) := inferInstance + +/-- The coordinate predual. -/ +def predual : Submodule ℝ (StrongDual ℝ K.Space) := + (Submodule.span ℝ (Set.range K.coordinate)).topologicalClosure + +instance predual_isClosed : IsClosed (K.predual : Set (StrongDual ℝ K.Space)) := + Submodule.isClosed_topologicalClosure _ + +lemma coordinate_mem_predual (a : Γ) : K.coordinate a ∈ K.predual := + Submodule.le_topologicalClosure _ (Submodule.subset_span ⟨a, rfl⟩) + +lemma functional_mem_predual (f : K.carrier) : K.functional f ∈ K.predual := by + rw [K.functional_eq_sum] + exact Submodule.sum_mem _ (fun a _ => + Submodule.smul_mem _ _ (K.coordinate_mem_predual a)) + +@[reducible] local instance predualDualNormedGroup : + NormedAddCommGroup (StrongDual ℝ K.predual) := inferInstance +@[reducible] local instance predualDualNormedSpace : + NormedSpace ℝ (StrongDual ℝ K.predual) := inferInstance + +/-- Canonical evaluation into the dual of the coordinate span. -/ +def evaluation : K.Space →L[ℝ] StrongDual ℝ K.predual := + (ContinuousLinearMap.precomp ℝ K.predual.subtypeL).comp + (NormedSpace.inclusionInDoubleDual ℝ K.Space) + +@[simp] lemma evaluation_apply (x : K.Space) (g : K.predual) : + K.evaluation x g = g.val x := rfl + +lemma norm_evaluation (x : K.Space) : ‖K.evaluation x‖ = ‖x‖ := by + apply le_antisymm + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg x) + intro g + exact (g.val.le_opNorm x).trans_eq (mul_comm _ _) + · change ‖x.val‖ ≤ ‖K.evaluation x‖ + apply lp.norm_le_of_forall_le (f := x.val) (norm_nonneg (K.evaluation x)) + intro f + let g : K.predual := ⟨K.functional f, K.functional_mem_predual f⟩ + calc + |K.functional f x| = ‖K.evaluation x g‖ := (Real.norm_eq_abs _).symm + _ ≤ ‖K.evaluation x‖ * ‖g‖ := (K.evaluation x).le_opNorm g + _ ≤ ‖K.evaluation x‖ * 1 := + mul_le_mul_of_nonneg_left (K.norm_functional_le f) (norm_nonneg (K.evaluation x)) + _ = _ := mul_one _ + +def evaluationIsometry : K.Space →ₗᵢ[ℝ] StrongDual ℝ K.predual where + toLinearMap := K.evaluation.toLinearMap + norm_map' := K.norm_evaluation + +end SeparableQuotient.NormConstruction.NormingSet + +namespace SeparableQuotient.NormConstruction.NormingSet +open scoped Topology Classical +open Filter +universe u +variable {Γ : Type u} (K : NormingSet Γ) + +lemma projection_norm_apply_le (A : Set Γ) (hA : K.CropStable A) (x : K.Space) : + ‖K.projection A hA x‖ ≤ ‖x‖ := + ((K.projection A hA).le_opNorm x).trans (by + simpa only [one_mul] using mul_le_mul_of_nonneg_right + (K.norm_projection_le A hA) (norm_nonneg x)) + +/-- Strong convergence of uniformly contractive coordinate crops whose sets eventually contain every coordinate. -/ +lemma tendsto_projection {ι : Type*} {l : Filter ι} (A : ι → Set Γ) + (hA : ∀ i, K.CropStable (A i)) (hcover : ∀ a, ∀ᶠ i in l, a ∈ A i) (x : K.Space) : + Tendsto (fun i => K.projection (A i) (hA i) x) l (𝓝 x) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨v, hv⟩ := K.denseRange_includeFinite.exists_dist_lt x (by positivity : (0 : ℝ) < ε/3) + have hevent : ∀ᶠ i in l, ∀ a ∈ v.support, a ∈ A i := + (v.support.eventually_all).mpr (fun a _ => hcover a) + filter_upwards [hevent] with i hi + have hvfix : K.projection (A i) (hA i) (K.includeFinite v) = K.includeFinite v := by + rw [K.projection_includeFinite] + congr 1 + ext a + by_cases ha : a ∈ A i + · simp [ha] + · have hz : v a = 0 := by + by_contra hn + exact ha (hi a (Finsupp.mem_support_iff.mpr hn)) + simp [ha, hz] + rw [dist_eq_norm] at hv ⊢ + calc + ‖K.projection (A i) (hA i) x - x‖ = + ‖K.projection (A i) (hA i) (x - K.includeFinite v) + (K.includeFinite v - x)‖ := by + rw [(K.projection (A i) (hA i)).map_sub, hvfix] + abel_nf + _ ≤ ‖K.projection (A i) (hA i) (x - K.includeFinite v)‖ + ‖K.includeFinite v - x‖ := + norm_add_le _ _ + _ ≤ ‖x - K.includeFinite v‖ + ‖K.includeFinite v - x‖ := by + gcongr + exact K.projection_norm_apply_le _ _ _ + _ < ε := by rw [norm_sub_rev (K.includeFinite v) x]; linarith + +end SeparableQuotient.NormConstruction.NormingSet + +namespace SeparableQuotient.NormConstruction.NormingSet +open scoped Topology Classical +universe u +variable {Γ : Type u} (K : NormingSet Γ) +@[reducible] local instance dualNormedGroup' : NormedAddCommGroup (StrongDual ℝ K.Space) := inferInstance +@[reducible] local instance dualNormedSpace' : NormedSpace ℝ (StrongDual ℝ K.Space) := inferInstance + +/-- The coordinate functional regarded as an element of the actual predual. -/ +def predualCoordinate (a : Γ) : K.predual := ⟨K.coordinate a, K.coordinate_mem_predual a⟩ + +def rationalPredual : (Γ →₀ ℚ) →ₗ[ℚ] K.predual := + Finsupp.linearCombination ℚ K.predualCoordinate + +lemma rationalPredual_val (f : Γ →₀ ℚ) : + (K.rationalPredual f).val = ∑ a ∈ f.support, (f a : ℝ) • K.coordinate a := by + simp only [rationalPredual, Finsupp.linearCombination_apply, Finsupp.sum] + rw [show (∑ a ∈ f.support, f a • K.predualCoordinate a).val = + ∑ a ∈ f.support, (f a • K.predualCoordinate a).val from + Submodule.coe_sum _ _ _] + congr 1 + +lemma rationalPredual_eq_functional (f : K.carrier) : + (K.rationalPredual f.val).val = K.functional f := by + rw [K.rationalPredual_val, K.functional_eq_sum] + +lemma norm_rationalPredual_le (f : Γ →₀ ℚ) (hf : f ∈ K.carrier) : + ‖K.rationalPredual f‖ ≤ 1 := by + change ‖(K.rationalPredual f).val‖ ≤ 1 + rw [K.rationalPredual_eq_functional ⟨f, hf⟩] + exact K.norm_functional_le ⟨f, hf⟩ + +@[simp] lemma rationalPredual_single (a : Γ) (q : ℚ) : + K.rationalPredual (Finsupp.single a q) = q • K.predualCoordinate a := + Finsupp.linearCombination_single _ _ _ + +lemma rationalPredual_apply (f : Γ →₀ ℚ) (x : K.Space) : + (K.rationalPredual f).val x = ∑ a ∈ f.support, (f a : ℝ) * K.coordinate a x := by + rw [K.rationalPredual_val] + simp only [sum_apply, smul_apply, smul_eq_mul] + +end SeparableQuotient.NormConstruction.NormingSet + +namespace SeparableQuotient.NormConstruction +open scoped Classical +universe u + +lemma absConvex_abs_le {V : Type u} [AddCommGroup V] [Module ℚ V] + (L : V →ₗ[ℚ] ℝ) (r : ℝ) (hr : 0 ≤ r) : AbsConvex ℚ {x | |L x| ≤ r} := by + constructor + · intro a ha + rintro _ ⟨x, hx, rfl⟩ + change |L (a • x)| ≤ r + rw [L.map_smul, Rat.smul_def, abs_mul, ← Real.norm_eq_abs (a : ℝ), Rat.norm_cast_real] + calc + _ ≤ ‖a‖ * r := mul_le_mul_of_nonneg_left hx (norm_nonneg a) + _ ≤ r := by simpa only [one_mul] using mul_le_mul_of_nonneg_right ha hr + · intro x hx y hy a b ha hb hab + change |L (a • x + b • y)| ≤ r + have ha' : (0 : ℝ) ≤ a := by exact_mod_cast ha + have hb' : (0 : ℝ) ≤ b := by exact_mod_cast hb + have hab' : (a : ℝ) + (b : ℝ) = 1 := by exact_mod_cast hab + calc + _ = |(a : ℝ) * L x + (b : ℝ) * L y| := by + simp only [L.map_add, L.map_smul, Rat.smul_def] + _ ≤ |(a : ℝ) * L x| + |(b : ℝ) * L y| := abs_add_le _ _ + _ = (a : ℝ) * |L x| + (b : ℝ) * |L y| := by + rw [abs_mul, abs_mul, abs_of_nonneg ha', abs_of_nonneg hb'] + _ ≤ (a : ℝ) * r + (b : ℝ) * r := add_le_add + (mul_le_mul_of_nonneg_left hx ha') (mul_le_mul_of_nonneg_left hy hb') + _ = r := by rw [← add_mul, hab', one_mul] + +end SeparableQuotient.NormConstruction + +namespace SeparableQuotient.NormConstruction.NormingSet +open scoped Classical +universe u +variable {Γ : Type u} (K : NormingSet Γ) +@[reducible] local instance dualNormedGroup'' : NormedAddCommGroup (StrongDual ℝ K.Space) := inferInstance +@[reducible] local instance dualNormedSpace'' : NormedSpace ℝ (StrongDual ℝ K.Space) := inferInstance + +/-- Evaluation of any rational array, not only chosen normers. -/ +def evaluateArray (x : K.Space) : (Γ →₀ ℚ) →ₗ[ℚ] ℝ where + toFun := fun f => (K.rationalPredual f).val x + map_add' := by intro f g; simp + map_smul' := by intro q f; simp + +lemma evaluateArray_eq (x : K.Space) (f : Γ →₀ ℚ) : + K.evaluateArray x f = ∑ a ∈ f.support, (f a : ℝ) * K.coordinate a x := + K.rationalPredual_apply f x + +lemma evaluateArray_eq_functional (x : K.Space) (f : K.carrier) : + K.evaluateArray x f.val = K.functional f x := by + change (K.rationalPredual f).val x = _ + rw [K.rationalPredual_eq_functional f] + +lemma norm_le_of_evaluateArray (x : K.Space) (r : ℝ) (hr : 0 ≤ r) + (h : ∀ f ∈ K.carrier, |K.evaluateArray x f| ≤ r) : ‖x‖ ≤ r := by + change ‖x.val‖ ≤ r + apply lp.norm_le_of_forall_le hr + intro f + change ‖K.functional f x‖ ≤ r + simpa only [K.evaluateArray_eq_functional x f, Real.norm_eq_abs] using h f.val f.property + +end SeparableQuotient.NormConstruction.NormingSet + +namespace SeparableQuotient.NormConstruction.NormingSet +open scoped Classical +universe u +variable {Γ : Type u} (K : NormingSet Γ) + +lemma evaluateArray_filter_of_zero (x : K.Space) (A : Set Γ) + (hx : ∀ a ∉ A, K.coordinate a x = 0) (f : Γ →₀ ℚ) : + K.evaluateArray x (f.filter (· ∈ A)) = K.evaluateArray x f := by + rw [K.evaluateArray_eq, K.evaluateArray_eq] + simp only [Finsupp.support_filter, Finset.sum_filter] + apply Finset.sum_congr rfl + intro a _ + by_cases ha : a ∈ A + · simp [ha] + · simp [ha, hx a ha] + +lemma evaluateArray_projection (x : K.Space) (A : Set Γ) (hA : K.CropStable A) + (f : Γ →₀ ℚ) : + K.evaluateArray (K.projection A hA x) f = K.evaluateArray x (f.filter (· ∈ A)) := by + rw [K.evaluateArray_eq, K.evaluateArray_eq] + simp only [Finsupp.support_filter, Finset.sum_filter] + apply Finset.sum_congr rfl + intro a _ + rw [K.coordinate_projection] + by_cases ha : a ∈ A <;> simp [ha] + +end SeparableQuotient.NormConstruction.NormingSet + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/CoordinatePredual.lean b/lean/OAI/Analysis/SeparableQuotients/CoordinatePredual.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac6befdd27652729eece5d1ebbd2e00287741fe9 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/CoordinatePredual.lean @@ -0,0 +1,436 @@ +import OAI.Analysis.SeparableQuotients.CoordinateDual + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction +open scoped Classical + +/-- The full norming set obtained from finite-stage pure and mixed operations. -/ +def norming : NormingSet Γ where + carrier := Full + coordinate_mem := Norming.coordinate_mem + coefficient_bound := full_coefficient_bound + +/-- The actual real Banach space E of the CH construction. -/ +abbrev E := norming.Space + +@[reducible] instance EGroup : NormedAddCommGroup E := inferInstanceAs (NormedAddCommGroup norming.Space) +@[reducible] instance ESpace : NormedSpace ℝ E := inferInstanceAs (NormedSpace ℝ norming.Space) +instance ETopologicalAdd : IsTopologicalAddGroup E := + SeminormedAddCommGroup.toIsTopologicalAddGroup +instance EContinuousAdd : ContinuousAdd E := ETopologicalAdd.toContinuousAdd + +instance : CompleteSpace E := inferInstanceAs (CompleteSpace norming.Space) + +instance : Infinite Γ := Cardinal.infinite_iff.mpr (by + simp [Γ, CoherentClosures.OmegaOne]) + +lemma infiniteDimensional : ¬ Module.Finite ℝ E := norming.infiniteDimensional + +abbrev e (a : Γ) : E := norming.generator a +abbrev coordinate (a : Γ) : StrongDual ℝ E := norming.coordinate a + +lemma norm_e (a : Γ) : ‖e a‖ = 1 := norming.norm_generator a + +lemma support_countable (x : E) : Set.Countable {a | coordinate a x ≠ 0} := + norming.support_countable x + +lemma coordinate_ext (x y : E) (h : ∀ a, coordinate a x = coordinate a y) : x = y := + norming.coordinate_ext h + +lemma cropStable (A : Crop) : norming.CropStable (A.set .mixed) := + full_crop A + +/-- Every ordinal/color rectangle projection is defined on the full completion. -/ +def projection (A : Crop) : E →L[ℝ] E := norming.projection (A.set .mixed) (cropStable A) + +lemma norm_projection_le (A : Crop) (x : E) : ‖projection A x‖ ≤ ‖x‖ := + ((norming.projection (A.set .mixed) (cropStable A)).le_opNorm x).trans (by + simpa only [one_mul] using mul_le_mul_of_nonneg_right + (norming.norm_projection_le (A.set .mixed) (cropStable A)) (norm_nonneg x)) + +lemma coordinate_projection (A : Crop) (x : E) (a : Γ) : + coordinate a (projection A x) = if a ∈ A.set .mixed then coordinate a x else 0 := + norming.coordinate_projection (A.set .mixed) (cropStable A) a x + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction LpFinite +open scoped Classical ENNReal + +/-- The ℓs-coordinate estimate on finite vectors. -/ +lemma norm_includeFinite_on_color (k : ℕ) (x : Γ →₀ ℝ) + (hx : ∀ a ∈ x.support, Colors.color a = k) : + ‖norming.includeFinite x‖ ≤ ‖realArray (Family.pure k).primalExponent x‖ := by + change ‖norming.finiteMap x‖ ≤ ‖realArray (Family.pure k).primalExponent x‖ + apply lp.norm_le_of_forall_le (norm_nonneg _) + intro f + rw [norming.finiteMap_apply] + have heq : x.sum (fun a t => t * (f.val a : ℝ)) = + x.sum (fun a t => t * (restrict (colorSet k) f.val a : ℝ)) := by + apply Finset.sum_congr rfl + intro a ha + simp only [restrict_apply, colorSet, Set.mem_ofPred_eq, hx a ha, ↓reduceIte] + rw [heq] + calc + _ ≤ ‖realArray (Family.pure k).primalExponent x‖ * + ‖array (Family.pure k).exponent (restrict (colorSet k) f.val)‖ := + pairing_le (Family.conjugate (.pure k)) _ _ + _ ≤ _ := by + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (full_color_lp_bound k f.val f.property) + (norm_nonneg (realArray (Family.pure k).primalExponent x)) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma Family.L_pos (f : Family) (j : ℕ) : 0 < f.L j := Parameters.L_pos _ _ + +/-- Every finite successive family of existing normers has its prescribed +Type I average in the same actual family. -/ +lemma pure_typeI_mem (k : ℕ) (e : TypeI (.pure k)) + (h : ∀ i, e.child i ∈ Pure k) : e.value ∈ Pure k := by + classical + choose n hn using (fun i => Set.mem_iUnion.mp (h i)) + let N := Finset.univ.sup n + have hn' : ∀ i, e.child i ∈ stage (pureBase k) (.pure k) N := by + intro i + exact stage_mono _ _ (Finset.le_sup (f := n) (Finset.mem_univ i)) (hn i) + exact Set.mem_iUnion.mpr ⟨N+1, Or.inl (Or.inr ⟨e, rfl, hn'⟩)⟩ + +lemma mixed_typeI_mem (e : TypeI .mixed) + (h : ∀ i, e.child i ∈ Full) : e.value ∈ Full := by + classical + choose n hn using (fun i => Set.mem_iUnion.mp (h i)) + let N := Finset.univ.sup n + have hn' : ∀ i, e.child i ∈ stage (⋃ k, Pure k) .mixed N := by + intro i + exact stage_mono _ _ (Finset.le_sup (f := n) (Finset.mem_univ i)) (hn i) + exact Set.mem_iUnion.mpr ⟨N+1, Or.inl (Or.inr ⟨e, rfl, hn'⟩)⟩ + +/-- A concrete signed coordinate Type I expression. -/ +def coordinateAverage (k j n : ℕ) (hj : 1 ≤ j) (hn : 1 ≤ n) + (hnj : n ≤ (Family.pure k).L j) (a : Fin n ↪o Γ) + (c : Fin n → ℚ) (hc : ∀ i, c i ≠ 0) : TypeI (.pure k) where + weight := j + weight_pos := hj + length := n + length_pos := hn + length_le := hnj + child := fun i => Finsupp.single (a i) (c i) + child_nonzero := fun i => by simpa using hc i + successive := by + intro i l hil α hα β hβ + have hα' : α = a i := by simpa [Finsupp.support_single _ (hc i)] using hα + have hβ' : β = a l := by simpa [Finsupp.support_single _ (hc l)] using hβ + subst α; subst β + exact ⟨a.strictMono hil, by simp⟩ + +lemma coordinateAverage_mem (k j n : ℕ) (hj : 1 ≤ j) (hn : 1 ≤ n) + (hnj : n ≤ (Family.pure k).L j) (a : Fin n ↪o Γ) + (ha : ∀ i, Colors.color (a i) = k) (c : Fin n → ℚ) + (hc : ∀ i, c i ≠ 0) (hsign : ∀ i, c i = 1 ∨ c i = -1) : + (coordinateAverage k j n hj hn hnj a c hc).value ∈ Full := by + apply pure_subset_full k + apply pure_typeI_mem + intro i + apply Set.mem_iUnion.mpr + refine ⟨0, Or.inr ⟨a i, ha i, ?_⟩⟩ + rcases hsign i with hi | hi <;> simp [coordinateAverage, hi] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction +open scoped Classical + +abbrev X₀ := norming.predual +abbrev coordinate₀ (a : Γ) : X₀ := norming.predualCoordinate a + +@[reducible] local instance dualEGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma signed_coordinate_bound (g : StrongDual ℝ X₀) + (k j n : ℕ) (hj : 1 ≤ j) (hn : 1 ≤ n) (hnj : n ≤ (Family.pure k).L j) + (a : Fin n ↪o Γ) (ha : ∀ i, Colors.color (a i) = k) : + (1 / ((Family.pure k).m j : ℝ)) * ∑ i, |g (coordinate₀ (a i))| ≤ ‖g‖ := by + let c : Fin n → ℚ := fun i => if 0 ≤ g (coordinate₀ (a i)) then 1 else -1 + have hc : ∀ i, c i ≠ 0 := by intro i; dsimp [c]; split_ifs <;> norm_num + have hsign : ∀ i, c i = 1 ∨ c i = -1 := by intro i; dsimp [c]; split_ifs <;> simp + let e := coordinateAverage k j n hj hn hnj a c hc + have he : e.value ∈ Full := coordinateAverage_mem k j n hj hn hnj a ha c hc hsign + have hb := g.le_opNorm (norming.rationalPredual e.value) + have hbound : |g (norming.rationalPredual e.value)| ≤ ‖g‖ := by + exact hb.trans (by simpa only [mul_one] using (mul_le_mul_of_nonneg_left + (norming.norm_rationalPredual_le e.value he) (norm_nonneg g))) + have heval : g (norming.rationalPredual e.value) = + (1 / ((Family.pure k).m j : ℝ)) * ∑ i, |g (coordinate₀ (a i))| := by + simp only [e, TypeI.value, coordinateAverage, map_sum, + norming.rationalPredual_single, map_rat_smul, Rat.smul_def, + Rat.cast_div, Rat.cast_one, Rat.cast_natCast] + congr 1 + apply Finset.sum_congr rfl + intro i _ + dsimp [c] + split_ifs with hi + · simp [abs_of_nonneg hi, coordinate₀] + · simp [abs_of_neg (lt_of_not_ge hi), coordinate₀] + exact (le_abs_self _).trans (by rwa [heval] at hbound) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical + +@[reducible] local instance dualEGroup2 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace2 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup2 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace2 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup2 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace2 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma predual_large_coordinates_finite (g : StrongDual ℝ X₀) (k : ℕ) + (δ : ℝ) (hδ : 0 < δ) : + Set.Finite {a : Γ | Colors.color a = k ∧ δ ≤ |g (coordinate₀ a)|} := by + by_contra hfin + have hInf : Set.Infinite {a : Γ | Colors.color a = k ∧ δ ≤ |g (coordinate₀ a)|} := hfin + have ht := Parameters.ratio_tendsto_atTop (Family.s_ge_two (.pure k)) + obtain ⟨l, hl⟩ := (ht.eventually (eventually_gt_atTop (‖g‖ / δ))).exists + let j := l+1 + let n := (Family.pure k).L j + have hn : 1 ≤ n := (Family.L_pos (.pure k) j) + obtain ⟨s, hs, hcard⟩ := hInf.exists_subset_card_eq n + let a : Fin n ↪o Γ := s.orderEmbOfFin hcard + have ha : ∀ i, Colors.color (a i) = k := fun i => + (hs (s.orderEmbOfFin_mem hcard i)).1 + have hlarge : ∀ i, δ ≤ |g (coordinate₀ (a i))| := fun i => + (hs (s.orderEmbOfFin_mem hcard i)).2 + have hbound := signed_coordinate_bound g k j n (by omega) hn le_rfl a ha + have hsum : (n : ℝ) * δ ≤ ∑ i, |g (coordinate₀ (a i))| := by + simpa using Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hlarge i) + have hm : (0 : ℝ) < (Family.pure k).m j := by exact_mod_cast Family.m_pos _ _ + have hl' : ‖g‖ / δ < (n : ℝ) / ((Family.pure k).m j : ℝ) := by + simpa [n, j, Family.L, Family.m] using hl + have hr : ‖g‖ < ((n : ℝ) / ((Family.pure k).m j : ℝ)) * δ := + (div_lt_iff₀ hδ).mp hl' + have hsmall : (1 / ((Family.pure k).m j : ℝ)) * ((n : ℝ) * δ) ≤ ‖g‖ := + (mul_le_mul_of_nonneg_left hsum (one_div_nonneg.mpr hm.le)).trans hbound + have heq : (1 / ((Family.pure k).m j : ℝ)) * ((n : ℝ) * δ) = + ((n : ℝ) / ((Family.pure k).m j : ℝ)) * δ := by ring + rw [heq] at hsmall + exact (not_lt_of_ge hsmall) hr + +/-- Direct countable support of every candidate dual-predual vector, from the +actual Type I operations and L_j/m_j→∞. No bounded completeness is assumed. -/ +lemma predual_coordinate_support_countable (g : StrongDual ℝ X₀) : + Set.Countable {a : Γ | g (coordinate₀ a) ≠ 0} := by + have h : Set.Countable (⋃ k : ℕ, ⋃ n : ℕ, + {a : Γ | Colors.color a = k ∧ 1 / ((n : ℝ)+1) ≤ |g (coordinate₀ a)|}) := + Set.countable_iUnion fun k => Set.countable_iUnion fun n => + (predual_large_coordinates_finite g k _ (by positivity)).countable + apply h.mono + intro a ha + obtain ⟨n, hn⟩ := exists_nat_one_div_lt (abs_pos.mpr ha) + exact Set.mem_iUnion.mpr ⟨Colors.color a, + Set.mem_iUnion.mpr ⟨n, rfl, hn.le⟩⟩ + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open scoped Classical + +def Crop.ordinalSet (I : Set Γ) (hI : Set.OrdConnected I) : Crop := + ⟨I, hI, Set.univ, Set.ordConnected_univ⟩ + +def Crop.colorSet (D : Set ℕ) (hD : Set.OrdConnected D) : Crop := + ⟨Set.univ, Set.ordConnected_univ, D, hD⟩ + +def Crop.oneColor (k : ℕ) : Crop := Crop.colorSet {k} Set.ordConnected_singleton + +def Crop.colorsBelow (n : ℕ) : Crop := Crop.colorSet (Set.Iio n) Set.ordConnected_Iio + +def Crop.colorsFrom (n : ℕ) : Crop := Crop.colorSet (Set.Ici n) Set.ordConnected_Ici + +@[simp] lemma Crop.oneColor_set (k : ℕ) : (Crop.oneColor k).set .mixed = Norming.colorSet k := by + ext a + simp [Crop.oneColor, Crop.colorSet, Crop.set, Norming.colorSet] + +@[simp] lemma Crop.colorsBelow_set (n : ℕ) : + (Crop.colorsBelow n).set .mixed = {a | Colors.color a < n} := by + ext a + simp [Crop.colorsBelow, Crop.colorSet, Crop.set] + +@[simp] lemma Crop.ordinalSet_set (I : Set Γ) (hI : Set.OrdConnected I) : + (Crop.ordinalSet I hI).set .mixed = I := by + ext a + simp [Crop.ordinalSet, Crop.set] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +lemma evaluateArray_projection (A : Crop) (x : E) (f : Array) : + norming.evaluateArray (projection A x) f = + norming.evaluateArray x (restrict (A.set .mixed) f) := + norming.evaluateArray_projection x (A.set .mixed) (cropStable A) f + +lemma evaluateArray_crop_of_zero (A : Set Γ) (x : E) + (hx : ∀ a ∉ A, coordinate a x = 0) (f : Array) : + norming.evaluateArray x (restrict A f) = norming.evaluateArray x f := + norming.evaluateArray_filter_of_zero x A hx f + +/-- The full and pure norms coincide on a single color. -/ +lemma norm_le_of_pure (k : ℕ) (x : E) (hx : ∀ a, Colors.color a ≠ k → coordinate a x = 0) + (r : ℝ) (hr : 0 ≤ r) (h : ∀ f ∈ Pure k, |norming.evaluateArray x f| ≤ r) : ‖x‖ ≤ r := by + apply norming.norm_le_of_evaluateArray x r hr + intro f hf + have hb := absConvexHull_min h (absConvex_abs_le (norming.evaluateArray x) r hr) + (full_color_hull k f hf) + change |norming.evaluateArray x (restrict (colorSet k) f)| ≤ r at hb + rwa [evaluateArray_crop_of_zero (colorSet k) x (fun a ha => hx a ha) f] at hb + +lemma exists_full_normer (x : E) (r : ℝ) (hr : 0 ≤ r) (hx : r < ‖x‖) : + ∃ f ∈ Full, r < norming.evaluateArray x f := by + by_contra h + push Not at h + have hb : ‖x‖ ≤ r := norming.norm_le_of_evaluateArray x r hr (by + intro f hf + apply abs_le.mpr + constructor + · have hn := h (-f) (full_neg f hf) + simpa only [map_neg, neg_le] using hn + · exact h f hf) + exact (not_lt_of_ge hb) hx + +lemma exists_pure_normer (k : ℕ) (x : E) + (hc : ∀ a, Colors.color a ≠ k → coordinate a x = 0) + (r : ℝ) (hr : 0 ≤ r) (hx : r < ‖x‖) : + ∃ f ∈ Pure k, r < norming.evaluateArray x f := by + by_contra h + push Not at h + have hb : ‖x‖ ≤ r := norm_le_of_pure k x hc r hr (by + intro f hf + apply abs_le.mpr + constructor + · have hn := h (-f) (pure_neg k f hf) + simpa only [map_neg, neg_le] using hn + · exact h f hf) + exact (not_lt_of_ge hb) hx + +lemma tendsto_colorsBelow (x : E) : + Tendsto (fun n => projection (Crop.colorsBelow n) x) atTop (𝓝 x) := by + apply norming.tendsto_projection + intro a + filter_upwards [eventually_gt_atTop (Colors.color a)] with n hn + simpa using hn + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open scoped Classical + +def Family.normers : Family → Set Array + | .pure k => Pure k + | .mixed => Full + +lemma Family.normers_subset_full (t : Family) : t.normers ⊆ Full := by + cases t with + | pure k => exact pure_subset_full k + | mixed => exact Set.Subset.rfl + +lemma Family.typeI_mem (t : Family) (e : TypeI t) + (h : ∀ i, e.child i ∈ t.normers) : e.value ∈ t.normers := by + cases t with + | pure k => exact pure_typeI_mem k e h + | mixed => exact mixed_typeI_mem e h + +lemma Family.exists_large_ratio (t : Family) (R : ℝ) : + ∃ j, 1 ≤ j ∧ R < (t.L j : ℝ) / (t.m j : ℝ) := by + obtain ⟨l, hl⟩ := ((Parameters.ratio_tendsto_atTop t.s_ge_two).eventually + (Filter.eventually_gt_atTop R)).exists + exact ⟨l+1, by omega, by simpa [Family.L, Family.m] using hl⟩ + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction +open scoped Classical + +@[reducible] local instance dualEGroup3 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace3 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup3 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace3 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup3 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace3 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma predual_array_apply (g : StrongDual ℝ X₀) (f : Array) : + g (norming.rationalPredual f) = ∑ a ∈ f.support, (f a : ℝ) * g (coordinate₀ a) := by + simp only [NormingSet.rationalPredual, Finsupp.linearCombination_apply, Finsupp.sum, + map_sum, map_rat_smul, Rat.smul_def, coordinate₀] + +lemma predual_array_eq_evaluate (g : StrongDual ℝ X₀) (f : Array) (x : E) + (hx : ∀ a ∈ f.support, coordinate a x = g (coordinate₀ a)) : + g (norming.rationalPredual f) = norming.evaluateArray x f := by + rw [predual_array_apply, norming.evaluateArray_eq] + exact Finset.sum_congr rfl (fun a ha => by rw [← hx a ha]) + +/-- A Type I obstruction to successive uniformly positive normers. -/ +lemma no_successive_positive_normers (g : StrongDual ℝ X₀) (t : Family) + (f : ℕ → Array) (hf : ∀ i, f i ∈ t.normers) + (hs : ∀ i j, i < j → Successive t (f i) (f j)) + (δ : ℝ) (hδ : 0 < δ) (hlarge : ∀ i, δ ≤ g (norming.rationalPredual (f i))) : False := by + obtain ⟨j, hj, hratio⟩ := t.exists_large_ratio (‖g‖ / δ) + let n := t.L j + let e : TypeI t := { + weight := j + weight_pos := hj + length := n + length_pos := t.L_pos j + length_le := le_rfl + child := fun i => f i.val + child_nonzero := fun i => by + intro hz + have h := hlarge i.val + rw [hz, map_zero, map_zero] at h + exact (not_le_of_gt hδ) h + successive := fun i l hil => hs i.val l.val hil } + have he : e.value ∈ Full := t.normers_subset_full (t.typeI_mem e (fun i => hf i.val)) + have hbound : g (norming.rationalPredual e.value) ≤ ‖g‖ := by + calc + _ ≤ |g (norming.rationalPredual e.value)| := le_abs_self _ + _ ≤ ‖g‖ * ‖norming.rationalPredual e.value‖ := g.le_opNorm _ + _ ≤ ‖g‖ := by + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (norming.norm_rationalPredual_le e.value he) (norm_nonneg g) + have heval : g (norming.rationalPredual e.value) = + (1 / (t.m j : ℝ)) * ∑ i : Fin n, g (norming.rationalPredual (f i.val)) := by + simp only [e, TypeI.value, map_rat_smul, Rat.smul_def, map_sum, + Rat.cast_div, Rat.cast_one, Rat.cast_natCast] + have hsum : (n : ℝ) * δ ≤ ∑ i : Fin n, g (norming.rationalPredual (f i.val)) := by + simpa using Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset (Fin n))) => hlarge i.val) + have hm : (0 : ℝ) < t.m j := by exact_mod_cast t.m_pos j + have hb : (1 / (t.m j : ℝ)) * ((n : ℝ) * δ) ≤ ‖g‖ := + (mul_le_mul_of_nonneg_left hsum (one_div_nonneg.mpr hm.le)).trans (by rwa [← heval]) + have hr : ‖g‖ < ((n : ℝ) / (t.m j : ℝ)) * δ := (div_lt_iff₀ hδ).mp hratio + have heq : (1 / (t.m j : ℝ)) * ((n : ℝ) * δ) = ((n : ℝ) / (t.m j : ℝ)) * δ := by ring + rw [heq] at hb + exact (not_lt_of_ge hb) hr + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/EvaluationCriterion.lean b/lean/OAI/Analysis/SeparableQuotients/EvaluationCriterion.lean new file mode 100644 index 0000000000000000000000000000000000000000..054a8afa2d5bd375c8dd268eaf69c1c0d768d0cd --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/EvaluationCriterion.lean @@ -0,0 +1,149 @@ +import OAI.Analysis.SeparableQuotients.FiniteNormers + +namespace OAI + +namespace SeparableQuotient +open Set Metric +open scoped Topology BigOperators +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X] +@[reducible] noncomputable local instance evaluationCriterionDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 X) := inferInstance +@[reducible] noncomputable local instance evaluationCriterionDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 X) := inferInstance + +@[reducible] noncomputable local instance evaluationCriterionSubspaceDualNormedGroup + (F : Submodule 𝕜 (StrongDual 𝕜 X)) : NormedAddCommGroup (StrongDual 𝕜 F) := inferInstance +@[reducible] noncomputable local instance evaluationCriterionSubspaceDualNormedSpace + (F : Submodule 𝕜 (StrongDual 𝕜 X)) : NormedSpace 𝕜 (StrongDual 𝕜 F) := inferInstance + +/-- Norm-separable evaluation on an infinite-dimensional dual subspace yields a separable quotient. -/ +theorem hasSeparableQuotient_of_separable_evaluation + (F : Submodule 𝕜 (StrongDual 𝕜 X)) [IsClosed (F : Set (StrongDual 𝕜 X))] + (hF : ¬ FiniteDimensional 𝕜 F) + (hsep : TopologicalSpace.IsSeparable (Set.range (subspaceEvaluation F))) : + HasSeparableQuotient 𝕜 X := by + classical + obtain ⟨xs, hxs⟩ := exists_dense_evaluations F hsep + let f := NormerStep.seq F hF xs + let H := NormerStep.prefixNormers F hF xs + have hn : ∀ n, (1 : ℝ) ≤ ‖f n‖ := fun n => (NormerStep.seq_norm F hF xs n).ge + let G := PrefixNormers.closedSpan f + let Z := H.coefficientSpan 1 (by norm_num) hn + let inc : G →L[𝕜] F := G.subtypeL.codRestrict F + (fun v => NormerStep.span_le F hF xs v.property) + let restriction : StrongDual 𝕜 F →L[𝕜] StrongDual 𝕜 G := + ContinuousLinearMap.precomp 𝕜 inc + have he (x : X) : restriction (subspaceEvaluation F x) = PrefixNormers.evaluation f x := by + ext v; rfl + have hx (j : ℕ) : restriction (subspaceEvaluation F (xs j)) ∈ Z := by + rw [he] + change PrefixNormers.evaluation (NormerStep.seq F hF xs) (xs j) ∈ Z + rw [NormerStep.evaluation_x] + apply Submodule.sum_mem + intro i hi + apply Submodule.smul_mem + exact Submodule.le_topologicalClosure _ (Submodule.subset_span (Set.mem_range_self i)) + have hc : IsClosed (restriction ⁻¹' (Z : Set (StrongDual 𝕜 G))) := + (H.coefficientSpan_isClosed 1 (by norm_num) hn).preimage restriction.continuous + apply H.hasSeparableQuotient_of_range 1 (by norm_num) hn + intro x + rw [← he x] + apply closure_minimal (t := restriction ⁻¹' (Z : Set (StrongDual 𝕜 G))) ?_ hc (hxs x) + rintro _ ⟨j, rfl⟩ + exact hx j + +end SeparableQuotient + +namespace SeparableQuotient +open Set Metric +open scoped Topology +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X Y : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X] + [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] [CompleteSpace Y] +@[reducible] noncomputable local instance necessityDualGroup (E : Type u) + [NormedAddCommGroup E] [NormedSpace 𝕜 E] : NormedAddCommGroup (StrongDual 𝕜 E) := + inferInstance +@[reducible] noncomputable local instance necessityDualSpace (E : Type u) + [NormedAddCommGroup E] [NormedSpace 𝕜 E] : NormedSpace 𝕜 (StrongDual 𝕜 E) := + inferInstance + +omit [CompleteSpace Y] in +/-- The dual of an infinite-dimensional normed space is infinite-dimensional. -/ +lemma dual_infiniteDimensional (hY : ¬ FiniteDimensional 𝕜 Y) : + ¬ FiniteDimensional 𝕜 (StrongDual 𝕜 Y) := by + intro h + let := h + apply hY + exact FiniteDimensional.of_injective (NormedSpace.inclusionInDoubleDualLi 𝕜).toLinearMap + (NormedSpace.inclusionInDoubleDualLi 𝕜).injective + +/-- The adjoint of an onto map is bounded below, with the actual open-mapping lift constant. -/ +lemma precomp_antilipschitz_of_surjective (T : X →L[𝕜] Y) (hT : Function.Surjective T) : + ∃ C : NNReal, AntilipschitzWith C + (ContinuousLinearMap.precomp 𝕜 T : StrongDual 𝕜 Y →L[𝕜] StrongDual 𝕜 X) := by + obtain ⟨g, _hg⟩ := T.exists_nonlinearRightInverse_of_surjective (LinearMap.range_eq_top.mpr hT) + let S : StrongDual 𝕜 Y →L[𝕜] StrongDual 𝕜 X := ContinuousLinearMap.precomp 𝕜 T + refine ⟨g.nnnorm, S.antilipschitz_of_bound ?_⟩ + intro f + apply f.opNorm_le_bound (mul_nonneg g.nnnorm.coe_nonneg (norm_nonneg _)) + intro y + calc + ‖f y‖ = ‖S f (g y)‖ := by + change ‖f y‖ = ‖f (T (g y))‖ + rw [g.right_inv] + _ ≤ ‖S f‖ * ‖g y‖ := + ContinuousLinearMap.le_opNorm _ _ + _ ≤ ‖S f‖ * (g.nnnorm * ‖y‖) := + mul_le_mul_of_nonneg_left (g.bound y) (norm_nonneg _) + _ = (g.nnnorm * ‖S f‖) * ‖y‖ := by ring + +/-- A separable quotient yields an infinite-dimensional dual subspace with norm-separable evaluation. -/ +theorem separable_evaluation_of_hasSeparableQuotient (hX : HasSeparableQuotient 𝕜 X) : + ∃ F : Submodule 𝕜 (StrongDual 𝕜 X), IsClosed (F : Set (StrongDual 𝕜 X)) ∧ + (¬ FiniteDimensional 𝕜 F) ∧ + TopologicalSpace.IsSeparable (Set.range (subspaceEvaluation F)) := by + obtain ⟨Y, hYn, hYs, hYc, hYsep, hYinf, T, hT⟩ := hX + let := hYn + let := hYs + let := hYc + let := hYsep + let S : StrongDual 𝕜 Y →L[𝕜] StrongDual 𝕜 X := ContinuousLinearMap.precomp 𝕜 T + obtain ⟨C, hC⟩ := precomp_antilipschitz_of_surjective T hT + have hSc : IsClosed (Set.range S) := hC.isClosed_range S.uniformContinuous + let F := S.range + have hFc : IsClosed (F : Set (StrongDual 𝕜 X)) := hSc + let e : StrongDual 𝕜 Y ≃L[𝕜] F := S.equivRange hC.injective hSc + have hFi : ¬ FiniteDimensional 𝕜 F := by + intro hf + let := hf + have : FiniteDimensional 𝕜 (StrongDual 𝕜 Y) := e.toLinearEquiv.symm.finiteDimensional + exact dual_infiniteDimensional hYinf inferInstance + let Q : Y →L[𝕜] StrongDual 𝕜 F := + (ContinuousLinearMap.precomp 𝕜 e.symm.toContinuousLinearMap).comp + (NormedSpace.inclusionInDoubleDual 𝕜 Y) + have he (x : X) : subspaceEvaluation F x = Q (T x) := by + ext f + obtain ⟨g, rfl⟩ := e.surjective f + change (S g) x = (e.symm (e g)) (T x) + rw [e.symm_apply_apply] + rfl + refine ⟨F, hFc, hFi, (TopologicalSpace.isSeparable_range Q.continuous).mono ?_⟩ + rintro _ ⟨x, rfl⟩ + exact ⟨T x, (he x).symm⟩ + +/-- Exact evaluation criterion over either scalar field. -/ +theorem hasSeparableQuotient_iff_separable_evaluation : + HasSeparableQuotient 𝕜 X ↔ + ∃ F : Submodule 𝕜 (StrongDual 𝕜 X), IsClosed (F : Set (StrongDual 𝕜 X)) ∧ + (¬ FiniteDimensional 𝕜 F) ∧ + TopologicalSpace.IsSeparable (Set.range (subspaceEvaluation F)) := by + refine ⟨separable_evaluation_of_hasSeparableQuotient, ?_⟩ + rintro ⟨F, hFc, hFi, hsep⟩ + let := hFc + exact hasSeparableQuotient_of_separable_evaluation F hFi hsep +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/ExactPairs.lean b/lean/OAI/Analysis/SeparableQuotients/ExactPairs.lean new file mode 100644 index 0000000000000000000000000000000000000000..0df482f16725c36e2758aa874526ebe0e88d05f4 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/ExactPairs.lean @@ -0,0 +1,189 @@ +import OAI.Analysis.SeparableQuotients.TreeBounds + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +lemma exists_finite_vector_normer {f : Family} (x : Γ →₀ ℝ) (hx0 : x ≠ 0) + (hx : 1 ≤ ‖norming.includeFinite x‖) + (hcolor : ∀ k, f = .pure k → ∀ a ∈ x.support, Colors.color a = k) : + ∃ (g : Array), g ∈ f.norming ∧ g ≠ 0 ∧ + (∀ a ∈ g.support, a ∈ (vectorCrop x hx0).set f) ∧ + 1/2 < norming.evaluateArray (norming.includeFinite x) g := by + have hn : ∃ g ∈ f.norming, 1/2 < norming.evaluateArray (norming.includeFinite x) g := by + cases f with + | pure k => + apply exists_pure_normer k _ _ _ (by norm_num) (by linarith) + intro a ha + rw [norming.coordinate_includeFinite] + exact Finsupp.notMem_support_iff.mp (fun h => ha (hcolor k rfl a h)) + | mixed => exact exists_full_normer _ _ (by norm_num) (by linarith) + obtain ⟨g,hg,hgv⟩ := hn + let A := vectorCrop x hx0 + have heq : norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) g) = + norming.evaluateArray (norming.includeFinite x) g := by + apply evaluateArray_crop_of_zero + intro a ha + rw [norming.coordinate_includeFinite] + exact Finsupp.notMem_support_iff.mp (fun h => ha (support_mem_vectorCrop f x hx0 a h)) + refine ⟨restrict (A.set f) g,family_norming_crop f A g hg,?_,?_,by rwa [heq]⟩ + · intro hz + rw [hz,map_zero] at heq + linarith + · intro a ha + by_contra hn + change a ∉ A.set f at hn + exact Finsupp.mem_support_iff.mp ha (by simp [restrict,hn]) + +lemma vectorCrop_mono {f : Family} {x y : Γ →₀ ℝ} (hx : x ≠ 0) (hy : y ≠ 0) + (hxy : x.support ⊆ y.support) : (vectorCrop x hx).set f ⊆ (vectorCrop y hy).set f := by + have ho : (vectorCrop x hx).ordinal ⊆ (vectorCrop y hy).ordinal := by + intro a ha + exact ⟨(Finset.min'_le _ _ (hxy (Finset.min'_mem _ _))).trans ha.1, + ha.2.trans (Finset.le_max' _ _ (hxy (Finset.max'_mem _ _)))⟩ + have hc : (vectorCrop x hx).colors ⊆ (vectorCrop y hy).colors := by + intro a ha + have hsub : x.support.image Colors.color ⊆ y.support.image Colors.color := Finset.image_subset_image hxy + exact ⟨(Finset.min'_le _ _ (hsub (Finset.min'_mem _ _))).trans ha.1, + ha.2.trans (Finset.le_max' _ _ (hsub (Finset.max'_mem _ _)))⟩ + intro a ha + cases f with + | pure k => exact ho ha + | mixed => exact ⟨ho ha.1,hc ha.2⟩ + +lemma BlockSequence.support_subset_sum {f : Family} (z : BlockSequence f) (k : ℕ) (i : Fin k) : + (z.vector i).support ⊆ (∑ j : Fin k, z.vector j).support := by + intro α hα + apply Finsupp.mem_support_iff.mpr + rw [Finsupp.finsetSum_apply,Finset.sum_eq_single i] + · exact Finsupp.mem_support_iff.mp hα + · intro j _ hji + apply Finsupp.notMem_support_iff.mp + intro hj + have hne : (j : ℕ) ≠ i := fun h => hji (Fin.ext h) + rcases lt_or_gt_of_ne hne with hlt | hlt + · exact (lt_irrefl α) (z.successive j i hlt α hj α hα).1 + · exact (lt_irrefl α) (z.successive i j hlt α hα α hj).1 + · simp + +lemma BlockSequence.sum_nonzero {f : Family} (z : BlockSequence f) (k : ℕ) (hk : 0 < k) : + (∑ j : Fin k, z.vector j) ≠ 0 := by + intro hz + obtain ⟨α,hα⟩ := Finsupp.support_nonempty_iff.mpr (z.nonzero 0) + have hh := z.support_subset_sum k ⟨0,hk⟩ hα + simp only [hz,Finsupp.support_zero,Finset.notMem_empty] at hh + +lemma BlockSequence.normer_cross {f : Family} (z : BlockSequence f) (i j : ℕ) (hij : i ≠ j) + (g : Array) (hg : ∀ α ∈ g.support, α ∈ (vectorCrop (z.vector i) (z.nonzero i)).set f) : + norming.evaluateArray (z.embed j) g = 0 := by + apply evaluateArray_finite_disjoint + apply Finset.disjoint_left.mpr + intro α hα hgα + rcases lt_or_gt_of_ne hij with hij | hji + · exact (lt_irrefl α) (vectorCrop_successive (z.nonzero i) (z.nonzero j) (z.successive i j hij) + α (hg α hgα) α (support_mem_vectorCrop f _ _ α hα)).1 + · exact (lt_irrefl α) (vectorCrop_successive (z.nonzero j) (z.nonzero i) (z.successive j i hji) + α (support_mem_vectorCrop f _ _ α hα) α (hg α hgα)).1 + +/-- Exact pairs with uncropped child legality and support bounds in both orders. -/ +structure ExactPair {f : Family} (z : BlockSequence f) (a J : ℕ) where + vector : Γ →₀ ℝ + nonzero : vector ≠ 0 + mem_tail : vector ∈ z.tailSpan a + norm_le : ‖norming.includeFinite vector‖ ≤ 500 + pure_color : ∀ k, f = .pure k → ∀ α ∈ vector.support, Colors.color α = k + piece : TypeI f + weight_eq : piece.weight = J + child_mem : ∀ h, piece.child h ∈ f.norming + eval_ge : 1/2 ≤ norming.evaluateArray (norming.includeFinite vector) piece.value + support : ∀ α ∈ piece.value.support, α ∈ (vectorCrop vector nonzero).set f + +lemma BlockSequence.exists_exactPair {f : Family} (z : BlockSequence f) (a J : ℕ) (hJ : 1 ≤ J) : + Nonempty (ExactPair z a J) := by + have hθ : 0 < f.theta J := by rw [Family.theta,Parameters.theta_eq f.s_ge_two]; positivity + have hL : (0 : ℝ) < f.L J := by exact_mod_cast f.L_pos J + have hm : (0 : ℝ) < f.m J := by exact_mod_cast f.m_pos J + let ε := f.theta J / (f.L J : ℝ)^(1/f.r) + have hε : 0 < ε := div_pos hθ (Real.rpow_pos_of_pos hL _) + obtain ⟨w⟩ := exists_thinnedWindows z J ε hε a + have heps : ε*(f.L J : ℝ)^(1/f.r) ≤ f.theta J := by + dsimp [ε] + rw [div_mul_cancel₀ _ (Real.rpow_pos_of_pos hL _).ne'] + let X := ∑ i : Fin (f.L J), w.blocks.vector i + have hX : X ≠ 0 := w.blocks.sum_nonzero _ (f.L_pos J) + let c : ℝ := (f.m J : ℝ)/(f.L J : ℝ) + have hc : 0 < c := div_pos hm hL + let y := c • X + have hy : y ≠ 0 := smul_ne_zero hc.ne' hX + have hys : y.support = X.support := Finsupp.support_smul_eq hc.ne' + have hn := fun i : Fin (f.L J) => exists_finite_vector_normer (w.blocks.vector i) (w.blocks.nonzero i) + (w.lower_norm i) (fun k hk α hα => w.blocks.pure_color k hk i α hα) + choose g hg hgn hgs hgv using hn + let e : TypeI f := { + weight := J + weight_pos := hJ + length := f.L J + length_pos := f.L_pos J + length_le := le_rfl + child := g + child_nonzero := hgn + successive := by + intro i j hij α hα β hβ + exact vectorCrop_successive (w.blocks.nonzero i) (w.blocks.nonzero j) + (w.blocks.successive i j hij) α (hgs i α hα) β (hgs j β hβ) } + have hgeval (i : Fin (f.L J)) : norming.evaluateArray (norming.includeFinite X) (g i) = + norming.evaluateArray (w.blocks.embed i) (g i) := by + have hgf : g i ∈ Full := f.norming_subset_full (hg i) + simp only [X,norming.evaluateArray_eq_functional _ ⟨g i,hgf⟩,map_sum] + apply Finset.sum_eq_single i + · intro j _ hji + rw [← norming.evaluateArray_eq_functional] + exact w.blocks.normer_cross i j (fun he => hji (Fin.ext he.symm)) (g i) (hgs i) + · simp + have hyEval : 1/2 ≤ norming.evaluateArray (norming.includeFinite y) e.value := by + have hef : e.value ∈ Full := f.norming_subset_full (e.mem_family hg) + rw [norming.evaluateArray_eq_functional _ ⟨e.value,hef⟩] + change 1/2 ≤ norming.functional ⟨e.value,hef⟩ (norming.includeFinite (c • X)) + rw [map_smul,map_smul] + rw [smul_eq_mul, ← norming.evaluateArray_eq_functional (norming.includeFinite X) ⟨e.value,hef⟩] + change 1/2 ≤ c * norming.evaluateArray (norming.includeFinite X) e.value + rw [TypeI.value,map_smul,map_sum] + simp only [show e.weight = J from rfl,show e.child = g from rfl,Rat.smul_def,Rat.cast_div,Rat.cast_one,Rat.cast_natCast] + have he : (f.L J : ℝ)*(1/2 : ℝ) ≤ ∑ i, norming.evaluateArray (norming.includeFinite X) (g i) := by + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] using + Finset.sum_le_sum (s := Finset.univ) (f := fun _ : Fin (f.L J) => (1/2 : ℝ)) + (g := fun i => norming.evaluateArray (norming.includeFinite X) (g i)) + (fun i _ => by rw [hgeval i]; exact (hgv i).le) + calc + 1/2 = c * ((1/(f.m J : ℝ))*((f.L J : ℝ)*(1/2))) := by dsimp [c]; field_simp + _ ≤ _ := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left he (by positivity)) hc.le + refine ⟨⟨y,hy,?_,?_,?_,e,rfl,hg,hyEval,?_⟩⟩ + · exact Submodule.smul_mem _ c (Submodule.sum_mem _ (fun i _ => w.mem_tail i)) + · have hb := w.norm_sum_bound (Finset.range (f.L J)) hJ (Finset.card_range _) (by simpa using heps) + have hXnorm : ‖norming.includeFinite X‖ ≤ 500*(f.L J : ℝ)/(f.m J : ℝ) := by + simpa only [X,Finset.sum_coe_sort,Fin.sum_univ_eq_sum_range] using hb + change ‖norming.includeFinite (c • X)‖ ≤ 500 + rw [map_smul,norm_smul,Real.norm_eq_abs,abs_of_pos hc] + calc + _ ≤ c*(500*(f.L J : ℝ)/(f.m J : ℝ)) := mul_le_mul_of_nonneg_left hXnorm hc.le + _ = 500 := by dsimp [c]; field_simp + · intro k hk α hα + rw [hys] at hα + obtain ⟨i,_,hi⟩ := Finsupp.mem_support_finsetSum α hα + exact w.blocks.pure_color k hk i α hi + · intro α hα + have hh : α ∈ (∑ i : Fin (f.L J),g i).support := Finsupp.support_smul hα + obtain ⟨i,_,hi⟩ := Finsupp.mem_support_finsetSum α hh + apply vectorCrop_mono (w.blocks.nonzero i) hy _ (hgs i α hi) + rw [hys] + exact w.blocks.support_subset_sum _ i + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/FiniteLp.lean b/lean/OAI/Analysis/SeparableQuotients/FiniteLp.lean new file mode 100644 index 0000000000000000000000000000000000000000..2970089278b501ddc3d71ff5e2a0bb29d468a28b --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/FiniteLp.lean @@ -0,0 +1,269 @@ +import OAI.Analysis.SeparableQuotients.NormingOperations + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.LpFinite +universe u +open scoped ENNReal NNReal Classical +variable {Γ : Type u} + +/-- A rational array, as an ℓᵖ vector. -/ +def array (p : ℝ≥0∞) (f : Γ →₀ ℚ) : lp (fun _ : Γ => ℝ) p := + ⟨fun a => (f a : ℝ), by + apply Memℓp.of_exponent_ge (q := 0) ?_ (zero_le : (0 : ℝ≥0∞) ≤ p) + apply memℓp_zero_iff.mpr + exact f.support.finite_toSet.subset (fun a ha => by simpa using ha)⟩ + +@[simp] lemma array_apply (p : ℝ≥0∞) (f : Γ →₀ ℚ) (a : Γ) : array p f a = (f a : ℝ) := rfl + +@[simp] lemma array_zero (p : ℝ≥0∞) : array p (0 : Γ →₀ ℚ) = 0 := by + apply lp.ext + funext a + simp + +@[simp] lemma array_add (p : ℝ≥0∞) (f g : Γ →₀ ℚ) : array p (f+g) = array p f + array p g := by + apply lp.ext + funext a + simp + +@[simp] lemma array_smul (p : ℝ≥0∞) (c : ℚ) (f : Γ →₀ ℚ) : + array p (c • f) = (c : ℝ) • array p f := by + apply lp.ext + funext a + simp + +@[simp] lemma array_sum {ι : Type*} (p : ℝ≥0∞) (s : Finset ι) (f : ι → Γ →₀ ℚ) : + array p (∑ i ∈ s, f i) = ∑ i ∈ s, array p (f i) := by + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => simp only [Finset.sum_insert hi, array_add, ih] + +lemma norm_array_filter_le (p : ℝ≥0∞) (hp : p ≠ 0) (f : Γ →₀ ℚ) (A : Set Γ) : + ‖array p (f.filter (· ∈ A))‖ ≤ ‖array p f‖ := by + apply lp.norm_mono hp + intro a + by_cases ha : a ∈ A <;> simp [ha] + +lemma norm_array_single {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : p ≠ 0) (a : Γ) (c : ℚ) : + ‖array p (Finsupp.single a c)‖ = |(c : ℝ)| := by + have h : array p (Finsupp.single a c) = lp.single p a (c : ℝ) := by + apply lp.ext + funext b + by_cases hba : b = a <;> simp [hba, lp.single_apply] + rw [h] + exact (lp.norm_single (E := fun _ : Γ => ℝ) (pos_iff_ne_zero.mpr hp) a (c : ℝ)).trans + (Real.norm_eq_abs _) + +end SeparableQuotient.LpFinite + +namespace SeparableQuotient.LpFinite +open scoped ENNReal NNReal Classical +universe u v +variable {Γ : Type u} {ι : Type v} {p : ℝ≥0∞} + +/-- Exact disjoint-support identity, including arbitrary finite index sets. -/ +lemma norm_sum_rpow (hp : 0 < p.toReal) (s : Finset ι) + (v : ι → lp (fun _ : Γ => ℝ) p) + (hdis : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → ∀ a, v i a = 0 ∨ v j a = 0) : + ‖∑ i ∈ s, v i‖ ^ p.toReal = ∑ i ∈ s, ‖v i‖ ^ p.toReal := by + have hpoint : ∀ a, ‖∑ i ∈ s, v i a‖ ^ p.toReal = ∑ i ∈ s, ‖v i a‖ ^ p.toReal := by + intro a + by_cases hex : ∃ i ∈ s, v i a ≠ 0 + · obtain ⟨i, hi, hv⟩ := hex + have hz : ∀ j ∈ s, j ≠ i → v j a = 0 := by + intro j hj hji + exact (hdis j hj i hi hji a).resolve_right hv + rw [Finset.sum_eq_single i (fun j hj hji => hz j hj hji) (fun hn => (hn hi).elim)] + rw [Finset.sum_eq_single i (fun j hj hji => by rw [hz j hj hji]; simp [hp.ne']) + (fun hn => (hn hi).elim)] + · push Not at hex + simp only [Finset.sum_eq_zero (fun i hi => hex i hi), norm_zero, + Real.zero_rpow hp.ne'] + symm + exact Finset.sum_eq_zero fun i hi => by rw [hex i hi]; simp [hp.ne'] + rw [lp.norm_rpow_eq_tsum hp] + simp only [lp.coeFn_sum, Finset.sum_apply, hpoint] + rw [Summable.tsum_finsetSum (fun i _ => (lp.memℓp (v i)).summable hp)] + simp only [lp.norm_rpow_eq_tsum hp] + +lemma norm_sum_le_card_rpow [Fact (1 ≤ p)] (hp : 0 < p.toReal) (s : Finset ι) + (v : ι → lp (fun _ : Γ => ℝ) p) + (hdis : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → ∀ a, v i a = 0 ∨ v j a = 0) + (hbound : ∀ i ∈ s, ‖v i‖ ≤ 1) : + ‖∑ i ∈ s, v i‖ ≤ (s.card : ℝ) ^ (1 / p.toReal) := by + apply (Real.rpow_le_rpow_iff (norm_nonneg _) (Real.rpow_nonneg (Nat.cast_nonneg _) _) hp).mp + rw [norm_sum_rpow hp s v hdis, ← Real.rpow_mul (Nat.cast_nonneg _), + one_div_mul_cancel hp.ne', Real.rpow_one] + calc + _ ≤ ∑ i ∈ s, (1 : ℝ) := Finset.sum_le_sum fun i hi => by + simpa using Real.rpow_le_rpow (norm_nonneg (v i)) (hbound i hi) hp.le + _ = _ := by simp + +end SeparableQuotient.LpFinite + +namespace SeparableQuotient.Norming +open scoped ENNReal NNReal Classical +open LpFinite + +def Family.r (f : Family) : ℝ := Parameters.r f.s +lemma Family.r_gt_one (f : Family) : 1 < f.r := + (Parameters.q_bounds f.s_ge_two).1.trans (Parameters.q_bounds f.s_ge_two).2.1 +lemma Family.r_pos (f : Family) : 0 < f.r := zero_lt_one.trans f.r_gt_one + +def Family.exponent (f : Family) : ℝ≥0∞ := ENNReal.ofReal f.r +instance Family.exponent_fact (f : Family) : Fact (1 ≤ f.exponent) := + ⟨by simpa [Family.exponent] using ENNReal.ofReal_le_ofReal f.r_gt_one.le⟩ +@[simp] lemma Family.exponent_toReal (f : Family) : f.exponent.toReal = f.r := + ENNReal.toReal_ofReal f.r_pos.le +lemma Family.exponent_ne_zero (f : Family) : f.exponent ≠ 0 := by + exact ne_of_gt ((zero_lt_one : (0 : ℝ≥0∞) < 1).trans_le (Fact.out : 1 ≤ f.exponent)) + +def Family.theta (f : Family) (j : ℕ) : ℝ := Parameters.theta f.s (j-1) +lemma Family.theta_nonneg (f : Family) (j : ℕ) : 0 ≤ f.theta j := by + rw [Family.theta, Parameters.theta_eq f.s_ge_two]; positivity +lemma Family.theta_formula (f : Family) (j : ℕ) : + f.theta j = (f.L j : ℝ)^(1/f.r) / (f.m j : ℝ) := rfl + +lemma TypeI.lp_bound {f : Family} (e : TypeI f) + (h : ∀ i, ‖array f.exponent (e.child i)‖ ≤ 1) : + ‖array f.exponent e.value‖ ≤ f.theta e.weight := by + have hd : ∀ i ∈ (Finset.univ : Finset (Fin e.length)), ∀ j ∈ Finset.univ, + i ≠ j → ∀ a, array f.exponent (e.child i) a = 0 ∨ + array f.exponent (e.child j) a = 0 := by + intro i _ j _ hij a + by_cases hi : e.child i a = 0 + · exact Or.inl (by simp [hi]) + · right + have hz : e.child j a = 0 := by + by_contra hj + exact hij (successive_coefficient_unique e.child e.successive hi hj) + simp [hz] + have hsum : ‖∑ i, array f.exponent (e.child i)‖ ≤ (e.length : ℝ)^(1/f.r) := by + simpa using norm_sum_le_card_rpow (by simpa using f.r_pos) Finset.univ + (fun i => array f.exponent (e.child i)) hd (fun i _ => h i) + have hm : 0 < (f.m e.weight : ℝ) := by exact_mod_cast f.m_pos _ + rw [TypeI.value, array_smul, array_sum, norm_smul, Family.theta_formula] + simp only [Rat.cast_div, Rat.cast_one, Rat.cast_natCast, Real.norm_eq_abs, + abs_of_pos (one_div_pos.mpr hm)] + calc + (1/(f.m e.weight:ℝ)) * ‖∑ i, array f.exponent (e.child i)‖ + ≤ (1/(f.m e.weight:ℝ)) * (e.length:ℝ)^(1/f.r) := + mul_le_mul_of_nonneg_left hsum (by positivity) + _ ≤ (1/(f.m e.weight:ℝ)) * (f.L e.weight:ℝ)^(1/f.r) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact Real.rpow_le_rpow (Nat.cast_nonneg _) (by exact_mod_cast e.length_le) + (one_div_nonneg.mpr f.r_pos.le) + _ = _ := by ring + +lemma FinitePath.crop_lp_bound {f : Family} (P : FinitePath f) (A : Crop) + (h : ∀ i j, ‖array f.exponent ((P.piece i).child j)‖ ≤ 1) : + ‖array f.exponent (restrict (A.set f) P.value)‖ ≤ ∑ j ∈ P.active A, f.theta j := by + let s : Finset (Fin P.length) := Finset.univ.filter + (fun i => restrict (A.set f) (P.raw.piece i) ≠ 0) + have heq : restrict (A.set f) P.value = ∑ i ∈ s, restrict (A.set f) (P.raw.piece i) := by + rw [FinitePath.value, restrict, Finsupp.filter_sum] + symm + apply Finset.sum_subset (Finset.filter_subset _ _) + intro i _ hi + simpa [s] using hi + rw [heq, array_sum] + calc + ‖∑ i ∈ s, array f.exponent (restrict (A.set f) (P.raw.piece i))‖ + ≤ ∑ i ∈ s, ‖array f.exponent (restrict (A.set f) (P.raw.piece i))‖ := norm_sum_le _ _ + _ ≤ ∑ i ∈ s, f.theta (P.raw.weight i) := by + apply Finset.sum_le_sum + intro i _ + calc + _ ≤ ‖array f.exponent (P.raw.piece i)‖ := + norm_array_filter_le f.exponent f.exponent_ne_zero _ _ + _ ≤ f.theta (P.raw.weight i) := by + rw [← P.value_eq, ← P.weight_eq] + exact (P.piece i).lp_bound (h i) + _ = _ := by + change _ = ∑ j ∈ s.image (fun i : Fin P.length => P.raw.weight i), f.theta j + rw [Finset.sum_image] + exact fun _ _ _ _ hij => P.valid.weight_strict.injective hij + +lemma TypeII.lp_bound {f : Family} (e : TypeII f) + (h : ∀ b i j, ‖array f.exponent (((e.path b).piece i).child j)‖ ≤ 1) : + ‖array f.exponent e.value‖ < 1/8 := by + let s := Finset.univ.biUnion (fun b => (e.path b).active (e.crop b)) + have hpos : ∀ j ∈ s, 1 ≤ j := by + intro j hj + obtain ⟨b, _, hj⟩ := Finset.mem_biUnion.mp hj + obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hj + exact (e.path b).valid.weight_pos _ i.isLt + have hinj : Set.InjOn (fun j : ℕ => j-1) s := by + intro j hj k hk heq + have := hpos j hj + have := hpos k hk + change j-1 = k-1 at heq + omega + rw [TypeII.value, array_sum] + calc + ‖∑ b, array f.exponent (e.coefficient b • restrict ((e.crop b).set f) (e.path b).value)‖ + ≤ ∑ b, ‖array f.exponent (e.coefficient b • restrict ((e.crop b).set f) (e.path b).value)‖ := + norm_sum_le _ _ + _ ≤ ∑ b, ∑ j ∈ (e.path b).active (e.crop b), f.theta j := by + apply Finset.sum_le_sum + intro b _ + rw [array_smul, norm_smul, Real.norm_eq_abs] + calc + _ ≤ 1 * ‖array f.exponent (restrict ((e.crop b).set f) (e.path b).value)‖ := + mul_le_mul_of_nonneg_right (e.coefficient_le_one b) (norm_nonneg _) + _ ≤ _ := by simpa using (e.path b).crop_lp_bound (e.crop b) (h b) + _ = ∑ j ∈ s, f.theta j := by + symm + apply Finset.sum_biUnion + intro b _ c _ hbc + exact e.disjoint_active hbc + _ = ∑ n ∈ s.image (fun j => j-1), Parameters.theta f.s n := by + rw [Finset.sum_image] + · rfl + · exact fun _ hj _ hk heq => hinj hj hk heq + _ ≤ ∑' n, Parameters.theta f.s n := + (Parameters.hasSum_theta f.s_ge_two).summable.sum_le_tsum _ + (fun n _ => by rw [Parameters.theta_eq f.s_ge_two]; positivity) + _ < 1/8 := Parameters.theta_sum_small f.s_ge_two + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped ENNReal NNReal Classical +open LpFinite + +lemma Family.theta_le_one (f : Family) (j : ℕ) : f.theta j ≤ 1 := by + rw [Family.theta, Parameters.theta_eq f.s_ge_two] + exact pow_le_one₀ (by norm_num) (by norm_num) + +lemma stage_lp_bound {base : Set Array} (f : Family) + (hbase : ∀ x ∈ base, ‖array f.exponent x‖ ≤ 1) : + ∀ n x, x ∈ stage base f n → ‖array f.exponent x‖ ≤ 1 := by + intro n + induction n with + | zero => exact hbase + | succ n ih => + intro x hx + rcases hx with (hx | ⟨e, rfl, he⟩) | ⟨e, rfl, he⟩ + · exact ih x hx + · exact (e.lp_bound (fun i => ih _ (he i))).trans (f.theta_le_one _) + · exact (e.lp_bound (fun b i j => ih _ (he b i j))).le.trans (by norm_num) + +/-- The pure coefficient ℓr estimate. -/ +lemma pure_lp_bound (k : ℕ) (x : Array) (hx : x ∈ Pure k) : + ‖array (Family.pure k).exponent x‖ ≤ 1 := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + apply stage_lp_bound (.pure k) ?_ n x hn + intro y hy + rcases hy with rfl | ⟨a, _, rfl | rfl⟩ + · simp + · rw [norm_array_single (Family.exponent_ne_zero _)]; norm_num + · rw [norm_array_single (Family.exponent_ne_zero _)]; norm_num + +end SeparableQuotient.Norming + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/FiniteNormers.lean b/lean/OAI/Analysis/SeparableQuotients/FiniteNormers.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fc5e410fa6c4200b768086d8886c6ac4e88efab --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/FiniteNormers.lean @@ -0,0 +1,301 @@ +import OAI.Analysis.SeparableQuotients.PrefixNormers + +namespace OAI + +namespace SeparableQuotient +open Set Metric +open scoped Topology +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + +@[reducible] noncomputable local instance selectionDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 X) := inferInstance +@[reducible] noncomputable local instance selectionDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 X) := inferInstance + +/-- Finite half-normers in the unit ball. -/ +theorem exists_finite_normers (F : Submodule 𝕜 (StrongDual 𝕜 X)) + [FiniteDimensional 𝕜 F] : + ∃ D : Finset X, (∀ d ∈ D, ‖d‖ ≤ 1) ∧ + ∀ v : F, ∃ d ∈ D, ‖v‖ ≤ 2 * ‖(v : StrongDual 𝕜 X) d‖ := by + classical + let U (d : closedBall (0 : X) 1) : Set F := + {v | (1 / 2 : ℝ) < ‖(v : StrongDual 𝕜 X) d‖} + have hU : ∀ d, IsOpen (U d) := by + intro d + exact isOpen_lt continuous_const + (((NormedSpace.inclusionInDoubleDual 𝕜 X d).comp F.subtypeL).continuous.norm) + have hcover : sphere (0 : F) 1 ⊆ ⋃ d, U d := by + intro v hv + have hn : ‖v‖ = 1 := by simpa only [mem_sphere, dist_zero_right] using hv + obtain ⟨d, hd, he⟩ := (v : StrongDual 𝕜 X).exists_lt_apply_of_lt_opNorm + (by change (1 / 2 : ℝ) < ‖v‖; rw [hn]; norm_num) + exact Set.mem_iUnion.mpr ⟨⟨d, by simpa only [mem_closedBall, dist_zero_right] using hd.le⟩, he⟩ + obtain ⟨t, ht⟩ := (isCompact_sphere (0 : F) 1).elim_finite_subcover U hU hcover + refine ⟨insert 0 (t.image Subtype.val), ?_, ?_⟩ + · intro d hd + rcases Finset.mem_insert.mp hd with rfl | hd + · simp + · obtain ⟨e, _, rfl⟩ := Finset.mem_image.mp hd + simpa only [mem_closedBall, dist_zero_right] using e.property + · intro v + by_cases hv : v = 0 + · subst v; exact ⟨0, Finset.mem_insert_self _ _, by simp⟩ + have hn : ‖v‖ ≠ 0 := norm_ne_zero_iff.mpr hv + have hp : 0 < ‖v‖ := norm_pos_iff.mpr hv + let w : F := (↑‖v‖ : 𝕜)⁻¹ • v + have hw : w ∈ sphere (0 : F) 1 := by + simp only [w, mem_sphere, dist_zero_right, norm_smul, norm_inv, + RCLike.norm_ofReal, abs_of_nonneg (norm_nonneg v), inv_mul_cancel₀ hn] + obtain ⟨d, hd, he⟩ := Set.mem_iUnion₂.mp (ht hw) + refine ⟨d, Finset.mem_insert_of_mem (Finset.mem_image.mpr ⟨d, hd, rfl⟩), ?_⟩ + change (1 / 2 : ℝ) < ‖((↑‖v‖ : 𝕜)⁻¹ • (v : StrongDual 𝕜 X)) d‖ at he + simp only [smul_apply, norm_smul, norm_inv, + RCLike.norm_ofReal, abs_of_nonneg (norm_nonneg v)] at he + have hm := (mul_lt_mul_of_pos_left he hp) + rw [← mul_assoc, mul_inv_cancel₀ hn, one_mul] at hm + linarith + +/-- Finite annihilation conditions leave a unit functional in every infinite-dimensional +subspace. -/ +theorem exists_unit_annihilator (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (A : Finset X) : + ∃ f : F, ‖f‖ = 1 ∧ ∀ x ∈ A, (f : StrongDual 𝕜 X) x = 0 := by + classical + let T : F →ₗ[𝕜] (A → 𝕜) := + { toFun := fun f x => (f : StrongDual 𝕜 X) x + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + have hex : ∃ f : F, f ≠ 0 ∧ ∀ x ∈ A, (f : StrongDual 𝕜 X) x = 0 := by + by_contra! hn + apply hF (FiniteDimensional.of_injective T ?_) + intro a b hab + apply sub_eq_zero.mp + by_contra h + obtain ⟨x, hx, hne⟩ := hn (a - b) h + apply hne + have he := congrFun hab ⟨x, hx⟩ + exact sub_eq_zero.mpr he + obtain ⟨f, hf, hzero⟩ := hex + refine ⟨(↑‖f‖ : 𝕜)⁻¹ • f, ?_, ?_⟩ + · simp only [norm_smul, norm_inv, RCLike.norm_ofReal, + abs_of_nonneg (norm_nonneg f), inv_mul_cancel₀ (norm_ne_zero_iff.mpr hf)] + · intro x hx + simp [hzero x hx] + +/-- One finite stage of the normer construction. -/ +structure NormerStep (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (A : Finset X) (S : Finset (StrongDual 𝕜 X)) where + f : F + D : Finset X + norm_f : ‖f‖ = 1 + vanish : ∀ x ∈ A, (f : StrongDual 𝕜 X) x = 0 + unit : ∀ d ∈ D, ‖d‖ ≤ 1 + norming : ∀ v ∈ Submodule.span 𝕜 (insert (f : StrongDual 𝕜 X) (S : Set _)), + ∃ d ∈ D, ‖v‖ ≤ 2 * ‖v d‖ + +noncomputable def chooseNormerStep (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (A : Finset X) (S : Finset (StrongDual 𝕜 X)) : + NormerStep F A S := Classical.choice <| by + classical + obtain ⟨f, hf, hv⟩ := exists_unit_annihilator F hF A + let G := Submodule.span 𝕜 (insert (f : StrongDual 𝕜 X) (S : Set _)) + let : FiniteDimensional 𝕜 G := FiniteDimensional.span_of_finite 𝕜 (S.finite_toSet.insert _) + obtain ⟨D, hD, hn⟩ := exists_finite_normers G + exact ⟨⟨f, D, hf, hv, hD, fun v hv => hn ⟨v, hv⟩⟩⟩ + +namespace NormerStep +noncomputable local instance : DecidableEq X := Classical.decEq X +noncomputable local instance : DecidableEq (StrongDual 𝕜 X) := Classical.decEq _ +variable (F : Submodule 𝕜 (StrongDual 𝕜 X)) (hF : ¬ FiniteDimensional 𝕜 F) +variable (xs : ℕ → X) + +/-- Accumulated annihilation constraints and preceding functionals. -/ +noncomputable def state : ℕ → Finset X × Finset (StrongDual 𝕜 X) + | 0 => (∅, ∅) + | n + 1 => + let p := state n + let q := chooseNormerStep F hF (insert (xs n) p.1) p.2 + (insert (xs n) (p.1 ∪ q.D), insert (q.f : StrongDual 𝕜 X) p.2) + +noncomputable def stage (n : ℕ) := + chooseNormerStep F hF (insert (xs n) (state F hF xs n).1) (state F hF xs n).2 + +noncomputable def seq (n : ℕ) : StrongDual 𝕜 X := (stage F hF xs n).f + +lemma state_succ (n : ℕ) : + state F hF xs (n + 1) = + (insert (xs n) ((state F hF xs n).1 ∪ (stage F hF xs n).D), + insert (seq F hF xs n) (state F hF xs n).2) := rfl + +lemma state_monotone : Monotone (fun n => (state F hF xs n).1) := by + classical + apply monotone_nat_of_le_succ + intro n d hd + rw [state_succ] + exact Finset.mem_insert_of_mem (Finset.mem_union_left _ hd) + +lemma state_vectors (n : ℕ) : + (state F hF xs n).2 = (Finset.range n).image (seq F hF xs) := by + classical + induction n with + | zero => rfl + | succ n ih => simp only [state_succ, Finset.range_add_one, Finset.image_insert, ih] + +lemma seq_mem (n : ℕ) : seq F hF xs n ∈ F := (stage F hF xs n).f.property +lemma seq_norm (n : ℕ) : ‖seq F hF xs n‖ = 1 := (stage F hF xs n).norm_f + +lemma seq_vanish_x {m n : ℕ} (hmn : m ≤ n) : seq F hF xs n (xs m) = 0 := by + classical + apply (stage F hF xs n).vanish + by_cases hm : m = n + · subst m; exact Finset.mem_insert_self _ _ + · apply Finset.mem_insert_of_mem + apply state_monotone F hF xs (Nat.succ_le_of_lt (lt_of_le_of_ne hmn hm)) + change xs m ∈ (state F hF xs (m + 1)).1 + rw [state_succ] + exact Finset.mem_insert_self _ _ + +lemma seq_vanish_D {m n : ℕ} (hmn : m < n) {d : X} + (hd : d ∈ (stage F hF xs m).D) : seq F hF xs n d = 0 := by + classical + apply (stage F hF xs n).vanish + apply Finset.mem_insert_of_mem + apply state_monotone F hF xs (Nat.succ_le_of_lt hmn) + change d ∈ (state F hF xs (m + 1)).1 + rw [state_succ] + exact Finset.mem_insert_of_mem (Finset.mem_union_right _ hd) + +lemma stage_norms_prefix (m : ℕ) (c : ℕ → 𝕜) : + ∃ d ∈ (stage F hF xs m).D, + ‖∑ i ∈ Finset.range (m + 1), c i • seq F hF xs i‖ ≤ + 2 * ‖(∑ i ∈ Finset.range (m + 1), c i • seq F hF xs i) d‖ := by + classical + apply (stage F hF xs m).norming + apply Submodule.sum_mem + intro i hi + apply Submodule.smul_mem + apply Submodule.subset_span + have hs := state_vectors F hF xs (m + 1) + rw [state_succ] at hs + dsimp only at hs + have : seq F hF xs i ∈ insert (seq F hF xs m) (state F hF xs m).2 := by + rw [hs] + exact Finset.mem_image.mpr ⟨i, hi, rfl⟩ + exact (Finset.mem_insert.mp this).elim (fun h => Or.inl h) (fun h => Or.inr h) + +end NormerStep + +end SeparableQuotient + +namespace SeparableQuotient +open Set Metric +open scoped Topology BigOperators +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] +@[reducible] noncomputable local instance criterionDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 X) := inferInstance +@[reducible] noncomputable local instance criterionDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 X) := inferInstance + +namespace NormerStep +variable (F : Submodule 𝕜 (StrongDual 𝕜 X)) (hF : ¬ FiniteDimensional 𝕜 F) +variable (xs : ℕ → X) + +/-- The recursive choices satisfy exactly the prefix hypotheses. -/ +noncomputable def prefixNormers : PrefixNormers (seq F hF xs) where + D := fun n => match n with + | 0 => {0} + | m + 1 => (stage F hF xs m).D + unit := by + intro m d hd + cases m with + | zero => have he : d = 0 := Finset.mem_singleton.mp hd + subst d; simp + | succ m => exact (stage F hF xs m).unit d hd + norming := by + intro m hm c + cases m with + | zero => omega + | succ m => exact stage_norms_prefix F hF xs m c + vanish := by + intro m n hmn d hd + cases m with + | zero => have he : d = 0 := Finset.mem_singleton.mp hd + subst d; simp + | succ m => exact seq_vanish_D F hF xs (Nat.lt_of_succ_le hmn) hd + +lemma span_le [IsClosed (F : Set (StrongDual 𝕜 X))] : + PrefixNormers.closedSpan (seq F hF xs) ≤ F := by + apply Submodule.topologicalClosure_minimal _ (ht := ‹IsClosed (F : Set (StrongDual 𝕜 X))›) + apply Submodule.span_le.mpr + rintro _ ⟨n, rfl⟩ + exact seq_mem F hF xs n + +lemma evaluation_x (j : ℕ) : + PrefixNormers.evaluation (seq F hF xs) (xs j) = + ∑ i ∈ Finset.range j, seq F hF xs i (xs j) • + (prefixNormers F hF xs).coord 1 (by norm_num) (fun n => (seq_norm F hF xs n).ge) i := by + classical + let H := prefixNormers F hF xs + have heq : Set.EqOn (NormedSpace.inclusionInDoubleDual 𝕜 X (xs j)) + (∑ i ∈ Finset.range j, seq F hF xs i (xs j) • + H.ambientCoord 1 (by norm_num) (fun n => (seq_norm F hF xs n).ge) i : + StrongDual 𝕜 (StrongDual 𝕜 X)) + (closure (Submodule.span 𝕜 (Set.range (seq F hF xs)) : Set (StrongDual 𝕜 X))) := by + apply ContinuousLinearMap.eqOn_closure_span + rintro _ ⟨n, rfl⟩ + change seq F hF xs n (xs j) = _ + simp only [sum_apply, smul_apply, H.ambientCoord_basis, smul_eq_mul, + mul_ite, mul_one, mul_zero] + by_cases hn : n < j + · simp [hn] + · simp [hn, seq_vanish_x F hF xs (Nat.le_of_not_gt hn)] + ext v + have hv := heq v.property + change (v : StrongDual 𝕜 X) (xs j) = _ at hv + simpa only [PrefixNormers.evaluation_apply, sum_apply, smul_apply, PrefixNormers.coord, + ContinuousLinearMap.comp_apply, Submodule.subtypeL_apply, H] using hv + +end NormerStep + +/-- The actual evaluation operator on a dual subspace. -/ +noncomputable def subspaceEvaluation (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + X →L[𝕜] StrongDual 𝕜 F := + (ContinuousLinearMap.precomp 𝕜 F.subtypeL).comp (NormedSpace.inclusionInDoubleDual 𝕜 X) + +@[simp] lemma subspaceEvaluation_apply (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (x : X) (f : F) : subspaceEvaluation F x f = (f : StrongDual 𝕜 X) x := rfl + +@[reducible] noncomputable local instance criterionSubspaceDualNormedGroup + (F : Submodule 𝕜 (StrongDual 𝕜 X)) : NormedAddCommGroup (StrongDual 𝕜 F) := inferInstance +@[reducible] noncomputable local instance criterionSubspaceDualNormedSpace + (F : Submodule 𝕜 (StrongDual 𝕜 X)) : NormedSpace 𝕜 (StrongDual 𝕜 F) := inferInstance + +/-- A dense sequence of evaluations can be represented by actual vectors of `X`. -/ +lemma exists_dense_evaluations (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hsep : TopologicalSpace.IsSeparable (Set.range (subspaceEvaluation F))) : + ∃ xs : ℕ → X, ∀ x : X, subspaceEvaluation F x ∈ + closure (Set.range (fun n => subspaceEvaluation F (xs n))) := by + classical + let R := Set.range (subspaceEvaluation F) + let : TopologicalSpace.SeparableSpace R := hsep.separableSpace + let : Nonempty R := ⟨⟨subspaceEvaluation F 0, Set.mem_range_self 0⟩⟩ + obtain ⟨ys, hys⟩ := TopologicalSpace.exists_dense_seq R + choose xs hxs using fun n => (ys n).property + refine ⟨xs, fun x => ?_⟩ + have he : (fun n => subspaceEvaluation F (xs n)) = fun n => (ys n).val := by + funext n; exact hxs n + rw [he] + have hc := image_closure_subset_closure_image + (continuous_subtype_val : Continuous (Subtype.val : R → StrongDual 𝕜 F)) + (s := Set.range ys) + have hm := hc ⟨⟨subspaceEvaluation F x, Set.mem_range_self x⟩, + hys (⟨subspaceEvaluation F x, Set.mem_range_self x⟩ : R), rfl⟩ + simpa only [← Set.range_comp'] using hm + +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/LpDuality.lean b/lean/OAI/Analysis/SeparableQuotients/LpDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..5def3b26a4a4e71e7b6e590bf785ed76f6962cd2 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/LpDuality.lean @@ -0,0 +1,220 @@ +import OAI.Analysis.SeparableQuotients.BranchSeparation + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.LpCoding +open Filter +open scoped Classical Topology ENNReal +universe u v +variable {ι : Type u} {p q : ℝ≥0∞} + +def finite (p : ℝ≥0∞) : (ι →₀ ℝ) →ₗ[ℝ] lp (fun _ : ι => ℝ) p where + toFun c := ⟨fun i => c i, Memℓp.of_exponent_ge (memℓp_zero_iff.mpr c.hasFiniteSupport) (zero_le (a := p))⟩ + map_add' _ _ := by apply lp.ext; funext i; rfl + map_smul' _ _ := by apply lp.ext; funext i; rfl + +@[simp] lemma finite_apply (p : ℝ≥0∞) (c : ι →₀ ℝ) (i : ι) : finite p c i = c i := rfl + +@[simp] lemma finite_single (p : ℝ≥0∞) (i : ι) (a : ℝ) : + finite p (Finsupp.single i a) = lp.single p i a := by + apply lp.ext + funext j + simp [lp.single_apply,Finsupp.single_apply,Pi.single_apply,eq_comm] + +lemma norm_finite (hp : 0 < p.toReal) (c : ι →₀ ℝ) : + ‖finite p c‖ = (∑ i ∈ c.support, |c i| ^ p.toReal) ^ (1/p.toReal) := by + rw [lp.norm_eq_tsum_rpow hp] + congr 1 + simp only [finite_apply,Real.norm_eq_abs] + apply tsum_eq_sum + intro i hi + simp [Finsupp.notMem_support_iff.mp hi,hp.ne'] + +lemma finite_dense [Fact (1 ≤ p)] (hp : p ≠ ∞) : DenseRange (finite p : (ι →₀ ℝ) → _) := by + intro x + apply isClosed_closure.mem_of_tendsto (lp.hasSum_single hp x) + apply Eventually.of_forall + intro s + apply subset_closure + refine ⟨∑ i ∈ s, Finsupp.single i (x i),?_⟩ + simp + +/-- The finite-support formulation of the norm of an ℓp dual element. -/ +lemma finite_dual_bound (hpq : p.toReal.HolderConjugate q.toReal) + (C : ℝ) (hC : 0 ≤ C) (a : ι → ℝ) + (h : ∀ c : ι →₀ ℝ, |c.sum (fun i t => t*a i)| ≤ C*‖finite p c‖) + (s : Finset ι) : ∑ i ∈ s, |a i| ^ q.toReal ≤ C ^ q.toReal := by + let sign : ℝ → ℝ := fun t => if 0 ≤ t then 1 else -1 + have sign_abs (t : ℝ) : |sign t| = 1 := by dsimp [sign]; split_ifs <;> norm_num + have sign_mul (t : ℝ) : sign t*t = |t| := by + dsimp [sign]; split_ifs with ht + · simp [abs_of_nonneg ht] + · simp [abs_of_neg (lt_of_not_ge ht)] + let c : ι →₀ ℝ := Finsupp.onFinset s + (fun i => if i ∈ s then sign (a i)*|a i|^(q.toReal-1) else 0) + (fun i hi => by by_contra hn; exact hi (ite_eq_right hn)) + have ci (i : ι) : c i = if i ∈ s then sign (a i)*|a i|^(q.toReal-1) else 0 := rfl + let A : ℝ := ∑ i ∈ s, |a i|^q.toReal + have hA : 0 ≤ A := Finset.sum_nonneg (fun i _ => Real.rpow_nonneg (abs_nonneg _) _) + have hpow (i : ι) : |sign (a i)*|a i|^(q.toReal-1)|^p.toReal = |a i|^q.toReal := by + rw [abs_mul,sign_abs,one_mul,abs_of_nonneg (Real.rpow_nonneg (abs_nonneg _) _), + ← Real.rpow_mul (abs_nonneg _),hpq.symm.sub_one_mul_conj] + have hc : ‖finite p c‖ = A^(1/p.toReal) := by + rw [lp.norm_eq_tsum_rpow hpq.pos] + congr 1 + calc + _ = ∑ i ∈ s, |c i|^p.toReal := by + simp only [finite_apply,Real.norm_eq_abs] + apply tsum_eq_sum + intro i hi + simp only [ci,ite_eq_right hi,abs_zero,Real.zero_rpow hpq.ne_zero] + _ = A := Finset.sum_congr rfl (fun i hi => by rw [ci,ite_eq_left hi,hpow]) + have hpair : c.sum (fun i t => t*a i) = A := by + rw [Finsupp.sum_of_support_subset c (show c.support ⊆ s from by + intro i hi; by_contra hn; exact Finsupp.mem_support_iff.mp hi (by rw [ci,ite_eq_right hn])) + (fun i t => t*a i) (fun i _ => zero_mul _)] + apply Finset.sum_congr rfl + intro i hi + rw [ci,ite_eq_left hi] + calc + sign (a i)*|a i|^(q.toReal-1)*a i = |a i|^(q.toReal-1)*|a i| := by rw [← sign_mul]; ring + _ = |a i|^q.toReal := by + rw [← Real.rpow_add_one' (abs_nonneg _) (by linarith [hpq.symm.pos])] + congr 1 + ring + have hb := h c + rw [hpair,abs_of_nonneg hA,hc] at hb + by_cases hAz : A=0 + · rw [show (∑ i ∈ s, |a i|^q.toReal)=0 from hAz] + exact Real.rpow_nonneg hC _ + have hAp : 0 < A := lt_of_le_of_ne hA (Ne.symm hAz) + have hnorm : A^(1/q.toReal) ≤ C := by + have hexp : 1/q.toReal = 1-1/p.toReal := by simpa only [one_div] using hpq.one_sub_inv.symm + rw [hexp,Real.rpow_sub hAp,Real.rpow_one] + exact (div_le_iff₀ (Real.rpow_pos_of_pos hAp _)).mpr hb + have hr := Real.rpow_le_rpow (Real.rpow_nonneg hA _) hnorm hpq.symm.pos.le + simpa only [← Real.rpow_mul hA,one_div_mul_cancel hpq.symm.ne_zero,Real.rpow_one] using hr + +lemma dual_mem (hpq : p.toReal.HolderConjugate q.toReal) + (C : ℝ) (hC : 0 ≤ C) (a : ι → ℝ) + (h : ∀ c : ι →₀ ℝ, |c.sum (fun i t => t*a i)| ≤ C*‖finite p c‖) : Memℓp a q := by + apply memℓp_gen' + simpa only [Real.norm_eq_abs] using finite_dual_bound hpq C hC a h + +lemma dual_norm (hpq : p.toReal.HolderConjugate q.toReal) + (C : ℝ) (hC : 0 ≤ C) (a : ι → ℝ) + (h : ∀ c : ι →₀ ℝ, |c.sum (fun i t => t*a i)| ≤ C*‖finite p c‖) : + ‖(⟨a,dual_mem hpq C hC a h⟩ : lp (fun _ : ι => ℝ) q)‖ ≤ C := by + apply lp.norm_le_of_forall_sum_le hpq.symm.pos hC + simpa only [Real.norm_eq_abs] using finite_dual_bound hpq C hC a h + +end SeparableQuotient.LpCoding + +namespace SeparableQuotient.LpCoding +open Filter +open scoped Classical Topology ENNReal +universe u v +variable {ι : Type u} {p q : ℝ≥0∞} [Fact (1 ≤ p)] [Fact (1 ≤ q)] + +omit [Fact (1 ≤ p)] [Fact (1 ≤ q)] in +lemma single_eq_smul (p : ℝ≥0∞) (i : ι) (a : ℝ) : + lp.single (E := fun _ : ι => ℝ) p i a = a • lp.single p i (1 : ℝ) := by + simpa only [smul_eq_mul,mul_one] using (lp.single_smul (E := fun _ : ι => ℝ) (𝕜 := ℝ) p i a (1 : ℝ)) + +lemma coefficient_bound (g : StrongDual ℝ (lp (fun _ : ι => ℝ) p)) (c : ι →₀ ℝ) : + |c.sum (fun i t => t*g (lp.single p i 1))| ≤ ‖g‖ * ‖finite p c‖ := by + have he : c.sum (fun i t => t*g (lp.single p i 1)) = g (finite p c) := by + conv_rhs => rw [← Finsupp.sum_single c] + simp only [map_finsuppSum,finite_single] + apply Finset.sum_congr rfl + intro i _ + dsimp only + rw [single_eq_smul p i (c i),map_smul,smul_eq_mul] + rw [he] + exact g.le_opNorm _ + +def coefficients (hpq : p.toReal.HolderConjugate q.toReal) + (g : StrongDual ℝ (lp (fun _ : ι => ℝ) p)) : lp (fun _ : ι => ℝ) q := + ⟨fun i => g (lp.single p i 1), + dual_mem hpq ‖g‖ (norm_nonneg _) _ (coefficient_bound g)⟩ + +omit [Fact (1 ≤ q)] in +@[simp] lemma coefficients_apply (hpq : p.toReal.HolderConjugate q.toReal) + (g : StrongDual ℝ (lp (fun _ : ι => ℝ) p)) (i : ι) : + coefficients hpq g i = g (lp.single p i 1) := rfl + +omit [Fact (1 ≤ q)] in +lemma norm_coefficients_le (hpq : p.toReal.HolderConjugate q.toReal) + (g : StrongDual ℝ (lp (fun _ : ι => ℝ) p)) : ‖coefficients hpq g‖ ≤ ‖g‖ := + dual_norm hpq ‖g‖ (norm_nonneg _) _ (coefficient_bound g) + +def coefficientMap (hpq : p.toReal.HolderConjugate q.toReal) : + StrongDual ℝ (lp (fun _ : ι => ℝ) p) →L[ℝ] lp (fun _ : ι => ℝ) q := + LinearMap.mkContinuous + { toFun := coefficients hpq + map_add' := fun _ _ => by apply lp.ext; rfl + map_smul' := fun _ _ => by apply lp.ext; rfl } + 1 (fun g => by simpa using norm_coefficients_le hpq g) + +@[simp] lemma coefficientMap_apply (hpq : p.toReal.HolderConjugate q.toReal) + (g : StrongDual ℝ (lp (fun _ : ι => ℝ) p)) (i : ι) : + coefficientMap hpq g i = g (lp.single p i 1) := rfl + +lemma norm_coefficientMap_le (hpq : p.toReal.HolderConjugate q.toReal) : + ‖coefficientMap (ι := ι) hpq‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro g + change ‖coefficients hpq g‖ ≤ 1*‖g‖ + simpa using norm_coefficients_le hpq g + +/-- Symmetry of the two ℓp dual evaluations. -/ +lemma eval_coefficients_symm (hpq : p.toReal.HolderConjugate q.toReal) + (hp : p ≠ ∞) (hq : q ≠ ∞) + (g : StrongDual ℝ (lp (fun _ : ι => ℝ) p)) + (h : StrongDual ℝ (lp (fun _ : ι => ℝ) q)) : + g (coefficients hpq.symm h) = h (coefficients hpq g) := by + have hg := g.continuous.tendsto _ |>.comp + (lp.hasSum_single hp (coefficients hpq.symm h)) + have hh := h.continuous.tendsto _ |>.comp + (lp.hasSum_single hq (coefficients hpq g)) + have he : (fun s : Finset ι => g (∑ i ∈ s, lp.single p i (coefficients hpq.symm h i))) = + (fun s : Finset ι => h (∑ i ∈ s, lp.single q i (coefficients hpq g i))) := by + funext s + simp only [map_sum,coefficients_apply] + apply Finset.sum_congr rfl + intro i _ + rw [single_eq_smul p i (h (lp.single q i 1)), + single_eq_smul q i (g (lp.single p i 1))] + simp only [map_smul,smul_eq_mul,mul_comm] + exact tendsto_nhds_unique hg (by simpa only [Function.comp_def,← he] using hh) + +variable {E : Type v} [NormedAddCommGroup E] [NormedSpace ℝ E] + +def analysisMap (hpq : p.toReal.HolderConjugate q.toReal) + (T : lp (fun _ : ι => ℝ) p →L[ℝ] E) : StrongDual ℝ E →L[ℝ] lp (fun _ : ι => ℝ) q := + LinearMap.mkContinuous + { toFun := fun g => coefficients hpq (g.comp T) + map_add' := fun g h => by apply lp.ext; rfl + map_smul' := fun c g => by apply lp.ext; rfl } + ‖T‖ (fun g => (norm_coefficients_le hpq (g.comp T)).trans + (by simpa only [mul_comm] using ContinuousLinearMap.opNorm_comp_le g T)) + +@[simp] lemma analysisMap_apply (hpq : p.toReal.HolderConjugate q.toReal) + (T : lp (fun _ : ι => ℝ) p →L[ℝ] E) (g : StrongDual ℝ E) (i : ι) : + analysisMap hpq T g i = g (T (lp.single p i 1)) := rfl + +lemma norm_analysisMap_le (hpq : p.toReal.HolderConjugate q.toReal) + (T : lp (fun _ : ι => ℝ) p →L[ℝ] E) : ‖analysisMap hpq T‖ ≤ ‖T‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro g + change ‖coefficients hpq (g.comp T)‖ ≤ _ + exact (norm_coefficients_le hpq (g.comp T)).trans + (by simpa only [mul_comm] using ContinuousLinearMap.opNorm_comp_le g T) + +end SeparableQuotient.LpCoding + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Main.lean b/lean/OAI/Analysis/SeparableQuotients/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0974be874e6306356f5c52e9def9cbb741b4d87 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Main.lean @@ -0,0 +1,14 @@ +import OAI.Analysis.SeparableQuotients.NegativeComplex + +namespace OAI + +namespace SeparableQuotient + +universe u + +theorem negative_main (hCH : CH) : ¬ SQ.{u} ℝ ∧ ¬ SQ.{u} ℂ := + ⟨negative_real hCH, negative_complex hCH⟩ + +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/MarkedEstimates.lean b/lean/OAI/Analysis/SeparableQuotients/MarkedEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..557521a64adeb974c744de1a6b40484e93de76ed --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/MarkedEstimates.lean @@ -0,0 +1,209 @@ +import OAI.Analysis.SeparableQuotients.WindowCharges + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.FiniteVectors +open scoped Classical ENNReal +universe u +variable {ι : Type u} [Fintype ι] + +def vec (p : ℝ≥0∞) (v : ι → ℝ) : lp (fun _ : ι => ℝ) p := ⟨v, Memℓp.all v⟩ + +@[simp] lemma vec_apply (p : ℝ≥0∞) (v : ι → ℝ) (i : ι) : vec p v i = v i := rfl +@[simp] lemma vec_zero (p : ℝ≥0∞) : vec p (0 : ι → ℝ) = 0 := rfl +@[simp] lemma vec_add (p : ℝ≥0∞) (v w : ι → ℝ) : vec p (v+w) = vec p v+vec p w := rfl +@[simp] lemma vec_smul (p : ℝ≥0∞) (c : ℝ) (v : ι → ℝ) : vec p (c • v) = c • vec p v := rfl + +lemma norm_rpow {p : ℝ≥0∞} (hp : 0 < p.toReal) (v : ι → ℝ) : + ‖vec p v‖^p.toReal = ∑ i, |v i|^p.toReal := by + rw [lp.norm_rpow_eq_tsum hp, tsum_fintype] + simp only [vec_apply, Real.norm_eq_abs] + +lemma norm_le {p : ℝ≥0∞} (hp : 0 < p.toReal) (v : ι → ℝ) (K : ℝ) (hK : 0 ≤ K) + (h : ∑ i, |v i|^p.toReal ≤ K^p.toReal) : ‖vec p v‖ ≤ K := by + apply (Real.rpow_le_rpow_iff (lp.norm_nonneg' (vec p v)) hK hp).mp + rw [norm_rpow hp] + exact h + +lemma sum_rpow_larger (v : ι → ℝ) (p r K : ℝ) (hp : 0 < p) (hpr : p ≤ r) (hK : 0 ≤ K) + (hv : ∑ i, |v i|^p ≤ K^p) : ∑ i, |v i|^r ≤ K^r := by + have hi (i : ι) : |v i| ≤ K := by + apply (Real.rpow_le_rpow_iff (abs_nonneg _) hK hp).mp + exact (Finset.single_le_sum (fun j _ => Real.rpow_nonneg (abs_nonneg (v j)) p) (Finset.mem_univ i)).trans hv + calc + _ = ∑ i, |v i|^p * |v i|^(r-p) := by + apply Finset.sum_congr rfl + intro i _ + rw [← Real.rpow_add' (abs_nonneg _) (by linarith : p+(r-p) ≠ 0)] + congr 1 + ring + _ ≤ ∑ i, |v i|^p * K^(r-p) := Finset.sum_le_sum (fun i _ => + mul_le_mul_of_nonneg_left (Real.rpow_le_rpow (abs_nonneg _) (hi i) (sub_nonneg.mpr hpr)) (Real.rpow_nonneg (abs_nonneg _) _)) + _ = (∑ i, |v i|^p) * K^(r-p) := (Finset.sum_mul ..).symm + _ ≤ K^p * K^(r-p) := mul_le_mul_of_nonneg_right hv (Real.rpow_nonneg hK _) + _ = K^r := by + rw [← Real.rpow_add' hK (by linarith : p+(r-p) ≠ 0)] + congr 1 + ring + +lemma norm_mono_exponent {p r : ℝ≥0∞} (hp : 0 < p.toReal) (hpr : p.toReal ≤ r.toReal) + (v : ι → ℝ) : ‖vec r v‖ ≤ ‖vec p v‖ := by + apply norm_le (hp.trans_le hpr) _ _ (lp.norm_nonneg' (vec p v)) + exact sum_rpow_larger v p.toReal r.toReal _ hp hpr (lp.norm_nonneg' (vec p v)) (le_of_eq (norm_rpow hp v).symm) + +lemma norm_const {p : ℝ≥0∞} (hp : 0 < p.toReal) (c : ℝ) : + ‖vec p (fun _ : ι => c)‖ = |c| * (Fintype.card ι : ℝ)^(1/p.toReal) := by + apply (Real.rpow_left_inj (lp.norm_nonneg' (vec p (fun _ : ι => c))) (by positivity) hp.ne').mp + rw [norm_rpow hp, Real.mul_rpow (abs_nonneg _) (by positivity), + ← Real.rpow_mul (Nat.cast_nonneg _), one_div_mul_cancel hp.ne', Real.rpow_one] + simp [mul_comm] + +lemma norm_le_card {p : ℝ≥0∞} (hp : 0 < p.toReal) (v : ι → ℝ) (K : ℝ) (hK : 0 ≤ K) + (h : ∀ i, |v i| ≤ K) : ‖vec p v‖ ≤ K * (Fintype.card ι : ℝ)^(1/p.toReal) := by + have hn : p ≠ 0 := by intro hh; simp [hh] at hp + calc + _ ≤ ‖vec p (fun _ : ι => K)‖ := lp.norm_mono hn (fun i => by simpa [Real.norm_eq_abs, abs_of_nonneg hK] using h i) + _ = _ := by rw [norm_const hp, abs_of_nonneg hK] + +lemma norm_mask_le {p : ℝ≥0∞} (hp : p ≠ 0) (v : ι → ℝ) (s : Finset ι) : + ‖vec p (fun i => if i ∈ s then v i else 0)‖ ≤ ‖vec p v‖ := by + apply lp.norm_mono hp + intro i + by_cases hi : i ∈ s <;> simp [hi] + +end SeparableQuotient.FiniteVectors + +namespace SeparableQuotient.FiniteVectors +open scoped Classical ENNReal +universe u v +variable {ι : Type u} [Fintype ι] {β : Type v} [Fintype β] + +lemma norm_eq_rpow {p : ℝ≥0∞} (hp : 0 < p.toReal) (v : ι → ℝ) : + ‖vec p v‖ = (∑ i, |v i|^p.toReal)^(1/p.toReal) := by + rw [← norm_rpow hp, ← Real.rpow_mul (lp.norm_nonneg' _), mul_one_div_cancel hp.ne', Real.rpow_one] + +lemma sum_abs_le_norm (p : ℝ) (hp : 1 < p) (v : ι → ℝ) : + ∑ i, |v i| ≤ ‖vec (ENNReal.ofReal p) v‖ * (Fintype.card ι : ℝ)^(1-1/p) := by + have hp0 : 0 < p := zero_lt_one.trans hp + have he : 0 < 1-1/p := sub_pos.mpr ((div_lt_one hp0).mpr hp) + have hc : Real.HolderConjugate p (1/(1-1/p)) := { + inv_add_inv_eq_inv := by simp [one_div] + left_pos := hp0 + right_pos := by positivity } + have h := Real.inner_le_Lp_mul_Lq_of_nonneg Finset.univ (f := fun i => |v i|) + (g := fun _ => (1 : ℝ)) hc (fun i _ => abs_nonneg _) (fun _ _ => zero_le_one) + simpa only [mul_one, Real.one_rpow, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, + one_div_one_div, norm_eq_rpow (by simpa only [ENNReal.toReal_ofReal hp0.le] using hp0 : 0 < (ENNReal.ofReal p).toReal), + ENNReal.toReal_ofReal hp0.le] using h + +/-- Eight marked entries per row imply the precise uniform marked charge, +using only the actual column Hölder bound. -/ +lemma marked_norm_bound (q : ℝ) (hq : 1 < q) (r : ℝ≥0∞) (hqr : q ≤ r.toReal) + (a : β → ℝ) (ha : ∑ b, |a b|^q ≤ 1) (marks : β → Finset ι) + (hmarks : ∀ b, (marks b).card ≤ 8) (M : ι → ℝ) (hM : ∀ i, 0 ≤ M i) + (hcolumn : ∀ i, M i ≤ 2 * (∑ b, if i ∈ marks b then |a b|^q else 0)^(1/q)) : + ‖vec r M‖ ≤ 16 ∧ ∑ i, M i ≤ 16*(Fintype.card ι : ℝ)^(1-1/q) := by + have hq0 : 0 < q := zero_lt_one.trans hq + let H (i : ι) : ℝ := ∑ b, if i ∈ marks b then |a b|^q else 0 + have hH (i : ι) : 0 ≤ H i := by apply Finset.sum_nonneg; intro b _; split_ifs <;> positivity + have hHsum : ∑ i, H i ≤ 8 := by + dsimp only [H] + rw [Finset.sum_comm] + calc + _ = ∑ b, ((marks b).card : ℝ) * |a b|^q := by + apply Finset.sum_congr rfl + intro b _ + simp + _ ≤ ∑ b, 8 * |a b|^q := Finset.sum_le_sum (fun b _ => + mul_le_mul_of_nonneg_right (by exact_mod_cast hmarks b) (Real.rpow_nonneg (abs_nonneg _) _)) + _ = 8 * ∑ b, |a b|^q := (Finset.mul_sum ..).symm + _ ≤ 8 := by linarith + have hpow (i : ι) : |M i|^q ≤ 2^q * H i := by + rw [abs_of_nonneg (hM i)] + calc + _ ≤ (2*H i^(1/q))^q := Real.rpow_le_rpow (hM i) (hcolumn i) hq0.le + _ = _ := by + rw [Real.mul_rpow (by norm_num) (Real.rpow_nonneg (hH i) _), + ← Real.rpow_mul (hH i), one_div_mul_cancel hq0.ne', Real.rpow_one] + have hbound : ‖vec (ENNReal.ofReal q) M‖ ≤ 2*(8 : ℝ)^(1/q) := by + apply norm_le (by simpa only [ENNReal.toReal_ofReal hq0.le] using hq0 : 0 < (ENNReal.ofReal q).toReal) _ _ (by positivity) + rw [ENNReal.toReal_ofReal hq0.le, Real.mul_rpow (by norm_num) (by positivity), + ← Real.rpow_mul (by norm_num : (0 : ℝ) ≤ 8), one_div_mul_cancel hq0.ne', Real.rpow_one] + exact (Finset.sum_le_sum (fun i _ => hpow i)).trans (by rw [← Finset.mul_sum]; gcongr) + have h16 : ‖vec (ENNReal.ofReal q) M‖ ≤ 16 := by + apply hbound.trans + have he : 1/q ≤ 1 := (div_le_one hq0).mpr hq.le + have hh : (8 : ℝ)^(1/q) ≤ 8 := by + simpa using Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 8) he + linarith + refine ⟨(norm_mono_exponent (by simpa only [ENNReal.toReal_ofReal hq0.le] using hq0 : 0 < (ENNReal.ofReal q).toReal) + (by simpa only [ENNReal.toReal_ofReal hq0.le] using hqr) M).trans h16, ?_⟩ + simpa only [abs_of_nonneg (hM _)] using (sum_abs_le_norm q hq M).trans + (mul_le_mul_of_nonneg_right h16 (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + +end SeparableQuotient.FiniteVectors + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology + +noncomputable def ThinnedWindows.markedCharge {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (i : s) : ℝ := + ∑ b, if i.val ∈ w.marks e hm s b then |(e.coefficient b : ℝ)| *|w.middleEval e b i| else 0 + +lemma ThinnedWindows.markedCharge_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (i : s) : + 0 ≤ w.markedCharge e hm s i := by + apply Finset.sum_nonneg + intro b _ + split_ifs <;> positivity + +lemma ThinnedWindows.marked_column {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (i : s) : + w.markedCharge e hm s i ≤ + 2*(∑ b, if i.val ∈ w.marks e hm s b then |(e.coefficient b : ℝ)|^f.q else 0)^(1/f.q) := by + let c (b : Fin e.length) : ℝ := if i.val ∈ w.marks e hm s b then e.coefficient b else 0 + have he (b : Fin e.length) : |c b| *|w.middleEval e b i| = + if i.val ∈ w.marks e hm s b then |(e.coefficient b : ℝ)| *|w.middleEval e b i| else 0 := by + dsimp [c] + split_ifs <;> simp + have hp (b : Fin e.length) : |c b|^f.q = + if i.val ∈ w.marks e hm s b then |(e.coefficient b : ℝ)|^f.q else 0 := by + dsimp [c] + split_ifs + · rfl + · rw [abs_zero, Real.zero_rpow] + exact ne_of_gt (show 0 < f.q from zero_lt_one.trans (Parameters.q_bounds f.s_ge_two).1) + calc + _ = ∑ b, |c b| *|w.middleEval e b i| := by simp only [he, markedCharge] + _ ≤ (∑ b, |c b|^f.q)^(1/f.q)*‖w.blocks.embed i‖ := + TypeII.window_column_bound e hm (w.lower i) (w.upper i) c (w.blocks.embed i) + _ ≤ (∑ b, |c b|^f.q)^(1/f.q)*2 := + mul_le_mul_of_nonneg_left (w.upper_norm i) (Real.rpow_nonneg (Finset.sum_nonneg (fun _ _ => by positivity)) _) + _ = _ := by simp only [hp]; ring + +lemma ThinnedWindows.marked_vector_bounds {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) : + ‖vec f.exponent (w.markedCharge e hm s)‖ ≤ 16 ∧ + (∑ i : s, w.markedCharge e hm s i) ≤ 16*(s.card : ℝ)^(1-1/f.q) := by + let marks (b : Fin e.length) : Finset s := (w.marks e hm s b).subtype (· ∈ s) + have hmarks (b : Fin e.length) : (marks b).card ≤ 8 := by + rw [show (marks b).card = ((w.marks e hm s b).filter (· ∈ s)).card by simp only [marks,Finset.card_subtype]] + exact (Finset.card_filter_le _ _).trans (w.marks_card e hm s b) + have hh := marked_norm_bound f.q (Parameters.q_bounds f.s_ge_two).1 f.exponent + (by simpa only [Family.exponent_toReal,Family.q,Family.r] using (Parameters.q_bounds f.s_ge_two).2.1.le) + (fun b => (e.coefficient b : ℝ)) e.bound marks hmarks (w.markedCharge e hm s) + (w.markedCharge_nonneg e hm s) (fun i => by simpa only [marks,Finset.mem_subtype] using w.marked_column e hm s i) + simpa only [Fintype.card_coe] using hh + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Model.lean b/lean/OAI/Analysis/SeparableQuotients/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..a91c78545f0c16068b0c6b82a9742d4273302957 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Model.lean @@ -0,0 +1,39 @@ +import Mathlib + +namespace OAI + +namespace SeparableQuotient + +open MeasureTheory Cardinal + +universe u + +/-- The continuum hypothesis. -/ +def CH : Prop := Cardinal.mk ℝ = Cardinal.aleph 1 + +/-- A bounded linear surjection onto an infinite-dimensional separable Banach space. -/ +def HasSeparableQuotient (𝕜 : Type) [RCLike 𝕜] + (X : Type u) [NormedAddCommGroup X] [NormedSpace 𝕜 X] : Prop := + ∃ (Y : Type u) (_ : NormedAddCommGroup Y) (_ : NormedSpace 𝕜 Y), + CompleteSpace Y ∧ TopologicalSpace.SeparableSpace Y ∧ + (¬ FiniteDimensional 𝕜 Y) ∧ ∃ T : X →L[𝕜] Y, Function.Surjective T + +/-- The separable quotient assertion at an arbitrary ambient universe. -/ +def SQ (𝕜 : Type) [RCLike 𝕜] : Prop := + ∀ (X : Type u) [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X], + (¬ FiniteDimensional 𝕜 X) → HasSeparableQuotient 𝕜 X + +/-- The probability measure is defined on the full powerset of the continuum. +The last clause quantifies over every smaller index set (represented as a +subset of ℝ); ENNReal tsum is the supremum of finite subsums. -/ +def RealValuedMeasurableContinuum : Prop := + ∃ μ : @Measure ℝ ⊤, + μ Set.univ = 1 ∧ + (∀ x : ℝ, μ {x} = 0) ∧ + ∀ (s : Set ℝ), Cardinal.mk s < Cardinal.mk ℝ → + ∀ (A : s → Set ℝ), Pairwise (fun i j => Disjoint (A i) (A j)) → + μ (⋃ i, A i) = ∑' i, μ (A i) + +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NegativeComplex.lean b/lean/OAI/Analysis/SeparableQuotients/NegativeComplex.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2fc7d1e31bfb8d38ec814bb7e22758513a5dfac --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NegativeComplex.lean @@ -0,0 +1,58 @@ +import OAI.Analysis.SeparableQuotients.ProductQuotients + +namespace OAI + +noncomputable section + +namespace SeparableQuotient +open Set TopologicalSpace +open scoped Classical +universe u + +lemma HasSeparableQuotient.of_equiv {𝕜 : Type} [RCLike 𝕜] + {X Z : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] (d : X ≃L[𝕜] Z) + (h : HasSeparableQuotient 𝕜 Z) : HasSeparableQuotient 𝕜 X := by + obtain ⟨Y,hYn,hYs,hYc,hYsep,hYi,T,hT⟩ := h + let := hYn + let := hYs + exact ⟨Y,hYn,hYs,hYc,hYsep,hYi,T.comp d.toContinuousLinearMap,hT.comp d.surjective⟩ + +/-- A complex quotient gives a real quotient of the underlying real space. -/ +lemma HasSeparableQuotient.restrictScalars {X : Type u} + [NormedAddCommGroup X] [NormedSpace ℂ X] [NormedSpace ℝ X] + [IsScalarTower ℝ ℂ X] + (h : HasSeparableQuotient ℂ X) : HasSeparableQuotient ℝ X := by + obtain ⟨Y,hYn,hYs,hYc,hYsep,hYi,T,hT⟩ := h + let := hYn + let := hYs + let : NormedSpace ℝ Y := NormedSpace.restrictScalars ℝ ℂ Y + have hi : ¬ FiniteDimensional ℝ Y := by + intro hh + let := hh + exact hYi (Module.Finite.of_restrictScalars_finite ℝ ℂ Y) + exact ⟨Y,inferInstance,inferInstance,hYc,hYsep,hi,T.restrictScalars ℝ,hT⟩ + +/-- A real space without a separable quotient has a complexification without a complex separable quotient. -/ +lemma complexify_noSQ (X : Type u) [NormedAddCommGroup X] + [NormedSpace ℝ X] [CompleteSpace X] (h : ¬ HasSeparableQuotient ℝ X) : + ¬ HasSeparableQuotient ℂ (Complexify X) := by + intro hh + have hr := hh.restrictScalars + have hp := hr.of_equiv (Complexify.pairEquiv X).symm + exact (hasSQ_prod_cases hp).elim h h + +/-- CH refutes the complex separable quotient assertion in every universe. -/ +theorem negative_complex (hCH : CH) : ¬ SQ.{u} ℂ := by + intro hSQ + apply negative_real.{u} hCH + intro X _ _ _ hXi + by_contra hX + have hc := hSQ (Complexify X) (Complexify.infinite X hXi) + exact complexify_noSQ X hX hc + +end SeparableQuotient + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NegativeReal.lean b/lean/OAI/Analysis/SeparableQuotients/NegativeReal.lean new file mode 100644 index 0000000000000000000000000000000000000000..d937dc4a2c933499db61e0f3edb99dba20271473 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NegativeReal.lean @@ -0,0 +1,50 @@ +import OAI.Analysis.SeparableQuotients.ChangedPredual + +namespace OAI + +noncomputable section + +namespace SeparableQuotient +open Set TopologicalSpace +open scoped Classical +universe u + +/-- CH refutes the real separable quotient assertion in every universe. -/ +theorem negative_real (hCH : CH) : ¬ SQ.{u} ℝ := by + intro hSQ + let X := ActualSpace.X hCH + let : NormedAddCommGroup X := inferInstance + let : NormedSpace ℝ X := inferInstance + let : CompleteSpace X := ActualSpace.X_complete hCH + let XU := ULift.{u} X + let : NormedAddCommGroup XU := inferInstance + let : NormedSpace ℝ XU := inferInstance + let : CompleteSpace XU := inferInstance + let d : XU ≃L[ℝ] X := ContinuousLinearEquiv.ulift + have hI : ¬ FiniteDimensional ℝ XU := by + intro hh + let := hh + exact ActualSpace.X_infinite hCH + (FiniteDimensional.of_injective d.symm.toLinearMap d.symm.injective) + have hsq := hSQ XU hI + let R : ActualSpace.E ≃L[ℝ] StrongDual ℝ XU := + (ActualSpace.twistedIso hCH).trans (d.symm.arrowCongr (ContinuousLinearEquiv.refl ℝ ℝ)) + let J : XU →L[ℝ] StrongDual ℝ ActualSpace.E := + (ActualSpace.X hCH).subtypeL.comp d.toContinuousLinearMap + have hR (e : ActualSpace.E) (x : XU) : R e x = J x e := by + exact ActualSpace.twistedIso_apply hCH e (d x) + obtain ⟨F,hF,hFi,hFs,hsep⟩ := separable_restriction_of_quotient R J hR hsq + let := hFs.separableSpace + apply ActualSpace.X_restriction_nonseparable hCH F hF hFi + apply hsep.mono + rintro _ ⟨x,hx,rfl⟩ + refine ⟨d.symm ⟨x,hx⟩,?_⟩ + change (J (d.symm ⟨x,hx⟩)).comp F.subtypeL = (ActualSpace.restrict F) x + simp only [J,ContinuousLinearMap.comp_apply,ContinuousLinearEquiv.coe_coe,d.apply_symm_apply] + rfl + +end SeparableQuotient + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NormCompletion.lean b/lean/OAI/Analysis/SeparableQuotients/NormCompletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe9d6b5c66ef43ef11fbffb3f124f8f60dc8ce0d --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NormCompletion.lean @@ -0,0 +1,290 @@ +import OAI.Analysis.SeparableQuotients.ColorDecomposition + +namespace OAI + +noncomputable section + +/- The completion of c₀₀ under a bounded rational norming set. -/ +namespace SeparableQuotient.NormConstruction +open scoped Topology ENNReal +open Filter +universe u +variable {Γ : Type u} + +structure NormingSet (Γ : Type u) where + carrier : Set (Γ →₀ ℚ) + coordinate_mem : ∀ a, Finsupp.single a 1 ∈ carrier + coefficient_bound : ∀ f ∈ carrier, ∀ a, |(f a : ℝ)| ≤ 1 + +namespace NormingSet +variable (K : NormingSet Γ) +abbrev BoundedSpace := lp (fun _ : K.carrier => ℝ) ⊤ + +def coordinateVector (a : Γ) : K.BoundedSpace := + ⟨fun f => (f.val a : ℝ), memℓp_infty ⟨1, by + rintro _ ⟨f, rfl⟩ + exact K.coefficient_bound f.val f.property a⟩⟩ + +@[simp] lemma coordinateVector_apply (a : Γ) (f : K.carrier) : + K.coordinateVector a f = (f.val a : ℝ) := rfl + +lemma norm_coordinateVector_le (a : Γ) : ‖K.coordinateVector a‖ ≤ 1 := + lp.norm_le_of_forall_le (by norm_num) fun f => K.coefficient_bound _ f.property a + +lemma norm_coordinateVector (a : Γ) : ‖K.coordinateVector a‖ = 1 := by + apply le_antisymm (K.norm_coordinateVector_le a) + simpa [coordinateVector] using lp.norm_apply_le_norm (by simp : (⊤ : ℝ≥0∞) ≠ 0) + (K.coordinateVector a) ⟨Finsupp.single a 1, K.coordinate_mem a⟩ + +/-- Algebraic inclusion of the prescribed finitely supported vectors. -/ +def finiteMap : (Γ →₀ ℝ) →ₗ[ℝ] K.BoundedSpace := + Finsupp.linearCombination ℝ K.coordinateVector + +@[simp] lemma finiteMap_single (a : Γ) (t : ℝ) : + K.finiteMap (Finsupp.single a t) = t • K.coordinateVector a := + Finsupp.linearCombination_single _ _ _ + +lemma finiteMap_apply (x : Γ →₀ ℝ) (f : K.carrier) : + K.finiteMap x f = x.sum (fun a t => t * (f.val a : ℝ)) := by + change (lp.evalₗ (𝕜 := ℝ) (fun _ : K.carrier => ℝ) ⊤ f) (K.finiteMap x) = _ + simp only [finiteMap, Finsupp.linearCombination_apply, Finsupp.sum, map_sum, + map_smul, lp.evalₗ_apply, K.coordinateVector_apply, smul_eq_mul] + +@[simp] lemma finiteMap_coordinate (x : Γ →₀ ℝ) (a : Γ) : + K.finiteMap x ⟨Finsupp.single a 1, K.coordinate_mem a⟩ = x a := by + classical + rw [K.finiteMap_apply] + simp [Finsupp.sum, Finsupp.single_apply, apply_ite, eq_comm] + +lemma finiteMap_injective : Function.Injective K.finiteMap := by + intro x y h + ext a + simpa only [K.finiteMap_coordinate] using + congrArg (fun z : K.BoundedSpace => z ⟨Finsupp.single a 1, K.coordinate_mem a⟩) h + +lemma norm_finiteMap_le_l1 (x : Γ →₀ ℝ) : + ‖K.finiteMap x‖ ≤ x.sum (fun _ t => |t|) := by + classical + calc + ‖K.finiteMap x‖ = ‖∑ a ∈ x.support, x a • K.coordinateVector a‖ := rfl + _ ≤ ∑ a ∈ x.support, ‖x a • K.coordinateVector a‖ := norm_sum_le _ _ + _ = _ := by simp only [norm_smul, K.norm_coordinateVector, mul_one, Real.norm_eq_abs, + Finsupp.sum] + +/-- The concrete Banach completion. Its norm is literally the supremum of +absolute evaluations over K. -/ +def closedSpan : Submodule ℝ K.BoundedSpace := K.finiteMap.range.topologicalClosure +abbrev Space := K.closedSpan + +instance : CompleteSpace K.Space := by + let : IsClosed (K.closedSpan : Set K.BoundedSpace) := + Submodule.isClosed_topologicalClosure _ + exact IsClosed.completeSpace_coe + +def includeFinite : (Γ →₀ ℝ) →ₗ[ℝ] K.Space := + K.finiteMap.codRestrict K.closedSpan (fun x => + Submodule.le_topologicalClosure _ ⟨x, rfl⟩) + +@[simp] lemma includeFinite_val (x : Γ →₀ ℝ) : + (K.includeFinite x).val = K.finiteMap x := rfl + +lemma denseRange_includeFinite : DenseRange K.includeFinite := by + have hd : DenseRange (Set.inclusion (show (K.finiteMap.range : Set K.BoundedSpace) ⊆ + K.closedSpan from Submodule.le_topologicalClosure _)) := + (denseRange_inclusion_iff _).mpr (by intro x hx; exact hx) + exact hd.comp (show Function.Surjective K.finiteMap.rangeRestrict from fun ⟨y, x, hx⟩ => + ⟨x, Subtype.ext hx⟩).denseRange + (continuous_inclusion _) + +def functional (f : K.carrier) : K.Space →L[ℝ] ℝ := + (lp.evalCLM ℝ (fun _ : K.carrier => ℝ) ⊤ f).comp K.closedSpan.subtypeL + +def coordinate (a : Γ) : K.Space →L[ℝ] ℝ := + K.functional ⟨Finsupp.single a 1, K.coordinate_mem a⟩ + +@[simp] lemma functional_includeFinite (f : K.carrier) (x : Γ →₀ ℝ) : + K.functional f (K.includeFinite x) = x.sum (fun a t => t * (f.val a : ℝ)) := + K.finiteMap_apply x f + +@[simp] lemma coordinate_includeFinite (a : Γ) (x : Γ →₀ ℝ) : + K.coordinate a (K.includeFinite x) = x a := K.finiteMap_coordinate x a + +def generator (a : Γ) : K.Space := K.includeFinite (Finsupp.single a 1) + +@[simp] lemma norm_generator (a : Γ) : ‖K.generator a‖ = 1 := by + change ‖K.finiteMap (Finsupp.single a 1)‖ = 1 + simp [K.norm_coordinateVector] + +lemma functional_bound (f : K.carrier) (x : K.Space) : |K.functional f x| ≤ ‖x‖ := + lp.norm_apply_le_norm (by simp : (⊤ : ℝ≥0∞) ≠ 0) x.val f + +lemma norm_functional_le (f : K.carrier) : ‖K.functional f‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro x + simpa [Real.norm_eq_abs] using K.functional_bound f x + +lemma coordinate_bound (a : Γ) (x : K.Space) : |K.coordinate a x| ≤ ‖x‖ := + K.functional_bound _ x + +lemma norm_eq_sup (x : K.Space) : ‖x‖ = ⨆ f : K.carrier, |K.functional f x| := + lp.norm_eq_ciSup x.val + +lemma approximating_sequence (x : K.Space) : + ∃ v : ℕ → Γ →₀ ℝ, Tendsto (fun n => K.includeFinite (v n)) atTop (𝓝 x) := by + have hx := K.denseRange_includeFinite x + obtain ⟨v, hv, ht⟩ := mem_closure_iff_seq_limit.mp hx + choose w hw using hv + exact ⟨w, by simpa only [hw] using ht⟩ + +/-- Every completed vector has countable coordinate support. -/ +lemma support_countable (x : K.Space) : Set.Countable {a | K.coordinate a x ≠ 0} := by + obtain ⟨v, hv⟩ := K.approximating_sequence x + have hc : Set.Countable (⋃ n, ((v n).support : Set Γ)) := + Set.countable_iUnion (fun n => (v n).support.countable_toSet) + apply hc.mono + intro a ha + by_contra h + have hz : ∀ n, v n a = 0 := by + intro n + by_contra hn + exact h (Set.mem_iUnion.mpr ⟨n, Finsupp.mem_support_iff.mpr hn⟩) + have ht := (K.coordinate a).continuous.tendsto x |>.comp hv + have ht0 : Tendsto (fun n => K.coordinate a (K.includeFinite (v n))) atTop (𝓝 0) := by + simpa only [K.coordinate_includeFinite, hz] using + (tendsto_const_nhds : Tendsto (fun _ : ℕ => (0 : ℝ)) atTop (𝓝 0)) + exact ha (tendsto_nhds_unique ht ht0) + +/-- Every norming functional is its finite coordinate combination even after +completion; hence no nonzero completed vector can vanish at every coordinate. -/ +lemma functional_eq_sum (f : K.carrier) : + K.functional f = ∑ a ∈ f.val.support, (f.val a : ℝ) • K.coordinate a := by + classical + let g : K.Space →L[ℝ] ℝ := ∑ a ∈ f.val.support, (f.val a : ℝ) • K.coordinate a + have hlin : (K.functional f).toLinearMap.comp K.includeFinite = + g.toLinearMap.comp K.includeFinite := by + apply Finsupp.lhom_ext + intro a t + simp only [LinearMap.comp_apply, ContinuousLinearMap.coe_coe, + K.functional_includeFinite, Finsupp.sum_single_index, zero_mul] + change t * (f.val a : ℝ) = (∑ b ∈ f.val.support, + (f.val b : ℝ) • K.coordinate b) (K.includeFinite (Finsupp.single a t)) + simp only [sum_apply, smul_apply, + K.coordinate_includeFinite, Finsupp.single_apply, smul_eq_mul] + rw [Finset.sum_eq_single a] + · simp [mul_comm] + · intro b _ hab + simp [Ne.symm hab] + · intro ha + have hz : f.val a = 0 := by simpa using (not_congr Finsupp.mem_support_iff).mp ha + simp [hz] + apply DFunLike.coe_injective + apply K.denseRange_includeFinite.equalizer (K.functional f).continuous g.continuous + funext x + exact LinearMap.congr_fun hlin x + +lemma coordinates_separate (x : K.Space) (h : ∀ a, K.coordinate a x = 0) : x = 0 := by + apply Subtype.ext + apply lp.ext + funext f + change K.functional f x = 0 + rw [K.functional_eq_sum] + simp [h] + +lemma coordinate_ext {x y : K.Space} (h : ∀ a, K.coordinate a x = K.coordinate a y) : x = y := by + apply sub_eq_zero.mp + apply K.coordinates_separate + intro a + rw [(K.coordinate a).map_sub x y, h a, sub_self] + +end NormingSet +end SeparableQuotient.NormConstruction + +namespace SeparableQuotient.NormConstruction.NormingSet +open scoped Topology ENNReal Classical +open Filter +universe u +variable {Γ : Type u} (K : NormingSet Γ) + +/-- Stability of a norming set under the specified coordinate crop. -/ +def CropStable (A : Set Γ) : Prop := ∀ f ∈ K.carrier, f.filter (· ∈ A) ∈ K.carrier + +variable (A : Set Γ) (hA : K.CropStable A) + +def cropNormer (f : K.carrier) : K.carrier := ⟨f.val.filter (· ∈ A), hA _ f.property⟩ + +def cropAmbient : K.BoundedSpace →L[ℝ] K.BoundedSpace := + LinearMap.mkContinuous + { toFun := fun x => ⟨fun f => x (K.cropNormer A hA f), memℓp_infty ⟨‖x‖, by + rintro _ ⟨f, rfl⟩ + exact lp.norm_apply_le_norm (by simp : (⊤ : ℝ≥0∞) ≠ 0) x _⟩⟩ + map_add' := fun x y => by apply lp.ext; rfl + map_smul' := fun c x => by apply lp.ext; rfl } + 1 (fun x => by + simpa only [one_mul] using lp.norm_le_of_forall_le (norm_nonneg x) + (fun f => lp.norm_apply_le_norm (by simp : (⊤ : ℝ≥0∞) ≠ 0) x + (K.cropNormer A hA f))) + +@[simp] lemma cropAmbient_apply (x : K.BoundedSpace) (f : K.carrier) : + K.cropAmbient A hA x f = x (K.cropNormer A hA f) := rfl + +lemma cropAmbient_finiteMap (x : Γ →₀ ℝ) : + K.cropAmbient A hA (K.finiteMap x) = K.finiteMap (x.filter (· ∈ A)) := by + apply lp.ext + funext f + rw [K.cropAmbient_apply, K.finiteMap_apply, K.finiteMap_apply] + simp only [cropNormer, Finsupp.filter_apply, apply_ite, Rat.cast_zero, + mul_zero] + rw [Finsupp.sum_filter_index] + simp only [Finsupp.sum, Finsupp.support_filter, Finset.sum_filter] + +lemma cropAmbient_mem (x : K.Space) : K.cropAmbient A hA x.val ∈ K.closedSpan := by + have hi : K.finiteMap.range ∈ Module.End.invtSubmodule (K.cropAmbient A hA) := by + rw [Module.End.mem_invtSubmodule_iff_map_le] + rintro _ ⟨_, ⟨v, rfl⟩, rfl⟩ + exact ⟨v.filter (· ∈ A), (K.cropAmbient_finiteMap A hA v).symm⟩ + have hc := Submodule.topologicalClosure_mem_invtSubmodule hi + rw [Module.End.mem_invtSubmodule_iff_map_le] at hc + exact hc ⟨x.val, x.property, rfl⟩ + +/-- Contractive interval/rectangle projection on the actual Banach completion. -/ +def projection : K.Space →L[ℝ] K.Space := + ((K.cropAmbient A hA).comp K.closedSpan.subtypeL).codRestrict K.closedSpan + (K.cropAmbient_mem A hA) + +lemma norm_projection_le : ‖K.projection A hA‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro x + change ‖K.cropAmbient A hA x.val‖ ≤ 1 * ‖x.val‖ + rw [one_mul] + exact lp.norm_le_of_forall_le (norm_nonneg x.val) + (fun f => lp.norm_apply_le_norm (by simp : (⊤ : ℝ≥0∞) ≠ 0) x.val + (K.cropNormer A hA f)) + +@[simp] lemma projection_includeFinite (x : Γ →₀ ℝ) : + K.projection A hA (K.includeFinite x) = K.includeFinite (x.filter (· ∈ A)) := + Subtype.ext (K.cropAmbient_finiteMap A hA x) + +lemma coordinate_projection (a : Γ) (x : K.Space) : + K.coordinate a (K.projection A hA x) = if a ∈ A then K.coordinate a x else 0 := by + have h : (K.coordinate a).comp (K.projection A hA) = + if a ∈ A then K.coordinate a else 0 := by + apply DFunLike.coe_injective + apply K.denseRange_includeFinite.equalizer + ((K.coordinate a).comp (K.projection A hA)).continuous + (if a ∈ A then K.coordinate a else (0 : K.Space →L[ℝ] ℝ)).continuous + funext v + by_cases ha : a ∈ A <;> simp [ha] + by_cases ha : a ∈ A <;> simpa [ha] using DFunLike.congr_fun h x + +lemma projection_idempotent (x : K.Space) : + K.projection A hA (K.projection A hA x) = K.projection A hA x := by + apply K.coordinate_ext + intro a + simp only [K.coordinate_projection] + split_ifs <;> rfl + +end SeparableQuotient.NormConstruction.NormingSet + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NormingBounds.lean b/lean/OAI/Analysis/SeparableQuotients/NormingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7fb8dbdbf24d45a4a569e229204297047b04e98 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NormingBounds.lean @@ -0,0 +1,294 @@ +import OAI.Analysis.SeparableQuotients.TreeCharges + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.FiniteVectors +open scoped Classical BigOperators ENNReal +universe u +variable {ι : Type u} [Fintype ι] + +lemma norm_mask_le_explicit {p : ℝ≥0∞} [DecidableEq ι] (hp : p ≠ 0) (v : ι → ℝ) (s : Finset ι) : + ‖vec p (fun i => if i ∈ s then v i else 0)‖ ≤ ‖vec p v‖ := by + apply lp.norm_mono hp + intro i + by_cases hi : i ∈ s <;> simp [vec_apply,hi] + +lemma norm_le_four {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : p ≠ 0) (v a b c d : ι → ℝ) + (ha : ∀ i, 0 ≤ a i) (hb : ∀ i, 0 ≤ b i) (hc : ∀ i, 0 ≤ c i) (hd : ∀ i, 0 ≤ d i) + (h : ∀ i, |v i| ≤ a i+b i+c i+d i) : + ‖vec p v‖ ≤ ‖vec p a‖+‖vec p b‖+‖vec p c‖+‖vec p d‖ := by + calc + _ ≤ ‖vec p (fun i => a i+b i+c i+d i)‖ := by + apply lp.norm_mono hp + intro i + simpa only [vec_apply,Real.norm_eq_abs,abs_of_nonneg (add_nonneg (add_nonneg (add_nonneg (ha i) (hb i)) (hc i)) (hd i))] using h i + _ = ‖vec p a+vec p b+vec p c+vec p d‖ := rfl + _ ≤ _ := (norm_add_le _ _).trans (add_le_add ((norm_add_le _ _).trans (add_le_add (norm_add_le _ _) le_rfl)) le_rfl) + +lemma single_support_bounds {p : ℝ≥0∞} (hp : 0 < p.toReal) (v : ι → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hv : ∀ i, |v i| ≤ K) (hs : ∀ i j, v i ≠ 0 → v j ≠ 0 → i = j) : + ‖vec p v‖ ≤ K ∧ (∑ i, |v i|) ≤ K := by + by_cases he : ∃ i, v i ≠ 0 + · obtain ⟨i,hi⟩ := he + have hz (j : ι) (hji : j ≠ i) : v j = 0 := by + by_contra hj + exact hji (hs j i hj hi) + constructor + · apply norm_le hp v K hK + rw [Finset.sum_eq_single i] + · exact Real.rpow_le_rpow (abs_nonneg _) (hv i) hp.le + · intro j _ hji + simp only [hz j hji,abs_zero,Real.zero_rpow hp.ne'] + · simp + · rw [Finset.sum_eq_single i] + · exact hv i + · intro j _ hji + simp [hz j hji] + · simp + · have hz : ∀ i, v i = 0 := by simpa only [not_exists,not_not] using he + constructor + · apply norm_le hp v K hK + simp only [hz,abs_zero,Real.zero_rpow hp.ne',Finset.sum_const_zero] + exact Real.rpow_nonneg hK _ + · simpa only [hz,abs_zero,Finset.sum_const_zero] using hK +end SeparableQuotient.FiniteVectors + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology + +lemma Family.base_zero (f : Family) : (0 : Array) ∈ f.base := by + cases f with + | pure k => exact pureBase_zero k + | mixed => exact Set.mem_iUnion.mpr ⟨0,pure_zero 0⟩ + +lemma Family.base_crop (f : Family) (A : Crop) (g : Array) (hg : g ∈ f.base) : + restrict (A.set f) g ∈ f.base := by + cases f with + | pure k => exact pureBase_crop k A g hg + | mixed => + obtain ⟨k,hk⟩ := Set.mem_iUnion.mp hg + apply Set.mem_iUnion.mpr + refine ⟨k,?_⟩ + rw [pure_mixed_crop k A g hk] + split_ifs + · exact pure_crop k A g hk + · exact pure_zero k + +lemma Family.stage_crop (f : Family) (n : ℕ) (A : Crop) (g : Array) (hg : g ∈ stage f.base f n) : + restrict (A.set f) g ∈ stage f.base f n := + Norming.stage_crop f (Family.base_zero f) (Family.base_crop f) n A g hg + +lemma evaluateArray_nonzero_witness (x : Γ →₀ ℝ) (g : Array) + (h : norming.evaluateArray (norming.includeFinite x) g ≠ 0) : + ∃ α ∈ x.support, g α ≠ 0 := by + rw [evaluateArray_finite] at h + obtain ⟨α,hα,hne⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + exact ⟨α,hα, fun hg => hne (by simp [hg])⟩ + +lemma BlockSequence.base_eval_unique {f : Family} (z : BlockSequence f) (g : Array) (hg : g ∈ f.base) + (i j : ℕ) (hi : norming.evaluateArray (z.embed i) g ≠ 0) + (hj : norming.evaluateArray (z.embed j) g ≠ 0) : i = j := by + obtain ⟨α,hα,hgα⟩ := evaluateArray_nonzero_witness (z.vector i) g hi + obtain ⟨β,hβ,hgβ⟩ := evaluateArray_nonzero_witness (z.vector j) g hj + have hbad (i j : ℕ) (hij : i < j) (α β : Γ) + (hα : α ∈ (z.vector i).support) (hβ : β ∈ (z.vector j).support) + (hgα : g α ≠ 0) (hgβ : g β ≠ 0) : False := by + cases f with + | pure k => + rcases hg with rfl | ⟨γ,_hc,rfl | rfl⟩ + · exact hgα rfl + all_goals + have hαγ : α = γ := by by_contra hn; exact hgα (Finsupp.single_eq_of_ne hn) + have hβγ : β = γ := by by_contra hn; exact hgβ (Finsupp.single_eq_of_ne hn) + subst α; subst β + exact (lt_irrefl γ) (z.successive i j hij γ hα γ hβ).1 + | mixed => + obtain ⟨k,hk⟩ := Set.mem_iUnion.mp hg + have hαc : Colors.color α = k := by by_contra hn; exact hgα (pure_vanish k g hk α hn) + have hβc : Colors.color β = k := by by_contra hn; exact hgβ (pure_vanish k g hk β hn) + have hh := (z.successive i j hij α hα β hβ).2 rfl + rw [hαc,hβc] at hh + exact (lt_irrefl k) hh + rcases lt_trichotomy i j with hij | hij | hij + · exact (hbad i j hij α β hα hβ hgα hgβ).elim + · exact hij + · exact (hbad j i hij β α hβ hα hgβ hgα).elim + +noncomputable def ThinnedWindows.evalVector {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (g : Array) (i : s) : ℝ := + if i ∈ I then |norming.evaluateArray (w.blocks.embed i) g| else 0 + +lemma ThinnedWindows.evalVector_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (g : Array) (i : s) : + 0 ≤ w.evalVector s I g i := by unfold ThinnedWindows.evalVector; split_ifs <;> positivity + +lemma ThinnedWindows.evalVector_base {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (g : Array) (hg : g ∈ f.base) : + ‖vec f.exponent (w.evalVector s I g)‖ ≤ 2 ∧ (∑ i : s, w.evalVector s I g i) ≤ 2 := by + have hb (i : s) : |w.evalVector s I g i| ≤ 2 := by + rw [abs_of_nonneg (w.evalVector_nonneg s I g i)] + unfold ThinnedWindows.evalVector + split_ifs + · have hgfull : g ∈ Full := f.norming_subset_full (Set.mem_iUnion.mpr ⟨0,hg⟩) + rw [norming.evaluateArray_eq_functional _ ⟨g,hgfull⟩] + exact (norming.functional_bound _ _).trans (w.upper_norm i) + · norm_num + have hu (i j : s) (hi : w.evalVector s I g i ≠ 0) (hj : w.evalVector s I g j ≠ 0) : i = j := by + have hn (i : s) (hi : w.evalVector s I g i ≠ 0) : norming.evaluateArray (w.blocks.embed i) g ≠ 0 := by + intro hz + apply hi + simp [ThinnedWindows.evalVector,hz] + exact Subtype.ext (w.blocks.base_eval_unique g hg i j (hn i hi) (hn j hj)) + have hh := single_support_bounds (by simpa only [Family.exponent_toReal] using f.r_pos : 0 < f.exponent.toReal) + (w.evalVector s I g) 2 (by norm_num) hb hu + simpa only [abs_of_nonneg (w.evalVector_nonneg s I g _)] using hh + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +noncomputable def TypeII.continuation {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (g : TypeII.Group e) (i : s) : ℝ := + (1/(f.m (TypeII.groupWeight e g) : ℝ)) * ∑ h, + w.evalVector s (TypeI.lowAssign w ((e.path g.1).piece g.2) s I h) + (restrict ((e.crop g.1).set f) (((e.path g.1).piece g.2).child h)) i + +lemma TypeII.continuation_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (g : TypeII.Group e) (i : s) : 0 ≤ TypeII.continuation e w s I g i := by + unfold TypeII.continuation + exact mul_nonneg (by positivity) (Finset.sum_nonneg (fun _ _ => w.evalVector_nonneg ..)) + +lemma ThinnedWindows.node_majorant {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) (i : s) : + w.evalVector s I e.value i ≤ (if i ∈ I then 2*ε else 0) + + (if i ∈ I then w.markedCharge e hm s i else 0) + + (∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I i) + + ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * TypeII.continuation e w s I g i := by + by_cases hi : i ∈ I + · simp only [ThinnedWindows.evalVector,hi,ite_true] + apply (w.node_split e hm s i).trans + rw [add_assoc (2*ε+w.markedCharge e hm s i),← Finset.sum_add_distrib] + apply add_le_add_right + apply Finset.sum_le_sum + intro g _ + rw [← mul_add] + apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) + by_cases hj : TypeII.groupWeight e g < w.lower i + · rw [ite_eq_left hj] + exact TypeI.low_eval_bound w ((e.path g.1).piece g.2) (e.crop g.1) (hm g.1 g.2) s I i hi hj + · rw [ite_eq_right hj] + exact add_nonneg (TypeI.boundaryCharge_nonneg ..) (TypeII.continuation_nonneg ..) + · simp only [ThinnedWindows.evalVector,hi,ite_false,zero_add] + exact add_nonneg (Finset.sum_nonneg (fun _ _ => mul_nonneg (abs_nonneg _) (TypeI.boundaryCharge_nonneg ..))) + (Finset.sum_nonneg (fun _ _ => mul_nonneg (abs_nonneg _) (TypeII.continuation_nonneg ..))) + +noncomputable def TypeII.boundaryVector {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I i + +noncomputable def TypeII.continuationVector {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * TypeII.continuation e w s I g i + +lemma ThinnedWindows.epsilonVector_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) : + ‖vec f.exponent (fun i : s => if i ∈ I then 2*ε else 0)‖ ≤ 2*(ε*(s.card : ℝ)^(1/f.r)) := by + have hp : 0 < f.exponent.toReal := by simpa only [Family.exponent_toReal] using f.r_pos + have hn : f.exponent ≠ 0 := by intro h; simp [h] at hp + calc + _ ≤ ‖vec f.exponent (fun _ : s => 2*ε)‖ := norm_mask_le_explicit hn _ I + _ = _ := by + rw [norm_const hp,abs_of_nonneg (mul_nonneg (by norm_num) w.epsilon_pos.le)] + simp only [Fintype.card_coe,Family.exponent_toReal] + ring + +lemma TypeII.boundaryVector_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) : + ‖vec f.exponent (TypeII.boundaryVector e w s I)‖ ≤ 4 := by + exact (TypeII.sum_vector_norm e s (fun g => TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I) 32 + (by norm_num) (fun _ _ => TypeI.boundaryCharge_norm ..)).trans_eq (by norm_num) + +lemma TypeII.continuation_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (g : TypeII.Group e) (K : ℝ) (hK : 0 ≤ K) + (hc : ∀ h, ‖vec f.exponent (w.evalVector s (TypeI.lowAssign w ((e.path g.1).piece g.2) s I h) + (restrict ((e.crop g.1).set f) (((e.path g.1).piece g.2).child h)))‖ ≤ K) : + ‖vec f.exponent (TypeII.continuation e w s I g)‖ ≤ K*f.theta (TypeII.groupWeight e g) := by + apply TypeI.recombine_norm w ((e.path g.1).piece g.2) s I _ K hK + · intro h i hi + simp only [ThinnedWindows.evalVector,hi,ite_false] + · exact hc + +lemma TypeII.continuationVector_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (hc : ∀ (g : TypeII.Group e) h, ‖vec f.exponent (w.evalVector s (TypeI.lowAssign w ((e.path g.1).piece g.2) s I h) + (restrict ((e.crop g.1).set f) (((e.path g.1).piece g.2).child h)))‖ ≤ 64) : + ‖vec f.exponent (TypeII.continuationVector e w s I)‖ ≤ 8 := by + exact (TypeII.sum_vector_norm e s (TypeII.continuation e w s I) 64 (by norm_num) + (fun g _ => TypeII.continuation_norm e w s I g 64 (by norm_num) (hc g))).trans_eq (by norm_num) + +lemma ThinnedWindows.node_uniform {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) + (hε : ε*(s.card : ℝ)^(1/f.r) ≤ 1) + (hc : ∀ (g : TypeII.Group e) h, ‖vec f.exponent + (w.evalVector s (TypeI.lowAssign w ((e.path g.1).piece g.2) s I h) + (restrict ((e.crop g.1).set f) (((e.path g.1).piece g.2).child h)))‖ ≤ 64) : + ‖vec f.exponent (w.evalVector s I e.value)‖ ≤ 64 := by + have hp : 0 < f.exponent.toReal := by simpa only [Family.exponent_toReal] using f.r_pos + have hn : f.exponent ≠ 0 := by intro h; simp [h] at hp + have hM : ‖vec f.exponent (fun i : s => if i ∈ I then w.markedCharge e hm s i else 0)‖ ≤ 16 := + (norm_mask_le_explicit hn _ I).trans (w.marked_vector_bounds e hm s).1 + have h := norm_le_four hn (w.evalVector s I e.value) + (fun i : s => if i ∈ I then 2*ε else 0) + (fun i : s => if i ∈ I then w.markedCharge e hm s i else 0) + (TypeII.boundaryVector e w s I) (TypeII.continuationVector e w s I) + (fun i => by split_ifs <;> nlinarith [w.epsilon_pos]) + (fun i => by split_ifs <;> first | exact w.markedCharge_nonneg e hm s i | exact le_rfl) + (fun i => Finset.sum_nonneg (fun _ _ => mul_nonneg (abs_nonneg _) (TypeI.boundaryCharge_nonneg ..))) + (fun i => Finset.sum_nonneg (fun _ _ => mul_nonneg (abs_nonneg _) (TypeII.continuation_nonneg ..))) + (fun i => by rw [abs_of_nonneg (w.evalVector_nonneg s I e.value i)]; exact w.node_majorant e hm s I i) + linarith [w.epsilonVector_norm s I, TypeII.boundaryVector_norm e w s I, TypeII.continuationVector_norm e w s I hc] + +lemma ThinnedWindows.stage_uniform {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (hε : ε*(s.card : ℝ)^(1/f.r) ≤ 1) : + ∀ n (g : Array), g ∈ stage f.base f n → ∀ I : Finset s, + ‖vec f.exponent (w.evalVector s I g)‖ ≤ 64 := by + intro n + induction n with + | zero => + intro g hg I + exact (w.evalVector_base s I g hg).1.trans (by norm_num) + | succ n ih => + intro g hg I + have hn : ∀ g, g ∈ stage f.base f n → g ∈ f.norming := fun g hg => Set.mem_iUnion.mpr ⟨n,hg⟩ + have ht (e : TypeII f) (he : ∀ b i h, ((e.path b).piece i).child h ∈ stage f.base f n) : + ‖vec f.exponent (w.evalVector s I e.value)‖ ≤ 64 := by + apply w.node_uniform e (fun b i h => hn _ (he b i h)) s I hε + intro g h + exact ih _ (Family.stage_crop f n _ _ (he g.1 g.2 h)) _ + rcases hg with (hg | ⟨e,rfl,he⟩) | ⟨e,rfl,he⟩ + · exact ih _ hg I + · simpa only [Norming.TypeI.toTypeII_value] using ht e.toTypeII (fun _ _ h => he h) + · exact ht e he + +lemma ThinnedWindows.norming_uniform {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (hε : ε*(s.card : ℝ)^(1/f.r) ≤ 1) + (g : Array) (hg : g ∈ f.norming) (I : Finset s) : + ‖vec f.exponent (w.evalVector s I g)‖ ≤ 64 := by + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hg + exact w.stage_uniform s hε n g hn I + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NormingFamilies.lean b/lean/OAI/Analysis/SeparableQuotients/NormingFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..00461105747d51b3527c3e718e5a39c58c2a9ac0 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NormingFamilies.lean @@ -0,0 +1,234 @@ +import OAI.Analysis.SeparableQuotients.Parameters + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming +open CoherentClosures PathCoding +open scoped ENNReal Classical +abbrev Γ := OmegaOne.{0} +abbrev Array := Γ →₀ ℚ + +inductive Family where + | pure : ℕ → Family + | mixed : Family + deriving DecidableEq + +def Family.s : Family → ℕ + | .pure k => k+2 + | .mixed => 2 + +lemma Family.s_ge_two (f : Family) : 2 ≤ f.s := by cases f <;> simp [Family.s] + +def Family.q (f : Family) : ℝ := Parameters.q f.s + +def Family.L (f : Family) (j : ℕ) : ℕ := Parameters.L f.s (j-1) +def Family.m (f : Family) (j : ℕ) : ℕ := Parameters.m f.s (j-1) + +lemma Family.m_pos (f : Family) (j : ℕ) : 0 < f.m j := Parameters.m_pos _ _ + +/-- Succession refers to the full supports, in both orders in mixed mode. -/ +def Successive (f : Family) (x y : Array) : Prop := + ∀ a ∈ x.support, ∀ b ∈ y.support, + a < b ∧ (f = .mixed → Colors.color a < Colors.color b) + +lemma Successive.disjoint {f : Family} {x y : Array} (h : Successive f x y) : + Disjoint x.support y.support := by + apply Finset.disjoint_left.mpr + intro a hx hy + exact (lt_irrefl a) (h a hx a hy).1 + +structure Crop where + ordinal : Set Γ + ordinal_convex : Set.OrdConnected ordinal + colors : Set ℕ + colors_convex : Set.OrdConnected colors + +def Crop.set (A : Crop) : Family → Set Γ + | .pure _ => A.ordinal + | .mixed => A.ordinal ∩ Colors.color ⁻¹' A.colors + +def restrict (A : Set Γ) (x : Array) : Array := x.filter (· ∈ A) + +@[simp] lemma restrict_apply (A : Set Γ) (x : Array) (a : Γ) : + restrict A x a = if a ∈ A then x a else 0 := Finsupp.filter_apply _ _ _ + +/-- A specified Type I expression. Child norming membership is imposed at its +construction stage, outside this data structure. -/ +structure TypeI (f : Family) where + weight : ℕ + weight_pos : 1 ≤ weight + length : ℕ + length_pos : 1 ≤ length + length_le : length ≤ f.L weight + child : Fin length → Array + child_nonzero : ∀ h, child h ≠ 0 + successive : ∀ h i, h < i → Successive f (child h) (child i) + +def TypeI.value {f : Family} (e : TypeI f) : Array := + (1 / (f.m e.weight : ℚ)) • ∑ h, e.child h + +/-- Exactly the finite prefix conditions, with unused raw entries ignored. +Padding raw data beyond length imposes no mathematical restriction. -/ +structure PrefixValid (P : RawPath) (length : ℕ) : Prop where + successive : ∀ i j, i < j → j < length → ∀ a ∈ (P.piece i).support, + ∀ b ∈ (P.piece j).support, a < b + metadata_strict : ∀ i j, i < j → j < length → P.metadata i < P.metadata j + metadata_pos : ∀ i, i < length → 1 ≤ P.metadata i + weight_pos : ∀ i, i < length → 1 ≤ P.weight i + weight_le_metadata : ∀ i, i < length → P.weight i ≤ P.metadata i + rho_bound : ∀ n, n < length → ∀ a b, a ∈ P.support n → b ∈ P.support n → a ≤ b → + rho a b ≤ P.metadata n + rule : ∀ n, n+1 < length → P.weight (n+1) = sigma (P.code n) + +lemma PrefixValid.weight_strict {P : RawPath} {len : ℕ} (h : PrefixValid P len) : + StrictMono (fun i : Fin len => P.weight i) := by + cases len with + | zero => intro i; exact i.elim0 + | succ len => + apply Fin.strictMono_iff_lt_succ.mpr + intro i + change P.weight i < P.weight ((i : ℕ)+1) + rw [h.rule i (by omega)] + exact (h.weight_le_metadata i (by omega)).trans_lt + ((P.metadata_le_codeBound i).trans_lt (codeBound_lt_sigma _)) + +structure FinitePath (f : Family) where + raw : RawPath + length : ℕ + length_pos : 1 ≤ length + valid : PrefixValid raw length + piece : Fin length → TypeI f + value_eq : ∀ i, (piece i).value = raw.piece i + weight_eq : ∀ i, (piece i).weight = raw.weight i + mixed_successive : ∀ (i j : Fin length), i < j → + Successive f (raw.piece i) (raw.piece j) + +def FinitePath.value {f : Family} (P : FinitePath f) : Array := ∑ i : Fin P.length, P.raw.piece i + +def FinitePath.active {f : Family} (P : FinitePath f) (A : Crop) : Finset ℕ := + (Finset.univ.filter (fun i : Fin P.length => restrict (A.set f) (P.raw.piece i) ≠ 0)).image + (fun i : Fin P.length => P.raw.weight i) + +structure TypeII (f : Family) where + length : ℕ + path : Fin length → FinitePath f + crop : Fin length → Crop + coefficient : Fin length → ℚ + bound : ∑ b, |(coefficient b : ℝ)| ^ f.q ≤ 1 + disjoint_active : Pairwise (fun b c => + Disjoint ((path b).active (crop b)) ((path c).active (crop c))) + +def TypeII.value {f : Family} (e : TypeII f) : Array := + ∑ b, e.coefficient b • restrict ((e.crop b).set f) (e.path b).value + +/-- Each stage retains previous stages and adjoins expressions whose Type I children belong to previous stages, with uncropped path data. -/ +def stage (base : Set Array) (f : Family) : ℕ → Set Array + | 0 => base + | n+1 => stage base f n ∪ + {x | ∃ e : TypeI f, e.value = x ∧ ∀ h, e.child h ∈ stage base f n} ∪ + {x | ∃ e : TypeII f, e.value = x ∧ + ∀ b i h, ((e.path b).piece i).child h ∈ stage base f n} + +def pureBase (k : ℕ) : Set Array := + {x | x = 0 ∨ ∃ a, Colors.color a = k ∧ + (x = Finsupp.single a 1 ∨ x = Finsupp.single a (-1))} + +def Pure (k : ℕ) : Set Array := ⋃ n, stage (pureBase k) (.pure k) n + +def Full : Set Array := ⋃ n, stage (⋃ k, Pure k) .mixed n + +lemma stage_mono (base : Set Array) (f : Family) : Monotone (stage base f) := by + apply monotone_nat_of_le_succ + intro n x hx + exact Or.inl (Or.inl hx) + +lemma pure_subset_full (k : ℕ) : Pure k ⊆ Full := by + intro x hx + exact Set.mem_iUnion.mpr ⟨0, Set.mem_iUnion.mpr ⟨k, hx⟩⟩ + +lemma coordinate_mem (a : Γ) : Finsupp.single a 1 ∈ Full := by + apply pure_subset_full (Colors.color a) + exact Set.mem_iUnion.mpr ⟨0, Or.inr ⟨a, rfl, Or.inl rfl⟩⟩ + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open CoherentClosures PathCoding +open scoped Classical + +lemma successive_coefficient_unique {f : Family} {n : ℕ} (v : Fin n → Array) + (h : ∀ i j, i < j → Successive f (v i) (v j)) {a : Γ} {i j : Fin n} + (hi : v i a ≠ 0) (hj : v j a ≠ 0) : i = j := by + by_contra hij + rcases lt_or_gt_of_ne hij with hij | hij + · exact Finset.disjoint_left.mp (h i j hij).disjoint + (Finsupp.mem_support_iff.mpr hi) (Finsupp.mem_support_iff.mpr hj) + · exact Finset.disjoint_left.mp (h j i hij).disjoint + (Finsupp.mem_support_iff.mpr hj) (Finsupp.mem_support_iff.mpr hi) + +lemma TypeI.coefficient_bound {f : Family} (e : TypeI f) + (h : ∀ i a, |(e.child i a : ℝ)| ≤ 1) (a : Γ) : + |(e.value a : ℝ)| ≤ 1 / (f.m e.weight : ℝ) := by + classical + have hm : 0 < (f.m e.weight : ℝ) := by exact_mod_cast f.m_pos _ + have hsum : |∑ i, (e.child i a : ℝ)| ≤ 1 := by + by_cases hex : ∃ i, e.child i a ≠ 0 + · obtain ⟨i, hi⟩ := hex + rw [Finset.sum_eq_single i] + · exact h i a + · intro j _ hji + have hz : e.child j a = 0 := by + by_contra hj + exact hji (successive_coefficient_unique e.child e.successive hj hi) + simp [hz] + · simp + · push Not at hex + simp [hex] + have heq : (e.value a : ℝ) = (1 / (f.m e.weight : ℝ)) * ∑ i, (e.child i a : ℝ) := by + simp [TypeI.value, Finsupp.smul_apply, smul_eq_mul] + rw [heq, abs_mul, abs_of_pos (one_div_pos.mpr hm)] + simpa using mul_le_mul_of_nonneg_left hsum (le_of_lt (one_div_pos.mpr hm)) + +/-- A coordinate meets at most one original path piece. -/ +def FinitePath.hitIndex {f : Family} (P : FinitePath f) (a : Γ) : Fin P.length := + if h : ∃ i : Fin P.length, P.raw.piece i a ≠ 0 then h.choose + else ⟨0, P.length_pos⟩ + +lemma FinitePath.value_at_hit {f : Family} (P : FinitePath f) (a : Γ) : + P.value a = P.raw.piece (P.hitIndex a) a := by + classical + by_cases hex : ∃ i : Fin P.length, P.raw.piece i a ≠ 0 + · have hi : P.raw.piece (P.hitIndex a) a ≠ 0 := by + simpa only [FinitePath.hitIndex, dite_eq_left hex] using hex.choose_spec + change (∑ i : Fin P.length, P.raw.piece i) a = _ + rw [Finsupp.finsetSum_apply, Finset.sum_eq_single (P.hitIndex a)] + · intro j _ hj + by_contra hne + exact hj (successive_coefficient_unique (fun i : Fin P.length => P.raw.piece i) + P.mixed_successive hne hi) + · simp + · push Not at hex + simp [FinitePath.value, hex] + +lemma FinitePath.hit_weight_active {f : Family} (P : FinitePath f) (A : Crop) (a : Γ) + (ha : restrict (A.set f) P.value a ≠ 0) : + P.raw.weight (P.hitIndex a) ∈ P.active A := by + classical + have hAc : a ∈ A.set f := by + by_contra hn + simp [hn] at ha + have hv : P.raw.piece (P.hitIndex a) a ≠ 0 := by + simpa [hAc, P.value_at_hit] using ha + apply Finset.mem_image.mpr + refine ⟨P.hitIndex a, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, rfl⟩ + intro hz + have hz' := congrArg (fun x : Array => x a) hz + exact hv (by simpa [hAc] using hz') + +end SeparableQuotient.Norming + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NormingOperations.lean b/lean/OAI/Analysis/SeparableQuotients/NormingOperations.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc56c60746facc91e3970d9a0ad37b11ab8bce45 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NormingOperations.lean @@ -0,0 +1,428 @@ +import OAI.Analysis.SeparableQuotients.NormingFamilies + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma Family.reciprocal_summable (f : Family) : + Summable (fun n => 1 / (Parameters.m f.s n : ℝ)) := + Summable.of_nonneg_of_le (fun _ => by positivity) + (Parameters.reciprocal_le_theta f.s_ge_two) (Parameters.hasSum_theta f.s_ge_two).summable + +lemma TypeII.coefficient_le_one {f : Family} (e : TypeII f) (b : Fin e.length) : + |(e.coefficient b : ℝ)| ≤ 1 := by + have hq : 0 < f.q := lt_trans zero_lt_one (Parameters.q_bounds f.s_ge_two).1 + have hb : |(e.coefficient b : ℝ)| ^ f.q ≤ 1 := + (Finset.single_le_sum (fun i _ => Real.rpow_nonneg (abs_nonneg (e.coefficient i : ℝ)) f.q) + (Finset.mem_univ b)).trans e.bound + by_contra h + have ht := Real.one_lt_rpow (lt_of_not_ge h) hq + exact (not_lt_of_ge hb) ht + +lemma TypeII.hit_weight_injective {f : Family} (e : TypeII f) (a : Γ) : + Set.InjOn (fun b : Fin e.length => (e.path b).raw.weight ((e.path b).hitIndex a)) + {b | restrict ((e.crop b).set f) (e.path b).value a ≠ 0} := by + intro b hb c hc heq + by_contra hbc + have hb' := (e.path b).hit_weight_active (e.crop b) a hb + have hc' := (e.path c).hit_weight_active (e.crop c) a hc + dsimp only at heq + rw [heq] at hb' + exact Finset.disjoint_left.mp (e.disjoint_active hbc) hb' hc' + +lemma TypeII.coefficient_bound {f : Family} (e : TypeII f) + (h : ∀ b i j a, |(((e.path b).piece i).child j a : ℝ)| ≤ 1) (a : Γ) : + |(e.value a : ℝ)| < 1/8 := by + classical + let active : Finset (Fin e.length) := Finset.univ.filter + (fun b => restrict ((e.crop b).set f) (e.path b).value a ≠ 0) + let j : Fin e.length → ℕ := fun b => + (e.path b).raw.weight ((e.path b).hitIndex a) + have jpos : ∀ b, 1 ≤ j b := fun b => (e.path b).valid.weight_pos _ + ((e.path b).hitIndex a).isLt + have jinj : Set.InjOn (fun b => j b - 1) active := by + intro b hb c hc heq + apply e.hit_weight_injective a (Finset.mem_filter.mp hb).2 (Finset.mem_filter.mp hc).2 + change j b = j c + dsimp only at heq + have := jpos b + have := jpos c + omega + have hterm : ∀ b ∈ active, + |(e.coefficient b : ℝ) * (restrict ((e.crop b).set f) (e.path b).value a : ℝ)| + ≤ 1 / (Parameters.m f.s (j b - 1) : ℝ) := by + intro b hb + have hAc : a ∈ (e.crop b).set f := by + by_contra hn + have := (Finset.mem_filter.mp hb).2 + simp [hn] at this + have hv : |((e.path b).raw.piece ((e.path b).hitIndex a) a : ℝ)| ≤ + 1 / (f.m (j b) : ℝ) := by + rw [← (e.path b).value_eq] + have hh := ((e.path b).piece ((e.path b).hitIndex a)).coefficient_bound + (h b ((e.path b).hitIndex a)) a + simpa only [(e.path b).weight_eq] using hh + rw [restrict_apply, ite_eq_left hAc, (e.path b).value_at_hit, abs_mul] + exact (mul_le_mul_of_nonneg_right (e.coefficient_le_one b) (abs_nonneg _)).trans + (by simpa only [one_mul, Family.m] using hv) + have hsum : (e.value a : ℝ) = ∑ b ∈ active, + (e.coefficient b : ℝ) * (restrict ((e.crop b).set f) (e.path b).value a : ℝ) := by + simp only [TypeII.value, Finsupp.finsetSum_apply, Finsupp.smul_apply, smul_eq_mul, Rat.cast_sum, + Rat.cast_mul] + symm + apply Finset.sum_subset (Finset.filter_subset _ _) + intro b _ hb + have hz : restrict ((e.crop b).set f) (e.path b).value a = 0 := by + simpa [active] using hb + simp [hz] + rw [hsum] + calc + |∑ b ∈ active, (e.coefficient b : ℝ) * + (restrict ((e.crop b).set f) (e.path b).value a : ℝ)| + ≤ ∑ b ∈ active, |(e.coefficient b : ℝ) * + (restrict ((e.crop b).set f) (e.path b).value a : ℝ)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ b ∈ active, 1 / (Parameters.m f.s (j b - 1) : ℝ) := Finset.sum_le_sum hterm + _ = ∑ n ∈ active.image (fun b => j b-1), 1 / (Parameters.m f.s n : ℝ) := by + rw [Finset.sum_image] + exact fun b hb c hc hbc => jinj hb hc hbc + _ ≤ ∑' n, 1 / (Parameters.m f.s n : ℝ) := + f.reciprocal_summable.sum_le_tsum _ (fun _ _ => by positivity) + _ < 1/8 := Parameters.reciprocal_sum_small f.s_ge_two + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma stage_coefficient_bound {base : Set Array} (f : Family) + (hbase : ∀ x ∈ base, ∀ a, |(x a : ℝ)| ≤ 1) : + ∀ n x, x ∈ stage base f n → ∀ a, |(x a : ℝ)| ≤ 1 := by + intro n + induction n with + | zero => exact hbase + | succ n ih => + intro x hx a + rcases hx with (hx | ⟨e, rfl, he⟩) | ⟨e, rfl, he⟩ + · exact ih x hx a + · exact (e.coefficient_bound (fun i => ih _ (he i)) a).trans (by + have hm : (1 : ℝ) ≤ f.m e.weight := by exact_mod_cast f.m_pos e.weight + exact (div_le_one (lt_of_lt_of_le (by norm_num) hm)).mpr hm) + · exact le_trans (le_of_lt (e.coefficient_bound + (fun b i j => ih _ (he b i j)) a)) (by norm_num) + +lemma pureBase_coefficient_bound (k : ℕ) (x : Array) (hx : x ∈ pureBase k) (a : Γ) : + |(x a : ℝ)| ≤ 1 := by + rcases hx with rfl | ⟨b, _, rfl | rfl⟩ + · simp + all_goals by_cases hab : a = b <;> simp [hab] + +lemma pure_coefficient_bound (k : ℕ) (x : Array) (hx : x ∈ Pure k) (a : Γ) : + |(x a : ℝ)| ≤ 1 := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + exact stage_coefficient_bound (.pure k) (pureBase_coefficient_bound k) n x hn a + +lemma full_coefficient_bound (x : Array) (hx : x ∈ Full) (a : Γ) : + |(x a : ℝ)| ≤ 1 := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + apply stage_coefficient_bound .mixed ?_ n x hn a + intro y hy + obtain ⟨k, hk⟩ := Set.mem_iUnion.mp hy + exact pure_coefficient_bound k y hk + +lemma restrict_support_subset (A : Set Γ) (x : Array) : + (restrict A x).support ⊆ x.support := Finset.filter_subset _ _ + +lemma restrict_zero (A : Set Γ) : restrict A 0 = 0 := by ext a; simp + +lemma restrict_smul (A : Set Γ) (c : ℚ) (x : Array) : + restrict A (c • x) = c • restrict A x := by + ext a + by_cases h : a ∈ A <;> simp [h] + +lemma restrict_sum {ι : Type*} (A : Set Γ) (s : Finset ι) (x : ι → Array) : + restrict A (∑ i ∈ s, x i) = ∑ i ∈ s, restrict A (x i) := Finsupp.filter_sum _ _ + +lemma restrict_restrict (A B : Set Γ) (x : Array) : + restrict A (restrict B x) = restrict (A ∩ B) x := by + ext a + by_cases hA : a ∈ A <;> by_cases hB : a ∈ B <;> simp [hA, hB] + +def Crop.inter (A B : Crop) : Crop := + ⟨A.ordinal ∩ B.ordinal, A.ordinal_convex.inter B.ordinal_convex, + A.colors ∩ B.colors, A.colors_convex.inter B.colors_convex⟩ + +@[simp] lemma Crop.inter_set (A B : Crop) (f : Family) : + (A.inter B).set f = A.set f ∩ B.set f := by + cases f <;> ext a <;> simp [Crop.set, Crop.inter, and_assoc, and_left_comm, and_comm] + +lemma Successive.restrict {f : Family} {x y : Array} (h : Successive f x y) (A : Set Γ) : + Successive f (restrict A x) (restrict A y) := by + intro a ha b hb + exact h a (restrict_support_subset A x ha) b (restrict_support_subset A y hb) + +lemma TypeII.active_crop_subset {f : Family} (P : FinitePath f) (A B : Crop) : + P.active (A.inter B) ⊆ P.active B := by + intro j hj + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hj + apply Finset.mem_image.mpr + refine ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, rfl⟩ + intro hz + have hn := (Finset.mem_filter.mp hi).2 + apply hn + rw [Crop.inter_set, ← restrict_restrict, hz, restrict_zero] + +/-- Crops of Type II expressions retain the original paths and coding. -/ +def TypeII.cropped {f : Family} (e : TypeII f) (A : Crop) : TypeII f where + length := e.length + path := e.path + crop b := A.inter (e.crop b) + coefficient := e.coefficient + bound := e.bound + disjoint_active := fun _b _c hbc => (e.disjoint_active hbc).mono + (TypeII.active_crop_subset _ _ _) (TypeII.active_crop_subset _ _ _) + +lemma TypeII.cropped_value {f : Family} (e : TypeII f) (A : Crop) : + (e.cropped A).value = restrict (A.set f) e.value := by + simp only [TypeII.value, TypeII.cropped, restrict_sum, restrict_smul, + Crop.inter_set, restrict_restrict] + rfl + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped Classical + +/-- The crop operation discards zero children in order. -/ +lemma TypeI.crop_cases {f : Family} (e : TypeI f) (A : Set Γ) : + restrict A e.value = 0 ∨ ∃ d : TypeI f, + d.weight = e.weight ∧ d.value = restrict A e.value ∧ + ∀ i, ∃ j, d.child i = restrict A (e.child j) := by + let S : Finset (Fin e.length) := Finset.univ.filter (fun i => restrict A (e.child i) ≠ 0) + have hsum : ∑ i ∈ S, restrict A (e.child i) = ∑ i, restrict A (e.child i) := by + apply Finset.sum_subset (Finset.filter_subset _ _) + intro i _ hi + simpa only [S, Finset.mem_filter, Finset.mem_univ, true_and, not_not] using hi + by_cases hS : S.Nonempty + · right + let idx : Fin S.card → Fin e.length := fun i => (S.orderIsoOfFin rfl i).val + have hidx : StrictMono idx := (S.orderEmbOfFin rfl).strictMono + have hiS : ∀ i, idx i ∈ S := fun i => (S.orderIsoOfFin rfl i).property + let d : TypeI f := + { weight := e.weight + weight_pos := e.weight_pos + length := S.card + length_pos := Finset.card_pos.mpr hS + length_le := (Finset.card_le_card (Finset.filter_subset _ _)).trans (by simpa using e.length_le) + child := fun i => restrict A (e.child (idx i)) + child_nonzero := fun i => (Finset.mem_filter.mp (hiS i)).2 + successive := fun i j hij => (e.successive _ _ (hidx hij)).restrict A } + refine ⟨d, rfl, ?_, fun i => ⟨idx i, rfl⟩⟩ + have hsum' : ∑ i : Fin S.card, restrict A (e.child (idx i)) = + ∑ i ∈ S, restrict A (e.child i) := by + calc + _ = ∑ i : S, restrict A (e.child i) := + (S.orderIsoOfFin rfl).toEquiv.sum_comp _ + _ = _ := (Finset.sum_subtype S (fun _ => Iff.rfl) (fun i => restrict A (e.child i))).symm + simp only [d, TypeI.value, restrict_smul, restrict_sum, hsum', hsum] + · left + have hz : ∀ i, restrict A (e.child i) = 0 := by + intro i + by_contra hi + exact hS ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hi⟩⟩ + simp only [TypeI.value, restrict_smul, restrict_sum, hz, Finset.sum_const_zero, smul_zero] + +lemma stage_zero {base : Set Array} (f : Family) (h0 : (0 : Array) ∈ base) (n : ℕ) : + (0 : Array) ∈ stage base f n := stage_mono base f (Nat.zero_le n) h0 + +lemma stage_crop {base : Set Array} (f : Family) (h0 : (0 : Array) ∈ base) + (hbase : ∀ (A : Crop) x, x ∈ base → restrict (A.set f) x ∈ base) : + ∀ n (A : Crop) x, x ∈ stage base f n → restrict (A.set f) x ∈ stage base f n := by + intro n + induction n with + | zero => exact hbase + | succ n ih => + intro A x hx + rcases hx with (hx | ⟨e, rfl, he⟩) | ⟨e, rfl, he⟩ + · exact Or.inl (Or.inl (ih A x hx)) + · rcases e.crop_cases (A.set f) with hz | ⟨d, _, hd, hchild⟩ + · rw [hz] + exact stage_zero f h0 (n+1) + · apply Or.inl ∘ Or.inr + refine ⟨d, hd, ?_⟩ + intro i + obtain ⟨j, hj⟩ := hchild i + rw [hj] + exact ih A _ (he j) + · right + exact ⟨e.cropped A, e.cropped_value A, he⟩ + +lemma pureBase_zero (k : ℕ) : (0 : Array) ∈ pureBase k := Or.inl rfl + +lemma pureBase_crop (k : ℕ) (A : Crop) (x : Array) (hx : x ∈ pureBase k) : + restrict (A.set (.pure k)) x ∈ pureBase k := by + rcases hx with rfl | ⟨a, ha, rfl | rfl⟩ + · exact Or.inl (restrict_zero _) + all_goals + by_cases hA : a ∈ A.set (.pure k) + · rw [restrict, Finsupp.filter_single_of_pos _ hA] + exact Or.inr ⟨a, ha, by first | exact Or.inl rfl | exact Or.inr rfl⟩ + · rw [restrict, Finsupp.filter_single_of_neg _ hA] + exact pureBase_zero k + +lemma pure_zero (k : ℕ) : (0 : Array) ∈ Pure k := Set.mem_iUnion.mpr ⟨0, pureBase_zero k⟩ + +lemma pure_crop (k : ℕ) (A : Crop) (x : Array) (hx : x ∈ Pure k) : + restrict (A.set (.pure k)) x ∈ Pure k := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + exact Set.mem_iUnion.mpr ⟨n, + stage_crop (.pure k) (pureBase_zero k) (pureBase_crop k) n A x hn⟩ + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma TypeI.zero_at {f : Family} (e : TypeI f) (a : Γ) + (h : ∀ i, e.child i a = 0) : e.value a = 0 := by + simp [TypeI.value, h] + +lemma FinitePath.zero_at {f : Family} (P : FinitePath f) (a : Γ) + (h : ∀ i j, (P.piece i).child j a = 0) : P.value a = 0 := by + rw [FinitePath.value, Finsupp.finsetSum_apply] + apply Finset.sum_eq_zero + intro i _ + rw [← P.value_eq] + exact (P.piece i).zero_at a (h i) + +lemma TypeII.zero_at {f : Family} (e : TypeII f) (a : Γ) + (h : ∀ b i j, ((e.path b).piece i).child j a = 0) : e.value a = 0 := by + simp only [TypeII.value, Finsupp.finsetSum_apply, Finsupp.smul_apply, smul_eq_mul, + restrict_apply] + apply Finset.sum_eq_zero + intro b _ + rw [(e.path b).zero_at a (h b)] + simp + +lemma stage_vanish {base : Set Array} (f : Family) (a : Γ) + (hbase : ∀ x ∈ base, x a = 0) : + ∀ n x, x ∈ stage base f n → x a = 0 := by + intro n + induction n with + | zero => exact hbase + | succ n ih => + intro x hx + rcases hx with (hx | ⟨e, rfl, he⟩) | ⟨e, rfl, he⟩ + · exact ih x hx + · exact e.zero_at a (fun i => ih _ (he i)) + · exact e.zero_at a (fun b i j => ih _ (he b i j)) + +lemma pure_vanish (k : ℕ) (x : Array) (hx : x ∈ Pure k) (a : Γ) + (ha : Colors.color a ≠ k) : x a = 0 := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + apply stage_vanish (.pure k) a ?_ n x hn + intro y hy + rcases hy with rfl | ⟨b, hb, rfl | rfl⟩ + · rfl + all_goals + have hab : a ≠ b := by intro h; subst b; exact ha hb + simp [hab] + +lemma pure_mixed_crop (k : ℕ) (A : Crop) (x : Array) (hx : x ∈ Pure k) : + restrict (A.set .mixed) x = + if k ∈ A.colors then restrict (A.set (.pure k)) x else 0 := by + ext a + by_cases hcol : Colors.color a = k + · by_cases hk : k ∈ A.colors <;> simp [Crop.set, hcol, hk] + · have hz := pure_vanish k x hx a hcol + by_cases hk : k ∈ A.colors <;> simp [Crop.set, hk, hz] + +lemma full_zero : (0 : Array) ∈ Full := pure_subset_full 0 (pure_zero 0) + +lemma full_crop (A : Crop) (x : Array) (hx : x ∈ Full) : + restrict (A.set .mixed) x ∈ Full := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + apply Set.mem_iUnion.mpr + refine ⟨n, stage_crop .mixed ?_ ?_ n A x hn⟩ + · exact Set.mem_iUnion.mpr ⟨0, pure_zero 0⟩ + · intro B y hy + obtain ⟨k, hk⟩ := Set.mem_iUnion.mp hy + apply Set.mem_iUnion.mpr + refine ⟨k, ?_⟩ + rw [pure_mixed_crop k B y hk] + split_ifs + · exact pure_crop k B y hk + · exact pure_zero k + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma Successive.neg {f : Family} {x y : Array} (h : Successive f x y) : + Successive f (-x) (-y) := by + intro a ha b hb + exact h a (by simpa using ha) b (by simpa using hb) + +def TypeI.neg {f : Family} (e : TypeI f) : TypeI f where + weight := e.weight + weight_pos := e.weight_pos + length := e.length + length_pos := e.length_pos + length_le := e.length_le + child i := -e.child i + child_nonzero i := neg_ne_zero.mpr (e.child_nonzero i) + successive i j hij := (e.successive i j hij).neg + +@[simp] lemma TypeI.neg_value {f : Family} (e : TypeI f) : e.neg.value = -e.value := by + simp [TypeI.value, TypeI.neg, Finset.sum_neg_distrib] + rfl + +def TypeII.neg {f : Family} (e : TypeII f) : TypeII f where + length := e.length + path := e.path + crop := e.crop + coefficient b := -e.coefficient b + bound := by simpa using e.bound + disjoint_active := e.disjoint_active + +@[simp] lemma TypeII.neg_value {f : Family} (e : TypeII f) : e.neg.value = -e.value := by + simp [TypeII.value, TypeII.neg, Finset.sum_neg_distrib] + rfl + +lemma stage_neg {base : Set Array} (f : Family) (hbase : ∀ x ∈ base, -x ∈ base) : + ∀ n x, x ∈ stage base f n → -x ∈ stage base f n := by + intro n + induction n with + | zero => exact hbase + | succ n ih => + intro x hx + rcases hx with (hx | ⟨e, rfl, he⟩) | ⟨e, rfl, he⟩ + · exact Or.inl (Or.inl (ih x hx)) + · exact Or.inl (Or.inr ⟨e.neg, e.neg_value, fun i => ih _ (he i)⟩) + · exact Or.inr ⟨e.neg, e.neg_value, he⟩ + +lemma pure_neg (k : ℕ) (x : Array) (hx : x ∈ Pure k) : -x ∈ Pure k := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + refine Set.mem_iUnion.mpr ⟨n, stage_neg (.pure k) ?_ n x hn⟩ + intro y hy + rcases hy with rfl | ⟨a, ha, rfl | rfl⟩ + · exact Or.inl neg_zero + · exact Or.inr ⟨a, ha, Or.inr (by simp)⟩ + · exact Or.inr ⟨a, ha, Or.inl (by simp)⟩ + +lemma full_neg (x : Array) (hx : x ∈ Full) : -x ∈ Full := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + refine Set.mem_iUnion.mpr ⟨n, stage_neg .mixed ?_ n x hn⟩ + intro y hy + obtain ⟨k, hk⟩ := Set.mem_iUnion.mp hy + exact Set.mem_iUnion.mpr ⟨k, pure_neg k y hk⟩ + +end SeparableQuotient.Norming + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/NormingTrees.lean b/lean/OAI/Analysis/SeparableQuotients/NormingTrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..022eb46cc557920917ddda8013c48f2e9e3233c2 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/NormingTrees.lean @@ -0,0 +1,344 @@ +import OAI.Analysis.SeparableQuotients.MarkedEstimates + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming +open PathCoding CoherentClosures +open scoped Classical + +lemma TypeI.value_ne_zero {f : Family} (e : TypeI f) : e.value ≠ 0 := by + let h : Fin e.length := ⟨0, e.length_pos⟩ + obtain ⟨a, ha⟩ := Finsupp.support_nonempty_iff.mpr (e.child_nonzero h) + have hca := Finsupp.mem_support_iff.mp ha + have hsum : (∑ i, e.child i) a = e.child h a := by + rw [Finsupp.finsetSum_apply, Finset.sum_eq_single h] + · intro i _ hih + by_contra hi + exact hih (successive_coefficient_unique e.child e.successive hi hca) + · simp + intro hz + have hza := congrArg (fun x : Array => x a) hz + have hm : (f.m e.weight : ℚ) ≠ 0 := Nat.cast_ne_zero.mpr (f.m_pos _).ne' + exact (mul_ne_zero (inv_ne_zero hm) hca) (by + simpa only [TypeI.value, Finsupp.smul_apply, hsum, smul_eq_mul, + one_div, Finsupp.zero_apply] using hza) + +noncomputable def TypeI.singletonMetadata {f : Family} (e : TypeI f) : ℕ := + max e.weight (1 + (e.value.support.product e.value.support).sup (fun p => rho p.1 p.2)) + +noncomputable def TypeI.singletonRaw {f : Family} (e : TypeI f) : RawPath where + piece := fun _ => e.value + weight := fun _ => e.weight + metadata := fun _ => e.singletonMetadata + nonzero := fun _ => e.value_ne_zero + +lemma TypeI.singletonRaw_valid {f : Family} (e : TypeI f) : PrefixValid e.singletonRaw 1 where + successive := fun i j hij hj => by omega + metadata_strict := fun i j hij hj => by omega + metadata_pos := fun _ _ => by + exact (by omega : 1 ≤ 1 + (e.value.support.product e.value.support).sup (fun p => rho p.1 p.2)).trans (le_max_right _ _) + weight_pos := fun _ _ => e.weight_pos + weight_le_metadata := fun _ _ => le_max_left _ _ + rho_bound := by + intro n hn a b ha hb _ + have hn0 : n = 0 := by omega + subst n + have ha' : a ∈ e.value.support := by simpa [RawPath.support,singletonRaw] using ha + have hb' : b ∈ e.value.support := by simpa [RawPath.support,singletonRaw] using hb + exact (Finset.le_sup (s := e.value.support.product e.value.support) (b := (a,b)) + (f := fun p : Γ × Γ => rho p.1 p.2) (Finset.mem_product.mpr ⟨ha',hb'⟩)).trans + ((Nat.le_add_left _ _).trans (le_max_right _ _)) + rule := fun n hn => by omega + +noncomputable def TypeI.singletonPath {f : Family} (e : TypeI f) : FinitePath f where + raw := e.singletonRaw + length := 1 + length_pos := le_rfl + valid := e.singletonRaw_valid + piece := fun _ => e + value_eq := fun _ => rfl + weight_eq := fun _ => rfl + mixed_successive := fun _i _j hij => (not_lt_of_ge (le_of_eq (Subsingleton.elim _ _)) hij).elim + +@[simp] lemma TypeI.singletonPath_value {f : Family} (e : TypeI f) : e.singletonPath.value = e.value := by + change (∑ _ : Fin 1, e.value) = e.value + simp + +noncomputable def TypeI.toTypeII {f : Family} (e : TypeI f) : TypeII f := e.singletonPath.oneTerm Crop.all + +@[simp] lemma TypeI.toTypeII_value {f : Family} (e : TypeI f) : e.toTypeII.value = e.value := by + simp [toTypeII] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +noncomputable def TypeI.childRange {f : Family} (e : TypeI f) (h : Fin e.length) : Set Γ := + ordinalHull (e.child h).support (Finsupp.support_nonempty_iff.mpr (e.child_nonzero h)) + +lemma TypeI.childRange_connected {f : Family} (e : TypeI f) (h : Fin e.length) : + Set.OrdConnected (TypeI.childRange e h) := ordinalHull_connected _ _ + +lemma TypeI.mem_childRange {f : Family} (e : TypeI f) (h : Fin e.length) {a : Γ} + (ha : a ∈ (e.child h).support) : a ∈ TypeI.childRange e h := mem_ordinalHull _ ha + +lemma TypeI.childRange_successive {f : Family} (e : TypeI f) (h k : Fin e.length) (hhk : h < k) : + ∀ a ∈ TypeI.childRange e h, ∀ b ∈ TypeI.childRange e k, a < b := + ordinalHull_successive _ _ (fun a ha b hb => (e.successive h k hhk a ha b hb).1) + +noncomputable def TypeI.hitChildren {f : Family} (e : TypeI f) (x : Γ →₀ ℝ) : Finset (Fin e.length) := + Finset.univ.filter (fun h => ∃ a ∈ x.support, a ∈ TypeI.childRange e h) + +lemma TypeI.cropped_child_zero {f : Family} (e : TypeI f) (A : Crop) (x : Γ →₀ ℝ) + (h : Fin e.length) (hh : h ∉ TypeI.hitChildren e x) : + norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) (e.child h)) = 0 := by + rw [norming.evaluateArray_eq] + apply Finset.sum_eq_zero + intro a ha + have haR := TypeI.mem_childRange e h (restrict_support_subset _ _ ha) + have hxa : x a = 0 := by + apply Finsupp.notMem_support_iff.mp + intro hx + exact hh (Finset.mem_filter.mpr ⟨Finset.mem_univ _, a, hx, haR⟩) + simp only [norming.coordinate_includeFinite,hxa,mul_zero] + +lemma TypeI.cropped_child_bound {f : Family} (e : TypeI f) (A : Crop) + (he : ∀ h, e.child h ∈ f.norming) (x : E) (h : Fin e.length) : + |norming.evaluateArray x (restrict (A.set f) (e.child h))| ≤ + ‖intervalProjection (TypeI.childRange e h) (TypeI.childRange_connected e h) x‖ := + abs_eval_supported_interval _ (f.norming_subset_full (family_norming_crop f A _ (he h))) + _ _ (fun _ ha => TypeI.mem_childRange e h (restrict_support_subset _ _ ha)) x + +lemma TypeI.cropped_child_sum_bound {f : Family} (e : TypeI f) (A : Crop) + (he : ∀ h, e.child h ∈ f.norming) (x : Γ →₀ ℝ) (N : ℕ) (C : ℝ) + (hC : 0 ≤ C) (hx : PartitionBound (norming.includeFinite x) N C f.r) + (hL : e.length ≤ N) : + ∑ h, |norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) (e.child h))| ≤ + C * ((TypeI.hitChildren e x).card : ℝ)^(1/f.r) := by + let S := TypeI.hitChildren e x + have heq : (∑ h, |norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) (e.child h))|) = + ∑ h ∈ S, |norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) (e.child h))| := by + symm + apply Finset.sum_subset (Finset.subset_univ S) + intro h _ hh + simp only [TypeI.cropped_child_zero e A x h hh,abs_zero] + rw [heq] + by_cases hS : S.Nonempty + · let idx := S.orderEmbOfFin rfl + have hN : S.card ≤ N := (Finset.card_le_univ S).trans (by simpa only [Fintype.card_fin] using hL) + have hp := hx S.card (by exact hS.card_pos) hN + (fun i => TypeI.childRange e (idx i)) (fun i => TypeI.childRange_connected e (idx i)) + (fun i j hij => TypeI.childRange_successive e _ _ (idx.strictMono hij)) + calc + _ ≤ ∑ h ∈ S, ‖intervalProjection (TypeI.childRange e h) (TypeI.childRange_connected e h) (norming.includeFinite x)‖ := + Finset.sum_le_sum (fun h _ => TypeI.cropped_child_bound e A he _ h) + _ = ∑ i : Fin S.card, ‖intervalProjection (TypeI.childRange e (idx i)) (TypeI.childRange_connected e (idx i)) (norming.includeFinite x)‖ := by + conv_lhs => rw [← S.map_orderEmbOfFin_univ rfl] + rw [Finset.sum_map] + rfl + _ ≤ _ := hp + · have hSE : S = ∅ := Finset.not_nonempty_iff_eq_empty.mp hS + rw [hSE,Finset.sum_empty] + exact mul_nonneg hC (Real.rpow_nonneg (Nat.cast_nonneg _) _) + +lemma TypeI.hitChildren_noncrossing {f : Family} (e : TypeI f) (z : BlockSequence f) + (i j : ℕ) (hij : i < j) (h k : Fin e.length) + (hh : h ∈ TypeI.hitChildren e (z.vector i)) (hk : k ∈ TypeI.hitChildren e (z.vector j)) : h ≤ k := by + apply le_of_not_gt + intro hkh + obtain ⟨a, ha, haR⟩ := (Finset.mem_filter.mp hh).2 + obtain ⟨b, hb, hbR⟩ := (Finset.mem_filter.mp hk).2 + have hab := (z.successive i j hij a ha b hb).1 + have hba := TypeI.childRange_successive e k h hkh b hbR a haR + exact (lt_asymm hab hba) + +lemma TypeI.boundary_incidence {f : Family} (e : TypeI f) (z : BlockSequence f) (s : Finset ℕ) : + ∑ i ∈ s.filter (fun i => 2 ≤ (TypeI.hitChildren e (z.vector i)).card), + (TypeI.hitChildren e (z.vector i)).card ≤ 2 * e.length := by + have hh := IntervalIncidence.noncrossing_boundary_incidence s (Finset.univ : Finset (Fin e.length)) + (fun i h => h ∈ TypeI.hitChildren e (z.vector i)) + (fun i _ j _ hij h _ k _ hi hk => TypeI.hitChildren_noncrossing e z i j hij h k hi hk) + simpa only [Finset.filter_mem_eq_inter,Finset.univ_inter,Finset.card_univ,Fintype.card_fin] using hh + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.FiniteVectors +open scoped Classical ENNReal +universe u v +variable {ι : Type u} [Fintype ι] {κ : Type v} + +lemma vec_sum (p : ℝ≥0∞) (s : Finset κ) (v : κ → ι → ℝ) : + vec p (fun i => ∑ k ∈ s, v k i) = ∑ k ∈ s, vec p (v k) := by + apply lp.ext + funext i + simp only [vec_apply,lp.coeFn_sum,Finset.sum_apply] + +lemma norm_sum_disjoint_le {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : 0 < p.toReal) + (s : Finset κ) (v : κ → ι → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hd : ∀ k ∈ s, ∀ l ∈ s, k ≠ l → ∀ i, v k i = 0 ∨ v l i = 0) + (hb : ∀ k ∈ s, ‖vec p (v k)‖ ≤ K) : + ‖vec p (fun i => ∑ k ∈ s, v k i)‖ ≤ K * (s.card : ℝ)^(1/p.toReal) := by + rw [vec_sum] + apply (Real.rpow_le_rpow_iff (norm_nonneg _) (by positivity) hp).mp + rw [LpFinite.norm_sum_rpow hp s (fun k => vec p (v k)) hd, + Real.mul_rpow hK (by positivity), ← Real.rpow_mul (Nat.cast_nonneg _), + one_div_mul_cancel hp.ne',Real.rpow_one] + calc + _ ≤ ∑ _k ∈ s, K^p.toReal := Finset.sum_le_sum (fun k hk => + Real.rpow_le_rpow (norm_nonneg _) (hb k hk) hp.le) + _ = _ := by simp [mul_comm] + +lemma norm_degree_le {p : ℝ≥0∞} (hp : 0 < p.toReal) (d : ι → ℝ) (A C : ℝ) + (hA : 0 ≤ A) (hC : 0 ≤ C) (hd : ∀ i, 0 ≤ d i) (hs : ∑ i, d i ≤ C) + (v : ι → ℝ) (hv : ∀ i, |v i| ≤ A*(d i)^(1/p.toReal)) : + ‖vec p v‖ ≤ A*C^(1/p.toReal) := by + apply norm_le hp _ _ (by positivity) + calc + _ ≤ ∑ i, (A*(d i)^(1/p.toReal))^p.toReal := + Finset.sum_le_sum (fun i _ => Real.rpow_le_rpow (abs_nonneg _) (hv i) hp.le) + _ = A^p.toReal * ∑ i, d i := by + simp_rw [Real.mul_rpow hA (Real.rpow_nonneg (hd _) _), ← Real.rpow_mul (hd _), + one_div_mul_cancel hp.ne',Real.rpow_one] + rw [Finset.mul_sum] + _ ≤ A^p.toReal*C := mul_le_mul_of_nonneg_left hs (Real.rpow_nonneg hA _) + _ = _ := by + rw [Real.mul_rpow hA (Real.rpow_nonneg hC _), ← Real.rpow_mul hC, + one_div_mul_cancel hp.ne',Real.rpow_one] + +lemma norm_le_sum_norm {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : p ≠ 0) + (s : Finset κ) (v : κ → ι → ℝ) (w : ι → ℝ) + (hw : ∀ i, |w i| ≤ ∑ k ∈ s, |v k i|) : + ‖vec p w‖ ≤ ∑ k ∈ s, ‖vec p (v k)‖ := by + have he (k : κ) : ‖vec p (fun i => |v k i|)‖ = ‖vec p (v k)‖ := by + apply le_antisymm <;> apply lp.norm_mono hp <;> intro i <;> simp [Real.norm_eq_abs] + calc + _ ≤ ‖vec p (fun i => ∑ k ∈ s, |v k i|)‖ := by + apply lp.norm_mono hp + intro i + simpa only [vec_apply,Real.norm_eq_abs,abs_of_nonneg (Finset.sum_nonneg (fun k _ => abs_nonneg (v k i)))] using hw i + _ = ‖∑ k ∈ s, vec p (fun i => |v k i|)‖ := congrArg norm (vec_sum p s _) + _ ≤ ∑ k ∈ s, ‖vec p (fun i => |v k i|)‖ := norm_sum_le _ _ + _ = _ := Finset.sum_congr rfl (fun k _ => he k) + +lemma sum_abs_le_holder {p : ℝ≥0∞} (hp : 1 < p.toReal) (v : ι → ℝ) : + ∑ i, |v i| ≤ (Fintype.card ι : ℝ)^(1-1/p.toReal) * ‖vec p v‖ := by + have hcon := Real.HolderConjugate.conjExponent hp + have hh := Real.inner_le_Lp_mul_Lq_of_nonneg Finset.univ (f := fun i => |v i|) + (g := fun _ => (1 : ℝ)) hcon (fun i _ => abs_nonneg _) (fun _ _ => zero_le_one) + have hroot : (∑ i, |v i|^p.toReal)^(1/p.toReal) = ‖vec p v‖ := by + rw [← norm_rpow (zero_lt_one.trans hp), ← Real.rpow_mul (lp.norm_nonneg' _), + mul_one_div_cancel (zero_lt_one.trans hp).ne',Real.rpow_one] + have hq : 1/Real.conjExponent p.toReal = 1-1/p.toReal := by + dsimp [Real.conjExponent] + field_simp + simpa only [mul_one,Real.one_rpow,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,hroot,hq,mul_comm] using hh + +end SeparableQuotient.FiniteVectors + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +abbrev TypeII.Group {f : Family} (e : TypeII f) := Σ b : Fin e.length, Fin (e.path b).length + +noncomputable def TypeII.groupValue {f : Family} (e : TypeII f) (g : TypeII.Group e) : Array := + restrict ((e.crop g.1).set f) (((e.path g.1).piece g.2).value) + +def TypeII.groupWeight {f : Family} (e : TypeII f) (g : TypeII.Group e) : ℕ := + ((e.path g.1).piece g.2).weight + +noncomputable def TypeII.activeGroups {f : Family} (e : TypeII f) : Finset (TypeII.Group e) := + Finset.univ.filter (fun g => TypeII.groupValue e g ≠ 0) + +lemma TypeII.groupWeight_active {f : Family} (e : TypeII f) {g : TypeII.Group e} + (hg : g ∈ TypeII.activeGroups e) : TypeII.groupWeight e g ∈ (e.path g.1).active (e.crop g.1) := by + apply Finset.mem_image.mpr + refine ⟨g.2, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, ?_⟩ + · simpa only [TypeII.groupValue,(e.path g.1).value_eq g.2] using (Finset.mem_filter.mp hg).2 + · exact ((e.path g.1).weight_eq g.2).symm + +lemma TypeII.groupWeight_injOn {f : Family} (e : TypeII f) : + Set.InjOn (TypeII.groupWeight e) (TypeII.activeGroups e) := by + intro g hg h hh hw + obtain ⟨b,i⟩ := g + obtain ⟨c,j⟩ := h + have hbc : b = c := by + by_contra hbc + exact Finset.disjoint_left.mp (e.disjoint_active hbc) + (TypeII.groupWeight_active e hg) (hw.symm ▸ TypeII.groupWeight_active e hh) + subst c + have hij : i = j := by + apply (e.path b).valid.weight_strict.injective + exact ((e.path b).weight_eq i).symm.trans (hw.trans ((e.path b).weight_eq j)) + subst j + rfl + +lemma TypeII.value_group_sum {f : Family} (e : TypeII f) : + e.value = ∑ g ∈ TypeII.activeGroups e, e.coefficient g.1 • TypeII.groupValue e g := by + have heq : e.value = ∑ g : TypeII.Group e, e.coefficient g.1 • TypeII.groupValue e g := by + rw [Fintype.sum_sigma] + change (∑ b, e.coefficient b • restrict ((e.crop b).set f) (e.path b).value) = _ + apply Finset.sum_congr rfl + intro b _ + simp only [FinitePath.value,restrict_sum,Finset.smul_sum,TypeII.groupValue,(e.path b).value_eq] + rw [heq] + symm + apply Finset.sum_subset (Finset.filter_subset _ _) + intro g _ hg + have hz : TypeII.groupValue e g = 0 := by simpa only [TypeII.activeGroups,Finset.mem_filter,Finset.mem_univ,true_and,not_not] using hg + simp only [hz,smul_zero] + +lemma TypeII.eval_group_sum {f : Family} (e : TypeII f) (x : E) : + norming.evaluateArray x e.value = ∑ g ∈ TypeII.activeGroups e, + (e.coefficient g.1 : ℝ) * norming.evaluateArray x (TypeII.groupValue e g) := by + rw [TypeII.value_group_sum] + simp only [map_sum,map_smul,Rat.smul_def] + +lemma typeI_cropped_eval_le_l1 {f : Family} (e : TypeI f) (A : Crop) + (hm : ∀ j, e.child j ∈ f.norming) (x : Γ →₀ ℝ) : + |norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) e.value)| ≤ + vectorL1 x * (1 / (f.m e.weight : ℝ)) := by + rw [evaluateArray_finite] + calc + _ ≤ ∑ a ∈ x.support, |((restrict (A.set f) e.value) a : ℝ) * x a| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ a ∈ x.support, (1 / (f.m e.weight : ℝ)) * |x a| := by + apply Finset.sum_le_sum + intro a _ + rw [abs_mul] + apply mul_le_mul_of_nonneg_right _ (abs_nonneg _) + by_cases ha : a ∈ A.set f + · simpa only [restrict_apply,ite_eq_left ha] using e.coefficient_bound + (fun j b => full_coefficient_bound _ (f.norming_subset_full (hm j)) b) a + · simp only [restrict_apply,ite_eq_right ha,Rat.cast_zero,abs_zero] + positivity + _ = _ := by rw [← Finset.mul_sum]; dsimp [vectorL1]; ring + +lemma TypeII.high_weight_bound {f : Family} (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (x : Γ →₀ ℝ) (T : ℕ) : + ∑ g ∈ (TypeII.activeGroups e).filter (fun g => T < TypeII.groupWeight e g), + |(e.coefficient g.1 : ℝ)| * |norming.evaluateArray (norming.includeFinite x) (TypeII.groupValue e g)| ≤ + vectorL1 x * tail (fun j => 1/(f.m j : ℝ)) (T+1) := by + let S := (TypeII.activeGroups e).filter (fun g => T < TypeII.groupWeight e g) + have hsum : ∑ g ∈ S, 1/(f.m (TypeII.groupWeight e g) : ℝ) ≤ tail (fun j => 1/(f.m j : ℝ)) (T+1) := + sum_le_tail _ f.m_inv_summable (fun _ => by positivity) S (TypeII.groupWeight e) + ((TypeII.groupWeight_injOn e).mono (Finset.filter_subset _ _)) (T+1) + (fun g hg => by have h := (Finset.mem_filter.mp hg).2; omega) + calc + _ ≤ ∑ g ∈ S, vectorL1 x * (1/(f.m (TypeII.groupWeight e g) : ℝ)) := by + apply Finset.sum_le_sum + intro g _ + apply le_trans (mul_le_mul_of_nonneg_right (e.coefficient_le_one g.1) (abs_nonneg _)) + simpa only [one_mul,TypeII.groupValue,TypeII.groupWeight] using + typeI_cropped_eval_le_l1 ((e.path g.1).piece g.2) (e.crop g.1) (hm g.1 g.2) x + _ = vectorL1 x * ∑ g ∈ S, 1/(f.m (TypeII.groupWeight e g) : ℝ) := (Finset.mul_sum ..).symm + _ ≤ _ := mul_le_mul_of_nonneg_left hsum (vectorL1_nonneg x) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Parameters.lean b/lean/OAI/Analysis/SeparableQuotients/Parameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..98afe9e6d920499142d95787259b519c85fa4942 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Parameters.lean @@ -0,0 +1,299 @@ +import OAI.Analysis.SeparableQuotients.PathCoding + +namespace OAI + +noncomputable section + +/- Admissible parameters for the pure s = k + 2 families and mixed s = 2 family, with q = (s + 1) / s. Integer powers avoid rounding noninteger powers. -/ +namespace SeparableQuotient.Parameters + +open Filter Topology + +def d (n : ℕ) : ℕ := n+11 + +/-- State stores the exponent scale and twice the sum of all earlier lengths. -/ +def state (s : ℕ) : ℕ → ℕ × ℕ + | 0 => ((d 0 + 1) + 1 + d 0 + (d 0)^2, 0) + | n+1 => + let old := state s n + let B := old.2 + 2 * 2^(s*(s+1)*old.1) + (old.1 + (B+1)*(d (n+1)+1) + 1 + d (n+1) + (d (n+1))^2, B) + +def t (s n : ℕ) : ℕ := (state s n).1 +def B (s n : ℕ) : ℕ := (state s n).2 +def L (s n : ℕ) : ℕ := 2^(s*(s+1)*t s n) +def m (s n : ℕ) : ℕ := 2^((s-1)*(s+1)*t s n+d n) +def r (s : ℕ) : ℝ := (s:ℝ)/((s:ℝ)-1) +def q (s : ℕ) : ℝ := ((s:ℝ)+1)/(s:ℝ) +def theta (s n : ℕ) : ℝ := (L s n : ℝ) ^ (1/r s) / (m s n : ℝ) + +lemma B_zero (s : ℕ) : B s 0 = 0 := rfl +lemma B_succ (s n : ℕ) : B s (n+1) = B s n + 2*L s n := rfl +lemma t_succ (s n : ℕ) : t s (n+1) = + t s n+(B s (n+1)+1)*(d (n+1)+1)+1+d (n+1)+(d (n+1))^2 := rfl + +lemma d_pos (n : ℕ) : 0 < d n := by simp [d] +lemma L_pos (s n : ℕ) : 0 < L s n := pow_pos (by omega) _ +lemma m_pos (s n : ℕ) : 0 < m s n := pow_pos (by omega) _ + +lemma t_bound (s n : ℕ) : (B s n+1)*(d n+1)+1+d n ≤ t s n := by + cases n with + | zero => simp [t, B, state] + | succ n => rw [t_succ]; omega + +lemma t_square (s n : ℕ) : (d n)^2 ≤ t s n := by + cases n with + | zero => simp [t, state] + | succ n => rw [t_succ]; omega + +lemma t_pos (s n : ℕ) : 0 < t s n := by + have := t_bound s n + omega + +lemma t_strict (s : ℕ) : StrictMono (t s) := by + apply strictMono_nat_of_lt_succ + intro n + rw [t_succ] + omega + +lemma B_eq_sum (s n : ℕ) : B s n = 2 * ∑ i ∈ Finset.range n, L s i := by + induction n with + | zero => simp [B_zero] + | succ n ih => rw [B_succ, ih, Finset.sum_range_succ]; ring + +lemma L_strict {s : ℕ} (hs : 2 ≤ s) : StrictMono (L s) := by + intro i j hij + apply Nat.pow_lt_pow_right (by omega : 1 < 2) + exact Nat.mul_lt_mul_of_pos_left (t_strict s hij) (by positivity) + +lemma m_strict {s : ℕ} (_hs : 2 ≤ s) : StrictMono (m s) := by + intro i j hij + apply Nat.pow_lt_pow_right (by omega : 1 < 2) + have htt := (t_strict s).monotone hij.le + have hmul := Nat.mul_le_mul_left ((s-1)*(s+1)) htt + dsimp [d] + omega + +lemma theta_numerator {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : + (L s n : ℝ) ^ (1/r s) = (2:ℝ)^((s-1)*(s+1)*t s n) := by + have hs0 : (s:ℝ) ≠ 0 := by exact_mod_cast (by omega : s ≠ 0) + have hs1 : 1 ≤ s := by omega + simp only [L, Nat.cast_pow, Nat.cast_ofNat] + rw [← Real.rpow_natCast, ← Real.rpow_natCast, ← Real.rpow_mul (by norm_num : (0:ℝ) ≤ 2)] + congr 1 + simp only [r, one_div_div, Nat.cast_mul, Nat.cast_add, Nat.cast_one, + Nat.cast_sub hs1] + field_simp + +lemma theta_eq {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : theta s n = (1/2:ℝ)^(d n) := by + rw [theta, theta_numerator hs] + simp only [m] + push_cast + rw [pow_add, div_mul_eq_div_div, div_self (by positivity : (2:ℝ)^((s-1)*(s+1)*t s n) ≠ 0)] + exact (one_div_pow _ _).symm + +lemma length_qprime_power (s n : ℕ) : + (L s n : ℝ) ^ (1/((s:ℝ)+1)) = (2:ℝ)^(s*t s n) := by + have hs1 : (s:ℝ)+1 ≠ 0 := by positivity + simp only [L, Nat.cast_pow, Nat.cast_ofNat] + rw [← Real.rpow_natCast, ← Real.rpow_natCast, ← Real.rpow_mul (by norm_num : (0:ℝ) ≤ 2)] + congr 1 + push_cast + field_simp + +lemma ratio_eq {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : + (L s n : ℝ) / (m s n : ℝ) = (2:ℝ)^((s+1)*t s n) / (2:ℝ)^(d n) := by + have hsplit : s*(s+1)*t s n = (s-1)*(s+1)*t s n+(s+1)*t s n := by + calc + _ = ((s-1)+1)*(s+1)*t s n := by congr 2; omega + _ = _ := by ring + simp only [L, m, Nat.cast_pow, Nat.cast_ofNat] + rw [hsplit, pow_add, pow_add] + exact mul_div_mul_left _ _ (by positivity) + +lemma depth_integer_bound (s n : ℕ) : + (1+B s n)^(d n) * (1+B s n+2^(s*t s n)) * 2^(d n) ≤ 2^((s+1)*t s n) := by + let b := B s n + let u := t s n + let e := d n + have ha : 1+b ≤ 2^(b+1) := by + have h := @Nat.lt_two_pow_self (b+1) + omega + have ha1 : 1 ≤ 2^(b+1) := Nat.one_le_pow _ _ (by omega) + have hc1 : 1 ≤ 2^(s*u) := Nat.one_le_pow _ _ (by omega) + have hsum : 1+b+2^(s*u) ≤ 2^(b+1+s*u+1) := by + have hleft : 1+b ≤ 2^(b+1)*2^(s*u) := ha.trans (by nlinarith) + have hright : 2^(s*u) ≤ 2^(b+1)*2^(s*u) := by nlinarith + rw [pow_succ, pow_add] + omega + have hp := Nat.pow_le_pow_left ha e + have hstep : (1+b)^e * (1+b+2^(s*u)) * 2^e ≤ + 2^((b+1)*e) * 2^(b+1+s*u+1) * 2^e := by + have hp' : (1+b)^e ≤ 2^((b+1)*e) := by simpa only [pow_mul] using hp + exact Nat.mul_le_mul_right _ (Nat.mul_le_mul hp' hsum) + calc + _ ≤ 2^((b+1)*e) * 2^(b+1+s*u+1) * 2^e := hstep + _ = 2^((b+1)*e+(b+1+s*u+1)+e) := by rw [← pow_add, ← pow_add] + _ ≤ 2^((s+1)*u) := by + apply Nat.pow_le_pow_right (by omega : 0 < 2) + have h := t_bound s n + change (b+1)*(e+1)+1+e ≤ u at h + nlinarith + +lemma depth_bound {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : + (1+(B s n:ℝ))^(d n) * + (1+(B s n:ℝ)+(L s n:ℝ)^(1/((s:ℝ)+1))) ≤ (L s n:ℝ)/(m s n:ℝ) := by + rw [length_qprime_power, ratio_eq hs] + apply (le_div_iff₀ (by positivity : 0 < (2:ℝ)^(d n))).mpr + exact_mod_cast depth_integer_bound s n + +lemma depth_theta_bound {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : + (1/8:ℝ)^(d n) ≤ theta s n := by + rw [theta_eq hs] + exact pow_le_pow_left₀ (by norm_num) (by norm_num) _ + +lemma hasSum_theta {s : ℕ} (hs : 2 ≤ s) : + HasSum (theta s) (1/1024:ℝ) := by + have hgeom : HasSum (fun n : ℕ => (1/2:ℝ)^n) 2 := by + convert hasSum_geometric_of_lt_one (by norm_num : (0:ℝ) ≤ 1/2) (by norm_num : (1/2:ℝ) < 1) using 1; norm_num + have h := hgeom.mul_left ((1/2:ℝ)^11) + have h' : HasSum (theta s) ((1/2:ℝ)^11*2) := h.congr_fun (by + intro n + rw [theta_eq hs, d, pow_add, mul_comm]) + norm_num at h' ⊢ + exact h' + +lemma theta_sum_small {s : ℕ} (hs : 2 ≤ s) : ∑' n, theta s n < (1/8:ℝ) := by + rw [(hasSum_theta hs).tsum_eq] + norm_num + +lemma theta_tail {s : ℕ} (hs : 2 ≤ s) (J : ℕ) : + ∑' n, theta s (J+n) ≤ 4*theta s J := by + have hgeom : HasSum (fun n : ℕ => (1/2:ℝ)^n) 2 := by + convert hasSum_geometric_of_lt_one (by norm_num : (0:ℝ) ≤ 1/2) (by norm_num : (1/2:ℝ) < 1) using 1; norm_num + have htail : HasSum (fun n => theta s (J+n)) (2*theta s J) := by + have h' : HasSum (fun n => theta s (J+n)) (theta s J*2) := + (hgeom.mul_left (theta s J)).congr_fun (by + intro n + rw [theta_eq hs, theta_eq hs, d, d] + rw [show J+n+11 = (J+11)+n by omega, pow_add]) + simpa only [mul_comm] using h' + rw [htail.tsum_eq] + have hpos : 0 ≤ theta s J := by rw [theta_eq hs]; positivity + linarith + +lemma reciprocal_le_theta {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : + 1/(m s n:ℝ) ≤ theta s n := by + rw [theta, theta_numerator hs] + apply div_le_div_of_nonneg_right _ (by positivity) + exact one_le_pow₀ (by norm_num) + +lemma reciprocal_sum_small {s : ℕ} (hs : 2 ≤ s) : + ∑' n, 1/(m s n:ℝ) < (1/8:ℝ) := by + have hsum := (hasSum_theta hs).summable + have hrecip : Summable (fun n => 1/(m s n:ℝ)) := + Summable.of_nonneg_of_le (fun n => by positivity) (reciprocal_le_theta hs) hsum + exact (Summable.tsum_le_tsum (reciprocal_le_theta hs) hrecip hsum).trans_lt + (theta_sum_small hs) + +lemma d_div_t_tendsto (s : ℕ) : + Tendsto (fun n => (d n:ℝ)/(t s n:ℝ)) atTop (𝓝 0) := by + apply squeeze_zero (fun n => by positivity) + (g := fun n => 1/(d n:ℝ)) + · intro n + have hd : 0 < (d n:ℝ) := by exact_mod_cast d_pos n + have ht : 0 < (t s n:ℝ) := by exact_mod_cast t_pos s n + apply (div_le_div_iff₀ ht hd).mpr + simpa only [one_mul, ← sq] using (show (d n:ℝ)^2 ≤ (t s n:ℝ) by exact_mod_cast t_square s n) + · exact (tendsto_add_atTop_iff_nat 11).mpr tendsto_one_div_atTop_nhds_zero_nat + +lemma log_ratio_eq {s : ℕ} (hs : 2 ≤ s) (n : ℕ) : + Real.log ((L s n:ℝ)/(m s n:ℝ)) / Real.log (L s n:ℝ) = + 1/(s:ℝ) - ((d n:ℝ)/(t s n:ℝ))/((s:ℝ)*((s:ℝ)+1)) := by + have hs0 : (s:ℝ) ≠ 0 := by exact_mod_cast (by omega : s ≠ 0) + have hs1 : (s:ℝ)+1 ≠ 0 := by positivity + have ht : (t s n:ℝ) ≠ 0 := by exact_mod_cast (t_pos s n).ne' + have hlog : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num : (1:ℝ) < 2)).ne' + rw [ratio_eq hs, Real.log_div (by positivity) (by positivity), Real.log_pow, Real.log_pow] + simp only [L, Nat.cast_pow, Nat.cast_ofNat, Real.log_pow] + push_cast + field_simp + +lemma parameter_growth {s : ℕ} (hs : 2 ≤ s) : + Tendsto (fun n => Real.log ((L s n:ℝ)/(m s n:ℝ)) / Real.log (L s n:ℝ)) + atTop (𝓝 (1/(s:ℝ))) := by + simp_rw [log_ratio_eq hs] + convert tendsto_const_nhds.sub ((d_div_t_tendsto s).div_const ((s:ℝ)*((s:ℝ)+1))) using 1 + simp + +lemma ratio_tendsto_atTop {s : ℕ} (hs : 2 ≤ s) : + Tendsto (fun n => (L s n:ℝ)/(m s n:ℝ)) atTop atTop := by + apply tendsto_atTop_mono (f := fun n => (2:ℝ)^n) + (fun n => ?_) (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) + rw [ratio_eq hs] + apply (le_div_iff₀ (by positivity : 0 < (2:ℝ)^(d n))).mpr + rw [← pow_add] + apply pow_le_pow_right₀ (by norm_num : (1:ℝ) ≤ 2) + have h := t_bound s n + have hd : n ≤ d n := by simp [d] + have hsd : 1 ≤ s+1 := by omega + nlinarith + +lemma s_r_conjugate {s : ℕ} (hs : 2 ≤ s) : Real.HolderConjugate (s:ℝ) (r s) := + Real.HolderConjugate.conjExponent (by exact_mod_cast (by omega : 1 < s)) + +lemma sNext_q_conjugate {s : ℕ} (hs : 2 ≤ s) : Real.HolderConjugate ((s:ℝ)+1) (q s) := by + have hs0 : (0:ℝ) < s := by exact_mod_cast (by omega : 0 < s) + have h := Real.HolderConjugate.conjExponent (p := (s:ℝ)+1) (by linarith) + simpa only [Real.conjExponent, add_sub_cancel_right, q] using h + +lemma q_bounds {s : ℕ} (hs : 2 ≤ s) : + 1 < q s ∧ q s < r s ∧ r s < (s:ℝ)+1 ∧ 1/((s:ℝ)+1) < 1/(s:ℝ) := by + have hsR : (2:ℝ) ≤ s := by exact_mod_cast hs + have hs0 : (0:ℝ) < s := by linarith + have hs1 : (0:ℝ) < (s:ℝ)-1 := by linarith + refine ⟨?_, ?_, ?_, ?_⟩ + · rw [q, lt_div_iff₀ hs0]; linarith + · rw [q, r, div_lt_div_iff₀ hs0 hs1]; nlinarith + · rw [r, div_lt_iff₀ hs1]; nlinarith + · exact one_div_lt_one_div_of_lt hs0 (by linarith) + +end SeparableQuotient.Parameters + +namespace SeparableQuotient.Colors +open CoherentClosures + +/-- A partition of ω₁ into countably many unbounded fibers. -/ +def partitionEquiv : OmegaOne.{0} ≃ ℕ × OmegaOne.{0} := + Classical.choice (Cardinal.eq.mp (by + simp only [OmegaOne, Cardinal.mk_prod, Cardinal.lift_id, Cardinal.mk_nat, + Cardinal.mk_ord_toType, Cardinal.aleph0_mul_aleph])) + +def color (a : OmegaOne.{0}) : ℕ := (partitionEquiv a).1 + +def inColor (k : ℕ) (a : OmegaOne.{0}) : OmegaOne.{0} := partitionEquiv.symm (k, a) + +@[simp] lemma color_inColor (k : ℕ) (a : OmegaOne.{0}) : color (inColor k a) = k := by + simp [color, inColor] + +lemma inColor_injective (k : ℕ) : Function.Injective (inColor k) := by + intro a b h + have := partitionEquiv.symm.injective h + exact (Prod.mk.inj this).2 + +lemma fiber_unbounded (k : ℕ) (β : OmegaOne.{0}) : + ∃ a : OmegaOne.{0}, color a = k ∧ β ≤ a := by + by_contra! h + have hlt : ∀ a : OmegaOne.{0}, inColor k a < β := fun a => h _ (color_inColor k a) + let e : OmegaOne.{0} → Set.Iio β := fun a => ⟨inColor k a, hlt a⟩ + have he : Function.Injective e := fun a b hab => + inColor_injective k (congrArg Subtype.val hab) + have hcard := Cardinal.mk_le_of_injective he + have hsmall := Cardinal.mk_Iio_lt β (by simp [OmegaOne]) + exact (not_le_of_gt hsmall) hcard + +end SeparableQuotient.Colors + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PartitionBlocks.lean b/lean/OAI/Analysis/SeparableQuotients/PartitionBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..10cffb0091d61d853384a449486d8ba01a2f407b --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PartitionBlocks.lean @@ -0,0 +1,313 @@ +import OAI.Analysis.SeparableQuotients.RamseyThinning + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +noncomputable def ordinalHull (s : Finset Γ) (hs : s.Nonempty) : Set Γ := + Set.Icc (s.min' hs) (s.max' hs) + +lemma ordinalHull_connected (s : Finset Γ) (hs : s.Nonempty) : + Set.OrdConnected (ordinalHull s hs) := Set.ordConnected_Icc + +lemma mem_ordinalHull {s : Finset Γ} (hs : s.Nonempty) {a : Γ} (ha : a ∈ s) : + a ∈ ordinalHull s hs := ⟨s.min'_le _ ha, s.le_max' _ ha⟩ + +lemma ordinalHull_successive {s t : Finset Γ} (hs : s.Nonempty) (ht : t.Nonempty) + (h : ∀ a ∈ s, ∀ b ∈ t, a < b) : + ∀ a ∈ ordinalHull s hs, ∀ b ∈ ordinalHull t ht, a < b := by + intro a ha b hb + exact ha.2.trans_lt ((h _ (s.max'_mem hs) _ (t.min'_mem ht)).trans_le hb.1) + +noncomputable def intervalProjection (I : Set Γ) (hI : Set.OrdConnected I) : E →L[ℝ] E := + projection (Crop.ordinalSet I hI) + +lemma abs_eval_supported_interval (g : Array) (hg : g ∈ Full) + (I : Set Γ) (hI : Set.OrdConnected I) (hs : (g.support : Set Γ) ⊆ I) (x : E) : + |norming.evaluateArray x g| ≤ ‖intervalProjection I hI x‖ := by + have hr : restrict I g = g := by + ext a + by_cases ha : a ∈ I + · simp [ha] + · have hz : g a = 0 := by + by_contra hne + exact ha (hs (Finsupp.mem_support_iff.mpr hne)) + simp [ha, hz] + have he : norming.evaluateArray (intervalProjection I hI x) g = norming.evaluateArray x g := by + rw [intervalProjection, evaluateArray_projection, Crop.ordinalSet_set, hr] + rw [← he, norming.evaluateArray_eq_functional _ ⟨g, hg⟩] + exact norming.functional_bound _ _ + +/-- An interval-partition inequality and its constant-16 difference-vector version. Intervals may be unbounded or singletons. -/ +def PartitionBound (x : E) (N : ℕ) (A r : ℝ) : Prop := + ∀ d : ℕ, 1 ≤ d → d ≤ N → ∀ (I : Fin d → Set Γ) (hI : ∀ i, Set.OrdConnected (I i)), + (∀ i j, i < j → ∀ a ∈ I i, ∀ b ∈ I j, a < b) → + ∑ i : Fin d, ‖intervalProjection (I i) (hI i) x‖ ≤ A * (d : ℝ)^(1/r) + +lemma typeI_eval_le_of_partition {f : Family} (x : E) (N : ℕ) (A : ℝ) + (hA : 0 ≤ A) (hx : PartitionBound x N A f.r) (e : TypeI f) + (he : ∀ i, e.child i ∈ f.norming) (hL : f.L e.weight ≤ N) : + |norming.evaluateArray x e.value| ≤ A * f.theta e.weight := by + have hs (i : Fin e.length) : (e.child i).support.Nonempty := + Finsupp.support_nonempty_iff.mpr (e.child_nonzero i) + let I : Fin e.length → Set Γ := fun i => ordinalHull (e.child i).support (hs i) + have hI (i : Fin e.length) : Set.OrdConnected (I i) := ordinalHull_connected _ _ + have hIs : ∀ i j, i < j → ∀ a ∈ I i, ∀ b ∈ I j, a < b := by + intro i j hij + exact ordinalHull_successive (hs i) (hs j) (fun a ha b hb => (e.successive i j hij a ha b hb).1) + have hp := hx e.length e.length_pos (e.length_le.trans hL) I hI hIs + have hb : |∑ i : Fin e.length, norming.evaluateArray x (e.child i)| ≤ A * (e.length : ℝ)^(1/f.r) := by + apply le_trans (Finset.abs_sum_le_sum_abs _ _) (le_trans (Finset.sum_le_sum (fun i _ => ?_)) hp) + exact abs_eval_supported_interval _ (f.norming_subset_full (he i)) (I i) (hI i) + (fun a ha => mem_ordinalHull (hs i) ha) x + have hm : 0 < (f.m e.weight : ℝ) := by exact_mod_cast f.m_pos e.weight + have heq : norming.evaluateArray x e.value = (1 / (f.m e.weight : ℝ)) * + ∑ i : Fin e.length, norming.evaluateArray x (e.child i) := by + simp only [TypeI.value, map_smul, map_sum, Rat.smul_def, Rat.cast_div, Rat.cast_one, + Rat.cast_natCast] + rw [heq, abs_mul, abs_of_pos (one_div_pos.mpr hm), Family.theta_formula] + calc + _ ≤ (1 / (f.m e.weight : ℝ)) * (A * (e.length : ℝ)^(1/f.r)) := + mul_le_mul_of_nonneg_left hb (one_div_nonneg.mpr hm.le) + _ ≤ (1 / (f.m e.weight : ℝ)) * (A * (f.L e.weight : ℝ)^(1/f.r)) := by + apply mul_le_mul_of_nonneg_left _ (one_div_nonneg.mpr hm.le) + apply mul_le_mul_of_nonneg_left _ hA + exact Real.rpow_le_rpow (Nat.cast_nonneg _) (by exact_mod_cast e.length_le) + (one_div_nonneg.mpr f.r_pos.le) + _ = _ := by ring + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +/-- Algebraic finite blocks in the specified tail, with no completion added. -/ +noncomputable def BlockSequence.tailSpan {f : Family} (z : BlockSequence f) (a : ℕ) : + Submodule ℝ (Γ →₀ ℝ) := Submodule.span ℝ (Set.range (fun n => z.vector (n+a))) + +structure UnitBlocks (f : Family) (S : Submodule ℝ (Γ →₀ ℝ)) (k : ℕ) where + vector : Fin k → Γ →₀ ℝ + mem : ∀ i, vector i ∈ S + unit : ∀ i, ‖norming.includeFinite (vector i)‖ = 1 + successive : ∀ i j, i < j → ∀ a ∈ (vector i).support, ∀ b ∈ (vector j).support, + a < b ∧ (f = .mixed → Colors.color a < Colors.color b) + pure_color : ∀ c, f = .pure c → ∀ i a, a ∈ (vector i).support → Colors.color a = c + +lemma UnitBlocks.nonzero {f S k} (v : UnitBlocks f S k) (i : Fin k) : v.vector i ≠ 0 := by + intro h + have := v.unit i + simp [h] at this + +noncomputable def UnitBlocks.select {f S k} (v : UnitBlocks f S k) (t : Finset (Fin k)) : + UnitBlocks f S t.card where + vector i := v.vector (t.orderEmbOfFin rfl i) + mem i := v.mem (t.orderEmbOfFin rfl i) + unit i := v.unit (t.orderEmbOfFin rfl i) + successive i j hij := v.successive (t.orderEmbOfFin rfl i) (t.orderEmbOfFin rfl j) ((t.orderEmbOfFin rfl).strictMono hij) + pure_color c hc i := v.pure_color c hc (t.orderEmbOfFin rfl i) + +lemma UnitBlocks.select_sum {f S k} (v : UnitBlocks f S k) (t : Finset (Fin k)) : + ∑ i, (v.select t).vector i = ∑ i ∈ t, v.vector i := by + change ∑ i, v.vector (t.orderEmbOfFin rfl i) = _ + conv_rhs => rw [← t.map_orderEmbOfFin_univ rfl] + rw [Finset.sum_map] + rfl + +noncomputable def BlockSequence.unitBlocks {f : Family} (z : BlockSequence f) (a k : ℕ) : + UnitBlocks f (z.tailSpan a) k where + vector i := (‖norming.includeFinite (z.vector (i+a))‖⁻¹) • z.vector (i+a) + mem i := Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, rfl⟩) + unit i := by + rw [map_smul, norm_smul, norm_inv, Real.norm_eq_abs, abs_norm, + inv_mul_cancel₀] + exact norm_ne_zero_iff.mpr (fun h => z.nonzero (i+a) (norming.includeFinite_injective (by simpa using h))) + successive i j hij α hα β hβ := by + apply z.successive (i+a) (j+a) (by omega) α _ β _ + · exact Finsupp.support_smul hα + · exact Finsupp.support_smul hβ + pure_color c hc i α hα := z.pure_color c hc (i+a) α (Finsupp.support_smul hα) + +noncomputable def blockSumSup (f : Family) (S : Submodule ℝ (Γ →₀ ℝ)) (k : ℕ) : ℝ := + sSup (Set.range (fun v : UnitBlocks f S k => ‖norming.includeFinite (∑ i, v.vector i)‖)) + +lemma UnitBlocks.norm_sum_le_length {f S k} (v : UnitBlocks f S k) : + ‖norming.includeFinite (∑ i, v.vector i)‖ ≤ k := by + rw [map_sum] + exact (norm_sum_le _ _).trans (by simp [v.unit]) + +lemma blockSumSup_bdd (f S k) : BddAbove + (Set.range (fun v : UnitBlocks f S k => ‖norming.includeFinite (∑ i, v.vector i)‖)) := + ⟨k, by rintro _ ⟨v, rfl⟩; exact v.norm_sum_le_length⟩ + +lemma UnitBlocks.norm_sum_le_sup {f S k} (v : UnitBlocks f S k) : + ‖norming.includeFinite (∑ i, v.vector i)‖ ≤ blockSumSup f S k := + le_csSup (blockSumSup_bdd f S k) ⟨v, rfl⟩ + +lemma UnitBlocks.norm_subsum_le_sup {f S k} (v : UnitBlocks f S k) (t : Finset (Fin k)) : + ‖norming.includeFinite (∑ i ∈ t, v.vector i)‖ ≤ blockSumSup f S t.card := by + rw [← v.select_sum t] + exact (v.select t).norm_sum_le_sup + +lemma blockSumSup_le_length {f S k} (hne : Nonempty (UnitBlocks f S k)) : + blockSumSup f S k ≤ k := by + apply csSup_le (Set.range_nonempty_iff_nonempty.mpr hne) + rintro _ ⟨v, rfl⟩ + exact v.norm_sum_le_length + +lemma blockSumSup_nonneg {f S k} (hne : Nonempty (UnitBlocks f S k)) : + 0 ≤ blockSumSup f S k := by + obtain ⟨v⟩ := hne + exact (norm_nonneg _).trans v.norm_sum_le_sup + +lemma unitBlocks_near_sup {f S k} (hne : Nonempty (UnitBlocks f S k)) (ha : 0 < blockSumSup f S k) : + ∃ v : UnitBlocks f S k, blockSumSup f S k / 2 < ‖norming.includeFinite (∑ i, v.vector i)‖ := by + obtain ⟨b, ⟨v, rfl⟩, hv⟩ := exists_lt_of_lt_csSup (s := Set.range + (fun v : UnitBlocks f S k => ‖norming.includeFinite (∑ i, v.vector i)‖)) + (Set.range_nonempty_iff_nonempty.mpr hne) + (by linarith : blockSumSup f S k / 2 < blockSumSup f S k) + exact ⟨v, hv⟩ + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +noncomputable def vectorCrop (x : Γ →₀ ℝ) (hx : x ≠ 0) : Crop where + ordinal := ordinalHull x.support (Finsupp.support_nonempty_iff.mpr hx) + ordinal_convex := ordinalHull_connected _ _ + colors := Set.Icc ((x.support.image Colors.color).min' ((Finsupp.support_nonempty_iff.mpr hx).image _)) + ((x.support.image Colors.color).max' ((Finsupp.support_nonempty_iff.mpr hx).image _)) + colors_convex := Set.ordConnected_Icc + +lemma support_mem_vectorCrop (f : Family) (x : Γ →₀ ℝ) (hx : x ≠ 0) (a : Γ) + (ha : a ∈ x.support) : a ∈ (vectorCrop x hx).set f := by + have ho := mem_ordinalHull (Finsupp.support_nonempty_iff.mpr hx) ha + have hc : Colors.color a ∈ (vectorCrop x hx).colors := by + exact ⟨Finset.min'_le _ _ (Finset.mem_image.mpr ⟨a, ha, rfl⟩), + Finset.le_max' _ _ (Finset.mem_image.mpr ⟨a, ha, rfl⟩)⟩ + cases f with + | pure _ => exact ho + | mixed => exact ⟨ho, hc⟩ + +lemma vectorCrop_successive {f : Family} {x y : Γ →₀ ℝ} (hx : x ≠ 0) (hy : y ≠ 0) + (h : ∀ a ∈ x.support, ∀ b ∈ y.support, + a < b ∧ (f = .mixed → Colors.color a < Colors.color b)) : + ∀ a ∈ (vectorCrop x hx).set f, ∀ b ∈ (vectorCrop y hy).set f, + a < b ∧ (f = .mixed → Colors.color a < Colors.color b) := by + intro a ha b hb + have haO : a ∈ (vectorCrop x hx).ordinal := by cases f <;> simp_all [Crop.set] + have hbO : b ∈ (vectorCrop y hy).ordinal := by cases f <;> simp_all [Crop.set] + refine ⟨ordinalHull_successive _ _ (fun c hc d hd => (h c hc d hd).1) a haO b hbO, ?_⟩ + intro hf + subst f + obtain ⟨c, hc, hcx⟩ := Finset.mem_image.mp ((x.support.image Colors.color).max'_mem + ((Finsupp.support_nonempty_iff.mpr hx).image _)) + obtain ⟨d, hd, hdy⟩ := Finset.mem_image.mp ((y.support.image Colors.color).min'_mem + ((Finsupp.support_nonempty_iff.mpr hy).image _)) + have hcd := (h c hc d hd).2 rfl + rw [hcx, hdy] at hcd + exact ha.2.2.trans_lt (hcd.trans_le hb.2.1) + +lemma family_norming_crop (f : Family) (A : Crop) (g : Array) (hg : g ∈ f.norming) : + restrict (A.set f) g ∈ f.norming := by + cases f with + | pure k => exact pure_crop k A g hg + | mixed => exact full_crop A g hg + +lemma exists_unit_vector_normer {f : Family} (x : Γ →₀ ℝ) (hx : ‖norming.includeFinite x‖ = 1) + (hcolor : ∀ k, f = .pure k → ∀ a ∈ x.support, Colors.color a = k) : + ∃ (g : Array), g ∈ f.norming ∧ g ≠ 0 ∧ + (∀ a ∈ g.support, a ∈ (vectorCrop x (by intro h; simp [h] at hx)).set f) ∧ + 1/2 < norming.evaluateArray (norming.includeFinite x) g := by + have hx0 : x ≠ 0 := by intro h; simp [h] at hx + have hn : ∃ g ∈ f.norming, 1/2 < norming.evaluateArray (norming.includeFinite x) g := by + cases f with + | pure k => + apply exists_pure_normer k _ _ _ (by norm_num) (by rw [hx]; norm_num) + intro a ha + rw [norming.coordinate_includeFinite] + exact Finsupp.notMem_support_iff.mp (fun h => ha (hcolor k rfl a h)) + | mixed => exact exists_full_normer _ _ (by norm_num) (by rw [hx]; norm_num) + obtain ⟨g, hg, hgv⟩ := hn + let A := vectorCrop x hx0 + have heq : norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) g) = + norming.evaluateArray (norming.includeFinite x) g := by + apply evaluateArray_crop_of_zero + intro a ha + rw [norming.coordinate_includeFinite] + exact Finsupp.notMem_support_iff.mp (fun h => ha (support_mem_vectorCrop f x hx0 a h)) + refine ⟨restrict (A.set f) g, family_norming_crop f A g hg, ?_, ?_, by rwa [heq]⟩ + · intro hz + rw [hz, map_zero] at heq + linarith + · intro a ha + by_contra hn + change a ∉ A.set f at hn + exact Finsupp.mem_support_iff.mp ha (by simp [restrict, hn]) + +lemma evaluateArray_finite_disjoint (x : Γ →₀ ℝ) (g : Array) + (h : Disjoint x.support g.support) : norming.evaluateArray (norming.includeFinite x) g = 0 := by + rw [evaluateArray_finite] + apply Finset.sum_eq_zero + intro a ha + have hg : g a = 0 := Finsupp.notMem_support_iff.mp (fun hg => Finset.disjoint_left.mp h ha hg) + simp [hg] + +lemma UnitBlocks.norm_sum_lower {f S} (j : ℕ) (hj : 1 ≤ j) (v : UnitBlocks f S (f.L j)) : + (f.L j : ℝ) / (2 * (f.m j : ℝ)) ≤ ‖norming.includeFinite (∑ i, v.vector i)‖ := by + have hn := fun i => exists_unit_vector_normer (v.vector i) (v.unit i) + (fun k hk => v.pure_color k hk i) + choose g hg hgn hgs hgv using hn + let e : TypeI f := { + weight := j + weight_pos := hj + length := f.L j + length_pos := f.L_pos j + length_le := le_rfl + child := g + child_nonzero := hgn + successive := by + intro i l hil a ha b hb + exact vectorCrop_successive (v.nonzero i) (v.nonzero l) (v.successive i l hil) + a (hgs i a ha) b (hgs l b hb) } + have hall : e.value ∈ Full := f.norming_subset_full (e.mem_family hg) + have heval (i : Fin (f.L j)) : norming.evaluateArray (norming.includeFinite (∑ l, v.vector l)) (g i) = + norming.evaluateArray (norming.includeFinite (v.vector i)) (g i) := by + have hgi : g i ∈ Full := f.norming_subset_full (hg i) + simp only [norming.evaluateArray_eq_functional _ ⟨g i, hgi⟩, map_sum] + apply Finset.sum_eq_single i + · intro l _ hli + rw [← norming.evaluateArray_eq_functional] + apply evaluateArray_finite_disjoint + apply Finset.disjoint_left.mpr + intro a ha hag + rcases lt_or_gt_of_ne hli with hli | hil + · exact (lt_irrefl a) (vectorCrop_successive (v.nonzero l) (v.nonzero i) + (v.successive l i hli) a (support_mem_vectorCrop f _ _ a ha) a (hgs i a hag)).1 + · exact (lt_irrefl a) (vectorCrop_successive (v.nonzero i) (v.nonzero l) + (v.successive i l hil) a (hgs i a hag) a (support_mem_vectorCrop f _ _ a ha)).1 + · simp + have hm : (0 : ℝ) < f.m j := by exact_mod_cast f.m_pos j + calc + (f.L j : ℝ)/(2*(f.m j : ℝ)) = (1/(f.m j : ℝ)) * ∑ _ : Fin (f.L j), (1/2 : ℝ) := by simp; ring + _ ≤ (1/(f.m j : ℝ)) * ∑ i, norming.evaluateArray (norming.includeFinite (v.vector i)) (g i) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => (hgv i).le)) (one_div_nonneg.mpr hm.le) + _ = norming.evaluateArray (norming.includeFinite (∑ i, v.vector i)) e.value := by + rw [TypeI.value, map_smul, map_sum] + simp only [e, Rat.smul_def, Rat.cast_div, Rat.cast_one, Rat.cast_natCast, heval] + _ ≤ |norming.evaluateArray (norming.includeFinite (∑ i, v.vector i)) e.value| := le_abs_self _ + _ ≤ ‖norming.includeFinite (∑ i, v.vector i)‖ := by + rw [norming.evaluateArray_eq_functional _ ⟨_, hall⟩] + exact norming.functional_bound _ _ + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PathCoding.lean b/lean/OAI/Analysis/SeparableQuotients/PathCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..59a458d36d1939c4b4d8a37f7c6d52b4ea5c3aeb --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PathCoding.lean @@ -0,0 +1,359 @@ +import OAI.Analysis.SeparableQuotients.CoherentClosures + +namespace OAI + +namespace SeparableQuotient.PathCoding + +open CoherentClosures + +section OrderedArray +variable {Γ : Type*} [LinearOrder Γ] + +/-- Position of a coordinate in an ordered finite closure; no ordinal label is +stored in the code. -/ +def position (s : Finset Γ) (x : Γ) : ℕ := (s.filter (· < x)).card + +lemma position_strictMonoOn (s : Finset Γ) : StrictMonoOn (position s) s := by + intro x hx y _ hxy + apply Finset.card_lt_card + apply Finset.ssubset_iff_subset_ne.mpr + refine ⟨?_, ?_⟩ + · intro z hz + simp only [Finset.mem_filter] at hz ⊢ + exact ⟨hz.1, hz.2.trans hxy⟩ + · intro heq + have h : x ∈ s.filter (· < y) := Finset.mem_filter.mpr ⟨hx, hxy⟩ + rw [← heq] at h + exact (lt_irrefl x) (Finset.mem_filter.mp h).2 + +lemma position_inj {s : Finset Γ} {x y : Γ} (hx : x ∈ s) (hy : y ∈ s) + (h : position s x = position s y) : x = y := + (position_strictMonoOn s).injOn hx hy h + +lemma position_align {s t : Finset Γ} {a x : Γ} + (h : s.filter (· ≤ a) = t.filter (· ≤ a)) (hx : x ≤ a) : + position s x = position t x := by + unfold position + congr 1 + ext z + constructor <;> intro hz + · obtain ⟨hz, hzx⟩ := Finset.mem_filter.mp hz + have hz' : z ∈ s.filter (· ≤ a) := + Finset.mem_filter.mpr ⟨hz, hzx.le.trans hx⟩ + rw [h] at hz' + exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hz').1, hzx⟩ + · obtain ⟨hz, hzx⟩ := Finset.mem_filter.mp hz + have hz' : z ∈ t.filter (· ≤ a) := + Finset.mem_filter.mpr ⟨hz, hzx.le.trans hx⟩ + rw [← h] at hz' + exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hz').1, hzx⟩ + +/-- A zero-filled rational array recorded by order positions, including zero values. -/ +def arrayCode (s : Finset Γ) (f : Γ →₀ ℚ) : Finset (ℕ × ℚ) := + s.image (fun x => (position s x, f x)) + +lemma arrayCode_match {s t : Finset Γ} {f g : Γ →₀ ℚ} + (h : arrayCode s f = arrayCode t g) {x : Γ} (hx : x ∈ s) : + ∃ y ∈ t, position s x = position t y ∧ f x = g y := by + have hm : (position s x, f x) ∈ arrayCode s f := Finset.mem_image.mpr ⟨x, hx, rfl⟩ + rw [h] at hm + obtain ⟨y, hy, heq⟩ := Finset.mem_image.mp hm + exact ⟨y, hy, (congrArg Prod.fst heq).symm, (congrArg Prod.snd heq).symm⟩ + +/-- Position alignment from equal compressed arrays and a shared initial segment. -/ +lemma position_alignment {s t : Finset Γ} {a : Γ} {f g : Γ →₀ ℚ} + (hst : s.filter (· ≤ a) = t.filter (· ≤ a)) + (hf : f.support ⊆ s) (hg : g.support ⊆ t) + (hfa : ∀ x ∈ f.support, x < a) + (hcode : arrayCode s f = arrayCode t g) : f = g := by + have align : ∀ x ∈ s, x ≤ a → x ∈ t ∧ position s x = position t x := by + intro x hx hxa + have hm : x ∈ s.filter (· ≤ a) := Finset.mem_filter.mpr ⟨hx, hxa⟩ + rw [hst] at hm + exact ⟨(Finset.mem_filter.mp hm).1, position_align hst hxa⟩ + have nonzero_align : ∀ x, f x ≠ 0 → f x = g x := by + intro x hx + have hfx : x ∈ f.support := Finsupp.mem_support_iff.mpr hx + obtain ⟨y, hy, hpos, hval⟩ := arrayCode_match hcode (hf hfx) + obtain ⟨hxt, hpxt⟩ := align x (hf hfx) (hfa x hfx).le + have heq : x = y := position_inj hxt hy (hpxt.symm.trans hpos) + simpa [heq] using hval + ext x + by_cases hfx : f x = 0 + · by_cases hgx : g x = 0 + · simp [hfx, hgx] + obtain ⟨y, hy, hpos, hval⟩ := arrayCode_match hcode.symm + (hg (Finsupp.mem_support_iff.mpr hgx)) + have hfy : f y ≠ 0 := by simpa [← hval] using hgx + have hys : y ∈ f.support := Finsupp.mem_support_iff.mpr hfy + obtain ⟨hyt, hpyt⟩ := align y hy (hfa y hys).le + have heq : x = y := position_inj (hg (Finsupp.mem_support_iff.mpr hgx)) hyt + (hpos.trans hpyt) + exact (hfy (heq ▸ hfx)).elim + · exact nonzero_align x hfx + +lemma closure_position_alignment {β γ a : OmegaOne} {p : ℕ} {f g : OmegaOne →₀ ℚ} + (hβ : a ∈ F β p) (hγ : a ∈ F γ p) + (hf : f.support ⊆ F β p) (hg : g.support ⊆ F γ p) + (ha : ∀ x ∈ f.support, x < a) + (hc : arrayCode (F β p) f = arrayCode (F γ p) g) : f = g := + position_alignment (shared_initial_segment β γ a p hβ hγ) hf hg ha hc + +end OrderedArray +end SeparableQuotient.PathCoding + +namespace SeparableQuotient.PathCoding + +open CoherentClosures + +abbrev Code := List (ℕ × ℕ × Finset (ℕ × ℚ)) + +def codeBound : Code → ℕ + | [] => 0 + | x :: xs => max x.2.1 (codeBound xs) + +lemma metadata_le_codeBound {c : Code} {x : ℕ × ℕ × Finset (ℕ × ℚ)} + (hx : x ∈ c) : x.2.1 ≤ codeBound c := by + induction c with + | nil => simp at hx + | cons y ys ih => + rcases List.mem_cons.mp hx with h | h + · subst x + exact le_max_left _ _ + · exact (ih h).trans (le_max_right _ _) + +/-- An injective code greater than every entry of its final metadata. -/ +noncomputable def sigma (c : Code) : ℕ := Nat.pair (Encodable.encode c) (codeBound c + 1) + +lemma sigma_injective : Function.Injective sigma := by + intro c d h + exact Encodable.encode_injective (Nat.pair_eq_pair.mp h).1 + +lemma codeBound_lt_sigma (c : Code) : codeBound c < sigma c := + (Nat.lt_succ_self _).trans_le (Nat.right_le_pair _ _) + +/-- Raw infinite path data, retaining the actual rational pieces, declared +weights and metadata. Nonzero pieces are included here to define the prefix +endpoint without arbitrary defaults. Type-I membership is not needed for the +combinatorial rigidity theorem. -/ +@[ext] structure RawPath where + piece : ℕ → OmegaOne →₀ ℚ + weight : ℕ → ℕ + metadata : ℕ → ℕ + nonzero : ∀ i, piece i ≠ 0 + +namespace RawPath + +noncomputable def support (P : RawPath) (n : ℕ) : Finset OmegaOne := + (Finset.range (n+1)).biUnion (fun i => (P.piece i).support) + +lemma mem_support_iff (P : RawPath) (n : ℕ) (a : OmegaOne) : + a ∈ P.support n ↔ ∃ i ≤ n, a ∈ (P.piece i).support := by + classical + simp only [support, Finset.mem_biUnion, Finset.mem_range, Nat.lt_succ_iff] + +lemma piece_support_subset (P : RawPath) {i n : ℕ} (hi : i ≤ n) : + (P.piece i).support ⊆ P.support n := by + intro a ha + exact (P.mem_support_iff n a).mpr ⟨i, hi, ha⟩ + +lemma support_nonempty (P : RawPath) (n : ℕ) : (P.support n).Nonempty := by + obtain ⟨a, ha⟩ := Finsupp.support_nonempty_iff.mpr (P.nonzero n) + exact ⟨a, P.piece_support_subset le_rfl ha⟩ + +noncomputable def endpoint (P : RawPath) (n : ℕ) : OmegaOne := + (P.support n).max' (P.support_nonempty n) + +lemma endpoint_mem (P : RawPath) (n : ℕ) : P.endpoint n ∈ P.support n := + Finset.max'_mem _ _ + +lemma le_endpoint (P : RawPath) {n : ℕ} {a : OmegaOne} (ha : a ∈ P.support n) : + a ≤ P.endpoint n := Finset.le_max' _ _ ha + +noncomputable def closure (P : RawPath) (n : ℕ) : Finset OmegaOne := + F (P.endpoint n) (P.metadata n) + +noncomputable def code (P : RawPath) (n : ℕ) : Code := + List.ofFn (fun i : Fin (n+1) => + (P.weight i, P.metadata i, arrayCode (P.closure n) (P.piece i))) + +lemma code_length (P : RawPath) (n : ℕ) : (P.code n).length = n+1 := + List.length_ofFn + +lemma code_eq_length {P Q : RawPath} {n m : ℕ} (h : P.code n = Q.code m) : n = m := by + have h' := congrArg List.length h + simpa only [code_length, Nat.add_right_cancel_iff] using h' + +lemma code_eq_at {P Q : RawPath} {n : ℕ} (h : P.code n = Q.code n) + (i : ℕ) (hi : i ≤ n) : + P.weight i = Q.weight i ∧ P.metadata i = Q.metadata i ∧ + arrayCode (P.closure n) (P.piece i) = arrayCode (Q.closure n) (Q.piece i) := by + have heq := congrFun (List.ofFn_injective h) ⟨i, Nat.lt_succ_iff.mpr hi⟩ + exact ⟨congrArg Prod.fst heq, congrArg (fun x => x.2.1) heq, + congrArg (fun x => x.2.2) heq⟩ + +lemma metadata_le_codeBound (P : RawPath) (n : ℕ) : P.metadata n ≤ codeBound (P.code n) := by + apply PathCoding.metadata_le_codeBound (x := + (P.weight n, P.metadata n, arrayCode (P.closure n) (P.piece n))) + exact List.mem_ofFn.mpr ⟨⟨n, by omega⟩, rfl⟩ + +/-- Exact support, succession, weight and metadata conditions of a path. The +Type-I construction contributes only additional restrictions, not needed below. -/ +structure Admissible (P : RawPath) : Prop where + successive : ∀ i j, i < j → ∀ a ∈ (P.piece i).support, + ∀ b ∈ (P.piece j).support, a < b + metadata_strict : StrictMono P.metadata + metadata_pos : ∀ i, 1 ≤ P.metadata i + weight_pos : ∀ i, 1 ≤ P.weight i + weight_le_metadata : ∀ i, P.weight i ≤ P.metadata i + rho_bound : ∀ n a b, a ∈ P.support n → b ∈ P.support n → a ≤ b → + rho a b ≤ P.metadata n + rule : ∀ n, P.weight (n+1) = sigma (P.code n) + +lemma Admissible.support_subset_closure {P : RawPath} (hP : P.Admissible) (n : ℕ) : + P.support n ⊆ P.closure n := by + intro a ha + exact (rho_le_iff a (P.endpoint n) (P.le_endpoint ha) _ (hP.metadata_pos n)).mp + (hP.rho_bound n a (P.endpoint n) ha (P.endpoint_mem n) (P.le_endpoint ha)) + +lemma Admissible.piece_support_subset_closure {P : RawPath} (hP : P.Admissible) + {i n : ℕ} (hi : i ≤ n) : (P.piece i).support ⊆ P.closure n := + (P.piece_support_subset hi).trans (hP.support_subset_closure n) + +lemma Admissible.weight_strict {P : RawPath} (hP : P.Admissible) : StrictMono P.weight := by + apply strictMono_nat_of_lt_succ + intro n + rw [hP.rule n] + exact (hP.weight_le_metadata n).trans_lt + ((P.metadata_le_codeBound n).trans_lt (codeBound_lt_sigma _)) + +end RawPath +end SeparableQuotient.PathCoding + +namespace SeparableQuotient.PathCoding.RawPath + +open CoherentClosures + +lemma Admissible.large_matching_prefix {P Q : RawPath} (hP : P.Admissible) (hQ : Q.Admissible) + (hinf : (Set.range P.weight ∩ Set.range Q.weight).Infinite) (N : ℕ) : + ∃ n ≥ N, P.code n = Q.code n := by + obtain ⟨w, ⟨⟨k, hk⟩, ⟨l, hl⟩⟩, hw⟩ := + hinf.exists_gt (max (P.weight (N+1)) (Q.weight 0)) + have hk' : N+1 < k := hP.weight_strict.lt_iff_lt.mp + (by rw [hk]; exact (le_max_left _ _).trans_lt hw) + have hl' : 0 < l := hQ.weight_strict.lt_iff_lt.mp + (by rw [hl]; exact (le_max_right _ _).trans_lt hw) + have hcode : P.code (k-1) = Q.code (l-1) := by + apply sigma_injective + rw [← hP.rule, ← hQ.rule] + have hk'' : k-1+1 = k := by omega + have hl'' : l-1+1 = l := by omega + rw [hk'', hl'', hk, hl] + have heq := code_eq_length hcode + refine ⟨k-1, by omega, ?_⟩ + simpa only [← heq] using hcode + +/-- The support of P is order-cofinal below that of Q. -/ +def SupportBelow (P Q : RawPath) : Prop := + ∀ i a, a ∈ (P.piece i).support → + ∃ j b, b ∈ (Q.piece j).support ∧ a ≤ b + +lemma supportBelow_total (P Q : RawPath) : P.SupportBelow Q ∨ Q.SupportBelow P := by + classical + by_cases h : P.SupportBelow Q + · exact Or.inl h + · right + simp only [SupportBelow, not_forall, not_exists, not_and, not_le] at h + obtain ⟨i, a, ha, h⟩ := h + intro j b hb + exact ⟨i, a, ha, (h j b hb).le⟩ + +lemma Admissible.eq_of_infinite_shared_weights_of_supportBelow {P Q : RawPath} + (hP : P.Admissible) (hQ : Q.Admissible) + (hinf : (Set.range P.weight ∩ Set.range Q.weight).Infinite) + (hPQ : P.SupportBelow Q) : P = Q := by + apply RawPath.ext + · funext i + obtain ⟨a, ha⟩ := Finsupp.support_nonempty_iff.mpr (P.nonzero (i+1)) + obtain ⟨k, b, hb, hab⟩ := hPQ (i+1) a ha + obtain ⟨n, hn, hcode⟩ := hP.large_matching_prefix hQ hinf (max (i+1) (max k (rho a b))) + have hin : i ≤ n := by omega + have hin' : i+1 ≤ n := (le_max_left _ _).trans hn + have hkn : k ≤ n := (le_max_left _ _).trans ((le_max_right _ _).trans hn) + have hrn : rho a b ≤ n := (le_max_right _ _).trans ((le_max_right _ _).trans hn) + have hmeta := (code_eq_at hcode n le_rfl).2.1 + have haP : a ∈ P.closure n := hP.piece_support_subset_closure hin' ha + have hbQ : b ∈ Q.closure n := hQ.piece_support_subset_closure hkn hb + have haB : a ∈ F b (Q.metadata n) := + (rho_le_iff a b hab _ (hQ.metadata_pos n)).mp + (hrn.trans (hQ.metadata_strict.id_le n)) + have haQ : a ∈ Q.closure n := by + rw [F_coherent (Q.endpoint n) b (Q.metadata n) hbQ] at haB + exact (Finset.mem_filter.mp haB).1 + apply position_alignment (a := a) + (show (P.closure n).filter (· ≤ a) = (Q.closure n).filter (· ≤ a) from ?_) + (hP.piece_support_subset_closure hin) (hQ.piece_support_subset_closure hin) + (fun x hx => hP.successive i (i+1) (by omega) x hx a ha) + (code_eq_at hcode i hin).2.2 + unfold closure at haP ⊢ + rw [hmeta] at haP ⊢ + exact shared_initial_segment (P.endpoint n) (Q.endpoint n) a (Q.metadata n) haP haQ + · funext i + obtain ⟨n, hin, hcode⟩ := hP.large_matching_prefix hQ hinf i + exact (code_eq_at hcode i hin).1 + · funext i + obtain ⟨n, hin, hcode⟩ := hP.large_matching_prefix hQ hinf i + exact (code_eq_at hcode i hin).2.1 + +/-- Distinct admissible paths have only finitely many shared weights. -/ +lemma Admissible.eq_of_infinite_shared_weights {P Q : RawPath} + (hP : P.Admissible) (hQ : Q.Admissible) + (hinf : (Set.range P.weight ∩ Set.range Q.weight).Infinite) : P = Q := by + rcases supportBelow_total P Q with h | h + · exact hP.eq_of_infinite_shared_weights_of_supportBelow hQ hinf h + · exact (hQ.eq_of_infinite_shared_weights_of_supportBelow hP + (by simpa only [Set.inter_comm] using hinf) h).symm + +lemma Admissible.shared_weights_finite {P Q : RawPath} + (hP : P.Admissible) (hQ : Q.Admissible) (hne : P ≠ Q) : + (Set.range P.weight ∩ Set.range Q.weight).Finite := by + by_contra hinf + exact hne (hP.eq_of_infinite_shared_weights hQ hinf) + +end SeparableQuotient.PathCoding.RawPath + +namespace SeparableQuotient.PathCoding.RawPath + +/-- A common finite deletion makes the weights of a finite collection of +pairwise distinct paths disjoint. This is the combinatorial input to the +Type-II tail estimate and the quotient-space path map. -/ +lemma Admissible.disjoint_weight_tails {ι : Type*} [Fintype ι] (P : ι → RawPath) + (hP : ∀ i, (P i).Admissible) (hinj : Function.Injective P) : + ∃ N : ℕ, Pairwise (fun i j => Disjoint + (Set.range (fun n => (P i).weight (n+N))) + (Set.range (fun n => (P j).weight (n+N)))) := by + classical + have hbound : ∀ i j : ι, ∃ B : ℕ, + i ≠ j → ∀ n m, (P i).weight n = (P j).weight m → n ≤ B := by + intro i j + by_cases hij : i = j + · exact ⟨0, fun h => (h hij).elim⟩ + · have hfin := (hP i).shared_weights_finite (hP j) (hinj.ne hij) + obtain ⟨B, hB⟩ := hfin.bddAbove + refine ⟨B, fun _ n m heq => ?_⟩ + exact ((hP i).weight_strict.id_le n).trans + (hB ⟨⟨n, rfl⟩, ⟨m, heq.symm⟩⟩) + choose B hB using hbound + let N := (Finset.univ : Finset (ι × ι)).sup (fun ij => B ij.1 ij.2) + 1 + refine ⟨N, ?_⟩ + intro i j hij + apply Set.disjoint_left.mpr + rintro w ⟨n, hn⟩ ⟨m, hm⟩ + have hnB := hB i j hij (n+N) (m+N) (hn.trans hm.symm) + have hBN : B i j < N := Nat.lt_succ_of_le + (Finset.le_sup (f := fun ij : ι × ι => B ij.1 ij.2) (Finset.mem_univ (i,j))) + omega + +end SeparableQuotient.PathCoding.RawPath + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PathConvergence.lean b/lean/OAI/Analysis/SeparableQuotients/PathConvergence.lean new file mode 100644 index 0000000000000000000000000000000000000000..c287cac8134b7f30674c3d83c24adb01b884bca2 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PathConvergence.lean @@ -0,0 +1,448 @@ +import OAI.Analysis.SeparableQuotients.RealCoefficients + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.PathSelection +open Filter +open scoped Topology Classical +universe u + +/-- A finite threshold selection procedure for quantitative overlap bounds. -/ +lemma threshold_selection {Λ : Type u} (f : Λ → ℕ → ℝ) (M δ : ℝ) + (hM : ∀ a n, |f a n| ≤ M) (N : ℕ) + (hcap : ∀ (s : Finset Λ) (φ : ℕ → ℕ), StrictMono φ → + (∀ a ∈ s, ∀ n, δ < |f a (φ n)|) → s.card ≤ N) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ + ∀ a, CauchySeq (fun n => f a (φ n)) ∨ ∀ᶠ n in atTop, |f a (φ n)| ≤ δ := by + let Attain : ℕ → Prop := fun k => ∃ (s : Finset Λ) (φ : ℕ → ℕ), + s.card = k ∧ StrictMono φ ∧ ∀ a ∈ s, + CauchySeq (fun n => f a (φ n)) ∧ ∀ n, δ < |f a (φ n)| + have hzero : Attain 0 := ⟨∅, id, by simp, strictMono_id, by simp⟩ + let k := Nat.findGreatest Attain N + obtain ⟨s, φ, hcard, hφ, hs⟩ := Nat.findGreatest_spec (P := Attain) (Nat.zero_le N) hzero + refine ⟨φ, hφ, fun a => ?_⟩ + by_cases has : a ∈ s + · exact Or.inl (hs a has).1 + · by_contra! bad + have hfreq : ∃ᶠ n in atTop, δ < |f a (φ n)| := by + simpa only [not_le] using bad.2 + obtain ⟨ψ, hψ, hψδ⟩ := extraction_of_frequently_atTop hfreq + obtain ⟨y, _, χ, hχ, htχ⟩ := isCompact_Icc.tendsto_subseq + (s := Set.Icc (-M) M) (x := fun n => f a (φ (ψ n))) + (fun n => abs_le.mp (hM a (φ (ψ n)))) + let η : ℕ → ℕ := φ ∘ ψ ∘ χ + have hη : StrictMono η := hφ.comp (hψ.comp hχ) + have hnew : Attain (k+1) := by + refine ⟨insert a s, η, ?_, hη, ?_⟩ + · rw [Finset.card_insert_of_notMem has, hcard] + · intro b hb + rcases Finset.mem_insert.mp hb with rfl | hb + · exact ⟨htχ.cauchySeq, fun n => hψδ (χ n)⟩ + · exact ⟨(hs b hb).1.comp_tendsto ((hψ.comp hχ).tendsto_atTop), + fun n => (hs b hb).2 (ψ (χ n))⟩ + have hbound : k+1 ≤ N := by + obtain ⟨t, η, ht, hη, hh⟩ := hnew + rw [← ht] + exact hcap t η hη (fun b hb => (hh b hb).2) + have := Nat.le_findGreatest (P := Attain) hbound hnew + change k+1 ≤ k at this + omega + +end SeparableQuotient.PathSelection + +namespace SeparableQuotient.PathSelection +open Filter +open scoped Topology Classical + +/-- A genuinely nested sequence of subsequences, with the usual diagonal map. -/ +structure Nested where + seq : ℕ → ℕ → ℕ + mono : ∀ k, StrictMono (seq k) + nested : ∀ k, ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ seq (k+1) = seq k ∘ ψ + +def Nested.diag (A : Nested) : ℕ → ℕ := fun n => A.seq n n + +lemma Nested.represent (A : Nested) {k n : ℕ} (hn : k ≤ n) (i : ℕ) : + ∃ j ≥ i, A.seq n i = A.seq k j := by + induction hn generalizing i with + | refl => exact ⟨i, le_rfl, rfl⟩ + | @step n hn ih => + obtain ⟨ψ, hψ, he⟩ := A.nested n + obtain ⟨j, hj, hij⟩ := ih (ψ i) + exact ⟨j, (hψ.id_le i).trans hj, by simpa only [he, Function.comp_apply] using hij⟩ + +lemma Nested.diag_strictMono (A : Nested) : StrictMono A.diag := by + apply strictMono_nat_of_lt_succ + intro n + obtain ⟨ψ, hψ, he⟩ := A.nested n + change A.seq n n < A.seq (n+1) (n+1) + rw [he, Function.comp_apply] + exact (A.mono n) ((Nat.lt_succ_self n).trans_le (hψ.id_le (n+1))) + +lemma Nested.eventually_diag (A : Nested) {P : ℕ → Prop} (k : ℕ) + (h : ∀ᶠ i in atTop, P (A.seq k i)) : ∀ᶠ n in atTop, P (A.diag n) := by + obtain ⟨N, hN⟩ := eventually_atTop.mp h + filter_upwards [eventually_ge_atTop (max k N)] with n hn + obtain ⟨j, hj, he⟩ := A.represent ((le_max_left k N).trans hn) n + change P (A.seq n n) + rw [he] + exact hN j ((le_max_right k N).trans (hn.trans hj)) + +lemma Nested.cauchy_diag {X : Type*} [PseudoMetricSpace X] (A : Nested) (f : ℕ → X) + (k : ℕ) (h : CauchySeq (f ∘ A.seq k)) : CauchySeq (f ∘ A.diag) := by + rw [Metric.cauchySeq_iff] at h ⊢ + intro ε hε + obtain ⟨N, hN⟩ := h ε hε + refine ⟨max k N, fun m hm n hn => ?_⟩ + obtain ⟨i, hi, he⟩ := A.represent ((le_max_left k N).trans hm) m + obtain ⟨j, hj, hf⟩ := A.represent ((le_max_left k N).trans hn) n + change dist (f (A.seq m m)) (f (A.seq n n)) < ε + rw [he, hf] + exact hN i ((le_max_right k N).trans (hm.trans hi)) j ((le_max_right k N).trans (hn.trans hj)) + +end SeparableQuotient.PathSelection + +namespace SeparableQuotient.PathSelection +open Filter +open scoped Topology Classical +universe u + +/-- Simultaneous convergence on an arbitrary, possibly uncountable, path family. +Only finite quantitative overlap bounds are required. -/ +lemma simultaneous_cauchy {Λ : Type u} (f : Λ → ℕ → ℝ) (M : ℝ) + (hM : ∀ a n, |f a n| ≤ M) + (hcap : ∀ δ : ℝ, 0 < δ → ∃ N : ℕ, + ∀ (s : Finset Λ) (φ : ℕ → ℕ), StrictMono φ → + (∀ a ∈ s, ∀ n, δ < |f a (φ n)|) → s.card ≤ N) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ a, CauchySeq (fun n => f a (φ n)) := by + let δ : ℕ → ℝ := fun n => 1/((n+1 : ℕ) : ℝ) + have hδ : ∀ n, 0 < δ n := by intro n; dsimp [δ]; positivity + let Subseq := {φ : ℕ → ℕ // StrictMono φ} + have hex : ∀ n (u : Subseq), ∃ v : Subseq, + (∀ a, CauchySeq (fun i => f a (v.val i)) ∨ + ∀ᶠ i in atTop, |f a (v.val i)| ≤ δ n) ∧ + ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ v.val = u.val ∘ ψ := by + intro n u + obtain ⟨N, hN⟩ := hcap (δ n) (hδ n) + obtain ⟨ψ, hψ, hgood⟩ := threshold_selection (fun a i => f a (u.val i)) M (δ n) + (fun a i => hM a (u.val i)) N + (fun s φ hφ hh => hN s (u.val ∘ φ) (u.property.comp hφ) hh) + exact ⟨⟨u.val ∘ ψ, u.property.comp hψ⟩, hgood, ψ, hψ, rfl⟩ + choose next hnext using hex + let U : ℕ → Subseq := Nat.rec ⟨id, strictMono_id⟩ (fun n u => next n u) + let A : Nested := { + seq := fun n => (U n).val + mono := fun n => (U n).property + nested := fun n => (hnext n (U n)).2 } + refine ⟨A.diag, A.diag_strictMono, fun a => ?_⟩ + by_cases hex : ∃ k, CauchySeq (fun n => f a (A.seq k n)) + · obtain ⟨k, hk⟩ := hex + exact A.cauchy_diag (f a) k hk + · have hsmall (k : ℕ) : ∀ᶠ n in atTop, |f a (A.diag n)| ≤ δ k := by + apply A.eventually_diag (P := fun i => |f a i| ≤ δ k) (k+1) + exact ((hnext k (U k)).1 a).resolve_left (fun h => hex ⟨k+1, h⟩) + have ht : Tendsto (fun n => f a (A.diag n)) atTop (𝓝 0) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + have hδ0 : Tendsto δ atTop (𝓝 0) := + (tendsto_add_atTop_iff_nat 1).mpr tendsto_one_div_atTop_nhds_zero_nat + obtain ⟨k, hk⟩ := (hδ0.eventually (gt_mem_nhds hε)).exists + filter_upwards [hsmall k] with n hn + simpa only [Real.dist_eq, sub_zero] using hn.trans_lt hk + exact ht.cauchySeq + +end SeparableQuotient.PathSelection + +namespace SeparableQuotient.PathSelection +open Filter +open scoped Topology + +lemma power_cap (r M δ : ℝ) (hr : r < 1) (hδ : 0 < δ) : + ∃ N : ℕ, ∀ n : ℕ, δ * n ≤ M * (n : ℝ)^r → n ≤ N := by + have ht : Tendsto (fun n : ℕ => (n : ℝ)^(1-r)) atTop atTop := + (tendsto_rpow_atTop (by linarith : 0 < 1-r)).comp tendsto_natCast_atTop_atTop + obtain ⟨N, hN⟩ := eventually_atTop.mp (ht.eventually (eventually_gt_atTop (M/δ))) + refine ⟨N, fun n hn => ?_⟩ + by_contra hbad + have hnN : N < n := Nat.lt_of_not_ge hbad + have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) + have hp : 0 < (n : ℝ)^r := Real.rpow_pos_of_pos hn0 _ + have hm : M < δ * (n : ℝ)^(1-r) := (div_lt_iff₀ hδ).mp (hN n hnN.le) + |>.trans_eq (mul_comm _ _) + have he : (n : ℝ)^r * (n : ℝ)^(1-r) = n := by + rw [← Real.rpow_add hn0, add_sub_cancel, Real.rpow_one] + have := mul_lt_mul_of_pos_left hm hp + rw [mul_left_comm, he] at this + nlinarith + +end SeparableQuotient.PathSelection + +namespace SeparableQuotient.Norming +open PathCoding +open scoped Classical + +/-- Paths are indexed by their full raw data, not by an arbitrary chosen +expression witnessing membership. The witness is retained when used. -/ +def PathIndex (f : Family) := {r : RawPath // ∃ P : InfinitePath f, P.raw = r} + +def PathIndex.repr {f : Family} (a : PathIndex f) : InfinitePath f := a.property.choose + +@[simp] lemma PathIndex.repr_raw {f : Family} (a : PathIndex f) : a.repr.raw = a.val := + a.property.choose_spec + +lemma PathIndex.repr_injective {f : Family} : Function.Injective + (fun a : PathIndex f => a.repr.raw) := by + intro a b hab + apply Subtype.ext + simpa only [PathIndex.repr_raw] using hab + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup10 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace10 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance + +lemma real_tail_bound {f : Family} {h : ℕ} (P : Fin h → InfinitePath f) (N : ℕ) + (hdis : Pairwise (fun i j => Disjoint + (Set.range (fun n => (P i).raw.weight (n+N+1))) + (Set.range (fun n => (P j).raw.weight (n+N+1))))) + (c : Fin h → ℝ) : + ‖∑ i, c i • pathTail (P i) N‖ ≤ (∑ i, |c i| ^ f.q) ^ (1/f.q) := by + have hq : 0 < f.q := lt_trans zero_lt_one (Parameters.q_bounds f.s_ge_two).1 + apply RealCoefficients.bound_from_unit f.q hq (fun i => pathTail (P i) N) + intro a ha + exact RealCoefficients.rational_to_real f.q hq (fun i => pathTail (P i) N) + (rational_tail_bound P N hdis) a ha + +lemma exists_tail_estimate {f : Family} {h : ℕ} (P : Fin h → InfinitePath f) + (hinj : Function.Injective (fun i => (P i).raw)) : + ∃ N, ∀ c : Fin h → ℝ, + ‖∑ i, c i • pathTail (P i) N‖ ≤ (∑ i, |c i| ^ f.q) ^ (1/f.q) := by + obtain ⟨N, hN⟩ := RawPath.Admissible.disjoint_weight_tails + (fun i => (P i).raw) (fun i => (P i).admissible) hinj + refine ⟨N, real_tail_bound P N ?_⟩ + intro i j hij + apply (hN hij).mono + · rintro w ⟨n, rfl⟩ + exact ⟨n+1, by change (P i).raw.weight ((n+1)+N) = (P i).raw.weight (n+N+1); congr 1; omega⟩ + · rintro w ⟨n, rfl⟩ + exact ⟨n+1, by change (P j).raw.weight ((n+1)+N) = (P j).raw.weight (n+N+1); congr 1; omega⟩ + +lemma tail_abs_sum_bound {f : Family} {h : ℕ} (P : Fin h → InfinitePath f) (N : ℕ) + (hN : ∀ c : Fin h → ℝ, + ‖∑ i, c i • pathTail (P i) N‖ ≤ (∑ i, |c i| ^ f.q) ^ (1/f.q)) (x : E) : + (∑ i, |pathTail (P i) N x|) ≤ (h : ℝ) ^ (1/f.q) * ‖x‖ := by + let c : Fin h → ℝ := fun i => RealCoefficients.signChoice (pathTail (P i) N x) + have hc (i : Fin h) : |c i| = 1 := RealCoefficients.abs_signChoice _ + have hv (i : Fin h) : c i * pathTail (P i) N x = |pathTail (P i) N x| := + RealCoefficients.signChoice_mul _ + have he : (∑ i, c i • pathTail (P i) N) x = ∑ i, |pathTail (P i) N x| := by + simp only [sum_apply, smul_apply, smul_eq_mul, hv] + calc + _ = |(∑ i, c i • pathTail (P i) N) x| := by + rw [he, abs_of_nonneg (Finset.sum_nonneg (fun i _ => abs_nonneg _))] + _ ≤ ‖∑ i, c i • pathTail (P i) N‖ * ‖x‖ := + by simpa only [Real.norm_eq_abs] using (∑ i, c i • pathTail (P i) N).le_opNorm x + _ ≤ _ := mul_le_mul_of_nonneg_right (by simpa only [hc, Real.one_rpow, + Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] using hN c) + (norm_nonneg _) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +/-- Bounded blocks are null on the coordinate predual. This intermediate +property is stated separately so that the path argument works for any such +sequence, not just a chosen block representation. -/ +def PredualNull (x : ℕ → E) : Prop := + ∀ y : X₀, Tendsto (fun n => y.val (x n)) atTop (𝓝 0) + +lemma path_threshold_cap {f : Family} (x : ℕ → E) (M : ℝ) + (hM : ∀ n, ‖x n‖ ≤ M) (hx : PredualNull x) (δ : ℝ) (hδ : 0 < δ) : + ∃ K : ℕ, ∀ (s : Finset (PathIndex f)) (φ : ℕ → ℕ), StrictMono φ → + (∀ a ∈ s, ∀ n, δ < |pathFunctional a.repr (x (φ n))|) → s.card ≤ K := by + have hq : 1 < f.q := (Parameters.q_bounds f.s_ge_two).1 + obtain ⟨K, hK⟩ := PathSelection.power_cap (1/f.q) M (δ/2) + ((div_lt_one (by linarith)).mpr (by linarith)) (by linarith) + refine ⟨K, fun s φ hφ hs => ?_⟩ + let e : Fin s.card ≃ s := s.equivFin.symm + let P : Fin s.card → InfinitePath f := fun i => (e i).val.repr + have hinj : Function.Injective (fun i => (P i).raw) := by + intro i j hij + apply e.injective + apply Subtype.ext + exact PathIndex.repr_injective hij + obtain ⟨N, hN⟩ := exists_tail_estimate P hinj + have hsmall (i : Fin s.card) : ∀ᶠ n in atTop, + |pathFunctional (P i) (x (φ n)) - pathTail (P i) N (x (φ n))| < δ/2 := by + have ht := (hx ⟨pathFunctional (P i) - pathTail (P i) N, + pathTail_complement_mem (P i) N⟩).comp hφ.tendsto_atTop + have hδ0 : |(0 : ℝ)| < δ/2 := by rw [abs_zero]; exact half_pos hδ + have he := ht.abs.eventually (gt_mem_nhds hδ0) + simpa only [Function.comp_apply, sub_apply, abs_zero] using he + obtain ⟨n, hn⟩ := (eventually_all_finset (I := Finset.univ)).mpr + (fun i _ => hsmall i) |>.exists + have hlower (i : Fin s.card) : δ/2 ≤ |pathTail (P i) N (x (φ n))| := by + have hh := hs (e i).val (e i).property n + have hh' := hn i (Finset.mem_univ i) + have ht := abs_sub_abs_le_abs_sub + (pathFunctional (P i) (x (φ n))) (pathTail (P i) N (x (φ n))) + dsimp only [P] at ht hh' + linarith + apply hK s.card + calc + δ/2 * (s.card : ℝ) = ∑ _i : Fin s.card, δ/2 := by simp [mul_comm] + _ ≤ ∑ i, |pathTail (P i) N (x (φ n))| := Finset.sum_le_sum (fun i _ => hlower i) + _ ≤ (s.card : ℝ)^(1/f.q) * ‖x (φ n)‖ := tail_abs_sum_bound P N hN _ + _ ≤ M * (s.card : ℝ)^(1/f.q) := by + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hM (φ n)) + (Real.rpow_nonneg (Nat.cast_nonneg _) _) + +lemma path_all_cauchy {f : Family} (x : ℕ → E) (M : ℝ) + (hM : ∀ n, ‖x n‖ ≤ M) (hx : PredualNull x) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ a : PathIndex f, + CauchySeq (fun n => pathFunctional a.repr (x (φ n))) := by + apply PathSelection.simultaneous_cauchy (fun (a : PathIndex f) (n : ℕ) => + pathFunctional a.repr (x n)) M + · intro a n + simpa only [Real.norm_eq_abs] using + (PathLimits.unit_bound _ (norm_pathFunctional_le a.repr) _).trans (hM n) + · exact path_threshold_cap x M hM hx + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.DenseZero +open Filter +open scoped Topology +universe u +variable {Z : Type u} [NormedAddCommGroup Z] [NormedSpace ℝ Z] + +lemma tendsto_zero_of_dense (g : ℕ → StrongDual ℝ Z) (M : ℝ) + (hM : ∀ n, ‖g n‖ ≤ M) (D : Set Z) (hD : Dense D) + (h : ∀ z ∈ D, Tendsto (fun n => g n z) atTop (𝓝 0)) (z : Z) : + Tendsto (fun n => g n z) atTop (𝓝 0) := by + have hM0 : 0 ≤ M := (norm_nonneg (g 0)).trans (hM 0) + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨w, hw, hzw⟩ := Metric.mem_closure_iff.mp (hD z) (ε/(2*(M+1))) (by positivity) + have he := (Metric.tendsto_nhds.mp (h w hw) (ε/2) (by linarith)) + filter_upwards [he] with n hn + have hdist : dist (g n z) (g n w) ≤ M * dist z w := by + rw [dist_eq_norm, ← map_sub, dist_eq_norm] + exact ((g n).le_opNorm (z-w)).trans + (mul_le_mul_of_nonneg_right (hM n) (norm_nonneg _)) + have hsmall : M * dist z w < ε/2 := by + have hd : dist z w < ε/(2*(M+1)) := by simpa only [dist_comm] using hzw + have hdm : (M+1) * dist z w < ε/2 := by + have hh := (lt_div_iff₀ (by positivity : 0 < 2*(M+1))).mp hd + nlinarith + have hle : M * dist z w ≤ (M+1) * dist z w := + mul_le_mul_of_nonneg_right (by linarith) (dist_nonneg : 0 ≤ dist z w) + exact hle.trans_lt hdm + exact (dist_triangle (g n z) (g n w) 0).trans_lt (by linarith) + +end SeparableQuotient.DenseZero + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup11 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace11 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +@[reducible] local instance predualGroup11 : NormedAddCommGroup X₀ := inferInstance +@[reducible] local instance predualSpace11 : NormedSpace ℝ X₀ := inferInstance +@[reducible] local instance dualPredualGroup11 : NormedAddCommGroup (StrongDual ℝ X₀) := inferInstance +@[reducible] local instance dualPredualSpace11 : NormedSpace ℝ (StrongDual ℝ X₀) := inferInstance + +lemma predualNull_of_coordinates (x : ℕ → E) (M : ℝ) + (hM : ∀ n, ‖x n‖ ≤ M) + (hx : ∀ a : Γ, Tendsto (fun n => coordinate a (x n)) atTop (𝓝 0)) : + PredualNull x := by + let V : Submodule ℝ X₀ := { + carrier := {y | Tendsto (fun n => y.val (x n)) atTop (𝓝 0)} + zero_mem' := by simp + add_mem' := by + intro y z hy hz + change Tendsto (fun n => (y.val + z.val) (x n)) atTop (𝓝 0) + simpa only [add_apply, add_zero] using hy.add hz + smul_mem' := by + intro c y hy + change Tendsto (fun n => (c • y.val) (x n)) atTop (𝓝 0) + simpa only [smul_apply, smul_zero] using hy.const_smul c } + have hspan : Submodule.span ℝ (Set.range coordinate₀) ≤ V := by + apply Submodule.span_le.mpr + rintro y ⟨a, rfl⟩ + exact hx a + intro y + exact DenseZero.tendsto_zero_of_dense (fun n => norming.evaluation (x n)) M + (fun n => (norming.norm_evaluation (x n)).le.trans (hM n)) + (Submodule.span ℝ (Set.range coordinate₀)) dense_span_coordinate₀ + (fun z hz => hspan hz) y + +/-- Admissible block sequences with real coefficients. Pure mode requires one color, mixed mode both orders. -/ +structure BlockSequence (f : Family) where + vector : ℕ → Γ →₀ ℝ + nonzero : ∀ n, vector n ≠ 0 + successive : ∀ i j, i < j → ∀ a ∈ (vector i).support, ∀ b ∈ (vector j).support, + a < b ∧ (f = .mixed → Colors.color a < Colors.color b) + pure_color : ∀ k, f = .pure k → ∀ n a, a ∈ (vector n).support → Colors.color a = k + +def BlockSequence.embed {f : Family} (x : BlockSequence f) (n : ℕ) : E := + norming.includeFinite (x.vector n) + +lemma BlockSequence.coordinate_eventually_zero {f : Family} (x : BlockSequence f) (a : Γ) : + ∀ᶠ n in atTop, coordinate a (x.embed n) = 0 := by + by_cases hex : ∃ n, x.vector n a ≠ 0 + · obtain ⟨i, hi⟩ := hex + filter_upwards [eventually_ge_atTop (i+1)] with n hn + change norming.coordinate a (norming.includeFinite (x.vector n)) = 0 + rw [norming.coordinate_includeFinite] + by_contra h + exact (lt_irrefl a) (x.successive i n (by omega) a (Finsupp.mem_support_iff.mpr hi) + a (Finsupp.mem_support_iff.mpr h)).1 + · push Not at hex + apply Eventually.of_forall + intro n + exact (norming.coordinate_includeFinite a (x.vector n)).trans (hex n) + +lemma BlockSequence.predualNull {f : Family} (x : BlockSequence f) (M : ℝ) + (hM : ∀ n, ‖x.embed n‖ ≤ M) : PredualNull x.embed := by + apply predualNull_of_coordinates x.embed M hM + intro a + exact tendsto_const_nhds.congr' ((x.coordinate_eventually_zero a).mono fun _ h => h.symm) + +lemma pathFunctional_eq_of_raw {f : Family} {P Q : InfinitePath f} (h : P.raw = Q.raw) : + pathFunctional P = pathFunctional Q := by + ext x + apply tendsto_nhds_unique (pathPartial_tendsto P x) + apply (pathPartial_tendsto Q x).congr' + apply Eventually.of_forall + intro n + simp only [pathPartial, ← norming.evaluateArray_eq_functional] + congr 1 + change (∑ i : Fin (n+1), Q.raw.piece i) = ∑ i : Fin (n+1), P.raw.piece i + rw [h] + +/-- Every bounded block sequence has a subsequence on which every path functional converges. -/ +lemma BlockSequence.all_paths_cauchy {f : Family} (x : BlockSequence f) (M : ℝ) + (hM : ∀ n, ‖x.embed n‖ ≤ M) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ P : InfinitePath f, + CauchySeq (fun n => pathFunctional P (x.embed (φ n))) := by + obtain ⟨φ, hφ, hp⟩ := path_all_cauchy x.embed M hM (x.predualNull M hM) + refine ⟨φ, hφ, fun P => ?_⟩ + let a : PathIndex f := ⟨P.raw, P, rfl⟩ + have he : pathFunctional a.repr = pathFunctional P := pathFunctional_eq_of_raw a.repr_raw + simpa only [he] using hp a + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PathLimits.lean b/lean/OAI/Analysis/SeparableQuotients/PathLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..9294483a5c375ef92282f9b375cb7cca89476fe7 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PathLimits.lean @@ -0,0 +1,388 @@ +import OAI.Analysis.SeparableQuotients.BoundedCompleteness + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.PathLimits +open Filter +open scoped Topology +universe u +variable {Z : Type u} [NormedAddCommGroup Z] [NormedSpace ℝ Z] + +lemma unit_bound (f : StrongDual ℝ Z) (hf : ‖f‖ ≤ 1) (x : Z) : ‖f x‖ ≤ ‖x‖ := + (f.le_opNorm x).trans (by simpa only [one_mul] using + mul_le_mul_of_nonneg_right hf (norm_nonneg x)) + +lemma cauchy_of_dense (f : ℕ → StrongDual ℝ Z) (hf : ∀ n, ‖f n‖ ≤ 1) + (D : Set Z) (hD : Dense D) (h : ∀ x ∈ D, CauchySeq (fun n => f n x)) (x : Z) : + CauchySeq (fun n => f n x) := by + rw [Metric.cauchySeq_iff] + intro ε hε + obtain ⟨y, hy, hxy⟩ := Metric.mem_closure_iff.mp (hD x) (ε/4) (by positivity) + obtain ⟨N, hN⟩ := Metric.cauchySeq_iff.mp (h y hy) (ε/4) (by positivity) + refine ⟨N, fun m hm n hn => ?_⟩ + have hmxy : dist (f m x) (f m y) ≤ dist x y := by + simpa only [dist_eq_norm, ← map_sub] using unit_bound (f m) (hf m) (x-y) + have hnxy : dist (f n y) (f n x) ≤ dist x y := by + rw [dist_comm (f n y)] + simpa only [dist_eq_norm, ← map_sub] using unit_bound (f n) (hf n) (x-y) + have ht := calc + dist (f m x) (f n x) ≤ dist (f m x) (f m y) + dist (f m y) (f n x) := dist_triangle _ _ _ + _ ≤ dist (f m x) (f m y) + (dist (f m y) (f n y) + dist (f n y) (f n x)) := + add_le_add le_rfl (dist_triangle _ _ _) + have := hN m hm n hn + have hd : dist x y < ε/4 := by simpa only [dist_comm] using hxy + linarith + +/-- Bounded pointwise convergence on a dense set determines an actual bounded +functional on the completed space; no weak-star sequential compactness is used. -/ +lemma exists_limit_of_dense (f : ℕ → StrongDual ℝ Z) (hf : ∀ n, ‖f n‖ ≤ 1) + (D : Set Z) (hD : Dense D) (h : ∀ x ∈ D, CauchySeq (fun n => f n x)) : + ∃ P : StrongDual ℝ Z, ‖P‖ ≤ 1 ∧ ∀ x, Tendsto (fun n => f n x) atTop (𝓝 (P x)) := by + choose g hg using (fun x => cauchySeq_tendsto_of_complete (cauchy_of_dense f hf D hD h x)) + have hb : Bornology.IsBounded (Set.range f) := isBounded_iff_forall_norm_le.mpr + ⟨1, by rintro _ ⟨n, rfl⟩; exact hf n⟩ + let P : StrongDual ℝ Z := ContinuousLinearMap.ofTendstoOfBoundedRange g f + (tendsto_pi_nhds.mpr hg) hb + have hP : ‖P‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound P (by norm_num) + intro x + simpa only [P, ContinuousLinearMap.ofTendstoOfBoundedRange_apply, one_mul] using le_of_tendsto (hg x).norm + (Filter.Eventually.of_forall (fun n => unit_bound (f n) (hf n) x)) + exact ⟨P, hP, hg⟩ + +end SeparableQuotient.PathLimits + +namespace SeparableQuotient.Norming +open scoped Classical +open PathCoding + +def Family.base : Family → Set Array + | .pure k => pureBase k + | .mixed => ⋃ k, Pure k + +def Family.norming (f : Family) : Set Array := ⋃ n, stage f.base f n + +lemma Family.norming_subset_full (f : Family) : f.norming ⊆ Full := by + cases f with + | pure k => exact pure_subset_full k + | mixed => exact Set.Subset.rfl + +lemma common_stage {f : Family} {ι : Type*} [Fintype ι] (x : ι → Array) + (hx : ∀ i, x i ∈ f.norming) : ∃ n, ∀ i, x i ∈ stage f.base f n := by + have hh : ∀ i, ∃ n, x i ∈ stage f.base f n := fun i => Set.mem_iUnion.mp (hx i) + choose n hn using hh + exact ⟨Finset.univ.sup n, fun i => stage_mono _ _ (Finset.le_sup (Finset.mem_univ i)) (hn i)⟩ + +lemma TypeI.mem_family {f : Family} (e : TypeI f) + (h : ∀ i, e.child i ∈ f.norming) : e.value ∈ f.norming := by + obtain ⟨n, hn⟩ := common_stage e.child h + exact Set.mem_iUnion.mpr ⟨n+1, Or.inl (Or.inr ⟨e, rfl, hn⟩)⟩ + +lemma TypeII.mem_family {f : Family} (e : TypeII f) + (h : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) : e.value ∈ f.norming := by + let ι := Σ b : Fin e.length, Σ i : Fin (e.path b).length, Fin ((e.path b).piece i).length + obtain ⟨n, hn⟩ := common_stage (fun a : ι => ((e.path a.1).piece a.2.1).child a.2.2) + (fun a => h a.1 a.2.1 a.2.2) + exact Set.mem_iUnion.mpr ⟨n+1, Or.inr ⟨e, rfl, fun b i j => hn ⟨b,i,j⟩⟩⟩ + +lemma admissible_prefix {P : RawPath} (h : P.Admissible) (n : ℕ) : PrefixValid P n where + successive := fun i j hij _ => h.successive i j hij + metadata_strict := fun _i _j hij _ => h.metadata_strict hij + metadata_pos := fun i _ => h.metadata_pos i + weight_pos := fun i _ => h.weight_pos i + weight_le_metadata := fun i _ => h.weight_le_metadata i + rho_bound := fun i _ => h.rho_bound i + rule := fun i _ => h.rule i + +/-- Actual infinite paths retain all original Type I expressions, weights, and +uncropped metadata. No completion of the coding tree is inserted as a path. -/ +structure InfinitePath (f : Family) where + raw : RawPath + admissible : raw.Admissible + piece : ℕ → TypeI f + value_eq : ∀ i, (piece i).value = raw.piece i + weight_eq : ∀ i, (piece i).weight = raw.weight i + successive : ∀ i j, i < j → Successive f (raw.piece i) (raw.piece j) + children_mem : ∀ i j, (piece i).child j ∈ f.norming + +def InfinitePath.prefix {f : Family} (P : InfinitePath f) (n : ℕ) : FinitePath f where + raw := P.raw + length := n+1 + length_pos := by omega + valid := admissible_prefix P.admissible (n+1) + piece := fun i => P.piece i + value_eq := fun i => P.value_eq i + weight_eq := fun i => P.weight_eq i + mixed_successive := fun i j hij => P.successive i j hij + +def FinitePath.oneTerm {f : Family} (P : FinitePath f) (A : Crop) : TypeII f where + length := 1 + path := fun _ => P + crop := fun _ => A + coefficient := fun _ => 1 + bound := by simp + disjoint_active := fun b c hbc => (hbc (Subsingleton.elim _ _)).elim + +@[simp] lemma FinitePath.oneTerm_value {f : Family} (P : FinitePath f) (A : Crop) : + (P.oneTerm A).value = restrict (A.set f) P.value := by + change (∑ _b : Fin 1, (1 : ℚ) • restrict (A.set f) P.value) = _ + simp + +lemma InfinitePath.prefix_crop_mem {f : Family} (P : InfinitePath f) (n : ℕ) (A : Crop) : + restrict (A.set f) (P.prefix n).value ∈ f.norming := by + rw [← FinitePath.oneTerm_value] + exact TypeII.mem_family _ (fun _ i j => P.children_mem i j) + +lemma InfinitePath.prefix_mem {f : Family} (P : InfinitePath f) (n : ℕ) : + (P.prefix n).value ∈ Full := by + apply f.norming_subset_full + simpa only [Crop.all_set, restrict_univ] using P.prefix_crop_mem n Crop.all + +lemma InfinitePath.piece_coefficient_unique {f : Family} (P : InfinitePath f) + {i j : ℕ} {a : Γ} (hi : P.raw.piece i a ≠ 0) (hj : P.raw.piece j a ≠ 0) : i = j := by + by_contra hn + rcases lt_or_gt_of_ne hn with h | h + · have := P.admissible.successive i j h a (Finsupp.mem_support_iff.mpr hi) + a (Finsupp.mem_support_iff.mpr hj) + exact (lt_irrefl a) this + · have := P.admissible.successive j i h a (Finsupp.mem_support_iff.mpr hj) + a (Finsupp.mem_support_iff.mpr hi) + exact (lt_irrefl a) this + +lemma InfinitePath.prefix_at_hit {f : Family} (P : InfinitePath f) (a : Γ) (i n : ℕ) + (hi : P.raw.piece i a ≠ 0) (hin : i ≤ n) : + (P.prefix n).value a = P.raw.piece i a := by + change (∑ j : Fin (n+1), P.raw.piece j) a = _ + rw [Finsupp.finsetSum_apply, Finset.sum_eq_single (⟨i, by omega⟩ : Fin (n+1))] + · intro j _ hji + by_contra hn + exact hji (Fin.ext (P.piece_coefficient_unique hn hi)) + · simp + +lemma InfinitePath.prefix_coordinate_eventually_constant {f : Family} (P : InfinitePath f) + (a : Γ) : ∃ q : ℚ, ∀ᶠ n in Filter.atTop, (P.prefix n).value a = q := by + by_cases h : ∃ i, P.raw.piece i a ≠ 0 + · obtain ⟨i, hi⟩ := h + exact ⟨P.raw.piece i a, (Filter.eventually_ge_atTop i).mono (fun n hn => P.prefix_at_hit a i n hi hn)⟩ + · push Not at h + refine ⟨0, Filter.Eventually.of_forall (fun n => ?_)⟩ + change (∑ j : Fin (n+1), P.raw.piece j) a = 0 + simp only [Finsupp.finsetSum_apply, h, Finset.sum_const_zero] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup8 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace8 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance + +def pathPartial {f : Family} (P : InfinitePath f) (n : ℕ) : StrongDual ℝ E := + norming.functional ⟨(P.prefix n).value, P.prefix_mem n⟩ + +lemma pathPartial_bound {f : Family} (P : InfinitePath f) (n : ℕ) : ‖pathPartial P n‖ ≤ 1 := + norming.norm_functional_le _ + +lemma pathPartial_finite_cauchy {f : Family} (P : InfinitePath f) (x : Γ →₀ ℝ) : + CauchySeq (fun n => pathPartial P n (norming.includeFinite x)) := by + choose q hq using P.prefix_coordinate_eventually_constant + have he : ∀ᶠ n in atTop, pathPartial P n (norming.includeFinite x) = + x.sum (fun a t => t * (q a : ℝ)) := by + filter_upwards [(Filter.eventually_all_finset x.support).mpr (fun a _ => hq a)] with n hn + rw [pathPartial, norming.functional_includeFinite] + apply Finset.sum_congr rfl + intro a ha + change x a * ((P.prefix n).value a : ℝ) = x a * (q a : ℝ) + rw [hn a ha] + exact (tendsto_const_nhds.congr' (he.mono fun _ h => h.symm)).cauchySeq + +lemma exists_pathFunctional {f : Family} (P : InfinitePath f) : + ∃ F : StrongDual ℝ E, ‖F‖ ≤ 1 ∧ ∀ x, Tendsto (fun n => pathPartial P n x) atTop (𝓝 (F x)) := by + apply PathLimits.exists_limit_of_dense _ (pathPartial_bound P) _ norming.denseRange_includeFinite + rintro _ ⟨x, rfl⟩ + exact pathPartial_finite_cauchy P x + +/-- Path partial sums are bounded and converge pointwise. -/ +def pathFunctional {f : Family} (P : InfinitePath f) : StrongDual ℝ E := + (exists_pathFunctional P).choose + +lemma norm_pathFunctional_le {f : Family} (P : InfinitePath f) : ‖pathFunctional P‖ ≤ 1 := + (exists_pathFunctional P).choose_spec.1 + +lemma pathPartial_tendsto {f : Family} (P : InfinitePath f) (x : E) : + Tendsto (fun n => pathPartial P n x) atTop (𝓝 (pathFunctional P x)) := + (exists_pathFunctional P).choose_spec.2 x + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open PathCoding +open scoped Classical + +def InfinitePath.tailCrop {f : Family} (P : InfinitePath f) (N : ℕ) : Crop where + ordinal := Set.Ioi (P.raw.endpoint N) + ordinal_convex := Set.ordConnected_Ioi + colors := Set.univ + colors_convex := Set.ordConnected_univ + +@[simp] lemma InfinitePath.tailCrop_set {f g : Family} (P : InfinitePath f) (N : ℕ) : + (P.tailCrop N).set g = Set.Ioi (P.raw.endpoint N) := by + cases g <;> simp [Crop.set, InfinitePath.tailCrop] + +lemma InfinitePath.before_endpoint {f : Family} (P : InfinitePath f) + {N i : ℕ} (hi : i ≤ N) {a : Γ} (ha : a ∈ (P.raw.piece i).support) : + a ≤ P.raw.endpoint N := P.raw.le_endpoint (P.raw.piece_support_subset hi ha) + +lemma InfinitePath.after_endpoint {f : Family} (P : InfinitePath f) + {N i : ℕ} (hi : N < i) {a : Γ} (ha : a ∈ (P.raw.piece i).support) : + P.raw.endpoint N < a := by + obtain ⟨j, hj, he⟩ := (P.raw.mem_support_iff N _).mp (P.raw.endpoint_mem N) + exact P.admissible.successive j i (hj.trans_lt hi) _ he a ha + +lemma InfinitePath.tail_piece {f : Family} (P : InfinitePath f) (N i : ℕ) : + restrict ((P.tailCrop N).set f) (P.raw.piece i) = if N < i then P.raw.piece i else 0 := by + ext a + rw [restrict_apply, tailCrop_set] + by_cases hai : P.raw.piece i a = 0 + · by_cases hi : N < i <;> simp [hi, hai] + · have ha := Finsupp.mem_support_iff.mpr hai + by_cases hi : N < i + · simp [hi, P.after_endpoint hi ha] + · have hnot : ¬ P.raw.endpoint N < a := not_lt_of_ge (P.before_endpoint (Nat.le_of_not_gt hi) ha) + simp [hi, hnot] + +lemma InfinitePath.tail_active_subset {f : Family} (P : InfinitePath f) (N n : ℕ) : + ↑((P.prefix n).active (P.tailCrop N)) ⊆ Set.range (fun i => P.raw.weight (i+N+1)) := by + intro w hw + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hw + have hi' := (Finset.mem_filter.mp hi).2 + change restrict ((P.tailCrop N).set f) (P.raw.piece i) ≠ 0 at hi' + rw [P.tail_piece] at hi' + have hNi : N < (i : ℕ) := by + by_contra hn + exact hi' (ite_eq_right hn) + refine ⟨(i : ℕ)-N-1, ?_⟩ + change P.raw.weight (((i : ℕ)-N-1)+N+1) = P.raw.weight i + congr 1 + omega + +lemma InfinitePath.tail_prefix_coeff {f : Family} (P : InfinitePath f) (N n : ℕ) + (hn : N ≤ n) : + restrict ((P.tailCrop N).set f) (P.prefix n).value = + (P.prefix n).value - (P.prefix N).value := by + ext a + rw [restrict_apply, tailCrop_set, Finsupp.sub_apply, Set.mem_Ioi] + by_cases ha : P.raw.endpoint N < a + · rw [ite_eq_left ha] + have hz : (P.prefix N).value a = 0 := by + change (∑ i : Fin (N+1), P.raw.piece i) a = 0 + rw [Finsupp.finsetSum_apply] + apply Finset.sum_eq_zero + intro i _ + by_contra h + exact (not_le_of_gt ha) (P.before_endpoint (by omega) (Finsupp.mem_support_iff.mpr h)) + simp [hz] + · rw [ite_eq_right ha] + by_cases hz : (P.prefix n).value a = 0 + · have hzN : (P.prefix N).value a = 0 := by + by_contra hzN + have hit := (P.prefix N).value_at_hit a + change (P.prefix N).value a = P.raw.piece ((P.prefix N).hitIndex a) a at hit + have hh : P.raw.piece ((P.prefix N).hitIndex a) a ≠ 0 := by rwa [← hit] + have he := P.prefix_at_hit a ((P.prefix N).hitIndex a) n hh + (by have := ((P.prefix N).hitIndex a).isLt; change _ < N+1 at this; omega) + exact hh (he.symm.trans hz) + simp [hz, hzN] + · have hit := (P.prefix n).value_at_hit a + change (P.prefix n).value a = P.raw.piece ((P.prefix n).hitIndex a) a at hit + have hh : P.raw.piece ((P.prefix n).hitIndex a) a ≠ 0 := by rwa [← hit] + have hi : ((P.prefix n).hitIndex a : ℕ) ≤ N := by + by_contra hi + exact ha (P.after_endpoint (Nat.lt_of_not_ge hi) (Finsupp.mem_support_iff.mpr hh)) + rw [P.prefix_at_hit a _ N hh hi, hit, sub_self] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +@[reducible] local instance dualEGroup9 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace9 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance + +lemma pathPartial_crop_apply {f : Family} (P : InfinitePath f) (N n : ℕ) (x : E) : + pathPartial P n (projection (P.tailCrop N) x) = + norming.evaluateArray x (restrict ((P.tailCrop N).set f) (P.prefix n).value) := by + rw [pathPartial, ← norming.evaluateArray_eq_functional] + change norming.evaluateArray (norming.projection _ _ x) _ = _ + rw [norming.evaluateArray_projection] + simp only [InfinitePath.tailCrop_set, restrict] + +def pathTail {f : Family} (P : InfinitePath f) (N : ℕ) : StrongDual ℝ E := + (pathFunctional P).comp (projection (P.tailCrop N)) + +lemma pathTail_complement {f : Family} (P : InfinitePath f) (N : ℕ) : + pathFunctional P - pathTail P N = (norming.rationalPredual (P.prefix N).value).val := by + ext x + have ht := (pathPartial_tendsto P x).sub + (pathPartial_tendsto P (projection (P.tailCrop N) x)) + apply tendsto_nhds_unique ht + apply tendsto_const_nhds.congr' + filter_upwards [eventually_ge_atTop N] with n hn + rw [pathPartial_crop_apply, P.tail_prefix_coeff N n hn, map_sub] + rw [norming.evaluateArray_eq_functional x ⟨(P.prefix n).value, P.prefix_mem n⟩] + change norming.evaluateArray x (P.prefix N).value = _ + simp only [pathPartial] + ring + +lemma pathTail_complement_mem {f : Family} (P : InfinitePath f) (N : ℕ) : + pathFunctional P - pathTail P N ∈ X₀ := by + rw [pathTail_complement] + exact (norming.rationalPredual (P.prefix N).value).property + +/-- The exact original coding is retained in all finite tails. -/ +lemma rational_tail_bound {f : Family} {h : ℕ} (P : Fin h → InfinitePath f) (N : ℕ) + (hdis : Pairwise (fun i j => Disjoint + (Set.range (fun n => (P i).raw.weight (n+N+1))) + (Set.range (fun n => (P j).raw.weight (n+N+1))))) + (c : Fin h → ℚ) (hc : ∑ i, |(c i : ℝ)| ^ f.q ≤ 1) : + ‖∑ i, (c i : ℝ) • pathTail (P i) N‖ ≤ 1 := by + let e : ℕ → TypeII f := fun n => { + length := h + path := fun i => (P i).prefix n + crop := fun i => (P i).tailCrop N + coefficient := c + bound := hc + disjoint_active := fun i j hij => Finset.disjoint_left.mpr (fun w hw hw' => + Set.disjoint_left.mp (hdis hij) ((P i).tail_active_subset N n hw) + ((P j).tail_active_subset N n hw')) } + have he : ∀ n, (e n).value ∈ Full := fun n => f.norming_subset_full + ((e n).mem_family (fun i j k => (P i).children_mem j k)) + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro x + have ht : Tendsto (fun n => ∑ i, (c i : ℝ) * pathPartial (P i) n + (projection ((P i).tailCrop N) x)) atTop + (𝓝 (∑ i, (c i : ℝ) * pathTail (P i) N x)) := by + apply tendsto_finsetSum _ + intro i _ + exact tendsto_const_nhds.mul (pathPartial_tendsto (P i) _) + have hb : ∀ n, ‖∑ i, (c i : ℝ) * pathPartial (P i) n + (projection ((P i).tailCrop N) x)‖ ≤ ‖x‖ := by + intro n + have heq : norming.evaluateArray x (e n).value = ∑ i, (c i : ℝ) * + pathPartial (P i) n (projection ((P i).tailCrop N) x) := by + simp only [e, TypeII.value, map_sum, map_rat_smul, Rat.smul_def, + pathPartial_crop_apply] + rw [← heq, norming.evaluateArray_eq_functional x ⟨(e n).value, he n⟩] + exact PathLimits.unit_bound _ (norming.norm_functional_le _) x + simpa only [sum_apply, smul_apply, + smul_eq_mul, one_mul] using le_of_tendsto ht.norm (Eventually.of_forall hb) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PathOperators.lean b/lean/OAI/Analysis/SeparableQuotients/PathOperators.lean new file mode 100644 index 0000000000000000000000000000000000000000..d76419cebc34cb935616e1c7db65497f2f3a444d --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PathOperators.lean @@ -0,0 +1,236 @@ +import OAI.Analysis.SeparableQuotients.LpDuality + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming +open scoped ENNReal + +def Family.pathExponent (f : Family) : ℝ≥0∞ := ENNReal.ofReal f.q +lemma Family.q_gt_one (f : Family) : 1 < f.q := (Parameters.q_bounds f.s_ge_two).1 +lemma Family.q_pos (f : Family) : 0 < f.q := zero_lt_one.trans f.q_gt_one +instance Family.pathExponent_fact (f : Family) : Fact (1 ≤ f.pathExponent) := + ⟨by simpa [Family.pathExponent] using ENNReal.ofReal_le_ofReal f.q_gt_one.le⟩ +@[simp] lemma Family.pathExponent_real (f : Family) : f.pathExponent.toReal = f.q := + ENNReal.toReal_ofReal f.q_pos.le +lemma Family.pathExponent_pos (f : Family) : 0 < f.pathExponent.toReal := by simpa using f.q_pos +lemma Family.pathExponent_ne_top (f : Family) : f.pathExponent ≠ ∞ := ENNReal.ofReal_ne_top +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter +open scoped Classical Topology +@[reducible] local instance pathDualGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance pathDualSpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +abbrev W := (StrongDual ℝ E) ⧸ X₀ +@[reducible] local instance wGroup : NormedAddCommGroup W := inferInstance +@[reducible] local instance wSpace : NormedSpace ℝ W := inferInstance +local instance wComplete : CompleteSpace W := inferInstance + +def pathCoset {f : Family} (P : PathIndex f) : W := X₀.mkQL (pathFunctional P.repr) + +lemma coset_sum_bound {f : Family} {h : ℕ} (P : Fin h → PathIndex f) + (hinj : Function.Injective P) (c : Fin h → ℝ) : + ‖∑ i, c i • pathCoset (P i)‖ ≤ (∑ i, |c i|^f.q)^(1/f.q) := by + obtain ⟨N,hN⟩ := exists_tail_estimate (fun i => (P i).repr) + (PathIndex.repr_injective.comp hinj) + have he (i : Fin h) : pathCoset (P i) = X₀.mkQL (pathTail (P i).repr N) := by + apply (Submodule.Quotient.eq X₀).mpr + exact pathTail_complement_mem _ _ + simp_rw [he] + simp_rw [← map_smul] + rw [← map_sum] + exact (Submodule.Quotient.norm_mk_le _ _).trans (hN c) + +def finitePathMap (f : Family) : (PathIndex f →₀ ℝ) →ₗ[ℝ] W := + Finsupp.linearCombination ℝ pathCoset + +lemma finitePathMap_bound (f : Family) (c : PathIndex f →₀ ℝ) : + ‖finitePathMap f c‖ ≤ ‖LpCoding.finite f.pathExponent c‖ := by + let e : Fin c.support.card ≃ c.support := c.support.equivFin.symm + have h := coset_sum_bound (fun i => (e i).val) + (Subtype.val_injective.comp e.injective) (fun i => c (e i)) + have he : finitePathMap f c = ∑ i : Fin c.support.card, c (e i) • pathCoset (e i).val := by + change (∑ a ∈ c.support, c a • pathCoset a) = _ + rw [← Finset.sum_attach] + exact (e.sum_comp (fun a : c.support => c a • pathCoset a.val)).symm + have hs : (∑ a ∈ c.support, |c a|^f.q) = ∑ i, |c (e i)|^f.q := by + rw [← Finset.sum_attach] + exact (e.sum_comp (fun a : c.support => |c a|^f.q)).symm + rw [he,LpCoding.norm_finite f.pathExponent_pos,Family.pathExponent_real,hs] + exact h + +/-- A bounded path map constructed by completion of path cosets. -/ +def pathMap (f : Family) : lp (fun _ : PathIndex f => ℝ) f.pathExponent →L[ℝ] W := + (finitePathMap f).extendOfNorm (LpCoding.finite f.pathExponent) + +lemma norm_pathMap_le (f : Family) : ‖pathMap f‖ ≤ 1 := by + exact LinearMap.opNorm_extendOfNorm_le (f := finitePathMap f) + (e := LpCoding.finite f.pathExponent) + (LpCoding.finite_dense (ι := PathIndex f) (p := f.pathExponent) f.pathExponent_ne_top) + (by norm_num) (fun c => by simpa only [one_mul] using finitePathMap_bound f c) + +lemma pathMap_finite (f : Family) (c : PathIndex f →₀ ℝ) : + pathMap f (LpCoding.finite f.pathExponent c) = finitePathMap f c := by + exact LinearMap.extendOfNorm_eq (f := finitePathMap f) + (e := LpCoding.finite f.pathExponent) + (LpCoding.finite_dense (ι := PathIndex f) (p := f.pathExponent) f.pathExponent_ne_top) + ⟨1,fun c => by simpa only [one_mul] using finitePathMap_bound f c⟩ c + +@[simp] lemma pathMap_single (f : Family) (P : PathIndex f) (a : ℝ) : + pathMap f (lp.single f.pathExponent P a) = a • pathCoset P := by + rw [← LpCoding.finite_single,pathMap_finite] + simp [finitePathMap] + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open PathCoding CoherentClosures Cardinal +open scoped Classical Cardinal + +lemma rawPath_card_le (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) : + Cardinal.mk RawPath ≤ Cardinal.mk Γ := by + have hΓ : Cardinal.mk Γ = continuum := by + rw [show Cardinal.mk Γ = Cardinal.aleph 1 by simp [Γ,OmegaOne],← hCH,Cardinal.mk_real] + have hA : Cardinal.mk Array = continuum := by + rw [Cardinal.mk_finsupp_of_infinite Γ ℚ,hΓ] + simp [Cardinal.aleph0_le_continuum] + let code : RawPath → (ℕ → Array × ℕ × ℕ) := fun P n => (P.piece n,P.weight n,P.metadata n) + have hi : Function.Injective code := by + intro P Q h + apply RawPath.ext + · funext n; exact congrArg Prod.fst (congrFun h n) + · funext n; exact congrArg (fun x => x.2.1) (congrFun h n) + · funext n; exact congrArg (fun x => x.2.2) (congrFun h n) + calc + Cardinal.mk RawPath ≤ Cardinal.mk (ℕ → Array × ℕ × ℕ) := Cardinal.mk_le_of_injective hi + _ = continuum := by simp [Cardinal.mk_prod,hA] + _ = Cardinal.mk Γ := hΓ.symm + +lemma pathIndex_card_le (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) (f : Family) : + Cardinal.mk (PathIndex f) ≤ Cardinal.mk Γ := + (Cardinal.mk_subtype_le _).trans (rawPath_card_le hCH) + +def pathLabelBase (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) (f : Family) : PathIndex f ↪ Γ := + Classical.choice ((Cardinal.le_def _ _).mp (pathIndex_card_le hCH f)) + +def Family.index : Family → ℕ + | .mixed => 0 + | .pure k => k+1 + +lemma Family.index_injective : Function.Injective Family.index := by + intro f g h + cases f <;> cases g <;> simp_all [Family.index] + +def Family.sourceColor : Family → ℕ + | .mixed => 1 + | .pure k => k+1 + +/-- An inner color partitions the shared C₁ while retaining the outer color. -/ +def pathLabel (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) (f : Family) (P : PathIndex f) : Γ := + Colors.inColor f.sourceColor (Colors.inColor f.index (pathLabelBase hCH f P)) + +@[simp] lemma pathLabel_color (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) (f : Family) (P : PathIndex f) : + Colors.color (pathLabel hCH f P) = f.sourceColor := by + simp [pathLabel] + +lemma pathLabel_injective (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) : + Function.Injective (fun z : (f : Family) × PathIndex f => pathLabel hCH z.1 z.2) := by + rintro ⟨f,P⟩ ⟨g,Q⟩ h + have hi := congrArg (fun a => (Colors.partitionEquiv a).2) h + simp only [pathLabel,Colors.inColor,Equiv.apply_symm_apply] at hi + have hf : f=g := Family.index_injective (by + have hh := congrArg Colors.color hi + simpa [Colors.color] using hh) + subst g + have hp : P=Q := (pathLabelBase hCH f).injective + (Colors.inColor_injective _ hi) + cases hp + rfl + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open scoped ENNReal + +def Family.sourceExponent (f : Family) : ℝ≥0∞ := (Family.pure f.sourceColor).primalExponent +instance Family.sourceExponent_fact (f : Family) : Fact (1 ≤ f.sourceExponent) := + (Family.pure f.sourceColor).primalExponent_fact +@[simp] lemma Family.sourceExponent_real (f : Family) : f.sourceExponent.toReal = (f.s : ℝ)+1 := by + change ((Family.pure f.sourceColor).primalExponent).toReal = _ + rw [Family.primalExponent_toReal] + cases f <;> simp [Family.sourceColor,Family.s] <;> ring +lemma Family.sourceExponent_ne_top (f : Family) : f.sourceExponent ≠ ∞ := ENNReal.natCast_ne_top _ +lemma Family.pathConjugate (f : Family) : f.sourceExponent.toReal.HolderConjugate f.pathExponent.toReal := by + simpa only [Family.sourceExponent_real,Family.pathExponent_real,Family.q] using + Parameters.sNext_q_conjugate f.s_ge_two + +def pathLabelEmb (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) (f : Family) : PathIndex f ↪ Γ where + toFun := pathLabel hCH f + inj' _ _ h := (pathLabelBase hCH f).injective + (Colors.inColor_injective f.index (Colors.inColor_injective f.sourceColor h)) + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter +open scoped Classical Topology + +variable (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) + +def finiteLabelMap (f : Family) : (PathIndex f →₀ ℝ) →ₗ[ℝ] E := + norming.includeFinite.comp (Finsupp.lmapDomain ℝ ℝ (pathLabel hCH f)) + +lemma finiteLabelMap_eq (f : Family) (c : PathIndex f →₀ ℝ) : + finiteLabelMap hCH f c = norming.includeFinite (c.embDomain (pathLabelEmb hCH f)) := by + rw [Finsupp.embDomain_eq_mapDomain] + rfl + +lemma finiteLabelMap_bound (f : Family) (c : PathIndex f →₀ ℝ) : + ‖finiteLabelMap hCH f c‖ ≤ ‖LpCoding.finite f.sourceExponent c‖ := by + rw [finiteLabelMap_eq] + calc + _ ≤ ‖LpFinite.realArray f.sourceExponent (c.embDomain (pathLabelEmb hCH f))‖ := by + apply norm_includeFinite_on_color + intro a ha + rw [Finsupp.support_embDomain] at ha + obtain ⟨i,hi,rfl⟩ := Finset.mem_map.mp ha + exact pathLabel_color hCH f i + _ = _ := by + change ‖LpCoding.finite f.sourceExponent (c.embDomain (pathLabelEmb hCH f))‖ = _ + rw [LpCoding.norm_finite f.pathConjugate.pos,LpCoding.norm_finite f.pathConjugate.pos, + Finsupp.support_embDomain,Finset.sum_map] + simp only [Finsupp.embDomain_apply_self] + +/-- The color synthesis operator. -/ +def labelMap (f : Family) : lp (fun _ : PathIndex f => ℝ) f.sourceExponent →L[ℝ] E := + (finiteLabelMap hCH f).extendOfNorm (LpCoding.finite f.sourceExponent) + +lemma norm_labelMap_le (f : Family) : ‖labelMap hCH f‖ ≤ 1 := by + exact LinearMap.opNorm_extendOfNorm_le (f := finiteLabelMap hCH f) + (e := LpCoding.finite f.sourceExponent) + (LpCoding.finite_dense (ι := PathIndex f) (p := f.sourceExponent) f.sourceExponent_ne_top) + (by norm_num) (fun c => by simpa only [one_mul] using finiteLabelMap_bound hCH f c) + +lemma labelMap_finite (f : Family) (c : PathIndex f →₀ ℝ) : + labelMap hCH f (LpCoding.finite f.sourceExponent c) = finiteLabelMap hCH f c := by + exact LinearMap.extendOfNorm_eq (f := finiteLabelMap hCH f) + (e := LpCoding.finite f.sourceExponent) + (LpCoding.finite_dense (ι := PathIndex f) (p := f.sourceExponent) f.sourceExponent_ne_top) + ⟨1,fun c => by simpa only [one_mul] using finiteLabelMap_bound hCH f c⟩ c + +@[simp] lemma labelMap_single (f : Family) (P : PathIndex f) (a : ℝ) : + labelMap hCH f (lp.single f.sourceExponent P a) = a • e (pathLabel hCH f P) := by + rw [← LpCoding.finite_single,labelMap_finite,finiteLabelMap_eq,Finsupp.embDomain_single] + change norming.includeFinite (Finsupp.single (pathLabel hCH f P) a) = _ + have hs : Finsupp.single (pathLabel hCH f P) a = a • Finsupp.single (pathLabel hCH f P) (1 : ℝ) := by + simp + rw [hs,map_smul] + rfl + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PathRigidity.lean b/lean/OAI/Analysis/SeparableQuotients/PathRigidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..75b8c09ddb8d146f5b0dc2dc4c325f9206dfd65d --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PathRigidity.lean @@ -0,0 +1,454 @@ +import OAI.Analysis.SeparableQuotients.PathStabilization + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming +open PathCoding +open scoped Classical + +/-- Legal crop selecting an interval of original weights, without recoding. -/ +def FinitePath.weightCrop {f : Family} (P : FinitePath f) (J T : ℕ) : Crop where + ordinal := {a | (∀ i : Fin P.length, P.raw.weight i < J → ∀ b ∈ (P.raw.piece i).support, b < a) ∧ + (∀ i : Fin P.length, T < P.raw.weight i → ∀ b ∈ (P.raw.piece i).support, a < b)} + ordinal_convex := ⟨by + intro a ha b hb z hz + exact ⟨fun i hi x hx => (ha.1 i hi x hx).trans_le hz.1, + fun i hi x hx => hz.2.trans_lt (hb.2 i hi x hx)⟩⟩ + colors := Set.univ + colors_convex := Set.ordConnected_univ + +lemma FinitePath.weightCrop_set {f : Family} (P : FinitePath f) (J T : ℕ) : + (P.weightCrop J T).set f = (P.weightCrop J T).ordinal := by + cases f <;> simp only [Crop.set, weightCrop, Set.preimage_univ, Set.inter_univ] + +lemma FinitePath.weightCrop_piece {f : Family} (P : FinitePath f) (J T : ℕ) (i : Fin P.length) : + restrict ((P.weightCrop J T).set f) (P.raw.piece i) = + if J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T then P.raw.piece i else 0 := by + rw [P.weightCrop_set] + ext a + rw [restrict_apply] + by_cases hi : J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T + · rw [ite_eq_left hi] + by_cases hia : P.raw.piece i a = 0 + · simp only [hia, ite_self] + · have ha : a ∈ (P.weightCrop J T).ordinal := by + refine ⟨fun j hj b hb => ?_, fun j hj b hb => ?_⟩ + · have hji : j < i := P.valid.weight_strict.lt_iff_lt.mp (hj.trans_le hi.1) + exact P.valid.successive j i hji i.isLt b hb a (Finsupp.mem_support_iff.mpr hia) + · have hij : i < j := P.valid.weight_strict.lt_iff_lt.mp (hi.2.trans_lt hj) + exact P.valid.successive i j hij j.isLt a (Finsupp.mem_support_iff.mpr hia) b hb + rw [ite_eq_left ha] + · rw [ite_eq_right hi] + by_cases hia : P.raw.piece i a = 0 + · simp only [hia, ite_self, Finsupp.zero_apply] + · have ha : a ∉ (P.weightCrop J T).ordinal := by + intro ha + rcases lt_or_ge (P.raw.weight i) J with h | h + · exact (lt_irrefl a) (ha.1 i h a (Finsupp.mem_support_iff.mpr hia)) + · have ht : T < P.raw.weight i := lt_of_not_ge (fun hh => hi ⟨h, hh⟩) + exact (lt_irrefl a) (ha.2 i ht a (Finsupp.mem_support_iff.mpr hia)) + simp only [ite_eq_right ha, Finsupp.zero_apply] + +def FinitePath.window {f : Family} (P : FinitePath f) (J T : ℕ) : Array := + ∑ i : Fin P.length, if J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T then P.raw.piece i else 0 + +def FinitePath.windowWeights {f : Family} (P : FinitePath f) (J T : ℕ) : Finset ℕ := + (Finset.univ.filter (fun i : Fin P.length => J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T)).image + (fun i : Fin P.length => P.raw.weight i) + +lemma FinitePath.weightCrop_value {f : Family} (P : FinitePath f) (J T : ℕ) : + restrict ((P.weightCrop J T).set f) P.value = P.window J T := by + simp only [FinitePath.value, restrict_sum, P.weightCrop_piece, window] + +lemma FinitePath.weightCrop_active {f : Family} (P : FinitePath f) (J T : ℕ) : + P.active (P.weightCrop J T) = P.windowWeights J T := by + unfold active windowWeights + apply congrArg (Finset.image (fun i : Fin P.length => P.raw.weight i)) + ext i + simp only [Finset.mem_filter, Finset.mem_univ, true_and, P.weightCrop_piece] + split_ifs with hi + · exact iff_of_true (P.raw.nonzero i) hi + · exact iff_of_false (by simp) hi + +lemma FinitePath.mem_windowWeights {f : Family} (P : FinitePath f) (J T w : ℕ) : + w ∈ P.windowWeights J T ↔ J ≤ w ∧ w ≤ T ∧ ∃ i : Fin P.length, P.raw.weight i = w := by + simp only [windowWeights, Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · rintro ⟨i, hi, rfl⟩ + exact ⟨hi.1, hi.2, i, rfl⟩ + · rintro ⟨hJ, hT, i, rfl⟩ + exact ⟨i, ⟨hJ, hT⟩, rfl⟩ + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology +@[reducible] local instance dualEGroup13 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace13 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance + +def croppedPathFunctional {f : Family} (P : FinitePath f) (A : Crop) : StrongDual ℝ E := + (norming.rationalPredual (restrict (A.set f) P.value)).val + +lemma rational_cropped_path_bound {f : Family} {h : ℕ} (P : Fin h → FinitePath f) + (A : Fin h → Crop) (hm : ∀ b i j, ((P b).piece i).child j ∈ f.norming) + (hdis : Pairwise (fun i j => Disjoint ((P i).active (A i)) ((P j).active (A j)))) + (c : Fin h → ℚ) (hc : ∑ i, |(c i : ℝ)| ^ f.q ≤ 1) : + ‖∑ i, (c i : ℝ) • croppedPathFunctional (P i) (A i)‖ ≤ 1 := by + let e : TypeII f := ⟨h, P, A, c, hc, hdis⟩ + have he : e.value ∈ Full := f.norming_subset_full (e.mem_family hm) + have heq : norming.functional ⟨e.value, he⟩ = + ∑ i, (c i : ℝ) • croppedPathFunctional (P i) (A i) := by + ext x + rw [← norming.evaluateArray_eq_functional] + simp only [e, TypeII.value, map_sum, map_rat_smul, Rat.smul_def, + sum_apply, smul_apply, smul_eq_mul, croppedPathFunctional, NormingSet.evaluateArray] + rfl + rw [← heq] + exact norming.norm_functional_le _ + +lemma real_cropped_path_bound {f : Family} {h : ℕ} (P : Fin h → FinitePath f) + (A : Fin h → Crop) (hm : ∀ b i j, ((P b).piece i).child j ∈ f.norming) + (hdis : Pairwise (fun i j => Disjoint ((P i).active (A i)) ((P j).active (A j)))) + (c : Fin h → ℝ) : + ‖∑ i, c i • croppedPathFunctional (P i) (A i)‖ ≤ (∑ i, |c i| ^ f.q) ^ (1/f.q) := by + have hq : 0 < f.q := lt_trans zero_lt_one (Parameters.q_bounds f.s_ge_two).1 + apply RealCoefficients.bound_from_unit f.q hq + exact RealCoefficients.rational_to_real f.q hq _ (rational_cropped_path_bound P A hm hdis) + +lemma cropped_abs_sum_bound {f : Family} {h : ℕ} (P : Fin h → FinitePath f) + (A : Fin h → Crop) (hm : ∀ b i j, ((P b).piece i).child j ∈ f.norming) + (hdis : Pairwise (fun i j => Disjoint ((P i).active (A i)) ((P j).active (A j)))) (x : E) : + (∑ i, |croppedPathFunctional (P i) (A i) x|) ≤ (h : ℝ) ^ (1/f.q) * ‖x‖ := by + let c : Fin h → ℝ := fun i => RealCoefficients.signChoice (croppedPathFunctional (P i) (A i) x) + have hc (i : Fin h) : |c i| = 1 := RealCoefficients.abs_signChoice _ + have hv (i : Fin h) : c i * croppedPathFunctional (P i) (A i) x = + |croppedPathFunctional (P i) (A i) x| := RealCoefficients.signChoice_mul _ + have he : (∑ i, c i • croppedPathFunctional (P i) (A i)) x = + ∑ i, |croppedPathFunctional (P i) (A i) x| := by + simp only [sum_apply, smul_apply, smul_eq_mul, hv] + calc + _ = |(∑ i, c i • croppedPathFunctional (P i) (A i)) x| := by + rw [he, abs_of_nonneg (Finset.sum_nonneg (fun i _ => abs_nonneg _))] + _ ≤ ‖∑ i, c i • croppedPathFunctional (P i) (A i)‖ * ‖x‖ := + by simpa only [Real.norm_eq_abs] using (∑ i, c i • croppedPathFunctional (P i) (A i)).le_opNorm x + _ ≤ _ := mul_le_mul_of_nonneg_right (by simpa only [hc, Real.one_rpow, + Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] + using (real_cropped_path_bound P A hm hdis c)) (norm_nonneg _) + +lemma window_disjoint_cap {f : Family} (M δ : ℝ) (hδ : 0 < δ) : + ∃ K : ℕ, ∀ (h : ℕ) (P : Fin h → FinitePath f) (J T : ℕ) (x : E), + (∀ b i j, ((P b).piece i).child j ∈ f.norming) → + Pairwise (fun i j => Disjoint ((P i).windowWeights J T) ((P j).windowWeights J T)) → + ‖x‖ ≤ M → (∀ b, δ < |norming.evaluateArray x ((P b).window J T)|) → h ≤ K := by + have hq : 1 < f.q := (Parameters.q_bounds f.s_ge_two).1 + obtain ⟨K, hK⟩ := PathSelection.power_cap (1/f.q) M δ + ((div_lt_one (by linarith)).mpr (by linarith)) hδ + refine ⟨K, fun h P J T x hm hdis hx hh => hK h ?_⟩ + have he (b : Fin h) : croppedPathFunctional (P b) ((P b).weightCrop J T) x = + norming.evaluateArray x ((P b).window J T) := by + simp only [croppedPathFunctional, (P b).weightCrop_value, NormingSet.evaluateArray] + rfl + calc + δ * (h : ℝ) = ∑ _b : Fin h, δ := by simp [mul_comm] + _ ≤ ∑ b, |croppedPathFunctional (P b) ((P b).weightCrop J T) x| := + Finset.sum_le_sum (fun b _ => by rw [he b]; exact (hh b).le) + _ ≤ (h : ℝ) ^ (1/f.q) * ‖x‖ := cropped_abs_sum_bound P _ hm + (by simpa only [FinitePath.weightCrop_active] using hdis) x + _ ≤ M * (h : ℝ) ^ (1/f.q) := by + simpa only [mul_comm] using mul_le_mul_of_nonneg_left hx (Real.rpow_nonneg (Nat.cast_nonneg _) _) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open PathCoding CoherentClosures +open scoped Classical + +/-- Actual pieces, original weights, and original metadata below a threshold. +This is deliberately not the compressed history, nor a cropped code. -/ +def FinitePath.lowHistory {f : Family} (P : FinitePath f) (J : ℕ) : Set (Array × ℕ × ℕ) := + {d | d.2.1 < J ∧ ∃ i : Fin P.length, + d = (P.raw.piece i, P.raw.weight i, P.raw.metadata i)} + +lemma PrefixValid.metadata_mono {P : RawPath} {len : ℕ} (hP : PrefixValid P len) + {i j : ℕ} (hij : i ≤ j) (hj : j < len) : P.metadata i ≤ P.metadata j := by + rcases hij.eq_or_lt with rfl | h + · exact le_rfl + · exact (hP.metadata_strict i j h hj).le + +lemma FinitePath.code_of_shared_weight {f : Family} (P Q : FinitePath f) + (i : Fin P.length) (j : Fin Q.length) (hi : 0 < i.val) (hj : 0 < j.val) + (hw : P.raw.weight i = Q.raw.weight j) : + i.val = j.val ∧ P.raw.code (i.val-1) = Q.raw.code (i.val-1) := by + have hc : P.raw.code (i.val-1) = Q.raw.code (j.val-1) := by + apply sigma_injective + rw [← P.valid.rule (i.val-1) (by omega), ← Q.valid.rule (j.val-1) (by omega)] + simpa only [Nat.sub_add_cancel (by omega : 1 ≤ i.val), + Nat.sub_add_cancel (by omega : 1 ≤ j.val)] using hw + have heq := RawPath.code_eq_length hc + have hij : i.val = j.val := by omega + exact ⟨hij, by simpa only [hij] using hc⟩ + +lemma closure_downward_rho (β a b : Γ) (p : ℕ) (hp : 1 ≤ p) + (hab : a ≤ b) (hb : b ∈ F β p) (hr : rho a b ≤ p) : a ∈ F β p := by + have ha := (rho_le_iff a b hab p hp).mp hr + rw [F_coherent β b p hb] at ha + exact (Finset.mem_filter.mp ha).1 + +/-- Two agreeing compressed histories whose later pieces meet one finite +coordinate set with sufficiently small rho have identical actual earlier +pieces. The anchors may be different coordinates and different pieces. -/ +lemma PrefixValid.low_piece_eq_of_anchors {P Q : RawPath} {len len' n i j k : ℕ} + (hP : PrefixValid P len) (hQ : PrefixValid Q len') + (hn : n < len) (hn' : n < len') (hc : P.code n = Q.code n) + (hij : i < j) (hik : i < k) (hjn : j ≤ n) (hkn : k ≤ n) + (a b : Γ) (ha : a ∈ (P.piece j).support) (hb : b ∈ (Q.piece k).support) + (hr : rho (min a b) (max a b) ≤ P.metadata n) : P.piece i = Q.piece i := by + have hm := (RawPath.code_eq_at hc n le_rfl).2.1 + rcases le_total a b with hab | hba + · have haQ : a ∈ Q.closure n := by + have hbQ := hQ.piece_support_subset_closure hkn hn' hb + unfold RawPath.closure at hbQ ⊢ + apply closure_downward_rho _ a b _ (hQ.metadata_pos n hn') hab hbQ + simpa only [min_eq_left hab, max_eq_right hab, hm] using hr + exact hP.piece_eq_of_code_anchor hQ hn hn' hij hjn hc a ha haQ + · have hbP : b ∈ P.closure n := by + have haP := hP.piece_support_subset_closure hjn hn ha + unfold RawPath.closure at haP ⊢ + apply closure_downward_rho _ b a _ (hP.metadata_pos n hn) hba haP + simpa only [min_eq_right hba, max_eq_left hba] using hr + exact (hQ.piece_eq_of_code_anchor hP hn' hn hik hkn hc.symm b hb hbP).symm + +lemma FinitePath.lowHistory_eq_of_code_anchors {f : Family} (P Q : FinitePath f) + (J n : ℕ) (hn : n < P.length) (hn' : n < Q.length) (hc : P.raw.code n = Q.raw.code n) + (j : Fin P.length) (k : Fin Q.length) (hjn : j.val ≤ n) (hkn : k.val ≤ n) + (hj : J ≤ P.raw.weight j) (hk : J ≤ Q.raw.weight k) + (a b : Γ) (ha : a ∈ (P.raw.piece j).support) (hb : b ∈ (Q.raw.piece k).support) + (hr : rho (min a b) (max a b) ≤ P.raw.metadata n) : P.lowHistory J = Q.lowHistory J := by + have hleft (i : Fin P.length) (hi : P.raw.weight i < J) : + ∃ i' : Fin Q.length, P.raw.piece i = Q.raw.piece i' ∧ + P.raw.weight i = Q.raw.weight i' ∧ P.raw.metadata i = Q.raw.metadata i' := by + have hij : i < j := P.valid.weight_strict.lt_iff_lt.mp (hi.trans_le hj) + have hin : i.val ≤ n := (show i.val ≤ j.val from hij.le).trans hjn + let i' : Fin Q.length := ⟨i.val, hin.trans_lt hn'⟩ + have he := RawPath.code_eq_at hc i hin + have hik : i' < k := Q.valid.weight_strict.lt_iff_lt.mp + (by change Q.raw.weight i < Q.raw.weight k; rw [← he.1]; exact hi.trans_le hk) + exact ⟨i', P.valid.low_piece_eq_of_anchors Q.valid hn hn' hc hij hik hjn hkn a b ha hb hr, + he.1, he.2.1⟩ + have hright (i : Fin Q.length) (hi : Q.raw.weight i < J) : + ∃ i' : Fin P.length, Q.raw.piece i = P.raw.piece i' ∧ + Q.raw.weight i = P.raw.weight i' ∧ Q.raw.metadata i = P.raw.metadata i' := by + have hik : i < k := Q.valid.weight_strict.lt_iff_lt.mp (hi.trans_le hk) + have hin : i.val ≤ n := (show i.val ≤ k.val from hik.le).trans hkn + let i' : Fin P.length := ⟨i.val, hin.trans_lt hn⟩ + have he := RawPath.code_eq_at hc i hin + have hij : i' < j := P.valid.weight_strict.lt_iff_lt.mp + (by change P.raw.weight i < P.raw.weight j; rw [he.1]; exact hi.trans_le hj) + exact ⟨i', (P.valid.low_piece_eq_of_anchors Q.valid hn hn' hc hij hik hjn hkn a b ha hb hr).symm, + he.1.symm, he.2.1.symm⟩ + ext d + constructor + · rintro ⟨hd, i, rfl⟩ + obtain ⟨i', hp, hw, hm⟩ := hleft i hd + exact ⟨hd, i', by rw [hp, hw, hm]⟩ + · rintro ⟨hd, i, rfl⟩ + obtain ⟨i', hp, hw, hm⟩ := hright i hd + exact ⟨hd, i', by rw [hp, hw, hm]⟩ + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open PathCoding CoherentClosures +open scoped Classical + +lemma FinitePath.lowHistory_eq_of_shared_later_weight {f : Family} (P Q : FinitePath f) + (Jv Tv Jt Tt Jk Tk : ℕ) (hvt : Tv < Jt) (htk : Tt < Jk) + (j : Fin P.length) (k : Fin Q.length) (t : Fin P.length) + (hj : Jv ≤ P.raw.weight j ∧ P.raw.weight j ≤ Tv) + (hk : Jv ≤ Q.raw.weight k ∧ Q.raw.weight k ≤ Tv) + (ht : Jt ≤ P.raw.weight t ∧ P.raw.weight t ≤ Tt) + (a b : Γ) (ha : a ∈ (P.raw.piece j).support) (hb : b ∈ (Q.raw.piece k).support) + (hr : rho (min a b) (max a b) ≤ Jt) + (hw : ∃ w, w ∈ P.windowWeights Jk Tk ∧ w ∈ Q.windowWeights Jk Tk) : + P.lowHistory Jv = Q.lowHistory Jv := by + obtain ⟨w, hwP, hwQ⟩ := hw + obtain ⟨hwJ, _, i, hei⟩ := (P.mem_windowWeights Jk Tk w).mp hwP + obtain ⟨_, _, i', hei'⟩ := (Q.mem_windowWeights Jk Tk w).mp hwQ + have htw : P.raw.weight t < P.raw.weight i := by omega + have hti : t < i := P.valid.weight_strict.lt_iff_lt.mp htw + have htJ : Jt ≤ Tt := ht.1.trans ht.2 + have hji : j < i := P.valid.weight_strict.lt_iff_lt.mp (by omega) + have hki' : k < i' := Q.valid.weight_strict.lt_iff_lt.mp (by omega) + have hi : 0 < i.val := (Nat.zero_le t.val).trans_lt hti + have hi' : 0 < i'.val := (Nat.zero_le k.val).trans_lt hki' + obtain ⟨he, hc⟩ := P.code_of_shared_weight Q i i' hi hi' (hei.trans hei'.symm) + have hn : i.val - 1 < P.length := by omega + have hn' : i.val - 1 < Q.length := by have := i'.isLt; omega + have htn : t.val ≤ i.val - 1 := by omega + have hmn : Jt ≤ P.raw.metadata (i.val-1) := ht.1.trans + ((P.valid.weight_le_metadata t t.isLt).trans (P.valid.metadata_mono htn hn)) + exact P.lowHistory_eq_of_code_anchors Q Jv (i.val-1) hn hn' hc j k + (by omega) (by omega) hj.1 hk.1 a b ha hb (hr.trans hmn) + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open PathCoding +open scoped Classical + +def FinitePath.lowHistoryFinset {f : Family} (P : FinitePath f) (J : ℕ) : Finset (Array × ℕ × ℕ) := + (Finset.univ.filter (fun i : Fin P.length => P.raw.weight i < J)).image + (fun i : Fin P.length => (P.raw.piece i, P.raw.weight i, P.raw.metadata i)) + +lemma FinitePath.mem_lowHistoryFinset {f : Family} (P : FinitePath f) (J : ℕ) + (d : Array × ℕ × ℕ) : d ∈ P.lowHistoryFinset J ↔ d ∈ P.lowHistory J := by + simp only [lowHistoryFinset, Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and, + lowHistory, Set.mem_ofPred_eq] + constructor + · rintro ⟨i, hi, rfl⟩ + exact ⟨hi, i, rfl⟩ + · rintro ⟨hd, i, rfl⟩ + exact ⟨i, hd, rfl⟩ + +lemma FinitePath.window_eq_sum_lowHistory {f : Family} (P : FinitePath f) (J T H : ℕ) + (hT : T < H) : P.window J T = + ∑ d ∈ P.lowHistoryFinset H, if J ≤ d.2.1 ∧ d.2.1 ≤ T then d.1 else 0 := by + rw [lowHistoryFinset, Finset.sum_image] + · rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro i _ + by_cases hi : J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T + · simp only [hi, and_self, ite_true, ite_eq_left (hi.2.trans_lt hT)] + · simp only [hi, ite_false, ite_self] + · intro i _ j _ he + apply P.valid.weight_strict.injective + exact congrArg (fun d : Array × ℕ × ℕ => d.2.1) he + +lemma FinitePath.window_eq_of_lowHistory {f : Family} (P Q : FinitePath f) (J T H : ℕ) + (hT : T < H) (he : P.lowHistory H = Q.lowHistory H) : P.window J T = Q.window J T := by + have hf : P.lowHistoryFinset H = Q.lowHistoryFinset H := by + ext d + rw [P.mem_lowHistoryFinset, Q.mem_lowHistoryFinset, he] + rw [P.window_eq_sum_lowHistory J T H hT, Q.window_eq_sum_lowHistory J T H hT, hf] + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +/-- A finite path with its original finite-stage children. -/ +def LegalFinitePath (f : Family) := {P : FinitePath f // ∀ i j, (P.piece i).child j ∈ f.norming} + +def WindowHit {f : Family} (P : LegalFinitePath f) (x : Γ →₀ ℝ) (J T : ℕ) (δ : ℝ) : Prop := + δ < |norming.evaluateArray (norming.includeFinite x) (P.val.window J T)| + +lemma window_anchor {f : Family} (P : FinitePath f) (x : Γ →₀ ℝ) (J T : ℕ) + (hh : norming.evaluateArray (norming.includeFinite x) (P.window J T) ≠ 0) : + ∃ i : Fin P.length, J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T ∧ + ∃ a ∈ x.support, a ∈ (P.raw.piece i).support := by + simp only [FinitePath.window, map_sum] at hh + obtain ⟨i, _, hi⟩ := Finset.exists_ne_zero_of_sum_ne_zero hh + have hw : J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T := by + by_contra hn + simp only [ite_eq_right hn, map_zero, ne_eq, not_true_eq_false] at hi + rw [ite_eq_left hw, norming.evaluateArray_eq] at hi + obtain ⟨a, ha, hh⟩ := Finset.exists_ne_zero_of_sum_ne_zero hi + refine ⟨i, hw.1, hw.2, a, ?_, ha⟩ + rw [norming.coordinate_includeFinite] at hh + exact Finsupp.mem_support_iff.mpr (fun hz => hh (by rw [hz, mul_zero])) + +lemma WindowHit.anchor {f : Family} {P : LegalFinitePath f} {x : Γ →₀ ℝ} + {J T : ℕ} {δ : ℝ} (hδ : 0 < δ) (hh : WindowHit P x J T δ) : + ∃ i : Fin P.val.length, J ≤ P.val.raw.weight i ∧ P.val.raw.weight i ≤ T ∧ + ∃ a ∈ x.support, a ∈ (P.val.raw.piece i).support := by + apply window_anchor + exact abs_pos.mp (hδ.trans hh) + +/-- Rigidity of two path histories with shared later weights. -/ +lemma disjoint_of_different_histories {f : Family} (P Q : LegalFinitePath f) + (x : Γ →₀ ℝ) (Jv Tv Jt Tt Jk Tk : ℕ) (hvt : Tv < Jt) (htk : Tt < Jk) + (δ : ℝ) (hδ : 0 < δ) + (hp : WindowHit P x Jv Tv δ) (hq : WindowHit Q x Jv Tv δ) + (ht : ∃ t : Fin P.val.length, Jt ≤ P.val.raw.weight t ∧ P.val.raw.weight t ≤ Tt) + (hr : ∀ a ∈ x.support, ∀ b ∈ x.support, rho (min a b) (max a b) ≤ Jt) + (hne : P.val.lowHistory Jv ≠ Q.val.lowHistory Jv) : + Disjoint (P.val.windowWeights Jk Tk) (Q.val.windowWeights Jk Tk) := by + obtain ⟨j, hj, hj', a, ha, ha'⟩ := hp.anchor hδ + obtain ⟨k, hk, hk', b, hb, hb'⟩ := hq.anchor hδ + obtain ⟨t, ht, ht'⟩ := ht + apply Finset.disjoint_left.mpr + intro w hw hw' + exact hne (P.val.lowHistory_eq_of_shared_later_weight Q.val Jv Tv Jt Tt Jk Tk hvt htk + j k t ⟨hj, hj'⟩ ⟨hk, hk'⟩ ⟨ht, ht'⟩ a b ha' hb' (hr a ha b hb) ⟨w, hw, hw'⟩) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +/-- Uniform finite covers from the history-class argument. -/ +lemma finite_window_covers {f : Family} (x : ℕ → Γ →₀ ℝ) (J T : ℕ → ℕ) + (horder : ∀ i j, i < j → T i < J j) + (hcoh : ∀ i j, i < j → ∀ a ∈ (x i).support, ∀ b ∈ (x i).support, + rho (min a b) (max a b) ≤ J j) + (M δ : ℝ) (hM : ∀ i, ‖norming.includeFinite (x i)‖ ≤ M) (hδ : 0 < δ) + (hall : ∀ w v t k : ℕ, w < v → v < t → t < k → + ∃ P : LegalFinitePath f, WindowHit P (x w) (J w) (T w) δ ∧ + WindowHit P (x v) (J v) (T v) δ ∧ WindowHit P (x t) (J t) (T t) δ ∧ + WindowHit P (x k) (J k) (T k) δ) : + ∃ D : ℕ, ∀ n, ∃ R : Finset (LegalFinitePath f), R.card ≤ D ∧ + ∀ i ≤ n, ∃ P ∈ R, WindowHit P (x i) (J i) (T i) δ := by + obtain ⟨D, hD⟩ := window_disjoint_cap (f := f) M δ hδ + refine ⟨D, fun n => ?_⟩ + have hex (i : Fin (n+1)) := hall i (n+1) (n+2) (n+3) i.isLt (by omega) (by omega) + choose P hP using hex + let H : Fin (n+1) → Set (Array × ℕ × ℕ) := fun i => (P i).val.lowHistory (J (n+1)) + let S : Finset (Set (Array × ℕ × ℕ)) := Finset.univ.image H + have hrep (d : S) : ∃ i : Fin (n+1), H i = d.val := by + obtain ⟨i, _, hi⟩ := Finset.mem_image.mp d.property + exact ⟨i, hi⟩ + let rep : S → Fin (n+1) := fun d => (hrep d).choose + have hr (d : S) : H (rep d) = d.val := (hrep d).choose_spec + let e : Fin S.card ≃ S := S.equivFin.symm + let Q : Fin S.card → LegalFinitePath f := fun b => P (rep (e b)) + have hQ (b : Fin S.card) : (Q b).val.lowHistory (J (n+1)) = (e b).val := hr (e b) + have hcard : S.card ≤ D := by + apply hD S.card (fun b => (Q b).val) (J (n+3)) (T (n+3)) (norming.includeFinite (x (n+3))) + (fun b => (Q b).property) + · intro b c hbc + apply disjoint_of_different_histories (Q b) (Q c) (x (n+1)) (J (n+1)) (T (n+1)) + (J (n+2)) (T (n+2)) (J (n+3)) (T (n+3)) (horder _ _ (by omega)) + (horder _ _ (by omega)) δ hδ + · exact (hP _).2.1 + · exact (hP _).2.1 + · obtain ⟨i, hi, hi', a, ha, ha'⟩ := ((hP (rep (e b))).2.2.1).anchor hδ + exact ⟨i, hi, hi'⟩ + · exact hcoh _ _ (by omega) + · rw [hQ, hQ] + exact fun hh => hbc (e.injective (Subtype.ext hh)) + · exact hM (n+3) + · intro b + exact (hP (rep (e b))).2.2.2 + refine ⟨Finset.univ.image Q, (Finset.card_image_le).trans (by simpa using hcard), fun i hi => ?_⟩ + let ii : Fin (n+1) := ⟨i, by omega⟩ + let d : S := ⟨H ii, Finset.mem_image.mpr ⟨ii, Finset.mem_univ _, rfl⟩⟩ + let b := e.symm d + have hh : (Q b).val.lowHistory (J (n+1)) = (P ii).val.lowHistory (J (n+1)) := by + rw [hQ] + exact congrArg Subtype.val (e.apply_symm_apply d) + refine ⟨Q b, Finset.mem_image.mpr ⟨b, Finset.mem_univ _, rfl⟩, ?_⟩ + change δ < |norming.evaluateArray _ ((Q b).val.window (J i) (T i))| + rw [(Q b).val.window_eq_of_lowHistory (P ii).val (J i) (T i) (J (n+1)) + (horder i (n+1) (by omega)) hh] + exact (hP ii).1 + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PathStabilization.lean b/lean/OAI/Analysis/SeparableQuotients/PathStabilization.lean new file mode 100644 index 0000000000000000000000000000000000000000..7395ebcfe551fda8b3da42289680a7e20c617c33 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PathStabilization.lean @@ -0,0 +1,489 @@ +import OAI.Analysis.SeparableQuotients.PathConvergence + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.DiscreteDiagonal +open Filter +open scoped Topology Classical + +/-- Countably many yes/no tests can be made eventually constant by one +subsequence. The index set is arbitrary countable, not just natural numbers. -/ +lemma exists_stabilizing_subsequence {ι : Type*} [Countable ι] (p : ℕ → ι → Prop) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ i, ∃ b : Prop, + ∀ᶠ n in atTop, p (φ n) i ↔ b := by + let x : ℕ → ι → Bool := fun n i => decide (p n i) + obtain ⟨y, _, φ, hφ, hy⟩ := isCompact_univ.tendsto_subseq + (x := x) (fun _ => Set.mem_univ _) + refine ⟨φ, hφ, fun i => ⟨y i = true, ?_⟩⟩ + have ht := (tendsto_pi_nhds.mp hy) i + have he : ∀ᶠ n in atTop, x (φ n) i = y i := + (by simpa only [nhds_discrete, tendsto_pure, Function.comp_apply] using ht) + filter_upwards [he] with n hn + change decide (p (φ n) i) = y i at hn + rw [← hn, decide_eq_true_eq] + +end SeparableQuotient.DiscreteDiagonal + +namespace SeparableQuotient.IncreasingLists +open Filter +open scoped Classical + +/-- Pointwise stabilization of membership in increasing finite lists, with an +infinite limiting set, stabilizes every list position. -/ +lemma positions_stabilize (len : ℕ → ℕ) (v : ℕ → ℕ → ℕ) + (hv : ∀ n, StrictMono (fun i : Fin (len n) => v n i)) (W : Set ℕ) + (hW : W.Infinite) + (hmem : ∀ w, ∀ᶠ n in atTop, (∃ i < len n, v n i = w) ↔ w ∈ W) : + ∀ i, ∀ᶠ n in atTop, i < len n ∧ v n i = Nat.nth (· ∈ W) i := by + intro i + induction i using Nat.strong_induction_on with + | h i ih => + let w := Nat.nth (· ∈ W) i + have hwi : w ∈ W := Nat.nth_mem_of_infinite hW i + have hsmall : ∀ᶠ n in atTop, ∀ u ≤ w, + (∃ k < len n, v n k = u) ↔ u ∈ W := by + simpa only [Finset.mem_range, Nat.lt_succ_iff] using + (eventually_all_finset (I := Finset.range (w+1))).mpr (fun u _ => hmem u) + have hprev : ∀ᶠ n in atTop, ∀ j < i, + j < len n ∧ v n j = Nat.nth (· ∈ W) j := by + simpa only [Finset.mem_range] using + (eventually_all_finset (I := Finset.range i)).mpr (fun j hj => ih j (Finset.mem_range.mp hj)) + filter_upwards [hsmall, hprev] with n hn hp + obtain ⟨k, hk, hkw⟩ := (hn w le_rfl).mpr hwi + have hki : k = i := by + rcases lt_trichotomy k i with h | h | h + · have he := (hp k h).2.symm.trans hkw + exact ((Nat.nth_injective hW he).not_lt h).elim + · exact h + · have hi : i < len n := h.trans hk + have hiv : v n i < w := (hv n (show (⟨i, hi⟩ : Fin (len n)) < ⟨k, hk⟩ from h)).trans_eq hkw + have hiW : v n i ∈ W := (hn (v n i) hiv.le).mp ⟨i, hi, rfl⟩ + obtain ⟨j, hj⟩ := Nat.subset_range_nth hiW + have hji : j < i := (Nat.nth_lt_nth hW).mp (hj ▸ hiv) + have hvi : v n j = v n i := (hp j hji).2.trans hj + exact ((hv n (show (⟨j, (hp j hji).1⟩ : Fin (len n)) < ⟨i, hi⟩ from hji)).ne hvi).elim + subst k + exact ⟨hk, hkw⟩ + +/-- Bounded windows of arbitrarily high eventual hits force the limiting +membership set to be infinite. The upper window endpoints are essential. -/ +lemma infinite_of_windows (len : ℕ → ℕ) (v : ℕ → ℕ → ℕ) (W : Set ℕ) + (hmem : ∀ w, ∀ᶠ n in atTop, (∃ i < len n, v n i = w) ↔ w ∈ W) + (hwin : ∀ B, ∃ T, ∀ᶠ n in atTop, ∃ i < len n, B < v n i ∧ v n i ≤ T) : + W.Infinite := by + apply Set.infinite_of_forall_exists_gt + intro B + obtain ⟨T, hT⟩ := hwin B + have hsmall : ∀ᶠ n in atTop, ∀ u ≤ T, + (∃ k < len n, v n k = u) ↔ u ∈ W := by + simpa only [Finset.mem_range, Nat.lt_succ_iff] using + (eventually_all_finset (I := Finset.range (T+1))).mpr (fun u _ => hmem u) + obtain ⟨n, hn, i, hi, hBi, hiT⟩ := (hsmall.and hT).exists + exact ⟨v n i, (hn (v n i) hiT).mp ⟨i, hi, rfl⟩, hBi⟩ + +end SeparableQuotient.IncreasingLists + +namespace SeparableQuotient.Norming +open PathCoding CoherentClosures Filter +open scoped Classical + +lemma PrefixValid.support_subset_closure {P : RawPath} {len : ℕ} + (h : PrefixValid P len) {n : ℕ} (hn : n < len) : + P.support n ⊆ P.closure n := by + intro a ha + exact (rho_le_iff a (P.endpoint n) (P.le_endpoint ha) _ (h.metadata_pos n hn)).mp + (h.rho_bound n hn a (P.endpoint n) ha (P.endpoint_mem n) (P.le_endpoint ha)) + +lemma PrefixValid.piece_support_subset_closure {P : RawPath} {len : ℕ} + (h : PrefixValid P len) {i n : ℕ} (hi : i ≤ n) (hn : n < len) : + (P.piece i).support ⊆ P.closure n := + (P.piece_support_subset hi).trans (h.support_subset_closure hn) + +/-- A retained coordinate in a later piece anchors the compressed code in the +actual ordinal labels. This is the finite-prefix version of path rigidity. -/ +lemma PrefixValid.piece_eq_of_code_anchor {P Q : RawPath} {len len' i j n : ℕ} + (hP : PrefixValid P len) (hQ : PrefixValid Q len') + (hn : n < len) (hn' : n < len') (hij : i < j) (hjn : j ≤ n) + (hc : P.code n = Q.code n) (a : Γ) + (ha : a ∈ (P.piece j).support) (ha' : a ∈ Q.closure n) : + P.piece i = Q.piece i := by + have hm := (RawPath.code_eq_at hc n le_rfl).2.1 + have haP := hP.piece_support_subset_closure hjn hn ha + apply position_alignment (a := a) ?_ + (hP.piece_support_subset_closure (hij.le.trans hjn) hn) + (hQ.piece_support_subset_closure (hij.le.trans hjn) hn') + (fun x hx => hP.successive i j hij (hjn.trans_lt hn) x hx a ha) + (RawPath.code_eq_at hc i (hij.le.trans hjn)).2.2 + unfold RawPath.closure at haP ha' ⊢ + rw [hm] at haP ⊢ + exact shared_initial_segment (P.endpoint n) (Q.endpoint n) a (Q.metadata n) haP ha' + +/-- Fixed successor weights and arbitrarily late retained coordinates force +stabilization of the entire *uncropped* data, not just coordinatewise limits. -/ +lemma finite_paths_stabilize {f : Family} (P : ℕ → FinitePath f) + (hlen : ∀ i, ∀ᶠ n in atTop, i < (P n).length) + (hw : ∀ i, ∃ w, ∀ᶠ n in atTop, (P n).raw.weight i = w) + (ha : ∀ i, ∃ j > i, ∃ a : Γ, + ∀ᶠ n in atTop, a ∈ ((P n).raw.piece j).support) : + ∀ i, ∃ d : Array × ℕ × ℕ, ∀ᶠ n in atTop, + (P n).raw.piece i = d.1 ∧ (P n).raw.weight i = d.2.1 ∧ + (P n).raw.metadata i = d.2.2 := by + intro i + obtain ⟨j, hij, a, ha⟩ := ha i + obtain ⟨w, hw⟩ := hw (j+1) + have hg := (hlen (j+1)).and (hw.and ha) + obtain ⟨n₀, hn₀, hw₀, ha₀⟩ := hg.exists + refine ⟨⟨(P n₀).raw.piece i, (P n₀).raw.weight i, (P n₀).raw.metadata i⟩, ?_⟩ + filter_upwards [hg] with n hn + have hc : (P n).raw.code j = (P n₀).raw.code j := by + apply sigma_injective + rw [← (P n).valid.rule j hn.1, ← (P n₀).valid.rule j hn₀, hn.2.1, hw₀] + refine ⟨(P n).valid.piece_eq_of_code_anchor (P n₀).valid + (by omega) (by omega) hij le_rfl hc a hn.2.2 + ((P n₀).valid.piece_support_subset_closure le_rfl (by omega) ha₀), ?_, ?_⟩ + · exact (RawPath.code_eq_at hc i hij.le).1 + · exact (RawPath.code_eq_at hc i hij.le).2.1 + +lemma raw_support_eq_of_prefix {P Q : RawPath} {n : ℕ} + (hp : ∀ i ≤ n, P.piece i = Q.piece i) : P.support n = Q.support n := by + ext a + simp only [RawPath.mem_support_iff] + constructor <;> rintro ⟨i, hi, ha⟩ + · exact ⟨i, hi, (hp i hi) ▸ ha⟩ + · exact ⟨i, hi, (hp i hi).symm ▸ ha⟩ + +lemma raw_code_eq_of_prefix {P Q : RawPath} {n : ℕ} + (hp : ∀ i ≤ n, P.piece i = Q.piece i) + (hw : ∀ i ≤ n, P.weight i = Q.weight i) + (hm : ∀ i ≤ n, P.metadata i = Q.metadata i) : P.code n = Q.code n := by + have hs := raw_support_eq_of_prefix hp + have he : P.endpoint n = Q.endpoint n := by + unfold RawPath.endpoint + congr 1 + have hc : P.closure n = Q.closure n := by + simp only [RawPath.closure, he, hm n le_rfl] + apply congrArg List.ofFn + funext i + simp only [hw i (by omega), hm i (by omega), hp i (by omega), hc] + +/-- Assemble the pointwise stabilized raw data into an actual infinite path. +Type-I membership is witnessed by original finite-path pieces, never by an +assumption that a limit belongs to the norming set. -/ +lemma infinite_path_of_stabilized {f : Family} (P : ℕ → FinitePath f) + (hmem : ∀ n i j, ((P n).piece i).child j ∈ f.norming) + (hlen : ∀ i, ∀ᶠ n in atTop, i < (P n).length) + (hstable : ∀ i, ∃ d : Array × ℕ × ℕ, ∀ᶠ n in atTop, + (P n).raw.piece i = d.1 ∧ (P n).raw.weight i = d.2.1 ∧ + (P n).raw.metadata i = d.2.2) : + ∃ Q : InfinitePath f, ∀ i, ∀ᶠ n in atTop, + (P n).raw.piece i = Q.raw.piece i ∧ + (P n).raw.weight i = Q.raw.weight i ∧ + (P n).raw.metadata i = Q.raw.metadata i := by + choose d hd using hstable + let Q : RawPath := { + piece := fun i => (d i).1 + weight := fun i => (d i).2.1 + metadata := fun i => (d i).2.2 + nonzero := fun i => by + obtain ⟨n, hn⟩ := (hd i).exists + exact hn.1 ▸ (P n).raw.nonzero i } + have he (i : ℕ) : ∀ᶠ n in atTop, + (P n).raw.piece i = Q.piece i ∧ (P n).raw.weight i = Q.weight i ∧ + (P n).raw.metadata i = Q.metadata i := hd i + have heAll (i : ℕ) : ∀ᶠ n in atTop, ∀ j ≤ i, + (P n).raw.piece j = Q.piece j ∧ (P n).raw.weight j = Q.weight j ∧ + (P n).raw.metadata j = Q.metadata j := by + simpa only [Finset.mem_range, Nat.lt_succ_iff] using + (eventually_all_finset (I := Finset.range (i+1))).mpr (fun j _ => he j) + have hc (i : ℕ) : ∀ᶠ n in atTop, (P n).raw.code i = Q.code i := by + filter_upwards [heAll i] with n hn + exact raw_code_eq_of_prefix (fun j hj => (hn j hj).1) + (fun j hj => (hn j hj).2.1) (fun j hj => (hn j hj).2.2) + have hvalid : Q.Admissible := { + successive := by + intro i j hij a ha b hb + obtain ⟨n, hn, hi, hj⟩ := ((hlen j).and ((he i).and (he j))).exists + exact (P n).valid.successive i j hij hn a (hi.1.symm ▸ ha) b (hj.1.symm ▸ hb) + metadata_strict := by + intro i j hij + obtain ⟨n, hn, hi, hj⟩ := ((hlen j).and ((he i).and (he j))).exists + simpa only [hi.2.2, hj.2.2] using (P n).valid.metadata_strict i j hij hn + metadata_pos := by + intro i + obtain ⟨n, hn, hi⟩ := ((hlen i).and (he i)).exists + simpa only [hi.2.2] using (P n).valid.metadata_pos i hn + weight_pos := by + intro i + obtain ⟨n, hn, hi⟩ := ((hlen i).and (he i)).exists + simpa only [hi.2.1] using (P n).valid.weight_pos i hn + weight_le_metadata := by + intro i + obtain ⟨n, hn, hi⟩ := ((hlen i).and (he i)).exists + simpa only [hi.2.1, hi.2.2] using (P n).valid.weight_le_metadata i hn + rho_bound := by + intro i a b ha hb hab + obtain ⟨n, hn, hi⟩ := ((hlen i).and (heAll i)).exists + have hs := raw_support_eq_of_prefix (fun j hj => (hi j hj).1) + simpa only [(hi i le_rfl).2.2] using (P n).valid.rho_bound i hn a b + (hs.symm ▸ ha) (hs.symm ▸ hb) hab + rule := by + intro i + obtain ⟨n, hn, hi, hci⟩ := ((hlen (i+1)).and ((he (i+1)).and (hc i))).exists + simpa only [hi.2.1, hci] using (P n).valid.rule i hn } + have hpiece (i : ℕ) : ∃ e : TypeI f, e.value = Q.piece i ∧ e.weight = Q.weight i ∧ + ∀ j, e.child j ∈ f.norming := by + obtain ⟨n, hn, hi⟩ := ((hlen i).and (he i)).exists + exact ⟨(P n).piece ⟨i, hn⟩, ((P n).value_eq _).trans hi.1, + ((P n).weight_eq _).trans hi.2.1, hmem n _⟩ + choose e heval heweight hemem using hpiece + refine ⟨⟨Q, hvalid, e, heval, heweight, ?_, hemem⟩, he⟩ + intro i j hij + obtain ⟨n, hn, hi, hj⟩ := ((hlen j).and ((he i).and (he j))).exists + simpa only [hi.1, hj.1] using (P n).mixed_successive + ⟨i, hij.trans hn⟩ ⟨j, hn⟩ hij + +lemma infinite_path_of_fixed_chain {f : Family} (P : ℕ → FinitePath f) + (hmem : ∀ n i j, ((P n).piece i).child j ∈ f.norming) + (hlen : ∀ i, ∀ᶠ n in atTop, i < (P n).length) + (hw : ∀ i, ∃ w, ∀ᶠ n in atTop, (P n).raw.weight i = w) + (ha : ∀ i, ∃ j > i, ∃ a : Γ, + ∀ᶠ n in atTop, a ∈ ((P n).raw.piece j).support) : + ∃ Q : InfinitePath f, ∀ i, ∀ᶠ n in atTop, + (P n).raw.piece i = Q.raw.piece i ∧ + (P n).raw.weight i = Q.raw.weight i ∧ + (P n).raw.metadata i = Q.raw.metadata i := + infinite_path_of_stabilized P hmem hlen (finite_paths_stabilize P hlen hw ha) + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open PathCoding Filter +open scoped Classical + +lemma PrefixValid.index_le_weight {P : RawPath} {len : ℕ} (h : PrefixValid P len) + (i : ℕ) (hi : i < len) : i ≤ P.weight i := by + induction i with + | zero => exact Nat.zero_le _ + | succ i ih => + have hv := h.weight_strict (show (⟨i, by omega⟩ : Fin len) < ⟨i+1, hi⟩ from by change i < i+1; omega) + have := ih (by omega) + change P.weight i < P.weight (i+1) at hv + omega + +/-- A compactness statement sufficient for the four-hits contradiction. Unlike +weak-star compactness alone, it recovers one actual infinite coded path. Every +high window has a finite upper endpoint and a finite possible coordinate set. -/ +lemma path_of_recurrent_windows {f : Family} (P : ℕ → FinitePath f) + (hmem : ∀ n i j, ((P n).piece i).child j ∈ f.norming) + (hwin : ∀ B : ℕ, ∃ T : ℕ, ∃ s : Finset Γ, ∀ᶠ n in atTop, + ∃ i < (P n).length, B < (P n).raw.weight i ∧ (P n).raw.weight i ≤ T ∧ + ∃ a ∈ s, a ∈ ((P n).raw.piece i).support) : + ∃ (φ : ℕ → ℕ) (Q : InfinitePath f), StrictMono φ ∧ ∀ i, ∀ᶠ n in atTop, + i < (P (φ n)).length ∧ (P (φ n)).raw.piece i = Q.raw.piece i ∧ + (P (φ n)).raw.weight i = Q.raw.weight i ∧ + (P (φ n)).raw.metadata i = Q.raw.metadata i := by + choose T s hs using hwin + let ι := ℕ ⊕ (Σ B : ℕ, ℕ × s B) + let test : ℕ → ι → Prop := fun n t => match t with + | .inl w => ∃ i < (P n).length, (P n).raw.weight i = w + | .inr ⟨B, i, a⟩ => a.val ∈ ((P n).raw.piece i).support + obtain ⟨φ, hφ, htest⟩ := DiscreteDiagonal.exists_stabilizing_subsequence test + choose b hb using htest + let W : Set ℕ := {w | b (.inl w)} + have hWmem (w : ℕ) : ∀ᶠ n in atTop, + (∃ i < (P (φ n)).length, (P (φ n)).raw.weight i = w) ↔ w ∈ W := hb (.inl w) + have hwin' (B : ℕ) : ∀ᶠ n in atTop, + ∃ i < (P (φ n)).length, B < (P (φ n)).raw.weight i ∧ + (P (φ n)).raw.weight i ≤ T B ∧ ∃ a ∈ s B, + a ∈ ((P (φ n)).raw.piece i).support := (hs B).filter_mono hφ.tendsto_atTop + have hW : W.Infinite := IncreasingLists.infinite_of_windows + (fun n => (P (φ n)).length) (fun n i => (P (φ n)).raw.weight i) W hWmem + (fun B => ⟨T B, (hwin' B).mono fun _ ⟨i, hi, hBi, hiT, _⟩ => ⟨i, hi, hBi, hiT⟩⟩) + let w := Nat.nth (· ∈ W) + have hpos (i : ℕ) : ∀ᶠ n in atTop, + i < (P (φ n)).length ∧ (P (φ n)).raw.weight i = w i := + IncreasingLists.positions_stabilize _ _ (fun n => (P (φ n)).valid.weight_strict) W hW hWmem i + have hanchor (i : ℕ) : ∃ j > i, ∃ a : Γ, + ∀ᶠ n in atTop, a ∈ ((P (φ n)).raw.piece j).support := by + let B := w i + have hpall : ∀ᶠ n in atTop, ∀ j ≤ T B, + j < (P (φ n)).length ∧ (P (φ n)).raw.weight j = w j := by + simpa only [Finset.mem_range, Nat.lt_succ_iff] using + (eventually_all_finset (I := Finset.range (T B+1))).mpr (fun j _ => hpos j) + have hc (j : Fin (T B+1)) (a : s B) : ∀ᶠ n in atTop, + a.val ∈ ((P (φ n)).raw.piece j).support ↔ b (.inr ⟨B, j.val, a⟩) := + hb (.inr ⟨B, j.val, a⟩) + have hcall : ∀ᶠ n in atTop, ∀ j : Fin (T B+1), ∀ a : s B, + a.val ∈ ((P (φ n)).raw.piece j).support ↔ b (.inr ⟨B, j.val, a⟩) := + eventually_all.mpr (fun j => eventually_all.mpr (hc j)) + obtain ⟨n, hn, hp, hcoord⟩ := ((hwin' B).and (hpall.and hcall)).exists + obtain ⟨j, hj, hBj, hjT, a, has, haj⟩ := hn + have hjT' : j ≤ T B := ((P (φ n)).valid.index_le_weight j hj).trans hjT + have hij : i < j := (Nat.nth_lt_nth hW).mp (hBj.trans_eq (hp j hjT').2) + have hba : b (.inr ⟨B, j, ⟨a, has⟩⟩) := (hcoord ⟨j, by omega⟩ ⟨a, has⟩).mp haj + refine ⟨j, hij, a, ?_⟩ + exact (hb (.inr ⟨B, j, ⟨a, has⟩⟩)).mono (fun _ h => h.mpr hba) + obtain ⟨Q, hQ⟩ := infinite_path_of_fixed_chain (P ∘ φ) (fun n => hmem (φ n)) + (fun i => (hpos i).mono fun _ h => h.1) + (fun i => ⟨w i, (hpos i).mono fun _ h => h.2⟩) hanchor + exact ⟨φ, Q, hφ, fun i => ((hpos i).and (hQ i)).mono (fun _ h => ⟨h.1.1, h.2⟩)⟩ + +end SeparableQuotient.Norming + +namespace SeparableQuotient.Norming +open Filter PathCoding +open scoped Classical Topology + +lemma Family.m_mono (f : Family) : Monotone f.m := + (Parameters.m_strict f.s_ge_two).monotone.comp (fun _ _ h => Nat.sub_le_sub_right h 1) + +lemma FinitePath.at_piece {f : Family} (P : FinitePath f) (i : Fin P.length) + (a : Γ) (hi : P.raw.piece i a ≠ 0) : P.value a = P.raw.piece i a := by + change (∑ j : Fin P.length, P.raw.piece j) a = _ + rw [Finsupp.finsetSum_apply, Finset.sum_eq_single i] + · intro j _ hji + by_contra hj + have he : j = i := Fin.ext (by + by_contra hne + rcases lt_or_gt_of_ne hne with h | h + · exact (lt_irrefl a) (P.valid.successive j i h i.isLt a + (Finsupp.mem_support_iff.mpr hj) a (Finsupp.mem_support_iff.mpr hi)) + · exact (lt_irrefl a) (P.valid.successive i j h j.isLt a + (Finsupp.mem_support_iff.mpr hi) a (Finsupp.mem_support_iff.mpr hj))) + exact hji he + · simp + +lemma FinitePath.coefficient_le {f : Family} (P : FinitePath f) + (hm : ∀ i j, (P.piece i).child j ∈ f.norming) (a : Γ) : + |(P.value a : ℝ)| ≤ 1/(f.m (P.raw.weight (P.hitIndex a)) : ℝ) := by + rw [P.value_at_hit, ← P.value_eq, ← P.weight_eq] + exact (P.piece (P.hitIndex a)).coefficient_bound + (fun j b => full_coefficient_bound _ (f.norming_subset_full (hm _ j)) b) a + +/-- Coordinate value of the bounded infinite path functional. -/ +def InfinitePath.coordinateValue {f : Family} (P : InfinitePath f) (a : Γ) : ℚ := + (P.prefix_coordinate_eventually_constant a).choose + +lemma InfinitePath.prefix_coordinateValue {f : Family} (P : InfinitePath f) (a : Γ) : + ∀ᶠ n in atTop, (P.prefix n).value a = P.coordinateValue a := + (P.prefix_coordinate_eventually_constant a).choose_spec + +lemma InfinitePath.coordinateValue_at_hit {f : Family} (P : InfinitePath f) + (a : Γ) (i : ℕ) (hi : P.raw.piece i a ≠ 0) : + P.coordinateValue a = P.raw.piece i a := by + obtain ⟨n, hn, hiv⟩ := ((P.prefix_coordinateValue a).and (eventually_ge_atTop i)).exists + exact hn.symm.trans (P.prefix_at_hit a i n hi hiv) + +lemma InfinitePath.coordinateValue_zero {f : Family} (P : InfinitePath f) + (a : Γ) (hi : ∀ i, P.raw.piece i a = 0) : P.coordinateValue a = 0 := by + obtain ⟨n, hn⟩ := (P.prefix_coordinateValue a).exists + rw [← hn] + change (∑ i : Fin (n+1), P.raw.piece i) a = 0 + simp only [Finsupp.finsetSum_apply, hi, Finset.sum_const_zero] + +/-- Stabilization is on exact actual uncropped pieces. Any extra pieces escape +in weight, and their coordinate coefficients tend to zero. -/ +lemma stabilized_coordinate_tendsto {f : Family} (P : ℕ → FinitePath f) + (hm : ∀ n i j, ((P n).piece i).child j ∈ f.norming) (Q : InfinitePath f) + (hst : ∀ i, ∀ᶠ n in atTop, i < (P n).length ∧ + (P n).raw.piece i = Q.raw.piece i ∧ (P n).raw.weight i = Q.raw.weight i) + (a : Γ) : Tendsto (fun n => ((P n).value a : ℝ)) atTop (𝓝 (Q.coordinateValue a : ℝ)) := by + by_cases hh : ∃ i, Q.raw.piece i a ≠ 0 + · obtain ⟨i, hi⟩ := hh + apply tendsto_const_nhds.congr' + filter_upwards [hst i] with n hn + rw [Q.coordinateValue_at_hit a i hi] + congr 1 + exact ((P n).at_piece ⟨i, hn.1⟩ a (by simpa only [hn.2.1] using hi)).trans + (congrArg (fun z : Array => z a) hn.2.1) |>.symm + · push Not at hh + rw [Q.coordinateValue_zero a hh, Rat.cast_zero] + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨N, hN⟩ := Metric.tendsto_atTop.mp f.reciprocal_summable.tendsto_atTop_zero ε hε + have heps : 1/(Parameters.m f.s N : ℝ) < ε := by + simpa only [Real.dist_eq, sub_zero, abs_of_nonneg (by positivity : + 0 ≤ 1/(Parameters.m f.s N : ℝ))] using hN N le_rfl + have hall : ∀ᶠ n in atTop, ∀ i ≤ N+2, i < (P n).length ∧ + (P n).raw.piece i = Q.raw.piece i ∧ (P n).raw.weight i = Q.raw.weight i := by + simpa only [Finset.mem_range, Nat.lt_succ_iff] using + (eventually_all_finset (I := Finset.range (N+2+1))).mpr (fun i _ => hst i) + filter_upwards [hall] with n hn + rw [Real.dist_eq, sub_zero] + by_cases hz : (P n).value a = 0 + · simpa only [hz, Rat.cast_zero, abs_zero] using hε + · let i := (P n).hitIndex a + have hi : N+2 < i.val := by + by_contra hnle + have hzero : (P n).raw.piece i a = 0 := by + rw [(hn i (by omega)).2.1, hh] + exact hz ((P n).value_at_hit a |>.trans hzero) + have hw : N+2 ≤ (P n).raw.weight i := + hi.le.trans ((P n).valid.index_le_weight i i.isLt) + have hmle : Parameters.m f.s N ≤ f.m ((P n).raw.weight i) := + (Parameters.m_strict f.s_ge_two).monotone (by omega) + exact ((P n).coefficient_le (hm n) a).trans_lt + ((one_div_le_one_div_of_le (by exact_mod_cast Parameters.m_pos f.s N) + (by exact_mod_cast hmle)).trans_lt heps) + +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology +@[reducible] local instance dualEGroup12 : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance dualESpace12 : NormedSpace ℝ (StrongDual ℝ E) := inferInstance + +lemma pathFunctional_finite {f : Family} (Q : InfinitePath f) (x : Γ →₀ ℝ) : + pathFunctional Q (norming.includeFinite x) = x.sum (fun a t => t * (Q.coordinateValue a : ℝ)) := by + apply tendsto_nhds_unique (pathPartial_tendsto Q _) + apply tendsto_const_nhds.congr' + filter_upwards [(eventually_all_finset x.support).mpr (fun a _ => Q.prefix_coordinateValue a)] with n hn + rw [pathPartial, norming.functional_includeFinite] + apply Finset.sum_congr rfl + intro a ha + simp only [hn a ha] + +lemma finitePath_mem_full {f : Family} (P : FinitePath f) + (hm : ∀ i j, (P.piece i).child j ∈ f.norming) : P.value ∈ Full := by + have h := TypeII.mem_family (P.oneTerm Crop.all) (fun _ i j => hm i j) + apply f.norming_subset_full + simpa only [FinitePath.oneTerm_value, Crop.all_set, restrict_univ] using h + +def finitePathFunctional {f : Family} (P : FinitePath f) + (hm : ∀ i j, (P.piece i).child j ∈ f.norming) : StrongDual ℝ E := + norming.functional ⟨P.value, finitePath_mem_full P hm⟩ + +lemma norm_finitePathFunctional_le {f : Family} (P : FinitePath f) + (hm : ∀ i j, (P.piece i).child j ∈ f.norming) : ‖finitePathFunctional P hm‖ ≤ 1 := + norming.norm_functional_le _ + +lemma stabilized_path_tendsto {f : Family} (P : ℕ → FinitePath f) + (hm : ∀ n i j, ((P n).piece i).child j ∈ f.norming) (Q : InfinitePath f) + (hst : ∀ i, ∀ᶠ n in atTop, i < (P n).length ∧ + (P n).raw.piece i = Q.raw.piece i ∧ (P n).raw.weight i = Q.raw.weight i) + (x : E) : Tendsto (fun n => finitePathFunctional (P n) (hm n) x) atTop (𝓝 (pathFunctional Q x)) := by + let g : ℕ → StrongDual ℝ E := fun n => finitePathFunctional (P n) (hm n) - pathFunctional Q + have hb (n : ℕ) : ‖g n‖ ≤ 2 := (norm_sub_le _ _).trans + (by linarith [norm_finitePathFunctional_le (P n) (hm n), norm_pathFunctional_le Q]) + have hz (y : E) (hy : y ∈ Set.range norming.includeFinite) : + Tendsto (fun n => g n y) atTop (𝓝 0) := by + obtain ⟨v, rfl⟩ := hy + have ht : Tendsto (fun n => finitePathFunctional (P n) (hm n) (norming.includeFinite v)) + atTop (𝓝 (pathFunctional Q (norming.includeFinite v))) := by + simp only [finitePathFunctional, norming.functional_includeFinite, pathFunctional_finite] + exact tendsto_finsetSum _ (fun a _ => tendsto_const_nhds.mul (stabilized_coordinate_tendsto P hm Q hst a)) + simpa only [g, sub_apply, sub_self] using ht.sub_const (pathFunctional Q (norming.includeFinite v)) + have ht := DenseZero.tendsto_zero_of_dense g 2 hb _ norming.denseRange_includeFinite hz x + have he : (fun n => g n x + pathFunctional Q x) = (fun n => finitePathFunctional (P n) (hm n) x) := by + funext n + simp only [g, sub_apply, sub_add_cancel] + simpa only [he, zero_add] using ht.add_const (pathFunctional Q x) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PerturbationOperator.lean b/lean/OAI/Analysis/SeparableQuotients/PerturbationOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..c05f54dc58cbb33ab0bfaa5f44c0725137a438df --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PerturbationOperator.lean @@ -0,0 +1,219 @@ +import OAI.Analysis.SeparableQuotients.PathOperators + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Norming + +def Family.at : ℕ → Family + | 0 => .mixed + | k+1 => .pure k +@[simp] lemma Family.at_index (f : Family) : Family.at f.index = f := by cases f <;> rfl +@[simp] lemma Family.index_at (n : ℕ) : (Family.at n).index = n := by cases n <;> rfl +lemma Family.at_injective : Function.Injective Family.at := fun _ _ h => by + simpa using congrArg Family.index h +end SeparableQuotient.Norming + +namespace SeparableQuotient.ActualSpace + +private lemma cachedNormedT2 (Y : Type*) [NormedAddCommGroup Y] : T2Space Y := inferInstance +open Norming NormConstruction PathCoding Filter +open scoped Classical Topology + +@[reducible] local instance opDualGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance opDualSpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +local instance opXClosed : IsClosed (X₀ : Set (StrongDual ℝ E)) := norming.predual_isClosed +@[reducible] local instance opWGroup : NormedAddCommGroup W := inferInstance +@[reducible] local instance opWSpace : NormedSpace ℝ W := inferInstance +local instance opWT2 : T2Space W := @cachedNormedT2 W opWGroup + +variable (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) + +def labelAnalysis (f : Family) : StrongDual ℝ E →L[ℝ] lp (fun _ : PathIndex f => ℝ) f.pathExponent := + LpCoding.analysisMap f.pathConjugate (labelMap hCH f) + +@[simp] lemma labelAnalysis_apply (f : Family) (y : StrongDual ℝ E) (P : PathIndex f) : + labelAnalysis hCH f y P = y (e (pathLabel hCH f P)) := by + change y (labelMap hCH f (lp.single f.sourceExponent P 1)) = _ + rw [labelMap_single,one_smul] + +lemma norm_labelAnalysis_le (f : Family) : ‖labelAnalysis hCH f‖ ≤ 1 := + (LpCoding.norm_analysisMap_le _ _).trans (norm_labelMap_le hCH f) + +def familyOperator (f : Family) : StrongDual ℝ E →L[ℝ] W := + (pathMap f).comp (labelAnalysis hCH f) + +lemma norm_familyOperator_le (f : Family) : ‖familyOperator hCH f‖ ≤ 1 := by + calc + _ ≤ ‖pathMap f‖ * ‖labelAnalysis hCH f‖ := ContinuousLinearMap.opNorm_comp_le _ _ + _ ≤ 1*1 := mul_le_mul (norm_pathMap_le f) (norm_labelAnalysis_le hCH f) + (norm_nonneg _) (by norm_num) + _ = _ := one_mul _ + +lemma labelAnalysis_coordinate_self (f : Family) (P : PathIndex f) : + labelAnalysis hCH f (coordinate (pathLabel hCH f P)) = lp.single f.pathExponent P 1 := by + apply lp.ext + funext Q + simp only [labelAnalysis_apply,coordinate_e,lp.single_apply,Pi.single_apply] + have he : pathLabel hCH f P = pathLabel hCH f Q ↔ P=Q := (pathLabelEmb hCH f).injective.eq_iff + simp only [he,eq_comm] + +lemma labelAnalysis_coordinate_other (f g : Family) (P : PathIndex f) (hfg : f ≠ g) : + labelAnalysis hCH g (coordinate (pathLabel hCH f P)) = 0 := by + apply lp.ext + funext Q + have hn : pathLabel hCH f P ≠ pathLabel hCH g Q := by + intro h + have hs : (Sigma.mk f P : (t : Family) × PathIndex t) = Sigma.mk g Q := + pathLabel_injective hCH h + exact hfg (congrArg Sigma.fst hs) + simp [labelAnalysis_apply,coordinate_e,hn] + +lemma familyOperator_coordinate (f g : Family) (P : PathIndex f) : + familyOperator hCH g (coordinate (pathLabel hCH f P)) = + if f=g then pathCoset P else 0 := by + by_cases h : f=g + · subst g + simp [familyOperator,labelAnalysis_coordinate_self] + · simp [familyOperator,labelAnalysis_coordinate_other hCH f g P h,h] + +def tau (n : ℕ) : ℝ := (1/32)*(1/2)^n +lemma tau_pos (n : ℕ) : 0 < tau n := by unfold tau; positivity +lemma tau_hasSum : HasSum tau (1/16) := by + have h := (hasSum_geometric_of_norm_lt_one (ξ := (1/2:ℝ)) (by norm_num)).mul_left (1/32:ℝ) + norm_num at h + exact h +lemma tau_summable : Summable tau := tau_hasSum.summable + +lemma operator_summable : Summable (fun n => tau n • familyOperator hCH (Family.at n)) := by + apply tau_summable.of_norm_bounded + intro n + rw [norm_smul,Real.norm_of_nonneg (tau_pos n).le] + exact mul_le_of_le_one_right (tau_pos n).le (norm_familyOperator_le hCH _) + +/-- The CH perturbation operator with norm at most 1/10. -/ +def B : StrongDual ℝ E →L[ℝ] W := ∑' n, tau n • familyOperator hCH (Family.at n) + +lemma norm_B_le : ‖B hCH‖ ≤ 1/10 := by + have hb : ‖B hCH‖ ≤ 1/16 := by + apply tsum_of_norm_bounded tau_hasSum + intro n + rw [norm_smul,Real.norm_of_nonneg (tau_pos n).le] + exact mul_le_of_le_one_right (tau_pos n).le (norm_familyOperator_le hCH _) + linarith + +lemma B_coordinate (f : Family) (P : PathIndex f) : + B hCH (coordinate (pathLabel hCH f P)) = tau f.index • pathCoset P := by + have hsum := (ContinuousLinearMap.apply ℝ W (coordinate (pathLabel hCH f P))).hasSum + (operator_summable hCH).hasSum + have hf : (fun n => (tau n • familyOperator hCH (Family.at n)) + (coordinate (pathLabel hCH f P))) = + (fun n => if n=f.index then tau f.index • pathCoset P else 0) := by + funext n + rw [smul_apply,familyOperator_coordinate] + by_cases h : n=f.index + · subst n; simp + · have hn : f ≠ Family.at n := by + intro hf + apply h + rw [hf,Family.index_at] + simp [h,hn] + have he := hasSum_ite_eq f.index (tau f.index • pathCoset P) + exact hsum.unique (by simpa only [ContinuousLinearMap.apply_apply,hf] using he) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding Filter +open scoped Classical Topology + +@[reducible] local instance propDualGroup : NormedAddCommGroup (StrongDual ℝ E) := inferInstance +@[reducible] local instance propDualSpace : NormedSpace ℝ (StrongDual ℝ E) := inferInstance +local instance propXClosed : IsClosed (X₀ : Set (StrongDual ℝ E)) := norming.predual_isClosed +@[reducible] local instance propWGroup : NormedAddCommGroup W := inferInstance +@[reducible] local instance propWSpace : NormedSpace ℝ W := inferInstance +@[reducible] local instance propWDualGroup : NormedAddCommGroup (StrongDual ℝ W) := inferInstance +@[reducible] local instance propWDualSpace : NormedSpace ℝ (StrongDual ℝ W) := inferInstance + +variable (hCH : Cardinal.mk ℝ = Cardinal.aleph 1) + +lemma pathMap_mem_closed (Z : Submodule ℝ W) (hZ : IsClosed (Z : Set W)) + (f : Family) (hf : ∀ P : PathIndex f, pathCoset P ∈ Z) + (a : lp (fun _ : PathIndex f => ℝ) f.pathExponent) : pathMap f a ∈ Z := by + refine (LpCoding.finite_dense (ι := PathIndex f) (p := f.pathExponent) f.pathExponent_ne_top).induction_on + (p := fun a => pathMap f a ∈ Z) a (hZ.preimage (pathMap f).continuous) ?_ + intro c + rw [pathMap_finite] + exact Z.sum_mem (fun i _ => Z.smul_mem _ (hf i)) + +lemma pathCoset_mem_B_predual (f : Family) (P : PathIndex f) : + pathCoset P ∈ X₀.map (B hCH).toLinearMap := by + have h : tau f.index • pathCoset P ∈ X₀.map (B hCH).toLinearMap := by + refine ⟨coordinate (pathLabel hCH f P),norming.coordinate_mem_predual _,?_⟩ + exact B_coordinate hCH f P + have hh := (X₀.map (B hCH).toLinearMap).smul_mem (tau f.index)⁻¹ h + simpa only [smul_smul,inv_mul_cancel₀ (tau_pos _).ne',one_smul] using hh + +lemma B_range_mem_predual_closure : + (B hCH).range ≤ (X₀.map (B hCH).toLinearMap).topologicalClosure := by + rintro _ ⟨y,rfl⟩ + let Z := (X₀.map (B hCH).toLinearMap).topologicalClosure + apply (Submodule.isClosed_topologicalClosure _).mem_of_tendsto + ((ContinuousLinearMap.apply ℝ W y).hasSum (operator_summable hCH).hasSum) + apply Eventually.of_forall + intro s + simp only [ContinuousLinearMap.apply_apply,smul_apply] + apply Z.sum_mem + intro n _ + apply Z.smul_mem + exact pathMap_mem_closed Z (Submodule.isClosed_topologicalClosure _) (Family.at n) + (fun P => Submodule.le_topologicalClosure _ (pathCoset_mem_B_predual hCH _ P)) + (labelAnalysis hCH _ y) + +def familyVector (f : Family) (w : StrongDual ℝ W) : E := + labelMap hCH f (LpCoding.coefficients f.pathConjugate.symm (w.comp (pathMap f))) + +lemma norm_familyVector_le (f : Family) (w : StrongDual ℝ W) : + ‖familyVector hCH f w‖ ≤ ‖w‖ := by + calc + _ ≤ ‖labelMap hCH f‖ * ‖LpCoding.coefficients f.pathConjugate.symm (w.comp (pathMap f))‖ := + (labelMap hCH f).le_opNorm _ + _ ≤ 1 * ‖w.comp (pathMap f)‖ := mul_le_mul (norm_labelMap_le hCH f) + (LpCoding.norm_coefficients_le _ _) (norm_nonneg _) (by norm_num) + _ ≤ ‖w‖ := by + rw [one_mul] + exact (ContinuousLinearMap.opNorm_comp_le _ _).trans + (mul_le_of_le_one_right (norm_nonneg _) (norm_pathMap_le f)) + +lemma familyVector_pair (f : Family) (w : StrongDual ℝ W) (y : StrongDual ℝ E) : + y (familyVector hCH f w) = w (familyOperator hCH f y) := by + exact LpCoding.eval_coefficients_symm f.pathConjugate f.sourceExponent_ne_top f.pathExponent_ne_top + (y.comp (labelMap hCH f)) (w.comp (pathMap f)) + +lemma vector_summable (w : StrongDual ℝ W) : + Summable (fun n => tau n • familyVector hCH (Family.at n) w) := by + apply (tau_summable.mul_right ‖w‖).of_norm_bounded + intro n + rw [norm_smul,Real.norm_of_nonneg (tau_pos n).le] + exact mul_le_mul_of_nonneg_left (norm_familyVector_le hCH _ _) (tau_pos n).le + +/-- The adjoint perturbation has range in the canonical evaluation image. -/ +lemma B_adjoint (w : StrongDual ℝ W) : + ∃ v : E, w.comp (B hCH) = NormedSpace.inclusionInDoubleDual ℝ E v := by + refine ⟨∑' n, tau n • familyVector hCH (Family.at n) w,?_⟩ + ext y + have hB := w.hasSum ((ContinuousLinearMap.apply ℝ W y).hasSum (operator_summable hCH).hasSum) + have hv := y.hasSum (vector_summable hCH w).hasSum + have he : (fun n => w ((tau n • familyOperator hCH (Family.at n)) y)) = + fun n => y (tau n • familyVector hCH (Family.at n) w) := by + funext n + simp only [smul_apply,map_smul,familyVector_pair] + change w (B hCH y) = y (∑' n, tau n • familyVector hCH (Family.at n) w) + exact hB.unique (by simpa only [ContinuousLinearMap.apply_apply,he] using hv) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexPerturbation.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f84e9a01fb108e62e9b62397733530bde91387b0 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexPerturbation.lean @@ -0,0 +1,185 @@ +import OAI.Analysis.SeparableQuotients.Positive.SeparatedWitness + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Scalar +variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℂ V] + [NormedSpace ℝ V] [IsScalarTower ℝ ℂ V] + +def imagCoordinate (f : ℕ → V) (n : ℕ) : StrongDual ℝ (ClosedSpan ℂ f) := + Complex.imCLM.comp ((prefixCoord ℂ f n).restrictScalars ℝ) + +def perturbTerm (f g : ℕ → V) (n : ℕ) : ClosedSpan ℂ f →L[ℝ] V := + (imagCoordinate f n).smulRight (g n - Complex.I • f n) + +lemma imagCoordinate_norm (f : ℕ → V) (h : PrefixBoundTwo ℂ f) (hv : ∀ n, ‖f n‖ = 1) + (n : ℕ) : ‖imagCoordinate f n‖ ≤ 4 := by + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro x + change |(prefixCoord ℂ f n x).im| ≤ 4 * ‖x‖ + exact (Complex.abs_im_le_norm _).trans (by + simpa using prefixCoord_bound ℂ f h (a := 1) (by norm_num) (fun i => (hv i).ge) x n) + +lemma summable_perturbTerm [CompleteSpace V] (f g : ℕ → V) + (h : PrefixBoundTwo ℂ f) (hv : ∀ n, ‖f n‖ = 1) + (hfg : ∀ n, ‖g n - Complex.I • f n‖ ≤ (1/2:ℝ)^n) : + Summable (perturbTerm f g) := by + apply Summable.of_norm_bounded ((summable_geometric_of_lt_one + (show (0:ℝ) ≤ 1/2 by norm_num) (by norm_num)).mul_left 4) + intro n + rw [perturbTerm, ContinuousLinearMap.norm_smulRight_apply] + exact mul_le_mul (imagCoordinate_norm f h hv n) (hfg n) (norm_nonneg _) (by norm_num) + +def perturbation (f g : ℕ → V) : ClosedSpan ℂ f →L[ℝ] V := ∑' n, perturbTerm f g n + +lemma perturbation_combination [CompleteSpace V] (f g : ℕ → V) + (h : PrefixBoundTwo ℂ f) (hv : ∀ n, ‖f n‖ = 1) + (hfg : ∀ n, ‖g n - Complex.I • f n‖ ≤ (1/2:ℝ)^n) (c : ℕ →₀ ℂ) : + perturbation f g (spanCombination ℂ f c) = + ∑ n ∈ c.support, (c n).im • (g n - Complex.I • f n) := by + have hs := summable_perturbTerm f g h hv hfg + change (ContinuousLinearMap.apply ℝ V (spanCombination ℂ f c)) (∑' n, perturbTerm f g n) = _ + rw [ContinuousLinearMap.map_tsum _ hs] + simp only [ContinuousLinearMap.apply_apply, perturbTerm, ContinuousLinearMap.smulRight_apply, + imagCoordinate, ContinuousLinearMap.comp_apply, Complex.imCLM_apply] + change (∑' n, (prefixCoord ℂ f n (spanCombination ℂ f c)).im • + (g n - Complex.I • f n)) = _ + simp only [prefixCoord_combination ℂ f h (a := 1) (by norm_num) (fun i => (hv i).ge)] + apply tsum_eq_sum + intro n hn + simp [Finsupp.notMem_support_iff.mp hn] + +lemma real_imag_perturbed (z : ℂ) (u v : V) : + z • u + z.im • (v - Complex.I • u) = z.re • u + z.im • v := by + have hz : z • u = z.re • u + z.im • (Complex.I • u) := by + conv_lhs => rw [← Complex.re_add_im z, add_smul, mul_smul] + rw [show (z.re:ℂ) • u = z.re • u from algebraMap_smul ℂ z.re u, + show (z.im:ℂ) • (Complex.I • u) = z.im • (Complex.I • u) from + algebraMap_smul ℂ z.im (Complex.I • u)] + rw [hz, smul_sub] + abel + + + +theorem perturbation_maps_into_real [CompleteSpace V] + (E : Submodule ℝ V) (hEcl : IsClosed (E : Set V)) (f g : ℕ → E) + (h : PrefixBoundTwo ℂ (fun n => (f n : V))) (hv : ∀ n, ‖f n‖ = 1) + (hfg : ∀ n, ‖(g n : V) - Complex.I • (f n : V)‖ ≤ (1/2:ℝ)^n) : + ∀ x : ClosedSpan ℂ (fun n => (f n : V)), + (x : V) + perturbation (fun n => (f n : V)) (fun n => (g n : V)) x ∈ E := by + intro x + refine (denseRange_spanCombination ℂ (fun n => (f n : V))).induction_on x (p := fun x => + (x : V) + perturbation (fun n => (f n : V)) (fun n => (g n : V)) x ∈ E) ?_ ?_ + · exact hEcl.preimage (by fun_prop) + · intro c + rw [spanCombination_coe, perturbation_combination _ _ h hv hfg c] + change (∑ n ∈ c.support, c n • (f n : V)) + + (∑ n ∈ c.support, (c n).im • ((g n : V) - Complex.I • (f n : V))) ∈ E + rw [← Finset.sum_add_distrib] + apply E.sum_mem + intro n hn + rw [real_imag_perturbed] + exact E.add_mem (E.smul_mem _ (f n).property) (E.smul_mem _ (g n).property) + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set TopologicalSpace Scalar +attribute [local instance] Scalar.dualSubmoduleNormedGroup Scalar.dualSubmoduleNormedSpace +attribute [local instance] realDualSubmoduleNormedGroup realDualSubmoduleNormedSpace +attribute [local instance] complexDualSubmoduleRealNormedSpace complexRealOperatorNormedGroup + complexRealOperatorMetric complexRealOperatorNormedSpace complexRealOperatorAdd + complexRealOperatorSMul complexRealOperatorT2 +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℂ X] + [NormedSpace ℝ X] [IsScalarTower ℝ ℂ X] + + + + +lemma perturbation_separable_eval (f g : ℕ → StrongDual ℂ X) + (h : PrefixBoundTwo ℂ f) (hv : ∀ n, ‖f n‖ = 1) + (hfg : ∀ n, ‖g n - Complex.I • f n‖ ≤ (1/2:ℝ)^n) : + IsSeparable (Set.range (fun x : X => + ((ContinuousLinearMap.restrictScalarsL ℂ X ℂ ℝ ℝ).flip x).comp (perturbation f g))) := by + let : ContinuousAdd (ClosedSpan ℂ f →L[ℝ] ℂ) := complexRealOperatorAdd _ + let : ContinuousSMul ℂ (ClosedSpan ℂ f →L[ℝ] ℂ) := complexRealOperatorSMul _ + let a (n : ℕ) : ClosedSpan ℂ f →L[ℝ] ℂ := Complex.ofRealCLM.comp (imagCoordinate f n) + let S := ClosedSpan ℂ a + have hSsep : IsSeparable (S : Set (ClosedSpan ℂ f →L[ℝ] ℂ)) := + ((Set.countable_range a).isSeparable.span (R := ℂ)).closure + apply hSsep.mono + rintro _ ⟨x, rfl⟩ + let ex : StrongDual ℂ X →L[ℝ] ℂ := + (ContinuousLinearMap.restrictScalarsL ℂ X ℂ ℝ ℝ).flip x + have he (n : ℕ) : ex.comp (perturbTerm f g n) = + (g n x - Complex.I * f n x) • a n := by + ext z + change (imagCoordinate f n z) • ((g n - Complex.I • f n) x) = + (g n x - Complex.I * f n x) * (imagCoordinate f n z : ℂ) + simp [smul_eq_mul, mul_comm] + have ht := summable_perturbTerm f g h hv hfg + change (ex.postcomp (ClosedSpan ℂ f)) (∑' n, perturbTerm f g n) ∈ S + rw [ContinuousLinearMap.map_tsum _ ht] + have hSclosed : IsClosed (S : Set (ClosedSpan ℂ f →L[ℝ] ℂ)) := isClosed_closure + apply tsum_mem hSclosed + intro n + change ex.comp (perturbTerm f g n) ∈ S + rw [he n] + exact S.smul_mem _ (spanVector ℂ a n).property + +lemma perturbation_witness + (E : Submodule ℝ (StrongDual ℂ X)) (hEcl : IsClosed (E : Set (StrongDual ℂ X))) + (hEsep : IsSeparable (Set.range (realEvaluation E))) (f g : ℕ → E) + (h : PrefixBoundTwo ℂ (fun n => (f n : StrongDual ℂ X))) (hv : ∀ n, ‖f n‖ = 1) + (hfg : ∀ n, ‖(g n : StrongDual ℂ X) - Complex.I • (f n : StrongDual ℂ X)‖ ≤ (1/2:ℝ)^n) : + ∃ H : Submodule ℂ (StrongDual ℂ X), IsClosed (H : Set (StrongDual ℂ X)) ∧ + ¬ FiniteDimensional ℂ H ∧ IsSeparable (Set.range (Scalar.evaluation H)) := by + let u : ℕ → StrongDual ℂ X := fun n => f n + let v : ℕ → StrongDual ℂ X := fun n => g n + let H := ClosedSpan ℂ u + let K := perturbation u v + let L₀ : H →L[ℝ] StrongDual ℂ X := H.subtypeL.restrictScalars ℝ + K + let L : H →L[ℝ] E := L₀.codRestrict E (perturbation_maps_into_real E hEcl f g h hv hfg) + have hHinf : ¬ FiniteDimensional ℂ H := by + intro hh + let := hh + have hi := (basisOfPrefix ℂ u h (a := 1) (by norm_num) (fun n => (hv n).ge)).linearIndependent + have hh := hi.lt_aleph0_of_finiteDimensional + simp at hh + refine ⟨H, Submodule.isClosed_topologicalClosure _, hHinf, ?_⟩ + apply complex_eval_separable_of_real + let evK : X → (H →L[ℝ] ℂ) := fun x => + ((ContinuousLinearMap.restrictScalarsL ℂ X ℂ ℝ ℝ).flip x).comp K + have hKsep : IsSeparable (Set.range evK) := perturbation_separable_eval u v h hv hfg + let φ : (E →L[ℝ] ℂ) × (H →L[ℝ] ℂ) → (H →L[ℝ] ℂ) := fun p => p.1.comp L - p.2 + have hφ : Continuous φ := by + let : IsTopologicalAddGroup (H →L[ℝ] ℂ) := ContinuousLinearMap.isTopologicalAddGroup + let : ContinuousSub (H →L[ℝ] ℂ) := IsTopologicalAddGroup.to_continuousSub + fun_prop + apply ((hEsep.prod hKsep).image hφ).mono + rintro _ ⟨x, rfl⟩ + refine ⟨(realEvaluation E x, evK x), ⟨Set.mem_range_self _, Set.mem_range_self _⟩, ?_⟩ + ext z + change ((z : StrongDual ℂ X) + K z) x - (K z) x = (z : StrongDual ℂ X) x + simp + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexSequences.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexSequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9164cd02d8c2fbc6c66f90a1eb909480bd8bc5a --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexSequences.lean @@ -0,0 +1,154 @@ +import OAI.Analysis.SeparableQuotients.Positive.ComplexSubspaces +import OAI.Analysis.SeparableQuotients.Positive.DualKernels +import OAI.Analysis.SeparableQuotients.Positive.ScalarBasis + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set TopologicalSpace +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℂ X] + [NormedSpace ℝ X] [IsScalarTower ℝ ℂ X] +local instance sequenceRealDualSubmoduleNormedGroup (space : Submodule ℝ (StrongDual ℂ X)) : + NormedAddCommGroup space := Submodule.normedAddCommGroup space +local instance sequenceRealDualSubmoduleNormedSpace (space : Submodule ℝ (StrongDual ℂ X)) : + NormedSpace ℝ space := Submodule.normedSpace space + + + +theorem exists_near_unit_annihilating + (E : Submodule ℝ (StrongDual ℂ X)) (hEcl : IsClosed (E : Set (StrongDual ℂ X))) + (hEinf : ¬ FiniteDimensional ℝ E) (hE : ¬ HasSeparatedInfiniteSubspace E) + (D : Finset X) {ε : ℝ} (hε : 0 < ε) : + ∃ f g : E, ‖f‖ = 1 ∧ (∀ d ∈ D, (f : StrongDual ℂ X) d = 0) ∧ + ‖(g : StrongDual ℂ X) - Complex.I • (f : StrongDual ℂ X)‖ < ε := by + let B : StrongDual ℂ X →L[ℝ] (D → ℂ) := ContinuousLinearMap.pi + (fun d => (ContinuousLinearMap.restrictScalarsL ℂ X ℂ ℝ ℝ).flip d.val) + let T := B.comp E.subtypeL + let M : Submodule ℝ (StrongDual ℂ X) := E ⊓ B.ker + have hME : M ≤ E := inf_le_left + have hMcl : IsClosed (M : Set (StrongDual ℂ X)) := hEcl.inter B.isClosed_ker + have hTinf := infiniteDimensional_ker_to_finite T hEinf + have hMinf : ¬ FiniteDimensional ℝ M := by + intro hh + let := hh + let J : T.ker →ₗ[ℝ] M := + { toFun := fun f => ⟨f.val.val, f.val.property, f.property⟩ + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + apply hTinf + apply FiniteDimensional.of_injective (V₂ := M) J + intro a b h + apply Subtype.ext + apply Subtype.ext + exact congrArg (fun y : M => (y : StrongDual ℂ X)) h + obtain ⟨f, hf, g, hfg⟩ := exists_near_rotation_of_not_separated E hE M hME hMcl hMinf hε + refine ⟨⟨f.val, hME f.property⟩, g, hf, ?_, hfg⟩ + intro d hd + exact congrFun f.property.2 (⟨d, hd⟩ : D) + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set TopologicalSpace +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℂ X] + [NormedSpace ℝ X] [IsScalarTower ℝ ℂ X] +attribute [local instance] sequenceRealDualSubmoduleNormedGroup sequenceRealDualSubmoduleNormedSpace +variable (E : Submodule ℝ (StrongDual ℂ X)) (hEcl : IsClosed (E : Set (StrongDual ℂ X))) + (hEinf : ¬ FiniteDimensional ℝ E) (hE : ¬ HasSeparatedInfiniteSubspace E) + +def chooseNearPair (n : ℕ) (D : Finset X) : E × E := by + let h := exists_near_unit_annihilating E hEcl hEinf hE D + (show (0 : ℝ) < (1/2)^n by positivity) + exact (h.choose, h.choose_spec.choose) + +lemma chooseNearPair_spec (n : ℕ) (D : Finset X) : + ‖(chooseNearPair E hEcl hEinf hE n D).1‖ = 1 ∧ + (∀ d ∈ D, ((chooseNearPair E hEcl hEinf hE n D).1 : StrongDual ℂ X) d = 0) ∧ + ‖((chooseNearPair E hEcl hEinf hE n D).2 : StrongDual ℂ X) - + Complex.I • ((chooseNearPair E hEcl hEinf hE n D).1 : StrongDual ℂ X)‖ < (1/2:ℝ)^n := by + exact (exists_near_unit_annihilating E hEcl hEinf hE D + (show (0 : ℝ) < (1/2)^n by positivity)).choose_spec.choose_spec + +def nearState : ℕ → (ℕ → E) × Finset X + | 0 => (fun _ => 0, chosenPrefixNormers (fun _ => (0 : StrongDual ℂ X)) 0) + | n+1 => + let s := nearState n + let v := (chooseNearPair E hEcl hEinf hE n s.2).1 + let f := Function.update s.1 n v + (f, s.2 ∪ chosenPrefixNormers (fun m => (f m : StrongDual ℂ X)) (n+1)) + +def nearPair (n : ℕ) : E × E := + chooseNearPair E hEcl hEinf hE n (nearState E hEcl hEinf hE n).2 + +def nearNormers (m : ℕ) : Finset X := + chosenPrefixNormers (fun n => ((nearState E hEcl hEinf hE m).1 n : StrongDual ℂ X)) m + +lemma nearState_value (n m : ℕ) (hn : n < m) : + (nearState E hEcl hEinf hE m).1 n = (nearPair E hEcl hEinf hE n).1 := by + induction m with + | zero => omega + | succ m ih => + by_cases hnm : n = m + · subst n + simp only [nearState, nearPair, Function.update_self] + · have hnm' : n < m := by omega + simpa only [nearState, Function.update_of_ne hnm] using ih hnm' + +lemma nearState_mono : Monotone (fun n => (nearState E hEcl hEinf hE n).2) := by + apply monotone_nat_of_le_succ + intro n + exact Finset.subset_union_left + +lemma nearNormers_subset (m : ℕ) : + nearNormers E hEcl hEinf hE m ⊆ (nearState E hEcl hEinf hE m).2 := by + cases m with + | zero => exact Finset.Subset.refl _ + | succ m => exact Finset.subset_union_right + +include hEcl hEinf hE + + + +theorem exists_near_prefix_sequence : + ∃ (f g : ℕ → E) (D : ℕ → Finset X), + (∀ n, ‖f n‖ = 1) ∧ (∀ m d, d ∈ D m → ‖d‖ ≤ 1) ∧ + (∀ m (v : StrongDual ℂ X), + v ∈ Submodule.span ℂ ((fun n => (f n : StrongDual ℂ X)) '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖) ∧ + (∀ m n, m ≤ n → ∀ d ∈ D m, (f n : StrongDual ℂ X) d = 0) ∧ + (∀ n, ‖(g n : StrongDual ℂ X) - Complex.I • (f n : StrongDual ℂ X)‖ < (1/2:ℝ)^n) := by + refine ⟨fun n => (nearPair E hEcl hEinf hE n).1, + fun n => (nearPair E hEcl hEinf hE n).2, nearNormers E hEcl hEinf hE, + fun n => (chooseNearPair_spec E hEcl hEinf hE n _).1, ?_, ?_, ?_, + fun n => (chooseNearPair_spec E hEcl hEinf hE n _).2.2⟩ + · intro m d hd + exact (chosenPrefixNormers_spec _ m).1 d hd + · intro m v hv + apply (chosenPrefixNormers_spec _ m).2 v + apply Submodule.span_mono (t := + (fun n => ((nearState E hEcl hEinf hE m).1 n : StrongDual ℂ X)) '' (Finset.range m : Set ℕ)) _ hv + rintro w ⟨n, hn, rfl⟩ + exact ⟨n, hn, congrArg Subtype.val (nearState_value E hEcl hEinf hE n m (Finset.mem_range.mp hn))⟩ + · intro m n hmn d hd + apply (chooseNearPair_spec E hEcl hEinf hE n _).2.1 + exact nearState_mono E hEcl hEinf hE hmn (nearNormers_subset E hEcl hEinf hE m hd) + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexSubspaces.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexSubspaces.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dbf7cbaf8355215f077f61375db6a4cdb6a4747 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ComplexSubspaces.lean @@ -0,0 +1,166 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℂ V] + [NormedSpace ℝ V] [IsScalarTower ℝ ℂ V] + + + +def complexOfInvariant (R : Submodule ℝ V) + (hI : ∀ x ∈ R, Complex.I • x ∈ R) : Submodule ℂ V where + carrier := R + zero_mem' := R.zero_mem + add_mem' := R.add_mem + smul_mem' z x hx := by + rw [← Complex.re_add_im z, add_smul, mul_smul] + have hre : (z.re : ℂ) • x = z.re • x := algebraMap_smul ℂ z.re x + have him : (z.im : ℂ) • (Complex.I • x) = z.im • (Complex.I • x) := + algebraMap_smul ℂ z.im (Complex.I • x) + rw [hre, him] + exact R.add_mem (R.smul_mem z.re hx) (R.smul_mem z.im (hI x hx)) + +def complexSum (W : Submodule ℝ V) : W × W →L[ℝ] V := + W.subtypeL.comp (ContinuousLinearMap.fst ℝ W W) + + Complex.I • W.subtypeL.comp (ContinuousLinearMap.snd ℝ W W) + +@[simp] lemma complexSum_apply (W : Submodule ℝ V) (p : W × W) : + complexSum W p = (p.1 : V) + Complex.I • (p.2 : V) := rfl + +lemma complexSum_range_invariant (W : Submodule ℝ V) : + ∀ x ∈ (complexSum W).range, Complex.I • x ∈ (complexSum W).range := by + rintro _ ⟨⟨u, v⟩, rfl⟩ + refine ⟨(-v, u), ?_⟩ + simp [complexSum_apply, smul_add, smul_smul, Complex.I_mul_I, add_comm] + + + + +def SeparatedFromMultiplication (E W : Submodule ℝ V) (C : ℝ) : Prop := + ∀ w : W, ∀ e : E, ‖w‖ ≤ C * ‖Complex.I • (w : V) - (e : V)‖ + +lemma complexSum_bound (E W : Submodule ℝ V) (hWE : W ≤ E) + {C : ℝ} (_hC : 0 ≤ C) (hsep : SeparatedFromMultiplication E W C) + (p : W × W) : ‖p‖ ≤ (1 + C) * ‖complexSum W p‖ := by + have hv : ‖p.2‖ ≤ C * ‖complexSum W p‖ := by + simpa [complexSum_apply, sub_neg_eq_add, add_comm] using + hsep p.2 ⟨-(p.1 : V), E.neg_mem (hWE p.1.property)⟩ + have hu : ‖p.1‖ ≤ (1 + C) * ‖complexSum W p‖ := by + have hid : (p.1 : V) = complexSum W p - Complex.I • (p.2 : V) := by + simp [complexSum_apply] + calc + ‖p.1‖ = ‖complexSum W p - Complex.I • (p.2 : V)‖ := congrArg norm hid + _ ≤ ‖complexSum W p‖ + ‖Complex.I • (p.2 : V)‖ := norm_sub_le _ _ + _ = ‖complexSum W p‖ + ‖p.2‖ := by simp [norm_smul] + _ ≤ ‖complexSum W p‖ + C * ‖complexSum W p‖ := add_le_add_right hv _ + _ = (1 + C) * ‖complexSum W p‖ := by ring + rw [Prod.norm_def] + exact max_le hu (hv.trans (by nlinarith [norm_nonneg (complexSum W p)])) + + + +theorem complex_subspace_of_separated [CompleteSpace V] + (E W : Submodule ℝ V) (hWE : W ≤ E) + (hWclosed : IsClosed (W : Set V)) (hWinf : ¬ FiniteDimensional ℝ W) + {C : ℝ} (hC : 0 ≤ C) (hsep : SeparatedFromMultiplication E W C) : + ∃ H : Submodule ℂ V, IsClosed (H : Set V) ∧ ¬ FiniteDimensional ℂ H ∧ + ∃ P Q : H →L[ℝ] E, ∀ h : H, + (h : V) = (P h : V) + Complex.I • (Q h : V) := by + let : IsClosed (W : Set V) := hWclosed + let B := complexSum W + have hB : AntilipschitzWith ⟨1 + C, by positivity⟩ B := + B.antilipschitz_of_bound (complexSum_bound E W hWE hC hsep) + have hBclosed : IsClosed (Set.range B) := + (hB.isClosedEmbedding B.uniformContinuous).isClosed_range + let H := complexOfInvariant B.range (complexSum_range_invariant W) + have hHclosed : IsClosed (H : Set V) := hBclosed + let : IsClosed (H : Set V) := hHclosed + let J : W × W →L[ℝ] H := B.codRestrict (H.restrictScalars ℝ) + (fun p => ⟨p, rfl⟩) + have hJinj : Function.Injective J := by + intro p q heq + exact hB.injective (congrArg Subtype.val heq) + have hJsurj : Function.Surjective J := by + intro h + obtain ⟨p, hp⟩ := h.property + exact ⟨p, Subtype.ext hp⟩ + let e : (W × W) ≃L[ℝ] H := ContinuousLinearEquiv.ofBijective J + (LinearMap.ker_eq_bot.mpr hJinj) (LinearMap.range_eq_top.mpr hJsurj) + have hHinf : ¬ FiniteDimensional ℂ H := by + intro hd + let := hd + let : FiniteDimensional ℝ H := FiniteDimensional.trans ℝ ℂ H + let j : W →ₗ[ℝ] H := e.toLinearMap.comp (LinearMap.inl ℝ W W) + apply hWinf + apply FiniteDimensional.of_injective (V₂ := H) j + exact e.injective.comp (fun u v h => congrArg Prod.fst h) + let L : W →L[ℝ] E := W.subtypeL.codRestrict E (fun w => hWE w.property) + let P : H →L[ℝ] E := (L.comp (ContinuousLinearMap.fst ℝ W W)).comp e.symm.toContinuousLinearMap + let Q : H →L[ℝ] E := (L.comp (ContinuousLinearMap.snd ℝ W W)).comp e.symm.toContinuousLinearMap + refine ⟨H, hHclosed, hHinf, P, Q, fun h => ?_⟩ + exact (congrArg Subtype.val (e.apply_symm_apply h)).symm + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set +variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℂ V] + [NormedSpace ℝ V] [IsScalarTower ℝ ℂ V] + +def HasSeparatedInfiniteSubspace (E : Submodule ℝ V) : Prop := + ∃ W : Submodule ℝ V, W ≤ E ∧ IsClosed (W : Set V) ∧ + ¬ FiniteDimensional ℝ W ∧ ∃ C : ℝ, 0 ≤ C ∧ SeparatedFromMultiplication E W C + + + + +theorem exists_near_rotation_of_not_separated + (E : Submodule ℝ V) (hE : ¬ HasSeparatedInfiniteSubspace E) + (M : Submodule ℝ V) (hME : M ≤ E) (hMclosed : IsClosed (M : Set V)) + (hMinf : ¬ FiniteDimensional ℝ M) {ε : ℝ} (hε : 0 < ε) : + ∃ f : M, ‖f‖ = 1 ∧ ∃ g : E, ‖(g : V) - Complex.I • (f : V)‖ < ε := by + have hnot : ¬ SeparatedFromMultiplication E M ε⁻¹ := + fun hh => hE ⟨M, hME, hMclosed, hMinf, ε⁻¹, inv_nonneg.mpr hε.le, hh⟩ + simp only [SeparatedFromMultiplication, not_forall, not_le] at hnot + obtain ⟨f, g, hfg⟩ := hnot + have hfpos : 0 < ‖f‖ := lt_of_le_of_lt (mul_nonneg (inv_nonneg.mpr hε.le) + (norm_nonneg _)) hfg + let u : M := ‖f‖⁻¹ • f + let v : E := ‖f‖⁻¹ • g + have hu : ‖u‖ = 1 := by + change ‖‖f‖⁻¹ • f‖ = 1 + exact norm_smul_inv_norm (norm_pos_iff.mp hfpos) + have herr : ‖(g : V) - Complex.I • (f : V)‖ < ε * ‖f‖ := by + have hh := (mul_lt_mul_iff_of_pos_left hε).mpr hfg + simpa only [← mul_assoc, mul_inv_cancel₀ (ne_of_gt hε), one_mul, norm_sub_rev] using hh + refine ⟨u, hu, v, ?_⟩ + have heq : (v : V) - Complex.I • (u : V) = + ‖f‖⁻¹ • ((g : V) - Complex.I • (f : V)) := by + simp only [u, v, Submodule.coe_smul, smul_sub] + rw [smul_comm Complex.I (‖f‖⁻¹)] + rw [heq, norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hfpos)] + calc + ‖f‖⁻¹ * ‖(g : V) - Complex.I • (f : V)‖ < ‖f‖⁻¹ * (ε * ‖f‖) := + (mul_lt_mul_iff_of_pos_left (inv_pos.mpr hfpos)).mpr herr + _ = ε := by field_simp + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ContinuumMeasure.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ContinuumMeasure.lean new file mode 100644 index 0000000000000000000000000000000000000000..098da4d840e7577853a1607c62ef1c7be4fc6542 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ContinuumMeasure.lean @@ -0,0 +1,438 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Rows +abbrev ContinuumIndex : Type := Cardinal.continuum.ord.ToType +instance continuumMeasurableSpace : MeasurableSpace ContinuumIndex := ⊤ +def ContinuumAdditive (μ : Measure ContinuumIndex) : Prop := + ∀ (ι : Type) (_ : Cardinal.mk ι < Cardinal.continuum) + (A : ι → Set ContinuumIndex), Pairwise (fun i j => Disjoint (A i) (A j)) → + μ (⋃ i, A i) = ∑' i, μ (A i) + + + +theorem small_null_union (μ : Measure ContinuumIndex) (hadd : ContinuumAdditive μ) + {ι : Type} (hι : Cardinal.mk ι < Cardinal.continuum) + (A : ι → Set ContinuumIndex) (hA : ∀ i, μ (A i) = 0) : + μ (⋃ i, A i) = 0 := by + classical + let U := ⋃ i, A i + let pick : U → ι := fun x => Classical.choose (Set.mem_iUnion.mp x.property) + have hpick (x : U) : x.val ∈ A (pick x) := + Classical.choose_spec (Set.mem_iUnion.mp x.property) + let B : ι → Set ContinuumIndex := fun i => {x | ∃ hx : x ∈ U, pick ⟨x, hx⟩ = i} + have hBA (i : ι) : B i ⊆ A i := by + rintro x ⟨hx, hi⟩ + simpa only [← hi] using hpick ⟨x, hx⟩ + have hdisj : Pairwise (fun i j => Disjoint (B i) (B j)) := by + intro i j hij + rw [Set.disjoint_left] + rintro x ⟨hx, hi⟩ ⟨hx', hj⟩ + exact hij (hi.symm.trans hj) + have hUn : (⋃ i, B i) = U := by + ext x + simp only [Set.mem_iUnion] + constructor + · rintro ⟨i, hx, _⟩ + exact hx + · intro hx + exact ⟨pick ⟨x, hx⟩, hx, rfl⟩ + rw [show (⋃ i, A i) = ⋃ i, B i from hUn.symm, hadd ι hι B hdisj] + have hz (i : ι) : μ (B i) = 0 := measure_mono_null (hBA i) (hA i) + simp only [hz, tsum_zero] + +theorem small_set_null (μ : Measure ContinuumIndex) (hadd : ContinuumAdditive μ) + (hsingle : ∀ i, μ {i} = 0) (A : Set ContinuumIndex) + (hA : Cardinal.mk A < Cardinal.continuum) : μ A = 0 := by + have h := small_null_union μ hadd hA (fun i : A => {i.val}) (fun i => hsingle i.val) + simpa using h + +theorem continuum_regular (μ : Measure ContinuumIndex) [IsProbabilityMeasure μ] + (hadd : ContinuumAdditive μ) (hsingle : ∀ i, μ {i} = 0) : + Cardinal.IsRegular Cardinal.continuum.{0} := by + refine ⟨Cardinal.aleph0_le_continuum, ?_⟩ + by_contra! h + obtain ⟨s, hs, hcard⟩ := Order.exists_cof_eq ContinuumIndex + have hsmall : Cardinal.mk s < Cardinal.continuum := by + rw [hcard, Ordinal.cof_toType] + exact h + have hcover : (⋃ i : s, Set.Iic i.val) = Set.univ := by + apply Set.eq_univ_iff_forall.mpr + intro x + obtain ⟨i, hi, hxi⟩ := hs x + exact Set.mem_iUnion.mpr ⟨⟨i, hi⟩, hxi⟩ + have hnull (i : s) : μ (Set.Iic i.val) = 0 := by + rw [← Set.Iio_union_right] + exact measure_union_null + (small_set_null μ hadd hsingle _ (by simpa using Cardinal.mk_Iio_lt i.val (by simp [ContinuumIndex]))) + (hsingle i.val) + have := small_null_union μ hadd hsmall (fun i : s => Set.Iic i.val) hnull + rw [hcover, measure_univ] at this + exact one_ne_zero this + + + +theorem continuous_cdf_of_null_singletons (ν : Measure ℝ) [IsProbabilityMeasure ν] + [NullSingletonClass ν] : Continuous (ProbabilityTheory.cdf ν) := by + apply continuous_iff_continuousAt.mpr + intro x + let f := ProbabilityTheory.cdf ν + apply f.mono.continuousAt_iff_leftLim_eq_rightLim.mpr + rw [f.rightLim_eq] + apply le_antisymm (f.mono.leftLim_le (le_refl x)) + have h : ENNReal.ofReal (f x - leftLim f x) = 0 := by + rw [← StieltjesFunction.measure_singleton, ProbabilityTheory.measure_cdf] + exact measure_singleton x + exact sub_nonpos.mp (ENNReal.ofReal_eq_zero.mp h) + +theorem exists_cdf_value (ν : Measure ℝ) [IsProbabilityMeasure ν] [NullSingletonClass ν] + {t : ℝ} (ht : 0 < t) (ht' : t < 1) : ∃ x, ProbabilityTheory.cdf ν x = t := by + exact intermediate_value_univ₂_eventually₂ (continuous_cdf_of_null_singletons ν) + continuous_const ((ProbabilityTheory.tendsto_cdf_atBot ν).eventually_le_const ht) + ((ProbabilityTheory.tendsto_cdf_atTop ν).eventually_const_le ht') + + + +theorem exists_subset_measure_of_real_embedding + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) [IsFiniteMeasure μ] [NullSingletonClass μ] + (b : I ↪ ℝ) (A : Set I) {t : ℝ} (ht : 0 ≤ t) (htA : t ≤ μ.real A) : + ∃ B ⊆ A, μ B = ENNReal.ofReal t := by + classical + by_cases ht0 : t = 0 + · exact ⟨∅, empty_subset _, by simp [ht0]⟩ + by_cases htEq : t = μ.real A + · exact ⟨A, Subset.rfl, by simp [htEq, measureReal_def]⟩ + have htpos : 0 < t := lt_of_le_of_ne ht (Ne.symm ht0) + have htlt : t < μ.real A := lt_of_le_of_ne htA htEq + have hApos : 0 < (μ A).toReal := htpos.trans htlt + have hA0 : μ A ≠ 0 := by + intro h + simp only [h, ENNReal.toReal_zero, lt_self_iff_false] at hApos + let p : Measure I := (μ A)⁻¹ • μ.restrict A + have hp : IsProbabilityMeasure p := by + constructor + simp [p, Measure.smul_apply, ENNReal.inv_mul_cancel hA0 (measure_ne_top μ A)] + have hpn : NullSingletonClass p := by + constructor + intro i + simp [p, Measure.smul_apply, measure_singleton] + let q : Measure ℝ := p.map b + have hq : IsProbabilityMeasure q := inferInstance + have hqn : NullSingletonClass q := by + constructor + intro x + rw [show q = p.map b from rfl, + Measure.map_apply Measurable.of_discrete (measurableSet_singleton x)] + exact (Set.subsingleton_singleton.preimage b.injective).measure_zero p + obtain ⟨x, hx⟩ := exists_cdf_value q (div_pos htpos hApos) + ((div_lt_one hApos).mpr htlt) + refine ⟨b ⁻¹' Iic x ∩ A, inter_subset_right, ?_⟩ + calc + μ (b ⁻¹' Iic x ∩ A) = μ A * q (Iic x) := by + rw [show q = p.map b from rfl, + Measure.map_apply Measurable.of_discrete measurableSet_Iic] + simp only [p, Measure.smul_apply, smul_eq_mul, + Measure.restrict_apply MeasurableSet.of_discrete] + rw [ENNReal.mul_inv_cancel_left hA0 (measure_ne_top μ A)] + _ = μ A * ENNReal.ofReal (t / (μ A).toReal) := by + rw [← ProbabilityTheory.ofReal_cdf q x, hx] + _ = ENNReal.ofReal t := by + rw [ENNReal.ofReal_div_of_pos hApos, ENNReal.ofReal_toReal (measure_ne_top μ A)] + rw [div_eq_mul_inv, mul_left_comm, ENNReal.mul_inv_cancel (hA0) (measure_ne_top μ A), mul_one] + + +theorem atomless_of_real_embedding + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) [IsFiniteMeasure μ] [NullSingletonClass μ] + (b : I ↪ ℝ) (A : Set I) (hA : 0 < μ A) : + ∃ B ⊆ A, 0 < μ B ∧ μ B < μ A := by + have hp : 0 < μ.real A := ENNReal.toReal_pos hA.ne' (measure_ne_top μ A) + obtain ⟨B, hBA, hB⟩ := exists_subset_measure_of_real_embedding μ b A + (t := μ.real A / 2) (by positivity) (by linarith) + refine ⟨B, hBA, ?_, ?_⟩ + · rw [hB] + exact ENNReal.ofReal_pos.mpr (by positivity) + · rw [hB, ← ENNReal.ofReal_toReal (measure_ne_top μ A)] + apply (ENNReal.ofReal_lt_ofReal_iff hp).mpr + linarith + + +theorem exists_subset_measure_ennreal + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) [IsFiniteMeasure μ] [NullSingletonClass μ] + (b : I ↪ ℝ) (A : Set I) {t : ℝ≥0∞} (htA : t ≤ μ A) : + ∃ B ⊆ A, μ B = t := by + have htfin : t ≠ ∞ := ne_top_of_le_ne_top (measure_ne_top μ A) htA + obtain ⟨B, hB, hμB⟩ := exists_subset_measure_of_real_embedding μ b A + (t := t.toReal) ENNReal.toReal_nonneg (ENNReal.toReal_mono (measure_ne_top μ A) htA) + exact ⟨B, hB, by simpa only [ENNReal.ofReal_toReal htfin] using hμB⟩ + + + +theorem exists_equal_partition + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) [IsFiniteMeasure μ] [NullSingletonClass μ] + (b : I ↪ ℝ) (n : ℕ) (A : Set I) (t : ℝ≥0∞) + (hA : μ A = (n + 1 : ℕ) * t) : + ∃ P : Fin (n + 1) → Set I, + Pairwise (fun i j => Disjoint (P i) (P j)) ∧ + (⋃ i, P i) = A ∧ ∀ i, μ (P i) = t := by + classical + induction n generalizing A with + | zero => + have : Nonempty (Fin (0 + 1)) := ⟨⟨0, by decide⟩⟩ + refine ⟨fun _ => A, ?_, ?_, ?_⟩ + · intro i j hij + exact (hij (Fin.ext (by omega))).elim + · ext x + simp only [Set.mem_iUnion] + exact ⟨fun ⟨i, hi⟩ => hi, fun hx => ⟨⟨0, by decide⟩, hx⟩⟩ + · intro i + simpa using hA + | succ n ih => + have htA : t ≤ μ A := by + rw [hA] + exact le_mul_of_one_le_left' (by norm_cast; omega) + obtain ⟨B, hBA, hB⟩ := exists_subset_measure_ennreal μ b A htA + have htfin : t ≠ ∞ := ne_top_of_le_ne_top (measure_ne_top μ A) htA + have hrem : μ (A \ B) = (n + 1 : ℕ) * t := by + rw [measure_sdiff hBA MeasurableSet.of_discrete.nullMeasurableSet (measure_ne_top μ B), hA, hB] + have hcast : ((n + 1 + 1 : ℕ) : ℝ≥0∞) = (n + 1 : ℕ) + 1 := by simp + rw [show n.succ + 1 = n + 1 + 1 from rfl, hcast, add_mul, one_mul] + exact ENNReal.add_sub_cancel_right htfin + obtain ⟨P, hdisj, hcover, hmass⟩ := ih (A \ B) hrem + have hPB (i) : P i ⊆ A \ B := by + rw [← hcover] + exact Set.subset_iUnion P i + refine ⟨Fin.cons B P, ?_, ?_, ?_⟩ + · intro i + refine Fin.cases ?_ (fun i => ?_) i + · intro j + refine Fin.cases ?_ (fun j => ?_) j + · intro hij + exact (hij rfl).elim + · intro _ + simpa using (disjoint_sdiff_right.mono_right (hPB j) : Disjoint B (P j)) + · intro j + refine Fin.cases ?_ (fun j => ?_) j + · intro _ + simpa using (disjoint_sdiff_right.mono_right (hPB i)).symm + · intro hij + simpa using hdisj (fun h => hij (congrArg Fin.succ h)) + · have hunion : (⋃ i, (Fin.cons B P : Fin (n + 2) → Set I) i) = B ∪ ⋃ i, P i := by + ext x + simp only [Set.mem_iUnion, Fin.exists_fin_succ, Fin.cons_zero, + Fin.cons_succ, Set.mem_union] + rw [hunion, hcover] + exact union_sdiff_cancel hBA + · intro i + exact Fin.cases (by simpa using hB) (fun j => by simpa using hmass j) i + + +theorem exists_uniform_finite_map + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) [IsProbabilityMeasure μ] [NullSingletonClass μ] + (b : I ↪ ℝ) (N : ℕ) (hN : 0 < N) : + ∃ j : I → Fin N, ∀ i, μ (j ⁻¹' {i}) = (N : ℝ≥0∞)⁻¹ := by + classical + obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hN) + obtain ⟨P, hdisj, hcover, hmass⟩ := exists_equal_partition μ b n Set.univ + ((n + 1 : ℕ) : ℝ≥0∞)⁻¹ (by + rw [measure_univ] + symm + exact ENNReal.mul_inv_cancel (by simp) (by simp)) + have hex (x : I) : ∃ i, x ∈ P i := by + apply Set.mem_iUnion.mp + rw [hcover] + exact Set.mem_univ x + let j : I → Fin (n + 1) := fun x => Classical.choose (hex x) + have hj (x : I) : x ∈ P (j x) := Classical.choose_spec (hex x) + refine ⟨j, fun i => ?_⟩ + have hfiber : j ⁻¹' {i} = P i := by + ext x + constructor + · intro hx + have : j x = i := hx + simpa only [← this] using hj x + · intro hx + change j x = i + by_contra hne + exact Set.disjoint_left.mp (hdisj hne) (hj x) hx + rw [hfiber] + exact hmass i + + +def RealValuedMeasurableContinuum : Prop := + ∃ μ : Measure ContinuumIndex, + μ Set.univ = 1 ∧ (∀ i, μ {i} = 0) ∧ ContinuumAdditive μ + +noncomputable def continuumRealEmbedding : ContinuumIndex ↪ ℝ := + (Classical.choice (Cardinal.eq.mp (by + simp [ContinuumIndex, Cardinal.mk_real]))).toEmbedding + + + +theorem continuum_measure_prerequisites (μ : Measure ContinuumIndex) + [IsProbabilityMeasure μ] (hadd : ContinuumAdditive μ) + (hsingle : ∀ i, μ {i} = 0) : + Cardinal.IsRegular Cardinal.continuum.{0} ∧ + (∀ A : Set ContinuumIndex, 0 < μ A → + ∃ B ⊆ A, 0 < μ B ∧ μ B < μ A) ∧ + (∀ N : ℕ, 0 < N → ∃ j : ContinuumIndex → Fin N, + ∀ i, μ (j ⁻¹' {i}) = (N : ℝ≥0∞)⁻¹) := by + let : NullSingletonClass μ := ⟨hsingle⟩ + exact ⟨continuum_regular μ hadd hsingle, + atomless_of_real_embedding μ continuumRealEmbedding, + exists_uniform_finite_map μ continuumRealEmbedding⟩ + + + +theorem small_null_union_lift {ι : Type u} (μ : Measure ContinuumIndex) + (hadd : ContinuumAdditive μ) (hι : Cardinal.mk ι < Cardinal.continuum.{u}) + (A : ι → Set ContinuumIndex) (hA : ∀ i, μ (A i) = 0) : + μ (⋃ i, A i) = 0 := by + classical + have hc : HasCardinalLT ι Cardinal.continuum.{0} := by + simpa only [HasCardinalLT, Cardinal.lift_uzero, Cardinal.lift_continuum] using hι + let : Small.{0} ι := hc.small + have hs : Cardinal.mk (Shrink.{0} ι) < Cardinal.continuum.{0} := by + have ht : Cardinal.lift.{u} (Cardinal.mk (Shrink.{0} ι)) < Cardinal.continuum.{u} := by + simpa only [Cardinal.lift_mk_shrink', Cardinal.lift_uzero] using hι + exact Cardinal.lift_lt_continuum.mp ht + have hz := small_null_union μ hadd hs (fun j : Shrink.{0} ι => A ((equivShrink ι).symm j)) + (fun j => hA _) + rwa [(equivShrink ι).symm.surjective.iUnion_comp A] at hz + + +theorem small_ae_all {ι : Type u} (μ : Measure ContinuumIndex) + (hadd : ContinuumAdditive μ) (hι : Cardinal.mk ι < Cardinal.continuum.{u}) + (P : ι → ContinuumIndex → Prop) (hP : ∀ i, ∀ᵐ x ∂μ, P i x) : + ∀ᵐ x ∂μ, ∀ i, P i x := by + rw [ae_iff] + have hz := small_null_union_lift μ hadd hι (fun i => {x | ¬ P i x}) + (fun i => ae_iff.mp (hP i)) + convert hz using 2 + ext x + simp only [Set.mem_iUnion, Set.mem_ofPred_eq, not_forall] + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + + +lemma row_sum_abs_le {N : ℕ} (u : Fin N → E) + (hu : ∀ c : Fin N → ℝ, ‖∑ j, c j • u j‖ ≤ 2 * Real.sqrt (∑ j, (c j)^2)) + (y : StrongDual ℝ E) (hy : ‖y‖ ≤ 1) : + ∑ j, |y (u j)| ≤ 2 * Real.sqrt N := by + let b (j : Fin N) := y (u j) + let S : ℝ := ∑ j, (b j)^2 + have hS : 0 ≤ S := Finset.sum_nonneg (fun _ _ => sq_nonneg _) + have hv : S ≤ 2 * Real.sqrt S := by + calc + S = y (∑ j, b j • u j) := by simp [S, b, sq, map_sum, map_smul] + _ ≤ ‖y (∑ j, b j • u j)‖ := le_abs_self _ + _ ≤ ‖∑ j, b j • u j‖ := by + exact (y.le_opNorm _).trans ((mul_le_mul_of_nonneg_right hy (norm_nonneg _)).trans_eq (one_mul _)) + _ ≤ 2 * Real.sqrt S := hu b + have hsqrt : Real.sqrt S ≤ 2 := by + nlinarith [Real.sq_sqrt hS, Real.sqrt_nonneg S] + have hS4 : S ≤ 4 := by nlinarith [Real.sq_sqrt hS, Real.sqrt_nonneg S] + have hc := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset (Fin N)) + (fun _ => (1 : ℝ)) (fun j => |b j|) + have hc' : (∑ j, |b j|)^2 ≤ (N : ℝ) * S := by + simpa only [one_mul, one_pow, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + nsmul_eq_mul, mul_one, sq_abs, S] using hc + have hn : 0 ≤ (N : ℝ) := Nat.cast_nonneg N + have hsum : 0 ≤ ∑ j, |b j| := Finset.sum_nonneg (fun _ _ => abs_nonneg _) + have hh : (N : ℝ) * S ≤ (N : ℝ) * 4 := mul_le_mul_of_nonneg_left hS4 hn + change (∑ j, |b j|) ≤ _ + nlinarith [Real.sq_sqrt hn, Real.sqrt_nonneg (N : ℝ)] + +lemma lintegral_uniform_finite + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) {N : ℕ} (hN : 0 < N) (j : I → Fin N) + (hj : ∀ i, μ (j ⁻¹' {i}) = (N : ℝ≥0∞)⁻¹) + (b : Fin N → ℝ) (hb : ∀ i, 0 ≤ b i) : + (∫⁻ α, ENNReal.ofReal (b (j α)) ∂μ) = ENNReal.ofReal ((∑ i, b i) / N) := by + rw [← lintegral_map (f := fun i => ENNReal.ofReal (b i)) Measurable.of_discrete (Measurable.of_discrete (f := j)), lintegral_fintype] + simp only [Measure.map_apply (Measurable.of_discrete (f := j)) (measurableSet_singleton _), hj] + rw [← Finset.sum_mul, ← ENNReal.ofReal_sum_of_nonneg (fun i _ => hb i)] + rw [ENNReal.ofReal_div_of_pos (by exact_mod_cast hN), ENNReal.ofReal_natCast, div_eq_mul_inv] + + + +lemma ae_summable_of_expected_bound + {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] (μ : Measure I) + (v : ℕ → I → ℝ) (b : ℕ → ℝ) (hb : ∀ n, 0 ≤ b n) (hs : Summable b) + (hv : ∀ n, (∫⁻ α, ENNReal.ofReal |v n α| ∂μ) ≤ ENNReal.ofReal (b n)) : + ∀ᵐ α ∂μ, Summable (fun n => |v n α|) := by + have hfin : (∫⁻ α, ∑' n, ENNReal.ofReal |v n α| ∂μ) ≠ ⊤ := by + rw [lintegral_tsum (fun n => Measurable.of_discrete.aemeasurable)] + apply ne_of_lt + exact lt_of_le_of_lt (ENNReal.tsum_le_tsum hv) + (by rw [← ENNReal.ofReal_tsum_of_nonneg hb hs]; exact ENNReal.ofReal_lt_top) + filter_upwards [ae_lt_top Measurable.of_discrete hfin] with α hα + have hz : (∑' n, ‖v n α‖ₑ) ≠ ⊤ := by + simpa only [← ofReal_norm, Real.norm_eq_abs] using hα.ne + simpa only [Real.norm_eq_abs] using tsum_enorm_ne_top_iff_summable_norm.mp hz + + +lemma row_geometric_identity (n : ℕ) : + 2 * Real.sqrt ((16 ^ (n+1) : ℕ) : ℝ) / (16 ^ (n+1) : ℕ) = + (1 / 2 : ℝ) * (1 / 4) ^ n := by + have hN : ((16 ^ (n+1) : ℕ) : ℝ) = ((4 : ℝ) ^ (n+1)) ^ 2 := by + push_cast + rw [← pow_mul, Nat.mul_comm, pow_mul] + norm_num + rw [hN, Real.sqrt_sq (by positivity)] + rw [pow_succ, div_pow] + field_simp + ring + + + +theorem select_rows_from_small_set {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] + (μ : Measure ContinuumIndex) [IsProbabilityMeasure μ] + (hadd : ContinuumAdditive μ) (hsingle : ∀ i, μ {i} = 0) + (u : ∀ n : ℕ, Fin (16 ^ (n+1)) → E) + (hu : ∀ n (c : Fin (16 ^ (n+1)) → ℝ), + ‖∑ j, c j • u n j‖ ≤ 2 * Real.sqrt (∑ j, (c j)^2)) + (A : Set (StrongDual ℝ E)) (hA : Cardinal.mk A < Cardinal.continuum.{u}) + (hy : ∀ y ∈ A, ‖y‖ ≤ 1) : + ∃ j : ∀ n : ℕ, Fin (16 ^ (n+1)), ∀ y ∈ A, Summable (fun n => |y (u n (j n))|) := by + have hN (n : ℕ) : 0 < 16 ^ (n+1) := pow_pos (by norm_num) _ + have hm (n : ℕ) := (continuum_measure_prerequisites μ hadd hsingle).2.2 _ (hN n) + choose j hj using hm + let b (n : ℕ) : ℝ := (1 / 2) * (1 / 4) ^ n + have hb : Summable b := + (summable_geometric_of_lt_one (by norm_num : (0:ℝ) ≤ 1 / 4) (by norm_num)).mul_left _ + have hsum (y : A) : ∀ᵐ α ∂μ, Summable (fun n => |y.val (u n (j n α))|) := by + apply ae_summable_of_expected_bound μ _ b (fun n => by dsimp [b]; positivity) hb + intro n + rw [lintegral_uniform_finite μ (hN n) (j n) (hj n) + (fun i => |y.val (u n i)|) (fun _ => abs_nonneg _)] + apply ENNReal.ofReal_le_ofReal + calc + (∑ i, |y.val (u n i)|) / (16 ^ (n+1) : ℕ) ≤ + (2 * Real.sqrt ((16 ^ (n+1) : ℕ) : ℝ)) / (16 ^ (n+1) : ℕ) := + div_le_div_of_nonneg_right (row_sum_abs_le (u n) (hu n) y.val (hy y.val y.property)) (by positivity) + _ = b n := row_geometric_identity n + have hall := small_ae_all μ hadd hA (fun y : A => fun α => + Summable (fun n => |y.val (u n (j n α))|)) hsum + obtain ⟨α, hα⟩ := hall.exists + exact ⟨fun n => j n α, fun y hy => hα ⟨y, hy⟩⟩ + +end SeparableQuotient.Positive.Rows + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/DualKernels.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/DualKernels.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fd4f570a404055a669522ec808a169ecc770be5 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/DualKernels.lean @@ -0,0 +1,132 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields +variable {𝕜 : Type*} [RCLike 𝕜] {V W : Type*} + [NormedAddCommGroup V] [NormedSpace 𝕜 V] + [NormedAddCommGroup W] [NormedSpace 𝕜 W] + + + +lemma infiniteDimensional_ker_to_finite (T : V →L[𝕜] W) [FiniteDimensional 𝕜 W] + (hV : ¬ FiniteDimensional 𝕜 V) : ¬ FiniteDimensional 𝕜 T.ker := by + intro hker + let := hker + have htop : FiniteDimensional 𝕜 ((⊤ : Submodule 𝕜 W).comap T.toLinearMap) := inferInstance + let := htop + let J : V →ₗ[𝕜] ((⊤ : Submodule 𝕜 W).comap T.toLinearMap) := + (LinearMap.id : V →ₗ[𝕜] V).codRestrict _ (fun _ => Submodule.mem_top) + exact hV (FiniteDimensional.of_injective J (fun a b h => congrArg Subtype.val h)) + +lemma exists_unit_of_infiniteDimensional (hV : ¬ FiniteDimensional 𝕜 V) : + ∃ v : V, ‖v‖ = 1 := by + have : Nontrivial V := by + by_contra hh + have : Subsingleton V := not_nontrivial_iff_subsingleton.mp hh + exact hV inferInstance + obtain ⟨v, hv⟩ := exists_ne (0 : V) + exact ⟨(‖v‖ : 𝕜)⁻¹ • v, norm_smul_inv_norm hv⟩ + +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] +local instance kernelDualSubmoduleNormedGroup (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + NormedAddCommGroup F := Submodule.normedAddCommGroup F +local instance kernelDualSubmoduleNormedSpace (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + NormedSpace 𝕜 F := Submodule.normedSpace F + +lemma exists_unit_annihilating_finite + (F : Submodule 𝕜 (StrongDual 𝕜 X)) (hF : ¬ FiniteDimensional 𝕜 F) (D : Finset X) : + ∃ f : F, ‖f‖ = 1 ∧ ∀ d ∈ D, (f : StrongDual 𝕜 X) d = 0 := by + let T : F →L[𝕜] (D → 𝕜) := ContinuousLinearMap.pi (fun d => F.subtypeL.flip d.val) + have hinf := infiniteDimensional_ker_to_finite T hF + obtain ⟨f, hf⟩ := exists_unit_of_infiniteDimensional hinf + refine ⟨f.val, hf, ?_⟩ + intro d hd + have hh := congrFun f.property (⟨d, hd⟩ : D) + exact hh +end SeparableQuotient.Positive.Fields + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields +variable {𝕜 : Type*} [RCLike 𝕜] {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] +local instance scalarDualSubmoduleNormedGroup (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + NormedAddCommGroup F := Submodule.normedAddCommGroup F +local instance scalarDualSubmoduleNormedSpace (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + NormedSpace 𝕜 F := Submodule.normedSpace F + +theorem exists_finite_half_normers_scalar (F : Submodule 𝕜 (StrongDual 𝕜 X)) + [FiniteDimensional 𝕜 F] : + ∃ D : Finset X, (∀ x ∈ D, ‖x‖ ≤ 1) ∧ + ∀ f ∈ F, ∃ x ∈ D, ‖f‖ ≤ 2 * ‖f x‖ := by + classical + let U : {x : X // ‖x‖ ≤ 1} → Set F := fun x => {f | (1:ℝ)/2 < ‖f.val x.val‖} + have ho (x : {x : X // ‖x‖ ≤ 1}) : IsOpen (U x) := + isOpen_lt continuous_const ((F.subtypeL.flip x.val).continuous.norm) + have hcover : sphere (0 : F) 1 ⊆ ⋃ x, U x := by + intro f hf + have hn : ‖f.val‖ = 1 := by simpa only [mem_sphere, dist_zero_right, Submodule.norm_coe] using hf + obtain ⟨x, hx, hfx⟩ := f.val.exists_lt_apply_of_lt_opNorm (show (1:ℝ)/2 < ‖f.val‖ by rw [hn]; norm_num) + exact mem_iUnion.mpr ⟨⟨x, hx.le⟩, hfx⟩ + obtain ⟨D₀, hD₀⟩ := (isCompact_sphere (0 : F) 1).elim_finite_subcover U ho hcover + let D := insert 0 (D₀.image Subtype.val) + refine ⟨D, ?_, ?_⟩ + · intro x hx + rcases Finset.mem_insert.mp hx with rfl | hx + · simp + · obtain ⟨y, _, rfl⟩ := Finset.mem_image.mp hx + exact y.property + · intro f hf + by_cases hh : f = 0 + · exact ⟨0, Finset.mem_insert_self _ _, by simp [hh]⟩ + let v : F := ⟨f, hf⟩ + have hv : v ≠ 0 := by intro h; exact hh (congrArg Subtype.val h) + let g : F := (‖f‖ : 𝕜)⁻¹ • v + have hg : g ∈ sphere (0 : F) 1 := by + rw [mem_sphere, dist_zero_right] + change ‖(‖v‖ : 𝕜)⁻¹ • v‖ = 1 + exact norm_smul_inv_norm hv + obtain ⟨x, hx⟩ := mem_iUnion.mp (hD₀ hg) + obtain ⟨hxD, hxg⟩ := mem_iUnion.mp hx + refine ⟨x.val, Finset.mem_insert_of_mem (Finset.mem_image.mpr ⟨x, hxD, rfl⟩), ?_⟩ + have he : (1:ℝ)/2 < ‖f‖⁻¹ * ‖f x.val‖ := by + simpa only [U, mem_ofPred_eq, g, Submodule.coe_smul, smul_apply, norm_smul, + norm_inv, RCLike.norm_ofReal, Real.norm_eq_abs, abs_norm, v] using hxg + have hn : 0 < ‖f‖ := norm_pos_iff.mpr hh + have hv' := mul_lt_mul_of_pos_left he hn + field_simp at hv' + linarith + +lemma exists_prefix_half_normers (f : ℕ → StrongDual 𝕜 X) (n : ℕ) : + ∃ D : Finset X, (∀ x ∈ D, ‖x‖ ≤ 1) ∧ + ∀ v ∈ Submodule.span 𝕜 (f '' (Finset.range n : Set ℕ)), + ∃ x ∈ D, ‖v‖ ≤ 2 * ‖v x‖ := by + have : FiniteDimensional 𝕜 (Submodule.span 𝕜 (f '' (Finset.range n : Set ℕ))) := + (Submodule.fg_iff_finiteDimensional _).mp (Submodule.fg_span ((Finset.finite_toSet _).image _)) + exact exists_finite_half_normers_scalar _ + +def chosenPrefixNormers (f : ℕ → StrongDual 𝕜 X) (n : ℕ) : Finset X := + (exists_prefix_half_normers f n).choose + +lemma chosenPrefixNormers_spec (f : ℕ → StrongDual 𝕜 X) (n : ℕ) : + (∀ x ∈ chosenPrefixNormers f n, ‖x‖ ≤ 1) ∧ + ∀ v ∈ Submodule.span 𝕜 (f '' (Finset.range n : Set ℕ)), + ∃ x ∈ chosenPrefixNormers f n, ‖v‖ ≤ 2 * ‖v x‖ := + (exists_prefix_half_normers f n).choose_spec +end SeparableQuotient.Positive.Fields + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/DualSequences.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/DualSequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..f18764e1292178282a0f0d0a4111c941305e9a60 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/DualSequences.lean @@ -0,0 +1,140 @@ +import OAI.Analysis.SeparableQuotients.Positive.DualKernels +import OAI.Analysis.SeparableQuotients.Positive.ScalarBasis + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields +attribute [local instance] scalarDualSubmoduleNormedGroup scalarDualSubmoduleNormedSpace +variable {𝕜 : Type*} [RCLike 𝕜] {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + +def chooseUnitVector (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (D : Finset X) : F := + (exists_unit_annihilating_finite F hF D).choose + +lemma chooseUnitVector_spec (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (D : Finset X) : + ‖chooseUnitVector F hF D‖ = 1 ∧ + ∀ d ∈ D, (chooseUnitVector F hF D : StrongDual 𝕜 X) d = 0 := + (exists_unit_annihilating_finite F hF D).choose_spec + + +def normerState (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) : ℕ → (ℕ → F) × Finset X + | 0 => (fun _ => 0, chosenPrefixNormers (fun _ => (0 : StrongDual 𝕜 X)) 0) + | n+1 => + let s := normerState F hF x n + let v := chooseUnitVector F hF (insert (x n) s.2) + let f := Function.update s.1 n v + (f, s.2 ∪ insert (x n) (chosenPrefixNormers (fun m => (f m : StrongDual 𝕜 X)) (n+1))) + +def selectedVector (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (n : ℕ) : F := + chooseUnitVector F hF (insert (x n) (normerState F hF x n).2) + +def selectedNormers (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (m : ℕ) : Finset X := + chosenPrefixNormers (fun n => ((normerState F hF x m).1 n : StrongDual 𝕜 X)) m + +lemma normerState_value (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (n m : ℕ) (hn : n < m) : + (normerState F hF x m).1 n = selectedVector F hF x n := by + induction m with + | zero => omega + | succ m ih => + by_cases hnm : n = m + · subst n + simp only [normerState, selectedVector, Function.update_self] + · have hnm' : n < m := by omega + simpa only [normerState, Function.update_of_ne hnm] using ih hnm' + +lemma normerState_mono (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) : + Monotone (fun n => (normerState F hF x n).2) := by + apply monotone_nat_of_le_succ + intro n + exact Finset.subset_union_left + +lemma selectedNormers_subset_state (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (m : ℕ) : + selectedNormers F hF x m ⊆ (normerState F hF x m).2 := by + cases m with + | zero => exact Finset.Subset.refl _ + | succ m => + exact (Finset.subset_insert _ _).trans Finset.subset_union_right + +lemma selectedVector_norm (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (n : ℕ) : + ‖selectedVector F hF x n‖ = 1 := + (chooseUnitVector_spec F hF _).1 + +lemma selectedVector_ann_test (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (n j : ℕ) (hj : j ≤ n) : + (selectedVector F hF x n : StrongDual 𝕜 X) (x j) = 0 := by + apply (chooseUnitVector_spec F hF _).2 + by_cases hnj : j = n + · subst j; exact Finset.mem_insert_self _ _ + · apply Finset.mem_insert_of_mem + apply normerState_mono F hF x (show j+1 ≤ n by omega) + exact Finset.mem_union_right _ (Finset.mem_insert_self _ _) + +lemma selectedVector_ann_normers (F : Submodule 𝕜 (StrongDual 𝕜 X)) + (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) (m n : ℕ) (hmn : m ≤ n) + (d : X) (hd : d ∈ selectedNormers F hF x m) : + (selectedVector F hF x n : StrongDual 𝕜 X) d = 0 := by + apply (chooseUnitVector_spec F hF _).2 + exact Finset.mem_insert_of_mem ((normerState_mono F hF x hmn) + (selectedNormers_subset_state F hF x m hd)) + + + +theorem exists_normed_prefix_sequence + (F : Submodule 𝕜 (StrongDual 𝕜 X)) (hF : ¬ FiniteDimensional 𝕜 F) (x : ℕ → X) : + ∃ (f : ℕ → F) (D : ℕ → Finset X), + (∀ n, ‖f n‖ = 1) ∧ (∀ m d, d ∈ D m → ‖d‖ ≤ 1) ∧ + (∀ m (v : StrongDual 𝕜 X), + v ∈ Submodule.span 𝕜 ((fun n => (f n : StrongDual 𝕜 X)) '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖) ∧ + (∀ m n, m ≤ n → ∀ d ∈ D m, (f n : StrongDual 𝕜 X) d = 0) ∧ + (∀ n j, j ≤ n → (f n : StrongDual 𝕜 X) (x j) = 0) := by + refine ⟨selectedVector F hF x, selectedNormers F hF x, selectedVector_norm F hF x, ?_, ?_, + selectedVector_ann_normers F hF x, selectedVector_ann_test F hF x⟩ + · intro m d hd + exact (chosenPrefixNormers_spec _ m).1 d hd + · intro m v hv + apply (chosenPrefixNormers_spec _ m).2 v + apply Submodule.span_mono (t := + (fun n => ((normerState F hF x m).1 n : StrongDual 𝕜 X)) '' (Finset.range m : Set ℕ)) _ hv + rintro w ⟨n, hn, rfl⟩ + exact ⟨n, hn, congrArg Subtype.val (normerState_value F hF x n m (Finset.mem_range.mp hn))⟩ +end SeparableQuotient.Positive.Fields + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields +universe u +def HasSeparableQuotient (𝕜 : Type) [RCLike 𝕜] (X : Type u) + [NormedAddCommGroup X] [NormedSpace 𝕜 X] : Prop := + ∃ (Y : Type u) (g : NormedAddCommGroup Y), + letI := g + ∃ s : NormedSpace 𝕜 Y, + letI := s + CompleteSpace Y ∧ SeparableSpace Y ∧ ¬ FiniteDimensional 𝕜 Y ∧ + ∃ T : X →L[𝕜] Y, Function.Surjective T + +end SeparableQuotient.Positive.Fields + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/FieldTransfer.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/FieldTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..1123b07e2247dad916f2a562f7ff17d26eb82324 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/FieldTransfer.lean @@ -0,0 +1,49 @@ +import OAI.Analysis.SeparableQuotients.Positive.ComplexPerturbation + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set TopologicalSpace Scalar +attribute [local instance] Scalar.dualSubmoduleNormedGroup Scalar.dualSubmoduleNormedSpace +attribute [local instance] realDualSubmoduleNormedGroup realDualSubmoduleNormedSpace +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℂ X] + [NormedSpace ℝ X] [IsScalarTower ℝ ℂ X] + + + +theorem complex_witness_of_real + (E : Submodule ℝ (StrongDual ℂ X)) (hEcl : IsClosed (E : Set (StrongDual ℂ X))) + (hEinf : ¬ FiniteDimensional ℝ E) (hEsep : IsSeparable (Set.range (realEvaluation E))) : + ∃ H : Submodule ℂ (StrongDual ℂ X), IsClosed (H : Set (StrongDual ℂ X)) ∧ + ¬ FiniteDimensional ℂ H ∧ IsSeparable (Set.range (Scalar.evaluation H)) := by + classical + by_cases hs : HasSeparatedInfiniteSubspace E + · exact complex_witness_of_separated E hEsep hs + · obtain ⟨f, g, D, hv, hD, hnorm, hann, hfg⟩ := + exists_near_prefix_sequence E hEcl hEinf hs + exact perturbation_witness E hEcl hEsep f g + (prefixBound_of_half_normers ℂ _ D hD hnorm hann) hv (fun n => (hfg n).le) + + + + +theorem positive_transfer [CompleteSpace X] + (h : HasSeparableQuotient ℝ X) : HasSeparableQuotient ℂ X := by + obtain ⟨E, hEcl, hEinf, hEsep⟩ := Scalar.evaluation_criterion.mp h + obtain ⟨F, hFcl, hFinf, hFsep⟩ := transport_real_witness E hEcl hEinf hEsep + obtain ⟨H, hHcl, hHinf, hHsep⟩ := complex_witness_of_real F hFcl hFinf hFsep + exact Scalar.evaluation_criterion.mpr ⟨H, hHcl, hHinf, hHsep⟩ + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/FiniteSuppression.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/FiniteSuppression.lean new file mode 100644 index 0000000000000000000000000000000000000000..a794b16996b8b4dc95850891fd41a3e2bbc90ffc --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/FiniteSuppression.lean @@ -0,0 +1,69 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + + +lemma exists_halfNormer (f : StrongDual ℝ X) : + ∃ x : X, ‖x‖ ≤ 1 ∧ ‖f‖ ≤ 2 * |f x| := by + by_cases hf : f = 0 + · exact ⟨0, by norm_num, by simp [hf]⟩ + have hp : 0 < ‖f‖ := norm_pos_iff.mpr hf + obtain ⟨x, hx, hfx⟩ := f.exists_lt_apply_of_lt_opNorm (show ‖f‖ / 2 < ‖f‖ by linarith) + refine ⟨x, hx.le, ?_⟩ + rw [Real.norm_eq_abs] at hfx + linarith + +def halfNormer (f : StrongDual ℝ X) : X := + if f = 0 then 0 else (exists_halfNormer f).choose + +@[simp] lemma halfNormer_zero : halfNormer (0 : StrongDual ℝ X) = 0 := by + simp [halfNormer] + +lemma norm_halfNormer (f : StrongDual ℝ X) : ‖halfNormer f‖ ≤ 1 := by + by_cases h : f = 0 + · simp [h] + · simpa only [halfNormer, ite_eq_right h] using (exists_halfNormer f).choose_spec.1 + +lemma halfNormer_bound (f : StrongDual ℝ X) : ‖f‖ ≤ 2 * |f (halfNormer f)| := by + by_cases h : f = 0 + · simp [h] + · simpa only [halfNormer, ite_eq_right h] using (exists_halfNormer f).choose_spec.2 + +abbrev UnitBall (X : Type*) [NormedAddCommGroup X] := {x : X // ‖x‖ ≤ 1} +def ballHalfNormer (f : StrongDual ℝ X) : UnitBall X := ⟨halfNormer f, norm_halfNormer f⟩ + + +lemma suppression_of_cross_vanishing {J : Type*} [Fintype J] (f : J → StrongDual ℝ X) + (a : J → ℝ) (s : Finset J) + (hzero : ∀ i, i ∉ s → f i (halfNormer (∑ j ∈ s, a j • f j)) = 0) : + ‖∑ j ∈ s, a j • f j‖ ≤ 2 * ‖∑ j, a j • f j‖ := by + let x := halfNormer (∑ j ∈ s, a j • f j) + have he : (∑ j, a j • f j) x = (∑ j ∈ s, a j • f j) x := by + simp only [sum_apply, smul_apply, smul_eq_mul] + apply (Finset.sum_subset (Finset.subset_univ s) _).symm + intro i _ hi + rw [hzero i hi, mul_zero] + have hb : |(∑ j, a j • f j) x| ≤ ‖∑ j, a j • f j‖ := by + simpa only [Real.norm_eq_abs, mul_one] using + (∑ j, a j • f j).le_opNorm_of_le (norm_halfNormer _) + calc + ‖∑ j ∈ s, a j • f j‖ ≤ 2 * |(∑ j ∈ s, a j • f j) x| := halfNormer_bound _ + _ = 2 * |(∑ j, a j • f j) x| := by rw [he] + _ ≤ 2 * ‖∑ j, a j • f j‖ := mul_le_mul_of_nonneg_left hb (by norm_num) + +end SeparableQuotient.Positive.Sampling + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/Main.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..02eff98e6f6773bec958b5abc681e394515ada7c --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/Main.lean @@ -0,0 +1,122 @@ +import OAI.Analysis.SeparableQuotients.Positive.RowQuotients +import OAI.Analysis.SeparableQuotients.Positive.TransfiniteFamily +import OAI.Analysis.SeparableQuotients.Positive.UnconditionalBasis +import OAI.Analysis.SeparableQuotients.Positive.FieldTransfer +import OAI.Analysis.SeparableQuotients.Main + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient +namespace Integration + + + +theorem small_type_additive + (μ : @Measure ℝ ⊤) + (hadd : ∀ (s : Set ℝ), Cardinal.mk s < Cardinal.mk ℝ → + ∀ (A : s → Set ℝ), Pairwise (fun i j => Disjoint (A i) (A j)) → + μ (⋃ i, A i) = ∑' i, μ (A i)) + (ι : Type) (hι : Cardinal.mk ι < Cardinal.continuum) + (A : ι → Set ℝ) (hA : Pairwise (fun i j => Disjoint (A i) (A j))) : + μ (⋃ i, A i) = ∑' i, μ (A i) := by + classical + have hi : Cardinal.mk ι ≤ Cardinal.mk ℝ := by + simpa only [Cardinal.mk_real] using hι.le + obtain ⟨e⟩ := Cardinal.le_def ι ℝ |>.mp hi + let s : Set ℝ := Set.range e + let d : ι ≃ s := Equiv.ofInjective e e.injective + have hs : Cardinal.mk s < Cardinal.mk ℝ := by + rw [← Cardinal.mk_congr d, Cardinal.mk_real] + exact hι + have hd := hadd s hs (fun j => A (d.symm j)) (fun j k h => + hA (fun h' => h (d.symm.injective h'))) + rw [d.symm.surjective.iUnion_comp, d.symm.tsum_eq (fun i => μ (A i))] at hd + exact hd + + + +theorem realValuedMeasurableContinuum_iff_index : + RealValuedMeasurableContinuum ↔ + ∃ μ : Measure Positive.Rows.ContinuumIndex, + IsProbabilityMeasure μ ∧ Positive.Rows.ContinuumAdditive μ ∧ + ∀ i, μ {i} = 0 := by + classical + let : MeasurableSpace ℝ := ⊤ + let e : ℝ ≃ Positive.Rows.ContinuumIndex := + Classical.choice (Cardinal.eq.mp (by simp [Positive.Rows.ContinuumIndex, Cardinal.mk_real])) + constructor + · rintro ⟨ν, hν, hsingle, hadd⟩ + let : IsProbabilityMeasure ν := ⟨hν⟩ + let μ : Measure Positive.Rows.ContinuumIndex := ν.map e + refine ⟨μ, inferInstance, ?_, ?_⟩ + · intro ι hι A hA + have hd : Pairwise (fun i j => Disjoint (e ⁻¹' A i) (e ⁻¹' A j)) := by + intro i j hij + exact (hA hij).preimage e + simpa only [μ, Measure.map_apply Measurable.of_discrete MeasurableSet.of_discrete, + Set.preimage_iUnion] using small_type_additive ν hadd ι hι _ hd + · intro i + rw [show μ = ν.map e from rfl, + Measure.map_apply Measurable.of_discrete MeasurableSet.of_discrete] + simpa only [Set.preimage, Set.mem_singleton_iff, ← e.eq_symm_apply, Set.ofPred_eq_eq_singleton] + using hsingle (e.symm i) + · rintro ⟨μ, hp, hadd, hsingle⟩ + let : IsProbabilityMeasure μ := hp + let ν : @Measure ℝ ⊤ := μ.map e.symm + have : IsProbabilityMeasure ν := inferInstance + refine ⟨ν, measure_univ, ?_, ?_⟩ + · intro x + rw [show ν = μ.map e.symm from rfl, + Measure.map_apply Measurable.of_discrete MeasurableSet.of_discrete] + simpa only [Set.preimage, Set.mem_singleton_iff, e.symm_apply_eq, Set.ofPred_eq_eq_singleton] + using hsingle (e x) + · intro s hs A hA + have hd : Pairwise (fun i j => Disjoint (e.symm ⁻¹' A i) (e.symm ⁻¹' A j)) := by + intro i j hij + exact (hA hij).preimage e.symm + simpa only [ν, Measure.map_apply Measurable.of_discrete MeasurableSet.of_discrete, + Set.preimage_iUnion] using hadd s (by simpa only [Cardinal.mk_real] using hs) _ hd + +end Integration + +namespace Integration + + + +theorem measurable_continuum_regular (h : RealValuedMeasurableContinuum) : + Cardinal.IsRegular Cardinal.continuum.{0} := by + obtain ⟨μ, hp, hadd, hsingle⟩ := realValuedMeasurableContinuum_iff_index.mp h + let : IsProbabilityMeasure μ := hp + exact Positive.Rows.continuum_regular μ hadd hsingle + +universe u + + + +theorem SQ_real_iff_complex : SQ.{u} ℝ ↔ SQ.{u} ℂ := by + constructor + · intro h X _ _ _ hinf + let : NormedSpace ℝ X := NormedSpace.restrictScalars ℝ ℂ X + have hr : ¬ FiniteDimensional ℝ X := by + intro hh + let := hh + exact hinf (Module.Finite.of_restrictScalars_finite ℝ ℂ X) + exact Positive.Fields.ComplexTransfer.positive_transfer (h X hr) + · intro h X _ _ _ hinf + by_contra hn + exact complexify_noSQ X hn (h (Complexify X) (Complexify.infinite X hinf)) + +end Integration +end SeparableQuotient + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/MeasurableCodes.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/MeasurableCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..0274cc0a7fd93840bfda99450cd44a5d1a9be655 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/MeasurableCodes.lean @@ -0,0 +1,155 @@ +import OAI.Analysis.SeparableQuotients.Positive.RowEvaluation + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling +variable (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] + + +abbrev WeakUnitBall := {y : WeakDual ℝ E // ‖WeakDual.toStrongDual y‖ ≤ 1} + +instance weakUnitBallCompact : CompactSpace (WeakUnitBall E) := by + exact (isCompact_iff_compactSpace (s := {y : WeakDual ℝ E | + ‖WeakDual.toStrongDual y‖ ≤ 1})).mp (by + simpa only [Set.preimage, Metric.mem_closedBall, dist_zero_right] using + (WeakDual.isCompact_closedBall (0 : StrongDual ℝ E) 1)) + +instance weakUnitBallMetrizable [SeparableSpace E] : MetrizableSpace (WeakUnitBall E) := + WeakDual.metrizable_of_isCompact ℝ E _ (isCompact_iff_compactSpace.mpr (weakUnitBallCompact E)) + +instance weakUnitBallSecondCountable [SeparableSpace E] : + SecondCountableTopology (WeakUnitBall E) := by infer_instance + +instance weakUnitBallMeasurable : MeasurableSpace (WeakUnitBall E) := borel _ +instance weakUnitBallBorel : BorelSpace (WeakUnitBall E) := ⟨rfl⟩ + +lemma continuous_weakUnitBall_eval : + Continuous (fun p : E × WeakUnitBall E => p.2.1 p.1) := by + apply continuous_iff_continuousAt.mpr + intro p + have hbound : ∀ q : E × WeakUnitBall E, + ‖q.2.1 (q.1 - p.1)‖ ≤ ‖q.1 - p.1‖ := by + intro q + exact (WeakDual.toStrongDual q.2.1).le_opNorm (q.1 - p.1) |>.trans + ((mul_le_mul_of_nonneg_right q.2.2 (norm_nonneg _)).trans_eq (one_mul _)) + have hdiff : Tendsto (fun q : E × WeakUnitBall E => q.2.1 (q.1 - p.1)) + (𝓝 p) (𝓝 0) := by + apply squeeze_zero_norm hbound + have hh : Continuous (fun q : E × WeakUnitBall E => ‖q.1 - p.1‖) := + (continuous_fst.sub continuous_const).norm + simpa only [sub_self, norm_zero] using hh.tendsto p + have hfix : Continuous (fun q : E × WeakUnitBall E => q.2.1 p.1) := + (WeakDual.eval_continuous p.1).comp (continuous_subtype_val.comp continuous_snd) + have hh := hdiff.add hfix.continuousAt + simpa only [ContinuousAt, map_sub, sub_add_cancel, zero_add] using hh + +variable [SeparableSpace E] [MeasurableSpace E] [BorelSpace E] + +omit [SeparableSpace E] [MeasurableSpace E] [BorelSpace E] in +lemma continuous_sequence_eval (n : ℕ) : + Continuous (fun p : (ℕ → E) × WeakUnitBall E => p.2.1 (p.1 n)) := + (continuous_weakUnitBall_eval E).comp (f := fun p : (ℕ → E) × WeakUnitBall E => (p.1 n, p.2)) + (((continuous_apply n).comp continuous_fst).prodMk continuous_snd) + +lemma measurable_sequence_eval (n : ℕ) : + Measurable (fun p : (ℕ → E) × WeakUnitBall E => p.2.1 (p.1 n)) := + (continuous_sequence_eval E n).measurable + +def limitOrZero {A : Type*} (f : ℕ → A → ℝ) (a : A) : ℝ := + if ∃ r, Tendsto (fun n => f n a) atTop (𝓝 r) then + limUnder atTop (fun n => f n a) else 0 + +lemma limitOrZero_of_tendsto {A : Type*} {f : ℕ → A → ℝ} {a : A} {r : ℝ} + (h : Tendsto (fun n => f n a) atTop (𝓝 r)) : limitOrZero f a = r := by + have hc : ∃ r, Tendsto (fun n => f n a) atTop (𝓝 r) := ⟨r, h⟩ + simp only [limitOrZero, ite_eq_left hc, h.limUnder_eq] + +lemma limitOrZero_of_not_tendsto {A : Type*} {f : ℕ → A → ℝ} {a : A} + (h : ¬ ∃ r, Tendsto (fun n => f n a) atTop (𝓝 r)) : + limitOrZero f a = 0 := by + simp only [limitOrZero, ite_eq_right h] + +lemma measurable_limitOrZero {A : Type*} [MeasurableSpace A] + {f : ℕ → A → ℝ} (hf : ∀ n, Measurable (f n)) : Measurable (limitOrZero f) := by + unfold limitOrZero + apply Measurable.ite (measurableSet_exists_tendsto (l := atTop) hf) + · exact (StronglyMeasurable.limUnder (fun n => (hf n).stronglyMeasurable)).measurable + · exact measurable_const + + +end SeparableQuotient.Positive.Sampling + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + + + +local instance dualSubmoduleNormedGroup (F : Submodule ℝ (StrongDual ℝ X)) : + NormedAddCommGroup F := Submodule.normedAddCommGroup F +local instance dualSubmoduleNormedSpace (F : Submodule ℝ (StrongDual ℝ X)) : + NormedSpace ℝ F := Submodule.normedSpace F + + +def evaluation (F : Submodule ℝ (StrongDual ℝ X)) : X →L[ℝ] StrongDual ℝ F := + F.subtypeL.flip + +@[simp] lemma evaluation_apply (F : Submodule ℝ (StrongDual ℝ X)) (x : X) (f : F) : + evaluation F x f = f.val x := rfl + +lemma norm_evaluation_le (F : Submodule ℝ (StrongDual ℝ X)) : ‖evaluation F‖ ≤ 1 := by + rw [evaluation, ContinuousLinearMap.opNorm_flip] + exact Submodule.norm_subtypeL_le F + + +def evaluationBall (F : Submodule ℝ (StrongDual ℝ X)) (x : {x : X // ‖x‖ ≤ 1}) : + WeakUnitBall F := + ⟨StrongDual.toWeakDual (evaluation F x.val), + (evaluation F).le_opNorm x.val |>.trans + ((mul_le_mul_of_nonneg_right (norm_evaluation_le F) (norm_nonneg _)).trans + (by simpa using x.property))⟩ + +variable (F : Submodule ℝ (StrongDual ℝ X)) [SeparableSpace F] + + +def sequentialCodeValue : (ℕ → F) × WeakUnitBall F → ℝ := + limitOrZero (fun n p => p.2.val (p.1 n)) + +lemma measurable_sequentialCodeValue : + letI : MeasurableSpace F := borel F + Measurable (sequentialCodeValue F) := by + let : MeasurableSpace F := borel F + have : BorelSpace F := ⟨rfl⟩ + exact measurable_limitOrZero (measurable_sequence_eval F) + +omit [SeparableSpace F] in +lemma sequentialCodeValue_eq {c : ℕ → F} {h : StrongDual ℝ (StrongDual ℝ F)} + (hc : ∀ y : StrongDual ℝ F, Tendsto (fun n => y (c n)) atTop (𝓝 (h y))) + (y : WeakUnitBall F) : sequentialCodeValue F (c, y) = h (WeakDual.toStrongDual y.val) := + limitOrZero_of_tendsto (hc _) + +omit [SeparableSpace F] in +lemma sequentialCodeValue_evaluation {c : ℕ → F} {h : StrongDual ℝ (StrongDual ℝ F)} + (hc : ∀ y : StrongDual ℝ F, Tendsto (fun n => y (c n)) atTop (𝓝 (h y))) + (x : {x : X // ‖x‖ ≤ 1}) : + sequentialCodeValue F (c, evaluationBall F x) = (h.comp (evaluation F)) x.val := by + exact sequentialCodeValue_eq F hc _ + +end SeparableQuotient.Positive.Sampling + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/RealAdjoint.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/RealAdjoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b49e11690304aa3ec418794b1a3b9dfc2babe8b --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/RealAdjoint.lean @@ -0,0 +1,135 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Rows +variable {X Y : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] + + + +lemma ball_subset_closure_image_of_adjoint_lower (T : X →L[ℝ] Y) {c : ℝ} + (hlower : ∀ f : StrongDual ℝ Y, c * ‖f‖ ≤ ‖f.comp T‖) : + closedBall (0 : Y) c ⊆ closure (T '' closedBall (0 : X) 1) := by + intro y hy + by_contra hn + have hconv : Convex ℝ (closure (T '' closedBall (0 : X) 1)) := + ((convex_closedBall (0 : X) 1).linear_image T.toLinearMap).closure + obtain ⟨f, a, hsep, hay⟩ := geometric_hahn_banach_closed_point hconv isClosed_closure hn + have ha : 0 < a := by + simpa using hsep 0 (subset_closure ⟨0, by simp, by simp⟩) + have hT : ‖f.comp T‖ ≤ a := by + apply ContinuousLinearMap.opNorm_le_of_unit_norm ha.le + intro x hx + apply abs_le.mpr + constructor + · have hh := hsep (T (-x)) (subset_closure ⟨-x, by simp [hx], rfl⟩) + simp only [map_neg] at hh + change -a ≤ f (T x) + linarith + · exact (hsep (T x) (subset_closure ⟨x, by simp [hx], rfl⟩)).le + have hy' : ‖y‖ ≤ c := by simpa using hy + have hfy : f y ≤ ‖f‖ * c := + (le_abs_self _).trans ((f.le_opNorm y).trans (mul_le_mul_of_nonneg_left hy' (norm_nonneg _))) + have hh := hlower f + nlinarith + +lemma approx_preimage_of_adjoint_lower (T : X →L[ℝ] Y) {c : ℝ} (hc : 0 < c) + (hlower : ∀ f : StrongDual ℝ Y, c * ‖f‖ ≤ ‖f.comp T‖) (z : Y) : + ∃ x : X, dist (T x) z ≤ 1 / 2 * ‖z‖ ∧ ‖x‖ ≤ c⁻¹ * ‖z‖ := by + by_cases hz : z = 0 + · exact ⟨0, by simp [hz], by simp [hz]⟩ + have hzn : 0 < ‖z‖ := norm_pos_iff.mpr hz + let r : ℝ := ‖z‖ / c + have hr : 0 < r := div_pos hzn hc + let y : Y := r⁻¹ • z + have hy : y ∈ closedBall (0 : Y) c := by + rw [mem_closedBall_zero_iff] + change ‖r⁻¹ • z‖ ≤ c + rw [norm_smul, norm_inv, Real.norm_eq_abs, abs_of_pos hr] + dsimp [r] + field_simp + linarith + have hyr : r • y = z := by simp [y, smul_smul, hr.ne'] + obtain ⟨w, ⟨x, hx, rfl⟩, hdist⟩ := Metric.mem_closure_iff.mp + (ball_subset_closure_image_of_adjoint_lower T hlower hy) (c / 2) (by positivity) + refine ⟨r • x, ?_, ?_⟩ + · have heq : dist (T (r • x)) z = r * dist (T x) y := by + rw [← hyr, map_smul, dist_eq_norm, ← smul_sub, norm_smul, Real.norm_eq_abs, + abs_of_pos hr, dist_eq_norm] + rw [heq] + calc + r * dist (T x) y ≤ r * (c / 2) := mul_le_mul_of_nonneg_left (by simpa [dist_comm] using hdist.le) hr.le + _ = 1 / 2 * ‖z‖ := by dsimp [r]; field_simp + · rw [norm_smul, Real.norm_eq_abs, abs_of_pos hr] + calc + r * ‖x‖ ≤ r * 1 := mul_le_mul_of_nonneg_left (by simpa using hx) hr.le + _ = c⁻¹ * ‖z‖ := by dsimp [r]; ring + + + +theorem surjective_of_adjoint_lower [CompleteSpace X] (T : X →L[ℝ] Y) {c : ℝ} + (hc : 0 < c) (hlower : ∀ f : StrongDual ℝ Y, c * ‖f‖ ≤ ‖f.comp T‖) : + ∀ z : Y, ∃ x : X, T x = z ∧ ‖x‖ ≤ (2 / c) * ‖z‖ := by + choose g hg using approx_preimage_of_adjoint_lower T hc hlower + let h (y : Y) := y - T (g y) + have hle : ∀ y, ‖h y‖ ≤ 1 / 2 * ‖y‖ := by + intro y + rw [← dist_eq_norm, dist_comm] + exact (hg y).1 + intro y + have hnle : ∀ n : ℕ, ‖h^[n] y‖ ≤ (1 / 2) ^ n * ‖y‖ := by + intro n + induction n with + | zero => simp + | succ n IH => + rw [Function.iterate_succ'] + apply le_trans (hle _) _ + rw [pow_succ', mul_assoc] + gcongr + let u (n : ℕ) := g (h^[n] y) + have ule : ∀ n, ‖u n‖ ≤ (1 / 2) ^ n * (c⁻¹ * ‖y‖) := fun n => by + apply le_trans (hg _).2 + calc + c⁻¹ * ‖h^[n] y‖ ≤ c⁻¹ * ((1 / 2) ^ n * ‖y‖) := by gcongr; exact hnle n + _ = (1 / 2) ^ n * (c⁻¹ * ‖y‖) := by ring + have sNu : Summable fun n => ‖u n‖ := by + refine .of_nonneg_of_le (fun n => norm_nonneg _) ule ?_ + exact Summable.mul_right _ summable_geometric_two + have su : Summable u := sNu.of_norm + let x := ∑' n, u n + have hx : ‖x‖ ≤ (2 / c) * ‖y‖ := calc + ‖x‖ ≤ ∑' n, ‖u n‖ := norm_tsum_le_tsum_norm sNu + _ ≤ ∑' n, (1 / 2) ^ n * (c⁻¹ * ‖y‖) := + sNu.tsum_le_tsum ule (Summable.mul_right _ summable_geometric_two) + _ = (∑' n : ℕ, (1 / 2 : ℝ) ^ n) * (c⁻¹ * ‖y‖) := tsum_mul_right + _ = (2 / c) * ‖y‖ := by rw [tsum_geometric_two]; ring + have heq : ∀ n : ℕ, T (∑ i ∈ Finset.range n, u i) = y - h^[n] y := by + intro n + induction n with + | zero => simp + | succ n IH => rw [Finset.sum_range_succ, map_add, IH, Function.iterate_succ_apply', sub_add] + have hl₁ : Tendsto (fun n => T (∑ i ∈ Finset.range n, u i)) atTop (𝓝 (T x)) := + (T.continuous.tendsto x).comp su.hasSum.tendsto_sum_nat + simp only [heq] at hl₁ + have hl₂ : Tendsto (fun n => y - h^[n] y) atTop (𝓝 (y - 0)) := by + refine tendsto_const_nhds.sub ?_ + rw [tendsto_iff_norm_sub_tendsto_zero] + simp only [sub_zero] + refine squeeze_zero (fun _ => norm_nonneg _) hnle ?_ + rw [← zero_mul ‖y‖] + exact (_root_.tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num)).mul tendsto_const_nhds + exact ⟨x, by simpa using tendsto_nhds_unique hl₁ hl₂, hx⟩ +end SeparableQuotient.Positive.Rows + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/RealWitness.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/RealWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..b070a26f6b8ea86ffbd0a2235c39c6d667081f34 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/RealWitness.lean @@ -0,0 +1,75 @@ +import OAI.Analysis.SeparableQuotients.Positive.ScalarQuotients + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set TopologicalSpace +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℂ X] + [NormedSpace ℝ X] [IsScalarTower ℝ ℂ X] +attribute [local instance] Scalar.dualSubmoduleNormedGroup Scalar.dualSubmoduleNormedSpace +local instance realDualSubmoduleNormedGroup (E : Submodule ℝ (StrongDual ℂ X)) : + NormedAddCommGroup E := Submodule.normedAddCommGroup E +local instance realDualSubmoduleNormedSpace (E : Submodule ℝ (StrongDual ℂ X)) : + NormedSpace ℝ E := Submodule.normedSpace E + + + +def realEvaluation (E : Submodule ℝ (StrongDual ℂ X)) : + X →L[ℝ] (E →L[ℝ] ℂ) := + ((ContinuousLinearMap.restrictScalarsL ℂ X ℂ ℝ ℝ).comp E.subtypeL).flip + +@[simp] lemma realEvaluation_apply (E : Submodule ℝ (StrongDual ℂ X)) + (x : X) (f : E) : realEvaluation E x f = (f : StrongDual ℂ X) x := rfl + + + +theorem transport_real_witness + (E : Submodule ℝ (StrongDual ℝ X)) (hEclosed : IsClosed (E : Set (StrongDual ℝ X))) + (hEinf : ¬ FiniteDimensional ℝ E) + (hEsep : IsSeparable (Set.range (Scalar.evaluation E))) : + ∃ F : Submodule ℝ (StrongDual ℂ X), + IsClosed (F : Set (StrongDual ℂ X)) ∧ ¬ FiniteDimensional ℝ F ∧ + IsSeparable (Set.range (realEvaluation F)) := by + let A : StrongDual ℝ X ≃L[ℝ] StrongDual ℂ X := + StrongDual.extendRCLikeL + let F : Submodule ℝ (StrongDual ℂ X) := E.map A.toLinearEquiv.toLinearMap + let e : E ≃L[ℝ] F := A.submoduleMap E + have hFclosed : IsClosed (F : Set (StrongDual ℂ X)) := + A.toHomeomorph.isClosedMap _ hEclosed + have hFinf : ¬ FiniteDimensional ℝ F := by + intro hh + let := hh + exact hEinf e.symm.toLinearEquiv.finiteDimensional + let φ : (StrongDual ℝ E × StrongDual ℝ E) → (F →L[ℝ] ℂ) := fun p => + ((Complex.ofRealCLM.comp p.1 - Complex.I • (Complex.ofRealCLM.comp p.2)).comp + e.symm.toContinuousLinearMap) + have hφ : Continuous φ := by fun_prop + have hsep : IsSeparable (φ '' (Set.range (Scalar.evaluation E) ×ˢ + Set.range (Scalar.evaluation E))) := (hEsep.prod hEsep).image hφ + refine ⟨F, hFclosed, hFinf, hsep.mono ?_⟩ + rintro _ ⟨x, rfl⟩ + refine ⟨(Scalar.evaluation E x, Scalar.evaluation E (Complex.I • x)), + ⟨Set.mem_range_self _, Set.mem_range_self _⟩, ?_⟩ + ext f + change ((e.symm f : E) : StrongDual ℝ X) x - Complex.I * + (((e.symm f : E) : StrongDual ℝ X) (Complex.I • x) : ℂ) = (f : StrongDual ℂ X) x + have he : A ((e.symm f : E) : StrongDual ℝ X) = (f : StrongDual ℂ X) := + congrArg Subtype.val (e.apply_symm_apply f) + rw [← he] + change _ = StrongDual.extendRCLike ((e.symm f : E) : StrongDual ℝ X) x + rw [StrongDual.extendRCLike_apply] + rfl + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/RowBasis.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/RowBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..74c19ca82f935a7f75e56004755c9713e5d448c2 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/RowBasis.lean @@ -0,0 +1,204 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Rows +variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + +abbrev ClosedSpan (v : ℕ → V) : Submodule ℝ V := + (Submodule.span ℝ (Set.range v)).topologicalClosure + +def spanVector (v : ℕ → V) (i : ℕ) : ClosedSpan v := + ⟨v i, Submodule.le_topologicalClosure _ (Submodule.subset_span (Set.mem_range_self i))⟩ + +def spanCombination (v : ℕ → V) : (ℕ →₀ ℝ) →ₗ[ℝ] ClosedSpan v := + Finsupp.linearCombination ℝ (spanVector v) + +lemma spanCombination_coe (v : ℕ → V) (c : ℕ →₀ ℝ) : + (spanCombination v c : V) = c.sum (fun i a => a • v i) := by + simp [spanCombination, Finsupp.linearCombination_apply, Finsupp.sum, spanVector] + +lemma denseRange_spanCombination (v : ℕ → V) : DenseRange (spanCombination v) := by + rw [DenseRange, Subtype.dense_iff] + have hr : (Subtype.val : ClosedSpan v → V) '' Set.range (spanCombination v) = + (Submodule.span ℝ (Set.range v) : Set V) := by + rw [← Set.range_comp] + change Set.range (fun c => (spanCombination v c : V)) = _ + simp only [spanCombination_coe] + change Set.range (Finsupp.linearCombination ℝ v) = _ + exact congrArg (fun s : Submodule ℝ V => (s : Set V)) + (Finsupp.range_linearCombination ℝ (v := v)) + change (ClosedSpan v : Set V) ⊆ closure ((Subtype.val : ClosedSpan v → V) '' Set.range (spanCombination v)) + rw [hr] + exact Set.Subset.rfl + + +def PrefixBoundTwo (v : ℕ → V) : Prop := + ∀ (c : ℕ →₀ ℝ) (m : ℕ), + ‖∑ i ∈ Finset.range m, c i • v i‖ ≤ 2 * ‖c.sum (fun i a => a • v i)‖ + +lemma prefix_coefficient_bound (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ ℝ) (i : ℕ) : + ‖c i‖ ≤ (4 / a) * ‖spanCombination v c‖ := by + have hdiff : c i • v i = (∑ j ∈ Finset.range (i+1), c j • v j) - + (∑ j ∈ Finset.range i, c j • v j) := by rw [Finset.sum_range_succ]; abel + have hh : ‖c i • v i‖ ≤ 4 * ‖c.sum (fun i a => a • v i)‖ := by + rw [hdiff] + exact (norm_sub_le _ _).trans ((add_le_add (h c (i+1)) (h c i)).trans_eq (by ring)) + rw [norm_smul] at hh + have hb : ‖c i‖ * a ≤ 4 * ‖spanCombination v c‖ := by + exact (mul_le_mul_of_nonneg_left (hv i) (norm_nonneg _)).trans + (by simpa only [← spanCombination_coe, Submodule.norm_coe] using hh) + rw [div_mul_eq_mul_div] + exact (le_div_iff₀ ha).mpr hb + + +def prefixCoord (v : ℕ → V) (i : ℕ) : StrongDual ℝ (ClosedSpan v) := + (Finsupp.lapply i).extendOfNorm (spanCombination v) + +lemma prefixCoord_combination (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ ℝ) (i : ℕ) : + prefixCoord v i (spanCombination v c) = c i := by + apply LinearMap.extendOfNorm_eq (denseRange_spanCombination v) + exact ⟨4 / a, fun c => prefix_coefficient_bound v h ha hv c i⟩ + +lemma prefixCoord_bound (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (x : ClosedSpan v) (i : ℕ) : + ‖prefixCoord v i x‖ ≤ (4 / a) * ‖x‖ := by + exact LinearMap.norm_extendOfNorm_apply_le (denseRange_spanCombination v) _ + (fun c => prefix_coefficient_bound v h ha hv c i) x + +lemma prefixCoord_ortho (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (i j : ℕ) : + prefixCoord v i (spanVector v j) = (Pi.single j (1 : ℝ) : ℕ → ℝ) i := by + have hc : spanCombination v (Finsupp.single j 1) = spanVector v j := by + simp [spanCombination] + rw [← hc, prefixCoord_combination v h ha hv] + simp [Finsupp.single_apply, Pi.single_apply, eq_comm] + + +def prefixProjection (v : ℕ → V) (s : Finset ℕ) : + ClosedSpan v →L[ℝ] ClosedSpan v := + ∑ i ∈ s, (prefixCoord v i).smulRight (spanVector v i) + +lemma prefixProjection_apply (v : ℕ → V) (s : Finset ℕ) (x : ClosedSpan v) : + prefixProjection v s x = ∑ i ∈ s, prefixCoord v i x • spanVector v i := by + simp [prefixProjection] + +lemma prefixProjection_bound (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (m : ℕ) (x : ClosedSpan v) : + ‖prefixProjection v (Finset.range m) x‖ ≤ 2 * ‖x‖ := by + refine (denseRange_spanCombination v).induction_on x (p := fun x => + ‖prefixProjection v (Finset.range m) x‖ ≤ 2 * ‖x‖) ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · intro c + rw [prefixProjection_apply] + simp only [prefixCoord_combination v h ha hv] + have hh := h c m + change ‖((∑ i ∈ Finset.range m, c i • spanVector v i : ClosedSpan v) : V)‖ ≤ + 2 * ‖(spanCombination v c : V)‖ + simpa only [Submodule.coe_sum, Submodule.coe_smul, spanVector, spanCombination_coe] using hh + +lemma prefixProjection_combination (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ ℝ) + (s : Finset ℕ) (hs : c.support ⊆ s) : + prefixProjection v s (spanCombination v c) = spanCombination v c := by + rw [prefixProjection_apply] + simp only [prefixCoord_combination v h ha hv] + exact (Finsupp.sum_of_support_subset c hs (fun i a => a • spanVector v i) (by simp)).symm + +lemma prefix_expansion (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (x : ClosedSpan v) : + HasSum (fun i => prefixCoord v i x • spanVector v i) x (SummationFilter.conditional ℕ) := by + have hequi : Equicontinuous (fun m : ℕ => + (prefixProjection v (Finset.range m) : ClosedSpan v → ClosedSpan v)) := by + have hb : ∃ C : ℝ, ∀ (m : ℕ) (y : ClosedSpan v), + ‖prefixProjection v (Finset.range m) y‖ ≤ C * ‖y‖ := + ⟨2, fun m y => prefixProjection_bound v h ha hv m y⟩ + exact ((NormedSpace.equicontinuous_TFAE (fun m => prefixProjection v (Finset.range m))).out 4 2).mp hb + rw [HasSum, SummationFilter.conditional_filter_eq_map_range, tendsto_map'_iff] + change Tendsto (fun m : ℕ => ∑ i ∈ Finset.range m, prefixCoord v i x • spanVector v i) + atTop (𝓝 x) + simp only [← prefixProjection_apply] + refine (denseRange_spanCombination v).induction_on x (p := fun x => + Tendsto (fun m : ℕ => prefixProjection v (Finset.range m) x) atTop (𝓝 x)) ?_ ?_ + · exact hequi.isClosed_setOfPred_tendsto continuous_id + · intro c + obtain ⟨N, hN⟩ := c.support.exists_nat_subset_range + apply tendsto_const_nhds.congr' + filter_upwards [eventually_ge_atTop N] with m hm + exact (prefixProjection_combination v h ha hv c (Finset.range m) + (hN.trans (Finset.range_mono hm))).symm + + +def basisOfPrefix (v : ℕ → V) (h : PrefixBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) : + SchauderBasis ℝ (ClosedSpan v) where + basis := spanVector v + coord := prefixCoord v + ortho := by + intro i j + rw [prefixCoord_ortho v h ha hv] + by_cases hij : i = j <;> simp [hij] + expansion := prefix_expansion v h ha hv + +end SeparableQuotient.Positive.Rows + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Rows +open Set +open scoped Classical BigOperators +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + + + +lemma prefixBound_of_half_normers (f : ℕ → StrongDual ℝ X) (D : ℕ → Finset X) + (hD : ∀ m x, x ∈ D m → ‖x‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual ℝ X), v ∈ Submodule.span ℝ (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * |v d|) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) : PrefixBoundTwo f := by + classical + intro c m + let v := ∑ i ∈ Finset.range m, c i • f i + have hv : v ∈ Submodule.span ℝ (f '' (Finset.range m : Set ℕ)) := by + apply Submodule.sum_mem + intro i hi + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, hi, rfl⟩) + obtain ⟨d, hd, hnormd⟩ := hnorm m v hv + have heval : (c.sum (fun i a => a • f i)) d = v d := by + simp only [Finsupp.sum, sum_apply, smul_apply, smul_eq_mul, v] + calc + ∑ i ∈ c.support, c i * f i d = ∑ i ∈ c.support ∪ Finset.range m, c i * f i d := by + apply Finset.sum_subset Finset.subset_union_left + intro i _ hi + simp [Finsupp.notMem_support_iff.mp hi] + _ = ∑ i ∈ Finset.range m, c i * f i d := by + symm + apply Finset.sum_subset Finset.subset_union_right + intro i _ hi + simp [hann m i (Nat.le_of_not_gt (by simpa using hi)) d hd] + calc + ‖v‖ ≤ 2 * |v d| := hnormd + _ = 2 * |(c.sum (fun i a => a • f i)) d| := by rw [heval] + _ ≤ 2 * ‖c.sum (fun i a => a • f i)‖ := by + gcongr + simpa only [Real.norm_eq_abs, mul_one] using + (c.sum (fun i a => a • f i)).le_opNorm_of_le (hD m d hd) +end SeparableQuotient.Positive.Rows + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/RowEvaluation.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/RowEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1371d5bae6002b114069186751c7fe4fb808e56 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/RowEvaluation.lean @@ -0,0 +1,229 @@ +import OAI.Analysis.SeparableQuotients.Positive.RowBasis +import OAI.Analysis.SeparableQuotients.Positive.RealAdjoint + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Rows +open Set Filter TopologicalSpace +open scoped Classical BigOperators Topology +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] +local instance dualSubmoduleNormedGroup (F : Submodule ℝ (StrongDual ℝ X)) : + NormedAddCommGroup F := Submodule.normedAddCommGroup F +local instance dualSubmoduleNormedSpace (F : Submodule ℝ (StrongDual ℝ X)) : + NormedSpace ℝ F := Submodule.normedSpace F + +def evaluation (G : Submodule ℝ (StrongDual ℝ X)) : X →L[ℝ] StrongDual ℝ G := G.subtypeL.flip + +lemma map_eq_of_spanVector {V W : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + [NormedAddCommGroup W] [NormedSpace ℝ W] (v : ℕ → V) + (φ ψ : ClosedSpan v →L[ℝ] W) + (he : ∀ i, φ (spanVector v i) = ψ (spanVector v i)) : φ = ψ := by + apply DFunLike.ext' + apply (denseRange_spanCombination v).equalizer φ.continuous ψ.continuous + funext c + change φ (spanCombination v c) = ψ (spanCombination v c) + simp only [spanCombination, Finsupp.linearCombination_apply, map_finsuppSum, map_smul, he] + +lemma evaluation_eq_prefix_at_normer (f : ℕ → StrongDual ℝ X) (hp : PrefixBoundTwo f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) (m : ℕ) (d : X) + (hann : ∀ i, m ≤ i → f i d = 0) : + evaluation (ClosedSpan f) d = ∑ i ∈ Finset.range m, (f i d) • prefixCoord f i := by + apply map_eq_of_spanVector f + intro j + have he : evaluation (ClosedSpan f) d (spanVector f j) = f j d := rfl + rw [he] + simp only [sum_apply, smul_apply, prefixCoord_ortho f hp ha hf, Pi.single_apply] + by_cases hj : j < m + · simp [Finset.mem_range, hj, eq_comm] + · simp [Finset.mem_range, hj, eq_comm, hann j (Nat.le_of_not_gt hj)] + + +theorem prefix_evaluation_adjoint_lower (f : ℕ → StrongDual ℝ X) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (D : ℕ → Finset X) (hD : ∀ m d, d ∈ D m → ‖d‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual ℝ X), v ∈ Submodule.span ℝ (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * |v d|) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) + (hrange : ∀ x : X, evaluation (ClosedSpan f) x ∈ ClosedSpan (prefixCoord f)) : + let T := (evaluation (ClosedSpan f)).codRestrict (ClosedSpan (prefixCoord f)) hrange + ∀ h : StrongDual ℝ (ClosedSpan (prefixCoord f)), ‖h‖ ≤ 2 * ‖h.comp T‖ := by + intro T h + have hp : PrefixBoundTwo f := prefixBound_of_half_normers f D hD hnorm hann + let vm (m : ℕ) : ClosedSpan f := + ∑ i ∈ Finset.range m, h (spanVector (prefixCoord f) i) • spanVector f i + have hvnorm (m : ℕ) : ‖vm m‖ ≤ 2 * ‖h.comp T‖ := by + have hvm : (vm m : StrongDual ℝ X) ∈ Submodule.span ℝ (f '' (Finset.range m : Set ℕ)) := by + simp only [vm, Submodule.coe_sum, Submodule.coe_smul, spanVector] + apply Submodule.sum_mem + intro i hi + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, hi, rfl⟩) + obtain ⟨d, hd, hv⟩ := hnorm m (vm m) hvm + have hdT : T d = ∑ i ∈ Finset.range m, (f i d) • spanVector (prefixCoord f) i := by + apply Subtype.ext + change evaluation (ClosedSpan f) d = _ + simpa only [Submodule.coe_sum, Submodule.coe_smul, spanVector] using + evaluation_eq_prefix_at_normer f hp ha hf m d (fun i hi => hann m i hi d hd) + have he : (vm m : StrongDual ℝ X) d = h (T d) := by + rw [hdT] + simp only [vm, Submodule.coe_sum, Submodule.coe_smul, spanVector, sum_apply, + smul_apply, map_sum, map_smul, smul_eq_mul] + apply Finset.sum_congr rfl + intro i hi + ring + have hb : |h (T d)| ≤ ‖h.comp T‖ := by + simpa only [ContinuousLinearMap.comp_apply, Real.norm_eq_abs, mul_one] using + (h.comp T).le_opNorm_of_le (hD m d hd) + calc + ‖vm m‖ ≤ 2 * |(vm m : StrongDual ℝ X) d| := hv + _ = 2 * |h (T d)| := by rw [he] + _ ≤ 2 * ‖h.comp T‖ := mul_le_mul_of_nonneg_left hb (by norm_num) + have hi (m j : ℕ) : prefixCoord f j (vm m) = + if j < m then h (spanVector (prefixCoord f) j) else 0 := by + simp only [vm, map_sum, map_smul, prefixCoord_ortho f hp ha hf, Pi.single_apply] + simp [Finset.mem_range] + apply h.opNorm_le_bound (by positivity) + intro z + refine (denseRange_spanCombination (prefixCoord f)).induction_on z + (p := fun z => ‖h z‖ ≤ 2 * ‖h.comp T‖ * ‖z‖) ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · intro c + obtain ⟨m, hm⟩ := c.support.exists_nat_subset_range + have he : (spanCombination (prefixCoord f) c : StrongDual ℝ (ClosedSpan f)) (vm m) = + h (spanCombination (prefixCoord f) c) := by + rw [spanCombination_coe] + simp only [spanCombination, Finsupp.linearCombination_apply, Finsupp.sum, + map_sum, map_smul, sum_apply, smul_apply, hi, smul_eq_mul] + apply Finset.sum_congr rfl + intro i hi' + simp only [ite_eq_left (Finset.mem_range.mp (hm hi'))] + rw [← he] + have hb := (spanCombination (prefixCoord f) c : StrongDual ℝ (ClosedSpan f)).le_opNorm (vm m) + exact hb.trans ((mul_le_mul_of_nonneg_left (hvnorm m) (norm_nonneg _)).trans_eq (by + change ‖spanCombination (prefixCoord f) c‖ * (2 * ‖h.comp T‖) = _ + ring)) + + +lemma closedSpan_separable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + (v : ℕ → V) : SeparableSpace (ClosedSpan v) := by + exact ((Set.countable_range v).isSeparable.span (R := ℝ)).closure.separableSpace + +lemma prefixCoord_linearIndependent (f : ℕ → StrongDual ℝ X) (hp : PrefixBoundTwo f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) : + LinearIndependent ℝ (spanVector (prefixCoord f)) := by + classical + rw [linearIndependent_iff'] + intro s c hc j hj + have he := congrArg (fun z : ClosedSpan (prefixCoord f) => + (z : StrongDual ℝ (ClosedSpan f)) (spanVector f j)) hc + have hh (i : ℕ) : (spanVector (prefixCoord f) i : StrongDual ℝ (ClosedSpan f)) = + prefixCoord f i := rfl + simpa only [Submodule.coe_sum, Submodule.coe_smul, Submodule.coe_zero, + sum_apply, smul_apply, zero_apply, hh, prefixCoord_ortho f hp ha hf, + Pi.single_apply, smul_eq_mul, mul_ite, mul_one, mul_zero, + Finset.sum_ite_eq', ite_eq_left hj] using he + + +theorem prefix_evaluation_surjective [CompleteSpace X] + (f : ℕ → StrongDual ℝ X) {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (D : ℕ → Finset X) (hD : ∀ m d, d ∈ D m → ‖d‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual ℝ X), v ∈ Submodule.span ℝ (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * |v d|) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) + (hrange : ∀ x : X, evaluation (ClosedSpan f) x ∈ ClosedSpan (prefixCoord f)) : + Function.Surjective ((evaluation (ClosedSpan f)).codRestrict (ClosedSpan (prefixCoord f)) hrange) ∧ + SeparableSpace (ClosedSpan (prefixCoord f)) ∧ + ¬ FiniteDimensional ℝ (ClosedSpan (prefixCoord f)) := by + let T := (evaluation (ClosedSpan f)).codRestrict (ClosedSpan (prefixCoord f)) hrange + have hlower (h : StrongDual ℝ (ClosedSpan (prefixCoord f))) : + (1 / 2 : ℝ) * ‖h‖ ≤ ‖h.comp T‖ := by + have hh := prefix_evaluation_adjoint_lower f ha hf D hD hnorm hann hrange h + change ‖h‖ ≤ 2 * ‖h.comp T‖ at hh + linarith + refine ⟨fun z => ?_, closedSpan_separable _, ?_⟩ + · obtain ⟨x, hx, _⟩ := surjective_of_adjoint_lower T (by norm_num : (0:ℝ) < 1 / 2) hlower z + exact ⟨x, hx⟩ + · intro hfd + let : FiniteDimensional ℝ (ClosedSpan (prefixCoord f)) := hfd + have hi := prefixCoord_linearIndependent f (prefixBound_of_half_normers f D hD hnorm hann) ha hf + have hh := hi.lt_aleph0_of_finiteDimensional + simp at hh + + + +lemma mem_coefficient_span_of_summable (f : ℕ → StrongDual ℝ X) (hp : PrefixBoundTwo f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (u : StrongDual ℝ (ClosedSpan f)) + (hu : Summable (fun n => |u (spanVector f n)|)) : + u ∈ ClosedSpan (prefixCoord f) := by + have hb (n : ℕ) : ‖prefixCoord f n‖ ≤ 4 / a := + (prefixCoord f n).opNorm_le_bound (by positivity) (fun z => prefixCoord_bound f hp ha hf z n) + let t (n : ℕ) : StrongDual ℝ (ClosedSpan f) := u (spanVector f n) • prefixCoord f n + have ht : Summable t := by + apply (hu.mul_right (4 / a)).of_norm_bounded + intro n + simpa only [t, norm_smul, Real.norm_eq_abs] using + mul_le_mul_of_nonneg_left (hb n) (abs_nonneg (u (spanVector f n))) + have hm : ∑' n, t n ∈ ClosedSpan (prefixCoord f) := by + apply tsum_mem (Submodule.isClosed_topologicalClosure _) + intro n + exact (ClosedSpan (prefixCoord f)).smul_mem _ (spanVector (prefixCoord f) n).property + have he : (∑' n, t n) = u := by + apply map_eq_of_spanVector f + intro j + have hh := (ContinuousLinearMap.apply ℝ ℝ (spanVector f j)).map_tsum ht + change (∑' n, t n) (spanVector f j) = ∑' n, t n (spanVector f j) at hh + rw [hh] + simp only [t, smul_apply, + prefixCoord_ortho f hp ha hf, Pi.single_apply, smul_eq_mul] + simp [eq_comm] + rwa [he] at hm + + + + +theorem eval_range_of_dense_summable + (E : Submodule ℝ (StrongDual ℝ X)) (hE : IsClosed (E : Set (StrongDual ℝ X))) + (g : ℕ → E) (hp : PrefixBoundTwo (fun i => (g i : StrongDual ℝ X))) + {a : ℝ} (ha : 0 < a) (hg : ∀ i, a ≤ ‖(g i : StrongDual ℝ X)‖) + (A : Set (StrongDual ℝ E)) + (hA : evaluation E '' Metric.closedBall (0 : X) 1 ⊆ closure A) + (hs : ∀ y ∈ A, Summable (fun n => |y (g n)|)) : + ∀ x : X, evaluation (ClosedSpan (fun i => (g i : StrongDual ℝ X))) x ∈ + ClosedSpan (prefixCoord (fun i => (g i : StrongDual ℝ X))) := by + let f : ℕ → StrongDual ℝ X := fun i => g i + have hGE : ClosedSpan f ≤ E := + Submodule.topologicalClosure_minimal _ + (Submodule.span_le.mpr (by rintro z ⟨i, rfl⟩; exact (g i).property)) hE + let I : ClosedSpan f →L[ℝ] E := (ClosedSpan f).subtypeL.codRestrict E (fun z => hGE z.property) + let Z := ClosedSpan (prefixCoord f) + have hclosed : IsClosed {y : StrongDual ℝ E | y.comp I ∈ Z} := + (Submodule.isClosed_topologicalClosure _).preimage (continuous_id.clm_comp_const I) + have hdense : closure A ⊆ {y : StrongDual ℝ E | y.comp I ∈ Z} := by + apply closure_minimal _ hclosed + intro y hy + exact mem_coefficient_span_of_summable f hp ha hg (y.comp I) (hs y hy) + have hunit (x : X) (hx : ‖x‖ ≤ 1) : evaluation (ClosedSpan f) x ∈ Z := by + exact hdense (hA ⟨x, by simpa only [Metric.mem_closedBall, dist_zero_right] using hx, rfl⟩) + intro x + by_cases hx : x = 0 + · simpa only [hx, map_zero] using Z.zero_mem + have hn : 0 < ‖x‖ := norm_pos_iff.mpr hx + have hu : ‖‖x‖⁻¹ • x‖ ≤ 1 := by + simp only [norm_smul, norm_inv, Real.norm_eq_abs, abs_norm, inv_mul_cancel₀ hn.ne'] + exact le_rfl + have hy := Z.smul_mem ‖x‖ (hunit (‖x‖⁻¹ • x) hu) + simpa only [map_smul, smul_smul, mul_inv_cancel₀ hn.ne', one_smul] using hy + +end SeparableQuotient.Positive.Rows + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/RowQuotients.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/RowQuotients.lean new file mode 100644 index 0000000000000000000000000000000000000000..58ae2f9fc0549757be535343f34d9983127f08c7 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/RowQuotients.lean @@ -0,0 +1,78 @@ +import OAI.Analysis.SeparableQuotients.Positive.RowEvaluation +import OAI.Analysis.SeparableQuotients.Positive.ContinuumMeasure +import OAI.Analysis.SeparableQuotients.Positive.RealAdjoint + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Rows +attribute [local instance] dualSubmoduleNormedGroup dualSubmoduleNormedSpace +open scoped BigOperators +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] + + +def HasSeparableQuotient (𝕜 : Type) [RCLike 𝕜] (X : Type u) + [NormedAddCommGroup X] [NormedSpace 𝕜 X] : Prop := + ∃ (Y : Type u) (g : NormedAddCommGroup Y), + letI := g + ∃ s : NormedSpace 𝕜 Y, + letI := s + CompleteSpace Y ∧ SeparableSpace Y ∧ ¬ FiniteDimensional 𝕜 Y ∧ + ∃ T : X →L[𝕜] Y, Function.Surjective T + + + + +theorem quotient_of_small_dense_rows + (μ : Measure ContinuumIndex) [IsProbabilityMeasure μ] + (hadd : ContinuumAdditive μ) (hsingle : ∀ i, μ {i} = 0) + (E : Submodule ℝ (StrongDual ℝ X)) (hE : IsClosed (E : Set (StrongDual ℝ X))) + (u : ∀ n : ℕ, Fin (16 ^ (n+1)) → E) + (hlo : ∀ n (c : Fin (16 ^ (n+1)) → ℝ), + Real.sqrt (∑ j, (c j)^2) ≤ ‖∑ j, c j • u n j‖) + (hhi : ∀ n (c : Fin (16 ^ (n+1)) → ℝ), + ‖∑ j, c j • u n j‖ ≤ 2 * Real.sqrt (∑ j, (c j)^2)) + (D : ℕ → Finset X) (hD : ∀ m d, d ∈ D m → ‖d‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual ℝ X), + v ∈ Submodule.span ℝ {w | ∃ n, n < m ∧ ∃ j, (u n j : StrongDual ℝ X) = w} → + ∃ d ∈ D m, ‖v‖ ≤ 2 * |v d|) + (hann : ∀ m n, m ≤ n → ∀ j d, d ∈ D m → (u n j : StrongDual ℝ X) d = 0) + (A : Set (StrongDual ℝ E)) (hcard : Cardinal.mk A < Cardinal.continuum.{u}) + (hunit : ∀ y ∈ A, ‖y‖ ≤ 1) + (hdense : evaluation E '' Metric.closedBall (0 : X) 1 ⊆ closure A) : + HasSeparableQuotient ℝ X := by + obtain ⟨j, hj⟩ := select_rows_from_small_set μ hadd hsingle u hhi A hcard hunit + let g (n : ℕ) : E := u n (j n) + let f (n : ℕ) : StrongDual ℝ X := g n + have hf (n : ℕ) : (1 : ℝ) ≤ ‖f n‖ := by + have hh := hlo n (Pi.single (j n) (1 : ℝ)) + simpa [f, g, Pi.single_apply] using hh + have hn m (v : StrongDual ℝ X) + (hv : v ∈ Submodule.span ℝ (f '' (Finset.range m : Set ℕ))) : + ∃ d ∈ D m, ‖v‖ ≤ 2 * |v d| := by + apply hnorm m v + apply Submodule.span_mono (t := {w | ∃ n, n < m ∧ ∃ j, (u n j : StrongDual ℝ X) = w}) _ hv + rintro w ⟨n, hn, rfl⟩ + exact ⟨n, Finset.mem_range.mp hn, j n, rfl⟩ + have han m n (hmn : m ≤ n) d (hd : d ∈ D m) : f n d = 0 := + hann m n hmn (j n) d hd + have hp := prefixBound_of_half_normers f D hD hn han + have hrange := eval_range_of_dense_summable E hE g hp (by norm_num : (0:ℝ) < 1) hf A hdense hj + obtain ⟨hsurj, hsep, hinf⟩ := + prefix_evaluation_surjective f (by norm_num : (0:ℝ) < 1) hf D hD hn han hrange + refine ⟨ClosedSpan (prefixCoord f), inferInstance, inferInstance, inferInstance, hsep, hinf, ?_⟩ + exact ⟨(evaluation (ClosedSpan f)).codRestrict (ClosedSpan (prefixCoord f)) hrange, hsurj⟩ + +end SeparableQuotient.Positive.Rows + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/SampledSuppression.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/SampledSuppression.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c310c9735f66d6e5bf3743a3bbb8dd28bb78049 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/SampledSuppression.lean @@ -0,0 +1,97 @@ +import OAI.Analysis.SeparableQuotients.Positive.TupleSampling + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling +open MeasureTheory Set Filter +open scoped Classical BigOperators +variable {I X C K : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + [NormedAddCommGroup X] [NormedSpace ℝ X] [MeasurableSpace C] [MeasurableSpace K] + + + +lemma ae_finite_suppression + {μ : Measure I} [IsProbabilityMeasure μ] + {code : I → C} {Φ : C × K → ℝ} {R : UnitBall X → K} + {f : I → StrongDual ℝ X} + (hΦ : Measurable Φ) + (heval : ∀ a x, Φ (code a, R x) = f a x) + (hnull : ∀ x : UnitBall X, ∀ᵐ a ∂μ, f a x = 0) + (n : ℕ) (c : Fin n → ℝ) (s : Finset (Fin n)) : + ∀ᵐ t ∂orderedMeasure μ n, + ‖∑ j ∈ s, c j • f (t j)‖ ≤ 2 * ‖∑ j, c j • f (t j)‖ := by + let Y : FullTuple I n → K := fun t => + R (ballHalfNormer (∑ j ∈ s, c j • f (t j))) + have hnullD : ∀ y ∈ Set.range R, ∀ᵐ a ∂μ, Φ (code a, y) = 0 := by + rintro y ⟨x, rfl⟩ + simpa only [heval] using hnull x + have hcross (i : Fin n) (hi : i ∉ s) : + ∀ᵐ t ∂orderedMeasure μ n, f (t i) (halfNormer (∑ j ∈ s, c j • f (t j))) = 0 := by + have hh := ordered_cross_vanishing hΦ hnullD i Y + (fun t => Set.mem_range_self _) (by + intro u v huv + apply congrArg (fun g => R (ballHalfNormer g)) + apply Finset.sum_congr rfl + intro j hj + rw [huv j (fun h => hi (h ▸ hj))]) + simpa only [Y, heval, ballHalfNormer] using hh + have hall : ∀ᵐ t ∂orderedMeasure μ n, ∀ i, i ∉ s → + f (t i) (halfNormer (∑ j ∈ s, c j • f (t j))) = 0 := by + apply ae_all_iff.mpr + intro i + by_cases hi : i ∈ s + · exact Eventually.of_forall (fun _ h => False.elim (h hi)) + · exact (hcross i hi).mono (fun _ ht _ => ht) + exact hall.mono (fun t ht => suppression_of_cross_vanishing (fun j => f (t j)) c s ht) + + +lemma real_suppression_of_rational {J V : Type*} [Fintype J] + [NormedAddCommGroup V] [NormedSpace ℝ V] (v : J → V) (s : Finset J) + (hq : ∀ q : J → ℚ, ‖∑ j ∈ s, (q j : ℝ) • v j‖ ≤ 2 * ‖∑ j, (q j : ℝ) • v j‖) : + ∀ c : J → ℝ, ‖∑ j ∈ s, c j • v j‖ ≤ 2 * ‖∑ j, c j • v j‖ := by + have hd : DenseRange (fun q : J → ℚ => fun j => (q j : ℝ)) := + DenseRange.piMap (fun _ => Rat.denseRange_cast) + intro c + refine hd.induction_on (p := fun c : J → ℝ => + ‖∑ j ∈ s, c j • v j‖ ≤ 2 * ‖∑ j, c j • v j‖) c ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · exact hq + + + +lemma exists_sequence_suppression + {μ : Measure I} [IsProbabilityMeasure μ] + {code : I → C} {Φ : C × K → ℝ} {R : UnitBall X → K} + {f : I → StrongDual ℝ X} + (hΦ : Measurable Φ) + (heval : ∀ a x, Φ (code a, R x) = f a x) + (hnull : ∀ x : UnitBall X, ∀ᵐ a ∂μ, f a x = 0) : + ∃ α : ℕ → I, ∀ n (c : Fin n → ℝ) (s : Finset (Fin n)), + ‖∑ j ∈ s, c j • f (α j.val)‖ ≤ 2 * ‖∑ j, c j • f (α j.val)‖ := by + let G : (n : ℕ) → FullTuple I n → Prop := fun n t => + ∀ (q : Fin n → ℚ) (s : Finset (Fin n)), + ‖∑ j ∈ s, (q j : ℝ) • f (t j)‖ ≤ 2 * ‖∑ j, (q j : ℝ) • f (t j)‖ + have hG : ∀ n, ∀ᵐ t ∂orderedMeasure μ n, G n t := by + intro n + apply ae_all_iff.mpr + intro q + apply ae_all_iff.mpr + intro s + exact ae_finite_suppression hΦ heval hnull n (fun j => (q j : ℝ)) s + obtain ⟨α, hα⟩ := exists_good_tuple_sequence μ G hG + refine ⟨α, fun n c s => ?_⟩ + exact real_suppression_of_rational (fun j : Fin n => f (α j.val)) s + (fun q => hα n q s) c +end SeparableQuotient.Positive.Sampling + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarAdjoint.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarAdjoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..71c8070e820b48e603756bf9b123fd7f87c6b5ea --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarAdjoint.lean @@ -0,0 +1,52 @@ +import OAI.Analysis.SeparableQuotients.Positive.RealAdjoint + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields +alias ball_subset_closure_image_of_adjoint_lower := Rows.ball_subset_closure_image_of_adjoint_lower +alias approx_preimage_of_adjoint_lower := Rows.approx_preimage_of_adjoint_lower +alias surjective_of_adjoint_lower := Rows.surjective_of_adjoint_lower +end SeparableQuotient.Positive.Fields + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.Scalar +variable (𝕜 : Type*) [RCLike 𝕜] +variable {X Y : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] + + + + +theorem surjective_of_adjoint_lower [CompleteSpace X] (T : X →L[𝕜] Y) {c : ℝ} + (hc : 0 < c) (hlower : ∀ h : StrongDual 𝕜 Y, c * ‖h‖ ≤ ‖h.comp T‖) : + ∀ y : Y, ∃ x : X, T x = y ∧ ‖x‖ ≤ (2 / c) * ‖y‖ := by + let : NormedSpace ℝ X := NormedSpace.restrictScalars ℝ 𝕜 X + let : NormedSpace ℝ Y := NormedSpace.restrictScalars ℝ 𝕜 Y + have hlowerR (h : StrongDual ℝ Y) : c * ‖h‖ ≤ ‖h.comp (T.restrictScalars ℝ)‖ := by + have hh := hlower (h.extendRCLike : StrongDual 𝕜 Y) + have he : (h.extendRCLike : StrongDual 𝕜 Y).comp T = + StrongDual.extendRCLike (h.comp (T.restrictScalars ℝ)) := by + ext x + simp only [ContinuousLinearMap.comp_apply, StrongDual.extendRCLike_apply, + ContinuousLinearMap.coe_restrictScalars', map_smul] + rw [he, StrongDual.norm_extendRCLike, StrongDual.norm_extendRCLike] at hh + exact hh + exact SeparableQuotient.Positive.Fields.surjective_of_adjoint_lower (T.restrictScalars ℝ) hc hlowerR +end SeparableQuotient.Positive.Fields.Scalar + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarBasis.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4578d6347a9b922caecdfdb591ecdf6ed725983 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarBasis.lean @@ -0,0 +1,206 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.Scalar +variable (𝕜 : Type*) [RCLike 𝕜] +variable {V : Type*} [NormedAddCommGroup V] [NormedSpace 𝕜 V] + +abbrev ClosedSpan (v : ℕ → V) : Submodule 𝕜 V := + (Submodule.span 𝕜 (Set.range v)).topologicalClosure + +def spanVector (v : ℕ → V) (i : ℕ) : ClosedSpan 𝕜 v := + ⟨v i, Submodule.le_topologicalClosure _ (Submodule.subset_span (Set.mem_range_self i))⟩ + +def spanCombination (v : ℕ → V) : (ℕ →₀ 𝕜) →ₗ[𝕜] ClosedSpan 𝕜 v := + Finsupp.linearCombination 𝕜 (spanVector 𝕜 v) + +lemma spanCombination_coe (v : ℕ → V) (c : ℕ →₀ 𝕜) : + (spanCombination 𝕜 v c : V) = c.sum (fun i a => a • v i) := by + simp [spanCombination, Finsupp.linearCombination_apply, Finsupp.sum, spanVector] + +lemma denseRange_spanCombination (v : ℕ → V) : DenseRange (spanCombination 𝕜 v) := by + rw [DenseRange, Subtype.dense_iff] + have hr : (Subtype.val : ClosedSpan 𝕜 v → V) '' Set.range (spanCombination 𝕜 v) = + (Submodule.span 𝕜 (Set.range v) : Set V) := by + rw [← Set.range_comp] + change Set.range (fun c => (spanCombination 𝕜 v c : V)) = _ + simp only [spanCombination_coe] + change Set.range (Finsupp.linearCombination 𝕜 v) = _ + exact congrArg (fun s : Submodule 𝕜 V => (s : Set V)) + (Finsupp.range_linearCombination 𝕜 (v := v)) + change (ClosedSpan 𝕜 v : Set V) ⊆ closure ((Subtype.val : ClosedSpan 𝕜 v → V) '' Set.range (spanCombination 𝕜 v)) + rw [hr] + exact Set.Subset.rfl + + +def PrefixBoundTwo (v : ℕ → V) : Prop := + ∀ (c : ℕ →₀ 𝕜) (m : ℕ), + ‖∑ i ∈ Finset.range m, c i • v i‖ ≤ 2 * ‖c.sum (fun i a => a • v i)‖ + +lemma prefix_coefficient_bound (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ 𝕜) (i : ℕ) : + ‖c i‖ ≤ (4 / a) * ‖spanCombination 𝕜 v c‖ := by + have hdiff : c i • v i = (∑ j ∈ Finset.range (i+1), c j • v j) - + (∑ j ∈ Finset.range i, c j • v j) := by rw [Finset.sum_range_succ]; abel + have hh : ‖c i • v i‖ ≤ 4 * ‖c.sum (fun i a => a • v i)‖ := by + rw [hdiff] + exact (norm_sub_le _ _).trans ((add_le_add (h c (i+1)) (h c i)).trans_eq (by ring)) + rw [norm_smul] at hh + have hb : ‖c i‖ * a ≤ 4 * ‖spanCombination 𝕜 v c‖ := by + exact (mul_le_mul_of_nonneg_left (hv i) (norm_nonneg _)).trans + (by simpa only [← spanCombination_coe, Submodule.norm_coe] using hh) + rw [div_mul_eq_mul_div] + exact (le_div_iff₀ ha).mpr hb + + +def prefixCoord (v : ℕ → V) (i : ℕ) : StrongDual 𝕜 (ClosedSpan 𝕜 v) := + (Finsupp.lapply i).extendOfNorm (spanCombination 𝕜 v) + +lemma prefixCoord_combination (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ 𝕜) (i : ℕ) : + prefixCoord 𝕜 v i (spanCombination 𝕜 v c) = c i := by + apply LinearMap.extendOfNorm_eq (denseRange_spanCombination 𝕜 v) + exact ⟨4 / a, fun c => prefix_coefficient_bound 𝕜 v h ha hv c i⟩ + +lemma prefixCoord_bound (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (x : ClosedSpan 𝕜 v) (i : ℕ) : + ‖prefixCoord 𝕜 v i x‖ ≤ (4 / a) * ‖x‖ := by + exact LinearMap.norm_extendOfNorm_apply_le (denseRange_spanCombination 𝕜 v) _ + (fun c => prefix_coefficient_bound 𝕜 v h ha hv c i) x + +lemma prefixCoord_ortho (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (i j : ℕ) : + prefixCoord 𝕜 v i (spanVector 𝕜 v j) = (Pi.single j (1 : 𝕜) : ℕ → 𝕜) i := by + have hc : spanCombination 𝕜 v (Finsupp.single j 1) = spanVector 𝕜 v j := by + simp [spanCombination] + rw [← hc, prefixCoord_combination 𝕜 v h ha hv] + simp [Finsupp.single_apply, Pi.single_apply, eq_comm] + + +def prefixProjection (v : ℕ → V) (s : Finset ℕ) : + ClosedSpan 𝕜 v →L[𝕜] ClosedSpan 𝕜 v := + ∑ i ∈ s, (prefixCoord 𝕜 v i).smulRight (spanVector 𝕜 v i) + +lemma prefixProjection_apply (v : ℕ → V) (s : Finset ℕ) (x : ClosedSpan 𝕜 v) : + prefixProjection 𝕜 v s x = ∑ i ∈ s, prefixCoord 𝕜 v i x • spanVector 𝕜 v i := by + simp [prefixProjection] + +lemma prefixProjection_bound (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (m : ℕ) (x : ClosedSpan 𝕜 v) : + ‖prefixProjection 𝕜 v (Finset.range m) x‖ ≤ 2 * ‖x‖ := by + refine (denseRange_spanCombination 𝕜 v).induction_on x (p := fun x => + ‖prefixProjection 𝕜 v (Finset.range m) x‖ ≤ 2 * ‖x‖) ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · intro c + rw [prefixProjection_apply] + simp only [prefixCoord_combination 𝕜 v h ha hv] + have hh := h c m + change ‖((∑ i ∈ Finset.range m, c i • spanVector 𝕜 v i : ClosedSpan 𝕜 v) : V)‖ ≤ + 2 * ‖(spanCombination 𝕜 v c : V)‖ + simpa only [Submodule.coe_sum, Submodule.coe_smul, spanVector, spanCombination_coe] using hh + +lemma prefixProjection_combination (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ 𝕜) + (s : Finset ℕ) (hs : c.support ⊆ s) : + prefixProjection 𝕜 v s (spanCombination 𝕜 v c) = spanCombination 𝕜 v c := by + rw [prefixProjection_apply] + simp only [prefixCoord_combination 𝕜 v h ha hv] + exact (Finsupp.sum_of_support_subset c hs (fun i a => a • spanVector 𝕜 v i) (by simp)).symm + +lemma prefix_expansion (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (x : ClosedSpan 𝕜 v) : + HasSum (fun i => prefixCoord 𝕜 v i x • spanVector 𝕜 v i) x (SummationFilter.conditional ℕ) := by + have hequi : Equicontinuous (fun m : ℕ => + (prefixProjection 𝕜 v (Finset.range m) : ClosedSpan 𝕜 v → ClosedSpan 𝕜 v)) := by + have hb : ∃ C : ℝ, ∀ (m : ℕ) (y : ClosedSpan 𝕜 v), + ‖prefixProjection 𝕜 v (Finset.range m) y‖ ≤ C * ‖y‖ := + ⟨2, fun m y => prefixProjection_bound 𝕜 v h ha hv m y⟩ + exact ((NormedSpace.equicontinuous_TFAE (fun m => prefixProjection 𝕜 v (Finset.range m))).out 4 2).mp hb + rw [HasSum, SummationFilter.conditional_filter_eq_map_range, tendsto_map'_iff] + change Tendsto (fun m : ℕ => ∑ i ∈ Finset.range m, prefixCoord 𝕜 v i x • spanVector 𝕜 v i) + atTop (𝓝 x) + simp only [← prefixProjection_apply] + refine (denseRange_spanCombination 𝕜 v).induction_on x (p := fun x => + Tendsto (fun m : ℕ => prefixProjection 𝕜 v (Finset.range m) x) atTop (𝓝 x)) ?_ ?_ + · exact hequi.isClosed_setOfPred_tendsto continuous_id + · intro c + obtain ⟨N, hN⟩ := c.support.exists_nat_subset_range + apply tendsto_const_nhds.congr' + filter_upwards [eventually_ge_atTop N] with m hm + exact (prefixProjection_combination 𝕜 v h ha hv c (Finset.range m) + (hN.trans (Finset.range_mono hm))).symm + + +def basisOfPrefix (v : ℕ → V) (h : PrefixBoundTwo 𝕜 v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) : + SchauderBasis 𝕜 (ClosedSpan 𝕜 v) where + basis := spanVector 𝕜 v + coord := prefixCoord 𝕜 v + ortho := by + intro i j + rw [prefixCoord_ortho 𝕜 v h ha hv] + by_cases hij : i = j <;> simp [hij] + expansion := prefix_expansion 𝕜 v h ha hv + +end SeparableQuotient.Positive.Fields.Scalar + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.Scalar +open Set +open scoped Classical BigOperators +variable (𝕜 : Type*) [RCLike 𝕜] +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + + + +lemma prefixBound_of_half_normers (f : ℕ → StrongDual 𝕜 X) (D : ℕ → Finset X) + (hD : ∀ m x, x ∈ D m → ‖x‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual 𝕜 X), v ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) : PrefixBoundTwo 𝕜 f := by + classical + intro c m + let v := ∑ i ∈ Finset.range m, c i • f i + have hv : v ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ)) := by + apply Submodule.sum_mem + intro i hi + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, hi, rfl⟩) + obtain ⟨d, hd, hnormd⟩ := hnorm m v hv + have heval : (c.sum (fun i a => a • f i)) d = v d := by + simp only [Finsupp.sum, sum_apply, smul_apply, smul_eq_mul, v] + calc + ∑ i ∈ c.support, c i * f i d = ∑ i ∈ c.support ∪ Finset.range m, c i * f i d := by + apply Finset.sum_subset Finset.subset_union_left + intro i _ hi + simp [Finsupp.notMem_support_iff.mp hi] + _ = ∑ i ∈ Finset.range m, c i * f i d := by + symm + apply Finset.sum_subset Finset.subset_union_right + intro i _ hi + simp [hann m i (Nat.le_of_not_gt (by simpa using hi)) d hd] + calc + ‖v‖ ≤ 2 * ‖v d‖ := hnormd + _ = 2 * ‖(c.sum (fun i a => a • f i)) d‖ := by rw [heval] + _ ≤ 2 * ‖c.sum (fun i a => a • f i)‖ := by + gcongr + simpa only [mul_one] using + (c.sum (fun i a => a • f i)).le_opNorm_of_le (hD m d hd) +end SeparableQuotient.Positive.Fields.Scalar + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarEvaluation.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbf6d11b848987bedc4714d355c281d38f71ba9f --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarEvaluation.lean @@ -0,0 +1,256 @@ +import OAI.Analysis.SeparableQuotients.Positive.ScalarBasis +import OAI.Analysis.SeparableQuotients.Positive.ScalarAdjoint + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.Scalar +open Set Filter TopologicalSpace +open scoped Classical BigOperators Topology +variable {𝕜 : Type*} [RCLike 𝕜] +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] +local instance dualSubmoduleNormedGroup (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + NormedAddCommGroup F := Submodule.normedAddCommGroup F +local instance dualSubmoduleNormedSpace (F : Submodule 𝕜 (StrongDual 𝕜 X)) : + NormedSpace 𝕜 F := Submodule.normedSpace F + +def evaluation (G : Submodule 𝕜 (StrongDual 𝕜 X)) : X →L[𝕜] StrongDual 𝕜 G := G.subtypeL.flip + +lemma map_eq_of_spanVector {V W : Type*} [NormedAddCommGroup V] [NormedSpace 𝕜 V] + [NormedAddCommGroup W] [NormedSpace 𝕜 W] (v : ℕ → V) + (φ ψ : ClosedSpan 𝕜 v →L[𝕜] W) + (he : ∀ i, φ (spanVector 𝕜 v i) = ψ (spanVector 𝕜 v i)) : φ = ψ := by + apply DFunLike.ext' + apply (denseRange_spanCombination 𝕜 v).equalizer φ.continuous ψ.continuous + funext c + change φ (spanCombination 𝕜 v c) = ψ (spanCombination 𝕜 v c) + simp only [spanCombination, Finsupp.linearCombination_apply, map_finsuppSum, map_smul, he] + +lemma evaluation_eq_prefix_at_normer (f : ℕ → StrongDual 𝕜 X) (hp : PrefixBoundTwo 𝕜 f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) (m : ℕ) (d : X) + (hann : ∀ i, m ≤ i → f i d = 0) : + evaluation (ClosedSpan 𝕜 f) d = ∑ i ∈ Finset.range m, (f i d) • prefixCoord 𝕜 f i := by + apply map_eq_of_spanVector f + intro j + have he : evaluation (ClosedSpan 𝕜 f) d (spanVector 𝕜 f j) = f j d := rfl + rw [he] + simp only [sum_apply, smul_apply, prefixCoord_ortho 𝕜 f hp ha hf, Pi.single_apply] + by_cases hj : j < m + · simp [Finset.mem_range, hj, eq_comm] + · simp [Finset.mem_range, hj, eq_comm, hann j (Nat.le_of_not_gt hj)] + +def adjointPrefixVector (f : ℕ → StrongDual 𝕜 X) + (h : StrongDual 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f))) (m : ℕ) : ClosedSpan 𝕜 f := + ∑ i ∈ Finset.range m, h (spanVector 𝕜 (prefixCoord 𝕜 f) i) • spanVector 𝕜 f i + +lemma adjointPrefixVector_bound (f : ℕ → StrongDual 𝕜 X) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (D : ℕ → Finset X) (hD : ∀ m d, d ∈ D m → ‖d‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual 𝕜 X), v ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) + (hrange : ∀ x : X, evaluation (ClosedSpan 𝕜 f) x ∈ ClosedSpan 𝕜 (prefixCoord 𝕜 f)) : + let T := (evaluation (ClosedSpan 𝕜 f)).codRestrict (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) hrange + ∀ (h : StrongDual 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f))) (m : ℕ), + ‖adjointPrefixVector f h m‖ ≤ 2 * ‖h.comp T‖ := by + intro T h + have hp : PrefixBoundTwo 𝕜 f := prefixBound_of_half_normers 𝕜 f D hD hnorm hann + intro m + have hvm : (adjointPrefixVector f h m : StrongDual 𝕜 X) ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ)) := by + simp only [adjointPrefixVector, Submodule.coe_sum, Submodule.coe_smul, spanVector] + apply Submodule.sum_mem + intro i hi + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, hi, rfl⟩) + obtain ⟨d, hd, hv⟩ := hnorm m (adjointPrefixVector f h m) hvm + have hdT : T d = ∑ i ∈ Finset.range m, (f i d) • spanVector 𝕜 (prefixCoord 𝕜 f) i := by + apply Subtype.ext + change evaluation (ClosedSpan 𝕜 f) d = _ + simpa only [Submodule.coe_sum, Submodule.coe_smul, spanVector] using + evaluation_eq_prefix_at_normer f hp ha hf m d (fun i hi => hann m i hi d hd) + have he : (adjointPrefixVector f h m : StrongDual 𝕜 X) d = h (T d) := by + rw [hdT] + simp only [adjointPrefixVector, Submodule.coe_sum, Submodule.coe_smul, spanVector, sum_apply, + smul_apply, map_sum, map_smul, smul_eq_mul] + apply Finset.sum_congr rfl + intro i hi + ring + have hb : ‖h (T d)‖ ≤ ‖h.comp T‖ := by + simpa only [ContinuousLinearMap.comp_apply, mul_one] using + (h.comp T).le_opNorm_of_le (hD m d hd) + calc + ‖adjointPrefixVector f h m‖ ≤ 2 * ‖(adjointPrefixVector f h m : StrongDual 𝕜 X) d‖ := hv + _ = 2 * ‖h (T d)‖ := by rw [he] + _ ≤ 2 * ‖h.comp T‖ := mul_le_mul_of_nonneg_left hb (by norm_num) + +lemma prefixCoord_adjointPrefixVector (f : ℕ → StrongDual 𝕜 X) (hp : PrefixBoundTwo 𝕜 f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (h : StrongDual 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f))) (m j : ℕ) : + prefixCoord 𝕜 f j (adjointPrefixVector f h m) = + if j < m then h (spanVector 𝕜 (prefixCoord 𝕜 f) j) else 0 := by + simp only [adjointPrefixVector, map_sum, map_smul, prefixCoord_ortho 𝕜 f hp ha hf, Pi.single_apply] + simp [Finset.mem_range] + +lemma coefficient_pairing_adjointPrefixVector (f : ℕ → StrongDual 𝕜 X) + (hp : PrefixBoundTwo 𝕜 f) {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (h : StrongDual 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f))) + (c : ℕ →₀ 𝕜) (m : ℕ) (hm : c.support ⊆ Finset.range m) : + (spanCombination 𝕜 (prefixCoord 𝕜 f) c : StrongDual 𝕜 (ClosedSpan 𝕜 f)) + (adjointPrefixVector f h m) = h (spanCombination 𝕜 (prefixCoord 𝕜 f) c) := by + rw [spanCombination_coe] + simp only [spanCombination, Finsupp.linearCombination_apply, Finsupp.sum, + map_sum, map_smul, sum_apply, smul_apply, + prefixCoord_adjointPrefixVector f hp ha hf, smul_eq_mul] + apply Finset.sum_congr rfl + intro i hi + simp only [ite_eq_left (Finset.mem_range.mp (hm hi))] + + +theorem prefix_evaluation_adjoint_lower (f : ℕ → StrongDual 𝕜 X) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (D : ℕ → Finset X) (hD : ∀ m d, d ∈ D m → ‖d‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual 𝕜 X), v ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) + (hrange : ∀ x : X, evaluation (ClosedSpan 𝕜 f) x ∈ ClosedSpan 𝕜 (prefixCoord 𝕜 f)) : + let T := (evaluation (ClosedSpan 𝕜 f)).codRestrict (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) hrange + ∀ h : StrongDual 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f)), ‖h‖ ≤ 2 * ‖h.comp T‖ := by + intro T h + have hp : PrefixBoundTwo 𝕜 f := prefixBound_of_half_normers 𝕜 f D hD hnorm hann + apply h.opNorm_le_bound (by positivity) + intro z + refine (denseRange_spanCombination 𝕜 (prefixCoord 𝕜 f)).induction_on z + (p := fun z => ‖h z‖ ≤ 2 * ‖h.comp T‖ * ‖z‖) ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · intro c + obtain ⟨m, hm⟩ := c.support.exists_nat_subset_range + have he := coefficient_pairing_adjointPrefixVector f hp ha hf h c m hm + rw [← he] + have hb := (spanCombination 𝕜 (prefixCoord 𝕜 f) c : StrongDual 𝕜 (ClosedSpan 𝕜 f)).le_opNorm (adjointPrefixVector f h m) + exact hb.trans ((mul_le_mul_of_nonneg_left (adjointPrefixVector_bound f ha hf D hD hnorm hann hrange h m) (norm_nonneg _)).trans_eq (by + change ‖spanCombination 𝕜 (prefixCoord 𝕜 f) c‖ * (2 * ‖h.comp T‖) = _ + ring)) + + +lemma closedSpan_separable {V : Type*} [NormedAddCommGroup V] [NormedSpace 𝕜 V] + (v : ℕ → V) : SeparableSpace (ClosedSpan 𝕜 v) := by + exact ((Set.countable_range v).isSeparable.span (R := 𝕜)).closure.separableSpace + +lemma prefixCoord_linearIndependent (f : ℕ → StrongDual 𝕜 X) (hp : PrefixBoundTwo 𝕜 f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) : + LinearIndependent 𝕜 (spanVector 𝕜 (prefixCoord 𝕜 f)) := by + classical + rw [linearIndependent_iff'] + intro s c hc j hj + have he := congrArg (fun z : ClosedSpan 𝕜 (prefixCoord 𝕜 f) => + (z : StrongDual 𝕜 (ClosedSpan 𝕜 f)) (spanVector 𝕜 f j)) hc + have hh (i : ℕ) : (spanVector 𝕜 (prefixCoord 𝕜 f) i : StrongDual 𝕜 (ClosedSpan 𝕜 f)) = + prefixCoord 𝕜 f i := rfl + simpa only [Submodule.coe_sum, Submodule.coe_smul, Submodule.coe_zero, + sum_apply, smul_apply, zero_apply, hh, prefixCoord_ortho 𝕜 f hp ha hf, + Pi.single_apply, smul_eq_mul, mul_ite, mul_one, mul_zero, + Finset.sum_ite_eq', ite_eq_left hj] using he + + +theorem prefix_evaluation_surjective [CompleteSpace X] + (f : ℕ → StrongDual 𝕜 X) {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (D : ℕ → Finset X) (hD : ∀ m d, d ∈ D m → ‖d‖ ≤ 1) + (hnorm : ∀ m (v : StrongDual 𝕜 X), v ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ)) → + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖) + (hann : ∀ m i, m ≤ i → ∀ d ∈ D m, f i d = 0) + (hrange : ∀ x : X, evaluation (ClosedSpan 𝕜 f) x ∈ ClosedSpan 𝕜 (prefixCoord 𝕜 f)) : + Function.Surjective ((evaluation (ClosedSpan 𝕜 f)).codRestrict (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) hrange) ∧ + SeparableSpace (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) ∧ + ¬ FiniteDimensional 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) := by + let T := (evaluation (ClosedSpan 𝕜 f)).codRestrict (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) hrange + have hlower (h : StrongDual 𝕜 (ClosedSpan 𝕜 (prefixCoord 𝕜 f))) : + (1 / 2 : ℝ) * ‖h‖ ≤ ‖h.comp T‖ := by + have hh := prefix_evaluation_adjoint_lower f ha hf D hD hnorm hann hrange h + change ‖h‖ ≤ 2 * ‖h.comp T‖ at hh + linarith + refine ⟨fun z => ?_, closedSpan_separable _, ?_⟩ + · obtain ⟨x, hx, _⟩ := surjective_of_adjoint_lower 𝕜 T (by norm_num : (0:ℝ) < 1 / 2) hlower z + exact ⟨x, hx⟩ + · intro hfd + let := hfd + have hi := prefixCoord_linearIndependent f (prefixBound_of_half_normers 𝕜 f D hD hnorm hann) ha hf + have hh := hi.lt_aleph0_of_finiteDimensional + simp at hh + + + +lemma mem_coefficient_span_of_summable (f : ℕ → StrongDual 𝕜 X) (hp : PrefixBoundTwo 𝕜 f) + {a : ℝ} (ha : 0 < a) (hf : ∀ i, a ≤ ‖f i‖) + (u : StrongDual 𝕜 (ClosedSpan 𝕜 f)) + (hu : Summable (fun n => ‖u (spanVector 𝕜 f n)‖)) : + u ∈ ClosedSpan 𝕜 (prefixCoord 𝕜 f) := by + have hb (n : ℕ) : ‖prefixCoord 𝕜 f n‖ ≤ 4 / a := + (prefixCoord 𝕜 f n).opNorm_le_bound (by positivity) (fun z => prefixCoord_bound 𝕜 f hp ha hf z n) + let t (n : ℕ) : StrongDual 𝕜 (ClosedSpan 𝕜 f) := u (spanVector 𝕜 f n) • prefixCoord 𝕜 f n + have ht : Summable t := by + apply (hu.mul_right (4 / a)).of_norm_bounded + intro n + simpa only [t, norm_smul] using + mul_le_mul_of_nonneg_left (hb n) (norm_nonneg (u (spanVector 𝕜 f n))) + have hm : ∑' n, t n ∈ ClosedSpan 𝕜 (prefixCoord 𝕜 f) := by + apply tsum_mem (Submodule.isClosed_topologicalClosure _) + intro n + exact (ClosedSpan 𝕜 (prefixCoord 𝕜 f)).smul_mem _ (spanVector 𝕜 (prefixCoord 𝕜 f) n).property + have he : (∑' n, t n) = u := by + apply map_eq_of_spanVector f + intro j + have hh := (ContinuousLinearMap.apply 𝕜 𝕜 (spanVector 𝕜 f j)).map_tsum ht + change (∑' n, t n) (spanVector 𝕜 f j) = ∑' n, t n (spanVector 𝕜 f j) at hh + rw [hh] + simp only [t, smul_apply, + prefixCoord_ortho 𝕜 f hp ha hf, Pi.single_apply, smul_eq_mul] + simp [eq_comm] + rwa [he] at hm + + + + +theorem eval_range_of_dense_summable + (E : Submodule 𝕜 (StrongDual 𝕜 X)) (hE : IsClosed (E : Set (StrongDual 𝕜 X))) + (g : ℕ → E) (hp : PrefixBoundTwo 𝕜 (fun i => (g i : StrongDual 𝕜 X))) + {a : ℝ} (ha : 0 < a) (hg : ∀ i, a ≤ ‖(g i : StrongDual 𝕜 X)‖) + (A : Set (StrongDual 𝕜 E)) + (hA : evaluation E '' Metric.closedBall (0 : X) 1 ⊆ closure A) + (hs : ∀ y ∈ A, Summable (fun n => ‖y (g n)‖)) : + ∀ x : X, evaluation (ClosedSpan 𝕜 (fun i => (g i : StrongDual 𝕜 X))) x ∈ + ClosedSpan 𝕜 (prefixCoord 𝕜 (fun i => (g i : StrongDual 𝕜 X))) := by + let f : ℕ → StrongDual 𝕜 X := fun i => g i + have hGE : ClosedSpan 𝕜 f ≤ E := + Submodule.topologicalClosure_minimal _ + (Submodule.span_le.mpr (by rintro z ⟨i, rfl⟩; exact (g i).property)) hE + let I : ClosedSpan 𝕜 f →L[𝕜] E := (ClosedSpan 𝕜 f).subtypeL.codRestrict E (fun z => hGE z.property) + let Z := ClosedSpan 𝕜 (prefixCoord 𝕜 f) + have hclosed : IsClosed {y : StrongDual 𝕜 E | y.comp I ∈ Z} := + (Submodule.isClosed_topologicalClosure _).preimage (continuous_id.clm_comp_const I) + have hdense : closure A ⊆ {y : StrongDual 𝕜 E | y.comp I ∈ Z} := by + apply closure_minimal _ hclosed + intro y hy + exact mem_coefficient_span_of_summable f hp ha hg (y.comp I) (hs y hy) + have hunit (x : X) (hx : ‖x‖ ≤ 1) : evaluation (ClosedSpan 𝕜 f) x ∈ Z := by + exact hdense (hA ⟨x, by simpa only [Metric.mem_closedBall, dist_zero_right] using hx, rfl⟩) + intro x + by_cases hx : x = 0 + · simpa only [hx, map_zero] using Z.zero_mem + have hn : 0 < ‖x‖ := norm_pos_iff.mpr hx + have hu : ‖(‖x‖ : 𝕜)⁻¹ • x‖ ≤ 1 := by + simp only [norm_smul, norm_inv, RCLike.norm_ofReal, abs_norm, inv_mul_cancel₀ hn.ne'] + exact le_rfl + have hy := Z.smul_mem (‖x‖ : 𝕜) (hunit ((‖x‖ : 𝕜)⁻¹ • x) hu) + simpa only [map_smul, smul_smul, mul_inv_cancel₀ (by exact_mod_cast hn.ne' : (‖x‖ : 𝕜) ≠ 0), one_smul] using hy + +end SeparableQuotient.Positive.Fields.Scalar + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarQuotients.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarQuotients.lean new file mode 100644 index 0000000000000000000000000000000000000000..19e9a90a80131e74c6f0aed7058b5d20ec9bd2c0 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/ScalarQuotients.lean @@ -0,0 +1,198 @@ +import OAI.Analysis.SeparableQuotients.Positive.ScalarEvaluation +import OAI.Analysis.SeparableQuotients.Positive.ScalarAdjoint +import OAI.Analysis.SeparableQuotients.Positive.DualSequences + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.Scalar +universe u +attribute [local instance] dualSubmoduleNormedGroup dualSubmoduleNormedSpace +open Set TopologicalSpace +open scoped Classical +variable {𝕜 : Type} [RCLike 𝕜] +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X] + + +theorem quotient_of_separable_evaluation + (F : Submodule 𝕜 (StrongDual 𝕜 X)) (hF : IsClosed (F : Set (StrongDual 𝕜 X))) + (hinf : ¬ FiniteDimensional 𝕜 F) + (hsep : IsSeparable (Set.range (evaluation F))) : HasSeparableQuotient 𝕜 X := by + classical + let : SeparableSpace (Set.range (evaluation F)) := hsep.separableSpace + let : Nonempty (Set.range (evaluation F)) := ⟨⟨evaluation F 0, Set.mem_range_self 0⟩⟩ + obtain ⟨y, hy⟩ := exists_dense_seq (α := Set.range (evaluation F)) + choose x hx using fun n => (y n).property + have hdense : Set.range (evaluation F) ⊆ closure (Set.range (fun n => evaluation F (x n))) := by + have hh := (Subtype.dense_iff.mp hy) + have he : Subtype.val '' Set.range y = Set.range (fun n => evaluation F (x n)) := by + ext z + simp only [Set.mem_image, Set.mem_range] + constructor + · rintro ⟨w, ⟨n, rfl⟩, rfl⟩; exact ⟨n, hx n⟩ + · rintro ⟨n, rfl⟩; exact ⟨y n, ⟨n, rfl⟩, (hx n).symm⟩ + rw [he] at hh + exact hh + obtain ⟨g, D, hg, hD, hn, hann, htest⟩ := exists_normed_prefix_sequence F hinf x + let f : ℕ → StrongDual 𝕜 X := fun n => g n + have hf (n : ℕ) : (1:ℝ) ≤ ‖f n‖ := (hg n).ge + have hn' m (v : StrongDual 𝕜 X) + (hv : v ∈ Submodule.span 𝕜 (f '' (Finset.range m : Set ℕ))) : + ∃ d ∈ D m, ‖v‖ ≤ 2 * ‖v d‖ := by + exact hn m v hv + have hp := prefixBound_of_half_normers 𝕜 f D hD hn' hann + have hs : ∀ z ∈ Set.range (fun n => evaluation F (x n)), + Summable (fun n => ‖z (g n)‖) := by + rintro z ⟨j, rfl⟩ + apply summable_of_ne_finset_zero (s := Finset.range j) + intro n hn + have hnj : j ≤ n := by simpa only [Finset.mem_range, not_lt] using hn + change ‖(g n : StrongDual 𝕜 X) (x j)‖ = 0 + rw [htest n j hnj, norm_zero] + have hrange := eval_range_of_dense_summable F hF g hp (by norm_num : (0:ℝ) < 1) hf + (Set.range (fun n => evaluation F (x n))) + (fun z hz => hdense (by obtain ⟨w, _, rfl⟩ := hz; exact Set.mem_range_self w)) hs + obtain ⟨hsurj, hZsep, hZinf⟩ := + prefix_evaluation_surjective f (by norm_num : (0:ℝ) < 1) hf D hD hn' hann hrange + refine ⟨ClosedSpan 𝕜 (prefixCoord 𝕜 f), inferInstance, inferInstance, inferInstance, hZsep, hZinf, ?_⟩ + exact ⟨(evaluation (ClosedSpan 𝕜 f)).codRestrict (ClosedSpan 𝕜 (prefixCoord 𝕜 f)) hrange, hsurj⟩ +end SeparableQuotient.Positive.Fields.Scalar + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields +variable {𝕜 : Type*} [RCLike 𝕜] {V : Type*} + [NormedAddCommGroup V] [NormedSpace 𝕜 V] + + + +theorem exists_separable_closed_infinite_subspace (hV : ¬ FiniteDimensional 𝕜 V) : + ∃ F : Submodule 𝕜 V, IsClosed (F : Set V) ∧ SeparableSpace F ∧ + ¬ FiniteDimensional 𝕜 F := by + classical + let B := Module.Free.chooseBasis 𝕜 V + let : Infinite (Module.Free.ChooseBasisIndex 𝕜 V) := ⟨by + intro h + let := h + exact hV B.finiteDimensional_of_finite⟩ + let e := Infinite.natEmbedding (Module.Free.ChooseBasisIndex 𝕜 V) + let f : ℕ → V := B ∘ e + have hf : LinearIndependent 𝕜 f := B.linearIndependent.comp e e.injective + let F : Submodule 𝕜 V := (Submodule.span 𝕜 (Set.range f)).topologicalClosure + refine ⟨F, Submodule.isClosed_topologicalClosure _, ?_, ?_⟩ + · exact ((Set.countable_range f).isSeparable.span (R := 𝕜)).closure.separableSpace + · intro hfd + let := hfd + let g (n : ℕ) : F := ⟨f n, Submodule.le_topologicalClosure _ + (Submodule.subset_span (Set.mem_range_self n))⟩ + have hg : LinearIndependent 𝕜 g := hf.of_comp F.subtype + have hh := hg.lt_aleph0_of_finiteDimensional + simp at hh + + + +theorem infiniteDimensional_strongDual (hV : ¬ FiniteDimensional 𝕜 V) : + ¬ FiniteDimensional 𝕜 (StrongDual 𝕜 V) := by + intro h + let := h + let J : V →ₗ[𝕜] StrongDual 𝕜 (StrongDual 𝕜 V) := + (NormedSpace.inclusionInDoubleDualLi 𝕜 (E := V)).toLinearMap + have hJ : Function.Injective J := by + intro x y hxy + exact (NormedSpace.inclusionInDoubleDualLi 𝕜 (E := V)).injective hxy + apply hV + exact FiniteDimensional.of_injective (V₂ := StrongDual 𝕜 (StrongDual 𝕜 V)) J hJ +end SeparableQuotient.Positive.Fields + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.Scalar +attribute [local instance] dualSubmoduleNormedGroup dualSubmoduleNormedSpace +open Set TopologicalSpace +variable {𝕜 : Type} [RCLike 𝕜] +variable {X Y : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X] +variable [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] [CompleteSpace Y] + +lemma dual_lower_of_surjective (T : X →L[𝕜] Y) (hsurj : Function.Surjective T) : + ∃ C : NNReal, ∀ g : StrongDual 𝕜 Y, ‖g‖ ≤ C * ‖g.comp T‖ := by + obtain ⟨C, hC, hpre⟩ := T.exists_preimage_norm_le hsurj + refine ⟨⟨C, hC.le⟩, fun g => g.opNorm_le_bound (by positivity) ?_⟩ + intro y + obtain ⟨x, hx, hnorm⟩ := hpre y + calc + ‖g y‖ = ‖(g.comp T) x‖ := by rw [ContinuousLinearMap.comp_apply, hx] + _ ≤ ‖g.comp T‖ * ‖x‖ := (g.comp T).le_opNorm x + _ ≤ ‖g.comp T‖ * (C * ‖y‖) := mul_le_mul_of_nonneg_left hnorm (norm_nonneg _) + _ = (C * ‖g.comp T‖) * ‖y‖ := by ring + + + +theorem separable_evaluation_of_quotient [SeparableSpace Y] + (T : X →L[𝕜] Y) (hsurj : Function.Surjective T) + (hY : ¬ FiniteDimensional 𝕜 Y) : + ∃ F : Submodule 𝕜 (StrongDual 𝕜 X), + IsClosed (F : Set (StrongDual 𝕜 X)) ∧ SeparableSpace F ∧ + ¬ FiniteDimensional 𝕜 F ∧ IsSeparable (Set.range (evaluation F)) := by + obtain ⟨U, hUclosed, hUsep, hUinf⟩ := exists_separable_closed_infinite_subspace + (infiniteDimensional_strongDual hY) + let := hUsep + let : IsClosed (U : Set (StrongDual 𝕜 Y)) := hUclosed + let A : StrongDual 𝕜 Y →L[𝕜] StrongDual 𝕜 X := T.precomp 𝕜 + let B : U →L[𝕜] StrongDual 𝕜 X := A.comp U.subtypeL + obtain ⟨C, hC⟩ := dual_lower_of_surjective T hsurj + have hB : AntilipschitzWith C B := B.antilipschitz_of_bound (fun u => hC u) + have hBclosed : IsClosed (Set.range B) := (hB.isClosedEmbedding B.uniformContinuous).isClosed_range + let F : Submodule 𝕜 (StrongDual 𝕜 X) := B.toLinearMap.range + let e : U ≃L[𝕜] F := ContinuousLinearMap.equivRange hB.injective hBclosed + have hFsep : SeparableSpace F := e.surjective.denseRange.separableSpace e.continuous + have hFinf : ¬ FiniteDimensional 𝕜 F := by + intro hh + let := hh + exact hUinf e.symm.toLinearEquiv.finiteDimensional + let J : F →L[𝕜] U := e.symm.toContinuousLinearMap + let S : Y →L[𝕜] StrongDual 𝕜 F := (J.precomp 𝕜).comp (evaluation U) + have hST (x : X) : S (T x) = evaluation F x := by + ext f + have he : B (e.symm f) = (f : StrongDual 𝕜 X) := + congrArg Subtype.val (e.apply_symm_apply f) + exact congrArg (fun g : StrongDual 𝕜 X => g x) he + refine ⟨F, hBclosed, hFsep, hFinf, ?_⟩ + apply (isSeparable_range S.continuous).mono + rintro z ⟨x, rfl⟩ + exact ⟨T x, hST x⟩ + + +theorem evaluation_criterion : HasSeparableQuotient 𝕜 X ↔ + ∃ F : Submodule 𝕜 (StrongDual 𝕜 X), + IsClosed (F : Set (StrongDual 𝕜 X)) ∧ + ¬ FiniteDimensional 𝕜 F ∧ IsSeparable (Set.range (evaluation F)) := by + constructor + · rintro ⟨Y, ng, ns, hcomplete, hsep, hinf, T, hT⟩ + let := ng + let := ns + let := hcomplete + let := hsep + obtain ⟨F, hFcl, _, hFinf, hFeval⟩ := separable_evaluation_of_quotient T hT hinf + exact ⟨F, hFcl, hFinf, hFeval⟩ + · rintro ⟨F, hFcl, hFinf, hFeval⟩ + exact quotient_of_separable_evaluation F hFcl hFinf hFeval +end SeparableQuotient.Positive.Fields.Scalar + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/SeparatedFamilies.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/SeparatedFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..7db22e25dca0e9de808b1eae6c59cd195a716b96 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/SeparatedFamilies.lean @@ -0,0 +1,209 @@ +import OAI.Analysis.SeparableQuotients.Positive.ContinuumMeasure + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Family +abbrev ContinuumIndex := Rows.ContinuumIndex +abbrev continuumMeasurableSpace : MeasurableSpace ContinuumIndex := Rows.continuumMeasurableSpace +abbrev ContinuumAdditive := Rows.ContinuumAdditive +alias small_null_union := Rows.small_null_union +alias small_set_null := Rows.small_set_null +alias continuum_regular := Rows.continuum_regular +end SeparableQuotient.Positive.Family + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Family + +lemma exists_separated_cover {Y : Type u} [MetricSpace Y] (r : ℝ) (hr : 0 ≤ r) : + ∃ S : Set Y, S.Pairwise (fun x y => r < dist x y) ∧ + ∀ y : Y, ∃ x ∈ S, dist y x ≤ r := by + classical + obtain ⟨S, hS⟩ := zorn_subset {S : Set Y | S.Pairwise (fun x y => r < dist x y)} (by + intro c hc hchain + refine ⟨⋃₀ c, hchain.pairwise_sUnion.mpr (fun s hs => hc hs), ?_⟩ + exact fun s hs => subset_sUnion_of_mem hs) + refine ⟨S, hS.prop, fun y => ?_⟩ + by_contra! hy + have hyS : y ∉ S := by + intro h + have := hy y h + simpa using (lt_of_le_of_lt hr this : 0 < dist y y) + have hins : (insert y S).Pairwise (fun x z => r < dist x z) := by + intro x hx z hz hxz + rcases hx with rfl | hx <;> rcases hz with rfl | hz + · exact (hxz rfl).elim + · exact hy z hz + · simpa only [dist_comm] using hy x hx + · exact hS.prop hx hz hxz + have : insert y S ⊆ S := hS.2 hins (subset_insert y S) + exact hyS (this (mem_insert y S)) + + + +theorem exists_large_separated_of_density {Y : Type u} [MetricSpace Y] + {κ : Cardinal.{u}} (hκ : κ.IsRegular) (hunc : Cardinal.aleph0 < κ) + (hdensity : ∀ S : Set Y, Dense S → κ ≤ Cardinal.mk S) : + ∃ r : ℝ, 0 < r ∧ ∃ S : Set Y, + S.Pairwise (fun x y => r < dist x y) ∧ κ ≤ Cardinal.mk S := by + classical + by_contra! h + choose S hsep hcover using fun n : ULift.{u} ℕ => + exists_separated_cover (Y := Y) (1 / (n.down + 1 : ℝ)) (by positivity) + have hsmall (n : ULift.{u} ℕ) : Cardinal.mk (S n) < κ := + h _ (by positivity) _ (hsep n) + have hdense : Dense (⋃ n, S n) := by + intro y + apply Metric.mem_closure_iff.mpr + intro ε hε + obtain ⟨n, hn⟩ := exists_nat_one_div_lt hε + obtain ⟨x, hx, hdist⟩ := hcover (ULift.up n) y + exact ⟨x, mem_iUnion.mpr ⟨ULift.up n, hx⟩, lt_of_le_of_lt hdist hn⟩ + have hc : Cardinal.mk (⋃ n, S n) < κ := + (Cardinal.card_iUnion_lt_iff_forall_of_isRegular hκ (by simpa using hunc)).mpr hsmall + exact (not_lt_of_ge (hdensity _ hdense)) hc + +end SeparableQuotient.Positive.Family + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Family + +local instance realSpaceRatSpace {E : Type u} [NormedAddCommGroup E] + [NormedSpace ℝ E] : NormedSpace ℚ E := NormedSpace.restrictScalars ℚ ℝ E + +local instance realSpaceRatTower {E : Type u} [NormedAddCommGroup E] + [NormedSpace ℝ E] : IsScalarTower ℚ ℝ E where + smul_assoc q r x := by + change ((q : ℝ) * r) • x = (q : ℝ) • (r • x) + exact mul_smul (q : ℝ) r x + + + +lemma closure_rat_span_eq_real {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] + (S : Set E) : + closure (Submodule.span ℚ S : Set E) = closure (Submodule.span ℝ S : Set E) := by + let Q := (Submodule.span ℚ S).topologicalClosure + let C : Submodule ℝ E := + { carrier := Q + zero_mem' := Q.zero_mem + add_mem' := Q.add_mem + smul_mem' := by + intro r x hx + apply (Rat.denseRange_cast : DenseRange ((↑) : ℚ → ℝ)).induction_on (p := fun a : ℝ => a • x ∈ Q) r + · exact (Submodule.span ℚ S).isClosed_topologicalClosure.preimage (continuous_id.smul continuous_const) + · intro q + simpa only [Rat.cast_smul_eq_qsmul] using Q.smul_mem q hx } + have hreal : Submodule.span ℝ S ≤ C := Submodule.span_le.mpr + (fun x hx => (Submodule.span ℚ S).le_topologicalClosure (Submodule.subset_span hx)) + have hrat : Submodule.span ℚ S ≤ (Submodule.span ℝ S).restrictScalars ℚ := + Submodule.span_le.mpr (fun x hx => Submodule.subset_span hx) + apply subset_antisymm (closure_mono hrat) + exact (Submodule.span ℝ S).topologicalClosure_minimal hreal isClosed_closure + +lemma card_rat_span_le {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] + (S : Set E) : + Cardinal.mk (Submodule.span ℚ S) ≤ max (Cardinal.mk S) Cardinal.aleph0 := by + classical + rcases S.eq_empty_or_nonempty with rfl | hS + · simp + · let : Nonempty S := hS.to_subtype + rw [Finsupp.span_eq_range_linearCombination] + change Cardinal.mk (Set.range (Finsupp.linearCombination ℚ (fun x : S => (x : E)))) ≤ _ + exact Cardinal.mk_range_le.trans_eq (by simp) + +end SeparableQuotient.Positive.Family + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Family + +lemma large_separated_away_small_closure {E : Type u} [MetricSpace E] + {κ : Cardinal.{u}} {S A : Set E} {δ : ℝ} (hδ : 0 < δ) + (hsep : S.Pairwise (fun x y => δ < dist x y)) + (hS : κ ≤ Cardinal.mk S) (hA : Cardinal.mk A < κ) (hne : A.Nonempty) : + ∃ y ∈ S, δ / 4 < Metric.infDist y (closure A) := by + classical + by_contra! h + have hc (y : S) : ∃ a : A, dist y.val a.val < δ / 2 := by + have hy := h y.val y.property + rw [Metric.infDist_closure] at hy + obtain ⟨a, ha, hya⟩ := (Metric.infDist_lt_iff hne).mp (show Metric.infDist y.val A < δ / 2 by linarith) + exact ⟨⟨a, ha⟩, hya⟩ + choose a ha using hc + have hinj : Function.Injective a := by + intro y z hyz + apply Subtype.ext + by_contra hne' + have hl := hsep y.property z.property hne' + have hy := ha y + have hz := ha z + rw [← hyz] at hz + have ht := dist_triangle y.val (a y).val z.val + rw [dist_comm (a y).val z.val] at ht + linarith + exact (not_le_of_gt hA) (hS.trans (Cardinal.mk_le_of_injective hinj)) + + + +lemma exists_unit_dual_annihilating {E : Type u} [NormedAddCommGroup E] + [NormedSpace ℝ E] (M : Submodule ℝ E) (x : E) {r : ℝ} + (hr : 0 < r) (hdist : r < Metric.infDist x (M : Set E)) : + ∃ h : StrongDual ℝ E, ‖h‖ = 1 ∧ + (∀ m ∈ M, h m = 0) ∧ r < |h x| := by + have hqx : r < ‖M.mkQL x‖ := by + change r < ‖(QuotientAddGroup.mk x : E ⧸ M.toAddSubgroup)‖ + rwa [QuotientAddGroup.norm_mk] + obtain ⟨g, hg, hgx⟩ := exists_dual_vector ℝ (M.mkQL x) (ne_of_gt (hr.trans hqx)) + let h₀ := g.comp M.mkQL + have hq : ‖M.mkQL‖ ≤ 1 := by + apply M.mkQL.opNorm_le_bound (by norm_num) + intro y + simpa using Submodule.Quotient.norm_mk_le M y + have hh₀ : ‖h₀‖ ≤ 1 := by + exact (g.opNorm_comp_le M.mkQL).trans (by simpa only [hg, one_mul] using hq) + have hv : h₀ x = ‖M.mkQL x‖ := hgx + have hx : r < |h₀ x| := by simpa only [hv, abs_of_nonneg (norm_nonneg _)] using hqx + have hn : 0 < ‖h₀‖ := norm_pos_iff.mpr (by + intro heq + have : h₀ x = 0 := by rw [heq]; rfl + rw [this, abs_zero] at hx + linarith) + refine ⟨‖h₀‖⁻¹ • h₀, ?_, ?_, ?_⟩ + · simp only [norm_smul, norm_inv, norm_norm, inv_mul_cancel₀ hn.ne'] + · intro m hm + have hqm : M.mkQL m = 0 := (Submodule.Quotient.mk_eq_zero M).mpr hm + simp [h₀, hqm] + · have hinv : 1 ≤ ‖h₀‖⁻¹ := (one_le_inv₀ hn).mpr hh₀ + simp only [smul_apply, smul_eq_mul, abs_mul, + abs_inv, abs_of_pos hn] + exact hx.trans_le (le_mul_of_one_le_left (abs_nonneg _) hinv) + +end SeparableQuotient.Positive.Family + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/SeparatedWitness.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/SeparatedWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cd8ddd4199a06a27fd6fa526dc6e32e3bdbd129 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/SeparatedWitness.lean @@ -0,0 +1,89 @@ +import OAI.Analysis.SeparableQuotients.Positive.ComplexSequences +import OAI.Analysis.SeparableQuotients.Positive.RealWitness + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Fields.ComplexTransfer +open Set TopologicalSpace Scalar +attribute [local instance] Scalar.dualSubmoduleNormedGroup Scalar.dualSubmoduleNormedSpace +attribute [local instance] realDualSubmoduleNormedGroup realDualSubmoduleNormedSpace +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℂ X] + [NormedSpace ℝ X] [IsScalarTower ℝ ℂ X] + +local instance complexDualSubmoduleRealNormedSpace (H : Submodule ℂ (StrongDual ℂ X)) : + NormedSpace ℝ H := Submodule.normedSpace (H.restrictScalars ℝ) + +local instance complexRealOperatorNormedGroup (H : Submodule ℂ (StrongDual ℂ X)) : + NormedAddCommGroup (H →L[ℝ] ℂ) := + ContinuousLinearMap.toNormedAddCommGroup (𝕜 := ℝ) (𝕜₂ := ℝ) (σ₁₂ := RingHom.id ℝ) +local instance complexRealOperatorMetric (H : Submodule ℂ (StrongDual ℂ X)) : + PseudoMetrizableSpace (H →L[ℝ] ℂ) := + @PseudoEMetricSpace.pseudoMetrizableSpace (H →L[ℝ] ℂ) + (inferInstance : PseudoEMetricSpace (H →L[ℝ] ℂ)) +local instance complexRealOperatorNormedSpace (H : Submodule ℂ (StrongDual ℂ X)) : + NormedSpace ℂ (H →L[ℝ] ℂ) := + ContinuousLinearMap.toNormedSpace (𝕜 := ℝ) (𝕜₂ := ℝ) (σ₁₂ := RingHom.id ℝ) +local instance complexRealOperatorAdd (H : Submodule ℂ (StrongDual ℂ X)) : + ContinuousAdd (H →L[ℝ] ℂ) := ContinuousLinearMap.isTopologicalAddGroup.toContinuousAdd +local instance complexRealOperatorSMul (H : Submodule ℂ (StrongDual ℂ X)) : + ContinuousSMul ℂ (H →L[ℝ] ℂ) := + @IsBoundedSMul.continuousSMul ℂ (H →L[ℝ] ℂ) _ + (inferInstance : PseudoMetricSpace (H →L[ℝ] ℂ)) _ _ _ + (@NormedSpace.toIsBoundedSMul ℂ (H →L[ℝ] ℂ) _ + (inferInstance : SeminormedAddCommGroup (H →L[ℝ] ℂ)) + (inferInstance : NormedSpace ℂ (H →L[ℝ] ℂ))) +local instance complexRealOperatorT2 (H : Submodule ℂ (StrongDual ℂ X)) : + T2Space (H →L[ℝ] ℂ) := + letI : ContinuousSMul ℝ H := IsBoundedSMul.continuousSMul + ContinuousLinearMap.instT2Space (𝕜₁ := ℝ) (𝕜₂ := ℝ) (σ := RingHom.id ℝ) + +lemma complex_eval_separable_of_real (H : Submodule ℂ (StrongDual ℂ X)) + (hs : IsSeparable (Set.range (realEvaluation (H.restrictScalars ℝ)))) : + IsSeparable (Set.range (Scalar.evaluation H)) := by + apply ((ContinuousLinearMap.isEmbedding_restrictScalars (𝕜 := ℂ) + (E := H) (F := ℂ) ℝ).isInducing.isSeparable_preimage hs).mono + rintro _ ⟨x, rfl⟩ + exact ⟨x, rfl⟩ + +lemma separable_evaluation_of_coordinates + (E : Submodule ℝ (StrongDual ℂ X)) + (hEsep : IsSeparable (Set.range (realEvaluation E))) + (H : Submodule ℂ (StrongDual ℂ X)) (P Q : H →L[ℝ] E) + (hPQ : ∀ h : H, (h : StrongDual ℂ X) = (P h : StrongDual ℂ X) + + Complex.I • (Q h : StrongDual ℂ X)) : + IsSeparable (Set.range (Scalar.evaluation H)) := by + apply complex_eval_separable_of_real + let φ : (E →L[ℝ] ℂ) → (H →L[ℝ] ℂ) := fun e => e.comp P + Complex.I • e.comp Q + have hφ : Continuous φ := by fun_prop + apply (hEsep.image hφ).mono + rintro _ ⟨x, rfl⟩ + refine ⟨realEvaluation E x, Set.mem_range_self _, ?_⟩ + ext h + change (P h : StrongDual ℂ X) x + Complex.I * (Q h : StrongDual ℂ X) x = + (h : StrongDual ℂ X) x + exact congrArg (fun f : StrongDual ℂ X => f x) (hPQ h).symm + +theorem complex_witness_of_separated + (E : Submodule ℝ (StrongDual ℂ X)) + (hEsep : IsSeparable (Set.range (realEvaluation E))) + (hsep : HasSeparatedInfiniteSubspace E) : + ∃ H : Submodule ℂ (StrongDual ℂ X), IsClosed (H : Set (StrongDual ℂ X)) ∧ + ¬ FiniteDimensional ℂ H ∧ IsSeparable (Set.range (Scalar.evaluation H)) := by + obtain ⟨W, hWE, hWcl, hWinf, C, hC, hsep⟩ := hsep + obtain ⟨H, hHcl, hHinf, P, Q, hPQ⟩ := + complex_subspace_of_separated E W hWE hWcl hWinf hC hsep + exact ⟨H, hHcl, hHinf, separable_evaluation_of_coordinates E hEsep H P Q hPQ⟩ + +end SeparableQuotient.Positive.Fields.ComplexTransfer + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/TransfiniteFamily.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/TransfiniteFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..02e66dfc3b9f8792e4de45950c3b7725532fd95c --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/TransfiniteFamily.lean @@ -0,0 +1,161 @@ +import OAI.Analysis.SeparableQuotients.Positive.SeparatedFamilies + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Family +open Set MeasureTheory TopologicalSpace Function +open scoped Cardinal +universe v +attribute [local instance] realSpaceRatSpace realSpaceRatTower + + + + +theorem continuum_large_density_family {Y : Type v} [NormedAddCommGroup Y] + [NormedSpace ℝ Y] (D : Set Y) (hne : D.Nonempty) + (hcard : Cardinal.mk D ≤ Cardinal.continuum.{v}) + (hdense : ∀ A : Set D, Dense A → Cardinal.continuum.{v} ≤ Cardinal.mk A) + (μ : Measure ContinuumIndex) [IsProbabilityMeasure μ] + (hadd : ContinuumAdditive μ) (hsingle : ∀ i, μ {i} = 0) : + ∃ ε : ℝ, 0 < ε ∧ ∃ h : ContinuumIndex → StrongDual ℝ Y, + (∀ α, ‖h α‖ = 1) ∧ + (∀ α, ∃ y ∈ D, ε < |h α y|) ∧ + ∀ y ∈ D, μ {α | h α y ≠ 0} = 0 := by + classical + let : Nonempty D := hne.to_subtype + have hreg : Cardinal.IsRegular Cardinal.continuum.{v} := by + simpa using (continuum_regular μ hadd hsingle).lift.{v} + obtain ⟨δ, hδ, S₀, hsep₀, hS₀⟩ := exists_large_separated_of_density hreg + Cardinal.aleph0_lt_continuum hdense + let S : Set Y := Subtype.val '' S₀ + have hsep : S.Pairwise (fun x y => δ < dist x y) := by + rintro x ⟨x', hx, rfl⟩ y ⟨y', hy, rfl⟩ hxy + exact hsep₀ hx hy (by intro h; exact hxy (congrArg Subtype.val h)) + have hS : Cardinal.continuum.{v} ≤ Cardinal.mk S := by + have heq : Cardinal.mk S = Cardinal.mk S₀ := + Cardinal.mk_congr (Equiv.Set.image _ _ Subtype.val_injective).symm + rw [heq] + exact hS₀ + obtain ⟨e⟩ : Nonempty (D ↪ ContinuumIndex) := Cardinal.lift_mk_le'.mp (by + simpa [ContinuumIndex] using hcard) + let z : ContinuumIndex → D := Function.invFun e + have hz : Function.Surjective z := (Function.leftInverse_invFun e.injective).surjective + let y : ContinuumIndex → Y := fun α => z α + let P : ContinuumIndex → Set Y := fun α => y '' Set.Iio α + let M : ContinuumIndex → Submodule ℝ Y := fun α => (Submodule.span ℝ (P α)).topologicalClosure + have hP (α : ContinuumIndex) : Cardinal.mk (P α) < Cardinal.continuum.{v} := by + have hc : Cardinal.mk (Set.Iio α) < Cardinal.continuum.{0} := by + simpa [ContinuumIndex] using Cardinal.mk_Iio_lt α (by simp [ContinuumIndex]) + have him : Cardinal.mk (P α) ≤ Cardinal.lift.{v} (Cardinal.mk (Set.Iio α)) := by + simpa [P] using (Cardinal.mk_image_le_lift (f := y) (s := Set.Iio α)) + exact him.trans_lt (Cardinal.lift_lt_continuum.mpr hc) + have hc (α : ContinuumIndex) : + ∃ h : StrongDual ℝ Y, ‖h‖ = 1 ∧ (∀ m ∈ M α, h m = 0) ∧ + ∃ y ∈ D, δ / 4 < |h y| := by + let A : Set Y := Submodule.span ℚ (P α) + have hA : Cardinal.mk A < Cardinal.continuum.{v} := + (card_rat_span_le (P α)).trans_lt (max_lt (hP α) Cardinal.aleph0_lt_continuum) + have hAne : A.Nonempty := ⟨0, Submodule.zero_mem _⟩ + obtain ⟨x, hx, hdist⟩ := large_separated_away_small_closure hδ hsep hS hA hAne + have hdist' : δ / 4 < Metric.infDist x (M α : Set Y) := by + simpa only [A, closure_rat_span_eq_real, M, Submodule.topologicalClosure_coe] using hdist + obtain ⟨h, hh, hann, hval⟩ := exists_unit_dual_annihilating (M α) x (by positivity) hdist' + refine ⟨h, hh, hann, x, ?_, hval⟩ + rcases hx with ⟨x', _, rfl⟩ + exact x'.property + choose h hnorm hann hval using hc + refine ⟨δ / 4, by positivity, h, hnorm, hval, ?_⟩ + intro w hw + obtain ⟨β, hβ⟩ := hz ⟨w, hw⟩ + have hsubset : {α | h α w ≠ 0} ⊆ Set.Iic β := by + intro α hα + by_contra hn + have hβα : β < α := lt_of_not_ge hn + apply hα + apply hann α + apply (Submodule.span ℝ (P α)).le_topologicalClosure + apply Submodule.subset_span + exact ⟨β, hβα, congrArg Subtype.val hβ⟩ + apply measure_mono_null hsubset + rw [← Set.Iio_union_right] + exact measure_union_null + (small_set_null μ hadd hsingle _ (by simpa [ContinuumIndex] using Cardinal.mk_Iio_lt β (by simp [ContinuumIndex]))) + (hsingle β) +end SeparableQuotient.Positive.Family + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal +universe u + +namespace SeparableQuotient.Positive.Family +open Set TopologicalSpace MeasureTheory +open scoped Cardinal + +lemma real_dual_cardinal_le {E : Type u} [NormedAddCommGroup E] + [NormedSpace ℝ E] [SeparableSpace E] : + Cardinal.mk (StrongDual ℝ E) ≤ Cardinal.continuum.{u} := by + obtain ⟨d, hd⟩ := exists_dense_seq E + let j : StrongDual ℝ E → ULift.{u} (ℕ → ℝ) := fun f => ULift.up (fun n => f (d n)) + have hj : Function.Injective j := by + intro f g hfg + have he : ∀ n, f (d n) = g (d n) := fun n => congrFun (congrArg ULift.down hfg) n + exact DFunLike.ext' (hd.equalizer f.continuous g.continuous (funext he)) + exact (Cardinal.mk_le_of_injective hj).trans_eq (by simp [Cardinal.mk_real]) + +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace ℝ X] +local instance dualSubmoduleNormedGroup (E : Submodule ℝ (StrongDual ℝ X)) : + NormedAddCommGroup E := Submodule.normedAddCommGroup E +local instance dualSubmoduleNormedSpace (E : Submodule ℝ (StrongDual ℝ X)) : + NormedSpace ℝ E := Submodule.normedSpace E + +def evaluation (E : Submodule ℝ (StrongDual ℝ X)) : X →L[ℝ] StrongDual ℝ E := + E.subtypeL.flip + +lemma norm_evaluation_le (E : Submodule ℝ (StrongDual ℝ X)) : ‖evaluation E‖ ≤ 1 := by + rw [evaluation, ContinuousLinearMap.opNorm_flip] + exact Submodule.norm_subtypeL_le E + + + +theorem evaluation_family_of_density (E : Submodule ℝ (StrongDual ℝ X)) + [SeparableSpace E] + (μ : Measure ContinuumIndex) [IsProbabilityMeasure μ] + (hadd : ContinuumAdditive μ) (hsingle : ∀ i, μ {i} = 0) + (hdense : ∀ A : Set (evaluation E '' {x : X | ‖x‖ ≤ 1}), Dense A → + Cardinal.continuum.{u} ≤ Cardinal.mk A) : + ∃ ε : ℝ, 0 < ε ∧ ∃ h : ContinuumIndex → StrongDual ℝ (StrongDual ℝ E), + (∀ α, ‖h α‖ = 1) ∧ + (∀ α, ε < ‖(h α).comp (evaluation E)‖ ∧ ‖(h α).comp (evaluation E)‖ ≤ 1) ∧ + ∀ x : X, ‖x‖ ≤ 1 → μ {α | h α (evaluation E x) ≠ 0} = 0 := by + let D := evaluation E '' {x : X | ‖x‖ ≤ 1} + have hne : D.Nonempty := ⟨0, 0, by simp, by simp⟩ + have hc : Cardinal.mk D ≤ Cardinal.continuum.{u} := + (Cardinal.mk_set_le D).trans real_dual_cardinal_le + obtain ⟨ε, hε, h, hn, hv, hz⟩ := + continuum_large_density_family D hne hc hdense μ hadd hsingle + refine ⟨ε, hε, h, hn, fun α => ?_, fun x hx => hz _ ⟨x, hx, rfl⟩⟩ + constructor + · obtain ⟨y, ⟨x, hx, rfl⟩, hval⟩ := hv α + exact hval.trans_le (by + simpa only [Real.norm_eq_abs, mul_one, ContinuousLinearMap.comp_apply] using + ((h α).comp (evaluation E)).le_opNorm_of_le hx) + · exact ((h α).opNorm_comp_le (evaluation E)).trans (by + simpa only [hn α, one_mul] using norm_evaluation_le E) + +end SeparableQuotient.Positive.Family + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/TupleSampling.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/TupleSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..3da38b0c996a4175cea6dd37d978e92077aee879 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/TupleSampling.lean @@ -0,0 +1,253 @@ +import OAI.Analysis.SeparableQuotients.Positive.FiniteSuppression + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling + +structure FullTuple (I : Type*) (n : ℕ) where + val : Fin n → I + +instance {I : Type*} {n : ℕ} : CoeFun (FullTuple I n) (fun _ => Fin n → I) := + ⟨FullTuple.val⟩ + +instance {I : Type*} {n : ℕ} : MeasurableSpace (FullTuple I n) := ⊤ + +namespace FullTuple +variable {I : Type*} {n : ℕ} +def nil : FullTuple I 0 := ⟨Fin.elim0⟩ +def cons (a : I) (t : FullTuple I n) : FullTuple I (n + 1) := ⟨Fin.cons a t.val⟩ +def head (t : FullTuple I (n + 1)) : I := t 0 +def tail (t : FullTuple I (n + 1)) : FullTuple I n := ⟨fun i => t i.succ⟩ +@[simp] lemma cons_zero (a : I) (t : FullTuple I n) : cons a t 0 = a := rfl +@[simp] lemma cons_succ (a : I) (t : FullTuple I n) (i : Fin n) : + cons a t i.succ = t i := rfl +@[simp] lemma head_cons (a : I) (t : FullTuple I n) : head (cons a t) = a := rfl +@[simp] lemma tail_cons (a : I) (t : FullTuple I n) : tail (cons a t) = t := by + cases t + rfl +@[simp] lemma cons_head_tail (t : FullTuple I (n + 1)) : cons t.head t.tail = t := by + cases t with + | mk t => + change FullTuple.mk (Fin.cons (t 0) (fun i => t i.succ)) = FullTuple.mk t + apply congrArg FullTuple.mk + funext i + exact Fin.cases rfl (fun _ => rfl) i +lemma eq_nil (t : FullTuple I 0) : t = nil := by + cases t with + | mk t => congr; funext i; exact Fin.elim0 i +end FullTuple + +variable {I : Type*} [MeasurableSpace I] [DiscreteMeasurableSpace I] + +def orderedMeasure (μ : Measure I) : (n : ℕ) → Measure (FullTuple I n) + | 0 => Measure.dirac FullTuple.nil + | n + 1 => μ.bind (fun a => (orderedMeasure μ n).map (FullTuple.cons a)) + +instance orderedMeasure_probability (μ : Measure I) [IsProbabilityMeasure μ] (n : ℕ) : + IsProbabilityMeasure (orderedMeasure μ n) := by + induction n with + | zero => exact Measure.dirac.isProbabilityMeasure + | succ n ih => + have := ih + apply isProbabilityMeasure_bind (Measurable.of_discrete.aemeasurable) + apply Eventually.of_forall + intro a + infer_instance + +lemma ae_bind_iff_of_full {T : Type*} [MeasurableSpace T] [DiscreteMeasurableSpace T] + (μ : Measure I) (ν : I → Measure T) (P : T → Prop) : + (∀ᵐ t ∂μ.bind ν, P t) ↔ ∀ᵐ a ∂μ, ∀ᵐ t ∂ν a, P t := by + simp only [ae_iff] + rw [Measure.bind_apply (MeasurableSet.of_discrete) (Measurable.of_discrete.aemeasurable)] + exact lintegral_eq_zero_iff Measurable.of_discrete + +omit [DiscreteMeasurableSpace I] in +lemma ae_orderedMeasure_zero (μ : Measure I) (P : FullTuple I 0 → Prop) : + (∀ᵐ t ∂orderedMeasure μ 0, P t) ↔ P FullTuple.nil := by + exact ae_dirac_iff MeasurableSet.of_discrete + +lemma ae_orderedMeasure_succ (μ : Measure I) {n : ℕ} + (P : FullTuple I (n + 1) → Prop) : + (∀ᵐ t ∂orderedMeasure μ (n + 1), P t) ↔ + ∀ᵐ a ∂μ, ∀ᵐ t ∂orderedMeasure μ n, P (FullTuple.cons a t) := by + rw [orderedMeasure, ae_bind_iff_of_full] + apply eventually_congr + exact Eventually.of_forall (fun _ => ae_map_iff Measurable.of_discrete.aemeasurable + MeasurableSet.of_discrete) + + + +def orderedAE (μ : Measure I) : (n : ℕ) → (FullTuple I n → Prop) → Prop + | 0, P => P FullTuple.nil + | n + 1, P => ∀ᵐ a ∂μ, orderedAE μ n (fun t => P (FullTuple.cons a t)) + +lemma ae_orderedMeasure_iff (μ : Measure I) (n : ℕ) (P : FullTuple I n → Prop) : + (∀ᵐ t ∂orderedMeasure μ n, P t) ↔ orderedAE μ n P := by + induction n with + | zero => exact ae_orderedMeasure_zero μ P + | succ n ih => + rw [ae_orderedMeasure_succ] + apply eventually_congr + exact Eventually.of_forall (fun _ => ih _) + +lemma coded_cross_vanishing + {I T C K : Type*} [MeasurableSpace I] [MeasurableSpace T] + [MeasurableSpace C] [MeasurableSpace K] + {μ : Measure I} {ν : Measure T} [SFinite μ] [SFinite ν] + {code : I → C} {Y : T → K} {Φ : C × K → ℝ} {D : Set K} + (hc : Measurable code) (hY : Measurable Y) (hΦ : Measurable Φ) + (hYD : ∀ t, Y t ∈ D) + (hnull : ∀ y ∈ D, ∀ᵐ i ∂μ, Φ (code i, y) = 0) : + ∀ᵐ i ∂μ, ∀ᵐ t ∂ν, Φ (code i, Y t) = 0 := by + have hm : Measurable (fun z : I × T => Φ (code z.1, Y z.2)) := + hΦ.comp (hc.prodMap hY) + apply (Measure.ae_ae_comm (μ := μ) (ν := ν) (p := fun i t => Φ (code i, Y t) = 0) + (measurableSet_eq_fun hm measurable_const)).mpr + exact Filter.Eventually.of_forall (fun t => hnull (Y t) (hYD t)) + + + +lemma orderedMeasure_succ_apply (μ : Measure I) {n : ℕ} + (A : Set (FullTuple I (n + 1))) : + orderedMeasure μ (n + 1) A = + ∫⁻ a, orderedMeasure μ n (FullTuple.cons a ⁻¹' A) ∂μ := by + rw [orderedMeasure, Measure.bind_apply MeasurableSet.of_discrete + Measurable.of_discrete.aemeasurable] + apply lintegral_congr + intro a + exact Measure.map_apply Measurable.of_discrete MeasurableSet.of_discrete + + + +lemma ordered_cross_vanishing + {C K : Type*} [MeasurableSpace C] [MeasurableSpace K] + {μ : Measure I} [IsProbabilityMeasure μ] + {code : I → C} {Φ : C × K → ℝ} {D : Set K} + (hΦ : Measurable Φ) + (hnull : ∀ y ∈ D, ∀ᵐ a ∂μ, Φ (code a, y) = 0) + {n : ℕ} (i : Fin n) (Y : FullTuple I n → K) + (hYD : ∀ t, Y t ∈ D) + (hindep : ∀ u v, (∀ j, j ≠ i → u j = v j) → Y u = Y v) : + ∀ᵐ t ∂orderedMeasure μ n, Φ (code (t i), Y t) = 0 := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + revert hindep + refine Fin.cases ?_ (fun i => ?_) i + · intro hindep + obtain ⟨a₀⟩ := nonempty_of_isProbabilityMeasure μ + have hsame (a : I) (t : FullTuple I n) : + Y (FullTuple.cons a t) = Y (FullTuple.cons a₀ t) := by + apply hindep + intro j hj + exact Fin.cases (fun h => False.elim (h rfl)) + (fun _ _ => rfl) j hj + apply (ae_orderedMeasure_succ μ _).mpr + have hh := coded_cross_vanishing + (μ := μ) (ν := orderedMeasure μ n) (code := code) + (Y := fun t => Y (FullTuple.cons a₀ t)) + Measurable.of_discrete Measurable.of_discrete hΦ + (fun t => hYD _) hnull + simpa only [FullTuple.cons_zero, hsame] using hh + · intro hindep + apply (ae_orderedMeasure_succ μ _).mpr + apply Eventually.of_forall + intro a + apply ih i (fun t => Y (FullTuple.cons a t)) (fun t => hYD _) + intro u v huv + apply hindep + intro j hj + refine Fin.cases (fun _ => rfl) (fun k hk => ?_) j hj + exact huv k (fun hki => hk (congrArg Fin.succ hki)) + +lemma ae_orderedMeasure_coord (μ : Measure I) [IsProbabilityMeasure μ] + {n : ℕ} (i : Fin n) (P : I → Prop) : + (∀ᵐ t ∂orderedMeasure μ n, P (t i)) ↔ ∀ᵐ a ∂μ, P a := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + refine Fin.cases ?_ (fun i => ?_) i + · simp only [ae_orderedMeasure_succ, FullTuple.cons_zero, eventually_const] + · simp only [ae_orderedMeasure_succ, FullTuple.cons_succ, ih, eventually_const] + + +namespace FullTuple +variable {J : Type*} {n : ℕ} +def toList (t : FullTuple J n) : List J := List.ofFn t.val +@[simp] lemma toList_nil : (nil : FullTuple J 0).toList = [] := rfl +@[simp] lemma toList_cons (a : J) (t : FullTuple J n) : + (cons a t).toList = a :: t.toList := by + simp only [toList, cons, List.ofFn_succ, Fin.cons_zero, Fin.cons_succ] +end FullTuple + + +def GoodPrefix (μ : Measure I) (G : List I → Prop) (p : List I) : Prop := + ∀ n, ∀ᵐ t ∂orderedMeasure μ n, G (p ++ t.toList) + +lemma goodPrefix_extend (μ : Measure I) [IsProbabilityMeasure μ] + (G : List I → Prop) (p : List I) (hp : GoodPrefix μ G p) : + ∃ a, GoodPrefix μ G (p ++ [a]) := by + have hh : ∀ᵐ a ∂μ, ∀ n, ∀ᵐ t ∂orderedMeasure μ n, + G ((p ++ [a]) ++ t.toList) := by + apply ae_all_iff.mpr + intro n + have hn := (ae_orderedMeasure_succ μ _).mp (hp (n + 1)) + simpa only [FullTuple.toList_cons, List.append_assoc, List.singleton_append] using hn + exact hh.exists + + + +lemma exists_good_prefix_sequence (μ : Measure I) [IsProbabilityMeasure μ] + (G : List I → Prop) + (hG : ∀ n, ∀ᵐ t ∂orderedMeasure μ n, G t.toList) : + ∃ α : ℕ → I, ∀ n, G (List.ofFn (fun i : Fin n => α i.val)) := by + have hstart : GoodPrefix μ G [] := by + simpa only [GoodPrefix, List.nil_append] using hG + let S := { p : List I // GoodPrefix μ G p } + let next : S → I := fun p => Classical.choose (goodPrefix_extend μ G p.1 p.2) + let step : S → S := fun p => ⟨p.1 ++ [next p], + Classical.choose_spec (goodPrefix_extend μ G p.1 p.2)⟩ + let chain : ℕ → S := Nat.rec ⟨[], hstart⟩ (fun _ p => step p) + let α : ℕ → I := fun n => next (chain n) + have hval : ∀ n, (chain n).1 = List.ofFn (fun i : Fin n => α i.val) := by + intro n + induction n with + | zero => rfl + | succ n ih => + change (chain n).1 ++ [α n] = _ + rw [ih, List.ofFn_succ'] + simp only [Fin.val_castSucc, Fin.val_last, List.concat_eq_append] + refine ⟨α, fun n => ?_⟩ + have hh := (ae_orderedMeasure_zero μ _).mp ((chain n).2 0) + simpa only [FullTuple.toList_nil, List.append_nil, hval] using hh + + +lemma exists_good_tuple_sequence (μ : Measure I) [IsProbabilityMeasure μ] + (G : (n : ℕ) → FullTuple I n → Prop) + (hG : ∀ n, ∀ᵐ t ∂orderedMeasure μ n, G n t) : + ∃ α : ℕ → I, ∀ n, G n ⟨fun i : Fin n => α i.val⟩ := by + let goodList : List I → Prop := fun l => G l.length ⟨l.get⟩ + have he (n : ℕ) (t : FullTuple I n) : goodList t.toList ↔ G n t := by + cases t with + | mk t => + exact Eq.to_iff (congrArg (fun p : Σ n : ℕ, Fin n → I => G p.1 ⟨p.2⟩) + (List.equivSigmaTuple.apply_symm_apply ⟨n, t⟩)) + have hh : ∀ n, ∀ᵐ t ∂orderedMeasure μ n, goodList t.toList := by + intro n + exact (hG n).mono (fun t ht => (he n t).mpr ht) + obtain ⟨α, hα⟩ := exists_good_prefix_sequence μ goodList hh + exact ⟨α, fun n => (he n ⟨fun i : Fin n => α i.val⟩).mp (hα n)⟩ + +end SeparableQuotient.Positive.Sampling + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/Positive/UnconditionalBasis.lean b/lean/OAI/Analysis/SeparableQuotients/Positive/UnconditionalBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bec65f0e1901af9c8c7427440a8f66db39715ef --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/Positive/UnconditionalBasis.lean @@ -0,0 +1,200 @@ +import OAI.Analysis.SeparableQuotients.Positive.SampledSuppression +import OAI.Analysis.SeparableQuotients.Positive.MeasurableCodes + +namespace OAI + +noncomputable section + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling +variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + +abbrev ClosedSpan (v : ℕ → V) := Rows.ClosedSpan v +abbrev spanVector (v : ℕ → V) := Rows.spanVector v +abbrev spanCombination (v : ℕ → V) := Rows.spanCombination v +alias spanCombination_coe := Rows.spanCombination_coe +alias denseRange_spanCombination := Rows.denseRange_spanCombination + +def SuppressionBoundTwo (v : ℕ → V) : Prop := + ∀ (c : ℕ →₀ ℝ) (s : Finset ℕ), + ‖∑ i ∈ s, c i • v i‖ ≤ 2 * ‖c.sum (fun i a => a • v i)‖ + +lemma suppressionBoundTwo_of_finite (v : ℕ → V) + (h : ∀ n (c : Fin n → ℝ) (s : Finset (Fin n)), + ‖∑ j ∈ s, c j • v j.val‖ ≤ 2 * ‖∑ j, c j • v j.val‖) : + SuppressionBoundTwo v := by + intro c s + obtain ⟨n, hn⟩ := (c.support ∪ s).exists_nat_subset_range + have hs : s ⊆ Finset.range n := fun i hi => hn (Finset.mem_union_right _ hi) + have hc : c.support ⊆ Finset.range n := fun i hi => hn (Finset.mem_union_left _ hi) + let t : Finset (Fin n) := Finset.univ.filter (fun i => i.val ∈ s) + have hsum : (∑ j ∈ t, c j.val • v j.val) = ∑ i ∈ s, c i • v i := by + apply Finset.sum_bij (fun i _ => i.val) + · intro i hi + exact (Finset.mem_filter.mp hi).2 + · intro i _ j _ hij + exact Fin.ext hij + · intro i hi + exact ⟨⟨i, Finset.mem_range.mp (hs hi)⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hi⟩, rfl⟩ + · intros; rfl + have htotal : (∑ j : Fin n, c j.val • v j.val) = c.sum (fun i a => a • v i) := by + rw [show (∑ j : Fin n, c j.val • v j.val) = + ∑ j ∈ Finset.range n, c j • v j from Fin.sum_univ_eq_sum_range (fun j => c j • v j) n] + exact (Finsupp.sum_of_support_subset c hc (fun i a => a • v i) (by simp)).symm + simpa only [hsum, htotal] using h n (fun j => c j.val) t + +lemma coefficient_bound (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ ℝ) (i : ℕ) : + ‖c i‖ ≤ (2 / a) * ‖spanCombination v c‖ := by + have hh := h c {i} + simp only [Finset.sum_singleton, norm_smul] at hh + have hb : ‖c i‖ * a ≤ 2 * ‖spanCombination v c‖ := by + exact (mul_le_mul_of_nonneg_left (hv i) (norm_nonneg _)).trans + (by simpa only [← spanCombination_coe, Submodule.norm_coe] using hh) + rw [div_mul_eq_mul_div] + exact (le_div_iff₀ ha).mpr hb + + +def suppressedCoord (v : ℕ → V) (i : ℕ) : StrongDual ℝ (ClosedSpan v) := + (Finsupp.lapply i).extendOfNorm (spanCombination v) + +lemma suppressedCoord_combination (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ ℝ) (i : ℕ) : + suppressedCoord v i (spanCombination v c) = c i := by + apply LinearMap.extendOfNorm_eq (denseRange_spanCombination v) + exact ⟨2 / a, fun c => coefficient_bound v h ha hv c i⟩ + +lemma suppressedCoord_bound (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (x : ClosedSpan v) (i : ℕ) : + ‖suppressedCoord v i x‖ ≤ (2 / a) * ‖x‖ := by + exact LinearMap.norm_extendOfNorm_apply_le (denseRange_spanCombination v) _ + (fun c => coefficient_bound v h ha hv c i) x + +lemma suppressedCoord_ortho (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (i j : ℕ) : + suppressedCoord v i (spanVector v j) = (Pi.single j (1 : ℝ) : ℕ → ℝ) i := by + have hc : spanCombination v (Finsupp.single j 1) = spanVector v j := by + simp [spanCombination, Rows.spanCombination] + rw [← hc, suppressedCoord_combination v h ha hv] + simp [Finsupp.single_apply, Pi.single_apply, eq_comm] + + +def suppressedProjection (v : ℕ → V) (s : Finset ℕ) : + ClosedSpan v →L[ℝ] ClosedSpan v := + ∑ i ∈ s, (suppressedCoord v i).smulRight (spanVector v i) + +lemma suppressedProjection_apply (v : ℕ → V) (s : Finset ℕ) (x : ClosedSpan v) : + suppressedProjection v s x = ∑ i ∈ s, suppressedCoord v i x • spanVector v i := by + simp [suppressedProjection] + +lemma suppressedProjection_bound (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (s : Finset ℕ) (x : ClosedSpan v) : + ‖suppressedProjection v s x‖ ≤ 2 * ‖x‖ := by + refine (denseRange_spanCombination v).induction_on x (p := fun x => + ‖suppressedProjection v s x‖ ≤ 2 * ‖x‖) ?_ ?_ + · exact isClosed_le (by fun_prop) (by fun_prop) + · intro c + rw [suppressedProjection_apply] + simp only [suppressedCoord_combination v h ha hv] + have hh := h c s + change ‖((∑ i ∈ s, c i • spanVector v i : ClosedSpan v) : V)‖ ≤ + 2 * ‖(spanCombination v c : V)‖ + simpa only [Submodule.coe_sum, Submodule.coe_smul, spanVector, Rows.spanVector, + spanCombination_coe] using hh + +lemma suppressedProjection_combination (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (c : ℕ →₀ ℝ) + (s : Finset ℕ) (hs : c.support ⊆ s) : + suppressedProjection v s (spanCombination v c) = spanCombination v c := by + rw [suppressedProjection_apply] + simp only [suppressedCoord_combination v h ha hv] + exact (Finsupp.sum_of_support_subset c hs (fun i a => a • spanVector v i) (by simp)).symm + +lemma suppressed_expansion (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) (x : ClosedSpan v) : + HasSum (fun i => suppressedCoord v i x • spanVector v i) x := by + have hequi : Equicontinuous (fun s : Finset ℕ => (suppressedProjection v s : ClosedSpan v → ClosedSpan v)) := by + have hb : ∃ C : ℝ, ∀ (s : Finset ℕ) (y : ClosedSpan v), + ‖suppressedProjection v s y‖ ≤ C * ‖y‖ := + ⟨2, fun s y => suppressedProjection_bound v h ha hv s y⟩ + exact ((NormedSpace.equicontinuous_TFAE (suppressedProjection v)).out 4 2).mp hb + change Tendsto (fun s : Finset ℕ => ∑ i ∈ s, suppressedCoord v i x • spanVector v i) + atTop (𝓝 x) + simp only [← suppressedProjection_apply] + refine (denseRange_spanCombination v).induction_on x (p := fun x => + Tendsto (fun s : Finset ℕ => suppressedProjection v s x) atTop (𝓝 x)) ?_ ?_ + · exact hequi.isClosed_setOfPred_tendsto continuous_id + · intro c + apply tendsto_const_nhds.congr' + filter_upwards [eventually_ge_atTop c.support] with s hs + exact (suppressedProjection_combination v h ha hv c s hs).symm + + + +def unconditionalBasisOfSuppression (v : ℕ → V) (h : SuppressionBoundTwo v) + {a : ℝ} (ha : 0 < a) (hv : ∀ i, a ≤ ‖v i‖) : + UnconditionalSchauderBasis ℕ ℝ (ClosedSpan v) where + basis := spanVector v + coord := suppressedCoord v + ortho := by + intro i j + rw [suppressedCoord_ortho v h ha hv] + by_cases hij : i = j <;> simp [hij] + expansion := suppressed_expansion v h ha hv + +end SeparableQuotient.Positive.Sampling + +end + +section +open Set Metric Filter TopologicalSpace MeasureTheory Function +open scoped Classical BigOperators Topology Cardinal ENNReal NNReal + +namespace SeparableQuotient.Positive.Sampling +open MeasureTheory Filter TopologicalSpace +open scoped Topology +attribute [local instance] dualSubmoduleNormedGroup dualSubmoduleNormedSpace + + + +def IsUnconditionalBasicSequence {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + (v : ℕ → V) : Prop := + ∃ b : UnconditionalSchauderBasis ℕ ℝ (ClosedSpan v), ∀ n, (b n : V) = v n + + + + +theorem coded_family_unconditional + {X I : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + [MeasurableSpace I] [DiscreteMeasurableSpace I] + (μ : Measure I) [IsProbabilityMeasure μ] + (F : Submodule ℝ (StrongDual ℝ X)) [SeparableSpace F] + (h : I → StrongDual ℝ (StrongDual ℝ F)) (code : I → ℕ → F) + (hcode : ∀ a y, Tendsto (fun n => y (code a n)) atTop (𝓝 (h a y))) + (hnull : ∀ x : UnitBall X, ∀ᵐ a ∂μ, h a (evaluation F x.val) = 0) + {ε : ℝ} (hε : 0 < ε) (hlower : ∀ a, ε ≤ ‖(h a).comp (evaluation F)‖) : + ∃ α : ℕ → I, IsUnconditionalBasicSequence (fun n => (h (α n)).comp (evaluation F)) := by + let : MeasurableSpace F := borel F + have : BorelSpace F := ⟨rfl⟩ + let f : I → StrongDual ℝ X := fun a => (h a).comp (evaluation F) + obtain ⟨α, hα⟩ := exists_sequence_suppression + (μ := μ) (code := code) (Φ := sequentialCodeValue F) + (R := evaluationBall F) (f := f) + (measurable_sequentialCodeValue F) + (fun a x => sequentialCodeValue_evaluation F (hcode a) x) hnull + have hs := suppressionBoundTwo_of_finite (fun n => f (α n)) hα + refine ⟨α, unconditionalBasisOfSuppression (fun n => f (α n)) hs hε + (fun n => hlower (α n)), ?_⟩ + intro n + rfl + +end SeparableQuotient.Positive.Sampling + +end + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/PrefixNormers.lean b/lean/OAI/Analysis/SeparableQuotients/PrefixNormers.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb5f024b796872aa73bfa2f5f364cff249d914a9 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/PrefixNormers.lean @@ -0,0 +1,493 @@ +import OAI.Analysis.SeparableQuotients.AdjointSurjectivity + +namespace OAI + +namespace SeparableQuotient +open Set Metric +open scoped BigOperators Topology +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + +@[reducible] noncomputable local instance prefixDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 X) := inferInstance +@[reducible] noncomputable local instance prefixDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 X) := inferInstance + +/-- Finite prefix normers for a zero-based sequence. The existential formulation is equivalent to a maximum over the finite set. -/ +structure PrefixNormers (f : ℕ → StrongDual 𝕜 X) where + D : ℕ → Finset X + unit : ∀ m, ∀ d ∈ D m, ‖d‖ ≤ 1 + norming : ∀ m, 0 < m → ∀ c : ℕ → 𝕜, ∃ d ∈ D m, + ‖∑ i ∈ Finset.range m, c i • f i‖ ≤ 2 * ‖(∑ i ∈ Finset.range m, c i • f i) d‖ + vanish : ∀ m n, m ≤ n → ∀ d ∈ D m, f n d = 0 + +namespace PrefixNormers + +variable {f : ℕ → StrongDual 𝕜 X} (H : PrefixNormers f) + +theorem prefix_evaluation (c : ℕ → 𝕜) {m N : ℕ} (hmN : m ≤ N) + {d : X} (hd : d ∈ H.D m) : + (∑ i ∈ Finset.range N, c i • f i) d = (∑ i ∈ Finset.range m, c i • f i) d := by + simp only [sum_apply, smul_apply] + symm + apply Finset.sum_subset (Finset.range_mono hmN) + intro i hiN him + have hmi : m ≤ i := by simpa using him + rw [H.vanish m i hmi d hd, smul_zero] + +include H + +theorem prefix_bound (c : ℕ → 𝕜) {m N : ℕ} (hmN : m ≤ N) : + ‖∑ i ∈ Finset.range m, c i • f i‖ ≤ 2 * ‖∑ i ∈ Finset.range N, c i • f i‖ := by + by_cases hm : m = 0 + · subst m; simp + obtain ⟨d, hd, hb⟩ := H.norming m (Nat.pos_of_ne_zero hm) c + rw [← H.prefix_evaluation c hmN hd] at hb + apply hb.trans + gcongr + exact ((∑ i ∈ Finset.range N, c i • f i).le_opNorm d).trans + (by + simpa using mul_le_mul_of_nonneg_left (H.unit m d hd) + (norm_nonneg (∑ i ∈ Finset.range N, c i • f i))) + +theorem term_bound (c : ℕ → 𝕜) {n N : ℕ} (hn : n < N) : + ‖c n • f n‖ ≤ 4 * ‖∑ i ∈ Finset.range N, c i • f i‖ := by + have hp := H.prefix_bound c (Nat.succ_le_of_lt hn) + have hq := H.prefix_bound c hn.le + have he : c n • f n = + (∑ i ∈ Finset.range (n + 1), c i • f i) - (∑ i ∈ Finset.range n, c i • f i) := by + rw [Finset.sum_range_succ, add_sub_cancel_left] + rw [he] + exact (norm_sub_le _ _).trans (by linarith) + +theorem coefficient_bound (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (c : ℕ → 𝕜) {n N : ℕ} (hn : n < N) : + ‖c n‖ ≤ (4 / a) * ‖∑ i ∈ Finset.range N, c i • f i‖ := by + have hb := H.term_bound c hn + rw [norm_smul] at hb + have hmul := mul_le_mul_of_nonneg_left (hf n) (norm_nonneg (c n)) + have he : 4 * ‖∑ i ∈ Finset.range N, c i • f i‖ / a = + (4 / a) * ‖∑ i ∈ Finset.range N, c i • f i‖ := by ring + rw [← he] + exact (le_div_iff₀ ha).mpr (hmul.trans hb) + +theorem finsupp_coefficient_bound (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (c : ℕ →₀ 𝕜) (n : ℕ) : + ‖c n‖ ≤ (4 / a) * ‖Finsupp.linearCombination 𝕜 f c‖ := by + classical + obtain ⟨N, hN⟩ := (insert n c.support).exists_nat_subset_range + have hsum : (∑ i ∈ Finset.range N, c i • f i) = + Finsupp.linearCombination 𝕜 f c := by + change (∑ i ∈ Finset.range N, c i • f i) = ∑ i ∈ c.support, c i • f i + symm + apply Finset.sum_subset (fun i hi => hN (Finset.mem_insert_of_mem hi)) + intro i _ hi + rw [Finsupp.notMem_support_iff.mp hi, zero_smul] + rw [← hsum] + exact H.coefficient_bound a ha hf c (Finset.mem_range.mp (hN (Finset.mem_insert_self _ _))) + +theorem linearIndependent (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + LinearIndependent 𝕜 f := by + rw [linearIndependent_iff] + intro c hc + ext n + have h := H.finsupp_coefficient_bound a ha hf c n + rw [hc, norm_zero, mul_zero] at h + simpa using norm_eq_zero.mp (le_antisymm h (norm_nonneg _)) + +/-- Bounded algebraic coordinate functionals. -/ +noncomputable def spanCoord (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n : ℕ) : + StrongDual 𝕜 (Submodule.span 𝕜 (Set.range f)) := + LinearMap.mkContinuous ((Finsupp.lapply (R := 𝕜) (M := 𝕜) n).comp (H.linearIndependent a ha hf).repr) + (4 / a) (fun x => by + have h := H.finsupp_coefficient_bound a ha hf + ((H.linearIndependent a ha hf).repr x) n + rw [LinearIndependent.linearCombination_repr] at h + exact h) + +theorem spanCoord_norm (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n : ℕ) : + ‖H.spanCoord a ha hf n‖ ≤ 4 / a := by + apply LinearMap.mkContinuous_norm_le + exact div_nonneg (by norm_num) ha.le + +theorem spanCoord_basis (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n j : ℕ) : + H.spanCoord a ha hf n ⟨f j, Submodule.subset_span (Set.mem_range_self j)⟩ = + if j = n then 1 else 0 := by + change (H.linearIndependent a ha hf).repr _ n = _ + rw [LinearIndependent.repr_eq_single _ j _ rfl] + simp [Finsupp.single_apply] + +/-- Hahn--Banach extension of each coordinate; restrictions to the closed span are canonical. -/ +theorem exists_ambientCoord (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + ∃ e : ℕ → StrongDual 𝕜 (StrongDual 𝕜 X), + (∀ n, ‖e n‖ ≤ 4 / a) ∧ (∀ n, ∀ x : Submodule.span 𝕜 (Set.range f), + e n x = H.spanCoord a ha hf n x) := by + have he (n : ℕ) := exists_extension_norm_eq (Submodule.span 𝕜 (Set.range f)) + (H.spanCoord a ha hf n) + choose e he hnorm using he + exact ⟨e, fun n => (hnorm n).trans_le (H.spanCoord_norm a ha hf n), he⟩ + +omit H in +lemma linearCombination_eq_sum_range (c : ℕ →₀ 𝕜) {N : ℕ} + (hN : c.support ⊆ Finset.range N) : + Finsupp.linearCombination 𝕜 f c = ∑ i ∈ Finset.range N, c i • f i := by + classical + change (∑ i ∈ c.support, c i • f i) = _ + apply Finset.sum_subset hN + intro i _ hi + rw [Finsupp.notMem_support_iff.mp hi, zero_smul] + +/-- The closed linear span of the sequence. -/ +def closedSpan (f : ℕ → StrongDual 𝕜 X) : Submodule 𝕜 (StrongDual 𝕜 X) := + (Submodule.span 𝕜 (Set.range f)).topologicalClosure + +noncomputable def ambientCoord (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + ℕ → StrongDual 𝕜 (StrongDual 𝕜 X) := + Classical.choose (H.exists_ambientCoord a ha hf) + +lemma ambientCoord_spec (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + (∀ n, ‖H.ambientCoord a ha hf n‖ ≤ 4 / a) ∧ + (∀ n, ∀ x : Submodule.span 𝕜 (Set.range f), + H.ambientCoord a ha hf n x = H.spanCoord a ha hf n x) := + Classical.choose_spec (H.exists_ambientCoord a ha hf) + +noncomputable def ambientPrefix (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (m : ℕ) : StrongDual 𝕜 X →L[𝕜] StrongDual 𝕜 X := + ∑ i ∈ Finset.range m, (H.ambientCoord a ha hf i).smulRight (f i) + +lemma ambientPrefix_apply_span (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (m : ℕ) (x : Submodule.span 𝕜 (Set.range f)) : + H.ambientPrefix a ha hf m x = + ∑ i ∈ Finset.range m, (H.linearIndependent a ha hf).repr x i • f i := by + simp only [ambientPrefix, sum_apply, ContinuousLinearMap.smulRight_apply, + (H.ambientCoord_spec a ha hf).2] + rfl + +lemma ambientPrefix_bound_span (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (m : ℕ) (x : Submodule.span 𝕜 (Set.range f)) : + ‖H.ambientPrefix a ha hf m x‖ ≤ 2 * ‖x‖ := by + let c := (H.linearIndependent a ha hf).repr x + obtain ⟨N, hN⟩ := c.support.exists_nat_subset_range + have hm : m ≤ max m N := le_max_left _ _ + have hN' : c.support ⊆ Finset.range (max m N) := + hN.trans (Finset.range_mono (le_max_right _ _)) + have he : (x : StrongDual 𝕜 X) = ∑ i ∈ Finset.range (max m N), c i • f i := by + rw [← linearCombination_eq_sum_range c hN'] + exact (H.linearIndependent a ha hf).linearCombination_repr x |>.symm + rw [ambientPrefix_apply_span] + change ‖∑ i ∈ Finset.range m, c i • f i‖ ≤ 2 * ‖(x : StrongDual 𝕜 X)‖ + rw [he] + exact H.prefix_bound c hm + +lemma ambientPrefix_bound (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (m : ℕ) (x : closedSpan f) : + ‖H.ambientPrefix a ha hf m x‖ ≤ 2 * ‖x‖ := by + have hc : IsClosed {x : StrongDual 𝕜 X | + ‖H.ambientPrefix a ha hf m x‖ ≤ 2 * ‖x‖} := + isClosed_le (H.ambientPrefix a ha hf m).continuous.norm (continuous_const.mul continuous_norm) + exact closure_minimal (fun x hx => H.ambientPrefix_bound_span a ha hf m ⟨x, hx⟩) + hc x.property + +lemma ambientPrefix_eventually_span (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (x : Submodule.span 𝕜 (Set.range f)) : + ∀ᶠ m in Filter.atTop, H.ambientPrefix a ha hf m x = (x : StrongDual 𝕜 X) := by + let c := (H.linearIndependent a ha hf).repr x + obtain ⟨N, hN⟩ := c.support.exists_nat_subset_range + filter_upwards [Filter.eventually_ge_atTop N] with m hm + rw [ambientPrefix_apply_span, ← linearCombination_eq_sum_range c + (hN.trans (Finset.range_mono hm))] + exact (H.linearIndependent a ha hf).linearCombination_repr x + +lemma ambientPrefix_tendsto (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (x : closedSpan f) : + Filter.Tendsto (fun m => H.ambientPrefix a ha hf m x) Filter.atTop + (𝓝 (x : StrongDual 𝕜 X)) := by + rw [Metric.tendsto_atTop] + intro ε hε + obtain ⟨y, hy, hxy⟩ := Metric.mem_closure_iff.mp x.property (ε / 4) (by positivity) + let yc : closedSpan f := ⟨y, Submodule.le_topologicalClosure _ hy⟩ + obtain ⟨N, hN⟩ := Filter.eventually_atTop.mp (H.ambientPrefix_eventually_span a ha hf ⟨y, hy⟩) + refine ⟨N, fun m hm => ?_⟩ + have he := hN m hm + have hb := H.ambientPrefix_bound a ha hf m (x - yc) + change ‖H.ambientPrefix a ha hf m ((x : StrongDual 𝕜 X) - y)‖ ≤ + 2 * ‖(x : StrongDual 𝕜 X) - y‖ at hb + rw [map_sub, he] at hb + rw [dist_eq_norm] at hxy ⊢ + calc + ‖H.ambientPrefix a ha hf m x - (x : StrongDual 𝕜 X)‖ ≤ + ‖H.ambientPrefix a ha hf m x - y‖ + ‖y - (x : StrongDual 𝕜 X)‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ 2 * ‖(x : StrongDual 𝕜 X) - y‖ + ‖y - (x : StrongDual 𝕜 X)‖ := + add_le_add hb le_rfl + _ < ε := by rw [norm_sub_rev y]; linarith + +omit H in +noncomputable def basisVector (f : ℕ → StrongDual 𝕜 X) (n : ℕ) : closedSpan f := + ⟨f n, Submodule.le_topologicalClosure _ (Submodule.subset_span (Set.mem_range_self n))⟩ + +noncomputable def coord (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n : ℕ) : + StrongDual 𝕜 (closedSpan f) := + (H.ambientCoord a ha hf n).comp (closedSpan f).subtypeL + +lemma coord_norm (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n : ℕ) : + ‖H.coord a ha hf n‖ ≤ 4 / a := by + apply ContinuousLinearMap.opNorm_le_bound _ (by positivity) + intro x + exact ((H.ambientCoord a ha hf n).le_opNorm x).trans + (mul_le_mul_of_nonneg_right ((H.ambientCoord_spec a ha hf).1 n) (norm_nonneg _)) + +lemma coord_basis (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n j : ℕ) : + H.coord a ha hf n (basisVector f j) = if j = n then 1 else 0 := by + change H.ambientCoord a ha hf n (f j) = _ + rw [(H.ambientCoord_spec a ha hf).2 n ⟨f j, Submodule.subset_span (Set.mem_range_self j)⟩] + exact H.spanCoord_basis a ha hf n j + +noncomputable def prefixOp (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (m : ℕ) : + closedSpan f →L[𝕜] closedSpan f := + ∑ i ∈ Finset.range m, (H.coord a ha hf i).smulRight (basisVector f i) + +lemma prefix_coe (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (m : ℕ) (x : closedSpan f) : + (H.prefixOp a ha hf m x : StrongDual 𝕜 X) = H.ambientPrefix a ha hf m x := by + simp [prefixOp, ambientPrefix, coord, basisVector] + +lemma prefix_norm (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (m : ℕ) : + ‖H.prefixOp a ha hf m‖ ≤ 2 := by + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro x + change ‖(H.prefixOp a ha hf m x : StrongDual 𝕜 X)‖ ≤ 2 * ‖x‖ + rw [prefix_coe] + exact H.ambientPrefix_bound a ha hf m x + +lemma prefix_tendsto (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (x : closedSpan f) : + Filter.Tendsto (fun m => H.prefixOp a ha hf m x) Filter.atTop (𝓝 x) := by + apply tendsto_subtype_rng.mpr + simpa only [prefix_coe] using H.ambientPrefix_tendsto a ha hf x + +/-- Finite prefix normers yield a basic sequence. -/ +noncomputable def schauderBasis (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + SchauderBasis 𝕜 (closedSpan f) where + basis := basisVector f + coord := H.coord a ha hf + ortho i j := by + classical + rw [H.coord_basis a ha hf i j] + by_cases h : i = j + · subst j; simp + · simp [h, Ne.symm h] + expansion x := by + change Filter.Tendsto (fun s : Finset ℕ => ∑ i ∈ s, + H.coord a ha hf i x • basisVector f i) (SummationFilter.conditional ℕ).filter (𝓝 x) + rw [SummationFilter.conditional_filter_eq_map_range, Filter.tendsto_map'_iff] + simpa only [Function.comp_def, prefixOp, sum_apply, ContinuousLinearMap.smulRight_apply] + using H.prefix_tendsto a ha hf x + +@[reducible] noncomputable local instance closedDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 (closedSpan f)) := inferInstance +@[reducible] noncomputable local instance closedDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 (closedSpan f)) := inferInstance + +/-- Evaluation on the closed span `G`. -/ +noncomputable def evaluation (f : ℕ → StrongDual 𝕜 X) : + X →L[𝕜] StrongDual 𝕜 (closedSpan f) := + (ContinuousLinearMap.precomp 𝕜 (closedSpan f).subtypeL).comp + (NormedSpace.inclusionInDoubleDual 𝕜 X) + +omit H in +@[simp] lemma evaluation_apply (x : X) (v : closedSpan f) : + evaluation f x v = (v : StrongDual 𝕜 X) x := rfl + +lemma ambientCoord_basis (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) (n j : ℕ) : + H.ambientCoord a ha hf n (f j) = if j = n then 1 else 0 := + H.coord_basis a ha hf n j + +lemma evaluation_normer (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + {m : ℕ} {d : X} (hd : d ∈ H.D m) : + evaluation f d = ∑ i ∈ Finset.range m, f i d • H.coord a ha hf i := by + classical + have heq : Set.EqOn (NormedSpace.inclusionInDoubleDual 𝕜 X d) + (∑ i ∈ Finset.range m, f i d • H.ambientCoord a ha hf i : + StrongDual 𝕜 (StrongDual 𝕜 X)) + (closure (Submodule.span 𝕜 (Set.range f) : Set (StrongDual 𝕜 X))) := by + apply ContinuousLinearMap.eqOn_closure_span + rintro _ ⟨n, rfl⟩ + change f n d = _ + simp only [sum_apply, smul_apply, H.ambientCoord_basis, smul_eq_mul, + mul_ite, mul_one, mul_zero] + by_cases hn : n < m + · simp [hn] + · simp [hn, H.vanish m n (Nat.le_of_not_gt hn) d hd] + ext v + have hv := heq v.property + change (v : StrongDual 𝕜 X) d = _ at hv + simpa only [evaluation_apply, sum_apply, smul_apply, coord, + ContinuousLinearMap.comp_apply, Submodule.subtypeL_apply] using hv + +/-- The coefficient vectors used in the adjoint bound. -/ +noncomputable def adjointVector (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (h : StrongDual 𝕜 (StrongDual 𝕜 (closedSpan f))) (m : ℕ) : closedSpan f := + ∑ i ∈ Finset.range m, h (H.coord a ha hf i) • basisVector f i + +lemma adjointVector_bound (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (h : StrongDual 𝕜 (StrongDual 𝕜 (closedSpan f))) (m : ℕ) : + ‖H.adjointVector a ha hf h m‖ ≤ 2 * ‖h.comp (evaluation f)‖ := by + classical + by_cases hm : m = 0 + · subst m; simp [adjointVector] + obtain ⟨d, hd, hb⟩ := H.norming m (Nat.pos_of_ne_zero hm) + (fun n => h (H.coord a ha hf n)) + have he : (h.comp (evaluation f)) d = + (∑ i ∈ Finset.range m, h (H.coord a ha hf i) • f i) d := by + rw [ContinuousLinearMap.comp_apply, H.evaluation_normer a ha hf hd] + simp [smul_eq_mul, mul_comm] + rw [← he] at hb + have hn := (h.comp (evaluation f)).le_opNorm d + have hu : ‖(h.comp (evaluation f)) d‖ ≤ ‖h.comp (evaluation f)‖ := + hn.trans (by + simpa using mul_le_mul_of_nonneg_left (H.unit m d hd) + (norm_nonneg (h.comp (evaluation f)))) + have hle := hb.trans (mul_le_mul_of_nonneg_left hu (by norm_num : (0 : ℝ) ≤ 2)) + change ‖(H.adjointVector a ha hf h m : StrongDual 𝕜 X)‖ ≤ _ + simpa only [adjointVector, Submodule.coe_sum, Submodule.coe_smul, basisVector] using hle + +lemma coord_adjointVector (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (h : StrongDual 𝕜 (StrongDual 𝕜 (closedSpan f))) (m n : ℕ) : + H.coord a ha hf n (H.adjointVector a ha hf h m) = + if n < m then h (H.coord a ha hf n) else 0 := by + classical + simp [adjointVector, H.coord_basis, smul_eq_mul, mul_ite] + +lemma linearCombination_adjointVector (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (h : StrongDual 𝕜 (StrongDual 𝕜 (closedSpan f))) (c : ℕ →₀ 𝕜) + {m : ℕ} (hm : c.support ⊆ Finset.range m) : + (Finsupp.linearCombination 𝕜 (H.coord a ha hf) c) (H.adjointVector a ha hf h m) = + h (Finsupp.linearCombination 𝕜 (H.coord a ha hf) c) := by + classical + change (∑ i ∈ c.support, c i • H.coord a ha hf i) (H.adjointVector a ha hf h m) = + h (∑ i ∈ c.support, c i • H.coord a ha hf i) + simp only [sum_apply, smul_apply, map_sum, map_smul] + apply Finset.sum_congr rfl + intro i hi + rw [H.coord_adjointVector, ite_eq_left (Finset.mem_range.mp (hm hi))] + +/-- The closed coefficient span `Z`. -/ +noncomputable def coefficientSpan (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + Submodule 𝕜 (StrongDual 𝕜 (closedSpan f)) := + (Submodule.span 𝕜 (Set.range (H.coord a ha hf))).topologicalClosure + +lemma adjoint_bound_on_coefficientSpan (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (h : StrongDual 𝕜 (StrongDual 𝕜 (closedSpan f))) (u : H.coefficientSpan a ha hf) : + ‖h u‖ ≤ (2 * ‖h.comp (evaluation f)‖) * ‖u‖ := by + have hc : IsClosed {u : StrongDual 𝕜 (closedSpan f) | + ‖h u‖ ≤ (2 * ‖h.comp (evaluation f)‖) * ‖u‖} := + isClosed_le h.continuous.norm (continuous_const.mul continuous_norm) + apply closure_minimal (t := {u | ‖h u‖ ≤ (2 * ‖h.comp (evaluation f)‖) * ‖u‖}) + (fun u hu => ?_) hc u.property + obtain ⟨c, rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp hu + obtain ⟨m, hm⟩ := c.support.exists_nat_subset_range + change ‖h (Finsupp.linearCombination 𝕜 (H.coord a ha hf) c)‖ ≤ + (2 * ‖h.comp (evaluation f)‖) * ‖Finsupp.linearCombination 𝕜 (H.coord a ha hf) c‖ + rw [← H.linearCombination_adjointVector a ha hf h c hm] + exact ((Finsupp.linearCombination 𝕜 (H.coord a ha hf) c).le_opNorm _).trans + (by + rw [mul_comm (2 * _)] + exact mul_le_mul_of_nonneg_left (H.adjointVector_bound a ha hf h m) (norm_nonneg _)) + +/-- Evaluation with codomain the closed coefficient span. -/ +noncomputable def evaluationToZ (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (hZ : ∀ x, evaluation f x ∈ H.coefficientSpan a ha hf) : + X →L[𝕜] H.coefficientSpan a ha hf := + (evaluation f).codRestrict (H.coefficientSpan a ha hf) hZ + +lemma evaluationToZ_adjoint_bound (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (hZ : ∀ x, evaluation f x ∈ H.coefficientSpan a ha hf) + (h : StrongDual 𝕜 (H.coefficientSpan a ha hf)) : + (1 / 2 : ℝ) * ‖h‖ ≤ ‖h.comp (H.evaluationToZ a ha hf hZ)‖ := by + obtain ⟨h', he, _⟩ := exists_extension_norm_eq (H.coefficientSpan a ha hf) h + have hcomp : h'.comp (evaluation f) = h.comp (H.evaluationToZ a ha hf hZ) := by + ext x + exact he (H.evaluationToZ a ha hf hZ x) + have hb : ‖h‖ ≤ 2 * ‖h.comp (H.evaluationToZ a ha hf hZ)‖ := by + apply h.opNorm_le_bound (mul_nonneg (by norm_num) (norm_nonneg _)) + intro u + rw [← he u] + simpa only [hcomp] using H.adjoint_bound_on_coefficientSpan a ha hf h' u + linarith + +/-- Coefficients are linearly independent, so their closed span is infinite dimensional. -/ +lemma coord_linearIndependent (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + LinearIndependent 𝕜 (H.coord a ha hf) := by + classical + refine linearIndependent_iff.mpr fun c hc => c.ext fun n => ?_ + have he := congrArg (fun u : StrongDual 𝕜 (closedSpan f) => u (basisVector f n)) hc + simpa [Finsupp.linearCombination_apply, Finsupp.sum, H.coord_basis, + smul_eq_mul, mul_ite] using he + +noncomputable def coefficientVector (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (n : ℕ) : H.coefficientSpan a ha hf := + ⟨H.coord a ha hf n, Submodule.le_topologicalClosure _ + (Submodule.subset_span (Set.mem_range_self n))⟩ + +lemma coefficientVector_linearIndependent (a : ℝ) (ha : 0 < a) + (hf : ∀ n, a ≤ ‖f n‖) : LinearIndependent 𝕜 (H.coefficientVector a ha hf) := + LinearIndependent.of_comp (H.coefficientSpan a ha hf).subtype + (H.coord_linearIndependent a ha hf) + +lemma coefficientSpan_infiniteDimensional (a : ℝ) (ha : 0 < a) + (hf : ∀ n, a ≤ ‖f n‖) : ¬ FiniteDimensional 𝕜 (H.coefficientSpan a ha hf) := by + intro h + let := h + exact Module.Finite.not_linearIndependent_of_infinite (H.coefficientVector a ha hf) + (H.coefficientVector_linearIndependent a ha hf) + +lemma coefficientSpan_isClosed (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + IsClosed (H.coefficientSpan a ha hf : Set (StrongDual 𝕜 (closedSpan f))) := + (Submodule.span 𝕜 (Set.range (H.coord a ha hf))).isClosed_topologicalClosure + +lemma coefficientSpan_separable (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) : + TopologicalSpace.SeparableSpace (H.coefficientSpan a ha hf) := by + have hs := ((Set.countable_range (H.coord a ha hf)).isSeparable.span (R := 𝕜)).closure + exact hs.separableSpace + +end PrefixNormers +end SeparableQuotient + +namespace SeparableQuotient +namespace PrefixNormers +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X] +variable {f : ℕ → StrongDual 𝕜 X} (H : PrefixNormers f) +@[reducible] noncomputable local instance outcomeDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 X) := inferInstance +@[reducible] noncomputable local instance outcomeDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 X) := inferInstance +@[reducible] noncomputable local instance outcomeClosedDualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 (closedSpan f)) := inferInstance +@[reducible] noncomputable local instance outcomeClosedDualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 (closedSpan f)) := inferInstance + +/-- The adjoint lower bound implies surjectivity of evaluation. -/ +theorem evaluationToZ_surjective (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (hZ : ∀ x, evaluation f x ∈ H.coefficientSpan a ha hf) : + Function.Surjective (H.evaluationToZ a ha hf hZ) := + surjective_of_adjoint_bound_rclike (𝕜 := 𝕜) (E := X) + (F := H.coefficientSpan a ha hf) (H.evaluationToZ a ha hf hZ) (1 / 2) + (by norm_num) (H.evaluationToZ_adjoint_bound a ha hf hZ) + +/-- Finite prefix normers yield a separable quotient. -/ +theorem hasSeparableQuotient_of_range (a : ℝ) (ha : 0 < a) (hf : ∀ n, a ≤ ‖f n‖) + (hZ : ∀ x, evaluation f x ∈ H.coefficientSpan a ha hf) : HasSeparableQuotient 𝕜 X := by + let : IsClosed (H.coefficientSpan a ha hf : Set (StrongDual 𝕜 (closedSpan f))) := + H.coefficientSpan_isClosed a ha hf + refine ⟨H.coefficientSpan a ha hf, inferInstance, inferInstance, inferInstance, + H.coefficientSpan_separable a ha hf, H.coefficientSpan_infiniteDimensional a ha hf, + H.evaluationToZ a ha hf hZ, H.evaluationToZ_surjective a ha hf hZ⟩ + +end PrefixNormers +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/ProductQuotients.lean b/lean/OAI/Analysis/SeparableQuotients/ProductQuotients.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dec640f23551939496306fa8bec40dbb307bab7 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/ProductQuotients.lean @@ -0,0 +1,95 @@ +import OAI.Analysis.SeparableQuotients.Complexification + +namespace OAI + +noncomputable section + +namespace SeparableQuotient +open Set TopologicalSpace Singular +open scoped Classical +universe u +variable {𝕜 : Type} [RCLike 𝕜] +variable {X Y : Type u} [NormedAddCommGroup X] [NormedSpace 𝕜 X] [CompleteSpace X] + [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] [CompleteSpace Y] + +@[reducible] local instance fsDualGroup (Z : Type u) [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] : + NormedAddCommGroup (StrongDual 𝕜 Z) := inferInstance +@[reducible] local instance fsDualSpace (Z : Type u) [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] : + NormedSpace 𝕜 (StrongDual 𝕜 Z) := inferInstance + +omit [CompleteSpace Y] in +lemma hasSQ_of_adjoint_not_SS (a : X →L[𝕜] Y) + (F : Submodule 𝕜 (StrongDual 𝕜 Y)) (hF : IsClosed (F : Set (StrongDual 𝕜 Y))) + (hsep : IsSeparable (range (subspaceEvaluation F))) + (hT : ¬ StrictlySingular ((ContinuousLinearMap.precomp 𝕜 a).comp F.subtypeL)) : + HasSeparableQuotient 𝕜 X := by + let : CompleteSpace F := hF.completeSpace_coe + obtain ⟨H,hH,hHi,U,hU⟩ := exists_lift_of_not_strictlySingular _ hT + let := hH + apply hasSeparableQuotient_of_separable_evaluation H hHi + let A : StrongDual 𝕜 F →L[𝕜] StrongDual 𝕜 H := ContinuousLinearMap.precomp 𝕜 U + apply (hsep.image A.continuous).mono + rintro _ ⟨x,rfl⟩ + refine ⟨subspaceEvaluation F (a x), mem_range_self _, ?_⟩ + ext h + exact congrArg (fun f : StrongDual 𝕜 X => f x) (hU h) + +omit [CompleteSpace X] [CompleteSpace Y] in +lemma norm_dual_prod_le (f : StrongDual 𝕜 (X × Y)) : + ‖f‖ ≤ ‖f.comp (ContinuousLinearMap.inl 𝕜 X Y)‖ + + ‖f.comp (ContinuousLinearMap.inr 𝕜 X Y)‖ := by + apply f.opNorm_le_bound (by positivity) + intro z + have he : z = (z.1,0) + (0,z.2) := by ext <;> simp + calc + ‖f z‖ = ‖f (z.1,0) + f (0,z.2)‖ := by rw [← map_add,← he] + _ ≤ ‖f (z.1,0)‖ + ‖f (0,z.2)‖ := norm_add_le _ _ + _ ≤ ‖f.comp (ContinuousLinearMap.inl 𝕜 X Y)‖ * ‖z.1‖ + + ‖f.comp (ContinuousLinearMap.inr 𝕜 X Y)‖ * ‖z.2‖ := add_le_add + ((f.comp (ContinuousLinearMap.inl 𝕜 X Y)).le_opNorm z.1) + ((f.comp (ContinuousLinearMap.inr 𝕜 X Y)).le_opNorm z.2) + _ ≤ ‖f.comp (ContinuousLinearMap.inl 𝕜 X Y)‖ * ‖z‖ + + ‖f.comp (ContinuousLinearMap.inr 𝕜 X Y)‖ * ‖z‖ := add_le_add + (mul_le_mul_of_nonneg_left (norm_fst_le z) (norm_nonneg _)) + (mul_le_mul_of_nonneg_left (norm_snd_le z) (norm_nonneg _)) + _ = _ := by ring + +omit [CompleteSpace X] [CompleteSpace Y] in +lemma top_infinite (hX : ¬ FiniteDimensional 𝕜 X) : + ¬ FiniteDimensional 𝕜 (⊤ : Submodule 𝕜 X) := by + intro h + let := h + exact hX (FiniteDimensional.of_surjective (⊤ : Submodule 𝕜 X).subtype + (fun x => ⟨⟨x,trivial⟩,rfl⟩)) + +/-- The separable quotient dichotomy for a product, via the evaluation criterion. -/ +theorem hasSQ_prod_cases (h : HasSeparableQuotient 𝕜 (X × Y)) : + HasSeparableQuotient 𝕜 X ∨ HasSeparableQuotient 𝕜 Y := by + obtain ⟨F,hF,hFi,hsep⟩ := separable_evaluation_of_hasSeparableQuotient h + let : CompleteSpace F := hF.completeSpace_coe + let p₁ : F →L[𝕜] StrongDual 𝕜 X := + (ContinuousLinearMap.precomp 𝕜 (ContinuousLinearMap.inl 𝕜 X Y)).comp F.subtypeL + let p₂ : F →L[𝕜] StrongDual 𝕜 Y := + (ContinuousLinearMap.precomp 𝕜 (ContinuousLinearMap.inr 𝕜 X Y)).comp F.subtypeL + by_cases h₁ : StrictlySingular p₁ + · right + apply hasSQ_of_adjoint_not_SS (ContinuousLinearMap.inr 𝕜 X Y) F hF hsep + obtain ⟨G,_hG,hGc,hGi,hsmall⟩ := StrictlySingular.exists_small_restriction p₁ h₁ + (⊤ : Submodule 𝕜 F) isClosed_univ (top_infinite hFi) (1/2) (by norm_num) + apply (not_strictlySingular_iff p₂).mpr + refine ⟨G,hGc,hGi,1/2,by norm_num,?_⟩ + intro g + have hn := norm_dual_prod_le (g.val : StrongDual 𝕜 (X × Y)) + have hs := hsmall g.val g.property + change ‖(g : F)‖ ≤ ‖p₁ g‖ + ‖p₂ g‖ at hn + change ‖p₁ g‖ ≤ (1/2 : ℝ)*‖g‖ at hs + change (1/2 : ℝ)*‖g‖ ≤ ‖p₂ g‖ + change ‖g‖ ≤ ‖p₁ g‖ + ‖p₂ g‖ at hn + linarith + · exact Or.inl (hasSQ_of_adjoint_not_SS (ContinuousLinearMap.inl 𝕜 X Y) F hF hsep h₁) + +end SeparableQuotient + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/QuotientPerturbation.lean b/lean/OAI/Analysis/SeparableQuotients/QuotientPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f857d46fbd1609739b4704a0caf4d4d7f041b43 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/QuotientPerturbation.lean @@ -0,0 +1,281 @@ +import OAI.Analysis.SeparableQuotients.Model + +namespace OAI + +namespace SeparableQuotient + +open MeasureTheory Cardinal + +universe u + +section Perturbation + +variable {𝕜 : Type} [RCLike 𝕜] +variable {M : Type u} [NormedAddCommGroup M] [NormedSpace 𝕜 M] + +/-- A quotient lift with norm bounded by 11/10 times the quotient norm. -/ +theorem quotient_lift (Y : Submodule 𝕜 M) [IsClosed (Y : Set M)] (w : M ⧸ Y) : + ∃ y : M, Y.mkQL y = w ∧ ‖y‖ ≤ (11 / 10 : ℝ) * ‖w‖ := by + by_cases hw : w = 0 + · subst w + exact ⟨0, map_zero _, by simp⟩ + · have hp : 0 < ‖w‖ / 10 := div_pos (norm_pos_iff.mpr hw) (by norm_num) + obtain ⟨y, hy, hnorm⟩ := Submodule.Quotient.norm_mk_lt w hp + refine ⟨y, hy, ?_⟩ + linarith + +noncomputable def quotientRightInverse (Y : Submodule 𝕜 M) [IsClosed (Y : Set M)] : + Y.mkQL.NonlinearRightInverse where + toFun w := (quotient_lift Y w).choose + nnnorm := 11 / 10 + bound' w := by + simpa using (quotient_lift Y w).choose_spec.2 + right_inv' w := (quotient_lift Y w).choose_spec.1 + +/-- Quantitative lift constant for a perturbed quotient map. -/ +noncomputable def liftConstant (b : ℝ) : ℝ := (11 / 10) / (1 - (11 / 10) * b) + +theorem liftConstant_properties {b : ℝ} (_hb0 : 0 ≤ b) (hb : b ≤ 1 / 10) : + 0 < liftConstant b ∧ liftConstant b * b < 1 ∧ + ((11 / 10 : ℝ)⁻¹ - b) * liftConstant b = 1 := by + have hd : 0 < 1 - (11 / 10 : ℝ) * b := by linarith + dsimp [liftConstant] + refine ⟨div_pos (by norm_num) hd, ?_, ?_⟩ + · apply (div_mul_eq_mul_div _ _ _).trans_lt + apply (div_lt_one hd).mpr + linarith + · have hh : 10 - b * 11 ≠ 0 := by linarith + have he : ((11 / 10 : ℝ)⁻¹ - b) * (11 / 10) = 1 - (11 / 10) * b := by + norm_num + ring + rw [← mul_div_assoc, he, div_self hd.ne'] + +/-- A 1/10 perturbation of a quotient map is onto, with a quantitative nonlinear lift bound. -/ +theorem perturbed_quotient_lift [CompleteSpace M] + (Y : Submodule 𝕜 M) [IsClosed (Y : Set M)] + (B : M →L[𝕜] M ⧸ Y) (hB : ‖B‖ ≤ 1 / 10) (w : M ⧸ Y) : + ∃ y : M, (Y.mkQL - B) y = w ∧ ‖y‖ ≤ liftConstant ‖B‖ * ‖w‖ := by + have hc := liftConstant_properties (norm_nonneg B) hB + have ha : ApproximatesLinearOn (Y.mkQL - B) Y.mkQL Set.univ ‖B‖₊ := by + intro x _ y _ + have he : (Y.mkQL - B) x - (Y.mkQL - B) y - Y.mkQL (x - y) = -(B (x - y)) := by + simp only [sub_apply, map_sub] + abel + rw [he, norm_neg] + exact B.le_opNorm (x - y) + have hs := ha.surjOn_closedBall_of_nonlinearRightInverse (quotientRightInverse Y) + (b := 0) (ε := liftConstant ‖B‖ * ‖w‖) + (mul_nonneg hc.1.le (norm_nonneg w)) (Set.subset_univ _) + have hw : w ∈ Metric.closedBall ((Y.mkQL - B) 0) + ((((quotientRightInverse Y).nnnorm : ℝ)⁻¹ - (‖B‖₊ : ℝ)) * + (liftConstant ‖B‖ * ‖w‖)) := by + simp only [map_zero, Metric.mem_closedBall, dist_zero_right] + change ‖w‖ ≤ ((11 / 10 : ℝ)⁻¹ - ‖B‖) * (liftConstant ‖B‖ * ‖w‖) + rw [← mul_assoc, hc.2.2, one_mul] + obtain ⟨y, hy, he⟩ := hs hw + exact ⟨y, he, by simpa only [Metric.mem_closedBall, dist_zero_right] using hy⟩ + +/-- The image of the perturbed kernel is dense in the closure of the image of the original kernel. -/ +theorem perturbed_quotient_dense [CompleteSpace M] + (Y : Submodule 𝕜 M) [IsClosed (Y : Set M)] + (B : M →L[𝕜] M ⧸ Y) (hB : ‖B‖ ≤ 1 / 10) + (hBV : ∀ y : M, B y ∈ (Y.map B.toLinearMap).topologicalClosure) : + ((Y.mkQL - B).ker.map B.toLinearMap).topologicalClosure = + (Y.map B.toLinearMap).topologicalClosure := by + let V := (Y.map B.toLinearMap).topologicalClosure + let G := ((Y.mkQL - B).ker.map B.toLinearMap).topologicalClosure + have hGV : G ≤ V := by + apply closure_minimal _ (Submodule.isClosed_topologicalClosure _) + rintro w ⟨x, hx, rfl⟩ + exact hBV x + have hG : IsClosed (G : Set (M ⧸ Y)) := Submodule.isClosed_topologicalClosure _ + let := hG + have hsmall : (‖B‖ * liftConstant ‖B‖) * (11 / 10) < 1 := by + have hd : 0 < 1 - (11/10:ℝ)*‖B‖ := by linarith + dsimp [liftConstant] + calc + ‖B‖ * (11 / 10 / (1 - 11 / 10 * ‖B‖)) * (11 / 10) = + (‖B‖ * (11 / 10) * (11 / 10)) / (1 - 11 / 10 * ‖B‖) := by ring + _ < 1 := (div_lt_one hd).mpr (by nlinarith [norm_nonneg B]) + have hVbound : ∀ v ∈ V, ‖G.mkQL v‖ ≤ (‖B‖ * liftConstant ‖B‖) * ‖v‖ := by + apply closure_minimal ?_ (isClosed_le (G.mkQL.continuous.norm) + (continuous_const.mul continuous_norm)) + rintro v ⟨y, hy, rfl⟩ + obtain ⟨x, hx, hnx⟩ := perturbed_quotient_lift Y B hB (B y) + have hQy : Y.mkQL y = 0 := (Submodule.Quotient.mk_eq_zero Y).mpr hy + have hyx : y + x ∈ (Y.mkQL - B).ker := by + change (Y.mkQL - B) (y + x) = 0 + rw [map_add, hx] + simp [hQy] + have hg : B (y + x) ∈ G := + Submodule.le_topologicalClosure _ ⟨y + x, hyx, rfl⟩ + have hzero : G.mkQL (B (y + x)) = 0 := + (Submodule.Quotient.mk_eq_zero G).mpr hg + have he : G.mkQL (B y) = -G.mkQL (B x) := by + simpa only [map_add, eq_neg_iff_add_eq_zero] using hzero + change ‖G.mkQL (B y)‖ ≤ (‖B‖ * liftConstant ‖B‖) * ‖B y‖ + rw [he, norm_neg] + calc + ‖G.mkQL (B x)‖ ≤ ‖B x‖ := Submodule.Quotient.norm_mk_le G (B x) + _ ≤ ‖B‖ * ‖x‖ := B.le_opNorm x + _ ≤ ‖B‖ * (liftConstant ‖B‖ * ‖B y‖) := + mul_le_mul_of_nonneg_left hnx (norm_nonneg B) + _ = (‖B‖ * liftConstant ‖B‖) * ‖B y‖ := (mul_assoc _ _ _).symm + apply le_antisymm hGV + intro v hv + obtain ⟨z, hz, hnz⟩ := quotient_lift G (G.mkQL v) + have hvz : v - z ∈ G := (Submodule.Quotient.eq G).mp hz.symm + have hzV : z ∈ V := by + have := V.sub_mem hv (hGV hvz) + simpa using this + have hn := hVbound z hzV + rw [hz] at hn + have hg0 := (liftConstant_properties (norm_nonneg B) hB).1.le + have hnn : ‖G.mkQL v‖ ≤ (‖B‖ * liftConstant ‖B‖ * (11 / 10)) * ‖G.mkQL v‖ := by + calc + ‖G.mkQL v‖ ≤ (‖B‖ * liftConstant ‖B‖) * ‖z‖ := hn + _ ≤ (‖B‖ * liftConstant ‖B‖) * ((11 / 10) * ‖G.mkQL v‖) := + mul_le_mul_of_nonneg_left hnz (mul_nonneg (norm_nonneg B) hg0) + _ = _ := (mul_assoc _ _ _).symm + have hzq : G.mkQL v = 0 := by + apply norm_eq_zero.mp + nlinarith [norm_nonneg (G.mkQL v)] + exact (Submodule.Quotient.mk_eq_zero G).mp hzq + +end Perturbation + +noncomputable def equivOfBijective {𝕜 : Type} [RCLike 𝕜] + {M N : Type u} [NormedAddCommGroup M] [NormedSpace 𝕜 M] [CompleteSpace M] + [NormedAddCommGroup N] [NormedSpace 𝕜 N] [CompleteSpace N] + (f : M →L[𝕜] N) (hf : Function.Bijective f) : M ≃L[𝕜] N := + (LinearEquiv.ofBijective f.toLinearMap hf).toContinuousLinearEquivOfContinuous f.continuous + +section Predual + +variable {𝕜 : Type} [RCLike 𝕜] +variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E] + +@[reducible] noncomputable local instance dualNormedGroup : + NormedAddCommGroup (StrongDual 𝕜 E) := inferInstance +@[reducible] noncomputable local instance dualNormedSpace : + NormedSpace 𝕜 (StrongDual 𝕜 E) := inferInstance + +/-- Restriction of the canonical evaluation embedding to a subspace of the dual. -/ +noncomputable def evalOn (Y : Submodule 𝕜 (StrongDual 𝕜 E)) : + E →L[𝕜] StrongDual 𝕜 Y := + (ContinuousLinearMap.precomp 𝕜 Y.subtypeL).comp (NormedSpace.inclusionInDoubleDual 𝕜 E) + +@[simp] theorem evalOn_apply (Y : Submodule 𝕜 (StrongDual 𝕜 E)) (e : E) (y : Y) : + evalOn Y e y = (y : StrongDual 𝕜 E) e := rfl + +/-- Surjectivity from the adjoint-range hypothesis and Hahn–Banach, +using a quotient lift of the graph map. -/ +theorem twisted_eval_surjective + (Y : Submodule 𝕜 (StrongDual 𝕜 E)) [IsClosed (Y : Set (StrongDual 𝕜 E))] + (hY : Function.Surjective (evalOn Y)) + (B : StrongDual 𝕜 E →L[𝕜] (StrongDual 𝕜 E) ⧸ Y) + (hBadj : ∀ w : StrongDual 𝕜 ((StrongDual 𝕜 E) ⧸ Y), + ∃ e : E, w.comp B = NormedSpace.inclusionInDoubleDual 𝕜 E e) : + Function.Surjective (evalOn (Y.mkQL - B).ker) := by + intro f + obtain ⟨g, hg, _⟩ := exists_extension_norm_eq (Y.mkQL - B).ker f + obtain ⟨e₀, he₀⟩ := hY (g.comp Y.subtypeL) + let z := g - NormedSpace.inclusionInDoubleDual 𝕜 E e₀ + have hz : Y ≤ z.ker := by + intro y hy + change g y - y e₀ = 0 + have he := DFunLike.congr_fun he₀ (⟨y, hy⟩ : Y) + exact sub_eq_zero.mpr he.symm + let w := Y.liftQL z hz + obtain ⟨e₁, he₁⟩ := hBadj w + refine ⟨e₀ + e₁, ?_⟩ + ext x + have hx : Y.mkQL (x : StrongDual 𝕜 E) = B x := by + have := x.property + change Y.mkQL (x : StrongDual 𝕜 E) - B x = 0 at this + exact sub_eq_zero.mp this + have hw : w (Y.mkQL (x : StrongDual 𝕜 E)) = g x - (x : StrongDual 𝕜 E) e₀ := rfl + have he := DFunLike.congr_fun he₁ (x : StrongDual 𝕜 E) + change w (B x) = (x : StrongDual 𝕜 E) e₁ at he + rw [hx, he] at hw + change (x : StrongDual 𝕜 E) (e₀ + e₁) = f x + rw [map_add, hw, ← hg x] + abel + +/-- The small quotient perturbation preserves injectivity of evaluation. -/ +theorem twisted_eval_injective + (Y : Submodule 𝕜 (StrongDual 𝕜 E)) [IsClosed (Y : Set (StrongDual 𝕜 E))] + (hY : Isometry (evalOn Y)) + (B : StrongDual 𝕜 E →L[𝕜] (StrongDual 𝕜 E) ⧸ Y) (hB : ‖B‖ ≤ 1 / 10) : + Function.Injective (evalOn (Y.mkQL - B).ker) := by + apply (injective_iff_map_eq_zero (evalOn (Y.mkQL - B).ker)).mpr + intro e he + have hc := liftConstant_properties (norm_nonneg B) hB + have hbnd : ‖evalOn Y e‖ ≤ (liftConstant ‖B‖ * ‖B‖) * ‖e‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ + (mul_nonneg (mul_nonneg hc.1.le (norm_nonneg B)) (norm_nonneg e)) + intro y + obtain ⟨t, ht, hnt⟩ := perturbed_quotient_lift Y B hB (B y) + have hQy : Y.mkQL (y : StrongDual 𝕜 E) = 0 := + (Submodule.Quotient.mk_eq_zero Y).mpr y.property + have hyt : (y : StrongDual 𝕜 E) + t ∈ (Y.mkQL - B).ker := by + change (Y.mkQL - B) ((y : StrongDual 𝕜 E) + t) = 0 + rw [map_add, ht] + simp [hQy] + have heyt := DFunLike.congr_fun he + (⟨(y : StrongDual 𝕜 E) + t, hyt⟩ : (Y.mkQL - B).ker) + change (y : StrongDual 𝕜 E) e + t e = 0 at heyt + have hye : (y : StrongDual 𝕜 E) e = -t e := eq_neg_of_add_eq_zero_left heyt + rw [evalOn_apply, hye, norm_neg] + calc + ‖t e‖ ≤ ‖t‖ * ‖e‖ := t.le_opNorm e + _ ≤ (liftConstant ‖B‖ * ‖B y‖) * ‖e‖ := + mul_le_mul_of_nonneg_right hnt (norm_nonneg e) + _ ≤ (liftConstant ‖B‖ * (‖B‖ * ‖y‖)) * ‖e‖ := + mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (B.le_opNorm y) hc.1.le) (norm_nonneg e) + _ = ((liftConstant ‖B‖ * ‖B‖) * ‖e‖) * ‖y‖ := by ring + have hn : ‖evalOn Y e‖ = ‖e‖ := + Isometry.norm_map_of_map_zero (f := fun x => evalOn Y x) hY (map_zero (evalOn Y)) e + rw [hn] at hbnd + apply norm_eq_zero.mp + nlinarith [norm_nonneg e] + +noncomputable def twisted_eval_equiv [CompleteSpace E] + (Y : Submodule 𝕜 (StrongDual 𝕜 E)) [IsClosed (Y : Set (StrongDual 𝕜 E))] + (hYiso : Isometry (evalOn Y)) (hYsurj : Function.Surjective (evalOn Y)) + (B : StrongDual 𝕜 E →L[𝕜] (StrongDual 𝕜 E) ⧸ Y) (hB : ‖B‖ ≤ 1 / 10) + (hBadj : ∀ w : StrongDual 𝕜 ((StrongDual 𝕜 E) ⧸ Y), + ∃ e : E, w.comp B = NormedSpace.inclusionInDoubleDual 𝕜 E e) : + E ≃L[𝕜] StrongDual 𝕜 (Y.mkQL - B).ker := by + have hi : Function.Injective (evalOn (Y.mkQL - B).ker) := + twisted_eval_injective Y hYiso B hB + have hs : Function.Surjective (evalOn (Y.mkQL - B).ker) := + twisted_eval_surjective Y hYsurj B hBadj + exact equivOfBijective (𝕜 := 𝕜) (M := E) (N := StrongDual 𝕜 (Y.mkQL - B).ker) + (evalOn (Y.mkQL - B).ker) ⟨hi, hs⟩ + +/-- A small perturbation of a quotient map produces an isomorphic dual of the perturbed kernel. -/ +theorem twist [CompleteSpace E] + (Y : Submodule 𝕜 (StrongDual 𝕜 E)) [IsClosed (Y : Set (StrongDual 𝕜 E))] + (hYiso : Isometry (evalOn Y)) (hYsurj : Function.Surjective (evalOn Y)) + (B : StrongDual 𝕜 E →L[𝕜] (StrongDual 𝕜 E) ⧸ Y) (hB : ‖B‖ ≤ 1 / 10) + (hBadj : ∀ w : StrongDual 𝕜 ((StrongDual 𝕜 E) ⧸ Y), + ∃ e : E, w.comp B = NormedSpace.inclusionInDoubleDual 𝕜 E e) + (hBrange : B.range ≤ (Y.map B.toLinearMap).topologicalClosure) : + CompleteSpace (Y.mkQL - B).ker ∧ + (∃ T : E ≃L[𝕜] StrongDual 𝕜 (Y.mkQL - B).ker, + ∀ (e : E) (x : (Y.mkQL - B).ker), T e x = (x : StrongDual 𝕜 E) e) ∧ + (((Y.mkQL - B).ker).map B.toLinearMap).topologicalClosure = + (Y.map B.toLinearMap).topologicalClosure := by + have : IsClosed ((Y.mkQL - B).ker : Set (StrongDual 𝕜 E)) := + (Y.mkQL - B).isClosed_ker + refine ⟨inferInstance, ?_, perturbed_quotient_dense Y B hB (fun y => hBrange ⟨y, rfl⟩)⟩ + let T := twisted_eval_equiv Y hYiso hYsurj B hB hBadj + exact ⟨T, fun _ _ => rfl⟩ + +end Predual + +end SeparableQuotient + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/RamseyThinning.lean b/lean/OAI/Analysis/SeparableQuotients/RamseyThinning.lean new file mode 100644 index 0000000000000000000000000000000000000000..e937a253337f466d79340d6baaf3beb5ce7d3619 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/RamseyThinning.lean @@ -0,0 +1,192 @@ +import OAI.Analysis.SeparableQuotients.WindowEstimates + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.InfiniteRamsey +open Filter +open scoped Classical + +variable {χ : Type*} [Finite χ] + +lemma eventually_constant (U : Ultrafilter ℕ) (f : ℕ → χ) : + ∃ b, ∀ᶠ m in U, f m = b := + U.eventually_exists_iff.mp (Eventually.of_forall (fun m => ⟨f m, rfl⟩)) + +def limitColor (U : Ultrafilter ℕ) (c : Finset ℕ → χ) : ℕ → Finset ℕ → χ + | 0, s => c s + | k+1, s => (eventually_constant U (fun m => limitColor U c k (insert m s))).choose + +lemma limitColor_eventually (U : Ultrafilter ℕ) (c : Finset ℕ → χ) + (k : ℕ) (s : Finset ℕ) : + ∀ᶠ m in U, limitColor U c k (insert m s) = limitColor U c (k+1) s := + (eventually_constant U (fun m => limitColor U c k (insert m s))).choose_spec + +/-- The finite-set form of the infinite Ramsey theorem, proved by iterated +ultrafilter colors. Used only for the four-hit thinning in exact-pairs. -/ +theorem homogeneous (n : ℕ) (c : Finset ℕ → χ) : + ∃ (M : Set ℕ) (b : χ), M.Infinite ∧ + ∀ s : Finset ℕ, (↑s : Set ℕ) ⊆ M → s.card = n → c s = b := by + let U := Ultrafilter.of (atTop : Filter ℕ) + let b := limitColor U c n ∅ + let Good : Finset ℕ → Prop := fun S => ∀ s ⊆ S, s.card ≤ n → limitColor U c (n-s.card) s = b + have hempty : Good ∅ := by + intro s hs _ + have he : s = ∅ := Finset.subset_empty.mp hs + subst s + rfl + have hstep (S : Finset ℕ) (hS : Good S) : ∃ m > S.sup id, Good (insert m S) := by + have hev (s : Finset ℕ) (hs : s ⊆ S) : ∀ᶠ m in U, + s.card < n → limitColor U c (n-s.card-1) (insert m s) = b := by + by_cases hlt : s.card < n + · have he : n-s.card-1+1 = n-s.card := by omega + exact (limitColor_eventually U c (n-s.card-1) s).mono + (fun _ h _ => h.trans (by rw [he]; exact hS s hs hlt.le)) + · exact Eventually.of_forall (fun _ h => (hlt h).elim) + have hall : ∀ᶠ m in U, ∀ s ∈ S.powerset, + s.card < n → limitColor U c (n-s.card-1) (insert m s) = b := + (eventually_all_finset S.powerset).mpr (fun s hs => hev s (Finset.mem_powerset.mp hs)) + have hlarge : ∀ᶠ m in U, S.sup id < m := + (eventually_gt_atTop (S.sup id)).filter_mono (Ultrafilter.of_le atTop) + obtain ⟨m, hm, hall⟩ := (hlarge.and hall).exists + have hmS : m ∉ S := by + intro h + exact (not_le_of_gt hm) (Finset.le_sup (f := id) h) + refine ⟨m, hm, fun s hs hcard => ?_⟩ + by_cases hms : m ∈ s + · let t := s.erase m + have hts : t ⊆ S := by + intro a ha + have hh := Finset.mem_of_subset hs (Finset.mem_of_mem_erase ha) + exact (Finset.mem_insert.mp hh).resolve_left (Finset.ne_of_mem_erase ha) + have htc : t.card+1 = s.card := by + exact Finset.card_erase_add_one hms + have he : insert m t = s := Finset.insert_erase hms + have hh := hall t (Finset.mem_powerset.mpr hts) (by omega) + simpa only [he, show n-t.card-1 = n-s.card by omega] using hh + · have hss : s ⊆ S := by + intro a ha + exact (Finset.mem_insert.mp (hs ha)).resolve_left (fun h => hms (h ▸ ha)) + exact hS s hss hcard + let next (S : {S : Finset ℕ // Good S}) : ℕ := (hstep S.val S.property).choose + have hn (S : {S : Finset ℕ // Good S}) : S.val.sup id < next S ∧ Good (insert (next S) S.val) := + (hstep S.val S.property).choose_spec + let seq : ℕ → {S : Finset ℕ // Good S} := Nat.rec ⟨∅, hempty⟩ + (fun _ S => ⟨insert (next S) S.val, (hn S).2⟩) + have hseq (i : ℕ) : (seq (i+1)).val = insert (next (seq i)) (seq i).val := rfl + have hmono : Monotone (fun i => (seq i).val) := monotone_nat_of_le_succ + (fun i => by rw [hseq]; exact Finset.subset_insert _ _) + let v : ℕ → ℕ := fun i => next (seq i) + have hvmem (i : ℕ) : v i ∈ (seq (i+1)).val := by rw [hseq]; exact Finset.mem_insert_self _ _ + have hv : StrictMono v := by + apply strictMono_nat_of_lt_succ + intro i + exact (Finset.le_sup (f := id) (hvmem i)).trans_lt (hn (seq (i+1))).1 + let M : Set ℕ := ⋃ i, ↑(seq i).val + have hM : M.Infinite := (Set.infinite_range_of_injective hv.injective).mono (by + rintro _ ⟨i, rfl⟩ + exact Set.mem_iUnion.mpr ⟨i+1, hvmem i⟩) + refine ⟨M, b, hM, fun s hs hcard => ?_⟩ + have hex : ∀ a : s, ∃ i, a.val ∈ (seq i).val := + fun a => Set.mem_iUnion.mp (hs a.property) + choose k hk using hex + let N := Finset.univ.sup k + have hsub : s ⊆ (seq N).val := by + intro a ha + exact hmono (Finset.le_sup (f := k) (Finset.mem_univ ⟨a, ha⟩)) (hk ⟨a, ha⟩) + have hh := (seq N).property s hsub hcard.le + simpa only [hcard, Nat.sub_self, limitColor] using hh + +/-- Relative version for any infinite subset of the natural numbers. -/ +theorem homogeneous_subset (n : ℕ) (c : Finset ℕ → χ) (A : Set ℕ) (hA : A.Infinite) : + ∃ (M : Set ℕ) (b : χ), M ⊆ A ∧ M.Infinite ∧ + ∀ s : Finset ℕ, (↑s : Set ℕ) ⊆ M → s.card = n → c s = b := by + let f : ℕ → ℕ := Nat.nth (· ∈ A) + have hf : StrictMono f := Nat.nth_strictMono hA + obtain ⟨B, b, hB, hb⟩ := homogeneous n (fun s => c (s.image f)) + refine ⟨f '' B, b, ?_, hB.image hf.injective.injOn, ?_⟩ + · rintro _ ⟨i, _, rfl⟩ + exact Nat.nth_mem_of_infinite hA i + · intro s hs hcard + let t := s.preimage f (hf.injective.injOn) + have him : t.image f = s := by + ext a + constructor + · intro ha + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp ha + exact Finset.mem_preimage.mp hi + · intro ha + obtain ⟨i, _, rfl⟩ := hs ha + exact Finset.mem_image.mpr ⟨i, Finset.mem_preimage.mpr ha, rfl⟩ + have hts : (↑t : Set ℕ) ⊆ B := by + intro i hi + have hfi : f i ∈ s := (Finset.mem_preimage.mp hi) + obtain ⟨j, hj, he⟩ := hs hfi + exact hf.injective he ▸ hj + have htcard : t.card = n := by rw [← hcard, ← him, Finset.card_image_of_injective _ hf.injective] + simpa only [him] using hb t hts htcard + +end SeparableQuotient.InfiniteRamsey + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +lemma four_distinct_finset (a b c d : ℕ) (hab : a < b) (hbc : b < c) (hcd : c < d) : + ({a,b,c,d} : Finset ℕ).card = 4 := by + have hac := hab.trans hbc + have hbd := hbc.trans hcd + have had := hac.trans hcd + simp [ne_of_lt hab, ne_of_lt hac, ne_of_lt had, ne_of_lt hbc, ne_of_lt hbd, ne_of_lt hcd] + +/-- Four-hit thinning under the Type I partition estimate. -/ +theorem four_hits_thinning {f : Family} (x : ℕ → Γ →₀ ℝ) (J T : ℕ → ℕ) + (hJT : ∀ i, J i ≤ T i) + (horder : ∀ i j, i < j → T i < J j) + (hs : ∀ i j, i < j → ∀ a ∈ (x i).support, ∀ b ∈ (x j).support, a < b) + (hcoh : ∀ i j, i < j → ∀ a ∈ (x i).support, ∀ b ∈ (x i).support, + rho (min a b) (max a b) ≤ J j) + (M A δ : ℝ) (hM : ∀ i, ‖norming.includeFinite (x i)‖ ≤ M) (hA : 0 ≤ A) (hδ : 0 < δ) + (hlow : ∀ i (e : TypeI f), (∀ j, e.child j ∈ f.norming) → e.weight < J i → + |norming.evaluateArray (norming.includeFinite (x i)) e.value| ≤ A * f.theta e.weight) + (htail : Tendsto (fun i => vectorL1 (x i) * tail (fun j => 1 / (f.m j : ℝ)) (T i+1)) atTop (𝓝 0)) + (hnull : ∀ Q : InfinitePath f, Tendsto (fun i => pathFunctional Q (norming.includeFinite (x i))) atTop (𝓝 0)) + (N : Set ℕ) (hN : N.Infinite) : + ∃ W ⊆ N, W.Infinite ∧ ∀ S : Finset ℕ, (↑S : Set ℕ) ⊆ W → S.card = 4 → + ¬ ∃ P : LegalFinitePath f, ∀ i ∈ S, WindowHit P (x i) (J i) (T i) δ := by + let pos (S : Finset ℕ) : Prop := ∃ P : LegalFinitePath f, ∀ i ∈ S, WindowHit P (x i) (J i) (T i) δ + let color : Finset ℕ → Bool := fun S => decide (pos S) + obtain ⟨W, b, hWN, hW, hhom⟩ := InfiniteRamsey.homogeneous_subset 4 color N hN + have hfalse : b = false := by + by_contra hb + have hb' : b = true := Bool.eq_true_of_not_eq_false hb + let u : ℕ → ℕ := Nat.nth (· ∈ W) + have hu : StrictMono u := Nat.nth_strictMono hW + have humem (i : ℕ) : u i ∈ W := Nat.nth_mem_of_infinite hW i + apply not_all_four_hits (fun i => x (u i)) (fun i => J (u i)) (fun i => T (u i)) + (fun i => hJT (u i)) (fun i j hij => horder _ _ (hu hij)) + (fun i j hij => hs _ _ (hu hij)) (fun i j hij => hcoh _ _ (hu hij)) + M A δ (fun i => hM (u i)) hA hδ (fun i => hlow (u i)) + (htail.comp hu.tendsto_atTop) (fun Q => (hnull Q).comp hu.tendsto_atTop) + intro w v t k hwv hvt htk + let S : Finset ℕ := {u w,u v,u t,u k} + have hc : color S = true := (hhom S (by + intro i hi + simp only [S, Finset.mem_coe, Finset.mem_insert, Finset.mem_singleton] at hi + rcases hi with rfl | rfl | rfl | rfl <;> exact humem _) (four_distinct_finset _ _ _ _ (hu hwv) (hu hvt) (hu htk))).trans hb' + have hp : pos S := of_decide_eq_true hc + obtain ⟨P, hP⟩ := hp + exact ⟨P, hP _ (by simp [S]), hP _ (by simp [S]), hP _ (by simp [S]), hP _ (by simp [S])⟩ + refine ⟨W, hWN, hW, fun S hS hc hp => ?_⟩ + have he : color S = false := (hhom S hS hc).trans hfalse + have hp' : pos S := hp + change decide (pos S) = false at he + rw [decide_eq_true hp'] at he + contradiction + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/RealCoefficients.lean b/lean/OAI/Analysis/SeparableQuotients/RealCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1dec17128059f62ef4c7ca354563b6d5acbd04c --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/RealCoefficients.lean @@ -0,0 +1,126 @@ +import OAI.Analysis.SeparableQuotients.PathLimits + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.RealCoefficients +open Filter +open scoped Topology +universe u v +variable {ι : Type u} [Fintype ι] +variable {Z : Type v} [SeminormedAddCommGroup Z] [NormedSpace ℝ Z] + +/-- Rational coefficients suffice for the closed finite-dimensional ℓq ball. +This uses actual density, not an assumed real Type II operation. -/ +lemma rational_to_real (q : ℝ) (hq : 0 < q) (v : ι → Z) + (h : ∀ c : ι → ℚ, (∑ i, |(c i : ℝ)| ^ q) ≤ 1 → ‖∑ i, (c i : ℝ) • v i‖ ≤ 1) + (c : ι → ℝ) (hc : (∑ i, |c i| ^ q) ≤ 1) : ‖∑ i, c i • v i‖ ≤ 1 := by + let Q : (ι → ℝ) → ℝ := fun c => ∑ i, |c i| ^ q + let F : (ι → ℝ) → Z := fun c => ∑ i, c i • v i + have hQ : Continuous Q := by + apply continuous_finsetSum + intro i _ + exact (Real.continuous_rpow_const hq.le).comp (continuous_apply i).abs + have hF : Continuous F := by + apply continuous_finsetSum + intro i _ + exact (continuous_apply i).smul continuous_const + have hD : DenseRange (fun a : ι → ℚ => fun i => (a i : ℝ)) := + DenseRange.piMap (fun _ => Rat.denseRange_cast) + have hstrict : ∀ a : ι → ℝ, Q a < 1 → ‖F a‖ ≤ 1 := by + intro a ha + have hclosed : IsClosed {a : ι → ℝ | ‖F a‖ ≤ 1} := isClosed_le hF.norm continuous_const + apply closure_minimal (s := {a : ι → ℝ | Q a < 1} ∩ + Set.range (fun a : ι → ℚ => fun i => (a i : ℝ))) (t := {a | ‖F a‖ ≤ 1}) + (by rintro _ ⟨hb, b, rfl⟩; exact h b hb.le) hclosed + exact hD.open_subset_closure_inter (isOpen_lt hQ continuous_const) ha + let t : ℕ → ℝ := fun n => 1 - 1/((n+2 : ℕ) : ℝ) + have ht0 (n : ℕ) : 0 ≤ t n := by + dsimp [t] + have hd : (1 : ℝ) ≤ ((n+2 : ℕ) : ℝ) := by norm_cast; omega + have : 1/((n+2 : ℕ) : ℝ) ≤ 1 := (div_le_one (by positivity)).mpr hd + linarith + have ht1 (n : ℕ) : t n < 1 := by + dsimp [t] + have : 0 < 1/((n+2 : ℕ) : ℝ) := by positivity + linarith + have ht : Tendsto t atTop (𝓝 1) := by + have hz : Tendsto (fun n : ℕ => 1/((n+2 : ℕ) : ℝ)) atTop (𝓝 0) := + (tendsto_add_atTop_iff_nat 2).mpr tendsto_one_div_atTop_nhds_zero_nat + simpa only [sub_zero] using tendsto_const_nhds.sub hz + have hb (n : ℕ) : ‖F (t n • c)‖ ≤ 1 := by + apply hstrict + have he : Q (t n • c) = (t n)^q * Q c := by + dsimp only [Q] + simp only [Pi.smul_apply, smul_eq_mul, abs_mul, abs_of_nonneg (ht0 n), + Real.mul_rpow (ht0 n) (abs_nonneg _), Finset.mul_sum] + rw [he] + exact lt_of_le_of_lt (mul_le_of_le_one_right (Real.rpow_nonneg (ht0 n) _) hc) + (Real.rpow_lt_one (ht0 n) (ht1 n) hq) + have htF : Tendsto (fun n => F (t n • c)) atTop (𝓝 (F c)) := by + have hcT : Tendsto (fun n => t n • c) atTop (𝓝 c) := by + simpa only [one_smul] using ht.smul (tendsto_const_nhds (x := c)) + exact (hF.tendsto c).comp hcT + exact le_of_tendsto htF.norm (Eventually.of_forall hb) + +end SeparableQuotient.RealCoefficients + +namespace SeparableQuotient.RealCoefficients +open scoped Classical +universe u v +variable {ι : Type u} [Fintype ι] +variable {Z : Type v} [SeminormedAddCommGroup Z] [NormedSpace ℝ Z] + +lemma bound_from_unit (q : ℝ) (hq : 0 < q) (v : ι → Z) + (h : ∀ c : ι → ℝ, (∑ i, |c i| ^ q) ≤ 1 → ‖∑ i, c i • v i‖ ≤ 1) + (c : ι → ℝ) : ‖∑ i, c i • v i‖ ≤ (∑ i, |c i| ^ q) ^ (1/q) := by + let z : ℝ := ∑ i, |c i| ^ q + have hz : 0 ≤ z := Finset.sum_nonneg (fun i _ => Real.rpow_nonneg (abs_nonneg _) _) + by_cases hz0 : z = 0 + · have hc0 (i : ι) : c i = 0 := by + have hi : |c i| ^ q ≤ z := Finset.single_le_sum + (fun j _ => Real.rpow_nonneg (abs_nonneg _) _) (Finset.mem_univ i) + rw [hz0] at hi + have he : |c i| ^ q = 0 := le_antisymm hi (Real.rpow_nonneg (abs_nonneg _) _) + exact abs_eq_zero.mp ((Real.rpow_eq_zero (abs_nonneg _) hq.ne').mp he) + rw [show (∑ i, c i • v i) = 0 by simp [hc0], norm_zero] + exact Real.rpow_nonneg hz _ + · let A : ℝ := z ^ (1/q) + have hA : 0 < A := Real.rpow_pos_of_pos (lt_of_le_of_ne hz (Ne.symm hz0)) _ + have hAq : A^q = z := by + rw [← Real.rpow_mul hz, one_div_mul_cancel hq.ne', Real.rpow_one] + have hd : (∑ i, |c i/A| ^ q) = 1 := by + simp only [abs_div, abs_of_pos hA, Real.div_rpow (abs_nonneg _) hA.le, + ← Finset.sum_div, hAq] + exact div_self hz0 + have hb := h (fun i => c i/A) hd.le + have he : (∑ i, c i • v i) = A • (∑ i, (c i/A) • v i) := by + rw [Finset.smul_sum] + apply Finset.sum_congr rfl + intro i _ + rw [smul_smul, mul_div_cancel₀ _ hA.ne'] + rw [he, norm_smul, Real.norm_eq_abs, abs_of_pos hA] + exact mul_le_of_le_one_right hA.le hb + +end SeparableQuotient.RealCoefficients + +namespace SeparableQuotient.RealCoefficients + +def signChoice (x : ℝ) : ℝ := if 0 ≤ x then 1 else -1 + +lemma abs_signChoice (x : ℝ) : |signChoice x| = 1 := by + unfold signChoice + split_ifs <;> norm_num + +lemma signChoice_mul (x : ℝ) : signChoice x * x = |x| := by + unfold signChoice + split_ifs with h + · simp only [one_mul, abs_of_nonneg h] + · simp only [neg_one_mul, abs_of_neg (lt_of_not_ge h)] + +end SeparableQuotient.RealCoefficients + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/SeparableSubspaces.lean b/lean/OAI/Analysis/SeparableQuotients/SeparableSubspaces.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3574361be8288c1f847a8877f02539c056914a3 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/SeparableSubspaces.lean @@ -0,0 +1,144 @@ +import OAI.Analysis.SeparableQuotients.PerturbationOperator + +namespace OAI + +noncomputable section + +namespace SeparableQuotient +open Set Metric TopologicalSpace Module +open scoped Classical Topology + +lemma exists_separable_closed_ID {𝕜 Y : Type*} [RCLike 𝕜] + [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] (hY : ¬ FiniteDimensional 𝕜 Y) : + ∃ F : Submodule 𝕜 Y, IsClosed (F : Set Y) ∧ ¬ FiniteDimensional 𝕜 F ∧ + IsSeparable (F : Set Y) := by + let b := Basis.ofVectorSpace 𝕜 Y + have hi : Infinite (Basis.ofVectorSpaceIndex 𝕜 Y) := by + by_contra h + let : Finite (Basis.ofVectorSpaceIndex 𝕜 Y) := not_infinite_iff_finite.mp h + exact hY (Module.Finite.of_basis b) + let := hi + let f : ℕ → Y := b ∘ (Infinite.natEmbedding (Basis.ofVectorSpaceIndex 𝕜 Y)) + have hf : LinearIndependent 𝕜 f := b.linearIndependent.comp _ (Infinite.natEmbedding _).injective + let F := (Submodule.span 𝕜 (range f)).topologicalClosure + have hm (n : ℕ) : f n ∈ F := Submodule.le_topologicalClosure _ (Submodule.subset_span (mem_range_self n)) + have hfi : LinearIndependent 𝕜 (fun n => (⟨f n,hm n⟩ : F)) := by + exact LinearIndependent.of_comp F.subtype hf + refine ⟨F, Submodule.isClosed_topologicalClosure _, ?_, (countable_range f).isSeparable.span.closure⟩ + intro h + let := h + exact Module.Finite.not_linearIndependent_of_infinite _ hfi + +lemma countable_of_separated_range {ι Y : Type*} [MetricSpace Y] + (f : ι → Y) (hsep : IsSeparable (range f)) (r : ℝ) (hr : 0 < r) + (hd : ∀ i j, i ≠ j → r ≤ dist (f i) (f j)) : Countable ι := by + obtain ⟨t,ht,hcl⟩ := hsep + have he (i : ι) : ∃ y : t, dist (f i) y < r/3 := by + obtain ⟨y,hy,hyi⟩ := Metric.mem_closure_iff.mp (hcl (mem_range_self i)) (r/3) (by positivity) + exact ⟨⟨y,hy⟩,hyi⟩ + choose g hg using he + have hgI : Function.Injective g := by + intro i j hij + by_contra hn + have h := hd i j hn + have ht := dist_triangle (f i) (g i) (f j) + have hi := hg i + have hj := hg j + rw [← hij,dist_comm (f j)] at hj + linarith + let := ht.to_subtype + exact hgI.countable + +end SeparableQuotient + +namespace SeparableQuotient +lemma boolSeq_uncountable : ¬ Countable (ℕ → Bool) := by + intro h + have hm := Cardinal.mk_le_aleph0_iff.mpr h + have he : Cardinal.mk (ℕ → Bool) = Cardinal.continuum := by + simp only [Cardinal.mk_arrow,Cardinal.mk_bool,Cardinal.mk_nat,Cardinal.lift_ofNat, + Cardinal.lift_aleph0,Cardinal.two_power_aleph0] + rw [he] at hm + exact (not_le_of_gt Cardinal.aleph0_lt_continuum) hm +end SeparableQuotient + +namespace SeparableQuotient +open Set TopologicalSpace +lemma quotient_closure_lift {𝕜 D : Type*} [RCLike 𝕜] + [NormedAddCommGroup D] [NormedSpace 𝕜 D] + (Y X : Submodule 𝕜 D) [IsClosed (Y : Set D)] (z : D) + (hz : Y.mkQL z ∈ (X.map Y.mkQ).topologicalClosure) : + z ∈ (X ⊔ Y).topologicalClosure := by + have he := Y.isOpenMap_mkQ.preimage_closure_eq_closure_preimage Y.mkQL.continuous + (X.map Y.mkQ : Set (D ⧸ Y)) + have hp : Y.mkQ ⁻¹' (X.map Y.mkQ : Set (D ⧸ Y)) = (X ⊔ Y : Submodule 𝕜 D) := by + change (Submodule.comap Y.mkQ (X.map Y.mkQ) : Set D) = _ + rw [Submodule.comap_map_eq,Submodule.ker_mkQ] + rw [hp] at he + change z ∈ closure ((X ⊔ Y : Submodule 𝕜 D) : Set D) + rw [← he] + exact hz +end SeparableQuotient + +namespace SeparableQuotient +open Set TopologicalSpace +open scoped Classical +universe u v +variable {X : Type u} {E : Type v} + [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] + [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] + +/-- Transfer the necessary evaluation criterion through the actual predual +isomorphism, retaining a separable closed infinite-dimensional subspace. -/ +lemma separable_restriction_of_quotient + (R : E ≃L[ℝ] StrongDual ℝ X) (J : X →L[ℝ] StrongDual ℝ E) + (hR : ∀ e x, R e x = J x e) (hSQ : HasSeparableQuotient ℝ X) : + ∃ F : Submodule ℝ E, IsClosed (F : Set E) ∧ ¬ FiniteDimensional ℝ F ∧ + IsSeparable (F : Set E) ∧ + IsSeparable (range (fun x : X => (J x).comp F.subtypeL)) := by + obtain ⟨H,hH,hHi,hHe⟩ := separable_evaluation_of_hasSeparableQuotient hSQ + let hNg : NormedAddCommGroup H := inferInstance + let hNs : NormedSpace ℝ H := inferInstance + let : CompleteSpace H := hH.completeSpace_coe + obtain ⟨G,hG,hGi,hGs⟩ := exists_separable_closed_ID (𝕜 := ℝ) (Y := H) hHi + let gNg : NormedAddCommGroup G := inferInstance + let gNs : NormedSpace ℝ G := inferInstance + let : CompleteSpace G := hG.completeSpace_coe + let : SeparableSpace G := hGs.separableSpace + let T : G →L[ℝ] E := R.symm.toContinuousLinearMap.comp (H.subtypeL.comp G.subtypeL) + have hi : Isometry (H.subtypeL.comp G.subtypeL) := fun _ _ => rfl + have hT : ∃ K, AntilipschitzWith K T := by + refine ⟨_,R.symm.antilipschitz.comp hi.antilipschitzWith⟩ + obtain ⟨K,hK⟩ := hT + let F := T.range + let fNg : NormedAddCommGroup F := inferInstance + let fNs : NormedSpace ℝ F := inferInstance + have hFc : IsClosed (F : Set E) := hK.isClosed_range T.uniformContinuous + let e : G ≃L[ℝ] F := T.equivRange hK.injective hFc + have hFi : ¬ FiniteDimensional ℝ F := by + intro hh + let := hh + exact hGi (FiniteDimensional.of_injective e.toLinearMap e.injective) + have hFs : IsSeparable (F : Set E) := isSeparable_range T.continuous + let U : F →L[ℝ] H := G.subtypeL.comp e.symm.toContinuousLinearMap + let A : StrongDual ℝ H →L[ℝ] StrongDual ℝ F := ContinuousLinearMap.precomp ℝ U + have he (x : X) : (J x).comp F.subtypeL = A (subspaceEvaluation H x) := by + ext z + obtain ⟨g,rfl⟩ := e.surjective z + change J x (T g) = ((U (e g) : H) : StrongDual ℝ X) x + have hu : U (e g) = (g : H) := by + change G.subtypeL (e.symm (e g)) = _ + rw [e.symm_apply_apply] + rfl + rw [hu] + change J x (R.symm ((g : H) : StrongDual ℝ X)) = ((g : H) : StrongDual ℝ X) x + rw [← hR,R.apply_symm_apply] + refine ⟨F,hFc,hFi,hFs,(hHe.image A.continuous).mono ?_⟩ + rintro _ ⟨x,rfl⟩ + exact ⟨subspaceEvaluation H x,mem_range_self x,(he x).symm⟩ + +end SeparableQuotient + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/StoppedCharges.lean b/lean/OAI/Analysis/SeparableQuotients/StoppedCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f22203ab266908bcb71456a475d1c04ed82001c --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/StoppedCharges.lean @@ -0,0 +1,350 @@ +import OAI.Analysis.SeparableQuotients.NormingBounds + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +noncomputable def TypeI.stoppedCharge {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + if i ∈ I ∧ e.weight < w.lower i then + (16/(f.m e.weight : ℝ)) * ((TypeI.hitChildren e (w.blocks.vector i)).card : ℝ)^(1/f.r) else 0 + +lemma TypeI.stoppedCharge_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) (i : s) : + 0 ≤ TypeI.stoppedCharge w e s I i := by unfold TypeI.stoppedCharge; split_ifs <;> positivity + +lemma TypeI.total_incidence {f : Family} (e : TypeI f) (z : BlockSequence f) (s : Finset ℕ) : + (∑ i : s, ((TypeI.hitChildren e (z.vector i)).card : ℝ)) ≤ 2*e.length+s.card := by + have hh (i : s) : ((TypeI.hitChildren e (z.vector i)).card : ℝ) ≤ TypeI.boundaryDegree e z i + 1 := by + unfold TypeI.boundaryDegree + split_ifs with h + · linarith + · have : (TypeI.hitChildren e (z.vector i)).card ≤ 1 := by omega + simpa only [zero_add] using (show ((TypeI.hitChildren e (z.vector i)).card : ℝ) ≤ 1 by exact_mod_cast this) + have hs := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hh i) + rw [Finset.sum_add_distrib] at hs + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_coe,nsmul_eq_mul,mul_one] at hs + linarith [TypeI.boundaryDegree_sum e z s] + +lemma TypeI.stoppedCharge_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) + (hs : s.card ≤ f.L J) (hj : J ≤ e.weight) : + ‖vec f.exponent (TypeI.stoppedCharge w e s I)‖ ≤ 48*f.theta e.weight := by + have hsum : (∑ i : s, ((TypeI.hitChildren e (w.blocks.vector i)).card : ℝ)) ≤ 3*(f.L e.weight : ℝ) := by + have hL : (e.length : ℝ) ≤ f.L e.weight := by exact_mod_cast e.length_le + have hc : (s.card : ℝ) ≤ f.L e.weight := by exact_mod_cast hs.trans (FamilyL_mono f hj) + linarith [TypeI.total_incidence e w.blocks s] + have hb := norm_degree_le (by simpa only [Family.exponent_toReal] using f.r_pos : 0 < f.exponent.toReal) + (fun i : s => ((TypeI.hitChildren e (w.blocks.vector i)).card : ℝ)) (16/(f.m e.weight : ℝ)) (3*f.L e.weight) + (by positivity) (by positivity) (fun _ => by positivity) hsum (TypeI.stoppedCharge w e s I) (fun i => by + rw [abs_of_nonneg (TypeI.stoppedCharge_nonneg w e s I i)] + unfold TypeI.stoppedCharge + split_ifs + · simp only [Family.exponent_toReal,le_refl] + · positivity) + have h3 : (3 : ℝ)^(1/f.r) ≤ 3 := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (by norm_num : (1:ℝ) ≤ 3) + ((div_le_one f.r_pos).mpr f.r_gt_one.le) + calc + _ ≤ (16/(f.m e.weight : ℝ)) * (3*(f.L e.weight : ℝ))^(1/f.r) := by simpa only [Family.exponent_toReal] using hb + _ ≤ (16/(f.m e.weight : ℝ)) * (3*(f.L e.weight : ℝ)^(1/f.r)) := by + rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 3) (Nat.cast_nonneg _)] + exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right h3 (by positivity)) (by positivity) + _ = _ := by rw [Family.theta_formula]; ring + +lemma TypeI.stopped_eval_bound {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (A : Crop) + (hm : ∀ h, e.child h ∈ f.norming) (s : Finset ℕ) (I : Finset s) (i : s) + (hi : i ∈ I) (hj : e.weight < w.lower i) : + |norming.evaluateArray (w.blocks.embed i) (restrict (A.set f) e.value)| ≤ + TypeI.stoppedCharge w e s I i := by + have hb := TypeI.cropped_child_sum_bound e A hm (w.blocks.vector i) (f.L (w.lower i)) 16 + (by norm_num) (w.partition i) (e.length_le.trans (FamilyL_mono f hj.le)) + rw [TypeI.eval_crop_sum,abs_mul,abs_of_nonneg (by positivity : 0 ≤ 1/(f.m e.weight : ℝ))] + have hh := (Finset.abs_sum_le_sum_abs _ _).trans hb + have hu := mul_le_mul_of_nonneg_left hh (by positivity : 0 ≤ 1/(f.m e.weight : ℝ)) + simpa only [TypeI.stoppedCharge,hi,hj,and_self,ite_true,BlockSequence.embed,div_mul_eq_mul_div,one_mul,mul_div_assoc] using hu + +lemma Family.sum_theta_tail_le {κ : Type*} (f : Family) (S : Finset κ) (j : κ → ℕ) (J : ℕ) + (hJ : 1 ≤ J) (hp : ∀ g ∈ S, J ≤ j g) (hinj : Set.InjOn j S) : + ∑ g ∈ S, f.theta (j g) ≤ 4*f.theta J := by + have hi : Set.InjOn (fun g => j g-J) S := by + intro g hg h hh he + apply hinj hg hh + have := hp g hg + have := hp h hh + dsimp only at he + omega + have he (g : κ) (hg : g ∈ S) : j g-1 = (J-1)+(j g-J) := by have := hp g hg; omega + have hs : Summable (fun n => Parameters.theta f.s ((J-1)+n)) := + ((Parameters.hasSum_theta f.s_ge_two).summable.comp_injective (fun n m h => by omega)) + calc + _ = ∑ n ∈ S.image (fun g => j g-J), Parameters.theta f.s ((J-1)+n) := by + rw [Finset.sum_image hi] + exact Finset.sum_congr rfl (fun g hg => congrArg (Parameters.theta f.s) (he g hg)) + _ ≤ ∑' n, Parameters.theta f.s ((J-1)+n) := hs.sum_le_tsum _ + (fun n _ => by rw [Parameters.theta_eq f.s_ge_two]; positivity) + _ ≤ _ := Parameters.theta_tail f.s_ge_two (J-1) + +lemma Parameters.B_sum (s n : ℕ) : Parameters.B s n = 2*∑ j ∈ Finset.range n, Parameters.L s j := by + induction n with + | zero => simp only [Parameters.B_zero,Finset.range_zero,Finset.sum_empty,mul_zero] + | succ n ih => rw [Parameters.B_succ,ih,Finset.sum_range_succ]; ring + +lemma Family.sum_low_lengths {κ : Type*} (f : Family) (S : Finset κ) (j : κ → ℕ) (J : ℕ) + (hp : ∀ g ∈ S, 1 ≤ j g) (hlt : ∀ g ∈ S, j g < J) (hinj : Set.InjOn j S) : + 2*(∑ g ∈ S, f.L (j g)) ≤ Parameters.B f.s (J-1) := by + have hi : Set.InjOn (fun g => j g-1) S := by + intro g hg h hh he + apply hinj hg hh + have := hp g hg + have := hp h hh + dsimp only at he + omega + have hsub : S.image (fun g => j g-1) ⊆ Finset.range (J-1) := by + intro n hn + obtain ⟨g,hg,rfl⟩ := Finset.mem_image.mp hn + have := hp g hg + have := hlt g hg + simp only [Finset.mem_range] + omega + rw [Parameters.B_sum] + apply Nat.mul_le_mul_left + rw [show (∑ g ∈ S, f.L (j g)) = ∑ n ∈ S.image (fun g => j g-1), Parameters.L f.s n by rw [Finset.sum_image hi]; rfl] + exact Finset.sum_le_sum_of_subset hsub + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +noncomputable def TypeII.earlyGroups {f : Family} (e : TypeII f) (J : ℕ) : Finset (TypeII.Group e) := + (TypeII.activeGroups e).filter (fun g => TypeII.groupWeight e g < J) + +abbrev TypeII.ChildVectors {f : Family} (e : TypeII f) (s : Finset ℕ) := + (g : TypeII.Group e) → Fin ((e.path g.1).piece g.2).length → s → ℝ + +noncomputable def TypeII.recombineEarly {f : Family} (e : TypeII f) (J : ℕ) (s : Finset ℕ) + (v : TypeII.ChildVectors e s) (i : s) : ℝ := + ∑ g ∈ TypeII.earlyGroups e J, |(e.coefficient g.1 : ℝ)| * + ((1/(f.m (TypeII.groupWeight e g) : ℝ)) * ∑ h, v g h i) + +lemma TypeII.early_lengths_bound {f : Family} (e : TypeII f) (J : ℕ) : + 2*(∑ g ∈ TypeII.earlyGroups e J, ((e.path g.1).piece g.2).length) ≤ Parameters.B f.s (J-1) := by + apply le_trans (Nat.mul_le_mul_left 2 (Finset.sum_le_sum (fun g _ => ((e.path g.1).piece g.2).length_le))) + exact Family.sum_low_lengths f _ (TypeII.groupWeight e) J (fun g _ => ((e.path g.1).piece g.2).weight_pos) + (fun _ hg => (Finset.mem_filter.mp hg).2) ((TypeII.groupWeight_injOn e).mono (Finset.filter_subset _ _)) + +lemma TypeII.early_theta_bound {f : Family} (e : TypeII f) (J : ℕ) : + ∑ g ∈ TypeII.earlyGroups e J, f.theta (TypeII.groupWeight e g) ≤ 1/8 := + Family.sum_theta_le f _ _ (fun g _ => ((e.path g.1).piece g.2).weight_pos) + ((TypeII.groupWeight_injOn e).mono (Finset.filter_subset _ _)) + +lemma TypeII.recombineEarly_nonneg {f : Family} (e : TypeII f) (J : ℕ) (s : Finset ℕ) + (v : TypeII.ChildVectors e s) (hv : ∀ g h i, 0 ≤ v g h i) (i : s) : + 0 ≤ TypeII.recombineEarly e J s v i := by + unfold TypeII.recombineEarly + exact Finset.sum_nonneg (fun g _ => mul_nonneg (abs_nonneg _) (mul_nonneg (by positivity) (Finset.sum_nonneg (fun h _ => hv g h i)))) + +lemma TypeII.recombineEarly_support {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (v : TypeII.ChildVectors e s) + (hv : ∀ g h i, i ∉ TypeI.lowAssign w ((e.path g.1).piece g.2) s I h → v g h i = 0) + (i : s) (hi : i ∉ I) : TypeII.recombineEarly e J s v i = 0 := by + apply Finset.sum_eq_zero + intro g _ + rw [Finset.sum_eq_zero (fun h _ => hv g h i (fun hh => hi (TypeI.lowAssign_subset w _ s I h hh))),mul_zero,mul_zero] + +lemma TypeII.recombineEarly_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (v : TypeII.ChildVectors e s) (K : ℝ) (hK : 0 ≤ K) + (hs : ∀ g h i, i ∉ TypeI.lowAssign w ((e.path g.1).piece g.2) s I h → v g h i = 0) + (hv : ∀ g h, ‖vec f.exponent (v g h)‖ ≤ K) : + ‖vec f.exponent (TypeII.recombineEarly e J s v)‖ ≤ K/8 := by + have hg (g : TypeII.Group e) : ‖vec f.exponent (fun i => |(e.coefficient g.1 : ℝ)| * + ((1/(f.m (TypeII.groupWeight e g) : ℝ))*∑ h, v g h i))‖ ≤ K*f.theta (TypeII.groupWeight e g) := by + change ‖|(e.coefficient g.1 : ℝ)| • vec f.exponent (fun i => (1/(f.m (TypeII.groupWeight e g) : ℝ))*∑ h, v g h i)‖ ≤ _ + rw [norm_smul,Real.norm_eq_abs,abs_abs] + exact ((mul_le_mul_of_nonneg_right (e.coefficient_le_one g.1) (norm_nonneg _)).trans_eq (one_mul _)).trans + (TypeI.recombine_norm w ((e.path g.1).piece g.2) s I (v g) K hK (hs g) (hv g)) + calc + _ ≤ ∑ g ∈ TypeII.earlyGroups e J, ‖vec f.exponent (fun i => |(e.coefficient g.1 : ℝ)| * + ((1/(f.m (TypeII.groupWeight e g) : ℝ))*∑ h, v g h i))‖ := by + unfold TypeII.recombineEarly + rw [vec_sum] + exact norm_sum_le _ _ + _ ≤ ∑ g ∈ TypeII.earlyGroups e J, K*f.theta (TypeII.groupWeight e g) := Finset.sum_le_sum (fun g _ => hg g) + _ = K * ∑ g ∈ TypeII.earlyGroups e J, f.theta (TypeII.groupWeight e g) := (Finset.mul_sum ..).symm + _ ≤ K*(1/8) := mul_le_mul_of_nonneg_left (TypeII.early_theta_bound e J) hK + _ = _ := by ring + +lemma TypeII.recombineEarly_l1 {f : Family} (e : TypeII f) (J : ℕ) (s : Finset ℕ) + (v : TypeII.ChildVectors e s) (K : ℝ) (hK : 0 ≤ K) + (hv : ∀ g h i, 0 ≤ v g h i) (hs : ∀ g h, (∑ i : s, v g h i) ≤ K) : + (∑ i : s, TypeII.recombineEarly e J s v i) ≤ (Parameters.B f.s (J-1) : ℝ)*K := by + have hc (g : TypeII.Group e) : |(e.coefficient g.1 : ℝ)| * (1/(f.m (TypeII.groupWeight e g) : ℝ)) ≤ 1 := by + have hm : (1 : ℝ) ≤ f.m (TypeII.groupWeight e g) := by exact_mod_cast f.m_pos _ + exact (mul_le_mul (e.coefficient_le_one g.1) (one_div_le_one_div_of_le (by norm_num) hm) (by positivity) (by norm_num)).trans_eq (by norm_num) + have hd : (∑ g ∈ TypeII.earlyGroups e J, (((e.path g.1).piece g.2).length : ℝ)) ≤ Parameters.B f.s (J-1) := by + have hh := TypeII.early_lengths_bound e J + exact_mod_cast (show (∑ g ∈ TypeII.earlyGroups e J, ((e.path g.1).piece g.2).length) ≤ Parameters.B f.s (J-1) by omega) + calc + _ = ∑ g ∈ TypeII.earlyGroups e J, (|(e.coefficient g.1 : ℝ)| * (1/(f.m (TypeII.groupWeight e g) : ℝ))) * + ∑ h, ∑ i : s, v g h i := by + unfold TypeII.recombineEarly + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro g _ + simp only [← Finset.mul_sum,← mul_assoc] + congr 1 + exact Finset.sum_comm + _ ≤ ∑ g ∈ TypeII.earlyGroups e J, ∑ h, ∑ i : s, v g h i := by + exact Finset.sum_le_sum (fun g _ => (mul_le_mul_of_nonneg_right (hc g) + (Finset.sum_nonneg (fun h _ => Finset.sum_nonneg (fun i _ => hv g h i)))).trans_eq (one_mul _)) + _ ≤ ∑ g ∈ TypeII.earlyGroups e J, (((e.path g.1).piece g.2).length : ℝ)*K := by + apply Finset.sum_le_sum + intro g _ + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] using Finset.sum_le_sum (s := Finset.univ) (fun h _ => hs g h) + _ = (∑ g ∈ TypeII.earlyGroups e J, (((e.path g.1).piece g.2).length : ℝ))*K := (Finset.sum_mul ..).symm + _ ≤ _ := mul_le_mul_of_nonneg_right hd hK + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +noncomputable def TypeII.lateGroups {f : Family} (e : TypeII f) (J : ℕ) : Finset (TypeII.Group e) := + (TypeII.activeGroups e).filter (fun g => J ≤ TypeII.groupWeight e g) + +noncomputable def TypeII.lateVector {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + ∑ g ∈ TypeII.lateGroups e J, |(e.coefficient g.1 : ℝ)| * TypeI.stoppedCharge w ((e.path g.1).piece g.2) s I i + +noncomputable def TypeII.earlyBoundary {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + ∑ g ∈ TypeII.earlyGroups e J, |(e.coefficient g.1 : ℝ)| * TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I i + +lemma TypeII.lateVector_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (i : s) : + 0 ≤ TypeII.lateVector e w s I i := + Finset.sum_nonneg (fun _ _ => mul_nonneg (abs_nonneg _) (TypeI.stoppedCharge_nonneg ..)) + +lemma TypeII.earlyBoundary_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (i : s) : + 0 ≤ TypeII.earlyBoundary e w s I i := + Finset.sum_nonneg (fun _ _ => mul_nonneg (abs_nonneg _) (TypeI.boundaryCharge_nonneg ..)) + +lemma TypeII.lateVector_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) + (hJ : 1 ≤ J) (hs : s.card ≤ f.L J) : + ‖vec f.exponent (TypeII.lateVector e w s I)‖ ≤ 192*f.theta J := by + have hg (g : TypeII.Group e) (hg : g ∈ TypeII.lateGroups e J) : + ‖vec f.exponent (fun i => |(e.coefficient g.1 : ℝ)| * TypeI.stoppedCharge w ((e.path g.1).piece g.2) s I i)‖ ≤ + 48*f.theta (TypeII.groupWeight e g) := by + change ‖|(e.coefficient g.1 : ℝ)| • vec f.exponent (TypeI.stoppedCharge w ((e.path g.1).piece g.2) s I)‖ ≤ _ + rw [norm_smul,Real.norm_eq_abs,abs_abs] + exact ((mul_le_mul_of_nonneg_right (e.coefficient_le_one g.1) (norm_nonneg _)).trans_eq (one_mul _)).trans + (TypeI.stoppedCharge_norm w _ s I hs (Finset.mem_filter.mp hg).2) + calc + _ ≤ ∑ g ∈ TypeII.lateGroups e J, ‖vec f.exponent (fun i => |(e.coefficient g.1 : ℝ)| * + TypeI.stoppedCharge w ((e.path g.1).piece g.2) s I i)‖ := by + unfold TypeII.lateVector + rw [vec_sum] + exact norm_sum_le _ _ + _ ≤ ∑ g ∈ TypeII.lateGroups e J, 48*f.theta (TypeII.groupWeight e g) := Finset.sum_le_sum hg + _ = 48 * ∑ g ∈ TypeII.lateGroups e J, f.theta (TypeII.groupWeight e g) := (Finset.mul_sum ..).symm + _ ≤ 48*(4*f.theta J) := mul_le_mul_of_nonneg_left (Family.sum_theta_tail_le f _ _ J hJ + (fun _ hg => (Finset.mem_filter.mp hg).2) ((TypeII.groupWeight_injOn e).mono (Finset.filter_subset _ _))) (by norm_num) + _ = _ := by ring + +lemma TypeII.earlyBoundary_l1 {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) : + (∑ i : s, TypeII.earlyBoundary e w s I i) ≤ 16*(Parameters.B f.s (J-1) : ℝ) := by + have hlen : 2*(∑ g ∈ TypeII.earlyGroups e J, (((e.path g.1).piece g.2).length : ℝ)) ≤ Parameters.B f.s (J-1) := + by exact_mod_cast TypeII.early_lengths_bound e J + calc + _ = ∑ g ∈ TypeII.earlyGroups e J, |(e.coefficient g.1 : ℝ)| * ∑ i : s, TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I i := by + unfold TypeII.earlyBoundary + rw [Finset.sum_comm] + simp only [Finset.mul_sum] + _ ≤ ∑ g ∈ TypeII.earlyGroups e J, 32*(((e.path g.1).piece g.2).length : ℝ) := by + apply Finset.sum_le_sum + intro g _ + exact ((mul_le_mul_of_nonneg_right (e.coefficient_le_one g.1) + (Finset.sum_nonneg (fun i _ => TypeI.boundaryCharge_nonneg w _ s I i))).trans_eq (one_mul _)).trans + (TypeI.boundaryCharge_l1 w _ s I) + _ = 32*(∑ g ∈ TypeII.earlyGroups e J, (((e.path g.1).piece g.2).length : ℝ)) := (Finset.mul_sum ..).symm + _ ≤ _ := by linarith + +noncomputable def ThinnedWindows.localSmall {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + (if i ∈ I then 2*ε else 0) + TypeII.lateVector e w s I i + +noncomputable def ThinnedWindows.localLarge {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) + (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + (if i ∈ I then w.markedCharge e hm s i else 0) + TypeII.earlyBoundary e w s I i + +lemma ThinnedWindows.localSmall_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) (s : Finset ℕ) (I : Finset s) (i : s) : + 0 ≤ w.localSmall e s I i := by + apply add_nonneg _ (TypeII.lateVector_nonneg ..) + split_ifs <;> nlinarith [w.epsilon_pos] + +lemma ThinnedWindows.localLarge_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) (i : s) : + 0 ≤ w.localLarge e hm s I i := by + apply add_nonneg _ (TypeII.earlyBoundary_nonneg ..) + split_ifs + · exact w.markedCharge_nonneg e hm s i + · exact le_rfl + +lemma ThinnedWindows.localSmall_support {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) (s : Finset ℕ) (I : Finset s) (i : s) (hi : i ∉ I) : + w.localSmall e s I i = 0 := by + simp only [ThinnedWindows.localSmall,hi,ite_false,zero_add,TypeII.lateVector,TypeI.stoppedCharge,false_and] + simp + +lemma ThinnedWindows.localLarge_support {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) (i : s) (hi : i ∉ I) : + w.localLarge e hm s I i = 0 := by + simp only [ThinnedWindows.localLarge,hi,ite_false,zero_add,TypeII.earlyBoundary,TypeI.boundaryCharge,false_and] + simp + +lemma ThinnedWindows.localSmall_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) (s : Finset ℕ) (I : Finset s) + (hJ : 1 ≤ J) (hs : s.card ≤ f.L J) (hε : ε*(s.card : ℝ)^(1/f.r) ≤ f.theta J) : + ‖vec f.exponent (w.localSmall e s I)‖ ≤ 194*f.theta J := by + change ‖vec f.exponent (fun i : s => if i ∈ I then 2*ε else 0) + vec f.exponent (TypeII.lateVector e w s I)‖ ≤ _ + have hh := norm_add_le (vec f.exponent (fun i : s => if i ∈ I then 2*ε else 0)) (vec f.exponent (TypeII.lateVector e w s I)) + linarith [w.epsilonVector_norm s I,TypeII.lateVector_norm e w s I hJ hs] + +lemma ThinnedWindows.localLarge_l1 {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) : + (∑ i : s, w.localLarge e hm s I i) ≤ 16*(1+(Parameters.B f.s (J-1) : ℝ)+(s.card : ℝ)^(1-1/f.q)) := by + have hM : (∑ i : s, if i ∈ I then w.markedCharge e hm s i else 0) ≤ ∑ i : s, w.markedCharge e hm s i := by + apply Finset.sum_le_sum + intro i _ + split_ifs + · exact le_rfl + · exact w.markedCharge_nonneg e hm s i + have hh := (w.marked_vector_bounds e hm s).2 + have hB := TypeII.earlyBoundary_l1 e w s I + simp only [ThinnedWindows.localLarge,Finset.sum_add_distrib] + linarith + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/StrictSingularity.lean b/lean/OAI/Analysis/SeparableQuotients/StrictSingularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..af6f225d0299d1c530bcc6832d4493b300f83b72 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/StrictSingularity.lean @@ -0,0 +1,456 @@ +import OAI.Analysis.SeparableQuotients.BranchPaths + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.Singular +open Set Metric +open scoped Classical Topology +variable {𝕜 : Type*} [RCLike 𝕜] +variable {Y Z : Type*} [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] + [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] + +/-- A strictly singular operator is not bounded below on any closed infinite-dimensional subspace. -/ +def StrictlySingular (T : Y →L[𝕜] Z) : Prop := + ∀ M : Submodule 𝕜 Y, IsClosed (M : Set Y) → ¬ FiniteDimensional 𝕜 M → + ∀ c : ℝ, 0 < c → ∃ x : M, ‖T x‖ < c*‖x‖ + +lemma finiteDimensional_of_ker [FiniteDimensional 𝕜 Z] (T : Y →ₗ[𝕜] Z) + [FiniteDimensional 𝕜 T.ker] : FiniteDimensional 𝕜 Y := by + have h : FiniteDimensional 𝕜 (Submodule.comap T (⊤ : Submodule 𝕜 Z)) := inferInstance + rw [Submodule.comap_top] at h + exact FiniteDimensional.of_injective (Submodule.topEquiv : (⊤ : Submodule 𝕜 Y) ≃ₗ[𝕜] Y).symm.toLinearMap + (Submodule.topEquiv.symm.injective) + +lemma exists_finite_vector_normers (F : Submodule 𝕜 Y) [FiniteDimensional 𝕜 F] : + ∃ D : Finset (StrongDual 𝕜 Y), (∀ d ∈ D, ‖d‖ ≤ 1) ∧ + ∀ v : F, ∃ d ∈ D, ‖v‖ ≤ 2*‖d v‖ := by + let U (d : closedBall (0 : StrongDual 𝕜 Y) 1) : Set F := {v | (1/2 : ℝ) < ‖d.1 v‖} + have hU : ∀ d, IsOpen (U d) := fun d => + isOpen_lt continuous_const ((d.1.comp F.subtypeL).continuous.norm) + have hc : sphere (0 : F) 1 ⊆ ⋃ d, U d := by + intro v hv + have hn : ‖v‖ = 1 := by simpa only [mem_sphere,dist_zero_right] using hv + obtain ⟨d,hd,he⟩ := exists_dual_vector'' 𝕜 (v : Y) + refine Set.mem_iUnion.mpr ⟨⟨d,by simpa only [mem_closedBall,dist_zero_right] using hd⟩,?_⟩ + change (1/2 : ℝ) < ‖d v‖ + rw [he,RCLike.norm_ofReal,abs_of_nonneg (norm_nonneg _)] + change (1/2 : ℝ) < ‖v‖ + rw [hn]; norm_num + obtain ⟨t,ht⟩ := (isCompact_sphere (0 : F) 1).elim_finite_subcover U hU hc + refine ⟨insert 0 (t.image Subtype.val),?_,?_⟩ + · intro d hd + rcases Finset.mem_insert.mp hd with rfl | hd + · simp + · obtain ⟨d,_,rfl⟩ := Finset.mem_image.mp hd + simpa only [mem_closedBall,dist_zero_right] using d.property + · intro v + by_cases hv : v = 0 + · subst v; exact ⟨0,Finset.mem_insert_self _ _,by simp⟩ + have hp : 0 < ‖v‖ := norm_pos_iff.mpr hv + let w : F := (↑‖v‖ : 𝕜)⁻¹ • v + have hw : w ∈ sphere (0 : F) 1 := by + simp only [w,mem_sphere,dist_zero_right,norm_smul,norm_inv,RCLike.norm_ofReal, + abs_of_nonneg (norm_nonneg v),inv_mul_cancel₀ hp.ne'] + obtain ⟨d,hd,he⟩ := Set.mem_iUnion₂.mp (ht hw) + refine ⟨d,Finset.mem_insert_of_mem (Finset.mem_image.mpr ⟨d,hd,rfl⟩),?_⟩ + change (1/2 : ℝ) < ‖d.1 ((↑‖v‖ : 𝕜)⁻¹ • (v : Y))‖ at he + rw [map_smul,norm_smul,norm_inv,RCLike.norm_ofReal,abs_of_nonneg (norm_nonneg v)] at he + have hm := mul_lt_mul_of_pos_left he hp + rw [← mul_assoc,mul_inv_cancel₀ hp.ne',one_mul] at hm + linarith + +/-- Finitely many exact annihilation conditions preserve infinite dimension. -/ +lemma finite_annihilator (M : Submodule 𝕜 Y) (hM : IsClosed (M : Set Y)) + (hI : ¬ FiniteDimensional 𝕜 M) (D : Finset (StrongDual 𝕜 Y)) : + ∃ N : Submodule 𝕜 Y, N ≤ M ∧ IsClosed (N : Set Y) ∧ ¬ FiniteDimensional 𝕜 N ∧ + ∀ x ∈ N, ∀ d ∈ D, d x = 0 := by + let A : Y →L[𝕜] (D → 𝕜) := ContinuousLinearMap.pi (fun d => d.1) + let N := M ⊓ A.ker + refine ⟨N,inf_le_left,hM.inter A.isClosed_ker,?_,?_⟩ + · intro hn + let : FiniteDimensional 𝕜 N := hn + let B := A.comp M.subtypeL + have hker : FiniteDimensional 𝕜 B.ker := by + let L : B.ker →ₗ[𝕜] N := { + toFun := fun x => ⟨x.1.1,⟨x.1.2,x.2⟩⟩ + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + exact FiniteDimensional.of_injective L (fun _ _ h => Subtype.ext (Subtype.ext (congrArg (fun y : N => (y : Y)) h))) + exact hI (finiteDimensional_of_ker B.toLinearMap) + · intro x hx d hd + have he : A x = 0 := hx.2 + exact congrFun he ⟨d,hd⟩ + +lemma StrictlySingular.exists_unit_small (T : Y →L[𝕜] Z) (hT : StrictlySingular T) + (M : Submodule 𝕜 Y) (hM : IsClosed (M : Set Y)) (hI : ¬ FiniteDimensional 𝕜 M) + (ε : ℝ) (hε : 0 < ε) : ∃ x : M, ‖x‖ = 1 ∧ ‖T x‖ < ε := by + obtain ⟨x,hx⟩ := hT M hM hI ε hε + have hx0 : 0 < ‖x‖ := by + by_contra hh + have hz : ‖x‖ = 0 := le_antisymm (le_of_not_gt hh) (norm_nonneg _) + rw [hz,mul_zero] at hx + exact (not_lt_of_ge (norm_nonneg _)) hx + refine ⟨(↑‖x‖ : 𝕜)⁻¹ • x,?_,?_⟩ + · simp only [norm_smul,norm_inv,RCLike.norm_ofReal,abs_of_nonneg (norm_nonneg _),inv_mul_cancel₀ hx0.ne'] + · change ‖T ((↑‖x‖ : 𝕜)⁻¹ • (x : Y))‖ < ε + rw [map_smul,norm_smul,norm_inv,RCLike.norm_ofReal,abs_of_nonneg (norm_nonneg _)] + exact (inv_mul_lt_iff₀ hx0).mpr (by nlinarith [hx]) + +end SeparableQuotient.Singular + +namespace SeparableQuotient.Singular +open Set Metric Filter +open scoped Classical Topology +variable {𝕜 : Type*} [RCLike 𝕜] +variable {Y Z : Type*} [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] + [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] + +structure VectorNormers (u : ℕ → Y) where + D : ℕ → Finset (StrongDual 𝕜 Y) + unit : ∀ m, ∀ d ∈ D m, ‖d‖ ≤ 1 + norming : ∀ m, ∀ c : ℕ → 𝕜, ∃ d ∈ D m, + ‖∑ i ∈ Finset.range m, c i • u i‖ ≤ 2 * ‖d (∑ i ∈ Finset.range m, c i • u i)‖ + vanish : ∀ m n, m ≤ n → ∀ d ∈ D m, d (u n) = 0 + +namespace VectorNormers +variable {u : ℕ → Y} (H : VectorNormers (𝕜 := 𝕜) u) +lemma prefix_eval (c : ℕ → 𝕜) {m N : ℕ} (hm : m ≤ N) {d : StrongDual 𝕜 Y} (hd : d ∈ H.D m) : + d (∑ i ∈ Finset.range N, c i • u i) = d (∑ i ∈ Finset.range m, c i • u i) := by + simp only [map_sum,map_smul] + symm + apply Finset.sum_subset (Finset.range_mono hm) + intro i _ hi + rw [H.vanish m i (by simpa using hi) d hd,smul_zero] + +include H in +lemma prefix_bound (c : ℕ → 𝕜) {m N : ℕ} (hm : m ≤ N) : + ‖∑ i ∈ Finset.range m, c i • u i‖ ≤ 2*‖∑ i ∈ Finset.range N, c i • u i‖ := by + obtain ⟨d,hd,hb⟩ := H.norming m c + rw [← H.prefix_eval c hm hd] at hb + exact hb.trans (mul_le_mul_of_nonneg_left ((d.le_opNorm _).trans + (by simpa only [one_mul] using mul_le_mul_of_nonneg_right (H.unit m d hd) (norm_nonneg _))) (by norm_num)) + +include H in +lemma coefficient_bound (hu : ∀ n, ‖u n‖ = 1) (c : ℕ → 𝕜) {n N : ℕ} (hn : n < N) : + ‖c n‖ ≤ 4*‖∑ i ∈ Finset.range N, c i • u i‖ := by + have hp := H.prefix_bound c (Nat.succ_le_of_lt hn) + have hq := H.prefix_bound c hn.le + have he : c n • u n = (∑ i ∈ Finset.range (n+1), c i • u i) - (∑ i ∈ Finset.range n, c i • u i) := by + rw [Finset.sum_range_succ,add_sub_cancel_left] + have hh := norm_sub_le (∑ i ∈ Finset.range (n+1), c i • u i) (∑ i ∈ Finset.range n, c i • u i) + rw [← he,norm_smul,hu,mul_one] at hh + linarith + +lemma linearCombination_eq_range (c : ℕ →₀ 𝕜) {N : ℕ} (hN : c.support ⊆ Finset.range N) : + Finsupp.linearCombination 𝕜 u c = ∑ i ∈ Finset.range N, c i • u i := by + change (∑ i ∈ c.support, c i • u i) = _ + apply Finset.sum_subset hN + intro i _ hi + rw [Finsupp.notMem_support_iff.mp hi,zero_smul] + +include H in +lemma finsupp_bound (hu : ∀ n, ‖u n‖ = 1) (c : ℕ →₀ 𝕜) (n : ℕ) : + ‖c n‖ ≤ 4*‖Finsupp.linearCombination 𝕜 u c‖ := by + obtain ⟨N,hN⟩ := (insert n c.support).exists_nat_subset_range + rw [linearCombination_eq_range c (fun i hi => hN (Finset.mem_insert_of_mem hi))] + exact H.coefficient_bound hu c (Finset.mem_range.mp (hN (Finset.mem_insert_self _ _))) + +include H in +lemma linearIndependent (hu : ∀ n, ‖u n‖ = 1) : LinearIndependent 𝕜 u := by + rw [linearIndependent_iff] + intro c hc + ext n + have hb := H.finsupp_bound hu c n + rw [hc,norm_zero,mul_zero] at hb + exact norm_eq_zero.mp (le_antisymm hb (norm_nonneg _)) +end VectorNormers + +namespace SmallRestriction + +def listSpan (l : List Y) : Submodule 𝕜 Y := Submodule.span 𝕜 (l.toFinset : Set Y) +instance (l : List Y) : FiniteDimensional 𝕜 (listSpan (𝕜 := 𝕜) l) := FiniteDimensional.span_finset 𝕜 _ + +def listNormers (l : List Y) : Finset (StrongDual 𝕜 Y) := + (exists_finite_vector_normers (listSpan (𝕜 := 𝕜) l)).choose +lemma listNormers_spec (l : List Y) : (∀ d ∈ listNormers (𝕜 := 𝕜) l, ‖d‖ ≤ 1) ∧ + ∀ x ∈ listSpan (𝕜 := 𝕜) l, ∃ d ∈ listNormers (𝕜 := 𝕜) l, ‖x‖ ≤ 2*‖d x‖ := by + have hh := (exists_finite_vector_normers (listSpan (𝕜 := 𝕜) l)).choose_spec + exact ⟨hh.1,fun x hx => hh.2 ⟨x,hx⟩⟩ + +structure State (𝕜 Y : Type*) [RCLike 𝕜] [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] where + vectors : List Y + normers : Finset (StrongDual 𝕜 Y) + +variable (T : Y →L[𝕜] Z) (hT : StrictlySingular T) + (M : Submodule 𝕜 Y) (hM : IsClosed (M : Set Y)) (hI : ¬ FiniteDimensional 𝕜 M) + (ε : ℝ) (hε : 0 < ε) + +include hT hM hI hε in +lemma exists_next (s : State 𝕜 Y) : ∃ y : Y, y ∈ M ∧ ‖y‖ = 1 ∧ + ‖T y‖ < ε*(1/2 : ℝ)^(s.vectors.length+3) ∧ ∀ d ∈ s.normers, d y = 0 := by + obtain ⟨N,hNM,hNc,hNi,hNd⟩ := finite_annihilator M hM hI s.normers + obtain ⟨y,hy,hTy⟩ := StrictlySingular.exists_unit_small T hT N hNc hNi + (ε*(1/2 : ℝ)^(s.vectors.length+3)) (by positivity) + exact ⟨y,hNM y.property,hy,hTy,hNd y y.property⟩ + +def nextVector (s : State 𝕜 Y) : Y := (exists_next T hT M hM hI ε hε s).choose +lemma nextVector_spec (s : State 𝕜 Y) : nextVector T hT M hM hI ε hε s ∈ M ∧ + ‖nextVector T hT M hM hI ε hε s‖ = 1 ∧ + ‖T (nextVector T hT M hM hI ε hε s)‖ < ε*(1/2 : ℝ)^(s.vectors.length+3) ∧ + ∀ d ∈ s.normers, d (nextVector T hT M hM hI ε hε s) = 0 := + (exists_next T hT M hM hI ε hε s).choose_spec + +def step (s : State 𝕜 Y) : State 𝕜 Y := + let l := s.vectors ++ [nextVector T hT M hM hI ε hε s] + ⟨l,s.normers ∪ listNormers l⟩ + +def state : ℕ → State 𝕜 Y + | 0 => ⟨[],listNormers []⟩ + | n+1 => step T hT M hM hI ε hε (state n) + +def seq (n : ℕ) : Y := nextVector T hT M hM hI ε hε (state T hT M hM hI ε hε n) + +local notation "s" => state T hT M hM hI ε hε +local notation "u" => seq T hT M hM hI ε hε +lemma vectors_state (n : ℕ) : (s n).vectors = List.ofFn (fun i : Fin n => u i) := by + induction n with + | zero => simp [state] + | succ n ih => + change (s n).vectors ++ [u n] = _ + rw [ih,List.ofFn_succ_last (f := fun i : Fin (n+1) => u i)] + rfl + +lemma state_length (n : ℕ) : (s n).vectors.length = n := by rw [vectors_state,List.length_ofFn] +lemma seq_spec (n : ℕ) : u n ∈ M ∧ ‖u n‖ = 1 ∧ ‖T (u n)‖ < ε*(1/2 : ℝ)^(n+3) := by + have hh := nextVector_spec T hT M hM hI ε hε (s n) + rw [state_length] at hh + exact ⟨hh.1,hh.2.1,hh.2.2.1⟩ + +lemma normers_mono : Monotone (fun n => (s n).normers) := by + apply monotone_nat_of_le_succ + intro n + exact Finset.subset_union_left + +lemma normers_unit (n : ℕ) : ∀ d ∈ (s n).normers, ‖d‖ ≤ 1 := by + induction n with + | zero => exact (listNormers_spec []).1 + | succ n ih => + intro d hd + rcases Finset.mem_union.mp hd with hd | hd + · exact ih d hd + · exact (listNormers_spec _).1 d hd + +lemma listNormers_subset (n : ℕ) : listNormers (s n).vectors ⊆ (s n).normers := by + cases n with + | zero => exact le_rfl + | succ n => exact Finset.subset_union_right + +def normers : VectorNormers (𝕜 := 𝕜) u where + D := fun n => (s n).normers + unit := normers_unit T hT M hM hI ε hε + norming := by + intro m c + have hx : (∑ i ∈ Finset.range m, c i • u i) ∈ listSpan (𝕜 := 𝕜) (s m).vectors := by + apply Submodule.sum_mem + intro i hi + apply Submodule.smul_mem + apply Submodule.subset_span + rw [Finset.mem_coe,List.mem_toFinset,vectors_state] + exact List.mem_ofFn.mpr ⟨⟨i,Finset.mem_range.mp hi⟩,rfl⟩ + obtain ⟨d,hd,hb⟩ := (listNormers_spec (s m).vectors).2 _ hx + exact ⟨d,listNormers_subset T hT M hM hI ε hε m hd,hb⟩ + vanish := by + intro m n hmn d hd + exact (nextVector_spec T hT M hM hI ε hε (s n)).2.2.2 d + (normers_mono T hT M hM hI ε hε hmn hd) + +end SmallRestriction +end SeparableQuotient.Singular + +namespace SeparableQuotient.Singular +open Set Metric Filter +open scoped Classical Topology +variable {𝕜 : Type*} [RCLike 𝕜] +variable {Y Z : Type*} [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] + [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] + +lemma VectorNormers.norm_small {u : ℕ → Y} (H : VectorNormers (𝕜 := 𝕜) u) + (hu : ∀ n, ‖u n‖ = 1) (T : Y →L[𝕜] Z) (ε : ℝ) (hε : 0 ≤ ε) + (hT : ∀ n, ‖T (u n)‖ ≤ ε*(1/2 : ℝ)^(n+3)) (c : ℕ →₀ 𝕜) : + ‖T (Finsupp.linearCombination 𝕜 u c)‖ ≤ ε*‖Finsupp.linearCombination 𝕜 u c‖ := by + let x := Finsupp.linearCombination 𝕜 u c + have hc (n : ℕ) := H.finsupp_bound hu c n + have hgeo : (∑ i ∈ c.support, (1/2 : ℝ)^i) ≤ 2 := by + simpa only [tsum_geometric_two] using summable_geometric_two.sum_le_tsum c.support (fun i _ => by positivity) + calc + ‖T x‖ ≤ ∑ i ∈ c.support, ‖c i‖*‖T (u i)‖ := by + change ‖T (∑ i ∈ c.support, c i • u i)‖ ≤ _ + rw [map_sum] + simpa only [map_smul,norm_smul] using norm_sum_le c.support (fun i => T (c i • u i)) + _ ≤ ∑ i ∈ c.support, (4*‖x‖)*(ε*(1/2 : ℝ)^(i+3)) := by + apply Finset.sum_le_sum + intro i _ + exact mul_le_mul (hc i) (hT i) (norm_nonneg _) (by positivity) + _ = (4*‖x‖*ε*(1/2 : ℝ)^3)*(∑ i ∈ c.support, (1/2 : ℝ)^i) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + rw [pow_add]; ring + _ ≤ (4*‖x‖*ε*(1/2 : ℝ)^3)*2 := mul_le_mul_of_nonneg_left hgeo (by positivity) + _ = ε*‖x‖ := by ring + +/-- A strictly singular operator has arbitrarily small norm on a closed infinite-dimensional subspace. -/ +theorem StrictlySingular.exists_small_restriction (T : Y →L[𝕜] Z) (hT : StrictlySingular T) + (M : Submodule 𝕜 Y) (hM : IsClosed (M : Set Y)) (hI : ¬ FiniteDimensional 𝕜 M) + (ε : ℝ) (hε : 0 < ε) : + ∃ N : Submodule 𝕜 Y, N ≤ M ∧ IsClosed (N : Set Y) ∧ ¬ FiniteDimensional 𝕜 N ∧ + ∀ x ∈ N, ‖T x‖ ≤ ε*‖x‖ := by + let u := SmallRestriction.seq T hT M hM hI ε hε + have hu (n : ℕ) := SmallRestriction.seq_spec T hT M hM hI ε hε n + let H := SmallRestriction.normers T hT M hM hI ε hε + let A := Submodule.span 𝕜 (Set.range u) + let N := A.topologicalClosure + have hAM : A ≤ M := Submodule.span_le.mpr (by rintro _ ⟨n,rfl⟩; exact (hu n).1) + refine ⟨N,closure_minimal hAM hM,Submodule.isClosed_topologicalClosure _,?_,?_⟩ + · intro hn + let : FiniteDimensional 𝕜 N := hn + let v (n : ℕ) : N := ⟨u n,Submodule.le_topologicalClosure _ (Submodule.subset_span (Set.mem_range_self n))⟩ + have hv : LinearIndependent 𝕜 v := LinearIndependent.of_comp N.subtype + (H.linearIndependent (fun n => (hu n).2.1)) + exact Module.Finite.not_linearIndependent_of_infinite v hv + · have hc : IsClosed {x : Y | ‖T x‖ ≤ ε*‖x‖} := + isClosed_le T.continuous.norm (continuous_const.mul continuous_norm) + apply closure_minimal _ hc + intro x hx + obtain ⟨c,rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp hx + exact H.norm_small (fun n => (hu n).2.1) T ε hε.le (fun n => (hu n).2.2.le) c + +/-- Finitely many strictly singular operators admit a common closed +infinite-dimensional small restriction, including the original ambient subspace. -/ +theorem exists_small_restriction_finite (D : Finset (Y →L[𝕜] Z)) + (hD : ∀ T ∈ D, StrictlySingular T) + (M : Submodule 𝕜 Y) (hM : IsClosed (M : Set Y)) (hI : ¬ FiniteDimensional 𝕜 M) + (ε : ℝ) (hε : 0 < ε) : + ∃ N : Submodule 𝕜 Y, N ≤ M ∧ IsClosed (N : Set Y) ∧ ¬ FiniteDimensional 𝕜 N ∧ + ∀ T ∈ D, ∀ x ∈ N, ‖T x‖ ≤ ε*‖x‖ := by + induction D using Finset.induction_on generalizing M with + | empty => exact ⟨M,le_rfl,hM,hI,by simp⟩ + | @insert T D hTD ih => + obtain ⟨N,hNM,hNc,hNi,hNd⟩ := ih (fun S hS => hD S (Finset.mem_insert_of_mem hS)) M hM hI + obtain ⟨N',hN'N,hN'c,hN'i,hN'T⟩ := StrictlySingular.exists_small_restriction T + (hD T (Finset.mem_insert_self _ _)) N hNc hNi ε hε + refine ⟨N',hN'N.trans hNM,hN'c,hN'i,?_⟩ + intro S hS x hx + rcases Finset.mem_insert.mp hS with rfl | hS + · exact hN'T x hx + · exact hNd S hS x (hN'N hx) + +end SeparableQuotient.Singular + +namespace SeparableQuotient.Singular +open Set Metric +open scoped Classical Topology +variable {𝕜 : Type*} [RCLike 𝕜] +variable {X Y Z W : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] + [NormedAddCommGroup Y] [NormedSpace 𝕜 Y] + [NormedAddCommGroup Z] [NormedSpace 𝕜 Z] + [NormedAddCommGroup W] [NormedSpace 𝕜 W] + +lemma not_strictlySingular_iff (T : Y →L[𝕜] Z) : + ¬ StrictlySingular T ↔ ∃ (M : Submodule 𝕜 Y), IsClosed (M : Set Y) ∧ + ¬ FiniteDimensional 𝕜 M ∧ ∃ c : ℝ, 0 < c ∧ ∀ x : M, c*‖x‖ ≤ ‖T x‖ := by + simp only [StrictlySingular, not_forall, not_exists, not_lt, exists_prop] + +lemma lowerBound_antilipschitz (T : Y →L[𝕜] Z) (c : ℝ) (hc : 0 < c) + (h : ∀ x, c*‖x‖ ≤ ‖T x‖) : AntilipschitzWith ⟨c⁻¹,inv_nonneg.mpr hc.le⟩ T := by + apply T.antilipschitz_of_bound + intro x + change ‖x‖ ≤ c⁻¹*‖T x‖ + exact (le_inv_mul_iff₀ hc).mpr (by simpa [mul_comm] using h x) + +lemma lowerBound_isClosed_range [CompleteSpace Y] (T : Y →L[𝕜] Z) (c : ℝ) (hc : 0 < c) + (h : ∀ x, c*‖x‖ ≤ ‖T x‖) : IsClosed (Set.range T) := + (lowerBound_antilipschitz T c hc h).isClosed_range T.uniformContinuous + +/-- A non-strictly-singular map furnishes a closed infinite-dimensional image +and a bounded lift into its original domain. -/ +theorem exists_lift_of_not_strictlySingular [CompleteSpace Y] [CompleteSpace Z] (T : Y →L[𝕜] Z) + (hT : ¬ StrictlySingular T) : + ∃ (H : Submodule 𝕜 Z), IsClosed (H : Set Z) ∧ ¬ FiniteDimensional 𝕜 H ∧ + ∃ U : H →L[𝕜] Y, ∀ x : H, T (U x) = x := by + obtain ⟨M,hM,hI,c,hc,h⟩ := (not_strictlySingular_iff T).mp hT + let : CompleteSpace M := hM.completeSpace_coe + let A := T.comp M.subtypeL + let e := A.equivRange (lowerBound_antilipschitz A c hc h).injective + (lowerBound_isClosed_range A c hc h) + refine ⟨A.range,lowerBound_isClosed_range A c hc h,?_,M.subtypeL.comp e.symm.toContinuousLinearMap,?_⟩ + · intro hF + let : FiniteDimensional 𝕜 A.range := hF + exact hI (FiniteDimensional.of_injective e.toLinearMap e.injective) + · intro x + exact congrArg (fun x : A.range => (x : Z)) (e.apply_symm_apply x) + +lemma StrictlySingular.comp_left (T : Y →L[𝕜] Z) (hT : StrictlySingular T) + (S : Z →L[𝕜] W) : StrictlySingular (S.comp T) := by + intro M hM hI c hc + obtain ⟨x,hx⟩ := hT M hM hI (c/(‖S‖+1)) (div_pos hc (by positivity)) + refine ⟨x,?_⟩ + have hp : 0 < ‖x‖ := by + by_contra hh + have hz := le_antisymm (le_of_not_gt hh) (norm_nonneg x) + rw [hz,mul_zero] at hx + exact (not_lt_of_ge (norm_nonneg _)) hx + have hn := S.le_opNorm (T x) + change ‖S (T x)‖ < _ + have hs : ‖S‖/(‖S‖+1) < 1 := (div_lt_one (by positivity)).mpr (by linarith) + calc + _ ≤ ‖S‖*‖T x‖ := hn + _ ≤ ‖S‖*((c/(‖S‖+1))*‖x‖) := mul_le_mul_of_nonneg_left hx.le (norm_nonneg _) + _ = (‖S‖/(‖S‖+1))*(c*‖x‖) := by ring + _ < 1*(c*‖x‖) := mul_lt_mul_of_pos_right hs (mul_pos hc hp) + _ = _ := one_mul _ + +lemma StrictlySingular.comp_right [CompleteSpace X] [CompleteSpace Y] + (T : Y →L[𝕜] Z) (hT : StrictlySingular T) (R : X →L[𝕜] Y) : + StrictlySingular (T.comp R) := by + by_contra hTR + obtain ⟨M,hM,hI,c,hc,h⟩ := (not_strictlySingular_iff _).mp hTR + let : CompleteSpace M := hM.completeSpace_coe + let A := R.comp M.subtypeL + have ha : ∀ x : M, (c/(‖T‖+1))*‖x‖ ≤ ‖A x‖ := by + intro x + have ht := T.le_opNorm (R x) + have hh := h x + change c*‖x‖ ≤ ‖T (R x)‖ at hh + change (c/(‖T‖+1))*‖x‖ ≤ ‖R x‖ + rw [div_mul_eq_mul_div,div_le_iff₀ (by positivity : 0 < ‖T‖+1)] + nlinarith [norm_nonneg (R x)] + have hap : 0 < c/(‖T‖+1) := div_pos hc (by positivity) + let e := A.equivRange (lowerBound_antilipschitz A _ hap ha).injective + (lowerBound_isClosed_range A _ hap ha) + have hAi : ¬ FiniteDimensional 𝕜 A.range := by + intro hF + let : FiniteDimensional 𝕜 A.range := hF + exact hI (FiniteDimensional.of_injective e.toLinearMap e.injective) + obtain ⟨y,hy⟩ := hT A.range (lowerBound_isClosed_range A _ hap ha) hAi + (c/(‖R‖+1)) (div_pos hc (by positivity)) + obtain ⟨x,hx⟩ := y.property + have hr := R.le_opNorm (x : X) + have hh := h x + have hxy : (y : Y) = R x := hx.symm + change ‖T (y : Y)‖ < (c/(‖R‖+1))*‖(y : Y)‖ at hy + rw [hxy] at hy + change c*‖x‖ ≤ ‖T (R x)‖ at hh + have hd : (c/(‖R‖+1))*‖R x‖ ≤ c*‖x‖ := by + rw [div_mul_eq_mul_div,div_le_iff₀ (by positivity : 0 < ‖R‖+1)] + change ‖R (x : X)‖ ≤ ‖R‖*‖x‖ at hr + nlinarith [norm_nonneg x] + exact (not_lt_of_ge hh) (hy.trans_le hd) + +end SeparableQuotient.Singular + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/TailBlocks.lean b/lean/OAI/Analysis/SeparableQuotients/TailBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..db8d28149f501fba32a0d64c65ea388c5459f991 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/TailBlocks.lean @@ -0,0 +1,338 @@ +import OAI.Analysis.SeparableQuotients.BlockEstimates + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction Filter +open scoped Classical Topology + +lemma BlockSequence.support_mem_tail {f : Family} (z : BlockSequence f) (a : ℕ) + {x : Γ →₀ ℝ} (hx : x ∈ z.tailSpan a) {α : Γ} (hα : α ∈ x.support) : + ∃ n, a ≤ n ∧ α ∈ (z.vector n).support := by + have hprop : ∀ (u : Γ →₀ ℝ), u ∈ z.tailSpan a → + ∀ α ∈ u.support, ∃ n, a ≤ n ∧ α ∈ (z.vector n).support := by + intro u hu + induction hu using Submodule.span_induction with + | mem y hy => + obtain ⟨n, rfl⟩ := hy + intro α hα + exact ⟨n+a, by omega, hα⟩ + | zero => simp + | add u v _ _ hu hv => + intro α hα + rcases Finset.mem_union.mp (Finsupp.support_add hα) with h | h + · exact hu α h + · exact hv α h + | smul c u _ hu => + intro α hα + exact hu α (Finsupp.support_smul hα) + exact hprop x hx α hα + +noncomputable def BlockSequence.prefixSupport {f : Family} (z : BlockSequence f) (b : ℕ) : Finset Γ := + (Finset.range b).biUnion (fun n => (z.vector n).support) + +lemma BlockSequence.prefixSupport_mono {f : Family} (z : BlockSequence f) : Monotone z.prefixSupport := by + intro a b hab + exact Finset.biUnion_subset_biUnion_of_subset_left _ (Finset.range_mono hab) + +lemma BlockSequence.support_subset_prefix {f : Family} (z : BlockSequence f) (a : ℕ) + {x : Γ →₀ ℝ} (hx : x ∈ z.tailSpan a) : ∃ b, a ≤ b ∧ x.support ⊆ z.prefixSupport b := by + have hprop : ∀ (u : Γ →₀ ℝ), u ∈ z.tailSpan a → + ∃ b, a ≤ b ∧ u.support ⊆ z.prefixSupport b := by + intro u hu + induction hu using Submodule.span_induction with + | mem y hy => + obtain ⟨n, rfl⟩ := hy + refine ⟨n+a+1, by omega, ?_⟩ + intro α hα + exact Finset.mem_biUnion.mpr ⟨n+a, Finset.mem_range.mpr (by omega), hα⟩ + | zero => exact ⟨a, le_rfl, by simp⟩ + | add u v _ _ hu hv => + obtain ⟨b, hb, hbu⟩ := hu + obtain ⟨c, hc, hcv⟩ := hv + refine ⟨max b c, hb.trans (le_max_left _ _), ?_⟩ + intro α hα + rcases Finset.mem_union.mp (Finsupp.support_add hα) with h | h + · exact z.prefixSupport_mono (le_max_left _ _) (hbu h) + · exact z.prefixSupport_mono (le_max_right _ _) (hcv h) + | smul c u _ hu => + obtain ⟨b, hb, hbu⟩ := hu + exact ⟨b, hb, fun _ h => hbu (Finsupp.support_smul h)⟩ + exact hprop x hx + +lemma BlockSequence.prefix_tail_successive {f : Family} (z : BlockSequence f) (b : ℕ) + {x y : Γ →₀ ℝ} (hx : x.support ⊆ z.prefixSupport b) (hy : y ∈ z.tailSpan b) : + ∀ α ∈ x.support, ∀ β ∈ y.support, + α < β ∧ (f = .mixed → Colors.color α < Colors.color β) := by + intro α hα β hβ + obtain ⟨i, hi, hiα⟩ := Finset.mem_biUnion.mp (hx hα) + obtain ⟨j, hj, hjβ⟩ := z.support_mem_tail b hy hβ + exact z.successive i j (lt_of_lt_of_le (Finset.mem_range.mp hi) hj) α hiα β hjβ + +lemma BlockSequence.tailSpan_mono {f : Family} (z : BlockSequence f) {a b : ℕ} (hab : a ≤ b) : + z.tailSpan b ≤ z.tailSpan a := by + apply Submodule.span_le.mpr + rintro u ⟨n, rfl⟩ + apply Submodule.subset_span + refine ⟨n+(b-a), ?_⟩ + change z.vector (n+(b-a)+a) = z.vector (n+b) + rw [show n+(b-a)+a = n+b by omega] + +lemma BlockSequence.tail_pure_color {f : Family} (z : BlockSequence f) (a : ℕ) + {x : Γ →₀ ℝ} (hx : x ∈ z.tailSpan a) (c : ℕ) (hc : f = .pure c) : + ∀ α ∈ x.support, Colors.color α = c := by + intro α hα + obtain ⟨n, _, hn⟩ := z.support_mem_tail a hx hα + exact z.pure_color c hc n α hn + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +noncomputable def BlockSequence.prefixRho {f : Family} (z : BlockSequence f) (a : ℕ) : ℕ := + (z.prefixSupport a ×ˢ z.prefixSupport a).sup (fun p => rho (min p.1 p.2) (max p.1 p.2)) + +lemma BlockSequence.le_prefixRho {f : Family} (z : BlockSequence f) (a : ℕ) {α β : Γ} + (hα : α ∈ z.prefixSupport a) (hβ : β ∈ z.prefixSupport a) : + rho (min α β) (max α β) ≤ z.prefixRho a := + Finset.le_sup (b := (α, β)) (f := fun p => rho (min p.1 p.2) (max p.1 p.2)) (Finset.mem_product.mpr ⟨hα, hβ⟩) + +/-- The recursively selected unit blocks, before pathwise-Cauchy differences. +No weak compactness hypothesis is smuggled into this structure. -/ +structure PreliminaryData {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (n : ℕ) where + vector : Γ →₀ ℝ + start : ℕ + finish : ℕ + lower : ℕ + upper : ℕ + mem : vector ∈ z.tailSpan start + support : vector.support ⊆ z.prefixSupport finish + finish_ge : start ≤ finish + unit : ‖norming.includeFinite vector‖ = 1 + prescribed : J < lower + order : lower ≤ upper + coherence : z.prefixRho start < lower + partition : PartitionBound (norming.includeFinite vector) (f.L lower) 8 f.r + tail_small : vectorL1 vector * tail (fun j => 1/(f.m j : ℝ)) (upper+1) ≤ ε/2 + tail_vanish : vectorL1 vector * tail (fun j => 1/(f.m j : ℝ)) (upper+1) ≤ 1/(n+1 : ℝ) + +lemma exists_preliminaryData {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (n a B : ℕ) : ∃ d : PreliminaryData z J ε n, d.start = a ∧ B < d.lower := by + let j := B+J+z.prefixRho a+1 + obtain ⟨u, hu, hunit, hpart⟩ := z.exists_partition_unit a (f.L j) (f.L_pos j) + obtain ⟨b, hb, hbu⟩ := z.support_subset_prefix a hu + have ht : Tendsto (fun t => vectorL1 u * tail (fun l => 1/(f.m l : ℝ)) (t+1)) atTop (𝓝 0) := by + simpa using (tendsto_const_nhds.mul ((tendsto_tail (fun l => 1/(f.m l : ℝ))).comp (tendsto_add_atTop_nat 1))) + have hmin : 0 < min (ε/2) (1/(n+1 : ℝ)) := lt_min (by linarith) (by positivity) + obtain ⟨T, hTj, hT⟩ := (eventually_ge_atTop j |>.and (ht.eventually (eventually_lt_nhds hmin))).exists + let d : PreliminaryData z J ε n := { + vector := u + start := a + finish := b + lower := j + upper := T + mem := hu + support := hbu + finish_ge := hb + unit := hunit + prescribed := by dsimp [j]; omega + order := hTj + coherence := by dsimp [j]; omega + partition := hpart + tail_small := hT.le.trans (min_le_left _ _) + tail_vanish := hT.le.trans (min_le_right _ _) } + exact ⟨d, rfl, by change B < j; dsimp [j]; omega⟩ + +noncomputable def preliminaryChoice {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (n a B : ℕ) : PreliminaryData z J ε n := (exists_preliminaryData z J ε hε n a B).choose + +lemma preliminaryChoice_spec {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (n a B : ℕ) : (preliminaryChoice z J ε hε n a B).start = a ∧ + B < (preliminaryChoice z J ε hε n a B).lower := (exists_preliminaryData z J ε hε n a B).choose_spec + +noncomputable def preliminaryData {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (a : ℕ) : (n : ℕ) → PreliminaryData z J ε n + | 0 => preliminaryChoice z J ε hε 0 a 0 + | n+1 => preliminaryChoice z J ε hε (n+1) (preliminaryData z J ε hε a n).finish + (preliminaryData z J ε hε a n).upper + +lemma preliminaryData_start_zero {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) (a : ℕ) : + (preliminaryData z J ε hε a 0).start = a := (preliminaryChoice_spec z J ε hε 0 a 0).1 + +lemma preliminaryData_start_succ {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) (a n : ℕ) : + (preliminaryData z J ε hε a (n+1)).start = (preliminaryData z J ε hε a n).finish := + (preliminaryChoice_spec z J ε hε (n+1) _ _).1 + +lemma preliminaryData_order_succ {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) (a n : ℕ) : + (preliminaryData z J ε hε a n).upper < (preliminaryData z J ε hε a (n+1)).lower := + (preliminaryChoice_spec z J ε hε (n+1) _ _).2 + +lemma preliminaryData_start_mono {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) (a : ℕ) : + Monotone (fun n => (preliminaryData z J ε hε a n).start) := by + apply monotone_nat_of_le_succ + intro n + rw [preliminaryData_start_succ] + exact (preliminaryData z J ε hε a n).finish_ge + +lemma preliminaryData_finish_le_start {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (a i j : ℕ) (hij : i < j) : + (preliminaryData z J ε hε a i).finish ≤ (preliminaryData z J ε hε a j).start := by + rw [← preliminaryData_start_succ] + exact preliminaryData_start_mono z J ε hε a (by omega) + +lemma preliminaryData_order {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (a i j : ℕ) (hij : i < j) : + (preliminaryData z J ε hε a i).upper < (preliminaryData z J ε hε a j).lower := by + have hlow : StrictMono (fun n => (preliminaryData z J ε hε a n).lower) := by + apply strictMono_nat_of_lt_succ + intro n + exact (preliminaryData z J ε hε a n).order.trans_lt (preliminaryData_order_succ z J ε hε a n) + exact (preliminaryData_order_succ z J ε hε a i).trans_le (hlow.monotone (by omega)) + +noncomputable def preliminaryBlocks {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) (a : ℕ) : + BlockSequence f where + vector n := (preliminaryData z J ε hε a n).vector + nonzero n := by + intro hz + have hh := (preliminaryData z J ε hε a n).unit + simp [hz] at hh + successive i j hij := z.prefix_tail_successive _ (preliminaryData z J ε hε a i).support + (z.tailSpan_mono (preliminaryData_finish_le_start z J ε hε a i j hij) (preliminaryData z J ε hε a j).mem) + pure_color c hc n := z.tail_pure_color _ (preliminaryData z J ε hε a n).mem c hc + +lemma preliminaryData_coherence {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) + (a i j : ℕ) (hij : i < j) {α β : Γ} + (hα : α ∈ (preliminaryData z J ε hε a i).vector.support) + (hβ : β ∈ (preliminaryData z J ε hε a i).vector.support) : + rho (min α β) (max α β) < (preliminaryData z J ε hε a j).lower := by + apply lt_of_le_of_lt (z.le_prefixRho _ ?_ ?_) (preliminaryData z J ε hε a j).coherence + · exact z.prefixSupport_mono (preliminaryData_finish_le_start z J ε hε a i j hij) + ((preliminaryData z J ε hε a i).support hα) + · exact z.prefixSupport_mono (preliminaryData_finish_le_start z J ε hε a i j hij) + ((preliminaryData z J ε hε a i).support hβ) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.SeriesTails +open Filter +open scoped Topology Classical + +lemma tail_antitone (a : ℕ → ℝ) (ha : Summable a) (hn : ∀ n, 0 ≤ a n) : Antitone (tail a) := by + intro N M hNM + have hs := ((summable_nat_add_iff N).mpr ha).sum_add_tsum_nat_add (M-N) + have hid : (∑' k, a (k+(M-N)+N)) = tail a M := by + apply tsum_congr + intro k + rw [show k+(M-N)+N = k+M by omega] + rw [hid] at hs + have hpos : 0 ≤ ∑ k ∈ Finset.range (M-N), a (k+N) := Finset.sum_nonneg (fun _ _ => hn _) + change tail a M ≤ ∑' k, a (k+N) + linarith + +end SeparableQuotient.SeriesTails + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +lemma vectorL1_eq_sum {x : Γ →₀ ℝ} {s : Finset Γ} (hs : x.support ⊆ s) : + vectorL1 x = ∑ a ∈ s, |x a| := by + apply Finset.sum_subset hs + intro a _ ha + rw [Finsupp.notMem_support_iff.mp ha, abs_zero] + +lemma vectorL1_sub_le (x y : Γ →₀ ℝ) : vectorL1 (x-y) ≤ vectorL1 x + vectorL1 y := by + rw [vectorL1_eq_sum Finsupp.support_sub, + vectorL1_eq_sum (Finset.subset_union_left : x.support ⊆ x.support ∪ y.support), + vectorL1_eq_sum (Finset.subset_union_right : y.support ⊆ x.support ∪ y.support), ← Finset.sum_add_distrib] + exact Finset.sum_le_sum (fun _ _ => abs_sub _ _) + +lemma PartitionBound.mono {x : E} {N M : ℕ} {A r : ℝ} (h : PartitionBound x N A r) (hMN : M ≤ N) : + PartitionBound x M A r := fun d hd hdM => h d hd (hdM.trans hMN) + +lemma PartitionBound.sub {x y : E} {N : ℕ} {A B r : ℝ} + (hx : PartitionBound x N A r) (hy : PartitionBound y N B r) : + PartitionBound (x-y) N (A+B) r := by + intro d hd hdN I hI hIs + calc + _ ≤ ∑ b, (‖intervalProjection (I b) (hI b) x‖ + ‖intervalProjection (I b) (hI b) y‖) := by + apply Finset.sum_le_sum + intro b _ + rw [map_sub] + exact norm_sub_le _ _ + _ = (∑ b, ‖intervalProjection (I b) (hI b) x‖) + (∑ b, ‖intervalProjection (I b) (hI b) y‖) := Finset.sum_add_distrib + _ ≤ A * (d : ℝ)^(1/r) + B * (d : ℝ)^(1/r) := add_le_add (hx d hd hdN I hI hIs) (hy d hd hdN I hI hIs) + _ = _ := by ring + +noncomputable def BlockSequence.subsequence {f : Family} (z : BlockSequence f) (φ : ℕ → ℕ) (hφ : StrictMono φ) : + BlockSequence f where + vector n := z.vector (φ n) + nonzero n := z.nonzero (φ n) + successive i j hij := z.successive (φ i) (φ j) (hφ hij) + pure_color c hc n := z.pure_color c hc (φ n) + +lemma BlockSequence.norm_sub_ge_one {f : Family} (z : BlockSequence f) {i j : ℕ} (hij : i < j) + (hi : ‖z.embed i‖ = 1) : 1 ≤ ‖norming.includeFinite (z.vector i-z.vector j)‖ := by + have hne := Finsupp.support_nonempty_iff.mpr (z.nonzero i) + let I := ordinalHull (z.vector i).support hne + have hI : Set.OrdConnected I := ordinalHull_connected _ _ + have hfix : intervalProjection I hI (z.embed i) = z.embed i := + intervalProjection_fixed I hI _ (fun _ ha => mem_ordinalHull hne ha) + have hzero : intervalProjection I hI (z.embed j) = 0 := by + apply intervalProjection_eq_zero + intro a ha haI + have hlt := (z.successive i j hij _ ((z.vector i).support.max'_mem hne) a ha).1 + exact (not_lt_of_ge haI.2) hlt + have heq : intervalProjection I hI (norming.includeFinite (z.vector i-z.vector j)) = z.embed i := by + rw [map_sub] + change intervalProjection I hI (z.embed i-z.embed j) = z.embed i + rw [map_sub, hfix, hzero, sub_zero] + calc + 1 = ‖intervalProjection I hI (norming.includeFinite (z.vector i-z.vector j))‖ := by rw [heq, hi] + _ ≤ _ := norm_projection_le _ _ + +noncomputable def BlockSequence.pairDifferences {f : Family} (z : BlockSequence f) + (hz : ∀ n, ‖z.embed n‖ = 1) : BlockSequence f where + vector n := z.vector (2*n)-z.vector (2*n+1) + nonzero n := by + intro hh + have hi := z.norm_sub_ge_one (by omega : 2*n < 2*n+1) (hz (2*n)) + simp [hh] at hi + norm_num at hi + successive i j hij a ha b hb := by + have ha' := Finset.mem_union.mp (Finsupp.support_sub ha) + have hb' := Finset.mem_union.mp (Finsupp.support_sub hb) + rcases ha' with ha | ha <;> rcases hb' with hb | hb + all_goals exact z.successive _ _ (by omega) a ha b hb + pure_color c hc n a ha := by + rcases Finset.mem_union.mp (Finsupp.support_sub ha) with ha | ha + · exact z.pure_color c hc (2*n) a ha + · exact z.pure_color c hc (2*n+1) a ha + +lemma BlockSequence.pairDifferences_norm {f : Family} (z : BlockSequence f) + (hz : ∀ n, ‖z.embed n‖ = 1) (n : ℕ) : + 1 ≤ ‖(z.pairDifferences hz).embed n‖ ∧ ‖(z.pairDifferences hz).embed n‖ ≤ 2 := by + refine ⟨z.norm_sub_ge_one (by omega) (hz (2*n)), ?_⟩ + change ‖norming.includeFinite (z.vector (2*n)-z.vector (2*n+1))‖ ≤ 2 + rw [map_sub] + exact (norm_sub_le _ _).trans (by change ‖z.embed (2*n)‖+‖z.embed (2*n+1)‖≤2; rw [hz, hz]; norm_num) + +lemma BlockSequence.pairDifferences_path_null {f : Family} (z : BlockSequence f) + (hz : ∀ n, ‖z.embed n‖ = 1) (hC : ∀ P : InfinitePath f, CauchySeq (fun n => pathFunctional P (z.embed n))) : + ∀ P : InfinitePath f, Tendsto (fun n => pathFunctional P ((z.pairDifferences hz).embed n)) atTop (𝓝 0) := by + intro P + obtain ⟨a, ha⟩ := cauchySeq_tendsto_of_complete (hC P) + have he : StrictMono (fun n : ℕ => 2*n) := by intro i j h; dsimp; omega + have ho : StrictMono (fun n : ℕ => 2*n+1) := by intro i j h; dsimp; omega + have ht := (ha.comp he.tendsto_atTop).sub (ha.comp ho.tendsto_atTop) + simpa only [BlockSequence.embed, BlockSequence.pairDifferences, map_sub, sub_self, Function.comp_apply] using ht + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/TreeBounds.lean b/lean/OAI/Analysis/SeparableQuotients/TreeBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..103c2c09afa44f7902f939c14b8127af922a3ec5 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/TreeBounds.lean @@ -0,0 +1,300 @@ +import OAI.Analysis.SeparableQuotients.StoppedCharges + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +noncomputable def TypeII.childEvals {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (e : TypeII f) (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) : TypeII.ChildVectors e s := + fun g h => w.evalVector s (TypeI.lowAssign w ((e.path g.1).piece g.2) s I h) + (restrict ((e.crop g.1).set f) (((e.path g.1).piece g.2).child h)) + +lemma TypeII.recombineEarly_add {f : Family} (e : TypeII f) (J : ℕ) (s : Finset ℕ) + (v u : TypeII.ChildVectors e s) (i : s) : + TypeII.recombineEarly e J s (fun g h i => v g h i + u g h i) i = + TypeII.recombineEarly e J s v i + TypeII.recombineEarly e J s u i := by + simp only [TypeII.recombineEarly,Finset.sum_add_distrib,mul_add] + +lemma TypeII.recombineEarly_mono {f : Family} (e : TypeII f) (J : ℕ) (s : Finset ℕ) + (v u : TypeII.ChildVectors e s) (h : ∀ g h i, v g h i ≤ u g h i) (i : s) : + TypeII.recombineEarly e J s v i ≤ TypeII.recombineEarly e J s u i := by + apply Finset.sum_le_sum + intro g _ + apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact Finset.sum_le_sum (fun k _ => h g k i) + +lemma ThinnedWindows.low_refined_bound {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) + (i : s) (hi : i ∈ I) : + (∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * + (if TypeII.groupWeight e g < w.lower i then + |norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g)| else 0)) ≤ + TypeII.earlyBoundary e w s I i + TypeII.lateVector e w s I i + + TypeII.recombineEarly e J s (TypeII.childEvals e w s I) i := by + have hh (g : TypeII.Group e) : (if TypeII.groupWeight e g < w.lower i then + |norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g)| else 0) ≤ + if TypeII.groupWeight e g < J then TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I i + + TypeII.continuation e w s I g i else TypeI.stoppedCharge w ((e.path g.1).piece g.2) s I i := by + by_cases hlow : TypeII.groupWeight e g < w.lower i + · rw [ite_eq_left hlow] + split_ifs with hj + · exact TypeI.low_eval_bound w ((e.path g.1).piece g.2) (e.crop g.1) (hm g.1 g.2) s I i hi hlow + · exact TypeI.stopped_eval_bound w ((e.path g.1).piece g.2) (e.crop g.1) (hm g.1 g.2) s I i hi hlow + · rw [ite_eq_right hlow] + split_ifs + · exact add_nonneg (TypeI.boundaryCharge_nonneg ..) (TypeII.continuation_nonneg ..) + · exact TypeI.stoppedCharge_nonneg .. + calc + _ ≤ ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * + (if TypeII.groupWeight e g < J then TypeI.boundaryCharge w ((e.path g.1).piece g.2) s I i + + TypeII.continuation e w s I g i else TypeI.stoppedCharge w ((e.path g.1).piece g.2) s I i) := + Finset.sum_le_sum (fun g _ => mul_le_mul_of_nonneg_left (hh g) (abs_nonneg _)) + _ = _ := by + unfold TypeII.earlyBoundary TypeII.lateVector TypeII.recombineEarly TypeII.earlyGroups TypeII.lateGroups + simp only [Finset.sum_filter] + rw [← Finset.sum_add_distrib,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro g _ + by_cases hj : TypeII.groupWeight e g < J + · simp only [hj,ite_true,not_le.mpr hj,ite_false,add_zero,TypeII.continuation,TypeII.childEvals,mul_add] + · simp only [hj,ite_false,not_lt.mp hj,ite_true,zero_add,add_zero] + +lemma ThinnedWindows.node_refined_majorant {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (I : Finset s) (i : s) : + w.evalVector s I e.value i ≤ w.localSmall e s I i+w.localLarge e hm s I i+ + TypeII.recombineEarly e J s (TypeII.childEvals e w s I) i := by + by_cases hi : i ∈ I + · have hn := w.node_split e hm s i + have hl := w.low_refined_bound e hm s I i hi + simp only [ThinnedWindows.evalVector,ThinnedWindows.localSmall,ThinnedWindows.localLarge,hi,ite_true] + linarith + · rw [w.localSmall_support e s I i hi,w.localLarge_support e hm s I i hi] + simp only [ThinnedWindows.evalVector,hi,ite_false,zero_add] + exact TypeII.recombineEarly_nonneg e J s (TypeII.childEvals e w s I) (fun _ _ _ => w.evalVector_nonneg ..) i + +lemma Family.norming_crop (f : Family) (A : Crop) (g : Array) (hg : g ∈ f.norming) : + restrict (A.set f) g ∈ f.norming := by + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hg + exact Set.mem_iUnion.mpr ⟨n,Family.stage_crop f n A g hn⟩ + +lemma Family.norming_cases (f : Family) (g : Array) (hg : g ∈ f.norming) : + g ∈ f.base ∨ ∃ e : TypeII f, e.value = g ∧ ∀ b i j, ((e.path b).piece i).child j ∈ f.norming := by + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hg + induction n with + | zero => exact Or.inl hn + | succ n ih => + rcases hn with (hn | ⟨e,rfl,he⟩) | ⟨e,rfl,he⟩ + · exact ih hn + · refine Or.inr ⟨e.toTypeII,e.toTypeII_value,fun _ _ h => ?_⟩ + exact Set.mem_iUnion.mpr ⟨n,he h⟩ + · exact Or.inr ⟨e,rfl,fun b i j => Set.mem_iUnion.mpr ⟨n,he b i j⟩⟩ + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +noncomputable def smallBudget (f : Family) (J d : ℕ) : ℝ := + (1552/7)*f.theta J+64*(1/8)^d +noncomputable def largeUnit (f : Family) (J : ℕ) (s : Finset ℕ) : ℝ := + 16*(1+(Parameters.B f.s (J-1) : ℝ)+(s.card : ℝ)^(1-1/f.q)) +noncomputable def largeBudget (f : Family) (J : ℕ) (s : Finset ℕ) (d : ℕ) : ℝ := + largeUnit f J s*(1+(Parameters.B f.s (J-1) : ℝ))^d + +lemma smallBudget_nonneg (f : Family) (J d : ℕ) : 0 ≤ smallBudget f J d := by + unfold smallBudget + have := f.theta_nonneg J + positivity +lemma largeUnit_ge (f : Family) (J : ℕ) (s : Finset ℕ) : 16 ≤ largeUnit f J s := by + unfold largeUnit + have : 0 ≤ (s.card : ℝ)^(1-1/f.q) := Real.rpow_nonneg (by positivity) _ + have : 0 ≤ (Parameters.B f.s (J-1) : ℝ) := by positivity + linarith +lemma largeBudget_ge (f : Family) (J : ℕ) (s : Finset ℕ) (d : ℕ) : largeUnit f J s ≤ largeBudget f J s d := by + unfold largeBudget + exact le_mul_of_one_le_right (by linarith [largeUnit_ge f J s]) (one_le_pow₀ (by + have hb : 0 ≤ (Parameters.B f.s (J-1) : ℝ) := by positivity + linarith)) +lemma largeBudget_nonneg (f : Family) (J : ℕ) (s : Finset ℕ) (d : ℕ) : 0 ≤ largeBudget f J s d := by + linarith [largeUnit_ge f J s,largeBudget_ge f J s d] +lemma smallBudget_succ (f : Family) (J d : ℕ) : + 194*f.theta J+smallBudget f J d/8 = smallBudget f J (d+1) := by + unfold smallBudget + rw [pow_succ] + ring +lemma largeBudget_step (f : Family) (J : ℕ) (s : Finset ℕ) (d : ℕ) : + largeUnit f J s+(Parameters.B f.s (J-1) : ℝ)*largeBudget f J s d ≤ largeBudget f J s (d+1) := by + calc + _ ≤ largeBudget f J s d+(Parameters.B f.s (J-1) : ℝ)*largeBudget f J s d := + add_le_add (largeBudget_ge f J s d) le_rfl + _ = _ := by unfold largeBudget; rw [pow_succ]; ring + +structure DepthMajorant {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (I : Finset s) (g : Array) (d : ℕ) where + small : s → ℝ + large : s → ℝ + small_nonneg : ∀ i, 0 ≤ small i + large_nonneg : ∀ i, 0 ≤ large i + small_support : ∀ i, i ∉ I → small i = 0 + large_support : ∀ i, i ∉ I → large i = 0 + majorizes : ∀ i, w.evalVector s I g i ≤ small i+large i + norm_small : ‖vec f.exponent small‖ ≤ smallBudget f J d + sum_large : (∑ i : s, large i) ≤ largeBudget f J s d + +lemma ThinnedWindows.exists_depthMajorant {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) + (hJ : 1 ≤ J) (hs : s.card ≤ f.L J) (hε : ε*(s.card : ℝ)^(1/f.r) ≤ f.theta J) + (d : ℕ) (I : Finset s) (g : Array) (hg : g ∈ f.norming) : + Nonempty (DepthMajorant w s I g d) := by + induction d generalizing I g with + | zero => + refine ⟨⟨w.evalVector s I g,fun _ => 0,w.evalVector_nonneg s I g,fun _ => le_rfl,?_,?_,?_,?_,?_⟩⟩ + · intro i hi + simp only [ThinnedWindows.evalVector,hi,ite_false] + · exact fun _ _ => rfl + · intro i + exact (add_zero _).ge + · apply (w.norming_uniform s (hε.trans (Family.theta_le_one f J)) g hg I).trans + unfold smallBudget + simp only [pow_zero,mul_one] + have := f.theta_nonneg J + linarith + · simpa only [Finset.sum_const_zero] using largeBudget_nonneg f J s 0 + | succ d ih => + rcases Family.norming_cases f g hg with hbase | ⟨e,rfl,he⟩ + · refine ⟨⟨fun _ => 0,w.evalVector s I g,fun _ => le_rfl,w.evalVector_nonneg s I g,?_,?_,?_,?_,?_⟩⟩ + · exact fun _ _ => rfl + · intro i hi + simp only [ThinnedWindows.evalVector,hi,ite_false] + · intro i + exact (zero_add _).ge + · simpa only [show vec f.exponent (fun _ : s => (0 : ℝ)) = 0 from rfl,norm_zero] using smallBudget_nonneg f J (d+1) + · linarith [(w.evalVector_base s I g hbase).2,largeUnit_ge f J s,largeBudget_ge f J s (d+1)] + · let C (k : TypeII.Group e) (h : Fin ((e.path k.1).piece k.2).length) := + Classical.choice (ih (TypeI.lowAssign w ((e.path k.1).piece k.2) s I h) + (restrict ((e.crop k.1).set f) (((e.path k.1).piece k.2).child h)) + (Family.norming_crop f _ _ (he k.1 k.2 h))) + let v : TypeII.ChildVectors e s := fun k h => (C k h).small + let u : TypeII.ChildVectors e s := fun k h => (C k h).large + refine ⟨⟨fun i => w.localSmall e s I i+TypeII.recombineEarly e J s v i, + fun i => w.localLarge e he s I i+TypeII.recombineEarly e J s u i,?_,?_,?_,?_,?_,?_,?_⟩⟩ + · intro i + exact add_nonneg (w.localSmall_nonneg e s I i) + (TypeII.recombineEarly_nonneg e J s v (fun k h i => (C k h).small_nonneg i) i) + · intro i + exact add_nonneg (w.localLarge_nonneg e he s I i) + (TypeII.recombineEarly_nonneg e J s u (fun k h i => (C k h).large_nonneg i) i) + · intro i hi + rw [w.localSmall_support e s I i hi,TypeII.recombineEarly_support e w s I v + (fun k h i hi => (C k h).small_support i hi) i hi,add_zero] + · intro i hi + rw [w.localLarge_support e he s I i hi,TypeII.recombineEarly_support e w s I u + (fun k h i hi => (C k h).large_support i hi) i hi,add_zero] + · intro i + have hh := TypeII.recombineEarly_mono e J s (TypeII.childEvals e w s I) + (fun k h i => v k h i+u k h i) (fun k h i => (C k h).majorizes i) i + rw [TypeII.recombineEarly_add] at hh + linarith [w.node_refined_majorant e he s I i] + · change ‖vec f.exponent (w.localSmall e s I)+vec f.exponent (TypeII.recombineEarly e J s v)‖ ≤ _ + apply (norm_add_le _ _).trans + rw [← smallBudget_succ] + exact add_le_add (w.localSmall_norm e s I hJ hs hε) + (TypeII.recombineEarly_norm e w s I v (smallBudget f J d) (smallBudget_nonneg f J d) + (fun k h i hi => (C k h).small_support i hi) (fun k h => (C k h).norm_small)) + · rw [Finset.sum_add_distrib] + exact (add_le_add (w.localLarge_l1 e he s I) + (TypeII.recombineEarly_l1 e J s u (largeBudget f J s d) (largeBudget_nonneg f J s d) + (fun k h i => (C k h).large_nonneg i) (fun k h => (C k h).sum_large))).trans + (largeBudget_step f J s d) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology ENNReal BigOperators + +lemma Family.qprime_formula (f : Family) : 1-1/f.q = 1/((f.s : ℝ)+1) := by + have hs : (0 : ℝ) < f.s := by exact_mod_cast (show 0 < f.s by have := f.s_ge_two; omega) + unfold Norming.Family.q Parameters.q + field_simp + ring + +lemma Family.holder_theta (f : Family) (J : ℕ) : + (f.L J : ℝ)^(1-1/f.r)*f.theta J = (f.L J : ℝ)/(f.m J : ℝ) := by + have hL : (0 : ℝ) < f.L J := by exact_mod_cast f.L_pos J + rw [f.theta_formula,← mul_div_assoc,← Real.rpow_add hL] + rw [show 1-1/f.r+1/f.r = 1 by ring,Real.rpow_one] + +lemma ThinnedWindows.sum_eval_bound {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (hJ : 1 ≤ J) (hs : s.card = f.L J) + (hε : ε*(s.card : ℝ)^(1/f.r) ≤ f.theta J) (g : Array) (hg : g ∈ f.norming) : + (∑ i : s, |norming.evaluateArray (w.blocks.embed i) g|) ≤ 500*(f.L J : ℝ)/(f.m J : ℝ) := by + let d := Parameters.d (J-1) + obtain ⟨c⟩ := w.exists_depthMajorant s hJ hs.le hε d Finset.univ g hg + have hb : smallBudget f J d ≤ (2000/7)*f.theta J := by + have hh := Parameters.depth_theta_bound f.s_ge_two (J-1) + change (1/8 : ℝ)^d ≤ f.theta J at hh + unfold smallBudget + linarith + have hlarge : largeBudget f J s d ≤ 16*((f.L J : ℝ)/(f.m J : ℝ)) := by + have hh := Parameters.depth_bound f.s_ge_two (J-1) + unfold largeBudget largeUnit + rw [hs,Family.qprime_formula] + change 16*(1+(Parameters.B f.s (J-1) : ℝ)+(Parameters.L f.s (J-1) : ℝ)^(1/((f.s : ℝ)+1))) * + (1+(Parameters.B f.s (J-1) : ℝ))^d ≤ 16*((Parameters.L f.s (J-1) : ℝ)/(Parameters.m f.s (J-1) : ℝ)) + nlinarith [hh] + have hsmall : (∑ i : s, c.small i) ≤ (2000/7)*((f.L J : ℝ)/(f.m J : ℝ)) := by + have hh := sum_abs_le_holder (by simpa only [Family.exponent_toReal] using f.r_gt_one : 1 < f.exponent.toReal) c.small + simp only [abs_of_nonneg (c.small_nonneg _),Family.exponent_toReal,Fintype.card_coe,hs] at hh + calc + _ ≤ (f.L J : ℝ)^(1-1/f.r)*‖vec f.exponent c.small‖ := hh + _ ≤ (f.L J : ℝ)^(1-1/f.r)*((2000/7)*f.theta J) := + mul_le_mul_of_nonneg_left (c.norm_small.trans hb) (Real.rpow_nonneg (by positivity) _) + _ = _ := by rw [mul_left_comm,Family.holder_theta] + have hmain : (∑ i : s, |norming.evaluateArray (w.blocks.embed i) g|) ≤ + (∑ i : s, c.small i)+(∑ i : s, c.large i) := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro i _ + simpa only [ThinnedWindows.evalVector,Finset.mem_univ,ite_true] using c.majorizes i + have hpos : 0 ≤ (f.L J : ℝ)/(f.m J : ℝ) := by positivity + have hl := c.sum_large.trans hlarge + calc + _ ≤ (2000/7+16)*((f.L J : ℝ)/(f.m J : ℝ)) := by linarith + _ ≤ 500*((f.L J : ℝ)/(f.m J : ℝ)) := mul_le_mul_of_nonneg_right (by norm_num) hpos + _ = _ := by ring + +lemma ThinnedWindows.norm_sum_bound {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (s : Finset ℕ) (hJ : 1 ≤ J) (hs : s.card = f.L J) + (hε : ε*(s.card : ℝ)^(1/f.r) ≤ f.theta J) : + ‖norming.includeFinite (∑ i : s, w.blocks.vector i)‖ ≤ 500*(f.L J : ℝ)/(f.m J : ℝ) := by + have hb (g : Array) (hg : g ∈ f.norming) : + |norming.evaluateArray (norming.includeFinite (∑ i : s, w.blocks.vector i)) g| ≤ + 500*(f.L J : ℝ)/(f.m J : ℝ) := by + have hf : g ∈ Full := f.norming_subset_full hg + rw [norming.evaluateArray_eq_functional _ ⟨g,hf⟩,map_sum,map_sum] + apply (Finset.abs_sum_le_sum_abs _ _).trans + simpa only [BlockSequence.embed,norming.evaluateArray_eq_functional _ ⟨g,hf⟩] using w.sum_eval_bound s hJ hs hε g hg + cases f with + | mixed => exact norming.norm_le_of_evaluateArray _ _ (by positivity) hb + | pure k => + apply norm_le_of_pure k _ _ _ (by positivity) hb + intro α hα + rw [norming.coordinate_includeFinite,Finsupp.finsetSum_apply] + apply Finset.sum_eq_zero + intro i _ + exact Finsupp.notMem_support_iff.mp (fun hi => hα (w.blocks.pure_color k rfl i α hi)) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/TreeCharges.lean b/lean/OAI/Analysis/SeparableQuotients/TreeCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a57c90657993d4040741ed9a759de58e25f82ce --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/TreeCharges.lean @@ -0,0 +1,336 @@ +import OAI.Analysis.SeparableQuotients.NormingTrees + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology + +lemma TypeI.eval_crop_sum {f : Family} (e : TypeI f) (A : Crop) (x : E) : + norming.evaluateArray x (restrict (A.set f) e.value) = + (1/(f.m e.weight : ℝ)) * ∑ h, norming.evaluateArray x (restrict (A.set f) (e.child h)) := by + simp only [TypeI.value,restrict_smul,restrict_sum,map_smul,map_sum,Rat.smul_def, + Rat.cast_div,Rat.cast_one,Rat.cast_natCast] + +noncomputable def TypeI.lowAssign {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) (h : Fin e.length) : Finset s := + I.filter (fun i => e.weight < w.lower i ∧ TypeI.hitChildren e (w.blocks.vector i) = {h}) + +lemma TypeI.lowAssign_subset {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) (h : Fin e.length) : + TypeI.lowAssign w e s I h ⊆ I := Finset.filter_subset _ _ + +lemma TypeI.lowAssign_disjoint {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) + (h k : Fin e.length) (hhk : h ≠ k) : + Disjoint (TypeI.lowAssign w e s I h) (TypeI.lowAssign w e s I k) := by + apply Finset.disjoint_left.mpr + intro i hi hk + exact hhk (Finset.singleton_injective ((Finset.mem_filter.mp hi).2.2.symm.trans (Finset.mem_filter.mp hk).2.2)) + +noncomputable def TypeI.boundaryDegree {f : Family} (e : TypeI f) (z : BlockSequence f) (i : ℕ) : ℝ := + if 2 ≤ (TypeI.hitChildren e (z.vector i)).card then (TypeI.hitChildren e (z.vector i)).card else 0 + +lemma TypeI.boundaryDegree_nonneg {f : Family} (e : TypeI f) (z : BlockSequence f) (i : ℕ) : + 0 ≤ TypeI.boundaryDegree e z i := by unfold TypeI.boundaryDegree; split_ifs <;> positivity + +lemma TypeI.boundaryDegree_sum {f : Family} (e : TypeI f) (z : BlockSequence f) (s : Finset ℕ) : + (∑ i : s, TypeI.boundaryDegree e z i) ≤ 2 * (e.length : ℝ) := by + have he : (∑ i : s, TypeI.boundaryDegree e z i) = + ((∑ i ∈ s.filter (fun i => 2 ≤ (TypeI.hitChildren e (z.vector i)).card), + (TypeI.hitChildren e (z.vector i)).card : ℕ) : ℝ) := by + simp only [TypeI.boundaryDegree,Finset.sum_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_zero] + exact (Finset.sum_coe_sort s (fun i : ℕ => if 2 ≤ (TypeI.hitChildren e (z.vector i)).card then ((TypeI.hitChildren e (z.vector i)).card : ℝ) else 0)) + rw [he] + exact_mod_cast TypeI.boundary_incidence e z s + +noncomputable def TypeI.boundaryCharge {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) (i : s) : ℝ := + if i ∈ I ∧ e.weight < w.lower i then + (16 / (f.m e.weight : ℝ)) * (TypeI.boundaryDegree e w.blocks i)^(1/f.r) else 0 + +lemma TypeI.boundaryCharge_nonneg {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) (i : s) : + 0 ≤ TypeI.boundaryCharge w e s I i := by + have hd := TypeI.boundaryDegree_nonneg e w.blocks i + unfold TypeI.boundaryCharge + split_ifs <;> positivity + +lemma TypeI.boundaryCharge_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) : + ‖vec f.exponent (TypeI.boundaryCharge w e s I)‖ ≤ 32 * f.theta e.weight := by + have hm : 0 < (f.m e.weight : ℝ) := by exact_mod_cast f.m_pos e.weight + have hb := norm_degree_le (by simpa only [Family.exponent_toReal] using f.r_pos : 0 < f.exponent.toReal) + (fun i : s => TypeI.boundaryDegree e w.blocks i) (16/(f.m e.weight : ℝ)) (2*e.length) + (by positivity) (by positivity) (fun i => TypeI.boundaryDegree_nonneg e w.blocks i) + (TypeI.boundaryDegree_sum e w.blocks s) (TypeI.boundaryCharge w e s I) (fun i => by + rw [abs_of_nonneg (TypeI.boundaryCharge_nonneg w e s I i)] + unfold TypeI.boundaryCharge + split_ifs + · simp only [Family.exponent_toReal,le_refl] + · exact mul_nonneg (by positivity) (Real.rpow_nonneg (TypeI.boundaryDegree_nonneg e w.blocks i) _)) + have hr : 1/f.r ≤ 1 := (div_le_one f.r_pos).mpr f.r_gt_one.le + have h2 : (2 : ℝ)^(1/f.r) ≤ 2 := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (by norm_num : (1:ℝ) ≤ 2) hr + calc + _ ≤ (16/(f.m e.weight : ℝ)) * (2*(e.length : ℝ))^(1/f.r) := by simpa only [Family.exponent_toReal] using hb + _ ≤ (16/(f.m e.weight : ℝ)) * (2*(f.L e.weight : ℝ)^(1/f.r)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 2) (Nat.cast_nonneg _)] + exact mul_le_mul h2 (Real.rpow_le_rpow (Nat.cast_nonneg _) (by exact_mod_cast e.length_le) (one_div_nonneg.mpr f.r_pos.le)) + (by positivity) (by norm_num) + _ = _ := by rw [Family.theta_formula]; ring + +lemma TypeI.low_eval_bound {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (A : Crop) + (hm : ∀ h, e.child h ∈ f.norming) (s : Finset ℕ) (I : Finset s) (i : s) + (hi : i ∈ I) (hj : e.weight < w.lower i) : + |norming.evaluateArray (w.blocks.embed i) (restrict (A.set f) e.value)| ≤ + TypeI.boundaryCharge w e s I i + (1/(f.m e.weight : ℝ)) * + ∑ h, if i ∈ TypeI.lowAssign w e s I h then + |norming.evaluateArray (w.blocks.embed i) (restrict (A.set f) (e.child h))| else 0 := by + have hr : 0 < 1/f.r := one_div_pos.mpr f.r_pos + have hb := TypeI.cropped_child_sum_bound e A hm (w.blocks.vector i) (f.L (w.lower i)) 16 + (by norm_num) (w.partition i) (e.length_le.trans (FamilyL_mono f hj.le)) + rw [TypeI.eval_crop_sum,abs_mul,abs_of_nonneg (by positivity : 0 ≤ 1/(f.m e.weight : ℝ))] + apply le_trans (mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs _ _) (by positivity)) + let H := TypeI.hitChildren e (w.blocks.vector i) + by_cases hd : 2 ≤ H.card + · have hu : TypeI.boundaryCharge w e s I i = 16/(f.m e.weight : ℝ) * (H.card : ℝ)^(1/f.r) := by + simp only [TypeI.boundaryCharge,hi,hj,and_self,ite_true,TypeI.boundaryDegree,show 2 ≤ (TypeI.hitChildren e (w.blocks.vector i)).card from hd,H] + rw [hu] + have hc := mul_le_mul_of_nonneg_left hb (by positivity : 0 ≤ 1/(f.m e.weight : ℝ)) + have hn : 0 ≤ (1/(f.m e.weight : ℝ)) * ∑ h, if i ∈ TypeI.lowAssign w e s I h then + |norming.evaluateArray (w.blocks.embed i) (restrict (A.set f) (e.child h))| else 0 := by positivity + dsimp only [BlockSequence.embed] at hc hn ⊢ + dsimp only [H] at ⊢ + calc + _ ≤ (1/(f.m e.weight : ℝ)) * (16*((TypeI.hitChildren e (w.blocks.vector i)).card : ℝ)^(1/f.r)) := hc + _ = 16/(f.m e.weight : ℝ) * ((TypeI.hitChildren e (w.blocks.vector i)).card : ℝ)^(1/f.r) := by ring + _ ≤ _ := le_add_of_nonneg_right hn + · have hsmall : H.card ≤ 1 := by omega + have heq (h : Fin e.length) : (if i ∈ TypeI.lowAssign w e s I h then + |norming.evaluateArray (w.blocks.embed i) (restrict (A.set f) (e.child h))| else 0) = + |norming.evaluateArray (w.blocks.embed i) (restrict (A.set f) (e.child h))| := by + by_cases hh : h ∈ H + · have hH : H = {h} := Finset.eq_singleton_iff_unique_mem.mpr ⟨hh, fun k hk => + (Finset.card_le_one.mp hsmall k hk h hh)⟩ + have ha : i ∈ TypeI.lowAssign w e s I h := Finset.mem_filter.mpr ⟨hi,hj,hH⟩ + simp only [ha,ite_true] + · dsimp only [BlockSequence.embed] + rw [TypeI.cropped_child_zero e A (w.blocks.vector i) h hh,abs_zero] + simp + simp_rw [heq] + exact le_add_of_nonneg_left (TypeI.boundaryCharge_nonneg w e s I i) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology + +lemma Family.sum_theta_le {κ : Type*} (f : Family) (S : Finset κ) (j : κ → ℕ) + (hp : ∀ g ∈ S, 1 ≤ j g) (hinj : Set.InjOn j S) : + ∑ g ∈ S, f.theta (j g) ≤ 1/8 := by + have hi : Set.InjOn (fun g => j g - 1) S := by + intro g hg h hh he + apply hinj hg hh + have := hp g hg + have := hp h hh + dsimp only at he + omega + calc + _ = ∑ n ∈ S.image (fun g => j g - 1), Parameters.theta f.s n := by + rw [Finset.sum_image hi] + rfl + _ ≤ ∑' n, Parameters.theta f.s n := + (Parameters.hasSum_theta f.s_ge_two).summable.sum_le_tsum _ + (fun n _ => by rw [Parameters.theta_eq f.s_ge_two]; positivity) + _ ≤ 1/8 := (Parameters.theta_sum_small f.s_ge_two).le + +lemma TypeII.group_theta_sum {f : Family} (e : TypeII f) : + ∑ g ∈ TypeII.activeGroups e, f.theta (TypeII.groupWeight e g) ≤ 1/8 := + Family.sum_theta_le f _ _ (fun g _ => ((e.path g.1).piece g.2).weight_pos) (TypeII.groupWeight_injOn e) + +lemma TypeI.recombine_norm {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) + (v : Fin e.length → s → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hs : ∀ h i, i ∉ TypeI.lowAssign w e s I h → v h i = 0) + (hv : ∀ h, ‖vec f.exponent (v h)‖ ≤ K) : + ‖vec f.exponent (fun i => (1/(f.m e.weight : ℝ)) * ∑ h, v h i)‖ ≤ K*f.theta e.weight := by + have hd : ∀ h ∈ (Finset.univ : Finset (Fin e.length)), ∀ k ∈ Finset.univ, h ≠ k → + ∀ i, v h i = 0 ∨ v k i = 0 := by + intro h _ k _ hhk i + by_cases hi : i ∈ TypeI.lowAssign w e s I h + · exact Or.inr (hs k i (fun hk => Finset.disjoint_left.mp (TypeI.lowAssign_disjoint w e s I h k hhk) hi hk)) + · exact Or.inl (hs h i hi) + have hb := norm_sum_disjoint_le (by simpa only [Family.exponent_toReal] using f.r_pos : 0 < f.exponent.toReal) + Finset.univ v K hK hd (fun h _ => hv h) + change ‖(1/(f.m e.weight : ℝ)) • vec f.exponent (fun i => ∑ h, v h i)‖ ≤ _ + rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg (by positivity : 0 ≤ 1/(f.m e.weight : ℝ))] + calc + _ ≤ (1/(f.m e.weight : ℝ)) * (K*(e.length : ℝ)^(1/f.r)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + simpa only [Family.exponent_toReal,Finset.card_univ,Fintype.card_fin] using hb + _ ≤ (1/(f.m e.weight : ℝ)) * (K*(f.L e.weight : ℝ)^(1/f.r)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow (Nat.cast_nonneg _) (by exact_mod_cast e.length_le) (one_div_nonneg.mpr f.r_pos.le)) hK) (by positivity) + _ = _ := by rw [Family.theta_formula]; ring + +lemma TypeII.sum_vector_norm {f : Family} (e : TypeII f) (s : Finset ℕ) + (v : TypeII.Group e → s → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hv : ∀ g ∈ TypeII.activeGroups e, ‖vec f.exponent (v g)‖ ≤ K*f.theta (TypeII.groupWeight e g)) : + ‖vec f.exponent (fun i => ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * v g i)‖ ≤ K/8 := by + have hr : ∀ g, ‖vec f.exponent (fun i => |(e.coefficient g.1 : ℝ)| * v g i)‖ ≤ ‖vec f.exponent (v g)‖ := by + intro g + change ‖|(e.coefficient g.1 : ℝ)| • vec f.exponent (v g)‖ ≤ _ + rw [norm_smul,Real.norm_eq_abs,abs_abs] + exact (mul_le_mul_of_nonneg_right (e.coefficient_le_one g.1) (norm_nonneg _)).trans_eq (one_mul _) + calc + _ ≤ ∑ g ∈ TypeII.activeGroups e, ‖vec f.exponent (fun i => |(e.coefficient g.1 : ℝ)| * v g i)‖ := by + rw [vec_sum] + exact norm_sum_le _ _ + _ ≤ ∑ g ∈ TypeII.activeGroups e, K*f.theta (TypeII.groupWeight e g) := + Finset.sum_le_sum (fun g hg => (hr g).trans (hv g hg)) + _ = K * ∑ g ∈ TypeII.activeGroups e, f.theta (TypeII.groupWeight e g) := (Finset.mul_sum ..).symm + _ ≤ K*(1/8) := mul_le_mul_of_nonneg_left (TypeII.group_theta_sum e) hK + _ = K/8 := by ring + +lemma TypeI.boundaryCharge_l1 {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeI f) (s : Finset ℕ) (I : Finset s) : + (∑ i : s, TypeI.boundaryCharge w e s I i) ≤ 32*e.length := by + have hm : (1 : ℝ) ≤ f.m e.weight := by exact_mod_cast f.m_pos e.weight + have hb (i : s) : TypeI.boundaryCharge w e s I i ≤ 16*TypeI.boundaryDegree e w.blocks i := by + have hpos := TypeI.boundaryDegree_nonneg e w.blocks i + unfold TypeI.boundaryCharge + split_ifs + · have hd : (TypeI.boundaryDegree e w.blocks i)^(1/f.r) ≤ TypeI.boundaryDegree e w.blocks i := by + unfold TypeI.boundaryDegree + split_ifs with hi + · simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le + (by exact_mod_cast (show 1 ≤ (TypeI.hitChildren e (w.blocks.vector i)).card by omega)) + ((div_le_one f.r_pos).mpr f.r_gt_one.le) + · rw [Real.zero_rpow (ne_of_gt (one_div_pos.mpr f.r_pos))] + exact mul_le_mul (div_le_self (by norm_num) hm) hd (by positivity) (by norm_num) + · positivity + calc + _ ≤ ∑ i : s, 16*TypeI.boundaryDegree e w.blocks i := Finset.sum_le_sum (fun i _ => hb i) + _ = 16 * ∑ i : s, TypeI.boundaryDegree e w.blocks i := (Finset.mul_sum ..).symm + _ ≤ 16*(2*e.length) := mul_le_mul_of_nonneg_left (TypeI.boundaryDegree_sum e w.blocks s) (by norm_num) + _ = _ := by ring + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter FiniteVectors +open scoped Classical Topology + +lemma TypeII.sum_group_mask {f : Family} (e : TypeII f) (x : E) (p : ℕ → Prop) [DecidablePred p] : + (∑ g ∈ TypeII.activeGroups e, if p (TypeII.groupWeight e g) then + (e.coefficient g.1 : ℝ) * norming.evaluateArray x (TypeII.groupValue e g) else 0) = + ∑ g : TypeII.Group e, if p (TypeII.groupWeight e g) then + (e.coefficient g.1 : ℝ) * norming.evaluateArray x (TypeII.groupValue e g) else 0 := by + apply Finset.sum_subset (Finset.filter_subset _ _) + intro g _ hg + have hz : TypeII.groupValue e g = 0 := by + simpa only [TypeII.activeGroups,Finset.mem_filter,Finset.mem_univ,true_and,not_not] using hg + simp [hz] + +lemma TypeII.middle_group_sum {f : Family} (e : TypeII f) (x : E) (lo up : ℕ) : + (∑ g ∈ TypeII.activeGroups e, if lo ≤ TypeII.groupWeight e g ∧ TypeII.groupWeight e g ≤ up then + (e.coefficient g.1 : ℝ) * norming.evaluateArray x (TypeII.groupValue e g) else 0) = + ∑ b, (e.coefficient b : ℝ) * norming.evaluateArray x + (restrict ((e.crop b).set f) ((e.path b).window lo up)) := by + rw [TypeII.sum_group_mask e x (fun j => lo ≤ j ∧ j ≤ up),Fintype.sum_sigma] + apply Finset.sum_congr rfl + intro b _ + simp only [FinitePath.window,restrict_sum,map_sum,Finset.mul_sum] + apply Finset.sum_congr rfl + intro h _ + simp only [TypeII.groupWeight,TypeII.groupValue,(e.path b).weight_eq,(e.path b).value_eq] + split_ifs <;> simp [restrict_zero] + +lemma TypeII.eval_three_parts {f : Family} (e : TypeII f) (x : E) (lo up : ℕ) (hl : lo ≤ up) : + norming.evaluateArray x e.value = + (∑ g ∈ TypeII.activeGroups e, if TypeII.groupWeight e g < lo then + (e.coefficient g.1 : ℝ) * norming.evaluateArray x (TypeII.groupValue e g) else 0) + + (∑ b, (e.coefficient b : ℝ) * norming.evaluateArray x + (restrict ((e.crop b).set f) ((e.path b).window lo up))) + + (∑ g ∈ TypeII.activeGroups e, if up < TypeII.groupWeight e g then + (e.coefficient g.1 : ℝ) * norming.evaluateArray x (TypeII.groupValue e g) else 0) := by + rw [TypeII.eval_group_sum,← TypeII.middle_group_sum,← Finset.sum_add_distrib,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro g _ + by_cases hL : TypeII.groupWeight e g < lo + · have hm : ¬ (lo ≤ TypeII.groupWeight e g ∧ TypeII.groupWeight e g ≤ up) := by omega + have hU : ¬ up < TypeII.groupWeight e g := by omega + simp only [hL,hm,hU,ite_true,ite_false,add_zero] + · by_cases hU : up < TypeII.groupWeight e g + · have hm : ¬ (lo ≤ TypeII.groupWeight e g ∧ TypeII.groupWeight e g ≤ up) := by omega + simp only [hL,hm,hU,ite_true,ite_false,zero_add] + · have hm : lo ≤ TypeII.groupWeight e g ∧ TypeII.groupWeight e g ≤ up := by omega + simp [hL,hU,hm] + +lemma ThinnedWindows.epsilon_pos {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) : 0 < ε := by + have hh := w.threshold_charge_succ 0 + have ht := w.threshold_pos 0 + have hu : (0 : ℝ) ≤ w.upper 0 := Nat.cast_nonneg _ + norm_num at hh + nlinarith + +lemma ThinnedWindows.middle_abs_bound {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (i : s) : + |∑ b, (e.coefficient b : ℝ) * w.middleEval e b i| ≤ w.markedCharge e hm s i + ε := by + calc + _ ≤ ∑ b, |(e.coefficient b : ℝ)| * |w.middleEval e b i| := by + simpa only [abs_mul] using Finset.abs_sum_le_sum_abs (fun b => (e.coefficient b : ℝ)*w.middleEval e b i) Finset.univ + _ = w.markedCharge e hm s i + + ∑ b, if i.val ∉ w.marks e hm s b then |(e.coefficient b : ℝ)| * |w.middleEval e b i| else 0 := by + rw [ThinnedWindows.markedCharge,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro b _ + by_cases hi : i.val ∈ w.marks e hm s b <;> simp [hi] + _ ≤ _ := add_le_add_right (w.unmarked_column w.epsilon_pos.le e hm s i i.property) _ + +lemma ThinnedWindows.node_split {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (i : s) : + |norming.evaluateArray (w.blocks.embed i) e.value| ≤ 2*ε+w.markedCharge e hm s i + + ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * + (if TypeII.groupWeight e g < w.lower i then + |norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g)| else 0) := by + have hh : |∑ g ∈ TypeII.activeGroups e, if w.upper i < TypeII.groupWeight e g then + (e.coefficient g.1 : ℝ)*norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g) else 0| ≤ ε := by + calc + _ ≤ ∑ g ∈ TypeII.activeGroups e, |if w.upper i < TypeII.groupWeight e g then + (e.coefficient g.1 : ℝ)*norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g) else 0| := Finset.abs_sum_le_sum_abs _ _ + _ = ∑ g ∈ (TypeII.activeGroups e).filter (fun g => w.upper i < TypeII.groupWeight e g), + |(e.coefficient g.1 : ℝ)| * |norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g)| := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro g _ + split_ifs <;> simp only [abs_mul,abs_zero] + _ ≤ vectorL1 (w.blocks.vector i) * SeriesTails.tail (fun j => 1/(f.m j : ℝ)) (w.upper i+1) := + TypeII.high_weight_bound e hm (w.blocks.vector i) (w.upper i) + _ ≤ ε := w.tail_small i + have hmB := w.middle_abs_bound e hm s i + have hl : |∑ g ∈ TypeII.activeGroups e, if TypeII.groupWeight e g < w.lower i then + (e.coefficient g.1 : ℝ)*norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g) else 0| ≤ + ∑ g ∈ TypeII.activeGroups e, |(e.coefficient g.1 : ℝ)| * + (if TypeII.groupWeight e g < w.lower i then |norming.evaluateArray (w.blocks.embed i) (TypeII.groupValue e g)| else 0) := by + apply (Finset.abs_sum_le_sum_abs _ _).trans_eq + apply Finset.sum_congr rfl + intro g _ + split_ifs <;> simp only [abs_mul,abs_zero,mul_zero] + rw [TypeII.eval_three_parts e _ _ _ (w.order i)] + exact ((abs_add_le _ _).trans (add_le_add ((abs_add_le _ _).trans (add_le_add hl hmB)) hh)).trans_eq (by ring) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/WindowCharges.lean b/lean/OAI/Analysis/SeparableQuotients/WindowCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec1171f5ff3bfa44213c3dd68f3cbb135284e9a1 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/WindowCharges.lean @@ -0,0 +1,300 @@ +import OAI.Analysis.SeparableQuotients.WindowThinning + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +/-- A crop meets but does not contain an actual finite block support. -/ +def PartialBlock {f : Family} (z : BlockSequence f) (A : Crop) (i : ℕ) : Prop := + (∃ a ∈ (z.vector i).support, a ∈ A.set f) ∧ ¬ (↑(z.vector i).support : Set Γ) ⊆ A.set f + +lemma BlockSequence.partial_crop_le_four {f : Family} (z : BlockSequence f) (A : Crop) (s : Finset ℕ) : + (s.filter (PartialBlock z A)).card ≤ 4 := by + cases f with + | pure k => + have ho := IntervalIncidence.partial_intersections_le_two s (fun i => (z.vector i).support) + (fun i j hij a ha b hb => (z.successive i j hij a ha b hb).1) A.ordinal A.ordinal_convex + have he : s.filter (PartialBlock z A) = + s.filter (fun i => (∃ a ∈ (z.vector i).support, a ∈ A.ordinal) ∧ ¬ (↑(z.vector i).support : Set Γ) ⊆ A.ordinal) := by + ext i + simp [PartialBlock, Crop.set] + rw [he] + omega + | mixed => + have ho := IntervalIncidence.partial_intersections_le_two s (fun i => (z.vector i).support) + (fun i j hij a ha b hb => (z.successive i j hij a ha b hb).1) A.ordinal A.ordinal_convex + let F (i : ℕ) : Finset ℕ := (z.vector i).support.image Colors.color + have hF : ∀ i j, i < j → ∀ a ∈ F i, ∀ b ∈ F j, a < b := by + intro i j hij a ha b hb + obtain ⟨α, hα, rfl⟩ := Finset.mem_image.mp ha + obtain ⟨β, hβ, rfl⟩ := Finset.mem_image.mp hb + exact (z.successive i j hij α hα β hβ).2 rfl + have hc := IntervalIncidence.partial_intersections_le_two s F hF A.colors A.colors_convex + let O := s.filter (fun i => (∃ a ∈ (z.vector i).support, a ∈ A.ordinal) ∧ + ¬ (↑(z.vector i).support : Set Γ) ⊆ A.ordinal) + let C := s.filter (fun i => (∃ a ∈ F i, a ∈ A.colors) ∧ ¬ (↑(F i) : Set ℕ) ⊆ A.colors) + have hsub : s.filter (PartialBlock z A) ⊆ O ∪ C := by + intro i hi + obtain ⟨hi, ⟨a, ha, hao, hac⟩, hnot⟩ := Finset.mem_filter.mp hi + by_cases hO : (↑(z.vector i).support : Set Γ) ⊆ A.ordinal + · apply Finset.mem_union_right + apply Finset.mem_filter.mpr + refine ⟨hi, ⟨Colors.color a, Finset.mem_image.mpr ⟨a, ha, rfl⟩, hac⟩, ?_⟩ + intro hC + apply hnot + intro b hb + exact ⟨hO hb, hC (Finset.mem_image.mpr ⟨b, hb, rfl⟩)⟩ + · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨hi, ⟨a, ha, hao⟩, hO⟩) + exact (Finset.card_le_card hsub).trans ((Finset.card_union_le _ _).trans (by dsimp [O,C]; omega)) + +lemma evaluateArray_crop_finite_fixed {f : Family} (x : Γ →₀ ℝ) (A : Crop) + (hx : (↑x.support : Set Γ) ⊆ A.set f) (g : Array) : + norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) g) = + norming.evaluateArray (norming.includeFinite x) g := by + apply evaluateArray_crop_of_zero + intro a ha + rw [norming.coordinate_includeFinite] + exact Finsupp.notMem_support_iff.mp (fun hh => ha (hx hh)) + +lemma evaluateArray_crop_nonzero_support {f : Family} (x : Γ →₀ ℝ) (A : Crop) (g : Array) + (h : norming.evaluateArray (norming.includeFinite x) (restrict (A.set f) g) ≠ 0) : + ∃ a ∈ x.support, a ∈ A.set f := by + by_contra hn + push Not at hn + apply h + rw [evaluateArray_finite] + apply Finset.sum_eq_zero + intro a ha + simp [restrict_apply, hn a ha] + +lemma crop_or_fixed_of_nonzero {f : Family} (z : BlockSequence f) (A : Crop) (i : ℕ) (g : Array) + (h : norming.evaluateArray (z.embed i) (restrict (A.set f) g) ≠ 0) : + PartialBlock z A i ∨ norming.evaluateArray (z.embed i) (restrict (A.set f) g) = + norming.evaluateArray (z.embed i) g := by + by_cases hh : (↑(z.vector i).support : Set Γ) ⊆ A.set f + · exact Or.inr (evaluateArray_crop_finite_fixed _ _ hh _) + · exact Or.inl ⟨evaluateArray_crop_nonzero_support _ _ _ h, hh⟩ + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +/-- The weighted absolute column estimate, obtained using the actual rational +Type II normers and density of rational coefficients, not an assumed dual ball. -/ +lemma cropped_weighted_abs_sum_bound {f : Family} {h : ℕ} (P : Fin h → FinitePath f) + (A : Fin h → Crop) (hm : ∀ b i j, ((P b).piece i).child j ∈ f.norming) + (hdis : Pairwise (fun i j => Disjoint ((P i).active (A i)) ((P j).active (A j)))) + (c : Fin h → ℝ) (x : E) : + (∑ i, |c i| * |croppedPathFunctional (P i) (A i) x|) ≤ + (∑ i, |c i|^f.q)^(1/f.q) * ‖x‖ := by + let d : Fin h → ℝ := fun i => |c i| * RealCoefficients.signChoice (croppedPathFunctional (P i) (A i) x) + have hd (i : Fin h) : |d i| = |c i| := by simp only [d, abs_mul, abs_abs, RealCoefficients.abs_signChoice, mul_one] + have he : (∑ i, d i • croppedPathFunctional (P i) (A i)) x = + ∑ i, |c i| * |croppedPathFunctional (P i) (A i) x| := by + simp only [sum_apply, smul_apply, smul_eq_mul, d, mul_assoc, RealCoefficients.signChoice_mul] + calc + _ = |(∑ i, d i • croppedPathFunctional (P i) (A i)) x| := by + rw [he, abs_of_nonneg (Finset.sum_nonneg (fun i _ => mul_nonneg (abs_nonneg _) (abs_nonneg _)))] + _ ≤ ‖∑ i, d i • croppedPathFunctional (P i) (A i)‖ * ‖x‖ := + by simpa only [Real.norm_eq_abs] using (∑ i, d i • croppedPathFunctional (P i) (A i)).le_opNorm x + _ ≤ _ := mul_le_mul_of_nonneg_right (by simpa only [hd] using real_cropped_path_bound P A hm hdis d) (norm_nonneg _) + +lemma TypeII.window_column_bound {f : Family} (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) + (J T : ℕ) (c : Fin e.length → ℝ) (x : E) : + (∑ b, |c b| * |norming.evaluateArray x (restrict ((e.crop b).set f) ((e.path b).window J T))|) ≤ + (∑ b, |c b|^f.q)^(1/f.q) * ‖x‖ := by + let A (b : Fin e.length) := ((e.path b).weightCrop J T).inter (e.crop b) + have hd : Pairwise (fun i j => Disjoint ((e.path i).active (A i)) ((e.path j).active (A j))) := by + intro b c hbc + exact (e.disjoint_active hbc).mono (TypeII.active_crop_subset _ _ _) (TypeII.active_crop_subset _ _ _) + have he (b : Fin e.length) : croppedPathFunctional (e.path b) (A b) x = + norming.evaluateArray x (restrict ((e.crop b).set f) ((e.path b).window J T)) := by + change norming.evaluateArray x (restrict ((A b).set f) (e.path b).value) = _ + dsimp only [A] + rw [Crop.inter_set, Set.inter_comm, ← restrict_restrict, FinitePath.weightCrop_value] + simpa only [he] using cropped_weighted_abs_sum_bound e.path A hm hd c x + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +lemma cropped_window_anchor {f : Family} (P : FinitePath f) (A : Crop) (x : E) (J T : ℕ) + (h : norming.evaluateArray x (restrict (A.set f) (P.window J T)) ≠ 0) : + ∃ j ∈ P.active A, J ≤ j ∧ j ≤ T := by + simp only [FinitePath.window, restrict_sum, map_sum] at h + obtain ⟨i, _, hi⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + have hw : J ≤ P.raw.weight i ∧ P.raw.weight i ≤ T := by + by_contra hn + simp only [ite_eq_right hn, restrict_zero, map_zero, ne_eq, not_true_eq_false] at hi + rw [ite_eq_left hw] at hi + refine ⟨P.raw.weight i, Finset.mem_image.mpr ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, rfl⟩, hw⟩ + intro hh + exact hi (by rw [hh, map_zero]) + +/-- Distinct original active weights bound the number of paths contributing +in a window. The +1 version is convenient for zero-based natural indices; +the positive-weight sharper T bound is not needed for the geometric charge. -/ +lemma TypeII.cropped_window_count {f : Family} (e : TypeII f) (x : E) (J T : ℕ) : + (Finset.univ.filter (fun b => norming.evaluateArray x + (restrict ((e.crop b).set f) ((e.path b).window J T)) ≠ 0)).card ≤ T+1 := by + let S := Finset.univ.filter (fun b => norming.evaluateArray x + (restrict ((e.crop b).set f) ((e.path b).window J T)) ≠ 0) + have h (b : S) : ∃ j ∈ (e.path b).active (e.crop b), J ≤ j ∧ j ≤ T := + cropped_window_anchor _ _ _ _ _ (Finset.mem_filter.mp b.property).2 + choose w hw hwJ hwT using h + let v (b : S) : Fin (T+1) := ⟨w b, by have := hwT b; omega⟩ + have hinj : Function.Injective v := by + intro b c hbc + apply Subtype.ext + by_contra hne + have hd := e.disjoint_active hne + have he : w b = w c := congrArg Fin.val hbc + exact Finset.disjoint_left.mp hd (hw b) (he.symm ▸ hw c) + simpa only [Fintype.card_coe, Fintype.card_fin] using Fintype.card_le_of_injective v hinj + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +noncomputable def firstNonzero (s : Finset ℕ) (t : ℕ → ℝ) : ℕ := + if h : (s.filter (fun i => t i ≠ 0)).Nonempty then (s.filter (fun i => t i ≠ 0)).min' h else 0 + +lemma firstNonzero_mem {s : Finset ℕ} {t : ℕ → ℝ} {i : ℕ} (hi : i ∈ s) (ht : t i ≠ 0) : + firstNonzero s t ∈ s ∧ t (firstNonzero s t) ≠ 0 := by + have h : (s.filter (fun i => t i ≠ 0)).Nonempty := ⟨i, Finset.mem_filter.mpr ⟨hi, ht⟩⟩ + rw [firstNonzero, dite_eq_left h] + exact Finset.mem_filter.mp (Finset.min'_mem _ h) + +lemma firstNonzero_le {s : Finset ℕ} {t : ℕ → ℝ} {i : ℕ} (hi : i ∈ s) (ht : t i ≠ 0) : + firstNonzero s t ≤ i := by + have h : (s.filter (fun i => t i ≠ 0)).Nonempty := ⟨i, Finset.mem_filter.mpr ⟨hi, ht⟩⟩ + rw [firstNonzero, dite_eq_left h] + exact Finset.min'_le _ i (Finset.mem_filter.mpr ⟨hi, ht⟩) + +noncomputable def ThinnedWindows.middleEval {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) (b : Fin e.length) (i : ℕ) : ℝ := + norming.evaluateArray (w.blocks.embed i) + (restrict ((e.crop b).set f) ((e.path b).window (w.lower i) (w.upper i))) + +noncomputable def ThinnedWindows.marks {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (b : Fin e.length) : Finset ℕ := + let n := firstNonzero s (w.middleEval e b) + ({n} ∩ s) ∪ (s.filter (PartialBlock w.blocks (e.crop b))) ∪ + (s.filter (fun i => n < i ∧ WindowHit ⟨e.path b, hm b⟩ (w.blocks.vector i) + (w.lower i) (w.upper i) (w.threshold n))) + +lemma ThinnedWindows.marks_card {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (b : Fin e.length) : + (w.marks e hm s b).card ≤ 8 := by + have h1 : ({firstNonzero s (w.middleEval e b)} ∩ s).card ≤ 1 := by + exact (Finset.card_le_card Finset.inter_subset_left).trans (by simp) + have h2 := w.blocks.partial_crop_le_four (e.crop b) s + have h3 := w.hits_after_le_three (firstNonzero s (w.middleEval e b)) s ⟨e.path b, hm b⟩ + unfold marks + apply (Finset.card_union_le _ _).trans + have hh := Finset.card_union_le ({firstNonzero s (w.middleEval e b)} ∩ s) + (s.filter (PartialBlock w.blocks (e.crop b))) + omega + +lemma ThinnedWindows.unmarked_small {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) (b : Fin e.length) + (i : ℕ) (hi : i ∈ s) (ht : w.middleEval e b i ≠ 0) (hmark : i ∉ w.marks e hm s b) : + firstNonzero s (w.middleEval e b) < i ∧ + |w.middleEval e b i| ≤ w.threshold (firstNonzero s (w.middleEval e b)) := by + have hle := firstNonzero_le hi ht + have hne : i ≠ firstNonzero s (w.middleEval e b) := by + intro hh + apply hmark + exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_inter.mpr ⟨Finset.mem_singleton.mpr hh, hi⟩)) + have hlt : firstNonzero s (w.middleEval e b) < i := lt_of_le_of_ne hle (Ne.symm hne) + have hp : ¬ PartialBlock w.blocks (e.crop b) i := by + intro hh + exact hmark (Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨hi,hh⟩))) + have hn : ¬ WindowHit ⟨e.path b, hm b⟩ (w.blocks.vector i) (w.lower i) (w.upper i) + (w.threshold (firstNonzero s (w.middleEval e b))) := by + intro hh + exact hmark (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨hi,hlt,hh⟩)) + have he := (crop_or_fixed_of_nonzero w.blocks (e.crop b) i + ((e.path b).window (w.lower i) (w.upper i)) ht).resolve_left hp + refine ⟨hlt, ?_⟩ + change |norming.evaluateArray (w.blocks.embed i) _| ≤ _ + rw [he] + exact le_of_not_gt hn + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +lemma geometric_charge_le (ε : ℝ) (hε : 0 ≤ ε) (i : ℕ) : + (∑ n ∈ Finset.range i, ε*(1/2 : ℝ)^(n+1)) ≤ ε := by + have he : ∀ i, (∑ n ∈ Finset.range i, ε*(1/2 : ℝ)^(n+1)) = ε*(1-(1/2 : ℝ)^i) := by + intro k + induction k with + | zero => simp + | succ k ih => rw [Finset.sum_range_succ, ih, pow_succ]; ring + rw [he] + nlinarith [pow_nonneg (by norm_num : (0 : ℝ) ≤ 1/2) i] + +lemma ThinnedWindows.unmarked_column {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (hε : 0 ≤ ε) (e : TypeII f) + (hm : ∀ b i j, ((e.path b).piece i).child j ∈ f.norming) (s : Finset ℕ) + (i : ℕ) (hi : i ∈ s) : + (∑ b, if i ∉ w.marks e hm s b then |(e.coefficient b : ℝ)| * |w.middleEval e b i| else 0) ≤ ε := by + let U : Finset (Fin e.length) := Finset.univ.filter + (fun b => w.middleEval e b i ≠ 0 ∧ i ∉ w.marks e hm s b) + let first (b : Fin e.length) := firstNonzero s (w.middleEval e b) + have hU (b : Fin e.length) (hb : b ∈ U) : first b < i ∧ |w.middleEval e b i| ≤ w.threshold (first b) := + w.unmarked_small e hm s b i hi (Finset.mem_filter.mp hb).2.1 (Finset.mem_filter.mp hb).2.2 + have hcount (n : ℕ) : (U.filter (fun b => first b = n)).card ≤ w.upper n+1 := by + apply le_trans (Finset.card_le_card ?_) (TypeII.cropped_window_count e (w.blocks.embed n) (w.lower n) (w.upper n)) + intro b hb + have hbU := Finset.mem_filter.mp hb + have hn := (firstNonzero_mem hi (Finset.mem_filter.mp hbU.1).2.1).2 + change w.middleEval e b (first b) ≠ 0 at hn + rw [hbU.2] at hn + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hn⟩ + calc + _ = ∑ b ∈ U, |(e.coefficient b : ℝ)| * |w.middleEval e b i| := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro b _ + by_cases ht : w.middleEval e b i = 0 <;> by_cases hm' : i ∈ w.marks e hm s b <;> simp [ht,hm'] + _ ≤ ∑ b ∈ U, w.threshold (first b) := Finset.sum_le_sum (fun b hb => + (mul_le_mul_of_nonneg_right (e.coefficient_le_one b) (abs_nonneg _)).trans (by simpa using (hU b hb).2)) + _ = ∑ n ∈ Finset.range i, ∑ b ∈ U.filter (fun b => first b = n), w.threshold (first b) := + (Finset.sum_fiberwise_of_maps_to (fun b hb => Finset.mem_range.mpr (hU b hb).1) _).symm + _ = ∑ n ∈ Finset.range i, ((U.filter (fun b => first b = n)).card : ℝ)*w.threshold n := by + apply Finset.sum_congr rfl + intro n _ + rw [show (∑ b ∈ U.filter (fun b => first b = n), w.threshold (first b)) = + ∑ b ∈ U.filter (fun b => first b = n), w.threshold n from + Finset.sum_congr rfl (fun b hb => by rw [(Finset.mem_filter.mp hb).2])] + simp + _ ≤ ∑ n ∈ Finset.range i, ε*(1/2 : ℝ)^(n+1) := by + apply Finset.sum_le_sum + intro n _ + rw [← w.threshold_charge_succ n] + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hcount n) (w.threshold_pos n).le + _ ≤ ε := geometric_charge_le ε hε i + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/WindowEstimates.lean b/lean/OAI/Analysis/SeparableQuotients/WindowEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..33f3995001dfda9f8b15402019f61a117cbe369d --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/WindowEstimates.lean @@ -0,0 +1,321 @@ +import OAI.Analysis.SeparableQuotients.PathRigidity + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.SeriesTails +open Filter +open scoped Topology Classical + +noncomputable def tail (a : ℕ → ℝ) (N : ℕ) : ℝ := ∑' k, a (k+N) + +lemma tendsto_tail (a : ℕ → ℝ) : Tendsto (tail a) atTop (𝓝 0) := + tendsto_sum_nat_add a + +lemma tail_nonneg (a : ℕ → ℝ) (ha : ∀ n, 0 ≤ a n) (N : ℕ) : 0 ≤ tail a N := + tsum_nonneg (fun _ => ha _) + +lemma sum_le_tail {ι : Type*} (a : ℕ → ℝ) (ha : Summable a) (hn : ∀ n, 0 ≤ a n) + (s : Finset ι) (w : ι → ℕ) (hi : Set.InjOn w s) (N : ℕ) (hN : ∀ i ∈ s, N ≤ w i) : + ∑ i ∈ s, a (w i) ≤ tail a N := by + have hinj : Set.InjOn (fun i => w i - N) s := by + intro i hi' j hj' hij + apply hi hi' hj' + have h1 := hN i hi' + have h2 := hN j hj' + change w i - N = w j - N at hij + omega + calc + ∑ i ∈ s, a (w i) = ∑ i ∈ s, a ((w i-N)+N) := by + exact Finset.sum_congr rfl (fun i hi => by rw [Nat.sub_add_cancel (hN i hi)]) + _ = ∑ k ∈ s.image (fun i => w i-N), a (k+N) := by + symm + apply Finset.sum_image + exact hinj + _ ≤ tail a N := ((summable_nat_add_iff N).mpr ha).sum_le_tsum _ (fun _ _ => hn _) + +end SeparableQuotient.SeriesTails + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter +open scoped Classical Topology + +lemma evaluateArray_finite (x : Γ →₀ ℝ) (g : Array) : + norming.evaluateArray (norming.includeFinite x) g = ∑ a ∈ x.support, (g a : ℝ) * x a := by + rw [norming.evaluateArray_eq] + simp only [norming.coordinate_includeFinite] + have h1 : ∑ a ∈ g.support, (g a : ℝ) * x a = + ∑ a ∈ g.support ∪ x.support, (g a : ℝ) * x a := by + apply Finset.sum_subset Finset.subset_union_left + intro a _ ha + simp [Finsupp.notMem_support_iff.mp ha] + have h2 : ∑ a ∈ x.support, (g a : ℝ) * x a = + ∑ a ∈ g.support ∪ x.support, (g a : ℝ) * x a := by + apply Finset.sum_subset Finset.subset_union_right + intro a _ ha + simp [Finsupp.notMem_support_iff.mp ha] + exact h1.trans h2.symm + +noncomputable def vectorL1 (x : Γ →₀ ℝ) : ℝ := ∑ a ∈ x.support, |x a| + +lemma vectorL1_nonneg (x : Γ →₀ ℝ) : 0 ≤ vectorL1 x := + Finset.sum_nonneg (fun _ _ => abs_nonneg _) + +lemma typeI_eval_le_l1 {f : Family} (e : TypeI f) + (hm : ∀ j, e.child j ∈ f.norming) (x : Γ →₀ ℝ) : + |norming.evaluateArray (norming.includeFinite x) e.value| ≤ + vectorL1 x * (1 / (f.m e.weight : ℝ)) := by + rw [evaluateArray_finite] + calc + |∑ a ∈ x.support, (e.value a : ℝ) * x a| ≤ ∑ a ∈ x.support, |(e.value a : ℝ) * x a| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ a ∈ x.support, |x a| * (1 / (f.m e.weight : ℝ)) := by + apply Finset.sum_le_sum + intro a _ + rw [abs_mul, mul_comm] + exact mul_le_mul_of_nonneg_left (e.coefficient_bound + (fun j a => full_coefficient_bound _ (f.norming_subset_full (hm j)) a) a) (abs_nonneg _) + _ = _ := by rw [← Finset.sum_mul]; rfl + +lemma path_piece_zero_of_earlier_hit {f : Family} (P : LegalFinitePath f) + (x y : Γ →₀ ℝ) (hs : ∀ a ∈ x.support, ∀ b ∈ y.support, a < b) + (J T : ℕ) (δ : ℝ) (hδ : 0 < δ) (hh : WindowHit P x J T δ) + (i : Fin P.val.length) (hi : P.val.raw.weight i < J) : + norming.evaluateArray (norming.includeFinite y) (P.val.raw.piece i) = 0 := by + obtain ⟨j, hj, _, a, ha, ha'⟩ := hh.anchor hδ + have hij : i < j := P.val.valid.weight_strict.lt_iff_lt.mp (hi.trans_le hj) + rw [evaluateArray_finite] + apply Finset.sum_eq_zero + intro b hb + have hz : P.val.raw.piece i b = 0 := by + by_contra hn + have hba := P.val.valid.successive i j hij j.isLt b + (Finsupp.mem_support_iff.mpr hn) a ha' + exact (lt_asymm hba (hs a ha b hb)) + simp only [hz, Rat.cast_zero, zero_mul] + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.Norming +open scoped Classical + +lemma Family.theta_summable (f : Family) : Summable f.theta := by + apply (summable_nat_add_iff 1).mp + simpa only [Family.theta, Nat.add_sub_cancel] using (Parameters.hasSum_theta f.s_ge_two).summable + +lemma Family.m_inv_summable (f : Family) : Summable (fun j => 1 / (f.m j : ℝ)) := by + apply (summable_nat_add_iff 1).mp + simpa only [Family.m, Nat.add_sub_cancel] using f.reciprocal_summable + +end SeparableQuotient.Norming + +namespace SeparableQuotient.SeriesTails +open scoped Classical + +lemma sum_outside_window_bound {ι : Type*} (s : Finset ι) (w : ι → ℕ) (v : ι → ℝ) + (hi : Set.InjOn w s) (B J T : ℕ) (hBJ : B ≤ J) (hJT : J ≤ T) + (a b : ℕ → ℝ) (ha : Summable a) (hb : Summable b) + (han : ∀ n, 0 ≤ a n) (hbn : ∀ n, 0 ≤ b n) + (A C : ℝ) (hA : 0 ≤ A) (hC : 0 ≤ C) + (hz : ∀ i ∈ s, w i < B → v i = 0) + (hl : ∀ i ∈ s, B ≤ w i → w i < J → |v i| ≤ A * a (w i)) + (hh : ∀ i ∈ s, T < w i → |v i| ≤ C * b (w i)) : + |(∑ i ∈ s, v i) - ∑ i ∈ s, if J ≤ w i ∧ w i ≤ T then v i else 0| ≤ + A * tail a B + C * tail b (T+1) := by + let lo := s.filter (fun i => B ≤ w i ∧ w i < J) + let hi' := s.filter (fun i => T < w i) + have heq : (∑ i ∈ s, v i) - (∑ i ∈ s, if J ≤ w i ∧ w i ≤ T then v i else 0) = + (∑ i ∈ lo, v i) + ∑ i ∈ hi', v i := by + rw [← Finset.sum_sub_distrib] + simp only [lo, hi', Finset.sum_filter, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i his + by_cases h1 : w i < B + · have h2 : ¬ (J ≤ w i ∧ w i ≤ T) := by omega + have h3 : ¬ (B ≤ w i ∧ w i < J) := by omega + have h4 : ¬ T < w i := by omega + simp only [hz i his h1, ite_eq_right h2, ite_eq_right h3, ite_eq_right h4, sub_self, add_zero] + · by_cases h2 : w i < J + · have h3 : ¬ (J ≤ w i ∧ w i ≤ T) := by omega + have h4 : B ≤ w i ∧ w i < J := by omega + have h5 : ¬ T < w i := by omega + simp only [ite_eq_right h3, ite_eq_left h4, ite_eq_right h5, sub_zero, add_zero] + · by_cases h3 : w i ≤ T + · have h4 : J ≤ w i ∧ w i ≤ T := by omega + have h5 : ¬ (B ≤ w i ∧ w i < J) := by omega + have h6 : ¬ T < w i := by omega + simp only [ite_eq_left h4, ite_eq_right h5, ite_eq_right h6, sub_self, add_zero] + · have h4 : ¬ (J ≤ w i ∧ w i ≤ T) := by omega + have h5 : ¬ (B ≤ w i ∧ w i < J) := by omega + have h6 : T < w i := by omega + simp only [ite_eq_right h4, ite_eq_right h5, ite_eq_left h6, sub_zero, zero_add] + have hlo : |∑ i ∈ lo, v i| ≤ A * tail a B := by + calc + _ ≤ ∑ i ∈ lo, |v i| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i ∈ lo, A * a (w i) := Finset.sum_le_sum (fun i his => + hl i (Finset.mem_filter.mp his).1 (Finset.mem_filter.mp his).2.1 (Finset.mem_filter.mp his).2.2) + _ = A * ∑ i ∈ lo, a (w i) := (Finset.mul_sum _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_left (sum_le_tail a ha han lo w + (hi.mono (Finset.filter_subset _ _)) B (fun i his => (Finset.mem_filter.mp his).2.1)) hA + have hhi : |∑ i ∈ hi', v i| ≤ C * tail b (T+1) := by + calc + _ ≤ ∑ i ∈ hi', |v i| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i ∈ hi', C * b (w i) := Finset.sum_le_sum (fun i his => + hh i (Finset.mem_filter.mp his).1 (Finset.mem_filter.mp his).2) + _ = C * ∑ i ∈ hi', b (w i) := (Finset.mul_sum _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_left (sum_le_tail b hb hbn hi' w + (hi.mono (Finset.filter_subset _ _)) (T+1) (fun i his => (Finset.mem_filter.mp his).2)) hC + rw [heq] + exact (abs_add_le _ _).trans (add_le_add hlo hhi) + +end SeparableQuotient.SeriesTails + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +lemma finitePathFunctional_apply {f : Family} (P : LegalFinitePath f) (x : E) : + finitePathFunctional P.val P.property x = norming.evaluateArray x P.val.value := by + exact (norming.evaluateArray_eq_functional x ⟨P.val.value, finitePath_mem_full P.val P.property⟩).symm + +lemma window_error_bound {f : Family} (P : LegalFinitePath f) + (x y : Γ →₀ ℝ) (hs : ∀ a ∈ x.support, ∀ b ∈ y.support, a < b) + (B S J T : ℕ) (hBJ : B ≤ J) (hJT : J ≤ T) + (δ A : ℝ) (hδ : 0 < δ) (hA : 0 ≤ A) (hh : WindowHit P x B S δ) + (hl : ∀ e : TypeI f, (∀ j, e.child j ∈ f.norming) → e.weight < J → + |norming.evaluateArray (norming.includeFinite y) e.value| ≤ A * f.theta e.weight) : + |finitePathFunctional P.val P.property (norming.includeFinite y) - + norming.evaluateArray (norming.includeFinite y) (P.val.window J T)| ≤ + A * tail f.theta B + vectorL1 y * tail (fun j => 1 / (f.m j : ℝ)) (T+1) := by + rw [finitePathFunctional_apply] + simp only [FinitePath.value, FinitePath.window, map_sum, apply_ite, map_zero] + apply sum_outside_window_bound Finset.univ (fun i : Fin P.val.length => P.val.raw.weight i) + _ P.val.valid.weight_strict.injective.injOn B J T hBJ hJT f.theta + (fun j => 1 / (f.m j : ℝ)) f.theta_summable f.m_inv_summable f.theta_nonneg + (fun _ => by positivity) A (vectorL1 y) hA (vectorL1_nonneg y) + · exact fun i _ hi => path_piece_zero_of_earlier_hit P x y hs B S δ hδ hh i hi + · intro i _ _ hi + rw [← P.val.weight_eq i] at hi + simpa only [P.val.value_eq, P.val.weight_eq] using hl (P.val.piece i) (P.property i) hi + · intro i _ _ + rw [← P.val.value_eq i, ← P.val.weight_eq i] + exact typeI_eval_le_l1 (P.val.piece i) (P.property i) y + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.CoverRecurrence +open Filter +open scoped Classical Topology + +/-- Uniformly finite covers of all initial segments give a single sequence of +covering objects which eventually hits every member of an infinite fixed set. +No compactness of the covering objects themselves is assumed. -/ +lemma recurrent_of_covers {Λ : Type*} (Hit : Λ → ℕ → Prop) (D : ℕ) + (hcover : ∀ n, ∃ R : Finset Λ, R.card ≤ D ∧ ∀ i ≤ n, ∃ P ∈ R, Hit P i) : + ∃ (P : ℕ → Λ) (W : Set ℕ), W.Infinite ∧ ∀ i ∈ W, ∀ᶠ n in atTop, Hit (P n) i := by + choose R hR hhit using hcover + have hfunc (n : ℕ) : ∃ P : Fin (D+1) → Λ, ∀ i ≤ n, ∃ b, Hit (P b) i := by + obtain ⟨p₀, hp₀, _⟩ := hhit n 0 (Nat.zero_le _) + let e : Fin (R n).card ≃ R n := (R n).equivFin.symm + let P : Fin (D+1) → Λ := fun b => if hb : b.val < (R n).card then (e ⟨b, hb⟩).val else p₀ + refine ⟨P, fun i hi => ?_⟩ + obtain ⟨p, hp, hh⟩ := hhit n i hi + let j := e.symm ⟨p, hp⟩ + let b : Fin (D+1) := ⟨j.val, j.isLt.trans_le ((hR n).trans (Nat.le_succ D))⟩ + refine ⟨b, ?_⟩ + have hb : b.val < (R n).card := j.isLt + change Hit (P b) i + rw [show P b = p from by + dsimp only [P] + rw [dite_eq_left hb] + change (e (e.symm ⟨p, hp⟩)).val = p + rw [e.apply_symm_apply]] + exact hh + choose P hP using hfunc + let c : ℕ → ℕ → Fin (D+1) := fun n i => if hi : i ≤ n then (hP n i hi).choose else 0 + have hc (n i : ℕ) (hi : i ≤ n) : Hit (P n (c n i)) i := by + simpa only [c, dite_eq_left hi] using (hP n i hi).choose_spec + obtain ⟨l, _, φ, hφ, hl⟩ := isCompact_univ.tendsto_subseq + (x := c) (fun _ => Set.mem_univ _) + obtain ⟨b, hb⟩ := Finite.exists_infinite_fiber l + refine ⟨fun n => P (φ n) b, {i | l i = b}, Set.infinite_coe_iff.mp hb, fun i hi => ?_⟩ + have he : ∀ᶠ n in atTop, c (φ n) i = l i := by + simpa only [nhds_discrete, tendsto_pure, Function.comp_apply] using (tendsto_pi_nhds.mp hl i) + filter_upwards [he, eventually_ge_atTop i] with n hn hin + have hh := hc (φ n) i (hin.trans (hφ.id_le n)) + rwa [hn, hi] at hh + +end SeparableQuotient.CoverRecurrence + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +/-- Pathwise nullity excludes four recurrent hits by reconstruction of a limiting infinite path. -/ +lemma not_all_four_hits {f : Family} (x : ℕ → Γ →₀ ℝ) (J T : ℕ → ℕ) + (hJT : ∀ i, J i ≤ T i) + (horder : ∀ i j, i < j → T i < J j) + (hs : ∀ i j, i < j → ∀ a ∈ (x i).support, ∀ b ∈ (x j).support, a < b) + (hcoh : ∀ i j, i < j → ∀ a ∈ (x i).support, ∀ b ∈ (x i).support, + rho (min a b) (max a b) ≤ J j) + (M A δ : ℝ) (hM : ∀ i, ‖norming.includeFinite (x i)‖ ≤ M) (hA : 0 ≤ A) (hδ : 0 < δ) + (hlow : ∀ i (e : TypeI f), (∀ j, e.child j ∈ f.norming) → e.weight < J i → + |norming.evaluateArray (norming.includeFinite (x i)) e.value| ≤ A * f.theta e.weight) + (htail : Tendsto (fun i => vectorL1 (x i) * tail (fun j => 1 / (f.m j : ℝ)) (T i+1)) atTop (𝓝 0)) + (hnull : ∀ Q : InfinitePath f, Tendsto (fun i => pathFunctional Q (norming.includeFinite (x i))) atTop (𝓝 0)) : + ¬ (∀ w v t k : ℕ, w < v → v < t → t < k → + ∃ P : LegalFinitePath f, WindowHit P (x w) (J w) (T w) δ ∧ + WindowHit P (x v) (J v) (T v) δ ∧ WindowHit P (x t) (J t) (T t) δ ∧ + WindowHit P (x k) (J k) (T k) δ) := by + intro hall + obtain ⟨D, hD⟩ := finite_window_covers x J T horder hcoh M δ hM hδ hall + obtain ⟨P, W, hW, hP⟩ := CoverRecurrence.recurrent_of_covers + (fun P i => WindowHit P (x i) (J i) (T i) δ) D hD + have hJ : StrictMono J := fun i j hij => (hJT i).trans_lt (horder i j hij) + have hwin (B : ℕ) : ∃ T' : ℕ, ∃ s : Finset Γ, ∀ᶠ n in atTop, + ∃ i < (P n).val.length, B < (P n).val.raw.weight i ∧ (P n).val.raw.weight i ≤ T' ∧ + ∃ a ∈ s, a ∈ ((P n).val.raw.piece i).support := by + obtain ⟨i, hi, hBi⟩ := hW.exists_gt B + refine ⟨T i, (x i).support, (hP i hi).mono fun n hn => ?_⟩ + obtain ⟨j, hj, hj', a, ha, ha'⟩ := hn.anchor hδ + exact ⟨j, j.isLt, hBi.trans_le ((hJ.id_le i).trans hj), hj', a, ha, ha'⟩ + obtain ⟨φ, Q, hφ, hQ⟩ := path_of_recurrent_windows (fun n => (P n).val) + (fun n => (P n).property) hwin + have hlim (i : ℕ) := stabilized_path_tendsto (fun n => (P (φ n)).val) + (fun n => (P (φ n)).property) Q + (fun j => (hQ j).mono fun _ hn => ⟨hn.1, hn.2.1, hn.2.2.1⟩) (norming.includeFinite (x i)) + have ht : Tendsto (fun i => A * tail f.theta (J i)) atTop (𝓝 0) := by + simpa only [mul_zero, Function.comp_def] using tendsto_const_nhds.mul ((tendsto_tail f.theta).comp hJ.tendsto_atTop) + obtain ⟨N₀, hN₀⟩ := eventually_atTop.mp (ht.eventually (gt_mem_nhds (by linarith : (0:ℝ) < δ/4))) + obtain ⟨w₀, hw₀, hNw₀⟩ := hW.exists_gt N₀ + have hsmall : A * tail f.theta (J w₀) < δ/4 := hN₀ _ hNw₀.le + obtain ⟨N₁, hN₁⟩ := eventually_atTop.mp (htail.eventually (gt_mem_nhds (by linarith : (0:ℝ) < δ/4))) + have hn : Tendsto (fun i => |pathFunctional Q (norming.includeFinite (x i))|) atTop (𝓝 0) := by + simpa only [abs_zero] using (hnull Q).abs + obtain ⟨N₂, hN₂⟩ := eventually_atTop.mp (hn.eventually (gt_mem_nhds (by linarith : (0:ℝ) < δ/2))) + obtain ⟨i, hi, hBig⟩ := hW.exists_gt (max w₀ (max N₁ N₂)) + have hwi : w₀ < i := (le_max_left _ _).trans_lt hBig + have hN1i : N₁ ≤ i := (le_trans (le_max_left _ _) (le_max_right _ _)).trans hBig.le + have hN2i : N₂ ≤ i := (le_trans (le_max_right _ _) (le_max_right _ _)).trans hBig.le + have hbound : ∀ᶠ n in atTop, + δ/2 ≤ |finitePathFunctional (P (φ n)).val (P (φ n)).property (norming.includeFinite (x i))| := by + filter_upwards [(hP w₀ hw₀).filter_mono hφ.tendsto_atTop, (hP i hi).filter_mono hφ.tendsto_atTop] with n hn₀ hni + have he := window_error_bound (P (φ n)) (x w₀) (x i) (hs w₀ i hwi) + (J w₀) (T w₀) (J i) (T i) (hJ.monotone hwi.le) (hJT i) δ A hδ hA hn₀ (hlow i) + have ht' := hN₁ i hN1i + have ha := abs_sub_abs_le_abs_sub + (norming.evaluateArray (norming.includeFinite (x i)) ((P (φ n)).val.window (J i) (T i))) + (finitePathFunctional (P (φ n)).val (P (φ n)).property (norming.includeFinite (x i))) + rw [abs_sub_comm] at ha + change δ < |norming.evaluateArray (norming.includeFinite (x i)) ((P (φ n)).val.window (J i) (T i))| at hni + linarith + have hge : δ/2 ≤ |pathFunctional Q (norming.includeFinite (x i))| := + ge_of_tendsto (hlim i).abs hbound + exact (not_lt_of_ge hge) (hN₂ i hN2i) + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SeparableQuotients/WindowThinning.lean b/lean/OAI/Analysis/SeparableQuotients/WindowThinning.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea14100a64a2f3cacef5a8a9e0f32f42ca9358c5 --- /dev/null +++ b/lean/OAI/Analysis/SeparableQuotients/WindowThinning.lean @@ -0,0 +1,310 @@ +import OAI.Analysis.SeparableQuotients.TailBlocks + +namespace OAI + +noncomputable section + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +lemma FamilyL_mono (f : Family) : Monotone f.L := by + intro i j hij + exact (Parameters.L_strict f.s_ge_two).monotone (Nat.sub_le_sub_right hij 1) + +lemma tail_sub_mul_le {f : Family} (x y : Γ →₀ ℝ) (T U : ℕ) (hTU : T ≤ U) : + vectorL1 (x-y) * tail (fun j => 1/(f.m j : ℝ)) (U+1) ≤ + vectorL1 x * tail (fun j => 1/(f.m j : ℝ)) (T+1) + + vectorL1 y * tail (fun j => 1/(f.m j : ℝ)) (U+1) := by + have hn : ∀ j, 0 ≤ 1/(f.m j : ℝ) := fun _ => by positivity + calc + _ ≤ (vectorL1 x+vectorL1 y) * tail (fun j => 1/(f.m j : ℝ)) (U+1) := + mul_le_mul_of_nonneg_right (vectorL1_sub_le x y) (tail_nonneg _ hn _) + _ = vectorL1 x * tail (fun j => 1/(f.m j : ℝ)) (U+1) + + vectorL1 y * tail (fun j => 1/(f.m j : ℝ)) (U+1) := by ring + _ ≤ _ := add_le_add (mul_le_mul_of_nonneg_left + (tail_antitone _ f.m_inv_summable hn (Nat.add_le_add_right hTU 1)) (vectorL1_nonneg x)) le_rfl + +/-- Window blocks with partition estimates, pathwise nullity, and coherent support bounds. -/ +structure WindowBlocks {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (a : ℕ) where + blocks : BlockSequence f + lower : ℕ → ℕ + upper : ℕ → ℕ + mem_tail : ∀ n, blocks.vector n ∈ z.tailSpan a + lower_norm : ∀ n, 1 ≤ ‖blocks.embed n‖ + upper_norm : ∀ n, ‖blocks.embed n‖ ≤ 2 + prescribed : ∀ n, J < lower n + order : ∀ n, lower n ≤ upper n + separated : ∀ i j, i < j → upper i < lower j + coherence : ∀ i j k, j < i → k < i → ∀ α ∈ (blocks.vector j).support, + ∀ β ∈ (blocks.vector k).support, rho (min α β) (max α β) < lower i + partition : ∀ n, PartitionBound (blocks.embed n) (f.L (lower n)) 16 f.r + tail_small : ∀ n, vectorL1 (blocks.vector n) * tail (fun j => 1/(f.m j : ℝ)) (upper n+1) ≤ ε + tail_vanish : Tendsto (fun n => vectorL1 (blocks.vector n) * tail (fun j => 1/(f.m j : ℝ)) (upper n+1)) atTop (𝓝 0) + path_null : ∀ P : InfinitePath f, Tendsto (fun n => pathFunctional P (blocks.embed n)) atTop (𝓝 0) + +lemma exists_windowBlocks {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (hε : 0 < ε) (a : ℕ) : + Nonempty (WindowBlocks z J ε a) := by + let d := preliminaryData z J ε hε a + let u := preliminaryBlocks z J ε hε a + have hu (n : ℕ) : ‖u.embed n‖ = 1 := (d n).unit + obtain ⟨φ, hφ, hC⟩ := u.all_paths_cauchy 1 (fun n => (hu n).le) + let v := u.subsequence φ hφ + have hv (n : ℕ) : ‖v.embed n‖ = 1 := hu (φ n) + let x := v.pairDifferences hv + let lo (n : ℕ) := (d (φ (2*n))).lower + let up (n : ℕ) := (d (φ (2*n+1))).upper + have hx (n : ℕ) : x.vector n = (d (φ (2*n))).vector - (d (φ (2*n+1))).vector := rfl + have hord {i j : ℕ} (hij : i < j) : (d i).upper < (d j).lower := + preliminaryData_order z J ε hε a i j hij + have hfin {i j : ℕ} (hij : i < j) : (d i).finish ≤ (d j).start := + preliminaryData_finish_le_start z J ε hε a i j hij + have hstart (n : ℕ) : a ≤ (d n).start := by + rw [← preliminaryData_start_zero z J ε hε a] + exact preliminaryData_start_mono z J ε hε a (Nat.zero_le n) + have hup (n : ℕ) : (d (φ (2*n))).upper ≤ (d (φ (2*n+1))).upper := + (hord (hφ (by omega))).le.trans (d (φ (2*n+1))).order + have htail (n : ℕ) : vectorL1 (x.vector n) * tail (fun j => 1/(f.m j : ℝ)) (up n+1) ≤ + vectorL1 (d (φ (2*n))).vector * tail (fun j => 1/(f.m j : ℝ)) ((d (φ (2*n))).upper+1) + + vectorL1 (d (φ (2*n+1))).vector * tail (fun j => 1/(f.m j : ℝ)) ((d (φ (2*n+1))).upper+1) := by + rw [hx] + exact tail_sub_mul_le _ _ _ _ (hup n) + have hdec (n : ℕ) : vectorL1 (x.vector n) * tail (fun j => 1/(f.m j : ℝ)) (up n+1) ≤ 2/(n+1 : ℝ) := by + have he : (n : ℝ)+1 ≤ (φ (2*n) : ℝ)+1 := by exact_mod_cast (show n+1 ≤ φ (2*n)+1 by + have hh : 2*n ≤ φ (2*n) := hφ.id_le (2*n) + omega) + have ho : (n : ℝ)+1 ≤ (φ (2*n+1) : ℝ)+1 := by exact_mod_cast (show n+1 ≤ φ (2*n+1)+1 by + have hh : 2*n+1 ≤ φ (2*n+1) := hφ.id_le (2*n+1) + omega) + calc + _ ≤ 1/(φ (2*n)+1 : ℝ) + 1/(φ (2*n+1)+1 : ℝ) := + (htail n).trans (add_le_add (d (φ (2*n))).tail_vanish (d (φ (2*n+1))).tail_vanish) + _ ≤ 1/(n+1 : ℝ) + 1/(n+1 : ℝ) := add_le_add (one_div_le_one_div_of_le (by positivity) he) + (one_div_le_one_div_of_le (by positivity) ho) + _ = _ := by ring + refine ⟨{ + blocks := x + lower := lo + upper := up + mem_tail := ?_ + lower_norm := fun n => (v.pairDifferences_norm hv n).1 + upper_norm := fun n => (v.pairDifferences_norm hv n).2 + prescribed := fun n => (d (φ (2*n))).prescribed + order := ?_ + separated := ?_ + coherence := ?_ + partition := ?_ + tail_small := ?_ + tail_vanish := ?_ + path_null := v.pairDifferences_path_null hv hC }⟩ + · intro n + rw [hx] + exact (z.tailSpan a).sub_mem (z.tailSpan_mono (hstart _) (d _).mem) + (z.tailSpan_mono (hstart _) (d _).mem) + · intro n + exact ((d (φ (2*n))).order.trans (hup n)) + · intro i j hij + exact hord (hφ (by omega : 2*i+1 < 2*j)) + · intro i j k hji hki α hα β hβ + have hprefix (t : ℕ) (hti : t < i) {γ : Γ} (hγ : γ ∈ (x.vector t).support) : γ ∈ z.prefixSupport (d (φ (2*i))).start := by + rw [hx] at hγ + rcases Finset.mem_union.mp (Finsupp.support_sub hγ) with hh | hh + · exact z.prefixSupport_mono (hfin (hφ (by omega))) ((d _).support hh) + · exact z.prefixSupport_mono (hfin (hφ (by omega))) ((d _).support hh) + exact (z.le_prefixRho _ (hprefix j hji hα) (hprefix k hki hβ)).trans_lt (d (φ (2*i))).coherence + · intro n + have hLow : (d (φ (2*n))).lower ≤ (d (φ (2*n+1))).lower := + (d (φ (2*n))).order.trans (hord (hφ (by omega : 2*n < 2*n+1))).le + have hL := FamilyL_mono f hLow + have hh := (d (φ (2*n))).partition.sub ((d (φ (2*n+1))).partition.mono hL) + change PartitionBound (norming.includeFinite (x.vector n)) _ 16 _ + rw [hx, map_sub] + simpa only [lo, show (8 : ℝ)+8 = 16 by norm_num] using hh + · intro n + exact (htail n).trans (by linarith [(d (φ (2*n))).tail_small, (d (φ (2*n+1))).tail_small]) + · have ht : Tendsto (fun n : ℕ => 2/(n+1 : ℝ)) atTop (𝓝 0) := by + simpa only [mul_zero, mul_one_div] using (tendsto_const_nhds.mul + (tendsto_one_div_add_atTop_nhds_zero_nat : Tendsto (fun n : ℕ => 1/(n+1 : ℝ)) atTop (𝓝 0))) + apply squeeze_zero _ hdec ht + intro n + exact mul_nonneg (vectorL1_nonneg _) (tail_nonneg _ (fun _ => by positivity) _) + +lemma WindowBlocks.four_hits {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : WindowBlocks z J ε a) (δ : ℝ) (hδ : 0 < δ) (N : Set ℕ) (hN : N.Infinite) : + ∃ W ⊆ N, W.Infinite ∧ ∀ S : Finset ℕ, (↑S : Set ℕ) ⊆ W → S.card = 4 → + ¬ ∃ P : LegalFinitePath f, ∀ i ∈ S, WindowHit P (w.blocks.vector i) (w.lower i) (w.upper i) δ := by + apply four_hits_thinning _ _ _ w.order w.separated + (fun i j hij α hα β hβ => (w.blocks.successive i j hij α hα β hβ).1) + (fun i j hij α hα β hβ => (w.coherence j i i hij hij α hα β hβ).le) + 2 16 δ w.upper_norm (by norm_num) hδ _ w.tail_vanish w.path_null N hN + intro i e he hj + exact typeI_eval_le_of_partition _ _ _ (by norm_num) (w.partition i) e he (FamilyL_mono f hj.le) + +end SeparableQuotient.ActualSpace + +namespace SeparableQuotient.AdaptiveThinning +open scoped Classical + +variable (R : ℕ → ℕ → Set ℕ → Prop) +variable (hR : ∀ n i (N : Set ℕ), N.Infinite → ∃ W ⊆ N, W.Infinite ∧ R n i W) + +structure Step (n : ℕ) (N : Set ℕ) where + index : ℕ + mem : index ∈ N + rest : Set ℕ + infinite : rest.Infinite + subset : rest ⊆ N + later : ∀ i ∈ rest, index < i + good : R n index rest + +include hR in +lemma exists_step (n : ℕ) (N : Set ℕ) (hN : N.Infinite) : Nonempty (Step R n N) := by + obtain ⟨i, hi⟩ := hN.nonempty + have htail : (N \ Set.Iic i).Infinite := hN.sdiff (Set.finite_Iic i) + obtain ⟨W, hW, hWi, hWR⟩ := hR n i _ htail + refine ⟨⟨i, hi, W, hWi, fun j hj => (hW hj).1, ?_, hWR⟩⟩ + intro j hj + have := (hW hj).2 + simpa using this + +noncomputable def choice (n : ℕ) (N : Set ℕ) (hN : N.Infinite) : Step R n N := + Classical.choice (exists_step R hR n N hN) + +structure State (n : ℕ) where + index : ℕ + rest : Set ℕ + infinite : rest.Infinite + later : ∀ i ∈ rest, index < i + good : R n index rest + +noncomputable def initial : State R 0 := + let s := choice R hR 0 Set.univ Set.infinite_univ + ⟨s.index, s.rest, s.infinite, s.later, s.good⟩ + +noncomputable def next {n : ℕ} (s : State R n) : State R (n+1) := + let t := choice R hR (n+1) s.rest s.infinite + ⟨t.index, t.rest, t.infinite, t.later, t.good⟩ + +lemma next_mem {n : ℕ} (s : State R n) : (next R hR s).index ∈ s.rest := + (choice R hR (n+1) s.rest s.infinite).mem + +lemma next_subset {n : ℕ} (s : State R n) : (next R hR s).rest ⊆ s.rest := + (choice R hR (n+1) s.rest s.infinite).subset + +noncomputable def state : (n : ℕ) → State R n + | 0 => initial R hR + | n+1 => next R hR (state n) + +lemma index_strict : StrictMono (fun n => (state R hR n).index) := by + apply strictMono_nat_of_lt_succ + intro n + exact (state R hR n).later _ (next_mem R hR (state R hR n)) + +lemma rest_antitone : Antitone (fun n => (state R hR n).rest) := by + apply antitone_nat_of_succ_le + intro n + exact next_subset R hR (state R hR n) + +lemma later_mem {n m : ℕ} (hnm : n < m) : (state R hR m).index ∈ (state R hR n).rest := by + have hm : 0 < m := Nat.zero_lt_of_lt hnm + have hh : m = (m-1)+1 := by omega + rw [hh] + exact rest_antitone R hR (show n ≤ m-1 by omega) (next_mem R hR (state R hR (m-1))) + +include hR in +/-- Repeated infinite thinning where the new relation can depend on the already +selected index and its position. No uniform-threshold or countability assumption +on the predicate R is required. -/ +theorem exists_adaptive : ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∃ W : ℕ → Set ℕ, + (∀ n, R n (φ n) (W n)) ∧ (∀ n m, n < m → φ m ∈ W n) := by + exact ⟨fun n => (state R hR n).index, index_strict R hR, + fun n => (state R hR n).rest, fun n => (state R hR n).good, + fun _ _ h => later_mem R hR h⟩ + +end SeparableQuotient.AdaptiveThinning + +namespace SeparableQuotient.ActualSpace +open Norming NormConstruction PathCoding CoherentClosures Filter SeriesTails +open scoped Classical Topology + +noncomputable def WindowBlocks.subsequence {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : WindowBlocks z J ε a) (φ : ℕ → ℕ) (hφ : StrictMono φ) : WindowBlocks z J ε a where + blocks := w.blocks.subsequence φ hφ + lower n := w.lower (φ n) + upper n := w.upper (φ n) + mem_tail n := w.mem_tail (φ n) + lower_norm n := w.lower_norm (φ n) + upper_norm n := w.upper_norm (φ n) + prescribed n := w.prescribed (φ n) + order n := w.order (φ n) + separated i j h := w.separated (φ i) (φ j) (hφ h) + coherence i j k hji hki := w.coherence (φ i) (φ j) (φ k) (hφ hji) (hφ hki) + partition n := w.partition (φ n) + tail_small n := w.tail_small (φ n) + tail_vanish := w.tail_vanish.comp hφ.tendsto_atTop + path_null P := (w.path_null P).comp hφ.tendsto_atTop + +/-- Successively thinned windows. The threshold indexed by n is used strictly after n. -/ +structure ThinnedWindows {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) (a : ℕ) + extends WindowBlocks z J ε a where + threshold : ℕ → ℝ + threshold_pos : ∀ n, 0 < threshold n + threshold_charge_succ : ∀ n, (upper n+1 : ℝ) * threshold n = ε * (1/2 : ℝ)^(n+1) + threshold_charge : ∀ n, (upper n : ℝ) * threshold n ≤ ε * (1/2 : ℝ)^(n+1) + four_hits_after : ∀ n (S : Finset ℕ), (∀ i ∈ S, n < i) → S.card = 4 → + ¬ ∃ P : LegalFinitePath f, ∀ i ∈ S, + WindowHit P (blocks.vector i) (lower i) (upper i) (threshold n) + +lemma exists_thinnedWindows {f : Family} (z : BlockSequence f) (J : ℕ) (ε : ℝ) + (hε : 0 < ε) (a : ℕ) : Nonempty (ThinnedWindows z J ε a) := by + obtain ⟨w⟩ := exists_windowBlocks z J ε hε a + let δ (n i : ℕ) : ℝ := ε / (w.upper i+1 : ℝ) * (1/2 : ℝ)^(n+1) + have hδ (n i : ℕ) : 0 < δ n i := by dsimp [δ]; positivity + let R (n i : ℕ) (W : Set ℕ) : Prop := ∀ S : Finset ℕ, (↑S : Set ℕ) ⊆ W → S.card = 4 → + ¬ ∃ P : LegalFinitePath f, ∀ k ∈ S, + WindowHit P (w.blocks.vector k) (w.lower k) (w.upper k) (δ n i) + have hR (n i : ℕ) (N : Set ℕ) (hN : N.Infinite) : ∃ W ⊆ N, W.Infinite ∧ R n i W := + w.four_hits (δ n i) (hδ n i) N hN + obtain ⟨φ, hφ, W, hW, hlater⟩ := AdaptiveThinning.exists_adaptive R hR + refine ⟨{ + toWindowBlocks := w.subsequence φ hφ + threshold n := δ n (φ n) + threshold_pos n := hδ n (φ n) + threshold_charge_succ := ?_ + threshold_charge := ?_ + four_hits_after := ?_ }⟩ + · intro n + change (w.upper (φ n)+1 : ℝ) * (ε / (w.upper (φ n)+1 : ℝ) * (1/2 : ℝ)^(n+1)) = _ + field_simp + · intro n + change (w.upper (φ n) : ℝ) * (ε / (w.upper (φ n)+1 : ℝ) * (1/2 : ℝ)^(n+1)) ≤ _ + have hh : (w.upper (φ n) : ℝ) * (ε / (w.upper (φ n)+1 : ℝ)) ≤ ε := by + rw [← mul_div_assoc, div_le_iff₀ (by positivity : (0 : ℝ) < w.upper (φ n)+1)] + nlinarith + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hh (by positivity : (0 : ℝ) ≤ (1/2 : ℝ)^(n+1)) + · intro n S hn hcard hh + apply hW n (S.image φ) _ _ + · obtain ⟨P, hP⟩ := hh + refine ⟨P, ?_⟩ + intro k hk + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hk + exact hP i hi + · intro k hk + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hk + exact hlater n i (hn i hi) + · rw [Finset.card_image_of_injective _ hφ.injective, hcard] + +lemma ThinnedWindows.hits_after_le_three {f : Family} {z : BlockSequence f} {J a : ℕ} {ε : ℝ} + (w : ThinnedWindows z J ε a) (n : ℕ) (s : Finset ℕ) (P : LegalFinitePath f) : + (s.filter (fun i => n < i ∧ WindowHit P (w.blocks.vector i) (w.lower i) (w.upper i) (w.threshold n))).card ≤ 3 := by + by_contra! h + obtain ⟨S, hS, hcard⟩ := Finset.exists_subset_card_eq (show 4 ≤ (s.filter (fun i => n < i ∧ + WindowHit P (w.blocks.vector i) (w.lower i) (w.upper i) (w.threshold n))).card by omega) + exact w.four_hits_after n S (fun i hi => (Finset.mem_filter.mp (hS hi)).2.1) hcard + ⟨P, fun i hi => (Finset.mem_filter.mp (hS hi)).2.2⟩ + +end SeparableQuotient.ActualSpace + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/ActualLabels1.lean b/lean/OAI/Analysis/SignedDisk/ActualLabels1.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e25a902658b97efae38f351224672ad3861f38a --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/ActualLabels1.lean @@ -0,0 +1,410 @@ +import OAI.Analysis.SignedDisk.CommonPrices1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace ActualLabels +open FiniteLabels ConeCoordinates DirectionNeighbors DyadicHats Finset + +def energyRate (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) (y : ℂ) (i : ℕ) : ℝ := + switchCost h r y i+energy h (r i) (q i) +lemma energyRate_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) (y : ℂ) (i : ℕ) : + 0 ≤ energyRate h r q y i := add_nonneg (switchCost_nonneg h r y i) (energy_nonneg h (r i) (q i)) +lemma energyRate_le_five (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) (y : ℂ) (i : ℕ) : + energyRate h r q y i ≤ 5 := by + have h1 := switchCost_le_one h r y i + have h2 := energy_le_four h (r i) (q i) + dsimp [energyRate] + linarith + +/-- Spatial comparison of the actual marginal laws. No independent coupling or +pointwise uniform distribution of labels is assumed. -/ +theorem marginal_spatial_distance (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) + (x y : ℂ) (j : ℕ) (hr : ∀ i ≤ j, 0 < r i) + (hx : ∀ i ≤ j, boxNorm (x-point (r i) (q i)) < 199*r i) + (hy : ∀ i ≤ j, boxNorm (y-point (r i) (q i)) < 199*r i) : + l1dist (marginal h r j x) (marginal h r j y) ≤ + comparisonConstant*‖x-y‖*∑ i ∈ range (j+1), energyRate h r q y i/r i := by + induction j with + | zero => + have he := initial_distance h (hr 0 le_rfl) x y + have hc : 1 ≤ energyRate h r q y 0 := by + dsimp [energyRate,switchCost] + linarith [energy_nonneg h (r 0) (q 0)] + have ht := mul_le_mul_of_nonneg_left + (div_le_div_of_nonneg_right hc (hr 0 le_rfl).le) + (mul_nonneg comparisonConstant_pos.le (norm_nonneg (x-y))) + simp only [Nat.zero_add,sum_range_one,marginal] + apply he.trans + convert ht using 1 + ring + | succ j ih => + have hd := ih (fun i hi => hr i (by omega)) (fun i hi => hx i (by omega)) (fun i hi => hy i (by omega)) + have hm := move_compare (marginal h r j x) (marginal h r j y) + (row h (r (j+1)) x) (row h (r (j+1)) y) + have hrow : (∑ n, marginal h r j y n*l1dist (row h (r (j+1)) x n) (row h (r (j+1)) y n)) ≤ + comparisonConstant*‖x-y‖/r (j+1)*energyRate h r q y (j+1) := by + calc + _ ≤ expect (marginal h r j y) (fun n => comparisonConstant*‖x-y‖/r (j+1)* + (rate h (r (j+1)) y n+energy h (r (j+1)) (q (j+1)))) := by + exact expect_mono _ (row_local_distance h (hr (j+1) le_rfl) (q (j+1)) x y + (hx (j+1) le_rfl) (hy (j+1) le_rfl)) + _ = _ := by rw [FiniteLabels.expect_mul,FiniteLabels.expect_add,FiniteLabels.expect_const]; rfl + change l1dist (marginal h r (j+1) x) (marginal h r (j+1) y) ≤ _ at hm + rw [sum_range_succ,mul_add] + have hterm : comparisonConstant*‖x-y‖/r (j+1)*energyRate h r q y (j+1) = + comparisonConstant*‖x-y‖*(energyRate h r q y (j+1)/r (j+1)) := by ring + rw [hterm] at hrow + linarith + +lemma switchCost_spatial (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℤ × ℤ) (x y : ℂ) (i : ℕ) + (hr : 0 < r (i+1)) (hx : boxNorm (x-point (r (i+1)) q) < 199*r (i+1)) + (hy : boxNorm (y-point (r (i+1)) q) < 199*r (i+1)) : + switchCost h r x (i+1) ≤ comparisonConstant*(switchCost h r y (i+1)+energy h (r (i+1)) q)+ + l1dist (marginal h r i x) (marginal h r i y) := by + have he := expect_compare (marginal h r i x) (marginal h r i y) + (fun n => by rw [abs_of_nonneg (rate_nonneg h (r (i+1)) x n)]; exact rate_le_one h (r (i+1)) x n) + have hrw := expect_mono (marginal h r i y) (rate_local h hr q x y hx hy) + rw [FiniteLabels.expect_mul,FiniteLabels.expect_add,FiniteLabels.expect_const] at hrw + change expect (marginal h r i y) (rate h (r (i+1)) x) ≤ + comparisonConstant*(switchCost h r y (i+1)+energy h (r (i+1)) q) at hrw + change expect (marginal h r i x) (rate h (r (i+1)) x) ≤ _ + linarith + +lemma derivativeCost_spatial (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℤ × ℤ) (x y : ℂ) (i : ℕ) + (hr : 0 < r (i+1)) (hx : boxNorm (x-point (r (i+1)) q) < 199*r (i+1)) + (hy : boxNorm (y-point (r (i+1)) q) < 199*r (i+1)) : + derivativeCost h r x (i+1) ≤ comparisonConstant*(switchCost h r y (i+1)+energy h (r (i+1)) q)+ + comparisonConstant*l1dist (marginal h r i x) (marginal h r i y) := by + have he := expect_compare (marginal h r i x) (marginal h r i y) + (fun n => by rw [abs_of_nonneg (rowDerivative_nonneg h hr.le x n)]; exact rowDerivative_uniform h hr x n) + have hrw := expect_mono (marginal h r i y) (row_local_derivative h hr q x y hx hy) + rw [FiniteLabels.expect_mul,FiniteLabels.expect_add,FiniteLabels.expect_const] at hrw + have hcoef : 16*(Fintype.card Label:ℝ) ≤ comparisonConstant := by + dsimp [comparisonConstant] + nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card Label)] + have hm := mul_le_mul_of_nonneg_right hcoef (l1dist_nonneg (marginal h r i x) (marginal h r i y)) + change derivativeCost h r x (i+1) ≤ _ at he + change expect (marginal h r i y) (rowDerivative h (r (i+1)) x) ≤ + comparisonConstant*(switchCost h r y (i+1)+energy h (r (i+1)) q) at hrw + linarith + +end ActualLabels + +namespace GeometricFilter +open Finset +/-- Causal dyadic averaging, with both the present and the complete past. -/ +def filt (c : ℕ → ℝ) : ℕ → ℝ + | 0 => c 0 + | i+1 => c (i+1)+filt c i/2 +lemma filt_nonneg {c : ℕ → ℝ} (hc : ∀ i, 0 ≤ c i) (i : ℕ) : 0 ≤ filt c i := by + induction i with + | zero => exact hc 0 + | succ i ih => exact add_nonneg (hc _) (div_nonneg ih (by norm_num)) +lemma le_filt {c : ℕ → ℝ} (hc : ∀ i, 0 ≤ c i) (i : ℕ) : c i ≤ filt c i := by + cases i with + | zero => exact le_rfl + | succ i => dsimp only [filt]; linarith [filt_nonneg hc i] +lemma filt_le {c : ℕ → ℝ} {A : ℝ} (hA : 0 ≤ A) (hc : ∀ i, c i ≤ A) (i : ℕ) : filt c i ≤ 2*A := by + induction i with + | zero => exact (hc 0).trans (by linarith) + | succ i ih => dsimp only [filt]; linarith [hc (i+1)] +lemma filt_mono {c d : ℕ → ℝ} (h : ∀ i, c i ≤ d i) (i : ℕ) : filt c i ≤ filt d i := by + induction i with + | zero => exact h 0 + | succ i ih => dsimp only [filt]; linarith [h (i+1)] +lemma filt_mul (c : ℕ → ℝ) (a : ℝ) (i : ℕ) : filt (fun j => a*c j) i = a*filt c i := by + induction i with + | zero => rfl + | succ i ih => simp only [filt,ih]; ring +lemma filt_sum (c : ℕ → ℝ) (i : ℕ) : + filt c i = ∑ j ∈ range (i+1), (1/2:ℝ)^(i-j)*c j := by + induction i with + | zero => simp [filt] + | succ i ih => + rw [filt,ih] + conv_rhs => rw [sum_range_succ] + simp only [Nat.sub_self,pow_zero,one_mul] + rw [add_comm] + congr 1 + rw [div_eq_mul_inv,sum_mul] + apply sum_congr rfl + intro j hj + have hj' : j ≤ i := by have := mem_range.mp hj; omega + rw [show i+1-j = (i-j)+1 by omega,pow_succ] + ring + +lemma filt_tail_strong {c : ℕ → ℝ} (hc0 : ∀ i, 0 ≤ c i) {b m : ℕ} (hbm : b ≤ m) : + (∑ i ∈ Ico b (m+1), filt c i) ≤ 2*∑ i ∈ Ico b (m+1), c i+2*filt c b := by + have hid : (∑ i ∈ Ico (b+1) (m+1), filt c i) = + (∑ i ∈ Ico (b+1) (m+1), c i)+(∑ i ∈ Ico b m, filt c i)/2 := by + rw [← sum_Ico_add' (fun i => filt c i) b m 1, + ← sum_Ico_add' (fun i => c i) b m 1] + simp only [filt,sum_add_distrib,sum_div] + have hsplit := sum_eq_sum_Ico_succ_bot (f := filt c) (by omega : b < m+1) + have hcsplit := sum_eq_sum_Ico_succ_bot (f := c) (by omega : b < m+1) + have he : (∑ i ∈ Ico b m, filt c i) ≤ ∑ i ∈ Ico b (m+1), filt c i := by + apply sum_le_sum_of_subset_of_nonneg (Ico_subset_Ico_right (by omega)) + intro i _ _ + exact filt_nonneg hc0 i + rw [hsplit,hid] at he + rw [hsplit,hid,hcsplit] + linarith [hc0 b] + +/-- The complete pre-birth history costs a fixed amount, not the birth index. -/ +theorem filt_tail {c : ℕ → ℝ} {A : ℝ} (hA : 0 ≤ A) (hc0 : ∀ i, 0 ≤ c i) + (hcA : ∀ i, c i ≤ A) {b m : ℕ} (hbm : b ≤ m) : + (∑ i ∈ Ico b (m+1), filt c i) ≤ 2*∑ i ∈ Ico b (m+1), c i+4*A := by + have h1 := filt_tail_strong hc0 hbm + have h2 := filt_le hA hcA b + linarith + +/-- Two geometric convolutions are summable on every occupied lifetime. -/ +theorem double_tail {c : ℕ → ℝ} {A : ℝ} (hA : 0 ≤ A) (hc0 : ∀ i, 0 ≤ c i) + (hcA : ∀ i, c i ≤ A) {b m : ℕ} (hbm : b ≤ m) : + (∑ i ∈ Ico b (m+1), filt (filt c) i) ≤ 4*∑ i ∈ Ico b (m+1), c i+16*A := by + have h1 := filt_tail hA hc0 hcA hbm + have h2 := filt_tail (by positivity : 0 ≤ 2*A) (filt_nonneg hc0) (filt_le hA hcA) hbm + linarith + +open Finset +lemma radius_sum {r c : ℕ → ℝ} (j : ℕ) (hr : ∀ i ≤ j, 0 < r i) + (hstep : ∀ i < j, r i = 2*r (i+1)) : + r j*(∑ i ∈ range (j+1), c i/r i) = filt c j := by + induction j with + | zero => simp only [Nat.zero_add,sum_range_one,filt]; field_simp [(hr 0 le_rfl).ne'] + | succ j ih => + have hs := ih (fun i hi => hr i (by omega)) (fun i hi => hstep i (by omega)) + rw [sum_range_succ,mul_add,filt] + have he : r (j+1)*(c (j+1)/r (j+1)) = c (j+1) := by field_simp [(hr (j+1) le_rfl).ne'] + rw [he,add_comm] + congr 1 + rw [← hs,hstep j (by omega)] + ring +end GeometricFilter + +namespace ActualLabels +open FiniteLabels ConeCoordinates DirectionNeighbors DyadicHats Finset GeometricFilter + +def spatialConstant : ℝ := 208*comparisonConstant^2 +lemma spatialConstant_pos : 0 < spatialConstant := by + dsimp [spatialConstant] + have := comparisonConstant_pos + positivity +lemma spatialConstant_ge : 2*comparisonConstant ≤ spatialConstant := by + dsimp [spatialConstant] + nlinarith [comparisonConstant_one] + +lemma scaled_marginal_distance (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) + (x y : ℂ) (j : ℕ) (hr : ∀ i ≤ j, 0 < r i) + (hstep : ∀ i < j, r i = 2*r (i+1)) + (hx : ∀ i ≤ j, boxNorm (x-point (r i) (q i)) < 199*r i) + (hy : ∀ i ≤ j, boxNorm (y-point (r i) (q i)) < 199*r i) : + r j*l1dist (marginal h r j x) (marginal h r j y) ≤ + comparisonConstant*‖x-y‖*filt (energyRate h r q y) j := by + have hd := mul_le_mul_of_nonneg_left (marginal_spatial_distance h r q x y j hr hx hy) (hr j le_rfl).le + have he := radius_sum (c := energyRate h r q y) j hr hstep + calc + _ ≤ r j*(comparisonConstant*‖x-y‖*∑ i ∈ range (j+1), energyRate h r q y i/r i) := hd + _ = _ := by rw [← mul_assoc,mul_comm (r j),mul_assoc,he] + +/-- Actual spatial comparison at every point of the neighborhood. The gradient +versions are pointwise bounded; differentiability is only needed later for IBP. -/ +theorem filtered_spatial_cost (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) + (x y : ℂ) (j : ℕ) (hr : ∀ i ≤ j, 0 < r i) + (hstep : ∀ i < j, r i = 2*r (i+1)) + (hx : ∀ i ≤ j, boxNorm (x-point (r i) (q i)) < 199*r i) + (hy : ∀ i ≤ j, boxNorm (y-point (r i) (q i)) < 199*r i) + (hdist : ‖x-y‖ ≤ 104*r j) : + switchCost h r x j+derivativeCost h r x j ≤ + spatialConstant*filt (energyRate h r q y) j := by + let c := energyRate h r q y + have hc0 : ∀ i, 0 ≤ c i := energyRate_nonneg h r q y + have hC := comparisonConstant_one + have hC0 := comparisonConstant_pos.le + cases j with + | zero => + have he : 1 ≤ c 0 := by dsimp [c,energyRate,switchCost]; linarith [energy_nonneg h (r 0) (q 0)] + have ht := derivativeCost_uniform h r x 0 (hr 0 le_rfl) + have hbound : 1+16*(Fintype.card Label:ℝ) ≤ 2*comparisonConstant := by + dsimp [comparisonConstant] + nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card Label)] + have hh := mul_le_mul_of_nonneg_left he spatialConstant_pos.le + dsimp only [switchCost,filt] + change _ ≤ spatialConstant*c 0 + nlinarith [spatialConstant_ge] + | succ j => + have hm := scaled_marginal_distance h r q x y j + (fun i hi => hr i (by omega)) (fun i hi => hstep i (by omega)) + (fun i hi => hx i (by omega)) (fun i hi => hy i (by omega)) + have hd : ‖x-y‖ ≤ 52*r j := by rw [hstep j (by omega)]; linarith + have hmag := mul_le_mul_of_nonneg_right hd (mul_nonneg hC0 (filt_nonneg hc0 j)) + have hd' : l1dist (marginal h r j x) (marginal h r j y) ≤ + 52*comparisonConstant*filt c j := by + have hrj := hr j (by omega) + change r j*l1dist (marginal h r j x) (marginal h r j y) ≤ + comparisonConstant*‖x-y‖*filt c j at hm + nlinarith + have hs := switchCost_spatial h r (q (j+1)) x y j (hr (j+1) le_rfl) + (hx (j+1) le_rfl) (hy (j+1) le_rfl) + have ht := derivativeCost_spatial h r (q (j+1)) x y j (hr (j+1) le_rfl) + (hx (j+1) le_rfl) (hy (j+1) le_rfl) + change switchCost h r x (j+1) ≤ comparisonConstant*c (j+1)+_ at hs + change derivativeCost h r x (j+1) ≤ comparisonConstant*c (j+1)+_ at ht + have hdC := mul_le_mul_of_nonneg_left hd' hC0 + have hcoef : (52*comparisonConstant+52*comparisonConstant^2)*filt c j ≤ + (104*comparisonConstant^2)*filt c j := by + apply mul_le_mul_of_nonneg_right _ (filt_nonneg hc0 j) + nlinarith + have hcC := mul_le_mul_of_nonneg_right spatialConstant_ge (hc0 (j+1)) + change _ ≤ spatialConstant*filt c (j+1) + rw [filt] + dsimp [spatialConstant] at hcC ⊢ + nlinarith +end ActualLabels + +namespace DyadicHats +lemma scale_mono {r : ℝ} (hr : 0 ≤ r) {i j : ℕ} (hij : i ≤ j) : scale r i ≤ scale r j := by + exact mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num : (1:ℝ) ≤ 2) hij) hr +lemma descending_step (r : ℝ) {m i : ℕ} (hi : i < m) : + scale r (m-i) = 2*scale r (m-(i+1)) := by + rw [show m-i = (m-(i+1))+1 by omega,scale_succ] +lemma descending_compare {r : ℝ} (hr : 0 ≤ r) {m l i : ℕ} (hi : i ≤ l+1) : + scale r (m-l) ≤ 2*scale r (m-i) := by + rw [← scale_succ] + exact scale_mono hr (by omega) + +def neighborhood (r : ℝ) (q : ℤ × ℤ) : Set ℂ := {x | boxNorm (x-point r q) ≤ 25*r} +lemma point_mem_neighborhood {r : ℝ} (hr : 0 ≤ r) (q : ℤ × ℤ) : point r q ∈ neighborhood r q := by + change boxNorm (point r q-point r q) ≤ _ + simp only [sub_self,boxNorm] + simpa using (mul_nonneg (by norm_num : (0:ℝ) ≤ 25) hr) +end DyadicHats + +namespace ActualMarkTrees +open DyadicHats IntrinsicMarks + +def pathVertex {N : ℕ} (q : Grid N) (p : List (Grid N)) (i : ℕ) : ℤ × ℤ := lastVertex q (p.take i) + +lemma terminal_path_locality {N : ℕ} (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {m : ℕ} {q : Grid N} {p : List (Grid N)} (hp : activePath (tree v m 1 q) p) + {i : ℕ} (hi : i ≤ m) : + boxNorm (point r (lastVertex q p)-point (scale r (m-i)) (pathVertex q p i)) < scale r (m-i) := by + have hlen := active_length v hp + have hp' : activePath (tree v m 1 q) (p.take i++p.drop i) := by simpa only [List.take_append_drop] using hp + have hl := active_prefix_locality v hr hp' (x := point r (lastVertex q p)) (by + rw [List.take_append_drop,hat_at_point hr.ne'] + norm_num) + simpa only [List.length_take,show min i p.length = i by omega,pathVertex] using hl + +/-- The neighborhoods used by assembly remain within the actual 200-neighbor +energy window at every earlier row, including the complete pre-birth history. -/ +lemma path_neighborhood_geometry {N : ℕ} (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {m : ℕ} {q : Grid N} {p : List (Grid N)} (hp : activePath (tree v m 1 q) p) + {l : ℕ} (hl : l ≤ m) {x : ℂ} + (hx : x ∈ neighborhood (scale r (m-l)) (pathVertex q p l)) + {i : ℕ} (hi : i ≤ m) (hil : i ≤ l+1) : + ‖x-point r (lastVertex q p)‖ ≤ 104*scale r (m-i) ∧ + boxNorm (x-point (scale r (m-i)) (pathVertex q p i)) < 199*scale r (m-i) ∧ + boxNorm (point r (lastVertex q p)-point (scale r (m-i)) (pathVertex q p i)) < 199*scale r (m-i) := by + let y := point r (lastVertex q p) + have hy := terminal_path_locality v hr hp hl + have hyi := terminal_path_locality v hr hp hi + have hxy := boxNorm_add_le (x-point (scale r (m-l)) (pathVertex q p l)) + (point (scale r (m-l)) (pathVertex q p l)-y) + rw [sub_add_sub_cancel,boxNorm_sub_comm (point _ _)] at hxy + change boxNorm (x-point (scale r (m-l)) (pathVertex q p l)) ≤ 25*scale r (m-l) at hx + have hd : boxNorm (x-y) ≤ 26*scale r (m-l) := by change boxNorm (y-_) < _ at hy; linarith + have hrel := descending_compare hr.le (m := m) hil + have hrp := scale_pos hr (m-i) + have hnorm := norm_le_two_boxNorm (x-y) + have hxi := boxNorm_add_le (x-y) (y-point (scale r (m-i)) (pathVertex q p i)) + rw [sub_add_sub_cancel] at hxi + change boxNorm (y-point (scale r (m-i)) (pathVertex q p i)) < scale r (m-i) at hyi + exact ⟨by dsimp only [y] at hnorm hd; linarith,by linarith,by linarith⟩ +end ActualMarkTrees + +namespace GeometricFilter +open Finset +lemma filt_mono_on {c d : ℕ → ℝ} (j : ℕ) (h : ∀ i ≤ j, c i ≤ d i) : filt c j ≤ filt d j := by + rw [filt_sum,filt_sum] + exact sum_le_sum (fun i hi => mul_le_mul_of_nonneg_left (h i (by have := mem_range.mp hi; omega)) (by positivity)) + +lemma shifted_tail {c : ℕ → ℝ} {A : ℝ} (hA : 0 ≤ A) (hc0 : ∀ i, 0 ≤ c i) + (hcA : ∀ i, c i ≤ A) {b m : ℕ} (hbm : b ≤ m) : + (∑ i ∈ Ico b (m+1), filt c (i+1)) ≤ 2*∑ i ∈ Ico b (m+1), c i+6*A := by + have he := sum_Ico_sub (filt c) (by omega : b ≤ m+1) + rw [sum_sub_distrib] at he + have h1 := filt_tail hA hc0 hcA hbm + linarith [filt_le hA hcA (m+1),filt_nonneg hc0 b] +end GeometricFilter + +namespace DyadicHats +noncomputable def localSup (f : ℂ → ℝ) (r : ℝ) (q : ℤ × ℤ) : ℝ := + sSup (f '' neighborhood r q) +lemma localSup_le {f : ℂ → ℝ} {r A : ℝ} (hr : 0 ≤ r) (q : ℤ × ℤ) + (h : ∀ x ∈ neighborhood r q, f x ≤ A) : localSup f r q ≤ A := by + apply csSup_le (Set.Nonempty.image f ⟨point r q,point_mem_neighborhood hr q⟩) + rintro z ⟨x,hx,rfl⟩ + exact h x hx +lemma le_localSup {f : ℂ → ℝ} {r A : ℝ} (q : ℤ × ℤ) + (h : ∀ x ∈ neighborhood r q, f x ≤ A) {x : ℂ} (hx : x ∈ neighborhood r q) : + f x ≤ localSup f r q := le_csSup ⟨A,by rintro z ⟨y,hy,rfl⟩; exact h y hy⟩ ⟨x,hx,rfl⟩ +lemma localSup_nonneg {f : ℂ → ℝ} {r A : ℝ} (hr : 0 ≤ r) (q : ℤ × ℤ) + (h0 : ∀ x, 0 ≤ f x) (h : ∀ x ∈ neighborhood r q, f x ≤ A) : 0 ≤ localSup f r q := + (h0 (point r q)).trans (le_localSup q h (point_mem_neighborhood hr q)) +end DyadicHats + +namespace ActualLabels +open DyadicHats GeometricFilter FiniteLabels Finset +lemma derivativeCost_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (i : ℕ) (hr : 0 ≤ r i) : + 0 ≤ derivativeCost h r x i := by + cases i with + | zero => exact mul_nonneg hr (sum_nonneg (fun _ _ => norm_nonneg _)) + | succ i => exact FiniteLabels.expect_nonneg _ (rowDerivative_nonneg h hr x) + +def cellCost (h : ℂ → ℂ) (r : ℕ → ℝ) (m l : ℕ) (q : ℤ × ℤ) : ℝ := + localSup (fun x => switchCost h r x l) (r l) q+ + (if l=m then 1 else localSup (fun x => switchCost h r x (l+1)) (r l) q)+ + filt (fun i => localSup (fun x => derivativeCost h r x i) (r l) q) l + +lemma cellCost_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) (m l : ℕ) (q : ℤ × ℤ) : + 0 ≤ cellCost h r m l q := by + have hs (i : ℕ) : 0 ≤ localSup (fun x => switchCost h r x i) (r l) q := + localSup_nonneg (hr l).le q (fun x => switchCost_nonneg h r x i) (fun x _ => switchCost_le_one h r x i) + have ht (i : ℕ) : 0 ≤ localSup (fun x => derivativeCost h r x i) (r l) q := + localSup_nonneg (hr l).le q (fun x => derivativeCost_nonneg h r x i (hr i).le) + (fun x _ => derivativeCost_uniform h r x i (hr i)) + dsimp only [cellCost] + exact add_nonneg (add_nonneg (hs _) (by split_ifs; exact zero_le_one; exact hs _)) (filt_nonneg ht l) +end ActualLabels + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/ActualMarkTrees1.lean b/lean/OAI/Analysis/SignedDisk/ActualMarkTrees1.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe2c0414e3efd9b11500a44b08f38c5ae8f2e6ad --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/ActualMarkTrees1.lean @@ -0,0 +1,405 @@ +import OAI.Analysis.SignedDisk.FiniteLabels2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace ActualMarkTrees +open DyadicHats IntrinsicMarks + +theorem direction_at_prefix {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) {k : ℕ} {b : ℝ} (hb : 0 ≤ b) + {q : Grid N} {p s : List (Grid N)} + (hp : activePath (tree (fun q => vectorMass h r q) k b q) (p++s)) : + direction (1:ℂ) (vector (atPath (tree (fun q => vectorMass h r q) k b q) p)) = + DirectionNeighbors.theta h (scale r (k-p.length)) (lastVertex q p) := by + have hlen : p.length ≤ k := by have := active_length _ hp; simp only [List.length_append] at this; omega + rw [atPath_tree _ b q p hlen,vector_actual hr hR hN hh hsupp] + have hpa := active_append hp + rw [atPath_tree _ b q p hlen] at hpa + have hpos : 0 < b*pathWeight q p := lt_of_le_of_ne + (mul_nonneg hb (pathWeight_nonneg q p)) (Ne.symm (active_ne_zero _ hpa)) + exact direction_smul_pos _ _ hpos + +open DyadicHats IntrinsicMarks Finset DirectionNeighbors ActualLabels + +def pathEnergy (h : ℂ → ℂ) (r : ℝ) (k : ℕ) {N : ℕ} (q : Grid N) + (p : List (Grid N)) : ℝ := energy h (scale r (k-p.length)) (lastVertex q p) + +def pathSwitches (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (x : ℂ) + {N : ℕ} (p : List (Grid N)) (b : ℕ) : ℝ := + ∑ i ∈ Ico b (p.length+1), switchCost h (fun j => scale r (k-j)) x i + +lemma mark_nonneg {ι : Type*} [Fintype ι] (t : Tree ι ℂ) (p : List ι) : + 0 ≤ rootMarkIndicator (1:ℂ) (1/800) t p := by + rcases rootMarkIndicator_cases (1:ℂ) (1/800) t p with h | h + · exact h.symm.le + · exact h.symm ▸ zero_le_one + +/-- The switch bound on every genuinely occupied path, using its complete +intrinsic history, even before the particle's birth. -/ +theorem path_switch_bound {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) + {p : List (Grid N)} (hp : activePath (tree (fun q => vectorMass h r q) k 1 q) p) + {b : ℕ} (hb : b ≤ p.length) {x : ℂ} (hx : hat r (lastVertex q p) x ≠ 0) : + pathSwitches h r k x p b ≤ 2+ + 2*pathCharge (rootMarkIndicator (1:ℂ) (1/800) (tree (fun q => vectorMass h r q) k 1 q)) p b+ + 2000000*pathCharge (pathEnergy h r k q) p b := by + classical + let t := tree (fun q => vectorMass h r q) k 1 q + let M := rootMarkIndicator (1:ℂ) (1/800) t + let rs : ℕ → ℝ := fun i => scale r (k-i) + let qs : ℕ → ℤ × ℤ := fun i => lastVertex q (p.take i) + let E : ℕ → ℝ := fun i => energy h (rs i) (qs i) + let A : ℕ → ℂ := fun i => rootAnchor (1:ℂ) (1/800) t (p.take i) + let bad : ℕ → Bool := fun i => decide (M (p.take i) ≠ 0 ∨ (1/1000:ℝ)^2 < E i) + have hlen : p.length = k := active_length _ hp + have hpos (i : ℕ) : 0 < rs i := scale_pos hr _ + have he0 (i : ℕ) : 0 ≤ E i := energy_nonneg h _ _ + have hpref (i : ℕ) : activePath t (p.take i++p.drop i) := by + simpa only [List.take_append_drop] using hp + have hloc (i : ℕ) (hi : i ≤ p.length) : boxNorm (x-point (rs i) (qs i)) ≤ 50*rs i := by + have hl := active_prefix_locality (fun q => vectorMass h r q) hr (hpref i) + (by simpa only [List.take_append_drop] using hx) + have hli : (p.take i).length = i := by simp only [List.length_take,min_eq_left hi] + simp only [hli] at hl + exact hl.le.trans (by dsimp only [rs,qs]; nlinarith [scale_pos hr (k-i)]) + have hdir (i : ℕ) (hi : i ≤ p.length) : + direction (1:ℂ) (vector (atPath t (p.take i))) = theta h (rs i) (qs i) := by + have hd := direction_at_prefix hr hR hN hh hsupp (by norm_num : (0:ℝ) ≤ 1) (hpref i) + simpa only [List.length_take,min_eq_left hi] using hd + have hbad (i : ℕ) : bad i = false → M (p.take i) = 0 ∧ E i ≤ (1/1000:ℝ)^2 := by + simp only [bad,decide_eq_false_iff_not,not_or,not_not,not_lt] + exact id + have hs := switchCost_sum h rs qs x A bad (by omega : b ≤ k) + (fun i _ => hpos (i+1)) + (fun i hi => hloc (i+1) (by simp only [Finset.mem_Ico] at hi; omega)) + (fun i _ hi => (hbad (i+1) hi).2) + (fun i hi he => by + have hil : i < p.length := by simp only [Finset.mem_Ico] at hi; omega + have ha := rootAnchor_step (1:ℂ) (by norm_num : (0:ℝ) ≤ 1/800) t p + (activePath_valid hp) hil (hbad (i+1) he).1 + rw [hdir (i+1) (by omega)] at ha + exact ha) + have hind (i : ℕ) : (if bad i then (1:ℝ) else 0) ≤ M (p.take i)+1000000*E i := by + rcases rootMarkIndicator_cases (1:ℂ) (1/800) t (p.take i) with hm | hm + · change M (p.take i) = 0 at hm + by_cases he : (1/1000:ℝ)^2 < E i + · simp only [bad,hm,ne_eq,not_true_eq_false,false_or,he,decide_true,ite_true] + nlinarith + · simp only [bad,hm,ne_eq,not_true_eq_false,false_or,he,decide_false,Bool.false_eq_true,ite_false] + nlinarith [he0 i] + · change M (p.take i) = 1 at hm + have hh0 := he0 i + by_cases he : bad i = true <;> simp [he,show M (p.take i) = 1 from hm] <;> nlinarith + have hterm : (∑ i ∈ Ico b k, if bad (i+1) then (1:ℝ) else 0) ≤ + pathCharge M p b+1000000*pathCharge (pathEnergy h r k q) p b := by + calc + _ ≤ ∑ i ∈ Ico b k, (M (p.take (i+1))+1000000*E (i+1)) := + sum_le_sum (fun i _ => hind (i+1)) + _ = ∑ i ∈ Ico (b+1) (k+1), (M (p.take i)+1000000*E i) := by + exact sum_Ico_add' (fun i => M (p.take i)+1000000*E i) b k 1 + _ ≤ ∑ i ∈ Ico b (p.length+1), (M (p.take i)+1000000*E i) := by + apply sum_le_sum_of_subset_of_nonneg + · intro i hi + simp only [Finset.mem_Ico] at hi ⊢ + omega + · intro i _ _ + exact add_nonneg (mark_nonneg t _) (mul_nonneg (by norm_num) (he0 i)) + _ = _ := by + rw [pathCharge_sum,pathCharge_sum,sum_add_distrib,mul_sum] + congr 1 + apply sum_congr rfl + intro i hi + congr 1 + have hil : i ≤ p.length := by have := (Finset.mem_Ico.mp hi).2; omega + simp only [E,rs,qs,pathEnergy,List.length_take,min_eq_left hil] + have hsum : pathSwitches h r k x p b = switchCost h rs x b+ + ∑ i ∈ Ico b k, switchCost h rs x (i+1) := by + change (∑ i ∈ Ico b (p.length+1), switchCost h rs x i) = _ + rw [hlen,Finset.sum_eq_sum_Ico_succ_bot (by omega : b < k+1),Finset.sum_Ico_add'] + rw [hsum] + have h1 := switchCost_le_one h rs x b + change _ ≤ 2+2*pathCharge M p b+2000000*pathCharge (pathEnergy h r k q) p b + linarith + +end ActualMarkTrees + +namespace CommonPrices +open DyadicHats ConeCoordinates ConeScalar Finset PricePieces LocalCancellation AffineDensities + +def sign (b : Bool) : ℝ := if b then 1 else -1 +lemma sign_cases (b : Bool) : sign b = 1 ∨ sign b = -1 := by cases b <;> simp [sign] +lemma sign_sq (b : Bool) : sign b^2 = 1 := by cases b <;> norm_num [sign] + +def cellPrice (N : ℕ) (r : ℝ) (h : ℂ → ℂ) (k : ℕ) (S : Finset (Grid N)) : ℝ := + ∑ q ∈ S, rootPrice N r h k q + +def rootWeight {N : ℕ} (S : Finset (Grid N)) (k j : ℕ) (s : Grid N) : ℝ := + ∑ q ∈ S, coeff N (k-j) q s +lemma rootWeight_nonneg {N : ℕ} (S : Finset (Grid N)) (k j : ℕ) (s : Grid N) : + 0 ≤ rootWeight S k j s := sum_nonneg (fun q _ => coeff_nonneg N (k-j) q s) + +abbrev ErrorIndex (N k : ℕ) := Fin (k+1) × Grid N × Bool + +def smallPiece {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) {r : ℝ} (hr : 0 < r) + (k : ℕ) (p : ℂ) (S : Finset (Grid N)) (n : ℂ) (i : ErrorIndex N k) : ErrorPiece 2 := + (errorPiece hh hr k i.1 (Nat.le_of_lt_succ i.1.isLt) p i.2.1 n (sign i.2.2)).weight + (rootWeight S k i.1 i.2.1) + +lemma smallPiece_mass {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) (i : ErrorIndex N k) : + (smallPiece hh hr k p S n i).mass ≤ (scale r k)⁻¹*2* + (rootWeight S k i.1 i.2.1*densityDefect N r (fun x => coordinate n (sign i.2.2) (h x)) i.1 i.2.1) := by + rw [smallPiece,ErrorPiece.mass_weight _ (rootWeight_nonneg ..)] + calc + _ ≤ rootWeight S k i.1 i.2.1*((scale r k)⁻¹* + (2*densityDefect N r (fun x => coordinate n (sign i.2.2) (h x)) i.1 i.2.1)) := + mul_le_mul_of_nonneg_left (errorPiece_mass hr hR hN hh hsupp k i.1 + (Nat.le_of_lt_succ i.1.isLt) p i.2.1 hn (sign_sq _)) (rootWeight_nonneg ..) + _ = _ := by ring + +lemma discounted_smallPiece_mass {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) (i : ErrorIndex N k) : + (smallPiece hh hr k p S n i).size^(1/100:ℝ)*(smallPiece hh hr k p S n i).mass ≤ + (scale r k)⁻¹*2*(rho^(k-i.1)* + (rootWeight S k i.1 i.2.1*densityDefect N r (fun x => coordinate n (sign i.2.2) (h x)) i.1 i.2.1)) := by + have hs : (smallPiece hh hr k p S n i).size^(1/100:ℝ) = rho^(k-i.1) := + scale_discount hr (Nat.le_of_lt_succ i.1.isLt) + rw [hs] + calc + _ ≤ rho^(k-i.1)*((scale r k)⁻¹*2* + (rootWeight S k i.1 i.2.1*densityDefect N r (fun x => coordinate n (sign i.2.2) (h x)) i.1 i.2.1)) := + mul_le_mul_of_nonneg_left (smallPiece_mass hr hR hN hh hsupp k p S hn i) (pow_nonneg rho_pos.le _) + _ = _ := by ring + +lemma weighted_defect_sum {N : ℕ} (r : ℝ) (h : ℂ → ℝ) (k : ℕ) (S : Finset (Grid N)) : + (∑ j : Fin (k+1), ∑ s : Grid N, rho^(k-j.val)*(rootWeight S k j s*densityDefect N r h j s)) = + ∑ q ∈ S, scalarPrice N r h rho k q := by + simp only [rootWeight,sum_mul,mul_sum] + simp_rw [Finset.sum_comm (s := univ) (t := S)] + apply sum_congr rfl + intro q _ + unfold scalarPrice + rw [← Fin.sum_univ_eq_sum_range] + apply sum_congr rfl + intro j _ + rw [mul_sum] + +lemma smallPiece_price {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) : + errorPrice (smallPiece hh hr k p S n) (1/100) ≤ (scale r k)⁻¹*2* + ∑ q ∈ S, (scalarPrice N r (fun x => coordinate n 1 (h x)) rho k q+ + scalarPrice N r (fun x => coordinate n (-1) (h x)) rho k q) := by + apply (sum_le_sum (fun i _ => discounted_smallPiece_mass hr hR hN hh hsupp k p S hn i)).trans_eq + rw [← mul_sum] + congr 1 + simp only [Fintype.sum_prod_type,Fintype.sum_bool,sign,Bool.false_eq_true, + ite_false,ite_true,sum_add_distrib] + rw [weighted_defect_sum,weighted_defect_sum,← sum_add_distrib] + +lemma smallPiece_common_price {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : n ∈ fixedPalette.labels) : + errorPrice (smallPiece hh hr k p S n) (1/100) ≤ (scale r k)⁻¹*2*cellPrice N r h k S := by + apply (smallPiece_price hr hR hN hh hsupp k p S (fixedPalette.unit n hn)).trans + apply mul_le_mul_of_nonneg_left _ (mul_nonneg (inv_nonneg.mpr (scale_pos hr k).le) (by norm_num)) + apply sum_le_sum + intro q _ + apply single_le_sum _ hn + intro n _ + exact add_nonneg + (scalarPrice_nonneg hr hR hN (scalar_integrable hh _) (scalar_support hsupp _) k q) + (scalarPrice_nonneg hr hR hN (scalar_integrable hh _) (scalar_support hsupp _) k q) + +open DyadicHats ConeCoordinates ConeScalar Finset PricePieces LocalCancellation AffineDensities + +def goodRoots {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) : Finset (Grid N) := + by classical exact S.filter (fun q => Good n (DirectionNeighbors.theta h (scale r k) q)) +def badRoots {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) : Finset (Grid N) := + by classical exact S.filter (fun q => ¬Good n (DirectionNeighbors.theta h (scale r k) q)) + +def rootSum {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) (y : ℂ) : ℂ := + ∑ q ∈ S, rootVector N r h k q n y + +lemma rootSum_integrable {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) + (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) : Integrable (rootSum h r k S n) := + integrable_finsetSum S (fun _ _ => rootVector_integrable hh r k _ n) + +lemma rootSum_partition {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) (y : ℂ) : + rootSum h r k (goodRoots h r k S n) n y+rootSum h r k (badRoots h r k S n) n y = rootSum h r k S n y := by + classical + exact sum_filter_add_sum_filter_not S (fun q => Good n (DirectionNeighbors.theta h (scale r k) q)) _ + +lemma rootSum_mass {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) : + (∫ y, ‖rootSum h r k S n y‖) ≤ 4*∑ q ∈ S, scalarMass h (scale r k) q := by + calc + _ ≤ ∫ y, ∑ q ∈ S, ‖rootVector N r h k q n y‖ := + integral_mono (rootSum_integrable hh r k S n).norm + (integrable_finsetSum S (fun _ _ => (rootVector_integrable hh r k _ n).norm)) + (fun y => norm_sum_le _ _) + _ = ∑ q ∈ S, ∫ y, ‖rootVector N r h k q n y‖ := + integral_finsetSum S (fun _ _ => (rootVector_integrable hh r k _ n).norm) + _ ≤ _ := by rw [mul_sum]; exact sum_le_sum (fun q _ => rootVector_mass hr hR hN hh hsupp k q hn) + +/-- The actual normalized positive-cone part on one cell. -/ +def goodCone {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s = 1 ∨ s = -1) : ConeDensity (axis n s) (1/2) where + density := rescale p (scale r k) (rootSum h r k (goodRoots h r k S n) n) + integrable := integrable_rescale (rootSum_integrable hh r k _ n) p (scale_pos hr k).ne' + cone := by + classical + apply ae_of_all + intro X + have hc := cone_sum (by norm_num : (0:ℝ) ≤ 1/2) (goodRoots h r k S n) + (fun q => rootVector N r h k q n (p+scale r k • X)) (by + intro q hq + have hg : Good n (DirectionNeighbors.theta h (scale r k) q) := (mem_filter.mp hq).2 + exact rootVector_cone hr hR hN hh hsupp k q hn hg hs _) + simp only [rescale,norm_smul,Real.norm_eq_abs,abs_of_pos (scale_pos hr k),real_inner_smul_right] + change (1/2:ℝ)*(scale r k*‖rootSum h r k (goodRoots h r k S n) n (p+scale r k • X)‖) ≤ _ + dsimp only [rootSum] + nlinarith [mul_le_mul_of_nonneg_left hc (scale_pos hr k).le] + +def badPrice {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) : ℝ := + ∑ q ∈ badRoots h r k S n, scalarMass h (scale r k) q + +/-- Bad cone roots are exactly the unrestricted size-one part. -/ +def badPiece {N : ℕ} {r : ℝ} (hr : 0 < r) {h : ℂ → ℂ} (hh : Integrable h) + (k : ℕ) (p : ℂ) (S : Finset (Grid N)) (n : ℂ) : ErrorPiece 2 := + unitPiece (rescale p (scale r k) (rootSum h r k (badRoots h r k S n) n)) + (integrable_rescale (rootSum_integrable hh r k _ n) p (scale_pos hr k).ne') 2 + +lemma badPiece_mass {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) : + (badPiece hr hh k p S n).mass ≤ (scale r k)⁻¹*4*badPrice h r k S n := by + change (∫ X, ‖rescale p (scale r k) (rootSum h r k (badRoots h r k S n) n) X‖) ≤ _ + rw [mass_rescale _ _ (scale_pos hr k)] + simpa only [mul_assoc,badPrice] using mul_le_mul_of_nonneg_left + (rootSum_mass hr hR hN hh hsupp k (badRoots h r k S n) hn) (inv_nonneg.mpr (scale_pos hr k).le) + +def cellErrors {N : ℕ} {r : ℝ} (hr : 0 < r) {h : ℂ → ℂ} (hh : Integrable h) + (k : ℕ) (p : ℂ) (S : Finset (Grid N)) (n : ℂ) : Option (ErrorIndex N k) → ErrorPiece 2 + | none => badPiece hr hh k p S n + | some i => smallPiece hh hr k p S n i + +lemma cellErrors_price {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : n ∈ fixedPalette.labels) : + errorPrice (cellErrors hr hh k p S n) (1/100) ≤ + (scale r k)⁻¹*(4*badPrice h r k S n+2*cellPrice N r h k S) := by + simp only [errorPrice,Fintype.sum_option,cellErrors,show (badPiece hr hh k p S n).size = 1 from rfl, + Real.one_rpow,one_mul] + have h1 := badPiece_mass hr hR hN hh hsupp k p S (fixedPalette.unit n hn) + have h2 := smallPiece_common_price hr hR hN hh hsupp k p S hn + unfold errorPrice at h2 + linarith + +open DyadicHats ConeCoordinates ConeScalar Finset PricePieces LocalCancellation AffineDensities + +lemma smallPiece_pair_sum {N : ℕ} {r : ℝ} (hr : 0 < r) {h : ℂ → ℂ} (hh : Integrable h) + (k : ℕ) (p : ℂ) (S : Finset (Grid N)) (n : ℂ) (j : Fin (k+1)) (q : Grid N) (X : ℂ) : + (∑ b : Bool, (smallPiece hh hr k p S n (j,q,b)).density X) = + rootWeight S k j q • rescale p (scale r k) (errorVector N r h j q n) X := by + simp only [Fintype.sum_bool,smallPiece,ErrorPiece.weight,errorPiece,sign, + Bool.false_eq_true,ite_false,ite_true,rescale,errorVector] + module + +lemma smallPiece_sum {N : ℕ} {r : ℝ} (hr : 0 < r) {h : ℂ → ℂ} (hh : Integrable h) + (k : ℕ) (p : ℂ) (S : Finset (Grid N)) (n : ℂ) (X : ℂ) : + (∑ i : ErrorIndex N k, (smallPiece hh hr k p S n i).density X) = + rescale p (scale r k) (fun y => ∑ q ∈ S, ∑ j ∈ range (k+1), + ∑ s : Grid N, coeff N (k-j) q s • errorVector N r h j s n y) X := by + simp only [Fintype.sum_prod_type,smallPiece_pair_sum,rootWeight,sum_smul,rescale,smul_sum] + simp_rw [Finset.sum_comm (s := univ) (t := S)] + apply sum_congr rfl + intro q _ + rw [← Fin.sum_univ_eq_sum_range] + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro s _ + module + +/-- Exact cell decomposition before imposing the local partition-of-unity +region. Both its scalar coordinates and all error densities are the actual +finite dyadic construction. -/ +theorem cell_decomposition {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s = 1 ∨ s = -1) (X : ℂ) : + (goodCone hr hR hN hh hsupp k p S hn hs).density X+ + (∑ i, (cellErrors hr hh k p S n i).density X) = + rescale p (scale r k) (fun y => (∑ q ∈ S, hat (scale r k) q y) • h y) X := by + rw [Fintype.sum_option] + change rescale p (scale r k) (rootSum h r k (goodRoots h r k S n) n) X+ + (rescale p (scale r k) (rootSum h r k (badRoots h r k S n) n) X+ + ∑ i : ErrorIndex N k, (smallPiece hh hr k p S n i).density X) = _ + rw [smallPiece_sum] + simp only [rescale,← smul_add,← add_assoc,rootSum_partition] + rw [sum_smul] + congr 1 + simp only [rootSum,← sum_add_distrib] + exact sum_congr rfl (fun q _ => (vector_decomposition hr hR hN hsupp k q hn _).symm) + +end CommonPrices + +namespace DirectionNeighbors +open DyadicHats +lemma mem_window_comm (d : ℕ) (p q : ℤ × ℤ) : p ∈ window d q ↔ q ∈ window d p := by + rw [mem_window_iff (by norm_num : (0:ℝ) < 1),mem_window_iff (by norm_num : (0:ℝ) < 1),boxNorm_sub_comm] + +lemma card_window (d : ℕ) (q : ℤ × ℤ) : (window d q).card = (2*d+1)^2 := by + change ((Finset.Icc (q.1-(d:ℤ)) (q.1+d)) ×ˢ + (Finset.Icc (q.2-(d:ℤ)) (q.2+d))).card = _ + rw [Finset.card_product,Int.card_Icc,Int.card_Icc] + have hq (z : ℤ) : (z+(d:ℤ)+1-(z-d)).toNat = 2*d+1 := by omega + rw [hq,hq,pow_two] + +end DirectionNeighbors + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/ActualMarkTrees2.lean b/lean/OAI/Analysis/SignedDisk/ActualMarkTrees2.lean new file mode 100644 index 0000000000000000000000000000000000000000..88a6e75a9ddc74ad13e5ee6ffd08d4f19b36dbe8 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/ActualMarkTrees2.lean @@ -0,0 +1,445 @@ +import OAI.Analysis.SignedDisk.ActualLabels1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace ActualMarkTrees +open DyadicHats IntrinsicMarks ActualLabels GeometricFilter Finset + +lemma path_filtered_cost {N : ℕ} (h : ℂ → ℂ) (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {m : ℕ} {q : Grid N} {p : List (Grid N)} (hp : activePath (tree v m 1 q) p) + {l : ℕ} (hl : l ≤ m) {x : ℂ} (hx : x ∈ neighborhood (scale r (m-l)) (pathVertex q p l)) + {i : ℕ} (hi : i ≤ m) (hil : i ≤ l+1) : + switchCost h (fun j => scale r (m-j)) x i+derivativeCost h (fun j => scale r (m-j)) x i ≤ + spatialConstant*filt (energyRate h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p))) i := by + apply filtered_spatial_cost h _ _ x _ i (fun j _ => scale_pos hr (m-j)) + (fun j hj => descending_step r (by omega)) + · intro j hj + exact (path_neighborhood_geometry v hr hp hl hx (by omega : j ≤ m) (by omega)).2.1 + · intro j hj + exact (path_neighborhood_geometry v hr hp hl hx (by omega : j ≤ m) (by omega)).2.2 + · exact (path_neighborhood_geometry v hr hp hl hx hi hil).1 + +lemma path_cellCost {N : ℕ} (h : ℂ → ℂ) (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {m : ℕ} {q : Grid N} {p : List (Grid N)} (hp : activePath (tree v m 1 q) p) + {l : ℕ} (hl : l ≤ m) : + cellCost h (fun j => scale r (m-j)) m l (pathVertex q p l) ≤ + spatialConstant*(filt (energyRate h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p))) l+ + filt (energyRate h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p))) (l+1)+ + filt (filt (energyRate h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p)))) l)+ + (if l=m then 1 else 0) := by + let rs := fun j => scale r (m-j) + let c := energyRate h rs (pathVertex q p) (point r (lastVertex q p)) + have hs (i : ℕ) (hi : i ≤ m) (hil : i ≤ l+1) : + localSup (fun x => switchCost h rs x i) (rs l) (pathVertex q p l) ≤ spatialConstant*filt c i := by + apply localSup_le (scale_pos hr _).le + intro x hx + have hh := path_filtered_cost h v hr hp hl hx hi hil + change switchCost h rs x i+derivativeCost h rs x i ≤ spatialConstant*filt c i at hh + linarith [derivativeCost_nonneg h rs x i (scale_pos hr _).le] + have ht (i : ℕ) (hi : i ≤ l) : + localSup (fun x => derivativeCost h rs x i) (rs l) (pathVertex q p l) ≤ spatialConstant*filt c i := by + apply localSup_le (scale_pos hr _).le + intro x hx + have hh := path_filtered_cost h v hr hp hl hx (show i ≤ m by omega) (show i ≤ l+1 by omega) + change switchCost h rs x i+derivativeCost h rs x i ≤ spatialConstant*filt c i at hh + linarith [switchCost_nonneg h rs x i] + have hT := filt_mono_on l ht + rw [filt_mul] at hT + have hnext : (if l=m then 1 else localSup (fun x => switchCost h rs x (l+1)) (rs l) (pathVertex q p l)) ≤ + spatialConstant*filt c (l+1)+(if l=m then 1 else 0) := by + split_ifs with he + · have hh := mul_nonneg spatialConstant_pos.le (filt_nonneg (energyRate_nonneg h rs (pathVertex q p) (point r (lastVertex q p))) (l+1)) + linarith + · simpa only [add_zero] using hs (l+1) (by omega) le_rfl + have hcur := hs l hl (by omega) + change cellCost h rs m l (pathVertex q p l) ≤ _ + dsimp only [cellCost] + change _ ≤ spatialConstant*(filt c l+filt c (l+1)+filt (filt c) l)+(if l=m then 1 else 0) + linarith + +lemma path_cellCost_sum {N : ℕ} (h : ℂ → ℂ) (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {m : ℕ} {q : Grid N} {p : List (Grid N)} (hp : activePath (tree v m 1 q) p) + {b : ℕ} (hb : b ≤ m) : + (∑ l ∈ Ico b (m+1), cellCost h (fun j => scale r (m-j)) m l (pathVertex q p l)) ≤ + spatialConstant*(8*∑ i ∈ Ico b (m+1), + energyRate h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p)) i+130)+1 := by + let c := energyRate h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p)) + have hc0 := energyRate_nonneg h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p)) + have hcA := energyRate_le_five h (fun j => scale r (m-j)) (pathVertex q p) (point r (lastVertex q p)) + have h1 := filt_tail (by norm_num : (0:ℝ) ≤ 5) hc0 hcA hb + have h2 := shifted_tail (by norm_num : (0:ℝ) ≤ 5) hc0 hcA hb + have h3 := double_tail (by norm_num : (0:ℝ) ≤ 5) hc0 hcA hb + have hs := sum_le_sum (fun l (hl : l ∈ Finset.Ico b (m+1)) => path_cellCost h v hr hp (show l ≤ m by have := Finset.mem_Ico.mp hl; omega)) + change _ ≤ ∑ l ∈ Ico b (m+1), (spatialConstant*(filt c l+filt c (l+1)+filt (filt c) l)+(if l=m then 1 else 0)) at hs + simp only [sum_add_distrib,← mul_sum] at hs + have he : (∑ l ∈ Ico b (m+1), if l=m then (1:ℝ) else 0) = 1 := by simp [hb] + rw [he] at hs + change _ ≤ spatialConstant*(8*∑ i ∈ Ico b (m+1), c i+130)+1 + have hh : (∑ i ∈ Ico b (m+1), filt c i)+(∑ i ∈ Ico b (m+1), filt c (i+1))+ + (∑ i ∈ Ico b (m+1), filt (filt c) i) ≤ 8*∑ i ∈ Ico b (m+1), c i+130 := by linarith + exact hs.trans (by nlinarith [mul_le_mul_of_nonneg_left hh spatialConstant_pos.le]) + +open DyadicHats IntrinsicMarks ActualLabels GeometricFilter DirectionNeighbors Finset + +def packingCharge {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (m : ℕ) (q : Grid N) : List (Grid N) → ℝ := + spatialCharge (fun j z => cellCost h (fun i => scale r (m-i)) m (m-j) z) m q + +lemma packingCharge_path {N : ℕ} (h : ℂ → ℂ) (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {m : ℕ} {q : Grid N} {p : List (Grid N)} (hp : activePath (tree v m 1 q) p) + {b : ℕ} (hb : b ≤ p.length) : + pathCharge (packingCharge h r m q) p b ≤ + 8*spatialConstant*particleSwitches h r m q p b+ + 8*spatialConstant*pathCharge (pathEnergy h r m q) p b+(130*spatialConstant+1) := by + have hlen := active_length v hp + have hs := path_cellCost_sum h v hr hp (show b ≤ m by omega) + have hC : pathCharge (packingCharge h r m q) p b = + ∑ i ∈ Ico b (m+1), cellCost h (fun j => scale r (m-j)) m i (pathVertex q p i) := by + rw [pathCharge_sum,hlen] + apply sum_congr rfl + intro i hi + have hi' : i ≤ m := by have := Finset.mem_Ico.mp hi; omega + simp only [packingCharge,spatialCharge,List.length_take,hlen,min_eq_left hi', + Nat.sub_sub_self hi',pathVertex] + have hE : (∑ i ∈ Ico b (m+1), energyRate h (fun j => scale r (m-j)) (pathVertex q p) + (point r (lastVertex q p)) i) = + particleSwitches h r m q p b+pathCharge (pathEnergy h r m q) p b := by + rw [pathCharge_sum] + simp only [particleSwitches,pathSwitches,hlen,energyRate,sum_add_distrib] + congr 1 + apply sum_congr rfl + intro i hi + have hi' : i ≤ m := by have := Finset.mem_Ico.mp hi; omega + simp only [pathEnergy,List.length_take,hlen,min_eq_left hi',pathVertex] + rw [hC] + rw [hE] at hs + linarith + +lemma tree_packing_bound {N : ℕ} (h : ℂ → ℂ) (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + (m : ℕ) (q : Grid N) : + nodeCharge (tree v m 1 q) (packingCharge h r m q) ≤ + 8*spatialConstant*particleEval (tree v m 1 q) (particleSwitches h r m q)+ + 8*spatialConstant*nodeCharge (tree v m 1 q) (pathEnergy h r m q)+ + (130*spatialConstant+1)*terminalMass (tree v m 1 q) := by + have hs := particleEval_mono_active (tree v m 1 q) + (F := pathCharge (packingCharge h r m q)) + (fun p b hp hb => packingCharge_path h v hr hp hb) + simp only [particleEval_add,particleEval_smul,particleEval_const,particle_occupancy] at hs + nlinarith only [hs] + +def packingConstant : ℝ := + 8*spatialConstant*(2560004+2000000*(576*(4097:ℝ)^2))+ + 8*spatialConstant*(576*(4097:ℝ)^2)+(130*spatialConstant+1) +lemma packingConstant_pos : 0 < packingConstant := by + dsimp [packingConstant] + have := spatialConstant_pos + positivity + +theorem spatial_packing {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) : + (∑ j ∈ range (m+1), ∑ q : Grid N, scalarMass h (scale r j) q* + cellCost h (fun i => scale r (m-i)) m (m-j) q) ≤ + packingConstant*(∫ y, ‖h y‖) := by + have hs := sum_le_sum (fun q (_ : q ∈ (univ : Finset (Grid N))) => + tree_packing_bound h (fun q => vectorMass h r q) hr m q) + simp only [sum_add_distrib,← mul_sum] at hs + have hleft : (∑ q : Grid N, nodeCharge (tree (fun q => vectorMass h r q) m 1 q) + (packingCharge h r m q)) = + ∑ j ∈ range (m+1), ∑ q : Grid N, scalarMass h (scale r j) q* + cellCost h (fun i => scale r (m-i)) m (m-j) q := by + unfold packingCharge + rw [sum_nodeCharge] + apply sum_congr rfl + intro j hj + apply sum_congr rfl + intro q hq + rw [← vectorMass_coeff hr hR hN hh hsupp] + rfl + rw [hleft,sum_energyCharge hr hR hN hh hsupp,sum_terminalMass] at hs + have hS := forest_switch_budget hr hR hN hh hsupp m + have hE := neighbor_energy_budget hr hR hN hh hsupp (m+1) + have hM := sum_scalarMass_grid_le (N := N) hh r + change (∑ q : Grid N, ‖vectorMass h r q‖) ≤ ∫ y, ‖h y‖ at hM + have hcoef : 0 ≤ 8*spatialConstant := by have := spatialConstant_pos; positivity + have hcoef' : 0 ≤ 130*spatialConstant+1 := by have := spatialConstant_pos; positivity + dsimp only [packingConstant] + nlinarith only [hs,mul_le_mul_of_nonneg_left hS hcoef, + mul_le_mul_of_nonneg_left hE hcoef,mul_le_mul_of_nonneg_left hM hcoef'] +end ActualMarkTrees + +namespace CommonPrices +open DyadicHats ConeCoordinates ConeScalar LocalCancellation AffineDensities DirectionNeighbors Finset DiskMoments PricePieces + +def rootMass {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) : ℝ := + ∑ q ∈ S, scalarMass h (scale r k) q +lemma rootMass_nonneg {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) : + 0 ≤ rootMass h r k S := sum_nonneg (fun _ _ => norm_nonneg _) + +def sizeErrors {N : ℕ} {r : ℝ} (hr : 0 < r) {h : ℂ → ℂ} (hh : Integrable h) + (k : ℕ) (p : ℂ) (S : Finset (Grid N)) (n : ℂ) : Option (ErrorIndex N k) → ErrorPiece 2 + | none => unitPiece (rescale p (scale r k) (rootSum h r k S n)) + (integrable_rescale (rootSum_integrable hh r k S n) p (scale_pos hr k).ne') 2 + | some i => smallPiece hh hr k p S n i + +lemma sizeErrors_price {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : ℂ) (S : Finset (Grid N)) + {n : ℂ} (hn : n ∈ fixedPalette.labels) : + errorPrice (sizeErrors hr hh k p S n) (1/100) ≤ + (scale r k)⁻¹*(4*rootMass h r k S+2*cellPrice N r h k S) := by + have hb : (sizeErrors hr hh k p S n none).mass ≤ (scale r k)⁻¹*4*rootMass h r k S := by + change (∫ X, ‖rescale p (scale r k) (rootSum h r k S n) X‖) ≤ _ + rw [mass_rescale _ _ (scale_pos hr k)] + simpa only [mul_assoc,rootMass] using mul_le_mul_of_nonneg_left + (rootSum_mass hr hR hN hh hsupp k S (fixedPalette.unit n hn)) (inv_nonneg.mpr (scale_pos hr k).le) + have hs := smallPiece_common_price hr hR hN hh hsupp k p S hn + change (∑ i, (smallPiece hh hr k p S n i).size^(1/100:ℝ)* + (smallPiece hh hr k p S n i).mass) ≤ _ at hs + simp only [errorPrice,Fintype.sum_option,show (sizeErrors hr hh k p S n none).size = 1 from rfl, + Real.one_rpow,one_mul] + change (sizeErrors hr hh k p S n none).mass + (∑ i, (smallPiece hh hr k p S n i).size^(1/100:ℝ)*(smallPiece hh hr k p S n i).mass) ≤ _ + linarith + +lemma sizeErrors_gradient {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {g : ℂ → ℝ} (hg : Differentiable ℝ g) + (hh : Integrable (gradient g)) (hsupp : ∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) + (k : ℕ) (p : ℤ × ℤ) {n : ℂ} (hn : ‖n‖ = 1) (X : ℂ) (hX : ‖X‖ ≤ 12) : + (∑ i, (sizeErrors hr hh k (point (scale r k) p) (cellRoots N p) n i).density X) = + gradient (fun Y => g (point (scale r k) p+scale r k • Y)) X := by + rw [Fintype.sum_option] + change rescale _ _ (rootSum _ _ _ _ _) X+ + (∑ i : ErrorIndex N k, (smallPiece hh hr k _ _ n i).density X) = _ + rw [smallPiece_sum,gradient_affine hg] + simp only [rescale,← smul_add,rootSum,← sum_add_distrib] + have he := sum_congr rfl (fun q (_ : q ∈ cellRoots N p) => + (vector_decomposition hr hR hN hsupp k q hn (point (scale r k) p+scale r k • X)).symm) + rw [he,← sum_smul,cell_partition (scale_pos hr k) (scale_index_bound hr hR hN k) hsupp p X hX] + +/-- The endpoint-bin gradient price, with all root terms retained rather than +silently using the cone estimate at one-sided maximizing radii. -/ +theorem size_cell_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → ∀ (k : ℕ) (p : ℤ × ℤ) + {n : ℂ}, n ∈ fixedPalette.labels → ∀ Q : Set ℂ, volume Q ≤ ENNReal.ofReal 1 → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ X in Q, F X) ≤ ENNReal.ofReal (C*(scale r k)⁻¹* + (rootMass (gradient g) r k (cellRoots N p)+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ X, ‖X‖ ≤ 2 → ∀ t, + EndpointRadius (fun Y => g (point (scale r k) p+scale r k • Y)) X t → + ENNReal.ofReal ‖∫ Y in Metric.ball X t, + gradient (fun Z => g (point (scale r k) p+scale r k • Z)) Y‖ ≤ F X := by + obtain ⟨C,hC,hmajor⟩ := size_majorant (by norm_num : (0:ℝ) ≤ 2) + refine ⟨4*C,by positivity,?_⟩ + intro N r R hr hR hN g hg hh hsupp k p n hn Q hQ + let b := sizeErrors hr hh k (point (scale r k) p) (cellRoots N p) n + have hg' : ContDiff ℝ 1 (fun Y => g (point (scale r k) p+scale r k • Y)) := hg.comp (by fun_prop) + obtain ⟨F,hFm,hFi,hFb⟩ := hmajor b _ hg' Q hQ + refine ⟨F,hFm,?_,?_⟩ + · apply hFi.trans + apply ENNReal.ofReal_le_ofReal + have hb := sizeErrors_price hr hR hN hh hsupp k (point (scale r k) p) (cellRoots N p) hn + have hD : 0 ≤ cellPrice N r (gradient g) k (cellRoots N p) := + sum_nonneg (fun q _ => rootPrice_nonneg hr hR hN hh hsupp k q) + change errorPrice b (1/100) ≤ _ at hb + have hrk := scale_pos hr k + nlinarith [mul_le_mul_of_nonneg_left hb hC.le,inv_nonneg.mpr hrk.le, + mul_nonneg (inv_nonneg.mpr hrk.le) hD] + · intro X hX t ht + apply hFb X _ t ht + filter_upwards with Y hY + apply sizeErrors_gradient hr hR hN (hg.differentiable one_ne_zero) hh hsupp k p (fixedPalette.unit n hn) + have hy : ‖Y-X‖ < 3 := by simpa only [Metric.mem_ball,dist_eq_norm] using hY + have htri := norm_add_le (Y-X) X + rw [sub_add_cancel] at htri + linarith +end CommonPrices + +namespace PlanePotential +open LocalCancellation + +lemma green_restrict_density {ψ : ℂ → ℝ} {R X : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hRX : R ≤ X) + (β : ℂ → ℂ) {x : ℂ} (hx : ‖x‖ ≤ X) (y : ℂ) : + ⟪green ψ x y, ({y : ℂ | ‖y‖ ≤ X}.indicator β) y⟫ = ⟪green ψ x y,β y⟫ := by + by_cases hy : ‖y‖ ≤ X + · simp [hy] + · rw [green_eq_zero_of_outside hψs hRX hx (lt_of_not_ge hy)] + simp + +lemma green_root_lp_local {ψ : ℂ → ℝ} {β : ℂ → ℂ} + (hψm : Measurable ψ) {R X B : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hRX : R ≤ X) (hM : 0 < R+X) (hB : 0 ≤ B) (hX : 0 < X) + (hβ : Integrable β) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, (ENNReal.ofReal |∫ y, ⟪green ψ x y,β y⟫|)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(4*X)^(1/2:ℝ))) * + (ENNReal.ofReal (∫ y, ‖β y‖))^(3/2:ℝ) := by + let β' := {y : ℂ | ‖y‖ ≤ X}.indicator β + have hi : Integrable β' := hβ.indicator (measurableSet_le measurable_norm measurable_const) + have hs : ∀ y, β' y ≠ 0 → ‖y‖ ≤ X := by + intro y hy + by_contra hn + exact hy (by simp [β',hn]) + have h := green_root_lp hψm hψs hψB hM hB (show 0 < X+X by linarith) hi hs + have he : (fun x => (ENNReal.ofReal |∫ y, ⟪green ψ x y,β' y⟫|)^(3/2:ℝ)) =ᵐ[volume.restrict {x : ℂ | ‖x‖ ≤ X}] + (fun x => (ENNReal.ofReal |∫ y, ⟪green ψ x y,β y⟫|)^(3/2:ℝ)) := by + filter_upwards [ae_restrict_mem (measurableSet_le measurable_norm measurable_const)] with x hx + congr 3 + exact integral_congr_ae (ae_of_all _ (green_restrict_density hψs hRX β hx)) + rw [lintegral_congr_ae he] at h + have hm : (∫ y, ‖β' y‖) ≤ ∫ y, ‖β y‖ := + integral_mono hi.norm hβ.norm (fun y => norm_indicator_le_norm_self β y) + have hm' := ENNReal.rpow_le_rpow (ENNReal.ofReal_le_ofReal hm) (by norm_num : (0:ℝ) ≤ 3/2) + have h' := h.trans (mul_le_mul_right hm' _) + simpa only [show 2*(X+X)=4*X by ring] using h' + +lemma green_zero_piece_lp_ae {ψ : ℂ → ℝ} {β : ℂ → ℂ} + (hψm : Measurable ψ) {R X B L a : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hψL : ∀ u v, |ψ u-ψ v| ≤ L*‖u-v‖) + (hM : 0 < R+X) (hB : 0 ≤ B) (hL : 0 ≤ L) (ha : 0 < a) + (z : ℂ) (hβ : Integrable β) (hzero : ∫ y, β y = 0) + (hβs : ∀ᵐ y, β y ≠ 0 → ‖y-z‖ ≤ a) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, + (ENNReal.ofReal |∫ y, ⟪green ψ x y,β y⟫|)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((8*Real.pi*(2*B*(R+X)^2)^(3/2:ℝ)+ + Real.pi*(8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)^(3/2:ℝ))*a^(1/2:ℝ)) * + (ENNReal.ofReal (∫ y, ‖β y‖))^(3/2:ℝ) := by + let β' := {y : ℂ | ‖y-z‖ ≤ a}.indicator β + have he : β' =ᵐ[volume] β := by + filter_upwards [hβs] with y hy + by_cases hs : ‖y-z‖ ≤ a + · simp [β',hs] + · have hz : β y = 0 := by by_contra hn; exact hs (hy hn) + simp [β',hs,hz] + have hi : Integrable β' := hβ.congr he.symm + have hz : ∫ y, β' y = 0 := (integral_congr_ae he).trans hzero + have hs : ∀ y, β' y ≠ 0 → ‖y-z‖ ≤ a := by + intro y hy + by_contra hn + exact hy (by simp [β',hn]) + have hp (x : ℂ) : (∫ y, ⟪green ψ x y,β' y⟫) = ∫ y, ⟪green ψ x y,β y⟫ := + integral_congr_ae (he.mono (fun y hy => by simpa only using congrArg (fun z => ⟪green ψ x y,z⟫) hy)) + have hm : (∫ y, ‖β' y‖) = ∫ y, ‖β y‖ := integral_congr_ae (he.mono (fun y hy => by simpa only using congrArg norm hy)) + simpa only [hp,hm] using green_zero_piece_lp hψm hψs hψB hψL hM hB hL ha z hi hz hs + +/-- The local decomposition theorem does not demand artificial bounded support +of the original densities: the actual Green kernel vanishes outside the +observation ball. -/ +theorem green_decomposition_norm_local {ι : Type*} [Fintype ι] + {ψ g : ℂ → ℝ} (hψ : Continuous ψ) (hψc : HasCompactSupport ψ) + (hg : ContDiff ℝ 1 g) {D R X B : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (hψ1 : ∫ z, ψ z = 1) + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hRX : R ≤ X) (hM : 0 < R+X) (hB : 0 ≤ B) (hX : 0 < X) + (β : ι → ℂ → ℂ) (hβ : ∀ i, Integrable (β i)) + (hdecomp : ∀ᵐ y, ‖y‖ ≤ X → gradient g y = ∑ i, β i y) : + eLpNorm (fun x => g x-∫ z, ψ z*g z) (3/2) (volume.restrict {x : ℂ | ‖x‖ ≤ X}) ≤ + ∑ i, eLpNorm (fun x => ∫ y, ⟪green ψ x y,β i y⟫) (3/2) + (volume.restrict {x : ℂ | ‖x‖ ≤ X}) := by + let β' := fun i => {y : ℂ | ‖y‖ ≤ X}.indicator (β i) + have hi (i : ι) : Integrable (β' i) := (hβ i).indicator (measurableSet_le measurable_norm measurable_const) + have hs (i : ι) (y : ℂ) (hy : β' i y ≠ 0) : ‖y‖ ≤ X := by + by_contra hn + exact hy (by simp [β',hn]) + have hd : ∀ᵐ y, ‖y‖ ≤ X → gradient g y = ∑ i, β' i y := by + filter_upwards [hdecomp] with y hy hY + simpa [β',hY] using hy hY + have h := green_decomposition_norm hψ hψc hg hD hψ1 hψs hψB hRX hM hB + (show 0 < X+X by linarith) β' hi hs hd + apply h.trans_eq + apply Finset.sum_congr rfl + intro i _ + apply eLpNorm_congr_ae + filter_upwards [ae_restrict_mem (measurableSet_le measurable_norm measurable_const)] with x hx + exact integral_congr_ae (ae_of_all _ (green_restrict_density hψs hRX (β i) hx)) + +/-- Uniform fractional small-support gain expressed in the common price +exponent 1/100, including the unrestricted unit-size terms. -/ +theorem exists_green_price : ∃ (ψ : ℂ → ℝ) (C : ℝ), 0 < C ∧ + ContDiff ℝ ∞ ψ ∧ HasCompactSupport ψ ∧ (∫ z, ψ z) = 1 ∧ + (∀ z, ψ z ≠ 0 → ‖z‖ ≤ 1) ∧ + ∀ b : ErrorPiece 2, + eLpNorm (fun x => ∫ y, ⟪green ψ x y,b.density y⟫) (3/2) + (volume.restrict {x : ℂ | ‖x‖ ≤ 8}) ≤ + ENNReal.ofReal (C*b.size^(1/100:ℝ)*b.mass) := by + obtain ⟨ψ,B,L,hB,hL,hψ,hψc,hψ1,hψs,hψB,hψL⟩ := exists_kernel_cutoff + let A : ℝ := (2*B*(1+8)^2)^(3/2:ℝ)*(4*Real.pi*(4*8)^(1/2:ℝ)) + let Z : ℝ := 8*Real.pi*(2*B*(1+8)^2)^(3/2:ℝ)+ + Real.pi*(8*B*(1+8)^2+(64/3:ℝ)*L*(1+8)^3)^(3/2:ℝ) + have hA : 0 ≤ A := by dsimp [A]; positivity + have hZ : 0 ≤ Z := by dsimp [Z]; positivity + let C : ℝ := A^(2/3:ℝ)+Z^(2/3:ℝ)*2^(1/3:ℝ)+1 + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨ψ,C,hC,hψ,hψc,hψ1,hψs,?_⟩ + intro b + have hb0 := b.size_pos.le + have hm0 := b.mass_nonneg + rw [eLpNorm_eq_eLpNorm' (by norm_num : (3/2:ℝ≥0∞) ≠ 0) (by finiteness) + (potential_aestronglyMeasurable _ (green_measurable ψ hψ.continuous.measurable) b.integrable)] + norm_num only [ENNReal.toReal_div, ENNReal.toReal_ofNat] + by_cases hb : b.size < 1 + · have ha : 0 < 2*b.size := mul_pos (by norm_num) b.size_pos + have hp := green_zero_piece_lp_ae hψ.continuous.measurable hψs hψB hψL (by norm_num : (0:ℝ) < 1+8) + hB hL ha b.center b.integrable (b.zero_mass hb) (b.support hb) + have hn := eLpNorm_three_halves_bound _ hp + change _ ≤ (ENNReal.ofReal (Z*(2*b.size)^(1/2:ℝ)))^(2/3:ℝ)*ENNReal.ofReal b.mass at hn + have he : (ENNReal.ofReal (Z*(2*b.size)^(1/2:ℝ)))^(2/3:ℝ)*ENNReal.ofReal b.mass = + ENNReal.ofReal (Z^(2/3:ℝ)*2^(1/3:ℝ)*b.size^(1/3:ℝ)*b.mass) := by + rw [ENNReal.ofReal_rpow_of_nonneg (by positivity) (by norm_num),← ENNReal.ofReal_mul (by positivity)] + congr 1 + rw [Real.mul_rpow hZ (by positivity),← Real.rpow_mul (by positivity),show (1/2:ℝ)*(2/3)=1/3 by norm_num, + Real.mul_rpow (by norm_num : (0:ℝ) ≤ 2) b.size_pos.le] + ring + rw [he] at hn + apply hn.trans (ENNReal.ofReal_le_ofReal _) + have hbpow : b.size^(1/3:ℝ) ≤ b.size^(1/100:ℝ) := + Real.rpow_le_rpow_of_exponent_ge b.size_pos b.size_le_one (by norm_num) + have hZC : Z^(2/3:ℝ)*2^(1/3:ℝ) ≤ C := by dsimp [C]; linarith [Real.rpow_nonneg hA (2/3)] + exact mul_le_mul_of_nonneg_right + (le_trans (mul_le_mul_of_nonneg_left hbpow (by positivity)) + (mul_le_mul_of_nonneg_right hZC (by positivity))) b.mass_nonneg + · have hb1 : b.size = 1 := le_antisymm b.size_le_one (le_of_not_gt hb) + have hp := green_root_lp_local hψ.continuous.measurable hψs hψB (by norm_num : (1:ℝ) ≤ 8) + (by norm_num : (0:ℝ) < 1+8) hB (by norm_num : (0:ℝ) < 8) b.integrable + have hn := eLpNorm_three_halves_bound _ hp + change _ ≤ (ENNReal.ofReal A)^(2/3:ℝ)*ENNReal.ofReal b.mass at hn + rw [ENNReal.ofReal_rpow_of_nonneg hA (by norm_num),← ENNReal.ofReal_mul (by positivity)] at hn + simp only [hb1,Real.one_rpow,mul_one] + apply hn.trans (ENNReal.ofReal_le_ofReal _) + apply mul_le_mul_of_nonneg_right _ b.mass_nonneg + dsimp [C] + linarith [mul_nonneg (Real.rpow_nonneg hZ (2/3)) (Real.rpow_nonneg (by norm_num : (0:ℝ) ≤ 2) (1/3))] +end PlanePotential + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/AffineDensities1.lean b/lean/OAI/Analysis/SignedDisk/AffineDensities1.lean new file mode 100644 index 0000000000000000000000000000000000000000..636be8d749aec81b1fcf57bcbf860f4d3047bf17 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/AffineDensities1.lean @@ -0,0 +1,452 @@ +import OAI.Analysis.SignedDisk.DirectionNeighbors1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace AffineDensities + +def rescale (p : ℂ) (r : ℝ) (h : ℂ → ℂ) (X : ℂ) : ℂ := r • h (p+r • X) + +lemma integrable_rescale {h : ℂ → ℂ} (hh : Integrable h) (p : ℂ) {r : ℝ} (hr : r ≠ 0) : + Integrable (rescale p r h) := ((hh.comp_add_left p).comp_smul hr).smul r + +lemma integral_affine (h : ℂ → ℂ) (p : ℂ) (r : ℝ) : + (∫ X : ℂ, h (p+r • X)) = (r^2)⁻¹ • ∫ y, h y := by + have he := Measure.integral_comp_smul volume (fun y : ℂ => h (p+y)) r + simpa only [Complex.finrank_real_complex,abs_of_nonneg (inv_nonneg.mpr (sq_nonneg r)), + integral_add_left_eq_self] using he + +lemma integral_rescale (h : ℂ → ℂ) (p : ℂ) {r : ℝ} (hr : r ≠ 0) : + (∫ X, rescale p r h X) = r⁻¹ • ∫ y, h y := by + simp only [rescale,integral_smul,integral_affine,smul_smul] + congr 1 + field_simp + +lemma mass_rescale (h : ℂ → ℂ) (p : ℂ) {r : ℝ} (hr : 0 < r) : + (∫ X, ‖rescale p r h X‖) = r⁻¹*(∫ y, ‖h y‖) := by + simp only [rescale,norm_smul,Real.norm_eq_abs,abs_of_nonneg hr.le,integral_const_mul] + have he := Measure.integral_comp_smul volume (fun y : ℂ => ‖h (p+y)‖) r + simp only [Complex.finrank_real_complex,smul_eq_mul, + abs_of_nonneg (inv_nonneg.mpr (sq_nonneg r))] at he + rw [he, integral_add_left_eq_self (fun y : ℂ => ‖h y‖)] + field_simp + +lemma rescale_support {h : ℂ → ℂ} {p z : ℂ} {r t : ℝ} (hr : 0 < r) + (hs : ∀ y, h y ≠ 0 → ‖y-z‖ ≤ t) (X : ℂ) (hX : rescale p r h X ≠ 0) : + ‖X-r⁻¹ • (z-p)‖ ≤ t/r := by + have hh : h (p+r • X) ≠ 0 := fun h => hX (by change r • _ = 0; rw [h,smul_zero]) + have hi := hs (p+r • X) hh + have he : p+r • X-z = r • (X-r⁻¹ • (z-p)) := by + rw [smul_sub,smul_smul,mul_inv_cancel₀ hr.ne',one_smul] + abel + rw [he,norm_smul,Real.norm_eq_abs,abs_of_nonneg hr.le] at hi + exact (le_div_iff₀ hr).mpr (by simpa only [mul_comm] using hi) + +end AffineDensities + +namespace PricePieces +open DyadicHats ConeCoordinates ConeScalar LocalCancellation AffineDensities + +lemma error_support {N : ℕ} {h : ℂ → ℝ} (hh : Integrable h) {r : ℝ} (hr : 0 < r) + (j : ℕ) (q : Grid N) (y : ℂ) (hy : densityError N r h j q y ≠ 0) : + ‖y-point (scale r j) q‖ ≤ 2*scale r j := by + have hn : hat (scale r j) q y ≠ 0 := fun hn => hy ((density_support hr hh j q y hn).2) + simpa only [Metric.mem_closedBall,dist_eq_norm] using support_hat_subset (scale_pos hr j) q hn + +lemma scale_le {r : ℝ} (hr : 0 < r) {j k : ℕ} (hj : j ≤ k) : scale r j ≤ scale r k := by + apply mul_le_mul_of_nonneg_right _ hr.le + exact pow_le_pow_right₀ (by norm_num : (1:ℝ) ≤ 2) hj + +def errorPiece {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) {r : ℝ} (hr : 0 < r) + (k j : ℕ) (hj : j ≤ k) (p : ℂ) (q : Grid N) (n : ℂ) (s : ℝ) : ErrorPiece 2 where + density := rescale p (scale r k) + (fun y => densityError N r (fun x => coordinate n s (h x)) j q y • axis n s) + integrable := integrable_rescale + ((densityError_integrable (scalar_integrable hh _) r j q).smul_const _) p (scale_pos hr k).ne' + size := scale r j / scale r k + size_pos := div_pos (scale_pos hr j) (scale_pos hr k) + size_le_one := (div_le_one (scale_pos hr k)).mpr (scale_le hr hj) + center := (scale r k)⁻¹ • (point (scale r j) q-p) + zero_mass := by + intro _ + rw [integral_rescale _ _ (scale_pos hr k).ne',integral_smul_const, + densityError_zero_mass (scalar_integrable hh _),zero_smul,smul_zero] + support := by + intro _ + apply ae_of_all + intro X hX + have hs : ∀ y, densityError N r (fun x => coordinate n s (h x)) j q y • axis n s ≠ 0 → + ‖y-point (scale r j) q‖ ≤ 2*scale r j := by + intro y hy + apply error_support (scalar_integrable hh _) hr j q y + exact fun h => hy (by rw [h,zero_smul]) + simpa only [mul_div_assoc] using rescale_support (scale_pos hr k) hs X hX + +lemma errorPiece_mass {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k j : ℕ) (hj : j ≤ k) (p : ℂ) (q : Grid N) + {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s^2 = 1) : + (errorPiece hh hr k j hj p q n s).mass ≤ (scale r k)⁻¹* + (2*densityDefect N r (fun x => coordinate n s (h x)) j q) := by + change (∫ X, ‖rescale _ _ _ X‖) ≤ _ + rw [mass_rescale _ _ (scale_pos hr k)] + simp only [norm_smul,axis_norm hn hs,mul_one,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_left + (densityError_cost hr hR hN (scalar_integrable hh _) (scalar_support hsupp _) j q) + (inv_nonneg.mpr (scale_pos hr k).le) + +end PricePieces + +namespace LocalCancellation + +/-- Multiplication of an error density by a nonnegative path coefficient. +Zero coefficients are retained as genuine zero-density pieces. -/ +def ErrorPiece.weight {Cs : ℝ} (b : ErrorPiece Cs) (w : ℝ) : ErrorPiece Cs where + density := fun y => w • b.density y + integrable := b.integrable.smul w + size := b.size + size_pos := b.size_pos + size_le_one := b.size_le_one + center := b.center + zero_mass := by intro hs; rw [integral_smul,b.zero_mass hs,smul_zero] + support := by + intro hs + filter_upwards [b.support hs] with y hy h + exact hy (fun hz => h (by rw [hz,smul_zero])) + +lemma ErrorPiece.mass_weight {Cs : ℝ} (b : ErrorPiece Cs) {w : ℝ} (hw : 0 ≤ w) : + (b.weight w).mass = w*b.mass := by + simp only [ErrorPiece.mass,ErrorPiece.weight,norm_smul,Real.norm_eq_abs,abs_of_nonneg hw, + integral_const_mul] + +/-- An unrestricted integrable root term is a legitimate size-one piece. -/ +def unitPiece (h : ℂ → ℂ) (hh : Integrable h) (Cs : ℝ) : ErrorPiece Cs where + density := h + integrable := hh + size := 1 + size_pos := zero_lt_one + size_le_one := le_rfl + center := 0 + zero_mass := by intro hs; exact (lt_irrefl (1:ℝ) hs).elim + support := by intro hs; exact (lt_irrefl (1:ℝ) hs).elim + +lemma cone_sum {ι : Type*} {e : ℂ} {κ : ℝ} (hκ : 0 ≤ κ) (s : Finset ι) (v : ι → ℂ) + (hv : ∀ i ∈ s, κ*‖v i‖ ≤ inner ℝ e (v i)) : + κ*‖∑ i ∈ s, v i‖ ≤ inner ℝ e (∑ i ∈ s, v i) := by + calc + _ ≤ κ*∑ i ∈ s, ‖v i‖ := mul_le_mul_of_nonneg_left (norm_sum_le _ _) hκ + _ = ∑ i ∈ s, κ*‖v i‖ := Finset.mul_sum _ _ _ + _ ≤ ∑ i ∈ s, inner ℝ e (v i) := Finset.sum_le_sum hv + _ = _ := (inner_sum _ _ _).symm + +end LocalCancellation + +namespace PricePieces +open DyadicHats ConeCoordinates ConeScalar LocalCancellation AffineDensities + +/-- The vector root comprises the two actual signed scalar surviving roots. -/ +def rootVector (N : ℕ) (r : ℝ) (h : ℂ → ℂ) (k : ℕ) (q : Grid N) (n : ℂ) (y : ℂ) : ℂ := + densityRoot N r (fun x => coordinate n 1 (h x)) k q y • axis n 1+ + densityRoot N r (fun x => coordinate n (-1) (h x)) k q y • axis n (-1) + +def errorVector (N : ℕ) (r : ℝ) (h : ℂ → ℂ) (j : ℕ) (q : Grid N) (n : ℂ) (y : ℂ) : ℂ := + densityError N r (fun x => coordinate n 1 (h x)) j q y • axis n 1+ + densityError N r (fun x => coordinate n (-1) (h x)) j q y • axis n (-1) + +lemma vector_decomposition {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + (k : ℕ) (q : Grid N) {n : ℂ} (hn : ‖n‖ = 1) (y : ℂ) : + hat (scale r k) q y • h y = rootVector N r h k q n y+ + ∑ j ∈ Finset.range (k+1), ∑ s : Grid N, coeff N (k-j) q s • errorVector N r h j s n y := by + have hp := density_decomposition hr hR hN (scalar_support hsupp (coordinate n 1)) k q y + have hm := density_decomposition hr hR hN (scalar_support hsupp (coordinate n (-1))) k q y + have hx := congrArg (fun z : ℂ => hat (scale r k) q y • z) (expansion hn (h y)) + rw [smul_add,smul_smul,smul_smul,hp,hm,add_smul,add_smul] at hx + simp only [rootVector,errorVector,smul_add,smul_smul,Finset.sum_add_distrib] + rw [← hx] + simp only [Finset.sum_smul] + abel + +lemma rootVector_integrable {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) + (r : ℝ) (k : ℕ) (q : Grid N) (n : ℂ) : Integrable (rootVector N r h k q n) := + (root_vector_integrable hh r k q n 1).add (root_vector_integrable hh r k q n (-1)) + +lemma rootVector_cone {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) {n : ℂ} (hn : ‖n‖ = 1) + (hg : Good n (IntrinsicMarks.direction 1 (vectorMass h (scale r k) q))) + {s : ℝ} (hs : s = 1 ∨ s = -1) (y : ℂ) : + (1/2:ℝ)*‖rootVector N r h k q n y‖ ≤ inner ℝ (axis n s) (rootVector N r h k q n y) := + pair_cone hn (good_root_nonneg hr hR hN hh hsupp k q hg (Or.inl rfl) y) + (good_root_nonneg hr hR hN hh hsupp k q hg (Or.inr rfl) y) hs + +lemma rootVector_mass {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) {n : ℂ} (hn : ‖n‖ = 1) : + (∫ y, ‖rootVector N r h k q n y‖) ≤ 4*scalarMass h (scale r k) q := by + calc + _ ≤ (∫ y, ‖densityRoot N r (fun x => coordinate n 1 (h x)) k q y • axis n 1‖)+ + (∫ y, ‖densityRoot N r (fun x => coordinate n (-1) (h x)) k q y • axis n (-1)‖) := + by + rw [← integral_add (root_vector_integrable hh r k q n 1).norm + (root_vector_integrable hh r k q n (-1)).norm] + exact integral_mono (rootVector_integrable hh r k q n).norm + ((root_vector_integrable hh r k q n 1).norm.add + (root_vector_integrable hh r k q n (-1)).norm) (fun y => norm_add_le _ _) + _ ≤ 2*scalarMass h (scale r k) q+2*scalarMass h (scale r k) q := + add_le_add (root_bound hr hR hN hh hsupp k q hn (by norm_num)) + (root_bound hr hR hN hh hsupp k q hn (by norm_num)) + _ = _ := by ring + +end PricePieces + +namespace CommonPrices +open DyadicHats ConeCoordinates ConeScalar Finset + +def rho : ℝ := (1/2:ℝ)^(1/100:ℝ) +lemma rho_pos : 0 < rho := Real.rpow_pos_of_pos (by norm_num) _ +lemma rho_lt_one : rho < 1 := Real.rpow_lt_one (by norm_num) (by norm_num) (by norm_num) + +lemma scale_ratio {r : ℝ} (hr : 0 < r) {j k : ℕ} (hj : j ≤ k) : + scale r j / scale r k = (1/2:ℝ)^(k-j) := by + dsimp [scale] + rw [mul_div_mul_right _ _ hr.ne'] + have hk : k = j+(k-j) := (Nat.add_sub_of_le hj).symm + conv_lhs => rw [hk,pow_add] + simp only [div_pow,one_pow] + field_simp + +lemma scale_discount {r : ℝ} (hr : 0 < r) {j k : ℕ} (hj : j ≤ k) : + (scale r j / scale r k)^(1/100:ℝ) = rho^(k-j) := by + rw [scale_ratio hr hj] + unfold rho + rw [← Real.rpow_natCast,← Real.rpow_mul (by norm_num),mul_comm ((k-j:ℕ):ℝ), + Real.rpow_mul (by norm_num),Real.rpow_natCast] + +/-- A common root price sums the two exact coordinate defects for every +member of one fixed finite palette; it does not depend on the active label. -/ +def rootPrice (N : ℕ) (r : ℝ) (h : ℂ → ℂ) (k : ℕ) (q : Grid N) : ℝ := + ∑ n ∈ fixedPalette.labels, + (scalarPrice N r (fun x => coordinate n 1 (h x)) rho k q+ + scalarPrice N r (fun x => coordinate n (-1) (h x)) rho k q) + +lemma scalarPrice_nonneg {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + 0 ≤ scalarPrice N r h rho k q := by + apply sum_nonneg + intro j _ + apply mul_nonneg (pow_nonneg rho_pos.le _) + exact sum_nonneg (fun s _ => mul_nonneg (coeff_nonneg N (k-j) q s) + (densityDefect_nonneg hr hR hN hh hsupp j s)) + +lemma rootPrice_nonneg {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + 0 ≤ rootPrice N r h k q := by + apply sum_nonneg + intro n _ + exact add_nonneg + (scalarPrice_nonneg hr hR hN (scalar_integrable hh _) (scalar_support hsupp _) k q) + (scalarPrice_nonneg hr hR hN (scalar_integrable hh _) (scalar_support hsupp _) k q) + +lemma coordinate_total_le {h : ℂ → ℂ} (hh : Integrable h) {n : ℂ} (hn : ‖n‖ = 1) + {s : ℝ} (hs : |s| ≤ 1) : (∫ x, |coordinate n s (h x)|) ≤ 2*(∫ x, ‖h x‖) := by + rw [← integral_const_mul] + exact integral_mono (scalar_integrable hh _).abs (hh.norm.const_mul 2) + (fun x => coordinate_norm_le hn hs _) + +lemma coordinate_price_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) {n : ℂ} (hn : ‖n‖ = 1) + {s : ℝ} (hs : |s| ≤ 1) (m : ℕ) : + (∑ k ∈ range (m+1), ∑ q : Grid N, + scalarPrice N r (fun x => coordinate n s (h x)) rho k q) ≤ + (1-rho)⁻¹*(∫ x, ‖h x‖) := by + apply (scalarPrice_budget hr hR hN (scalar_integrable hh _) (scalar_support hsupp _) + rho_pos.le rho_lt_one m).trans + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (by linarith [rho_lt_one])) + have he := coordinate_total_le hh hn hs + linarith + +/-- The genuine all-label root price has a uniform total budget, including +the terminal scalar splits at the finest scale. -/ +theorem rootPrice_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) : + (∑ k ∈ range (m+1), ∑ q : Grid N, rootPrice N r h k q) ≤ + (2*(fixedPalette.labels.card:ℝ)*(1-rho)⁻¹)*(∫ x, ‖h x‖) := by + unfold rootPrice + simp_rw [Finset.sum_comm (s := univ) (t := fixedPalette.labels)] + rw [Finset.sum_comm] + calc + _ ≤ ∑ _n ∈ fixedPalette.labels, 2*((1-rho)⁻¹*(∫ x, ‖h x‖)) := by + apply sum_le_sum + intro n hn + simp_rw [sum_add_distrib] + have hp := coordinate_price_budget hr hR hN hh hsupp (fixedPalette.unit n hn) + (by norm_num : |(1:ℝ)| ≤ 1) m + have hm := coordinate_price_budget hr hR hN hh hsupp (fixedPalette.unit n hn) + (by norm_num : |(-1:ℝ)| ≤ 1) m + linarith + _ = _ := by rw [sum_const,nsmul_eq_mul]; ring + +end CommonPrices + +namespace FiniteLabels +open DyadicHats +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma spatialRow_mixture (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (r : ℝ) (x : ℂ) (j : ι) : + spatialRow old target p hp0 hp1 r x j = + interpolate r (fun z => (1-p z)*delta old j+p z*delta (target z) j) x := by + have he (z : ℤ × ℤ) : (1-p z)*delta old j+p z*delta (target z) j = + delta old j+p z*(delta (target z) j-delta old j) := by ring + simp_rw [he] + rw [interpolate_add,interpolate_const] + rfl + +lemma spatialRow_vanish (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (r : ℝ) (x : ℂ) (j : ι) + (hj : ∀ z, hat r z x ≠ 0 → (1-p z)*delta old j+p z*delta (target z) j = 0) : + spatialRow old target p hp0 hp1 r x j = 0 := by + rw [spatialRow_mixture] + have he : interpolate r (fun z => (1-p z)*delta old j+p z*delta (target z) j) x = + interpolate r (fun _ => 0) x := interpolate_congr_on r x hj + rw [he,interpolate_const] + +end FiniteLabels + +namespace ActualLabels +open FiniteLabels ConeCoordinates DirectionNeighbors DyadicHats + +abbrev Label := {n : ℂ // n ∈ fixedPalette.labels} +instance : Fintype Label := Finset.fintypeCoeSort fixedPalette.labels +instance : DecidableEq Label := Classical.decEq _ + +lemma label_unit (n : Label) : ‖(n:ℂ)‖ = 1 := fixedPalette.unit n n.property + +def target (h : ℂ → ℂ) (r : ℝ) (z : ℤ × ℤ) : Label := + quantize (Theta h r z) (norm_theta h r (chosen h r z)) +lemma target_close (h : ℂ → ℂ) (r : ℝ) (z : ℤ × ℤ) : + ‖Theta h r z-(target h r z:ℂ)‖ < 1/2000 := quantize_close _ _ + +def switchChance (h : ℂ → ℂ) (r : ℝ) (n : Label) (z : ℤ × ℤ) : ℝ := + probability (1/100) ‖(n:ℂ)-Theta h r z‖ +lemma switchChance_nonneg (h : ℂ → ℂ) (r : ℝ) (n : Label) (z : ℤ × ℤ) : + 0 ≤ switchChance h r n z := probability_nonneg _ _ +lemma switchChance_le_one (h : ℂ → ℂ) (r : ℝ) (n : Label) (z : ℤ × ℤ) : + switchChance h r n z ≤ 1 := probability_le_one _ _ + +def row (h : ℂ → ℂ) (r : ℝ) (x : ℂ) (n : Label) : Law Label := + spatialRow n (target h r) (switchChance h r n) (switchChance_nonneg h r n) + (switchChance_le_one h r n) r x + +def initial (h : ℂ → ℂ) (r : ℝ) (x : ℂ) : Law Label := + spatialRow (quantize 1 (by norm_num)) (target h r) (fun _ => 1) + (fun _ => zero_le_one) (fun _ => le_rfl) r x + +lemma nearby_sample_close {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) (z : ℤ × ℤ) (hz : hat r z x ≠ 0) : + ‖Theta h r z-theta h r q‖ ≤ 1/1000 := by + have hloc : boxNorm (point r z-point r q) ≤ 200*r := + hat_vertex_local hr (by linarith) hz + have he := energy_controls hr h q z hloc + nlinarith [norm_nonneg (Theta h r z-theta h r q)] + +lemma sampled_good {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) (z : ℤ × ℤ) (hz : hat r z x ≠ 0) : + Good (target h r z) (theta h r q) := by + apply good_of_close (label_unit _) + have he := nearby_sample_close hr h q hx hE z hz + have ht := target_close h r z + have hn : ‖theta h r q-(target h r z:ℂ)‖ ≤ ‖theta h r q-Theta h r z‖+‖Theta h r z-(target h r z:ℂ)‖ := by + simpa only [dist_eq_norm] using dist_triangle (theta h r q) (Theta h r z) (target h r z:ℂ) + have he' : ‖theta h r q-Theta h r z‖ ≤ 1/1000 := by simpa only [norm_sub_rev] using he + linarith + +lemma retained_good {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) (z : ℤ × ℤ) (hz : hat r z x ≠ 0) + (n : Label) (hp : switchChance h r n z < 1) : Good (n:ℂ) (theta h r q) := by + have hd := (probability_lt_one_iff (by norm_num : (0:ℝ)<1/100)).mp hp + have he := nearby_sample_close hr h q hx hE z hz + apply good_of_close (label_unit n) + have hn : ‖theta h r q-(n:ℂ)‖ ≤ ‖theta h r q-Theta h r z‖+‖Theta h r z-(n:ℂ)‖ := by + simpa only [dist_eq_norm] using dist_triangle (theta h r q) (Theta h r z) (n:ℂ) + have he' : ‖theta h r q-Theta h r z‖ ≤ 1/1000 := by simpa only [norm_sub_rev] using he + have hd' : ‖Theta h r z-(n:ℂ)‖ < 2*(1/100:ℝ) := by simpa only [norm_sub_rev] using hd + linarith + +lemma initial_bad_zero {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) (n : Label) + (hn : ¬Good (n:ℂ) (theta h r q)) : initial h r x n = 0 := by + apply spatialRow_vanish + intro z hz + have ht : n ≠ target h r z := fun ht => hn (ht ▸ sampled_good hr h q hx hE z hz) + simp [delta,ht] + +lemma row_bad_zero {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) (old n : Label) + (hn : ¬Good (n:ℂ) (theta h r q)) : row h r x old n = 0 := by + apply spatialRow_vanish + intro z hz + have ht : n ≠ target h r z := fun ht => hn (ht ▸ sampled_good hr h q hx hE z hz) + by_cases ho : n = old + · subst n + have hp : switchChance h r old z = 1 := le_antisymm (switchChance_le_one h r old z) + (le_of_not_gt (fun hp => hn (retained_good hr h q hx hE z hz old hp))) + simp [hp,delta,ht] + · simp [delta,ho,ht] + +/-- The actual finite-state label marginal, with its scale-dependent spatial +rows. This definition introduces no geometric or probabilistic hypothesis. -/ +def marginal (h : ℂ → ℂ) (r : ℕ → ℝ) : ℕ → ℂ → Law Label + | 0,x => initial h (r 0) x + | k+1,x => move (marginal h r k x) (row h (r (k+1)) x) + +theorem marginal_bad_zero (h : ℂ → ℂ) (r : ℕ → ℝ) (k : ℕ) (hr : 0 < r k) + (q : ℤ × ℤ) {x : ℂ} (hx : boxNorm (x-point (r k) q) ≤ 50*r k) + (hE : energy h (r k) q ≤ (1/1000:ℝ)^2) (n : Label) + (hn : ¬Good (n:ℂ) (theta h (r k) q)) : marginal h r k x n = 0 := by + cases k with + | zero => exact initial_bad_zero hr h q hx hE n hn + | succ k => + simp only [marginal,move_apply,row_bad_zero hr h q hx hE _ n hn,mul_zero,Finset.sum_const_zero] + +end ActualLabels + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/CommonPrices1.lean b/lean/OAI/Analysis/SignedDisk/CommonPrices1.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd89a613b571c33ef5afef13d9bc866b8cd2372a --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/CommonPrices1.lean @@ -0,0 +1,434 @@ +import OAI.Analysis.SignedDisk.ActualMarkTrees1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace CommonPrices +open DyadicHats ConeCoordinates Finset DirectionNeighbors + +def cellRoots (N : ℕ) (p : ℤ × ℤ) : Finset (Grid N) := + univ.filter (fun q => (q : ℤ × ℤ) ∈ window 20 p) + +lemma cellPrice_spatial {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (P : Finset (ℤ × ℤ)) : + (∑ p ∈ P, cellPrice N r h k (cellRoots N p)) ≤ 1681*∑ q : Grid N, rootPrice N r h k q := by + simp only [cellPrice,cellRoots,sum_filter] + rw [Finset.sum_comm] + rw [mul_sum] + apply sum_le_sum + intro q _ + have hn := rootPrice_nonneg hr hR hN hh hsupp k q + have hs : P.filter (fun p => (q:ℤ×ℤ) ∈ window 20 p) ⊆ window 20 q := by + intro p hp + exact (mem_window_comm 20 _ _).mp (mem_filter.mp hp).2 + have hc : ((P.filter (fun p => (q:ℤ×ℤ) ∈ window 20 p)).card : ℝ) ≤ 1681 := by + have hc := Finset.card_le_card hs + rw [card_window] at hc + exact_mod_cast hc + rw [← sum_filter,sum_const,nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right hc hn + +/-- The common geometric price has a genuine uniform spatial-and-scale +budget, including every desired finite set of observation cells. -/ +theorem cellPrice_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) : + (∑ k ∈ range (m+1), ∑ p ∈ P k, cellPrice N r h k (cellRoots N p)) ≤ + 1681*((fixedPalette.labels.card:ℝ)*2/(1-rho))*(∫ y, ‖h y‖) := by + calc + _ ≤ ∑ k ∈ range (m+1), 1681*∑ q : Grid N, rootPrice N r h k q := + sum_le_sum (fun k _ => cellPrice_spatial hr hR hN hh hsupp k (P k)) + _ = 1681*(∑ k ∈ range (m+1), ∑ q : Grid N, rootPrice N r h k q) := by rw [mul_sum] + _ ≤ _ := by + have ht := mul_le_mul_of_nonneg_left (rootPrice_budget hr hR hN hh hsupp m) (by norm_num : (0:ℝ) ≤ 1681) + have he : 1681*(2*(fixedPalette.labels.card:ℝ)*(1-rho)⁻¹*(∫ y, ‖h y‖)) = + 1681*((fixedPalette.labels.card:ℝ)*2/(1-rho))*(∫ y, ‖h y‖) := by ring + exact ht.trans_eq he + +end CommonPrices + +namespace ActualMarkTrees +open DyadicHats IntrinsicMarks Finset DirectionNeighbors + +lemma nodeCharge_scale {N : ℕ} (v : Grid N → ℂ) (k : ℕ) {b : ℝ} (hb : 0 ≤ b) + (q : Grid N) (C : List (Grid N) → ℝ) : + nodeCharge (tree v k b q) C = b*nodeCharge (tree v k 1 q) C := by + induction k generalizing b q C with + | zero => simp [tree,nodeCharge,Real.norm_eq_abs,abs_of_nonneg hb,mul_assoc] + | succ k ih => + change ‖vector (tree v (k+1) b q)‖*C []+ + (∑ a : Grid N, nodeCharge (tree v k (b*step q a) a) (fun p => C (a::p))) = + b*(‖vector (tree v (k+1) 1 q)‖*C []+ + (∑ a : Grid N, nodeCharge (tree v k (1*step q a) a) (fun p => C (a::p)))) + simp only [vector_tree,norm_smul,Real.norm_eq_abs,abs_of_nonneg hb, + abs_one,one_mul] + simp_rw [ih (mul_nonneg hb (step_nonneg _ _)),ih (step_nonneg _ _)] + rw [mul_add,mul_sum] + congr 1 + · ring + · apply sum_congr rfl + intro a ha + ring + +def spatialCharge {N : ℕ} (C : ℕ → Grid N → ℝ) (k : ℕ) (q : Grid N) + (p : List (Grid N)) : ℝ := C (k-p.length) (lastVertex q p) + +lemma spatialCharge_cons {N : ℕ} (C : ℕ → Grid N → ℝ) (k : ℕ) (q a : Grid N) + (p : List (Grid N)) : spatialCharge C (k+1) q (a::p) = spatialCharge C k a p := by + simp [spatialCharge,List.length_cons,lastVertex] + +lemma sum_nodeCharge {N : ℕ} (v : Grid N → ℂ) (k : ℕ) (C : ℕ → Grid N → ℝ) : + (∑ q, nodeCharge (tree v k 1 q) (spatialCharge C k q)) = + ∑ j ∈ range (k+1), ∑ a : Grid N, + ‖∑ z : Grid N, coeff N j a z • v z‖*C j a := by + induction k with + | zero => + have hv (a : Grid N) : (∑ z : Grid N, coeff N 0 a z • v z) = v a := by + simpa only [tree,vector,one_smul] using (vector_tree v 0 1 a).symm + simp only [tree,nodeCharge,one_smul,spatialCharge,List.length_nil,Nat.sub_zero, + lastVertex,Nat.zero_add,sum_range_one,hv] + | succ k ih => + have hrec (q : Grid N) : nodeCharge (tree v (k+1) 1 q) (spatialCharge C (k+1) q) = + ‖∑ z : Grid N, coeff N (k+1) q z • v z‖*C (k+1) q+ + ∑ a : Grid N, step q a*nodeCharge (tree v k 1 a) (spatialCharge C k a) := by + change ‖vector (tree v (k+1) 1 q)‖*spatialCharge C (k+1) q []+_ = _ + simp only [vector_tree,one_smul,spatialCharge,List.length_nil,Nat.sub_zero,lastVertex, + one_mul,List.length_cons,Nat.add_sub_add_right] + congr 1 + apply sum_congr rfl + intro a ha + exact nodeCharge_scale v k (step_nonneg q a) a _ + simp_rw [hrec] + rw [sum_add_distrib,Finset.sum_comm (f := fun (q a : Grid N) => step q a* + nodeCharge (tree v k 1 a) (spatialCharge C k a))] + simp_rw [← sum_mul,grid_step_column,one_mul] + rw [ih] + conv_rhs => rw [sum_range_succ] + exact add_comm _ _ + +lemma sum_energyCharge {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) : + (∑ q : Grid N, nodeCharge (tree (fun q => vectorMass h r q) k 1 q) + (pathEnergy h r k q)) = + ∑ j ∈ range (k+1), ∑ q : Grid N, scalarMass h (scale r j) q*energy h (scale r j) q := by + change (∑ q : Grid N, nodeCharge (tree (fun q => vectorMass h r q) k 1 q) + (spatialCharge (fun j q => energy h (scale r j) q) k q)) = _ + rw [sum_nodeCharge] + apply sum_congr rfl + intro j hj + apply sum_congr rfl + intro q hq + rw [← vectorMass_coeff hr hR hN hh hsupp] + rfl + +/-- Particle observations use the prescribed terminal vertex, not a hat-density +surrogate. This is the frozen spatial location carried throughout the process. -/ +def particleSwitches {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (q : Grid N) + (p : List (Grid N)) (b : ℕ) : ℝ := + pathSwitches h r k (point r (lastVertex q p)) p b + +theorem particle_switch_bound {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + particleEval (tree (fun q => vectorMass h r q) k 1 q) (particleSwitches h r k q) ≤ + 2560004*terminalMass (tree (fun q => vectorMass h r q) k 1 q)+ + 2000000*nodeCharge (tree (fun q => vectorMass h r q) k 1 q) (pathEnergy h r k q) := by + have hp := particleEval_mono_active (tree (fun q => vectorMass h r q) k 1 q) + (F := particleSwitches h r k q) + (fun p b hp hb => path_switch_bound hr hR hN hh hsupp k q hp hb (x := point r (lastVertex q p)) (by + rw [hat_at_point hr.ne'] + norm_num)) + simp only [particleEval_add,particleEval_smul,particleEval_const,particle_occupancy, + root_marked_occupancy] at hp + have hm := costWithRoot_le (by simp : ‖(1:ℂ)‖ = 1) + (by norm_num : (0:ℝ) < 1/800) (tree (fun q => vectorMass h r q) k 1 q) + norm_num at hm + change particleEval _ (particleSwitches h r k q) ≤ _ at hp + linarith + +/-- The switch budget for the actual finite spatial forest, with every birth +population included and frozen terminal positions observed. -/ +theorem forest_switch_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) : + (∑ q : Grid N, particleEval (tree (fun q => vectorMass h r q) k 1 q) + (particleSwitches h r k q)) ≤ + (2560004+2000000*(576*(4097:ℝ)^2))*(∫ y, ‖h y‖) := by + have hs := sum_le_sum (fun q (_ : q ∈ (univ : Finset (Grid N))) => + particle_switch_bound hr hR hN hh hsupp k q) + simp only [sum_add_distrib,← mul_sum] at hs + rw [sum_terminalMass,sum_energyCharge hr hR hN hh hsupp] at hs + have ht := sum_scalarMass_grid_le (N := N) hh r + have he := neighbor_energy_budget hr hR hN hh hsupp (k+1) + change (∑ q : Grid N, ‖vectorMass h r q‖) ≤ ∫ y, ‖h y‖ at ht + nlinarith only [hs,ht,he] + +end ActualMarkTrees + +namespace FiniteLabels +variable {ι : Type*} [Fintype ι] +lemma expect_const (μ : Law ι) (c : ℝ) : expect μ (fun _ => c) = c := by + rw [expect,← Finset.sum_mul,μ.total,one_mul] +lemma expect_mul (μ : Law ι) (f : ι → ℝ) (c : ℝ) : + expect μ (fun i => c*f i) = c*expect μ f := by + simp only [expect,Finset.mul_sum,mul_left_comm] +lemma expect_mono (μ : Law ι) {f g : ι → ℝ} (h : ∀ i, f i ≤ g i) : + expect μ f ≤ expect μ g := Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (h i) (μ.nonneg i)) +lemma expect_le_const (μ : Law ι) {f : ι → ℝ} {c : ℝ} (h : ∀ i, f i ≤ c) : + expect μ f ≤ c := (expect_mono μ h).trans_eq (expect_const μ c) +lemma expect_compare (μ ν : Law ι) {f : ι → ℝ} {c : ℝ} (h : ∀ i, |f i| ≤ c) : + expect μ f ≤ expect ν f+c*l1dist μ ν := by + have he := expectation_difference μ ν h + change |expect μ f-expect ν f| ≤ c*l1dist μ ν at he + have hl := le_abs_self (expect μ f-expect ν f) + linarith +end FiniteLabels + +namespace ActualLabels +open FiniteLabels ConeCoordinates DirectionNeighbors DyadicHats Finset + +def comparisonConstant : ℝ := 1280000*((Fintype.card Label:ℝ)+1) +lemma comparisonConstant_ge : 1280000 ≤ comparisonConstant := by + dsimp [comparisonConstant] + nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card Label)] +lemma comparisonConstant_pos : 0 < comparisonConstant := lt_of_lt_of_le (by norm_num) comparisonConstant_ge +lemma comparisonConstant_one : 1 ≤ comparisonConstant := by linarith [comparisonConstant_ge] + +def rowDerivative (h : ℂ → ℂ) (r : ℝ) (x : ℂ) (n : Label) : ℝ := + r*∑ j : Label, ‖gradient (fun y => row h r y n j) x‖ +def derivativeCost (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) : ℕ → ℝ + | 0 => r 0*∑ j : Label, ‖gradient (fun y => initial h (r 0) y j) x‖ + | i+1 => expect (marginal h r i x) (rowDerivative h (r (i+1)) x) + +lemma rowDerivative_nonneg (h : ℂ → ℂ) {r : ℝ} (hr : 0 ≤ r) (x : ℂ) (n : Label) : + 0 ≤ rowDerivative h r x n := mul_nonneg hr (sum_nonneg (fun _ _ => norm_nonneg _)) +lemma rowDerivative_uniform (h : ℂ → ℂ) {r : ℝ} (hr : 0 < r) (x : ℂ) (n : Label) : + rowDerivative h r x n ≤ 16*(Fintype.card Label:ℝ) := by + have hh := spatialRow_local_derivative n (target h r) (switchChance h r n) + (switchChance_nonneg h r n) (switchChance_le_one h r n) hr (by norm_num : (0:ℝ) ≤ 1) + (q := x) (x := x) (by simp only [sub_self,boxNorm]; norm_num; positivity) + (fun z _ => switchChance_le_one h r n z) + change rowDerivative h r x n ≤ 16*(Fintype.card Label:ℝ)*1 at hh + simpa only [mul_one] using hh +lemma initial_distance (h : ℂ → ℂ) {r : ℝ} (hr : 0 < r) (x y : ℂ) : + l1dist (initial h r x) (initial h r y) ≤ comparisonConstant/r*‖x-y‖ := by + have he := spatialRow_distance (quantize 1 (by norm_num)) (target h r) (fun _ => 1) + (fun _ => zero_le_one) (fun _ => le_rfl) hr (by norm_num : (0:ℝ) ≤ 1) + (fun _ => le_rfl) x y + apply he.trans + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + rw [← mul_div_assoc] + apply div_le_div_of_nonneg_right _ hr.le + dsimp [comparisonConstant] + nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card Label)] +lemma derivativeCost_uniform (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (i : ℕ) (hr : 0 < r i) : + derivativeCost h r x i ≤ 16*(Fintype.card Label:ℝ) := by + cases i with + | zero => + have hh := spatialRow_local_derivative (quantize 1 (by norm_num)) (target h (r 0)) (fun _ => 1) + (fun _ => zero_le_one) (fun _ => le_rfl) hr (by norm_num : (0:ℝ) ≤ 1) + (q := x) (x := x) (by simp only [sub_self,boxNorm]; norm_num; positivity) (fun _ _ => le_rfl) + change derivativeCost h r x 0 ≤ 16*(Fintype.card Label:ℝ)*1 at hh + simpa only [mul_one] using hh + | succ i => exact expect_le_const _ (rowDerivative_uniform h hr x) + +lemma rate_local (h : ℂ → ℂ) {r : ℝ} (hr : 0 < r) (q : ℤ × ℤ) (x y : ℂ) + (hx : boxNorm (x-point r q) < 199*r) (hy : boxNorm (y-point r q) < 199*r) (n : Label) : + rate h r x n ≤ comparisonConstant*(rate h r y n+energy h r q) := by + have he := switchRate_local_compare (by norm_num : (0:ℝ) < 1/100) hr (Theta h r) + (n:ℂ) (theta h r q) (point r q) x y hx hy (energy_controls hr h q) + change rate h r x n ≤ 2*rate h r y n+8*((1/100:ℝ)⁻¹)^2*energy h r q at he + norm_num at he + have h0 := rate_nonneg h r y n + have h1 := energy_nonneg h r q + have hC := comparisonConstant_ge + nlinarith + +lemma row_local_distance (h : ℂ → ℂ) {r : ℝ} (hr : 0 < r) (q : ℤ × ℤ) (x y : ℂ) + (hx : boxNorm (x-point r q) < 199*r) (hy : boxNorm (y-point r q) < 199*r) (n : Label) : + l1dist (row h r x n) (row h r y n) ≤ + comparisonConstant*‖x-y‖/r*(rate h r y n+energy h r q) := by + have he := spatialSwitchRow_local_distance (by norm_num : (0:ℝ) < 1/100) hr (energy_nonneg h r q) + (fun n : Label => (n:ℂ)) (Theta h r) (target h r) n (theta h r q) (point r q) x y hx hy + (energy_controls hr h q) + change l1dist (row h r x n) (row h r y n) ≤ + (Fintype.card Label:ℝ)*(16*(2*rate h r y n+8*((1/100:ℝ)⁻¹)^2*energy h r q)/r)*‖x-y‖ at he + apply he.trans + have h0 := rate_nonneg h r y n + have h1 := energy_nonneg h r q + have hb : (Fintype.card Label:ℝ)*(16*(2*rate h r y n+8*((1/100:ℝ)⁻¹)^2*energy h r q)) ≤ + comparisonConstant*(rate h r y n+energy h r q) := by + dsimp [comparisonConstant] + norm_num + nlinarith [mul_nonneg (Nat.cast_nonneg (α := ℝ) (Fintype.card Label)) h0, + mul_nonneg (Nat.cast_nonneg (α := ℝ) (Fintype.card Label)) h1] + have hb' := mul_le_mul_of_nonneg_right (div_le_div_of_nonneg_right hb hr.le) (norm_nonneg (x-y)) + convert hb' using 1 <;> ring + +lemma row_local_derivative (h : ℂ → ℂ) {r : ℝ} (hr : 0 < r) (q : ℤ × ℤ) (x y : ℂ) + (hx : boxNorm (x-point r q) < 199*r) (hy : boxNorm (y-point r q) < 199*r) (n : Label) : + rowDerivative h r x n ≤ comparisonConstant*(rate h r y n+energy h r q) := by + have he := spatialSwitchRow_local_derivative (by norm_num : (0:ℝ) < 1/100) hr (energy_nonneg h r q) + (fun n : Label => (n:ℂ)) (Theta h r) (target h r) n (theta h r q) (point r q) x y hx hy + (energy_controls hr h q) + change rowDerivative h r x n ≤ + 16*(Fintype.card Label:ℝ)*(2*rate h r y n+8*((1/100:ℝ)⁻¹)^2*energy h r q) at he + apply he.trans + have h0 := rate_nonneg h r y n + have h1 := energy_nonneg h r q + dsimp [comparisonConstant] + norm_num + nlinarith [mul_nonneg (Nat.cast_nonneg (α := ℝ) (Fintype.card Label)) h0, + mul_nonneg (Nat.cast_nonneg (α := ℝ) (Fintype.card Label)) h1] + +end ActualLabels + +namespace AffineDensities +lemma gradient_affine {g : ℂ → ℝ} (hg : Differentiable ℝ g) (p : ℂ) (r : ℝ) (X : ℂ) : + gradient (fun Y => g (p+r • Y)) X = rescale p r (gradient g) X := by + have hA : HasFDerivAt (fun Y : ℂ => p+r • Y) (r • ContinuousLinearMap.id ℝ ℂ) X := + ((hasFDerivAt_id X).const_smul r).const_add p + have hc := (hg (p+r • X)).hasFDerivAt.comp X hA + change HasFDerivAt (fun Y => g (p+r • Y)) _ X at hc + apply (InnerProductSpace.toDual ℝ ℂ).injective + simp only [toDual_gradient,rescale,map_smul] + rw [hc.fderiv] + ext z + simp +end AffineDensities + +namespace DyadicHats +open Finset +lemma vector_partition_grid {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (x : ℂ) : + (∑ p : Grid N, hat r p x) • h x = h x := by + by_cases hx : h x = 0 + · simp only [hx,smul_zero] + · have he := density_partition_grid hr hN (h := fun y => ‖h y‖) + (fun y hy => hs y (fun hh => hy (by rw [hh,norm_zero]))) x + rw [← sum_mul] at he + have hsum : (∑ p : Grid N, hat r p x) = 1 := by + apply mul_right_cancel₀ (norm_ne_zero_iff.mpr hx) + simpa only [one_mul] using he + rw [hsum,one_smul] +end DyadicHats + +namespace CommonPrices +open DyadicHats ConeCoordinates ConeScalar LocalCancellation AffineDensities DirectionNeighbors Finset DiskMoments + +lemma hat_mem_cellRoots {N : ℕ} {r : ℝ} (hr : 0 < r) (p : ℤ × ℤ) (X : ℂ) (hX : ‖X‖ ≤ 12) + (q : Grid N) (hq : hat r q (point r p+r • X) ≠ 0) : q ∈ cellRoots N p := by + have hl := (hat_ne_zero_iff hr q (point r p+r • X)).mp hq + have hnorm : boxNorm (r • X) ≤ 12*r := by + apply (boxNorm_le_norm _).trans + rw [norm_smul,Real.norm_eq_abs,abs_of_pos hr] + nlinarith + have hh := boxNorm_add_le (point r q-(point r p+r • X)) (r • X) + rw [boxNorm_sub_comm (point r q)] at hh + have hie : point r q-(point r p+r • X)+r • X = point r q-point r p := by abel + rw [hie] at hh + apply mem_filter.mpr + refine ⟨mem_univ _,?_⟩ + rw [mem_window_iff hr 20] + norm_num + linarith + +lemma cell_partition {N : ℕ} {r R : ℝ} (hr : 0 < r) (hN : R/r+1 ≤ (N:ℝ)) + {h : ℂ → ℂ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (p : ℤ × ℤ) (X : ℂ) (hX : ‖X‖ ≤ 12) : + (∑ q ∈ cellRoots N p, hat r q (point r p+r • X)) • h (point r p+r • X) = h (point r p+r • X) := by + have he : (∑ q ∈ cellRoots N p, hat r q (point r p+r • X)) = + ∑ q : Grid N, hat r q (point r p+r • X) := by + apply sum_subset (subset_univ _) + intro q _ hq + by_contra hh + exact hq (hat_mem_cellRoots hr p X hX q hh) + rw [he] + exact vector_partition_grid hr hN hs _ + +lemma cell_decomposition_gradient {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {g : ℂ → ℝ} (hg : Differentiable ℝ g) + (hh : Integrable (gradient g)) (hsupp : ∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) + (k : ℕ) (p : ℤ × ℤ) {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s = 1 ∨ s = -1) + (X : ℂ) (hX : ‖X‖ ≤ 12) : + (goodCone hr hR hN hh hsupp k (point (scale r k) p) (cellRoots N p) hn hs).density X+ + (∑ i, (cellErrors hr hh k (point (scale r k) p) (cellRoots N p) n i).density X) = + gradient (fun Y => g (point (scale r k) p+scale r k • Y)) X := by + rw [cell_decomposition hr hR hN hh hsupp k _ _ hn hs,gradient_affine hg] + simp only [rescale] + rw [cell_partition (scale_pos hr k) (scale_index_bound hr hR hN k) hsupp p X hX] + +/-- The hard directional local price, instantiated with the actual common-price +cone decomposition on the actual neighboring grid roots. -/ +theorem directional_cell_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → ∀ (k : ℕ) (p : ℤ × ℤ) + {n : ℂ}, n ∈ fixedPalette.labels → ∀ {s : ℝ}, (s = 1 ∨ s = -1) → + ∀ Q : Set ℂ, volume Q ≤ ENNReal.ofReal 1 → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ X in Q, F X) ≤ ENNReal.ofReal (C*(scale r k)⁻¹* + (badPrice (gradient g) r k (cellRoots N p) n+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ X, ‖X‖ ≤ 2 → ∀ t, + NeighborhoodRadius (fun Y => g (point (scale r k) p+scale r k • Y)) X t → + ENNReal.ofReal (max 0 (-inner ℝ (axis n s) + (∫ Y in Metric.ball X t, gradient (fun Z => g (point (scale r k) p+scale r k • Z)) Y))) ≤ F X := by + obtain ⟨C,hC,hmajor⟩ := direction_majorant (by norm_num : (0:ℝ) ≤ 2) (by norm_num : (0:ℝ) < 1/2) + refine ⟨4*C,by positivity,?_⟩ + intro N r R hr hR hN g hg hh hsupp k p n hn s hs Q hQ + have hnu := fixedPalette.unit n hn + let a := goodCone hr hR hN hh hsupp k (point (scale r k) p) (cellRoots N p) hnu hs + let b := cellErrors hr hh k (point (scale r k) p) (cellRoots N p) n + have hg' : ContDiff ℝ 1 (fun Y => g (point (scale r k) p+scale r k • Y)) := hg.comp (by fun_prop) + obtain ⟨F,hFm,hFi,hFb⟩ := hmajor a b (axis_norm hnu (by rcases hs with rfl | rfl <;> norm_num)) _ hg' Q hQ + refine ⟨F,hFm,?_,?_⟩ + · apply hFi.trans + apply ENNReal.ofReal_le_ofReal + have hb := cellErrors_price hr hR hN hh hsupp k (point (scale r k) p) (cellRoots N p) hn + have hD : 0 ≤ cellPrice N r (gradient g) k (cellRoots N p) := + sum_nonneg (fun q _ => rootPrice_nonneg hr hR hN hh hsupp k q) + change errorPrice b (1/100) ≤ _ at hb + have hrk := scale_pos hr k + nlinarith [mul_le_mul_of_nonneg_left hb hC.le,inv_nonneg.mpr hrk.le, + mul_nonneg (inv_nonneg.mpr hrk.le) hD] + · intro X hX t ht + apply hFb X _ t ht + filter_upwards with Y hY + apply cell_decomposition_gradient hr hR hN (hg.differentiable one_ne_zero) hh hsupp k p hnu hs + have hy : ‖Y-X‖ < 3 := by simpa only [Metric.mem_ball,dist_eq_norm] using hY + have htri := norm_add_le (Y-X) X + rw [sub_add_cancel] at htri + linarith + +end CommonPrices + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/CommonPrices2.lean b/lean/OAI/Analysis/SignedDisk/CommonPrices2.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e39136c387a0350ddf75f2543fb6936d541e222 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/CommonPrices2.lean @@ -0,0 +1,424 @@ +import OAI.Analysis.SignedDisk.SignedRuns2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace CommonPrices +open DyadicHats DirectionNeighbors Finset ConeCoordinates + +lemma cellRoots_budget {N : ℕ} (B : Grid N → ℝ) (hB : ∀ q, 0 ≤ B q) + (P : Finset (ℤ × ℤ)) : + (∑ p ∈ P, ∑ q ∈ cellRoots N p, B q) ≤ 1681*∑ q, B q := by + simp only [cellRoots,sum_filter] + rw [Finset.sum_comm,Finset.mul_sum] + apply sum_le_sum + intro q _ + have hs : P.filter (fun p => (q:ℤ×ℤ) ∈ window 20 p) ⊆ window 20 q := by + intro p hp + exact (mem_window_comm 20 _ _).mp (mem_filter.mp hp).2 + have hc : ((P.filter (fun p => (q:ℤ×ℤ) ∈ window 20 p)).card : ℝ) ≤ 1681 := by + have hc := Finset.card_le_card hs + rw [card_window] at hc + exact_mod_cast hc + rw [← sum_filter,sum_const,nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right hc (hB q) + +lemma badPrice_nonneg {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) : + 0 ≤ badPrice h r k S n := sum_nonneg (fun _ _ => norm_nonneg _) + +lemma badPrice_le_rootMass {N : ℕ} (h : ℂ → ℂ) (r : ℝ) (k : ℕ) (S : Finset (Grid N)) (n : ℂ) : + badPrice h r k S n ≤ rootMass h r k S := by + classical + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (fun _ _ _ => norm_nonneg _) +end CommonPrices + +namespace ActualLabels +open DyadicHats DirectionNeighbors FiniteLabels CommonPrices ConeCoordinates Finset + +lemma marginal_localSup_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (k : ℕ) (hr : 0 < r k) + (p : ℤ × ℤ) (n : Label) : 0 ≤ localSup (fun x => marginal h r k x n) (r k) p := + localSup_nonneg hr.le p (fun x => (marginal h r k x).nonneg n) (fun _ _ => law_le_one _ _) + +lemma marginal_localSup_le_one (h : ℂ → ℂ) (r : ℕ → ℝ) (k : ℕ) (hr : 0 < r k) + (p : ℤ × ℤ) (n : Label) : localSup (fun x => marginal h r k x n) (r k) p ≤ 1 := + localSup_le hr.le p (fun _ _ => law_le_one _ _) + +lemma marginal_localSup_bad_zero {N : ℕ} (h : ℂ → ℂ) (r : ℕ → ℝ) (k : ℕ) (hr : 0 < r k) + (p : ℤ × ℤ) (q : Grid N) (hq : q ∈ cellRoots N p) + (hE : energy h (r k) q ≤ (1/1000:ℝ)^2) (n : Label) + (hn : ¬Good (n:ℂ) (theta h (r k) q)) : localSup (fun x => marginal h r k x n) (r k) p = 0 := by + apply le_antisymm _ (marginal_localSup_nonneg h r k hr p n) + apply localSup_le hr.le p + intro y hy + have hqp : boxNorm (point (r k) p-point (r k) q) ≤ 20*r k := by + rw [boxNorm_sub_comm] + exact (mem_window_iff hr 20 p q).mp (mem_filter.mp hq).2 + have hb := boxNorm_add_le (y-point (r k) p) (point (r k) p-point (r k) q) + rw [sub_add_sub_cancel] at hb + have hy' : boxNorm (y-point (r k) p) ≤ 25*r k := hy + rw [marginal_bad_zero h r k hr q (by linarith) hE n hn] + +/-- The actual bad-root charge is paid by geometric energy, not a separately +assumed probability budget. -/ +lemma marginal_badPrice_bound {N : ℕ} (h : ℂ → ℂ) (r : ℕ → ℝ) (base : ℝ) + (k j : ℕ) (hr : 0 < r k) (hrj : r k = scale base j) (p : ℤ × ℤ) (n : Label) : + localSup (fun x => marginal h r k x n) (r k) p*badPrice h base j (cellRoots N p) n ≤ + 1000000*∑ q ∈ cellRoots N p, scalarMass h (r k) q*energy h (r k) q := by + classical + have hp0 := marginal_localSup_nonneg h r k hr p n + have hp1 := marginal_localSup_le_one h r k hr p n + unfold badPrice + rw [mul_sum] + calc + _ ≤ ∑ q ∈ badRoots h base j (cellRoots N p) n, + 1000000*(scalarMass h (r k) q*energy h (r k) q) := by + apply sum_le_sum + intro q hq + have hqp := (mem_filter.mp hq).1 + have hbad : ¬Good (n:ℂ) (theta h (r k) q) := by + simpa only [hrj] using (mem_filter.mp hq).2 + rw [← hrj] + by_cases hE : energy h (r k) q ≤ (1/1000:ℝ)^2 + · rw [marginal_localSup_bad_zero h r k hr p q hqp hE n hbad,zero_mul] + exact mul_nonneg (by norm_num) (mul_nonneg (norm_nonneg _) (energy_nonneg _ _ _)) + · have he : 1 ≤ 1000000*energy h (r k) q := by norm_num at hE; linarith + have hb := mul_le_mul_of_nonneg_right hp1 (norm_nonneg (vectorMass h (r k) q)) + have hc := mul_le_mul_of_nonneg_right he (norm_nonneg (vectorMass h (r k) q)) + dsimp only [scalarMass] at ⊢ + nlinarith + _ ≤ _ := by + rw [mul_sum] + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (fun q _ _ => + mul_nonneg (by norm_num) (mul_nonneg (norm_nonneg _) (energy_nonneg _ _ _))) +end ActualLabels + +namespace PhysicalCells +open DyadicHats Finset + +/-- Measurable full-lattice patch; no choice of maximizing radius occurs. -/ +def patch (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (x : ℂ) : ℝ≥0∞ := + ∑' p, (cell (point r p) r).indicator (F p) x + +lemma patch_measurable (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (hF : ∀ p, Measurable (F p)) : + Measurable (patch r F) := + Measurable.tsum (fun p => (hF p).indicator (cell_measurable _ _)) + +lemma le_patch (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (p : ℤ × ℤ) {x : ℂ} + (hx : x ∈ cell (point r p) r) : F p x ≤ patch r F x := by + have he := ENNReal.le_tsum (f := fun q => (cell (point r q) r).indicator (F q) x) p + simpa only [patch,Set.indicator_of_mem hx] using he + +lemma lintegral_patch (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (hF : ∀ p, Measurable (F p)) : + (∫⁻ x, patch r F x) = ∑' p, ∫⁻ x in cell (point r p) r, F p x := by + simp only [patch] + rw [lintegral_tsum (f := fun p x => (cell (point r p) r).indicator (F p) x) (fun p => ((hF p).indicator (cell_measurable _ _)).aemeasurable)] + simp_rw [lintegral_indicator (cell_measurable _ _)] + +lemma lintegral_patch_budget (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (hF : ∀ p, Measurable (F p)) + (B : (ℤ × ℤ) → ℝ) (hB : ∀ p, 0 ≤ B p) (A : ℝ) + (hcell : ∀ p, (∫⁻ x in cell (point r p) r, F p x) ≤ ENNReal.ofReal (B p)) + (hbudget : ∀ P : Finset (ℤ × ℤ), ∑ p ∈ P, B p ≤ A) : + (∫⁻ x, patch r F x) ≤ ENNReal.ofReal A := by + rw [lintegral_patch r F hF] + exact (ENNReal.tsum_le_tsum hcell).trans (tsum_ofReal_le B hB A hbudget) + +lemma patch_finite (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (hF : ∀ p, Measurable (F p)) + {A : ℝ} (hi : (∫⁻ x, patch r F x) ≤ ENNReal.ofReal A) : + ∀ᵐ x, patch r F x ≠ ⊤ := by + exact (ae_lt_top (patch_measurable r F hF) (ne_top_of_le_ne_top ENNReal.ofReal_ne_top hi)).mono + (fun _ hx => hx.ne) + +lemma patch_integrable (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (hF : ∀ p, Measurable (F p)) + {A : ℝ} (hi : (∫⁻ x, patch r F x) ≤ ENNReal.ofReal A) : + Integrable (fun x => (patch r F x).toReal) := + integrable_toReal_of_lintegral_ne_top (patch_measurable r F hF).aemeasurable + (ne_top_of_le_ne_top ENNReal.ofReal_ne_top hi) + +lemma real_le_patch {r : ℝ} (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (p : ℤ × ℤ) {x : ℂ} + (hx : x ∈ cell (point r p) r) (hf : patch r F x ≠ ⊤) {a : ℝ} + (hb : ENNReal.ofReal a ≤ F p x) : a ≤ (patch r F x).toReal := by + exact (le_max_left a 0).trans (by + rw [← ENNReal.toReal_ofReal'] + exact (ENNReal.toReal_le_toReal ENNReal.ofReal_ne_top hf).mpr (hb.trans (le_patch r F p hx))) + +/-- Take the cell supremum of a weight only after the local price has been +proved. This bounds all three spatial budgets by the corresponding local prices. -/ +lemma weighted_patch_bound (r : ℝ) (F : (ℤ × ℤ) → ℂ → ℝ≥0∞) (hF : ∀ p, Measurable (F p)) + (W : ℂ → ℝ≥0∞) (hW : Measurable W) (A B : (ℤ × ℤ) → ℝ) + (hA : ∀ p, 0 ≤ A p) (_hB : ∀ p, 0 ≤ B p) + (hcell : ∀ p, (∫⁻ x in cell (point r p) r, F p x) ≤ ENNReal.ofReal (B p)) + (hWB : ∀ p x, x ∈ cell (point r p) r → W x ≤ ENNReal.ofReal (A p)) : + (∫⁻ x, W x*patch r F x) ≤ ∑' p, ENNReal.ofReal (A p*B p) := by + simp only [patch,← ENNReal.tsum_mul_left] + rw [lintegral_tsum (f := fun p x => W x*(cell (point r p) r).indicator (F p) x) (fun p => (hW.mul ((hF p).indicator (cell_measurable _ _))).aemeasurable)] + apply ENNReal.tsum_le_tsum + intro p + have he : (fun x => W x*(cell (point r p) r).indicator (F p) x) = + (cell (point r p) r).indicator (fun x => W x*F p x) := by + funext x + by_cases hx : x ∈ cell (point r p) r <;> simp [hx] + rw [he,lintegral_indicator (cell_measurable _ _)] + calc + _ ≤ ∫⁻ x in cell (point r p) r, ENNReal.ofReal (A p)*F p x := by + apply lintegral_mono_ae + filter_upwards [ae_restrict_mem (cell_measurable (point r p) r)] with x hx + exact mul_le_mul' (hWB p x hx) le_rfl + _ = ENNReal.ofReal (A p)*(∫⁻ x in cell (point r p) r, F p x) := + lintegral_const_mul _ (hF p) + _ ≤ ENNReal.ofReal (A p)*ENNReal.ofReal (B p) := mul_le_mul' le_rfl (hcell p) + _ = _ := (ENNReal.ofReal_mul (hA p)).symm +end PhysicalCells + +namespace ActualLabels +open DyadicHats FiniteLabels GeometricFilter Finset + +/-- Global geometric extension of the finite descending radius grid. -/ +def geometricRadii (base : ℝ) (m : ℕ) (k : ℕ) : ℝ := scale base m/(2:ℝ)^k +lemma geometricRadii_pos {base : ℝ} (hb : 0 < base) (m k : ℕ) : + 0 < geometricRadii base m k := div_pos (scale_pos hb m) (by positivity) +lemma geometricRadii_step (base : ℝ) (m k : ℕ) : + 2*geometricRadii base m (k+1) = geometricRadii base m k := by + unfold geometricRadii + rw [pow_succ] + field_simp +lemma geometricRadii_eq (base : ℝ) {m k : ℕ} (hk : k ≤ m) : + geometricRadii base m k = scale base (m-k) := by + unfold geometricRadii scale + rw [show m = (m-k)+k by omega,pow_add] + field_simp + rw [show m-k+k-k = m-k by omega] + ring + +lemma marginal_congr (h : ℂ → ℂ) (r s : ℕ → ℝ) (k : ℕ) + (hrs : ∀ i, i ≤ k → r i = s i) (x : ℂ) : marginal h r k x = marginal h s k x := by + induction k with + | zero => simp only [marginal,hrs 0 le_rfl] + | succ k ih => + simp only [marginal,hrs (k+1) le_rfl,ih (fun i hi => hrs i (by omega))] + +lemma switchCost_congr (h : ℂ → ℂ) (r s : ℕ → ℝ) (k : ℕ) + (hrs : ∀ i, i ≤ k → r i = s i) (x : ℂ) : switchCost h r x k = switchCost h s x k := by + cases k with + | zero => rfl + | succ k => + simp only [switchCost,hrs (k+1) le_rfl,marginal_congr h r s k (fun i hi => hrs i (by omega)) x] + +lemma derivativeCost_congr (h : ℂ → ℂ) (r s : ℕ → ℝ) (k : ℕ) + (hrs : ∀ i, i ≤ k → r i = s i) (x : ℂ) : derivativeCost h r x k = derivativeCost h s x k := by + cases k with + | zero => simp only [derivativeCost,hrs 0 le_rfl] + | succ k => + simp only [derivativeCost,hrs (k+1) le_rfl,marginal_congr h r s k (fun i hi => hrs i (by omega)) x] + +lemma cellCost_congr (h : ℂ → ℂ) (r s : ℕ → ℝ) (m l : ℕ) (hl : l ≤ m) + (hrs : ∀ i, i ≤ m → r i = s i) (q : ℤ × ℤ) : cellCost h r m l q = cellCost h s m l q := by + have hsw (i : ℕ) (hi : i ≤ m) : (fun x => switchCost h r x i) = fun x => switchCost h s x i := by + funext x + exact switchCost_congr h r s i (fun j hj => hrs j (by omega)) x + have hdc (i : ℕ) (hi : i ≤ m) : (fun x => derivativeCost h r x i) = fun x => derivativeCost h s x i := by + funext x + exact derivativeCost_congr h r s i (fun j hj => hrs j (by omega)) x + unfold cellCost + rw [hrs l hl,hsw l hl] + congr 1 + · split_ifs with he + · rfl + · rw [hsw (l+1) (by omega)] + · rw [filt_sum,filt_sum] + apply sum_congr rfl + intro i hi + rw [hdc i (by have := mem_range.mp hi; omega)] +end ActualLabels + +namespace SignedRuns +open ActualLabels FiniteLabels Finset DiskMoments PhysicalCells SignedAssembly + +lemma run_cone_bound {g : ℂ → ℝ} {r : ℕ → ℝ} + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (H : ℕ → Label → ℝ) (J : ℕ → ℝ) (hH : ∀ k n, 0 ≤ H k n) (hJ : ∀ k, 0 ≤ J k) + (x : ℂ) (n : Label) (p : List Label) + (hd : ∀ i j, i ≤ j → DifferentiableAt ℝ (runEnvelope g r i j) x) + (hinterior : ∀ k n t, PhysicalNeighborhoodRadius g (r k) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H k n) + (hend : ∀ k t, PhysicalEndpointRadius g (r k) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J k) : + ((runs (n::p)).map fun a => coneContribution a.dir (gradient (runEnvelope g r a.first a.last) x)).sum ≤ + divergence (fun y => potential g r y (n::p)) x+ + ((runs (n::p)).map fun a => J a.first).sum+ + ((runs (n::p)).map fun a => ∑ k ∈ Icc a.first a.last, H k a.dir).sum+ + 2*((runs (n::p)).map fun a => J a.first+J a.last).sum := by + rw [potential_divergence hg hc hr (n::p) x hd] + rw [← List.sum_map_mul_left,← List.sum_map_add,← List.sum_map_add,← List.sum_map_add] + apply List.sum_le_sum + intro a ha + have hab := runs_bounds n p a ha + have hu := run_unfavorable_bound hg hc hr hstep H J hH hJ x a.dir hab.1 + (hd _ _ hab.1) (hinterior · a.dir ·) hend + have hb := hend a.first (r a.first) ⟨⟨le_rfl,by linarith [hr a.first]⟩,Or.inl rfl⟩ + have hi := real_inner_le_norm (a.dir:ℂ) (gradient (fun y => signedAverage g y (r a.first)) x) + rw [label_unit,one_mul] at hi + simp only [inner_sub_right] + unfold coneContribution unfavorable at * + linarith + +/-- Complete pointwise signed assembly, still retaining the divergence term. +The remaining terms are exactly the direct directional and boundary costs. -/ +theorem pointwise_signed_master {g : ℂ → ℝ} (h : ℂ → ℂ) {r : ℕ → ℝ} + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (H : ℕ → Label → ℝ) (J : ℕ → ℝ) (hH : ∀ k n, 0 ≤ H k n) (hJ : ∀ k, 0 ≤ J k) + (old : Label) (m : ℕ) (x : ℂ) + (hd : ∀ i j, i ≤ j → DifferentiableAt ℝ (runEnvelope g r i j) x) + (hinterior : ∀ k n t, PhysicalNeighborhoodRadius g (r k) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H k n) + (hend : ∀ k t, PhysicalEndpointRadius g (r k) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J k) : + ‖gradient (runEnvelope g r 0 m) x‖ ≤ 12*( + leafSum (fun q => weight h r old x q*divergence (fun y => potential g r y q) x) (m+1) []+ + (∑ k ∈ range (m+1), expect (marginal h r k x) (H k))+ + 3*(∑ k ∈ range (m+1), boundaryCost h r x m k*J k)) := by + have hh := leafSum_mono + (fun q => weight h r old x q*((runs q).map fun a => coneContribution a.dir + (gradient (runEnvelope g r a.first a.last) x)).sum) + (fun q => weight h r old x q*divergence (fun y => potential g r y q) x+ + weight h r old x q*((runs q).map fun a => J a.first).sum+ + weight h r old x q*((runs q).map fun a => ∑ k ∈ Icc a.first a.last, H k a.dir).sum+ + 2*(weight h r old x q*((runs q).map fun a => J a.first+J a.last).sum)) (m+1) [] (by + intro q hq + cases q with + | nil => simp at hq + | cons n p => + have hh := mul_le_mul_of_nonneg_left + (run_cone_bound hg hc hr hstep H J hH hJ x n p hd hinterior hend) + (weight_nonneg h r old x (n::p)) + nlinarith only [hh]) + rw [leafSum_add,leafSum_add,leafSum_add,leafSum_const_mul,expected_span_sum] at hh + have hb := expected_boundary_sum_bound h r old x J hJ m + have hs := expected_start_sum_bound h r old x J hJ m + have hsb : (∑ k ∈ range (m+1), switchCost h r x k*J k) ≤ + ∑ k ∈ range (m+1), boundaryCost h r x m k*J k := by + apply sum_le_sum + intro k _ + apply mul_le_mul_of_nonneg_right _ (hJ k) + unfold boundaryCost + have hn : 0 ≤ if k=m then (1:ℝ) else switchCost h r x (k+1) := by + split_ifs + · exact zero_le_one + · exact switchCost_nonneg h r x (k+1) + linarith + have hm := expected_run_master g h r hg hc hr hstep old m x hd + linarith +end SignedRuns + +namespace PhysicalCells +open DyadicHats +lemma center_mem_cell (p : ℂ) (r : ℝ) : p ∈ cell p r := by + simp [cell,toUnit,unitCell] +noncomputable def cellSup (f : ℂ → ℝ) (r : ℝ) (p : ℤ × ℤ) : ℝ := + sSup (f '' cell (point r p) r) +lemma cellSup_le {f : ℂ → ℝ} {r A : ℝ} (p : ℤ × ℤ) + (h : ∀ x ∈ cell (point r p) r, f x ≤ A) : cellSup f r p ≤ A := by + apply csSup_le (Set.Nonempty.image f ⟨point r p,center_mem_cell _ _⟩) + rintro z ⟨x,hx,rfl⟩ + exact h x hx +lemma le_cellSup {f : ℂ → ℝ} {r A : ℝ} (p : ℤ × ℤ) + (h : ∀ x ∈ cell (point r p) r, f x ≤ A) {x : ℂ} (hx : x ∈ cell (point r p) r) : + f x ≤ cellSup f r p := le_csSup ⟨A,by rintro z ⟨y,hy,rfl⟩; exact h y hy⟩ ⟨x,hx,rfl⟩ +lemma cellSup_nonneg {f : ℂ → ℝ} {r A : ℝ} (p : ℤ × ℤ) + (h0 : ∀ x, 0 ≤ f x) (h : ∀ x ∈ cell (point r p) r, f x ≤ A) : 0 ≤ cellSup f r p := + (h0 (point r p)).trans (le_cellSup p h (center_mem_cell _ _)) +end PhysicalCells + +namespace ActualLabels +open DyadicHats GeometricFilter PhysicalCells CommonPrices DirectionNeighbors FiniteLabels Finset + +def pointCost (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (m k : ℕ) : ℝ := + boundaryCost h r x m k+filt (fun i => derivativeCost h r x i) k + +def costLimit : ℝ := 2+32*(Fintype.card Label:ℝ) +lemma costLimit_pos : 0 < costLimit := by dsimp [costLimit]; positivity +lemma pointCost_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) (x : ℂ) (m k : ℕ) : + 0 ≤ pointCost h r x m k := add_nonneg (boundaryCost_nonneg h r x m k) + (filt_nonneg (fun i => derivativeCost_nonneg h r x i (hr i).le) k) +lemma pointCost_le (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) (x : ℂ) (m k : ℕ) : + pointCost h r x m k ≤ costLimit := by + have hs0 := switchCost_le_one h r x k + have hs1 := switchCost_le_one h r x (k+1) + have ht := filt_le (by positivity : (0:ℝ) ≤ 16*(Fintype.card Label:ℝ)) + (fun i => derivativeCost_uniform h r x i (hr i)) k + dsimp [pointCost,boundaryCost,costLimit] + split_ifs <;> linarith + +lemma pointCost_le_cellCost (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) + (m k : ℕ) (q : ℤ × ℤ) (x : ℂ) (hx : x ∈ neighborhood (r k) q) : + pointCost h r x m k ≤ cellCost h r m k q := by + have hs (i : ℕ) : switchCost h r x i ≤ localSup (fun y => switchCost h r y i) (r k) q := + le_localSup q (fun y _ => switchCost_le_one h r y i) hx + have ht (i : ℕ) : derivativeCost h r x i ≤ localSup (fun y => derivativeCost h r y i) (r k) q := + le_localSup q (fun y _ => derivativeCost_uniform h r y i (hr i)) hx + have hf := filt_mono ht k + dsimp [pointCost,boundaryCost,cellCost] + split_ifs <;> linarith [hs k,hs (k+1)] + +lemma cellSup_pointCost_le {N : ℕ} (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) + (m k : ℕ) (p : ℤ × ℤ) (q : Grid N) (hq : q ∈ cellRoots N p) : + cellSup (fun x => pointCost h r x m k) (r k) p ≤ cellCost h r m k q := by + apply cellSup_le p + intro x hx + exact pointCost_le_cellCost h r hr m k q x (cell_subset_root_neighborhood (hr k) p q hq hx) + +lemma cellSup_pointCost_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) + (m k : ℕ) (p : ℤ × ℤ) : 0 ≤ cellSup (fun x => pointCost h r x m k) (r k) p := + cellSup_nonneg p (fun x => pointCost_nonneg h r hr x m k) (fun x _ => pointCost_le h r hr x m k) +lemma cellSup_pointCost_uniform (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) + (m k : ℕ) (p : ℤ × ℤ) : cellSup (fun x => pointCost h r x m k) (r k) p ≤ costLimit := + cellSup_le p (fun x _ => pointCost_le h r hr x m k) + +lemma pointCost_cell_budget {N : ℕ} (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ i, 0 < r i) + (base : ℝ) (m k j : ℕ) (hrj : r k = scale base j) (P : Finset (ℤ × ℤ)) : + (∑ p ∈ P, cellSup (fun x => pointCost h r x m k) (r k) p* + rootMass h base j (cellRoots N p)) ≤ + 1681*∑ q : Grid N, scalarMass h (r k) q*cellCost h r m k q := by + calc + _ ≤ ∑ p ∈ P, ∑ q ∈ cellRoots N p, scalarMass h (r k) q*cellCost h r m k q := by + apply sum_le_sum + intro p _ + unfold rootMass + rw [mul_sum] + apply sum_le_sum + intro q hq + rw [← hrj,mul_comm] + exact mul_le_mul_of_nonneg_left (cellSup_pointCost_le h r hr m k p q hq) (norm_nonneg _) + _ ≤ _ := cellRoots_budget _ (fun q => mul_nonneg (norm_nonneg _) (cellCost_nonneg h r hr m k q)) P +end ActualLabels + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/CommonPrices3.lean b/lean/OAI/Analysis/SignedDisk/CommonPrices3.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c71bc9d3d756117ac1c20d4746d88f553345760 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/CommonPrices3.lean @@ -0,0 +1,444 @@ +import OAI.Analysis.SignedDisk.CommonPrices2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace CommonPrices +open DyadicHats ConeCoordinates Finset + +def priceConstant : ℝ := 1681*((fixedPalette.labels.card:ℝ)*2/(1-rho)) +lemma priceConstant_nonneg : 0 ≤ priceConstant := by + unfold priceConstant + exact mul_nonneg (by norm_num) (div_nonneg (by positivity) (by linarith [rho_lt_one])) +lemma cellPrice_nonneg {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (S : Finset (Grid N)) : + 0 ≤ cellPrice N r h k S := sum_nonneg (fun q _ => rootPrice_nonneg hr hR hN hh hsupp k q) +lemma rootMass_cell_budget {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) + (k : ℕ) (P : Finset (ℤ × ℤ)) : + (∑ p ∈ P, rootMass h r k (cellRoots N p)) ≤ 1681*(∫ y, ‖h y‖) := by + exact (cellRoots_budget _ (fun q => norm_nonneg (vectorMass h (scale r k) q)) P).trans + (mul_le_mul_of_nonneg_left (sum_scalarMass_grid_le hh _) (by norm_num)) +end CommonPrices + +namespace ActualLabels +open DyadicHats GeometricFilter PhysicalCells CommonPrices DirectionNeighbors FiniteLabels Finset ActualMarkTrees + +lemma geometricRadii_reverse (base : ℝ) {m j : ℕ} (hj : j ≤ m) : + geometricRadii base m (m-j) = scale base j := by + rw [geometricRadii_eq base (Nat.sub_le m j),Nat.sub_sub_self hj] + +lemma pointCost_mass_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) : + (∑ j ∈ range (m+1), ∑ p ∈ P j, + cellSup (fun x => pointCost h (geometricRadii base m) x m (m-j)) (scale base j) p* + rootMass h base j (cellRoots N p)) ≤ 1681*packingConstant*(∫ y, ‖h y‖) := by + have he : (∑ j ∈ range (m+1), ∑ q : Grid N, scalarMass h (scale base j) q* + cellCost h (geometricRadii base m) m (m-j) q) = + ∑ j ∈ range (m+1), ∑ q : Grid N, scalarMass h (scale base j) q* + cellCost h (fun i => scale base (m-i)) m (m-j) q := by + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro q _ + rw [cellCost_congr h _ _ m (m-j) (Nat.sub_le m j) + (fun i hi => geometricRadii_eq base hi)] + calc + _ ≤ ∑ j ∈ range (m+1), 1681*∑ q : Grid N, scalarMass h (scale base j) q* + cellCost h (geometricRadii base m) m (m-j) q := by + apply sum_le_sum + intro j hj + have hjm : j ≤ m := by have := mem_range.mp hj; omega + have ht := pointCost_cell_budget (N := N) h (geometricRadii base m) (geometricRadii_pos hb m) + base m (m-j) j (geometricRadii_reverse base hjm) (P j) + simpa only [geometricRadii_reverse base hjm] using ht + _ = 1681*(∑ j ∈ range (m+1), ∑ q : Grid N, scalarMass h (scale base j) q* + cellCost h (geometricRadii base m) m (m-j) q) := by rw [mul_sum] + _ ≤ _ := by + rw [he,mul_assoc] + exact mul_le_mul_of_nonneg_left (spatial_packing hb hR hN hh hsupp m) (by norm_num) + +lemma pointCost_price_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) : + (∑ j ∈ range (m+1), ∑ p ∈ P j, + cellSup (fun x => pointCost h (geometricRadii base m) x m (m-j)) (scale base j) p* + cellPrice N base h j (cellRoots N p)) ≤ costLimit*priceConstant*(∫ y, ‖h y‖) := by + calc + _ ≤ ∑ j ∈ range (m+1), ∑ p ∈ P j, costLimit*cellPrice N base h j (cellRoots N p) := by + apply sum_le_sum + intro j hj + have hjm : j ≤ m := by have := mem_range.mp hj; omega + apply sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_right _ (cellPrice_nonneg hb hR hN hh hsupp j _) + rw [← geometricRadii_reverse base hjm] + exact cellSup_pointCost_uniform h _ (geometricRadii_pos hb m) m (m-j) p + _ = costLimit*(∑ j ∈ range (m+1), ∑ p ∈ P j, cellPrice N base h j (cellRoots N p)) := by + simp only [mul_sum] + _ ≤ _ := by + rw [mul_assoc] + exact mul_le_mul_of_nonneg_left (cellPrice_budget hb hR hN hh hsupp m P) costLimit_pos.le + +lemma marginal_bad_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) (n : Label) : + (∑ j ∈ range (m+1), ∑ p ∈ P j, + localSup (fun x => marginal h (geometricRadii base m) (m-j) x n) (scale base j) p* + badPrice h base j (cellRoots N p) n) ≤ + (1000000*1681*(576*(4097:ℝ)^2))*(∫ y, ‖h y‖) := by + calc + _ ≤ ∑ j ∈ range (m+1), 1000000*1681*∑ q : Grid N, + scalarMass h (scale base j) q*energy h (scale base j) q := by + apply sum_le_sum + intro j hj + have hjm : j ≤ m := by have := mem_range.mp hj; omega + calc + _ ≤ ∑ p ∈ P j, 1000000*∑ q ∈ cellRoots N p, + scalarMass h (scale base j) q*energy h (scale base j) q := by + apply sum_le_sum + intro p _ + have ht := marginal_badPrice_bound (N := N) h (geometricRadii base m) base (m-j) j + (geometricRadii_pos hb m (m-j)) (geometricRadii_reverse base hjm) p n + simpa only [geometricRadii_reverse base hjm] using ht + _ ≤ _ := by + rw [← mul_sum,mul_assoc] + exact mul_le_mul_of_nonneg_left (cellRoots_budget _ + (fun q => mul_nonneg (norm_nonneg _) (energy_nonneg _ _ _)) (P j)) (by norm_num) + _ ≤ _ := by + rw [← mul_sum] + have ht := mul_le_mul_of_nonneg_left (neighbor_energy_budget hb hR hN hh hsupp (m+1)) + (by norm_num : (0:ℝ) ≤ 1000000*1681) + nlinarith only [ht] + +lemma marginal_price_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) (n : Label) : + (∑ j ∈ range (m+1), ∑ p ∈ P j, + localSup (fun x => marginal h (geometricRadii base m) (m-j) x n) (scale base j) p* + cellPrice N base h j (cellRoots N p)) ≤ priceConstant*(∫ y, ‖h y‖) := by + apply le_trans _ (cellPrice_budget hb hR hN hh hsupp m P) + apply sum_le_sum + intro j hj + have hjm : j ≤ m := by have := mem_range.mp hj; omega + apply sum_le_sum + intro p _ + have hbnd : localSup (fun x => marginal h (geometricRadii base m) (m-j) x n) (scale base j) p ≤ 1 := by + rw [← geometricRadii_reverse base hjm] + exact marginal_localSup_le_one h _ (m-j) (geometricRadii_pos hb m (m-j)) p n + simpa only [one_mul] using mul_le_mul_of_nonneg_right hbnd (cellPrice_nonneg hb hR hN hh hsupp j _) + +open DyadicHats PhysicalCells CommonPrices ActualMarkTrees Finset FiniteLabels + +def spatialPriceConstant : ℝ := 1681*packingConstant+costLimit*priceConstant +lemma spatialPriceConstant_pos : 0 < spatialPriceConstant := by + unfold spatialPriceConstant + have := packingConstant_pos + have := costLimit_pos + have := priceConstant_nonneg + positivity + +def directPriceConstant : ℝ := 1000000*1681*(576*(4097:ℝ)^2)+priceConstant +lemma directPriceConstant_pos : 0 < directPriceConstant := by + unfold directPriceConstant + have := priceConstant_nonneg + positivity + +lemma pointCost_total_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) : + (∑ j ∈ range (m+1), ∑ p ∈ P j, + cellSup (fun x => pointCost h (geometricRadii base m) x m (m-j)) (scale base j) p* + (rootMass h base j (cellRoots N p)+cellPrice N base h j (cellRoots N p))) ≤ + spatialPriceConstant*(∫ y, ‖h y‖) := by + simp only [mul_add,sum_add_distrib] + have h1 := pointCost_mass_budget hb hR hN hh hsupp m P + have h2 := pointCost_price_budget hb hR hN hh hsupp m P + unfold spatialPriceConstant + nlinarith only [h1,h2] + +lemma marginal_total_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) (P : ℕ → Finset (ℤ × ℤ)) (n : Label) : + (∑ j ∈ range (m+1), ∑ p ∈ P j, + localSup (fun x => marginal h (geometricRadii base m) (m-j) x n) (scale base j) p* + (badPrice h base j (cellRoots N p) n+cellPrice N base h j (cellRoots N p))) ≤ + directPriceConstant*(∫ y, ‖h y‖) := by + simp only [mul_add,sum_add_distrib] + have h1 := marginal_bad_budget hb hR hN hh hsupp m P n + have h2 := marginal_price_budget hb hR hN hh hsupp m P n + unfold directPriceConstant + nlinarith only [h1,h2] +end ActualLabels + +namespace CommonPrices +open DyadicHats Finset +lemma cellPrice_level_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (j : ℕ) (P : Finset (ℤ × ℤ)) : + (∑ p ∈ P, cellPrice N base h j (cellRoots N p)) ≤ priceConstant*(∫ y, ‖h y‖) := by + have hi := single_le_sum (s := range (j+1)) + (f := fun k => ∑ p ∈ P, cellPrice N base h k (cellRoots N p)) + (fun k _ => sum_nonneg (fun p _ => cellPrice_nonneg hb hR hN hh hsupp k _)) + (by simp : j ∈ range (j+1)) + exact hi.trans (cellPrice_budget hb hR hN hh hsupp j (fun _ => P)) + +lemma total_level_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (j : ℕ) (P : Finset (ℤ × ℤ)) : + (∑ p ∈ P, (rootMass h base j (cellRoots N p)+cellPrice N base h j (cellRoots N p))) ≤ + (1681+priceConstant)*(∫ y, ‖h y‖) := by + rw [sum_add_distrib,add_mul] + exact add_le_add (rootMass_cell_budget hh base j P) (cellPrice_level_budget hb hR hN hh hsupp j P) +end CommonPrices + +namespace ActualLabels +open DyadicHats GeometricFilter PhysicalCells FiniteLabels Finset +lemma gradient_measurable (f : ℂ → ℝ) : Measurable (gradient f) := + (InnerProductSpace.toDual ℝ ℂ).symm.continuous.measurable.comp (measurable_fderiv ℝ f) + +lemma marginal_continuous (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) (k : ℕ) (n : Label) : + Continuous (fun x => marginal h r k x n) := by + induction k generalizing n with + | zero => exact (observation_lipschitz h r 0 (hr 0) n n).continuous + | succ k ih => + change Continuous (fun x => ∑ j : Label, marginal h r k x j*row h (r (k+1)) x j n) + apply continuous_finsetSum + intro j _ + exact (ih j).mul (observation_lipschitz h r (k+1) (hr (k+1)) j n).continuous + +lemma rate_continuous (h : ℂ → ℂ) {r : ℝ} (hr : 0 < r) (n : Label) : + Continuous (fun x => rate h r x n) := by + exact (interpolate_lipschitz hr (by norm_num : (0:ℝ) ≤ 1) (fun p => by + rw [abs_of_nonneg (switchChance_nonneg h r n p)] + exact switchChance_le_one h r n p)).continuous + +lemma switchCost_continuous (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) (k : ℕ) : + Continuous (fun x => switchCost h r x k) := by + cases k with + | zero => exact continuous_const + | succ k => + change Continuous (fun x => ∑ j : Label, marginal h r k x j*rate h (r (k+1)) x j) + exact continuous_finsetSum _ (fun j _ => (marginal_continuous h r hr k j).mul (rate_continuous h (hr (k+1)) j)) + +lemma derivativeCost_measurable (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) (k : ℕ) : + Measurable (fun x => derivativeCost h r x k) := by + cases k with + | zero => + change Measurable (fun x => r 0*∑ j : Label, ‖gradient (fun y => initial h (r 0) y j) x‖) + exact measurable_const.mul (Finset.measurable_fun_sum _ (fun j _ => (gradient_measurable _).norm)) + | succ k => + change Measurable (fun x => ∑ n : Label, marginal h r k x n*(r (k+1)* + ∑ j : Label, ‖gradient (fun y => row h (r (k+1)) y n j) x‖)) + apply Finset.measurable_fun_sum + intro n _ + exact (marginal_continuous h r hr k n).measurable.mul + (measurable_const.mul (Finset.measurable_fun_sum _ (fun j _ => (gradient_measurable _).norm))) + +lemma filt_measurable {f : ℂ → ℕ → ℝ} (hf : ∀ i, Measurable (fun x => f x i)) (k : ℕ) : + Measurable (fun x => filt (f x) k) := by + induction k with + | zero => exact hf 0 + | succ k ih => exact (hf (k+1)).add (ih.div_const 2) + +lemma pointCost_measurable (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) (m k : ℕ) : + Measurable (fun x => pointCost h r x m k) := by + unfold pointCost boundaryCost + apply Measurable.add + · apply Measurable.add (switchCost_continuous h r hr k).measurable + split_ifs + · exact measurable_const + · exact (switchCost_continuous h r hr (k+1)).measurable + · exact filt_measurable (derivativeCost_measurable h r hr) k +end ActualLabels + +namespace PhysicalCells +open Finset +lemma sum_tsum_ofReal_le {ι κ : Type*} (s : Finset ι) (B : ι → κ → ℝ) + (hB : ∀ i ∈ s, ∀ p, 0 ≤ B i p) (A : ℝ) + (hbudget : ∀ P : Finset κ, ∑ i ∈ s, ∑ p ∈ P, B i p ≤ A) : + (∑ i ∈ s, ∑' p, ENNReal.ofReal (B i p)) ≤ ENNReal.ofReal A := by + rw [← Summable.tsum_finsetSum (fun _ _ => ENNReal.summable)] + simp_rw [← ENNReal.ofReal_sum_of_nonneg (fun i hi => hB i hi _)] + apply tsum_ofReal_le _ (fun p => sum_nonneg (fun i hi => hB i hi p)) + intro P + rw [Finset.sum_comm] + exact hbudget P + +lemma integrated_weighted_patches {ι : Type*} + (s : Finset ι) (r : ι → ℝ) (F : ι → (ℤ × ℤ) → ℂ → ℝ≥0∞) + (hF : ∀ i ∈ s, ∀ p, Measurable (F i p)) + (W : ι → ℂ → ℝ≥0∞) (hW : ∀ i ∈ s, Measurable (W i)) + (A B : ι → (ℤ × ℤ) → ℝ) (hA : ∀ i ∈ s, ∀ p, 0 ≤ A i p) + (hB : ∀ i ∈ s, ∀ p, 0 ≤ B i p) + (hcell : ∀ i ∈ s, ∀ p, (∫⁻ x in cell (DyadicHats.point (r i) p) (r i), F i p x) ≤ ENNReal.ofReal (B i p)) + (hWB : ∀ i ∈ s, ∀ p x, x ∈ cell (DyadicHats.point (r i) p) (r i) → W i x ≤ ENNReal.ofReal (A i p)) + (C : ℝ) (hbudget : ∀ P : Finset (ℤ × ℤ), ∑ i ∈ s, ∑ p ∈ P, A i p*B i p ≤ C) : + (∑ i ∈ s, ∫⁻ x, W i x*patch (r i) (F i) x) ≤ ENNReal.ofReal C := by + apply le_trans (sum_le_sum (fun i hi => weighted_patch_bound (r i) (F i) (hF i hi) + (W i) (hW i hi) (A i) (B i) (hA i hi) (hB i hi) (hcell i hi) (hWB i hi))) + exact sum_tsum_ofReal_le s _ (fun i hi p => mul_nonneg (hA i hi p) (hB i hi p)) C hbudget +end PhysicalCells + +namespace GeometricFilter +open Finset +lemma radius_convolution {r : ℕ → ℝ} (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (c J : ℕ → ℝ) (m : ℕ) : + (∑ k ∈ range m, c k/r k*(∑ l ∈ Ico k m, r l*J l)) = + ∑ l ∈ range m, filt c l*J l := by + simp only [mul_sum] + rw [← Nat.Ico_zero_eq_range,Finset.sum_Ico_Ico_comm] + simp only [Nat.Ico_zero_eq_range] + apply sum_congr rfl + intro l _ + rw [← sum_mul] + have he := radius_sum (r := r) (c := c) l (fun i _ => hr i) (fun i _ => (hstep i).symm) + rw [← he] + ring +end GeometricFilter + +namespace SignedRuns +open ActualLabels FiniteLabels Finset DiskMoments PhysicalCells SignedAssembly GeometricFilter + +lemma total_divergence_integrable (g : ℂ → ℝ) (h : ℂ → ℂ) (r : ℕ → ℝ) + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (old : Label) (m : ℕ) : + Integrable (fun x => leafSum (fun q => weight h r old x q*divergence (fun y => potential g r y q) x) m []) := by + apply leafSum_integrable + intro q + obtain ⟨K,hK⟩ := weight_lipschitz h r hr old q + apply weighted_divergence_integrable hK _ (potential_regular hg hc hr hstep q) + intro x + rw [Real.norm_eq_abs,abs_of_nonneg (weight_nonneg h r old x q)] + exact weight_le_one h r old x q + +lemma total_flux_integrable (g : ℂ → ℝ) (h : ℂ → ℂ) (r : ℕ → ℝ) + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (old : Label) (m : ℕ) : + Integrable (fun x => leafSum (fun q => inner ℝ (gradient (fun y => weight h r old y q) x) + (potential g r x q)) m []) := by + apply leafSum_integrable + intro q + obtain ⟨K,hK⟩ := weight_lipschitz h r hr old q + exact potential_flux_integrable hK (potential_regular hg hc hr hstep q) + +lemma band_gradient_integrable {g : ℂ → ℝ} {r : ℕ → ℝ} + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (m : ℕ) : Integrable (gradient (runEnvelope g r 0 m)) := by + have hab : r m ≤ 2*r 0 := by + have hh := radius_antitone r hr hstep (Nat.zero_le m) + linarith [hr 0] + obtain ⟨L,hL⟩ := run_envelope_lipschitz hg hc (hr m) hab + exact SignedDisk.LipschitzWith.integrable_gradient hL (run_envelope_hasCompactSupport hg hc (hr m) hab) + +/-- Integration of the signed master, with its actual history law. The only +remaining inputs here are actual analytic majorants and their integrals; no +unsigned sum of run gradients is introduced. -/ +theorem integrated_signed_master {g : ℂ → ℝ} (h : ℂ → ℂ) {r : ℕ → ℝ} + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (H : ℕ → Label → ℂ → ℝ) (J : ℕ → ℂ → ℝ) + (hH : ∀ k n x, 0 ≤ H k n x) (hJ : ∀ k x, 0 ≤ J k x) + (old : Label) (m : ℕ) + (hinterior : ∀ᵐ x, ∀ k n t, PhysicalNeighborhoodRadius g (r k) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H k n x) + (hend : ∀ᵐ x, ∀ k t, PhysicalEndpointRadius g (r k) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J k x) + (hvalue : ∀ᵐ x, ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |signedAverage g x t-signedAverage g x t'| ≤ r k*J k x) + (hHi : ∀ k, k ≤ m → ∀ n, Integrable (H k n)) + (hJi : ∀ k, k ≤ m → Integrable (J k)) : + (∫ x, ‖gradient (runEnvelope g r 0 m) x‖) ≤ + 12*((∑ k ∈ range (m+1), ∫ x, expect (marginal h r k x) (fun n => H k n x))+ + 4*(∑ k ∈ range (m+1), ∫ x, pointCost h r x m k*J k x)) := by + have hdi (k : ℕ) (hk : k ≤ m) : + Integrable (fun x => expect (marginal h r k x) (fun n => H k n x)) := by + apply integrable_finsetSum + intro n _ + apply (hHi k hk n).bdd_mul (marginal_continuous h r hr k n).measurable.aestronglyMeasurable + exact ae_of_all _ (fun x => by + rw [Real.norm_eq_abs,abs_of_nonneg ((marginal h r k x).nonneg n)] + exact law_le_one _ _) + have hbi (k : ℕ) (hk : k ≤ m) : Integrable (fun x => pointCost h r x m k*J k x) := by + apply (hJi k hk).bdd_mul (pointCost_measurable h r hr m k).aestronglyMeasurable + exact ae_of_all _ (fun x => by + rw [Real.norm_eq_abs,abs_of_nonneg (pointCost_nonneg h r hr x m k)] + exact pointCost_le h r hr x m k) + let D := fun x => ∑ k ∈ range (m+1), expect (marginal h r k x) (fun n => H k n x) + let B := fun x => ∑ k ∈ range (m+1), pointCost h r x m k*J k x + have hDi : Integrable D := integrable_finsetSum _ (fun k hk => hdi k (by have := mem_range.mp hk; omega)) + have hBi : Integrable B := integrable_finsetSum _ (fun k hk => hbi k (by have := mem_range.mp hk; omega)) + let div := fun x => leafSum (fun q => weight h r old x q*divergence (fun y => potential g r y q) x) (m+1) [] + let flux := fun x => leafSum (fun q => inner ℝ (gradient (fun y => weight h r old y q) x) (potential g r x q)) (m+1) [] + have hdivi : Integrable div := total_divergence_integrable g h r hg hc hr hstep old (m+1) + have hfluxi : Integrable flux := total_flux_integrable g h r hg hc hr hstep old (m+1) + have hb (x : ℂ) : (∑ k ∈ range (m+1), boundaryCost h r x m k*J k x) ≤ B x := by + apply sum_le_sum + intro k _ + apply mul_le_mul_of_nonneg_right _ (hJ k x) + dsimp [pointCost] + linarith [filt_nonneg (fun i => derivativeCost_nonneg h r x i (hr i).le) k] + have hmaster : ∀ᵐ x, ‖gradient (runEnvelope g r 0 m) x‖ ≤ 12*(div x+D x+3*B x) := by + filter_upwards [runs_ae_diff hg hc hr hstep,hinterior,hend] with x hd hi he + have hh := pointwise_signed_master h hg hc hr hstep (fun k n => H k n x) (fun k => J k x) + (fun k n => hH k n x) (fun k => hJ k x) old m x hd hi he + change ‖gradient (runEnvelope g r 0 m) x‖ ≤ 12*(div x+D x+3*_) at hh + linarith [hb x] + have hf : ∀ᵐ x, -flux x ≤ B x := by + filter_upwards [observation_ae_diff h r hr,hvalue] with x hd hv + have ht := actual_signed_flux_bound g h r hg hr hstep old x hd (fun k => r k*J k x) hv (m+1) + rw [radius_convolution hr hstep] at ht + have hle : (∑ k ∈ range (m+1), filt (fun i => derivativeCost h r x i) k*J k x) ≤ B x := by + apply sum_le_sum + intro k _ + apply mul_le_mul_of_nonneg_right _ (hJ k x) + dsimp [pointCost] + linarith [boundaryCost_nonneg h r x m k] + exact (neg_le_abs (flux x)).trans (ht.trans hle) + have hi := integral_mono_ae (band_gradient_integrable hg hc hr hstep m).norm + ((hdivi.add hDi).add (hBi.const_mul 3) |>.const_mul 12) hmaster + simp only [Pi.add_apply] at hi + rw [integral_const_mul,integral_add (f := fun x => div x+D x) (g := fun x => 3*B x) (hdivi.add hDi) (hBi.const_mul 3),integral_add hdivi hDi, + integral_const_mul] at hi + have hip : (∫ x, div x) = -∫ x, flux x := history_weighted_ibp g h r hg hc hr hstep old (m+1) + have hfi := integral_mono_ae hfluxi.neg hBi hf + simp only [Pi.neg_apply,integral_neg] at hfi + have hDint : (∫ x, D x) = ∑ k ∈ range (m+1), ∫ x, expect (marginal h r k x) (fun n => H k n x) := + integral_finsetSum _ (fun k hk => hdi k (by have := mem_range.mp hk; omega)) + have hBint : (∫ x, B x) = ∑ k ∈ range (m+1), ∫ x, pointCost h r x m k*J k x := + integral_finsetSum _ (fun k hk => hbi k (by have := mem_range.mp hk; omega)) + rw [hip] at hi + rw [← hDint,← hBint] + linarith +end SignedRuns + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/CommonPrices4.lean b/lean/OAI/Analysis/SignedDisk/CommonPrices4.lean new file mode 100644 index 0000000000000000000000000000000000000000..48f26d1c706d14e5b3ebfe31570b3fdd0f09e8e8 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/CommonPrices4.lean @@ -0,0 +1,433 @@ +import OAI.Analysis.SignedDisk.CommonPrices3 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace CommonPrices +open DyadicHats ConeCoordinates Finset DiskMoments PhysicalCells SignedRuns FiniteLabels ActualLabels + +/-- Combine the two actual signed directional prices; the labels are unchanged. -/ +theorem physical_unfavorable_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → ∀ (k : ℕ) (p : ℤ × ℤ) (n : Label), + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ y in cell (point (scale r k) p) (scale r k), F y) ≤ ENNReal.ofReal + (C*(badPrice (gradient g) r k (cellRoots N p) n+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ y ∈ cell (point (scale r k) p) (scale r k), ∀ t, + PhysicalNeighborhoodRadius g (scale r k) y t → + ENNReal.ofReal (unfavorable n (gradient (fun z => signedAverage g z t) y)) ≤ F y := by + obtain ⟨C,hC,hp⟩ := physical_directional_price + refine ⟨2*C,by positivity,?_⟩ + intro N r R hr hR hN g hg hh hs hd k p n + obtain ⟨F,hFm,hFi,hFb⟩ := hp hr hR hN hg hh hs hd k p n.property (Or.inl rfl : (1:ℝ)=1 ∨ (1:ℝ)=-1) + obtain ⟨G,hGm,hGi,hGb⟩ := hp hr hR hN hg hh hs hd k p n.property (Or.inr rfl : (-1:ℝ)=1 ∨ (-1:ℝ)=-1) + have hn : 0 ≤ C*(badPrice (gradient g) r k (cellRoots N p) n+cellPrice N r (gradient g) k (cellRoots N p)) := + mul_nonneg hC.le (add_nonneg (badPrice_nonneg _ _ _ _ _) (cellPrice_nonneg hr hR hN hh hs k _)) + refine ⟨fun y => F y+G y,hFm.add hGm,?_,?_⟩ + · rw [lintegral_add_left hFm] + calc + _ ≤ ENNReal.ofReal (C*(_+_))+ENNReal.ofReal (C*(_+_)) := add_le_add hFi hGi + _ = _ := by rw [← ENNReal.ofReal_add hn hn]; congr 1; ring + · intro y hy t ht + rw [unfavorable,ENNReal.ofReal_add (le_max_left _ _) (le_max_left _ _)] + exact add_le_add (hFb y hy t ht) (hGb y hy t ht) + +/-- A single actual endpoint price pays both the gradient and the normalized +oscillation. It is introduced before any spatial supremum is taken. -/ +theorem physical_joint_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → ∀ (k : ℕ) (p : ℤ × ℤ) (n : Label), + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ y in cell (point (scale r k) p) (scale r k), F y) ≤ ENNReal.ofReal + (C*(rootMass (gradient g) r k (cellRoots N p)+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + (∀ y ∈ cell (point (scale r k) p) (scale r k), ∀ t, + PhysicalEndpointRadius g (scale r k) y t → + ENNReal.ofReal ‖gradient (fun z => signedAverage g z t) y‖ ≤ F y) ∧ + (∀ y ∈ cell (point (scale r k) p) (scale r k), ∀ t t', + 0 < t → t ≤ 4*scale r k → 0 < t' → t' ≤ 4*scale r k → + ENNReal.ofReal (|signedAverage g y t-signedAverage g y t'|/scale r k) ≤ F y) := by + obtain ⟨Cs,hCs,hp⟩ := physical_size_price + obtain ⟨Cv,hCv,hq⟩ := physical_value_price + refine ⟨Cs+Cv,add_pos hCs hCv,?_⟩ + intro N r R hr hR hN g hg hh hs hd k p n + obtain ⟨F,hFm,hFi,hFb⟩ := hp hr hR hN hg hh hs hd k p n.property + obtain ⟨G,hGm,hGi,hGb⟩ := hq hr hR hN hg hh hs hd k p n.property + have hrk := scale_pos hr k + let B := rootMass (gradient g) r k (cellRoots N p)+cellPrice N r (gradient g) k (cellRoots N p) + have hB : 0 ≤ B := add_nonneg (rootMass_nonneg _ _ _ _) (cellPrice_nonneg hr hR hN hh hs k _) + have hG : (∫⁻ y in cell (point (scale r k) p) (scale r k), ENNReal.ofReal (scale r k)⁻¹*G y) ≤ ENNReal.ofReal (Cv*B) := by + rw [lintegral_const_mul _ hGm] + calc + _ ≤ ENNReal.ofReal (scale r k)⁻¹*ENNReal.ofReal (Cv*scale r k*B) := mul_le_mul' le_rfl hGi + _ = _ := by rw [← ENNReal.ofReal_mul (inv_nonneg.mpr hrk.le)]; congr 1; field_simp + refine ⟨fun y => F y+ENNReal.ofReal (scale r k)⁻¹*G y, + hFm.add (measurable_const.mul hGm),?_,?_,?_⟩ + · rw [lintegral_add_left hFm] + calc + _ ≤ ENNReal.ofReal (Cs*B)+ENNReal.ofReal (Cv*B) := add_le_add hFi hG + _ = _ := by rw [← ENNReal.ofReal_add (mul_nonneg hCs.le hB) (mul_nonneg hCv.le hB),← add_mul] + · intro y hy t ht + exact (hFb y hy t ht).trans le_self_add + · intro y hy t t' ht hb ht' hb' + have hgg := mul_le_mul' (le_refl (ENNReal.ofReal (scale r k)⁻¹)) (hGb y hy t t' ht hb ht' hb') + rw [← ENNReal.ofReal_mul (inv_nonneg.mpr hrk.le),inv_mul_eq_div] at hgg + exact hgg.trans le_add_self +end CommonPrices + +namespace PhysicalCells +open Finset + +lemma real_weighted_patches {ι : Type*} (s : Finset ι) + (r : ι → ℝ) (F : ι → (ℤ × ℤ) → ℂ → ℝ≥0∞) + (hFi : ∀ i ∈ s, Integrable (fun x => (patch (r i) (F i) x).toReal)) + (W : ι → ℂ → ℝ) (hW : ∀ i ∈ s, Measurable (W i)) + (hW0 : ∀ i ∈ s, ∀ x, 0 ≤ W i x) (M : ℝ) + (hWM : ∀ i ∈ s, ∀ x, W i x ≤ M) {C : ℝ} (hC : 0 ≤ C) + (hf : (∑ i ∈ s, ∫⁻ x, ENNReal.ofReal (W i x)*patch (r i) (F i) x) ≤ ENNReal.ofReal C) : + (∑ i ∈ s, ∫ x, W i x*(patch (r i) (F i) x).toReal) ≤ C := by + have hi (i : ι) (hi : i ∈ s) : Integrable (fun x => W i x*(patch (r i) (F i) x).toReal) := by + apply (hFi i hi).bdd_mul (hW i hi).aestronglyMeasurable + exact ae_of_all _ (fun x => by rw [Real.norm_eq_abs,abs_of_nonneg (hW0 i hi x)]; exact hWM i hi x) + apply (ENNReal.ofReal_le_ofReal_iff hC).mp + rw [ENNReal.ofReal_sum_of_nonneg (fun i hi => integral_nonneg (fun x => mul_nonneg (hW0 i hi x) ENNReal.toReal_nonneg))] + apply le_trans _ hf + apply sum_le_sum + intro i his + rw [ofReal_integral_eq_lintegral_ofReal (hi i his) (ae_of_all _ (fun x => mul_nonneg (hW0 i his x) ENNReal.toReal_nonneg))] + apply lintegral_mono + intro x + change ENNReal.ofReal (W i x * (patch (r i) (F i) x).toReal) ≤ ENNReal.ofReal (W i x) * patch (r i) (F i) x + rw [ENNReal.ofReal_mul (hW0 i his x)] + exact mul_le_mul' le_rfl ENNReal.ofReal_toReal_le +end PhysicalCells + +namespace CommonPrices +open DyadicHats ConeCoordinates Finset DiskMoments PhysicalCells SignedRuns FiniteLabels ActualLabels + +lemma bad_total_level_budget {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) + (hN : R/base+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (j : ℕ) (P : Finset (ℤ × ℤ)) (n : Label) : + (∑ p ∈ P, (badPrice h base j (cellRoots N p) n+cellPrice N base h j (cellRoots N p))) ≤ + (1681+priceConstant)*(∫ y, ‖h y‖) := by + apply le_trans _ (total_level_budget hb hR hN hh hsupp j P) + apply sum_le_sum + intro p hp + exact add_le_add (badPrice_le_rootMass h base j (cellRoots N p) n) le_rfl + +/-- Actual full-lattice unfavorable prices, with the genuine marginal law. -/ +theorem patched_unfavorable : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) (hN : R/base+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → + ∃ H : ℕ → Label → ℂ → ℝ, + (∀ j n x, 0 ≤ H j n x) ∧ (∀ j n, Integrable (H j n)) ∧ + (∀ᵐ x, ∀ j n t, PhysicalNeighborhoodRadius g (scale base j) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H j n x) ∧ + (∀ m n, (∑ j ∈ range (m+1), ∫ x, marginal (gradient g) (geometricRadii base m) (m-j) x n*H j n x) ≤ + C*(∫ y, ‖gradient g y‖)) := by + obtain ⟨c,hc,hp⟩ := physical_unfavorable_price + refine ⟨c*directPriceConstant,mul_pos hc directPriceConstant_pos,?_⟩ + intro N base R hb hR hN g hg hh hs hd + choose F hFm hFi hFb using fun j n p => hp hb hR hN hg hh hs hd j p n + let B := fun j p n => badPrice (gradient g) base j (cellRoots N p) n+cellPrice N base (gradient g) j (cellRoots N p) + have hB (j p n) : 0 ≤ B j p n := add_nonneg (badPrice_nonneg _ _ _ _ _) (cellPrice_nonneg hb hR hN hh hs j _) + have hpi (j n) : (∫⁻ x, patch (scale base j) (F j n) x) ≤ + ENNReal.ofReal (c*((1681+priceConstant)*(∫ y, ‖gradient g y‖))) := by + apply lintegral_patch_budget _ _ (hFm j n) (fun p => c*B j p n) (fun p => mul_nonneg hc.le (hB j p n)) _ (hFi j n) + intro P + rw [← mul_sum] + exact mul_le_mul_of_nonneg_left (bad_total_level_budget hb hR hN hh hs j P n) hc.le + let H := fun j n x => (patch (scale base j) (F j n) x).toReal + have hHi (j n) : Integrable (H j n) := patch_integrable _ _ (hFm j n) (hpi j n) + refine ⟨H,fun _ _ _ => ENNReal.toReal_nonneg,hHi,?_,?_⟩ + · have hfin : ∀ᵐ x, ∀ j n, patch (scale base j) (F j n) x ≠ ⊤ := + (ae_all_iff).mpr (fun j => (ae_all_iff).mpr (fun n => patch_finite _ _ (hFm j n) (hpi j n))) + filter_upwards [hfin] with x hx + intro j n t ht + exact real_le_patch (F j n) (gridIndex (scale base j) x) (mem_index_cell (scale_pos hb j) x) (hx j n) + (hFb j n _ x (mem_index_cell (scale_pos hb j) x) t ht) + · intro m n + let W := fun j x => marginal (gradient g) (geometricRadii base m) (m-j) x n + let A := fun j p => localSup (W j) (scale base j) p + have hA (j) (hj : j ∈ range (m+1)) (p) : 0 ≤ A j p := by + have hjm : j ≤ m := by have := mem_range.mp hj; omega + dsimp [A,W] + rw [← geometricRadii_reverse base hjm] + exact marginal_localSup_nonneg _ _ _ (geometricRadii_pos hb m (m-j)) p n + have hwm (j) : Measurable (W j) := (marginal_continuous _ _ (geometricRadii_pos hb m) (m-j) n).measurable + have hWB (j) (hj : j ∈ range (m+1)) (p x) (hx : x ∈ cell (point (scale base j) p) (scale base j)) : + ENNReal.ofReal (W j x) ≤ ENNReal.ofReal (A j p) := by + apply ENNReal.ofReal_le_ofReal + apply le_localSup p (fun y _ => law_le_one _ _) + change DyadicHats.boxNorm (x-point (scale base j) p) ≤ 25*scale base j + have ht := mem_cell_box (scale_pos hb j) hx + linarith [scale_pos hb j] + have hwt := integrated_weighted_patches (range (m+1)) (scale base) (fun j => F j n) + (fun j _ => hFm j n) (fun j x => ENNReal.ofReal (W j x)) (fun j _ => (hwm j).ennreal_ofReal) + A (fun j p => c*B j p n) hA (fun j _ p => mul_nonneg hc.le (hB j p n)) + (fun j _ => hFi j n) hWB (c*directPriceConstant*(∫ y, ‖gradient g y‖)) (by + intro P + have hbgt := mul_le_mul_of_nonneg_left (marginal_total_budget hb hR hN hh hs m (fun _ => P) n) hc.le + simpa only [A,W,B,mul_sum,mul_assoc,mul_left_comm] using hbgt) + exact real_weighted_patches (range (m+1)) (scale base) (fun j => F j n) (fun j _ => hHi j n) + W (fun j _ => hwm j) (fun j _ x => (marginal _ _ _ x).nonneg n) 1 (fun j _ x => law_le_one _ _) + (mul_nonneg (mul_nonneg hc.le directPriceConstant_pos.le) (integral_nonneg (fun y => norm_nonneg _))) hwt + +/-- Actual endpoint/value weights charged simultaneously at every level. -/ +theorem patched_joint : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {base R : ℝ} (hb : 0 < base) (hR : 0 ≤ R) (hN : R/base+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → + ∃ J : ℕ → ℂ → ℝ, + (∀ j x, 0 ≤ J j x) ∧ (∀ j, Integrable (J j)) ∧ + (∀ᵐ x, ∀ j t, PhysicalEndpointRadius g (scale base j) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J j x) ∧ + (∀ᵐ x, ∀ j t t', 0 < t → t ≤ 4*scale base j → 0 < t' → t' ≤ 4*scale base j → + |signedAverage g x t-signedAverage g x t'| ≤ scale base j*J j x) ∧ + (∀ m, (∑ j ∈ range (m+1), ∫ x, pointCost (gradient g) (geometricRadii base m) x m (m-j)*J j x) ≤ + C*(∫ y, ‖gradient g y‖)) := by + obtain ⟨c,hc,hp⟩ := physical_joint_price + refine ⟨c*spatialPriceConstant,mul_pos hc spatialPriceConstant_pos,?_⟩ + intro N base R hb hR hN g hg hh hs hd + let n : Label := target (gradient g) base (0,0) + choose F hFm hFi hFb hFv using fun j p => hp hb hR hN hg hh hs hd j p n + let B := fun j p => rootMass (gradient g) base j (cellRoots N p)+cellPrice N base (gradient g) j (cellRoots N p) + have hB (j p) : 0 ≤ B j p := add_nonneg (rootMass_nonneg _ _ _ _) (cellPrice_nonneg hb hR hN hh hs j _) + have hpi (j) : (∫⁻ x, patch (scale base j) (F j) x) ≤ + ENNReal.ofReal (c*((1681+priceConstant)*(∫ y, ‖gradient g y‖))) := by + apply lintegral_patch_budget _ _ (hFm j) (fun p => c*B j p) (fun p => mul_nonneg hc.le (hB j p)) _ (hFi j) + intro P + rw [← mul_sum] + exact mul_le_mul_of_nonneg_left (total_level_budget hb hR hN hh hs j P) hc.le + let J := fun j x => (patch (scale base j) (F j) x).toReal + have hJi (j) : Integrable (J j) := patch_integrable _ _ (hFm j) (hpi j) + have hfin : ∀ᵐ x, ∀ j, patch (scale base j) (F j) x ≠ ⊤ := + (ae_all_iff).mpr (fun j => patch_finite _ _ (hFm j) (hpi j)) + refine ⟨J,fun _ _ => ENNReal.toReal_nonneg,hJi,?_,?_,?_⟩ + · filter_upwards [hfin] with x hx + intro j t ht + exact real_le_patch (F j) (gridIndex (scale base j) x) (mem_index_cell (scale_pos hb j) x) (hx j) + (hFb j _ x (mem_index_cell (scale_pos hb j) x) t ht) + · filter_upwards [hfin] with x hx + intro j t t' ht hb' ht' hb'' + have ht := real_le_patch (F j) (gridIndex (scale base j) x) (mem_index_cell (scale_pos hb j) x) (hx j) + (hFv j _ x (mem_index_cell (scale_pos hb j) x) t t' ht hb' ht' hb'') + exact (div_le_iff₀ (scale_pos hb j)).mp ht |>.trans_eq (mul_comm _ _) + · intro m + let W := fun j x => pointCost (gradient g) (geometricRadii base m) x m (m-j) + let A := fun j p => cellSup (W j) (scale base j) p + have hwm (j) : Measurable (W j) := pointCost_measurable _ _ (geometricRadii_pos hb m) m (m-j) + have hw0 (j x) : 0 ≤ W j x := pointCost_nonneg _ _ (geometricRadii_pos hb m) x m (m-j) + have hwM (j x) : W j x ≤ costLimit := pointCost_le _ _ (geometricRadii_pos hb m) x m (m-j) + have hA (j p) : 0 ≤ A j p := cellSup_nonneg p (hw0 j) (fun x _ => hwM j x) + have hWB (j p x) (hx : x ∈ cell (point (scale base j) p) (scale base j)) : + ENNReal.ofReal (W j x) ≤ ENNReal.ofReal (A j p) := + ENNReal.ofReal_le_ofReal (le_cellSup p (fun y _ => hwM j y) hx) + have hwt := integrated_weighted_patches (range (m+1)) (scale base) F + (fun j _ => hFm j) (fun j x => ENNReal.ofReal (W j x)) (fun j _ => (hwm j).ennreal_ofReal) + A (fun j p => c*B j p) (fun j _ => hA j) (fun j _ p => mul_nonneg hc.le (hB j p)) + (fun j _ => hFi j) (fun j _ => hWB j) (c*spatialPriceConstant*(∫ y, ‖gradient g y‖)) (by + intro P + have hbgt := mul_le_mul_of_nonneg_left (pointCost_total_budget hb hR hN hh hs m (fun _ => P)) hc.le + simpa only [A,W,B,mul_sum,mul_assoc,mul_left_comm] using hbgt) + exact real_weighted_patches (range (m+1)) (scale base) F (fun j _ => hJi j) + W (fun j _ => hwm j) (fun j _ => hw0 j) costLimit (fun j _ => hwM j) + (mul_nonneg (mul_nonneg hc.le spatialPriceConstant_pos.le) (integral_nonneg (fun y => norm_nonneg _))) hwt +end CommonPrices + +namespace SignedRuns +open ActualLabels FiniteLabels Finset DiskMoments PhysicalCells SignedAssembly GeometricFilter CommonPrices DyadicHats + +/-- Reverse the spatial scale index and fill unused indices with genuine global +Lipschitz bounds. Only the physical prices at indices at most m are integrated. -/ +lemma master_from_patches {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + {base : ℝ} (hb : 0 < base) (m : ℕ) + (H : ℕ → Label → ℂ → ℝ) (J : ℕ → ℂ → ℝ) + (hH : ∀ j n x, 0 ≤ H j n x) (hJ : ∀ j x, 0 ≤ J j x) + (hHi : ∀ j n, Integrable (H j n)) (hJi : ∀ j, Integrable (J j)) + (hinterior : ∀ᵐ x, ∀ j n t, PhysicalNeighborhoodRadius g (scale base j) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H j n x) + (hend : ∀ᵐ x, ∀ j t, PhysicalEndpointRadius g (scale base j) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J j x) + (hvalue : ∀ᵐ x, ∀ j t t', 0 < t → t ≤ 4*scale base j → 0 < t' → t' ≤ 4*scale base j → + |signedAverage g x t-signedAverage g x t'| ≤ scale base j*J j x) : + (∫ x, ‖gradient (runEnvelope g (geometricRadii base m) 0 m) x‖) ≤ + 12*((∑ j ∈ range (m+1), ∫ x, expect (marginal (gradient g) (geometricRadii base m) (m-j) x) (fun n => H j n x))+ + 4*(∑ j ∈ range (m+1), ∫ x, pointCost (gradient g) (geometricRadii base m) x m (m-j)*J j x)) := by + classical + let r := geometricRadii base m + have hr := geometricRadii_pos hb m + obtain ⟨L,hL⟩ := hg.lipschitzWith_of_hasCompactSupport hc one_ne_zero + obtain ⟨M,hM⟩ := hc.exists_bound_of_continuous hg.continuous + have hM0 : 0 ≤ M := (norm_nonneg (g 0)).trans (hM 0) + have hMa (y) : |g y| ≤ M := by simpa only [Real.norm_eq_abs] using hM y + let H' := fun k n x => if k ≤ m then H (m-k) n x else 2*(L:ℝ) + let J' := fun k x => if k ≤ m then J (m-k) x else (L:ℝ)+2*M/r k + have hH' (k n x) : 0 ≤ H' k n x := by dsimp [H']; split_ifs; exact hH _ _ _; positivity + have hJ' (k x) : 0 ≤ J' k x := by + dsimp [J']; split_ifs + · exact hJ _ _ + · exact add_nonneg L.coe_nonneg (div_nonneg (mul_nonneg (by norm_num) hM0) (hr k).le) + have hHi' (k) (hk : k ≤ m) (n) : Integrable (H' k n) := by simpa only [H',ite_eq_left hk] using hHi (m-k) n + have hJi' (k) (hk : k ≤ m) : Integrable (J' k) := by simpa only [J',ite_eq_left hk] using hJi (m-k) + have hint' : ∀ᵐ x, ∀ k n t, PhysicalNeighborhoodRadius g (r k) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H' k n x := by + filter_upwards [hinterior] with x hx + intro k n t ht + dsimp [H'] + split_ifs with hk + · apply hx + simpa only [r,geometricRadii_eq base hk] using ht + · exact (unfavorable_le_norm n _).trans (mul_le_mul_of_nonneg_left + (gradient_norm_le (signedAverage_lipschitz hL ((hr k).trans_le ht.1.1)) x) (by norm_num)) + have hend' : ∀ᵐ x, ∀ k t, PhysicalEndpointRadius g (r k) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J' k x := by + filter_upwards [hend] with x hx + intro k t ht + dsimp [J'] + split_ifs with hk + · apply hx + simpa only [r,geometricRadii_eq base hk] using ht + · have he := gradient_norm_le (signedAverage_lipschitz hL ((hr k).trans_le ht.1.1)) x + have hpos : 0 ≤ 2*M/r k := div_nonneg (mul_nonneg (by norm_num) hM0) (hr k).le + linarith + have hval' : ∀ᵐ x, ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |signedAverage g x t-signedAverage g x t'| ≤ r k*J' k x := by + filter_upwards [hvalue] with x hx + intro k t t' ht hbt ht' hbt' + dsimp [J'] + split_ifs with hk + · simpa only [r,geometricRadii_eq base hk] using hx (m-k) t t' ht + (by simpa only [r,geometricRadii_eq base hk] using hbt) ht' + (by simpa only [r,geometricRadii_eq base hk] using hbt') + · have he := abs_sub (signedAverage g x t) (signedAverage g x t') + have he1 := signedAverage_abs_le hMa x ht + have he2 := signedAverage_abs_le hMa x ht' + rw [mul_add,mul_div_cancel₀ _ (hr k).ne'] + have hp : 0 ≤ r k*(L:ℝ) := mul_nonneg (hr k).le L.coe_nonneg + linarith + have hi := integrated_signed_master (gradient g) hg hc hr (geometricRadii_step base m) + H' J' hH' hJ' (target (gradient g) base (0,0)) m hint' hend' hval' hHi' hJi' + have hd : (∑ k ∈ range (m+1), ∫ x, expect (marginal (gradient g) r k x) (fun n => H' k n x)) = + ∑ j ∈ range (m+1), ∫ x, expect (marginal (gradient g) r (m-j) x) (fun n => H j n x) := by + rw [← sum_range_reflect (fun k => ∫ x, expect (marginal (gradient g) r k x) (fun n => H' k n x)) (m+1)] + apply sum_congr rfl + intro j hj + have hjm : j ≤ m := by have := mem_range.mp hj; omega + simp only [Nat.add_sub_cancel,H',ite_eq_left (Nat.sub_le m j),Nat.sub_sub_self hjm] + have he : (∑ k ∈ range (m+1), ∫ x, pointCost (gradient g) r x m k*J' k x) = + ∑ j ∈ range (m+1), ∫ x, pointCost (gradient g) r x m (m-j)*J j x := by + rw [← sum_range_reflect (fun k => ∫ x, pointCost (gradient g) r x m k*J' k x) (m+1)] + apply sum_congr rfl + intro j hj + have hjm : j ≤ m := by have := mem_range.mp hj; omega + simp only [Nat.add_sub_cancel,J',ite_eq_left (Nat.sub_le m j),Nat.sub_sub_self hjm] + rw [hd,he] at hi + exact hi + +/-- The genuine smooth signed dyadic finite-band estimate. No probability, +common-price, local analytic estimate, or total variation bound is assumed. -/ +theorem smooth_compact_dyadic_band : ∃ C : ℝ, 0 < C ∧ + ∀ {g : ℂ → ℝ}, ContDiff ℝ 1 g → HasCompactSupport g → + ∀ {base : ℝ}, 0 < base → ∀ m : ℕ, + (∫ x, ‖gradient (runEnvelope g (geometricRadii base m) 0 m) x‖) ≤ C*(∫ x, ‖gradient g x‖) := by + obtain ⟨Cd,hCd,hpd⟩ := patched_unfavorable + obtain ⟨Cj,hCj,hpj⟩ := patched_joint + refine ⟨12*((Fintype.card Label:ℝ)*Cd+4*Cj),by positivity,?_⟩ + intro g hg hc base hb m + have hh : Integrable (gradient g) := (continuous_gradient hg).integrable_of_hasCompactSupport (gradient_hasCompactSupport hc) + obtain ⟨R0,hR0⟩ := (gradient_hasCompactSupport hc).isBounded.subset_closedBall (0:ℂ) + let R := max 0 R0 + have hR : 0 ≤ R := le_max_left _ _ + have hs : ∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R := by + intro y hy + have he : ‖y‖ ≤ R0 := by simpa only [Metric.mem_closedBall,dist_zero_right] using hR0 (subset_tsupport (gradient g) hy) + exact he.trans (le_max_right _ _) + obtain ⟨N,hN⟩ := exists_nat_ge (R/base+1) + obtain ⟨L,hL⟩ := hg.lipschitzWith_of_hasCompactSupport hc one_ne_zero + have hd : ∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D := ⟨L,fun _ => norm_fderiv_le_of_lipschitz ℝ hL⟩ + obtain ⟨H,hH,hHi,hHd,hHb⟩ := hpd hb hR hN hg hh hs hd + obtain ⟨J,hJ,hJi,hJe,hJv,hJb⟩ := hpj hb hR hN hg hh hs hd + have hi := master_from_patches hg hc hb m H J hH hJ hHi hJi hHd hJe hJv + have hdi (j : ℕ) (n : Label) : Integrable (fun x => marginal (gradient g) (geometricRadii base m) (m-j) x n*H j n x) := by + apply (hHi j n).bdd_mul (marginal_continuous _ _ (geometricRadii_pos hb m) (m-j) n).measurable.aestronglyMeasurable + exact ae_of_all _ (fun x => by rw [Real.norm_eq_abs,abs_of_nonneg ((marginal _ _ _ x).nonneg n)]; exact law_le_one _ _) + have hD : (∑ j ∈ range (m+1), ∫ x, expect (marginal (gradient g) (geometricRadii base m) (m-j) x) (fun n => H j n x)) ≤ + (Fintype.card Label:ℝ)*Cd*(∫ y, ‖gradient g y‖) := by + simp only [FiniteLabels.expect] + simp_rw [integral_finsetSum univ (fun n _ => hdi _ n)] + rw [Finset.sum_comm] + have he := sum_le_sum (s := univ) (fun n _ => hHb m n) + simpa only [sum_const,card_univ,nsmul_eq_mul,mul_assoc] using he + have hB := hJb m + nlinarith only [hi,hD,hB] +end SignedRuns + +/- Directional weak gradients and coordinate isometries on the plane. -/ +namespace WeakSobolev +open ContinuousLinearMap +open scoped Convolution +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + {μ : Measure E} [μ.IsAddHaarMeasure] + +/-- Directional, coordinate-free distributional gradient. -/ +def HasGradient (f : E → ℝ) (g : E → E) : Prop := + ∀ φ : E → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → ∀ v : E, + (∫ x, f x * fderiv ℝ φ x v ∂μ) = -∫ x, ⟪g x,v⟫ * φ x ∂μ + +lemma norm_convolution_le {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] + {K : E → ℝ} {g : E → F} + (hK : Integrable K μ) (hg : Integrable g μ) : + (∫ x, ‖(K ⋆[lsmul ℝ ℝ,μ] g) x‖ ∂μ) ≤ (∫ x, |K x| ∂μ)*(∫ x, ‖g x‖ ∂μ) := by + have hi := hK.norm.integrable_convolution (lsmul ℝ ℝ) hg.norm + calc + _ ≤ ∫ x, ( (fun y => ‖K y‖) ⋆[lsmul ℝ ℝ,μ] (fun y => ‖g y‖)) x ∂μ := by + apply integral_mono_ae (hK.integrable_convolution (lsmul ℝ ℝ) hg).norm hi + filter_upwards [hK.norm.ae_convolution_exists (lsmul ℝ ℝ) hg.norm] with x hx + simp only [convolution_def,lsmul_apply,smul_eq_mul] at hx ⊢ + exact norm_integral_le_of_norm_le hx (ae_of_all _ (fun y => by rw [norm_smul])) + _ = _ := by rw [integral_convolution _ hK.norm hg.norm]; simp only [lsmul_apply,smul_eq_mul,Real.norm_eq_abs] + +lemma lipschitz_hasGradient {f : E → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) : + HasGradient (μ := μ) f (gradient f) := by + intro φ hφ hc v + obtain ⟨K,hK⟩ := hφ.lipschitzWith_of_hasCompactSupport hc (by simp) + exact SignedDisk.LipschitzWith.integral_mul_fderiv_eq_neg hf hK hc v +end WeakSobolev + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DirectionNeighbors1.lean b/lean/OAI/Analysis/SignedDisk/DirectionNeighbors1.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6a8fbd88506252207dedf395291d222d23a94d2 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DirectionNeighbors1.lean @@ -0,0 +1,414 @@ +import OAI.Analysis.SignedDisk.DyadicHats3 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace DirectionNeighbors +open DyadicHats +lemma scale_scale (r : ℝ) (k d : ℕ) : scale (scale r k) d = scale r (k+d) := by + simp only [scale,pow_add] + ring + +lemma shifted_mass_bound (A : ℕ → ℝ) {V : ℝ} (h0 : ∀ k, 0 ≤ A k) + (hV : ∀ k, A k ≤ V) (m d : ℕ) : + (∑ k ∈ Finset.range m, (A k-A (k+d))) ≤ d*V := by + have he : (∑ k ∈ Finset.range m, A k)+(∑ k ∈ Finset.range d, A (k+m)) = + (∑ k ∈ Finset.range d, A k)+(∑ k ∈ Finset.range m, A (k+d)) := by + calc + _ = ∑ k ∈ Finset.range (m+d), A k := by + simpa only [Nat.add_comm] using (Finset.sum_range_add A m d).symm + _ = ∑ k ∈ Finset.range (d+m), A k := by rw [Nat.add_comm m d] + _ = _ := by simpa only [Nat.add_comm] using Finset.sum_range_add A d m + have hprefix : (∑ k ∈ Finset.range d, A k) ≤ d*V := by + calc + _ ≤ ∑ _k ∈ Finset.range d, V := Finset.sum_le_sum (fun k _ => hV k) + _ = _ := by simp + have htail : 0 ≤ ∑ k ∈ Finset.range d, A (k+m) := Finset.sum_nonneg (fun k _ => h0 _) + rw [Finset.sum_sub_distrib] + linarith + +theorem neighbor_energy_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (m : ℕ) : + (∑ k ∈ Finset.range m, ∑ q : Grid N, + scalarMass h (scale r k) q*energy h (scale r k) q) ≤ + (576*(4097:ℝ)^2)*(∫ y, ‖h y‖) := by + let A := fun k => ∑ q : Grid N, scalarMass h (scale r k) q + have he (k : ℕ) : + (∑ q : Grid N, scalarMass h (scale r k) q*energy h (scale r k) q) ≤ + (48*(4097:ℝ)^2)*(A k-A (k+12)) := by + simpa only [scale_scale] using level_energy_budget (scale_pos hr k) hR + (scale_index_bound hr hR hN k) hh hs + have hsum := Finset.sum_le_sum (fun k (_ : k ∈ Finset.range m) => he k) + rw [← Finset.mul_sum] at hsum + have hA0 (k : ℕ) : 0 ≤ A k := Finset.sum_nonneg (fun _ _ => norm_nonneg _) + have hAV (k : ℕ) : A k ≤ ∫ y, ‖h y‖ := sum_scalarMass_grid_le hh _ + have hb := shifted_mass_bound A hA0 hAV m 12 + have hf := hsum.trans (mul_le_mul_of_nonneg_left hb (by positivity : (0:ℝ) ≤ 48*(4097:ℝ)^2)) + norm_num at hf ⊢ + nlinarith only [hf] +end DirectionNeighbors + +/-! Actual fixed palette and literal cone coordinates. -/ + +open MeasureTheory Set +open scoped RealInnerProductSpace + +namespace ConeCoordinates + +def axis (n : ℂ) (s : ℝ) : ℂ := (Real.sqrt 3/2) • n + (s/2) • (Complex.I*n) +def coordinate (n : ℂ) (s : ℝ) : ℂ →L[ℝ] ℝ := + (1 / Real.sqrt 3) • innerSL ℝ n + s • innerSL ℝ (Complex.I*n) + +lemma sqrt3_pos : 0 < Real.sqrt 3 := Real.sqrt_pos.2 (by norm_num) +lemma sqrt3_sq : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) +lemma sqrt3_bounds : 3/2 ≤ Real.sqrt 3 ∧ Real.sqrt 3 ≤ 2 := by + have := sqrt3_sq + have := sqrt3_pos + constructor <;> nlinarith +lemma inner_re (n z : ℂ) : inner ℝ n z = (star n*z).re := by + simp [real_inner_eq_re_inner ℂ, RCLike.inner_apply, Complex.mul_re] + ring +lemma inner_im (n z : ℂ) : inner ℝ (Complex.I*n) z = (star n*z).im := by + simp [real_inner_eq_re_inner ℂ, RCLike.inner_apply, Complex.mul_re, Complex.mul_im] + ring +lemma mul_star_of_unit {n : ℂ} (hn : ‖n‖ = 1) : n * star n = 1 := by + simpa [Complex.normSq_eq_norm_sq, hn] using Complex.mul_conj n +lemma coordinate_apply (n z : ℂ) (s : ℝ) : + coordinate n s z = (star n*z).re / Real.sqrt 3 + s*(star n*z).im := by + change (1/Real.sqrt 3)*inner ℝ n z + s*inner ℝ (Complex.I*n) z = _ + rw [inner_re,inner_im] + ring +lemma expansion {n : ℂ} (hn : ‖n‖ = 1) (z : ℂ) : + coordinate n 1 z • axis n 1 + coordinate n (-1) z • axis n (-1) = z := by + have hs : Real.sqrt 3 ≠ 0 := ne_of_gt sqrt3_pos + have hz : n*(star n*z) = z := by rw [← mul_assoc,mul_star_of_unit hn,one_mul] + have he : coordinate n 1 z • axis n 1 + coordinate n (-1) z • axis n (-1) = + n*(star n*z) := by + apply Complex.ext <;> simp [axis,coordinate_apply,Complex.mul_re,Complex.mul_im] <;> field_simp <;> ring + exact he.trans hz +lemma axis_norm {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s^2 = 1) : + ‖axis n s‖ = 1 := by + have he : axis n s = (↑(Real.sqrt 3/2)+(↑s/2)*Complex.I)*n := by + apply Complex.ext <;> simp [axis,Complex.mul_re,Complex.mul_im]; ring + rw [he,norm_mul,hn,mul_one] + have hsq := sqrt3_sq + have h : Complex.normSq (↑(Real.sqrt 3/2)+(↑s/2)*Complex.I) = 1 := by + simp [Complex.normSq_apply,Complex.mul_re,Complex.mul_im] + nlinarith + have hn0 := norm_nonneg (↑(Real.sqrt 3/2)+(↑s/2)*Complex.I : ℂ) + rw [Complex.normSq_eq_norm_sq] at h + nlinarith +lemma inner_axis (n z : ℂ) (s : ℝ) : + inner ℝ (axis n s) z = Real.sqrt 3/2 * inner ℝ n z + s/2*inner ℝ (Complex.I*n) z := by + simp only [axis,inner_add_left,real_inner_smul_left] +lemma coordinate_norm_le {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : |s| ≤ 1) (z : ℂ) : + |coordinate n s z| ≤ 2 * ‖z‖ := by + have ha : |inner ℝ n z| ≤ ‖z‖ := by simpa [hn] using abs_real_inner_le_norm n z + have hb : |inner ℝ (Complex.I*n) z| ≤ ‖z‖ := by + simpa [norm_mul,hn] using abs_real_inner_le_norm (Complex.I*n) z + have hr : 1 / Real.sqrt 3 ≤ 1 := by rw [div_le_one sqrt3_pos]; linarith [sqrt3_bounds] + have hnon : 0 ≤ 1 / Real.sqrt 3 := (div_pos (by norm_num) sqrt3_pos).le + calc + |coordinate n s z| ≤ (1/Real.sqrt 3)*|inner ℝ n z| + |s| *|inner ℝ (Complex.I*n) z| := by + change |(1/Real.sqrt 3)*inner ℝ n z + s*inner ℝ (Complex.I*n) z| ≤ _ + simpa only [abs_mul,abs_of_nonneg hnon] using + abs_add_le ((1/Real.sqrt 3)*inner ℝ n z) (s*inner ℝ (Complex.I*n) z) + _ ≤ 1*‖z‖+1*‖z‖ := add_le_add (mul_le_mul hr ha (abs_nonneg _) (by norm_num)) + (mul_le_mul hs hb (abs_nonneg _) (by norm_num)) + _ = 2*‖z‖ := by ring + +/-- Closed sector between the literal two palette axes. -/ +def Good (n z : ℂ) : Prop := 0 ≤ coordinate n 1 z ∧ 0 ≤ coordinate n (-1) z + +lemma good_of_close {n z : ℂ} (hn : ‖n‖ = 1) (hclose : ‖z-n‖ ≤ 1/10) : Good n z := by + have ha : |inner ℝ n (z-n)| ≤ 1/10 := by + have h := abs_real_inner_le_norm n (z-n) + simp only [hn,one_mul] at h + exact h.trans hclose + have hb : |inner ℝ (Complex.I*n) (z-n)| ≤ 1/10 := by + have h := abs_real_inner_le_norm (Complex.I*n) (z-n) + simp only [norm_mul,Complex.norm_I,hn,one_mul] at h + exact h.trans hclose + have hin : inner ℝ n n = 1 := by simp [hn] + have hip : inner ℝ (Complex.I*n) n = 0 := by + rw [inner_im,show star n*n = 1 by simpa [mul_comm] using mul_star_of_unit hn] + simp + simp only [inner_sub_right,hin,hip,sub_zero] at ha hb + have hab := (abs_le.mp ha).1 + have hbb := abs_le.mp hb + have hs := sqrt3_bounds + have ha' : 1/10 ≤ inner ℝ n z / Real.sqrt 3 := by + apply (le_div_iff₀ sqrt3_pos).2 + nlinarith + change 0 ≤ (1/Real.sqrt 3)*inner ℝ n z + 1*inner ℝ (Complex.I*n) z ∧ + 0 ≤ (1/Real.sqrt 3)*inner ℝ n z + (-1)*inner ℝ (Complex.I*n) z + have hei : (1/Real.sqrt 3)*inner ℝ n z = inner ℝ n z / Real.sqrt 3 := by ring + rw [hei] + constructor <;> nlinarith + +lemma inner_quarter_self {n : ℂ} (hn : ‖n‖ = 1) : inner ℝ (Complex.I*n) n = 0 := by + rw [inner_im,show star n*n = 1 by simpa [mul_comm] using mul_star_of_unit hn] + simp +lemma axes_inner {n : ℂ} (hn : ‖n‖ = 1) : inner ℝ (axis n 1) (axis n (-1)) = 1/2 := by + rw [inner_axis] + simp only [axis,inner_add_right,real_inner_smul_right] + have hnn : inner ℝ n n = 1 := by simp [hn] + have hnp : inner ℝ n (Complex.I*n) = 0 := by rw [real_inner_comm]; exact inner_quarter_self hn + have hpn := inner_quarter_self hn + have hpp : inner ℝ (Complex.I*n) (Complex.I*n) = 1 := by simp [hn] + rw [hnn,hnp,hpn,hpp] + nlinarith [sqrt3_sq] +lemma norm_le_coords {n : ℂ} (hn : ‖n‖ = 1) (z : ℂ) : + ‖z‖ ≤ |inner ℝ n z|+|inner ℝ (Complex.I*n) z| := by + have hnorm : ‖star n*z‖ = ‖z‖ := by simp [hn] + rw [inner_re,inner_im,← hnorm] + exact Complex.norm_le_abs_re_add_abs_im _ + +theorem cone_algebra {n : ℂ} (hn : ‖n‖ = 1) (z : ℂ) : + ‖z‖ ≤ 12*(inner ℝ n z + max 0 (-inner ℝ (axis n 1) z) + + max 0 (-inner ℝ (axis n (-1)) z)) := by + let a := inner ℝ n z + let b := inner ℝ (Complex.I*n) z + let u := max 0 (-inner ℝ (axis n 1) z) + let v := max 0 (-inner ℝ (axis n (-1)) z) + have hu0 : 0 ≤ u := le_max_left _ _ + have hv0 : 0 ≤ v := le_max_left _ _ + have hu : -(Real.sqrt 3/2*a+1/2*b) ≤ u := by simpa only [u,v,a,b,inner_axis] using le_max_right 0 (-inner ℝ (axis n 1) z) + have hv : -(Real.sqrt 3/2*a+(-1)/2*b) ≤ v := by simpa only [u,v,a,b,inner_axis] using le_max_right 0 (-inner ℝ (axis n (-1)) z) + have hs := sqrt3_bounds + have ha : |a| ≤ 2*(a+u+v) := by + by_cases h : 0 ≤ a + · rw [abs_of_nonneg h]; linarith + · rw [abs_of_neg (lt_of_not_ge h)] + have hmul := mul_le_mul_of_nonpos_right hs.1 (le_of_not_ge h) + nlinarith + have hb : |b| ≤ 2*(u+v)+2*|a| := by + have haa : Real.sqrt 3*a ≤ 2*|a| := + (mul_le_mul_of_nonneg_left (le_abs_self a) sqrt3_pos.le).trans + (mul_le_mul_of_nonneg_right hs.2 (abs_nonneg a)) + apply abs_le.2 + constructor <;> linarith + have hz := norm_le_coords hn z + change ‖z‖ ≤ 12*(a+u+v) + change ‖z‖ ≤ |a|+|b| at hz + have := neg_le_abs a + linarith + +/-- A finite fixed palette, all members genuinely on the unit circle. -/ +structure Palette where + labels : Finset ℂ + unit : ∀ n ∈ labels, ‖n‖ = 1 + cover : ∀ z : ℂ, ‖z‖ = 1 → ∃ n ∈ labels, ‖z-n‖ < 1/2000 + +lemma exists_palette : Nonempty Palette := by + classical + let S := Metric.sphere (0 : ℂ) 1 + have hc : IsCompact S := isCompact_sphere 0 1 + obtain ⟨t,hts,htfin,ht⟩ := hc.elim_finite_subcover_image (fun n (_ : n ∈ S) => Metric.isOpen_ball (x := n) (ε := (1/2000:ℝ))) (by + intro z hz + exact Set.mem_iUnion₂.2 ⟨z,hz,by simp⟩) + refine ⟨⟨htfin.toFinset,?_,?_⟩⟩ + · intro n hn + simpa [S,Metric.mem_sphere,dist_zero_right] using hts (htfin.mem_toFinset.mp hn) + · intro z hz + have hzS : z ∈ S := by simpa [S,Metric.mem_sphere,dist_zero_right] using hz + obtain ⟨n,hn,hzn⟩ := Set.mem_iUnion₂.mp (ht hzS) + exact ⟨n,htfin.mem_toFinset.mpr hn,by simpa [Metric.mem_ball,dist_eq_norm] using hzn⟩ + +def fixedPalette : Palette := Classical.choice exists_palette + +def quantize (z : ℂ) (hz : ‖z‖ = 1) : {n : ℂ // n ∈ fixedPalette.labels} := + ⟨Classical.choose (fixedPalette.cover z hz), (Classical.choose_spec (fixedPalette.cover z hz)).1⟩ +lemma quantize_close (z : ℂ) (hz : ‖z‖ = 1) : ‖z-(quantize z hz : ℂ)‖ < 1/2000 := + (Classical.choose_spec (fixedPalette.cover z hz)).2 + +end ConeCoordinates + +namespace ActualMarkTrees +open DyadicHats IntrinsicMarks Finset + +def tree {N : ℕ} (v : Grid N → ℂ) : ℕ → ℝ → Grid N → Tree (Grid N) ℂ + | 0,b,p => .leaf (b • v p) + | k+1,b,p => .branch (fun q => tree v k (b*step p q) q) + +lemma vector_tree {N : ℕ} (v : Grid N → ℂ) (k : ℕ) (b : ℝ) (p : Grid N) : + vector (tree v k b p) = b • ∑ q : Grid N, coeff N k p q • v q := by + induction k generalizing b p with + | zero => simp [tree,vector,coeff] + | succ k ih => + simp only [tree,vector,ih,coeff,smul_sum,sum_smul,smul_smul] + rw [Finset.sum_comm] + apply sum_congr rfl + intro q hq + apply sum_congr rfl + intro a ha + congr 1 + ring + +lemma terminalMass_tree {N : ℕ} (v : Grid N → ℂ) (k : ℕ) {b : ℝ} (hb : 0 ≤ b) (p : Grid N) : + terminalMass (tree v k b p) = b * ∑ q : Grid N, coeff N k p q * ‖v q‖ := by + induction k generalizing b p with + | zero => simp [tree,terminalMass,coeff,Real.norm_eq_abs,abs_of_nonneg hb] + | succ k ih => + simp only [tree,terminalMass] + simp_rw [ih (mul_nonneg hb (step_nonneg _ _)),coeff,mul_sum,sum_mul] + rw [Finset.sum_comm] + apply sum_congr rfl + intro q hq + rw [mul_sum] + apply sum_congr rfl + intro a ha + ring + +lemma sum_terminalMass {N : ℕ} (v : Grid N → ℂ) (k : ℕ) : + (∑ p : Grid N, terminalMass (tree v k 1 p)) = ∑ q : Grid N, ‖v q‖ := by + simp_rw [terminalMass_tree v k (by norm_num : (0:ℝ) ≤ 1),one_mul] + rw [Finset.sum_comm] + simp_rw [← sum_mul,coeff_column,one_mul] + +lemma vector_actual {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (b : ℝ) (p : Grid N) : + vector (tree (fun q : Grid N => vectorMass h r q) k b p) = + b • vectorMass h (scale r k) p := by + rw [vector_tree,← vectorMass_coeff hr hR hN hh hs] + +/-- The actual finite dyadic vector forest satisfies the intrinsic mark budget. +The roots, terminal masses and every intermediate vector are their true hat +integrals; no abstract mark budget is supplied as a hypothesis. -/ +theorem mark_budget {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) (k : ℕ) + {δ : ℝ} (hδ : 0 < δ) : + (∑ p : Grid N, costWithRoot (1:ℂ) δ + (tree (fun q : Grid N => vectorMass h r q) k 1 p)) ≤ + (1+2/δ^2)*(∫ y, ‖h y‖) := by + calc + _ ≤ ∑ p : Grid N, (1+2/δ^2)*terminalMass + (tree (fun q : Grid N => vectorMass h r q) k 1 p) := + sum_le_sum (fun _ _ => costWithRoot_le (by simp) hδ _) + _ = (1+2/δ^2)*(∑ q : Grid N, scalarMass h r q) := by + rw [← mul_sum,sum_terminalMass] + rfl + _ ≤ _ := mul_le_mul_of_nonneg_left (sum_scalarMass_grid_le hh r) (by positivity) + +end ActualMarkTrees + +namespace ScalarCancellation +variable {α ι : Type*} [MeasurableSpace α] {μ : Measure α} [Fintype ι] +lemma roots_nonneg_of_mass (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) + (hm : 0 ≤ ∫ x, refined w f k q x ∂μ) : ∀ x, 0 ≤ roots μ w f k q x := by + cases k with + | zero => exact (root_spec (hf q)).2.2.2.2.1 hm + | succ k => + have hi := integrable_finsetSum Finset.univ + (fun s _ => (roots_integrable w hf k s).const_mul (w k q s)) + have hs := root_spec hi + have he := roots_mass w hf (k+1) q + change (∫ x, root μ _ x ∂μ) = _ at he + rw [hs.2.1] at he + exact hs.2.2.2.2.1 (by rw [he]; exact hm) +end ScalarCancellation + +namespace ConeScalar +open ConeCoordinates DyadicHats IntrinsicMarks + +lemma scalar_integrable {h : ℂ → ℂ} (hh : Integrable h) (c : ℂ →L[ℝ] ℝ) : + Integrable (fun x => c (h x)) := c.integrable_comp hh +lemma scalar_support {h : ℂ → ℂ} {R : ℝ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + (c : ℂ →L[ℝ] ℝ) : ∀ y, c (h y) ≠ 0 → ‖y‖ ≤ R := by + intro y hy + exact hs y (fun h => hy (by simp [h])) +lemma scalar_mass {h : ℂ → ℂ} (hh : Integrable h) (c : ℂ →L[ℝ] ℝ) (r : ℝ) (q : ℤ × ℤ) : + (∫ y, hat r q y*c (h y)) = c (vectorMass h r q) := by + have he := c.integral_comp_comm (integrable_hat_smul hh r q) + simpa only [map_smul,smul_eq_mul,vectorMass] using he + +lemma coordinate_mass_nonneg {n v : ℂ} + (hg : Good n (direction 1 v)) {s : ℝ} (hs : s = 1 ∨ s = -1) : + 0 ≤ coordinate n s v := by + have he := congrArg (coordinate n s) (mass_direction (1:ℂ) v) + rw [map_smul,smul_eq_mul] at he + rw [← he] + exact mul_nonneg (norm_nonneg _) (hs.elim (fun h => h ▸ hg.1) (fun h => h ▸ hg.2)) + +lemma good_root_nonneg {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) {n : ℂ} + (hg : Good n (direction 1 (vectorMass h (scale r k) q))) {s : ℝ} + (hs : s = 1 ∨ s = -1) (y : ℂ) : + 0 ≤ densityRoot N r (fun x => coordinate n s (h x)) k q y := by + apply ScalarCancellation.roots_nonneg_of_mass (weights N) + (pieces_integrable (scalar_integrable hh _) r) k q _ y + simp_rw [refined_eq_density hr hR hN (scalar_support hsupp _),scalar_mass hh] + exact coordinate_mass_nonneg hg hs + +lemma root_mass_norm {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) + {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s^2 = 1) : + (∫ y, ‖densityRoot N r (fun x => coordinate n s (h x)) k q y • axis n s‖) = + |coordinate n s (vectorMass h (scale r k) q)| := by + simp only [norm_smul,axis_norm hn hs,Real.norm_eq_abs,mul_one] + rw [densityRoot_abs_mass hr hR hN (scalar_integrable hh _) (scalar_support hsupp _),scalar_mass hh] + +lemma root_vector_integrable {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) + (r : ℝ) (k : ℕ) (q : Grid N) (n : ℂ) (s : ℝ) : + Integrable (fun y => densityRoot N r (fun x => coordinate n s (h x)) k q y • axis n s) := + (densityRoot_integrable (scalar_integrable hh _) r k q).smul_const _ + +lemma root_bound {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hsupp : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) + {n : ℂ} (hn : ‖n‖ = 1) {s : ℝ} (hs : s^2 = 1) : + (∫ y, ‖densityRoot N r (fun x => coordinate n s (h x)) k q y • axis n s‖) ≤ + 2*scalarMass h (scale r k) q := by + rw [root_mass_norm hr hR hN hh hsupp k q hn hs] + apply coordinate_norm_le hn + exact (abs_le_one_iff_mul_self_le_one).mpr (by nlinarith) + +lemma pair_cone {n : ℂ} (hn : ‖n‖ = 1) {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + {s : ℝ} (hs : s = 1 ∨ s = -1) : + (1/2:ℝ)*‖a • axis n 1+b • axis n (-1)‖ ≤ inner ℝ (axis n s) + (a • axis n 1+b • axis n (-1)) := by + have hnorm : ‖a • axis n 1+b • axis n (-1)‖ ≤ a+b := by + convert norm_add_le (a • axis n 1) (b • axis n (-1)) using 1 + simp only [norm_smul,Real.norm_eq_abs,abs_of_nonneg ha,abs_of_nonneg hb, + axis_norm hn (by norm_num : (1:ℝ)^2=1),axis_norm hn (by norm_num : (-1:ℝ)^2=1),mul_one] + have hp : inner ℝ (axis n 1) (axis n 1) = 1 := by simp [axis_norm hn (by norm_num : (1:ℝ)^2=1)] + have hm : inner ℝ (axis n (-1)) (axis n (-1)) = 1 := by simp [axis_norm hn (by norm_num : (-1:ℝ)^2=1)] + have hpm := axes_inner hn + have hmp : inner ℝ (axis n (-1)) (axis n 1) = 1/2 := by rw [real_inner_comm]; exact hpm + rcases hs with rfl | rfl <;> simp only [inner_add_right,real_inner_smul_right,hp,hm,hpm,hmp] <;> linarith + +end ConeScalar + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskGeometry1.lean b/lean/OAI/Analysis/SignedDisk/DiskGeometry1.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d996a64fe0d8a449d8a5454c8b5ce381e5f22fd --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskGeometry1.lean @@ -0,0 +1,498 @@ +import OAI.Analysis.SignedDisk.Model + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace + +noncomputable section + +namespace SignedDisk + +namespace DiskGeometry + +/-- Cancellation of translated monotone integrals on a finite interval. -/ +theorem monotone_increment_interval {G : ℝ → ℝ} (hG : Monotone G) + {C v : ℝ} (h0 : ∀ x, 0 ≤ G x) (hC : ∀ x, G x ≤ C) (hv : 0 ≤ v) + (a b : ℝ) : + (∫ l in a..b, (G (l + v) - G (l - v))) ≤ 2 * v * C := by + have hp : Monotone (fun l => G (l + v)) := hG.comp (by intro x y h; dsimp; linarith) + have hm : Monotone (fun l => G (l - v)) := hG.comp (fun _ _ h => sub_le_sub_right h v) + rw [intervalIntegral.integral_sub hp.intervalIntegrable hm.intervalIntegrable, + intervalIntegral.integral_comp_add_right, intervalIntegral.integral_comp_sub_right, + intervalIntegral.integral_interval_sub_interval_comm' hG.intervalIntegrable + hG.intervalIntegrable hG.intervalIntegrable] + have hn : 0 ≤ ∫ l in a - v..a + v, G l := + intervalIntegral.integral_nonneg_of_forall (by linarith) h0 + have hb : (∫ l in b - v..b + v, G l) ≤ 2 * v * C := by + calc + (∫ l in b - v..b + v, G l) ≤ ∫ l in b - v..b + v, C := + intervalIntegral.integral_mono (by linarith) hG.intervalIntegrable + intervalIntegrable_const hC + _ = 2 * v * C := by + rw [intervalIntegral.integral_const] + change ((b + v) - (b - v)) * C = _ + ring + linarith + +theorem monotone_increment_integrable {G : ℝ → ℝ} (hG : Monotone G) + {C v : ℝ} (h0 : ∀ x, 0 ≤ G x) (hC : ∀ x, G x ≤ C) (hv : 0 ≤ v) : + Integrable (fun l => G (l + v) - G (l - v)) ∧ + (∫ l, (G (l + v) - G (l - v))) ≤ 2 * v * C := by + have hp : Monotone (fun l => G (l + v)) := hG.comp (by intro x y h; dsimp; linarith) + have hm : Monotone (fun l => G (l - v)) := hG.comp (fun _ _ h => sub_le_sub_right h v) + have hn (l : ℝ) : 0 ≤ G (l + v) - G (l - v) := sub_nonneg.mpr (hG (by linarith)) + have hi (a b : ℝ) : IntervalIntegrable (fun l => G (l + v) - G (l - v)) volume a b := + hp.intervalIntegrable.sub hm.intervalIntegrable + have htop : Tendsto (fun n : ℕ => (n : ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have hbot : Tendsto (fun n : ℕ => -(n : ℝ)) atTop atBot := tendsto_neg_atTop_atBot.comp htop + have hint : Integrable (fun l => G (l + v) - G (l - v)) := by + apply integrable_of_intervalIntegral_norm_bounded (2 * v * C) + (fun n : ℕ => (hi (-(n : ℝ)) n).1) hbot htop + exact Eventually.of_forall (fun n => by + simp_rw [Real.norm_of_nonneg (hn _)] + exact monotone_increment_interval hG h0 hC hv _ _) + refine ⟨hint, ?_⟩ + exact le_of_tendsto (intervalIntegral_tendsto_integral hint hbot htop) + (Eventually.of_forall (fun n => monotone_increment_interval hG h0 hC hv (-(n : ℝ)) n)) + +/-- The permitted jump times have uniformly bounded length, independent of the +size of the original positive measure. Only its truncated distribution is used. -/ +theorem monotone_jump_window_measure {H : ℝ → ℝ} (hH : Monotone H) + (hH0 : ∀ l, 0 ≤ H l) {T U v : ℝ} (hT : 0 ≤ T) (hU : 0 < U) (hv : 0 ≤ v) : + volume {l | H (l - v) ≤ T ∧ U ≤ H (l + v) - H (l - v)} ≤ + ENNReal.ofReal (2 * v * (1 + T / U)) := by + let G : ℝ → ℝ := fun l => min (H l) (T + U) + have hG : Monotone G := hH.min monotone_const + have hG0 : ∀ l, 0 ≤ G l := fun l => le_min (hH0 l) (by positivity) + have hGC : ∀ l, G l ≤ T + U := fun l => min_le_right _ _ + obtain ⟨hi, hb⟩ := monotone_increment_integrable hG hG0 hGC hv + have hn (l : ℝ) : 0 ≤ G (l + v) - G (l - v) := sub_nonneg.mpr (hG (by linarith)) + have hmi : Integrable (fun l => (G (l + v) - G (l - v)) / U) := hi.div_const U + have hm := hmi.measure_le_integral + (Eventually.of_forall (fun l => div_nonneg (hn l) hU.le)) + (s := {l | H (l - v) ≤ T ∧ U ≤ H (l + v) - H (l - v)}) (by + intro l hl + rw [le_div_iff₀ hU, one_mul] + have hd : G (l - v) = H (l - v) := min_eq_left (by linarith [hl.1]) + rw [hd] + change U ≤ min (H (l + v)) (T + U) - H (l - v) + rw [le_sub_iff_add_le, le_min_iff] + exact ⟨by linarith [hl.2], by linarith [hl.1]⟩) + calc + volume {l | H (l - v) ≤ T ∧ U ≤ H (l + v) - H (l - v)} ≤ + ENNReal.ofReal (∫ l, (G (l + v) - G (l - v)) / U) := hm + _ ≤ ENNReal.ofReal (2 * v * (1 + T / U)) := by + apply ENNReal.ofReal_le_ofReal + rw [integral_div] + calc + (∫ l, G (l + v) - G (l - v)) / U ≤ (2 * v * (T + U)) / U := + div_le_div_of_nonneg_right hb hU.le + _ = 2 * v * (1 + T / U) := by field_simp; ring + +/-- A polar-coordinate area bound from uniform lengths of radial sections. -/ +theorem volume_le_radial_sections {s : Set ℂ} (hs : MeasurableSet s) + (z : ℂ) {R : ℝ} (hR : 0 ≤ R) {B : ℝ≥0∞} + (hbound : ∀ x ∈ s, ‖x - z‖ ≤ R) + (hsections : ∀ θ : ℝ, volume {r : ℝ | 0 < r ∧ + z + (r : ℂ) * ((Real.cos θ : ℂ) + (Real.sin θ : ℂ) * Complex.I) ∈ s} ≤ B) : + volume s ≤ ENNReal.ofReal (2 * Real.pi * R) * B := by + classical + let f : ℂ → ℝ≥0∞ := s.indicator 1 + have hf : Measurable f := measurable_const.indicator hs + have hfc : Measurable (fun p : ℝ × ℝ => f (z + Complex.polarCoord.symm p)) := by + apply hf.comp + simp only [Complex.polarCoord_symm_apply] + fun_prop + have hpolar : volume s = ∫⁻ p in polarCoord.target, + ENNReal.ofReal p.1 * f (z + Complex.polarCoord.symm p) := by + rw [← lintegral_indicator_one hs] + change (∫⁻ x, f x) = _ + rw [← lintegral_add_left_eq_self f z, + ← Complex.lintegral_comp_polarCoord_symm (fun x => f (z + x))] + rfl + have hinner (θ : ℝ) : (∫⁻ r in Ioi (0 : ℝ), f (z + Complex.polarCoord.symm (r, θ))) ≤ B := by + let A : Set ℝ := {r | 0 < r ∧ + z + (r : ℂ) * ((Real.cos θ : ℂ) + (Real.sin θ : ℂ) * Complex.I) ∈ s} + have hA : MeasurableSet A := measurableSet_Ioi.inter (hs.preimage (by fun_prop)) + calc + _ = ∫⁻ r, A.indicator 1 r := by + rw [← lintegral_indicator measurableSet_Ioi] + apply lintegral_congr + intro r + by_cases hr : 0 < r <;> + by_cases hx : z + (r : ℂ) * ((Real.cos θ : ℂ) + (Real.sin θ : ℂ) * Complex.I) ∈ s <;> + simp only [f, A, Complex.polarCoord_symm_apply, Set.indicator_apply, + mem_Ioi, mem_ofPred_eq, Pi.one_apply, hr, hx, + and_true, and_false, ite_true, ite_false] + _ = volume A := lintegral_indicator_one hA + _ ≤ B := hsections θ + calc + volume s = ∫⁻ p in polarCoord.target, + ENNReal.ofReal p.1 * f (z + Complex.polarCoord.symm p) := hpolar + _ ≤ ∫⁻ p in polarCoord.target, + ENNReal.ofReal R * f (z + Complex.polarCoord.symm p) := by + apply setLIntegral_mono' polarCoord.open_target.measurableSet + intro p hp + by_cases hx : z + Complex.polarCoord.symm p ∈ s + · gcongr + have hn := hbound _ hx + rw [add_sub_cancel_left, Complex.norm_polarCoord_symm, abs_of_pos hp.1] at hn + exact hn + · simp only [f, indicator_of_notMem hx, mul_zero, le_refl] + _ = ENNReal.ofReal R * ∫⁻ θ in Ioo (-Real.pi) Real.pi, + ∫⁻ r in Ioi (0 : ℝ), f (z + Complex.polarCoord.symm (r, θ)) := by + rw [lintegral_const_mul _ hfc] + congr 1 + exact setLIntegral_prod_symm _ hfc.aemeasurable + _ ≤ ENNReal.ofReal R * ∫⁻ θ in Ioo (-Real.pi) Real.pi, B := by + gcongr with θ + exact hinner θ + _ = ENNReal.ofReal (2 * Real.pi * R) * B := by + rw [lintegral_const, Measure.restrict_apply_univ, Real.volume_Ioo] + rw [show Real.pi - -Real.pi = 2 * Real.pi by ring] + rw [mul_comm (2 * Real.pi) R, ENNReal.ofReal_mul hR] + ac_rfl + +/-- Mass in the increasing family of tangent disks, away from its tangency cap. -/ +def tangentMass (S : Measure ℂ) (ρ : ℝ) (z θ : ℂ) (L : ℝ) : ℝ := + (S ({y : ℂ | ρ ≤ ‖y - z‖} ∩ Metric.ball (z + L • θ) L)).toReal + +theorem tangentMass_nonneg (S : Measure ℂ) (ρ : ℝ) (z θ : ℂ) (L : ℝ) : + 0 ≤ tangentMass S ρ z θ L := ENNReal.toReal_nonneg + +theorem tangentMass_mono (S : Measure ℂ) [IsFiniteMeasure S] (ρ : ℝ) + (z θ : ℂ) (hθ : ‖θ‖ = 1) : Monotone (tangentMass S ρ z θ) := by + intro L L' hLL' + by_cases hL : 0 < L + · apply ENNReal.toReal_mono (measure_ne_top S _) + exact measure_mono (inter_subset_inter_right _ (tangent_ball_mono hθ hL hLL')) + · have hball : Metric.ball (z + L • θ) L = ∅ := Metric.ball_eq_empty.mpr (le_of_not_gt hL) + simp only [tangentMass, hball, inter_empty, measure_empty, ENNReal.toReal_zero] + exact ENNReal.toReal_nonneg + +theorem measurable_tangentMass (S : Measure ℂ) [IsFiniteMeasure S] (ρ : ℝ) + {α : Type*} [MeasurableSpace α] {z θ : α → ℂ} {L : α → ℝ} + (hz : Measurable z) (hθ : Measurable θ) (hL : Measurable L) : + Measurable (fun a => tangentMass S ρ (z a) (θ a) (L a)) := by + have hm : MeasurableSet {p : α × ℂ | ρ ≤ ‖p.2 - z p.1‖ ∧ + dist p.2 (z p.1 + L p.1 • θ p.1) < L p.1} := by + exact (measurableSet_le measurable_const ((measurable_snd.sub (hz.comp measurable_fst)).norm)).inter + (measurableSet_lt (measurable_snd.dist ((hz.comp measurable_fst).add + ((hL.comp measurable_fst).smul (hθ.comp measurable_fst)))) (hL.comp measurable_fst)) + exact (measurable_measure_prodMk_left (ν := S) hm).ennreal_toReal + +/-- The measurable condition whose planar cost is bounded by the ray-length estimate. -/ +def rayCondition (S : Measure ℂ) (ρ T U v : ℝ) (x z : ℂ) : Prop := + 1 / 2 ≤ ‖x - z‖ ∧ ‖x - z‖ ≤ 3 ∧ + tangentMass S ρ z (‖x - z‖⁻¹ • (x - z)) (‖x - z‖ - v) ≤ T ∧ + U ≤ tangentMass S ρ z (‖x - z‖⁻¹ • (x - z)) (‖x - z‖ + v) - + tangentMass S ρ z (‖x - z‖⁻¹ • (x - z)) (‖x - z‖ - v) + +theorem measurableSet_rayCondition (S : Measure ℂ) [IsFiniteMeasure S] + (ρ T U v : ℝ) : MeasurableSet {p : ℂ × ℂ | rayCondition S ρ T U v p.1 p.2} := by + have hn : Measurable (fun p : ℂ × ℂ => ‖p.1 - p.2‖) := by fun_prop + have hdir : Measurable (fun p : ℂ × ℂ => ‖p.1 - p.2‖⁻¹ • (p.1 - p.2)) := by fun_prop + have hm := measurable_tangentMass S ρ measurable_snd hdir (hn.sub_const v) + have hp := measurable_tangentMass S ρ measurable_snd hdir (hn.add_const v) + exact (measurableSet_le measurable_const hn).inter + ((measurableSet_le hn measurable_const).inter + ((measurableSet_le hm measurable_const).inter (measurableSet_le measurable_const (hp.sub hm)))) + +/-- Full two-dimensional ray-condition estimate, independent of the chosen radius. -/ +theorem volume_rayCondition (S : Measure ℂ) [IsFiniteMeasure S] (ρ : ℝ) + {T U v : ℝ} (hT : 0 ≤ T) (hU : 0 < U) (hv : 0 ≤ v) (z : ℂ) : + volume {x : ℂ | rayCondition S ρ T U v x z} ≤ + ENNReal.ofReal (6 * Real.pi) * ENNReal.ofReal (2 * v * (1 + T / U)) := by + have hs : MeasurableSet {x : ℂ | rayCondition S ρ T U v x z} := + (measurableSet_rayCondition S ρ T U v).preimage + (show Measurable (fun x : ℂ => (x, z)) by fun_prop) + have hbound : ∀ x ∈ {x : ℂ | rayCondition S ρ T U v x z}, ‖x - z‖ ≤ 3 := + fun _ h => h.2.1 + have hsections (a : ℝ) : volume {r : ℝ | 0 < r ∧ + z + (r : ℂ) * ((Real.cos a : ℂ) + (Real.sin a : ℂ) * Complex.I) ∈ + {x : ℂ | rayCondition S ρ T U v x z}} ≤ + ENNReal.ofReal (2 * v * (1 + T / U)) := by + let θ : ℂ := (Real.cos a : ℂ) + (Real.sin a : ℂ) * Complex.I + have hθ : ‖θ‖ = 1 := by + simpa only [θ, Complex.ofReal_cos, Complex.ofReal_sin] using Complex.norm_cos_add_sin_mul_I a + apply le_trans (measure_mono (t := {l : ℝ | tangentMass S ρ z θ (l - v) ≤ T ∧ + U ≤ tangentMass S ρ z θ (l + v) - tangentMass S ρ z θ (l - v)}) ?_) + (monotone_jump_window_measure (tangentMass_mono S ρ z θ hθ) + (tangentMass_nonneg S ρ z θ) hT hU hv) + rintro r ⟨hr, hx⟩ + have hnorm : ‖z + (r : ℂ) * θ - z‖ = r := by + rw [add_sub_cancel_left, norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hr, hθ, mul_one] + have hdir : ‖z + (r : ℂ) * θ - z‖⁻¹ • (z + (r : ℂ) * θ - z) = θ := by + rw [hnorm, add_sub_cancel_left, ← Complex.real_smul, smul_smul, inv_mul_cancel₀ hr.ne', one_smul] + change rayCondition S ρ T U v (z + (r : ℂ) * θ) z at hx + rw [rayCondition] at hx + rw [hdir, hnorm] at hx + exact hx.2.2 + simpa only [show (2 : ℝ) * Real.pi * 3 = 6 * Real.pi by ring] using + volume_le_radial_sections hs z (by norm_num : (0 : ℝ) ≤ 3) hbound hsections + +def thinShell (x : ℂ) (r δ : ℝ) : Set ℂ := {y | |‖y - x‖ - r| ≤ δ} + +theorem measurableSet_thinShell (x : ℂ) (r δ : ℝ) : MeasurableSet (thinShell x r δ) := by + exact measurableSet_le (by fun_prop) measurable_const + +theorem shell_center_bounds {x z : ℂ} {r δ : ℝ} (hr : r ∈ Icc (1 : ℝ) 2) + (hδ : δ ≤ 1 / 4) (hz : z ∈ thinShell x r δ) : + 1 / 2 ≤ ‖x - z‖ ∧ ‖x - z‖ ≤ 3 := by + change |‖z - x‖ - r| ≤ δ at hz + have hh := abs_le.mp hz + rw [norm_sub_rev z x] at hh + constructor <;> linarith [hr.1, hr.2] + +theorem shell_pair_close {x y z : ℂ} {r δ : ℝ} + (hy : y ∈ thinShell x r δ) (hz : z ∈ thinShell x r δ) : + |‖y - x‖ - ‖x - z‖| ≤ 2 * δ := by + change |‖y - x‖ - r| ≤ δ at hy + change |‖z - x‖ - r| ≤ δ at hz + have hy' := abs_le.mp hy + have hz' := abs_le.mp hz + rw [norm_sub_rev z x] at hz' + exact abs_le.mpr ⟨by linarith [hy'.1, hz'.2], by linarith [hy'.2, hz'.1]⟩ + +/-- Every distant point of the thin shell crosses the tangent disks in the short window. -/ +theorem shell_subset_tangent_difference {z θ : ℂ} (hθ : ‖θ‖ = 1) {l ρ δ : ℝ} + (hl : 1 / 2 ≤ l) (hl3 : l ≤ 3) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (hδ : 0 < δ) (hδρ : δ ≤ ρ ^ 2 / 1600) : + {y : ℂ | ρ ≤ ‖y - z‖ ∧ |‖y - (z + l • θ)‖ - l| ≤ 2 * δ} ⊆ + ({y : ℂ | ρ ≤ ‖y - z‖} ∩ + Metric.ball (z + (l + 200 * δ / ρ ^ 2) • θ) (l + 200 * δ / ρ ^ 2)) \ + ({y : ℂ | ρ ≤ ‖y - z‖} ∩ + Metric.ball (z + (l - 200 * δ / ρ ^ 2) • θ) (l - 200 * δ / ρ ^ 2)) := by + let v : ℝ := 200 * δ / ρ ^ 2 + have hr2 : 0 < ρ ^ 2 := sq_pos_of_pos hρ + have hvp : 0 < v := by dsimp [v]; positivity + have hvs : v ≤ 1 / 8 := by + dsimp [v] + apply (div_le_iff₀ hr2).2 + linarith + have hlm : 0 < l - v := by linarith + have hlp : 0 < l + v := by linarith + have h78 : 78 * δ / ρ ^ 2 < v := by + dsimp [v] + exact (div_lt_div_iff_of_pos_right hr2).2 (by linarith) + rintro y ⟨hsep, hclose⟩ + obtain ⟨ha, hw⟩ := shell_entry_window hθ hl hl3 hρ hρ1 hδ hδρ hsep (by + simpa only [dist_eq_norm] using hclose) + have ha0 : 0 < ⟪y - z, θ⟫ := lt_of_lt_of_le (by positivity) ha + have hentrylo : l - v < entryParameter z y θ := by linarith [(abs_le.mp hw).1] + have hentryhi : entryParameter z y θ < l + v := by linarith [(abs_le.mp hw).2] + refine ⟨⟨hsep, (mem_tangent_ball_iff_entry hθ hlp ha0).2 hentryhi⟩, ?_⟩ + rintro ⟨_, hm⟩ + have hm' := (mem_tangent_ball_iff_entry hθ hlm ha0).1 hm + linarith + +/-- The shell mass away from a cap is bounded by the one-dimensional tangent-mass jump. -/ +theorem shell_mass_le_jump (S : Measure ℂ) [IsFiniteMeasure S] + {x z : ℂ} {r ρ δ : ℝ} (hr : r ∈ Icc (1 : ℝ) 2) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (hδ : 0 < δ) (hδρ : δ ≤ ρ ^ 2 / 1600) (hz : z ∈ thinShell x r δ) : + (S (thinShell x r δ \ Metric.ball z ρ)).toReal ≤ + tangentMass S ρ z (‖x - z‖⁻¹ • (x - z)) (‖x - z‖ + 200 * δ / ρ ^ 2) - + tangentMass S ρ z (‖x - z‖⁻¹ • (x - z)) (‖x - z‖ - 200 * δ / ρ ^ 2) := by + let l : ℝ := ‖x - z‖ + let θ : ℂ := l⁻¹ • (x - z) + have hδquarter : δ ≤ 1 / 4 := by nlinarith + obtain ⟨hl, hl3⟩ := shell_center_bounds hr hδquarter hz + have hl0 : 0 < l := by dsimp [l]; linarith + have hθ : ‖θ‖ = 1 := by + dsimp only [θ] + rw [norm_smul, Real.norm_of_nonneg (inv_nonneg.mpr hl0.le)] + exact inv_mul_cancel₀ hl0.ne' + have hx : z + l • θ = x := by + dsimp only [θ] + rw [smul_smul, mul_inv_cancel₀ hl0.ne', one_smul] + abel + let A := {y : ℂ | ρ ≤ ‖y - z‖} ∩ + Metric.ball (z + (l - 200 * δ / ρ ^ 2) • θ) (l - 200 * δ / ρ ^ 2) + let B := {y : ℂ | ρ ≤ ‖y - z‖} ∩ + Metric.ball (z + (l + 200 * δ / ρ ^ 2) • θ) (l + 200 * δ / ρ ^ 2) + have hAm : MeasurableSet A := (measurableSet_le measurable_const (by fun_prop)).inter + Metric.isOpen_ball.measurableSet + have hsub : thinShell x r δ \ Metric.ball z ρ ⊆ B \ A := by + apply subset_trans _ (shell_subset_tangent_difference hθ hl hl3 hρ hρ1 hδ hδρ) + rintro y ⟨hy, hyz⟩ + exact ⟨le_of_not_gt (by simpa only [Metric.mem_ball, dist_eq_norm] using hyz), + by rw [hx]; exact shell_pair_close hy hz⟩ + have hAB : A ⊆ B := by + apply inter_subset_inter_right + apply tangent_ball_mono hθ + · have : 200 * δ / ρ ^ 2 ≤ 1 / 8 := by + apply (div_le_iff₀ (sq_pos_of_pos hρ)).2 + linarith + change 0 < l - 200 * δ / ρ ^ 2 + linarith + · have : 0 ≤ 200 * δ / ρ ^ 2 := by positivity + linarith + have hmass := ENNReal.toReal_mono (measure_ne_top S (B \ A)) (measure_mono hsub) + rw [measure_sdiff hAB hAm.nullMeasurableSet (measure_ne_top S A), + ENNReal.toReal_sub_of_le (measure_mono hAB) (measure_ne_top S B)] at hmass + exact hmass + +/-- The earlier tangent-disk mass is controlled by the concentric interior mass. -/ +theorem earlier_mass_le_interior (S : Measure ℂ) [IsFiniteMeasure S] + {x z : ℂ} {r ρ δ : ℝ} (hr : r ∈ Icc (1 : ℝ) 2) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (hδ : 0 < δ) (hδρ : δ ≤ ρ ^ 2 / 1600) (hz : z ∈ thinShell x r δ) : + tangentMass S ρ z (‖x - z‖⁻¹ • (x - z)) (‖x - z‖ - 200 * δ / ρ ^ 2) ≤ + (S (Metric.ball x (r - δ))).toReal := by + let l : ℝ := ‖x - z‖ + let θ : ℂ := l⁻¹ • (x - z) + have hδquarter : δ ≤ 1 / 4 := by nlinarith + obtain ⟨hl, hl3⟩ := shell_center_bounds hr hδquarter hz + have hl0 : 0 < l := by dsimp [l]; linarith + have hθ : ‖θ‖ = 1 := by + dsimp only [θ] + rw [norm_smul, Real.norm_of_nonneg (inv_nonneg.mpr hl0.le)] + exact inv_mul_cancel₀ hl0.ne' + have hx : z + l • θ = x := by + dsimp only [θ] + rw [smul_smul, mul_inv_cancel₀ hl0.ne', one_smul] + abel + apply ENNReal.toReal_mono (measure_ne_top S _) + apply measure_mono + apply (earlier_tangent_disk_subset hθ hl hl3 hρ hρ1 hδ hδρ).trans + rw [hx] + apply Metric.ball_subset_ball + change |‖z - x‖ - r| ≤ δ at hz + have hh := (abs_le.mp hz).2 + rw [norm_sub_rev z x] at hh + change l - 2 * δ ≤ r - δ + dsimp [l] + linarith + +/-- Area of a strip with continuously moving interval fibers. -/ +theorem volume_interval_fibers (c : ℝ → ℝ) (hc : Continuous c) + (lo hi w : ℝ) : + volume {p : ℝ × ℝ | p.2 ∈ Icc lo hi ∧ + p.1 ∈ Icc (c p.2 - w) (c p.2 + w)} = + ENNReal.ofReal (hi - lo) * ENNReal.ofReal (2 * w) := by + have hs : MeasurableSet {p : ℝ × ℝ | p.2 ∈ Icc lo hi ∧ + p.1 ∈ Icc (c p.2 - w) (c p.2 + w)} := by + exact (measurableSet_Icc.preimage continuous_snd.measurable).inter + ((isClosed_le (hc.comp continuous_snd |>.sub continuous_const) continuous_fst).measurableSet.inter + (isClosed_le continuous_fst (hc.comp continuous_snd |>.add continuous_const)).measurableSet) + change (volume.prod volume) _ = _ + rw [Measure.prod_apply_symm hs] + have hf (y : ℝ) : + volume ((fun x : ℝ => (x, y)) ⁻¹' {p : ℝ × ℝ | p.2 ∈ Icc lo hi ∧ + p.1 ∈ Icc (c p.2 - w) (c p.2 + w)}) = + (Icc lo hi).indicator (fun _ => ENNReal.ofReal (2 * w)) y := by + by_cases hy : y ∈ Icc lo hi + · simp only [preimage_ofPred_eq, hy, true_and, indicator_of_mem hy] + change volume (Icc (c y - w) (c y + w)) = _ + rw [Real.volume_Icc] + congr 1 + ring + · simp only [preimage_ofPred_eq, hy, false_and, ofPred_false, measure_empty, indicator_of_notMem hy] + simp_rw [hf] + rw [lintegral_indicator measurableSet_Icc, lintegral_const, Measure.restrict_apply_univ, + Real.volume_Icc, mul_comm] + +/-- A nonvertical affine strip cut off in the second coordinate. -/ +theorem volume_affine_strip {a : ℝ} (ha : a ≠ 0) (b c d R w : ℝ) : + volume {p : ℝ × ℝ | |p.2 - d| ≤ R ∧ |a * p.1 + b * p.2 + c| ≤ w} = + ENNReal.ofReal (2 * R) * ENNReal.ofReal (2 * (w / |a|)) := by + have hs : {p : ℝ × ℝ | |p.2 - d| ≤ R ∧ |a * p.1 + b * p.2 + c| ≤ w} = + {p : ℝ × ℝ | p.2 ∈ Icc (d - R) (d + R) ∧ + p.1 ∈ Icc (-(b * p.2 + c) / a - w / |a|) + (-(b * p.2 + c) / a + w / |a|)} := by + ext p + simp only [mem_ofPred_eq, mem_Icc] + have heq : a * p.1 + b * p.2 + c = a * (p.1 - -(b * p.2 + c) / a) := by + field_simp + ring + rw [heq, abs_mul, ← le_div_iff₀' (abs_pos.mpr ha)] + simp only [abs_le] + constructor <;> rintro ⟨⟨h1, h2⟩, h3, h4⟩ <;> constructor <;> constructor <;> linarith + rw [hs] + rw [volume_interval_fibers (fun y => -(b * y + c) / a) (by fun_prop)] + congr 2 + ring + +/-- At least one coordinate sees half the Euclidean separation. -/ +theorem complex_coordinate_separation {z : ℂ} {ρ : ℝ} (hz : ρ ≤ ‖z‖) : + ρ / 2 ≤ |z.re| ∨ ρ / 2 ≤ |z.im| := by + by_contra h + push Not at h + have hnorm : ‖z‖ ≤ |z.re| + |z.im| := Complex.norm_le_abs_re_add_abs_im z + linarith + +/-- The centers of two separated points lying on an almost common circle form +an affine strip of small area. No selected radius occurs here. -/ +theorem volume_two_point_strip {y z : ℂ} {ρ δ : ℝ} (hρ : 0 < ρ) (hδ : 0 ≤ δ) + (hyz : ρ ≤ ‖y - z‖) : + volume {x : ℂ | ‖x - z‖ ≤ 3 ∧ |‖x - y‖ ^ 2 - ‖x - z‖ ^ 2| ≤ 13 * δ} ≤ + ENNReal.ofReal (156 * δ / ρ) := by + let a : ℝ := 2 * (z.re - y.re) + let b : ℝ := 2 * (z.im - y.im) + let c : ℝ := ‖y‖ ^ 2 - ‖z‖ ^ 2 + have halg (x : ℂ) : ‖x - y‖ ^ 2 - ‖x - z‖ ^ 2 = a * x.re + b * x.im + c := by + simp only [Complex.sq_norm, Complex.normSq_apply, Complex.sub_re, Complex.sub_im, a, b, c] + ring + have hsplit := complex_coordinate_separation hyz + have hmain (a b c d : ℝ) (ha : ρ ≤ |a|) : + volume {p : ℝ × ℝ | |p.2 - d| ≤ 3 ∧ |a * p.1 + b * p.2 + c| ≤ 13 * δ} ≤ + ENNReal.ofReal (156 * δ / ρ) := by + have hap : 0 < |a| := hρ.trans_le ha + rw [volume_affine_strip (abs_pos.mp hap)] + rw [← ENNReal.ofReal_mul (by norm_num)] + apply ENNReal.ofReal_le_ofReal + calc + (2 * 3) * (2 * (13 * δ / |a|)) = 156 * δ / |a| := by ring + _ ≤ 156 * δ / ρ := div_le_div_of_nonneg_left (by positivity) hρ ha + rcases hsplit with hre | him + · have ha : ρ ≤ |a| := by + dsimp [a] + rw [abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2), abs_sub_comm] + simpa only [Complex.sub_re] using (show ρ ≤ 2 * |(y - z).re| by linarith) + let s : Set (ℝ × ℝ) := {p | |p.2 - z.im| ≤ 3 ∧ |a * p.1 + b * p.2 + c| ≤ 13 * δ} + have hsub : {x : ℂ | ‖x - z‖ ≤ 3 ∧ |‖x - y‖ ^ 2 - ‖x - z‖ ^ 2| ≤ 13 * δ} ⊆ + Complex.measurableEquivRealProd ⁻¹' s := by + intro x hx + exact ⟨(Complex.abs_im_le_norm (x - z)).trans hx.1, by simpa [halg x] using hx.2⟩ + have hs : MeasurableSet s := by + exact (isClosed_le (show Continuous (fun p : ℝ × ℝ => |p.2 - z.im|) from by fun_prop) + continuous_const).measurableSet.inter + (isClosed_le (show Continuous (fun p : ℝ × ℝ => |a * p.1 + b * p.2 + c|) from by fun_prop) + continuous_const).measurableSet + calc + _ ≤ volume (Complex.measurableEquivRealProd ⁻¹' s) := measure_mono hsub + _ = volume s := Complex.volume_preserving_equiv_real_prod.measure_preimage hs.nullMeasurableSet + _ ≤ _ := hmain a b c z.im ha + · have hb : ρ ≤ |b| := by + dsimp [b] + rw [abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2), abs_sub_comm] + simpa only [Complex.sub_im] using (show ρ ≤ 2 * |(y - z).im| by linarith) + let s : Set (ℝ × ℝ) := {p | |p.2 - z.re| ≤ 3 ∧ |b * p.1 + a * p.2 + c| ≤ 13 * δ} + have hmp : MeasurePreserving (fun x : ℂ => (x.im, x.re)) := + Measure.measurePreserving_swap.comp Complex.volume_preserving_equiv_real_prod + have hsub : {x : ℂ | ‖x - z‖ ≤ 3 ∧ |‖x - y‖ ^ 2 - ‖x - z‖ ^ 2| ≤ 13 * δ} ⊆ + (fun x : ℂ => (x.im, x.re)) ⁻¹' s := by + intro x hx + refine ⟨(Complex.abs_re_le_norm (x - z)).trans hx.1, ?_⟩ + simpa only [halg x, add_comm (a * x.re) (b * x.im)] using hx.2 + have hs : MeasurableSet s := by + exact (isClosed_le (show Continuous (fun p : ℝ × ℝ => |p.2 - z.re|) from by fun_prop) + continuous_const).measurableSet.inter + (isClosed_le (show Continuous (fun p : ℝ × ℝ => |b * p.1 + a * p.2 + c|) from by fun_prop) + continuous_const).measurableSet + calc + _ ≤ volume ((fun x : ℂ => (x.im, x.re)) ⁻¹' s) := measure_mono hsub + _ = volume s := hmp.measure_preimage hs.nullMeasurableSet + _ ≤ _ := hmain b a c z.re hb + +end DiskGeometry + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskGeometry2.lean b/lean/OAI/Analysis/SignedDisk/DiskGeometry2.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb853d5190773ed03f5ec6517028a60e8ba88c23 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskGeometry2.lean @@ -0,0 +1,513 @@ +import OAI.Analysis.SignedDisk.DiskGeometry1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace + +noncomputable section + +namespace SignedDisk + +namespace DiskGeometry + +def pairCondition (ρ δ : ℝ) (x z y : ℂ) : Prop := + 1 / 2 ≤ ‖x - z‖ ∧ ‖x - z‖ ≤ 3 ∧ + |‖y - x‖ - ‖x - z‖| ≤ 2 * δ ∧ ρ ≤ ‖y - z‖ + +theorem measurableSet_pairCondition (ρ δ : ℝ) : + MeasurableSet {p : (ℂ × ℂ) × ℂ | pairCondition ρ δ p.1.1 p.1.2 p.2} := by + have hn : Measurable (fun p : (ℂ × ℂ) × ℂ => ‖p.1.1 - p.1.2‖) := by fun_prop + have hc : Measurable (fun p : (ℂ × ℂ) × ℂ => |‖p.2 - p.1.1‖ - ‖p.1.1 - p.1.2‖|) := by fun_prop + have hs : Measurable (fun p : (ℂ × ℂ) × ℂ => ‖p.2 - p.1.2‖) := by fun_prop + exact (measurableSet_le measurable_const hn).inter + ((measurableSet_le hn measurable_const).inter + ((measurableSet_le hc measurable_const).inter (measurableSet_le measurable_const hs))) + +theorem volume_pairCondition {ρ δ : ℝ} (hρ : 0 < ρ) + (hδ : 0 ≤ δ) (hδquarter : δ ≤ 1 / 4) (z y : ℂ) : + volume {x : ℂ | pairCondition ρ δ x z y} ≤ ENNReal.ofReal (156 * δ / ρ) := by + by_cases hsep : ρ ≤ ‖y - z‖ + · apply le_trans (measure_mono (t := {x : ℂ | ‖x - z‖ ≤ 3 ∧ + |‖x - y‖ ^ 2 - ‖x - z‖ ^ 2| ≤ 13 * δ}) ?_) + (volume_two_point_strip hρ hδ hsep) + intro x hx + obtain ⟨hl, hl3, hc, _⟩ := hx + refine ⟨hl3, ?_⟩ + rw [norm_sub_rev x y] + exact shell_square_error (norm_nonneg _) hl3 hδ hδquarter (norm_nonneg _) hc + · have he : {x : ℂ | pairCondition ρ δ x z y} = ∅ := by + ext x + simp only [mem_ofPred_eq, mem_empty_iff_false, iff_false] + exact fun h => hsep h.2.2.2 + rw [he, measure_empty] + exact bot_le + +def pairMass (ν : Measure ℂ) (ρ δ : ℝ) (x z : ℂ) : ℝ≥0∞ := + ν {y : ℂ | pairCondition ρ δ x z y} + +theorem measurable_pairMass (ν : Measure ℂ) [IsFiniteMeasure ν] (ρ δ : ℝ) : + Measurable (fun p : ℂ × ℂ => pairMass ν ρ δ p.1 p.2) := + measurable_measure_prodMk_left (measurableSet_pairCondition ρ δ) + +def rayIndicator (S : Measure ℂ) (ρ T U v : ℝ) (x z : ℂ) : ℝ≥0∞ := + {p : ℂ × ℂ | rayCondition S ρ T U v p.1 p.2}.indicator 1 (x, z) + +theorem measurable_rayIndicator (S : Measure ℂ) [IsFiniteMeasure S] (ρ T U v : ℝ) : + Measurable (fun p : ℂ × ℂ => rayIndicator S ρ T U v p.1 p.2) := + measurable_const.indicator (measurableSet_rayCondition S ρ T U v) + +/-- The first contribution to the Borel majorant is controlled by the two-point strip. -/ +theorem lintegral_pairMass (ν : Measure ℂ) [IsFiniteMeasure ν] {ρ δ : ℝ} + (hρ : 0 < ρ) (hδ : 0 ≤ δ) (hδquarter : δ ≤ 1 / 4) : + (∫⁻ x : ℂ, ∫⁻ z : ℂ, pairMass ν ρ δ x z ∂ν) ≤ + ENNReal.ofReal (156 * δ / ρ) * ν univ * ν univ := by + rw [lintegral_lintegral_swap (measurable_pairMass ν ρ δ).aemeasurable] + apply le_trans (lintegral_mono (fun z => ?_)) + (by rw [lintegral_const]) + let A : Set (ℂ × ℂ) := {p | pairCondition ρ δ p.1 z p.2} + have hA : MeasurableSet A := (measurableSet_pairCondition ρ δ).preimage + (show Measurable (fun p : ℂ × ℂ => ((p.1, z), p.2)) by fun_prop) + have he (x : ℂ) : pairMass ν ρ δ x z = ∫⁻ y : ℂ, A.indicator 1 (x, y) ∂ν := by + rw [show (fun y : ℂ => A.indicator 1 (x, y)) = + {y : ℂ | pairCondition ρ δ x z y}.indicator 1 by + ext y; exact (indicator_comp_right (fun y : ℂ => (x, y))).symm] + exact (lintegral_indicator_one ((measurableSet_pairCondition ρ δ).preimage + (show Measurable (fun y : ℂ => ((x, z), y)) by fun_prop))).symm + simp_rw [he] + rw [lintegral_lintegral_swap (f := fun x y : ℂ => A.indicator 1 (x, y)) + (measurable_const.indicator hA).aemeasurable] + calc + _ ≤ ∫⁻ y : ℂ, ENNReal.ofReal (156 * δ / ρ) ∂ν := by + apply lintegral_mono + intro y + have hei : (fun x : ℂ => A.indicator (1 : ℂ × ℂ → ℝ≥0∞) (x, y)) = + {x : ℂ | pairCondition ρ δ x z y}.indicator 1 := by + ext x + exact (indicator_comp_right (fun x : ℂ => (x, y))).symm + dsimp only + rw [hei] + have hsm : MeasurableSet {x : ℂ | pairCondition ρ δ x z y} := + (measurableSet_pairCondition ρ δ).preimage + (show Measurable (fun x : ℂ => ((x, z), y)) by fun_prop) + exact (lintegral_indicator_one hsm).le.trans (volume_pairCondition hρ hδ hδquarter z y) + _ = _ := lintegral_const _ + +/-- The second contribution is controlled by monotone ray jumps and polar coordinates. -/ +theorem lintegral_rayIndicator (ν S : Measure ℂ) [IsFiniteMeasure ν] [IsFiniteMeasure S] + (ρ : ℝ) {T U v : ℝ} (hT : 0 ≤ T) (hU : 0 < U) (hv : 0 ≤ v) : + (∫⁻ x : ℂ, ∫⁻ z : ℂ, rayIndicator S ρ T U v x z ∂ν) ≤ + (ENNReal.ofReal (6 * Real.pi) * ENNReal.ofReal (2 * v * (1 + T / U))) * ν univ := by + rw [lintegral_lintegral_swap (measurable_rayIndicator S ρ T U v).aemeasurable] + calc + _ ≤ ∫⁻ _z : ℂ, + ENNReal.ofReal (6 * Real.pi) * ENNReal.ofReal (2 * v * (1 + T / U)) ∂ν := by + apply lintegral_mono + intro z + have he : (fun x : ℂ => rayIndicator S ρ T U v x z) = + {x : ℂ | rayCondition S ρ T U v x z}.indicator 1 := by + ext x + exact (indicator_comp_right (fun x : ℂ => (x, z))).symm + dsimp only + rw [he] + have hsm : MeasurableSet {x : ℂ | rayCondition S ρ T U v x z} := + (measurableSet_rayCondition S ρ T U v).preimage + (show Measurable (fun x : ℂ => (x, z)) by fun_prop) + exact (lintegral_indicator_one hsm).le.trans (volume_rayCondition S ρ hT hU hv z) + _ = _ := lintegral_const _ + +/-- Failure of every cap forces the majorant bracket to be at least one. -/ +theorem bad_cap_bracket (S ν : Measure ℂ) [IsFiniteMeasure S] [IsFiniteMeasure ν] + {x z : ℂ} {r ρ δ T U : ℝ} (hr : r ∈ Icc (1 : ℝ) 2) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hδ : 0 < δ) (hδρ : δ ≤ ρ ^ 2 / 1600) + (hT : 0 ≤ T) (hU : 0 < U) (hz : z ∈ thinShell x r δ) + (hi : S (Metric.ball x (r - δ)) ≤ ENNReal.ofReal T) + (hb : ENNReal.ofReal (2 * U) < (S + ν) (thinShell x r δ \ Metric.ball z ρ)) : + 1 ≤ (ENNReal.ofReal U)⁻¹ * pairMass ν ρ δ x z + + rayIndicator S ρ T U (200 * δ / ρ ^ 2) x z := by + have hδquarter : δ ≤ 1 / 4 := by nlinarith + obtain ⟨hl, hl3⟩ := shell_center_bounds hr hδquarter hz + have hcases : ENNReal.ofReal U ≤ ν (thinShell x r δ \ Metric.ball z ρ) ∨ + ENNReal.ofReal U ≤ S (thinShell x r δ \ Metric.ball z ρ) := by + by_contra h + push Not at h + have he2 : ENNReal.ofReal (2 * U) = ENNReal.ofReal U + ENNReal.ofReal U := by + rw [two_mul, ENNReal.ofReal_add hU.le hU.le] + have hm : (S + ν) (thinShell x r δ \ Metric.ball z ρ) ≤ ENNReal.ofReal (2 * U) := by + rw [Measure.add_apply, he2] + exact add_le_add h.2.le h.1.le + exact (not_le_of_gt hb) hm + rcases hcases with hν | hS + · have hp : ENNReal.ofReal U ≤ pairMass ν ρ δ x z := by + apply hν.trans (measure_mono ?_) + rintro y ⟨hy, hsep⟩ + exact ⟨hl, hl3, shell_pair_close hy hz, + le_of_not_gt (by simpa only [Metric.mem_ball, dist_eq_norm] using hsep)⟩ + calc + 1 = (ENNReal.ofReal U)⁻¹ * ENNReal.ofReal U := + (ENNReal.inv_mul_cancel (ENNReal.ofReal_pos.mpr hU).ne' ENNReal.ofReal_ne_top).symm + _ ≤ (ENNReal.ofReal U)⁻¹ * pairMass ν ρ δ x z := mul_le_mul_right hp _ + _ ≤ _ := le_self_add + · have hi' : (S (Metric.ball x (r - δ))).toReal ≤ T := by + have := ENNReal.toReal_mono ENNReal.ofReal_ne_top hi + simpa only [ENNReal.toReal_ofReal hT] using this + have hS' : U ≤ (S (thinShell x r δ \ Metric.ball z ρ)).toReal := + (ENNReal.ofReal_le_iff_le_toReal (measure_ne_top S _)).1 hS + have hc : rayCondition S ρ T U (200 * δ / ρ ^ 2) x z := + ⟨hl, hl3, (earlier_mass_le_interior S hr hρ hρ1 hδ hδρ hz).trans hi', + hS'.trans (shell_mass_le_jump S hr hρ hρ1 hδ hδρ hz)⟩ + have hone : rayIndicator S ρ T U (200 * δ / ρ ^ 2) x z = 1 := + indicator_of_mem hc 1 + rw [hone] + exact le_add_self + +/-- A radius-independent Borel majorant combining separated shell pairs and ray jumps. -/ +def shellMajorant (ν S : Measure ℂ) (ρ δ T U : ℝ) (x : ℂ) : ℝ≥0∞ := + (ENNReal.ofReal U)⁻¹ ^ 2 * (∫⁻ z, pairMass ν ρ δ x z ∂ν) + + (ENNReal.ofReal U)⁻¹ * (∫⁻ z, rayIndicator S ρ T U (200 * δ / ρ ^ 2) x z ∂ν) + +theorem measurable_shellMajorant (ν S : Measure ℂ) [IsFiniteMeasure ν] [IsFiniteMeasure S] + (ρ δ T U : ℝ) : Measurable (shellMajorant ν S ρ δ T U) := by + exact ((measurable_pairMass ν ρ δ).lintegral_prod_right.const_mul _).add + ((measurable_rayIndicator S ρ T U (200 * δ / ρ ^ 2)).lintegral_prod_right.const_mul _) + +theorem shellMajorant_eq_bracket (ν S : Measure ℂ) [IsFiniteMeasure ν] [IsFiniteMeasure S] + (ρ δ T U : ℝ) (x : ℂ) : + shellMajorant ν S ρ δ T U x = (ENNReal.ofReal U)⁻¹ * ∫⁻ z, + ((ENNReal.ofReal U)⁻¹ * pairMass ν ρ δ x z + + rayIndicator S ρ T U (200 * δ / ρ ^ 2) x z) ∂ν := by + have hp : Measurable (fun z : ℂ => pairMass ν ρ δ x z) := + (measurable_pairMass ν ρ δ).comp (measurable_const.prodMk measurable_id) + rw [lintegral_add_left (hp.const_mul _), lintegral_const_mul _ hp] + unfold shellMajorant + ring + +/-- The majorant is integrable uniformly over all radii. -/ +theorem lintegral_shellMajorant (ν S : Measure ℂ) [IsFiniteMeasure ν] [IsFiniteMeasure S] + {ρ δ T U : ℝ} (hρ : 0 < ρ) (hδ : 0 ≤ δ) (hδquarter : δ ≤ 1 / 4) + (hT : 0 ≤ T) (hU : 0 < U) : + (∫⁻ x, shellMajorant ν S ρ δ T U x) ≤ + (ENNReal.ofReal U)⁻¹ ^ 2 * (ENNReal.ofReal (156 * δ / ρ) * ν univ * ν univ) + + (ENNReal.ofReal U)⁻¹ * ((ENNReal.ofReal (6 * Real.pi) * + ENNReal.ofReal (2 * (200 * δ / ρ ^ 2) * (1 + T / U))) * ν univ) := by + have hp : Measurable (fun x : ℂ => ∫⁻ z, pairMass ν ρ δ x z ∂ν) := + (measurable_pairMass ν ρ δ).lintegral_prod_right + have hr : Measurable (fun x : ℂ => ∫⁻ z, rayIndicator S ρ T U (200 * δ / ρ ^ 2) x z ∂ν) := + (measurable_rayIndicator S ρ T U (200 * δ / ρ ^ 2)).lintegral_prod_right + simp only [shellMajorant] + rw [lintegral_add_left (hp.const_mul _), lintegral_const_mul _ hp, lintegral_const_mul _ hr] + exact add_le_add + (mul_le_mul_right (lintegral_pairMass ν hρ hδ hδquarter) _) + (mul_le_mul_right (lintegral_rayIndicator ν S ρ hT hU (by positivity)) _) + +/-- The majorant detects simultaneous failure of concentration at every cap. -/ +theorem one_le_majorant_of_no_cap (ν S : Measure ℂ) [IsFiniteMeasure ν] [IsFiniteMeasure S] + {ρ δ T U : ℝ} (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hδ : 0 < δ) + (hδρ : δ ≤ ρ ^ 2 / 1600) (hT : 0 ≤ T) (hU : 0 < U) + {x : ℂ} {r : ℝ} (hr : r ∈ Icc (1 : ℝ) 2) + (hν : ENNReal.ofReal U ≤ ν (thinShell x r δ)) + (hS : S (Metric.ball x (r - δ)) ≤ ENNReal.ofReal T) + (hbad : ∀ z ∈ thinShell x r δ, + ENNReal.ofReal (2 * U) < (S + ν) (thinShell x r δ \ Metric.ball z ρ)) : + 1 ≤ shellMajorant ν S ρ δ T U x := by + have hu0 : ENNReal.ofReal U ≠ 0 := (ENNReal.ofReal_pos.mpr hU).ne' + rw [shellMajorant_eq_bracket] + calc + 1 = (ENNReal.ofReal U)⁻¹ * ENNReal.ofReal U := + (ENNReal.inv_mul_cancel hu0 ENNReal.ofReal_ne_top).symm + _ ≤ (ENNReal.ofReal U)⁻¹ * ν (thinShell x r δ) := mul_le_mul_right hν _ + _ = (ENNReal.ofReal U)⁻¹ * (∫⁻ z, (thinShell x r δ).indicator 1 z ∂ν) := by + rw [lintegral_indicator_one (measurableSet_thinShell x r δ)] + _ ≤ _ := by + apply mul_le_mul_right + apply lintegral_mono + intro z + by_cases hz : z ∈ thinShell x r δ + · rw [indicator_of_mem hz] + exact bad_cap_bracket S ν hr hρ hρ1 hδ hδρ hT hU hz hS (hbad z hz) + · rw [indicator_of_notMem hz] + exact bot_le + +/-- Full radius-independent shell concentration, with explicit absolute constants. -/ +theorem shell_concentration (ν S : Measure ℂ) [IsFiniteMeasure ν] [IsFiniteMeasure S] + {ρ δ T U : ℝ} (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hδ : 0 < δ) + (hδρ : δ ≤ ρ ^ 2 / 1600) (hT : 0 ≤ T) (hU : 0 < U) : + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ + (ENNReal.ofReal U)⁻¹ ^ 2 * (ENNReal.ofReal (156 * δ / ρ) * ν univ * ν univ) + + (ENNReal.ofReal U)⁻¹ * ((ENNReal.ofReal (6 * Real.pi) * + ENNReal.ofReal (2 * (200 * δ / ρ ^ 2) * (1 + T / U))) * ν univ) ∧ + ∀ x ∉ E, ∀ r ∈ Icc (1 : ℝ) 2, + ENNReal.ofReal U ≤ ν (thinShell x r δ) → + S (Metric.ball x (r - δ)) ≤ ENNReal.ofReal T → + ∃ z ∈ thinShell x r δ, + (S + ν) (thinShell x r δ \ Metric.ball z ρ) ≤ ENNReal.ofReal (2 * U) := by + let E : Set ℂ := {x | 1 ≤ shellMajorant ν S ρ δ T U x} + have hE : MeasurableSet E := measurableSet_le measurable_const + (measurable_shellMajorant ν S ρ δ T U) + refine ⟨E, hE, ?_, ?_⟩ + · have hm := meas_ge_le_lintegral_div (μ := (volume : Measure ℂ)) + (measurable_shellMajorant ν S ρ δ T U).aemeasurable one_ne_zero ENNReal.one_ne_top + simp only [div_one] at hm + refine hm.trans (lintegral_shellMajorant ν S hρ hδ.le ?_ hT hU) + have hρsq : ρ ^ 2 ≤ 1 := by nlinarith + linarith + · intro x hx r hr hν hS + by_contra h + push Not at h + exact hx (one_le_majorant_of_no_cap ν S hρ hρ1 hδ hδρ hT hU hr hν hS h) + +end DiskGeometry + +open MeasureTheory Set Filter +open scoped Topology RealInnerProductSpace ContDiff + +namespace DiskMoments + +local instance : Fact (Module.finrank ℝ ℂ = 2) := ⟨Complex.finrank_real_complex⟩ + +def rotation (t : ℝ) : ℂ ≃ₗᵢ[ℝ] ℂ := Complex.orientation.rotation (t : Real.Angle) + +lemma rotation_apply (t : ℝ) (z : ℂ) : + rotation t z = ((Real.cos t : ℂ) + (Real.sin t : ℂ) * Complex.I) * z := by + simp only [rotation, Complex.rotation, Real.Angle.coe_toCircle, Real.Angle.cos_coe, Real.Angle.sin_coe] + +lemma rotation_zero (z : ℂ) : rotation 0 z = z := by simp [rotation_apply] + +lemma rotation_norm (t : ℝ) (z : ℂ) : ‖rotation t z‖ = ‖z‖ := + (rotation t).norm_map z + +lemma integral_rotation (g : ℂ → ℝ) (x : ℂ) (r t : ℝ) : + (∫ z in Metric.ball 0 r, g (x + rotation t z)) = + ∫ z in Metric.ball 0 r, g (x + z) := by + have hpre : (rotation t) ⁻¹' Metric.ball (0 : ℂ) r = Metric.ball 0 r := by + ext z + simp [Metric.mem_ball, dist_zero_right] + have h := (rotation t).measurePreserving.setIntegral_preimage_emb + (rotation t).toHomeomorph.measurableEmbedding (fun z => g (x + z)) (Metric.ball 0 r) + rw [hpre] at h + exact h + +lemma hasDerivAt_rotation (t : ℝ) (z : ℂ) : + HasDerivAt (fun a : ℝ => rotation a z) (Complex.I * rotation t z) t := by + simp only [rotation_apply] + convert! (((Real.hasDerivAt_cos t).ofReal_comp.add + ((Real.hasDerivAt_sin t).ofReal_comp.mul_const Complex.I )).mul_const z) using 1; try rfl + simp only [Complex.ofReal_neg] + ring_nf + simp [sub_eq_add_neg] + +/-- The circulation moment of a smooth gradient on a disk vanishes. -/ +theorem rotational_moment_zero {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (x : ℂ) (r : ℝ) : + (∫ z in Metric.ball 0 r, (fderiv ℝ g (x + z)) (Complex.I * z)) = 0 := by + let F : ℝ → ℂ → ℝ := fun t z => g (x + rotation t z) + let F' : ℝ → ℂ → ℝ := fun t z => + (fderiv ℝ g (x + rotation t z)) (Complex.I * rotation t z) + have hdc : Continuous (fderiv ℝ g) := hg.continuous_fderiv one_ne_zero + obtain ⟨C, hC⟩ := (isCompact_closedBall x r).exists_bound_of_continuousOn hdc.continuousOn + have hFm (t : ℝ) : Continuous (F t) := hg.continuous.comp (by fun_prop) + have hF'm (t : ℝ) : Continuous (F' t) := by + unfold F' + exact (hdc.comp (by fun_prop)).clm_apply (by fun_prop) + have hFi : IntegrableOn (F 0) (Metric.ball 0 r) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall 0 r) (hFm 0).continuousOn).mono_set + Metric.ball_subset_closedBall + have hdiff (z : ℂ) (t : ℝ) : HasDerivAt (fun t => F t z) (F' t z) t := by + exact ((hg.differentiable one_ne_zero).differentiableAt.hasFDerivAt.comp_hasDerivAt t + ((hasDerivAt_rotation t z).const_add x)) + have hbound : ∀ᵐ z ∂volume.restrict (Metric.ball (0 : ℂ) r), ∀ t ∈ (univ : Set ℝ), + ‖F' t z‖ ≤ max C 0 * r := by + filter_upwards [ae_restrict_mem measurableSet_ball] with z hz t _ + have hz' : ‖z‖ ≤ r := by simpa [Metric.mem_ball, dist_zero_right] using (show ‖z‖ < r by simpa [Metric.mem_ball, dist_zero_right] using hz).le + have hpos : x + rotation t z ∈ Metric.closedBall x r := by + simpa [Metric.mem_closedBall, dist_eq_norm, rotation_norm] using hz' + exact ((fderiv ℝ g (x + rotation t z)).le_opNorm _).trans + (mul_le_mul ((hC _ hpos).trans (le_max_left _ _)) + (by simpa [norm_mul, rotation_norm] using hz') (norm_nonneg _) (le_max_right _ _)) + have hb : IntegrableOn (fun _ : ℂ => max C 0 * r) (Metric.ball 0 r) := by + exact integrableOn_const (by finiteness) + have hd := (hasDerivAt_integral_of_dominated_loc_of_deriv_le (μ := volume.restrict (Metric.ball (0 : ℂ) r)) + (x₀ := (0 : ℝ)) (s := univ) (F := F) (F' := F') (bound := fun _ => max C 0 * r) + Filter.univ_mem (Filter.Eventually.of_forall (fun t => (hFm t).aestronglyMeasurable)) + hFi (hF'm 0).aestronglyMeasurable hbound hb + (Filter.Eventually.of_forall (fun z t _ => hdiff z t))).2 + have hconst : (fun t => ∫ z in Metric.ball 0 r, F t z) = + fun _ => ∫ z in Metric.ball 0 r, g (x + z) := by + funext t + exact integral_rotation g x r t + rw [hconst] at hd + have he := hd.unique (hasDerivAt_const 0 (∫ z in Metric.ball 0 r, g (x + z))) + simpa only [F', rotation_zero] using he + +lemma integral_translate_ball {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : ℂ → E) (x : ℂ) (r : ℝ) : + (∫ z in Metric.ball 0 r, f (x + z)) = ∫ y in Metric.ball x r, f y := by + have hpre : (fun z : ℂ => x + z) ⁻¹' Metric.ball x r = Metric.ball 0 r := by + ext z + simp [Metric.mem_ball, dist_eq_norm] + have h := (measurePreserving_add_left volume x).setIntegral_preimage_emb + (Homeomorph.addLeft x).measurableEmbedding f (Metric.ball x r) + rwa [hpre] at h + +lemma continuous_gradient {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) : + Continuous (gradient g) := + (InnerProductSpace.toDual ℝ ℂ).symm.continuous.comp (hg.continuous_fderiv one_ne_zero) + +lemma real_moment_integrand (g : ℂ → ℝ) (x z : ℂ) : + (star z * gradient g x).re = (fderiv ℝ g x) z := by + rw [← inner_gradient_left, Complex.inner] + simp [mul_comm] + +lemma imaginary_moment_integrand (g : ℂ → ℝ) (x z : ℂ) : + (star z * gradient g x).im = (fderiv ℝ g x) (Complex.I * z) := by + rw [← inner_gradient_left, Complex.inner] + simp [Complex.mul_re, Complex.mul_im] + ring + +/-- The imaginary part of the actual complex disk moment is zero. -/ +theorem imaginary_moment_zero {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (x : ℂ) (r : ℝ) : + (∫ y in Metric.ball x r, star (y - x) * gradient g y).im = 0 := by + have ht := (integral_translate_ball (fun y => star (y-x) * gradient g y) x r).symm + rw [ht] + have hi : IntegrableOn (fun z => star ((x+z)-x) * gradient g (x+z)) (Metric.ball 0 r) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall 0 r) + ((by fun_prop : Continuous (fun z : ℂ => star ((x+z)-x))).mul + ((continuous_gradient hg).comp (by fun_prop))).continuousOn).mono_set + Metric.ball_subset_closedBall + change Complex.imCLM (∫ z in Metric.ball 0 r, star ((x+z)-x) * gradient g (x+z)) = 0 + rw [← Complex.imCLM.integral_comp_comm hi] + convert rotational_moment_zero hg x r using 1 + congr 1 + funext z + simpa using imaginary_moment_integrand g (x+z) z + +/-- Differentiate a disk average on its fixed unit-disk model. -/ +theorem hasDerivAt_integral_unitDisk {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (x : ℂ) (t : ℝ) : + HasDerivAt (fun s : ℝ => ∫ z in Metric.ball (0 : ℂ) 1, g (x + s • z)) + (∫ z in Metric.ball (0 : ℂ) 1, (fderiv ℝ g (x + t • z)) z) t := by + let F : ℝ → ℂ → ℝ := fun s z => g (x + s • z) + let F' : ℝ → ℂ → ℝ := fun s z => (fderiv ℝ g (x + s • z)) z + have hdc : Continuous (fderiv ℝ g) := hg.continuous_fderiv one_ne_zero + obtain ⟨C, hC⟩ := (isCompact_closedBall x (|t|+1)).exists_bound_of_continuousOn hdc.continuousOn + have hFm (s : ℝ) : Continuous (F s) := hg.continuous.comp (by fun_prop) + have hF'm (s : ℝ) : Continuous (F' s) := by + unfold F' + exact (hdc.comp (by fun_prop)).clm_apply continuous_id + have hFi : IntegrableOn (F t) (Metric.ball 0 1) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall 0 1) (hFm t).continuousOn).mono_set + Metric.ball_subset_closedBall + have hdiff (z : ℂ) (s : ℝ) : HasDerivAt (fun s => F s z) (F' s z) s := by + convert! ((hg.differentiable one_ne_zero).differentiableAt.hasFDerivAt.comp_hasDerivAt s + (((hasDerivAt_id s).smul_const z).const_add x)) using 1 + simp [F', id_eq] + have hbound : ∀ᵐ z ∂volume.restrict (Metric.ball (0 : ℂ) 1), + ∀ s ∈ Metric.ball t 1, ‖F' s z‖ ≤ max C 0 := by + filter_upwards [ae_restrict_mem measurableSet_ball] with z hz s hs + have hz' : ‖z‖ ≤ 1 := by simpa [Metric.mem_ball, dist_zero_right] using + (show ‖z‖ < 1 by simpa [Metric.mem_ball, dist_zero_right] using hz).le + have hs' : |s| ≤ |t| + 1 := by + have hh : |s-t| < 1 := by simpa [Metric.mem_ball, Real.dist_eq] using hs + have hh' := abs_add_le (s-t) t + rw [sub_add_cancel] at hh' + linarith + have hpos : x + s • z ∈ Metric.closedBall x (|t|+1) := by + simp only [Metric.mem_closedBall, dist_eq_norm, add_sub_cancel_left, norm_smul, Real.norm_eq_abs] + exact (mul_le_mul_of_nonneg_left hz' (abs_nonneg s)).trans (by simpa using hs') + exact ((fderiv ℝ g (x+s•z)).le_opNorm _).trans + (by simpa only [mul_one] using (mul_le_mul ((hC _ hpos).trans (le_max_left C 0)) hz' + (norm_nonneg _) (le_max_right C 0))) + exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le (μ := volume.restrict (Metric.ball (0 : ℂ) 1)) + (x₀ := t) (s := Metric.ball t 1) (F := F) (F' := F') (bound := fun _ => max C 0) + (Metric.ball_mem_nhds _ zero_lt_one) (Filter.Eventually.of_forall (fun s => (hFm s).aestronglyMeasurable)) + hFi (hF'm t).aestronglyMeasurable hbound (integrableOn_const (by finiteness)) + (Filter.Eventually.of_forall (fun z s _ => hdiff z s))).2 + +lemma integral_scale_ball {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : ℂ → E) {t : ℝ} (ht : 0 < t) : + (∫ z in Metric.ball (0 : ℂ) 1, f (t • z)) = + (t^2)⁻¹ • ∫ z in Metric.ball (0 : ℂ) t, f z := by + convert Measure.setIntegral_comp_smul_of_pos volume f (Metric.ball 0 1) ht using 1 + rw [Complex.finrank_real_complex, smul_ball ht.ne', smul_zero, Real.norm_eq_abs, abs_of_pos ht, mul_one] + +/-- Signed normalized average on a centered Euclidean disk in the complex plane. -/ +def signedAverage (g : ℂ → ℝ) (x : ℂ) (t : ℝ) : ℝ := + (∫ y in Metric.ball x t, g y) / (Real.pi * t^2) + +lemma signedAverage_fixedDomain (g : ℂ → ℝ) (x : ℂ) {t : ℝ} (ht : 0 < t) : + signedAverage g x t = (∫ z in Metric.ball (0 : ℂ) 1, g (x + t • z)) / Real.pi := by + rw [integral_scale_ball (fun z => g (x+z)) ht, integral_translate_ball] + simp only [signedAverage, smul_eq_mul] + ring + +lemma integral_fderiv_scale (g : ℂ → ℝ) (x : ℂ) {t : ℝ} (ht : 0 < t) : + (∫ z in Metric.ball (0 : ℂ) 1, (fderiv ℝ g (x+t•z)) z) = + (t^3)⁻¹ * ∫ y in Metric.ball x t, (fderiv ℝ g y) (y-x) := by + have hi (z : ℂ) : (fderiv ℝ g (x+t•z)) z = + t⁻¹ * (fderiv ℝ g (x+t•z)) (t•z) := by + rw [map_smul, smul_eq_mul, ← mul_assoc, inv_mul_cancel₀ ht.ne', one_mul] + simp_rw [hi] + rw [integral_const_mul, integral_scale_ball (fun z => (fderiv ℝ g (x+z)) z) ht] + have hh : (∫ z in Metric.ball (0 : ℂ) t, (fderiv ℝ g (x+z)) z) = + ∫ y in Metric.ball x t, (fderiv ℝ g y) (y-x) := by + simpa using integral_translate_ball (fun y => (fderiv ℝ g y) (y-x)) x t + rw [hh] + simp only [smul_eq_mul] + ring + +lemma integral_fderiv_moment_real {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) (t : ℝ) : + (∫ y in Metric.ball x t, (fderiv ℝ g y) (y-x)) = + (∫ y in Metric.ball x t, star (y-x) * gradient g y).re := by + have hi : IntegrableOn (fun y => star (y-x) * gradient g y) (Metric.ball x t) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall x t) + ((by fun_prop : Continuous (fun y : ℂ => star (y-x))).mul + (continuous_gradient hg)).continuousOn).mono_set Metric.ball_subset_closedBall + change _ = Complex.reCLM _ + rw [← Complex.reCLM.integral_comp_comm hi] + congr 1 + funext y + exact (real_moment_integrand g y (y-x)).symm + +/-- The radial disk derivative is the real part of its complex moment. -/ +theorem hasDerivAt_signedAverage {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (x : ℂ) {t : ℝ} (ht : 0 < t) : + HasDerivAt (signedAverage g x) + ((∫ y in Metric.ball x t, star (y-x) * gradient g y).re / (Real.pi * t^3)) t := by + have hd := (hasDerivAt_integral_unitDisk hg x t).div_const Real.pi + rw [integral_fderiv_scale g x ht, integral_fderiv_moment_real hg x t] at hd + have he : (fun s => (∫ z in Metric.ball (0 : ℂ) 1, g (x+s•z)) / Real.pi) + =ᶠ[𝓝 t] signedAverage g x := by + filter_upwards [eventually_gt_nhds ht] with s hs + exact (signedAverage_fixedDomain g x hs).symm + convert! hd.congr_of_eventuallyEq he.symm using 1; try rfl + ring + +lemma ball_ae_closedBall (x : ℂ) (r : ℝ) : + Metric.ball x r =ᵐ[volume] Metric.closedBall x r := by + apply ae_eq_of_subset_of_measure_ge Metric.ball_subset_closedBall + · exact (Measure.addHaar_closedBall_eq_addHaar_ball volume x r).le + · exact measurableSet_ball.nullMeasurableSet + · exact measure_closedBall_lt_top.ne + +lemma continuous_integral_fderiv_unit {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) : + Continuous (fun t : ℝ => ∫ z in Metric.ball (0 : ℂ) 1, (fderiv ℝ g (x+t•z)) z) := by + have he (t : ℝ) : (∫ z in Metric.ball (0 : ℂ) 1, (fderiv ℝ g (x+t•z)) z) = + ∫ z in Metric.closedBall (0 : ℂ) 1, (fderiv ℝ g (x+t•z)) z := + setIntegral_congr_set (ball_ae_closedBall 0 1) + simp_rw [he] + apply continuous_parametric_integral_of_continuous _ (isCompact_closedBall 0 1) + exact ((hg.continuous_fderiv one_ne_zero).comp (by fun_prop)).clm_apply continuous_snd + +end DiskMoments + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskKernels1.lean b/lean/OAI/Analysis/SignedDisk/DiskKernels1.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c58eced0057b96cf06c5afbbc8027c0defe70aa --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskKernels1.lean @@ -0,0 +1,441 @@ +import OAI.Analysis.SignedDisk.DiskGeometry2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff + +noncomputable section + +namespace SignedDisk + +open MeasureTheory Set Filter +open scoped Topology Interval NNReal + +namespace DiskKernels + +/-- An ordinary nonnegative probability density supported on a radius interval. -/ +structure RadiusDensity (a b : ℝ) (M : ℝ≥0) where + toFun : ℝ → ℝ + integrable : Integrable toFun + nonneg : ∀ t, 0 ≤ toFun t + integral_one : ∫ t, toFun t = 1 + bound : ∀ t, toFun t ≤ M + support : ∀ t, t ∉ Icc a b → toFun t = 0 + +instance {a b : ℝ} {M : ℝ≥0} : CoeFun (RadiusDensity a b M) (fun _ => ℝ → ℝ) := + ⟨RadiusDensity.toFun⟩ + +def tail {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (u : ℝ) : ℝ := + ∫ t in Ioi u, k t + +lemma tail_nonneg {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (u : ℝ) : + 0 ≤ tail k u := integral_nonneg k.nonneg + +lemma tail_le_one {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (u : ℝ) : + tail k u ≤ 1 := by + rw [← k.integral_one] + exact setIntegral_le_integral k.integrable (Eventually.of_forall k.nonneg) + +lemma tail_one {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) {u : ℝ} (hu : u < a) : + tail k u = 1 := by + rw [tail, setIntegral_eq_integral_of_forall_compl_eq_zero, k.integral_one] + intro t ht + apply k.support + simp only [mem_Ioi, not_lt] at ht + intro h + linarith [h.1] + +lemma tail_zero {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) {u : ℝ} (hu : b ≤ u) : + tail k u = 0 := by + apply integral_eq_zero_of_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + apply k.support + intro h + have := ht + simp only [mem_Ioi] at this + linarith [h.2] + +lemma tail_lipschitz {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) : + LipschitzWith M (tail k) := by + apply LipschitzWith.of_dist_le_mul + intro u v + rw [Real.dist_eq, ← Real.norm_eq_abs, tail, tail, + intervalIntegral.integral_Ioi_sub_Ioi' k.integrable.integrableOn k.integrable.integrableOn] + have h := intervalIntegral.norm_integral_le_of_norm_le_const + (a := u) (b := v) (f := k) (C := (M : ℝ)) (fun t _ => by + rw [Real.norm_eq_abs, abs_of_nonneg (k.nonneg t)] + exact k.bound t) + simpa only [Real.dist_eq, abs_sub_comm v u] using h + +def kernel {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x y : ℂ) : ℝ := + tail k (dist y x) + +lemma kernel_lipschitz {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x : ℂ) : + LipschitzWith M (kernel k x) := by + apply LipschitzWith.of_dist_le_mul + intro y z + exact ((tail_lipschitz k).dist_le_mul (dist y x) (dist z x)).trans + (mul_le_mul_of_nonneg_left (dist_dist_dist_le_left y z x) M.coe_nonneg) + +lemma kernel_one {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x : ℂ) + {y : ℂ} (hy : y ∈ Metric.ball x a) : kernel k x y = 1 := tail_one k hy + +lemma kernel_zero {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x : ℂ) + {y : ℂ} (hy : y ∉ Metric.ball x b) : kernel k x y = 0 := + tail_zero k (not_lt.mp hy) + +/-- The radial tail is exactly the positive average of disk indicators. -/ +lemma kernel_eq_integral {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x y : ℂ) : + kernel k x y = ∫ t, k t * (Metric.ball x t).indicator (fun _ => (1 : ℝ)) y := by + rw [kernel, tail, ← integral_indicator measurableSet_Ioi] + congr 1 + funext t + by_cases ht : dist y x < t + · simp [Set.indicator_of_mem, ht, Metric.mem_ball] + · simp [Set.indicator_of_notMem, ht, Metric.mem_ball] + +/-- Convex combinations preserve all density and support bounds. -/ +def mix {a b : ℝ} {M : ℝ≥0} (k l : RadiusDensity a b M) + (w : ℝ) (hw0 : 0 ≤ w) (hw1 : w ≤ 1) : RadiusDensity a b M where + toFun t := w * k t + (1-w) * l t + integrable := (k.integrable.const_mul w).add (l.integrable.const_mul (1-w)) + nonneg t := add_nonneg (mul_nonneg hw0 (k.nonneg t)) (mul_nonneg (sub_nonneg.mpr hw1) (l.nonneg t)) + integral_one := by + rw [integral_add (k.integrable.const_mul w) (l.integrable.const_mul (1-w)), + integral_const_mul, integral_const_mul, k.integral_one, l.integral_one] + ring + bound t := by + have h₁ := mul_le_mul_of_nonneg_left (k.bound t) hw0 + have h₂ := mul_le_mul_of_nonneg_left (l.bound t) (sub_nonneg.mpr hw1) + nlinarith + support t ht := by rw [k.support t ht, l.support t ht]; ring + +/-- Two oppositely signed moments admit an explicit convex zero. -/ +lemma convex_zero {A B : ℝ} (hA : 0 ≤ A) (hB : B ≤ 0) : + ∃ w : ℝ, 0 ≤ w ∧ w ≤ 1 ∧ w*A+(1-w)*B = 0 := by + by_cases h : A-B=0 + · refine ⟨1, zero_le_one, le_rfl, ?_⟩ + have : A = 0 := by linarith + simp [this] + · have hp : 0 < A-B := lt_of_le_of_ne (by linarith) (Ne.symm h) + refine ⟨-B/(A-B), div_nonneg (neg_nonneg.mpr hB) hp.le, ?_, ?_⟩ + · apply (div_le_one hp).mpr + linarith + · field_simp + ring + +def inverseCube (t : ℝ) : ℝ := (t^3)⁻¹ + +def cubeMass (a b : ℝ) : ℝ := ∫ t in Icc a b, inverseCube t + +lemma inverseCube_bounds {t : ℝ} (ht : t ∈ Icc ((1 : ℝ)/2) 3) : + (1 : ℝ)/27 ≤ inverseCube t ∧ inverseCube t ≤ 8 := by + have ht0 : 0 < t := by linarith [ht.1] + have hl : (1 : ℝ)/8 ≤ t^3 := by + have := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 1/2) ht.1 3 + norm_num at this + exact this + have hu : t^3 ≤ 27 := by + have := pow_le_pow_left₀ ht0.le ht.2 3 + norm_num at this + exact this + constructor + · simpa [inverseCube, one_div] using one_div_le_one_div_of_le (pow_pos ht0 3) hu + · simpa [inverseCube, one_div] using one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1/8) hl + +lemma continuousOn_inverseCube {a b : ℝ} (ha : 0 < a) : + ContinuousOn inverseCube (Icc a b) := by + apply (continuous_id.pow 3).continuousOn.inv₀ + intro t ht + exact pow_ne_zero 3 (ne_of_gt (lt_of_lt_of_le ha ht.1)) + +lemma cubeMass_lower {a b : ℝ} (ha : (1 : ℝ)/2 ≤ a) (hb : b ≤ 3) : + (b-a)/27 ≤ cubeMass a b := by + by_cases hab : a ≤ b + · have hi := (continuousOn_inverseCube (b := b) (show 0 < a by linarith)).integrableOn_Icc (μ := volume) + have h := setIntegral_mono_on (f := fun _ : ℝ => (1 : ℝ)/27) + (integrableOn_const isCompact_Icc.measure_ne_top) hi measurableSet_Icc + (fun t ht => (inverseCube_bounds ⟨ha.trans ht.1, ht.2.trans hb⟩).1) + simp only [setIntegral_const, measureReal_def, Real.volume_Icc, + ENNReal.toReal_ofReal (sub_nonneg.mpr hab), smul_eq_mul] at h + simpa only [cubeMass, div_eq_mul_inv, one_mul] using h + · have he : Icc a b = ∅ := Icc_eq_empty hab + have hx : cubeMass a b = 0 := by simp [cubeMass, he] + rw [hx] + exact div_nonpos_of_nonpos_of_nonneg (sub_nonpos.mpr (le_of_not_ge hab)) (by norm_num) + +lemma cubeMass_pos {a b : ℝ} (ha : (1 : ℝ)/2 ≤ a) (hb : b ≤ 3) (hab : a < b) : + 0 < cubeMass a b := (div_pos (sub_pos.mpr hab) (by norm_num)).trans_le (cubeMass_lower ha hb) + +def cubeDensity (a b t : ℝ) : ℝ := + (Icc a b).indicator (fun t => inverseCube t / cubeMass a b) t + +lemma cubeDensity_integrable {a b : ℝ} (ha : 0 < a) : Integrable (cubeDensity a b) := + ((continuousOn_inverseCube ha).div_const (cubeMass a b)).integrableOn_Icc.integrable_indicator + measurableSet_Icc + +lemma cubeDensity_integral {a b : ℝ} (ha : (1 : ℝ)/2 ≤ a) (hb : b ≤ 3) (hab : a < b) : + (∫ t, cubeDensity a b t) = 1 := by + simp only [cubeDensity] + rw [integral_indicator measurableSet_Icc, integral_div, ← cubeMass, + div_self (cubeMass_pos ha hb hab).ne'] + +lemma cubeDensity_nonneg {a b : ℝ} (ha : (1 : ℝ)/2 ≤ a) (hb : b ≤ 3) (hab : a < b) + (t : ℝ) : 0 ≤ cubeDensity a b t := by + apply Set.indicator_nonneg + intro t ht + exact div_nonneg ((by norm_num : (0 : ℝ) ≤ 1/27).trans + (inverseCube_bounds ⟨ha.trans ht.1, ht.2.trans hb⟩).1) (cubeMass_pos ha hb hab).le + +lemma cubeDensity_bound {a b : ℝ} (ha : (1 : ℝ)/2 ≤ a) (hb : b ≤ 3) (hab : a < b) + (t : ℝ) : cubeDensity a b t ≤ 216/(b-a) := by + by_cases ht : t ∈ Icc a b + · rw [cubeDensity, Set.indicator_of_mem ht] + have hM := cubeMass_pos ha hb hab + have hl := cubeMass_lower ha hb + have hbnd := (inverseCube_bounds ⟨ha.trans ht.1, ht.2.trans hb⟩).2 + apply (div_le_iff₀ hM).mpr + have hD : 0 < b-a := sub_pos.mpr hab + have hl' : 8 ≤ 216/(b-a) * cubeMass a b := by + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hD).mpr + linarith + exact hbnd.trans hl' + · simp only [cubeDensity, Set.indicator_of_notMem ht] + positivity + +/-- The concrete normalized inverse-cube density, with an absolute width bound. -/ +def inverseCubeDensity (a b : ℝ) (ha : (1 : ℝ)/2 ≤ a) (hb : b ≤ 3) (hab : a < b) : + RadiusDensity a b ⟨216/(b-a), by positivity⟩ where + toFun := cubeDensity a b + integrable := cubeDensity_integrable (by linarith) + nonneg := cubeDensity_nonneg ha hb hab + integral_one := cubeDensity_integral ha hb hab + bound := cubeDensity_bound ha hb hab + support t ht := Set.indicator_of_notMem ht _ + +def enlarge {a b a' b' : ℝ} {M N : ℝ≥0} (k : RadiusDensity a b M) + (ha : a' ≤ a) (hb : b ≤ b') (hM : M ≤ N) : RadiusDensity a' b' N where + toFun := k + integrable := k.integrable + nonneg := k.nonneg + integral_one := k.integral_one + bound t := (k.bound t).trans hM + support t ht := k.support t (fun h => ht ⟨ha.trans h.1, h.2.trans hb⟩) + +/-- Fubini identifies a radial kernel pairing with the average of disk pairings. -/ +theorem kernel_pairing {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] + {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x : ℂ) + {f : ℂ → E} (hf : Integrable f) : + (∫ y, kernel k x y • f y) = ∫ t, k t • ∫ y in Metric.ball x t, f y := by + let A : Set (ℝ × ℂ) := {p | dist p.2 x < p.1} + have hA : MeasurableSet A := measurableSet_lt (by fun_prop) measurable_fst + let F : ℝ × ℂ → E := A.indicator (fun p => k p.1 • f p.2) + have hF : Integrable F (volume.prod volume) := (k.integrable.smul_prod hf).indicator hA + have hleft (t : ℝ) : (∫ y, F (t,y)) = k t • ∫ y in Metric.ball x t, f y := by + have he : (fun y => F (t,y)) = fun y => k t • (Metric.ball x t).indicator f y := by + funext y + by_cases h : dist y x < t + · simp [F, A, Metric.mem_ball, h] + · simp [F, A, Metric.mem_ball, h] + rw [he, integral_smul, integral_indicator measurableSet_ball] + have hright (y : ℂ) : (∫ t, F (t,y)) = kernel k x y • f y := by + have he : (fun t => F (t,y)) = fun t => (Ioi (dist y x)).indicator k t • f y := by + funext t + by_cases h : dist y x < t + · simp [F, A, h] + · simp [F, A, h] + rw [he, integral_smul_const, integral_indicator measurableSet_Ioi] + rfl + have hh := integral_integral_swap (f := fun t y => F (t,y)) hF + simp_rw [hleft, hright] at hh + exact hh.symm + +end DiskKernels + +namespace DiskMoments +open DiskKernels + +def moment (g : ℂ → ℝ) (x : ℂ) (t : ℝ) : ℂ := + ∫ y in Metric.ball x t, star (y-x) * gradient g y + +def radialDerivative (g : ℂ → ℝ) (x : ℂ) (t : ℝ) : ℝ := + (∫ z in Metric.ball (0 : ℂ) 1, (fderiv ℝ g (x+t•z)) z) / Real.pi + +lemma continuous_radialDerivative {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) : + Continuous (radialDerivative g x) := (continuous_integral_fderiv_unit hg x).div_const Real.pi + +lemma moment_coefficient {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) + {t : ℝ} (ht : 0 < t) : (moment g x t).re / (Real.pi * t^3) = radialDerivative g x t := by + rw [radialDerivative, integral_fderiv_scale g x ht, integral_fderiv_moment_real hg] + simp only [moment] + ring + +lemma hasDerivAt_signedAverage_fixed {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (x : ℂ) {t : ℝ} (ht : 0 < t) : + HasDerivAt (signedAverage g x) (radialDerivative g x t) t := by + rw [← moment_coefficient hg x ht] + exact hasDerivAt_signedAverage hg x ht + +lemma moment_eq {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) + {t : ℝ} (ht : 0 < t) : + moment g x t = ((Real.pi * t^3 * radialDerivative g x t : ℝ) : ℂ) := by + apply Complex.ext + · simp only [Complex.ofReal_re] + have hh := moment_coefficient hg x ht + have hp : Real.pi * t^3 ≠ 0 := mul_ne_zero Real.pi_ne_zero (pow_ne_zero 3 ht.ne') + exact (div_eq_iff hp).mp hh |>.trans (mul_comm _ _) + · simpa only [moment, Complex.ofReal_im] using imaginary_moment_zero hg x t + +lemma integral_radialDerivative {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) + {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + (∫ t in Icc a b, radialDerivative g x t) = signedAverage g x b - signedAverage g x a := by + rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hab] + apply intervalIntegral.integral_eq_sub_of_hasDerivAt _ ((continuous_radialDerivative hg x).intervalIntegrable a b) + intro t ht + rw [uIcc_of_le hab] at ht + exact hasDerivAt_signedAverage_fixed hg x (lt_of_lt_of_le ha ht.1) + +lemma cubeDensity_moment_integrable {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) + {a b : ℝ} (ha : 0 < a) : + Integrable (fun t => cubeDensity a b t • moment g x t) := by + have he : (fun t => cubeDensity a b t • moment g x t) = + (Icc a b).indicator (fun t => + (((Real.pi / cubeMass a b) * radialDerivative g x t : ℝ) : ℂ)) := by + funext t + by_cases ht : t ∈ Icc a b + · have ht0 := lt_of_lt_of_le ha ht.1 + rw [cubeDensity, Set.indicator_of_mem ht, Set.indicator_of_mem ht, moment_eq hg x ht0] + apply Complex.ext <;> simp only [Complex.smul_re, Complex.smul_im, Complex.ofReal_re, + Complex.ofReal_im, smul_eq_mul, mul_zero] + simp only [inverseCube] + field_simp + · simp [cubeDensity, Set.indicator_of_notMem ht] + rw [he] + exact (Complex.continuous_ofReal.comp ((continuous_radialDerivative hg x).const_mul _)).continuousOn.integrableOn_Icc.integrable_indicator measurableSet_Icc + +lemma cubeDensity_moment_integral {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) + {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + (∫ t, cubeDensity a b t • moment g x t) = + (((Real.pi / cubeMass a b) * (signedAverage g x b - signedAverage g x a) : ℝ) : ℂ) := by + have he : (fun t => cubeDensity a b t • moment g x t) = + (Icc a b).indicator (fun t => + (((Real.pi / cubeMass a b) * radialDerivative g x t : ℝ) : ℂ)) := by + funext t + by_cases ht : t ∈ Icc a b + · have ht0 := lt_of_lt_of_le ha ht.1 + rw [cubeDensity, Set.indicator_of_mem ht, Set.indicator_of_mem ht, moment_eq hg x ht0] + apply Complex.ext <;> simp only [Complex.smul_re, Complex.smul_im, Complex.ofReal_re, + Complex.ofReal_im, smul_eq_mul, mul_zero] + simp only [inverseCube] + field_simp + · simp [cubeDensity, Set.indicator_of_notMem ht] + rw [he, integral_indicator measurableSet_Icc] + change (∫ t in Icc a b, Complex.ofRealCLM ((Real.pi / cubeMass a b) * radialDerivative g x t)) = _ + rw [Complex.ofRealCLM.integral_comp_comm + ((continuous_radialDerivative hg x).const_mul _).continuousOn.integrableOn_Icc, + integral_const_mul, integral_radialDerivative hg x ha hab] + rfl + +lemma gradient_hasCompactSupport {g : ℂ → ℝ} (hc : HasCompactSupport g) : + HasCompactSupport (gradient g) := (hc.fderiv ℝ).comp_left (map_zero _) + +lemma moment_density_integrable {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (x : ℂ) : + Integrable (fun y => star (y-x) * gradient g y) := + ((by fun_prop : Continuous (fun y : ℂ => star (y-x))).mul (continuous_gradient hg)).integrable_of_hasCompactSupport + (gradient_hasCompactSupport hc).mul_left + +end DiskMoments + +namespace DiskKernels + +/-- Only integrability over the largest supporting disk is required. -/ +theorem kernel_pairing_local {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [CompleteSpace E] {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x : ℂ) + {f : ℂ → E} (hf : IntegrableOn f (Metric.ball x b)) : + (∫ y, kernel k x y • f y) = ∫ t, k t • ∫ y in Metric.ball x t, f y := by + have hh := kernel_pairing k x (hf.integrable_indicator measurableSet_ball) + have hleft : (fun y => kernel k x y • (Metric.ball x b).indicator f y) = + fun y => kernel k x y • f y := by + funext y + by_cases hy : y ∈ Metric.ball x b + · rw [Set.indicator_of_mem hy] + · rw [Set.indicator_of_notMem hy, kernel_zero k x hy, zero_smul, zero_smul] + rw [hleft] at hh + rw [hh] + apply integral_congr_ae + filter_upwards with t + by_cases ht : t ∈ Icc a b + · congr 1 + apply setIntegral_congr_fun measurableSet_ball + intro y hy + exact Set.indicator_of_mem (show y ∈ Metric.ball x b from lt_of_lt_of_le hy ht.2) f + · rw [k.support t ht, zero_smul, zero_smul] + +end DiskKernels + +namespace DiskMoments +open DiskKernels + +/-- A faithful balanced disk-mixture kernel, with an explicit absolute bound. -/ +theorem balanced_kernel {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x : ℂ) + {r δ : ℝ} (hr : r ∈ Icc (1 : ℝ) 2) (hδ : 0 < δ) (hδ' : δ ≤ 1/4) + (hm : signedAverage g x (r-δ) ≤ signedAverage g x r) + (hp : signedAverage g x (r+δ) ≤ signedAverage g x r) : + ∃ k : RadiusDensity (r-δ) (r+δ) ⟨216/δ, by positivity⟩, + (∫ y, kernel k x y • (star (y-x) * gradient g y)) = 0 := by + have ha : (1 : ℝ)/2 ≤ r-δ := by linarith [hr.1] + have hb : r+δ ≤ (3 : ℝ) := by linarith [hr.2] + have hrh : (1 : ℝ)/2 ≤ r := by linarith [hr.1] + have hrb : r ≤ (3 : ℝ) := by linarith [hr.2] + have hmr : r-δ < r := by linarith + have hpr : r < r+δ := by linarith + let km : RadiusDensity (r-δ) (r+δ) ⟨216/δ, by positivity⟩ := + enlarge (inverseCubeDensity (r-δ) r ha hrb hmr) le_rfl hpr.le (by + change 216/(r-(r-δ)) ≤ 216/δ + simp) + let kp : RadiusDensity (r-δ) (r+δ) ⟨216/δ, by positivity⟩ := + enlarge (inverseCubeDensity r (r+δ) hrh hb hpr) hmr.le le_rfl (by + change 216/(r+δ-r) ≤ 216/δ + simp) + let A := Real.pi / cubeMass (r-δ) r * (signedAverage g x r - signedAverage g x (r-δ)) + let B := Real.pi / cubeMass r (r+δ) * (signedAverage g x (r+δ) - signedAverage g x r) + have hA : 0 ≤ A := mul_nonneg (div_nonneg Real.pi_pos.le (cubeMass_pos ha hrb hmr).le) + (sub_nonneg.mpr hm) + have hB : B ≤ 0 := mul_nonpos_of_nonneg_of_nonpos + (div_nonneg Real.pi_pos.le (cubeMass_pos hrh hb hpr).le) (sub_nonpos.mpr hp) + obtain ⟨w, hw0, hw1, hw⟩ := convex_zero hA hB + let k := mix km kp w hw0 hw1 + refine ⟨k, ?_⟩ + have hfi : IntegrableOn (fun y => star (y-x) * gradient g y) (Metric.ball x (r+δ)) := + (((by fun_prop : Continuous (fun y : ℂ => star (y-x))).mul (continuous_gradient hg)).continuousOn.integrableOn_compact (isCompact_closedBall x (r+δ))).mono_set Metric.ball_subset_closedBall + rw [kernel_pairing_local k x hfi] + change (∫ t, (w * cubeDensity (r-δ) r t + (1-w) * cubeDensity r (r+δ) t) • moment g x t) = 0 + simp_rw [add_smul, mul_smul] + have him : Integrable (fun t : ℝ => w • (cubeDensity (r-δ) r t • moment g x t)) := by + convert! (cubeDensity_moment_integrable hg x (a := r-δ) (b := r) (by linarith [ha])).smul w + have hip : Integrable (fun t : ℝ => (1-w) • (cubeDensity r (r+δ) t • moment g x t)) := by + convert! (cubeDensity_moment_integrable hg x (a := r) (b := r+δ) (by linarith [hr.1])).smul (1-w) + rw [integral_add him hip, + integral_smul, integral_smul, + cubeDensity_moment_integral hg x (by linarith [ha]) hmr.le, + cubeDensity_moment_integral hg x (by linarith [hr.1]) hpr.le] + change w • (A : ℂ) + (1-w) • (B : ℂ) = 0 + apply Complex.ext <;> simp only [Complex.smul_re, Complex.smul_im, Complex.ofReal_re, + Complex.ofReal_im, Complex.add_re, Complex.add_im, Complex.zero_re, Complex.zero_im, + smul_eq_mul, mul_zero, add_zero] + exact hw + +end DiskMoments + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskMaximalTools1.lean b/lean/OAI/Analysis/SignedDisk/DiskMaximalTools1.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d00dead42efd990ce699f9238ad09b141569645 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskMaximalTools1.lean @@ -0,0 +1,486 @@ +import OAI.Analysis.SignedDisk.DiskScales3 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal + +noncomputable section + +namespace SignedDisk + +namespace DiskMaximalTools + +lemma maximal_layer_coefficient {t p : ℝ} (ht : 0 < t) : + (25 / ENNReal.ofReal (t/2))*ENNReal.ofReal (t^(p-1)) = + ENNReal.ofReal 50*ENNReal.ofReal (t^(p-2)) := by + rw [← show ENNReal.ofReal (25:ℝ) = 25 by norm_num, + ← ENNReal.ofReal_div_of_pos (by linarith : 0 < t/2), + ← ENNReal.ofReal_mul (by positivity : 0 ≤ (25:ℝ)/(t/2)), + ← ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 50)] + congr 1 + have hpow : t^(p-1) = t*t^(p-2) := by + calc + _ = t^(1+(p-2)) := by congr 1; ring + _ = t^(1:ℝ)*t^(p-2) := Real.rpow_add ht _ _ + _ = _ := by rw [Real.rpow_one] + rw [hpow] + field_simp + ring + +/-- A full strong p estimate from Vitali, truncation and Tonelli. No maximal +inequality is supplied as an assumption. The real representative is controlled +even before a separate almost-everywhere finiteness argument. -/ +theorem strong_rationalMaximal {f : ℂ → ℝ} (hf : Measurable f) + (hf0 : ∀ x, 0 ≤ f x) [IsFiniteMeasure (volume.withDensity (fun x => ENNReal.ofReal (f x)))] + {p : ℝ} (hp : 1 < p) : + (∫⁻ x, ENNReal.ofReal ((rationalMaximal (volume.withDensity (fun x => ENNReal.ofReal (f x))) x).toReal^p)) ≤ + ENNReal.ofReal (50*p*2^(p-1)/(p-1)) * (∫⁻ x, ENNReal.ofReal ((f x)^p)) := by + let M := rationalMaximal (volume.withDensity (fun x => ENNReal.ofReal (f x))) + have hM : Measurable M := measurable_rationalMaximal _ + have htail (t : ℝ) (ht : 0 < t) : volume {x | t < (M x).toReal} ≤ + (25/ENNReal.ofReal (t/2)) * ∫⁻ x, if t < 2*f x then ENNReal.ofReal (f x) else 0 := by + have hsub : {x | t < (M x).toReal} ⊆ {x | ENNReal.ofReal t < M x} := by + intro x hx + exact (ENNReal.ofReal_lt_ofReal_iff_of_nonneg ht.le).mpr hx |>.trans_le ENNReal.ofReal_toReal_le + apply le_trans (measure_mono hsub) + have hweak := weak_truncated hf.ennreal_ofReal ht + apply hweak.trans_eq + congr 1 + apply lintegral_congr + intro x + have heq : ENNReal.ofReal (t/2) < ENNReal.ofReal (f x) ↔ t < 2*f x := by + rw [ENNReal.ofReal_lt_ofReal_iff_of_nonneg (by linarith : 0 ≤ t/2)] + constructor <;> intro h <;> linarith + simp only [Set.indicator,Set.mem_ofPred_eq,heq] + rw [lintegral_rpow_eq_lintegral_meas_lt_mul volume (ae_of_all _ (fun _ => ENNReal.toReal_nonneg)) + hM.ennreal_toReal.aemeasurable (by linarith : 0 < p)] + have hlayer : (∫⁻ t in Ioi 0, volume {x | t < (M x).toReal}*ENNReal.ofReal (t^(p-1))) ≤ + ENNReal.ofReal 50 * (∫⁻ t in Ioi 0, + (∫⁻ x, if t < 2*f x then ENNReal.ofReal (f x) else 0)*ENNReal.ofReal (t^(p-2))) := by + calc + _ ≤ ∫⁻ t in Ioi 0, ENNReal.ofReal 50 * + ((∫⁻ x, if t < 2*f x then ENNReal.ofReal (f x) else 0)*ENNReal.ofReal (t^(p-2))) := by + apply lintegral_mono_ae + filter_upwards [self_mem_ae_restrict measurableSet_Ioi] with t ht + calc + _ ≤ ((25/ENNReal.ofReal (t/2)) * ∫⁻ x, if t < 2*f x then ENNReal.ofReal (f x) else 0)* + ENNReal.ofReal (t^(p-1)) := by gcongr; exact htail t ht + _ = _ := by + rw [mul_right_comm, maximal_layer_coefficient ht] + ring + _ = _ := lintegral_const_mul' _ _ ENNReal.ofReal_ne_top + calc + _ ≤ ENNReal.ofReal p*(ENNReal.ofReal 50 * (∫⁻ t in Ioi 0, + (∫⁻ x, if t < 2*f x then ENNReal.ofReal (f x) else 0)*ENNReal.ofReal (t^(p-2)))) := by + gcongr + _ = _ := by + rw [truncation_layer_integral hf hf0 hp] + have hc : ENNReal.ofReal p*(ENNReal.ofReal 50 * ENNReal.ofReal (2^(p-1)/(p-1))) = + ENNReal.ofReal (50*p*2^(p-1)/(p-1)) := by + rw [← ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 50), + ← ENNReal.ofReal_mul (by linarith : 0 ≤ p)] + congr 1 + ring + simpa only [mul_assoc] using congrArg + (fun c => c*(∫⁻ x, ENNReal.ofReal ((f x)^p))) hc + +lemma disk_average_le_rationalMaximal_exact (ν : Measure ℂ) (x : ℂ) {r : ℝ} (hr : 0 < r) : + ν (ball x r) / volume (ball x r) ≤ rationalMaximal ν x := by + let I := {q : ℚ // 0 < q ∧ (q:ℝ) < r} + have hdir : Directed (· ⊆ ·) (fun q : I => ball x (q:ℚ)) := by + intro i j + refine ⟨⟨max i.val j.val,?_,?_⟩,?_,?_⟩ + · exact lt_max_of_lt_left i.property.1 + · exact_mod_cast max_lt i.property.2 j.property.2 + · exact ball_subset_ball (by exact_mod_cast le_max_left i.val j.val) + · exact ball_subset_ball (by exact_mod_cast le_max_right i.val j.val) + have heq : (⋃ q : I, ball x (q:ℚ)) = ball x r := by + ext y + constructor + · intro hy + obtain ⟨q,hq⟩ := mem_iUnion.mp hy + exact (ball_subset_ball q.property.2.le) hq + · intro hy + have hd : dist y x < r := hy + obtain ⟨q,hq0,hqr⟩ := exists_rat_btwn (show max 0 (dist y x) < r by exact max_lt hr hd) + have hq : 0 < (q:ℝ) := lt_of_le_of_lt (le_max_left _ _) hq0 + have hqRat : (0:ℚ) < q := by exact_mod_cast hq + refine mem_iUnion.mpr ⟨⟨q,hqRat,hqr⟩,?_⟩ + exact lt_of_le_of_lt (le_max_right _ _) hq0 + have hv0 : volume (ball x r) ≠ 0 := by + rw [volume_disk_real _ hr.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hr))) + apply (ENNReal.div_le_iff hv0 measure_ball_lt_top.ne).mpr + rw [← heq,hdir.measure_iUnion] + apply iSup_le + intro q + have hq0 : 0 < (q.val:ℝ) := by exact_mod_cast q.property.1 + have hqv : volume (ball x (q.val:ℝ)) ≠ 0 := by + rw [volume_disk_real _ hq0.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hq0))) + have hav : ν (ball x (q.val:ℝ)) / volume (ball x (q.val:ℝ)) ≤ rationalMaximal ν x := + le_iSup_of_le q.val (le_iSup_of_le q.property.1 le_rfl) + calc + _ ≤ rationalMaximal ν x * volume (ball x (q.val:ℝ)) := + (ENNReal.div_le_iff hqv measure_ball_lt_top.ne).mp hav + _ ≤ _ := by + gcongr + exact subset_iUnion (fun q : I => ball x (q:ℚ)) q + +/-- Countability loses neither radii nor high values: the rational expression is +exactly the centered disk maximal function of the measure. -/ +theorem all_radii_eq_rational (ν : Measure ℂ) (x : ℂ) : + (⨆ (r : ℝ) (_ : 0 < r), ν (ball x r)/volume (ball x r)) = rationalMaximal ν x := by + apply le_antisymm + · apply iSup_le + intro r + apply iSup_le + intro hr + exact disk_average_le_rationalMaximal_exact ν x hr + · unfold rationalMaximal + apply iSup_le + intro q + apply iSup_le + intro hq + have hq' : 0 < (q:ℝ) := by exact_mod_cast hq + exact le_iSup_of_le (q:ℝ) (le_iSup_of_le hq' le_rfl) + +lemma rationalMaximal_le_of_density_le {f : ℂ → ℝ≥0∞} {B : ℝ≥0∞} (hf : ∀ x, f x ≤ B) (x : ℂ) : + rationalMaximal (volume.withDensity f) x ≤ B := by + unfold rationalMaximal + apply iSup_le + intro q + apply iSup_le + intro hq + have hq' : 0 < (q:ℝ) := by exact_mod_cast hq + have hv0 : volume (ball x (q:ℝ)) ≠ 0 := by + rw [volume_disk_real _ hq'.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hq'))) + apply (ENNReal.div_le_iff hv0 measure_ball_lt_top.ne).mpr + rw [withDensity_apply _ measurableSet_ball] + calc + _ ≤ ∫⁻ y in ball x (q:ℝ), B := lintegral_mono hf + _ = _ := by simp + +end DiskMaximalTools + +open MeasureTheory Set +open scoped ENNReal NNReal + +namespace ScalarCancellation + +/-- A nonnegative scalar residual retaining exactly the net mass. Its removal +has the exact cancellation defect as L1 cost. -/ +theorem positive_residual {α : Type*} [MeasurableSpace α] {μ : Measure α} + {h : α → ℝ} (hh : Integrable h μ) (hc : 0 ≤ ∫ x, h x ∂μ) : + ∃ ρ : α → ℝ, Integrable ρ μ ∧ (∀ x, 0 ≤ ρ x) ∧ + (∀ x, ρ x ≤ max (h x) 0) ∧ (∫ x, ρ x ∂μ) = ∫ x, h x ∂μ ∧ + (∫ x, |h x-ρ x| ∂μ) = (∫ x, |h x| ∂μ) - ∫ x, h x ∂μ ∧ + (∀ x, h x = 0 → ρ x = 0) := by + let p : α → ℝ := fun x => max (h x) 0 + have hp : Integrable p μ := by + convert (hh.add hh.abs).div_const 2 using 1 + funext x + by_cases hx : 0 ≤ h x + · simp only [p,max_eq_left hx,abs_of_nonneg hx,Pi.add_apply] + ring + · simp only [p,max_eq_right (le_of_not_ge hx),abs_of_nonpos (le_of_not_ge hx),Pi.add_apply] + ring + have hp0 : 0 ≤ ∫ x, p x ∂μ := integral_nonneg (fun x => le_max_right _ _) + have hcp : (∫ x, h x ∂μ) ≤ ∫ x, p x ∂μ := integral_mono hh hp (fun x => le_max_left _ _) + by_cases hP : (∫ x, p x ∂μ) = 0 + · have hc0 : (∫ x, h x ∂μ) = 0 := le_antisymm (hP ▸ hcp) hc + refine ⟨0,integrable_zero _ _ _,fun _ => le_rfl,fun x => le_max_right _ _,?_,?_,fun _ _ => rfl⟩ + · simp [hc0] + · simp [hc0] + · have hPpos : 0 < ∫ x, p x ∂μ := lt_of_le_of_ne hp0 (Ne.symm hP) + let q := (∫ x, h x ∂μ)/(∫ x, p x ∂μ) + have hq0 : 0 ≤ q := div_nonneg hc hp0 + have hq1 : q ≤ 1 := (div_le_one hPpos).mpr hcp + let ρ : α → ℝ := fun x => q*p x + have hρ : Integrable ρ μ := hp.const_mul q + have hρ0 : ∀ x, 0 ≤ ρ x := fun x => mul_nonneg hq0 (le_max_right _ _) + have hρp : ∀ x, ρ x ≤ p x := fun x => mul_le_of_le_one_left (le_max_right _ _) hq1 + have hi : (∫ x, ρ x ∂μ) = ∫ x, h x ∂μ := by + rw [show ρ = fun x => q*p x from rfl,integral_const_mul] + exact div_mul_cancel₀ _ hP + have habs : ∀ x, |h x-ρ x| = |h x|-ρ x := by + intro x + by_cases hhx : 0 ≤ h x + · rw [abs_of_nonneg hhx,abs_of_nonneg] + simpa only [p,max_eq_left hhx] using sub_nonneg.mpr (hρp x) + · have hx0 : h x ≤ 0 := (lt_of_not_ge hhx).le + have : ρ x = 0 := by simp [ρ,p,max_eq_right hx0] + simp [this] + refine ⟨ρ,hρ,hρ0,hρp,hi,?_,?_⟩ + · simp_rw [habs] + rw [integral_sub hh.abs hρ,hi] + · intro x hx + simp [ρ,p,hx] + +/-- Every integrable scalar density splits into a constant-sign root and a +zero-mass error, without replacing the actual terminal density by its mass. -/ +theorem residual_split {α : Type*} [MeasurableSpace α] {μ : Measure α} + {h : α → ℝ} (hh : Integrable h μ) : + ∃ ρ β : α → ℝ, Integrable ρ μ ∧ Integrable β μ ∧ + (∀ x, h x = ρ x+β x) ∧ (∫ x, ρ x ∂μ) = ∫ x, h x ∂μ ∧ + (∫ x, β x ∂μ) = 0 ∧ (∫ x, |ρ x| ∂μ) = |∫ x, h x ∂μ| ∧ + (∫ x, |β x| ∂μ) = (∫ x, |h x| ∂μ)-|∫ x, h x ∂μ| ∧ + ((0 ≤ ∫ x, h x ∂μ) → ∀ x, 0 ≤ ρ x) ∧ + ((∫ x, h x ∂μ) < 0 → ∀ x, ρ x ≤ 0) ∧ + (∀ x, h x = 0 → ρ x = 0 ∧ β x = 0) := by + by_cases hc : 0 ≤ ∫ x, h x ∂μ + · obtain ⟨ρ,hρ,hρ0,_,hi,hcost,hzero⟩ := positive_residual hh hc + refine ⟨ρ,fun x => h x-ρ x,hρ,hh.sub hρ,fun x => by ring,hi,?_,?_,?_, + fun _ => hρ0,fun hn => (not_lt_of_ge hc hn).elim,?_⟩ + · rw [integral_sub hh hρ,hi,sub_self] + · simp_rw [abs_of_nonneg (hρ0 _)] + rw [hi,abs_of_nonneg hc] + · rwa [abs_of_nonneg hc] + · intro x hx + simp [hx,hzero x hx] + · have hc' : (∫ x, h x ∂μ) < 0 := lt_of_not_ge hc + have hn : 0 ≤ ∫ x, -h x ∂μ := by rw [integral_neg]; linarith + obtain ⟨ρ,hρ,hρ0,_,hi,hcost,hzero⟩ := positive_residual hh.neg hn + have hi' : (∫ x, ρ x ∂μ) = -(∫ x, h x ∂μ) := by simpa only [Pi.neg_apply,integral_neg] using hi + refine ⟨fun x => -ρ x,fun x => h x+ρ x,hρ.neg,hh.add hρ,fun x => by ring,?_,?_,?_,?_, + fun hn => (not_le_of_gt hc' hn).elim,fun _ x => neg_nonpos.mpr (hρ0 x),?_⟩ + · rw [integral_neg,hi',neg_neg] + · rw [integral_add hh hρ,hi',add_neg_cancel] + · simp_rw [abs_neg,abs_of_nonneg (hρ0 _)] + rw [hi',abs_of_neg hc'] + · have heq : (fun x => |-h x-ρ x|) = fun x => |h x+ρ x| := by + funext x + rw [show -h x-ρ x = -(h x+ρ x) by ring,abs_neg] + simp only [Pi.neg_apply] at hcost + rw [heq] at hcost + simpa only [abs_neg,integral_neg,abs_of_neg hc',sub_neg_eq_add] using hcost + · intro x hx + have hz := hzero x (by simp [hx]) + simp [hx,hz] + +/-- One backward refinement step. The new cancelling piece has cost no larger +than the scalar norm defect of the children; overlap can only lower this cost. -/ +theorem refinement_residual {α ι : Type*} [MeasurableSpace α] {μ : Measure α} + [Fintype ι] (w : ι → ℝ) (hw : ∀ i, 0 ≤ w i) (ρ : ι → α → ℝ) + (hρ : ∀ i, Integrable (ρ i) μ) : + ∃ R β : α → ℝ, Integrable R μ ∧ Integrable β μ ∧ + (∀ x, (∑ i, w i*ρ i x) = R x+β x) ∧ + (∫ x, R x ∂μ) = ∑ i, w i*(∫ x, ρ i x ∂μ) ∧ + (∫ x, β x ∂μ) = 0 ∧ + (∫ x, |R x| ∂μ) = |∑ i, w i*(∫ x, ρ i x ∂μ)| ∧ + (∫ x, |β x| ∂μ) ≤ + (∑ i, w i*(∫ x, |ρ i x| ∂μ))-|∑ i, w i*(∫ x, ρ i x ∂μ)| ∧ + ((0 ≤ ∑ i, w i*(∫ x, ρ i x ∂μ)) → ∀ x, 0 ≤ R x) ∧ + (∀ x, (∀ i, w i*ρ i x = 0) → R x = 0 ∧ β x = 0) := by + classical + let f : α → ℝ := fun x => ∑ i, w i*ρ i x + have hf : Integrable f μ := integrable_finsetSum _ (fun i _ => (hρ i).const_mul _) + have hfi : (∫ x, f x ∂μ) = ∑ i, w i*(∫ x, ρ i x ∂μ) := by + rw [show f = fun x => ∑ i, w i*ρ i x from rfl,integral_finsetSum] + · simp only [integral_const_mul] + · exact fun i _ => (hρ i).const_mul _ + have hcost : (∫ x, |f x| ∂μ) ≤ ∑ i, w i*(∫ x, |ρ i x| ∂μ) := by + calc + _ ≤ ∫ x, ∑ i, w i*|ρ i x| ∂μ := by + apply integral_mono hf.abs (integrable_finsetSum _ (fun i _ => (hρ i).abs.const_mul _)) + intro x + calc + _ ≤ ∑ i, |w i*ρ i x| := Finset.abs_sum_le_sum_abs _ _ + _ = _ := by simp_rw [abs_mul,abs_of_nonneg (hw _)] + _ = _ := by + rw [integral_finsetSum _ (fun i _ => (hρ i).abs.const_mul _)] + simp only [integral_const_mul] + obtain ⟨R,β,hR,hβ,hdec,hi,hzero,habs,hβcost,hpos,_,hsupp⟩ := residual_split hf + refine ⟨R,β,hR,hβ,hdec,hi.trans hfi,hzero,?_,?_,?_,?_⟩ + · rwa [hfi] at habs + · rw [hβcost,hfi] + exact sub_le_sub_right hcost _ + · intro hp + apply hpos + rwa [hfi] + · intro x hx + apply hsupp + exact Finset.sum_eq_zero (fun i _ => hx i) + +variable {α : Type*} [MeasurableSpace α] {μ : Measure α} + +/-- Canonical positive/negative root selected from the proved scalar splitting, +not an assumed decomposition. -/ +def root (μ : Measure α) (f : α → ℝ) : α → ℝ := by + classical + exact if h : Integrable f μ then (residual_split h).choose else 0 + +lemma root_spec {f : α → ℝ} (hf : Integrable f μ) : + Integrable (root μ f) μ ∧ + (∫ x, root μ f x ∂μ) = ∫ x, f x ∂μ ∧ + (∫ x, |root μ f x| ∂μ) = |∫ x, f x ∂μ| ∧ + (∫ x, |f x-root μ f x| ∂μ) = (∫ x, |f x| ∂μ)-|∫ x, f x ∂μ| ∧ + ((0 ≤ ∫ x, f x ∂μ) → ∀ x, 0 ≤ root μ f x) ∧ + ((∫ x, f x ∂μ) < 0 → ∀ x, root μ f x ≤ 0) ∧ + (∀ x, f x = 0 → root μ f x = 0) := by + rw [root,dite_eq_left hf] + obtain ⟨β,hR,_,hdec,hi,_,habs,hcost,hpos,hneg,hsupp⟩ := (residual_split hf).choose_spec + refine ⟨hR,hi,habs,?_,hpos,hneg,fun x hx => (hsupp x hx).1⟩ + convert hcost using 1 + apply integral_congr_ae + exact ae_of_all _ (fun x => by dsimp only; rw [hdec x]; congr 1; ring) + +variable {ι : Type*} [Fintype ι] + +def refined (w : ℕ → ι → ι → ℝ) (f : ι → α → ℝ) : ℕ → ι → α → ℝ + | 0,q => f q + | k+1,q => fun x => ∑ s, w k q s*refined w f k s x + +def roots (μ : Measure α) (w : ℕ → ι → ι → ℝ) (f : ι → α → ℝ) : ℕ → ι → α → ℝ + | 0,q => root μ (f q) + | k+1,q => root μ (fun x => ∑ s, w k q s*roots μ w f k s x) + +def errors (μ : Measure α) (w : ℕ → ι → ι → ℝ) (f : ι → α → ℝ) : ℕ → ι → α → ℝ + | 0,q => fun x => f q x-roots μ w f 0 q x + | k+1,q => fun x => (∑ s, w k q s*roots μ w f k s x)-roots μ w f (k+1) q x + +lemma refined_integrable (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + Integrable (refined w f k q) μ := by + induction k generalizing q with + | zero => exact hf q + | succ k ih => exact integrable_finsetSum _ (fun s _ => (ih s).const_mul _) + +lemma roots_integrable (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + Integrable (roots μ w f k q) μ := by + induction k generalizing q with + | zero => exact (root_spec (hf q)).1 + | succ k ih => exact (root_spec (integrable_finsetSum _ (fun s _ => (ih s).const_mul _))).1 + +lemma roots_mass (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + (∫ x, roots μ w f k q x ∂μ) = ∫ x, refined w f k q x ∂μ := by + induction k generalizing q with + | zero => exact (root_spec (hf q)).2.1 + | succ k ih => + rw [roots,(root_spec (integrable_finsetSum _ (fun s _ => (roots_integrable w hf k s).const_mul _))).2.1, + refined,integral_finsetSum _ (fun s _ => (roots_integrable w hf k s).const_mul _), + integral_finsetSum _ (fun s _ => (refined_integrable w hf k s).const_mul _)] + simp_rw [integral_const_mul,ih] + +lemma roots_abs_mass (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + (∫ x, |roots μ w f k q x| ∂μ) = |∫ x, refined w f k q x ∂μ| := by + cases k with + | zero => exact (root_spec (hf q)).2.2.1 + | succ k => + have hs := root_spec (integrable_finsetSum Finset.univ + (fun s _ => (roots_integrable w hf k s).const_mul (w k q s))) + change (∫ x, |root μ _ x| ∂μ) = _ + rw [hs.2.2.1,← hs.2.1] + exact congrArg abs (roots_mass w hf (k+1) q) + +lemma errors_integrable (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + Integrable (errors μ w f k q) μ := by + cases k with + | zero => exact (hf q).sub (roots_integrable w hf 0 q) + | succ k => + exact (integrable_finsetSum _ (fun s _ => (roots_integrable w hf k s).const_mul _)).sub + (roots_integrable w hf (k+1) q) + +lemma errors_zero_mass (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + (∫ x, errors μ w f k q x ∂μ) = 0 := by + cases k with + | zero => + rw [errors,integral_sub (hf q) (roots_integrable w hf 0 q),roots_mass] + exact sub_self _ + exact hf + | succ k => + rw [errors,integral_sub + (integrable_finsetSum _ (fun s _ => (roots_integrable w hf k s).const_mul _)) + (roots_integrable w hf (k+1) q),roots, + (root_spec (integrable_finsetSum _ (fun s _ => (roots_integrable w hf k s).const_mul _))).2.1, + sub_self] + +/-- The whole scalar cancellation tree is built by backward splitting. Each +nonterminal zero-mass piece costs at most its positive refinement norm defect. -/ +theorem errors_cost (w : ℕ → ι → ι → ℝ) (hw : ∀ k q s, 0 ≤ w k q s) + {f : ι → α → ℝ} (hf : ∀ q, Integrable (f q) μ) (k : ℕ) (q : ι) : + (∫ x, |errors μ w f (k+1) q x| ∂μ) ≤ + (∑ s, w k q s*|∫ x, refined w f k s x ∂μ|)-|∫ x, refined w f (k+1) q x ∂μ| := by + have hi : Integrable (fun x => ∑ s, w k q s*roots μ w f k s x) μ := + integrable_finsetSum _ (fun s _ => (roots_integrable w hf k s).const_mul _) + have hs := root_spec hi + change (∫ x, |(∑ s, w k q s*roots μ w f k s x)-root μ _ x| ∂μ) ≤ _ + rw [hs.2.2.2.1] + have hm : (∫ x, ∑ s, w k q s*roots μ w f k s x ∂μ) = ∫ x, refined w f (k+1) q x ∂μ := by + rw [← hs.2.1] + exact roots_mass w hf (k+1) q + rw [hm] + apply sub_le_sub_right + calc + _ ≤ ∫ x, ∑ s, w k q s*|roots μ w f k s x| ∂μ := by + apply integral_mono hi.abs (integrable_finsetSum _ (fun s _ => (roots_integrable w hf k s).abs.const_mul _)) + intro x + calc + _ ≤ ∑ s, |w k q s*roots μ w f k s x| := Finset.abs_sum_le_sum_abs _ _ + _ = _ := by simp_rw [abs_mul,abs_of_nonneg (hw k q _)] + _ = _ := by + rw [integral_finsetSum _ (fun s _ => (roots_integrable w hf k s).abs.const_mul _)] + simp_rw [integral_const_mul,roots_abs_mass w hf] + +lemma errors_terminal_cost (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (q : ι) : + (∫ x, |errors μ w f 0 q x| ∂μ) = (∫ x, |f q x| ∂μ)-|∫ x, f q x ∂μ| := + (root_spec (hf q)).2.2.2.1 + +lemma error_recurrence (w : ℕ → ι → ι → ℝ) (f : ι → α → ℝ) (k : ℕ) (q : ι) (x : α) : + refined w f (k+1) q x-roots μ w f (k+1) q x = errors μ w f (k+1) q x+ + ∑ s, w k q s*(refined w f k s x-roots μ w f k s x) := by + simp only [refined,errors,mul_sub,Finset.sum_sub_distrib] + ring + +/-- Support nesting is preserved by the new construction, even when child +scalar masses vanish or overlapping densities cancel each other. -/ +theorem roots_errors_support (w : ℕ → ι → ι → ℝ) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (S : ℕ → ι → Set α) + (hfS : ∀ q x, x ∉ S 0 q → f q x = 0) + (hS : ∀ k q s, w k q s ≠ 0 → S k s ⊆ S (k+1) q) : + ∀ k q x, x ∉ S k q → roots μ w f k q x = 0 ∧ errors μ w f k q x = 0 := by + intro k + induction k with + | zero => + intro q x hx + have hf0 := hfS q x hx + have hR0 := (root_spec (hf q)).2.2.2.2.2.2 x hf0 + exact ⟨hR0,by simp only [errors,roots,hf0,hR0,sub_self]⟩ + | succ k ih => + intro q x hx + have hz : (∑ s, w k q s*roots μ w f k s x) = 0 := by + apply Finset.sum_eq_zero + intro s _ + by_cases hw : w k q s = 0 + · simp [hw] + · have hs : x ∉ S k s := fun h => hx (hS k q s hw h) + rw [(ih s x hs).1,mul_zero] + have hR0 := (root_spec (integrable_finsetSum Finset.univ + (fun s _ => (roots_integrable w hf k s).const_mul (w k q s)))).2.2.2.2.2.2 x hz + exact ⟨hR0,by simp only [errors,roots,hz,hR0,sub_self]⟩ + +end ScalarCancellation + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskMaximalTools2.lean b/lean/OAI/Analysis/SignedDisk/DiskMaximalTools2.lean new file mode 100644 index 0000000000000000000000000000000000000000..586345ba4019d5717ef601c6ed4ce0b797acfd03 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskMaximalTools2.lean @@ -0,0 +1,435 @@ +import OAI.Analysis.SignedDisk.ActualMarkTrees2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace DiskMaximalTools + +lemma strong_three_halves_norm {f : ℂ → ℝ} (hf : Measurable f) + (hf0 : ∀ x, 0 ≤ f x) [IsFiniteMeasure (volume.withDensity (fun x => ENNReal.ofReal (f x)))] : + eLpNorm (fun x => (rationalMaximal (volume.withDensity (fun x => ENNReal.ofReal (f x))) x).toReal) + (3/2) volume ≤ ENNReal.ofReal ((150*2^(1/2:ℝ))^(2/3:ℝ))*eLpNorm f (3/2) volume := by + have h := strong_rationalMaximal hf hf0 (by norm_num : (1:ℝ) < 3/2) + have hs := ENNReal.rpow_le_rpow h (by norm_num : (0:ℝ) ≤ 2/3) + rw [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num : (0:ℝ) ≤ 2/3)] at hs + have hp : (50*(3/2:ℝ)*2^((3/2:ℝ)-1)/((3/2:ℝ)-1)) = 150*2^(1/2:ℝ) := by + norm_num + ring + rw [hp,ENNReal.ofReal_rpow_of_nonneg (by positivity) (by norm_num)] at hs + rw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by norm_num : (3/2:ℝ≥0∞) ≠ 0) + (ENNReal.div_ne_top (by norm_num) (by norm_num)) + (measurable_rationalMaximal _).ennreal_toReal.aestronglyMeasurable, + eLpNorm_eq_lintegral_rpow_enorm_toReal (by norm_num : (3/2:ℝ≥0∞) ≠ 0) + (ENNReal.div_ne_top (by norm_num) (by norm_num)) hf.aestronglyMeasurable] + norm_num only [ENNReal.toReal_div,ENNReal.toReal_ofNat,one_div_div] + simp only [← ofReal_norm,Real.norm_eq_abs,abs_of_nonneg ENNReal.toReal_nonneg, + abs_of_nonneg (hf0 _),ENNReal.ofReal_rpow_of_nonneg (hf0 _) (by norm_num : (0:ℝ) ≤ 3/2), + ENNReal.ofReal_rpow_of_nonneg ENNReal.toReal_nonneg (by norm_num : (0:ℝ) ≤ 3/2)] at hs ⊢ + exact hs + +lemma lintegral_le_three_halves_norm {f : ℂ → ℝ} (hf : AEStronglyMeasurable f volume) + (hf0 : ∀ x, 0 ≤ f x) {Q : Set ℂ} (hQ : volume Q ≤ 1) : + (∫⁻ x in Q, ENNReal.ofReal (f x)) ≤ eLpNorm f (3/2) volume := by + have h := eLpNorm_le_eLpNorm_mul_rpow_measure_univ + (show (1:ℝ≥0∞) ≤ 3/2 by rw [ENNReal.le_div_iff_mul_le (by norm_num) (by norm_num)]; norm_num) hf.restrict (μ := volume.restrict Q) + have he : (1 / ENNReal.toReal 1 - 1 / ENNReal.toReal (3/2)) = (1/3:ℝ) := by norm_num + rw [he,Measure.restrict_apply_univ] at h + have hpow : (volume Q)^(1/3:ℝ) ≤ 1 := by + simpa using ENNReal.rpow_le_rpow hQ (by norm_num : (0:ℝ) ≤ 1/3) + calc + _ = eLpNorm f 1 (volume.restrict Q) := by + rw [eLpNorm_one_eq_lintegral_enorm hf.restrict] + simp only [← ofReal_norm,Real.norm_eq_abs,abs_of_nonneg (hf0 _)] + _ ≤ eLpNorm f (3/2) (volume.restrict Q)*(volume Q)^(1/3:ℝ) := h + _ ≤ eLpNorm f (3/2) (volume.restrict Q) := by simpa using mul_le_mul_right hpow _ + _ ≤ _ := eLpNorm_mono_measure _ Measure.restrict_le_self +end DiskMaximalTools + +namespace PlanePotential +open LocalCancellation + +/-- The complete local L^(3/2) value estimate for a genuine finite vector +cancellation decomposition, with the common 1/100 price. -/ +theorem local_value_lp : ∃ C : ℝ, 0 < C ∧ + ∀ {ι : Type} [Fintype ι] (b : ι → ErrorPiece 2) {g : ℂ → ℝ}, + ContDiff ℝ 1 g → (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → + (∀ᵐ y, ‖y‖ ≤ 8 → gradient g y = ∑ i, (b i).density y) → + ∃ c : ℝ, eLpNorm (fun x => g x-c) (3/2) (volume.restrict {x : ℂ | ‖x‖ ≤ 8}) ≤ + ENNReal.ofReal (C * errorPrice b (1/100)) := by + obtain ⟨ψ,C,hC,hψ,hψc,hψ1,hψs,hprice⟩ := exists_green_price + obtain ⟨B,hB⟩ := hψc.exists_bound_of_continuous hψ.continuous + have hB0 : 0 ≤ B := (norm_nonneg (ψ 0)).trans (hB 0) + have hψB (z : ℂ) : |ψ z| ≤ B := by simpa only [Real.norm_eq_abs] using hB z + refine ⟨C,hC,?_⟩ + intro ι _ b g hg hD hdecomp + obtain ⟨D,hD⟩ := hD + refine ⟨∫ z, ψ z*g z,?_⟩ + apply (green_decomposition_norm_local hψ.continuous hψc hg hD hψ1 hψs hψB + (by norm_num : (1:ℝ) ≤ 8) (by norm_num : (0:ℝ) < 1+8) hB0 (by norm_num : (0:ℝ) < 8) + (fun i => (b i).density) (fun i => (b i).integrable) hdecomp).trans + apply (Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hprice (b i))).trans_eq + rw [← ENNReal.ofReal_sum_of_nonneg (fun i _ => mul_nonneg (mul_nonneg hC.le (Real.rpow_nonneg (b i).size_pos.le _)) (b i).mass_nonneg)] + congr 1 + rw [errorPrice,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring +end PlanePotential + +namespace DiskMoments +open DiskMaximalTools + +lemma signedAverage_sub_const {g : ℂ → ℝ} (hg : Continuous g) (c : ℝ) (x : ℂ) {t : ℝ} (ht : 0 < t) : + signedAverage (fun y => g y-c) x t = signedAverage g x t-c := by + have hi : IntegrableOn g (Metric.ball x t) := + (hg.continuousOn.integrableOn_compact (isCompact_closedBall x t)).mono_set Metric.ball_subset_closedBall + have hc : IntegrableOn (fun _ : ℂ => c) (Metric.ball x t) := integrableOn_const measure_ball_lt_top.ne + unfold signedAverage + rw [integral_sub hi hc,integral_const] + have hv : (volume (Metric.ball x t)).toReal = Real.pi*t^2 := by + rw [volume_disk_real x ht.le,ENNReal.toReal_ofReal (by positivity)] + simp only [Measure.real,Measure.restrict_apply_univ,hv,smul_eq_mul] + field_simp + +/-- A true disk average of a continuous function is controlled by the local +absolute-density maximal function. No maximizing-radius selection is used. -/ +lemma local_average_le {g : ℂ → ℝ} (hg : Continuous g) (c : ℝ) + {x : ℂ} (hx : ‖x‖ ≤ 2) {t : ℝ} (ht : 0 < t) (ht4 : t ≤ 4) : + ENNReal.ofReal |signedAverage g x t-c| ≤ + rationalMaximal (volume.withDensity (fun y => ENNReal.ofReal + (({y : ℂ | ‖y‖ ≤ 8}.indicator (fun y => |g y-c|)) y))) x := by + let f : ℂ → ℝ := {y : ℂ | ‖y‖ ≤ 8}.indicator (fun y => |g y-c|) + have hf : Measurable f := ((hg.measurable.sub measurable_const).abs).indicator + (measurableSet_le measurable_norm measurable_const) + have hfi : Integrable f := by + apply IntegrableOn.integrable_indicator _ (measurableSet_le measurable_norm measurable_const) + apply ContinuousOn.integrableOn_compact + (show IsCompact {y : ℂ | ‖y‖ ≤ 8} by simpa only [Metric.closedBall,dist_zero_right] using isCompact_closedBall (0:ℂ) 8) + exact (hg.sub continuous_const).abs.continuousOn + have hsub (y : ℂ) (hy : y ∈ Metric.ball x t) : ‖y‖ ≤ 8 := by + have hy' : ‖y-x‖ < t := by simpa only [Metric.mem_ball,dist_eq_norm] using hy + have hh := norm_add_le (y-x) x + rw [sub_add_cancel] at hh + linarith + have he : (∫ y in Metric.ball x t, f y) = ∫ y in Metric.ball x t, |g y-c| := by + apply setIntegral_congr_fun measurableSet_ball + intro y hy + simp [f,hsub y hy] + have hav : |signedAverage g x t-c| ≤ (∫ y in Metric.ball x t, f y)/(Real.pi*t^2) := by + rw [← signedAverage_sub_const hg c x ht,signedAverage,abs_div,abs_of_pos (by positivity : 0 < Real.pi*t^2),he] + apply div_le_div_of_nonneg_right _ (by positivity) + simpa only [Real.norm_eq_abs] using norm_integral_le_integral_norm (fun y => g y-c) (μ := volume.restrict (Metric.ball x t)) + have hν : (volume.withDensity (fun y => ENNReal.ofReal (f y))) (Metric.ball x t) = + ENNReal.ofReal (∫ y in Metric.ball x t, f y) := by + rw [withDensity_apply _ measurableSet_ball] + exact (ofReal_integral_eq_lintegral_ofReal hfi.integrableOn + (ae_of_all _ (fun y => by dsimp [f]; exact Set.indicator_nonneg (fun _ _ => abs_nonneg _ ) y))).symm + apply (ENNReal.ofReal_le_ofReal hav).trans + rw [ENNReal.ofReal_div_of_pos (by positivity : 0 < Real.pi*t^2),← hν,← volume_disk_real x ht.le] + exact disk_average_le_rationalMaximal_exact _ x ht +end DiskMoments + +namespace PlanePotential +open LocalCancellation DiskMaximalTools DiskMoments + +/-- Full local value-oscillation price, for every pair of positive radii at +most four. The measurable majorant is an actual centered Euclidean disk +maximal function, not an assumed analytic input. -/ +theorem local_value_majorant : ∃ C : ℝ, 0 < C ∧ + ∀ {ι : Type} [Fintype ι] (b : ι → ErrorPiece 2) {g : ℂ → ℝ}, + ContDiff ℝ 1 g → (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → + (∀ᵐ y, ‖y‖ ≤ 8 → gradient g y = ∑ i, (b i).density y) → + ∀ Q : Set ℂ, volume Q ≤ ENNReal.ofReal 1 → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ x in Q, F x) ≤ ENNReal.ofReal (C*errorPrice b (1/100)) ∧ + ∀ x, ‖x‖ ≤ 2 → ∀ t t', 0 < t → t ≤ 4 → 0 < t' → t' ≤ 4 → + ENNReal.ofReal |signedAverage g x t-signedAverage g x t'| ≤ F x := by + obtain ⟨C,hC,hlocal⟩ := local_value_lp + let K : ℝ := (150*2^(1/2:ℝ))^(2/3:ℝ) + have hK : 0 < K := by dsimp [K]; positivity + refine ⟨2*K*C,by positivity,?_⟩ + intro ι _ b g hg hD hdecomp Q hQ + obtain ⟨c,hc⟩ := hlocal b hg hD hdecomp + let f : ℂ → ℝ := {y : ℂ | ‖y‖ ≤ 8}.indicator (fun y => |g y-c|) + have hf : Measurable f := ((hg.continuous.measurable.sub measurable_const).abs).indicator + (measurableSet_le measurable_norm measurable_const) + have hf0 (y : ℂ) : 0 ≤ f y := Set.indicator_nonneg (fun _ _ => abs_nonneg _) y + have hfi : Integrable f := by + apply IntegrableOn.integrable_indicator _ (measurableSet_le measurable_norm measurable_const) + apply ContinuousOn.integrableOn_compact + (show IsCompact {y : ℂ | ‖y‖ ≤ 8} by simpa only [Metric.closedBall,dist_zero_right] using isCompact_closedBall (0:ℂ) 8) + exact (hg.continuous.sub continuous_const).abs.continuousOn + let ν := volume.withDensity (fun y => ENNReal.ofReal (f y)) + have hν : ν univ = ENNReal.ofReal (∫ y, f y) := by + rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ] + exact (ofReal_integral_eq_lintegral_ofReal hfi (ae_of_all _ hf0)).symm + have : IsFiniteMeasure ν := ⟨by rw [hν]; exact ENNReal.ofReal_lt_top⟩ + let M : ℂ → ℝ := fun x => (rationalMaximal ν x).toReal + have hM : Measurable M := (measurable_rationalMaximal ν).ennreal_toReal + have hMf : ∀ x, rationalMaximal ν x ≠ ⊤ := by + obtain ⟨B,hB⟩ := (isCompact_closedBall (0:ℂ) 8).exists_bound_of_continuousOn + (hg.continuous.sub (continuous_const (y := c))).continuousOn + have hbnd (y : ℂ) : f y ≤ max B 0 := by + by_cases hy : ‖y‖ ≤ 8 + · have hby := hB y (by simpa only [Metric.mem_closedBall,dist_zero_right] using hy) + simpa [f, hy, Real.norm_eq_abs] using hby.trans (le_max_left B 0) + · simp [f, hy] + intro x + exact ne_of_lt ((rationalMaximal_le_of_density_le (fun y => ENNReal.ofReal_le_ofReal (hbnd y)) x).trans_lt ENNReal.ofReal_lt_top) + have hfnorm : eLpNorm f (3/2) volume = eLpNorm (fun x => g x-c) (3/2) (volume.restrict {x : ℂ | ‖x‖ ≤ 8}) := by + rw [eLpNorm_indicator_eq_eLpNorm_restrict (measurableSet_le measurable_norm measurable_const)] + simpa only [Real.norm_eq_abs] using eLpNorm_norm (fun x => g x-c) + (hg.continuous.sub continuous_const).aestronglyMeasurable + (p := (3/2:ℝ≥0∞)) (μ := volume.restrict {x : ℂ | ‖x‖ ≤ 8}) + have hn : eLpNorm M (3/2) volume ≤ ENNReal.ofReal K*ENNReal.ofReal (C*errorPrice b (1/100)) := by + apply (strong_three_halves_norm hf hf0).trans + apply mul_le_mul_right _ _ + simpa only [hfnorm] using hc + refine ⟨fun x => ENNReal.ofReal 2*ENNReal.ofReal (M x),measurable_const.mul hM.ennreal_ofReal,?_,?_⟩ + · rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] + apply (mul_le_mul_right (lintegral_le_three_halves_norm hM.aestronglyMeasurable + (fun _ => ENNReal.toReal_nonneg) (by simpa using hQ)) _).trans + apply (mul_le_mul_right hn _).trans_eq + rw [← ENNReal.ofReal_mul hK.le,← ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 2)] + congr 1 + ring + · intro x hx t t' ht ht4 ht' ht4' + have ha : |signedAverage g x t-c| ≤ M x := + (ENNReal.ofReal_le_iff_le_toReal (hMf x)).mp (local_average_le hg.continuous c hx ht ht4) + have hb : |signedAverage g x t'-c| ≤ M x := + (ENNReal.ofReal_le_iff_le_toReal (hMf x)).mp (local_average_le hg.continuous c hx ht' ht4') + change ENNReal.ofReal _ ≤ ENNReal.ofReal 2 * ENNReal.ofReal (M x) + rw [← ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 2)] + apply ENNReal.ofReal_le_ofReal + have hh := abs_sub_le (signedAverage g x t) c (signedAverage g x t') + rw [abs_sub_comm c] at hh + linarith +end PlanePotential + +namespace AffineDensities +lemma fderiv_affine_bound {g : ℂ → ℝ} (hg : Differentiable ℝ g) (p : ℂ) (r : ℝ) + {D : ℝ} (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) : + ∃ B : ℝ, ∀ X, ‖fderiv ℝ (fun Y => g (p+r • Y)) X‖ ≤ B := by + refine ⟨D*|r|,?_⟩ + intro X + have hA : HasFDerivAt (fun Y : ℂ => p+r • Y) + (r • ContinuousLinearMap.id ℝ ℂ) X := by + simpa using ((hasFDerivAt_id X).const_smul r).const_add p + have hd := (hg (p+r • X)).hasFDerivAt.comp X hA + simp only [Function.comp_def] at hd + rw [hd.fderiv] + apply (ContinuousLinearMap.opNorm_comp_le _ _).trans + simp only [norm_smul,Real.norm_eq_abs,ContinuousLinearMap.norm_id, mul_one] + exact mul_le_mul_of_nonneg_right (hD _) (abs_nonneg _) +end AffineDensities + +namespace CommonPrices +open DyadicHats ConeCoordinates LocalCancellation AffineDensities DirectionNeighbors Finset DiskMoments PricePieces + +/-- The actual common-price value estimate, including every terminal error and +all roots. This is the third local analytic input to signed run assembly. -/ +theorem value_cell_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → ∀ (k : ℕ) (p : ℤ × ℤ) + {n : ℂ}, n ∈ fixedPalette.labels → ∀ Q : Set ℂ, volume Q ≤ ENNReal.ofReal 1 → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ X in Q, F X) ≤ ENNReal.ofReal (C*(scale r k)⁻¹* + (rootMass (gradient g) r k (cellRoots N p)+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ X, ‖X‖ ≤ 2 → ∀ t t', 0 < t → t ≤ 4 → 0 < t' → t' ≤ 4 → + ENNReal.ofReal |signedAverage (fun Y => g (point (scale r k) p+scale r k • Y)) X t- + signedAverage (fun Y => g (point (scale r k) p+scale r k • Y)) X t'| ≤ F X := by + obtain ⟨C,hC,hmajor⟩ := PlanePotential.local_value_majorant + refine ⟨4*C,by positivity,?_⟩ + intro N r R hr hR hN g hg hh hsupp hD k p n hn Q hQ + let b := sizeErrors hr hh k (point (scale r k) p) (cellRoots N p) n + have hg' : ContDiff ℝ 1 (fun Y => g (point (scale r k) p+scale r k • Y)) := hg.comp (by fun_prop) + obtain ⟨D,hD⟩ := hD + have hD' := fderiv_affine_bound (hg.differentiable one_ne_zero) (point (scale r k) p) (scale r k) hD + have hd : ∀ᵐ X, ‖X‖ ≤ 8 → + gradient (fun Y => g (point (scale r k) p+scale r k • Y)) X = ∑ i, (b i).density X := by + filter_upwards with X hX + exact (sizeErrors_gradient hr hR hN (hg.differentiable one_ne_zero) hh hsupp k p + (fixedPalette.unit n hn) X (by linarith)).symm + obtain ⟨F,hFm,hFi,hFb⟩ := hmajor b hg' hD' hd Q hQ + refine ⟨F,hFm,?_,hFb⟩ + apply hFi.trans + apply ENNReal.ofReal_le_ofReal + have hb := sizeErrors_price hr hR hN hh hsupp k (point (scale r k) p) (cellRoots N p) hn + have hDp : 0 ≤ cellPrice N r (gradient g) k (cellRoots N p) := + sum_nonneg (fun q _ => rootPrice_nonneg hr hR hN hh hsupp k q) + change errorPrice b (1/100) ≤ _ at hb + have hrk := scale_pos hr k + nlinarith [mul_le_mul_of_nonneg_left hb hC.le,inv_nonneg.mpr hrk.le, + mul_nonneg (inv_nonneg.mpr hrk.le) hDp] +end CommonPrices + +namespace PhysicalCells +open MeasureTheory Set + +def unitCell : Set ℂ := {X | X.re ∈ Ico (0:ℝ) 1 ∧ X.im ∈ Ico (0:ℝ) 1} +def toUnit (p : ℂ) (r : ℝ) (y : ℂ) : ℂ := r⁻¹ • (y-p) +def cell (p : ℂ) (r : ℝ) : Set ℂ := toUnit p r ⁻¹' unitCell + +lemma unitCell_measurable : MeasurableSet unitCell := + (Complex.measurable_re measurableSet_Ico).inter (Complex.measurable_im measurableSet_Ico) +lemma toUnit_continuous (p : ℂ) (r : ℝ) : Continuous (toUnit p r) := by unfold toUnit; fun_prop +lemma cell_measurable (p : ℂ) (r : ℝ) : MeasurableSet (cell p r) := + (toUnit_continuous p r).measurable unitCell_measurable +lemma volume_unitCell : volume unitCell = 1 := by + have he := Complex.volume_preserving_equiv_real_prod.measure_preimage + (s := Ico (0:ℝ) 1 ×ˢ Ico (0:ℝ) 1) (measurableSet_Ico.prod measurableSet_Ico).nullMeasurableSet + change volume unitCell = _ at he + rw [he] + change (volume.prod volume) (Ico (0:ℝ) 1 ×ˢ Ico (0:ℝ) 1) = 1 + rw [Measure.prod_prod] + norm_num +lemma norm_unitCell {X : ℂ} (hX : X ∈ unitCell) : ‖X‖ ≤ 2 := by + have h := Complex.norm_le_abs_re_add_abs_im X + rw [abs_of_nonneg hX.1.1,abs_of_nonneg hX.2.1] at h + linarith [hX.1.2,hX.2.2] +lemma toUnit_affine (p : ℂ) {r : ℝ} (hr : r ≠ 0) (X : ℂ) : toUnit p r (p+r • X) = X := by + simp [toUnit,hr] +lemma affine_toUnit (p : ℂ) {r : ℝ} (hr : r ≠ 0) (y : ℂ) : p+r • toUnit p r y = y := by + simp [toUnit,hr] + +lemma lintegral_smul (F : ℂ → ℝ≥0∞) {r : ℝ} (hr : r ≠ 0) : + (∫⁻ X : ℂ, F (r • X)) = ENNReal.ofReal ((r^2)⁻¹)*(∫⁻ y, F y) := by + have he := (lintegral_map_equiv (μ := volume) F + (Homeomorph.smul (isUnit_iff_ne_zero.mpr hr).unit).toMeasurableEquiv).symm + change (∫⁻ X : ℂ, F (r • X)) = ∫⁻ y, F y ∂Measure.map (fun X : ℂ => r • X) volume at he + rw [he,Measure.map_addHaar_smul volume hr,lintegral_smul_measure] + simp only [Complex.finrank_real_complex,abs_of_nonneg (inv_nonneg.mpr (sq_nonneg r)),smul_eq_mul] + +lemma lintegral_toUnit (F : ℂ → ℝ≥0∞) (p : ℂ) {r : ℝ} (hr : r ≠ 0) : + (∫⁻ y : ℂ, F (toUnit p r y)) = ENNReal.ofReal (r^2)*(∫⁻ X, F X) := by + calc + (∫⁻ y : ℂ, F (r⁻¹ • (y-p))) = ∫⁻ y : ℂ, F (r⁻¹ • y) := + lintegral_sub_right_eq_self (μ := (volume : Measure ℂ)) (fun y : ℂ => F (r⁻¹ • y)) p + _ = _ := by rw [lintegral_smul _ (inv_ne_zero hr),inv_pow,inv_inv] + +/-- Exact physical-space change of variables, with the two-dimensional volume +factor and no integrability or measurability assumptions on the majorant. -/ +lemma lintegral_cell (F : ℂ → ℝ≥0∞) (p : ℂ) {r : ℝ} (hr : r ≠ 0) : + (∫⁻ y in cell p r, F y) = ENNReal.ofReal (r^2)*∫⁻ X in unitCell, F (p+r • X) := by + rw [← lintegral_indicator (cell_measurable p r),← lintegral_indicator unitCell_measurable] + have he (y : ℂ) : (cell p r).indicator F y = + unitCell.indicator (fun X => F (p+r • X)) (toUnit p r y) := by + by_cases hy : y ∈ cell p r + · rw [Set.indicator_of_mem hy,Set.indicator_of_mem (show toUnit p r y ∈ unitCell from hy),affine_toUnit p hr] + · rw [Set.indicator_of_notMem hy,Set.indicator_of_notMem (show toUnit p r y ∉ unitCell from hy)] + simp_rw [he] + exact lintegral_toUnit _ p hr + +lemma cell_majorant {F : ℂ → ℝ≥0∞} (p : ℂ) {r : ℝ} (hr : r ≠ 0) : + (∫⁻ y in cell p r, F (toUnit p r y)) = ENNReal.ofReal (r^2)*∫⁻ X in unitCell, F X := by + rw [lintegral_cell _ p hr] + simp only [toUnit_affine p hr] +end PhysicalCells + +namespace DiskMoments +lemma signedAverage_affine (g : ℂ → ℝ) (p X : ℂ) {r t : ℝ} (hr : 0 < r) (ht : 0 < t) : + signedAverage (fun Y => g (p+r • Y)) X t = signedAverage g (p+r • X) (r*t) := by + rw [signedAverage_fixedDomain _ _ ht,signedAverage_fixedDomain _ _ (mul_pos hr ht)] + congr 1 + apply setIntegral_congr_fun measurableSet_ball + intro Z _ + change g (p+r • (X+t • Z)) = g (p+r • X+(r*t) • Z) + congr 1 + rw [smul_add,smul_smul] + abel + +lemma gradient_signedAverage {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (x : ℂ) {t : ℝ} (ht : 0 < t) : + gradient (fun y => signedAverage g y t) x = + (Real.pi*t^2)⁻¹ • ∫ y in Metric.ball x t, gradient g y := by + have hi : IntegrableOn (fun z : ℂ => fderiv ℝ g (x+t • z)) (Metric.ball 0 1) := + (((hg.continuous_fderiv one_ne_zero).comp (by fun_prop)).continuousOn.integrableOn_compact + (isCompact_closedBall (0:ℂ) 1)).mono_set Metric.ball_subset_closedBall + rw [gradient,(hasFDerivAt_signedAverage hg hD x ht).fderiv,map_smul] + have he := (InnerProductSpace.toDual ℝ ℂ).symm.toContinuousLinearMap.integral_comp_comm hi + change (∫ z in Metric.ball (0:ℂ) 1, (InnerProductSpace.toDual ℝ ℂ).symm (fderiv ℝ g (x+t • z))) = + (InnerProductSpace.toDual ℝ ℂ).symm (∫ z in Metric.ball (0:ℂ) 1, fderiv ℝ g (x+t • z)) at he + rw [← he] + change (1/Real.pi) • (∫ z in Metric.ball (0:ℂ) 1, gradient g (x+t • z)) = _ + rw [integral_scale_ball (fun z => gradient g (x+z)) ht,integral_translate_ball,smul_smul] + congr 1 + ring + +lemma gradient_average_affine {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (p X : ℂ) {r t : ℝ} (hr : 0 < r) (ht : 0 < t) : + gradient (fun Y => signedAverage (fun Z => g (p+r • Z)) Y t) X = + r • gradient (fun y => signedAverage g y (r*t)) (p+r • X) := by + have he : (fun Y => signedAverage (fun Z => g (p+r • Z)) Y t) = + (fun Y => signedAverage g (p+r • Y) (r*t)) := by + funext Y + exact signedAverage_affine g p Y hr ht + rw [he] + exact AffineDensities.gradient_affine (fun y => + (hasFDerivAt_signedAverage hg hD y (mul_pos hr ht)).differentiableAt) p r X + +def PhysicalNeighborhoodRadius (g : ℂ → ℝ) (r : ℝ) (x : ℂ) (t : ℝ) : Prop := + t ∈ Icc r (2*r) ∧ ∀ s, 0 < s → |s-t| ≤ r/4 → signedAverage g x s ≤ signedAverage g x t + +def PhysicalEndpointRadius (g : ℂ → ℝ) (r : ℝ) (x : ℂ) (t : ℝ) : Prop := + t ∈ Icc r (2*r) ∧ (t = r ∨ t = 2*r ∨ ∀ s ∈ Icc r (2*r), signedAverage g x s ≤ signedAverage g x t) + +lemma neighborhoodRadius_affine {g : ℂ → ℝ} (p X : ℂ) {r t : ℝ} (hr : 0 < r) + (ht : PhysicalNeighborhoodRadius g r (p+r • X) (r*t)) : + NeighborhoodRadius (fun Y => g (p+r • Y)) X t := by + have ht1 : 1 ≤ t := (le_of_mul_le_mul_left (by simpa only [mul_one] using ht.1.1) hr) + have ht2 : t ≤ 2 := (le_of_mul_le_mul_left (by simpa only [mul_comm 2 r] using ht.1.2) hr) + refine ⟨⟨ht1,ht2⟩,?_⟩ + intro s hs habs + rw [signedAverage_affine _ _ _ hr hs,signedAverage_affine _ _ _ hr (by linarith)] + apply ht.2 (r*s) (mul_pos hr hs) + rw [← mul_sub,abs_mul,abs_of_pos hr] + nlinarith + +lemma endpointRadius_affine {g : ℂ → ℝ} (p X : ℂ) {r t : ℝ} (hr : 0 < r) + (ht : PhysicalEndpointRadius g r (p+r • X) (r*t)) : + EndpointRadius (fun Y => g (p+r • Y)) X t := by + have ht1 : 1 ≤ t := (le_of_mul_le_mul_left (by simpa only [mul_one] using ht.1.1) hr) + have ht2 : t ≤ 2 := (le_of_mul_le_mul_left (by simpa only [mul_comm 2 r] using ht.1.2) hr) + refine ⟨⟨ht1,ht2⟩,?_⟩ + rcases ht.2 with he | he | he + · left + nlinarith + · right; left + nlinarith + · right; right + intro s hs + rw [signedAverage_affine _ _ _ hr (by linarith [hs.1]),signedAverage_affine _ _ _ hr (by linarith)] + exact he (r*s) ⟨by nlinarith [hs.1],by nlinarith [hs.2]⟩ +end DiskMoments + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskMoments1.lean b/lean/OAI/Analysis/SignedDisk/DiskMoments1.lean new file mode 100644 index 0000000000000000000000000000000000000000..a60cdc84a5fc3da36e702b39ed043d906456460e --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskMoments1.lean @@ -0,0 +1,462 @@ +import OAI.Analysis.SignedDisk.SignedRuns1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace DiskMoments +lemma signedAverage_hasCompactSupport {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (hc : HasCompactSupport g) {t : ℝ} (ht : 0 < t) : + HasCompactSupport (fun x => signedAverage g x t) := by + have he : RadiusEnvelope.envelope (fun s x => signedAverage g x s) t t = + fun x => signedAverage g x t := by + funext x + obtain ⟨s,hs,he,_⟩ := RadiusEnvelope.attains (u := fun s x => signedAverage g x s) (a := t) (b := t) le_rfl x (signedAverage_radius_continuousOn hg x ht) + have hst : s = t := le_antisymm hs.2 hs.1 + simpa only [hst] using he + rw [← he] + exact run_envelope_hasCompactSupport hg hc ht le_rfl +end DiskMoments + +namespace SignedRuns +open DiskMoments ActualLabels + +def Regular (f : ℂ → ℂ) : Prop := HasCompactSupport f ∧ ∃ L : ℝ≥0, LipschitzWith L f + +lemma regular_zero : Regular (fun _ : ℂ => (0:ℂ)) := + ⟨HasCompactSupport.zero,0,LipschitzWith.const 0⟩ + +lemma regular_add {f g : ℂ → ℂ} (hf : Regular f) (hg : Regular g) : + Regular (fun x => f x+g x) := by + obtain ⟨hfC,L,hfL⟩ := hf + obtain ⟨hgC,K,hgL⟩ := hg + exact ⟨hfC.add hgC,L+K,hfL.add hgL⟩ + +lemma regular_scalar {f : ℂ → ℝ} (hc : HasCompactSupport f) {L : ℝ≥0} + (hf : LipschitzWith L f) (n : Label) : Regular (fun x => f x • (n:ℂ)) := by + refine ⟨hc.smul_right,L,?_⟩ + rw [lipschitzWith_iff_norm_sub_le] at hf ⊢ + intro x y + simpa only [← sub_smul,norm_smul,label_unit,mul_one] using hf x y + +lemma regular_listSum {α : Type*} (l : List α) (f : α → ℂ → ℂ) + (hf : ∀ a ∈ l, Regular (f a)) : Regular (fun x => (l.map fun a => f a x).sum) := by + induction l with + | nil => exact regular_zero + | cons a l ih => + exact regular_add (hf a (by simp)) (ih (fun b hb => hf b (by simp [hb]))) + +lemma runTerm_regular {g : ℂ → ℝ} {r : ℕ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (a : Run) (ha : a.first ≤ a.last) : + Regular (fun x => (runEnvelope g r a.first a.last x-signedAverage g x (r a.first)) • (a.dir:ℂ)) := by + have hab : r a.last ≤ 2*r a.first := by + have := radius_antitone r hr hstep ha + linarith [hr a.first] + obtain ⟨L,hL⟩ := run_envelope_lipschitz hg hgc (hr a.last) hab + obtain ⟨K,hK⟩ := hg.lipschitzWith_of_hasCompactSupport hgc one_ne_zero + apply regular_scalar + ((run_envelope_hasCompactSupport hg hgc (hr a.last) hab).sub (signedAverage_hasCompactSupport hg hgc (hr a.first))) + (hL.sub (signedAverage_lipschitz hK (hr a.first))) + +/-- Every exact history potential is compactly supported and Lipschitz, as +needed for signed weighted integration by parts. -/ +theorem potential_regular {g : ℂ → ℝ} {r : ℕ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (p : List Label) : Regular (fun x => potential g r x p) := by + cases p with + | nil => exact regular_zero + | cons n p => + simp_rw [potential_eq_runs] + exact regular_listSum (runs (n::p)) _ (fun a ha => + runTerm_regular hg hgc hr hstep a (runs_bounds n p a ha).1) + +open Complex + +def divergence (V : ℂ → ℂ) (x : ℂ) : ℝ := + fderiv ℝ (fun y => (V y).re) x 1+fderiv ℝ (fun y => (V y).im) x I + +lemma inner_coordinates (z w : ℂ) : + inner ℝ z w = inner ℝ z (1:ℂ)*w.re+inner ℝ z I*w.im := by + conv_lhs => rw [← Complex.re_add_im w] + rw [inner_add_right] + have hre : (w.re:ℂ) = w.re • (1:ℂ) := by simp + have him : (w.im:ℂ)*I = w.im • I := by rw [Complex.real_smul] + rw [hre,him,real_inner_smul_right,real_inner_smul_right] + ring + +lemma gradient_aestronglyMeasurable (f : ℂ → ℝ) : AEStronglyMeasurable (gradient f) := + ((InnerProductSpace.toDual ℝ ℂ).symm.continuous.measurable.comp + (measurable_fderiv ℝ f)).aestronglyMeasurable + +lemma gradient_norm_le {f : ℂ → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) (x : ℂ) : + ‖gradient f x‖ ≤ (L:ℝ) := by + simpa only [gradient,(InnerProductSpace.toDual ℝ ℂ).symm.norm_map] using + (norm_fderiv_le_of_lipschitz ℝ hf : ‖fderiv ℝ f x‖ ≤ (L:ℝ)) + +lemma integrable_fderiv_apply {f : ℂ → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) + (hc : HasCompactSupport f) (v : ℂ) : Integrable (fun x => fderiv ℝ f x v) := by + have hi := (innerSL ℝ v).integrable_comp (SignedDisk.LipschitzWith.integrable_gradient (μ := volume) hf hc) + apply hi.congr + filter_upwards with x + change inner ℝ v (gradient f x) = _ + rw [real_inner_comm,gradient,InnerProductSpace.toDual_symm_apply] + +lemma integrable_gradient_mul {f g : ℂ → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) + (hg : Integrable g) (v : ℂ) : Integrable (fun x => inner ℝ (gradient f x) v*g x) := by + apply hg.bdd_mul ((gradient_aestronglyMeasurable f).inner aestronglyMeasurable_const) + filter_upwards with x + exact (norm_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (gradient_norm_le hf x) (norm_nonneg v)) + +lemma regular_integrable (V : ℂ → ℂ) (hV : Regular V) : Integrable V := by + obtain ⟨hc,L,hL⟩ := hV + exact hL.continuous.integrable_of_hasCompactSupport hc + +lemma weighted_divergence_integrable {w : ℂ → ℝ} {K : ℝ≥0} (hw : LipschitzWith K w) + (hb : ∀ x, ‖w x‖ ≤ 1) {V : ℂ → ℂ} (hV : Regular V) : + Integrable (fun x => w x*divergence V x) := by + obtain ⟨hc,L,hL⟩ := hV + have hr := integrable_fderiv_apply (Complex.reCLM.lipschitzWith.comp hL) + (hc.comp_left (map_zero Complex.reCLM)) (1:ℂ) + have hi := integrable_fderiv_apply (Complex.imCLM.lipschitzWith.comp hL) + (hc.comp_left (map_zero Complex.imCLM)) I + exact (hr.add hi).bdd_mul hw.continuous.aestronglyMeasurable (ae_of_all _ hb) + +lemma potential_flux_integrable {w : ℂ → ℝ} {K : ℝ≥0} (hw : LipschitzWith K w) + {V : ℂ → ℂ} (hV : Regular V) : + Integrable (fun x => inner ℝ (gradient w x) (V x)) := by + have hi := regular_integrable V hV + apply (hi.norm.const_mul (K:ℝ)).mono' + ((gradient_aestronglyMeasurable w).inner hi.aestronglyMeasurable) + filter_upwards with x + exact (norm_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (gradient_norm_le hw x) (norm_nonneg _)) + +/-- Weighted vector integration by parts for the actual class of compact +Lipschitz path potentials and bounded Lipschitz spatial history weights. -/ +theorem vector_weighted_ibp {w : ℂ → ℝ} {K : ℝ≥0} (hw : LipschitzWith K w) + (hb : ∀ x, ‖w x‖ ≤ 1) {V : ℂ → ℂ} (hV : Regular V) : + (∫ x, w x*divergence V x) = -∫ x, inner ℝ (gradient w x) (V x) := by + obtain ⟨hc,L,hL⟩ := hV + have hrL := Complex.reCLM.lipschitzWith.comp hL + have hiL := Complex.imCLM.lipschitzWith.comp hL + have hrC := hc.comp_left (map_zero Complex.reCLM) + have hiC := hc.comp_left (map_zero Complex.imCLM) + have hr := (integrable_fderiv_apply hrL hrC (1:ℂ)).bdd_mul + hw.continuous.aestronglyMeasurable (ae_of_all _ hb) + have hi := (integrable_fderiv_apply hiL hiC I).bdd_mul + hw.continuous.aestronglyMeasurable (ae_of_all _ hb) + have hrr := integrable_gradient_mul hw (hrL.continuous.integrable_of_hasCompactSupport hrC) (1:ℂ) + have hir := integrable_gradient_mul hw (hiL.continuous.integrable_of_hasCompactSupport hiC) I + change (∫ x, w x*(fderiv ℝ (Complex.reCLM ∘ V) x 1+fderiv ℝ (Complex.imCLM ∘ V) x I)) = _ + simp only [mul_add] + rw [integral_add hr hi,SignedDisk.LipschitzWith.integral_mul_fderiv_eq_neg hw hrL hrC (1:ℂ), + SignedDisk.LipschitzWith.integral_mul_fderiv_eq_neg hw hiL hiC I,← neg_add,← integral_add hrr hir] + congr 1 + apply integral_congr_ae + filter_upwards with x + exact (inner_coordinates _ _).symm + +open ActualLabels FiniteLabels SignedAssembly Finset DiskMoments + +lemma leafSum_add (f g : List Label → ℝ) (d : ℕ) (p : List Label) : + leafSum (fun q => f q+g q) d p = leafSum f d p+leafSum g d p := by + induction d generalizing p with + | zero => rfl + | succ d ih => simp only [leafSum,ih,sum_add_distrib] + +lemma leafSum_mul_const (f : List Label → ℝ) (c : ℝ) (d : ℕ) (p : List Label) : + leafSum (fun q => f q*c) d p = leafSum f d p*c := by + induction d generalizing p with + | zero => rfl + | succ d ih => simp only [leafSum,ih,sum_mul] + +lemma leafSum_const_mul (f : List Label → ℝ) (c : ℝ) (d : ℕ) (p : List Label) : + leafSum (fun q => c*f q) d p = c*leafSum f d p := by + simpa only [mul_comm] using leafSum_mul_const f c d p + +lemma leafSum_neg (f : List Label → ℝ) (d : ℕ) (p : List Label) : + leafSum (fun q => -(f q)) d p = -leafSum f d p := by + simpa only [neg_one_mul] using leafSum_const_mul f (-1) d p + +lemma leafSum_mono (f g : List Label → ℝ) (d : ℕ) (p : List Label) + (hle : ∀ q, q.length = p.length+d → f q ≤ g q) : leafSum f d p ≤ leafSum g d p := by + induction d generalizing p with + | zero => exact hle p (by simp) + | succ d ih => + apply sum_le_sum + intro n _ + apply ih + intro q hq + apply hle q + simp only [List.length_cons] at hq + omega + +lemma leafSum_congr (f g : List Label → ℝ) (d : ℕ) (p : List Label) + (he : ∀ q, q.length = p.length+d → f q = g q) : leafSum f d p = leafSum g d p := + le_antisymm (leafSum_mono f g d p (fun q hq => (he q hq).le)) + (leafSum_mono g f d p (fun q hq => (he q hq).ge)) + +lemma leafSum_weight (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) (d : ℕ) (p : List Label) : + leafSum (weight h r old x) d p = weight h r old x p := by + induction d generalizing p with + | zero => rfl + | succ d ih => + simp only [leafSum,ih,weight,← mul_sum,(observation h r p.length x (p.headD old)).total,mul_one] + +lemma leafSum_integrable (f : List Label → ℂ → ℝ) (hf : ∀ q, Integrable (f q)) + (d : ℕ) (p : List Label) : Integrable (fun x => leafSum (fun q => f q x) d p) := by + induction d generalizing p with + | zero => exact hf p + | succ d ih => exact integrable_finsetSum _ (fun n _ => ih (n::p)) + +lemma integral_leafSum (f : List Label → ℂ → ℝ) (hf : ∀ q, Integrable (f q)) + (d : ℕ) (p : List Label) : + (∫ x, leafSum (fun q => f q x) d p) = leafSum (fun q => ∫ x, f q x) d p := by + induction d generalizing p with + | zero => rfl + | succ d ih => + simp only [leafSum] + rw [integral_finsetSum _ (fun n _ => leafSum_integrable f hf d (n::p))] + exact sum_congr rfl (fun n _ => ih (n::p)) + +theorem history_weighted_ibp (g : ℂ → ℝ) (h : ℂ → ℂ) (r : ℕ → ℝ) + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (old : Label) (m : ℕ) : + (∫ x, leafSum (fun q => weight h r old x q*divergence (fun y => potential g r y q) x) m []) = + -∫ x, leafSum (fun q => inner ℝ (gradient (fun y => weight h r old y q) x) (potential g r x q)) m [] := by + have hreg (q : List Label) := potential_regular hg hc hr hstep q + have hint (q : List Label) : Integrable (fun x => weight h r old x q*divergence (fun y => potential g r y q) x) := by + obtain ⟨K,hK⟩ := weight_lipschitz h r hr old q + apply weighted_divergence_integrable hK _ (hreg q) + intro x + rw [Real.norm_eq_abs,abs_of_nonneg (weight_nonneg h r old x q)] + exact weight_le_one h r old x q + have hflux (q : List Label) : Integrable (fun x => inner ℝ (gradient (fun y => weight h r old y q) x) (potential g r x q)) := by + obtain ⟨K,hK⟩ := weight_lipschitz h r hr old q + exact potential_flux_integrable hK (hreg q) + rw [integral_leafSum _ hint,integral_leafSum _ hflux,← leafSum_neg] + apply leafSum_congr + intro q _ + obtain ⟨K,hK⟩ := weight_lipschitz h r hr old q + apply vector_weighted_ibp hK _ (hreg q) + intro x + rw [Real.norm_eq_abs,abs_of_nonneg (weight_nonneg h r old x q)] + exact weight_le_one h r old x q + +/-- Averaging preserves the complete signed run-master inequality; finite +history weights sum to one at every observation point. -/ +theorem expected_run_master (g : ℂ → ℝ) (h : ℂ → ℂ) (r : ℕ → ℝ) + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (old : Label) (m : ℕ) (x : ℂ) + (hd : ∀ i j, i ≤ j → DifferentiableAt ℝ (runEnvelope g r i j) x) : + ‖gradient (runEnvelope g r 0 m) x‖ ≤ + 12*leafSum (fun q => weight h r old x q*((runs q).map fun a => coneContribution a.dir + (gradient (runEnvelope g r a.first a.last) x)).sum) (m+1) [] := by + have hh := leafSum_mono + (fun q => weight h r old x q*‖gradient (runEnvelope g r 0 m) x‖) + (fun q => weight h r old x q*(12*((runs q).map fun a => coneContribution a.dir + (gradient (runEnvelope g r a.first a.last) x)).sum)) (m+1) [] (by + intro q hq + cases q with + | nil => simp at hq + | cons n p => + have hp : p.length = m := by simpa using hq + apply mul_le_mul_of_nonneg_left _ (weight_nonneg h r old x (n::p)) + simpa only [hp] using run_master hg hc hr hstep n p x hd) + rw [leafSum_mul_const,leafSum_weight,weight,one_mul] at hh + have he : (fun q => weight h r old x q*(12*((runs q).map fun a => coneContribution a.dir + (gradient (runEnvelope g r a.first a.last) x)).sum)) = + (fun q => 12*(weight h r old x q*((runs q).map fun a => coneContribution a.dir + (gradient (runEnvelope g r a.first a.last) x)).sum)) := by funext q; ring + rw [he,leafSum_const_mul] at hh + exact hh + +open DiskMoments ActualLabels Complex + +lemma divergence_add {U V : ℂ → ℂ} {x : ℂ} + (hU : DifferentiableAt ℝ U x) (hV : DifferentiableAt ℝ V x) : + divergence (fun y => U y+V y) x = divergence U x+divergence V x := by + have hUr : DifferentiableAt ℝ (fun y => (U y).re) x := Complex.reCLM.differentiableAt.comp x hU + have hVr : DifferentiableAt ℝ (fun y => (V y).re) x := Complex.reCLM.differentiableAt.comp x hV + have hUi : DifferentiableAt ℝ (fun y => (U y).im) x := Complex.imCLM.differentiableAt.comp x hU + have hVi : DifferentiableAt ℝ (fun y => (V y).im) x := Complex.imCLM.differentiableAt.comp x hV + simp only [divergence,Complex.add_re,Complex.add_im] + rw [fderiv_fun_add hUr hVr,fderiv_fun_add hUi hVi] + simp only [_root_.add_apply] + ring + +lemma divergence_scalar {f : ℂ → ℝ} {x : ℂ} (hf : DifferentiableAt ℝ f x) (n : ℂ) : + divergence (fun y => f y • n) x = inner ℝ n (gradient f x) := by + simp only [divergence,Complex.real_smul,Complex.mul_re,Complex.mul_im, + Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero,add_zero] + rw [fderiv_mul_const hf n.re,fderiv_mul_const hf n.im] + simp only [_root_.smul_apply,smul_eq_mul] + rw [real_inner_comm,inner_coordinates] + simp only [gradient,InnerProductSpace.toDual_symm_apply] + ring + +lemma listSum_diff {α : Type*} (l : List α) (V : α → ℂ → ℂ) {x : ℂ} + (hd : ∀ a ∈ l, DifferentiableAt ℝ (V a) x) : + DifferentiableAt ℝ (fun y => (l.map fun a => V a y).sum) x := by + induction l with + | nil => exact differentiableAt_const 0 + | cons a l ih => + exact (hd a (by simp)).add (ih (fun a ha => hd a (by simp [ha]))) + +lemma divergence_listSum {α : Type*} (l : List α) (V : α → ℂ → ℂ) {x : ℂ} + (hd : ∀ a ∈ l, DifferentiableAt ℝ (V a) x) : + divergence (fun y => (l.map fun a => V a y).sum) x = (l.map fun a => divergence (V a) x).sum := by + induction l with + | nil => simp [divergence] + | cons a l ih => + have hs := listSum_diff l V (fun b hb => hd b (by simp [hb])) + simp only [List.map_cons,List.sum_cons] + rw [divergence_add (hd a (by simp)) hs,ih (fun b hb => hd b (by simp [hb]))] + +lemma average_diff {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + (x : ℂ) {t : ℝ} (ht : 0 < t) : DifferentiableAt ℝ (fun y => signedAverage g y t) x := by + obtain ⟨K,hK⟩ := hg.lipschitzWith_of_hasCompactSupport hc one_ne_zero + exact (hasFDerivAt_signedAverage hg (fun y => norm_fderiv_le_of_lipschitz ℝ hK) x ht).differentiableAt + +/-- The divergence of the exact path potential is the complete signed sum +of run gradients, with precisely the starting-baseline gradients removed. -/ +lemma potential_divergence {g : ℂ → ℝ} {r : ℕ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) (hr : ∀ k, 0 < r k) (p : List Label) (x : ℂ) + (hd : ∀ i j, i ≤ j → DifferentiableAt ℝ (runEnvelope g r i j) x) : + divergence (fun y => potential g r y p) x = + ((runs p).map fun a => inner ℝ (a.dir:ℂ) + (gradient (runEnvelope g r a.first a.last) x-gradient (fun y => signedAverage g y (r a.first)) x)).sum := by + cases p with + | nil => simp [potential,runs,divergence] + | cons n p => + simp_rw [potential_eq_runs] + have hd' (a : Run) (ha : a ∈ runs (n::p)) : + DifferentiableAt ℝ (fun y => runEnvelope g r a.first a.last y-signedAverage g y (r a.first)) x := + (hd a.first a.last (runs_bounds n p a ha).1).sub (average_diff hg hgc x (hr a.first)) + rw [divergence_listSum _ _ (fun a ha => (hd' a ha).smul_const (a.dir:ℂ))] + apply congrArg List.sum + apply List.map_congr_left + intro a ha + rw [divergence_scalar (hd' a ha)] + congr 1 + simp only [gradient] + rw [fderiv_fun_sub (hd a.first a.last (runs_bounds n p a ha).1) (average_diff hg hgc x (hr a.first)),map_sub] + +open DiskMoments ActualLabels Finset ConeCoordinates + +lemma radius_in_run_bin (r : ℕ → ℝ) (hstep : ∀ k, 2*r (k+1) = r k) + {i j : ℕ} (hij : i ≤ j) {t : ℝ} (ht : t ∈ Icc (r j) (2*r i)) : + ∃ k ∈ Set.Icc i j, t ∈ Icc (r k) (2*r k) := by + obtain ⟨l,hl,htl⟩ := radius_in_bin (fun k => r (i+k)) + (fun k => by simpa [Nat.add_assoc] using hstep (i+k)) (j-i) + (by simpa only [Nat.add_sub_of_le hij,Nat.add_zero] using ht) + exact ⟨i+l,⟨by omega,by omega⟩,htl⟩ + +lemma attaining_endpoint {g : ℂ → ℝ} {r : ℕ → ℝ} + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + {i j k : ℕ} (hik : i ≤ k) (hkj : k ≤ j) {x : ℂ} {t : ℝ} + (ht : t ∈ Icc (r k) (2*r k)) + (hmax : ∀ s ∈ Icc (r j) (2*r i), signedAverage g x s ≤ signedAverage g x t) : + PhysicalEndpointRadius g (r k) x t := by + refine ⟨ht,Or.inr (Or.inr ?_)⟩ + intro s hs + apply hmax + constructor + · exact (radius_antitone r hr hstep hkj).trans hs.1 + · have := radius_antitone r hr hstep hik + linarith [hs.2] + +lemma attaining_interior {g : ℂ → ℝ} {r : ℕ → ℝ} + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + {i j k : ℕ} (hik : i < k) (hkj : k < j) {x : ℂ} {t : ℝ} + (ht : t ∈ Icc (r k) (2*r k)) + (hmax : ∀ s ∈ Icc (r j) (2*r i), signedAverage g x s ≤ signedAverage g x t) : + PhysicalNeighborhoodRadius g (r k) x t := by + refine ⟨ht,?_⟩ + intro s _ hs + apply hmax + have hs' := abs_le.mp hs + have hlow := radius_antitone r hr hstep (show k+1 ≤ j by omega) + have hhigh := radius_antitone r hr hstep (show i+1 ≤ k by omega) + constructor <;> linarith [hstep k,hstep i,hr k,ht.1,ht.2] + +def unfavorable (n : Label) (z : ℂ) : ℝ := + max 0 (-inner ℝ (axis n 1) z)+max 0 (-inner ℝ (axis n (-1)) z) + +lemma unfavorable_nonneg (n : Label) (z : ℂ) : 0 ≤ unfavorable n z := + add_nonneg (le_max_left _ _) (le_max_left _ _) + +lemma unfavorable_le_norm (n : Label) (z : ℂ) : unfavorable n z ≤ 2*‖z‖ := by + have h (s : ℝ) (hs : s^2 = 1) : max 0 (-inner ℝ (axis n s) z) ≤ ‖z‖ := by + apply max_le (norm_nonneg _) + have hh := abs_real_inner_le_norm (axis (n:ℂ) s) z + rw [axis_norm (label_unit n) hs,one_mul] at hh + exact (neg_le_abs _).trans hh + have hp := h 1 (by norm_num) + have hm := h (-1) (by norm_num) + unfold unfavorable + linarith + +/-- The exact unfavorable run term is charged either to one interior bin or +one of its two end bins; padding by nonnegative costs permits summing runs. -/ +lemma run_unfavorable_bound {g : ℂ → ℝ} {r : ℕ → ℝ} + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (H : ℕ → Label → ℝ) (J : ℕ → ℝ) (hH : ∀ k n, 0 ≤ H k n) (hJ : ∀ k, 0 ≤ J k) + (x : ℂ) (n : Label) {i j : ℕ} (hij : i ≤ j) + (hd : DifferentiableAt ℝ (runEnvelope g r i j) x) + (hinterior : ∀ k t, PhysicalNeighborhoodRadius g (r k) x t → + unfavorable n (gradient (fun y => signedAverage g y t) x) ≤ H k n) + (hend : ∀ k t, PhysicalEndpointRadius g (r k) x t → + ‖gradient (fun y => signedAverage g y t) x‖ ≤ J k) : + unfavorable n (gradient (runEnvelope g r i j) x) ≤ + (∑ k ∈ Icc i j, H k n)+2*(J i+J j) := by + obtain ⟨t,ht,he,hm⟩ := runEnvelope_attains g r hg hr hstep hij x + rw [run_gradient_touching hg hc hr hd ht he] + obtain ⟨k,hk,hkt⟩ := radius_in_run_bin r hstep hij ht + have hs : 0 ≤ ∑ k ∈ Icc i j, H k n := sum_nonneg (fun _ _ => hH _ _) + by_cases hki : k = i + · subst k + have hb := (unfavorable_le_norm n _).trans (mul_le_mul_of_nonneg_left + (hend i t (attaining_endpoint hr hstep le_rfl hij hkt hm)) (by norm_num : (0:ℝ) ≤ 2)) + linarith [hJ j] + by_cases hkj : k = j + · subst k + have hb := (unfavorable_le_norm n _).trans (mul_le_mul_of_nonneg_left + (hend j t (attaining_endpoint hr hstep hij le_rfl hkt hm)) (by norm_num : (0:ℝ) ≤ 2)) + linarith [hJ i] + have hik := hk.1 + have hkj' := hk.2 + have hb := hinterior k t (attaining_interior hr hstep (by omega) (by omega) hkt hm) + have hsum : H k n ≤ ∑ l ∈ Icc i j, H l n := single_le_sum (fun l _ => hH l n) (Finset.mem_Icc.mpr hk) + linarith [hJ i,hJ j] +end SignedRuns + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskScales1.lean b/lean/OAI/Analysis/SignedDisk/DiskScales1.lean new file mode 100644 index 0000000000000000000000000000000000000000..be9222d4ffb5486a3bfa50f58967af82a701cdbe --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskScales1.lean @@ -0,0 +1,404 @@ +import OAI.Analysis.SignedDisk.LocalCancellation3 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace DiskScales + +lemma norm_geometric_rpow_lt {p : ℝ} (hp : 0 < p) : (1/2 : ℝ)^p < 1 := + Real.rpow_lt_one (by norm_num) (by norm_num) hp + +lemma raw_endpoint_tail_scaled {A t δ M : ℝ} (hA : 0 ≤ A) (ht : 0 < t) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hM0 : 0 ≤ M) + (hM : M ≤ A*δ^(-(1/50 : ℝ))) : + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ ^ 2 * + (ENNReal.ofReal (156*δ/δ^(1/5 : ℝ))*ENNReal.ofReal M*ENNReal.ofReal M) + + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ * + ((ENNReal.ofReal (6*Real.pi)*ENNReal.ofReal (2*(200*δ/(δ^(1/5 : ℝ))^2)))*ENNReal.ofReal M) + + ENNReal.ofReal (24*Real.pi*δ)*ENNReal.ofReal M/ENNReal.ofReal (t*δ^(1/10 : ℝ)) ≤ + ENNReal.ofReal (156*(A/t)^2*δ^(14/25 : ℝ)+2424*Real.pi*(A/t)*δ^(9/25 : ℝ)) := by + calc + _ ≤ ENNReal.ofReal (156*(A/t)^2*δ^(14/25 : ℝ)+2400*Real.pi*(A/t)*δ^(9/25 : ℝ)) + + ENNReal.ofReal (24*Real.pi*(A/t)*δ^(9/25 : ℝ)) := + add_le_add (shell_tail_scaled hA ht hδ hδ1 hM0 hM) + (endpoint_tail_scaled hA ht hδ hδ1 hM) + _ = _ := by + rw [← ENNReal.ofReal_add (by positivity) (by positivity)] + congr 1 + ring + +lemma geometric_tail_sum {A t d : ℝ} (hA : 0 ≤ A) (ht : 0 < t) (hd : 0 ≤ d) : + (∑' n : ℕ, ENNReal.ofReal + (156*(A/t)^2*(width d n)^(14/25 : ℝ)+2424*Real.pi*(A/t)*(width d n)^(9/25 : ℝ))) = + ENNReal.ofReal (156*(A/t)^2*d^(14/25 : ℝ)/(1-(1/2 : ℝ)^(14/25 : ℝ))+ + 2424*Real.pi*(A/t)*d^(9/25 : ℝ)/(1-(1/2 : ℝ)^(9/25 : ℝ))) := by + have h1 := (summable_width_rpow hd (by norm_num : (0 : ℝ) < 14/25)).mul_left (156*(A/t)^2) + have h2 := (summable_width_rpow hd (by norm_num : (0 : ℝ) < 9/25)).mul_left (2424*Real.pi*(A/t)) + have hn (n : ℕ) : 0 ≤ width d n := mul_nonneg hd (pow_nonneg (by norm_num) n) + have hc1 : 0 ≤ 156*(A/t)^2 := by positivity + have hc2 : 0 ≤ 2424*Real.pi*(A/t) := by positivity + rw [← ENNReal.ofReal_tsum_of_nonneg (fun n => add_nonneg + (mul_nonneg hc1 (Real.rpow_nonneg (hn n) _)) + (mul_nonneg hc2 (Real.rpow_nonneg (hn n) _))) (h1.add h2), + Summable.tsum_add h1 h2, tsum_mul_left, tsum_mul_left, + tsum_width_rpow hd (by norm_num : (0 : ℝ) < 14/25), + tsum_width_rpow hd (by norm_num : (0 : ℝ) < 9/25)] + congr 1 + ring + +/-- After the initial-width choice d=A/t, the failure exponents are strictly +larger than one, rather than the nonintegrable weak-(1,1) exponent. -/ +lemma starting_width_tail {A t : ℝ} (hA : 0 < A) (ht : 0 < t) : + 156*(A/t)^2*(A/t)^(14/25 : ℝ)/(1-(1/2 : ℝ)^(14/25 : ℝ))+ + 2424*Real.pi*(A/t)*(A/t)^(9/25 : ℝ)/(1-(1/2 : ℝ)^(9/25 : ℝ)) = + (156/(1-(1/2 : ℝ)^(14/25 : ℝ)))*(A/t)^(64/25 : ℝ)+ + (2424*Real.pi/(1-(1/2 : ℝ)^(9/25 : ℝ)))*(A/t)^(34/25 : ℝ) := by + have hq : 0 < A/t := div_pos hA ht + have he1 : (A/t)^2*(A/t)^(14/25 : ℝ) = (A/t)^(64/25 : ℝ) := by + rw [← Real.rpow_natCast, ← Real.rpow_add hq] + norm_num + have he2 : (A/t)*(A/t)^(9/25 : ℝ) = (A/t)^(34/25 : ℝ) := by + conv_lhs => lhs; rw [← Real.rpow_one (A/t)] + rw [← Real.rpow_add hq] + norm_num + calc + _ = (156/(1-(1/2 : ℝ)^(14/25 : ℝ)))*((A/t)^2*(A/t)^(14/25 : ℝ))+ + (2424*Real.pi/(1-(1/2 : ℝ)^(9/25 : ℝ)))*((A/t)*(A/t)^(9/25 : ℝ)) := by ring + _ = _ := by rw [he1,he2] + +lemma size_start_identity {Cs A t : ℝ} (hA : 0 < A) (ht : 0 < t) : + (1+216*Cs)/(A/t)^(1/100 : ℝ)*A+ + (16+4538*Cs)*t*(A/t)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) = + t*((1+216*Cs)*(A/t)^(99/100 : ℝ)+ + (16+4538*Cs)*(A/t)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) := by + have hq : 0 < A/t := div_pos hA ht + have he : (A/t)/(A/t)^(1/100 : ℝ) = (A/t)^(99/100 : ℝ) := by + have hh := Real.rpow_sub hq (1 : ℝ) (1/100 : ℝ) + norm_num at hh + exact hh.symm + have hAt : t*(A/t) = A := by field_simp + calc + _ = t*((1+216*Cs)*((A/t)/(A/t)^(1/100 : ℝ))+ + (16+4538*Cs)*(A/t)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) := by + rw [mul_add] + congr 1 + · calc + _ = (1+216*Cs)/(A/t)^(1/100 : ℝ)*(t*(A/t)) := by rw [hAt] + _ = _ := by ring + · ring + _ = _ := by rw [he] + +/-- One fixed small-width cutoff enforces geometry and the strict endpoint +size threshold at every smaller positive width. -/ +lemma exists_size_parameters (Cs : ℝ) : + ∃ d₀ : ℝ, 0 < d₀ ∧ d₀ ≤ 1/4 ∧ + (∀ δ : ℝ, 0 < δ → δ ≤ d₀ → δ ≤ (δ^(1/5 : ℝ))^2/1600) ∧ + (∀ δ : ℝ, 0 < δ → δ ≤ d₀ → + (1+216*Cs)*δ^(99/100 : ℝ)+ + (16+4538*Cs)*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) ≤ 1) := by + obtain ⟨d,hd,hdq,hgeom⟩ := exists_admissible_width + have ht : Tendsto (fun δ : ℝ => (1+216*Cs)*δ^(99/100 : ℝ)+ + (16+4538*Cs)*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) (𝓝 0) (𝓝 0) := by + have h1 := (Real.continuous_rpow_const (by norm_num : (0 : ℝ) ≤ 99/100)).tendsto 0 + have h2 := (Real.continuous_rpow_const (by norm_num : (0 : ℝ) ≤ 1/10)).tendsto 0 + simpa using (h1.const_mul (1+216*Cs)).add ((h2.const_mul (16+4538*Cs)).div_const _) + obtain ⟨l,u,hu,hs⟩ := mem_nhds_iff_exists_Ioo_subset.mp + (ht.eventually_lt_const (by norm_num : (0 : ℝ) < 1)) + let d₀ := min d (u/2) + have hd0 : 0 < d₀ := lt_min hd (by linarith [hu.2]) + refine ⟨d₀,hd0,(min_le_left _ _).trans hdq,fun δ hδ hδd => hgeom δ hδ (hδd.trans (min_le_left _ _)), ?_⟩ + intro δ hδ hδd + apply le_of_lt + apply hs + exact ⟨lt_trans hu.1 hδ, lt_of_le_of_lt hδd ((min_le_right _ _).trans_lt (by linarith [hu.2]))⟩ + +def sizeTailConstant : ℝ := + 156/(1-(1/2 : ℝ)^(14/25 : ℝ))+2424*Real.pi/(1-(1/2 : ℝ)^(9/25 : ℝ)) + +lemma sizeTailConstant_pos : 0 < sizeTailConstant := by + have h1 : 0 < 1-(1/2 : ℝ)^(14/25 : ℝ) := sub_pos.mpr (norm_geometric_rpow_lt (by norm_num)) + have h2 : 0 < 1-(1/2 : ℝ)^(9/25 : ℝ) := sub_pos.mpr (norm_geometric_rpow_lt (by norm_num)) + unfold sizeTailConstant + positivity + +lemma collapse_size_tail {q : ℝ} (hq : 0 < q) (hq1 : q ≤ 1) : + (156/(1-(1/2 : ℝ)^(14/25 : ℝ)))*q^(64/25 : ℝ)+ + (2424*Real.pi/(1-(1/2 : ℝ)^(9/25 : ℝ)))*q^(34/25 : ℝ) ≤ + sizeTailConstant*q^(34/25 : ℝ) := by + have hc : 0 ≤ 156/(1-(1/2 : ℝ)^(14/25 : ℝ)) := + div_nonneg (by norm_num) (sub_nonneg.mpr ((norm_geometric_rpow_lt (by norm_num)).le)) + have he := mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow_of_exponent_ge hq hq1 (by norm_num : (34/25 : ℝ) ≤ 64/25)) hc + unfold sizeTailConstant + nlinarith + +end DiskScales + +namespace LocalCancellation +open DiskKernels DiskMoments DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +/-- The uniform integrable superlevel tail, with both forced band endpoints. +The only decomposition assumption is equality of the specified densities on +each observation disk. No direction positivity is needed for this size bound. -/ +theorem size_tail {Cs : ℝ} (hCs : 0 ≤ Cs) : + ∃ L : ℝ, 1 ≤ L ∧ ∀ {ι : Type*} [Fintype ι] (b : ι → ErrorPiece Cs), + 0 < errorPrice b (1/100) → ∀ t : ℝ, L*errorPrice b (1/100) ≤ t → + ∀ g : ℂ → ℝ, ContDiff ℝ 1 g → + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ ENNReal.ofReal (sizeTailConstant*(errorPrice b (1/100)/t)^(34/25 : ℝ)) ∧ + ∀ x ∉ E, + (∀ᵐ y, y ∈ Metric.ball x 3 → ∑ j, (b j).density y = gradient g y) → + ∀ r, EndpointRadius g x r → ‖∫ y in Metric.ball x r, gradient g y‖ ≤ t := by + obtain ⟨d₀,hd0,hdq,hgeom,hsmall⟩ := exists_size_parameters Cs + have hL : 1 ≤ (1 : ℝ)/d₀ := (le_div_iff₀ hd0).mpr (by linarith) + refine ⟨1/d₀,hL,?_⟩ + intro ι _ b hA t ht g hg + let A := errorPrice b (1/100) + have hAt : A ≤ t := (le_mul_of_one_le_left hA.le hL).trans ht + have ht0 : 0 < t := lt_of_lt_of_le hA hAt + have hqd : A/t ≤ d₀ := by + apply (div_le_iff₀ ht0).mpr + have hh : A/d₀ ≤ t := by simpa only [A,one_div, div_eq_mul_inv, mul_comm, mul_one] using ht + have hh' := (div_le_iff₀ hd0).mp hh + linarith + have hq0 : 0 < A/t := div_pos hA ht0 + have hq1 : A/t ≤ 1 := by linarith + have hqq : A/t ≤ 1/4 := hqd.trans hdq + obtain ⟨E,hE,hEv,hEst⟩ := size_endpoint_raw b hCs hq0 hqq + (fun δ hδ hδq => hgeom δ hδ (hδq.trans hqd)) ht0 hAt hg + refine ⟨E,hE,?_,?_⟩ + · apply hEv.trans + calc + _ ≤ ∑' n : ℕ, ENNReal.ofReal + (156*(A/t)^2*(width (A/t) n)^(14/25 : ℝ)+ + 2424*Real.pi*(A/t)*(width (A/t) n)^(9/25 : ℝ)) := by + apply ENNReal.tsum_le_tsum + intro n + have hw0 : 0 < width (A/t) n := width_pos hq0 n + have hw1 : width (A/t) n ≤ 1 := (width_le hq0.le n).trans hq1 + apply raw_endpoint_tail_scaled hA.le ht0 hw0 hw1 (coarseMass_nonneg b _ _) + have hh := coarseMass_bound b (by norm_num : (0 : ℝ) ≤ 1/100) hw0 + norm_num at hh + rw [Real.rpow_neg hw0.le] + exact hh + _ = ENNReal.ofReal + ((156/(1-(1/2 : ℝ)^(14/25 : ℝ)))*(A/t)^(64/25 : ℝ)+ + (2424*Real.pi/(1-(1/2 : ℝ)^(9/25 : ℝ)))*(A/t)^(34/25 : ℝ)) := by + rw [geometric_tail_sum hA.le ht0 hq0.le, starting_width_tail hA ht0] + _ ≤ ENNReal.ofReal (sizeTailConstant*(A/t)^(34/25 : ℝ)) := + ENNReal.ofReal_le_ofReal (collapse_size_tail hq0 hq1) + · intro x hx hh r hr + apply (hEst x hx hh r hr).trans + rw [size_start_identity hA ht0] + exact (mul_le_mul_of_nonneg_left (hsmall _ hq0 hqd) ht0.le).trans_eq (mul_one t) + +end LocalCancellation + +namespace DyadicMajorant + +section +variable {X : Type*} [MeasurableSpace X] + +/-- A Borel price built from exceptions, rather than a measurability-dependent +selection of maximizing radii. -/ +def price (t : ℝ) (E : ℕ → Set X) (x : X) : ℝ≥0∞ := + ENNReal.ofReal t + ∑' n : ℕ, (E n).indicator (fun _ => ENNReal.ofReal (t*2^(n+1))) x + +lemma measurable_price (t : ℝ) {E : ℕ → Set X} (hE : ∀ n, MeasurableSet (E n)) : + Measurable (price t E) := by + unfold price + have hs : Measurable (fun x => ∑' n : ℕ, (E n).indicator (fun _ => ENNReal.ofReal (t*2^(n+1))) x) := Measurable.tsum (fun n => + (measurable_const : Measurable (fun _ : X => ENNReal.ofReal (t*2^(n+1)))).indicator (hE n)) + exact measurable_const.add hs + +omit [MeasurableSpace X] in +lemma majorizes {t v : ℝ} (ht : 0 < t) {E : ℕ → Set X} {x : X} + (hv : ∀ n : ℕ, x ∉ E n → v ≤ t*2^n) : + ENNReal.ofReal v ≤ price t E x := by + by_cases hvt : v ≤ t + · exact (ENNReal.ofReal_le_ofReal hvt).trans le_self_add + · have he : ∃ n : ℕ, v ≤ t*2^n := by + obtain ⟨n,hn⟩ := pow_unbounded_of_one_lt (v/t) (by norm_num : (1 : ℝ) < 2) + exact ⟨n, le_of_lt ((div_lt_iff₀ ht).mp hn |> fun h => by simpa only [mul_comm] using h)⟩ + let n := Nat.find he + have hn : v ≤ t*2^n := Nat.find_spec he + have hn0 : n ≠ 0 := by + intro hz + have : v ≤ t := by simpa only [hz, pow_zero, mul_one] using hn + exact hvt this + obtain ⟨j,hj⟩ := Nat.exists_eq_succ_of_ne_zero hn0 + have hjn : j < n := by omega + have hmem : x ∈ E j := by + by_contra h + exact Nat.find_min he hjn (hv j h) + have hp : ENNReal.ofReal (t*2^(j+1)) ≤ price t E x := by + have hs := ENNReal.le_tsum j (f := fun n : ℕ => (E n).indicator (fun _ => ENNReal.ofReal (t*2^(n+1))) x) + rw [indicator_of_mem hmem] at hs + exact hs.trans le_add_self + apply le_trans (ENNReal.ofReal_le_ofReal hn) + simpa only [hj, Nat.succ_eq_add_one] using hp + +lemma lintegral_price (μ : Measure X) {Q : Set X} + (t : ℝ) {E : ℕ → Set X} (hE : ∀ n, MeasurableSet (E n)) : + (∫⁻ x in Q, price t E x ∂μ) ≤ + ENNReal.ofReal t*μ Q + ∑' n : ℕ, ENNReal.ofReal (t*2^(n+1))*μ (E n) := by + simp only [price] + rw [lintegral_add_left measurable_const, lintegral_const, Measure.restrict_apply_univ, + lintegral_tsum (fun n => (measurable_const.indicator (hE n)).aemeasurable)] + apply add_le_add le_rfl + apply ENNReal.tsum_le_tsum + intro n + rw [lintegral_indicator (hE n), lintegral_const, Measure.restrict_apply_univ, + Measure.restrict_apply (hE n)] + exact mul_le_mul_right (measure_mono inter_subset_left) _ + +end + +lemma weighted_geometric_sum {t K c : ℝ} (ht : 0 ≤ t) (hK : 0 ≤ K) + (hc : 0 ≤ c) (hc1 : 2*c < 1) : + (∑' n : ℕ, ENNReal.ofReal (t*2^(n+1))*ENNReal.ofReal (K*c^n)) = + ENNReal.ofReal (2*t*K/(1-2*c)) := by + have he (n : ℕ) : ENNReal.ofReal (t*2^(n+1))*ENNReal.ofReal (K*c^n) = + ENNReal.ofReal (2*t*K*(2*c)^n) := by + rw [← ENNReal.ofReal_mul (by positivity)] + congr 1 + rw [mul_pow, pow_succ] + ring + simp_rw [he] + have hc' : ‖2*c‖ < 1 := by rw [Real.norm_eq_abs, abs_of_nonneg (by positivity)]; exact hc1 + rw [← ENNReal.ofReal_tsum_of_nonneg (fun n => by positivity) + ((summable_geometric_of_norm_lt_one hc').mul_left (2*t*K)), + tsum_mul_left, tsum_geometric_of_norm_lt_one hc'] + rfl + +variable {X : Type*} [MeasurableSpace X] + +lemma lintegral_price_geometric (μ : Measure X) {Q : Set X} {q t K c : ℝ} + (hq : 0 ≤ q) (hQ : μ Q ≤ ENNReal.ofReal q) (ht : 0 ≤ t) + (hK : 0 ≤ K) (hc : 0 ≤ c) (hc1 : 2*c < 1) + {E : ℕ → Set X} (hE : ∀ n, MeasurableSet (E n)) + (hEv : ∀ n : ℕ, μ (E n) ≤ ENNReal.ofReal (K*c^n)) : + (∫⁻ x in Q, price t E x ∂μ) ≤ + ENNReal.ofReal (t*(q+2*K/(1-2*c))) := by + apply (lintegral_price μ t hE).trans + calc + _ ≤ ENNReal.ofReal t*ENNReal.ofReal q+ + ∑' n : ℕ, ENNReal.ofReal (t*2^(n+1))*ENNReal.ofReal (K*c^n) := + add_le_add (mul_le_mul_right hQ _) (ENNReal.tsum_le_tsum fun n => mul_le_mul_right (hEv n) _) + _ = ENNReal.ofReal (t*q)+ENNReal.ofReal (2*t*K/(1-2*c)) := by + rw [← ENNReal.ofReal_mul ht, weighted_geometric_sum ht hK hc hc1] + _ = _ := by + rw [← ENNReal.ofReal_add (mul_nonneg ht hq) (by positivity [sub_pos.mpr hc1])] + congr 1 + ring + +end DyadicMajorant + +namespace LocalCancellation +open DiskScales DiskMoments + +lemma errorPrice_zero {ι : Type*} [Fintype ι] {Cs α : ℝ} (b : ι → ErrorPiece Cs) + (hA : errorPrice b α = 0) : ∀ j, (b j).density =ᵐ[volume] 0 := by + intro j + have hterm : (b j).size^α*(b j).mass ≤ errorPrice b α := + Finset.single_le_sum (fun k _ => mul_nonneg (Real.rpow_nonneg (b k).size_pos.le _) (b k).mass_nonneg) (Finset.mem_univ j) + have hm : (b j).mass = 0 := by + have hp := Real.rpow_pos_of_pos (b j).size_pos α + rw [hA] at hterm + nlinarith [(b j).mass_nonneg] + have hz := (integral_eq_zero_iff_of_nonneg (fun y => norm_nonneg ((b j).density y)) (b j).integrable.norm).mp hm + filter_upwards [hz] with y hy + exact norm_eq_zero.mp hy + +lemma dyadic_ratio {A L : ℝ} (hA : 0 < A) (hL : 1 ≤ L) (n : ℕ) : + A/(L*A*2^n) ≤ (1/2 : ℝ)^n := by + have hLA : 0 < L*A := mul_pos (by linarith) hA + have hn : 0 < (2 : ℝ)^n := by positivity + calc + _ ≤ (L*A)/(L*A*2^n) := div_le_div_of_nonneg_right (le_mul_of_one_le_left hA.le hL) (mul_nonneg hLA.le hn.le) + _ = (1/2 : ℝ)^n := by rw [div_pow]; field_simp; simp + +/-- A simultaneous Borel integrable price for every admissible disk gradient. +The constant is independent of the number of pieces. -/ +theorem size_majorant {Cs : ℝ} (hCs : 0 ≤ Cs) : + ∃ C : ℝ, 0 < C ∧ ∀ {ι : Type*} [Fintype ι] (b : ι → ErrorPiece Cs) + (g : ℂ → ℝ), ContDiff ℝ 1 g → ∀ Q : Set ℂ, volume Q ≤ ENNReal.ofReal 1 → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ x in Q, F x) ≤ ENNReal.ofReal (C*errorPrice b (1/100)) ∧ + ∀ x, (∀ᵐ y, y ∈ Metric.ball x 3 → ∑ j, (b j).density y = gradient g y) → + ∀ r, EndpointRadius g x r → + ENNReal.ofReal ‖∫ y in Metric.ball x r, gradient g y‖ ≤ F x := by + obtain ⟨L,hL,hsize⟩ := size_tail hCs + let c : ℝ := (1/2 : ℝ)^(34/25 : ℝ) + have hc : 0 ≤ c := Real.rpow_nonneg (by norm_num) _ + have hc1 : 2*c < 1 := by + have hh := Real.rpow_lt_rpow_of_exponent_gt (by norm_num : (0 : ℝ) < 1/2) + (by norm_num : (1/2 : ℝ) < 1) (by norm_num : (1 : ℝ) < 34/25) + norm_num at hh + linarith + let C := L*(1+2*sizeTailConstant/(1-2*c)) + have hC : 0 < C := mul_pos (by linarith) (by + have := sizeTailConstant_pos + have := sub_pos.mpr hc1 + positivity) + refine ⟨C,hC,?_⟩ + intro ι _ b g hg Q hQ + let A := errorPrice b (1/100) + by_cases hAz : A = 0 + · refine ⟨0,measurable_const,?_,?_⟩ + · simp only [Pi.zero_apply, lintegral_zero, A, hAz, mul_zero, ENNReal.ofReal_zero, le_refl] + · intro x hh r hr + have hz := errorPrice_zero b hAz + have hs : (∑ j, ∫ y in Metric.ball x r, (b j).density y) = 0 := by + apply Finset.sum_eq_zero + intro j _ + exact integral_eq_zero_of_ae ((ae_restrict_of_ae (hz j))) + have he := ball_pairing_decomposition b x (by linarith [hr.1.2] : r ≤ 3) hh + rw [← he,hs,norm_zero,ENNReal.ofReal_zero] + exact le_refl _ + · have hA : 0 < A := lt_of_le_of_ne (errorPrice_nonneg b _) (Ne.symm hAz) + have ht : 0 < L*A := mul_pos (by linarith) hA + have hts (n : ℕ) : L*A ≤ L*A*2^n := le_mul_of_one_le_right ht.le (one_le_pow₀ (by norm_num)) + choose E hE hEv hbound using fun n : ℕ => hsize b hA (L*A*2^n) (hts n) g hg + refine ⟨DyadicMajorant.price (L*A) E, DyadicMajorant.measurable_price _ hE,?_,?_⟩ + · have htail (n : ℕ) : volume (E n) ≤ ENNReal.ofReal (sizeTailConstant*c^n) := by + apply (hEv n).trans + apply ENNReal.ofReal_le_ofReal + apply mul_le_mul_of_nonneg_left _ sizeTailConstant_pos.le + calc + _ ≤ ((1/2 : ℝ)^n)^(34/25 : ℝ) := Real.rpow_le_rpow (by positivity) (dyadic_ratio hA hL n) (by norm_num) + _ = c^n := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num), mul_comm (n : ℝ), + Real.rpow_mul (by norm_num), Real.rpow_natCast] + have hi := DyadicMajorant.lintegral_price_geometric volume (by norm_num : (0 : ℝ) ≤ 1) hQ ht.le + sizeTailConstant_pos.le hc hc1 hE htail + convert hi using 1 + congr 1 + dsimp [C,A] + ring + · intro x hh r hr + apply DyadicMajorant.majorizes ht + intro n hn + exact hbound n x hn hh r hr + +end LocalCancellation + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskScales2.lean b/lean/OAI/Analysis/SignedDisk/DiskScales2.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0f45a1d0af9e8aac6f7f13859c4308767dd444e --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskScales2.lean @@ -0,0 +1,465 @@ +import OAI.Analysis.SignedDisk.LocalCancellation5 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace DiskScales + +def errorGapConstant (Cs : ℝ) : ℝ := + 2*(1+216*Cs)+(16+4538*Cs)/(1-(1/2 : ℝ)^(1/10 : ℝ)) + +def directionGapConstant (Cs κ : ℝ) : ℝ := + (16+4538*Cs)+4*(errorGapConstant Cs/κ)+14+(16+4538*Cs)/(1-(1/2 : ℝ)^(1/10 : ℝ)) + +lemma errorGapConstant_pos {Cs : ℝ} (hCs : 0 ≤ Cs) : 0 < errorGapConstant Cs := by + have hden : 0 < 1-(1/2 : ℝ)^(1/10 : ℝ) := by linarith [norm_geometric_rpow_lt (by norm_num : (0 : ℝ) < 1/10)] + unfold errorGapConstant + positivity + +lemma directionGapConstant_ge {Cs κ : ℝ} (hCs : 0 ≤ Cs) (hκ : 0 < κ) : + 16+4538*Cs ≤ directionGapConstant Cs κ := by + have hden : 0 < 1-(1/2 : ℝ)^(1/10 : ℝ) := by linarith [norm_geometric_rpow_lt (by norm_num : (0 : ℝ) < 1/10)] + have he : 0 ≤ errorGapConstant Cs/κ := div_nonneg (errorGapConstant_pos hCs).le hκ.le + have hn : 0 ≤ (16+4538*Cs)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by positivity + unfold directionGapConstant + linarith + +lemma directionGapConstant_pos {Cs κ : ℝ} (hCs : 0 ≤ Cs) (hκ : 0 < κ) : + 0 < directionGapConstant Cs κ := by + have hh := directionGapConstant_ge hCs hκ + linarith + +lemma direction_cap_scale {Cs κ δ t : ℝ} (hCs : 0 ≤ Cs) (hκ : 0 < κ) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (ht : 0 ≤ t) : + 4*δ^(1/5 : ℝ)*((errorGapConstant Cs*t*δ^(-(1/50 : ℝ)))/κ)+14*(t*δ^(1/10 : ℝ))+ + (16+4538*Cs)*t*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) ≤ + directionGapConstant Cs κ*t*δ^(1/10 : ℝ) := by + have hp : δ^(1/5 : ℝ)*δ^(-(1/50 : ℝ)) ≤ δ^(1/10 : ℝ) := by + rw [← Real.rpow_add hδ] + exact Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num) + have hb := mul_le_mul_of_nonneg_left hp + (by exact mul_nonneg (mul_nonneg (by norm_num) (div_nonneg (errorGapConstant_pos hCs).le hκ.le)) ht : + 0 ≤ 4*(errorGapConstant Cs/κ)*t) + have hb' : 4*δ^(1/5 : ℝ)*((errorGapConstant Cs*t*δ^(-(1/50 : ℝ)))/κ) ≤ + 4*(errorGapConstant Cs/κ)*t*δ^(1/10 : ℝ) := by + calc + _ = 4*(errorGapConstant Cs/κ)*t*(δ^(1/5 : ℝ)*δ^(-(1/50 : ℝ))) := by ring + _ ≤ _ := hb + have hnon : 0 ≤ (16+4538*Cs)*t*δ^(1/10 : ℝ) := by positivity + calc + _ ≤ 4*(errorGapConstant Cs/κ)*t*δ^(1/10 : ℝ)+14*(t*δ^(1/10 : ℝ))+ + (16+4538*Cs)*t*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by linarith + _ ≤ (16+4538*Cs)*t*δ^(1/10 : ℝ)+ + (4*(errorGapConstant Cs/κ)*t*δ^(1/10 : ℝ)+14*(t*δ^(1/10 : ℝ))+ + (16+4538*Cs)*t*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) := le_add_of_nonneg_left hnon + _ = _ := by unfold directionGapConstant; ring + +end DiskScales + +namespace LocalCancellation +open DiskKernels DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +/-- The full finite/infinite active-width argument at a fixed center. The cap +premise is exactly the already proved shell concentration output, not a radius +selection or a projection estimate. -/ +lemma direction_sequence_point {Cs κ d t r : ℝ} {e : ℂ} (a : ConeDensity e κ) + (b : ι → ErrorPiece Cs) (he : ‖e‖ = 1) (hκ : 0 < κ) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hdq : d ≤ 1/4) (hr : r ∈ Icc (1 : ℝ) 2) + (hAt : errorPrice b (1/100) ≤ t) + (k : ∀ n : ℕ, RadiusDensity (r-width d n) (r+width d n) + ⟨216/width d n, div_nonneg (by norm_num) (width_pos hd n).le⟩) (x : ℂ) + (hM : ∀ n, (∫ y, star (y-x)*(kernel (k n) x y : ℂ)*a.density y)+ + (∑ v, ∫ y, star (y-x)*(kernel (k n) x y : ℂ)*(b v).density y) = 0) + (hcap : ∀ j, t*(width d j)^(1/10 : ℝ) ≤ coarseMass b (width d j) (thinShell x r (width d j)) → + (∫ y in Metric.ball x (r-width d j), ‖a.density y‖) ≤ + (errorGapConstant Cs/κ)*t*(width d j)^(-(1/50 : ℝ)) → + ∃ z ∈ thinShell x r (width d j), + (∫ y in thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ)), ‖a.density y‖)+ + coarseMass b (width d j) (thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ))) ≤ + 2*(t*(width d j)^(1/10 : ℝ))) : + max 0 (-inner ℝ e ((∫ y in Metric.ball x r, a.density y)+(∑ v, ∫ y in Metric.ball x r, (b v).density y))) ≤ + (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100)+ + directionGapConstant Cs κ*t*d^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by + classical + have ht : 0 ≤ t := (errorPrice_nonneg b (1/100)).trans hAt + have hd1 : d ≤ 1 := by linarith + have hwp (i : ℕ) := width_pos hd i + have hwq (i : ℕ) := (width_le hd.le i).trans hdq + have hw1 (i : ℕ) := (width_le hd.le i).trans hd1 + have hrw (i : ℕ) : r+width d i ≤ 3 := by linarith [hwq i,hr.2] + have hgpos := directionGapConstant_pos hCs hκ + have hgle := directionGapConstant_ge hCs hκ + let p (i : ℕ) := ∑ v, ∫ y, (kernel (k i) x y : ℂ)*(b v).density y + let P (i : ℕ) := (∫ y, (kernel (k i) x y : ℂ)*a.density y)+p i + let N (i : ℕ) := max 0 (-inner ℝ e (P i)) + let active (i : ℕ) := t*(width d i)^(1/10 : ℝ) ≤ coarseMass b (width d i) (thinShell x r (width d i)) + let inc (i : ℕ) := directionGapConstant Cs κ*t*(width d i)^(1/10 : ℝ) + let B := (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100) + have hi0 (i : ℕ) : 0 ≤ inc i := mul_nonneg (mul_nonneg hgpos.le ht) (Real.rpow_nonneg (hwp i).le _) + have hN0 (i : ℕ) : 0 ≤ N i := le_max_left _ _ + have hNerr (i : ℕ) : N i ≤ ‖p i‖ := cone_negative_le_error a he hκ.le + (kernel_lipschitz (k i) x).continuous.aestronglyMeasurable + (kernel_nonneg (k i) x) (kernel_le_one (k i) x) (p i) + have hfirst (n : ℕ) (hn : ∀ i < n, ¬active i) : N n ≤ B+∑ i ∈ Finset.range n, inc i := by + have hincr (i : ℕ) (hin : i < n) : dist (p i) (p (i+1)) ≤ inc i := by + have hs : coarseMass b (width d i) (thinShell x r (width d i)) ≤ t*(width d i)^(1/10 : ℝ) := + le_of_lt (lt_of_not_ge (hn i hin)) + exact (inactive_kernel_distance b hCs hd hd1 hAt k x i hs).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hgle ht) (Real.rpow_nonneg (hwp i).le _)) + have hh := dist_le_range_sum_of_dist_le n (fun {i} hin => hincr i hin) + have hp0 : ‖p 0‖ ≤ B := by + have h := kernel_error_bound b hCs (hwp 0) (hw1 0) (k 0) x + simpa only [p,B,width,pow_zero,mul_one] using h + have hp : ‖p n‖ ≤ ‖p 0‖+dist (p 0) (p n) := by + calc + ‖p n‖ = ‖p 0+(p n-p 0)‖ := by congr 1; abel + _ ≤ ‖p 0‖+‖p n-p 0‖ := norm_add_le _ _ + _ = _ := by rw [dist_eq_norm,norm_sub_rev] + linarith [hNerr n] + have hgap (j n : ℕ) (hjn : j < n) (ha : active j) + (hn : ∀ i, j < i → i < n → ¬active i) : N n ≤ N j+inc j := by + by_cases hnn : N n ≤ N j + · exact hnn.trans (le_add_of_nonneg_right (hi0 j)) + have hsmall (i : ℕ) (hji : j < i) (hin : i < n) : + coarseMass b (width d i) (thinShell x r (width d i)) ≤ t*(width d i)^(1/10 : ℝ) := + le_of_lt (lt_of_not_ge (hn i hji hin)) + obtain ⟨hpj,hpn⟩ := kernel_gap_errors b hCs hd hd1 hAt k x hjn hsmall + change ‖p j‖ ≤ errorGapConstant Cs*t*(width d j)^(-(1/50 : ℝ)) at hpj + change ‖p n‖ ≤ errorGapConstant Cs*t*(width d j)^(-(1/50 : ℝ)) at hpn + have hneg : inner ℝ e (P n) < 0 := by + by_contra hh + have hh' : N n = 0 := max_eq_left (by linarith [le_of_not_gt hh]) + exact hnn (by rw [hh']; exact hN0 j) + have hmass := cone_mass_of_nonpositive a he hκ + (kernel_lipschitz (k n) x).continuous.aestronglyMeasurable + (kernel_nonneg (k n) x) (kernel_le_one (k n) x) hneg.le + have hinterior : (∫ y in Metric.ball x (r-width d j), ‖a.density y‖) ≤ + (errorGapConstant Cs/κ)*t*(width d j)^(-(1/50 : ℝ)) := by + calc + _ ≤ ∫ y, kernel (k n) x y*‖a.density y‖ := + interior_mass_le_kernel a.integrable (k n) x (width_antitone hd.le hjn.le) + _ ≤ ‖p n‖/κ := hmass + _ ≤ (errorGapConstant Cs*t*(width d j)^(-(1/50 : ℝ)))/κ := div_le_div_of_nonneg_right hpn hκ.le + _ = _ := by ring + obtain ⟨z,hz,hzc⟩ := hcap j ha hinterior + have hzlo : (1 : ℝ)/2 ≤ ‖z-x‖ := by + have hh := (abs_le.mp (show |‖z-x‖-r| ≤ width d j from hz)).1 + linarith [hr.1,hwq j] + have hD3 : ∀ y ∈ thinShell x r (width d j), ‖y-x‖ ≤ 3 := by + intro y hy + have hh := (abs_le.mp (show |‖y-x‖-r| ≤ width d j from hy)).2 + linarith [hrw j] + have hcapb : coarseMass b (width d j) (thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ))) ≤ + 2*(t*(width d j)^(1/10 : ℝ)) := by + have hn : 0 ≤ ∫ y in thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ)), ‖a.density y‖ := + integral_nonneg (fun y => norm_nonneg _) + linarith + have hcapa : (∫ y in thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ)), ‖a.density y‖) ≤ + 2*(t*(width d j)^(1/10 : ℝ)) := by + linarith [coarseMass_nonneg b (width d j) (thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ)))] + let R := ∑ v, ∫ y, correction x z y*((kernel (k n) x y : ℂ)-kernel (k j) x y)*(b v).density y + have hR : ‖R‖ ≤ (16+4538*Cs)*t*(width d j)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := + corrected_kernel_gap b hCs hd hdq hr hAt k x z hjn hzlo hcapb hsmall + have hsupp : ∀ y, kernel (k n) x y-kernel (k j) x y ≠ 0 → y ∈ thinShell x r (width d j) := by + intro y hy + apply difference_support (k j) (k n) (width_antitone hd.le hjn.le) x y + simpa only [← Complex.ofReal_sub,ne_eq,Complex.ofReal_eq_zero] using hy + have hcor : P n-P j = + (∫ y, correction x z y*((kernel (k n) x y : ℂ)-kernel (k j) x y)*a.density y)+R := + balanced_kernel_gap_identity b a.integrable (k j) (k n) x z (hrw j) (hrw n) + (width_antitone hd.le hjn.le) (hM j) (hM n) + have hh := negative_gap_cap a he hκ (Real.rpow_nonneg (hwp j).le (1/5)) + (kernel_lipschitz (k j) x).continuous.aestronglyMeasurable + (kernel_lipschitz (k n) x).continuous.aestronglyMeasurable + (kernel_nonneg (k j) x) (kernel_le_one (k j) x) + (kernel_nonneg (k n) x) (kernel_le_one (k n) x) + (measurableSet_thinShell x r (width d j)) hsupp x z hzlo hD3 hcapa hpj hpn hneg hcor + change N n ≤ N j+4*(width d j)^(1/5 : ℝ)*((errorGapConstant Cs*t*(width d j)^(-(1/50 : ℝ)))/κ)+ + 7*(2*(t*(width d j)^(1/10 : ℝ)))+‖R‖ at hh + have hscale := direction_cap_scale hCs hκ (hwp j) (hw1 j) ht + dsimp only [inc] + linarith + let Z := (∫ y in Metric.ball x r, a.density y)+(∑ v, ∫ y in Metric.ball x r, (b v).density y) + have hlimP : Tendsto P atTop (𝓝 Z) := + (tendsto_kernel_pairing k (tendsto_width d) x a.integrable).add + (tendsto_finsetSum Finset.univ (fun v _ => tendsto_kernel_pairing k (tendsto_width d) x (b v).integrable)) + have hlimN : Tendsto N atTop (𝓝 (max 0 (-inner ℝ e Z))) := + tendsto_const_nhds.max ((tendsto_const_nhds.inner hlimP).neg) + have hsm : Summable inc := (summable_width_rpow hd.le (by norm_num : (0 : ℝ) < 1/10)).mul_left _ + have hh := last_active_limit active N inc B _ hi0 hsm hlimN hfirst hgap + dsimp only [inc] at hh + rw [tsum_mul_left,tsum_width_rpow hd.le (by norm_num : (0 : ℝ) < 1/10)] at hh + convert hh using 1; dsimp only [B,Z]; ring + +def directionShellBound {Cs : ℝ} (b : ι → ErrorPiece Cs) (κ t δ : ℝ) : ℝ≥0∞ := + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ ^ 2 * + (ENNReal.ofReal (156*δ/δ^(1/5 : ℝ))* + ENNReal.ofReal (coarseMass b δ univ)*ENNReal.ofReal (coarseMass b δ univ)) + + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ * + ((ENNReal.ofReal (6*Real.pi)* + ENNReal.ofReal (2*(200*δ/(δ^(1/5 : ℝ))^2)* + (1+((errorGapConstant Cs/κ)*t*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ)))))* + ENNReal.ofReal (coarseMass b δ univ)) + +/-- Radius-independent exceptional union for the full directional sequence. +The cap property is produced by shell concentration for the actual densities. -/ +theorem direction_sequence {e : ℂ} {κ Cs d t : ℝ} (a : ConeDensity e κ) + (b : ι → ErrorPiece Cs) (he : ‖e‖ = 1) (hκ : 0 < κ) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hdq : d ≤ 1/4) + (hgeom : ∀ δ : ℝ, 0 < δ → δ ≤ d → δ ≤ (δ^(1/5 : ℝ))^2/1600) + (ht : 0 < t) (hAt : errorPrice b (1/100) ≤ t) : + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ ∑' n : ℕ, directionShellBound b κ t (width d n) ∧ + ∀ x ∉ E, ∀ r ∈ Icc (1 : ℝ) 2, + ∀ k : ∀ n : ℕ, RadiusDensity (r-width d n) (r+width d n) + ⟨216/width d n, div_nonneg (by norm_num) (width_pos hd n).le⟩, + (∀ n, (∫ y, star (y-x)*(kernel (k n) x y : ℂ)*a.density y)+ + (∑ v, ∫ y, star (y-x)*(kernel (k n) x y : ℂ)*(b v).density y) = 0) → + max 0 (-inner ℝ e ((∫ y in Metric.ball x r, a.density y)+ + (∑ v, ∫ y in Metric.ball x r, (b v).density y))) ≤ + (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100)+ + directionGapConstant Cs κ*t*d^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by + have : IsFiniteMeasure (densityMeasure a.density) := densityMeasure_finite a.integrable + have hd1 : d ≤ 1 := by linarith + have hwp (n : ℕ) := width_pos hd n + have hw1 (n : ℕ) := (width_le hd.le n).trans hd1 + have hρ (n : ℕ) : 0 < (width d n)^(1/5 : ℝ) := Real.rpow_pos_of_pos (hwp n) _ + have hρ1 (n : ℕ) : (width d n)^(1/5 : ℝ) ≤ 1 := + Real.rpow_le_one (hwp n).le (hw1 n) (by norm_num) + have hs (n : ℕ) := shell_concentration (coarseMeasure b (width d n)) (densityMeasure a.density) + (hρ n) (hρ1 n) (hwp n) (hgeom _ (hwp n) (width_le hd.le n)) + (mul_nonneg (mul_nonneg (div_nonneg (errorGapConstant_pos hCs).le hκ.le) ht.le) + (Real.rpow_nonneg (hwp n).le (-(1/50 : ℝ)))) + (mul_pos ht (Real.rpow_pos_of_pos (hwp n) (1/10 : ℝ))) + choose E hE hEv hEst using hs + refine ⟨⋃ n, E n, MeasurableSet.iUnion hE, + (measure_iUnion_le E).trans (ENNReal.tsum_le_tsum ?_), ?_⟩ + · intro n + simpa only [directionShellBound,coarseMeasure_apply b (width d n) MeasurableSet.univ] using hEv n + · intro x hx r hr k hM + apply direction_sequence_point a b he hκ hCs hd hdq hr hAt k x hM + intro j ha hi + have hxE : x ∉ E j := fun hh => hx (mem_iUnion.mpr ⟨j,hh⟩) + obtain ⟨z,hz,hcap⟩ := hEst j x hxE r hr + (by rw [coarseMeasure_apply b (width d j) (measurableSet_thinShell x r (width d j))]; exact ENNReal.ofReal_le_ofReal ha) + (by rw [densityMeasure_apply a.integrable measurableSet_ball]; exact ENNReal.ofReal_le_ofReal hi) + refine ⟨z,hz,?_⟩ + have hD : MeasurableSet (thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ))) := + (measurableSet_thinShell x r (width d j)).diff measurableSet_ball + rw [Measure.add_apply, densityMeasure_apply a.integrable hD, + coarseMeasure_apply b (width d j) hD, ← ENNReal.ofReal_add + (integral_nonneg (fun _ => norm_nonneg _)) (coarseMass_nonneg b (width d j) _)] at hcap + exact (ENNReal.ofReal_le_ofReal_iff (mul_nonneg (by norm_num) + (mul_nonneg ht.le (Real.rpow_nonneg (hwp j).le _)))).mp hcap + +end LocalCancellation + +namespace DiskMoments +open DiskKernels + +def NeighborhoodRadius (g : ℂ → ℝ) (x : ℂ) (r : ℝ) : Prop := + r ∈ Icc (1 : ℝ) 2 ∧ ∀ t : ℝ, 0 < t → |t-r| ≤ 1/4 → + signedAverage g x t ≤ signedAverage g x r + +lemma neighborhood_kernel {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {x : ℂ} {r δ : ℝ} + (hr : NeighborhoodRadius g x r) (hδ : 0 < δ) (hδq : δ ≤ 1/4) : + ∃ k : RadiusDensity (r-δ) (r+δ) ⟨216/δ, by positivity⟩, + (∫ y, kernel k x y • (star (y-x)*gradient g y)) = 0 := by + apply balanced_kernel hg x hr.1 hδ hδq + · apply hr.2 _ (by linarith [hr.1.1]) + rw [abs_le] + constructor <;> linarith + · apply hr.2 _ (by linarith [hr.1.1]) + rw [abs_le] + constructor <;> linarith + +end DiskMoments + +namespace LocalCancellation +open DiskKernels DiskMoments DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +lemma mixed_moment_pairing_decomposition {Cs r δ : ℝ} (b : ι → ErrorPiece Cs) + {a : ℂ → ℂ} (ha : Integrable a) {M : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) + (x : ℂ) {h : ℂ → ℂ} (hr : r+δ ≤ 3) + (hh : ∀ᵐ y, y ∈ Metric.ball x 3 → a y+∑ j, (b j).density y = h y) : + (∫ y, star (y-x)*(kernel k x y : ℂ)*a y)+ + (∑ j, ∫ y, star (y-x)*(kernel k x y : ℂ)*(b j).density y) = + ∫ y, kernel k x y • (star (y-x)*h y) := by + rw [← integral_finsetSum _ (fun j _ => moment_pairing_integrable (b j) k x hr), + ← integral_add (general_moment_integrable ha k x hr) + (integrable_finsetSum _ (fun j _ => moment_pairing_integrable (b j) k x hr))] + apply integral_congr_ae + filter_upwards [hh] with y hy + simp only [← Finset.mul_sum, ← mul_add] + by_cases hmem : y ∈ Metric.ball x 3 + · rw [hy hmem, Complex.real_smul] + ring + · have hk : kernel k x y = 0 := kernel_zero k x (fun hb => hmem (lt_of_lt_of_le hb hr)) + rw [hk, Complex.ofReal_zero, mul_zero, zero_mul, zero_smul] + +lemma mixed_ball_pairing_decomposition {Cs r : ℝ} (b : ι → ErrorPiece Cs) + {a : ℂ → ℂ} (ha : Integrable a) (x : ℂ) {h : ℂ → ℂ} (hr : r ≤ 3) + (hh : ∀ᵐ y, y ∈ Metric.ball x 3 → a y+∑ j, (b j).density y = h y) : + (∫ y in Metric.ball x r, a y)+(∑ j, ∫ y in Metric.ball x r, (b j).density y) = + ∫ y in Metric.ball x r, h y := by + rw [← integral_finsetSum _ (fun j _ => (b j).integrable.integrableOn), + ← integral_add ha.integrableOn (integrable_finsetSum _ (fun j _ => (b j).integrable.integrableOn))] + apply setIntegral_congr_ae measurableSet_ball + filter_upwards [hh] with y hy hyb + exact hy (lt_of_lt_of_le hyb hr) + +/-- Directional estimate at all genuine neighborhood-maximizing radii, +with only the original local density equality. -/ +theorem direction_raw {e : ℂ} {κ Cs d t : ℝ} (a : ConeDensity e κ) + (b : ι → ErrorPiece Cs) (he : ‖e‖ = 1) (hκ : 0 < κ) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hdq : d ≤ 1/4) + (hgeom : ∀ δ : ℝ, 0 < δ → δ ≤ d → δ ≤ (δ^(1/5 : ℝ))^2/1600) + (ht : 0 < t) (hAt : errorPrice b (1/100) ≤ t) + {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) : + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ ∑' n : ℕ, directionShellBound b κ t (width d n) ∧ + ∀ x ∉ E, + (∀ᵐ y, y ∈ Metric.ball x 3 → a.density y+∑ j, (b j).density y = gradient g y) → + ∀ r, NeighborhoodRadius g x r → + max 0 (-inner ℝ e (∫ y in Metric.ball x r, gradient g y)) ≤ + (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100)+ + directionGapConstant Cs κ*t*d^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by + obtain ⟨E,hE,hEv,hEst⟩ := direction_sequence a b he hκ hCs hd hdq hgeom ht hAt + refine ⟨E,hE,hEv,?_⟩ + intro x hx hh r hr + choose k hk using fun n => neighborhood_kernel hg hr (width_pos hd n) ((width_le hd.le n).trans hdq) + rw [← mixed_ball_pairing_decomposition b a.integrable x (by linarith [hr.1.2]) hh] + apply hEst x hx r hr.1 k + intro n + rw [mixed_moment_pairing_decomposition b a.integrable (k n) x + (by linarith [hr.1.2,(width_le hd.le n).trans hdq]) hh] + exact hk n + +end LocalCancellation + +namespace DiskScales + +lemma third_power_identity {δ : ℝ} (hδ : 0 < δ) : + ((δ^(1/10 : ℝ))⁻¹ * (δ / (δ^(1/5 : ℝ))^2 * δ^(-(1/50 : ℝ)))) * + (δ^(-(1/50 : ℝ))/δ^(1/10 : ℝ)) = δ^(9/25 : ℝ) := by + rw [second_power_identity hδ, ← Real.rpow_sub hδ, ← Real.rpow_add hδ] + norm_num + +lemma direction_shell_tail_scaled {A t δ M H : ℝ} (hA : 0 ≤ A) (ht : 0 < t) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hM0 : 0 ≤ M) (hH : 0 ≤ H) + (hM : M ≤ A*δ^(-(1/50 : ℝ))) : + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ ^ 2 * + (ENNReal.ofReal (156*δ/δ^(1/5 : ℝ))*ENNReal.ofReal M*ENNReal.ofReal M) + + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ * + ((ENNReal.ofReal (6*Real.pi)*ENNReal.ofReal + (2*(200*δ/(δ^(1/5 : ℝ))^2)*(1+(H*t*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ)))))*ENNReal.ofReal M) ≤ + ENNReal.ofReal ((1+H)*(156*(A/t)^2*δ^(14/25 : ℝ)+2424*Real.pi*(A/t)*δ^(9/25 : ℝ))) := by + have hU : 0 < t*δ^(1/10 : ℝ) := mul_pos ht (Real.rpow_pos_of_pos hδ _) + rw [← ENNReal.ofReal_inv_of_pos hU, ← ENNReal.ofReal_pow (inv_nonneg.mpr hU.le)] + have hp : 0 ≤ 156*δ/δ^(1/5 : ℝ) := by positivity + have hp' : 0 ≤ 2*(200*δ/(δ^(1/5 : ℝ))^2)*(1+(H*t*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ))) := by positivity + rw [← ENNReal.ofReal_mul hp, ← ENNReal.ofReal_mul (mul_nonneg hp hM0), + ← ENNReal.ofReal_mul (sq_nonneg _), + ← ENNReal.ofReal_mul (show (0 : ℝ) ≤ 6*Real.pi by positivity), + ← ENNReal.ofReal_mul (mul_nonneg (by positivity) hp'), + ← ENNReal.ofReal_mul (inv_nonneg.mpr hU.le), + ← ENNReal.ofReal_add (by positivity) (by positivity)] + apply ENNReal.ofReal_le_ofReal + have hfirst : (t*δ^(1/10 : ℝ))⁻¹^2 * (156*δ/δ^(1/5 : ℝ)*M*M) ≤ + 156*(A/t)^2*δ^(14/25 : ℝ) := by + calc + _ ≤ (t*δ^(1/10 : ℝ))⁻¹^2 * + (156*δ/δ^(1/5 : ℝ)*(A*δ^(-(1/50 : ℝ)))*(A*δ^(-(1/50 : ℝ)))) := by gcongr + _ = _ := by rw [← first_power_identity hδ]; simp only [mul_inv_rev]; ring + have hratio : (H*t*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ)) = H*(δ^(-(1/50 : ℝ))/δ^(1/10 : ℝ)) := by + field_simp + have hsecond : (t*δ^(1/10 : ℝ))⁻¹ * + (6*Real.pi*(2*(200*δ/(δ^(1/5 : ℝ))^2)*(1+(H*t*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ))))*M) ≤ + (1+H)*(2400*Real.pi*(A/t)*δ^(9/25 : ℝ)) := by + calc + _ ≤ (t*δ^(1/10 : ℝ))⁻¹ * + (6*Real.pi*(2*(200*δ/(δ^(1/5 : ℝ))^2)*(1+(H*t*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ))))*(A*δ^(-(1/50 : ℝ)))) := by gcongr + _ = 2400*Real.pi*(A/t)*δ^(12/25 : ℝ)+H*(2400*Real.pi*(A/t)*δ^(9/25 : ℝ)) := by + rw [hratio, ← third_power_identity hδ, ← second_power_identity hδ] + simp only [mul_inv_rev] + ring + _ ≤ 2400*Real.pi*(A/t)*δ^(9/25 : ℝ)+H*(2400*Real.pi*(A/t)*δ^(9/25 : ℝ)) := + add_le_add (mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num : (9/25 : ℝ) ≤ 12/25)) + (by positivity : 0 ≤ 2400*Real.pi*(A/t))) le_rfl + _ = _ := by ring + have hfirst' : 156*(A/t)^2*δ^(14/25 : ℝ) ≤ (1+H)*(156*(A/t)^2*δ^(14/25 : ℝ)) := + le_mul_of_one_le_left (by positivity) (by linarith) + have hextra : (1+H)*(2400*Real.pi*(A/t)*δ^(9/25 : ℝ)) ≤ + (1+H)*(2424*Real.pi*(A/t)*δ^(9/25 : ℝ)) := by gcongr; norm_num + calc + _ ≤ (1+H)*(156*(A/t)^2*δ^(14/25 : ℝ))+(1+H)*(2424*Real.pi*(A/t)*δ^(9/25 : ℝ)) := + add_le_add (hfirst.trans hfirst') (hsecond.trans hextra) + _ = _ := by ring + +lemma direction_start_identity {Cs κ A t : ℝ} (hA : 0 < A) (ht : 0 < t) : + (1+216*Cs)/(A/t)^(1/100 : ℝ)*A+ + directionGapConstant Cs κ*t*(A/t)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) = + t*((1+216*Cs)*(A/t)^(99/100 : ℝ)+ + directionGapConstant Cs κ*(A/t)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) := by + have hq : 0 < A/t := div_pos hA ht + have he : (A/t)/(A/t)^(1/100 : ℝ) = (A/t)^(99/100 : ℝ) := by + have hh := Real.rpow_sub hq (1 : ℝ) (1/100 : ℝ) + norm_num at hh + exact hh.symm + have hAt : t*(A/t) = A := by field_simp + calc + _ = t*((1+216*Cs)*((A/t)/(A/t)^(1/100 : ℝ))+ + directionGapConstant Cs κ*(A/t)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) := by + rw [mul_add] + congr 1 + · calc + _ = (1+216*Cs)/(A/t)^(1/100 : ℝ)*(t*(A/t)) := by rw [hAt] + _ = _ := by ring + · ring + _ = _ := by rw [he] + +lemma exists_direction_parameters (Cs κ : ℝ) : + ∃ d₀ : ℝ, 0 < d₀ ∧ d₀ ≤ 1/4 ∧ + (∀ δ : ℝ, 0 < δ → δ ≤ d₀ → δ ≤ (δ^(1/5 : ℝ))^2/1600) ∧ + (∀ δ : ℝ, 0 < δ → δ ≤ d₀ → + (1+216*Cs)*δ^(99/100 : ℝ)+ + directionGapConstant Cs κ*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) ≤ 1) := by + obtain ⟨d,hd,hdq,hgeom⟩ := exists_admissible_width + have ht : Tendsto (fun δ : ℝ => (1+216*Cs)*δ^(99/100 : ℝ)+ + directionGapConstant Cs κ*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) (𝓝 0) (𝓝 0) := by + have h1 := (Real.continuous_rpow_const (by norm_num : (0 : ℝ) ≤ 99/100)).tendsto 0 + have h2 := (Real.continuous_rpow_const (by norm_num : (0 : ℝ) ≤ 1/10)).tendsto 0 + simpa using (h1.const_mul (1+216*Cs)).add ((h2.const_mul (directionGapConstant Cs κ)).div_const _) + obtain ⟨l,u,hu,hs⟩ := mem_nhds_iff_exists_Ioo_subset.mp + (ht.eventually_lt_const (by norm_num : (0 : ℝ) < 1)) + let d₀ := min d (u/2) + have hd0 : 0 < d₀ := lt_min hd (by linarith [hu.2]) + refine ⟨d₀,hd0,(min_le_left _ _).trans hdq,fun δ hδ hδd => hgeom δ hδ (hδd.trans (min_le_left _ _)), ?_⟩ + intro δ hδ hδd + apply le_of_lt + apply hs + exact ⟨lt_trans hu.1 hδ, lt_of_le_of_lt hδd ((min_le_right _ _).trans_lt (by linarith [hu.2]))⟩ + +end DiskScales + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DiskScales3.lean b/lean/OAI/Analysis/SignedDisk/DiskScales3.lean new file mode 100644 index 0000000000000000000000000000000000000000..417a2462923c2d760be9945067597ea7c04b6b44 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DiskScales3.lean @@ -0,0 +1,452 @@ +import OAI.Analysis.SignedDisk.DiskScales2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace DiskScales + +def directionTailConstant (Cs κ : ℝ) : ℝ := (1+errorGapConstant Cs/κ)*sizeTailConstant + +lemma directionTailConstant_pos {Cs κ : ℝ} (hCs : 0 ≤ Cs) (hκ : 0 < κ) : + 0 < directionTailConstant Cs κ := by + unfold directionTailConstant + have hh := errorGapConstant_pos hCs + exact mul_pos (by positivity) sizeTailConstant_pos + +end DiskScales + +namespace LocalCancellation +open DiskKernels DiskMoments DiskGeometry DiskScales + +/-- A genuine superlevel bound with exponent 34/25 > 1 for all neighborhood +maxima, independent of the number of positive or cancelling pieces. -/ +theorem direction_tail {Cs κ : ℝ} (hCs : 0 ≤ Cs) (hκ : 0 < κ) : + ∃ L : ℝ, 1 ≤ L ∧ ∀ {ι : Type*} [Fintype ι] {e : ℂ} (a : ConeDensity e κ) + (b : ι → ErrorPiece Cs), ‖e‖ = 1 → + 0 < errorPrice b (1/100) → ∀ t : ℝ, L*errorPrice b (1/100) ≤ t → + ∀ g : ℂ → ℝ, ContDiff ℝ 1 g → + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ ENNReal.ofReal (directionTailConstant Cs κ*(errorPrice b (1/100)/t)^(34/25 : ℝ)) ∧ + ∀ x ∉ E, + (∀ᵐ y, y ∈ Metric.ball x 3 → a.density y+∑ j, (b j).density y = gradient g y) → + ∀ r, NeighborhoodRadius g x r → + max 0 (-inner ℝ e (∫ y in Metric.ball x r, gradient g y)) ≤ t := by + obtain ⟨d₀,hd0,hdq,hgeom,hsmall⟩ := exists_direction_parameters Cs κ + have hL : 1 ≤ (1 : ℝ)/d₀ := (le_div_iff₀ hd0).mpr (by linarith) + refine ⟨1/d₀,hL,?_⟩ + intro ι _ e a b he hA t ht g hg + let A := errorPrice b (1/100) + let H := errorGapConstant Cs/κ + have hH : 0 ≤ H := div_nonneg (errorGapConstant_pos hCs).le hκ.le + have hH1 : 0 ≤ 1+H := by linarith + have hAt : A ≤ t := (le_mul_of_one_le_left hA.le hL).trans ht + have ht0 : 0 < t := lt_of_lt_of_le hA hAt + have hqd : A/t ≤ d₀ := by + apply (div_le_iff₀ ht0).mpr + have hh : A/d₀ ≤ t := by simpa only [A,one_div, div_eq_mul_inv, mul_comm, mul_one] using ht + have hh' := (div_le_iff₀ hd0).mp hh + linarith + have hq0 : 0 < A/t := div_pos hA ht0 + have hq1 : A/t ≤ 1 := by linarith + have hqq : A/t ≤ 1/4 := hqd.trans hdq + obtain ⟨E,hE,hEv,hEst⟩ := direction_raw a b he hκ hCs hq0 hqq + (fun δ hδ hδq => hgeom δ hδ (hδq.trans hqd)) ht0 hAt hg + refine ⟨E,hE,?_,?_⟩ + · apply hEv.trans + calc + _ ≤ ∑' n : ℕ, ENNReal.ofReal (1+H)*ENNReal.ofReal + (156*(A/t)^2*(width (A/t) n)^(14/25 : ℝ)+ + 2424*Real.pi*(A/t)*(width (A/t) n)^(9/25 : ℝ)) := by + apply ENNReal.tsum_le_tsum + intro n + rw [← ENNReal.ofReal_mul hH1] + apply direction_shell_tail_scaled hA.le ht0 (width_pos hq0 n) + ((width_le hq0.le n).trans hq1) (coarseMass_nonneg b _ _) hH + have hw0 := width_pos hq0 n + have hh := coarseMass_bound b (by norm_num : (0 : ℝ) ≤ 1/100) hw0 + norm_num at hh + rw [Real.rpow_neg hw0.le] + exact hh + _ = ENNReal.ofReal (1+H)*ENNReal.ofReal + ((156/(1-(1/2 : ℝ)^(14/25 : ℝ)))*(A/t)^(64/25 : ℝ)+ + (2424*Real.pi/(1-(1/2 : ℝ)^(9/25 : ℝ)))*(A/t)^(34/25 : ℝ)) := by + rw [ENNReal.tsum_mul_left,geometric_tail_sum hA.le ht0 hq0.le, starting_width_tail hA ht0] + _ ≤ ENNReal.ofReal (1+H)*ENNReal.ofReal (sizeTailConstant*(A/t)^(34/25 : ℝ)) := by + gcongr + exact collapse_size_tail hq0 hq1 + _ = _ := by rw [← ENNReal.ofReal_mul hH1]; congr 1; dsimp only [directionTailConstant,H,A]; ring + · intro x hx hh r hr + apply (hEst x hx hh r hr).trans + rw [direction_start_identity hA ht0] + exact (mul_le_mul_of_nonneg_left (hsmall _ hq0 hqd) ht0.le).trans_eq (mul_one t) + +lemma cone_ball_nonneg {e : ℂ} {κ : ℝ} (a : ConeDensity e κ) (hκ : 0 ≤ κ) (x : ℂ) (r : ℝ) : + 0 ≤ inner ℝ e (∫ y in Metric.ball x r, a.density y) := by + rw [← integral_inner a.integrable.integrableOn e] + apply integral_nonneg_of_ae + filter_upwards [ae_restrict_of_ae a.cone] with y hy + exact (mul_nonneg hκ (norm_nonneg _)).trans hy + +/-- Full Borel integrable directional price. This is the hard local +cancellation estimate, not an assumed maximal-operator endpoint. -/ +theorem direction_majorant {Cs κ : ℝ} (hCs : 0 ≤ Cs) (hκ : 0 < κ) : + ∃ C : ℝ, 0 < C ∧ ∀ {ι : Type*} [Fintype ι] {e : ℂ} (a : ConeDensity e κ) + (b : ι → ErrorPiece Cs), ‖e‖ = 1 → + ∀ g : ℂ → ℝ, ContDiff ℝ 1 g → ∀ Q : Set ℂ, volume Q ≤ ENNReal.ofReal 1 → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ x in Q, F x) ≤ ENNReal.ofReal (C*errorPrice b (1/100)) ∧ + ∀ x, (∀ᵐ y, y ∈ Metric.ball x 3 → a.density y+∑ j, (b j).density y = gradient g y) → + ∀ r, NeighborhoodRadius g x r → + ENNReal.ofReal (max 0 (-inner ℝ e (∫ y in Metric.ball x r, gradient g y))) ≤ F x := by + obtain ⟨L,hL,hdir⟩ := direction_tail hCs hκ + let c : ℝ := (1/2 : ℝ)^(34/25 : ℝ) + have hc : 0 ≤ c := Real.rpow_nonneg (by norm_num) _ + have hc1 : 2*c < 1 := by + have hh := Real.rpow_lt_rpow_of_exponent_gt (by norm_num : (0 : ℝ) < 1/2) + (by norm_num : (1/2 : ℝ) < 1) (by norm_num : (1 : ℝ) < 34/25) + norm_num at hh + linarith + let C := L*(1+2*directionTailConstant Cs κ/(1-2*c)) + have hD := directionTailConstant_pos hCs hκ + have hC : 0 < C := mul_pos (by linarith) (by + have := sub_pos.mpr hc1 + positivity) + refine ⟨C,hC,?_⟩ + intro ι _ e a b he g hg Q hQ + let A := errorPrice b (1/100) + by_cases hAz : A = 0 + · refine ⟨0,measurable_const,?_,?_⟩ + · simp only [Pi.zero_apply, lintegral_zero, A, hAz, mul_zero, ENNReal.ofReal_zero, le_refl] + · intro x hh r hr + have hz := errorPrice_zero b hAz + have hs : (∑ j, ∫ y in Metric.ball x r, (b j).density y) = 0 := by + apply Finset.sum_eq_zero + intro j _ + exact integral_eq_zero_of_ae (ae_restrict_of_ae (hz j)) + have hb := mixed_ball_pairing_decomposition b a.integrable x (by linarith [hr.1.2] : r ≤ 3) hh + rw [← hb,hs,add_zero,max_eq_left (neg_nonpos.mpr (cone_ball_nonneg a hκ.le x r)),ENNReal.ofReal_zero] + exact le_refl _ + · have hA : 0 < A := lt_of_le_of_ne (errorPrice_nonneg b _) (Ne.symm hAz) + have ht : 0 < L*A := mul_pos (by linarith) hA + have hts (n : ℕ) : L*A ≤ L*A*2^n := le_mul_of_one_le_right ht.le (one_le_pow₀ (by norm_num)) + choose E hE hEv hbound using fun n : ℕ => hdir a b he hA (L*A*2^n) (hts n) g hg + refine ⟨DyadicMajorant.price (L*A) E, DyadicMajorant.measurable_price _ hE,?_,?_⟩ + · have htail (n : ℕ) : volume (E n) ≤ ENNReal.ofReal (directionTailConstant Cs κ*c^n) := by + apply (hEv n).trans + apply ENNReal.ofReal_le_ofReal + apply mul_le_mul_of_nonneg_left _ hD.le + calc + _ ≤ ((1/2 : ℝ)^n)^(34/25 : ℝ) := Real.rpow_le_rpow (by positivity) (dyadic_ratio hA hL n) (by norm_num) + _ = c^n := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num), mul_comm (n : ℝ), + Real.rpow_mul (by norm_num), Real.rpow_natCast] + have hi := DyadicMajorant.lintegral_price_geometric volume (by norm_num : (0 : ℝ) ≤ 1) hQ ht.le + hD.le hc hc1 hE htail + convert hi using 1 + congr 1 + dsimp [C,A] + ring + · intro x hh r hr + apply DyadicMajorant.majorizes ht + intro n hn + exact hbound n x hn hh r hr + +end LocalCancellation + +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology + +namespace DiskMaximalTools + +lemma volume_dilate_five (x : ℂ) (r : ℝ) : + volume (ball x (5*r)) = 25 * volume (ball x r) := by + rw [Complex.volume_ball, Complex.volume_ball, ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 5)] + norm_num [mul_pow] + ring + +/-- The actual Vitali weak-(1,1) estimate, with no assumed maximal inequality. -/ +theorem weak_bound_bounded_family {ι : Type*} (t : Set ι) (x : ι → ℂ) (r : ι → ℝ) + (ν : Measure ℂ) {R a : ℝ} (ha : 0 < a) + (hr : ∀ i ∈ t, 0 < r i) (hR : ∀ i ∈ t, r i ≤ R) + (hav : ∀ i ∈ t, ENNReal.ofReal a * volume (ball (x i) (r i)) ≤ ν (ball (x i) (r i))) : + volume (⋃ i ∈ t, ball (x i) (r i)) ≤ (25 / ENNReal.ofReal a) * ν univ := by + obtain ⟨u,hut,hdisj,hcover⟩ := Vitali.exists_disjoint_subfamily_covering_enlargement_ball + t x r R hR 5 (by norm_num) + have huc : u.Countable := hdisj.countable_of_isOpen (fun _ _ => isOpen_ball) + (fun i hi => ⟨x i,mem_ball_self (hr i (hut hi))⟩) + have : Countable u := huc.to_subtype + have hsub : (⋃ i ∈ t, ball (x i) (r i)) ⊆ ⋃ i : u, ball (x i) (5*r i) := by + intro y hy + obtain ⟨i,hi,hy⟩ := mem_iUnion₂.mp hy + obtain ⟨j,hj,hij⟩ := hcover i hi + exact mem_iUnion.mpr ⟨⟨j,hj⟩,hij hy⟩ + have hmass : (∑' i : u, ν (ball (x i) (r i))) ≤ ν univ := by + rw [← measure_iUnion (fun (i j : u) hij => hdisj i.property j.property (fun h => hij (Subtype.ext h))) + (fun _ => measurableSet_ball)] + exact measure_mono (subset_univ _) + calc + _ ≤ volume (⋃ i : u, ball (x i) (5*r i)) := measure_mono hsub + _ ≤ ∑' i : u, volume (ball (x i) (5*r i)) := measure_iUnion_le _ + _ = ∑' i : u, 25 * volume (ball (x i) (r i)) := by simp_rw [volume_dilate_five] + _ ≤ ∑' i : u, (25 / ENNReal.ofReal a) * ν (ball (x i) (r i)) := by + apply ENNReal.tsum_le_tsum + intro i + have hb := hav i (hut i.property) + calc + _ = (25 / ENNReal.ofReal a) * (ENNReal.ofReal a * volume (ball (x i) (r i))) := by + rw [← mul_assoc, ENNReal.div_mul_cancel (ne_of_gt (ENNReal.ofReal_pos.mpr ha)) ENNReal.ofReal_ne_top] + _ ≤ _ := by gcongr + _ = (25 / ENNReal.ofReal a) * ∑' i : u, ν (ball (x i) (r i)) := by rw [ENNReal.tsum_mul_left] + _ ≤ _ := by gcongr + +lemma volume_disk_real (x : ℂ) {r : ℝ} (hr : 0 ≤ r) : + volume (ball x r) = ENNReal.ofReal (Real.pi*r^2) := by + rw [Complex.volume_ball,ENNReal.ofReal_mul Real.pi_nonneg,ENNReal.ofReal_pow hr] + rw [← (ENNReal.ofReal_coe_nnreal : ENNReal.ofReal (NNReal.pi : ℝ) = (NNReal.pi : ℝ≥0∞))] + exact mul_comm _ _ + +/-- All high-average balls of a finite measure have a common finite radius +bound; the bounded-family Vitali argument therefore controls every radius. -/ +theorem weak_bound {ν : Measure ℂ} [IsFiniteMeasure ν] {a : ℝ} (ha : 0 < a) : + volume {x : ℂ | ∃ r : ℝ, 0 < r ∧ + ENNReal.ofReal a * volume (ball x r) ≤ ν (ball x r)} ≤ + (25 / ENNReal.ofReal a) * ν univ := by + let t : Set (ℂ × ℝ) := {p | 0 < p.2 ∧ + ENNReal.ofReal a * volume (ball p.1 p.2) ≤ ν (ball p.1 p.2)} + let B : ℝ := (ν univ).toReal/(a*Real.pi) + have hB : 0 ≤ B := div_nonneg ENNReal.toReal_nonneg (mul_pos ha Real.pi_pos).le + have hR : ∀ p ∈ t, p.2 ≤ B+1 := by + intro p hp + have hh := hp.2.trans (measure_mono (subset_univ _)) + rw [volume_disk_real _ hp.1.le,← ENNReal.ofReal_mul ha.le] at hh + have hh' : a*(Real.pi*p.2^2) ≤ (ν univ).toReal := by + exact (ENNReal.ofReal_le_iff_le_toReal (measure_ne_top _ _)).mp hh + have hs : p.2^2 ≤ B := (le_div_iff₀ (mul_pos ha Real.pi_pos)).mpr (by nlinarith) + nlinarith [sq_nonneg (p.2-1)] + have hweak := weak_bound_bounded_family t Prod.fst Prod.snd ν ha + (fun _ hp => hp.1) hR (fun _ hp => hp.2) + apply le_trans (measure_mono ?_) hweak + intro x hx + obtain ⟨r,hr,havg⟩ := hx + exact mem_iUnion₂.mpr ⟨(x,r),⟨hr,havg⟩,mem_ball_self hr⟩ + +/-- A countable measurable envelope, sufficiently rich for every actual disk. -/ +def rationalMaximal (ν : Measure ℂ) (x : ℂ) : ℝ≥0∞ := + ⨆ (q : ℚ) (_ : 0 < q), ν (ball x q) / volume (ball x q) + +lemma measurable_ball_mass (ν : Measure ℂ) [SFinite ν] (r : ℝ) : + Measurable (fun x : ℂ => ν (ball x r)) := by + have hm : MeasurableSet {p : ℂ × ℂ | dist p.2 p.1 < r} := + isOpen_lt (continuous_snd.dist continuous_fst) continuous_const |>.measurableSet + exact measurable_measure_prodMk_left hm + +lemma measurable_rationalMaximal (ν : Measure ℂ) [SFinite ν] : + Measurable (rationalMaximal ν) := by + unfold rationalMaximal + apply Measurable.iSup + intro q + apply Measurable.iSup + intro _ + have hd : Measurable (fun x : ℂ => volume (ball x (q:ℝ))) := by + simp only [Complex.volume_ball] + exact measurable_const + exact (measurable_ball_mass ν (q:ℝ)).div hd + +lemma weak_rationalMaximal {ν : Measure ℂ} [IsFiniteMeasure ν] {a : ℝ} (ha : 0 < a) : + volume {x | ENNReal.ofReal a < rationalMaximal ν x} ≤ + (25 / ENNReal.ofReal a) * ν univ := by + apply le_trans (measure_mono ?_) (weak_bound ha) + intro x hx + change ENNReal.ofReal a < ⨆ (q : ℚ) (_ : 0 < q), ν (ball x q) / volume (ball x q) at hx + obtain ⟨q,hh⟩ := lt_iSup_iff.mp hx + obtain ⟨hq,hh⟩ := lt_iSup_iff.mp hh + have hq' : (0:ℝ) < q := by exact_mod_cast hq + refine ⟨q,hq',?_⟩ + have hv0 : volume (ball x (q:ℝ)) ≠ 0 := by + rw [volume_disk_real _ hq'.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hq'))) + exact ((ENNReal.lt_div_iff_mul_lt (Or.inl hv0) (Or.inl measure_ball_lt_top.ne)).mp hh).le + +lemma disk_average_le_rationalMaximal (ν : Measure ℂ) (x : ℂ) {r : ℝ} (hr : 0 < r) : + ν (ball x r) / volume (ball x r) ≤ 4*rationalMaximal ν x := by + obtain ⟨q,hqr,hrq⟩ := exists_rat_btwn (show r < 2*r by linarith) + have hq : (0 : ℝ) < q := hr.trans hqr + have hqRat : (0:ℚ) < q := by exact_mod_cast hq + have hd : volume (ball x (q:ℝ)) ≤ 4*volume (ball x r) := by + rw [volume_disk_real _ hq.le,volume_disk_real _ hr.le, + ← show ENNReal.ofReal (4:ℝ) = 4 by norm_num,← ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 4)] + apply ENNReal.ofReal_le_ofReal + have hs : (q:ℝ)^2 ≤ 4*r^2 := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left hs Real.pi_nonneg] + have hv0 : volume (ball x r) ≠ 0 := by + rw [volume_disk_real _ hr.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hr))) + have hvq0 : volume (ball x (q:ℝ)) ≠ 0 := by + rw [volume_disk_real _ hq.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hq))) + have hav : ν (ball x (q:ℝ)) / volume (ball x (q:ℝ)) ≤ rationalMaximal ν x := + le_iSup_of_le q (le_iSup_of_le hqRat le_rfl) + have hnum : ν (ball x r) ≤ rationalMaximal ν x * (4*volume (ball x r)) := by + calc + _ ≤ ν (ball x (q:ℝ)) := measure_mono (ball_subset_ball hqr.le) + _ ≤ rationalMaximal ν x * volume (ball x (q:ℝ)) := + (ENNReal.div_le_iff hvq0 measure_ball_lt_top.ne).mp hav + _ ≤ _ := by gcongr + apply (ENNReal.div_le_iff hv0 measure_ball_lt_top.ne).mpr + convert hnum using 1 + ring + +/-- Truncating an input below half the testing height sharpens weak type by +charging only its large values. This is the interpolation mechanism. -/ +lemma weak_split {ν η : Measure ℂ} [IsFiniteMeasure η] {a : ℝ} (ha : 0 < a) + (hsplit : ∀ x r, 0 < r → ν (ball x r) ≤ η (ball x r)+ + ENNReal.ofReal (a/2)*volume (ball x r)) : + volume {x | ENNReal.ofReal a < rationalMaximal ν x} ≤ + (25 / ENNReal.ofReal (a/2)) * η univ := by + apply le_trans (measure_mono ?_) (weak_bound (by linarith : 0 < a/2)) + intro x hx + change ENNReal.ofReal a < ⨆ (q : ℚ) (_ : 0 < q), ν (ball x q) / volume (ball x q) at hx + obtain ⟨q,hh⟩ := lt_iSup_iff.mp hx + obtain ⟨hq,hh⟩ := lt_iSup_iff.mp hh + have hq' : (0:ℝ) < q := by exact_mod_cast hq + have hv0 : volume (ball x (q:ℝ)) ≠ 0 := by + rw [volume_disk_real _ hq'.le] + exact ne_of_gt (ENNReal.ofReal_pos.mpr (mul_pos Real.pi_pos (sq_pos_of_pos hq'))) + have hh' := (ENNReal.lt_div_iff_mul_lt (Or.inl hv0) (Or.inl measure_ball_lt_top.ne)).mp hh + refine ⟨q,hq',?_⟩ + by_contra h + have hη : η (ball x (q:ℝ)) ≤ ENNReal.ofReal (a/2)*volume (ball x (q:ℝ)) := (lt_of_not_ge h).le + have hfull := (hsplit x q hq').trans (add_le_add hη le_rfl) + have hsum : ENNReal.ofReal (a/2)+ENNReal.ofReal (a/2) = ENNReal.ofReal a := by + rw [← ENNReal.ofReal_add (by linarith : 0 ≤ a/2) (by linarith : 0 ≤ a/2)] + congr 1 + ring + rw [← add_mul,hsum] at hfull + exact (not_lt_of_ge hfull) hh' + +lemma weak_truncated {f : ℂ → ℝ≥0∞} (hf : Measurable f) + [IsFiniteMeasure (volume.withDensity f)] {a : ℝ} (ha : 0 < a) : + volume {x | ENNReal.ofReal a < rationalMaximal (volume.withDensity f) x} ≤ + (25 / ENNReal.ofReal (a/2)) * + ∫⁻ x, {x | ENNReal.ofReal (a/2) < f x}.indicator f x := by + let H := {x | ENNReal.ofReal (a/2) < f x} + let η := volume.withDensity (H.indicator f) + have hle : η ≤ volume.withDensity f := withDensity_mono (ae_of_all _ (indicator_le_self _ _)) + have : IsFiniteMeasure η := isFiniteMeasure_of_le _ hle + have hweak := weak_split (ν := volume.withDensity f) (η := η) ha ?_ + · simpa only [η,withDensity_apply _ MeasurableSet.univ,setLIntegral_univ] using hweak + · intro x r _ + rw [withDensity_apply _ measurableSet_ball,show η = volume.withDensity (H.indicator f) from rfl, + withDensity_apply _ measurableSet_ball] + calc + _ ≤ ∫⁻ y in ball x r, H.indicator f y+ENNReal.ofReal (a/2) := by + apply lintegral_mono + intro y + dsimp only + by_cases hy : y ∈ H + · rw [indicator_of_mem hy] + exact le_add_right le_rfl + · rw [indicator_of_notMem hy,zero_add] + exact le_of_not_gt hy + _ = _ := by + rw [lintegral_add_left (hf.indicator (measurableSet_lt measurable_const hf))] + simp only [lintegral_const,Measure.restrict_apply_univ] + rfl + +end DiskMaximalTools + +open MeasureTheory Set +open scoped ENNReal NNReal + +namespace DiskMaximalTools + +lemma lintegral_rpow_Ioo {b s : ℝ} (hb : 0 ≤ b) (hs : -1 < s) : + (∫⁻ t in Ioo 0 b, ENNReal.ofReal (t^s)) = ENNReal.ofReal (b^(s+1)/(s+1)) := by + rcases eq_or_lt_of_le hb with rfl | hb + · simp [Real.zero_rpow (by linarith : s+1 ≠ 0)] + · have hi : IntegrableOn (fun t : ℝ => t^s) (Ioo 0 b) := + (intervalIntegral.integrableOn_Ioo_rpow_iff hb).mpr hs + rw [← ofReal_integral_eq_lintegral_ofReal hi] + · rw [← integral_Ioc_eq_integral_Ioo,← intervalIntegral.integral_of_le hb.le, + integral_rpow (Or.inl hs)] + simp [Real.zero_rpow (by linarith : s+1 ≠ 0)] + · filter_upwards [self_mem_ae_restrict measurableSet_Ioo] with t ht + exact Real.rpow_nonneg ht.1.le _ + +lemma truncation_layer_single {b p : ℝ} (hb : 0 ≤ b) (hp : 1 < p) : + (∫⁻ t in Ioi 0, (if t < 2*b then ENNReal.ofReal b else 0)*ENNReal.ofReal (t^(p-2))) = + ENNReal.ofReal (2^(p-1)/(p-1))*ENNReal.ofReal (b^p) := by + have heq : (fun t : ℝ => (if t < 2*b then ENNReal.ofReal b else 0)*ENNReal.ofReal (t^(p-2))) = + (Iio (2*b)).indicator (fun t => ENNReal.ofReal b * ENNReal.ofReal (t^(p-2))) := by + funext t + by_cases ht : t < 2*b <;> simp [ht] + rw [heq,lintegral_indicator measurableSet_Iio,Measure.restrict_restrict measurableSet_Iio] + have hi : Iio (2*b) ∩ Ioi (0:ℝ) = Ioo 0 (2*b) := by ext t; simp [and_comm] + rw [hi,lintegral_const_mul'' _ (by fun_prop)] + rw [lintegral_rpow_Ioo (by positivity : 0 ≤ 2*b) (by linarith : -1 < p-2)] + have hpp : p-2+1 = p-1 := by ring + rw [hpp] + have h2 : 0 ≤ (2:ℝ)^(p-1)/(p-1) := div_nonneg (Real.rpow_nonneg (by norm_num) _) (by linarith) + rw [← ENNReal.ofReal_mul hb,← ENNReal.ofReal_mul h2] + congr 1 + rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 2) hb] + have hp0 : 0 < p-1 := by linarith + have hpow : b*b^(p-1) = b^p := by + rcases eq_or_lt_of_le hb with rfl | hb + · simp [Real.zero_rpow hp0.ne',Real.zero_rpow (by linarith : p ≠ 0)] + · calc + b*b^(p-1) = b^(1:ℝ)*b^(p-1) := by rw [Real.rpow_one] + _ = b^(1+(p-1)) := (Real.rpow_add hb _ _).symm + _ = b^p := by congr 1; ring + calc + b * (2^(p-1)*b^(p-1)/(p-1)) = (2^(p-1)/(p-1))*(b*b^(p-1)) := by ring + _ = _ := by rw [hpow] + +/-- Exact Tonelli computation behind strong maximal interpolation, for every +p > 1. The singularity at testing height zero is actually integrated. -/ +theorem truncation_layer_integral {α : Type*} [MeasurableSpace α] {μ : Measure α} + [SFinite μ] {f : α → ℝ} (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) {p : ℝ} (hp : 1 < p) : + (∫⁻ t in Ioi 0, + (∫⁻ x, if t < 2*f x then ENNReal.ofReal (f x) else 0 ∂μ)*ENNReal.ofReal (t^(p-2))) = + ENNReal.ofReal (2^(p-1)/(p-1))*(∫⁻ x, ENNReal.ofReal ((f x)^p) ∂μ) := by + have hm : Measurable (fun z : ℝ × α => + (if z.1 < 2*f z.2 then ENNReal.ofReal (f z.2) else 0)*ENNReal.ofReal (z.1^(p-2))) := by + apply Measurable.mul + · exact ((hf.comp measurable_snd).ennreal_ofReal).ite + (measurableSet_lt measurable_fst ((hf.comp measurable_snd).const_mul 2)) measurable_const + · exact (measurable_fst.pow_const _).ennreal_ofReal + calc + _ = ∫⁻ t in Ioi 0, ∫⁻ x, + (if t < 2*f x then ENNReal.ofReal (f x) else 0)*ENNReal.ofReal (t^(p-2)) ∂μ := by + apply lintegral_congr + intro t + rw [lintegral_mul_const' _ _ ENNReal.ofReal_ne_top] + _ = ∫⁻ x, (∫⁻ t in Ioi 0, + (if t < 2*f x then ENNReal.ofReal (f x) else 0)*ENNReal.ofReal (t^(p-2))) ∂μ := + lintegral_lintegral_swap hm.aemeasurable + _ = ∫⁻ x, ENNReal.ofReal (2^(p-1)/(p-1))*ENNReal.ofReal ((f x)^p) ∂μ := by + apply lintegral_congr + intro x + exact truncation_layer_single (hf0 x) hp + _ = _ := lintegral_const_mul'' _ ((hf.pow_const _).ennreal_ofReal.aemeasurable) + +end DiskMaximalTools + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DyadicHats1.lean b/lean/OAI/Analysis/SignedDisk/DyadicHats1.lean new file mode 100644 index 0000000000000000000000000000000000000000..47a69aba1652ab932703aba66f9334a7fa5e2a3c --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DyadicHats1.lean @@ -0,0 +1,445 @@ +import OAI.Analysis.SignedDisk.LabelSwitches1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology + +noncomputable section + +namespace SignedDisk + +namespace DyadicHats + +def point (r : ℝ) (p : ℤ × ℤ) : ℂ := ⟨r*p.1,r*p.2⟩ +def boxNorm (x : ℂ) : ℝ := max |x.re| |x.im| + +lemma boxNorm_nonneg (x : ℂ) : 0 ≤ boxNorm x := le_trans (abs_nonneg _) (le_max_left _ _) +lemma boxNorm_le_norm (x : ℂ) : boxNorm x ≤ ‖x‖ := + max_le (Complex.abs_re_le_norm _) (Complex.abs_im_le_norm _) +lemma norm_le_two_boxNorm (x : ℂ) : ‖x‖ ≤ 2*boxNorm x := by + have h := Complex.norm_le_abs_re_add_abs_im x + have hr : |x.re| ≤ boxNorm x := le_max_left _ _ + have hi : |x.im| ≤ boxNorm x := le_max_right _ _ + linarith +lemma boxNorm_add_le (x y : ℂ) : boxNorm (x+y) ≤ boxNorm x+boxNorm y := by + apply max_le + · exact (abs_add_le _ _).trans (add_le_add (le_max_left _ _) (le_max_left _ _)) + · exact (abs_add_le _ _).trans (add_le_add (le_max_right _ _) (le_max_right _ _)) +lemma boxNorm_neg (x : ℂ) : boxNorm (-x) = boxNorm x := by simp [boxNorm] +lemma boxNorm_sub_comm (x y : ℂ) : boxNorm (x-y) = boxNorm (y-x) := by + rw [← neg_sub y x,boxNorm_neg] + +lemma hat_pos_iff {r : ℝ} (hr : 0 < r) (p : ℤ × ℤ) (x : ℂ) : + 0 < hat r p x ↔ boxNorm (x-point r p) < r := by + have hp : 0 < hat r p x ↔ 0 < tent (x.re/r-p.1) ∧ 0 < tent (x.im/r-p.2) := by + constructor + · intro h + exact ⟨pos_of_mul_pos_left h (tent_nonneg _),pos_of_mul_pos_right h (tent_nonneg _)⟩ + · intro h + exact mul_pos h.1 h.2 + rw [hp,tent_pos_iff,tent_pos_iff] + have hr0 : r ≠ 0 := ne_of_gt hr + have h1 : x.re/r-p.1 = (x.re-r*p.1)/r := by field_simp + have h2 : x.im/r-p.2 = (x.im-r*p.2)/r := by field_simp + rw [h1,h2,abs_div,abs_div,abs_of_pos hr,div_lt_one hr,div_lt_one hr] + simp only [boxNorm,Complex.sub_re,Complex.sub_im,point,max_lt_iff] + +lemma hat_ne_zero_iff {r : ℝ} (hr : 0 < r) (p : ℤ × ℤ) (x : ℂ) : + hat r p x ≠ 0 ↔ boxNorm (x-point r p) < r := by + constructor + · intro h + exact (hat_pos_iff hr p x).mp (lt_of_le_of_ne (hat_nonneg r p x) (Ne.symm h)) + · intro h + exact ne_of_gt ((hat_pos_iff hr p x).mpr h) + +lemma support_hat_subset {r : ℝ} (hr : 0 < r) (p : ℤ × ℤ) : + Function.support (hat r p) ⊆ Metric.closedBall (point r p) (2*r) := by + intro x hx + rw [Metric.mem_closedBall,dist_eq_norm] + exact (norm_le_two_boxNorm _).trans (mul_le_mul_of_nonneg_left ((hat_ne_zero_iff hr p x).mp hx).le (by norm_num)) + +lemma hasCompactSupport_hat {r : ℝ} (hr : 0 < r) (p : ℤ × ℤ) : + HasCompactSupport (hat r p) := by + apply IsCompact.of_isClosed_subset (isCompact_closedBall (point r p) (2*r)) isClosed_closure + exact closure_minimal (support_hat_subset hr p) Metric.isClosed_closedBall + +/-- Globally uniform spatial Lipschitz bound for the literal bilinear hats. -/ +lemma lipschitz_hat {r : ℝ} (hr : 0 < r) (p : ℤ × ℤ) : + LipschitzWith (Real.toNNReal (2/r)) (hat r p) := by + rw [lipschitzWith_iff_dist_le_mul] + intro x y + let a := tent (x.re/r-p.1) + let b := tent (x.im/r-p.2) + let c := tent (y.re/r-p.1) + let d := tent (y.im/r-p.2) + have h1 : |a-c| ≤ ‖x-y‖/r := by + have h := lipschitz_tent.dist_le_mul (x.re/r-p.1) (y.re/r-p.1) + simp only [Real.dist_eq,NNReal.coe_one,one_mul,sub_sub_sub_cancel_right,← sub_div, + abs_div,abs_of_pos hr] at h + exact h.trans (div_le_div_of_nonneg_right (Complex.abs_re_le_norm (x-y)) hr.le) + have h2 : |b-d| ≤ ‖x-y‖/r := by + have h := lipschitz_tent.dist_le_mul (x.im/r-p.2) (y.im/r-p.2) + simp only [Real.dist_eq,NNReal.coe_one,one_mul,sub_sub_sub_cancel_right,← sub_div, + abs_div,abs_of_pos hr] at h + exact h.trans (div_le_div_of_nonneg_right (Complex.abs_im_le_norm (x-y)) hr.le) + have hab : |a*b-c*d| ≤ |a-c|+|b-d| := by + calc + _ = |(a-c)*b+c*(b-d)| := by congr 1; ring + _ ≤ |(a-c)*b|+|c*(b-d)| := abs_add_le _ _ + _ = |a-c| *b+c*|b-d| := by rw [abs_mul,abs_mul,abs_of_nonneg (tent_nonneg _),abs_of_nonneg (tent_nonneg _)] + _ ≤ |a-c| *1+1*|b-d| := add_le_add + (mul_le_mul_of_nonneg_left (tent_le_one _) (abs_nonneg _)) + (mul_le_mul_of_nonneg_right (tent_le_one _) (abs_nonneg _)) + _ = _ := by ring + change |a*b-c*d| ≤ _ + rw [Real.coe_toNNReal (2/r) (by positivity),dist_eq_norm] + calc + _ ≤ ‖x-y‖/r+‖x-y‖/r := hab.trans (add_le_add h1 h2) + _ = _ := by ring + +lemma step_locality {p q : ℤ × ℤ} (hpq : 0 < step p q) {r : ℝ} (hr : 0 < r) : + boxNorm (point (r/2) q-point r p) ≤ r/2 := by + have h1 : |(q.1:ℝ)/2-p.1| < 1 := (tent_pos_iff _).mp + (pos_of_mul_pos_left hpq (tent_nonneg _)) + have h2 : |(q.2:ℝ)/2-p.2| < 1 := (tent_pos_iff _).mp + (pos_of_mul_pos_right hpq (tent_nonneg _)) + have hbound (j k : ℤ) (h : |(j:ℝ)/2-k| < 1) : |(j:ℝ)/2-k| ≤ 1/2 := by + have habs := abs_lt.mp h + have hlow : 2*k-1 ≤ j := by + have : (2*k-2:ℝ) < j := by linarith + have : 2*k-2 < j := by exact_mod_cast this + omega + have hhigh : j ≤ 2*k+1 := by + have : (j:ℝ) < 2*k+2 := by linarith + have : j < 2*k+2 := by exact_mod_cast this + omega + have hlo : (2:ℝ)*k-1 ≤ j := by exact_mod_cast hlow + have hhi : (j:ℝ) ≤ 2*k+1 := by exact_mod_cast hhigh + rw [abs_le] + constructor <;> linarith + have h1' := hbound q.1 p.1 h1 + have h2' := hbound q.2 p.2 h2 + change max |r/2*q.1-r*p.1| |r/2*q.2-r*p.2| ≤ r/2 + have hm (j k : ℤ) (h : |(j:ℝ)/2-k| ≤ 1/2) : |r/2*j-r*k| ≤ r/2 := by + rw [show r/2*j-r*k = r*((j:ℝ)/2-k) by ring,abs_mul,abs_of_pos hr] + nlinarith + exact max_le (hm _ _ h1') (hm _ _ h2') + +open scoped BigOperators + +/-- Literal nine-child support of an adjacent dyadic refinement row. -/ +def children (p : ℤ × ℤ) : Finset (ℤ × ℤ) := + (Finset.Icc (2*p.1-1) (2*p.1+1)).product (Finset.Icc (2*p.2-1) (2*p.2+1)) + +lemma tent_half_zero {j k : ℤ} (h : j ∉ Finset.Icc (2*k-1) (2*k+1)) : + tent ((j:ℝ)/2-k) = 0 := by + have ht : j-2*k ∉ Finset.Icc (-1) 1 := by + simp only [Finset.mem_Icc] at * + omega + convert tent_half_integer ht using 1 + push_cast + congr 1 + ring + +lemma step_zero_of_not_child {p q : ℤ × ℤ} (hq : q ∉ children p) : step p q = 0 := by + have hq' : ¬(q.1 ∈ Finset.Icc (2*p.1-1) (2*p.1+1) ∧ q.2 ∈ Finset.Icc (2*p.2-1) (2*p.2+1)) := by + exact fun hn => hq (Finset.mem_product.mpr hn) + rw [not_and_or] at hq' + rcases hq' with hq | hq + · rw [step,tent_half_zero hq,zero_mul] + · rw [step,tent_half_zero hq,mul_zero] + +lemma hat_refine_finite (r : ℝ) (p : ℤ × ℤ) (x : ℂ) : + hat (2*r) p x = ∑ q ∈ children p, step p q*hat r q x := by + rw [hat_refine,tsum_eq_sum (s := children p)] + intro q hq + rw [step_zero_of_not_child hq,zero_mul] + +/-- The vector mass of the actual density, not an abstract additive tree. -/ +def vectorMass (h : ℂ → ℂ) (r : ℝ) (p : ℤ × ℤ) : ℂ := ∫ y, hat r p y • h y + +def scalarMass (h : ℂ → ℂ) (r : ℝ) (p : ℤ × ℤ) : ℝ := ‖vectorMass h r p‖ + +lemma integrable_hat_smul {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) (p : ℤ × ℤ) : + Integrable (fun y => hat r p y • h y) := by + apply hh.bdd_smul 1 (continuous_hat r p).aestronglyMeasurable + filter_upwards with y + simpa only [Real.norm_eq_abs,abs_of_nonneg (hat_nonneg r p y)] using hat_le_one r p y + +lemma vectorMass_refine {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) (p : ℤ × ℤ) : + vectorMass h (2*r) p = ∑ q ∈ children p, step p q • vectorMass h r q := by + unfold vectorMass + simp_rw [hat_refine_finite,Finset.sum_smul,mul_smul] + rw [integral_finsetSum] + · apply Finset.sum_congr rfl + intro q hq + exact integral_smul _ _ + · intro q hq + exact (integrable_hat_smul hh r q).smul _ + +lemma scalarMass_le_integral {h : ℂ → ℂ} (r : ℝ) (p : ℤ × ℤ) : + scalarMass h r p ≤ ∫ y, hat r p y * ‖h y‖ := by + unfold scalarMass vectorMass + simpa only [norm_smul,Real.norm_eq_abs,abs_of_nonneg (hat_nonneg _ _ _)] using + norm_integral_le_integral_norm (fun y => hat r p y • h y) + +/-- Any finite set of roots carries at most the total L1 density, uniformly +in the scale. This proves the full-grid mass budget once finite support is used. -/ +lemma sum_scalarMass_le {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) (S : Finset (ℤ × ℤ)) : + ∑ p ∈ S, scalarMass h r p ≤ ∫ y, ‖h y‖ := by + have hi (p : ℤ × ℤ) : Integrable (fun y => hat r p y * ‖h y‖) := by + simpa only [norm_smul,Real.norm_eq_abs,abs_of_nonneg (hat_nonneg _ _ _)] using + (integrable_hat_smul hh r p).norm + calc + _ ≤ ∑ p ∈ S, ∫ y, hat r p y * ‖h y‖ := Finset.sum_le_sum (fun p _ => scalarMass_le_integral r p) + _ = ∫ y, ∑ p ∈ S, hat r p y * ‖h y‖ := (integral_finsetSum _ (fun p _ => hi p)).symm + _ ≤ ∫ y, ‖h y‖ := by + apply integral_mono (integrable_finsetSum _ (fun p _ => hi p)) hh.norm + intro y + change (∑ p ∈ S, hat r p y * ‖h y‖) ≤ ‖h y‖ + rw [← Finset.sum_mul] + have hs := Summable.sum_le_tsum S (fun p _ => hat_nonneg r p y) (summable_hat r y) + rw [tsum_hat] at hs + simpa only [one_mul] using mul_le_mul_of_nonneg_right hs (norm_nonneg (h y)) + +lemma scalarMass_refine_le {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) (p : ℤ × ℤ) : + scalarMass h (2*r) p ≤ ∑ q ∈ children p, step p q*scalarMass h r q := by + unfold scalarMass + rw [vectorMass_refine hh] + simpa only [norm_smul,Real.norm_eq_abs,abs_of_nonneg (step_nonneg _ _)] using + norm_sum_le (children p) (fun q => step p q • vectorMass h r q) + +/-- A finite index set that contains every hat meeting a fixed bounded region. -/ +def boundedIndices (r R : ℝ) : Finset (ℤ × ℤ) := + (Finset.Icc (-⌈R/r+1⌉) ⌈R/r+1⌉).product (Finset.Icc (-⌈R/r+1⌉) ⌈R/r+1⌉) + +lemma mem_boundedIndices {r R : ℝ} (hr : 0 < r) {x : ℂ} (hx : ‖x‖ ≤ R) + {p : ℤ × ℤ} (hp : hat r p x ≠ 0) : p ∈ boundedIndices r R := by + have hpos : 0 < hat r p x := lt_of_le_of_ne (hat_nonneg r p x) (Ne.symm hp) + have h1 := (tent_pos_iff _).mp (pos_of_mul_pos_left hpos (tent_nonneg _)) + have h2 := (tent_pos_iff _).mp (pos_of_mul_pos_right hpos (tent_nonneg _)) + have hbound (a : ℝ) (j : ℤ) (ha : |a| ≤ R) (hj : |a/r-j| < 1) : + j ∈ Finset.Icc (-⌈R/r+1⌉) ⌈R/r+1⌉ := by + have hq : |a/r| ≤ R/r := by rw [abs_div,abs_of_pos hr]; exact div_le_div_of_nonneg_right ha hr.le + have hja : |(j:ℝ)| ≤ R/r+1 := by + calc + _ = |a/r-(a/r-j)| := by congr 1; ring + _ ≤ |a/r|+|a/r-j| := abs_sub _ _ + _ ≤ R/r+1 := add_le_add hq hj.le + have hlo := (abs_le.mp hja).1 + have hhi := (abs_le.mp hja).2 + have hc := Int.le_ceil (R/r+1) + simp only [Finset.mem_Icc] + constructor + · have : (-(⌈R/r+1⌉:ℝ)) ≤ j := by linarith + exact_mod_cast this + · have : (j:ℝ) ≤ ⌈R/r+1⌉ := hhi.trans hc + exact_mod_cast this + exact Finset.mem_product.mpr ⟨hbound x.re p.1 ((Complex.abs_re_le_norm x).trans hx) h1, + hbound x.im p.2 ((Complex.abs_im_le_norm x).trans hx) h2⟩ + +lemma vectorMass_zero_of_not_index {h : ℂ → ℂ} {r R : ℝ} (hr : 0 < r) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) {p : ℤ × ℤ} (hp : p ∉ boundedIndices r R) : + vectorMass h r p = 0 := by + apply integral_eq_zero_of_ae + filter_upwards with y + by_cases hy : h y = 0 + · simp only [hy,smul_zero,Pi.zero_apply] + · have hh : hat r p y = 0 := by + by_contra hn + exact hp (mem_boundedIndices hr (hs y hy) hn) + simp only [hh,zero_smul,Pi.zero_apply] + +/-- Compactly supported actual densities have finitely many nonzero vector +masses at each positive scale. -/ +lemma finite_vectorMass_support {h : ℂ → ℂ} (hc : HasCompactSupport h) {r : ℝ} (hr : 0 < r) : + (Function.support (vectorMass h r)).Finite := by + obtain ⟨R,hR⟩ := hc.isBounded.subset_closedBall (0:ℂ) + apply (boundedIndices r R).finite_toSet.subset + intro p hp + by_contra hn + exact hp (vectorMass_zero_of_not_index hr (fun y hy => by + simpa only [Metric.mem_closedBall,dist_zero_right] using hR (subset_tsupport h hy)) hn) + +end DyadicHats + +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff + +namespace LipschitzWith +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + {μ : Measure E} [IsAddHaarMeasure μ] {f g : E → ℝ} {L K : ℝ≥0} + +/-- Genuine integration by parts for Lipschitz weights and compact Lipschitz +potentials. Differentiability is required only almost everywhere, and follows +from Rademacher rather than being a new premise. -/ +theorem integral_fderiv_mul_eq_neg (hf : LipschitzWith L f) (hg : LipschitzWith K g) + (hgc : HasCompactSupport g) (v : E) : + (∫ x, fderiv ℝ f x v * g x ∂μ) = -∫ x, fderiv ℝ g x v * f x ∂μ := by + have h1 : (fun x => fderiv ℝ f x v*g x) =ᵐ[μ] fun x => lineDeriv ℝ f x v*g x := by + filter_upwards [hf.ae_differentiableAt (μ := μ)] with x hx + rw [hx.lineDeriv_eq_fderiv] + have h2 : (fun x => lineDeriv ℝ g x (-v)*f x) =ᵐ[μ] fun x => -(fderiv ℝ g x v*f x) := by + filter_upwards [hg.ae_differentiableAt (μ := μ)] with x hx + rw [hx.lineDeriv_eq_fderiv,map_neg,neg_mul] + rw [integral_congr_ae h1,hf.integral_lineDeriv_mul_eq hg hgc v,integral_congr_ae h2,integral_neg] + +/-- The total gradient version obtained from Riesz and measurable fderiv is +locally integrable, including on the nondifferentiability set. -/ +theorem locallyIntegrable_gradient (hf : LipschitzWith L f) : + LocallyIntegrable (gradient f) μ := by + have hm : AEStronglyMeasurable (gradient f) μ := + ((InnerProductSpace.toDual ℝ E).symm.continuous.measurable.comp + (measurable_fderiv ℝ f)).aestronglyMeasurable + have hb : ∀ x, ‖gradient f x‖ ≤ (L:ℝ) := by + intro x + simpa only [gradient,(InnerProductSpace.toDual ℝ E).symm.norm_map] using + (norm_fderiv_le_of_lipschitz ℝ hf : ‖fderiv ℝ f x‖ ≤ (L:ℝ)) + exact (memLp_top_of_bound hm (L:ℝ) (ae_of_all _ hb)).locallyIntegrable le_top + +theorem integrable_gradient (hf : LipschitzWith L f) (hc : HasCompactSupport f) : + Integrable (gradient f) μ := by + have hs : HasCompactSupport (gradient f) := + (hc.fderiv ℝ).comp_left (map_zero (InnerProductSpace.toDual ℝ E).symm) + exact (integrableOn_iff_integrable_of_support_subset (subset_tsupport (gradient f))).mp + ((SignedDisk.LipschitzWith.locallyIntegrable_gradient hf).integrableOn_isCompact hs) + +theorem integral_mul_fderiv_eq_neg (hf : LipschitzWith L f) (hg : LipschitzWith K g) + (hgc : HasCompactSupport g) (v : E) : + (∫ x, f x * fderiv ℝ g x v ∂μ) = -∫ x, inner ℝ (gradient f x) v * g x ∂μ := by + simp only [gradient,InnerProductSpace.toDual_symm_apply] + have h := SignedDisk.LipschitzWith.integral_fderiv_mul_eq_neg (μ := μ) hf hg hgc v + rw [show (fun x => f x * fderiv ℝ g x v) = (fun x => fderiv ℝ g x v * f x) by + funext x; exact mul_comm _ _] + linarith + +end LipschitzWith + +open MeasureTheory Set Metric Filter Finset +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology + +namespace DyadicHats + +def indexBox (N : ℕ) : Finset (ℤ × ℤ) := + (Finset.Icc (-(N:ℤ)) N).product (Finset.Icc (-(N:ℤ)) N) +abbrev Grid (N : ℕ) := {p : ℤ × ℤ // p ∈ indexBox N} + +lemma parent_in_box {N : ℕ} {p q : ℤ × ℤ} (hq : q ∈ indexBox N) (hpq : step p q ≠ 0) : + p ∈ indexBox N := by + have hq1 : -(N:ℤ) ≤ q.1 ∧ q.1 ≤ N := Finset.mem_Icc.mp (Finset.mem_product.mp hq).1 + have hq2 : -(N:ℤ) ≤ q.2 ∧ q.2 ≤ N := Finset.mem_Icc.mp (Finset.mem_product.mp hq).2 + have hh : 0 < step p q := lt_of_le_of_ne (step_nonneg p q) (Ne.symm hpq) + have h1 := (tent_pos_iff _).mp (pos_of_mul_pos_left hh (tent_nonneg _)) + have h2 := (tent_pos_iff _).mp (pos_of_mul_pos_right hh (tent_nonneg _)) + have hbound (j k : ℤ) (hk : -(N:ℤ) ≤ k ∧ k ≤ N) (ha : |(k:ℝ)/2-j| < 1) : + j ∈ Finset.Icc (-(N:ℤ)) N := by + have hlo : -(N:ℝ) ≤ k := by exact_mod_cast hk.1 + have hhi : (k:ℝ) ≤ N := by exact_mod_cast hk.2 + have hj := abs_lt.mp ha + simp only [Finset.mem_Icc] + constructor + · by_contra hn + have : j ≤ -(N:ℤ)-1 := by omega + have : (j:ℝ) ≤ -(N:ℝ)-1 := by exact_mod_cast this + nlinarith [Nat.cast_nonneg (α := ℝ) N] + · by_contra hn + have : (N:ℤ)+1 ≤ j := by omega + have : (N:ℝ)+1 ≤ j := by exact_mod_cast this + nlinarith [Nat.cast_nonneg (α := ℝ) N] + exact Finset.mem_product.mpr ⟨hbound _ _ hq1 h1,hbound _ _ hq2 h2⟩ + +/-- Restriction to a finite box retains the exact column normalization of the +positive dyadic refinement matrix; it does not normalize its rows. -/ +lemma grid_step_column (N : ℕ) (q : Grid N) : (∑ p : Grid N, step p q) = 1 := by + have he := step_column q.val + rw [tsum_eq_sum (s := indexBox N)] at he + · exact (Finset.sum_coe_sort (indexBox N) (fun p => step p q)).trans he + · intro p hp + by_contra hn + exact hp (parent_in_box q.property hn) + +lemma mem_indexBox_of_le {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {x : ℂ} (hx : ‖x‖ ≤ R) {p : ℤ × ℤ} (hp : hat r p x ≠ 0) : + p ∈ indexBox N := by + have hm := mem_boundedIndices hr hx hp + have hc : ⌈R/r+1⌉ ≤ (N:ℤ) := Int.ceil_le.mpr (by simpa only [Int.cast_natCast] using hN) + have h1 := Finset.mem_Icc.mp (Finset.mem_product.mp hm).1 + have h2 := Finset.mem_Icc.mp (Finset.mem_product.mp hm).2 + apply Finset.mem_product.mpr + constructor <;> apply Finset.mem_Icc.mpr <;> constructor <;> omega + +lemma hat_mul_zero_outside {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + {p : ℤ × ℤ} (hp : p ∉ indexBox N) (x : ℂ) : hat r p x*h x = 0 := by + by_cases hx : h x = 0 + · rw [hx,mul_zero] + · have ht : hat r p x = 0 := by + by_contra hn + exact hp (mem_indexBox_of_le hr hN (hs x hx) hn) + rw [ht,zero_mul] + +lemma density_partition_grid {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (x : ℂ) : + (∑ p : Grid N, hat r p x*h x) = h x := by + have he : (∑' p : ℤ × ℤ, hat r p x*h x) = ∑ p ∈ indexBox N, hat r p x*h x := + tsum_eq_sum (fun p hp => hat_mul_zero_outside hr hN hs hp x) + rw [Finset.sum_coe_sort (indexBox N) (fun p => hat r p x*h x),← he, + tsum_mul_right,tsum_hat,one_mul] + +lemma density_refine_grid {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + (p : Grid N) (x : ℂ) : + hat (2*r) p x*h x = ∑ q : Grid N, step p q*(hat r q x*h x) := by + rw [hat_refine,← tsum_mul_right,tsum_eq_sum (s := indexBox N)] + · rw [Finset.sum_coe_sort (indexBox N) (fun q => step p q*(hat r q x*h x))] + apply Finset.sum_congr rfl + intro q hq + ring + · intro q hq + rw [mul_assoc,hat_mul_zero_outside hr hN hs hq x,mul_zero] + +lemma integrable_hat_mul {h : ℂ → ℝ} (hh : Integrable h) (r : ℝ) (p : ℤ × ℤ) : + Integrable (fun y => hat r p y*h y) := by + exact hh.bdd_smul 1 (continuous_hat r p).aestronglyMeasurable + (ae_of_all _ (fun y => by + simpa only [Real.norm_eq_abs,abs_of_nonneg (hat_nonneg r p y)] using hat_le_one r p y)) + +def scale (r : ℝ) (k : ℕ) : ℝ := (2:ℝ)^k*r +lemma scale_pos {r : ℝ} (hr : 0 < r) (k : ℕ) : 0 < scale r k := by unfold scale; positivity +lemma scale_succ (r : ℝ) (k : ℕ) : scale r (k+1) = 2*scale r k := by + unfold scale + rw [pow_succ] + ring +lemma le_scale {r : ℝ} (hr : 0 ≤ r) (k : ℕ) : r ≤ scale r k := by + have hp : (1:ℝ) ≤ 2^k := one_le_pow₀ (by norm_num) + simpa only [one_mul,scale] using mul_le_mul_of_nonneg_right hp hr + +lemma scale_index_bound {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) (k : ℕ) : R/scale r k+1 ≤ (N:ℝ) := by + have hd : R / scale r k ≤ R / r := div_le_div_of_nonneg_left hR hr (le_scale hr.le k) + linarith + +end DyadicHats + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DyadicHats2.lean b/lean/OAI/Analysis/SignedDisk/DyadicHats2.lean new file mode 100644 index 0000000000000000000000000000000000000000..9efc54bd6b17535b058d6e0da8774dd1c229241e --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DyadicHats2.lean @@ -0,0 +1,409 @@ +import OAI.Analysis.SignedDisk.DyadicHats1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace DyadicHats + +section +open scoped BigOperators + +lemma step_support {r : ℝ} (_hr : 0 < r) {p q : ℤ × ℤ} (hw : step p q ≠ 0) : + Function.support (hat r q) ⊆ Function.support (hat (2*r) p) := by + have hq : q ∈ children p := by + by_contra hn + exact hw (step_zero_of_not_child hn) + intro x hx + have hpos : 0 < step p q*hat r q x := mul_pos + (lt_of_le_of_ne (step_nonneg p q) (Ne.symm hw)) + (lt_of_le_of_ne (hat_nonneg r q x) (Ne.symm hx)) + have hle : step p q*hat r q x ≤ hat (2*r) p x := by + rw [hat_refine_finite] + exact Finset.single_le_sum (fun s _ => mul_nonneg (step_nonneg p s) (hat_nonneg r s x)) hq + exact ne_of_gt (hpos.trans_le hle) + +variable {N : ℕ} +def weights (N : ℕ) : ℕ → Grid N → Grid N → ℝ := fun _ p q => step p q +def pieces (N : ℕ) (r : ℝ) (h : ℂ → ℝ) : Grid N → ℂ → ℝ := fun q x => hat r q x*h x + +def densityRoot (N : ℕ) (r : ℝ) (h : ℂ → ℝ) := + ScalarCancellation.roots volume (weights N) (pieces N r h) +def densityError (N : ℕ) (r : ℝ) (h : ℂ → ℝ) := + ScalarCancellation.errors volume (weights N) (pieces N r h) + +lemma pieces_integrable {h : ℂ → ℝ} (hh : Integrable h) (r : ℝ) (q : Grid N) : + Integrable (pieces N r h q) := integrable_hat_mul hh r q + +lemma refined_eq_density {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + (k : ℕ) (q : Grid N) (x : ℂ) : + ScalarCancellation.refined (weights N) (pieces N r h) k q x = hat (scale r k) q x*h x := by + induction k generalizing q with + | zero => simp only [ScalarCancellation.refined,pieces,scale,pow_zero,one_mul] + | succ k ih => + simp only [ScalarCancellation.refined,weights,ih,scale_succ] + exact (density_refine_grid (scale_pos hr k) (scale_index_bound hr hR hN k) hs q x).symm + +lemma densityRoot_integrable {h : ℂ → ℝ} (hh : Integrable h) (r : ℝ) (k : ℕ) (q : Grid N) : + Integrable (densityRoot N r h k q) := + ScalarCancellation.roots_integrable _ (pieces_integrable hh r) k q +lemma densityError_integrable {h : ℂ → ℝ} (hh : Integrable h) (r : ℝ) (k : ℕ) (q : Grid N) : + Integrable (densityError N r h k q) := + ScalarCancellation.errors_integrable _ (pieces_integrable hh r) k q +lemma densityError_zero_mass {h : ℂ → ℝ} (hh : Integrable h) (r : ℝ) (k : ℕ) (q : Grid N) : + (∫ x, densityError N r h k q x) = 0 := + ScalarCancellation.errors_zero_mass _ (pieces_integrable hh r) k q + +lemma densityRoot_mass {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + (∫ x, densityRoot N r h k q x) = ∫ x, hat (scale r k) q x*h x := by + have he := ScalarCancellation.roots_mass (weights N) (pieces_integrable hh r) k q + simpa only [densityRoot,refined_eq_density hr hR hN hs] using he + +lemma densityRoot_abs_mass {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + (∫ x, |densityRoot N r h k q x|) = |∫ x, hat (scale r k) q x*h x| := by + have he := ScalarCancellation.roots_abs_mass (weights N) (pieces_integrable hh r) k q + simpa only [densityRoot,refined_eq_density hr hR hN hs] using he + +lemma density_support {r : ℝ} (hr : 0 < r) {h : ℂ → ℝ} (hh : Integrable h) + (k : ℕ) (q : Grid N) (x : ℂ) (hx : hat (scale r k) q x = 0) : + densityRoot N r h k q x = 0 ∧ densityError N r h k q x = 0 := by + apply ScalarCancellation.roots_errors_support (weights N) (pieces_integrable hh r) + (fun k q => Function.support (hat (scale r k) q)) ?_ ?_ k q x (by simpa using hx) + · intro q y hy + have hz : hat r q y = 0 := by simpa [scale] using hy + simp only [pieces,hz,zero_mul] + · intro k p q hw + rw [scale_succ] + exact step_support (scale_pos hr k) hw + +def densityDefect (N : ℕ) (r : ℝ) (h : ℂ → ℝ) : ℕ → Grid N → ℝ + | 0,q => ((∫ x, hat r q x*|h x|)-|∫ x, hat r q x*h x|)/2 + | k+1,q => ((∑ s : Grid N, step q s*|∫ x, hat (scale r k) s x*h x|)- + |∫ x, hat (scale r (k+1)) q x*h x|)/2 + +lemma densityError_cost {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + (∫ x, |densityError N r h k q x|) ≤ 2*densityDefect N r h k q := by + cases k with + | zero => + have he := ScalarCancellation.errors_terminal_cost (weights N) (pieces_integrable hh r) q + simp only [pieces,abs_mul,abs_of_nonneg (hat_nonneg r q _)] at he + rw [densityDefect] + change (∫ x, |ScalarCancellation.errors volume (weights N) (pieces N r h) 0 q x|) ≤ _ + rw [he] + linarith + | succ k => + have he := ScalarCancellation.errors_cost (weights N) (fun _ p s => step_nonneg p s) + (pieces_integrable hh r) k q + simp only [refined_eq_density hr hR hN hs,weights] at he + change (∫ x, |ScalarCancellation.errors volume (weights N) (pieces N r h) (k+1) q x|) ≤ _ + rw [densityDefect] + linarith + +lemma densityError_total_cost {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (n : ℕ) : + (∑ k ∈ Finset.range (n+1), ∑ q : Grid N, ∫ x, |densityError N r h k q x|) ≤ ∫ x, |h x| := by + have he := ScalarCancellation.errors_total_cost_le (weights N) (fun _ p s => step_nonneg p s) + (fun _ q => grid_step_column N q) (pieces_integrable hh r) n + have hi : (∑ q : Grid N, ∫ x, |pieces N r h q x|) = ∫ x, |h x| := by + rw [← integral_finsetSum _ (fun q _ => (pieces_integrable hh r q).abs)] + apply integral_congr_ae + apply ae_of_all + intro x + simp only [pieces,abs_mul,abs_of_nonneg (hat_nonneg r _ x)] + apply density_partition_grid hr hN + intro y hy + exact hs y (fun hz => hy (by rw [hz,abs_zero])) + exact he.trans_eq hi + +end + +open Finset + +/-- Coherent refinement coefficients, evaluated by exact positive matrix +composition on the finite box. These are not row-stochastic transitions. -/ +def coeff (N : ℕ) : ℕ → Grid N → Grid N → ℝ + | 0,p,q => if p=q then 1 else 0 + | d+1,p,q => ∑ a : Grid N, step p a*coeff N d a q + +lemma coeff_nonneg (N d : ℕ) (p q : Grid N) : 0 ≤ coeff N d p q := by + induction d generalizing p with + | zero => simp only [coeff]; split_ifs <;> norm_num + | succ d ih => exact sum_nonneg fun a _ => mul_nonneg (step_nonneg p a) (ih a) + +lemma coeff_column (N d : ℕ) (q : Grid N) : (∑ p : Grid N, coeff N d p q) = 1 := by + induction d with + | zero => simp [coeff] + | succ d ih => + simp only [coeff] + rw [Finset.sum_comm] + simp_rw [← sum_mul,grid_step_column,one_mul] + exact ih + +/-- All lower-level error densities, with their actual coherent coefficients, +reconstruct the genuine coarse hat density exactly. -/ +theorem density_decomposition {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + (k : ℕ) (q : Grid N) (x : ℂ) : + hat (scale r k) q x*h x = densityRoot N r h k q x+ + ∑ j ∈ range (k+1), ∑ s : Grid N, coeff N (k-j) q s*densityError N r h j s x := by + rw [← refined_eq_density hr hR hN hs] + apply ScalarCancellation.telescoped_decomposition (weights N) (pieces N r h) + (fun k j p s => coeff N (k-j) p s) + · intro j p s + simp only [Nat.sub_self,coeff] + · intro k j p s hj + rw [show k+1-j = k-j+1 by omega,coeff] + rfl + +lemma terminal_abs_sum {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) : + (∑ q : Grid N, ∫ x, hat r q x*|h x|) = ∫ x, |h x| := by + rw [← integral_finsetSum (Finset.univ : Finset (Grid N)) (fun q _ => integrable_hat_mul hh.abs r q)] + apply integral_congr_ae + apply ae_of_all + intro x + apply density_partition_grid hr hN + intro y hy + exact hs y (fun hz => hy (by rw [hz,abs_zero])) + +lemma densityDefect_sum_succ (N : ℕ) (r : ℝ) (h : ℂ → ℝ) (k : ℕ) : + (∑ q : Grid N, densityDefect N r h (k+1) q) = + ((∑ q : Grid N, |∫ x, hat (scale r k) q x*h x|)- + (∑ q : Grid N, |∫ x, hat (scale r (k+1)) q x*h x|))/2 := by + simp only [densityDefect] + rw [← sum_div,sum_sub_distrib] + congr 2 + rw [Finset.sum_comm] + simp_rw [← sum_mul,grid_step_column,one_mul] + +/-- Exact telescoping of the literal scalar defects, including the finest +terminal split. No depth-dependent or terminal remainder is discarded. -/ +theorem densityDefect_budget_eq {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (n : ℕ) : + (∑ k ∈ range (n+1), ∑ q : Grid N, densityDefect N r h k q) = + ((∫ x, |h x|)-(∑ q : Grid N, |∫ x, hat (scale r n) q x*h x|))/2 := by + induction n with + | zero => + simp only [Nat.zero_add,range_one,sum_singleton,densityDefect, + scale,pow_zero,one_mul] + rw [← sum_div,sum_sub_distrib] + rw [terminal_abs_sum hr hN hh hs] + | succ n ih => + rw [sum_range_succ,ih,densityDefect_sum_succ] + ring + +lemma densityDefect_nonneg {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (q : Grid N) : + 0 ≤ densityDefect N r h k q := by + have he := densityError_cost hr hR hN hh hs k q + have hn : 0 ≤ ∫ x, |densityError N r h k q x| := integral_nonneg (fun x => abs_nonneg _) + linarith + +lemma densityDefect_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (n : ℕ) : + (∑ k ∈ range (n+1), ∑ q : Grid N, densityDefect N r h k q) ≤ (∫ x, |h x|)/2 := by + rw [densityDefect_budget_eq hr hN hh hs] + have he : 0 ≤ ∑ q : Grid N, |∫ x, hat (scale r n) q x*h x| := sum_nonneg fun _ _ => abs_nonneg _ + linarith + +/-- The common scalar price assigned to a root. The geometric discount is +applied at the actual birth scale of each zero-mass error. -/ +def scalarPrice (N : ℕ) (r : ℝ) (h : ℂ → ℝ) (ρ : ℝ) (k : ℕ) (q : Grid N) : ℝ := + ∑ j ∈ range (k+1), ρ^(k-j)*∑ s : Grid N, coeff N (k-j) q s*densityDefect N r h j s + +lemma scalarPrice_sum (N : ℕ) (r : ℝ) (h : ℂ → ℝ) (ρ : ℝ) (k : ℕ) : + (∑ q : Grid N, scalarPrice N r h ρ k q) = + ∑ j ∈ range (k+1), ρ^(k-j)*∑ s : Grid N, densityDefect N r h j s := by + simp only [scalarPrice] + rw [Finset.sum_comm] + apply sum_congr rfl + intro j _ + rw [← mul_sum,Finset.sum_comm] + congr 1 + simp_rw [← sum_mul,coeff_column,one_mul] + +open Finset + +lemma discount_recurrence (ρ : ℝ) (a : ℕ → ℝ) (k : ℕ) : + (∑ j ∈ range (k+2), ρ^(k+1-j)*a j) = + a (k+1)+ρ*(∑ j ∈ range (k+1), ρ^(k-j)*a j) := by + rw [sum_range_succ] + simp only [Nat.sub_self,pow_zero,one_mul,mul_sum] + rw [add_comm] + congr 1 + apply sum_congr rfl + intro j hj + rw [show k+1-j = (k-j)+1 by have := mem_range.mp hj; omega,pow_succ] + ring + +lemma triangle_discount_bound {ρ : ℝ} (hρ : 0 ≤ ρ) (hρ1 : ρ < 1) + {a : ℕ → ℝ} (ha : ∀ j, 0 ≤ a j) (n : ℕ) : + (∑ k ∈ range (n+1), ∑ j ∈ range (k+1), ρ^(k-j)*a j) ≤ + (1-ρ)⁻¹*∑ j ∈ range (n+1), a j := by + let b : ℕ → ℝ := fun k => ∑ j ∈ range (k+1), ρ^(k-j)*a j + have hb : ∀ k, 0 ≤ b k := fun k => sum_nonneg fun j _ => mul_nonneg (pow_nonneg hρ _) (ha j) + have hi : ∀ n, (1-ρ)*(∑ k ∈ range (n+1), b k) = + (∑ j ∈ range (n+1), a j)-ρ*b n := by + intro n + induction n with + | zero => simp [b]; ring + | succ n ih => + rw [sum_range_succ (f := b) (n := n+1),sum_range_succ (f := a) (n := n+1),mul_add,ih] + have he : b (n+1) = a (n+1)+ρ*b n := discount_recurrence ρ a n + rw [he] + ring + have hle : (1-ρ)*(∑ k ∈ range (n+1), b k) ≤ ∑ j ∈ range (n+1), a j := by + rw [hi] + exact sub_le_self _ (mul_nonneg hρ (hb n)) + rw [inv_mul_eq_div] + exact (le_div_iff₀ (sub_pos.mpr hρ1)).mpr (by rwa [mul_comm]) + +theorem scalarPrice_budget {N : ℕ} {r R ρ : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℝ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (hρ : 0 ≤ ρ) (hρ1 : ρ < 1) (n : ℕ) : + (∑ k ∈ range (n+1), ∑ q : Grid N, scalarPrice N r h ρ k q) ≤ + (1-ρ)⁻¹*((∫ x, |h x|)/2) := by + simp_rw [scalarPrice_sum] + apply (triangle_discount_bound hρ hρ1 + (fun j => sum_nonneg fun q _ => densityDefect_nonneg hr hR hN hh hs j q) n).trans + exact mul_le_mul_of_nonneg_left (densityDefect_budget hr hN hh hs n) + (inv_nonneg.mpr (sub_nonneg.mpr hρ1.le)) + +open Finset + +def activeIndices (r : ℝ) (x : ℂ) : Finset (ℤ × ℤ) := + ({⌊x.re/r⌋,⌊x.re/r⌋+1} : Finset ℤ).product {⌊x.im/r⌋,⌊x.im/r⌋+1} + +lemma hat_zero_of_not_active (r : ℝ) (x : ℂ) {p : ℤ × ℤ} (hp : p ∉ activeIndices r x) : + hat r p x = 0 := by + have hp' : ¬(p.1 ∈ ({⌊x.re/r⌋,⌊x.re/r⌋+1} : Finset ℤ) ∧ + p.2 ∈ ({⌊x.im/r⌋,⌊x.im/r⌋+1} : Finset ℤ)) := fun hn => hp (mem_product.mpr hn) + rw [not_and_or] at hp' + rcases hp' with h|h + · simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at h + rw [hat,tent_eq_zero_of_ne_floor h.1 h.2,zero_mul] + · simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at h + rw [hat,tent_eq_zero_of_ne_floor h.1 h.2,mul_zero] + +lemma activeIndices_card (r : ℝ) (x : ℂ) : (activeIndices r x).card ≤ 4 := by + change (({⌊x.re/r⌋,⌊x.re/r⌋+1} : Finset ℤ) ×ˢ + ({⌊x.im/r⌋,⌊x.im/r⌋+1} : Finset ℤ)).card ≤ 4 + rw [Finset.card_product] + exact (Nat.mul_le_mul (card_insert_le ..) (card_insert_le ..)).trans (by simp) + +lemma summable_weighted_hat (r : ℝ) (x : ℂ) (f : ℤ × ℤ → ℝ) : + Summable (fun p => hat r p x*f p) := by + apply summable_of_ne_finset_zero (s := activeIndices r x) + intro p hp + rw [hat_zero_of_not_active r x hp,zero_mul] + +/-- The literal locally finite tent interpolation, indexed by the whole grid. -/ +def interpolate (r : ℝ) (f : ℤ × ℤ → ℝ) (x : ℂ) : ℝ := ∑' p, hat r p x*f p + +lemma interpolate_eq_sum (r : ℝ) (f : ℤ × ℤ → ℝ) (x : ℂ) + (S : Finset (ℤ × ℤ)) (hS : activeIndices r x ⊆ S) : + interpolate r f x = ∑ p ∈ S, hat r p x*f p := by + apply tsum_eq_sum + intro p hp + rw [hat_zero_of_not_active r x (fun hn => hp (hS hn)),zero_mul] + +lemma interpolate_add (r : ℝ) (f g : ℤ × ℤ → ℝ) (x : ℂ) : + interpolate r (fun p => f p+g p) x = interpolate r f x+interpolate r g x := by + simp only [interpolate,mul_add] + exact (summable_weighted_hat r x f).tsum_add (summable_weighted_hat r x g) +lemma interpolate_sub (r : ℝ) (f g : ℤ × ℤ → ℝ) (x : ℂ) : + interpolate r (fun p => f p-g p) x = interpolate r f x-interpolate r g x := by + simp only [interpolate,mul_sub] + exact (summable_weighted_hat r x f).tsum_sub (summable_weighted_hat r x g) +lemma interpolate_mul_const (r : ℝ) (f : ℤ × ℤ → ℝ) (x : ℂ) (c : ℝ) : + interpolate r (fun p => f p*c) x = interpolate r f x*c := by + simp only [interpolate,← mul_assoc,tsum_mul_right] +lemma interpolate_const (r : ℝ) (x : ℂ) (c : ℝ) : interpolate r (fun _ => c) x = c := by + rw [interpolate,tsum_mul_right,tsum_hat,one_mul] +lemma interpolate_nonneg (r : ℝ) (x : ℂ) {f : ℤ × ℤ → ℝ} (hf : ∀ p, 0 ≤ f p) : + 0 ≤ interpolate r f x := tsum_nonneg fun p => mul_nonneg (hat_nonneg r p x) (hf p) +lemma interpolate_mono (r : ℝ) (x : ℂ) {f g : ℤ × ℤ → ℝ} (h : ∀ p, f p ≤ g p) : + interpolate r f x ≤ interpolate r g x := by + exact Summable.tsum_le_tsum (fun p => mul_le_mul_of_nonneg_left (h p) (hat_nonneg r p x)) + (summable_weighted_hat r x f) (summable_weighted_hat r x g) +lemma interpolate_le_const (r : ℝ) (x : ℂ) {f : ℤ × ℤ → ℝ} {c : ℝ} (hf : ∀ p, f p ≤ c) : + interpolate r f x ≤ c := (interpolate_mono r x hf).trans_eq (interpolate_const r x c) + +lemma interpolate_finset_sum {ι : Type*} (s : Finset ι) (r : ℝ) + (f : ι → ℤ × ℤ → ℝ) (x : ℂ) : + interpolate r (fun p => ∑ i ∈ s, f i p) x = ∑ i ∈ s, interpolate r (f i) x := by + simp only [interpolate,mul_sum] + exact Summable.tsum_finsetSum (fun i _ => summable_weighted_hat r x (f i)) + +/-- Only eight tents can contribute to a difference of two interpolated values. +This is the quantitative global Lipschitz bound with no grid cardinality loss. -/ +theorem interpolate_lipschitz {r B : ℝ} (hr : 0 < r) (hB : 0 ≤ B) + {f : ℤ × ℤ → ℝ} (hf : ∀ p, |f p| ≤ B) : + LipschitzWith (Real.toNNReal (16*B/r)) (interpolate r f) := by + rw [lipschitzWith_iff_dist_le_mul] + intro x y + let S := activeIndices r x ∪ activeIndices r y + have hcard : S.card ≤ 8 := (Finset.card_union_le (activeIndices r x) (activeIndices r y)).trans + (by have := activeIndices_card r x; have := activeIndices_card r y; omega) + have hsum : |interpolate r f x-interpolate r f y| ≤ + (S.card:ℝ)*((2/r)*‖x-y‖*B) := by + rw [interpolate_eq_sum r f x S subset_union_left,interpolate_eq_sum r f y S subset_union_right, + ← sum_sub_distrib] + calc + _ ≤ ∑ p ∈ S, |hat r p x*f p-hat r p y*f p| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ _p ∈ S, (2/r)*‖x-y‖*B := by + apply sum_le_sum + intro p _ + rw [← sub_mul,abs_mul] + have hb := (lipschitz_hat hr p).dist_le_mul x y + rw [Real.dist_eq,Real.coe_toNNReal (2/r) (by positivity),dist_eq_norm] at hb + exact mul_le_mul hb (hf p) (abs_nonneg _) (by positivity) + _ = _ := by rw [sum_const,nsmul_eq_mul] + rw [Real.dist_eq,Real.coe_toNNReal (16*B/r) (by positivity),dist_eq_norm] + have hcard' : (S.card:ℝ) ≤ 8 := by exact_mod_cast hcard + calc + _ ≤ (8:ℝ)*((2/r)*‖x-y‖*B) := hsum.trans (mul_le_mul_of_nonneg_right hcard' (by positivity)) + _ = _ := by ring + +end DyadicHats + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/DyadicHats3.lean b/lean/OAI/Analysis/SignedDisk/DyadicHats3.lean new file mode 100644 index 0000000000000000000000000000000000000000..af7e49efa55784e9d9de0360e47a6449f1135e73 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/DyadicHats3.lean @@ -0,0 +1,410 @@ +import OAI.Analysis.SignedDisk.FiniteLabels1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace DyadicHats + +lemma coeff_eq_hat {N : ℕ} {r : ℝ} (hr : 0 < r) (k : ℕ) (p q : Grid N) : + coeff N k p q = hat (scale r k) p (point r q) := by + induction k generalizing p with + | zero => + simp only [coeff,scale,pow_zero,one_mul,hat_at_point hr.ne'] + by_cases hpq : p=q + · rw [ite_eq_left hpq,ite_eq_left (congrArg Subtype.val hpq)] + · rw [ite_eq_right hpq,ite_eq_right (fun h => hpq (Subtype.ext h))] + | succ k ih => + rw [coeff,scale_succ,hat_refine,tsum_eq_sum (s := indexBox N)] + · rw [← sum_coe_sort (indexBox N) (fun j => step p j*hat (scale r k) j (point r q))] + apply sum_congr rfl + intro j hj + rw [ih] + · intro j hj + have hz : hat (scale r k) j (point r q) = 0 := by + by_contra hn + have hb := velocity_bound_on_grid hr k q + exact hj (hat_vertex_bound (scale_pos hr k) hb.1 hb.2 hn) + rw [hz,mul_zero] + +lemma hat_refine_grid_at {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {x : ℂ} (hx : ‖x‖ ≤ R) (p : Grid N) : + hat (2*r) p x = ∑ q : Grid N, step p q*hat r q x := by + rw [hat_refine,tsum_eq_sum (s := indexBox N)] + · exact (sum_coe_sort (indexBox N) (fun q => step p q*hat r q x)).symm + · intro q hq + have hz : hat r q x = 0 := by + by_contra hn + exact hq (mem_indexBox_of_le hr hN hx hn) + rw [hz,mul_zero] + +lemma vectorMass_grid_refine {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (p : Grid N) : + vectorMass h (2*r) p = ∑ q : Grid N, step p q • vectorMass h r q := by + let f := fun y => ∑ q : Grid N, step p q • (hat r q y • h y) + have hf : (fun y => hat (2*r) p y • h y) = f := by + funext y + by_cases hy : h y=0 + · simp only [f,hy,smul_zero,sum_const_zero] + · rw [hat_refine_grid_at hr hN (hs y hy) p,sum_smul] + simp only [f,smul_smul] + rw [vectorMass,hf] + dsimp only [f] + have hi (q : Grid N) : Integrable (fun y => step p q • (hat r q y • h y)) := + Integrable.smul (step p q) (integrable_hat_smul hh r q) + rw [integral_finsetSum Finset.univ (fun q _ => hi q)] + apply sum_congr rfl + intro q hq + rw [integral_smul] + rfl + +lemma vectorMass_coeff {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (k : ℕ) (p : Grid N) : + vectorMass h (scale r k) p = ∑ q : Grid N, coeff N k p q • vectorMass h r q := by + induction k generalizing p with + | zero => simp [coeff,scale] + | succ k ih => + rw [scale_succ,vectorMass_grid_refine (scale_pos hr k) (scale_index_bound hr hR hN k) hh hs] + simp only [ih,smul_sum,smul_smul,coeff,sum_smul] + exact Finset.sum_comm + +lemma sum_scalarMass_grid_le {N : ℕ} {h : ℂ → ℂ} (hh : Integrable h) (r : ℝ) : + (∑ q : Grid N, scalarMass h r q) ≤ ∫ y, ‖h y‖ := by + rw [sum_coe_sort (indexBox N) (fun q => scalarMass h r q)] + exact sum_scalarMass_le hh r (indexBox N) + +open Finset + +lemma hat_lower {r a : ℝ} (hr : 0 < r) (ha : a ≤ 1) (p : ℤ × ℤ) (x : ℂ) + (hx : boxNorm (x-point r p) ≤ a*r) : (1-a)^2 ≤ hat r p x := by + have h1 := (le_max_left |(x-point r p).re| |(x-point r p).im|).trans hx + have h2 := (le_max_right |(x-point r p).re| |(x-point r p).im|).trans hx + simp only [Complex.sub_re,Complex.sub_im,point] at h1 h2 + have hh (t : ℝ) (j : ℤ) (h : |t-r*j| ≤ a*r) : 1-a ≤ tent (t/r-j) := by + have he : t/r-j = (t-r*j)/r := by field_simp + rw [he,tent,abs_div,abs_of_pos hr] + have hd : |t-r*j|/r ≤ a := (div_le_iff₀ hr).mpr h + exact (sub_le_sub_left hd 1).trans (le_max_left _ _) + calc + (1-a)^2 = (1-a)*(1-a) := by ring + _ ≤ tent (x.re/r-p.1)*tent (x.im/r-p.2) := + mul_le_mul (hh _ _ h1) (hh _ _ h2) (sub_nonneg.mpr ha) (tent_nonneg _) + _ = _ := rfl + +def nearParent (q : ℤ × ℤ) : ℤ × ℤ := ((q.1+2048)/4096,(q.2+2048)/4096) + +lemma nearParent_int_bound (j : ℤ) : |j-4096*((j+2048)/4096)| ≤ 2048 := by + rw [abs_le] + omega + +lemma nearParent_box {r : ℝ} (hr : 0 < r) (q : ℤ × ℤ) : + boxNorm (point r q-point (4096*r) (nearParent q)) ≤ (1/2 : ℝ)*(4096*r) := by + have hh (j : ℤ) : |r*j-(4096*r)*((j+2048)/4096:ℤ)| ≤ (1/2:ℝ)*(4096*r) := by + have hi : |(j:ℝ)-4096*((j+2048)/4096:ℤ)| ≤ 2048 := by exact_mod_cast nearParent_int_bound j + have he : r*j-(4096*r)*((j+2048)/4096:ℤ) = r*((j:ℝ)-4096*((j+2048)/4096:ℤ)) := by ring + rw [he,abs_mul,abs_of_pos hr] + nlinarith + exact max_le (hh q.1) (hh q.2) + +lemma nearParent_mem {N : ℕ} {q : ℤ × ℤ} (hq : q ∈ indexBox N) : nearParent q ∈ indexBox N := by + have h1 := Finset.mem_Icc.mp (Finset.mem_product.mp hq).1 + have h2 := Finset.mem_Icc.mp (Finset.mem_product.mp hq).2 + apply Finset.mem_product.mpr + constructor <;> apply Finset.mem_Icc.mpr <;> dsimp only [nearParent] <;> constructor <;> omega + +lemma nearParent_hat_lower {r : ℝ} (hr : 0 < r) (q w : ℤ × ℤ) + (hw : boxNorm (point r w-point r q) ≤ 500*r) : + 1/4 ≤ hat (scale r 12) (nearParent q) (point r q) ∧ + 9/64 ≤ hat (scale r 12) (nearParent q) (point r w) := by + have hs : scale r 12 = 4096*r := by norm_num [scale] + have hq := nearParent_box hr q + have ht := boxNorm_add_le (point r w-point r q) (point r q-point (4096*r) (nearParent q)) + rw [sub_add_sub_cancel] at ht + have hw' : boxNorm (point r w-point (4096*r) (nearParent q)) ≤ (5/8:ℝ)*(4096*r) := by + linarith + have h1 := hat_lower (by positivity : 0 < 4096*r) (by norm_num : (1/2:ℝ) ≤ 1) (nearParent q) (point r q) hq + have h2 := hat_lower (by positivity : 0 < 4096*r) (by norm_num : (5/8:ℝ) ≤ 1) (nearParent q) (point r w) hw' + rw [hs] + norm_num at h1 h2 ⊢ + exact ⟨h1,h2⟩ + +lemma nearParent_fiber_card (S : Finset (ℤ × ℤ)) (p : ℤ × ℤ) : + (S.filter (fun q => nearParent q=p)).card ≤ 4097^2 := by + let T := (Finset.Icc (4096*p.1-2048) (4096*p.1+2048)).product + (Finset.Icc (4096*p.2-2048) (4096*p.2+2048)) + have hsub : S.filter (fun q => nearParent q=p) ⊆ T := by + intro q hq + have he := (Finset.mem_filter.mp hq).2 + have h1 := nearParent_int_bound q.1 + have h2 := nearParent_int_bound q.2 + have he1 : (q.1+2048)/4096=p.1 := congrArg Prod.fst he + have he2 : (q.2+2048)/4096=p.2 := congrArg Prod.snd he + rw [he1,abs_le] at h1 + rw [he2,abs_le] at h2 + exact Finset.mem_product.mpr ⟨Finset.mem_Icc.mpr ⟨by omega,by omega⟩, + Finset.mem_Icc.mpr ⟨by omega,by omega⟩⟩ + apply (Finset.card_le_card hsub).trans + dsimp only [T] + change ((Finset.Icc (4096*p.1-2048) (4096*p.1+2048)) ×ˢ + (Finset.Icc (4096*p.2-2048) (4096*p.2+2048))).card ≤ 4097^2 + rw [Finset.card_product,Int.card_Icc,Int.card_Icc] + have he (j : ℤ) : 4096*j+2048+1-(4096*j-2048)=4097 := by ring + rw [he,he] + change (4097:ℕ)*4097 ≤ 4097^2 + norm_num + +end DyadicHats + +namespace DirectionNeighbors +open DyadicHats Finset + +/-- The complete fixed grid window. No spatial observation enters the choices. -/ +def window (d : ℕ) (q : ℤ × ℤ) : Finset (ℤ × ℤ) := + (Finset.Icc (q.1-d) (q.1+d)).product (Finset.Icc (q.2-d) (q.2+d)) + +lemma self_mem_window (d : ℕ) (q : ℤ × ℤ) : q ∈ window d q := by + exact Finset.mem_product.mpr ⟨Finset.mem_Icc.mpr ⟨by omega,by omega⟩, + Finset.mem_Icc.mpr ⟨by omega,by omega⟩⟩ + +lemma mem_window_iff {r : ℝ} (hr : 0 < r) (d : ℕ) (q z : ℤ × ℤ) : + z ∈ window d q ↔ boxNorm (point r z-point r q) ≤ (d:ℝ)*r := by + have hh (a b : ℤ) : |r*a-r*b| ≤ (d:ℝ)*r ↔ b-(d:ℤ) ≤ a ∧ a ≤ b+d := by + rw [← mul_sub,abs_mul,abs_of_pos hr,mul_comm (d:ℝ) r,mul_le_mul_iff_right₀ hr] + have hc : |(a:ℝ)-(b:ℝ)| ≤ (d:ℝ) ↔ |a-b| ≤ (d:ℤ) := by + exact_mod_cast Iff.rfl + rw [hc,abs_le] + omega + change (_ ∈ ((Finset.Icc _ _) ×ˢ (Finset.Icc _ _))) ↔ max _ _ ≤ _ + rw [Finset.mem_product,Finset.mem_Icc,Finset.mem_Icc,max_le_iff] + exact (hh _ _).symm.and (hh _ _).symm + +private lemma max_exists (f : ℤ × ℤ → ℝ) (d : ℕ) (q : ℤ × ℤ) : + ∃ z ∈ window d q, ∀ z' ∈ window d q, f z' ≤ f z := + Finset.exists_max_image (window d q) f ⟨q,self_mem_window d q⟩ + +def maxVertex (f : ℤ × ℤ → ℝ) (d : ℕ) (q : ℤ × ℤ) : ℤ × ℤ := + Classical.choose (max_exists f d q) +lemma maxVertex_mem (f : ℤ × ℤ → ℝ) (d : ℕ) (q : ℤ × ℤ) : + maxVertex f d q ∈ window d q := (Classical.choose_spec (max_exists f d q)).1 +lemma le_maxVertex (f : ℤ × ℤ → ℝ) (d : ℕ) (q : ℤ × ℤ) {z : ℤ × ℤ} + (hz : z ∈ window d q) : f z ≤ f (maxVertex f d q) := + (Classical.choose_spec (max_exists f d q)).2 z hz + +def chosen (h : ℂ → ℂ) (r : ℝ) : ℤ × ℤ → ℤ × ℤ := maxVertex (scalarMass h r) 300 + +def theta (h : ℂ → ℂ) (r : ℝ) (q : ℤ × ℤ) : ℂ := + IntrinsicMarks.direction 1 (vectorMass h r q) +def Theta (h : ℂ → ℂ) (r : ℝ) (z : ℤ × ℤ) : ℂ := theta h r (chosen h r z) + +def worstVertex (h : ℂ → ℂ) (r : ℝ) (q : ℤ × ℤ) : ℤ × ℤ := + maxVertex (fun z => ‖Theta h r z-theta h r q‖^2) 200 q + +def energy (h : ℂ → ℂ) (r : ℝ) (q : ℤ × ℤ) : ℝ := + ‖Theta h r (worstVertex h r q)-theta h r q‖^2 + +lemma norm_theta (h : ℂ → ℂ) (r : ℝ) (q : ℤ × ℤ) : ‖theta h r q‖ = 1 := + IntrinsicMarks.norm_direction (by norm_num) _ +lemma energy_nonneg (h : ℂ → ℂ) (r : ℝ) (q : ℤ × ℤ) : 0 ≤ energy h r q := sq_nonneg _ +lemma energy_le_four (h : ℂ → ℂ) (r : ℝ) (q : ℤ × ℤ) : energy h r q ≤ 4 := by + have hn := norm_sub_le (Theta h r (worstVertex h r q)) (theta h r q) + simp only [Theta,norm_theta] at hn + change ‖theta h r (chosen h r (worstVertex h r q))-theta h r q‖^2 ≤ 4 + nlinarith [norm_nonneg (theta h r (chosen h r (worstVertex h r q))-theta h r q)] + +lemma energy_controls {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q z : ℤ × ℤ) + (hz : boxNorm (point r z-point r q) ≤ 200*r) : + ‖Theta h r z-theta h r q‖^2 ≤ energy h r q := by + apply le_maxVertex (fun z => ‖Theta h r z-theta h r q‖^2) 200 q + exact (mem_window_iff hr 200 q z).mpr (by simpa using hz) + +lemma worstVertex_near {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) : + boxNorm (point r (worstVertex h r q)-point r q) ≤ 200*r := by + have hm := maxVertex_mem (fun z => ‖Theta h r z-theta h r q‖^2) 200 q + simpa only [worstVertex,Nat.cast_ofNat] using (mem_window_iff hr 200 q _).mp hm + +lemma chosen_near {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (z : ℤ × ℤ) : + boxNorm (point r (chosen h r z)-point r z) ≤ 300*r := by + simpa only [chosen,Nat.cast_ofNat] using + (mem_window_iff hr 300 z _).mp (maxVertex_mem (scalarMass h r) 300 z) + +/-- The actual chosen neighbor supplies at least the root's mass and is within +500 fine-grid units, precisely the inputs spent by the coarse triangle defect. -/ +lemma worst_chosen_spec {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) : + scalarMass h r q ≤ scalarMass h r (chosen h r (worstVertex h r q)) ∧ + boxNorm (point r (chosen h r (worstVertex h r q))-point r q) ≤ 500*r := by + let z := worstVertex h r q + have hz : boxNorm (point r z-point r q) ≤ 200*r := worstVertex_near hr h q + have hz' : boxNorm (point r q-point r z) ≤ 300*r := by + rw [boxNorm_sub_comm] + linarith + have ha := le_maxVertex (scalarMass h r) 300 z ((mem_window_iff hr 300 z q).mpr (by simpa using hz')) + have hw := chosen_near hr h z + have ht := boxNorm_add_le (point r (chosen h r z)-point r z) (point r z-point r q) + rw [sub_add_sub_cancel] at ht + exact ⟨ha,by linarith⟩ + +open DyadicHats + +lemma vectorMass_mem_grid {N : ℕ} {r R : ℝ} (hr : 0 < r) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) + {q : ℤ × ℤ} (hq : vectorMass h r q ≠ 0) : q ∈ indexBox N := by + by_contra hn + apply hq + apply integral_eq_zero_of_ae + filter_upwards with y + by_cases hy : h y=0 + · simp only [hy,smul_zero,Pi.zero_apply] + · have hh : hat r q y=0 := by + by_contra hz + exact hn (mem_indexBox_of_le hr hN (hs y hy) hz) + simp only [hh,zero_smul,Pi.zero_apply] + +/-- The literal triangle defect over twelve positive refinements. -/ +def coarseDefect (N : ℕ) (h : ℂ → ℂ) (r : ℝ) (d : ℕ) (p : Grid N) : ℝ := + (∑ q : Grid N, coeff N d p q*scalarMass h r q)-scalarMass h (scale r d) p + +lemma direction_refine {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (d : ℕ) (p : Grid N) : + scalarMass h (scale r d) p • theta h (scale r d) p = + ∑ q : Grid N, (coeff N d p q*scalarMass h r q) • theta h r q := by + rw [show scalarMass h (scale r d) p • theta h (scale r d) p = + vectorMass h (scale r d) p from IntrinsicMarks.mass_direction 1 _] + rw [vectorMass_coeff hr hR hN hh hs] + apply Finset.sum_congr rfl + intro q _ + rw [mul_smul] + congr 1 + exact (IntrinsicMarks.mass_direction 1 _).symm + +lemma coarseDefect_nonneg {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (d : ℕ) (p : Grid N) : + 0 ≤ coarseDefect N h r d p := by + have he := VectorRefinement.quadratic_defect (coeff N d p) (fun q : Grid N => scalarMass h r q) + (fun q : Grid N => theta h r q) (theta h (scale r d) p) (scalarMass h (scale r d) p) + (norm_theta _ _ _) (fun _ => norm_theta _ _ _) (direction_refine hr hR hN hh hs d p) + rw [coarseDefect,he] + apply mul_nonneg (by norm_num) + exact Finset.sum_nonneg fun q _ => + mul_nonneg (mul_nonneg (coeff_nonneg _ _ _ _) (norm_nonneg _)) (sq_nonneg _) + +lemma coarseDefect_sum (N : ℕ) (h : ℂ → ℂ) (r : ℝ) (d : ℕ) : + (∑ p : Grid N, coarseDefect N h r d p) = + (∑ q : Grid N, scalarMass h r q)-(∑ p : Grid N, scalarMass h (scale r d) p) := by + simp only [coarseDefect,Finset.sum_sub_distrib] + congr 1 + rw [Finset.sum_comm] + simp_rw [← Finset.sum_mul,coeff_column,one_mul] + +def parent (N : ℕ) (q : Grid N) : Grid N := ⟨nearParent q,nearParent_mem q.property⟩ + +/-- The actual maximally differing neighbor spends true vector cancellation, +not an independently postulated directional budget. -/ +lemma neighbor_charge {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) (q : Grid N) : + scalarMass h r q*energy h r q ≤ 48*coarseDefect N h r 12 (parent N q) := by + by_cases hq : scalarMass h r q=0 + · rw [hq,zero_mul] + exact mul_nonneg (by norm_num) (coarseDefect_nonneg hr hR hN hh hs 12 _) + have hqpos : 0 < scalarMass h r q := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hq) + let z := chosen h r (worstVertex h r q) + have hz := worst_chosen_spec hr h q + have hzpos : 0 < scalarMass h r z := hqpos.trans_le hz.1 + have hzmem : z ∈ indexBox N := vectorMass_mem_grid hr hN hs (norm_ne_zero_iff.mp (ne_of_gt hzpos)) + let s : Grid N := ⟨z,hzmem⟩ + have hweights := nearParent_hat_lower hr q z hz.2 + have hwq : 1/4 ≤ coeff N 12 (parent N q) q := by + rw [coeff_eq_hat hr] + exact hweights.1 + have hws : 9/64 ≤ coeff N 12 (parent N q) s := by + rw [coeff_eq_hat hr] + exact hweights.2 + have he := VectorRefinement.pair_defect_bound (coeff N 12 (parent N q)) + (fun p : Grid N => scalarMass h r p) (fun p : Grid N => theta h r p) + (theta h (scale r 12) (parent N q)) (scalarMass h (scale r 12) (parent N q)) + (fun p => coeff_nonneg N 12 _ p) (fun _ => norm_nonneg _) + (norm_theta _ _ _) (fun _ => norm_theta _ _ _) + (direction_refine hr hR hN hh hs 12 _) hwq hws hz.1 + change scalarMass h r q*‖theta h r z-theta h r q‖^2 ≤ _ + rw [norm_sub_rev] + exact he + +lemma parent_fiber_card (N : ℕ) (p : Grid N) : + (Finset.univ.filter (fun q : Grid N => parent N q=p)).card ≤ 4097^2 := by + let F := Finset.univ.filter (fun q : Grid N => parent N q=p) + let e : Grid N ↪ ℤ × ℤ := ⟨Subtype.val,Subtype.val_injective⟩ + have hm : F.map e ⊆ (indexBox N).filter (fun q => nearParent q=p.val) := by + intro q hq + obtain ⟨s,hs,rfl⟩ := Finset.mem_map.mp hq + apply Finset.mem_filter.mpr + exact ⟨s.property,congrArg Subtype.val (Finset.mem_filter.mp hs).2⟩ + calc + _ = (F.map e).card := (Finset.card_map e).symm + _ ≤ ((indexBox N).filter (fun q => nearParent q=p.val)).card := Finset.card_le_card hm + _ ≤ 4097^2 := nearParent_fiber_card _ _ + +lemma parent_sum_bound (N : ℕ) (a : Grid N → ℝ) (ha : ∀ p, 0 ≤ a p) : + (∑ q : Grid N, a (parent N q)) ≤ (4097:ℝ)^2*∑ p : Grid N, a p := by + rw [← Finset.sum_fiberwise Finset.univ (parent N) (fun q => a (parent N q)),Finset.mul_sum] + apply Finset.sum_le_sum + intro p _ + calc + _ = ∑ q ∈ Finset.univ.filter (fun q => parent N q=p), a p := by + apply Finset.sum_congr rfl + intro q hq + rw [(Finset.mem_filter.mp hq).2] + _ = ((Finset.univ.filter (fun q => parent N q=p)).card:ℝ)*a p := by simp + _ ≤ (4097:ℝ)^2*a p := by + apply mul_le_mul_of_nonneg_right _ (ha p) + exact_mod_cast parent_fiber_card N p + +/-- Uniform one-scale neighbor energy bound by the actual twelve-scale mass drop. -/ +theorem level_energy_budget {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) + (hN : R/r+1 ≤ (N:ℝ)) {h : ℂ → ℂ} (hh : Integrable h) + (hs : ∀ y, h y ≠ 0 → ‖y‖ ≤ R) : + (∑ q : Grid N, scalarMass h r q*energy h r q) ≤ + (48*(4097:ℝ)^2)*((∑ q : Grid N, scalarMass h r q)- + ∑ p : Grid N, scalarMass h (scale r 12) p) := by + have h1 := Finset.sum_le_sum (fun q (_ : q ∈ (Finset.univ : Finset (Grid N))) => + neighbor_charge hr hR hN hh hs q) + have h2 := parent_sum_bound N (coarseDefect N h r 12) + (fun p => coarseDefect_nonneg hr hR hN hh hs 12 p) + rw [← Finset.mul_sum] at h1 + have h3 := h1.trans (mul_le_mul_of_nonneg_left h2 (by norm_num : (0:ℝ) ≤ 48)) + rw [coarseDefect_sum] at h3 + simpa only [mul_assoc] using h3 + +end DirectionNeighbors + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/FiniteLabels1.lean b/lean/OAI/Analysis/SignedDisk/FiniteLabels1.lean new file mode 100644 index 0000000000000000000000000000000000000000..472658e19451306a4cc6a59febd1fd38e8569d39 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/FiniteLabels1.lean @@ -0,0 +1,418 @@ +import OAI.Analysis.SignedDisk.DyadicHats2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace FiniteLabels +open DyadicHats +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma delta_diff_le_one (i j k : ι) : |delta i k-delta j k| ≤ 1 := by + exact abs_sub_le_iff.mpr ⟨by linarith [(delta i).nonneg k,law_le_one (delta i) k,(delta j).nonneg k], + by linarith [(delta j).nonneg k,law_le_one (delta j) k,(delta i).nonneg k]⟩ + +/-- The actual locally finite transition row on the entire spatial grid. -/ +def spatialRow (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (r : ℝ) (x : ℂ) : Law ι where + mass j := delta old j+interpolate r (fun z => p z*(delta (target z) j-delta old j)) x + nonneg j := by + simp only [mul_sub,interpolate_sub,interpolate_mul_const] + have h0 := interpolate_nonneg r x hp0 + have h1 := interpolate_le_const r x hp1 + have h2 := interpolate_nonneg r x (fun z => mul_nonneg (hp0 z) ((delta (target z)).nonneg j)) + have hd := (delta old).nonneg j + nlinarith + total := by + rw [sum_add_distrib,(delta old).total,← interpolate_finset_sum] + have he : (fun z => ∑ j : ι, p z*(delta (target z) j-delta old j)) = fun _ => 0 := by + funext z + rw [← mul_sum,sum_sub_distrib,(delta _).total,(delta _).total,sub_self,mul_zero] + rw [he,interpolate_const,add_zero] + +lemma spatialRow_formula (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (r : ℝ) (x : ℂ) (j : ι) : + spatialRow old target p hp0 hp1 r x j = + delta old j+interpolate r (fun z => p z*(delta (target z) j-delta old j)) x := rfl + +lemma spatialRow_component_lipschitz (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) {r B : ℝ} (hr : 0 < r) (hB : 0 ≤ B) + (hpB : ∀ z, p z ≤ B) (j : ι) : + LipschitzWith (Real.toNNReal (16*B/r)) (fun x => spatialRow old target p hp0 hp1 r x j) := by + have hl := interpolate_lipschitz hr hB (f := fun z => p z*(delta (target z) j-delta old j)) + (fun z => by rw [abs_mul,abs_of_nonneg (hp0 z)]; exact + (mul_le_mul_of_nonneg_left (delta_diff_le_one _ _ _) (hp0 z)).trans (by simpa using hpB z)) + change LipschitzWith (Real.toNNReal (16*B/r)) + (fun x => delta old j+interpolate r (fun z => p z*(delta (target z) j-delta old j)) x) + simpa only [zero_add] using (LipschitzWith.const (delta old j)).add hl + +lemma spatialRow_distance (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) {r B : ℝ} (hr : 0 < r) (hB : 0 ≤ B) + (hpB : ∀ z, p z ≤ B) (x y : ℂ) : + l1dist (spatialRow old target p hp0 hp1 r x) (spatialRow old target p hp0 hp1 r y) ≤ + (Fintype.card ι:ℝ)*(16*B/r)*‖x-y‖ := by + unfold l1dist + calc + _ ≤ ∑ _j : ι, (16*B/r)*‖x-y‖ := by + apply sum_le_sum + intro j _ + have hl := (spatialRow_component_lipschitz old target p hp0 hp1 hr hB hpB j).dist_le_mul x y + rw [Real.dist_eq,Real.coe_toNNReal (16*B/r) (by positivity),dist_eq_norm] at hl + exact hl + _ = _ := by rw [sum_const,card_univ,nsmul_eq_mul,mul_assoc] + +end FiniteLabels + +namespace DyadicHats +open Finset Filter + +lemma interpolate_congr_on (r : ℝ) (x : ℂ) {f g : ℤ × ℤ → ℝ} + (h : ∀ p, hat r p x ≠ 0 → f p = g p) : interpolate r f x = interpolate r g x := by + apply tsum_congr + intro p + by_cases hp : hat r p x = 0 + · simp only [hp,zero_mul] + · rw [h p hp] + +lemma interpolate_mono_on (r : ℝ) (x : ℂ) {f g : ℤ × ℤ → ℝ} + (h : ∀ p, hat r p x ≠ 0 → f p ≤ g p) : interpolate r f x ≤ interpolate r g x := by + apply Summable.tsum_le_tsum _ (summable_weighted_hat r x f) (summable_weighted_hat r x g) + intro p + by_cases hp : hat r p x = 0 + · simp only [hp,zero_mul,le_refl] + · exact mul_le_mul_of_nonneg_left (h p hp) (hat_nonneg r p x) + +lemma hat_vertex_local {r : ℝ} (hr : 0 < r) {x q : ℂ} + (hx : boxNorm (x-q) < 199*r) {p : ℤ × ℤ} (hp : hat r p x ≠ 0) : + boxNorm (point r p-q) ≤ 200*r := by + have hd := (hat_ne_zero_iff hr p x).mp hp + have ht := boxNorm_add_le (point r p-x) (x-q) + rw [sub_add_sub_cancel,boxNorm_sub_comm (point r p) x] at ht + linarith + +lemma continuous_boxNorm : Continuous boxNorm := + (Complex.continuous_re.abs).max (Complex.continuous_im.abs) + +lemma local_neighborhood {r : ℝ} {q x : ℂ} (hx : boxNorm (x-q) < 199*r) : + ∀ᶠ y in 𝓝 x, boxNorm (y-q) < 199*r := by + exact ((continuous_boxNorm.comp (continuous_id.sub continuous_const)).continuousAt.eventually + (eventually_lt_nhds hx)) + +def truncate (r : ℝ) (q : ℂ) (p : ℤ × ℤ → ℝ) (z : ℤ × ℤ) : ℝ := + if boxNorm (point r z-q) ≤ 200*r then p z else 0 + +lemma truncate_nonneg (r : ℝ) (q : ℂ) {p : ℤ × ℤ → ℝ} (hp : ∀ z, 0 ≤ p z) (z : ℤ × ℤ) : + 0 ≤ truncate r q p z := by unfold truncate; split_ifs <;> simp [hp] +lemma truncate_le {r B : ℝ} {q : ℂ} {p : ℤ × ℤ → ℝ} (hB : 0 ≤ B) + (hp : ∀ z, boxNorm (point r z-q) ≤ 200*r → p z ≤ B) (z : ℤ × ℤ) : + truncate r q p z ≤ B := by unfold truncate; split_ifs with h; exact hp z h; exact hB +lemma interpolate_truncate {r : ℝ} (hr : 0 < r) {q x : ℂ} + (hx : boxNorm (x-q) < 199*r) (p : ℤ × ℤ → ℝ) : + interpolate r (truncate r q p) x = interpolate r p x := by + apply interpolate_congr_on + intro z hz + exact ite_eq_left (hat_vertex_local hr hx hz) + +end DyadicHats + +namespace FiniteLabels + +section +open DyadicHats Finset Filter +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma spatialRow_truncate (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) {r : ℝ} (hr : 0 < r) {q x : ℂ} + (hx : boxNorm (x-q) < 199*r) (j : ι) : + spatialRow old target (truncate r q p) (truncate_nonneg r q hp0) + (truncate_le (by norm_num) (fun z _ => hp1 z)) r x j = + spatialRow old target p hp0 hp1 r x j := by + rw [spatialRow_formula,spatialRow_formula] + congr 1 + apply interpolate_congr_on + intro z hz + rw [truncate,ite_eq_left (hat_vertex_local hr hx hz)] + +lemma spatialRow_local_distance (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) {r B : ℝ} (hr : 0 < r) (hB : 0 ≤ B) + {q x y : ℂ} (hx : boxNorm (x-q) < 199*r) (hy : boxNorm (y-q) < 199*r) + (hpB : ∀ z, boxNorm (point r z-q) ≤ 200*r → p z ≤ B) : + l1dist (spatialRow old target p hp0 hp1 r x) (spatialRow old target p hp0 hp1 r y) ≤ + (Fintype.card ι:ℝ)*(16*B/r)*‖x-y‖ := by + have h := spatialRow_distance old target (truncate r q p) (truncate_nonneg r q hp0) + (truncate_le (by norm_num) (fun z _ => hp1 z)) hr hB (truncate_le hB hpB) x y + simpa only [l1dist,spatialRow_truncate old target p hp0 hp1 hr hx, + spatialRow_truncate old target p hp0 hp1 hr hy] using h + +/-- The derivative cost is bounded by the local switched mass, with a constant +fixed by the finite palette, rather than by the number of scales or vertices. -/ +lemma spatialRow_local_derivative (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) {r B : ℝ} (hr : 0 < r) (hB : 0 ≤ B) + {q x : ℂ} (hx : boxNorm (x-q) < 199*r) + (hpB : ∀ z, boxNorm (point r z-q) ≤ 200*r → p z ≤ B) : + r*∑ j : ι, ‖gradient (fun y => spatialRow old target p hp0 hp1 r y j) x‖ ≤ + 16*(Fintype.card ι:ℝ)*B := by + have hb (j : ι) : ‖gradient (fun y => spatialRow old target p hp0 hp1 r y j) x‖ ≤ 16*B/r := by + have he : (fun y => spatialRow old target (truncate r q p) (truncate_nonneg r q hp0) + (truncate_le (by norm_num) (fun z _ => hp1 z)) r y j) =ᶠ[𝓝 x] + (fun y => spatialRow old target p hp0 hp1 r y j) := by + filter_upwards [local_neighborhood hx] with y hy + exact spatialRow_truncate old target p hp0 hp1 hr hy j + have hl := spatialRow_component_lipschitz old target (truncate r q p) (truncate_nonneg r q hp0) + (truncate_le (by norm_num) (fun z _ => hp1 z)) hr hB (truncate_le hB hpB) j + have hd := he.fderiv_eq (𝕜 := ℝ) + have hn := norm_fderiv_le_of_lipschitz ℝ (x₀ := x) hl + rw [hd,Real.coe_toNNReal (16*B/r) (by positivity)] at hn + simpa only [gradient,(InnerProductSpace.toDual ℝ ℂ).symm.norm_map] using hn + calc + _ ≤ r*∑ _j : ι, 16*B/r := mul_le_mul_of_nonneg_left (sum_le_sum (fun j _ => hb j)) hr.le + _ = _ := by rw [sum_const,card_univ,nsmul_eq_mul]; field_simp + +end + +def probability (τ d : ℝ) : ℝ := min 1 ((τ⁻¹*max (d-τ) 0)^2) +def amplitude (τ d : ℝ) : ℝ := min 1 (τ⁻¹*max (d-τ) 0) + +lemma probability_formula (τ d : ℝ) : + probability τ d = min 1 (τ^(-2:ℤ)*max (d-τ) 0^2) := by + simp only [probability,mul_pow,zpow_neg,zpow_ofNat,inv_pow] + +lemma amplitude_nonneg {τ : ℝ} (hτ : 0 ≤ τ) (d : ℝ) : 0 ≤ amplitude τ d := + le_min (by norm_num) (mul_nonneg (inv_nonneg.mpr hτ) (le_max_right _ _)) +lemma amplitude_le_one (τ d : ℝ) : amplitude τ d ≤ 1 := min_le_left _ _ +lemma probability_nonneg (τ d : ℝ) : 0 ≤ probability τ d := le_min (by norm_num) (sq_nonneg _) +lemma probability_le_one (τ d : ℝ) : probability τ d ≤ 1 := min_le_left _ _ + +lemma probability_eq_square {τ : ℝ} (hτ : 0 ≤ τ) (d : ℝ) : + probability τ d = amplitude τ d^2 := by + have hx : 0 ≤ τ⁻¹*max (d-τ) 0 := mul_nonneg (inv_nonneg.mpr hτ) (le_max_right _ _) + unfold probability amplitude + by_cases h : τ⁻¹*max (d-τ) 0 ≤ 1 + · rw [min_eq_right h,min_eq_right (by nlinarith)] + · rw [min_eq_left (le_of_not_ge h),min_eq_left (by nlinarith)] + norm_num + +lemma amplitude_lipschitz {τ : ℝ} (hτ : 0 < τ) : + LipschitzWith (Real.toNNReal τ⁻¹) (amplitude τ) := by + have hid : LipschitzWith 1 (fun d : ℝ => d-τ) := by + rw [lipschitzWith_iff_dist_le_mul] + intro x y + simp only [NNReal.coe_one,one_mul,Real.dist_eq,sub_sub_sub_cancel_right,le_refl] + have hmax : LipschitzWith 1 (fun d : ℝ => max (d-τ) 0) := by + simpa only [max_eq_left (by norm_num : (0:ℝ≥0) ≤ 1)] using hid.max (LipschitzWith.const 0) + have hm : LipschitzWith (Real.toNNReal τ⁻¹) (fun d : ℝ => τ⁻¹*max (d-τ) 0) := by + rw [lipschitzWith_iff_dist_le_mul] + intro d d' + rw [Real.dist_eq,Real.dist_eq,← mul_sub,abs_mul, + abs_of_nonneg (inv_nonneg.mpr hτ.le),Real.coe_toNNReal _ (inv_nonneg.mpr hτ.le)] + have hl := hmax.dist_le_mul d d' + simp only [Real.dist_eq,NNReal.coe_one,one_mul] at hl + exact mul_le_mul_of_nonneg_left hl (inv_nonneg.mpr hτ.le) + rw [lipschitzWith_iff_dist_le_mul] + intro x y + change dist (min 1 (τ⁻¹*max (x-τ) 0)) (min 1 (τ⁻¹*max (y-τ) 0)) ≤ _ + simpa only [max_eq_right (by positivity : (0:ℝ≥0) ≤ Real.toNNReal τ⁻¹)] using + ((LipschitzWith.const (1:ℝ)).min hm).dist_le_mul x y + +lemma probability_compare {τ : ℝ} (hτ : 0 < τ) (d d' : ℝ) : + probability τ d ≤ 2*probability τ d'+2*τ⁻¹^2*|d-d'|^2 := by + rw [probability_eq_square hτ.le,probability_eq_square hτ.le] + have hl := (amplitude_lipschitz hτ).dist_le_mul d d' + rw [Real.dist_eq,Real.dist_eq,Real.coe_toNNReal _ (inv_nonneg.mpr hτ.le)] at hl + have hdiff : (amplitude τ d-amplitude τ d')^2 ≤ (τ⁻¹*|d-d'|)^2 := by + nlinarith [sq_abs (amplitude τ d-amplitude τ d'),abs_nonneg (amplitude τ d-amplitude τ d'), + mul_nonneg (inv_nonneg.mpr hτ.le) (abs_nonneg (d-d'))] + nlinarith [sq_nonneg (amplitude τ d-2*amplitude τ d')] + +lemma probability_norm_compare {E : Type*} [NormedAddCommGroup E] {τ : ℝ} + (hτ : 0 < τ) (n θ θ' : E) : + probability τ ‖n-θ‖ ≤ 2*probability τ ‖n-θ'‖+2*τ⁻¹^2*‖θ-θ'‖^2 := by + apply (probability_compare hτ ‖n-θ‖ ‖n-θ'‖).trans + have hd : |‖n-θ‖-‖n-θ'‖| ≤ ‖θ-θ'‖ := by + simpa only [sub_sub_sub_cancel_left,norm_sub_rev θ' θ] using abs_norm_sub_norm_le (n-θ) (n-θ') + have hs : |‖n-θ‖-‖n-θ'‖|^2 ≤ ‖θ-θ'‖^2 := by + nlinarith [abs_nonneg (‖n-θ‖-‖n-θ'‖),norm_nonneg (θ-θ')] + have hh := mul_le_mul_of_nonneg_left hs (show 0 ≤ 2*τ⁻¹^2 by positivity) + linarith + +lemma probability_eq_zero {τ d : ℝ} (hd : d ≤ τ) : probability τ d = 0 := by + rw [probability,max_eq_right (sub_nonpos.mpr hd)] + norm_num + +lemma probability_lt_one_iff {τ d : ℝ} (hτ : 0 < τ) : probability τ d < 1 ↔ d < 2*τ := by + rw [probability,min_lt_iff] + constructor + · intro h + rcases h with h|h + · exact (lt_irrefl _ h).elim + have hm := le_max_left (d-τ) 0 + have hn : 0 ≤ τ⁻¹*max (d-τ) 0 := by positivity + have ht : τ⁻¹*max (d-τ) 0 < 1 := by nlinarith + rw [inv_mul_eq_div,div_lt_one hτ] at ht + linarith + · intro h + right + have hm : max (d-τ) 0 < τ := max_lt (by linarith) hτ + have hn : 0 ≤ τ⁻¹*max (d-τ) 0 := by positivity + have ht : τ⁻¹*max (d-τ) 0 < 1 := by rw [inv_mul_eq_div,div_lt_one hτ]; exact hm + nlinarith + +open DyadicHats + +lemma interpolate_const_mul (r : ℝ) (f : ℤ × ℤ → ℝ) (x : ℂ) (c : ℝ) : + interpolate r (fun p => c*f p) x = c*interpolate r f x := by + simp only [mul_comm c,interpolate_mul_const] + +lemma norm_sub_sq_le_four {E : Type*} [NormedAddCommGroup E] (u v w : E) {A : ℝ} + (hu : ‖u-w‖^2 ≤ A) (hv : ‖v-w‖^2 ≤ A) : ‖u-v‖^2 ≤ 4*A := by + have ht : ‖u-v‖ ≤ ‖u-w‖+‖v-w‖ := by + simpa only [sub_add_sub_cancel,norm_sub_rev w v] using norm_add_le (u-w) (w-v) + nlinarith [norm_nonneg (u-v),norm_nonneg (u-w),norm_nonneg (v-w), + sq_nonneg (‖u-w‖-‖v-w‖)] + +def switchRate (τ r : ℝ) (Θ : ℤ × ℤ → ℂ) (n x : ℂ) : ℝ := + interpolate r (fun z => probability τ ‖n-Θ z‖) x + +lemma switchRate_nonneg (τ r : ℝ) (Θ : ℤ × ℤ → ℂ) (n x : ℂ) : + 0 ≤ switchRate τ r Θ n x := interpolate_nonneg r x (fun _ => probability_nonneg _ _) +lemma switchRate_le_one (τ r : ℝ) (Θ : ℤ × ℤ → ℂ) (n x : ℂ) : + switchRate τ r Θ n x ≤ 1 := interpolate_le_const r x (fun _ => probability_le_one _ _) + +/-- The row-rate comparison is produced from the literal quadratic probability +and the actual partition of unity, uniformly over all nearby grid vertices. -/ +lemma probability_le_rate_energy {τ r E : ℝ} (hτ : 0 < τ) (hr : 0 < r) + (Θ : ℤ × ℤ → ℂ) (n θ q y : ℂ) (hy : boxNorm (y-q) < 199*r) + (hE : ∀ z, boxNorm (point r z-q) ≤ 200*r → ‖Θ z-θ‖^2 ≤ E) + (z : ℤ × ℤ) (hz : boxNorm (point r z-q) ≤ 200*r) : + probability τ ‖n-Θ z‖ ≤ 2*switchRate τ r Θ n y+8*τ⁻¹^2*E := by + have hp (z' : ℤ × ℤ) (hz' : hat r z' y ≠ 0) : + probability τ ‖n-Θ z‖ ≤ 2*probability τ ‖n-Θ z'‖+8*τ⁻¹^2*E := by + have he := norm_sub_sq_le_four (Θ z) (Θ z') θ (hE z hz) (hE z' (hat_vertex_local hr hy hz')) + have hh := probability_norm_compare hτ n (Θ z) (Θ z') + have hm := mul_le_mul_of_nonneg_left he (show 0 ≤ 2*τ⁻¹^2 by positivity) + nlinarith + calc + _ = interpolate r (fun _ => probability τ ‖n-Θ z‖) y := (interpolate_const _ _ _).symm + _ ≤ interpolate r (fun z' => 2*probability τ ‖n-Θ z'‖+8*τ⁻¹^2*E) y := + interpolate_mono_on r y hp + _ = _ := by rw [interpolate_add,interpolate_const_mul,interpolate_const]; rfl + +lemma switchRate_local_compare {τ r E : ℝ} (hτ : 0 < τ) (hr : 0 < r) + (Θ : ℤ × ℤ → ℂ) (n θ q x y : ℂ) + (hx : boxNorm (x-q) < 199*r) (hy : boxNorm (y-q) < 199*r) + (hE : ∀ z, boxNorm (point r z-q) ≤ 200*r → ‖Θ z-θ‖^2 ≤ E) : + switchRate τ r Θ n x ≤ 2*switchRate τ r Θ n y+8*τ⁻¹^2*E := by + change interpolate r _ x ≤ _ + calc + _ ≤ interpolate r (fun _ => 2*switchRate τ r Θ n y+8*τ⁻¹^2*E) x := by + apply interpolate_mono_on + intro z hz + exact probability_le_rate_energy hτ hr Θ n θ q y hy hE z (hat_vertex_local hr hx hz) + _ = _ := interpolate_const _ _ _ + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def spatialSwitchRow (τ r : ℝ) (label : ι → ℂ) (Θ : ℤ × ℤ → ℂ) + (target : ℤ × ℤ → ι) (old : ι) (x : ℂ) : Law ι := + spatialRow old target (fun z => probability τ ‖label old-Θ z‖) + (fun _ => probability_nonneg _ _) (fun _ => probability_le_one _ _) r x + +lemma spatialSwitchRow_local_distance {τ r E : ℝ} (hτ : 0 < τ) (hr : 0 < r) (hE0 : 0 ≤ E) + (label : ι → ℂ) (Θ : ℤ × ℤ → ℂ) (target : ℤ × ℤ → ι) (old : ι) + (θ q x y : ℂ) (hx : boxNorm (x-q) < 199*r) (hy : boxNorm (y-q) < 199*r) + (hE : ∀ z, boxNorm (point r z-q) ≤ 200*r → ‖Θ z-θ‖^2 ≤ E) : + l1dist (spatialSwitchRow τ r label Θ target old x) (spatialSwitchRow τ r label Θ target old y) ≤ + (Fintype.card ι:ℝ)* + (16*(2*switchRate τ r Θ (label old) y+8*τ⁻¹^2*E)/r)*‖x-y‖ := by + apply spatialRow_local_distance old target _ _ _ hr + (by have h := switchRate_nonneg τ r Θ (label old) y; positivity) hx hy + intro z hz + exact probability_le_rate_energy hτ hr Θ (label old) θ q y hy hE z hz + +lemma spatialSwitchRow_local_derivative {τ r E : ℝ} (hτ : 0 < τ) (hr : 0 < r) (hE0 : 0 ≤ E) + (label : ι → ℂ) (Θ : ℤ × ℤ → ℂ) (target : ℤ × ℤ → ι) (old : ι) + (θ q x y : ℂ) (hx : boxNorm (x-q) < 199*r) (hy : boxNorm (y-q) < 199*r) + (hE : ∀ z, boxNorm (point r z-q) ≤ 200*r → ‖Θ z-θ‖^2 ≤ E) : + r*∑ j : ι, ‖gradient (fun x => spatialSwitchRow τ r label Θ target old x j) x‖ ≤ + 16*(Fintype.card ι:ℝ)*(2*switchRate τ r Θ (label old) y+8*τ⁻¹^2*E) := by + apply spatialRow_local_derivative old target _ _ _ hr + (by have h := switchRate_nonneg τ r Θ (label old) y; positivity) hx + intro z hz + exact probability_le_rate_energy hτ hr Θ (label old) θ q y hy hE z hz + +end FiniteLabels + +namespace DyadicHats +open Finset + +lemma hat_at_point {r : ℝ} (hr : r ≠ 0) (p q : ℤ × ℤ) : + hat r p (point r q) = if p=q then 1 else 0 := by + have ht (a b : ℤ) : tent ((b:ℝ)-(a:ℝ)) = if a=b then 1 else 0 := by + by_cases h : a=b + · simp [h,tent] + · rw [ite_eq_right h] + apply tent_eq_zero_of_one_le + have hi : (1:ℤ) ≤ |b-a| := Int.one_le_abs (sub_ne_zero.mpr (Ne.symm h)) + exact_mod_cast hi + simp only [hat,point,mul_div_cancel_left₀ _ hr,ht] + split_ifs <;> simp_all [Prod.ext_iff] + +lemma hat_vertex_bound {r : ℝ} (hr : 0 < r) {N : ℕ} {x : ℂ} + (hx1 : |x.re| ≤ r*N) (hx2 : |x.im| ≤ r*N) + {p : ℤ × ℤ} (hp : hat r p x ≠ 0) : p ∈ indexBox N := by + have h := (hat_ne_zero_iff hr p x).mp hp + have h1 := lt_of_le_of_lt (le_max_left |(x-point r p).re| |(x-point r p).im|) h + have h2 := lt_of_le_of_lt (le_max_right |(x-point r p).re| |(x-point r p).im|) h + simp only [Complex.sub_re,Complex.sub_im,point] at h1 h2 + have hb (t : ℝ) (j : ℤ) (ht : |t| ≤ r*N) (hj : |t-r*j| < r) : + j ∈ Finset.Icc (-(N:ℤ)) N := by + have ht' := abs_le.mp ht + have hj' := abs_lt.mp hj + have hlo : -(N:ℝ)-1 < (j:ℝ) := by nlinarith + have hhi : (j:ℝ) < (N:ℝ)+1 := by nlinarith + have hlo' : -(N:ℤ)-1 < j := by exact_mod_cast hlo + have hhi' : j < (N:ℤ)+1 := by exact_mod_cast hhi + exact Finset.mem_Icc.mpr ⟨by omega,by omega⟩ + exact Finset.mem_product.mpr ⟨hb _ _ hx1 h1,hb _ _ hx2 h2⟩ + +lemma velocity_bound_on_grid {N : ℕ} {r : ℝ} (hr : 0 < r) (k : ℕ) (q : Grid N) : + |(point r q).re| ≤ scale r k*N ∧ |(point r q).im| ≤ scale r k*N := by + have h1 := Finset.mem_Icc.mp (Finset.mem_product.mp q.property).1 + have h2 := Finset.mem_Icc.mp (Finset.mem_product.mp q.property).2 + have hh (j : ℤ) (hj : -(N:ℤ) ≤ j ∧ j ≤ N) : |r*j| ≤ scale r k*N := by + have hj' : |(j:ℝ)| ≤ N := abs_le.mpr ⟨by exact_mod_cast hj.1,by exact_mod_cast hj.2⟩ + rw [abs_mul,abs_of_pos hr] + exact (mul_le_mul_of_nonneg_left hj' hr.le).trans + (mul_le_mul_of_nonneg_right (le_scale hr.le k) (Nat.cast_nonneg N)) + exact ⟨hh q.val.1 h1,hh q.val.2 h2⟩ + +end DyadicHats + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/FiniteLabels2.lean b/lean/OAI/Analysis/SignedDisk/FiniteLabels2.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ba98d238f61d77deb2a3740da1ab64fa5217234 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/FiniteLabels2.lean @@ -0,0 +1,475 @@ +import OAI.Analysis.SignedDisk.AffineDensities1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace FiniteLabels +open DyadicHats Finset +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +def expect (μ : Law ι) (f : ι → ℝ) : ℝ := ∑ i, μ i*f i + +lemma expect_nonneg (μ : Law ι) {f : ι → ℝ} (hf : ∀ i, 0 ≤ f i) : 0 ≤ expect μ f := + sum_nonneg (fun i _ => mul_nonneg (μ.nonneg i) (hf i)) +lemma expect_le_one (μ : Law ι) {f : ι → ℝ} (hf : ∀ i, f i ≤ 1) : expect μ f ≤ 1 := by + calc + _ ≤ ∑ i, μ i*1 := sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (hf i) (μ.nonneg i)) + _ = _ := by simp only [mul_one,μ.total] +lemma expect_add (μ : Law ι) (f g : ι → ℝ) : + expect μ (fun i => f i+g i) = expect μ f+expect μ g := by + simp only [expect,mul_add,sum_add_distrib] +lemma expect_sub (μ : Law ι) (f g : ι → ℝ) : + expect μ (fun i => f i-g i) = expect μ f-expect μ g := by + simp only [expect,mul_sub,sum_sub_distrib] +lemma expect_move (μ : Law ι) (P : ι → Law κ) (f : κ → ℝ) : + expect (move μ P) f = expect μ (fun i => expect (P i) f) := by + simp only [expect,move_apply,sum_mul,mul_sum,mul_assoc] + rw [Finset.sum_comm] + +variable [DecidableEq ι] +lemma expect_delta (i : ι) (f : ι → ℝ) : expect (delta i) f = f i := by + simp [expect,delta] + +lemma spatialRow_expect (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (r : ℝ) (x : ℂ) (f : ι → ℝ) : + expect (spatialRow old target p hp0 hp1 r x) f = + f old+interpolate r (fun z => p z*(f (target z)-f old)) x := by + simp only [expect,spatialRow_formula,add_mul,sum_add_distrib] + rw [show (∑ i : ι, delta old i*f i) = f old from expect_delta old f] + congr 1 + simp_rw [← interpolate_mul_const] + rw [← interpolate_finset_sum] + congr 1 + funext z + simp only [mul_sub,sub_mul,sum_sub_distrib,mul_assoc,← mul_sum] + rw [show (∑ i : ι, delta (target z) i*f i) = f (target z) from expect_delta _ _, + show (∑ i : ι, delta old i*f i) = f old from expect_delta _ _] + +/-- An absorbing finite set gives exact drift equal to the off-diagonal +switch rate. Conditions concern only tents that actually meet the point. -/ +lemma spatialRow_absorbing (old : ι) (target : ℤ × ℤ → ι) (p : ℤ × ℤ → ℝ) + (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (r : ℝ) (x : ℂ) + (b : ι → ℝ) (hb : b old = 0 ∨ b old = 1) + (ht : ∀ z, hat r z x ≠ 0 → b (target z) = 0) + (hz : b old = 0 → ∀ z, hat r z x ≠ 0 → p z = 0) : + expect (spatialRow old target p hp0 hp1 r x) b+interpolate r p x = b old := by + rw [spatialRow_expect] + rcases hb with hb|hb + · have he : interpolate r p x = 0 := by + rw [interpolate_congr_on r x (hz hb),interpolate_const] + have he' : interpolate r (fun z => p z*(b (target z)-b old)) x = 0 := by + have hc : ∀ z, hat r z x ≠ 0 → p z*(b (target z)-b old) = 0 := by + intro z h; rw [ht z h,hb]; ring + rw [interpolate_congr_on r x hc,interpolate_const] + rw [he,he']; ring + · have hi : interpolate r (fun z => p z*(b (target z)-b old)) x = + interpolate r (fun z => p z*(-1)) x := by + apply interpolate_congr_on + intro z h; rw [ht z h,hb]; ring + rw [hi,interpolate_mul_const]; ring + +end FiniteLabels + +namespace ActualLabels +open FiniteLabels DyadicHats DirectionNeighbors ConeCoordinates + +def badWeight (anchor : ℂ) (n : Label) : ℝ := + if ‖(n:ℂ)-anchor‖ ≤ (1/200:ℝ) then 0 else 1 +lemma badWeight_cases (a : ℂ) (n : Label) : badWeight a n = 0 ∨ badWeight a n = 1 := by + unfold badWeight; split_ifs <;> simp +lemma badWeight_nonneg (a : ℂ) (n : Label) : 0 ≤ badWeight a n := by + rcases badWeight_cases a n with h|h <;> linarith +lemma badWeight_le_one (a : ℂ) (n : Label) : badWeight a n ≤ 1 := by + rcases badWeight_cases a n with h|h <;> linarith + +def rate (h : ℂ → ℂ) (r : ℝ) (x : ℂ) (n : Label) : ℝ := + interpolate r (switchChance h r n) x +lemma rate_nonneg (h : ℂ → ℂ) (r : ℝ) (x : ℂ) (n : Label) : 0 ≤ rate h r x n := + interpolate_nonneg r x (switchChance_nonneg h r n) +lemma rate_le_one (h : ℂ → ℂ) (r : ℝ) (x : ℂ) (n : Label) : rate h r x n ≤ 1 := + interpolate_le_const r x (switchChance_le_one h r n) + +theorem row_drift {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) {anchor : ℂ} + (ha : ‖theta h r q-anchor‖ ≤ 1/800) (old : Label) : + expect (row h r x old) (badWeight anchor)+rate h r x old = badWeight anchor old := by + apply spatialRow_absorbing _ _ _ _ _ _ _ _ (badWeight_cases _ _) + · intro z hz + have he := nearby_sample_close hr h q hx hE z hz + have ht := target_close h r z + have hn : ‖(target h r z:ℂ)-anchor‖ ≤ + ‖(target h r z:ℂ)-Theta h r z‖+‖Theta h r z-theta h r q‖+‖theta h r q-anchor‖ := by + simpa only [dist_eq_norm] using dist_triangle4 (target h r z:ℂ) (Theta h r z) (theta h r q) anchor + have ht' : ‖(target h r z:ℂ)-Theta h r z‖ < 1/2000 := by simpa only [norm_sub_rev] using ht + exact ite_eq_left (by linarith) + · intro hb z hz + have hba : ‖(old:ℂ)-anchor‖ ≤ 1/200 := by + by_contra hn + unfold badWeight at hb + rw [ite_eq_right hn] at hb + norm_num at hb + have he := nearby_sample_close hr h q hx hE z hz + apply probability_eq_zero + have hn : ‖(old:ℂ)-Theta h r z‖ ≤ + ‖(old:ℂ)-anchor‖+‖anchor-theta h r q‖+‖theta h r q-Theta h r z‖ := by + simpa only [dist_eq_norm] using dist_triangle4 (old:ℂ) anchor (theta h r q) (Theta h r z) + have he' : ‖theta h r q-Theta h r z‖ ≤ 1/1000 := by simpa only [norm_sub_rev] using he + have ha' : ‖anchor-theta h r q‖ ≤ 1/800 := by simpa only [norm_sub_rev] using ha + linarith + +lemma law_drift {r : ℝ} (hr : 0 < r) (h : ℂ → ℂ) (q : ℤ × ℤ) + {x : ℂ} (hx : boxNorm (x-point r q) ≤ 50*r) + (hE : energy h r q ≤ (1/1000:ℝ)^2) {anchor : ℂ} + (ha : ‖theta h r q-anchor‖ ≤ 1/800) (μ : Law Label) : + expect (move μ (row h r x)) (badWeight anchor)+expect μ (rate h r x) = + expect μ (badWeight anchor) := by + rw [expect_move,← expect_add] + congr 1 + funext old + exact row_drift hr h q hx hE ha old + +open FiniteLabels DyadicHats DirectionNeighbors Finset + +def switchCost (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) : ℕ → ℝ + | 0 => 1 + | k+1 => expect (marginal h r k x) (rate h (r (k+1)) x) + +lemma switchCost_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (k : ℕ) : + 0 ≤ switchCost h r x k := by + cases k with + | zero => exact zero_le_one + | succ k => exact FiniteLabels.expect_nonneg _ (rate_nonneg h (r (k+1)) x) +lemma switchCost_le_one (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (k : ℕ) : + switchCost h r x k ≤ 1 := by + cases k with + | zero => exact le_rfl + | succ k => exact expect_le_one _ (rate_le_one h (r (k+1)) x) + +/-- A telescoping estimate between arbitrary birth and death times. These are +geometric low-energy assumptions on a path, not a switch-budget premise. -/ +theorem switchCost_sum (h : ℂ → ℂ) (r : ℕ → ℝ) (q : ℕ → ℤ × ℤ) (x : ℂ) + (anchor : ℕ → ℂ) (exceptional : ℕ → Bool) {b m : ℕ} (hbm : b ≤ m) + (hr : ∀ k ∈ Finset.Ico b m, 0 < r (k+1)) + (hx : ∀ k ∈ Finset.Ico b m, boxNorm (x-point (r (k+1)) (q (k+1))) ≤ 50*r (k+1)) + (hE : ∀ k ∈ Finset.Ico b m, exceptional (k+1) = false → + energy h (r (k+1)) (q (k+1)) ≤ (1/1000:ℝ)^2) + (ha : ∀ k ∈ Finset.Ico b m, exceptional (k+1) = false → + anchor (k+1) = anchor k ∧ ‖theta h (r (k+1)) (q (k+1))-anchor k‖ ≤ 1/800) : + (∑ k ∈ Finset.Ico b m, switchCost h r x (k+1)) ≤ + 1+2*∑ k ∈ Finset.Ico b m, if exceptional (k+1) then (1:ℝ) else 0 := by + let v : ℕ → ℝ := fun k => expect (marginal h r k x) (badWeight (anchor k)) + have hv0 (k : ℕ) : 0 ≤ v k := FiniteLabels.expect_nonneg _ (badWeight_nonneg _) + have hv1 (k : ℕ) : v k ≤ 1 := expect_le_one _ (badWeight_le_one _) + have hs (k : ℕ) (hk : k ∈ Finset.Ico b m) : switchCost h r x (k+1) ≤ + v k-v (k+1)+2*(if exceptional (k+1) then (1:ℝ) else 0) := by + cases he : exceptional (k+1) with + | false => + obtain ⟨heq,hclose⟩ := ha k hk he + have hd := law_drift (hr k hk) h (q (k+1)) (hx k hk) (hE k hk he) hclose (marginal h r k x) + have hd' : v (k+1)+switchCost h r x (k+1) = v k := by + simpa only [v,marginal,switchCost,heq] using hd + simp only [Bool.false_eq_true,ite_false,mul_zero,add_zero] + linarith + | true => + simp only [ite_true,mul_one] + linarith [switchCost_le_one h r x (k+1),hv0 k,hv1 (k+1)] + have hall := sum_le_sum hs + rw [sum_add_distrib,← mul_sum] at hall + have ht : (∑ k ∈ Finset.Ico b m, (v k-v (k+1))) = v b-v m := by + have hh := Finset.sum_Ico_sub (fun k => -v k) hbm + simpa only [neg_sub_neg] using hh + rw [ht] at hall + linarith [hv1 b,hv0 m] + +end ActualLabels + +namespace IntrinsicMarks +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] + +/-- Only paths ending in a nonzero terminal vector can carry particles. -/ +def activePath : Tree ι E → List ι → Prop + | .leaf v, [] => v ≠ 0 + | .leaf _, _::_ => False + | .branch _, [] => False + | .branch t, i::p => activePath (t i) p + +omit [Fintype ι] in +lemma activePath_valid {t : Tree ι E} {p : List ι} (h : activePath t p) : validPath t p := by + induction p generalizing t with + | nil => cases t <;> simp_all [activePath,validPath] + | cons i p ih => cases t with + | leaf v => exact h.elim + | branch t => exact ih h + +lemma rootEval_mono_active (t : Tree ι E) {F G : List ι → ℝ} + (h : ∀ p, activePath t p → F p ≤ G p) : rootEval t F ≤ rootEval t G := by + induction t generalizing F G with + | leaf v => + by_cases hv : v = 0 + · simp [rootEval,hv] + · exact mul_le_mul_of_nonneg_left (h [] hv) (norm_nonneg v) + | branch t ih => + apply mul_le_mul_of_nonneg_left _ (survival_nonneg t) + exact Finset.sum_le_sum fun i _ => ih i (fun p hp => h (i::p) hp) + +lemma lateEval_mono_active (t : Tree ι E) {F G : List ι → ℕ → ℝ} + (h : ∀ p b, activePath t p → b ≤ p.length → F p b ≤ G p b) : lateEval t F ≤ lateEval t G := by + induction t generalizing F G with + | leaf v => rfl + | branch t ih => + unfold lateEval + apply add_le_add + · apply mul_le_mul_of_nonneg_left _ (sub_nonneg.mpr (survival_le_one t)) + exact Finset.sum_le_sum fun i _ => rootEval_mono_active (t i) (fun p hp => h (i::p) 1 hp (by simp)) + · exact Finset.sum_le_sum fun i _ => ih i (fun p b hp hb => h (i::p) (b+1) hp (by simpa using Nat.succ_le_succ hb)) + +lemma particleEval_mono_active (t : Tree ι E) {F G : List ι → ℕ → ℝ} + (h : ∀ p b, activePath t p → b ≤ p.length → F p b ≤ G p b) : particleEval t F ≤ particleEval t G := + add_le_add (rootEval_mono_active t (fun p hp => h p 0 hp (Nat.zero_le _))) + (lateEval_mono_active t h) + +/-- The subtree at a prefix (values beyond terminal nodes are immaterial). -/ +def atPath : Tree ι E → List ι → Tree ι E + | t, [] => t + | .leaf v, _::_ => .leaf v + | .branch t, i::p => atPath (t i) p + +omit [Fintype ι] in +lemma active_append {t : Tree ι E} {p q : List ι} (h : activePath t (p++q)) : + activePath (atPath t p) q := by + induction p generalizing t with + | nil => simpa only [atPath,List.nil_append] using h + | cons i p ih => + cases t with + | leaf v => exact h.elim + | branch t => exact ih h + +end IntrinsicMarks + +namespace ActualMarkTrees +open DyadicHats IntrinsicMarks + +def lastVertex {N : ℕ} (q : Grid N) : List (Grid N) → Grid N + | [] => q + | s::p => lastVertex s p + +def pathWeight {N : ℕ} (q : Grid N) : List (Grid N) → ℝ + | [] => 1 + | s::p => step q s*pathWeight s p + +lemma pathWeight_nonneg {N : ℕ} (q : Grid N) (p : List (Grid N)) : 0 ≤ pathWeight q p := by + induction p generalizing q with + | nil => exact zero_le_one + | cons s p ih => exact mul_nonneg (step_nonneg q s) (ih s) + +lemma active_length {N : ℕ} (v : Grid N → ℂ) {k : ℕ} {b : ℝ} {q : Grid N} + {p : List (Grid N)} (h : activePath (tree v k b q) p) : p.length = k := by + induction k generalizing b q p with + | zero => cases p with + | nil => rfl + | cons i p => exact h.elim + | succ k ih => cases p with + | nil => exact h.elim + | cons i p => exact congrArg Nat.succ (ih h) + +lemma active_ne_zero {N : ℕ} (v : Grid N → ℂ) {k : ℕ} {b : ℝ} {q : Grid N} + {p : List (Grid N)} (h : activePath (tree v k b q) p) : b ≠ 0 := by + induction k generalizing b q p with + | zero => cases p with + | nil => + intro hb + simp [tree,activePath,hb] at h + | cons i p => exact h.elim + | succ k ih => cases p with + | nil => exact h.elim + | cons i p => exact (mul_ne_zero_iff.mp (ih h)).1 + +lemma atPath_tree {N : ℕ} (v : Grid N → ℂ) {k : ℕ} (b : ℝ) (q : Grid N) + (p : List (Grid N)) (hp : p.length ≤ k) : + atPath (tree v k b q) p = tree v (k-p.length) (b*pathWeight q p) (lastVertex q p) := by + induction p generalizing k b q with + | nil => simp [atPath,pathWeight,lastVertex] + | cons i p ih => + cases k with + | zero => simp at hp + | succ k => + simp only [tree,atPath] + rw [ih (b*step q i) i (by simpa using hp)] + simp only [List.length_cons,Nat.succ_sub_succ_eq_sub,pathWeight,lastVertex,mul_assoc] + +lemma active_hat_support {N : ℕ} (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {k : ℕ} {b : ℝ} {q : Grid N} {p : List (Grid N)} + (h : activePath (tree v k b q) p) {x : ℂ} (hx : hat r (lastVertex q p) x ≠ 0) : + hat (scale r k) q x ≠ 0 := by + induction k generalizing b q p with + | zero => cases p with + | nil => simpa [lastVertex,scale] using hx + | cons i p => exact h.elim + | succ k ih => cases p with + | nil => exact h.elim + | cons i p => + have hi := ih h hx + have hs := (mul_ne_zero_iff.mp (active_ne_zero v h)).2 + rw [scale_succ] + exact step_support (scale_pos hr k) hs hi + +lemma lastVertex_append {N : ℕ} (q : Grid N) (p s : List (Grid N)) : + lastVertex q (p++s) = lastVertex (lastVertex q p) s := by + induction p generalizing q with + | nil => rfl + | cons i p ih => exact ih i + +/-- Actual spatial locality, at every prefix of every positive-mass particle +path, for every terminal position in the genuine finest hat support. -/ +theorem active_prefix_locality {N : ℕ} (v : Grid N → ℂ) {r : ℝ} (hr : 0 < r) + {k : ℕ} {b : ℝ} {q : Grid N} {p s : List (Grid N)} + (h : activePath (tree v k b q) (p++s)) {x : ℂ} + (hx : hat r (lastVertex q (p++s)) x ≠ 0) : + boxNorm (x-point (scale r (k-p.length)) (lastVertex q p)) < scale r (k-p.length) := by + have hp : p.length ≤ k := by have := active_length v h; simp only [List.length_append] at this; omega + have hh := active_append h + rw [atPath_tree v b q p hp] at hh + rw [lastVertex_append] at hx + exact (hat_ne_zero_iff (scale_pos hr _) _ _).mp (active_hat_support v hr hh hx) + +end ActualMarkTrees + +namespace IntrinsicMarks +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +def reset (δ : ℝ) (v n : E) : E := if δ < ‖v-n‖ then v else n + +def anchor (e : E) (δ : ℝ) : Tree ι E → E → List ι → E + | .leaf v,n,_ => reset δ (direction e v) n + | .branch t,n,[] => reset δ (direction e (∑ i,vector (t i))) n + | .branch t,n,i::p => anchor e δ (t i) (reset δ (direction e (∑ j,vector (t j))) n) p + +def rootAnchor (e : E) (δ : ℝ) (t : Tree ι E) : List ι → E := + anchor e δ t (direction e (vector t)) + +lemma anchor_zero (e : E) (δ : ℝ) (t : Tree ι E) (n : E) + (hm : markIndicator e δ t n [] = 0) : + anchor e δ t n [] = n ∧ ‖direction e (vector t)-n‖ ≤ δ := by + cases t with + | leaf v => + have hc : ¬δ < ‖direction e v-n‖ := by + intro hc + simp [markIndicator,hc] at hm + exact ⟨by simp [anchor,reset,hc],le_of_not_gt hc⟩ + | branch t => + have hc : ¬δ < ‖direction e (∑ i,vector (t i))-n‖ := by + intro hc + simp [markIndicator,hc] at hm + exact ⟨by simp [anchor,reset,hc],le_of_not_gt hc⟩ + +lemma anchor_step (e : E) (δ : ℝ) (t : Tree ι E) (n : E) (p : List ι) + (hp : validPath t p) {s : ℕ} (hs : s < p.length) + (hm : markIndicator e δ t n (p.take (s+1)) = 0) : + anchor e δ t n (p.take (s+1)) = anchor e δ t n (p.take s) ∧ + ‖direction e (vector (atPath t (p.take (s+1))))-anchor e δ t n (p.take s)‖ ≤ δ := by + induction p generalizing t n s with + | nil => simp at hs + | cons i p ih => + cases t with + | leaf v => simp [validPath] at hp + | branch t => + cases s with + | zero => + have hm' : markIndicator e δ (t i) (reset δ (direction e (∑ j,vector (t j))) n) [] = 0 := by + simpa only [List.take_succ_cons,List.take_zero,markIndicator,reset] using hm + simpa only [List.take_succ_cons,List.take_zero,anchor,atPath] using + anchor_zero e δ (t i) (reset δ (direction e (∑ j,vector (t j))) n) hm' + | succ s => + simp only [List.length_cons,Nat.succ_lt_succ_iff] at hs + simpa only [List.take_succ_cons,anchor,atPath] using + ih (t i) (reset δ (direction e (∑ j,vector (t j))) n) hp hs hm + +lemma rootMark_cons (e : E) {δ : ℝ} (hδ : 0 ≤ δ) (t : Tree ι E) (i : ι) (p : List ι) : + rootMarkIndicator e δ t (i::p) = markIndicator e δ t (direction e (vector t)) (i::p) := by + cases t <;> simp [rootMarkIndicator,markIndicator,vector,not_lt_of_ge hδ] + +lemma rootAnchor_step (e : E) {δ : ℝ} (hδ : 0 ≤ δ) (t : Tree ι E) (p : List ι) + (hp : validPath t p) {s : ℕ} (hs : s < p.length) + (hm : rootMarkIndicator e δ t (p.take (s+1)) = 0) : + rootAnchor e δ t (p.take (s+1)) = rootAnchor e δ t (p.take s) ∧ + ‖direction e (vector (atPath t (p.take (s+1))))-rootAnchor e δ t (p.take s)‖ ≤ δ := by + apply anchor_step e δ t (direction e (vector t)) p hp hs + cases p with + | nil => simp at hs + | cons i p => simpa only [List.take_succ_cons,rootMark_cons e hδ] using hm + +lemma markIndicator_cases (e : E) (δ : ℝ) (t : Tree ι E) (n : E) (p : List ι) : + markIndicator e δ t n p = 0 ∨ markIndicator e δ t n p = 1 := by + induction p generalizing t n with + | nil => cases t <;> simp only [markIndicator] <;> split_ifs <;> simp + | cons i p ih => + cases t with + | leaf v => exact Or.inl rfl + | branch t => exact ih _ _ + +lemma rootMarkIndicator_cases (e : E) (δ : ℝ) (t : Tree ι E) (p : List ι) : + rootMarkIndicator e δ t p = 0 ∨ rootMarkIndicator e δ t p = 1 := by + cases p with + | nil => cases t <;> exact Or.inr rfl + | cons i p => cases t with + | leaf v => exact Or.inl rfl + | branch t => exact markIndicator_cases e δ (t i) _ p + +lemma direction_smul_pos (e v : E) {b : ℝ} (hb : 0 < b) : direction e (b • v) = direction e v := by + by_cases hv : v = 0 + · simp [hv,direction] + · have hb0 := hb.ne' + simp only [direction,smul_eq_zero,hb0,hv,or_self,ite_false,norm_smul, + Real.norm_eq_abs,abs_of_pos hb,mul_inv_rev,smul_smul] + congr 1 + field_simp + +omit [Fintype ι] [InnerProductSpace ℝ E] in +lemma pathCharge_sum (C : List ι → ℝ) (p : List ι) (b : ℕ) : + pathCharge C p b = ∑ s ∈ Finset.Ico b (p.length+1), C (p.take s) := by + induction p generalizing C b with + | nil => cases b <;> simp [pathCharge] + | cons i p ih => + cases b with + | zero => + simp only [pathCharge,ih,List.length_cons,Nat.Ico_zero_eq_range] + rw [Finset.sum_range_succ' (fun s => C ((i::p).take s)) (p.length+1)] + simp only [List.take_succ_cons,List.take_zero] + exact add_comm _ _ + | succ b => + simp only [pathCharge,ih,List.length_cons] + rw [← Finset.sum_Ico_add' (fun s => C ((i::p).take s)) b (p.length+1) 1] + simp only [List.take_succ_cons] + +end IntrinsicMarks + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/IntrinsicMarks1.lean b/lean/OAI/Analysis/SignedDisk/IntrinsicMarks1.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb66ef99f11ef4d8e9a7deac9673f89888a01ce5 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/IntrinsicMarks1.lean @@ -0,0 +1,401 @@ +import OAI.Analysis.SignedDisk.PlanePotential2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace + +noncomputable section + +namespace SignedDisk + +namespace IntrinsicMarks +open Finset +variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [Fintype ι] + +def validPath : Tree ι E → List ι → Prop + | .leaf _, p => p = [] + | .branch _, [] => False + | .branch t, i::p => validPath (t i) p + +omit [InnerProductSpace ℝ E] in +lemma rootEval_mono_on (t : Tree ι E) {F G : List ι → ℝ} + (h : ∀ p, validPath t p → F p ≤ G p) : rootEval t F ≤ rootEval t G := by + induction t generalizing F G with + | leaf v => exact mul_le_mul_of_nonneg_left (h [] rfl) (norm_nonneg _) + | branch t ih => + apply mul_le_mul_of_nonneg_left _ (survival_nonneg t) + exact sum_le_sum fun i _ => ih i (fun p hp => h (i::p) hp) + +omit [InnerProductSpace ℝ E] in +lemma lateEval_mono_on (t : Tree ι E) {F G : List ι → ℕ → ℝ} + (h : ∀ p b, validPath t p → b ≤ p.length → F p b ≤ G p b) : + lateEval t F ≤ lateEval t G := by + induction t generalizing F G with + | leaf v => rfl + | branch t ih => + unfold lateEval + apply add_le_add + · apply mul_le_mul_of_nonneg_left _ (sub_nonneg.mpr (survival_le_one t)) + exact sum_le_sum fun i _ => rootEval_mono_on (t i) (fun p hp => h (i::p) 1 hp (by simp)) + · exact sum_le_sum fun i _ => ih i (fun p b hp hb => h (i::p) (b+1) hp (by simpa using Nat.succ_le_succ hb)) + +omit [InnerProductSpace ℝ E] in +/-- Particle monotonicity requires bounds only on genuine terminal paths and +legal birth times; the explicit construction has no mass elsewhere. -/ +theorem particleEval_mono_on (t : Tree ι E) {F G : List ι → ℕ → ℝ} + (h : ∀ p b, validPath t p → b ≤ p.length → F p b ≤ G p b) : + particleEval t F ≤ particleEval t G := by + exact add_le_add (rootEval_mono_on t (fun p hp => h p 0 hp (Nat.zero_le _))) + (lateEval_mono_on t h) + +/-- Intrinsic marks as an actual function on prefixes, with first-crossing +reset. Prefixes outside the tree have zero charge. -/ +def markIndicator (e : E) (δ : ℝ) : Tree ι E → E → List ι → ℝ + | .leaf v, n, [] => if δ < ‖direction e v-n‖ then 1 else 0 + | .leaf _, _, _::_ => 0 + | .branch t, n, [] => if δ < ‖direction e (∑ i, vector (t i))-n‖ then 1 else 0 + | .branch t, n, i::p => + let v := ∑ j, vector (t j) + markIndicator e δ (t i) (if δ < ‖direction e v-n‖ then direction e v else n) p + +def rootMarkIndicator (e : E) (δ : ℝ) : Tree ι E → List ι → ℝ + | _, [] => 1 + | .leaf _, _::_ => 0 + | .branch t, i::p => markIndicator e δ (t i) (direction e (∑ j, vector (t j))) p + +lemma marked_occupancy (e : E) (δ : ℝ) (t : Tree ι E) (n : E) : + nodeCharge t (markIndicator e δ t n) = markedCost e δ t n := by + induction t generalizing n with + | leaf v => simp only [nodeCharge,markIndicator,markedCost]; split_ifs <;> simp + | branch t ih => + simp only [nodeCharge,markIndicator,markedCost] + split_ifs with h + · simp only [mul_one] + congr 1 + exact sum_congr rfl (fun i _ => ih i _) + · simp only [mul_zero,zero_add] + exact sum_congr rfl (fun i _ => ih i _) + +lemma root_marked_occupancy (e : E) (δ : ℝ) (t : Tree ι E) : + nodeCharge t (rootMarkIndicator e δ t) = costWithRoot e δ t := by + cases t with + | leaf v => simp [nodeCharge,rootMarkIndicator,costWithRoot] + | branch t => simp only [nodeCharge,rootMarkIndicator,costWithRoot,mul_one,marked_occupancy] + +theorem particle_mark_budget {e : E} (he : ‖e‖ = 1) {δ : ℝ} (hδ : 0 < δ) + (t : Tree ι E) : + particleEval t (pathCharge (rootMarkIndicator e δ t)) ≤ + (1+2/δ^2)*terminalMass t := by + rw [particle_occupancy,root_marked_occupancy] + exact costWithRoot_le he hδ t + +/-- Turning a genuine pathwise switch bound into the global budget uses exact +occupancy, rather than a false assumption that every particle is born at a root. -/ +theorem particle_switch_budget {e : E} (he : ‖e‖ = 1) {δ c : ℝ} (hδ : 0 < δ) + (t : Tree ι E) (energy : List ι → ℝ) (switches : List ι → ℕ → ℝ) + (hpath : ∀ p b, validPath t p → b ≤ p.length → switches p b ≤ + 1+2*pathCharge (rootMarkIndicator e δ t) p b+c*pathCharge energy p b) : + particleEval t switches ≤ (3+4/δ^2)*terminalMass t+c*nodeCharge t energy := by + have h := particleEval_mono_on t hpath + simp only [particleEval_add,particleEval_smul,particleEval_const,particle_occupancy, + root_marked_occupancy] at h + have hm := costWithRoot_le he hδ t + calc + _ ≤ terminalMass t*1 + 2*((1+2/δ^2)*terminalMass t)+c*nodeCharge t energy := + h.trans (by gcongr) + _ = _ := by ring + +end IntrinsicMarks + +namespace SignedAssembly +open Finset +open scoped RealInnerProductSpace +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +structure RowJet (ι E : Type*) [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] where + law : FiniteLabels.Law ι + grad : ι → E + total_grad : ∑ i, grad i = 0 + +inductive JetTree (ι E : Type*) [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] where + | leaf : E → JetTree ι E + | branch : RowJet ι E → E → ℝ → (ι → JetTree ι E) → JetTree ι E + +def mean : JetTree ι E → E + | .leaf v => v + | .branch row _ _ t => ∑ i, row.law i • mean (t i) + +def flux : JetTree ι E → ℝ + | .leaf _ => 0 + | .branch row _ _ t => ∑ i, ⟪row.grad i,mean (t i)⟫ + ∑ i, row.law i*flux (t i) + +/-- Product-rule expansion over all terminal label histories. The carried mass +and its derivative are updated by the exact Leibniz rule. -/ +def pathFlux : JetTree ι E → ℝ → E → ℝ + | .leaf v, _, G => ⟪G,v⟫ + | .branch row _ _ t, q, G => + ∑ i, pathFlux (t i) (q*row.law i) (q • row.grad i+row.law i • G) + +lemma pathFlux_eq (t : JetTree ι E) (q : ℝ) (G : E) : + pathFlux t q G = ⟪G,mean t⟫+q*flux t := by + induction t generalizing q G with + | leaf v => simp [pathFlux,mean,flux] + | branch row c B t ih => + simp only [pathFlux,ih,inner_add_left,real_inner_smul_left,sum_add_distrib, + ← mul_sum,mean,flux,inner_sum,real_inner_smul_right] + simp only [mul_assoc, ← mul_sum] + ring + +lemma terminal_flux (t : JetTree ι E) : pathFlux t 1 0 = flux t := by + rw [pathFlux_eq,inner_zero_left,one_mul,zero_add] + +def TerminalBound : JetTree ι E → E → ℝ → Prop + | .leaf v, c, B => ‖v-c‖ ≤ B + | .branch _ _ _ t, c, B => ∀ i, TerminalBound (t i) c B + +lemma mean_bound (t : JetTree ι E) (c : E) (B : ℝ) (h : TerminalBound t c B) : + ‖mean t-c‖ ≤ B := by + induction t with + | leaf v => exact h + | branch row _ _ t ih => + have he : mean (.branch row (0:E) 0 t)-c = ∑ i, row.law i • (mean (t i)-c) := by + simp only [mean,smul_sub,sum_sub_distrib,← sum_smul,row.law.total,one_smul] + change ‖mean (.branch row (0:E) 0 t)-c‖ ≤ B + rw [he] + calc + _ ≤ ∑ i, ‖row.law i • (mean (t i)-c)‖ := norm_sum_le _ _ + _ = ∑ i, row.law i*‖mean (t i)-c‖ := by + simp only [norm_smul,Real.norm_eq_abs,abs_of_nonneg (row.law.nonneg _)] + _ ≤ ∑ i, row.law i*B := sum_le_sum fun i _ => + mul_le_mul_of_nonneg_left (ih i (h i)) (row.law.nonneg i) + _ = B := by rw [← sum_mul,row.law.total,one_mul] + +/-- This is the exact zero-row-sum cancellation. No unsigned path-potential +bound is used and the parent prefix may be arbitrarily large. -/ +lemma prefix_cancellation (row : RowJet ι E) (v : ι → E) (c : E) : + (∑ i, ⟪row.grad i,v i⟫) = ∑ i, ⟪row.grad i,v i-c⟫ := by + simp only [inner_sub_right,sum_sub_distrib,← sum_inner,row.total_grad,inner_zero_left,sub_zero] + +lemma row_flux_bound (row : RowJet ι E) (v : ι → E) (c : E) (B : ℝ) + (h : ∀ i, ‖v i-c‖ ≤ B) : + |∑ i, ⟪row.grad i,v i⟫| ≤ (∑ i, ‖row.grad i‖)*B := by + rw [prefix_cancellation row v c] + calc + _ ≤ ∑ i, |⟪row.grad i,v i-c⟫| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ i, ‖row.grad i‖*B := sum_le_sum fun i _ => + (abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_left (h i) (norm_nonneg _)) + _ = _ := by rw [← sum_mul] + +def Controlled : JetTree ι E → Prop + | .leaf _ => True + | .branch _ c B t => (∀ i, TerminalBound (t i) c B) ∧ ∀ i, Controlled (t i) + +def cost : JetTree ι E → ℝ + | .leaf _ => 0 + | .branch row _ B t => (∑ i, ‖row.grad i‖)*B+∑ i, row.law i*cost (t i) + +/-- Full finite-history signed flux estimate, with all stochastic prefix +weights kept. The node bound is the tail oscillation, not the old envelope. -/ +theorem signed_flux_bound (t : JetTree ι E) (ht : Controlled t) : + |pathFlux t 1 0| ≤ cost t := by + rw [terminal_flux] + induction t with + | leaf v => simp [flux,cost] + | branch row c B t ih => + change |(∑ i, ⟪row.grad i,mean (t i)⟫)+∑ i, row.law i*flux (t i)| ≤ _ + calc + _ ≤ |∑ i, ⟪row.grad i,mean (t i)⟫|+|∑ i, row.law i*flux (t i)| := abs_add_le _ _ + _ ≤ (∑ i, ‖row.grad i‖)*B+∑ i, row.law i*cost (t i) := by + apply add_le_add (row_flux_bound row (fun i => mean (t i)) c B + (fun i => mean_bound (t i) c B (ht.1 i))) + calc + _ ≤ ∑ i, |row.law i*flux (t i)| := abs_sum_le_sum_abs _ _ + _ = ∑ i, row.law i*|flux (t i)| := by + simp only [abs_mul,abs_of_nonneg (row.law.nonneg _)] + _ ≤ _ := sum_le_sum fun i _ => mul_le_mul_of_nonneg_left (ih i (ht.2 i)) (row.law.nonneg i) + _ = _ := rfl + +end SignedAssembly + +open scoped ContDiff +namespace PlanePotential +lemma potential_norm_lintegral {L : ℂ → ℂ} (hL : Measurable L) {b : ℂ → ℂ} + (hb : Integrable b) : + (∫⁻ y, ‖⟪L y,b y⟫‖ₑ) ≤ + ∫⁻ y, ENNReal.ofReal ‖L y‖ ∂volume.withDensity (fun y => ENNReal.ofReal ‖b y‖) := by + rw [lintegral_withDensity_eq_lintegral_mul₀' hb.aestronglyMeasurable.norm.aemeasurable.ennreal_ofReal + hL.norm.ennreal_ofReal.aemeasurable] + apply lintegral_mono + intro y + dsimp only [Pi.mul_apply] + rw [← ofReal_norm] + change ENNReal.ofReal ‖⟪L y,b y⟫‖ ≤ ENNReal.ofReal ‖b y‖ * ENNReal.ofReal ‖L y‖ + rw [← ENNReal.ofReal_mul (norm_nonneg _)] + exact ENNReal.ofReal_le_ofReal ((norm_inner_le_norm _ _).trans_eq (mul_comm _ _)) + +lemma potential_integrable_of_density {L : ℂ → ℂ} (hL : Measurable L) {b : ℂ → ℂ} + (hb : Integrable b) + (hfinite : (∫⁻ y, ENNReal.ofReal ‖L y‖ ∂volume.withDensity (fun y => ENNReal.ofReal ‖b y‖)) < ⊤) : + Integrable (fun y => ⟪L y,b y⟫) := by + refine ⟨hL.aestronglyMeasurable.inner hb.aestronglyMeasurable,?_⟩ + rw [hasFiniteIntegral_iff_enorm] + exact (potential_norm_lintegral hL hb).trans_lt hfinite + +/-- Finiteness of the genuine singular integrals, obtained from the column +estimate itself. This justifies insertion of the finite vector decomposition. -/ +theorem kernel_potential_ae_integrable (μ : Measure ℂ) [SFinite μ] + {K : ℂ × ℂ → ℂ} (hK : Measurable K) {b : ℂ → ℂ} (hb : Integrable b) + {C : ℝ≥0∞} (hC : C < ⊤) + (hcol : ∀ᵐ y ∂volume.withDensity (fun y => ENNReal.ofReal ‖b y‖), + (∫⁻ x, (ENNReal.ofReal ‖K (x,y)‖)^(3/2:ℝ) ∂μ) ≤ C) : + ∀ᵐ x ∂μ, Integrable (fun y => ⟪K (x,y),b y⟫) := by + let ν := volume.withDensity (fun y => ENNReal.ofReal ‖b y‖) + have hm : ν univ = ENNReal.ofReal (∫ y, ‖b y‖) := by + dsimp only [ν] + rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ] + exact (ofReal_integral_eq_lintegral_ofReal hb.norm + (ae_of_all _ (fun _ => norm_nonneg _))).symm + have hν : ν univ < ⊤ := by rw [hm]; exact ENNReal.ofReal_lt_top + have : IsFiniteMeasure ν := ⟨hν⟩ + have hlp := kernel_column_lp μ ν hK.norm.ennreal_ofReal hcol + have hfinite : (∫⁻ x, (∫⁻ y, ENNReal.ofReal ‖K (x,y)‖ ∂ν)^(3/2:ℝ) ∂μ) ≠ ⊤ := + ne_of_lt (hlp.trans_lt (ENNReal.mul_lt_top hC (ENNReal.rpow_lt_top_of_nonneg (by norm_num) hν.ne))) + have hae := ae_lt_top (hK.norm.ennreal_ofReal.lintegral_prod_right.pow_const _) hfinite + filter_upwards [hae] with x hx + apply potential_integrable_of_density (hK.comp (measurable_const.prodMk measurable_id)) hb + apply lt_top_iff_ne_top.mpr + intro htop + change (∫⁻ y, ENNReal.ofReal ‖K (x,y)‖ ∂ν) = ⊤ at htop + rw [htop,ENNReal.top_rpow_of_pos (by norm_num : (0:ℝ) < 3/2)] at hx + exact (lt_irrefl _ hx) + +lemma green_root_column {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X Y B : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) (hXY : 0 < X+Y) {y : ℂ} (hy : ‖y‖ ≤ Y) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, (ENNReal.ofReal ‖green ψ x y‖)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(2*(X+Y))^(1/2:ℝ))) := by + apply kernel_near_three_halves (by positivity) (by positivity : 0 < 2*(X+Y)) y + · intro x hx + rw [mem_ball,dist_eq_norm] + have hn := norm_sub_le x y + change ‖x‖ ≤ X at hx + linarith + · intro x hx + exact green_size_all hψm hψs hψB hM hB hx + +lemma green_ae_integrable {ψ : ℂ → ℝ} {β : ℂ → ℂ} + (hψm : Measurable ψ) {R X Y B : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) (hXY : 0 < X+Y) + (hβ : Integrable β) (hβs : ∀ y, β y ≠ 0 → ‖y‖ ≤ Y) : + ∀ᵐ x ∂volume.restrict {x : ℂ | ‖x‖ ≤ X}, Integrable (fun y => ⟪green ψ x y,β y⟫) := by + apply kernel_potential_ae_integrable _ (green_measurable ψ hψm) hβ ENNReal.ofReal_lt_top + rw [ae_withDensity_iff' hβ.aestronglyMeasurable.norm.aemeasurable.ennreal_ofReal] + filter_upwards with y hy + apply green_root_column hψm hψs hψB hM hB hXY + apply hβs y + intro hy0 + simp [hy0] at hy + +lemma green_root_lp {ψ : ℂ → ℝ} {β : ℂ → ℂ} + (hψm : Measurable ψ) {R X Y B : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) (hXY : 0 < X+Y) + (hβ : Integrable β) (hβs : ∀ y, β y ≠ 0 → ‖y‖ ≤ Y) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, (ENNReal.ofReal |∫ y, ⟪green ψ x y,β y⟫|)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(2*(X+Y))^(1/2:ℝ))) * + (ENNReal.ofReal (∫ y, ‖β y‖))^(3/2:ℝ) := by + let ν := volume.withDensity (fun y => ENNReal.ofReal ‖β y‖) + have hν : ν univ = ENNReal.ofReal (∫ y, ‖β y‖) := by + dsimp only [ν] + rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ] + exact (ofReal_integral_eq_lintegral_ofReal hβ.norm + (ae_of_all _ (fun _ => norm_nonneg _))).symm + have : IsFiniteMeasure ν := ⟨by rw [hν]; exact ENNReal.ofReal_lt_top⟩ + have hm := green_measurable ψ hψm + have hcol := kernel_column_lp (volume.restrict {x : ℂ | ‖x‖ ≤ X}) ν hm.norm.ennreal_ofReal + (C := ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(2*(X+Y))^(1/2:ℝ)))) (by + rw [ae_withDensity_iff' hβ.aestronglyMeasurable.norm.aemeasurable.ennreal_ofReal] + filter_upwards with y hy + apply green_root_column hψm hψs hψB hM hB hXY + apply hβs y + intro hy0 + simp [hy0] at hy) + rw [hν] at hcol + apply le_trans _ hcol + apply lintegral_mono + intro x + exact ENNReal.rpow_le_rpow (potential_domination + (hm.comp (measurable_const.prodMk measurable_id)) hβ) (by norm_num) + +lemma eLpNorm_three_halves_bound (μ : Measure ℂ) {F : ℂ → ℝ} {K m : ℝ≥0∞} + (h : (∫⁻ x, (ENNReal.ofReal |F x|)^(3/2:ℝ) ∂μ) ≤ K*m^(3/2:ℝ)) : + eLpNorm' F (3/2:ℝ) μ ≤ K^(2/3:ℝ)*m := by + rw [eLpNorm'_eq_lintegral_enorm] + norm_num only [one_div_div] + have hpow := ENNReal.rpow_le_rpow h (by norm_num : (0:ℝ) ≤ 2/3) + rw [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num : (0:ℝ) ≤ 2/3),← ENNReal.rpow_mul] at hpow + norm_num only [show (3/2:ℝ)*(2/3)=1 by norm_num,ENNReal.rpow_one] at hpow + simpa only [← ofReal_norm,Real.norm_eq_abs] using hpow + +lemma potential_aestronglyMeasurable (μ : Measure ℂ) {K : ℂ × ℂ → ℂ} + (hK : Measurable K) {β : ℂ → ℂ} (hβ : Integrable β) : + AEStronglyMeasurable (fun x => ∫ y, ⟪K (x,y),β y⟫) μ := by + have h : AEStronglyMeasurable (fun z : ℂ × ℂ => @inner ℝ ℂ _ (K z) (β z.2)) (μ.prod volume) := + hK.aestronglyMeasurable.inner hβ.aestronglyMeasurable.comp_snd + exact h.integral_prod_right' + +lemma potential_memLp_of_bound (μ : Measure ℂ) {K : ℂ × ℂ → ℂ} + (hK : Measurable K) {β : ℂ → ℂ} (hβ : Integrable β) {C m : ℝ≥0∞} + (hC : C < ⊤) (hm : m < ⊤) + (h : (∫⁻ x, (ENNReal.ofReal |∫ y, ⟪K (x,y),β y⟫|)^(3/2:ℝ) ∂μ) ≤ C*m^(3/2:ℝ)) : + MemLp (fun x => ∫ y, ⟪K (x,y),β y⟫) (3/2) μ := by + rw [memLp_iff, eLpNorm_eq_eLpNorm' (by norm_num : (3/2:ℝ≥0∞) ≠ 0) + (by finiteness) (potential_aestronglyMeasurable μ hK hβ)] + norm_num only [ENNReal.toReal_div, ENNReal.toReal_ofNat] + exact (eLpNorm_three_halves_bound μ h).trans_lt + (ENNReal.mul_lt_top (ENNReal.rpow_lt_top_of_nonneg (by norm_num) hC.ne) hm) + +/-- A genuine fixed smooth probability cutoff. Its finite size and Lipschitz +constants depend on no input, no dyadic level and no number of scales. -/ +theorem exists_kernel_cutoff : ∃ (ψ : ℂ → ℝ) (B L : ℝ), + 0 ≤ B ∧ 0 ≤ L ∧ ContDiff ℝ ∞ ψ ∧ HasCompactSupport ψ ∧ + (∫ x, ψ x) = 1 ∧ (∀ x, ψ x ≠ 0 → ‖x‖ ≤ 1) ∧ + (∀ x, |ψ x| ≤ B) ∧ (∀ x y, |ψ x-ψ y| ≤ L*‖x-y‖) := by + let φ : ContDiffBump (0:ℂ) := ⟨1/2,1,by norm_num,by norm_num⟩ + let ψ := φ.normed volume + have hc : HasCompactSupport ψ := φ.hasCompactSupport_normed + have hd : ContDiff ℝ ∞ ψ := φ.contDiff_normed + obtain ⟨B,hB⟩ := hc.exists_bound_of_continuous hd.continuous + obtain ⟨L,hL⟩ := hd.lipschitzWith_of_hasCompactSupport hc (by simp) + refine ⟨ψ,B,L,le_trans (norm_nonneg (ψ 0)) (hB 0),L.coe_nonneg,hd,hc, + φ.integral_normed,?_,?_,?_⟩ + · intro x hx + have hs : x ∈ Function.support ψ := hx + rw [φ.support_normed_eq] at hs + exact (show ‖x‖ < 1 by simpa only [mem_ball,dist_zero_right] using hs).le + · intro x + simpa only [Real.norm_eq_abs] using hB x + · intro x y + simpa only [Real.norm_eq_abs] using hL.norm_sub_le x y + +end PlanePotential + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/LabelSwitches1.lean b/lean/OAI/Analysis/SignedDisk/LabelSwitches1.lean new file mode 100644 index 0000000000000000000000000000000000000000..916bd42c3024916c94fc5c1f0cad7883f0059cb5 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/LabelSwitches1.lean @@ -0,0 +1,402 @@ +import OAI.Analysis.SignedDisk.IntrinsicMarks1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff + +noncomputable section + +namespace SignedDisk + +open Finset + +namespace LabelSwitches + +/-- Whether a switch has occurred since the most recent exceptional level. -/ +def active (bad sw : ℕ → Bool) : ℕ → Bool + | 0 => false + | n+1 => if bad n then false else active bad sw n || sw n + +def count (p : ℕ → Bool) (n : ℕ) : ℕ := ∑ i ∈ range n, if p i then 1 else 0 + +lemma active_witness (bad sw : ℕ → Bool) (n : ℕ) (h : active bad sw n = true) : + ∃ i < n, sw i = true ∧ ∀ j, i ≤ j → j < n → bad j = false := by + induction n with + | zero => simp [active] at h + | succ n ih => + by_cases hb : bad n = true + · simp [active,hb] at h + · have hb' : bad n = false := by cases hbn : bad n <;> simp_all + simp only [active,hb',Bool.false_eq_true,↓reduceIte,Bool.or_eq_true] at h + rcases h with h | h + · obtain ⟨i,hi,hs,hn⟩ := ih h + refine ⟨i,Nat.lt_succ_of_lt hi,hs,?_⟩ + intro j hij hj + by_cases hjn : j < n + · exact hn j hij hjn + · have : j = n := by omega + simpa [this] using hb' + · refine ⟨n,Nat.lt_succ_self n,h,?_⟩ + intro j hj hj' + have : j=n := by omega + simpa [this] using hb' + +theorem count_le (bad sw : ℕ → Bool) (n : ℕ) + (hsep : ∀ i j, i < j → j < n → sw i = true → sw j = true → + ∃ k, i ≤ k ∧ k ≤ j ∧ bad k = true) : + count sw n ≤ 1+2*count bad n := by + have hns (j : ℕ) (hj : j < n) (ha : active bad sw j = true) (hb : bad j = false) : + sw j = false := by + obtain ⟨i,hi,hs,hb0⟩ := active_witness bad sw j ha + cases hv : sw j with + | false => rfl + | true => + obtain ⟨k,hik,hkj,hbk⟩ := hsep i j hi hj hs hv + by_cases hkj' : k < j + · have := hb0 k hik hkj' + simp_all + · have : k=j := by omega + simp_all + have aux : ∀ m ≤ n, count sw m ≤ 2*count bad m + if active bad sw m then 1 else 0 := by + intro m hm + induction m with + | zero => simp [count,active] + | succ m ih => + have ih' := ih (Nat.le_trans (Nat.le_succ m) hm) + have hstep := hns m (by omega) + simp only [count,sum_range_succ] at ih' ⊢ + simp only [active] + by_cases hb : bad m = true <;> by_cases hs : sw m = true <;> + by_cases ha : active bad sw m = true <;> simp_all <;> omega + have h := aux n le_rfl + split_ifs at h <;> omega + +/-- Quantitative energy version. The exceptional set is the union of marks +and levels with energy exceeding c. This includes an arbitrary birth offset. -/ +theorem count_energy (mark sw : ℕ → Bool) (E : ℕ → ℝ) (n : ℕ) {c : ℝ} + (hc : 0 < c) (hE : ∀ i < n, 0 ≤ E i) + (hsep : ∀ i j, i < j → j < n → sw i = true → sw j = true → + ∃ k, i ≤ k ∧ k ≤ j ∧ (mark k = true ∨ c < E k)) : + ((count sw n : ℕ) : ℝ) ≤ 1+2*((count mark n : ℕ) : ℝ)+(2/c)*∑ i ∈ range n, E i := by + let bad : ℕ → Bool := fun i => decide (mark i = true ∨ c < E i) + have hb := count_le bad sw n (by + intro i j hij hj hi hj' + obtain ⟨k,hik,hkj,hk⟩ := hsep i j hij hj hi hj' + exact ⟨k,hik,hkj,by simpa [bad] using hk⟩) + have henergy : ((count bad n : ℕ) : ℝ) ≤ ((count mark n : ℕ) : ℝ)+(1/c)*∑ i ∈ range n, E i := by + simp only [count,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero,mul_sum,← sum_add_distrib] + apply sum_le_sum + intro i hi + have hi' : i < n := mem_range.mp hi + have he := hE i hi' + have hec : 0 ≤ (1/c)*E i := mul_nonneg (by positivity) he + by_cases hm : mark i = true + · simp only [bad,hm,true_or,decide_true,↓reduceIte] + linarith + · by_cases hce : c < E i + · have he1 : 1 ≤ (1/c)*E i := by + rw [one_div,mul_comm,← div_eq_mul_inv,le_div_iff₀ hc] + simpa using hce.le + simpa [bad,hm,hce] using he1 + · simpa [bad,hm,hce] using hec + have hb' : ((count sw n : ℕ) : ℝ) ≤ 1+2*((count bad n : ℕ) : ℝ) := by exact_mod_cast hb + calc + _ ≤ 1+2*(((count mark n : ℕ) : ℝ)+(1/c)*∑ i ∈ range n, E i) := by linarith + _ = _ := by ring + +end LabelSwitches + +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology + +namespace PlanePotential + +/-- The global segment kernel vanishes off the region on which the actual +finite density decomposition is valid. -/ +lemma green_eq_zero_of_outside {ψ : ℂ → ℝ} {R X : ℝ} + (hs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hRX : R ≤ X) {x y : ℂ} + (hx : ‖x‖ ≤ X) (hy : X < ‖y‖) : green ψ x y = 0 := by + have hz (t : ℝ) (ht : t ∈ Ioc (0:ℝ) 1) : ψ (x+t⁻¹ • (y-x)) = 0 := by + by_contra hh + have hw := hs _ hh + have heq : y = (1-t) • x+t • (x+t⁻¹ • (y-x)) := by + rw [smul_add,smul_smul,mul_inv_cancel₀ ht.1.ne',one_smul] + module + have hn := norm_add_le ((1-t) • x) (t • (x+t⁻¹ • (y-x))) + rw [← heq,norm_smul,norm_smul,Real.norm_eq_abs,Real.norm_eq_abs, + abs_of_nonneg (sub_nonneg.mpr ht.2),abs_of_pos ht.1] at hn + have hle := add_le_add (mul_le_mul_of_nonneg_left hx (sub_nonneg.mpr ht.2)) + (mul_le_mul_of_nonneg_left (hw.trans hRX) ht.1.le) + nlinarith + have hi : greenScalar ψ x y = 0 := by + unfold greenScalar + apply setIntegral_eq_zero_of_forall_eq_zero + intro t ht + simp only [hz t ht,zero_mul] + simp only [green,hi,neg_zero,zero_smul] + +lemma green_gradient_representation {ψ g : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (hψ1 : ∫ z, ψ z = 1) (x : ℂ) : + (∫ y, ⟪green ψ x y,gradient g y⟫) = g x-∫ z, ψ z*g z := by + simpa only [inner_gradient_right,RCLike.conj_to_real] using + green_representation hψ hψc hg hD hψ1 x + +theorem green_finite_decomposition {ι : Type*} [Fintype ι] + {ψ g : ℂ → ℝ} (hψ : Continuous ψ) (hψc : HasCompactSupport ψ) + (hg : ContDiff ℝ 1 g) {D R X Y B : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (hψ1 : ∫ z, ψ z = 1) + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hRX : R ≤ X) (hM : 0 < R+X) (hB : 0 ≤ B) (hXY : 0 < X+Y) + (β : ι → ℂ → ℂ) (hβ : ∀ i, Integrable (β i)) + (hβs : ∀ i y, β i y ≠ 0 → ‖y‖ ≤ Y) + (hdecomp : ∀ᵐ y, ‖y‖ ≤ X → gradient g y = ∑ i, β i y) : + ∀ᵐ x ∂volume.restrict {x : ℂ | ‖x‖ ≤ X}, + g x-∫ z, ψ z*g z = ∑ i, ∫ y, ⟪green ψ x y,β i y⟫ := by + have hall := ae_all_iff.mpr (fun i => green_ae_integrable hψ.measurable hψs hψB hM hB hXY + (hβ i) (hβs i)) + filter_upwards [hall,ae_restrict_mem (measurableSet_le measurable_norm measurable_const)] with x hi hx + rw [← green_gradient_representation hψ hψc hg hD hψ1 x,← integral_finsetSum _ (fun i _ => hi i)] + apply integral_congr_ae + filter_upwards [hdecomp] with y hy + by_cases hyX : ‖y‖ ≤ X + · rw [hy hyX,inner_sum] + · rw [green_eq_zero_of_outside hψs hRX hx (lt_of_not_ge hyX)] + simp + +/-- The complete finite Minkowski step, after genuine kernel insertion. -/ +theorem green_decomposition_norm {ι : Type*} [Fintype ι] + {ψ g : ℂ → ℝ} (hψ : Continuous ψ) (hψc : HasCompactSupport ψ) + (hg : ContDiff ℝ 1 g) {D R X Y B : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (hψ1 : ∫ z, ψ z = 1) + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hRX : R ≤ X) (hM : 0 < R+X) (hB : 0 ≤ B) (hXY : 0 < X+Y) + (β : ι → ℂ → ℂ) (hβ : ∀ i, Integrable (β i)) + (hβs : ∀ i y, β i y ≠ 0 → ‖y‖ ≤ Y) + (hdecomp : ∀ᵐ y, ‖y‖ ≤ X → gradient g y = ∑ i, β i y) : + eLpNorm (fun x => g x-∫ z, ψ z*g z) (3/2) (volume.restrict {x : ℂ | ‖x‖ ≤ X}) ≤ + ∑ i, eLpNorm (fun x => ∫ y, ⟪green ψ x y,β i y⟫) (3/2) + (volume.restrict {x : ℂ | ‖x‖ ≤ X}) := by + let μ := volume.restrict {x : ℂ | ‖x‖ ≤ X} + let F : ι → ℂ → ℝ := fun i x => ∫ y, ⟪green ψ x y,β i y⟫ + have hmeas : ∀ i, AEStronglyMeasurable (F i) μ := fun i => + potential_aestronglyMeasurable _ (green_measurable ψ hψ.measurable) (hβ i) + have heq : (fun x => g x-∫ z, ψ z*g z) =ᵐ[μ] fun x => ∑ i, F i x := + green_finite_decomposition hψ hψc hg hD hψ1 hψs hψB hRX hM hB hXY β hβ hβs hdecomp + have hsum : eLpNorm (∑ i, F i) (3/2) μ ≤ ∑ i, eLpNorm (F i) (3/2) μ := + eLpNorm_sum_le (by + rw [ENNReal.le_div_iff_mul_le (by norm_num) (by norm_num)] + norm_num) + rw [eLpNorm_congr_ae heq] + have hfun : (∑ i, F i) = fun x => ∑ i, F i x := by ext x; simp + rw [hfun] at hsum + exact hsum + +end PlanePotential + +namespace RadiusEnvelope +variable {E : Type*} + +/-- The signed envelope over the entire compact real-radius interval. -/ +def envelope (u : ℝ → E → ℝ) (a b : ℝ) (x : E) : ℝ := + sSup ((fun r => u r x) '' Icc a b) + +lemma attains {u : ℝ → E → ℝ} {a b : ℝ} (hab : a ≤ b) (x : E) + (hc : ContinuousOn (fun r => u r x) (Icc a b)) : + ∃ r ∈ Icc a b, envelope u a b x = u r x ∧ ∀ t ∈ Icc a b, u t x ≤ u r x := by + obtain ⟨r,hr,hm⟩ := isCompact_Icc.exists_isMaxOn (Set.nonempty_Icc.mpr hab) hc + refine ⟨r,hr,?_,hm⟩ + apply le_antisymm + · apply csSup_le ((Set.nonempty_Icc.mpr hab).image _) + rintro _ ⟨t,ht,rfl⟩ + exact hm ht + · apply le_csSup (isCompact_Icc.image_of_continuousOn hc).bddAbove + exact mem_image_of_mem _ hr + +lemma le_envelope {u : ℝ → E → ℝ} {a b r : ℝ} (hr : r ∈ Icc a b) (x : E) + (hc : ContinuousOn (fun r => u r x) (Icc a b)) : u r x ≤ envelope u a b x := by + obtain ⟨t,ht,he,hm⟩ := attains (hr.1.trans hr.2) x hc + rw [he] + exact hm r hr + +lemma lipschitz [NormedAddCommGroup E] {u : ℝ → E → ℝ} {a b : ℝ} {L : ℝ≥0} (hab : a ≤ b) + (hc : ∀ x, ContinuousOn (fun r => u r x) (Icc a b)) + (hL : ∀ r ∈ Icc a b, LipschitzWith L (u r)) : + LipschitzWith L (envelope u a b) := by + rw [lipschitzWith_iff_dist_le_mul] + intro x y + obtain ⟨r,hr,her,hmr⟩ := attains hab x (hc x) + obtain ⟨t,ht,het,hmt⟩ := attains hab y (hc y) + rw [Real.dist_eq,abs_le] + constructor + · have h := (hL t ht).dist_le_mul x y + rw [Real.dist_eq] at h + rw [het] + have hx := le_envelope ht x (hc x) + have ha := (abs_le.mp h).1 + linarith + · have h := (hL r hr).dist_le_mul x y + rw [Real.dist_eq] at h + rw [her] + have hy := le_envelope hr y (hc y) + have ha := (abs_le.mp h).2 + linarith + +lemma zero_of_all_zero {u : ℝ → E → ℝ} {a b : ℝ} (hab : a ≤ b) {x : E} + (hc : ContinuousOn (fun r => u r x) (Icc a b)) + (hz : ∀ r ∈ Icc a b, u r x = 0) : envelope u a b x = 0 := by + obtain ⟨r,hr,he,_⟩ := attains hab x hc + exact he.trans (hz r hr) + +/-- Differentiable touching holds for every attaining radius; no derivative of +an argmax selector is taken. -/ +theorem fderiv_touching [NormedAddCommGroup E] [NormedSpace ℝ E] {u : ℝ → E → ℝ} {a b r : ℝ} {x : E} + (hr : r ∈ Icc a b) (hc : ∀ y, ContinuousOn (fun t => u t y) (Icc a b)) + (he : envelope u a b x = u r x) + (hd : DifferentiableAt ℝ (envelope u a b) x) (hu : DifferentiableAt ℝ (u r) x) : + fderiv ℝ (envelope u a b) x = fderiv ℝ (u r) x := by + have hm : IsLocalMin (fun y => envelope u a b y-u r y) x := by + apply IsMinOn.isLocalMin (s := univ) _ univ_mem + intro y _ + change envelope u a b x-u r x ≤ envelope u a b y-u r y + rw [he,sub_self] + exact sub_nonneg.mpr (le_envelope hr y (hc y)) + have hz := hm.hasFDerivAt_eq_zero (hd.hasFDerivAt.sub hu.hasFDerivAt) + exact sub_eq_zero.mp hz + +end RadiusEnvelope + +namespace DiskMoments + +lemma signedAverage_lipschitz {g : ℂ → ℝ} {L : ℝ≥0} (hg : LipschitzWith L g) + {t : ℝ} (ht : 0 < t) : LipschitzWith L (fun x => signedAverage g x t) := by + rw [lipschitzWith_iff_dist_le_mul] + intro x y + rw [signedAverage_fixedDomain g x ht,signedAverage_fixedDomain g y ht,Real.dist_eq, + ← sub_div,abs_div,abs_of_pos Real.pi_pos] + have hxi : IntegrableOn (fun z : ℂ => g (x+t • z)) (Metric.ball 0 1) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall 0 1) + (hg.continuous.comp (by fun_prop)).continuousOn).mono_set Metric.ball_subset_closedBall + have hyi : IntegrableOn (fun z : ℂ => g (y+t • z)) (Metric.ball 0 1) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall 0 1) + (hg.continuous.comp (by fun_prop)).continuousOn).mono_set Metric.ball_subset_closedBall + rw [← integral_sub hxi hyi] + have : IsFiniteMeasure (volume.restrict (Metric.ball (0:ℂ) 1)) := + ⟨by simp⟩ + have hi := norm_integral_le_of_norm_le_const (μ := volume.restrict (Metric.ball (0:ℂ) 1)) + (C := (L:ℝ)*dist x y) (f := fun z : ℂ => g (x+t • z)-g (y+t • z)) (by + filter_upwards with z + simpa only [Real.norm_eq_abs,← Real.dist_eq,dist_add_right] using hg.dist_le_mul (x+t • z) (y+t • z)) + have hv : (volume.restrict (Metric.ball (0:ℂ) 1)).real univ = Real.pi := by + simp [measureReal_def,Complex.volume_ball] + rw [hv,Real.norm_eq_abs] at hi + exact (div_le_iff₀ Real.pi_pos).mpr hi + +lemma signedAverage_radius_continuousOn {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (x : ℂ) {a b : ℝ} (ha : 0 < a) : + ContinuousOn (fun t => signedAverage g x t) (Icc a b) := by + intro t ht + exact (hasDerivAt_signedAverage hg x (ha.trans_le ht.1)).continuousAt.continuousWithinAt + +lemma hasFDerivAt_signedAverage {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (x : ℂ) {t : ℝ} (ht : 0 < t) : + HasFDerivAt (fun x => signedAverage g x t) + ((1/Real.pi) • ∫ z in Metric.ball 0 1, fderiv ℝ g (x+t • z)) x := by + let F : ℂ → ℂ → ℝ := fun x z => g (x+t • z) + have hFi : IntegrableOn (F x) (Metric.ball 0 1) := + (ContinuousOn.integrableOn_compact (isCompact_closedBall 0 1) + (hg.continuous.comp (by fun_prop)).continuousOn).mono_set Metric.ball_subset_closedBall + have hd := hasFDerivAt_integral_of_dominated_of_fderiv_le + (μ := volume.restrict (Metric.ball (0:ℂ) 1)) (F := F) + (F' := fun x z => fderiv ℝ g (x+t • z)) (bound := fun _ => D) + (s := univ) (x₀ := x) univ_mem + (Eventually.of_forall (fun x => (hg.continuous.comp (by fun_prop)).aestronglyMeasurable)) + hFi ((hg.continuous_fderiv one_ne_zero).comp (by fun_prop)).aestronglyMeasurable + (ae_of_all _ (fun z x _ => hD (x+t • z))) (integrableOn_const (by finiteness)) + (ae_of_all _ (fun z x _ => by + simpa only [ContinuousLinearMap.comp_id,Function.comp_def,id_eq,F] using + (hg.differentiable one_ne_zero (x+t • z)).hasFDerivAt.comp x ((hasFDerivAt_id x).add_const (t • z)))) + convert! hd.const_mul (1/Real.pi) using 1 + · funext y + simpa only [F,div_eq_mul_inv,one_div,mul_comm,mul_one] using signedAverage_fixedDomain g y ht + +/-- Actual signed run envelopes: locally differentiable almost everywhere, over +all radii in their compact interval. -/ +theorem run_envelope_lipschitz {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + ∃ L : ℝ≥0, LipschitzWith L (RadiusEnvelope.envelope (fun r x => signedAverage g x r) a b) := by + obtain ⟨L,hL⟩ := hg.lipschitzWith_of_hasCompactSupport hgc one_ne_zero + exact ⟨L,RadiusEnvelope.lipschitz hab (fun x => signedAverage_radius_continuousOn hg x ha) + (fun r hr => signedAverage_lipschitz hL (ha.trans_le hr.1))⟩ + +lemma signedAverage_eq_zero_of_outside {g : ℂ → ℝ} {R : ℝ} + (hs : ∀ y, g y ≠ 0 → ‖y‖ ≤ R) {x : ℂ} {t : ℝ} (hx : R+t ≤ ‖x‖) : + signedAverage g x t = 0 := by + unfold signedAverage + have hz : (∫ y in Metric.ball x t, g y) = 0 := by + apply setIntegral_eq_zero_of_forall_eq_zero + intro y hy + by_contra hny + have hn := hs y hny + have hd : ‖x-y‖ < t := by simpa only [Metric.mem_ball,dist_eq_norm,norm_sub_rev] using hy + have hh : ‖x‖ ≤ ‖x-y‖+‖y‖ := by simpa only [sub_add_cancel] using norm_add_le (x-y) y + linarith + rw [hz,zero_div] + +/-- Every radius in the run is retained, but a common compact spatial support +still exists. -/ +theorem run_envelope_hasCompactSupport {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + HasCompactSupport (RadiusEnvelope.envelope (fun r x => signedAverage g x r) a b) := by + obtain ⟨R,hR⟩ := hgc.isBounded.subset_closedBall (0:ℂ) + have hs : ∀ y, g y ≠ 0 → ‖y‖ ≤ R := by + intro y hy + simpa only [Metric.mem_closedBall,dist_zero_right] using hR (subset_tsupport g hy) + apply IsCompact.of_isClosed_subset (isCompact_closedBall (0:ℂ) (R+b)) isClosed_closure + apply closure_minimal _ Metric.isClosed_closedBall + intro x hx + rw [Metric.mem_closedBall,dist_zero_right] + by_contra hn + have hz : RadiusEnvelope.envelope (fun r x => signedAverage g x r) a b x = 0 := by + apply RadiusEnvelope.zero_of_all_zero hab (signedAverage_radius_continuousOn hg x ha) + intro r hr + exact signedAverage_eq_zero_of_outside hs (by linarith [hr.2]) + exact hx hz + +/-- AE differentiability and universal touching of actual run gradients. -/ +theorem run_envelope_ae_touching {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + ∀ᵐ x, ∀ r ∈ Icc a b, + RadiusEnvelope.envelope (fun r x => signedAverage g x r) a b x = signedAverage g x r → + fderiv ℝ (RadiusEnvelope.envelope (fun r x => signedAverage g x r) a b) x = + (1/Real.pi) • ∫ z in Metric.ball 0 1, fderiv ℝ g (x+r • z) := by + obtain ⟨L,hL⟩ := run_envelope_lipschitz hg hgc ha hab + obtain ⟨K,hK⟩ := hg.lipschitzWith_of_hasCompactSupport hgc one_ne_zero + filter_upwards [hL.ae_differentiableAt] with x hx + intro r hr he + have hd := hasFDerivAt_signedAverage hg (fun y => norm_fderiv_le_of_lipschitz ℝ hK) x + (ha.trans_le hr.1) + exact (RadiusEnvelope.fderiv_touching hr (fun y => signedAverage_radius_continuousOn hg y ha) + he hx hd.differentiableAt).trans hd.fderiv + +end DiskMoments + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/LocalCancellation1.lean b/lean/OAI/Analysis/SignedDisk/LocalCancellation1.lean new file mode 100644 index 0000000000000000000000000000000000000000..db5d16417bb1cea963be2648a610a7732b05a516 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/LocalCancellation1.lean @@ -0,0 +1,467 @@ +import OAI.Analysis.SignedDisk.DiskKernels1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal + +noncomputable section + +namespace SignedDisk + +namespace LocalCancellation + +lemma integrable_lip_mul {b F : ℂ → ℂ} (hb : Integrable b) + {L : ℝ≥0} (hF : LipschitzWith L F) (z : ℂ) {s : ℝ} + (hsupp : ∀ᵐ y, b y ≠ 0 → ‖y-z‖ ≤ s) : Integrable (fun y => F y * b y) := by + have hbound : ∀ᵐ y, ‖(F y - F z) * b y‖ ≤ ((L : ℝ) * s) * ‖b y‖ := by + filter_upwards [hsupp] with y hy + by_cases hby : b y = 0 + · simp [hby] + · rw [norm_mul] + exact mul_le_mul_of_nonneg_right + ((hF.norm_sub_le y z).trans (mul_le_mul_of_nonneg_left (hy hby) L.coe_nonneg)) + (norm_nonneg _) + have hdiff : Integrable (fun y => (F y - F z) * b y) := + (hb.norm.smul ((L : ℝ) * s)).mono' + ((hF.continuous.sub continuous_const).aestronglyMeasurable.mul hb.aestronglyMeasurable) hbound + have h := hdiff.add (hb.const_mul (F z)) + change Integrable (fun y => (F y-F z)*b y + F z * b y) at h + simpa only [← add_mul, sub_add_cancel] using h + +/-- Cancellation against the actual integrable complex error density. -/ +lemma lip_cancellation {b F : ℂ → ℂ} (hb : Integrable b) (hzero : ∫ y, b y = 0) + {L : ℝ≥0} (hF : LipschitzWith L F) (z : ℂ) {s : ℝ} + (hsupp : ∀ᵐ y, b y ≠ 0 → ‖y-z‖ ≤ s) : + ‖∫ y, F y * b y‖ ≤ (L : ℝ) * s * ∫ y, ‖b y‖ := by + have hprod := integrable_lip_mul hb hF z hsupp + have he : (∫ y, (F y - F z) * b y) = ∫ y, F y * b y := by + simp_rw [sub_mul] + rw [integral_sub hprod (hb.const_mul (F z)), integral_const_mul, hzero, mul_zero, sub_zero] + rw [← he] + calc + ‖∫ y, (F y-F z) * b y‖ ≤ ∫ y, ((L : ℝ) * s) * ‖b y‖ := by + apply norm_integral_le_of_norm_le (hb.norm.smul ((L : ℝ) * s)) + filter_upwards [hsupp] with y hy + by_cases hby : b y = 0 + · simp [hby] + · rw [norm_mul] + exact mul_le_mul_of_nonneg_right + ((hF.norm_sub_le y z).trans (mul_le_mul_of_nonneg_left (hy hby) L.coe_nonneg)) + (norm_nonneg _) + _ = (L : ℝ) * s * ∫ y, ‖b y‖ := integral_const_mul _ _ + +lemma bounded_pairing {b F : ℂ → ℂ} (hb : Integrable b) {M : ℝ} + (hF : ∀ y, ‖F y‖ ≤ M) : ‖∫ y, F y * b y‖ ≤ M * ∫ y, ‖b y‖ := by + calc + ‖∫ y, F y * b y‖ ≤ ∫ y, M * ‖b y‖ := by + apply norm_integral_le_of_norm_le (hb.norm.const_mul M) + exact Eventually.of_forall (fun y => by rw [norm_mul]; exact mul_le_mul_of_nonneg_right (hF y) (norm_nonneg _)) + _ = M * ∫ y, ‖b y‖ := integral_const_mul _ _ + +lemma min_one_le_rpow {a α : ℝ} (ha : 0 ≤ a) (hα0 : 0 ≤ α) (hα1 : α ≤ 1) : + min 1 a ≤ a ^ α := by + by_cases ha1 : a ≤ 1 + · rw [min_eq_right ha1] + by_cases hz : a = 0 + · rw [hz] + exact Real.rpow_nonneg (by norm_num) _ + · simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_ge (lt_of_le_of_ne ha (Ne.symm hz)) ha1 hα1 + · rw [min_eq_left (le_of_not_ge ha1)] + exact Real.one_le_rpow (le_of_not_ge ha1) hα0 + +structure ErrorPiece (Cs : ℝ) where + density : ℂ → ℂ + integrable : Integrable density + size : ℝ + size_pos : 0 < size + size_le_one : size ≤ 1 + center : ℂ + zero_mass : size < 1 → ∫ y, density y = 0 + support : size < 1 → ∀ᵐ y, density y ≠ 0 → ‖y-center‖ ≤ Cs * size + +def ErrorPiece.mass {Cs : ℝ} (b : ErrorPiece Cs) : ℝ := ∫ y, ‖b.density y‖ + +lemma ErrorPiece.mass_nonneg {Cs : ℝ} (b : ErrorPiece Cs) : 0 ≤ b.mass := + integral_nonneg (fun _ => norm_nonneg _) + +/-- The single-piece interpolation discount, with no smoothness assumed on the density. -/ +lemma piece_discount {Cs α δ C : ℝ} (b : ErrorPiece Cs) + (hα0 : 0 ≤ α) (hα1 : α ≤ 1) (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (hC : 1 ≤ C) {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hLC : (L : ℝ) * Cs ≤ C / δ) : + ‖∫ y, F y * b.density y‖ ≤ C * (b.size / δ) ^ α * b.mass := by + have hr : ‖∫ y, F y * b.density y‖ ≤ b.mass := by + convert! bounded_pairing b.integrable hFb using 1 + simp only [one_mul, ErrorPiece.mass] + have hCm : 0 ≤ C * b.mass := mul_nonneg (by linarith) b.mass_nonneg + have hm : ‖∫ y, F y * b.density y‖ ≤ C * min 1 (b.size/δ) * b.mass := by + by_cases hs : b.size < 1 + · have hl := lip_cancellation b.integrable (b.zero_mass hs) hF b.center (b.support hs) + have hl' : ‖∫ y, F y * b.density y‖ ≤ C * (b.size/δ) * b.mass := by + have hh := mul_le_mul_of_nonneg_right hLC (mul_nonneg b.size_pos.le b.mass_nonneg) + calc + _ ≤ (L : ℝ) * (Cs * b.size) * b.mass := hl + _ ≤ C * (b.size/δ) * b.mass := by convert! hh using 1 <;> ring + have hr' : ‖∫ y, F y * b.density y‖ ≤ C * 1 * b.mass := by nlinarith [b.mass_nonneg] + by_cases hh : 1 ≤ b.size/δ + · simpa only [min_eq_left hh] using hr' + · simpa only [min_eq_right (le_of_not_ge hh)] using hl' + · have hs1 : b.size = 1 := le_antisymm b.size_le_one (le_of_not_gt hs) + have hh : 1 ≤ b.size / δ := by rw [hs1]; exact (one_le_div hδ).mpr hδ1 + rw [min_eq_left hh] + nlinarith [b.mass_nonneg] + calc + _ ≤ C * min 1 (b.size/δ) * b.mass := hm + _ ≤ C * (b.size/δ)^α * b.mass := by + nlinarith [mul_le_mul_of_nonneg_left + (min_one_le_rpow (div_nonneg b.size_pos.le hδ.le) hα0 hα1) hCm] + +/-- Multiplication by the position keeps a bounded-support Lipschitz test Lipschitz. -/ +lemma position_lipschitz {F : ℂ → ℂ} {L M R : ℝ≥0} (hF : LipschitzWith L F) + (hM : ∀ y, ‖F y‖ ≤ M) (x : ℂ) + (hR : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ R) : + LipschitzWith (R*L+M) (fun y => star (y-x) * F y) := by + apply LipschitzWith.of_dist_le_mul + intro y z + rw [dist_eq_norm, dist_eq_norm] + change ‖star (y-x)*F y - star (z-x)*F z‖ ≤ ((R : ℝ)*(L : ℝ)+(M : ℝ))*‖y-z‖ + by_cases hz : F z = 0 + · rw [hz, mul_zero, sub_zero] + by_cases hy : F y = 0 + · simp only [hy, mul_zero, norm_zero] + positivity + · have hFy : ‖F y‖ ≤ (L : ℝ)*‖y-z‖ := by simpa only [hz, sub_zero] using hF.norm_sub_le y z + rw [norm_mul, norm_star] + have hh := mul_le_mul (hR y hy) hFy (norm_nonneg _) R.coe_nonneg + nlinarith [mul_nonneg M.coe_nonneg (norm_nonneg (y-z))] + · have he : star (y-x)*F y-star (z-x)*F z = + star (z-x)*(F y-F z)+star (y-z)*F y := by + simp only [star_sub] + ring + rw [he] + calc + _ ≤ ‖star (z-x)*(F y-F z)‖+‖star (y-z)*F y‖ := norm_add_le _ _ + _ = ‖z-x‖*‖F y-F z‖+‖y-z‖*‖F y‖ := by rw [norm_mul, norm_mul, norm_star, norm_star] + _ ≤ (R : ℝ)*((L : ℝ)*‖y-z‖)+‖y-z‖*(M : ℝ) := + add_le_add (mul_le_mul (hR z hz) (hF.norm_sub_le y z) (norm_nonneg _) R.coe_nonneg) + (mul_le_mul_of_nonneg_left (hM y) (norm_nonneg _)) + _ = _ := by ring + +def correction (x z y : ℂ) : ℂ := 1 - star (y-x) / star (z-x) + +lemma correction_eq {x z y : ℂ} (hz : z ≠ x) : + correction x z y = star (z-y) / star (z-x) := by + have hzx : star (z-x) ≠ 0 := star_ne_zero.mpr (sub_ne_zero.mpr hz) + have he : star (z-x)-star (y-x) = star (z-y) := by simp only [star_sub]; ring + calc + correction x z y = (star (z-x)-star (y-x))/star (z-x) := by + rw [sub_div, div_self hzx] + rfl + _ = star (z-y)/star (z-x) := by rw [he] + +lemma norm_correction {x z y : ℂ} (hz : z ≠ x) : + ‖correction x z y‖ = ‖y-z‖ / ‖z-x‖ := by + rw [correction_eq hz, norm_div, norm_star, norm_star, norm_sub_rev z y] + +lemma correction_cap_bound {x z y : ℂ} {ρ : ℝ} + (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hy : ‖y-z‖ ≤ ρ) : + ‖correction x z y‖ ≤ 2*ρ := by + have hzx : 0 < ‖z-x‖ := by linarith + have hne : z ≠ x := sub_ne_zero.mp (norm_pos_iff.mp hzx) + rw [norm_correction hne] + have hρ : 0 ≤ ρ := (norm_nonneg _).trans hy + apply (div_le_iff₀ hzx).mpr + nlinarith + +lemma correction_bounded {x z y : ℂ} (hz : (1 : ℝ)/2 ≤ ‖z-x‖) + (hy : ‖y-x‖ ≤ 3) : ‖correction x z y‖ ≤ 7 := by + have hzx : 0 < ‖z-x‖ := by linarith + calc + ‖correction x z y‖ ≤ 1+‖y-x‖/‖z-x‖ := by + simpa only [correction, norm_one, norm_div, norm_star] using norm_sub_le (1 : ℂ) (star (y-x)/star (z-x)) + _ ≤ 7 := by + have : ‖y-x‖/‖z-x‖ ≤ 6 := (div_le_iff₀ hzx).mpr (by linarith) + linarith + +/-- Global Lipschitz control of the corrected increment test. -/ +lemma corrected_lipschitz {F : ℂ → ℂ} {L M R H : ℝ≥0} (hF : LipschitzWith L F) + (hM : ∀ y, ‖F y‖ ≤ M) (x z : ℂ) + (hR : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ R) (hH : ‖(star (z-x))⁻¹‖ ≤ H) : + LipschitzWith (L+H*(R*L+M)) (fun y => correction x z y * F y) := by + have hp := position_lipschitz hF hM x hR + apply LipschitzWith.of_dist_le_mul + intro y w + have he : correction x z y*F y-correction x z w*F w = + (F y-F w)-(star (z-x))⁻¹*(star (y-x)*F y-star (w-x)*F w) := by + simp only [correction, div_eq_mul_inv] + ring + rw [dist_eq_norm, he, dist_eq_norm] + calc + _ ≤ ‖F y-F w‖+‖(star (z-x))⁻¹*(star (y-x)*F y-star (w-x)*F w)‖ := norm_sub_le _ _ + _ ≤ (L : ℝ)*‖y-w‖+(H : ℝ)*(((R : ℝ)*(L : ℝ)+(M : ℝ))*‖y-w‖) := by + apply add_le_add (hF.norm_sub_le y w) + rw [norm_mul] + exact mul_le_mul hH (hp.norm_sub_le y w) (norm_nonneg _) H.coe_nonneg + _ = _ := by simp only [NNReal.coe_add, NNReal.coe_mul]; ring + +variable {ι : Type*} [Fintype ι] + +def errorPrice {Cs : ℝ} (b : ι → ErrorPiece Cs) (α : ℝ) : ℝ := + ∑ d, (b d).size ^ α * (b d).mass + +lemma errorPrice_nonneg {Cs : ℝ} (b : ι → ErrorPiece Cs) (α : ℝ) : + 0 ≤ errorPrice b α := Finset.sum_nonneg (fun d _ => + mul_nonneg (Real.rpow_nonneg (b d).size_pos.le _) (b d).mass_nonneg) + +lemma square_rpow {δ : ℝ} (hδ : 0 ≤ δ) (α : ℝ) : + (δ^2)^α = δ^(2*α) := by + rw [Real.rpow_mul hδ, Real.rpow_two] + +lemma coarse_mass_mul_le {Cs α δ : ℝ} (b : ι → ErrorPiece Cs) (hα : 0 ≤ α) + (hδ : 0 ≤ δ) : + δ^(2*α) * (∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), (b d).mass) ≤ + errorPrice b α := by + classical + rw [Finset.mul_sum] + have hp : δ^(2*α) = (δ^2)^α := (square_rpow hδ α).symm + calc + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), (b d).size^α*(b d).mass := by + apply Finset.sum_le_sum + intro d hd + rw [hp] + exact mul_le_mul_of_nonneg_right + (Real.rpow_le_rpow (sq_nonneg δ) (Finset.mem_filter.mp hd).2 hα) (b d).mass_nonneg + _ ≤ errorPrice b α := Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) + (fun d _ _ => mul_nonneg (Real.rpow_nonneg (b d).size_pos.le _) (b d).mass_nonneg) + +lemma fine_size_sum_le {Cs α δ : ℝ} (b : ι → ErrorPiece Cs) (hα : α ≤ 1) + (hδ : 0 ≤ δ) : + (∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), (b d).size*(b d).mass) ≤ + δ^(2*(1-α))*errorPrice b α := by + classical + calc + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), + δ^(2*(1-α))*((b d).size^α*(b d).mass) := by + apply Finset.sum_le_sum + intro d hd + have hs : (b d).size < δ^2 := (Finset.mem_filter.mp hd).2 + have he : (b d).size = (b d).size^α*(b d).size^(1-α) := by + rw [← Real.rpow_add (b d).size_pos] + simp + have hh := Real.rpow_le_rpow (b d).size_pos.le hs.le (sub_nonneg.mpr hα) + rw [square_rpow hδ] at hh + calc + _ = ((b d).size^α*(b d).size^(1-α))*(b d).mass := congrArg (fun v => v*(b d).mass) he + _ = (b d).size^(1-α)*((b d).size^α*(b d).mass) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hh + (mul_nonneg (Real.rpow_nonneg (b d).size_pos.le _) (b d).mass_nonneg) + _ = δ^(2*(1-α)) * (∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), + (b d).size^α*(b d).mass) := (Finset.mul_sum ..).symm + _ ≤ δ^(2*(1-α))*errorPrice b α := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) + (fun d _ _ => mul_nonneg (Real.rpow_nonneg (b d).size_pos.le _) (b d).mass_nonneg)) + (Real.rpow_nonneg hδ _) + +lemma total_pairing_discount {Cs α δ C : ℝ} (b : ι → ErrorPiece Cs) + (hα0 : 0 ≤ α) (hα1 : α ≤ 1) (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (hC : 1 ≤ C) {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hLC : (L : ℝ)*Cs ≤ C/δ) : + ‖∑ d, ∫ y, F y*(b d).density y‖ ≤ C/δ^α*errorPrice b α := by + calc + _ ≤ ∑ d, ‖∫ y, F y*(b d).density y‖ := norm_sum_le _ _ + _ ≤ ∑ d, C*((b d).size/δ)^α*(b d).mass := Finset.sum_le_sum + (fun d _ => piece_discount (b d) hα0 hα1 hδ hδ1 hC hF hFb hLC) + _ = C/δ^α*errorPrice b α := by + rw [errorPrice, Finset.mul_sum] + apply Finset.sum_congr rfl + intro d _ + rw [Real.div_rpow (b d).size_pos.le hδ.le] + ring + +/-- All fine errors together retain the stronger, summable power of the width. -/ +lemma fine_pairing_bound {Cs α δ : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hα : α ≤ 1) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) : + ‖∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), ∫ y, F y*(b d).density y‖ ≤ + (L : ℝ)*Cs*δ^(2*(1-α))*errorPrice b α := by + classical + calc + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), ‖∫ y, F y*(b d).density y‖ := norm_sum_le _ _ + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), + (L : ℝ)*Cs*((b d).size*(b d).mass) := by + apply Finset.sum_le_sum + intro d hd + have hs : (b d).size < 1 := lt_of_lt_of_le (Finset.mem_filter.mp hd).2 (by nlinarith) + have hh := lip_cancellation (b d).integrable ((b d).zero_mass hs) hF (b d).center ((b d).support hs) + convert! hh using 1 + dsimp only [ErrorPiece.mass] + ring + _ = (L : ℝ)*Cs*(∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), + (b d).size*(b d).mass) := (Finset.mul_sum ..).symm + _ ≤ (L : ℝ)*Cs*(δ^(2*(1-α))*errorPrice b α) := + mul_le_mul_of_nonneg_left (fine_size_sum_le b hα hδ) (mul_nonneg L.coe_nonneg hCs) + _ = _ := by ring + +end LocalCancellation + +open MeasureTheory Set Filter +open scoped Topology NNReal Real + +namespace LocalCancellation + +/-- Norm total-variation measure of an actual complex density. -/ +def densityMeasure (b : ℂ → ℂ) : Measure ℂ := volume.withDensity (fun y => ENNReal.ofReal ‖b y‖) + +lemma densityMeasure_apply {b : ℂ → ℂ} (hb : Integrable b) {D : Set ℂ} + (hD : MeasurableSet D) : densityMeasure b D = ENNReal.ofReal (∫ y in D, ‖b y‖) := by + rw [densityMeasure, withDensity_apply _ hD] + exact (ofReal_integral_eq_lintegral_ofReal hb.integrableOn.norm + (Eventually.of_forall (fun _ => norm_nonneg _))).symm + +lemma densityMeasure_univ {b : ℂ → ℂ} (hb : Integrable b) : + densityMeasure b univ = ENNReal.ofReal (∫ y, ‖b y‖) := by + rw [densityMeasure_apply hb MeasurableSet.univ, Measure.restrict_univ] + +lemma densityMeasure_finite {b : ℂ → ℂ} (hb : Integrable b) : IsFiniteMeasure (densityMeasure b) := by + constructor + rw [densityMeasure_univ hb] + exact ENNReal.ofReal_lt_top + +/-- A cap decomposition bound, with all integrals over genuine densities. -/ +lemma pairing_majorant {b F : ℂ → ℂ} (hb : Integrable b) {A : Set ℂ} + (hA : MeasurableSet A) (c d : ℝ) + (hF : ∀ y, ‖F y‖ ≤ c + d*A.indicator (fun _ => (1 : ℝ)) y) : + ‖∫ y, F y*b y‖ ≤ c*(∫ y, ‖b y‖)+d*(∫ y in A, ‖b y‖) := by + have hi : Integrable (fun y => c*‖b y‖+d*A.indicator (fun y => ‖b y‖) y) := + (hb.norm.const_mul c).add ((hb.norm.indicator hA).const_mul d) + calc + _ ≤ ∫ y, c*‖b y‖+d*A.indicator (fun y => ‖b y‖) y := by + apply norm_integral_le_of_norm_le hi + filter_upwards with y + rw [norm_mul] + have hh := mul_le_mul_of_nonneg_right (hF y) (norm_nonneg (b y)) + convert! hh using 1 + by_cases hy : y ∈ A + · simp only [Set.indicator_of_mem hy, mul_one] + ring + · simp only [Set.indicator_of_notMem hy, mul_zero, add_zero] + _ = _ := by + rw [integral_add (hb.norm.const_mul c) ((hb.norm.indicator hA).const_mul d), + integral_const_mul, integral_const_mul, integral_indicator hA] + +/-- Cancellation of an exact complex moment allows an off-center correction. -/ +lemma moment_correction {b F : ℂ → ℂ} (x z : ℂ) + (hF : Integrable (fun y => F y*b y)) + (hM : Integrable (fun y => star (y-x)*F y*b y)) + (hzero : ∫ y, star (y-x)*F y*b y = 0) : + (∫ y, F y*b y) = ∫ y, (1-star (y-x)/star (z-x))*F y*b y := by + have he : (fun y => (1-star (y-x)/star (z-x))*F y*b y) = + fun y => F y*b y-(star (z-x))⁻¹*(star (y-x)*F y*b y) := by + funext y + simp only [div_eq_mul_inv] + ring + rw [he, integral_sub hF (hM.const_mul _), integral_const_mul, hzero, mul_zero, sub_zero] + +lemma corrected_pairing_cap {b F : ℂ → ℂ} (hb : Integrable b) {D : Set ℂ} + (hD : MeasurableSet D) (hFb : ∀ y, ‖F y‖ ≤ 1) + (hFD : ∀ y, F y ≠ 0 → y ∈ D) (x z : ℂ) {ρ : ℝ} (hρ : 0 ≤ ρ) + (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) : + ‖∫ y, correction x z y*F y*b y‖ ≤ + 2*ρ*(∫ y, ‖b y‖)+7*(∫ y in D \ Metric.ball z ρ, ‖b y‖) := by + apply pairing_majorant hb (hD.diff measurableSet_ball) (2*ρ) 7 + intro y + by_cases hFy : F y = 0 + · simp only [hFy, mul_zero, norm_zero] + exact add_nonneg (mul_nonneg (by norm_num) hρ) + (mul_nonneg (by norm_num) (Set.indicator_nonneg (fun _ _ => zero_le_one) y)) + · have hyD := hFD y hFy + by_cases hyB : y ∈ Metric.ball z ρ + · have hc := correction_cap_bound hz (show ‖y-z‖ ≤ ρ from by simpa only [dist_eq_norm] using (Metric.mem_ball.mp hyB).le) + rw [Set.indicator_of_notMem (show y ∉ D \ Metric.ball z ρ from fun h => h.2 hyB), mul_zero, add_zero] + rw [norm_mul] + simpa only [mul_one] using mul_le_mul hc (hFb y) (norm_nonneg _) (mul_nonneg (by norm_num) hρ) + · rw [Set.indicator_of_mem (show y ∈ D \ Metric.ball z ρ from ⟨hyD,hyB⟩), mul_one] + have hc := correction_bounded hz (hD3 y hyD) + rw [norm_mul] + have hh := mul_le_mul hc (hFb y) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 7) + nlinarith + +lemma supported_pairing {b F : ℂ → ℂ} (hb : Integrable b) {D : Set ℂ} + (hD : MeasurableSet D) (hFb : ∀ y, ‖F y‖ ≤ 1) + (hFD : ∀ y, F y ≠ 0 → y ∈ D) : + ‖∫ y, F y*b y‖ ≤ ∫ y in D, ‖b y‖ := by + have hh := pairing_majorant hb hD 0 1 (show ∀ y, ‖F y‖ ≤ 0+1*D.indicator (fun _ => (1 : ℝ)) y from by + intro y + by_cases hy : y ∈ D + · simpa only [Set.indicator_of_mem hy, mul_one, zero_add] using hFb y + · have hf : F y = 0 := by by_contra h; exact hy (hFD y h) + simp only [hf, norm_zero, Set.indicator_of_notMem hy, mul_zero, zero_add, le_refl]) + simpa only [zero_mul, one_mul, zero_add] using hh + +variable {ι : Type*} [Fintype ι] + +def coarseMeasure {Cs : ℝ} (b : ι → ErrorPiece Cs) (δ : ℝ) : Measure ℂ := + ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), densityMeasure (b d).density + +def coarseMass {Cs : ℝ} (b : ι → ErrorPiece Cs) (δ : ℝ) (D : Set ℂ) : ℝ := + ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), ∫ y in D, ‖(b d).density y‖ + +lemma coarseMass_nonneg {Cs : ℝ} (b : ι → ErrorPiece Cs) (δ : ℝ) (D : Set ℂ) : + 0 ≤ coarseMass b δ D := Finset.sum_nonneg (fun _ _ => integral_nonneg (fun _ => norm_nonneg _)) + +lemma coarseMeasure_apply {Cs : ℝ} (b : ι → ErrorPiece Cs) (δ : ℝ) {D : Set ℂ} + (hD : MeasurableSet D) : coarseMeasure b δ D = ENNReal.ofReal (coarseMass b δ D) := by + classical + simp only [coarseMeasure, Measure.finsetSum_apply, densityMeasure_apply (b _).integrable hD, + coarseMass] + rw [ENNReal.ofReal_sum_of_nonneg (fun d _ => integral_nonneg (fun _ => norm_nonneg _))] + +instance coarseMeasure_finite {Cs : ℝ} (b : ι → ErrorPiece Cs) (δ : ℝ) : + IsFiniteMeasure (coarseMeasure b δ) := by + constructor + rw [coarseMeasure_apply b δ MeasurableSet.univ] + exact ENNReal.ofReal_lt_top + +lemma coarseMass_univ {Cs : ℝ} (b : ι → ErrorPiece Cs) (δ : ℝ) : + coarseMass b δ univ = ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), (b d).mass := by + simp only [coarseMass, ErrorPiece.mass, Measure.restrict_univ] + +lemma coarseMass_bound {Cs α δ : ℝ} (b : ι → ErrorPiece Cs) (hα : 0 ≤ α) + (hδ : 0 < δ) : coarseMass b δ univ ≤ errorPrice b α / δ^(2*α) := by + rw [le_div_iff₀ (Real.rpow_pos_of_pos hδ _), mul_comm, coarseMass_univ] + exact coarse_mass_mul_le b hα hδ.le + +/-- The uncorrected increment costs only shell mass plus the fine-error discount. -/ +lemma increment_bound {Cs α δ : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hα : α ≤ 1) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) : + ‖∑ d, ∫ y, F y*(b d).density y‖ ≤ + coarseMass b δ D+(L : ℝ)*Cs*δ^(2*(1-α))*errorPrice b α := by + classical + have he : (∑ d, ∫ y, F y*(b d).density y) = + (∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), ∫ y, F y*(b d).density y)+ + (∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), ∫ y, F y*(b d).density y) := by + simpa only [not_le] using (Finset.sum_filter_add_sum_filter_not Finset.univ + (fun d => δ^2 ≤ (b d).size) (fun d => ∫ y, F y*(b d).density y)).symm + rw [he] + apply (norm_add_le _ _).trans + apply add_le_add + · apply (norm_sum_le _ _).trans + exact Finset.sum_le_sum (fun d _ => supported_pairing (b d).integrable hD hFb hFD) + · exact fine_pairing_bound b hCs hα hδ hδ1 hF + +end LocalCancellation + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/LocalCancellation2.lean b/lean/OAI/Analysis/SignedDisk/LocalCancellation2.lean new file mode 100644 index 0000000000000000000000000000000000000000..a36c057d1c4a9a8e4403d14a60cd280c63197053 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/LocalCancellation2.lean @@ -0,0 +1,456 @@ +import OAI.Analysis.SignedDisk.LocalCancellation1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace LocalCancellation + +lemma integrable_bounded_pairing {b F : ℂ → ℂ} (hb : Integrable b) + (hF : AEStronglyMeasurable F) {M : ℝ} (hM : ∀ y, ‖F y‖ ≤ M) : + Integrable (fun y => F y*b y) := by + apply (hb.norm.const_mul M).mono' (hF.mul hb.aestronglyMeasurable) + filter_upwards with y + change ‖F y * b y‖ ≤ M * ‖b y‖ + rw [norm_mul] + exact mul_le_mul_of_nonneg_right (hM y) (norm_nonneg _) + +lemma position_bound {F : ℂ → ℂ} (hF : ∀ y, ‖F y‖ ≤ 1) (x : ℂ) + {R : ℝ} (hR0 : 0 ≤ R) (hR : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ R) : + ∀ y, ‖star (y-x)*F y‖ ≤ R := by + intro y + by_cases hy : F y = 0 + · simpa only [hy, mul_zero, norm_zero] using hR0 + · rw [norm_mul, norm_star] + simpa only [mul_one] using mul_le_mul (hR y hy) (hF y) (norm_nonneg _) hR0 + +variable {ι : Type*} [Fintype ι] + +/-- The decisive corrected active increment, prior to substitution of the dyadic powers. +The zero moment is the exact one furnished by two balanced kernels, not a bound. -/ +lemma corrected_increment_bound {Cs α δ ρ : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hα : α ≤ 1) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hρ : 0 ≤ ρ) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) (x z : ℂ) + (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) + (hzero : ∑ d, ∫ y, star (y-x)*F y*(b d).density y = 0) : + ‖∑ d, ∫ y, F y*(b d).density y‖ ≤ + 2*ρ*coarseMass b δ univ+7*coarseMass b δ (D \ Metric.ball z ρ)+ + ((L : ℝ)+2*(3*(L : ℝ)+1))*Cs*δ^(2*(1-α))*errorPrice b α := by + classical + have hnorm : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ (3 : ℝ) := fun y hy => hD3 y (hFD y hy) + have hH : ‖(star (z-x))⁻¹‖ ≤ (2 : ℝ) := by + rw [norm_inv, norm_star] + have hn : 0 < ‖z-x‖ := by linarith + rw [inv_eq_one_div, div_le_iff₀ hn] + linarith + have hcorr : LipschitzWith (L+2*(3*L+1)) (fun y => correction x z y*F y) := + corrected_lipschitz (M := 1) (R := 3) (H := 2) hF hFb x z hnorm hH + have he (d : ι) : (∫ y, correction x z y*F y*(b d).density y) = + (∫ y, F y*(b d).density y) - (star (z-x))⁻¹*(∫ y, star (y-x)*F y*(b d).density y) := by + have hf := integrable_bounded_pairing (b d).integrable hF.continuous.aestronglyMeasurable hFb + have hm : Integrable (fun y => star (y-x)*F y*(b d).density y) := + integrable_bounded_pairing (b d).integrable + ((by fun_prop : Continuous (fun y : ℂ => star (y-x))).mul hF.continuous).aestronglyMeasurable + (position_bound hFb x (by norm_num) hnorm) + have hid : (fun y => correction x z y*F y*(b d).density y) = + fun y => F y*(b d).density y - (star (z-x))⁻¹*(star (y-x)*F y*(b d).density y) := by + funext y + simp only [correction, div_eq_mul_inv] + ring + rw [hid, integral_sub hf (hm.const_mul _), integral_const_mul] + have hall : (∑ d, ∫ y, correction x z y*F y*(b d).density y) = + ∑ d, ∫ y, F y*(b d).density y := by + simp_rw [he] + rw [Finset.sum_sub_distrib, ← Finset.mul_sum, hzero, mul_zero, sub_zero] + rw [← hall] + have hsplit : (∑ d, ∫ y, correction x z y*F y*(b d).density y) = + (∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), ∫ y, correction x z y*F y*(b d).density y)+ + (∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), ∫ y, correction x z y*F y*(b d).density y) := by + simpa only [not_le] using (Finset.sum_filter_add_sum_filter_not Finset.univ + (fun d => δ^2 ≤ (b d).size) (fun d => ∫ y, correction x z y*F y*(b d).density y)).symm + rw [hsplit] + apply (norm_add_le _ _).trans + apply add_le_add + · calc + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), + ‖∫ y, correction x z y*F y*(b d).density y‖ := norm_sum_le _ _ + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), + (2*ρ*(∫ y, ‖(b d).density y‖)+7*(∫ y in D \ Metric.ball z ρ, ‖(b d).density y‖)) := + Finset.sum_le_sum (fun d _ => corrected_pairing_cap (b d).integrable hD hFb hFD x z hρ hz hD3) + _ = _ := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] + simp only [coarseMass, Measure.restrict_univ] + · exact fine_pairing_bound b hCs hα hδ hδ1 hcorr + +end LocalCancellation + +namespace DiskKernels + +lemma kernel_nonneg {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x y : ℂ) : + 0 ≤ kernel k x y := tail_nonneg k _ + +lemma kernel_le_one {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x y : ℂ) : + kernel k x y ≤ 1 := tail_le_one k _ + +lemma complex_kernel_lipschitz {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x : ℂ) : + LipschitzWith M (fun y => (kernel k x y : ℂ)) := by + simpa only [one_mul, Function.comp_def] using Complex.isometry_ofReal.lipschitzWith.comp (kernel_lipschitz k x) + +lemma complex_kernel_bound {a b : ℝ} {M : ℝ≥0} (k : RadiusDensity a b M) (x y : ℂ) : + ‖(kernel k x y : ℂ)‖ ≤ 1 := by + simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (kernel_nonneg k x y)] using kernel_le_one k x y + +lemma difference_bound {a b c d : ℝ} {M N : ℝ≥0} + (k : RadiusDensity a b M) (l : RadiusDensity c d N) (x y : ℂ) : + ‖((kernel l x y : ℂ) - kernel k x y)‖ ≤ 1 := by + rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs, abs_le] + constructor <;> linarith [kernel_nonneg k x y, kernel_nonneg l x y, kernel_le_one k x y, kernel_le_one l x y] + +lemma difference_support {r δ ε : ℝ} {M N : ℝ≥0} + (k : RadiusDensity (r-δ) (r+δ) M) (l : RadiusDensity (r-ε) (r+ε) N) + (hεδ : ε ≤ δ) (x y : ℂ) (h : (kernel l x y : ℂ) - kernel k x y ≠ 0) : + |‖y-x‖-r| ≤ δ := by + by_cases hlo : ‖y-x‖ < r-δ + · have hk : kernel k x y = 1 := kernel_one k x (by simpa only [Metric.mem_ball, dist_eq_norm] using hlo) + have hl : kernel l x y = 1 := kernel_one l x (by + simp only [Metric.mem_ball, dist_eq_norm] + linarith) + exact False.elim (h (by simp only [hk, hl, sub_self])) + · by_cases hup : r+δ ≤ ‖y-x‖ + · have hk : kernel k x y = 0 := kernel_zero k x (by + simpa only [Metric.mem_ball, dist_eq_norm, not_lt] using hup) + have hl : kernel l x y = 0 := kernel_zero l x (by + simp only [Metric.mem_ball, dist_eq_norm, not_lt] + linarith) + exact False.elim (h (by simp only [hk, hl, sub_self])) + · rw [abs_le] + constructor <;> linarith + +/-- At every point away from the boundary circle, all such mixtures tend to + the actual sharp disk. No convergence of the chosen radius densities is assumed. -/ +lemma tendsto_kernel {r : ℝ} {δ : ℕ → ℝ} {M : ℕ → ℝ≥0} + (k : ∀ n, RadiusDensity (r-δ n) (r+δ n) (M n)) + (hδ : Tendsto δ atTop (𝓝 0)) (x y : ℂ) (hy : ‖y-x‖ ≠ r) : + Tendsto (fun n => kernel (k n) x y) atTop + (𝓝 ((Metric.ball x r).indicator (fun _ => (1 : ℝ)) y)) := by + by_cases h : ‖y-x‖ < r + · have he : ∀ᶠ n in atTop, kernel (k n) x y = 1 := by + filter_upwards [hδ.eventually_lt_const (sub_pos.mpr h)] with n hn + exact kernel_one (k n) x (by + simp only [Metric.mem_ball, dist_eq_norm] + linarith) + have hmem : y ∈ Metric.ball x r := by simpa only [Metric.mem_ball, dist_eq_norm] using h + rw [indicator_of_mem hmem] + exact tendsto_const_nhds.congr' (he.mono fun _ hn => hn.symm) + · have hh : r < ‖y-x‖ := lt_of_le_of_ne (le_of_not_gt h) (Ne.symm hy) + have he : ∀ᶠ n in atTop, kernel (k n) x y = 0 := by + filter_upwards [hδ.eventually_lt_const (sub_pos.mpr hh)] with n hn + exact kernel_zero (k n) x (by + simp only [Metric.mem_ball, dist_eq_norm, not_lt] + linarith) + have hmem : y ∉ Metric.ball x r := by simpa only [Metric.mem_ball, dist_eq_norm] using h + rw [indicator_of_notMem hmem] + exact tendsto_const_nhds.congr' (he.mono fun _ hn => hn.symm) + +/-- Dominated convergence of an arbitrary sequence of mixtures against each + actual absolutely continuous finite vector measure. -/ +lemma tendsto_kernel_pairing {r : ℝ} {δ : ℕ → ℝ} {M : ℕ → ℝ≥0} + (k : ∀ n, RadiusDensity (r-δ n) (r+δ n) (M n)) + (hδ : Tendsto δ atTop (𝓝 0)) (x : ℂ) {b : ℂ → ℂ} (hb : Integrable b) : + Tendsto (fun n => ∫ y, (kernel (k n) x y : ℂ)*b y) atTop + (𝓝 (∫ y in Metric.ball x r, b y)) := by + rw [← integral_indicator measurableSet_ball] + apply tendsto_integral_of_dominated_convergence (fun y => ‖b y‖) + · intro n + exact (complex_kernel_lipschitz (k n) x).continuous.aestronglyMeasurable.mul hb.aestronglyMeasurable + · exact hb.norm + · intro n + filter_upwards with y + change ‖(kernel (k n) x y : ℂ)*b y‖ ≤ ‖b y‖ + rw [norm_mul] + exact mul_le_of_le_one_left (norm_nonneg _) (complex_kernel_bound (k n) x y) + · have hcircle : ∀ᵐ y : ℂ, ‖y-x‖ ≠ r := by + simpa only [Metric.mem_sphere, dist_eq_norm] using (measure_eq_zero_iff_ae_notMem.mp (Measure.addHaar_sphere volume x r)) + filter_upwards [hcircle] with y hy + have h := (Complex.continuous_ofReal.tendsto _).comp (tendsto_kernel k hδ x y hy) + have hm := h.mul_const (b y) + convert! hm using 1 + by_cases hmem : y ∈ Metric.ball x r + · simp only [indicator_of_mem hmem, Complex.ofReal_one, one_mul] + · simp only [indicator_of_notMem hmem, Complex.ofReal_zero, zero_mul] + +end DiskKernels + +namespace LocalCancellation +open DiskGeometry + +variable {ι : Type*} [Fintype ι] + +theorem size_step {Cs α δ ρ U : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hα : α ≤ 1) (hδ : 0 < δ) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hδρ : δ ≤ ρ^2/1600) (hU : 0 < U) : + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ + (ENNReal.ofReal U)⁻¹ ^ 2 * + (ENNReal.ofReal (156*δ/ρ)*ENNReal.ofReal (coarseMass b δ univ)*ENNReal.ofReal (coarseMass b δ univ)) + + (ENNReal.ofReal U)⁻¹ * + ((ENNReal.ofReal (6*Real.pi)*ENNReal.ofReal (2*(200*δ/ρ^2)))*ENNReal.ofReal (coarseMass b δ univ)) ∧ + ∀ x ∉ E, ∀ r ∈ Icc (1 : ℝ) 2, ∀ (L : ℝ≥0) (F : ℂ → ℂ), + LipschitzWith L F → (∀ y, ‖F y‖ ≤ 1) → + (∀ y, F y ≠ 0 → y ∈ thinShell x r δ) → + (U ≤ coarseMass b δ (thinShell x r δ) → + (∑ d, ∫ y, star (y-x)*F y*(b d).density y) = 0) → + ‖∑ d, ∫ y, F y*(b d).density y‖ ≤ + 2*ρ*coarseMass b δ univ+14*U+ + ((L : ℝ)+2*(3*(L : ℝ)+1))*Cs*δ^(2*(1-α))*errorPrice b α := by + obtain ⟨E, hE, hEv, hcap⟩ := shell_concentration (coarseMeasure b δ) (0 : Measure ℂ) + hρ hρ1 hδ hδρ (le_refl 0) hU + refine ⟨E, hE, ?_, ?_⟩ + · simpa only [coarseMeasure_apply b δ MeasurableSet.univ, zero_div, add_zero, mul_one] using hEv + · intro x hx r hr L F hF hFb hFD hzero + have hδ1 : δ ≤ 1 := by nlinarith [sq_nonneg (ρ-1)] + have hδq : δ ≤ 1/4 := by nlinarith [sq_nonneg (ρ-1)] + have hM0 : 0 ≤ coarseMass b δ univ := by + rw [coarseMass_univ] + exact Finset.sum_nonneg (fun d _ => (b d).mass_nonneg) + have hf0 : 0 ≤ Cs*δ^(2*(1-α))*errorPrice b α := + mul_nonneg (mul_nonneg hCs (Real.rpow_nonneg hδ.le _)) (errorPrice_nonneg b α) + by_cases hactive : U ≤ coarseMass b δ (thinShell x r δ) + · have hact : ENNReal.ofReal U ≤ coarseMeasure b δ (thinShell x r δ) := by + rw [coarseMeasure_apply b δ (measurableSet_thinShell x r δ)] + exact ENNReal.ofReal_le_ofReal hactive + obtain ⟨z, hz, hzc⟩ := hcap x hx r hr hact (by simp) + have hzc' : coarseMass b δ (thinShell x r δ \ Metric.ball z ρ) ≤ 2*U := by + rw [zero_add, coarseMeasure_apply b δ ((measurableSet_thinShell x r δ).diff measurableSet_ball)] at hzc + exact (ENNReal.ofReal_le_ofReal_iff (by positivity)).mp hzc + have hzbound : 1/2 ≤ ‖z-x‖ := by + simpa only [norm_sub_rev] using (shell_center_bounds hr hδq hz).1 + have hD3 : ∀ y ∈ thinShell x r δ, ‖y-x‖ ≤ 3 := by + intro y hy + simpa only [norm_sub_rev] using (shell_center_bounds hr hδq hy).2 + have hc := corrected_increment_bound b hCs hα hδ.le hδ1 hρ.le hF + (measurableSet_thinShell x r δ) hFb hFD x z hzbound hD3 (hzero hactive) + nlinarith + · have hi := increment_bound b hCs hα hδ.le hδ1 hF + (measurableSet_thinShell x r δ) hFb hFD + have hx0 : 0 ≤ 2*ρ*coarseMass b δ univ := by positivity + have hL : (L : ℝ) ≤ (L : ℝ)+2*(3*(L : ℝ)+1) := by linarith [L.coe_nonneg] + have hh := mul_le_mul_of_nonneg_right hL hf0 + nlinarith + +end LocalCancellation + +namespace DiskGeometry + +lemma thinShell_eq_diff {x : ℂ} {r δ : ℝ} : + thinShell x r δ = Metric.closedBall x (r+δ) \ Metric.ball x (r-δ) := by + ext y + simp only [thinShell, mem_ofPred_eq, abs_le, Set.mem_sdiff, Metric.mem_closedBall, + Metric.mem_ball, dist_eq_norm, not_lt] + constructor <;> intro h <;> constructor <;> linarith [h.1, h.2] + +/-- Exact area of an annulus, including the inner and outer circles. -/ +lemma volume_thinShell (x : ℂ) {r δ : ℝ} (hδ : 0 ≤ δ) (hr : δ ≤ r) : + volume (thinShell x r δ) = ENNReal.ofReal (4*Real.pi*r*δ) := by + have hi : 0 ≤ r-δ := sub_nonneg.mpr hr + have ho : 0 ≤ r+δ := by linarith + rw [thinShell_eq_diff, measure_sdiff (fun y hy => Metric.ball_subset_closedBall + (Metric.ball_subset_ball (by linarith) hy)) measurableSet_ball.nullMeasurableSet measure_ball_lt_top.ne, + Complex.volume_closedBall, Complex.volume_ball] + rw [← ENNReal.ofReal_pow ho, ← ENNReal.ofReal_pow hi] + rw [← (ENNReal.ofReal_coe_nnreal : ENNReal.ofReal (NNReal.pi : ℝ) = (NNReal.pi : ℝ≥0∞))] + change ENNReal.ofReal ((r+δ)^2) * ENNReal.ofReal Real.pi - + ENNReal.ofReal ((r-δ)^2) * ENNReal.ofReal Real.pi = ENNReal.ofReal (4*Real.pi*r*δ) + rw [← ENNReal.ofReal_mul (sq_nonneg _), ← ENNReal.ofReal_mul (sq_nonneg _), + ← ENNReal.ofReal_sub _ (mul_nonneg (sq_nonneg _) Real.pi_pos.le)] + congr 1 + ring + +lemma measurableSet_shellPairs (r δ : ℝ) : + MeasurableSet {p : ℂ × ℂ | p.2 ∈ thinShell p.1 r δ} := by + exact measurableSet_le (by fun_prop : Measurable (fun p : ℂ × ℂ => |‖p.2-p.1‖-r|)) measurable_const + +def shellMass (ν : Measure ℂ) (r δ : ℝ) (x : ℂ) : ℝ≥0∞ := ν (thinShell x r δ) + +lemma measurable_shellMass (ν : Measure ℂ) [IsFiniteMeasure ν] (r δ : ℝ) : + Measurable (shellMass ν r δ) := + measurable_measure_prodMk_left (measurableSet_shellPairs r δ) + +lemma shell_symm (x y : ℂ) (r δ : ℝ) : y ∈ thinShell x r δ ↔ x ∈ thinShell y r δ := by + simp only [thinShell, mem_ofPred_eq, norm_sub_rev x y] + +/-- The integrated shell mass is its exact area times the total input mass. -/ +lemma lintegral_shellMass (ν : Measure ℂ) [IsFiniteMeasure ν] {r δ : ℝ} + (hδ : 0 ≤ δ) (hr : δ ≤ r) : + (∫⁻ x, shellMass ν r δ x) = ENNReal.ofReal (4*Real.pi*r*δ)*ν univ := by + let A : Set (ℂ × ℂ) := {p | p.2 ∈ thinShell p.1 r δ} + have hA : MeasurableSet A := measurableSet_shellPairs r δ + have he (x : ℂ) : shellMass ν r δ x = ∫⁻ y, A.indicator 1 (x,y) ∂ν := by + rw [show (fun y : ℂ => A.indicator 1 (x,y)) = (thinShell x r δ).indicator 1 by + ext y; exact (indicator_comp_right (fun y : ℂ => (x,y))).symm] + exact (lintegral_indicator_one (measurableSet_thinShell x r δ)).symm + simp_rw [he] + rw [lintegral_lintegral_swap (f := fun x y : ℂ => A.indicator 1 (x,y)) + (measurable_const.indicator hA).aemeasurable] + have hei (y : ℂ) : (fun x : ℂ => A.indicator (1 : ℂ × ℂ → ℝ≥0∞) (x,y)) = + (thinShell y r δ).indicator 1 := by + ext x + by_cases h : y ∈ thinShell x r δ + · rw [indicator_of_mem (show (x,y) ∈ A from h), indicator_of_mem ((shell_symm x y r δ).mp h)] + rfl + · rw [indicator_of_notMem (show (x,y) ∉ A from h), indicator_of_notMem (fun hx => h ((shell_symm x y r δ).mpr hx))] + simp_rw [hei, lintegral_indicator_one (measurableSet_thinShell _ r δ), volume_thinShell _ hδ hr] + exact lintegral_const _ + +lemma shellMass_exception (ν : Measure ℂ) [IsFiniteMeasure ν] {r δ U : ℝ} + (hδ : 0 ≤ δ) (hr : δ ≤ r) (hU : 0 < U) : + MeasurableSet {x | ENNReal.ofReal U ≤ shellMass ν r δ x} ∧ + volume {x | ENNReal.ofReal U ≤ shellMass ν r δ x} ≤ + ENNReal.ofReal (4*Real.pi*r*δ)*ν univ / ENNReal.ofReal U := by + refine ⟨measurableSet_le measurable_const (measurable_shellMass ν r δ), ?_⟩ + have h := meas_ge_le_lintegral_div (μ := (volume : Measure ℂ)) + (measurable_shellMass ν r δ).aemeasurable (ENNReal.ofReal_pos.mpr hU).ne' ENNReal.ofReal_ne_top + rwa [lintegral_shellMass ν hδ hr] at h + +/-- A shell whose radius is sufficiently close to an endpoint is contained + in the endpoint annulus; this covers forced endpoint radii as well. -/ +lemma thinShell_subset_endpoint {x : ℂ} {r a δ : ℝ} (hra : |r-a| ≤ δ) : + thinShell x r δ ⊆ thinShell x a (2*δ) := by + intro y hy + change |‖y-x‖-r| ≤ δ at hy + change |‖y-x‖-a| ≤ 2*δ + calc + _ = |(‖y-x‖-r)+(r-a)| := by congr 1; ring + _ ≤ |‖y-x‖-r|+|r-a| := abs_add_le _ _ + _ ≤ 2*δ := by linarith + +end DiskGeometry + +namespace DiskScales + +def width (δ : ℝ) (n : ℕ) : ℝ := δ*(1/2 : ℝ)^n + +lemma width_pos {δ : ℝ} (hδ : 0 < δ) (n : ℕ) : 0 < width δ n := by + unfold width + positivity + +lemma width_le {δ : ℝ} (hδ : 0 ≤ δ) (n : ℕ) : width δ n ≤ δ := by + unfold width + exact mul_le_of_le_one_right hδ (pow_le_one₀ (by norm_num) (by norm_num)) + +lemma width_succ (δ : ℝ) (n : ℕ) : width δ (n+1) = width δ n / 2 := by + simp only [width, pow_succ] + ring + +lemma width_antitone {δ : ℝ} (hδ : 0 ≤ δ) : Antitone (width δ) := by + apply antitone_nat_of_succ_le + intro n + rw [width_succ] + have : 0 ≤ width δ n := mul_nonneg hδ (pow_nonneg (by norm_num) _) + linarith + +lemma tendsto_width (δ : ℝ) : Tendsto (width δ) atTop (𝓝 0) := by + change Tendsto (fun n => δ*(1/2 : ℝ)^n) atTop (𝓝 0) + simpa only [mul_zero] using + (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 1/2) + (by norm_num : (1/2 : ℝ) < 1)).const_mul δ + +lemma width_rpow {δ : ℝ} (hδ : 0 ≤ δ) (p : ℝ) (n : ℕ) : + (width δ n)^p = δ^p*((1/2 : ℝ)^p)^n := by + rw [width, Real.mul_rpow hδ (pow_nonneg (by norm_num) n)] + congr 1 + rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num), + mul_comm (n : ℝ) p, Real.rpow_mul (by norm_num), Real.rpow_natCast] + +lemma ratio_norm_lt {p : ℝ} (hp : 0 < p) : ‖(1/2 : ℝ)^p‖ < 1 := by + rw [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg (by norm_num) _)] + exact Real.rpow_lt_one (by norm_num) (by norm_num) hp + +lemma summable_width_rpow {δ p : ℝ} (hδ : 0 ≤ δ) (hp : 0 < p) : + Summable (fun n => (width δ n)^p) := by + simp_rw [width_rpow hδ] + exact (summable_geometric_of_norm_lt_one (ratio_norm_lt hp)).mul_left _ + +lemma tsum_width_rpow {δ p : ℝ} (hδ : 0 ≤ δ) (hp : 0 < p) : + (∑' n, (width δ n)^p) = δ^p / (1-(1/2 : ℝ)^p) := by + simp_rw [width_rpow hδ] + rw [tsum_mul_left, tsum_geometric_of_norm_lt_one (ratio_norm_lt hp)] + rfl + +lemma scaled_increment {Cs A t δ M L : ℝ} (hCs : 0 ≤ Cs) (hA : 0 ≤ A) + (hAt : A ≤ t) (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (hM : M ≤ A*δ^(-(1/50 : ℝ))) (hL : L ≤ 648/δ) : + 2*δ^(1/5 : ℝ)*M+14*(t*δ^(1/10 : ℝ))+ + (L+2*(3*L+1))*Cs*δ^(2*(1-(1/100 : ℝ)))*A ≤ + (16+4538*Cs)*t*δ^(1/10 : ℝ) := by + have ht : 0 ≤ t := hA.trans hAt + have hc : L+2*(3*L+1) ≤ 4538/δ := by + have hh : L*δ ≤ 648 := (le_div_iff₀ hδ).mp hL + apply (le_div_iff₀ hδ).mpr + nlinarith + have he1 : δ^(1/5 : ℝ)*δ^(-(1/50 : ℝ)) = δ^(9/50 : ℝ) := by + rw [← Real.rpow_add hδ] + norm_num + have he2 : δ⁻¹*δ^(2*(1-(1/100 : ℝ))) = δ^(49/50 : ℝ) := by + rw [← Real.rpow_neg_one, ← Real.rpow_add hδ] + norm_num + have hb1 : δ^(9/50 : ℝ) ≤ δ^(1/10 : ℝ) := + Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num) + have hb2 : δ^(49/50 : ℝ) ≤ δ^(1/10 : ℝ) := + Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num) + have hm : 2*δ^(1/5 : ℝ)*M ≤ 2*t*δ^(1/10 : ℝ) := by + calc + _ ≤ 2*δ^(1/5 : ℝ)*(A*δ^(-(1/50 : ℝ))) := + mul_le_mul_of_nonneg_left hM (by positivity) + _ = 2*A*δ^(9/50 : ℝ) := by rw [← he1]; ring + _ ≤ 2*t*δ^(1/10 : ℝ) := mul_le_mul (by linarith) hb1 + (Real.rpow_nonneg hδ.le _) (by positivity) + have hf : (L+2*(3*L+1))*Cs*δ^(2*(1-(1/100 : ℝ)))*A ≤ + 4538*Cs*t*δ^(1/10 : ℝ) := by + calc + _ ≤ (4538/δ)*Cs*δ^(2*(1-(1/100 : ℝ)))*A := by gcongr + _ = 4538*Cs*A*δ^(49/50 : ℝ) := by rw [← he2]; ring + _ ≤ 4538*Cs*t*δ^(1/10 : ℝ) := mul_le_mul (by gcongr) hb2 + (Real.rpow_nonneg hδ.le _) (by positivity) + nlinarith + +/-- A single small width works for both shell geometry and every smaller width. -/ +lemma exists_admissible_width : ∃ δ₀ : ℝ, 0 < δ₀ ∧ δ₀ ≤ 1/4 ∧ + ∀ δ : ℝ, 0 < δ → δ ≤ δ₀ → δ ≤ (δ^(1/5 : ℝ))^2/1600 := by + have ht : Tendsto (fun δ : ℝ => δ^(3/5 : ℝ)) (𝓝 0) (𝓝 0) := by + simpa using (Real.continuous_rpow_const (by norm_num : (0 : ℝ) ≤ 3/5)).tendsto 0 + have hev := ht.eventually_lt_const (by norm_num : (0 : ℝ) < 1/1600) + obtain ⟨l,u,hu,hs⟩ := mem_nhds_iff_exists_Ioo_subset.mp hev + let d := min (u/2) (1/4) + have hd : 0 < d := lt_min (by linarith [hu.2]) (by norm_num) + refine ⟨d, hd, min_le_right _ _, fun δ hδ hδd => ?_⟩ + have hdltu : d < u := lt_of_le_of_lt (min_le_left _ _) (by linarith [hu.2]) + have hp : δ^(3/5 : ℝ) < 1/1600 := hs ⟨lt_trans hu.1 hδ, lt_of_le_of_lt hδd hdltu⟩ + have he : δ = δ^(3/5 : ℝ)*(δ^(1/5 : ℝ))^2 := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hδ.le, ← Real.rpow_add hδ] + norm_num + calc + δ = δ^(3/5 : ℝ)*(δ^(1/5 : ℝ))^2 := he + _ ≤ (δ^(1/5 : ℝ))^2/1600 := + (mul_le_mul_of_nonneg_right hp.le (sq_nonneg _)).trans_eq (by ring) + +end DiskScales + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/LocalCancellation3.lean b/lean/OAI/Analysis/SignedDisk/LocalCancellation3.lean new file mode 100644 index 0000000000000000000000000000000000000000..2014a67f7d003e88e2a9347ce73502a0021ada63 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/LocalCancellation3.lean @@ -0,0 +1,403 @@ +import OAI.Analysis.SignedDisk.LocalCancellation2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace LocalCancellation +open DiskGeometry DiskKernels DiskScales +variable {ι : Type*} [Fintype ι] + +/-- Uniform exceptional sets controlling a whole decreasing sequence of disk +mixtures. Only active increments require the exact balanced moment. -/ +theorem size_sequence {Cs d t : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hdq : d ≤ 1/4) + (hgeom : ∀ δ : ℝ, 0 < δ → δ ≤ d → δ ≤ (δ^(1/5 : ℝ))^2/1600) + (ht : 0 < t) (hAt : errorPrice b (1/100) ≤ t) : + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ ∑' n : ℕ, ( + (ENNReal.ofReal (t*(width d n)^(1/10 : ℝ)))⁻¹ ^ 2 * + (ENNReal.ofReal (156*width d n/(width d n)^(1/5 : ℝ))* + ENNReal.ofReal (coarseMass b (width d n) univ)*ENNReal.ofReal (coarseMass b (width d n) univ)) + + (ENNReal.ofReal (t*(width d n)^(1/10 : ℝ)))⁻¹ * + ((ENNReal.ofReal (6*Real.pi)*ENNReal.ofReal (2*(200*width d n/((width d n)^(1/5 : ℝ))^2)))* + ENNReal.ofReal (coarseMass b (width d n) univ))) ∧ + ∀ x ∉ E, ∀ r ∈ Icc (1 : ℝ) 2, + ∀ k : ∀ n : ℕ, RadiusDensity (r-width d n) (r+width d n) + ⟨216/width d n, div_nonneg (by norm_num) (width_pos hd n).le⟩, + (∀ n, t*(width d n)^(1/10 : ℝ) ≤ coarseMass b (width d n) (thinShell x r (width d n)) → + (∑ j, ∫ y, star (y-x)*((kernel (k (n+1)) x y : ℂ)-kernel (k n) x y)*(b j).density y) = 0) → + ‖∑ j, ∫ y in Metric.ball x r, (b j).density y‖ ≤ + (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100)+ + (16+4538*Cs)*t*d^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by + have hd1 : d ≤ 1 := by linarith + have hwp (n : ℕ) : 0 < width d n := width_pos hd n + have hw1 (n : ℕ) : width d n ≤ 1 := (width_le hd.le n).trans hd1 + have hρ (n : ℕ) : 0 < (width d n)^(1/5 : ℝ) := Real.rpow_pos_of_pos (hwp n) _ + have hρ1 (n : ℕ) : (width d n)^(1/5 : ℝ) ≤ 1 := + Real.rpow_le_one (hwp n).le (hw1 n) (by norm_num) + have hs (n : ℕ) := size_step b hCs (by norm_num : (1/100 : ℝ) ≤ 1) + (hwp n) (hρ n) (hρ1 n) (hgeom _ (hwp n) (width_le hd.le n)) + (mul_pos ht (Real.rpow_pos_of_pos (hwp n) (1/10 : ℝ))) + choose E hE hEv hEst using hs + refine ⟨⋃ n, E n, MeasurableSet.iUnion hE, + (measure_iUnion_le E).trans (ENNReal.tsum_le_tsum hEv), ?_⟩ + intro x hx r hr k hz + have hxE (n : ℕ) : x ∉ E n := fun hn => hx (mem_iUnion.mpr ⟨n,hn⟩) + let P (n : ℕ) : ℂ := ∑ j, ∫ y, (kernel (k n) x y : ℂ)*(b j).density y + let B : ℂ := ∑ j, ∫ y in Metric.ball x r, (b j).density y + have hPi (n : ℕ) (j : ι) : Integrable (fun y => (kernel (k n) x y : ℂ)*(b j).density y) := + integrable_bounded_pairing (b j).integrable (complex_kernel_lipschitz (k n) x).continuous.aestronglyMeasurable (complex_kernel_bound (k n) x) + have hdist (n : ℕ) : dist (P n) (P (n+1)) ≤ + (16+4538*Cs)*t*(width d n)^(1/10 : ℝ) := by + let F (y : ℂ) : ℂ := (kernel (k (n+1)) x y : ℂ)-kernel (k n) x y + have hL : 216/width d (n+1)+216/width d n ≤ 648/width d n := by + rw [width_succ] + apply le_of_eq + ring + have hF := (complex_kernel_lipschitz (k (n+1)) x).sub (complex_kernel_lipschitz (k n) x) + have hbnd := hEst n x (hxE n) r hr _ F hF + (difference_bound (k n) (k (n+1)) x) + (difference_support (k n) (k (n+1)) (width_antitone hd.le (Nat.le_succ n)) x) + (hz n) + have hM : coarseMass b (width d n) univ ≤ + errorPrice b (1/100)*(width d n)^(-(1/50 : ℝ)) := by + have hh := coarseMass_bound b (by norm_num : (0 : ℝ) ≤ 1/100) (hwp n) + norm_num at hh + simpa only [Real.rpow_neg (hwp n).le, div_eq_mul_inv] using hh + have hstep := scaled_increment hCs (errorPrice_nonneg b (1/100)) hAt (hwp n) (hw1 n) hM hL + have he : P (n+1)-P n = ∑ j, ∫ y, F y*(b j).density y := by + change (∑ j, ∫ y, (kernel (k (n+1)) x y : ℂ)*(b j).density y) - + (∑ j, ∫ y, (kernel (k n) x y : ℂ)*(b j).density y) = _ + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro j _ + rw [← integral_sub (hPi (n+1) j) (hPi n j)] + congr 1 + ext y + simp only [F, sub_mul] + rw [dist_eq_norm, norm_sub_rev, he] + exact hbnd.trans hstep + have hlim : Tendsto P atTop (𝓝 B) := + tendsto_finsetSum Finset.univ (fun j _ => tendsto_kernel_pairing k (tendsto_width d) x (b j).integrable) + have hsm : Summable (fun n => (16+4538*Cs)*t*(width d n)^(1/10 : ℝ)) := + (summable_width_rpow hd.le (by norm_num : (0 : ℝ) < 1/10)).mul_left _ + have htail := dist_le_tsum_of_dist_le_of_tendsto₀ _ hdist hsm hlim + rw [tsum_mul_left, tsum_width_rpow hd.le (by norm_num : (0 : ℝ) < 1/10)] at htail + have hstart : ‖P 0‖ ≤ (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100) := by + have hh := total_pairing_discount b (by norm_num : (0 : ℝ) ≤ 1/100) + (by norm_num : (1/100 : ℝ) ≤ 1) (hwp 0) (hw1 0) + (show 1 ≤ 1+216*Cs by linarith) + (complex_kernel_lipschitz (k 0) x) (complex_kernel_bound (k 0) x) + (show (216/width d 0)*Cs ≤ (1+216*Cs)/width d 0 by + apply (le_div_iff₀ (hwp 0)).mpr + field_simp [(hwp 0).ne'] + linarith) + simpa only [P, width, pow_zero, mul_one] using hh + calc + ‖B‖ = ‖P 0+(B-P 0)‖ := by congr 1; ring + _ ≤ ‖P 0‖+‖B-P 0‖ := norm_add_le _ _ + _ = ‖P 0‖+dist (P 0) B := by rw [dist_eq_norm, norm_sub_rev] + _ ≤ (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100)+ + (16+4538*Cs)*t*(d^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ))) := + add_le_add hstart htail + _ = _ := by ring + +end LocalCancellation + +namespace DiskGeometry + +def endpointFailure (ν : Measure ℂ) (δ U : ℝ) : Set ℂ := + {x | ENNReal.ofReal U ≤ shellMass ν 1 (2*δ) x} ∪ + {x | ENNReal.ofReal U ≤ shellMass ν 2 (2*δ) x} + +lemma endpoint_failure_bound (ν : Measure ℂ) [IsFiniteMeasure ν] + {δ U : ℝ} (hδ : 0 ≤ δ) (hδq : δ ≤ 1/4) (hU : 0 < U) : + MeasurableSet (endpointFailure ν δ U) ∧ + volume (endpointFailure ν δ U) ≤ ENNReal.ofReal (24*Real.pi*δ)*ν univ/ENNReal.ofReal U := by + obtain ⟨h1,hb1⟩ := shellMass_exception ν (show 0 ≤ 2*δ by positivity) + (show 2*δ ≤ 1 by linarith) hU + obtain ⟨h2,hb2⟩ := shellMass_exception ν (show 0 ≤ 2*δ by positivity) + (show 2*δ ≤ 2 by linarith) hU + refine ⟨h1.union h2, (measure_union_le _ _).trans ((add_le_add hb1 hb2).trans_eq ?_)⟩ + simp only [div_eq_mul_inv] + rw [← add_mul, ← add_mul, ← ENNReal.ofReal_add (by positivity) (by positivity)] + congr 3 + ring + +lemma active_away_from_endpoints (ν : Measure ℂ) {x : ℂ} {δ U r : ℝ} + (hx : x ∉ endpointFailure ν δ U) (hr : r ∈ Icc (1 : ℝ) 2) + (ha : ENNReal.ofReal U ≤ ν (thinShell x r δ)) : + 1+δ ≤ r ∧ r+δ ≤ 2 := by + constructor + · by_contra hh + have he : |r-1| ≤ δ := by rw [abs_of_nonneg (by linarith [hr.1])]; linarith + exact hx (Or.inl (ha.trans (measure_mono (thinShell_subset_endpoint he)))) + · by_contra hh + have he : |r-2| ≤ δ := by rw [abs_of_nonpos (by linarith [hr.2])]; linarith + exact hx (Or.inr (ha.trans (measure_mono (thinShell_subset_endpoint he)))) + +end DiskGeometry + +namespace DiskMoments +open DiskKernels DiskGeometry + +def EndpointRadius (g : ℂ → ℝ) (x : ℂ) (r : ℝ) : Prop := + r ∈ Icc (1 : ℝ) 2 ∧ (r = 1 ∨ r = 2 ∨ + ∀ t ∈ Icc (1 : ℝ) 2, signedAverage g x t ≤ signedAverage g x r) + +/-- Every band-maximizing or forced-endpoint radius has honest mixtures; +balancing is imposed exactly when its width stays inside the band. -/ +lemma endpoint_kernel {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {x : ℂ} {r δ : ℝ} + (hr : EndpointRadius g x r) (hδ : 0 < δ) (hδq : δ ≤ 1/4) : + ∃ k : RadiusDensity (r-δ) (r+δ) ⟨216/δ, by positivity⟩, + (1+δ ≤ r ∧ r+δ ≤ 2 → + (∫ y, kernel k x y • (star (y-x)*gradient g y)) = 0) := by + by_cases hi : 1+δ ≤ r ∧ r+δ ≤ 2 + · have hm : ∀ t ∈ Icc (1 : ℝ) 2, signedAverage g x t ≤ signedAverage g x r := by + rcases hr.2 with h | h | h + · linarith [hi.1] + · linarith [hi.2] + · exact h + obtain ⟨k,hk⟩ := balanced_kernel hg x hr.1 hδ hδq + (hm _ ⟨by linarith [hi.1], by linarith [hr.1.2]⟩) + (hm _ ⟨by linarith [hr.1.1], hi.2⟩) + exact ⟨k, fun _ => hk⟩ + · have ha : (1 : ℝ)/2 ≤ r-δ := by linarith [hr.1.1] + have hb : r+δ ≤ (3 : ℝ) := by linarith [hr.1.2] + have hab : r-δ < r+δ := by linarith + let k := inverseCubeDensity (r-δ) (r+δ) ha hb hab + refine ⟨enlarge k le_rfl le_rfl ?_, fun h => (hi h).elim⟩ + change 216/(r+δ-(r-δ)) ≤ 216/δ + apply div_le_div_of_nonneg_left (by norm_num) hδ + linarith + +end DiskMoments + +namespace LocalCancellation +open DiskKernels DiskMoments DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +lemma moment_pairing_integrable {Cs r δ : ℝ} (b : ErrorPiece Cs) + {M : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) (x : ℂ) (hr : r+δ ≤ 3) : + Integrable (fun y => star (y-x)*(kernel k x y : ℂ)*b.density y) := by + apply integrable_bounded_pairing b.integrable + ((by fun_prop : Continuous (fun y : ℂ => star (y-x))).mul + (complex_kernel_lipschitz k x).continuous).aestronglyMeasurable + apply position_bound (complex_kernel_bound k x) x (by norm_num : (0 : ℝ) ≤ 3) + intro y hy + have hyb : y ∈ Metric.ball x (r+δ) := by + by_contra hh + exact hy (by rw [kernel_zero k x hh, Complex.ofReal_zero]) + exact (show ‖y-x‖ < r+δ by simpa only [Metric.mem_ball, dist_eq_norm] using hyb).le.trans hr + +/-- A local equality of genuine densities suffices for all supported moments. -/ +lemma moment_pairing_decomposition {Cs r δ : ℝ} (b : ι → ErrorPiece Cs) + {M : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) (x : ℂ) {h : ℂ → ℂ} + (hr : r+δ ≤ 3) (hh : ∀ᵐ y, y ∈ Metric.ball x 3 → ∑ j, (b j).density y = h y) : + (∑ j, ∫ y, star (y-x)*(kernel k x y : ℂ)*(b j).density y) = + ∫ y, kernel k x y • (star (y-x)*h y) := by + rw [← integral_finsetSum _ (fun j _ => moment_pairing_integrable (b j) k x hr)] + apply integral_congr_ae + filter_upwards [hh] with y hy + simp only [← Finset.mul_sum] + by_cases hmem : y ∈ Metric.ball x 3 + · rw [hy hmem, Complex.real_smul] + ring + · have hk : kernel k x y = 0 := kernel_zero k x + (fun hb => hmem (lt_of_lt_of_le hb hr)) + rw [hk, Complex.ofReal_zero, mul_zero, zero_mul, zero_smul] + +lemma moment_difference_decomposition {Cs r δ ε : ℝ} (b : ι → ErrorPiece Cs) + {M N : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) + (l : RadiusDensity (r-ε) (r+ε) N) (x : ℂ) {h : ℂ → ℂ} + (hrδ : r+δ ≤ 3) (hrε : r+ε ≤ 3) + (hh : ∀ᵐ y, y ∈ Metric.ball x 3 → ∑ j, (b j).density y = h y) + (hk : (∫ y, kernel k x y • (star (y-x)*h y)) = 0) + (hl : (∫ y, kernel l x y • (star (y-x)*h y)) = 0) : + (∑ j, ∫ y, star (y-x)*((kernel l x y : ℂ)-kernel k x y)*(b j).density y) = 0 := by + have he : ∀ j, (∫ y, star (y-x)*((kernel l x y : ℂ)-kernel k x y)*(b j).density y) = + (∫ y, star (y-x)*(kernel l x y : ℂ)*(b j).density y) - + (∫ y, star (y-x)*(kernel k x y : ℂ)*(b j).density y) := by + intro j + rw [← integral_sub (moment_pairing_integrable (b j) l x hrε) + (moment_pairing_integrable (b j) k x hrδ)] + congr 1 + ext y + ring + simp_rw [he] + rw [Finset.sum_sub_distrib, moment_pairing_decomposition b l x hrε hh, + moment_pairing_decomposition b k x hrδ hh, hk, hl, sub_self] + +lemma ball_pairing_decomposition {Cs r : ℝ} (b : ι → ErrorPiece Cs) + (x : ℂ) {h : ℂ → ℂ} (hr : r ≤ 3) + (hh : ∀ᵐ y, y ∈ Metric.ball x 3 → ∑ j, (b j).density y = h y) : + (∑ j, ∫ y in Metric.ball x r, (b j).density y) = ∫ y in Metric.ball x r, h y := by + rw [← integral_finsetSum _ (fun j _ => (b j).integrable.integrableOn)] + apply setIntegral_congr_ae measurableSet_ball + filter_upwards [hh] with y hy hyb + exact hy (lt_of_lt_of_le hyb hr) + +/-- The full raw band-endpoint size estimate. All maxima and both forced radii +are simultaneous, with no measurable radius selection required. -/ +theorem size_endpoint_raw {Cs d t : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hdq : d ≤ 1/4) + (hgeom : ∀ δ : ℝ, 0 < δ → δ ≤ d → δ ≤ (δ^(1/5 : ℝ))^2/1600) + (ht : 0 < t) (hAt : errorPrice b (1/100) ≤ t) + {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) : + ∃ E : Set ℂ, MeasurableSet E ∧ + volume E ≤ ∑' n : ℕ, ( + (ENNReal.ofReal (t*(width d n)^(1/10 : ℝ)))⁻¹ ^ 2 * + (ENNReal.ofReal (156*width d n/(width d n)^(1/5 : ℝ))* + ENNReal.ofReal (coarseMass b (width d n) univ)*ENNReal.ofReal (coarseMass b (width d n) univ)) + + (ENNReal.ofReal (t*(width d n)^(1/10 : ℝ)))⁻¹ * + ((ENNReal.ofReal (6*Real.pi)*ENNReal.ofReal (2*(200*width d n/((width d n)^(1/5 : ℝ))^2)))* + ENNReal.ofReal (coarseMass b (width d n) univ)) + + ENNReal.ofReal (24*Real.pi*width d n)*ENNReal.ofReal (coarseMass b (width d n) univ)/ + ENNReal.ofReal (t*(width d n)^(1/10 : ℝ))) ∧ + ∀ x ∉ E, + (∀ᵐ y, y ∈ Metric.ball x 3 → ∑ j, (b j).density y = gradient g y) → + ∀ r, EndpointRadius g x r → + ‖∫ y in Metric.ball x r, gradient g y‖ ≤ + (1+216*Cs)/d^(1/100 : ℝ)*errorPrice b (1/100)+ + (16+4538*Cs)*t*d^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by + have hwp (n : ℕ) : 0 < width d n := width_pos hd n + have hwq (n : ℕ) : width d n ≤ 1/4 := (width_le hd.le n).trans hdq + let F (n : ℕ) := endpointFailure (coarseMeasure b (width d n)) (width d n) + (t*(width d n)^(1/10 : ℝ)) + have hF (n : ℕ) := endpoint_failure_bound (coarseMeasure b (width d n)) + (hwp n).le (hwq n) (mul_pos ht (Real.rpow_pos_of_pos (hwp n) (1/10 : ℝ))) + obtain ⟨E,hE,hEv,hEst⟩ := size_sequence b hCs hd hdq hgeom ht hAt + refine ⟨E ∪ ⋃ n, F n, hE.union (MeasurableSet.iUnion fun n => (hF n).1), ?_, ?_⟩ + · apply (measure_union_le _ _).trans + apply (add_le_add hEv ((measure_iUnion_le F).trans (ENNReal.tsum_le_tsum (fun n => (hF n).2)))).trans_eq + rw [← ENNReal.tsum_add] + congr 1 + funext n + rw [coarseMeasure_apply b (width d n) MeasurableSet.univ] + · intro x hx hh r hr + have hxE : x ∉ E := fun h => hx (Or.inl h) + have hxF (n : ℕ) : x ∉ F n := fun h => hx (Or.inr (mem_iUnion.mpr ⟨n,h⟩)) + choose k hk using fun n => endpoint_kernel hg hr (hwp n) (hwq n) + rw [← ball_pairing_decomposition b x (by linarith [hr.1.2]) hh] + apply hEst x hxE r hr.1 k + intro n ha + have haway : 1+width d n ≤ r ∧ r+width d n ≤ 2 := by + apply active_away_from_endpoints (coarseMeasure b (width d n)) (hxF n) hr.1 + rw [coarseMeasure_apply b (width d n) (measurableSet_thinShell x r (width d n))] + exact ENNReal.ofReal_le_ofReal ha + have haway' : 1+width d (n+1) ≤ r ∧ r+width d (n+1) ≤ 2 := by + have hw := width_antitone hd.le (Nat.le_succ n) + constructor <;> linarith [haway.1,haway.2] + exact moment_difference_decomposition b (k n) (k (n+1)) x + (by linarith [hr.1.2,hwq n]) (by linarith [hr.1.2,hwq (n+1)]) hh + (hk n haway) (hk (n+1) haway') + +end LocalCancellation + +namespace DiskScales + +lemma first_power_identity {δ : ℝ} (hδ : 0 < δ) : + (δ^(1/10 : ℝ))⁻¹^2 * (δ / δ^(1/5 : ℝ) * δ^(-(1/50 : ℝ)) * δ^(-(1/50 : ℝ))) = + δ^(14/25 : ℝ) := by + rw [← Real.rpow_neg hδ.le, ← Real.rpow_natCast, ← Real.rpow_mul hδ.le] + have he (a : ℝ) : δ / δ^a = δ^(1-a) := by + rw [Real.rpow_sub hδ, Real.rpow_one] + rw [he] + rw [← mul_assoc, ← mul_assoc, ← Real.rpow_add hδ, ← Real.rpow_add hδ, ← Real.rpow_add hδ] + norm_num + +lemma second_power_identity {δ : ℝ} (hδ : 0 < δ) : + (δ^(1/10 : ℝ))⁻¹ * (δ / (δ^(1/5 : ℝ))^2 * δ^(-(1/50 : ℝ))) = + δ^(12/25 : ℝ) := by + rw [← Real.rpow_neg hδ.le, ← Real.rpow_natCast, ← Real.rpow_mul hδ.le] + have he (a : ℝ) : δ / δ^a = δ^(1-a) := by + rw [Real.rpow_sub hδ, Real.rpow_one] + rw [he] + rw [← mul_assoc, ← Real.rpow_add hδ, ← Real.rpow_add hδ] + norm_num + +lemma endpoint_power_identity {δ : ℝ} (hδ : 0 < δ) : + δ * δ^(-(1/50 : ℝ)) / δ^(1/10 : ℝ) = δ^(22/25 : ℝ) := by + have he : δ * δ^(-(1/50 : ℝ)) = δ^(1-(1/50 : ℝ)) := by + simp only [Real.rpow_sub hδ, Real.rpow_one, Real.rpow_neg hδ.le, div_eq_mul_inv] + rw [he, ← Real.rpow_sub hδ] + norm_num + +/-- The two geometric failure mechanisms have integrable superlevel powers. -/ +lemma shell_tail_scaled {A t δ M : ℝ} (hA : 0 ≤ A) (ht : 0 < t) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hM0 : 0 ≤ M) + (hM : M ≤ A*δ^(-(1/50 : ℝ))) : + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ ^ 2 * + (ENNReal.ofReal (156*δ/δ^(1/5 : ℝ))*ENNReal.ofReal M*ENNReal.ofReal M) + + (ENNReal.ofReal (t*δ^(1/10 : ℝ)))⁻¹ * + ((ENNReal.ofReal (6*Real.pi)*ENNReal.ofReal (2*(200*δ/(δ^(1/5 : ℝ))^2)))*ENNReal.ofReal M) ≤ + ENNReal.ofReal (156*(A/t)^2*δ^(14/25 : ℝ)+2400*Real.pi*(A/t)*δ^(9/25 : ℝ)) := by + have hU : 0 < t*δ^(1/10 : ℝ) := mul_pos ht (Real.rpow_pos_of_pos hδ _) + rw [← ENNReal.ofReal_inv_of_pos hU, ← ENNReal.ofReal_pow (inv_nonneg.mpr hU.le)] + have hp : 0 ≤ 156*δ/δ^(1/5 : ℝ) := by positivity + have hp' : 0 ≤ 2*(200*δ/(δ^(1/5 : ℝ))^2) := by positivity + rw [← ENNReal.ofReal_mul hp, ← ENNReal.ofReal_mul (mul_nonneg hp hM0), + ← ENNReal.ofReal_mul (sq_nonneg _), + ← ENNReal.ofReal_mul (show (0 : ℝ) ≤ 6*Real.pi by positivity), + ← ENNReal.ofReal_mul (mul_nonneg (by positivity) hp'), + ← ENNReal.ofReal_mul (inv_nonneg.mpr hU.le), + ← ENNReal.ofReal_add (by positivity) (by positivity)] + apply ENNReal.ofReal_le_ofReal + have hfirst : (t*δ^(1/10 : ℝ))⁻¹^2 * (156*δ/δ^(1/5 : ℝ)*M*M) ≤ + 156*(A/t)^2*δ^(14/25 : ℝ) := by + calc + _ ≤ (t*δ^(1/10 : ℝ))⁻¹^2 * + (156*δ/δ^(1/5 : ℝ)*(A*δ^(-(1/50 : ℝ)))*(A*δ^(-(1/50 : ℝ)))) := by gcongr + _ = 156*(A/t)^2*δ^(14/25 : ℝ) := by + rw [← first_power_identity hδ] + simp only [mul_inv_rev] + ring + have hsecond : (t*δ^(1/10 : ℝ))⁻¹ * + (6*Real.pi*(2*(200*δ/(δ^(1/5 : ℝ))^2))*M) ≤ + 2400*Real.pi*(A/t)*δ^(9/25 : ℝ) := by + calc + _ ≤ (t*δ^(1/10 : ℝ))⁻¹ * + (6*Real.pi*(2*(200*δ/(δ^(1/5 : ℝ))^2))*(A*δ^(-(1/50 : ℝ)))) := by gcongr + _ = 2400*Real.pi*(A/t)*δ^(12/25 : ℝ) := by + rw [← second_power_identity hδ] + simp only [mul_inv_rev] + ring + _ ≤ 2400*Real.pi*(A/t)*δ^(9/25 : ℝ) := + mul_le_mul_of_nonneg_left (Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num)) (by positivity) + exact add_le_add hfirst hsecond + +lemma endpoint_tail_scaled {A t δ M : ℝ} (hA : 0 ≤ A) (ht : 0 < t) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (hM : M ≤ A*δ^(-(1/50 : ℝ))) : + ENNReal.ofReal (24*Real.pi*δ)*ENNReal.ofReal M / ENNReal.ofReal (t*δ^(1/10 : ℝ)) ≤ + ENNReal.ofReal (24*Real.pi*(A/t)*δ^(9/25 : ℝ)) := by + rw [← ENNReal.ofReal_mul (by positivity), ← ENNReal.ofReal_div_of_pos (by positivity)] + apply ENNReal.ofReal_le_ofReal + calc + _ ≤ (24*Real.pi*δ)*(A*δ^(-(1/50 : ℝ)))/(t*δ^(1/10 : ℝ)) := by gcongr + _ = 24*Real.pi*(A/t)*δ^(22/25 : ℝ) := by + rw [← endpoint_power_identity hδ] + ring + _ ≤ 24*Real.pi*(A/t)*δ^(9/25 : ℝ) := + mul_le_mul_of_nonneg_left (Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num)) (by positivity) + +end DiskScales + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/LocalCancellation4.lean b/lean/OAI/Analysis/SignedDisk/LocalCancellation4.lean new file mode 100644 index 0000000000000000000000000000000000000000..e03a02ec3d6d2242abc2022a8407876857f44ff9 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/LocalCancellation4.lean @@ -0,0 +1,415 @@ +import OAI.Analysis.SignedDisk.DiskScales1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace LocalCancellation + +section +open DiskKernels DiskGeometry + +/-- An integrable aggregate of vectors in a fixed acute cone. It covers the +positive pieces by taking their sum; no direction is imposed on errors. -/ +structure ConeDensity (e : ℂ) (κ : ℝ) where + density : ℂ → ℂ + integrable : Integrable density + cone : ∀ᵐ y, κ*‖density y‖ ≤ inner ℝ e (density y) + +lemma inner_unit_bound {e p : ℂ} (he : ‖e‖ = 1) : |inner ℝ e p| ≤ ‖p‖ := by + simpa only [he,one_mul] using abs_real_inner_le_norm e p + +lemma negative_projection_le_norm {e p : ℂ} (he : ‖e‖ = 1) : + max 0 (-inner ℝ e p) ≤ ‖p‖ := by + exact max_le (norm_nonneg _) ((neg_le_abs _).trans (inner_unit_bound he)) + +lemma negative_projection_change (e p q : ℂ) (he : ‖e‖ = 1) : + max 0 (-inner ℝ e q) ≤ max 0 (-inner ℝ e p)+‖q-p‖ := by + have h := inner_unit_bound (p := q-p) he + rw [inner_sub_right] at h + apply max_le + · positivity + · have hh := neg_le_abs (inner ℝ e q-inner ℝ e p) + have hm := le_max_right (0 : ℝ) (-inner ℝ e p) + linarith + +lemma cone_pairing {e : ℂ} {κ : ℝ} (a : ConeDensity e κ) + {K : ℂ → ℝ} (hK : AEStronglyMeasurable K) (hK0 : ∀ y, 0 ≤ K y) + (hK1 : ∀ y, K y ≤ 1) : + κ*(∫ y, K y*‖a.density y‖) ≤ inner ℝ e (∫ y, (K y : ℂ)*a.density y) := by + have hKn (y : ℂ) : ‖K y‖ ≤ 1 := by rw [Real.norm_eq_abs, abs_of_nonneg (hK0 y)]; exact hK1 y + have hi : Integrable (fun y => K y*‖a.density y‖) := a.integrable.norm.bdd_mul hK (ae_of_all _ hKn) + have hia : Integrable (fun y => (K y : ℂ)*a.density y) := + a.integrable.bdd_mul (Complex.continuous_ofReal.comp_aestronglyMeasurable hK) + (ae_of_all _ (fun y => by simpa only [Complex.norm_real] using hKn y)) + rw [← integral_const_mul, ← integral_inner hia e] + apply integral_mono_ae (hi.const_mul κ) ((innerSL ℝ e).integrable_comp hia) + filter_upwards [a.cone] with y hy + change κ*(K y*‖a.density y‖) ≤ inner ℝ e ((K y : ℂ)*a.density y) + rw [← Complex.real_smul, inner_smul_right] + nlinarith [mul_le_mul_of_nonneg_left hy (hK0 y)] + +/-- Nonpositive total projection bounds the weighted good mass by the error. -/ +lemma cone_mass_of_nonpositive {e : ℂ} {κ : ℝ} (a : ConeDensity e κ) + (he : ‖e‖ = 1) (hκ : 0 < κ) {K : ℂ → ℝ} (hK : AEStronglyMeasurable K) + (hK0 : ∀ y, 0 ≤ K y) (hK1 : ∀ y, K y ≤ 1) {p : ℂ} + (hp : inner ℝ e ((∫ y, (K y : ℂ)*a.density y)+p) ≤ 0) : + (∫ y, K y*‖a.density y‖) ≤ ‖p‖/κ := by + apply (le_div_iff₀ hκ).mpr + have hh := cone_pairing a hK hK0 hK1 + have hb := inner_unit_bound (p := p) he + rw [inner_add_right] at hp + have hn := neg_le_abs (inner ℝ e p) + nlinarith + +/-- Crossing the zero projection selects a genuine convex kernel, not an +arbitrary discontinuous truncation. -/ +lemma crossing_interpolation (e p q : ℂ) (hq : inner ℝ e q < 0) : + ∃ θ : ℝ, 0 ≤ θ ∧ θ ≤ 1 ∧ + inner ℝ e (θ • p+(1-θ) • q) ≤ 0 ∧ + max 0 (-inner ℝ e (θ • p+(1-θ) • q)) = max 0 (-inner ℝ e p) := by + by_cases hp : inner ℝ e p ≤ 0 + · refine ⟨1,zero_le_one,le_rfl,?_,?_⟩ + · simpa using hp + · simp + · obtain ⟨θ,hθ0,hθ1,hzero⟩ := convex_zero (le_of_not_ge hp) hq.le + refine ⟨θ,hθ0,hθ1,?_,?_⟩ + · simp only [inner_add_right, inner_smul_right, hzero, le_refl] + · rw [inner_add_right, inner_smul_right, inner_smul_right, hzero, + neg_zero, max_self, max_eq_left (by linarith : -inner ℝ e p ≤ 0)] + +/-- The cap cost of the good density is weighted interior mass, not its +possibly enormous total mass. -/ +lemma cone_corrected_cap {a : ℂ → ℂ} (ha : Integrable a) + {K L : ℂ → ℝ} (hK : AEStronglyMeasurable K) (hL : AEStronglyMeasurable L) + (hK0 : ∀ y, 0 ≤ K y) (hK1 : ∀ y, K y ≤ 1) + (hL0 : ∀ y, 0 ≤ L y) (hL1 : ∀ y, L y ≤ 1) + {D : Set ℂ} (hD : MeasurableSet D) (hsupp : ∀ y, L y-K y ≠ 0 → y ∈ D) + (x z : ℂ) {ρ : ℝ} (hρ : 0 ≤ ρ) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) + (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) : + ‖∫ y, correction x z y*((L y : ℂ)-K y)*a y‖ ≤ + 2*ρ*(∫ y, (L y+K y)*‖a y‖)+7*(∫ y in D \ Metric.ball z ρ, ‖a y‖) := by + have hi : Integrable (fun y => (L y+K y)*‖a y‖) := + ha.norm.bdd_mul (c := 2) (hL.add hK) (ae_of_all _ (fun y => by + rw [Real.norm_eq_abs, abs_of_nonneg (add_nonneg (hL0 y) (hK0 y))] + linarith [hK1 y,hL1 y])) + let B := D \ Metric.ball z ρ + have hB : MeasurableSet B := hD.diff measurableSet_ball + have hbi : Integrable (B.indicator (fun y => ‖a y‖)) := ha.norm.indicator hB + have hmaj : ‖∫ y, correction x z y*((L y : ℂ)-K y)*a y‖ ≤ + ∫ y, 2*ρ*((L y+K y)*‖a y‖)+7*B.indicator (fun y => ‖a y‖) y := by + apply norm_integral_le_of_norm_le ((hi.const_mul _).add (hbi.const_mul _)) + filter_upwards with y + change ‖correction x z y*((L y : ℂ)-K y)*a y‖ ≤ 2*ρ*((L y+K y)*‖a y‖)+7*B.indicator (fun y => ‖a y‖) y + have hk := hK0 y + have hl := hL0 y + have hb : 0 ≤ B.indicator (fun y => ‖a y‖) y := Set.indicator_nonneg (fun _ _ => norm_nonneg _) y + have hf : ‖((L y : ℂ)-K y)‖ = |L y-K y| := by + rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] + have hsum : |L y-K y| ≤ L y+K y := abs_le.mpr ⟨by linarith [hL0 y], by linarith [hK0 y]⟩ + have hone : |L y-K y| ≤ 1 := abs_le.mpr ⟨by linarith [hL0 y,hK1 y],by linarith [hL1 y,hK0 y]⟩ + by_cases hzero : L y-K y = 0 + · have hc : (L y : ℂ)-K y = 0 := by exact_mod_cast hzero + rw [hc, mul_zero, zero_mul, norm_zero] + positivity + · have hyD := hsupp y hzero + by_cases hyB : y ∈ Metric.ball z ρ + · have hc := correction_cap_bound hz (show ‖y-z‖ ≤ ρ from by simpa only [dist_eq_norm] using (Metric.mem_ball.mp hyB).le) + rw [indicator_of_notMem (show y ∉ B from fun h => h.2 hyB), mul_zero, add_zero, + norm_mul, norm_mul, hf] + have hh := mul_le_mul hc hsum (abs_nonneg _) (by positivity : 0 ≤ 2*ρ) + nlinarith [mul_le_mul_of_nonneg_right hh (norm_nonneg (a y))] + · rw [indicator_of_mem (show y ∈ B from ⟨hyD,hyB⟩),norm_mul,norm_mul,hf] + have hc := mul_le_mul (correction_bounded hz (hD3 y hyD)) hone (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 7) + have hh := mul_le_mul_of_nonneg_right hc (norm_nonneg (a y)) + have hn : 0 ≤ 2*ρ*((L y+K y)*‖a y‖) := by positivity + nlinarith + rw [integral_add (hi.const_mul _) (hbi.const_mul _), integral_const_mul, + integral_const_mul, integral_indicator hB] at hmaj + exact hmaj + +open DiskKernels DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +/-- The error contribution to the corrected first active step; no moment +cancellation for the errors alone is presumed. -/ +lemma corrected_error_bound {Cs α δ ρ : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hα : α ≤ 1) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hρ : 0 ≤ ρ) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) (x z : ℂ) + (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) : + ‖∑ d, ∫ y, correction x z y*F y*(b d).density y‖ ≤ + 2*ρ*coarseMass b δ univ+7*coarseMass b δ (D \ Metric.ball z ρ)+ + ((L : ℝ)+2*(3*(L : ℝ)+1))*Cs*δ^(2*(1-α))*errorPrice b α := by + classical + have hnorm : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ (3 : ℝ) := fun y hy => hD3 y (hFD y hy) + have hH : ‖(star (z-x))⁻¹‖ ≤ (2 : ℝ) := by + rw [norm_inv, norm_star] + have hn : 0 < ‖z-x‖ := by linarith + rw [inv_eq_one_div, div_le_iff₀ hn] + linarith + have hcorr : LipschitzWith (L+2*(3*L+1)) (fun y => correction x z y*F y) := + corrected_lipschitz (M := 1) (R := 3) (H := 2) hF hFb x z hnorm hH + have hsplit : (∑ d, ∫ y, correction x z y*F y*(b d).density y) = + (∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), ∫ y, correction x z y*F y*(b d).density y)+ + (∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), ∫ y, correction x z y*F y*(b d).density y) := by + simpa only [not_le] using (Finset.sum_filter_add_sum_filter_not Finset.univ + (fun d => δ^2 ≤ (b d).size) (fun d => ∫ y, correction x z y*F y*(b d).density y)).symm + rw [hsplit] + apply (norm_add_le _ _).trans + apply add_le_add + · calc + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), + ‖∫ y, correction x z y*F y*(b d).density y‖ := norm_sum_le _ _ + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), + (2*ρ*(∫ y, ‖(b d).density y‖)+7*(∫ y in D \ Metric.ball z ρ, ‖(b d).density y‖)) := + Finset.sum_le_sum (fun d _ => corrected_pairing_cap (b d).integrable hD hFb hFD x z hρ hz hD3) + _ = _ := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] + simp only [coarseMass, Measure.restrict_univ] + · exact fine_pairing_bound b hCs hα hδ hδ1 hcorr + +end + +open DiskKernels DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +lemma increment_bound_general {Cs α δ M : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hα : α ≤ 1) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ M) (hFD : ∀ y, F y ≠ 0 → y ∈ D) : + ‖∑ d, ∫ y, F y*(b d).density y‖ ≤ + M*coarseMass b δ D+(L : ℝ)*Cs*δ^(2*(1-α))*errorPrice b α := by + classical + have he : (∑ d, ∫ y, F y*(b d).density y) = + (∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), ∫ y, F y*(b d).density y)+ + (∑ d ∈ Finset.univ.filter (fun d => (b d).size < δ^2), ∫ y, F y*(b d).density y) := by + simpa only [not_le] using (Finset.sum_filter_add_sum_filter_not Finset.univ + (fun d => δ^2 ≤ (b d).size) (fun d => ∫ y, F y*(b d).density y)).symm + rw [he] + apply (norm_add_le _ _).trans + apply add_le_add + · calc + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), ‖∫ y, F y*(b d).density y‖ := norm_sum_le _ _ + _ ≤ ∑ d ∈ Finset.univ.filter (fun d => δ^2 ≤ (b d).size), M*(∫ y in D, ‖(b d).density y‖) := by + apply Finset.sum_le_sum + intro d _ + have hh := pairing_majorant (b d).integrable hD 0 M (fun y => by + by_cases hy : y ∈ D + · simpa only [indicator_of_mem hy, mul_one, zero_add] using hFb y + · have hf : F y = 0 := by by_contra h; exact hy (hFD y h) + simp only [hf,norm_zero,indicator_of_notMem hy,mul_zero,add_zero,le_refl]) + simpa only [zero_mul,zero_add] using hh + _ = _ := by rw [← Finset.mul_sum]; rfl + · exact fine_pairing_bound b hCs hα hδ hδ1 hF + +lemma correction_kernel_bound {F : ℂ → ℂ} (hFb : ∀ y, ‖F y‖ ≤ 1) + (x z : ℂ) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ 3) : + ∀ y, ‖correction x z y*F y‖ ≤ 7 := by + intro y + by_cases hy : F y = 0 + · simp only [hy,mul_zero,norm_zero]; norm_num + · rw [norm_mul] + simpa only [mul_one] using mul_le_mul (correction_bounded hz (hD3 y hy)) (hFb y) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 7) + +lemma corrected_inactive_bound {Cs α δ : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hα : α ≤ 1) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) (x z : ℂ) + (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) : + ‖∑ d, ∫ y, correction x z y*F y*(b d).density y‖ ≤ + 7*coarseMass b δ D+((L : ℝ)+2*(3*(L : ℝ)+1))*Cs*δ^(2*(1-α))*errorPrice b α := by + have hnorm : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ (3 : ℝ) := fun y hy => hD3 y (hFD y hy) + have hH : ‖(star (z-x))⁻¹‖ ≤ (2 : ℝ) := by + rw [norm_inv, norm_star] + have hn : 0 < ‖z-x‖ := by linarith + rw [inv_eq_one_div, div_le_iff₀ hn] + linarith + have hcorr : LipschitzWith (L+2*(3*L+1)) (fun y => correction x z y*F y) := + corrected_lipschitz (M := 1) (R := 3) (H := 2) hF hFb x z hnorm hH + exact increment_bound_general b hCs hα hδ hδ1 hcorr hD (correction_kernel_bound hFb x z hz hnorm) + (fun y hy => hFD y (fun h => hy (by rw [h,mul_zero]))) + +end LocalCancellation + +/-- A finite last-active-index induction. Its hypotheses are local gaps, not +an assumed global estimate, and no infinite list of active indices is chosen. -/ +lemma last_active_bound (active : ℕ → Prop) (N a : ℕ → ℝ) (B : ℝ) + (ha : ∀ i, 0 ≤ a i) + (hfirst : ∀ n, (∀ i < n, ¬active i) → N n ≤ B+∑ i ∈ Finset.range n, a i) + (hgap : ∀ j n, j < n → active j → (∀ i, j < i → i < n → ¬active i) → + N n ≤ N j+a j) : ∀ n, N n ≤ B+∑ i ∈ Finset.range n, a i := by + classical + intro n + induction n using Nat.strong_induction_on with + | h n ih => + let S := (Finset.range n).filter active + by_cases hS : S.Nonempty + · let j := S.max' hS + have hjmem : j ∈ S := Finset.max'_mem S hS + have hjn : j < n := Finset.mem_range.mp (Finset.mem_filter.mp hjmem).1 + have hjact : active j := (Finset.mem_filter.mp hjmem).2 + have hng : ∀ i, j < i → i < n → ¬active i := by + intro i hji hin hi + have his : i ∈ S := Finset.mem_filter.mpr ⟨Finset.mem_range.mpr hin,hi⟩ + exact (not_lt_of_ge (Finset.le_max' S i his)) hji + have hh := hgap j n hjn hjact hng + have hb := ih j hjn + have hs : (∑ i ∈ Finset.range (j+1), a i) ≤ ∑ i ∈ Finset.range n, a i := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono (Nat.succ_le_of_lt hjn)) (fun i _ _ => ha i) + rw [Finset.sum_range_succ] at hs + linarith + · apply hfirst n + intro i hi hai + exact hS ⟨i,Finset.mem_filter.mpr ⟨Finset.mem_range.mpr hi,hai⟩⟩ + +lemma last_active_limit (active : ℕ → Prop) (N a : ℕ → ℝ) (B Z : ℝ) + (ha : ∀ i, 0 ≤ a i) (hsm : Summable a) (hN : Tendsto N atTop (𝓝 Z)) + (hfirst : ∀ n, (∀ i < n, ¬active i) → N n ≤ B+∑ i ∈ Finset.range n, a i) + (hgap : ∀ j n, j < n → active j → (∀ i, j < i → i < n → ¬active i) → + N n ≤ N j+a j) : Z ≤ B+∑' i, a i := by + apply le_of_tendsto hN + filter_upwards with n + exact (last_active_bound active N a B ha hfirst hgap n).trans + (add_le_add le_rfl (hsm.sum_le_tsum (Finset.range n) (fun i _ => ha i))) + +namespace LocalCancellation +open DiskKernels DiskGeometry DiskScales + +lemma real_weight_integrable {a : ℂ → ℂ} (ha : Integrable a) {K : ℂ → ℝ} + (hK : AEStronglyMeasurable K) (hK0 : ∀ y, 0 ≤ K y) (hK1 : ∀ y, K y ≤ 1) : + Integrable (fun y => (K y : ℂ)*a y) := + integrable_bounded_pairing ha (Complex.continuous_ofReal.comp_aestronglyMeasurable hK) + (fun y => by rw [Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg (hK0 y)]; exact hK1 y) + +lemma real_weight_norm_integrable {a : ℂ → ℂ} (ha : Integrable a) {K : ℂ → ℝ} + (hK : AEStronglyMeasurable K) (hK0 : ∀ y, 0 ≤ K y) (hK1 : ∀ y, K y ≤ 1) : + Integrable (fun y => K y*‖a y‖) := + ha.norm.bdd_mul hK (ae_of_all _ fun y => by + rw [Real.norm_eq_abs,abs_of_nonneg (hK0 y)]; exact hK1 y) + +lemma convex_pairing {a : ℂ → ℂ} {K L : ℂ → ℝ} + (hiK : Integrable (fun y => (K y : ℂ)*a y)) + (hiL : Integrable (fun y => (L y : ℂ)*a y)) (θ : ℝ) : + (∫ y, ((θ*K y+(1-θ)*L y : ℝ) : ℂ)*a y) = + θ • (∫ y, (K y : ℂ)*a y)+(1-θ) • (∫ y, (L y : ℂ)*a y) := by + have he : (fun y => ((θ*K y+(1-θ)*L y : ℝ) : ℂ)*a y) = + (fun y => θ • ((K y : ℂ)*a y)+(1-θ) • ((L y : ℂ)*a y)) := by + ext y + simp only [Complex.ofReal_add,Complex.ofReal_mul,Complex.real_smul] + ring + rw [he] + calc + _ = (∫ y, θ • ((K y : ℂ)*a y))+(∫ y, (1-θ) • ((L y : ℂ)*a y)) := + integral_add (hiK.smul θ) (hiL.smul (1-θ)) + _ = _ := by rw [integral_smul,integral_smul] + +/-- Analytic comparison of two balanced mixtures at a negative later +projection. The only error term is their fixed-correction difference. -/ +lemma negative_gap_cap {e : ℂ} {κ B ρ H : ℝ} (a : ConeDensity e κ) + (he : ‖e‖ = 1) (hκ : 0 < κ) (hρ : 0 ≤ ρ) + {K L : ℂ → ℝ} (hK : AEStronglyMeasurable K) (hL : AEStronglyMeasurable L) + (hK0 : ∀ y, 0 ≤ K y) (hK1 : ∀ y, K y ≤ 1) + (hL0 : ∀ y, 0 ≤ L y) (hL1 : ∀ y, L y ≤ 1) + {D : Set ℂ} (hD : MeasurableSet D) (hsupp : ∀ y, L y-K y ≠ 0 → y ∈ D) + (x z : ℂ) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) + (hcap : (∫ y in D \ Metric.ball z ρ, ‖a.density y‖) ≤ H) + {p q R : ℂ} (hp : ‖p‖ ≤ B) (hq : ‖q‖ ≤ B) + (hneg : inner ℝ e ((∫ y, (L y : ℂ)*a.density y)+q) < 0) + (hcor : ((∫ y, (L y : ℂ)*a.density y)+q)-((∫ y, (K y : ℂ)*a.density y)+p) = + (∫ y, correction x z y*((L y : ℂ)-K y)*a.density y)+R) : + max 0 (-inner ℝ e ((∫ y, (L y : ℂ)*a.density y)+q)) ≤ + max 0 (-inner ℝ e ((∫ y, (K y : ℂ)*a.density y)+p))+ + 4*ρ*(B/κ)+7*H+‖R‖ := by + let P := (∫ y, (K y : ℂ)*a.density y)+p + let Q := (∫ y, (L y : ℂ)*a.density y)+q + obtain ⟨θ,hθ0,hθ1,hθneg,hθeq⟩ := crossing_interpolation e P Q hneg + let J (y : ℂ) := θ*K y+(1-θ)*L y + have hJ0 (y : ℂ) : 0 ≤ J y := add_nonneg (mul_nonneg hθ0 (hK0 y)) (mul_nonneg (sub_nonneg.mpr hθ1) (hL0 y)) + have hJ1 (y : ℂ) : J y ≤ 1 := by + have h1 := mul_le_mul_of_nonneg_left (hK1 y) hθ0 + have h2 := mul_le_mul_of_nonneg_left (hL1 y) (sub_nonneg.mpr hθ1) + dsimp [J] + nlinarith + have hJ : AEStronglyMeasurable J := (hK.const_mul θ).add (hL.const_mul (1-θ)) + have hiK := real_weight_integrable a.integrable hK hK0 hK1 + have hiL := real_weight_integrable a.integrable hL hL0 hL1 + let pstar := θ • p+(1-θ) • q + have hpstar : ‖pstar‖ ≤ B := by + calc + ‖pstar‖ ≤ ‖θ • p‖+‖(1-θ) • q‖ := norm_add_le _ _ + _ = θ*‖p‖+(1-θ)*‖q‖ := by + rw [norm_smul,norm_smul,Real.norm_eq_abs,Real.norm_eq_abs, + abs_of_nonneg hθ0,abs_of_nonneg (sub_nonneg.mpr hθ1)] + _ ≤ θ*B+(1-θ)*B := add_le_add (mul_le_mul_of_nonneg_left hp hθ0) + (mul_le_mul_of_nonneg_left hq (sub_nonneg.mpr hθ1)) + _ = B := by ring + have hstar : (∫ y, (J y : ℂ)*a.density y)+pstar = θ • P+(1-θ) • Q := by + rw [show (∫ y, (J y : ℂ)*a.density y) = _ from convex_pairing hiK hiL θ] + dsimp [P,Q,pstar] + ring + have hsmass := cone_mass_of_nonpositive a he hκ hJ hJ0 hJ1 + (show inner ℝ e ((∫ y, (J y : ℂ)*a.density y)+pstar) ≤ 0 by rw [hstar]; exact hθneg) + have hlmass := cone_mass_of_nonpositive a he hκ hL hL0 hL1 hneg.le + have hweighted : (∫ y, (L y+J y)*‖a.density y‖) ≤ 2*(B/κ) := by + have hiLn := real_weight_norm_integrable a.integrable hL hL0 hL1 + have hiJn := real_weight_norm_integrable a.integrable hJ hJ0 hJ1 + simp_rw [add_mul] + rw [integral_add hiLn hiJn] + have hs := hsmass.trans (div_le_div_of_nonneg_right hpstar hκ.le) + have hl := hlmass.trans (div_le_div_of_nonneg_right hq hκ.le) + linarith + have hJdiff (y : ℂ) : L y-J y = θ*(L y-K y) := by dsimp [J]; ring + have hJDs : ∀ y, L y-J y ≠ 0 → y ∈ D := by + intro y hy + apply hsupp y + intro h + exact hy (by rw [hJdiff,h,mul_zero]) + let G := ∫ y, correction x z y*((L y : ℂ)-J y)*a.density y + have hG : ‖G‖ ≤ 4*ρ*(B/κ)+7*H := by + have hh := cone_corrected_cap a.integrable hJ hL hJ0 hJ1 hL0 hL1 hD hJDs x z hρ hz hD3 + change ‖G‖ ≤ _ at hh + have hg := mul_le_mul_of_nonneg_left hweighted (by positivity : 0 ≤ 2*ρ) + have hc := mul_le_mul_of_nonneg_left hcap (by norm_num : (0 : ℝ) ≤ 7) + nlinarith + have hGid : G = θ • (∫ y, correction x z y*((L y : ℂ)-K y)*a.density y) := by + rw [← integral_smul] + apply integral_congr_ae + filter_upwards with y + change correction x z y*((L y : ℂ)-(θ*K y+(1-θ)*L y : ℝ))*a.density y = + θ • (correction x z y*((L y : ℂ)-K y)*a.density y) + simp only [Complex.ofReal_add,Complex.ofReal_mul,Complex.ofReal_sub,Complex.ofReal_one,Complex.real_smul] + ring + have hdiff : Q-(θ • P+(1-θ) • Q) = G+θ • R := by + have hh : Q-P = (∫ y, correction x z y*((L y : ℂ)-K y)*a.density y)+R := hcor + rw [hGid, ← smul_add, ← hh] + simp only [sub_smul,one_smul,smul_sub] + abel + have hR : ‖θ • R‖ ≤ ‖R‖ := by + rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg hθ0] + exact mul_le_of_le_one_left (norm_nonneg _) hθ1 + have hn := negative_projection_change e (θ • P+(1-θ) • Q) Q he + rw [hθeq,hdiff] at hn + have hh := (norm_add_le G (θ • R)).trans (add_le_add hG hR) + change max 0 (-inner ℝ e Q) ≤ max 0 (-inner ℝ e P)+4*ρ*(B/κ)+7*H+‖R‖ + linarith + +end LocalCancellation + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/LocalCancellation5.lean b/lean/OAI/Analysis/SignedDisk/LocalCancellation5.lean new file mode 100644 index 0000000000000000000000000000000000000000..11f121a6fe49cc933842d4e9affa0f7843d0c5d8 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/LocalCancellation5.lean @@ -0,0 +1,431 @@ +import OAI.Analysis.SignedDisk.LocalCancellation4 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real + +noncomputable section + +namespace SignedDisk + +namespace LocalCancellation +open DiskKernels DiskGeometry DiskScales + +lemma cone_negative_le_error {e : ℂ} {κ : ℝ} (a : ConeDensity e κ) + (he : ‖e‖ = 1) (hκ : 0 ≤ κ) {K : ℂ → ℝ} + (hK : AEStronglyMeasurable K) (hK0 : ∀ y, 0 ≤ K y) (hK1 : ∀ y, K y ≤ 1) (p : ℂ) : + max 0 (-inner ℝ e ((∫ y, (K y : ℂ)*a.density y)+p)) ≤ ‖p‖ := by + have hh := cone_pairing a hK hK0 hK1 + have hi : 0 ≤ ∫ y, K y*‖a.density y‖ := integral_nonneg (fun y => mul_nonneg (hK0 y) (norm_nonneg _)) + have hproj : 0 ≤ inner ℝ e (∫ y, (K y : ℂ)*a.density y) := (mul_nonneg hκ hi).trans hh + rw [inner_add_right] + exact max_le (norm_nonneg _) (by linarith [(abs_le.mp (inner_unit_bound (p := p) he)).1]) + +lemma general_moment_integrable {a : ℂ → ℂ} (ha : Integrable a) + {r δ : ℝ} {M : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) (x : ℂ) (hr : r+δ ≤ 3) : + Integrable (fun y => star (y-x)*(kernel k x y : ℂ)*a y) := by + apply integrable_bounded_pairing ha + ((by fun_prop : Continuous (fun y : ℂ => star (y-x))).mul + (complex_kernel_lipschitz k x).continuous).aestronglyMeasurable + apply position_bound (complex_kernel_bound k x) x (by norm_num : (0 : ℝ) ≤ 3) + intro y hy + have hyb : y ∈ Metric.ball x (r+δ) := by + by_contra hh + exact hy (by rw [kernel_zero k x hh, Complex.ofReal_zero]) + exact (show ‖y-x‖ < r+δ by simpa only [Metric.mem_ball, dist_eq_norm] using hyb).le.trans hr + +lemma correcting_pairing {a F : ℂ → ℂ} (ha : Integrable a) + (hF : AEStronglyMeasurable F) (hFb : ∀ y, ‖F y‖ ≤ 1) (x z : ℂ) + (hsupp : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ 3) : + (∫ y, correction x z y*F y*a y) = (∫ y, F y*a y) - + (star (z-x))⁻¹*(∫ y, star (y-x)*F y*a y) := by + have hi := integrable_bounded_pairing ha hF hFb + have him : Integrable (fun y => star (y-x)*F y*a y) := + integrable_bounded_pairing ha + ((by fun_prop : Continuous (fun y : ℂ => star (y-x))).aestronglyMeasurable.mul hF) + (position_bound hFb x (by norm_num : (0 : ℝ) ≤ 3) hsupp) + have he : (fun y => correction x z y*F y*a y) = + fun y => F y*a y-(star (z-x))⁻¹*(star (y-x)*F y*a y) := by + ext y + simp only [correction,div_eq_mul_inv] + ring + rw [he,integral_sub hi (him.const_mul _),integral_const_mul] + +lemma general_kernel_pairing_sub {a : ℂ → ℂ} (ha : Integrable a) + {u v u' v' : ℝ} {M N : ℝ≥0} (k : RadiusDensity u v M) (l : RadiusDensity u' v' N) (x : ℂ) : + (∫ y, (kernel l x y : ℂ)*a y)-(∫ y, (kernel k x y : ℂ)*a y) = + ∫ y, ((kernel l x y : ℂ)-kernel k x y)*a y := by + rw [← integral_sub + (integrable_bounded_pairing ha (complex_kernel_lipschitz l x).continuous.aestronglyMeasurable (complex_kernel_bound l x)) + (integrable_bounded_pairing ha (complex_kernel_lipschitz k x).continuous.aestronglyMeasurable (complex_kernel_bound k x))] + congr 1 + ext y + ring + +lemma corrected_kernel_integrable {a : ℂ → ℂ} (ha : Integrable a) + {r δ : ℝ} {M : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) (x z : ℂ) + (hr : r+δ ≤ 3) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) : + Integrable (fun y => correction x z y*(kernel k x y : ℂ)*a y) := by + apply integrable_bounded_pairing ha + ((by unfold correction; fun_prop : Continuous (correction x z)).mul (complex_kernel_lipschitz k x).continuous).aestronglyMeasurable + apply correction_kernel_bound (complex_kernel_bound k x) x z hz + intro y hy + have hyb : y ∈ Metric.ball x (r+δ) := by + by_contra hh + exact hy (by rw [kernel_zero k x hh,Complex.ofReal_zero]) + exact (show ‖y-x‖ < r+δ by simpa only [Metric.mem_ball,dist_eq_norm] using hyb).le.trans hr + +lemma corrected_kernel_pairing_sub {a : ℂ → ℂ} (ha : Integrable a) + {r δ ε : ℝ} {M N : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) + (l : RadiusDensity (r-ε) (r+ε) N) (x z : ℂ) + (hrδ : r+δ ≤ 3) (hrε : r+ε ≤ 3) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) : + (∫ y, correction x z y*(kernel l x y : ℂ)*a y)- + (∫ y, correction x z y*(kernel k x y : ℂ)*a y) = + ∫ y, correction x z y*((kernel l x y : ℂ)-kernel k x y)*a y := by + rw [← integral_sub (corrected_kernel_integrable ha l x z hrε hz) + (corrected_kernel_integrable ha k x z hrδ hz)] + congr 1 + ext y + ring + +lemma interior_mass_le_kernel {a : ℂ → ℂ} (ha : Integrable a) + {r δ ε : ℝ} {M : ℝ≥0} (k : RadiusDensity (r-ε) (r+ε) M) (x : ℂ) (hεδ : ε ≤ δ) : + (∫ y in Metric.ball x (r-δ), ‖a y‖) ≤ ∫ y, kernel k x y*‖a y‖ := by + rw [← integral_indicator measurableSet_ball] + apply integral_mono_ae (ha.norm.indicator measurableSet_ball) + (ha.norm.bdd_mul (kernel_lipschitz k x).continuous.aestronglyMeasurable + (ae_of_all _ (fun y => by rw [Real.norm_eq_abs,abs_of_nonneg (kernel_nonneg k x y)]; exact kernel_le_one k x y))) + filter_upwards with y + by_cases hy : y ∈ Metric.ball x (r-δ) + · have hk : kernel k x y = 1 := kernel_one k x (by + simp only [Metric.mem_ball] at hy ⊢ + linarith) + simp only [indicator_of_mem hy,hk,one_mul,le_refl] + · simp only [indicator_of_notMem hy] + exact mul_nonneg (kernel_nonneg k x y) (norm_nonneg _) + +end LocalCancellation + +namespace DiskScales + +lemma width_add (d : ℝ) (j n : ℕ) : width d (j+n) = width (width d j) n := by + simp only [width,pow_add] + ring + +lemma sum_width_tail {d p : ℝ} (hd : 0 ≤ d) (hp : 0 < p) (j n : ℕ) : + (∑ i ∈ Finset.Ico j n, (width d i)^p) ≤ (width d j)^p/(1-(1/2 : ℝ)^p) := by + rw [Finset.sum_Ico_eq_sum_range] + have hs : Summable (fun i => (width (width d j) i)^p) := + summable_width_rpow (by dsimp [width]; positivity) hp + have hh := hs.sum_le_tsum (Finset.range (n-j)) (fun i _ => Real.rpow_nonneg (by dsimp [width]; positivity) p) + simp_rw [width_add] + exact hh.trans_eq (tsum_width_rpow (by dsimp [width]; positivity) hp) + +lemma dist_width_tail {α : Type*} [PseudoMetricSpace α] {d p C : ℝ} (hd : 0 ≤ d) + (hp : 0 < p) (hC : 0 ≤ C) {f : ℕ → α} {j n : ℕ} (hjn : j ≤ n) + (hincr : ∀ i, j ≤ i → i < n → dist (f i) (f (i+1)) ≤ C*(width d i)^p) : + dist (f j) (f n) ≤ C*(width d j)^p/(1-(1/2 : ℝ)^p) := by + have hh := dist_le_Ico_sum_of_dist_le hjn (fun {i} hi hin => hincr i hi hin) + rw [← Finset.mul_sum] at hh + exact hh.trans (by simpa only [mul_div_assoc] using + mul_le_mul_of_nonneg_left (sum_width_tail hd hp j n) hC) + +end DiskScales + +namespace LocalCancellation +open DiskKernels DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +lemma moment_kernel_pairing_sub {a : ℂ → ℂ} (ha : Integrable a) + {r δ ε : ℝ} {M N : ℝ≥0} (k : RadiusDensity (r-δ) (r+δ) M) + (l : RadiusDensity (r-ε) (r+ε) N) (x : ℂ) (hrδ : r+δ ≤ 3) (hrε : r+ε ≤ 3) : + (∫ y, star (y-x)*(kernel l x y : ℂ)*a y)- + (∫ y, star (y-x)*(kernel k x y : ℂ)*a y) = + ∫ y, star (y-x)*((kernel l x y : ℂ)-kernel k x y)*a y := by + rw [← integral_sub (general_moment_integrable ha l x hrε) (general_moment_integrable ha k x hrδ)] + congr 1 + ext y + ring + +lemma total_correction {Cs : ℝ} (b : ι → ErrorPiece Cs) {a F : ℂ → ℂ} (ha : Integrable a) + (hF : AEStronglyMeasurable F) (hFb : ∀ y, ‖F y‖ ≤ 1) (x z : ℂ) + (hsupp : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ 3) + (hzero : (∫ y, star (y-x)*F y*a y)+(∑ j, ∫ y, star (y-x)*F y*(b j).density y) = 0) : + (∫ y, F y*a y)+(∑ j, ∫ y, F y*(b j).density y) = + (∫ y, correction x z y*F y*a y)+(∑ j, ∫ y, correction x z y*F y*(b j).density y) := by + rw [correcting_pairing ha hF hFb x z hsupp] + simp_rw [correcting_pairing (b _).integrable hF hFb x z hsupp] + rw [Finset.sum_sub_distrib, ← Finset.mul_sum] + linear_combination (star (z-x))⁻¹*hzero + +lemma balanced_kernel_gap_identity {Cs : ℝ} (b : ι → ErrorPiece Cs) {a : ℂ → ℂ} + (ha : Integrable a) {r δ ε : ℝ} {M N : ℝ≥0} + (k : RadiusDensity (r-δ) (r+δ) M) (l : RadiusDensity (r-ε) (r+ε) N) + (x z : ℂ) (hrδ : r+δ ≤ 3) (hrε : r+ε ≤ 3) (hεδ : ε ≤ δ) + (hMk : (∫ y, star (y-x)*(kernel k x y : ℂ)*a y)+ + (∑ j, ∫ y, star (y-x)*(kernel k x y : ℂ)*(b j).density y) = 0) + (hMl : (∫ y, star (y-x)*(kernel l x y : ℂ)*a y)+ + (∑ j, ∫ y, star (y-x)*(kernel l x y : ℂ)*(b j).density y) = 0) : + ((∫ y, (kernel l x y : ℂ)*a y)+(∑ j, ∫ y, (kernel l x y : ℂ)*(b j).density y))- + ((∫ y, (kernel k x y : ℂ)*a y)+(∑ j, ∫ y, (kernel k x y : ℂ)*(b j).density y)) = + (∫ y, correction x z y*((kernel l x y : ℂ)-kernel k x y)*a y)+ + (∑ j, ∫ y, correction x z y*((kernel l x y : ℂ)-kernel k x y)*(b j).density y) := by + let F (y : ℂ) := (kernel l x y : ℂ)-kernel k x y + have hsupp : ∀ y, F y ≠ 0 → ‖y-x‖ ≤ 3 := by + intro y hy + have hh := (abs_le.mp (difference_support k l hεδ x y hy)).2 + linarith + have hzero : (∫ y, star (y-x)*F y*a y)+ + (∑ j, ∫ y, star (y-x)*F y*(b j).density y) = 0 := by + simp_rw [F, ← moment_kernel_pairing_sub ha k l x hrδ hrε, + ← moment_kernel_pairing_sub (b _).integrable k l x hrδ hrε] + rw [Finset.sum_sub_distrib] + linear_combination hMl-hMk + have hcorr := total_correction b ha + ((complex_kernel_lipschitz l x).continuous.sub (complex_kernel_lipschitz k x).continuous).aestronglyMeasurable + (difference_bound k l x) x z hsupp hzero + calc + _ = ((∫ y, (kernel l x y : ℂ)*a y)-(∫ y, (kernel k x y : ℂ)*a y))+ + ((∑ j, ∫ y, (kernel l x y : ℂ)*(b j).density y)- + (∑ j, ∫ y, (kernel k x y : ℂ)*(b j).density y)) := by abel + _ = (∫ y, F y*a y)+(∑ j, ∫ y, F y*(b j).density y) := by + rw [general_kernel_pairing_sub ha k l x, ← Finset.sum_sub_distrib] + simp_rw [general_kernel_pairing_sub (b _).integrable k l x] + rfl + _ = _ := hcorr + +lemma kernel_error_bound {Cs δ r : ℝ} (b : ι → ErrorPiece Cs) (hCs : 0 ≤ Cs) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (k : RadiusDensity (r-δ) (r+δ) ⟨216/δ, by positivity⟩) (x : ℂ) : + ‖∑ j, ∫ y, (kernel k x y : ℂ)*(b j).density y‖ ≤ + (1+216*Cs)/δ^(1/100 : ℝ)*errorPrice b (1/100) := by + exact total_pairing_discount b (by norm_num : (0 : ℝ) ≤ 1/100) + (by norm_num : (1/100 : ℝ) ≤ 1) hδ hδ1 (by linarith) + (complex_kernel_lipschitz k x) (complex_kernel_bound k x) + (by change (216/δ)*Cs ≤ (1+216*Cs)/δ + apply (le_div_iff₀ hδ).mpr + field_simp [hδ.ne'] + linarith) + +lemma coarse_bound_scaled {Cs δ : ℝ} (b : ι → ErrorPiece Cs) (hδ : 0 < δ) : + coarseMass b δ univ ≤ errorPrice b (1/100)*δ^(-(1/50 : ℝ)) := by + have hh := coarseMass_bound b (by norm_num : (0 : ℝ) ≤ 1/100) hδ + norm_num at hh + simpa only [Real.rpow_neg hδ.le,div_eq_mul_inv] using hh + +lemma scaled_ordinary_inactive {Cs δ t : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hAt : errorPrice b (1/100) ≤ t) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) + (hL : (L : ℝ) ≤ 648/δ) (hsmall : coarseMass b δ D ≤ t*δ^(1/10 : ℝ)) : + ‖∑ j, ∫ y, F y*(b j).density y‖ ≤ (16+4538*Cs)*t*δ^(1/10 : ℝ) := by + have hi := increment_bound b hCs (by norm_num : (1/100 : ℝ) ≤ 1) hδ.le hδ1 hF hD hFb hFD + have hs := scaled_increment hCs (errorPrice_nonneg b (1/100)) hAt hδ hδ1 (coarse_bound_scaled b hδ) hL + have hM : 0 ≤ 2*δ^(1/5 : ℝ)*coarseMass b δ univ := by + exact mul_nonneg (by positivity) (coarseMass_nonneg b δ univ) + have hC : 0 ≤ 2*(3*(L : ℝ)+1)*Cs*δ^(2*(1-(1/100 : ℝ)))*errorPrice b (1/100) := by + exact mul_nonneg (by positivity) (errorPrice_nonneg b (1/100)) + have hU : 0 ≤ t*δ^(1/10 : ℝ) := mul_nonneg ((errorPrice_nonneg b (1/100)).trans hAt) (by positivity) + nlinarith + +lemma scaled_corrected_inactive {Cs δ t : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hAt : errorPrice b (1/100) ≤ t) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) + (hL : (L : ℝ) ≤ 648/δ) (hsmall : coarseMass b δ D ≤ t*δ^(1/10 : ℝ)) + (x z : ℂ) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) : + ‖∑ j, ∫ y, correction x z y*F y*(b j).density y‖ ≤ + (16+4538*Cs)*t*δ^(1/10 : ℝ) := by + have hi := corrected_inactive_bound b hCs (by norm_num : (1/100 : ℝ) ≤ 1) hδ.le hδ1 hF hD hFb hFD x z hz hD3 + have hs := scaled_increment hCs (errorPrice_nonneg b (1/100)) hAt hδ hδ1 (coarse_bound_scaled b hδ) hL + have hM : 0 ≤ 2*δ^(1/5 : ℝ)*coarseMass b δ univ := + mul_nonneg (by positivity) (coarseMass_nonneg b δ univ) + have hU : 0 ≤ t*δ^(1/10 : ℝ) := mul_nonneg ((errorPrice_nonneg b (1/100)).trans hAt) (by positivity) + nlinarith + +lemma scaled_corrected_active {Cs δ t : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hAt : errorPrice b (1/100) ≤ t) + {L : ℝ≥0} {F : ℂ → ℂ} (hF : LipschitzWith L F) {D : Set ℂ} (hD : MeasurableSet D) + (hFb : ∀ y, ‖F y‖ ≤ 1) (hFD : ∀ y, F y ≠ 0 → y ∈ D) + (hL : (L : ℝ) ≤ 648/δ) (x z : ℂ) (hz : (1 : ℝ)/2 ≤ ‖z-x‖) + (hD3 : ∀ y ∈ D, ‖y-x‖ ≤ 3) + (hcap : coarseMass b δ (D \ Metric.ball z (δ^(1/5 : ℝ))) ≤ 2*(t*δ^(1/10 : ℝ))) : + ‖∑ j, ∫ y, correction x z y*F y*(b j).density y‖ ≤ + (16+4538*Cs)*t*δ^(1/10 : ℝ) := by + have hi := corrected_error_bound b hCs (by norm_num : (1/100 : ℝ) ≤ 1) hδ.le hδ1 + (Real.rpow_nonneg hδ.le (1/5)) hF hD hFb hFD x z hz hD3 + have hs := scaled_increment hCs (errorPrice_nonneg b (1/100)) hAt hδ hδ1 (coarse_bound_scaled b hδ) hL + linarith + +end LocalCancellation + +namespace DiskScales + +lemma successor_discount {δ : ℝ} (hδ : 0 < δ) : + (δ/2)⁻¹^(1/100 : ℝ) ≤ 2*δ⁻¹^(1/100 : ℝ) := by + rw [inv_div,Real.div_rpow (by norm_num : (0 : ℝ) ≤ 2) hδ.le,Real.inv_rpow hδ.le] + have hh : (2 : ℝ)^(1/100 : ℝ) ≤ 2 := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 2) + (by norm_num : (1/100 : ℝ) ≤ 1) + exact div_le_div_of_nonneg_right hh (by positivity) + +lemma geometric_den_pos {p : ℝ} (hp : 0 < p) : 0 < 1-(1/2 : ℝ)^p := by + linarith [norm_geometric_rpow_lt hp] + +lemma coarse_error_scale {Cs A t δ : ℝ} (hCs : 0 ≤ Cs) (hA : 0 ≤ A) + (hAt : A ≤ t) (hδ : 0 < δ) (hδ1 : δ ≤ 1) : + 2*((1+216*Cs)/δ^(1/100 : ℝ)*A) + + (16+4538*Cs)*t*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) ≤ + (2*(1+216*Cs)+(16+4538*Cs)/(1-(1/2 : ℝ)^(1/10 : ℝ)))*t*δ^(-(1/50 : ℝ)) := by + have ht : 0 ≤ t := hA.trans hAt + have hp1 : δ^(-(1/100 : ℝ)) ≤ δ^(-(1/50 : ℝ)) := + Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num) + have hp2 : δ^(1/10 : ℝ) ≤ δ^(-(1/50 : ℝ)) := + Real.rpow_le_rpow_of_exponent_ge hδ hδ1 (by norm_num) + have h1 : 2*((1+216*Cs)/δ^(1/100 : ℝ)*A) ≤ 2*(1+216*Cs)*t*δ^(-(1/50 : ℝ)) := by + rw [Real.rpow_neg hδ.le] at hp1 + calc + _ = 2*(1+216*Cs)*A*(δ^(1/100 : ℝ))⁻¹ := by ring + _ ≤ 2*(1+216*Cs)*t*δ^(-(1/50 : ℝ)) := mul_le_mul (by gcongr) hp1 (by positivity) (by positivity) + have hd := geometric_den_pos (by norm_num : (0 : ℝ) < 1/10) + have h2 := mul_le_mul_of_nonneg_left hp2 + (by positivity : 0 ≤ (16+4538*Cs)*t/(1-(1/2 : ℝ)^(1/10 : ℝ))) + have h2' : (16+4538*Cs)*t*δ^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) ≤ + ((16+4538*Cs)/(1-(1/2 : ℝ)^(1/10 : ℝ)))*t*δ^(-(1/50 : ℝ)) := by + calc + _ = ((16+4538*Cs)*t/(1-(1/2 : ℝ)^(1/10 : ℝ)))*δ^(1/10 : ℝ) := by ring + _ ≤ ((16+4538*Cs)*t/(1-(1/2 : ℝ)^(1/10 : ℝ)))*δ^(-(1/50 : ℝ)) := h2 + _ = _ := by ring + linarith + +end DiskScales + +namespace LocalCancellation +open DiskKernels DiskGeometry DiskScales +variable {ι : Type*} [Fintype ι] + +lemma inactive_kernel_distance {Cs d t r : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hd1 : d ≤ 1) (hAt : errorPrice b (1/100) ≤ t) + (k : ∀ n : ℕ, RadiusDensity (r-width d n) (r+width d n) + ⟨216/width d n, div_nonneg (by norm_num) (width_pos hd n).le⟩) (x : ℂ) (n : ℕ) + (hsmall : coarseMass b (width d n) (thinShell x r (width d n)) ≤ t*(width d n)^(1/10 : ℝ)) : + dist (∑ j, ∫ y, (kernel (k n) x y : ℂ)*(b j).density y) + (∑ j, ∫ y, (kernel (k (n+1)) x y : ℂ)*(b j).density y) ≤ + (16+4538*Cs)*t*(width d n)^(1/10 : ℝ) := by + rw [dist_eq_norm,norm_sub_rev,← Finset.sum_sub_distrib] + simp_rw [general_kernel_pairing_sub (b _).integrable (k n) (k (n+1)) x] + apply scaled_ordinary_inactive b hCs (width_pos hd n) ((width_le hd.le n).trans hd1) hAt + ((complex_kernel_lipschitz (k (n+1)) x).sub (complex_kernel_lipschitz (k n) x)) + (measurableSet_thinShell x r (width d n)) (difference_bound (k n) (k (n+1)) x) + (difference_support (k n) (k (n+1)) (width_antitone hd.le (Nat.le_succ n)) x) ?_ hsmall + change 216/width d (n+1)+216/width d n ≤ 648/width d n + rw [width_succ] + exact le_of_eq (by ring) + +lemma kernel_gap_errors {Cs d t r : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hd1 : d ≤ 1) (hAt : errorPrice b (1/100) ≤ t) + (k : ∀ n : ℕ, RadiusDensity (r-width d n) (r+width d n) + ⟨216/width d n, div_nonneg (by norm_num) (width_pos hd n).le⟩) (x : ℂ) {j n : ℕ} (hjn : j < n) + (hsmall : ∀ i, j < i → i < n → coarseMass b (width d i) (thinShell x r (width d i)) ≤ + t*(width d i)^(1/10 : ℝ)) : + let B := (2*(1+216*Cs)+(16+4538*Cs)/(1-(1/2 : ℝ)^(1/10 : ℝ)))*t*(width d j)^(-(1/50 : ℝ)) + ‖∑ v, ∫ y, (kernel (k j) x y : ℂ)*(b v).density y‖ ≤ B ∧ + ‖∑ v, ∫ y, (kernel (k n) x y : ℂ)*(b v).density y‖ ≤ B := by + have ht : 0 ≤ t := (errorPrice_nonneg b (1/100)).trans hAt + have hwp (i : ℕ) := width_pos hd i + have hw1 (i : ℕ) := (width_le hd.le i).trans hd1 + have hjpos : 0 < width d j := hwp j + let P (i : ℕ) := ∑ v, ∫ y, (kernel (k i) x y : ℂ)*(b v).density y + have hind (i : ℕ) : ‖P i‖ ≤ (1+216*Cs)/(width d i)^(1/100 : ℝ)*errorPrice b (1/100) := + kernel_error_bound b hCs (hwp i) (hw1 i) (k i) x + have hsuc : ‖P (j+1)‖ ≤ 2*((1+216*Cs)/(width d j)^(1/100 : ℝ)*errorPrice b (1/100)) := by + have hh := successor_discount (hwp j) + have hi := hind (j+1) + rw [width_succ] at hi + have ha := mul_le_mul_of_nonneg_left hh + (mul_nonneg (show 0 ≤ 1+216*Cs by linarith) (errorPrice_nonneg b (1/100))) + simp only [Real.inv_rpow (hwp j).le,Real.inv_rpow (by positivity : 0 ≤ width d j/2)] at ha + exact hi.trans (by convert ha using 1 <;> ring) + have htail := dist_width_tail hd.le (by norm_num : (0 : ℝ) < 1/10) + (by positivity : 0 ≤ (16+4538*Cs)*t) (Nat.succ_le_of_lt hjn) + (fun i hji hin => inactive_kernel_distance b hCs hd hd1 hAt k x i (hsmall i (by omega) hin)) + have hpow : (width d (j+1))^(1/10 : ℝ) ≤ (width d j)^(1/10 : ℝ) := + Real.rpow_le_rpow (hwp (j+1)).le (width_antitone hd.le (Nat.le_succ j)) (by norm_num) + have hdg := geometric_den_pos (by norm_num : (0 : ℝ) < 1/10) + have htail' : dist (P (j+1)) (P n) ≤ + (16+4538*Cs)*t*(width d j)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := + htail.trans (div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hpow (by positivity)) hdg.le) + have hn : ‖P n‖ ≤ ‖P (j+1)‖+dist (P (j+1)) (P n) := by + calc + ‖P n‖ = ‖P (j+1)+(P n-P (j+1))‖ := by congr 1; abel + _ ≤ ‖P (j+1)‖+‖P n-P (j+1)‖ := norm_add_le _ _ + _ = _ := by rw [dist_eq_norm,norm_sub_rev] + have hscale := coarse_error_scale hCs (errorPrice_nonneg b (1/100)) hAt (hwp j) (hw1 j) + constructor + · have hnon : 0 ≤ (1+216*Cs)/(width d j)^(1/100 : ℝ)*errorPrice b (1/100) := + mul_nonneg (by positivity) (errorPrice_nonneg b (1/100)) + have htailnon : 0 ≤ (16+4538*Cs)*t*(width d j)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by positivity + exact (hind j).trans (by linarith) + · change ‖P n‖ ≤ _ + linarith + +lemma corrected_kernel_gap {Cs d t r : ℝ} (b : ι → ErrorPiece Cs) + (hCs : 0 ≤ Cs) (hd : 0 < d) (hdq : d ≤ 1/4) (hr : r ∈ Icc (1 : ℝ) 2) + (hAt : errorPrice b (1/100) ≤ t) + (k : ∀ n : ℕ, RadiusDensity (r-width d n) (r+width d n) + ⟨216/width d n, div_nonneg (by norm_num) (width_pos hd n).le⟩) (x z : ℂ) {j n : ℕ} (hjn : j < n) + (hz : (1 : ℝ)/2 ≤ ‖z-x‖) + (hcap : coarseMass b (width d j) (thinShell x r (width d j) \ Metric.ball z ((width d j)^(1/5 : ℝ))) ≤ + 2*(t*(width d j)^(1/10 : ℝ))) + (hsmall : ∀ i, j < i → i < n → coarseMass b (width d i) (thinShell x r (width d i)) ≤ + t*(width d i)^(1/10 : ℝ)) : + ‖∑ v, ∫ y, correction x z y*((kernel (k n) x y : ℂ)-kernel (k j) x y)*(b v).density y‖ ≤ + (16+4538*Cs)*t*(width d j)^(1/10 : ℝ)/(1-(1/2 : ℝ)^(1/10 : ℝ)) := by + have ht : 0 ≤ t := (errorPrice_nonneg b (1/100)).trans hAt + have hd1 : d ≤ 1 := by linarith + have hwp (i : ℕ) := width_pos hd i + have hw1 (i : ℕ) := (width_le hd.le i).trans hd1 + have hrw (i : ℕ) : r+width d i ≤ 3 := by linarith [width_le hd.le i,hr.2] + let R (i : ℕ) := ∑ v, ∫ y, correction x z y*(kernel (k i) x y : ℂ)*(b v).density y + have hid (i l : ℕ) : R l-R i = + ∑ v, ∫ y, correction x z y*((kernel (k l) x y : ℂ)-kernel (k i) x y)*(b v).density y := by + dsimp only [R] + rw [← Finset.sum_sub_distrib] + simp_rw [corrected_kernel_pairing_sub (b _).integrable (k i) (k l) x z (hrw i) (hrw l) hz] + have hincr (i : ℕ) (hji : j ≤ i) (hin : i < n) : + dist (R i) (R (i+1)) ≤ (16+4538*Cs)*t*(width d i)^(1/10 : ℝ) := by + rw [dist_eq_norm,norm_sub_rev,hid] + have hD3 : ∀ y ∈ thinShell x r (width d i), ‖y-x‖ ≤ 3 := by + intro y hy + have hh := (abs_le.mp (show |‖y-x‖-r| ≤ width d i from hy)).2 + linarith [hrw i] + have hL : (216/width d (i+1)+216/width d i : ℝ) ≤ 648/width d i := by rw [width_succ]; exact le_of_eq (by ring) + have hF := (complex_kernel_lipschitz (k (i+1)) x).sub (complex_kernel_lipschitz (k i) x) + have hs := difference_support (k i) (k (i+1)) (width_antitone hd.le (Nat.le_succ i)) x + by_cases hij : i = j + · subst i + exact scaled_corrected_active b hCs (hwp j) (hw1 j) hAt hF + (measurableSet_thinShell x r (width d j)) (difference_bound (k j) (k (j+1)) x) hs hL x z hz hD3 hcap + · exact scaled_corrected_inactive b hCs (hwp i) (hw1 i) hAt hF + (measurableSet_thinShell x r (width d i)) (difference_bound (k i) (k (i+1)) x) hs hL + (hsmall i (by omega) hin) x z hz hD3 + have hh := dist_width_tail hd.le (by norm_num : (0 : ℝ) < 1/10) + (by positivity : 0 ≤ (16+4538*Cs)*t) hjn.le hincr + rw [dist_eq_norm,norm_sub_rev,hid] at hh + exact hh + +end LocalCancellation + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/Main.lean b/lean/OAI/Analysis/SignedDisk/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b89e0501c576d3b38493168a244bb36c7b5a181 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/Main.lean @@ -0,0 +1,345 @@ +import OAI.Analysis.SignedDisk.CommonPrices4 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace SobolevBand +open DiskMoments RadiusEnvelope + +def band (f : ℂ → ℝ) (a b : ℝ) := envelope (fun r x => signedAverage f x r) a b + +lemma smooth_average_lipschitz {f : ℂ → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) + {a t : ℝ} (ha : 0 signedAverage f x t) := by + obtain ⟨L,hL⟩ := hf.lipschitzWith_of_hasCompactSupport hc one_ne_zero + have hD := fun y => norm_fderiv_le_of_lipschitz ℝ hL (x₀ := y) + have hi : Integrable (gradient f) := (continuous_gradient hf).integrable_of_hasCompactSupport (gradient_hasCompactSupport hc) + have ht := ha.trans_le hat + apply lipschitzWith_of_nnnorm_fderiv_le (fun x => (hasFDerivAt_signedAverage hf hD x ht).differentiableAt) + intro x + change ‖fderiv ℝ (fun x => signedAverage f x t) x‖ ≤ _ + rw [← (InnerProductSpace.toDual ℝ ℂ).symm.norm_map] + change ‖gradient (fun x => signedAverage f x t) x‖ ≤ _ + rw [gradient_signedAverage hf hD x ht,norm_smul,Real.norm_eq_abs,abs_of_pos (by positivity : 0<(Real.pi*t^2)⁻¹)] + have he : ‖∫ y in Metric.ball x t, gradient f y‖ ≤ ∫ y, ‖gradient f y‖ := + (norm_integral_le_integral_norm _).trans (setIntegral_le_integral hi.norm (ae_of_all _ (fun y => norm_nonneg _))) + rw [← div_eq_inv_mul] + exact (div_le_div_of_nonneg_right he (by positivity)).trans + (div_le_div_of_nonneg_left (integral_nonneg (fun y => norm_nonneg _)) (by positivity) + (mul_le_mul_of_nonneg_left (sq_le_sq₀ ha.le ht.le |>.mpr hat) Real.pi_pos.le)) + +lemma smooth_band_lipschitz {f : ℂ → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) + {a b : ℝ} (ha : 0 signedAverage_radius_continuousOn hf x ha) + (fun _ hr => smooth_average_lipschitz hf hc ha hr.1) + +open DiskMoments RadiusEnvelope SignedRuns GeometricFilter DyadicHats ActualLabels + +lemma geometric_band_eq (f : ℂ → ℝ) (a : ℝ) (m : ℕ) : + runEnvelope f (geometricRadii a m) 0 m = band f a (2*((2:ℝ)^m*a)) := by + unfold runEnvelope band + rw [geometricRadii_eq a (le_refl m),geometricRadii_eq a (Nat.zero_le m)] + simp only [Nat.sub_self,Nat.sub_zero,scale,pow_zero,one_mul] + +lemma smooth_band_integrable_gradient {f : ℂ → ℝ} (hf : ContDiff ℝ 1 f) + (hc : HasCompactSupport f) {a b : ℝ} (ha : 0 f (e x)) (fun x => e.symm (g (e x))) := by + intro φ hφ hc v + let ψ := φ ∘ e.symm + have hψ : ContDiff ℝ ∞ ψ := hφ.comp e.symm.contDiff + have hψc : HasCompactSupport ψ := hc.comp_homeomorph e.symm.toHomeomorph + have hd x : fderiv ℝ ψ (e x) (e v)=fderiv ℝ φ x v := by + rw [fderiv_comp (e x) (hφ.differentiable (by simp) _) (e.symm.differentiableAt),e.symm.fderiv] + change fderiv ℝ φ (e.symm (e x)) (e.symm (e v))=fderiv ℝ φ x v + simp only [e.symm_apply_apply] + have hi x : ⟪e.symm (g (e x)),v⟫=⟪g (e x),e v⟫ := by + simpa only [e.apply_symm_apply] using (e.inner_map_map (e.symm (g (e x))) v).symm + have h := hw ψ hψ hψc (e v) + rw [← e.measurePreserving.integral_comp e.toMeasurableEquiv.measurableEmbedding (fun y => f y*fderiv ℝ ψ y (e v)), + ← e.measurePreserving.integral_comp e.toMeasurableEquiv.measurableEmbedding (fun y => ⟪g y,e v⟫*ψ y)] at h + simpa only [hd,← hi,ψ,Function.comp_apply,e.symm_apply_apply] using h +end WeakSobolev + +namespace CenteredDiskEndpoint +open WeakSobolev + +lemma hasGradient_iff_hasWeakGradient {f : Plane → ℝ} {g : Plane → Plane} + (hf : LocallyIntegrable f) (hg : Integrable g) : + HasGradient (μ := volume) f g ↔ HasWeakGradient f g := by + constructor + · intro hw φ hφ hc i + simpa only [testPartial,EuclideanSpace.inner_single_right,RCLike.conj_to_real,one_mul] + using hw φ hφ hc (EuclideanSpace.single i 1) + · intro hw φ hφ hc v + have hv : v=∑ i : Fin 2,v i • EuclideanSpace.single i 1 := by + simpa only [EuclideanSpace.basisFun_repr,EuclideanSpace.basisFun_apply] using + ((EuclideanSpace.basisFun (Fin 2) ℝ).sum_repr v).symm + have hleft i : Integrable (fun x => f x*testPartial φ i x) := + hf.integrable_smul_right_of_hasCompactSupport + ((hφ.continuous_fderiv (by simp)).clm_apply continuous_const) (hc.fderiv_apply ℝ _) + have hright i : Integrable (fun x => g x i*φ x) := + ((EuclideanSpace.proj (𝕜 := ℝ) i).integrable_comp hg).locallyIntegrable.integrable_smul_right_of_hasCompactSupport hφ.continuous hc + have hd x : f x*fderiv ℝ φ x v=∑ i : Fin 2,v i*(f x*testPartial φ i x) := by + conv_lhs => rw [hv] + simp only [_root_.map_sum,map_smul,smul_eq_mul,Finset.mul_sum,testPartial] + apply Finset.sum_congr rfl + intro i _ + ring + have hi x : ⟪g x,v⟫*φ x=∑ i : Fin 2,v i*(g x i*φ x) := by + conv_lhs => rw [hv] + simp only [inner_sum,real_inner_smul_right,EuclideanSpace.inner_single_right,RCLike.conj_to_real,one_mul,Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + ring + simp_rw [hd,hi] + rw [integral_finsetSum _ (fun i _ => (hleft i).const_mul _), + integral_finsetSum _ (fun i _ => (hright i).const_mul _)] + simp only [integral_const_mul,hw φ hφ hc,Finset.sum_neg_distrib,mul_neg] + +/-- The coordinate isometry preserves Euclidean, not max-product, norms. -/ +def complexPlane : ℂ ≃ₗᵢ[ℝ] Plane := Complex.orthonormalBasisOneI.repr + +lemma integrable_comp_complexPlane {F : Type*} [NormedAddCommGroup F] {f : Plane → F} : + Integrable (fun z => f (complexPlane z)) ↔ Integrable f := + complexPlane.measurePreserving.integrable_comp_emb complexPlane.toMeasurableEquiv.measurableEmbedding + +lemma integrable_comp_complexPlane_symm {F : Type*} [NormedAddCommGroup F] {f : ℂ → F} : + Integrable (fun x => f (complexPlane.symm x)) ↔ Integrable f := + complexPlane.symm.measurePreserving.integrable_comp_emb complexPlane.symm.toMeasurableEquiv.measurableEmbedding + +lemma locallyIntegrable_comp_complexPlane {f : Plane → ℝ} : + LocallyIntegrable (fun z => f (complexPlane z)) ↔ LocallyIntegrable f := by + have h := locallyIntegrable_map_homeomorph complexPlane.toHomeomorph (f := f) (μ := volume) + change LocallyIntegrable f (Measure.map complexPlane volume) ↔ LocallyIntegrable (fun z => f (complexPlane z)) at h + rw [complexPlane.measurePreserving.map_eq] at h + exact h.symm + +lemma gradientNorm_comp_complexPlane (g : Plane → Plane) : + (∫ z,‖complexPlane.symm (g (complexPlane z))‖)=gradientNorm g := by + simp only [LinearIsometryEquiv.norm_map,gradientNorm] + exact complexPlane.measurePreserving.integral_comp complexPlane.toMeasurableEquiv.measurableEmbedding (fun x => ‖g x‖) + +lemma gradientNorm_comp_complexPlane_symm (G : ℂ → ℂ) : + gradientNorm (fun x => complexPlane (G (complexPlane.symm x)))=∫ z,‖G z‖ := by + simp only [LinearIsometryEquiv.norm_map,gradientNorm] + exact complexPlane.symm.measurePreserving.integral_comp complexPlane.symm.toMeasurableEquiv.measurableEmbedding (fun z => ‖G z‖) +end CenteredDiskEndpoint + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff Convolution + +namespace SobolevBand +open DiskMoments RadiusEnvelope ContinuousLinearMap + +lemma band_self (f : ℂ → ℝ) (a : ℝ) : + band f a a = fun x => signedAverage f x a := by + funext x + simp [band, envelope, Set.Icc_self] + +/-- The normalized open-disk kernel, without an absolute value on the input. -/ +def diskKernel (a : ℝ) : ℂ → ℝ := + (Metric.ball (0 : ℂ) a).indicator (fun _ => (Real.pi * a^2)⁻¹) + +lemma diskKernel_nonneg (a : ℝ) (x : ℂ) : 0 ≤ diskKernel a x := by + apply Set.indicator_nonneg + intro y hy + positivity + +lemma diskKernel_integrable (a : ℝ) : Integrable (diskKernel a) := by + exact (integrableOn_const measure_ball_lt_top.ne).integrable_indicator measurableSet_ball + +lemma diskKernel_integral_abs {a : ℝ} (ha : 0 < a) : + (∫ x, |diskKernel a x|) = 1 := by + simp_rw [abs_of_nonneg (diskKernel_nonneg a _)] + rw [diskKernel, integral_indicator measurableSet_ball, setIntegral_const, + measureReal_def, Complex.volume_ball] + simp only [ENNReal.toReal_mul, ENNReal.toReal_pow, ENNReal.toReal_ofReal ha.le, + smul_eq_mul] + change a^2 * Real.pi * (Real.pi*a^2)⁻¹ = 1 + field_simp + +lemma diskKernel_convolution {F : Type*} [NormedAddCommGroup F] + [NormedSpace ℝ F] (g : ℂ → F) (a : ℝ) (x : ℂ) : + (diskKernel a ⋆[lsmul ℝ ℝ, volume] g) x = + (Real.pi*a^2)⁻¹ • ∫ y in Metric.ball x a, g y := by + rw [convolution_eq_swap, ← integral_smul, ← integral_indicator measurableSet_ball] + apply integral_congr_ae + apply ae_of_all + intro y + have hm : x-y ∈ Metric.ball (0 : ℂ) a ↔ y ∈ Metric.ball x a := by + simp only [Metric.mem_ball, dist_eq_norm, sub_zero, norm_sub_rev] + by_cases hy : y ∈ Metric.ball x a + · simp only [diskKernel, Set.indicator_of_mem (hm.mpr hy), Set.indicator_of_mem hy, + lsmul_apply] + · simp only [diskKernel, Set.indicator_of_notMem (mt hm.mp hy), + Set.indicator_of_notMem hy, lsmul_apply, zero_smul] + +lemma smooth_band_self_bound {f : ℂ → ℝ} (hf : ContDiff ℝ 1 f) + (hc : HasCompactSupport f) {a : ℝ} (ha : 0 < a) : + (∫ x, ‖gradient (band f a a) x‖) ≤ ∫ x, ‖gradient f x‖ := by + have hgi : Integrable (gradient f) := + (continuous_gradient hf).integrable_of_hasCompactSupport (gradient_hasCompactSupport hc) + obtain ⟨L, hL⟩ := hf.lipschitzWith_of_hasCompactSupport hc one_ne_zero + have he : gradient (band f a a) = diskKernel a ⋆[lsmul ℝ ℝ, volume] gradient f := by + funext x + rw [band_self, gradient_signedAverage hf + (fun y => norm_fderiv_le_of_lipschitz ℝ hL (x₀ := y)) x ha, + diskKernel_convolution] + rw [he] + have h := WeakSobolev.norm_convolution_le (diskKernel_integrable a) hgi + simpa only [diskKernel_integral_abs ha, one_mul] using h + +/-- The natural index includes zero, with one absolute constant for both cases. -/ +theorem smooth_dyadic_bound_including_zero : ∃ C : ℝ, 0 ≤ C ∧ + ∀ {f : ℂ → ℝ}, ContDiff ℝ 1 f → HasCompactSupport f → + ∀ {a : ℝ}, 0 < a → ∀ m : ℕ, + (∫ x, ‖gradient (band f a ((2 : ℝ)^m*a)) x‖) ≤ C*(∫ x, ‖gradient f x‖) := by + obtain ⟨C, hC, hbound⟩ := smooth_dyadic_bound + refine ⟨max C 1, (le_max_right C 1).trans' zero_le_one, ?_⟩ + intro f hf hc a ha m + have hv : 0 ≤ ∫ x, ‖gradient f x‖ := integral_nonneg (fun x => norm_nonneg _) + cases m with + | zero => + simpa only [pow_zero, one_mul] using + (smooth_band_self_bound hf hc ha).trans + (by simpa only [one_mul] using mul_le_mul_of_nonneg_right (le_max_right C 1) hv) + | succ n => + have he : (2 : ℝ)^(n+1)*a = 2*((2 : ℝ)^n*a) := by rw [pow_succ]; ring + rw [he] + exact (hbound hf hc ha n).trans + (mul_le_mul_of_nonneg_right (le_max_left C 1) hv) + +end SobolevBand + +namespace CenteredDiskEndpoint +open DiskMoments SobolevBand WeakSobolev + +theorem plane_finiteDimensional : FiniteDimensional ℝ Plane := inferInstance + +theorem plane_borelSpace : BorelSpace Plane := inferInstance + +theorem plane_completeSpace : CompleteSpace Plane := inferInstance + +lemma signedAverage_comp_complexPlane (f : Plane → ℝ) (z : ℂ) (r : ℝ) : + signedAverage (fun w => f (complexPlane w)) z r = diskAverage f (complexPlane z) r := by + unfold signedAverage diskAverage + congr 1 + have h := complexPlane.measurePreserving.setIntegral_image_emb + complexPlane.toMeasurableEquiv.measurableEmbedding f (Metric.ball z r) + rw [complexPlane.image_ball] at h + exact h.symm + +lemma signedBand_comp_complexPlane (f : Plane → ℝ) (a b : ℝ) : + band (fun w => f (complexPlane w)) a b = fun z => signedBand f a b (complexPlane z) := by + funext z + simp only [band, RadiusEnvelope.envelope, signedBand, signedAverage_comp_complexPlane] + +lemma gradient_comp_complexPlane {f : Plane → ℝ} (hf : Differentiable ℝ f) (z : ℂ) : + gradient (fun w => f (complexPlane w)) z = complexPlane.symm (gradient f (complexPlane z)) := by + apply ext_inner_right ℝ + intro v + rw [inner_gradient_left] + change fderiv ℝ (f ∘ complexPlane) z v = _ + rw [fderiv_comp z (hf _) complexPlane.differentiableAt, complexPlane.fderiv] + change fderiv ℝ f (complexPlane z) (complexPlane v) = _ + rw [← inner_gradient_left] + simpa only [complexPlane.apply_symm_apply] using + complexPlane.inner_map_map (complexPlane.symm (gradient f (complexPlane z))) v + +theorem main_signed_finite_band : SignedFiniteBandStatement := by + obtain ⟨C, hC, hbound⟩ := smooth_dyadic_bound_including_zero + refine ⟨C, hC, ?_⟩ + intro f hf hc a ha m + let f' : ℂ → ℝ := fun z => f (complexPlane z) + have hf1 : ContDiff ℝ 1 f := hf.of_le (by simp) + have hf' : ContDiff ℝ 1 f' := hf1.comp complexPlane.contDiff + have hc' : HasCompactSupport f' := hc.comp_homeomorph complexPlane.toHomeomorph + have hab : a ≤ (2 : ℝ)^m*a := by + have hp : (1 : ℝ) ≤ (2 : ℝ)^m := one_le_pow₀ (by norm_num) + simpa only [one_mul] using mul_le_mul_of_nonneg_right hp ha.le + have hL := smooth_band_lipschitz hf' hc' ha hab + have hFi' := hL.continuous.locallyIntegrable (μ := volume) + have hGi' := smooth_band_integrable_gradient hf' hc' ha hab + have he : band f' a ((2 : ℝ)^m*a) = + fun z => signedBand f a ((2 : ℝ)^m*a) (complexPlane z) := + signedBand_comp_complexPlane f a _ + have hFi : LocallyIntegrable (signedBand f a ((2 : ℝ)^m*a)) := by + apply locallyIntegrable_comp_complexPlane.mp + simpa only [he] using hFi' + let G' := gradient (band f' a ((2 : ℝ)^m*a)) + let G := fun x => complexPlane (G' (complexPlane.symm x)) + have hG0 : Integrable (fun x => G' (complexPlane.symm x)) := + integrable_comp_complexPlane_symm.mpr hGi' + have hGi : Integrable G := + complexPlane.toContinuousLinearEquiv.toContinuousLinearMap.integrable_comp hG0 + have hw' : HasGradient (μ := volume) (band f' a ((2 : ℝ)^m*a)) G' := + lipschitz_hasGradient hL + have hw0 := hw'.comp_isometry complexPlane.symm + have hw : HasWeakGradient (signedBand f a ((2 : ℝ)^m*a)) G := by + apply (hasGradient_iff_hasWeakGradient hFi hGi).mp + simpa only [he, complexPlane.apply_symm_apply, LinearIsometryEquiv.symm_symm] using hw0 + refine ⟨hFi, G, hGi, hw, ?_⟩ + have hnorm : (∫ z, ‖gradient f' z‖) = gradientNorm (gradient f) := by + calc + _ = ∫ z, ‖complexPlane.symm (gradient f (complexPlane z))‖ := by + apply integral_congr_ae + exact ae_of_all _ (fun z => congrArg norm + (gradient_comp_complexPlane (hf1.differentiable one_ne_zero) z)) + _ = _ := gradientNorm_comp_complexPlane (gradient f) + rw [show gradientNorm G = ∫ z, ‖G' z‖ from gradientNorm_comp_complexPlane_symm G'] + exact (hbound hf' hc' ha m).trans_eq (congrArg (fun v => C*v) hnorm) + +end CenteredDiskEndpoint + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/Model.lean b/lean/OAI/Analysis/SignedDisk/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f068de545752d8cac059e97131d5067c395c0e1 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/Model.lean @@ -0,0 +1,442 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace SignedDisk + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff + +namespace CenteredDiskEndpoint + +/-- The Euclidean plane, not the product space with its max norm. -/ +abbrev Plane := EuclideanSpace ℝ (Fin 2) + +def diskAverage (f : Plane → ℝ) (x : Plane) (r : ℝ) : ℝ := + (∫ y in Metric.ball x r, f y) / (Real.pi * r ^ 2) + +/-- Absolute disk average, retaining possible infinite values. -/ +def absoluteDiskAverage (f : Plane → ℝ) (x : Plane) (r : ℝ) : ℝ≥0∞ := + (∫⁻ y in Metric.ball x r, ENNReal.ofReal |f y|) / + ENNReal.ofReal (Real.pi * r ^ 2) + +/-- The actual centered disk maximal function, over every positive real radius. -/ +def maximal (f : Plane → ℝ) (x : Plane) : ℝ≥0∞ := + ⨆ (r : ℝ) (_ : 0 < r), absoluteDiskAverage f x r + +/-- Real representative; the endpoint also asserts that `maximal f` is finite a.e. -/ +def maximalReal (f : Plane → ℝ) (x : Plane) : ℝ := (maximal f x).toReal + +/-- The i-th coordinate derivative of a smooth test function. -/ +def testPartial (φ : Plane → ℝ) (i : Fin 2) (x : Plane) : ℝ := + fderiv ℝ φ x (EuclideanSpace.single i 1) + +/-- Distributional first derivatives represented by a vector-valued function. -/ +def HasWeakGradient (f : Plane → ℝ) (g : Plane → Plane) : Prop := + ∀ (φ : Plane → ℝ), ContDiff ℝ ∞ φ → HasCompactSupport φ → + ∀ i : Fin 2, (∫ x, f x * testPartial φ i x) = -∫ x, g x i * φ x + +/-- Real inhomogeneous W^(1,1) on the whole plane. -/ +def InW11 (f : Plane → ℝ) : Prop := + Integrable f ∧ ∃ g : Plane → Plane, Integrable g ∧ HasWeakGradient f g + +/-- Local W^(1,1), expressed using the same distributional gradient convention. -/ +def InW11Loc (f : Plane → ℝ) : Prop := + LocallyIntegrable f ∧ + ∃ g : Plane → Plane, LocallyIntegrable g ∧ HasWeakGradient f g + +/-- The gradient L1 norm in Euclidean norm. -/ +def gradientNorm (g : Plane → Plane) : ℝ := ∫ x, ‖g x‖ + +/-- Signed envelope over all real radii in the closed band, including its endpoints. -/ +def signedBand (f : Plane → ℝ) (a b : ℝ) (x : Plane) : ℝ := + sSup ((fun r => diskAverage f x r) '' Icc a b) + +def SignedFiniteBandStatement : Prop := + ∃ C : ℝ, 0 ≤ C ∧ + ∀ (f : Plane → ℝ), ContDiff ℝ ∞ f → HasCompactSupport f → + ∀ (a : ℝ), 0 < a → ∀ m : ℕ, + LocallyIntegrable (signedBand f a ((2 : ℝ)^m * a)) ∧ + ∃ G : Plane → Plane, Integrable G ∧ + HasWeakGradient (signedBand f a ((2 : ℝ)^m * a)) G ∧ + gradientNorm G ≤ C * gradientNorm (gradient f) + +/-- Exact endpoint, including finiteness before passing to the real representative. +Quantifying the input gradient makes the norm bound independent of a choice of +representative of its weak derivatives. -/ +def EndpointStatement : Prop := + ∃ C : ℝ, 0 ≤ C ∧ + ∀ (f : Plane → ℝ) (g : Plane → Plane), + Integrable f → Integrable g → HasWeakGradient f g → + (∀ᵐ x, maximal f x ≠ ⊤) ∧ + LocallyIntegrable (maximalReal f) ∧ + InW11Loc (maximalReal f) ∧ + ∃ G : Plane → Plane, Integrable G ∧ + HasWeakGradient (maximalReal f) G ∧ gradientNorm G ≤ C * gradientNorm g + +/-- The normalization is precisely planar Lebesgue disk area. -/ +theorem volume_disk (x : Plane) {r : ℝ} (hr : 0 ≤ r) : + volume (Metric.ball x r) = ENNReal.ofReal (Real.pi * r ^ 2) := by + rw [EuclideanSpace.volume_ball_fin_two, ENNReal.ofReal_mul Real.pi_nonneg, + ENNReal.ofReal_pow hr] + exact mul_comm _ _ + +/-- For every admissible input and positive radius the extended average agrees +with the real absolute-value average, rather than a signed average. -/ +theorem absoluteDiskAverage_eq_ofReal {f : Plane → ℝ} {x : Plane} {r : ℝ} + (hf : IntegrableOn f (Metric.ball x r)) (hr : 0 < r) : + absoluteDiskAverage f x r = ENNReal.ofReal (diskAverage (fun y => |f y|) x r) := by + have hden : 0 < Real.pi * r ^ 2 := mul_pos Real.pi_pos (sq_pos_of_pos hr) + rw [absoluteDiskAverage, diskAverage, ENNReal.ofReal_div_of_pos hden, + ofReal_integral_eq_lintegral_ofReal hf.abs (Filter.Eventually.of_forall (fun y => abs_nonneg (f y)))] + +theorem absoluteDiskAverage_ne_top {f : Plane → ℝ} {x : Plane} {r : ℝ} + (hf : IntegrableOn f (Metric.ball x r)) (hr : 0 < r) : + absoluteDiskAverage f x r ≠ ⊤ := by + rw [absoluteDiskAverage_eq_ofReal hf hr] + exact ENNReal.ofReal_ne_top + +theorem absoluteDiskAverage_le_maximal (f : Plane → ℝ) (x : Plane) {r : ℝ} + (hr : 0 < r) : absoluteDiskAverage f x r ≤ maximal f x := by + exact le_iSup_of_le r (le_iSup_of_le hr le_rfl) + +theorem maximal_abs (f : Plane → ℝ) : maximal (fun y => |f y|) = maximal f := by + funext x + simp only [maximal, absoluteDiskAverage, abs_abs] + +theorem inW11_of_gradient {f : Plane → ℝ} {g : Plane → Plane} + (hf : Integrable f) (hg : Integrable g) (hw : HasWeakGradient f g) : InW11 f := + ⟨hf, g, hg, hw⟩ + +theorem inW11Loc_of_gradient {f : Plane → ℝ} {g : Plane → Plane} + (hf : LocallyIntegrable f) (hg : Integrable g) (hw : HasWeakGradient f g) : InW11Loc f := + ⟨hf, g, hg.locallyIntegrable, hw⟩ + +theorem integral_smul_sub_const {α E : Type*} [MeasurableSpace α] + [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] + {μ : Measure α} {b : α → E} {K : α → ℝ} + (hb : Integrable b μ) (hK : Integrable (fun y => K y • b y) μ) + (hzero : ∫ y, b y ∂μ = 0) (c : ℝ) : + (∫ y, (K y - c) • b y ∂μ) = ∫ y, K y • b y ∂μ := by + simp_rw [sub_smul] + have hc : Integrable (fun y => c • b y) μ := hb.smul c + rw [integral_sub hK hc, integral_smul, hzero, smul_zero, sub_zero] + +/-- The small-support zero-mass discount for actual integrable vector densities. +The kernel need only be Lipschitz; no smoothness or unproved moment estimate is +assumed. -/ +theorem localized_cancellation {b : Plane → Plane} {K : Plane → ℝ} + (hb : Integrable b) (hzero : ∫ y, b y = 0) + {L : ℝ≥0} (hK : LipschitzWith L K) (z : Plane) {s : ℝ} + (hsupp : ∀ᵐ y, b y ≠ 0 → ‖y - z‖ ≤ s) : + ‖∫ y, K y • b y‖ ≤ (L : ℝ) * s * ∫ y, ‖b y‖ := by + have hbound : ∀ᵐ y, ‖(K y - K z) • b y‖ ≤ ((L : ℝ) * s) * ‖b y‖ := by + filter_upwards [hsupp] with y hy + by_cases hby : b y = 0 + · simp [hby] + · rw [norm_smul] + exact mul_le_mul_of_nonneg_right + ((hK.norm_sub_le y z).trans (mul_le_mul_of_nonneg_left (hy hby) L.coe_nonneg)) + (norm_nonneg _) + have hdiff : Integrable (fun y => (K y - K z) • b y) := + (hb.norm.smul ((L : ℝ) * s)).mono' + ((hK.continuous.sub continuous_const).aestronglyMeasurable.smul hb.aestronglyMeasurable) + hbound + have hprod : Integrable (fun y => K y • b y) := by + have h := hdiff.add (hb.smul (K z)) + change Integrable (fun y => (K y - K z) • b y + K z • b y) at h + simpa only [← add_smul, sub_add_cancel] using h + rw [← integral_smul_sub_const hb hprod hzero (K z)] + calc + ‖∫ y, (K y - K z) • b y‖ ≤ ∫ y, ((L : ℝ) * s) * ‖b y‖ := + norm_integral_le_of_norm_le (hb.norm.smul ((L : ℝ) * s)) hbound + _ = (L : ℝ) * s * ∫ y, ‖b y‖ := integral_const_mul _ _ + +open InnerProductSpace +open scoped RealInnerProductSpace + +/-- A change of representatives on null sets does not change weak derivatives. -/ +theorem HasWeakGradient.congr_ae {f f' : Plane → ℝ} {g g' : Plane → Plane} + (h : HasWeakGradient f g) (hf : f =ᵐ[volume] f') (hg : g =ᵐ[volume] g') : + HasWeakGradient f' g' := by + intro φ hφ hφc i + calc + (∫ x, f' x * testPartial φ i x) = ∫ x, f x * testPartial φ i x := by + apply integral_congr_ae + filter_upwards [hf] with x hx + rw [hx] + _ = -∫ x, g x i * φ x := h φ hφ hφc i + _ = -∫ x, g' x i * φ x := by + congr 1 + apply integral_congr_ae + filter_upwards [hg] with x hx + rw [hx] + +/-- The distributional gradient is unique as an a.e. class. -/ +theorem HasWeakGradient.ae_unique {f : Plane → ℝ} {g g' : Plane → Plane} + (h : HasWeakGradient f g) (h' : HasWeakGradient f g') + (hg : LocallyIntegrable g) (hg' : LocallyIntegrable g') : g =ᵐ[volume] g' := by + have hcoord (i : Fin 2) : ∀ᵐ x, g x i = g' x i := by + have hgi : LocallyIntegrable (fun x => g x i) := fun x => + (EuclideanSpace.proj (𝕜 := ℝ) i).integrableAtFilter_comp (hg x) + have hgi' : LocallyIntegrable (fun x => g' x i) := fun x => + (EuclideanSpace.proj (𝕜 := ℝ) i).integrableAtFilter_comp (hg' x) + apply ae_eq_of_integral_contDiff_smul_eq hgi hgi' + intro φ hφ hφc + have heq := (h φ hφ hφc i).symm.trans (h' φ hφ hφc i) + simpa only [neg_inj, smul_eq_mul, mul_comm] using heq + filter_upwards [ae_all_iff.mpr hcoord] with x hx + ext i + exact hx i + +/-- Coordinate convention agreement with Mathlib's classical Euclidean gradient. -/ +theorem classicalGradient_apply (f : Plane → ℝ) (x : Plane) (i : Fin 2) : + gradient f x i = testPartial f i x := by + simpa only [EuclideanSpace.inner_single_right, RCLike.conj_to_real, one_mul, testPartial] using + (inner_gradient_left (f := f) (x := x) (y := EuclideanSpace.single i 1)) + +/-- No integrability hypothesis is smuggled into the definition of the weak +identity: every C¹ function satisfies it when tested against compact support. -/ +theorem contDiff_hasWeakGradient {f : Plane → ℝ} (hf : ContDiff ℝ 1 f) : + HasWeakGradient f (gradient f) := by + intro φ hφ hφc i + have hfd : Continuous (fun x => fderiv ℝ f x (EuclideanSpace.single i 1)) := + (hf.continuous_fderiv one_ne_zero).clm_apply continuous_const + have hφd : Continuous (fun x => fderiv ℝ φ x (EuclideanSpace.single i 1)) := + (hφ.continuous_fderiv (by simp)).clm_apply continuous_const + have hφds : HasCompactSupport (fun x => fderiv ℝ φ x (EuclideanSpace.single i 1)) := + hφc.fderiv_apply ℝ (EuclideanSpace.single i 1) + simp_rw [classicalGradient_apply, testPartial] + apply integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + · exact (hfd.mul hφ.continuous).integrable_of_hasCompactSupport hφc.mul_left + · exact (hf.continuous.mul hφd).integrable_of_hasCompactSupport hφds.mul_left + · exact (hf.continuous.mul hφ.continuous).integrable_of_hasCompactSupport hφc.mul_left + · intro x _ + exact hf.differentiable one_ne_zero x + · intro x _ + exact hφ.differentiable (by simp) x + +end CenteredDiskEndpoint + +open scoped RealInnerProductSpace + +namespace CenteredDiskEndpoint +open Filter + +/-- Spherical boundaries are null, so the choice of an open disk does not alter +Lebesgue differentiation averages. -/ +theorem disk_ae_eq_closedDisk (x : Plane) (r : ℝ) : + Metric.ball x r =ᵐ[volume] Metric.closedBall x r := by + apply ae_eq_of_subset_of_measure_ge Metric.ball_subset_closedBall + · exact (Measure.addHaar_closedBall_eq_addHaar_ball volume x r).le + · exact measurableSet_ball.nullMeasurableSet + · exact measure_closedBall_lt_top.ne + +theorem average_closedDisk_eq (f : Plane → ℝ) (x : Plane) {r : ℝ} (hr : 0 ≤ r) : + (⨍ y in Metric.closedBall x r, f y) = diskAverage f x r := by + rw [← setAverage_congr (disk_ae_eq_closedDisk x r), setAverage_eq, + diskAverage, measureReal_def, volume_disk x hr, ENNReal.toReal_ofReal (by positivity)] + simp only [smul_eq_mul, div_eq_inv_mul] + +/-- Almost every point is a Lebesgue point for absolute disk averages. -/ +theorem ae_tendsto_diskAverage_abs {f : Plane → ℝ} (hf : Integrable f) : + ∀ᵐ x, Tendsto (fun r => diskAverage (fun y => |f y|) x r) + (𝓝[>] (0 : ℝ)) (𝓝 |f x|) := by + filter_upwards [IsUnifLocDoublingMeasure.ae_tendsto_average volume hf.abs.locallyIntegrable 0] + with x hx + have h := hx (fun _ : ℝ => x) (fun r : ℝ => r) tendsto_id + (Eventually.of_forall (fun r => by simp)) + apply h.congr' + filter_upwards [self_mem_nhdsWithin] with r hr + exact average_closedDisk_eq (fun y => |f y|) x hr.le + +/-- Away from zero the denominator alone bounds all absolute averages. -/ +theorem diskAverage_abs_le_of_radius_le {f : Plane → ℝ} (hf : Integrable f) + (x : Plane) {a r : ℝ} (ha : 0 < a) (har : a ≤ r) : + diskAverage (fun y => |f y|) x r ≤ (∫ y, |f y|) / (Real.pi * a ^ 2) := by + have hr : 0 < r := ha.trans_le har + have hnum : (∫ y in Metric.ball x r, |f y|) ≤ ∫ y, |f y| := + integral_mono_measure Measure.restrict_le_self + (Eventually.of_forall (fun y => abs_nonneg (f y))) hf.abs + have hden : Real.pi * a ^ 2 ≤ Real.pi * r ^ 2 := + mul_le_mul_of_nonneg_left ((sq_le_sq₀ ha.le hr.le).2 har) Real.pi_nonneg + dsimp [diskAverage] + calc + (∫ y in Metric.ball x r, |f y|) / (Real.pi * r ^ 2) ≤ + (∫ y, |f y|) / (Real.pi * r ^ 2) := + div_le_div_of_nonneg_right hnum (by positivity) + _ ≤ (∫ y, |f y|) / (Real.pi * a ^ 2) := + div_le_div_of_nonneg_left (integral_nonneg (fun y => abs_nonneg (f y))) + (by positivity) hden + +/-- A genuine clause of the endpoint, in fact valid for every L¹ input. No +maximal bound, gradient hypothesis, or selected radius is used here. -/ +theorem ae_maximal_ne_top {f : Plane → ℝ} (hf : Integrable f) : + ∀ᵐ x, maximal f x ≠ ⊤ := by + filter_upwards [ae_tendsto_diskAverage_abs hf] with x hx + obtain ⟨C, hC⟩ := hx.isBoundedUnder_le + obtain ⟨a, ha, haC⟩ := mem_nhdsGT_iff_exists_Ioc_subset.mp hC + have hbound (r : ℝ) (hr : 0 < r) : + diskAverage (fun y => |f y|) x r ≤ max C ((∫ y, |f y|) / (Real.pi * a ^ 2)) := by + by_cases hra : r ≤ a + · exact (haC ⟨hr, hra⟩).trans (le_max_left _ _) + · exact (diskAverage_abs_le_of_radius_le hf x ha (le_of_not_ge hra)).trans + (le_max_right _ _) + have hmax : maximal f x ≤ ENNReal.ofReal + (max C ((∫ y, |f y|) / (Real.pi * a ^ 2))) := by + apply iSup_le + intro r + apply iSup_le + intro hr + rw [absoluteDiskAverage_eq_ofReal hf.integrableOn hr] + exact ENNReal.ofReal_le_ofReal (hbound r hr) + exact ne_top_of_le_ne_top ENNReal.ofReal_ne_top hmax + +end CenteredDiskEndpoint + +open MeasureTheory Set Filter +open scoped Topology ENNReal + +open scoped Real RealInnerProductSpace + +namespace DiskGeometry +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +theorem mem_tangent_ball_iff {z y θ : E} (hθ : ‖θ‖ = 1) {L : ℝ} (hL : 0 < L) : + y ∈ Metric.ball (z + L • θ) L ↔ ‖y - z‖ ^ 2 < 2 * L * ⟪y - z, θ⟫ := by + rw [Metric.mem_ball, dist_eq_norm] + have hv : y - (z + L • θ) = (y - z) - L • θ := by abel + rw [hv, ← sq_lt_sq₀ (norm_nonneg _) hL.le, norm_sub_sq_real, + norm_smul, Real.norm_eq_abs, abs_of_pos hL, hθ, mul_one, real_inner_smul_right] + constructor <;> intro h <;> nlinarith + +theorem tangent_ball_mono {z θ : E} (hθ : ‖θ‖ = 1) {L L' : ℝ} + (hL : 0 < L) (hLL' : L ≤ L') : + Metric.ball (z + L • θ) L ⊆ Metric.ball (z + L' • θ) L' := by + intro y hy + rw [mem_tangent_ball_iff hθ hL] at hy + rw [mem_tangent_ball_iff hθ (hL.trans_le hLL')] + have hinner : 0 < ⟪y - z, θ⟫ := by + by_contra hh + have hh' : ⟪y - z, θ⟫ ≤ 0 := le_of_not_gt hh + have := mul_nonpos_of_nonneg_of_nonpos (show 0 ≤ 2 * L by positivity) hh' + nlinarith [sq_nonneg ‖y - z‖] + exact hy.trans_le (mul_le_mul_of_nonneg_right (by linarith) hinner.le) + +def entryParameter (z y θ : E) : ℝ := ‖y - z‖ ^ 2 / (2 * ⟪y - z, θ⟫) + +theorem mem_tangent_ball_iff_entry {z y θ : E} (hθ : ‖θ‖ = 1) + {L : ℝ} (hL : 0 < L) (ha : 0 < ⟪y - z, θ⟫) : + y ∈ Metric.ball (z + L • θ) L ↔ entryParameter z y θ < L := by + rw [mem_tangent_ball_iff hθ hL, entryParameter, div_lt_iff₀ (by positivity)] + ring_nf + +/-- Uniform estimate on the affine difference of squared distances in a thin shell. -/ +theorem shell_square_error {l δ d : ℝ} (hl : 0 ≤ l) (hl3 : l ≤ 3) + (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1 / 4) (hd : 0 ≤ d) (hclose : |d - l| ≤ 2 * δ) : + |d ^ 2 - l ^ 2| ≤ 13 * δ := by + have hd_upper : d ≤ l + 2 * δ := (abs_le.mp hclose).2 |> fun h => by linarith + have hsum : 0 ≤ d + l := add_nonneg hd hl + calc + |d ^ 2 - l ^ 2| = |d - l| * (d + l) := by + rw [show d ^ 2 - l ^ 2 = (d - l) * (d + l) by ring, abs_mul, abs_of_nonneg hsum] + _ ≤ (2 * δ) * (d + l) := mul_le_mul_of_nonneg_right hclose hsum + _ ≤ 13 * δ := by nlinarith + +/-- A shell point separated from the tangency point has positive radial projection. -/ +theorem shell_projection_lower {ρ δ l a w2 : ℝ} + (hρ : 0 < ρ) (hl : 0 < l) (hl3 : l ≤ 3) + (hδ : δ ≤ ρ ^ 2 / 1600) (hw : ρ ^ 2 ≤ w2) + (herr : |w2 - 2 * l * a| ≤ 13 * δ) : + ρ ^ 2 / 12 ≤ a := by + have hr2 : 0 < ρ ^ 2 := sq_pos_of_pos hρ + have he := (abs_le.mp herr).2 + have hla : 0 < a := by nlinarith + nlinarith + +theorem entry_window {ρ δ l a w2 : ℝ} + (hρ : 0 < ρ) (hδ : 0 ≤ δ) (ha : ρ ^ 2 / 12 ≤ a) + (herr : |w2 - 2 * l * a| ≤ 13 * δ) : + |w2 / (2 * a) - l| ≤ 78 * δ / ρ ^ 2 := by + have hr2 : 0 < ρ ^ 2 := sq_pos_of_pos hρ + have ha0 : 0 < a := lt_of_lt_of_le (by positivity) ha + have h2a : 0 < 2 * a := by positivity + rw [show w2 / (2 * a) - l = (w2 - 2 * l * a) / (2 * a) by field_simp, + abs_div, abs_of_pos h2a] + calc + |w2 - 2 * l * a| / (2 * a) ≤ 13 * δ / (2 * a) := + div_le_div_of_nonneg_right herr h2a.le + _ ≤ 78 * δ / ρ ^ 2 := by + apply (div_le_div_iff₀ h2a hr2).2 + nlinarith [mul_le_mul_of_nonneg_right ha hδ] + +/-- Bound for the entry parameter for an actual shell near a tangent disk. -/ +theorem shell_entry_window {z y θ : E} (hθ : ‖θ‖ = 1) {l ρ δ : ℝ} + (hl : 1 / 2 ≤ l) (hl3 : l ≤ 3) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (hδ : 0 < δ) (hδρ : δ ≤ ρ ^ 2 / 1600) + (hsep : ρ ≤ ‖y - z‖) + (hclose : |dist y (z + l • θ) - l| ≤ 2 * δ) : + ρ ^ 2 / 12 ≤ ⟪y - z, θ⟫ ∧ + |entryParameter z y θ - l| ≤ 78 * δ / ρ ^ 2 := by + have hl0 : 0 < l := by linarith + have hδ1 : δ ≤ 1 / 4 := by nlinarith + have hsq : ρ ^ 2 ≤ ‖y - z‖ ^ 2 := + (sq_le_sq₀ hρ.le (norm_nonneg _)).2 hsep + have hd := shell_square_error hl0.le hl3 hδ.le hδ1 (dist_nonneg (x := y)) hclose + have hv : y - (z + l • θ) = (y - z) - l • θ := by abel + have herr : |‖y - z‖ ^ 2 - 2 * l * ⟪y - z, θ⟫| ≤ 13 * δ := by + rw [dist_eq_norm, hv, norm_sub_sq_real, real_inner_smul_right, norm_smul, + Real.norm_eq_abs, abs_of_pos hl0, hθ, mul_one] at hd + convert hd using 1 + congr 1 + ring + have ha := shell_projection_lower hρ hl0 hl3 hδρ hsq herr + exact ⟨ha, entry_window hρ hδ.le ha herr⟩ + +theorem earlier_tangent_disk_subset {z θ : E} (hθ : ‖θ‖ = 1) {l ρ δ : ℝ} + (hl : 1 / 2 ≤ l) (hl3 : l ≤ 3) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (hδ : 0 < δ) (hδρ : δ ≤ ρ ^ 2 / 1600) : + {y : E | ρ ≤ ‖y - z‖} ∩ + Metric.ball (z + (l - 200 * δ / ρ ^ 2) • θ) (l - 200 * δ / ρ ^ 2) ⊆ + Metric.ball (z + l • θ) (l - 2 * δ) := by + let v : ℝ := 200 * δ / ρ ^ 2 + have hr2 : 0 < ρ ^ 2 := sq_pos_of_pos hρ + have hvpos : 0 < v := by dsimp [v]; positivity + have hvsmall : v ≤ 1 / 8 := by + dsimp [v] + apply (div_le_iff₀ hr2).2 + linarith + have hv_eq : v * ρ ^ 2 = 200 * δ := by + dsimp [v]; exact div_mul_cancel₀ _ hr2.ne' + have hl0 : 0 < l := by linarith + have hlv : 0 < l - v := by linarith + have hδquarter : δ ≤ 1 / 4 := by nlinarith + have hrad : 0 < l - 2 * δ := by nlinarith + rintro y ⟨hsep, hy⟩ + change y ∈ Metric.ball (z + (l - v) • θ) (l - v) at hy + rw [mem_tangent_ball_iff hθ hlv] at hy + have hnorm : ρ ^ 2 ≤ ‖y - z‖ ^ 2 := + (sq_le_sq₀ hρ.le (norm_nonneg _)).2 hsep + have hapos : 0 < ⟪y - z, θ⟫ := by + by_contra ha + have hmul := mul_nonpos_of_nonneg_of_nonpos + (show 0 ≤ 2 * (l - v) by positivity) (le_of_not_gt ha) + nlinarith + have halower : ρ ^ 2 / 6 < ⟪y - z, θ⟫ := by nlinarith + have hva := mul_lt_mul_of_pos_left halower hvpos + have hsqdist : dist y (z + l • θ) ^ 2 < (l - 2 * δ) ^ 2 := by + rw [dist_eq_norm, show y - (z + l • θ) = (y - z) - l • θ by abel, + norm_sub_sq_real, real_inner_smul_right, norm_smul, Real.norm_eq_abs, + abs_of_pos hl0, hθ, mul_one] + nlinarith [mul_le_mul_of_nonneg_right hl3 hδ.le] + exact (sq_lt_sq₀ dist_nonneg hrad.le).1 hsqdist + +end DiskGeometry + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/PhysicalCells1.lean b/lean/OAI/Analysis/SignedDisk/PhysicalCells1.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ec3ad08390b017575182496ca4bd1101ac1c41d --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/PhysicalCells1.lean @@ -0,0 +1,477 @@ +import OAI.Analysis.SignedDisk.DiskMaximalTools2 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace PhysicalCells +lemma derivative_majorant_integral {F : ℂ → ℝ≥0∞} {C P : ℝ} (p : ℂ) {r : ℝ} + (hr : 0 < r) (hF : (∫⁻ X in unitCell, F X) ≤ ENNReal.ofReal (C*r⁻¹*P)) : + (∫⁻ y in cell p r, ENNReal.ofReal r⁻¹*F (toUnit p r y)) ≤ ENNReal.ofReal (C*P) := by + rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top,cell_majorant p hr.ne'] + apply (mul_le_mul' le_rfl (mul_le_mul' le_rfl hF)).trans_eq + rw [← ENNReal.ofReal_mul (sq_nonneg r),← ENNReal.ofReal_mul (inv_nonneg.mpr hr.le)] + congr 1 + field_simp + +lemma value_majorant_integral {F : ℂ → ℝ≥0∞} {C P : ℝ} (p : ℂ) {r : ℝ} + (hr : 0 < r) (hF : (∫⁻ X in unitCell, F X) ≤ ENNReal.ofReal (C*r⁻¹*P)) : + (∫⁻ y in cell p r, F (toUnit p r y)) ≤ ENNReal.ofReal (C*r*P) := by + rw [cell_majorant p hr.ne'] + apply (mul_le_mul' le_rfl hF).trans_eq + rw [← ENNReal.ofReal_mul (sq_nonneg r)] + congr 1 + field_simp +end PhysicalCells + +namespace DiskMoments +lemma average_gradient_norm_le {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (x : ℂ) {t : ℝ} (ht : 1 ≤ t) : + ‖gradient (fun y => signedAverage g y t) x‖ ≤ ‖∫ y in Metric.ball x t, gradient g y‖ := by + have hp : 0 < Real.pi*t^2 := mul_pos Real.pi_pos (sq_pos_of_pos (by linarith)) + have h1 : 1 ≤ Real.pi*t^2 := by nlinarith [Real.pi_gt_three,sq_nonneg (t-1)] + rw [gradient_signedAverage hg hD x (by linarith),norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hp)] + exact mul_le_of_le_one_left (norm_nonneg _) ((inv_le_one₀ hp).mpr h1) + +lemma average_gradient_negative_le {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (x n : ℂ) {t : ℝ} (ht : 1 ≤ t) : + max 0 (-inner ℝ n (gradient (fun y => signedAverage g y t) x)) ≤ + max 0 (-inner ℝ n (∫ y in Metric.ball x t, gradient g y)) := by + have hp : 0 < Real.pi*t^2 := mul_pos Real.pi_pos (sq_pos_of_pos (by linarith)) + have h1 : 1 ≤ Real.pi*t^2 := by nlinarith [Real.pi_gt_three,sq_nonneg (t-1)] + rw [gradient_signedAverage hg hD x (by linarith),inner_smul_right,← mul_neg, + ← mul_zero (Real.pi*t^2)⁻¹,← mul_max_of_nonneg _ _ (inv_nonneg.mpr hp.le)] + simp only [mul_zero] + exact mul_le_of_le_one_left (le_max_left _ _) ((inv_le_one₀ hp).mpr h1) + +lemma physical_gradient_norm_majorant {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (p X : ℂ) {r t : ℝ} (hr : 0 < r) (ht : 0 < t) + {F : ℝ≥0∞} + (hF : ENNReal.ofReal ‖gradient (fun Y => signedAverage (fun Z => g (p+r • Z)) Y t) X‖ ≤ F) : + ENNReal.ofReal ‖gradient (fun y => signedAverage g y (r*t)) (p+r • X)‖ ≤ + ENNReal.ofReal r⁻¹*F := by + have h : ENNReal.ofReal r⁻¹*_ ≤ ENNReal.ofReal r⁻¹*F := mul_le_mul' le_rfl hF + rw [gradient_average_affine hg hD p X hr ht,norm_smul,Real.norm_eq_abs,abs_of_pos hr, + ← ENNReal.ofReal_mul (inv_nonneg.mpr hr.le),inv_mul_cancel_left₀ hr.ne'] at h + exact h + +lemma physical_gradient_negative_majorant {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (p X n : ℂ) {r t : ℝ} (hr : 0 < r) (ht : 0 < t) + {F : ℝ≥0∞} + (hF : ENNReal.ofReal (max 0 (-inner ℝ n + (gradient (fun Y => signedAverage (fun Z => g (p+r • Z)) Y t) X))) ≤ F) : + ENNReal.ofReal (max 0 (-inner ℝ n (gradient (fun y => signedAverage g y (r*t)) (p+r • X)))) ≤ + ENNReal.ofReal r⁻¹*F := by + have h : ENNReal.ofReal r⁻¹*_ ≤ ENNReal.ofReal r⁻¹*F := mul_le_mul' le_rfl hF + rw [gradient_average_affine hg hD p X hr ht,inner_smul_right,← mul_neg, + ← mul_zero r,← mul_max_of_nonneg _ _ hr.le, + ← ENNReal.ofReal_mul (inv_nonneg.mpr hr.le),inv_mul_cancel_left₀ hr.ne'] at h + simpa only [mul_zero] using h +end DiskMoments + +namespace CommonPrices +open DyadicHats ConeCoordinates LocalCancellation AffineDensities DirectionNeighbors Finset DiskMoments PricePieces PhysicalCells + +theorem physical_directional_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → ∀ (k : ℕ) (p : ℤ × ℤ) + {n : ℂ}, n ∈ fixedPalette.labels → ∀ {s : ℝ}, (s = 1 ∨ s = -1) → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ y in cell (point (scale r k) p) (scale r k), F y) ≤ ENNReal.ofReal + (C*(badPrice (gradient g) r k (cellRoots N p) n+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ y ∈ cell (point (scale r k) p) (scale r k), ∀ t, + PhysicalNeighborhoodRadius g (scale r k) y t → + ENNReal.ofReal (max 0 (-inner ℝ (axis n s) (gradient (fun z => signedAverage g z t) y))) ≤ F y := by + obtain ⟨C,hC,hmajor⟩ := directional_cell_price + refine ⟨C,hC,?_⟩ + intro N r R hr hR hN g hg hh hsupp hD k p n hn s hs + obtain ⟨D,hD⟩ := hD + obtain ⟨D',hD'⟩ := fderiv_affine_bound (hg.differentiable one_ne_zero) (point (scale r k) p) (scale r k) hD + obtain ⟨F,hFm,hFi,hFb⟩ := hmajor hr hR hN hg hh hsupp k p hn hs unitCell (by rw [volume_unitCell]; norm_num) + refine ⟨fun y => ENNReal.ofReal (scale r k)⁻¹*F (toUnit (point (scale r k) p) (scale r k) y), + measurable_const.mul (hFm.comp (toUnit_continuous _ _).measurable), + derivative_majorant_integral _ (scale_pos hr k) hFi,?_⟩ + intro y hy t ht + let X := toUnit (point (scale r k) p) (scale r k) y + have hX : ‖X‖ ≤ 2 := norm_unitCell hy + have he : point (scale r k) p+scale r k • X = y := affine_toUnit _ (scale_pos hr k).ne' y + have ht' : PhysicalNeighborhoodRadius g (scale r k) + (point (scale r k) p+scale r k • X) (scale r k*(t/scale r k)) := by + simpa only [he,mul_div_cancel₀ _ (scale_pos hr k).ne'] using ht + have htn := neighborhoodRadius_affine _ X (scale_pos hr k) ht' + have hg' : ContDiff ℝ 1 (fun Z => g (point (scale r k) p+scale r k • Z)) := hg.comp (by fun_prop) + have hb := (ENNReal.ofReal_le_ofReal (average_gradient_negative_le hg' hD' X (axis n s) htn.1.1)).trans + (hFb X hX _ htn) + have hf := physical_gradient_negative_majorant hg hD (point (scale r k) p) X (axis n s) + (scale_pos hr k) (by linarith [htn.1.1]) hb + simpa only [he,mul_div_cancel₀ _ (scale_pos hr k).ne'] using hf + +theorem physical_size_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → ∀ (k : ℕ) (p : ℤ × ℤ) + {n : ℂ}, n ∈ fixedPalette.labels → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ y in cell (point (scale r k) p) (scale r k), F y) ≤ ENNReal.ofReal + (C*(rootMass (gradient g) r k (cellRoots N p)+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ y ∈ cell (point (scale r k) p) (scale r k), ∀ t, + PhysicalEndpointRadius g (scale r k) y t → + ENNReal.ofReal ‖gradient (fun z => signedAverage g z t) y‖ ≤ F y := by + obtain ⟨C,hC,hmajor⟩ := size_cell_price + refine ⟨C,hC,?_⟩ + intro N r R hr hR hN g hg hh hsupp hD k p n hn + obtain ⟨D,hD⟩ := hD + obtain ⟨D',hD'⟩ := fderiv_affine_bound (hg.differentiable one_ne_zero) (point (scale r k) p) (scale r k) hD + obtain ⟨F,hFm,hFi,hFb⟩ := hmajor hr hR hN hg hh hsupp k p hn unitCell (by rw [volume_unitCell]; norm_num) + refine ⟨fun y => ENNReal.ofReal (scale r k)⁻¹*F (toUnit (point (scale r k) p) (scale r k) y), + measurable_const.mul (hFm.comp (toUnit_continuous _ _).measurable), + derivative_majorant_integral _ (scale_pos hr k) hFi,?_⟩ + intro y hy t ht + let X := toUnit (point (scale r k) p) (scale r k) y + have hX : ‖X‖ ≤ 2 := norm_unitCell hy + have he : point (scale r k) p+scale r k • X = y := affine_toUnit _ (scale_pos hr k).ne' y + have ht' : PhysicalEndpointRadius g (scale r k) + (point (scale r k) p+scale r k • X) (scale r k*(t/scale r k)) := by + simpa only [he,mul_div_cancel₀ _ (scale_pos hr k).ne'] using ht + have htn := endpointRadius_affine _ X (scale_pos hr k) ht' + have hg' : ContDiff ℝ 1 (fun Z => g (point (scale r k) p+scale r k • Z)) := hg.comp (by fun_prop) + have hb := (ENNReal.ofReal_le_ofReal (average_gradient_norm_le hg' hD' X htn.1.1)).trans + (hFb X hX _ htn) + have hf := physical_gradient_norm_majorant hg hD (point (scale r k) p) X + (scale_pos hr k) (by linarith [htn.1.1]) hb + simpa only [he,mul_div_cancel₀ _ (scale_pos hr k).ne'] using hf + +theorem physical_value_price : ∃ C : ℝ, 0 < C ∧ + ∀ {N : ℕ} {r R : ℝ} (hr : 0 < r) (hR : 0 ≤ R) (hN : R/r+1 ≤ (N:ℝ)) + {g : ℂ → ℝ}, ContDiff ℝ 1 g → Integrable (gradient g) → + (∀ y, gradient g y ≠ 0 → ‖y‖ ≤ R) → + (∃ D : ℝ, ∀ y, ‖fderiv ℝ g y‖ ≤ D) → ∀ (k : ℕ) (p : ℤ × ℤ) + {n : ℂ}, n ∈ fixedPalette.labels → + ∃ F : ℂ → ℝ≥0∞, Measurable F ∧ + (∫⁻ y in cell (point (scale r k) p) (scale r k), F y) ≤ ENNReal.ofReal + (C*scale r k*(rootMass (gradient g) r k (cellRoots N p)+cellPrice N r (gradient g) k (cellRoots N p))) ∧ + ∀ y ∈ cell (point (scale r k) p) (scale r k), ∀ t t', + 0 < t → t ≤ 4*scale r k → 0 < t' → t' ≤ 4*scale r k → + ENNReal.ofReal |signedAverage g y t-signedAverage g y t'| ≤ F y := by + obtain ⟨C,hC,hmajor⟩ := value_cell_price + refine ⟨C,hC,?_⟩ + intro N r R hr hR hN g hg hh hsupp hD k p n hn + obtain ⟨F,hFm,hFi,hFb⟩ := hmajor hr hR hN hg hh hsupp hD k p hn unitCell (by rw [volume_unitCell]; norm_num) + refine ⟨fun y => F (toUnit (point (scale r k) p) (scale r k) y), + hFm.comp (toUnit_continuous _ _).measurable, + value_majorant_integral _ (scale_pos hr k) hFi,?_⟩ + intro y hy t t' ht hb ht' hb' + let X := toUnit (point (scale r k) p) (scale r k) y + have he : point (scale r k) p+scale r k • X = y := affine_toUnit _ (scale_pos hr k).ne' y + have hrk := scale_pos hr k + have hf := hFb X (norm_unitCell hy) (t/scale r k) (t'/scale r k) + (div_pos ht hrk) ((div_le_iff₀ hrk).mpr hb) (div_pos ht' hrk) ((div_le_iff₀ hrk).mpr hb') + simpa only [signedAverage_affine _ _ _ hrk (div_pos ht hrk), + signedAverage_affine _ _ _ hrk (div_pos ht' hrk),he,mul_div_cancel₀ _ hrk.ne'] using hf +end CommonPrices + +namespace DiskMoments +lemma signedAverage_abs_le {g : ℂ → ℝ} {M : ℝ} (hM : ∀ y, |g y| ≤ M) + (x : ℂ) {t : ℝ} (ht : 0 < t) : |signedAverage g x t| ≤ M := by + rw [signedAverage_fixedDomain g x ht,abs_div,abs_of_pos Real.pi_pos] + have : IsFiniteMeasure (volume.restrict (Metric.ball (0:ℂ) 1)) := ⟨by simp⟩ + have hi := norm_integral_le_of_norm_le_const (μ := volume.restrict (Metric.ball (0:ℂ) 1)) + (C := M) (f := fun z : ℂ => g (x+t • z)) (ae_of_all _ (fun z => by simpa only [Real.norm_eq_abs] using hM (x+t • z))) + have hv : (volume.restrict (Metric.ball (0:ℂ) 1)).real univ = Real.pi := by + simp [measureReal_def,Complex.volume_ball] + rw [hv,Real.norm_eq_abs] at hi + exact (div_le_iff₀ Real.pi_pos).mpr hi + +def oscillationSet (g : ℂ → ℝ) (r : ℝ) (x : ℂ) : Set ℝ := + {a | ∃ t t', 0 < t ∧ t ≤ 4*r ∧ 0 < t' ∧ t' ≤ 4*r ∧ a = |signedAverage g x t-signedAverage g x t'|} +def oscillation (g : ℂ → ℝ) (r : ℝ) (x : ℂ) : ℝ := sSup (oscillationSet g r x) + +lemma oscillationSet_zero (g : ℂ → ℝ) {r : ℝ} (hr : 0 < r) (x : ℂ) : + 0 ∈ oscillationSet g r x := ⟨r,r,hr,by linarith,hr,by linarith,by simp⟩ +lemma oscillationSet_bdd {g : ℂ → ℝ} (hg : Continuous g) (hc : HasCompactSupport g) (r : ℝ) (x : ℂ) : + BddAbove (oscillationSet g r x) := by + obtain ⟨M,hM⟩ := hc.exists_bound_of_continuous hg + refine ⟨2*M,?_⟩ + rintro a ⟨t,t',ht,_,ht',_,rfl⟩ + have hb : ∀ y, |g y| ≤ M := by simpa only [Real.norm_eq_abs] using hM + have h1 := signedAverage_abs_le hb x ht + have h2 := signedAverage_abs_le hb x ht' + linarith [abs_sub (signedAverage g x t) (signedAverage g x t')] +lemma oscillation_nonneg {g : ℂ → ℝ} (hg : Continuous g) (hc : HasCompactSupport g) {r : ℝ} + (hr : 0 < r) (x : ℂ) : 0 ≤ oscillation g r x := + le_csSup (oscillationSet_bdd hg hc r x) (oscillationSet_zero g hr x) +lemma le_oscillation {g : ℂ → ℝ} (hg : Continuous g) (hc : HasCompactSupport g) {r : ℝ} + (x : ℂ) {t t' : ℝ} (ht : 0 < t) (hb : t ≤ 4*r) (ht' : 0 < t') (hb' : t' ≤ 4*r) : + |signedAverage g x t-signedAverage g x t'| ≤ oscillation g r x := + le_csSup (oscillationSet_bdd hg hc r x) ⟨t,t',ht,hb,ht',hb',rfl⟩ +lemma oscillation_majorant {g : ℂ → ℝ} {r : ℝ} (hr : 0 < r) (x : ℂ) {F : ℝ≥0∞} + (hF : ∀ t t', 0 < t → t ≤ 4*r → 0 < t' → t' ≤ 4*r → + ENNReal.ofReal |signedAverage g x t-signedAverage g x t'| ≤ F) : + ENNReal.ofReal (oscillation g r x) ≤ F := by + by_cases htop : F = ⊤ + · simp only [htop,le_top] + · apply (ENNReal.ofReal_le_iff_le_toReal htop).mpr + apply csSup_le ⟨0,oscillationSet_zero g hr x⟩ + rintro a ⟨t,t',ht,hb,ht',hb',rfl⟩ + exact (ENNReal.ofReal_le_iff_le_toReal htop).mp (hF t t' ht hb ht' hb') +end DiskMoments + +namespace SignedRuns + +section +open DiskMoments RadiusEnvelope ActualLabels Finset + +variable (g : ℂ → ℝ) (r : ℕ → ℝ) +def runEnvelope (i j : ℕ) (x : ℂ) : ℝ := + envelope (fun t y => signedAverage g y t) (r j) (2*r i) x + +lemma radius_antitone (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) : Antitone r := by + apply antitone_nat_of_succ_le + intro k + have := hr (k+1) + linarith [hstep k] + +lemma runEnvelope_attains (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) {i j : ℕ} (hij : i ≤ j) (x : ℂ) : + ∃ t ∈ Icc (r j) (2*r i), runEnvelope g r i j x = signedAverage g x t ∧ + ∀ s ∈ Icc (r j) (2*r i), signedAverage g x s ≤ signedAverage g x t := by + apply attains _ x (signedAverage_radius_continuousOn hg x (hr j)) + have := radius_antitone r hr hstep hij + linarith [hr i] + +lemma runEnvelope_le_next (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) {i j : ℕ} (hij : i ≤ j) (x : ℂ) : + runEnvelope g r i j x ≤ runEnvelope g r i (j+1) x := by + obtain ⟨t,ht,he,_⟩ := runEnvelope_attains g r hg hr hstep hij x + rw [he] + apply le_envelope ⟨(radius_antitone r hr hstep (Nat.le_succ j)).trans ht.1,ht.2⟩ x + (signedAverage_radius_continuousOn hg x (hr (j+1))) + +lemma runEnvelope_extension_bound (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) {i j : ℕ} (hij : i ≤ j) (x : ℂ) {V : ℝ} + (hV : ∀ t t', 0 < t → t ≤ 4*r (j+1) → 0 < t' → t' ≤ 4*r (j+1) → + |signedAverage g x t-signedAverage g x t'| ≤ V) : + |runEnvelope g r i (j+1) x-runEnvelope g r i j x| ≤ V := by + have hV0 : 0 ≤ V := by + have hh := hr (j+1) + simpa using hV (r (j+1)) (r (j+1)) hh (by linarith) hh (by linarith) + have h0 := runEnvelope_le_next g r hg hr hstep hij x + rw [abs_of_nonneg (sub_nonneg.mpr h0)] + obtain ⟨t,ht,he,_⟩ := runEnvelope_attains g r hg hr hstep (hij.trans (Nat.le_succ j)) x + rw [he] + by_cases htj : r j ≤ t + · have hh := le_envelope (u := fun t y => signedAverage g y t) ⟨htj,ht.2⟩ x + (signedAverage_radius_continuousOn hg x (hr j)) + change signedAverage g x t ≤ runEnvelope g r i j x at hh + linarith + · have hb : signedAverage g x (r j) ≤ runEnvelope g r i j x := by + change signedAverage g x (r j) ≤ envelope (fun t y => signedAverage g y t) (r j) (2*r i) x + apply le_envelope (u := fun t y => signedAverage g y t) (a := r j) (b := 2*r i) (r := r j) ⟨le_rfl,?_⟩ x (signedAverage_radius_continuousOn hg x (hr j)) + have := radius_antitone r hr hstep hij + linarith [hr i] + have hh := hV t (r j) ((hr (j+1)).trans_le ht.1) + (by linarith [hstep j,hr (j+1)]) (hr j) (by linarith [hstep j,hr (j+1)]) + linarith [le_abs_self (signedAverage g x t-signedAverage g x (r j))] + +lemma runEnvelope_new_bound (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (j : ℕ) (x : ℂ) {V : ℝ} + (hV : ∀ t t', 0 < t → t ≤ 4*r j → 0 < t' → t' ≤ 4*r j → + |signedAverage g x t-signedAverage g x t'| ≤ V) : + |runEnvelope g r j j x-signedAverage g x (r j)| ≤ V := by + obtain ⟨t,ht,he,_⟩ := runEnvelope_attains g r hg hr hstep le_rfl x + rw [he] + exact hV t (r j) ((hr j).trans_le ht.1) (by linarith [hr j,ht.2]) (hr j) (by linarith [hr j]) + +/-- Reversed chronological histories. The active run's start is retained when +its new label agrees, and is reset to the new time at a switch. -/ +def activeStart : List Label → ℕ + | [] => 0 + | [_] => 0 + | n::old::p => if n = old then activeStart (old::p) else (old::p).length + +lemma activeStart_le (n : Label) (p : List Label) : activeStart (n::p) ≤ p.length := by + induction p generalizing n with + | nil => simp [activeStart] + | cons old p ih => + dsimp only [activeStart] + split_ifs + · exact (ih old).trans (by simp) + · rfl + +/-- The exact closed-prefix vector potential, updated without ever taking the +absolute size of an old large-radius envelope. -/ +def potential (x : ℂ) : List Label → ℂ + | [] => 0 + | [n] => (runEnvelope g r 0 0 x-signedAverage g x (r 0)) • (n:ℂ) + | n::old::p => potential x (old::p)+ + (if n = old then (runEnvelope g r (activeStart (old::p)) (p.length+1) x- + runEnvelope g r (activeStart (old::p)) p.length x) • (n:ℂ) + else (runEnvelope g r (p.length+1) (p.length+1) x- + signedAverage g x (r (p.length+1))) • (n:ℂ)) + +lemma potential_increment (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (x : ℂ) (v : ℕ → ℝ) + (hv : ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |signedAverage g x t-signedAverage g x t'| ≤ v k) + (n : Label) (p : List Label) : ‖potential g r x (n::p)-potential g r x p‖ ≤ v p.length := by + cases p with + | nil => + simp only [potential,List.length_nil,sub_zero,norm_smul,Real.norm_eq_abs,label_unit,mul_one] + exact runEnvelope_new_bound g r hg hr hstep 0 x (hv 0) + | cons old p => + simp only [potential,add_sub_cancel_left,List.length_cons] + split_ifs + · simp only [norm_smul,Real.norm_eq_abs,label_unit,mul_one] + exact runEnvelope_extension_bound g r hg hr hstep (activeStart_le old p) x (hv (p.length+1)) + · simp only [norm_smul,Real.norm_eq_abs,label_unit,mul_one] + exact runEnvelope_new_bound g r hg hr hstep (p.length+1) x (hv (p.length+1)) + +theorem potential_continuation_bound (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (x : ℂ) (v : ℕ → ℝ) + (hv : ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |signedAverage g x t-signedAverage g x t'| ≤ v k) + (p q : List Label) : ‖potential g r x (q++p)-potential g r x p‖ ≤ + ∑ k ∈ Ico p.length (p.length+q.length), v k := by + induction q with + | nil => simp + | cons n q ih => + have htri : ‖potential g r x ((n::q)++p)-potential g r x p‖ ≤ + ‖potential g r x (n::(q++p))-potential g r x (q++p)‖+ + ‖potential g r x (q++p)-potential g r x p‖ := by + simpa only [sub_add_sub_cancel,List.cons_append] using norm_add_le + (potential g r x (n::(q++p))-potential g r x (q++p)) + (potential g r x (q++p)-potential g r x p) + have hi := potential_increment g r hg hr hstep x v hv n (q++p) + apply htri.trans + rw [List.length_cons,Nat.add_succ,sum_Ico_succ_top (by omega : p.length ≤ p.length+q.length)] + simpa only [List.length_append,Nat.add_comm,add_comm] using add_le_add hi ih +end + +open SignedAssembly FiniteLabels ActualLabels Finset + +variable (g : ℂ → ℝ) (r : ℕ → ℝ) (x : ℂ) +variable (J : ℕ → Label → RowJet Label ℂ) (v : ℕ → ℝ) + +/-- The actual closed-prefix potentials at the leaves, with the stochastic +row jet at every observation time. -/ +def jet : ℕ → List Label → Label → JetTree Label ℂ + | 0,p,_ => .leaf (potential g r x p) + | d+1,p,n => .branch (J p.length n) (potential g r x p) + (∑ k ∈ Ico p.length (p.length+d+1), v k) (fun a => jet d (a::p) a) + +lemma jet_terminalBound (d : ℕ) (p : List Label) (old : Label) (c : ℂ) (B : ℝ) + (h : ∀ q : List Label, q.length = d → ‖potential g r x (q++p)-c‖ ≤ B) : + TerminalBound (jet g r x J v d p old) c B := by + induction d generalizing p old with + | zero => simpa only [jet,TerminalBound,List.nil_append] using h [] rfl + | succ d ih => + intro n + apply ih + intro q hq + have hh := h (q++[n]) (by simp only [List.length_append,List.length_singleton,hq]) + simpa only [List.append_assoc,List.singleton_append] using hh + +lemma jet_controlled (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) + (hv : ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |DiskMoments.signedAverage g x t-DiskMoments.signedAverage g x t'| ≤ v k) + (d : ℕ) (p : List Label) (old : Label) : Controlled (jet g r x J v d p old) := by + induction d generalizing p old with + | zero => trivial + | succ d ih => + constructor + · intro n + apply jet_terminalBound + intro q hq + have hh := potential_continuation_bound g r hg hr hstep x v hv p (q++[n]) + simpa only [List.append_assoc,List.singleton_append,List.length_append,List.length_singleton,hq,Nat.add_assoc] using hh + · intro n + exact ih (n::p) n + +/-- Backward expected reward for an arbitrary time-dependent finite Markov law. -/ +def rewardCost (reward : ℕ → Label → ℝ) : ℕ → ℕ → Label → ℝ + | _,0,_ => 0 + | k,d+1,n => reward k n+expect (J k n).law (fun a => rewardCost reward (k+1) d a) + +lemma jet_cost (d : ℕ) (p : List Label) (old : Label) (m : ℕ) (hm : p.length+d = m) : + cost (jet g r x J v d p old) = rewardCost J + (fun k n => (∑ a, ‖(J k n).grad a‖)*(∑ l ∈ Ico k m, v l)) p.length d old := by + induction d generalizing p old with + | zero => rfl + | succ d ih => + simp only [jet,cost,rewardCost] + have htop : p.length+d+1 = m := by omega + rw [htop] + congr 1 + apply sum_congr rfl + intro a _ + rw [ih (a::p) a (by simp only [List.length_cons]; omega)] + rfl + +lemma expect_rewardCost (reward : ℕ → Label → ℝ) (μ : ℕ → Law Label) + (hμ : ∀ k, μ (k+1) = move (μ k) (fun n => (J k n).law)) (d k : ℕ) : + expect (μ k) (rewardCost J reward k d) = + ∑ i ∈ Ico k (k+d), expect (μ i) (reward i) := by + induction d generalizing k with + | zero => simp [rewardCost,FiniteLabels.expect] + | succ d ih => + change expect (μ k) (fun n => reward k n+expect (J k n).law (fun a => rewardCost J reward (k+1) d a)) = _ + rw [expect_add,← expect_move,← hμ k,ih] + rw [sum_Ico_eq_sum_range,sum_Ico_eq_sum_range] + simp only [Nat.add_sub_cancel_left,Nat.add_assoc,Nat.add_sub_cancel_left] + rw [sum_range_succ'] + simp only [Nat.add_zero,Nat.add_left_comm,add_comm,Nat.add_sub_cancel_right] + +/-- Signed finite-history flux with the actual run potential and the exact +forward stochastic marginal law. No old large-radius envelope is priced. -/ +theorem run_signed_flux_bound (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) + (hv : ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |DiskMoments.signedAverage g x t-DiskMoments.signedAverage g x t'| ≤ v k) + (m : ℕ) (old : Label) (μ : ℕ → Law Label) (hμ0 : μ 0 = delta old) + (hμ : ∀ k, μ (k+1) = move (μ k) (fun n => (J k n).law)) : + |pathFlux (jet g r x J v m [] old) 1 0| ≤ + ∑ k ∈ range m, expect (μ k) (fun n => ∑ a, ‖(J k n).grad a‖)* + (∑ l ∈ Ico k m, v l) := by + have hh := signed_flux_bound _ (jet_controlled g r x J v hg hr hstep hv m [] old) + rw [jet_cost g r x J v m [] old m (by simp)] at hh + have he := expect_rewardCost J + (fun k n => (∑ a, ‖(J k n).grad a‖)*(∑ l ∈ Ico k m, v l)) μ hμ m 0 + rw [hμ0,expect_delta] at he + simp only [Nat.zero_add,Nat.Ico_zero_eq_range] at he + simp only [List.length_nil] at hh + rw [he] at hh + simpa only [FiniteLabels.expect,← mul_assoc,← sum_mul] using hh +end SignedRuns + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/PlanePotential1.lean b/lean/OAI/Analysis/SignedDisk/PlanePotential1.lean new file mode 100644 index 0000000000000000000000000000000000000000..68aaae963444f580058b03ea9d43fbc9eed67ad1 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/PlanePotential1.lean @@ -0,0 +1,469 @@ +import OAI.Analysis.SignedDisk.ScalarCancellation1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal + +noncomputable section + +namespace SignedDisk + +open MeasureTheory Set +open scoped ENNReal NNReal + +namespace PlanePotential + +/-- Hölder followed by Tonelli gives the integral-kernel Minkowski estimate at +p=3/2. Both measures and the actual joint kernel remain explicit. -/ +theorem kernel_lp_three_halves {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] + (μ : Measure α) (ν : Measure β) [SFinite μ] [SFinite ν] + {K : α × β → ℝ≥0∞} (hK : Measurable K) {C : ℝ≥0∞} + (hC : ∀ y, (∫⁻ x, (K (x,y))^(3/2:ℝ) ∂μ) ≤ C^(3/2:ℝ)) : + (∫⁻ x, (∫⁻ y, K (x,y) ∂ν)^(3/2:ℝ) ∂μ) ≤ (C*ν univ)^(3/2:ℝ) := by + have hpq : Real.HolderConjugate (3/2) 3 := by + rw [Real.holderConjugate_iff] + norm_num + have hpoint (x : α) : (∫⁻ y, K (x,y) ∂ν)^(3/2:ℝ) ≤ + (∫⁻ y, K (x,y)^(3/2:ℝ) ∂ν)*(ν univ)^(1/2:ℝ) := by + have h := ENNReal.lintegral_mul_le_Lp_mul_Lq ν hpq (f := fun y => K (x,y)) (g := fun _ => 1) + ((hK.comp (measurable_const.prodMk measurable_id)).aemeasurable) + (aemeasurable_const (b := (1:ℝ≥0∞))) + simp only [Pi.mul_apply,mul_one,ENNReal.one_rpow,lintegral_const,one_mul] at h + have h' := ENNReal.rpow_le_rpow h (by norm_num : (0:ℝ) ≤ 3/2) + simpa only [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num : (0:ℝ) ≤ 3/2),← ENNReal.rpow_mul, + show (1/(3/2:ℝ))*(3/2)=1 by norm_num, + show (1/(3:ℝ))*(3/2)=1/2 by norm_num,ENNReal.rpow_one,one_mul] using h' + calc + _ ≤ ∫⁻ x, (∫⁻ y, K (x,y)^(3/2:ℝ) ∂ν)*(ν univ)^(1/2:ℝ) ∂μ := + lintegral_mono (fun x => hpoint x) + _ = (∫⁻ y, ∫⁻ x, K (x,y)^(3/2:ℝ) ∂μ ∂ν)*(ν univ)^(1/2:ℝ) := by + rw [lintegral_mul_const _ (hK.pow_const _).lintegral_prod_right, + lintegral_lintegral_swap (hK.pow_const _).aemeasurable] + _ ≤ (C^(3/2:ℝ)*ν univ)*(ν univ)^(1/2:ℝ) := by + apply mul_le_mul_left + exact (lintegral_mono hC).trans_eq (lintegral_const _) + _ = _ := by + rw [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num : (0:ℝ) ≤ 3/2),mul_assoc] + congr 1 + calc + _ = (ν univ)^(1:ℝ)*(ν univ)^(1/2:ℝ) := by rw [ENNReal.rpow_one] + _ = (ν univ)^((1:ℝ)+1/2) := (ENNReal.rpow_add_of_nonneg 1 (1/2) (by norm_num) (by norm_num)).symm + _ = _ := by norm_num + +end PlanePotential + +open Finset +open scoped RealInnerProductSpace + +namespace FiniteLabels +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +structure Law (ι : Type*) [Fintype ι] where + mass : ι → ℝ + nonneg : ∀ i, 0 ≤ mass i + total : ∑ i, mass i = 1 + +instance : CoeFun (Law ι) (fun _ => ι → ℝ) := ⟨Law.mass⟩ + +def delta [DecidableEq ι] (i : ι) : Law ι where + mass j := if j=i then 1 else 0 + nonneg j := by split_ifs <;> norm_num + total := by simp + +lemma law_le_one (μ : Law ι) (i : ι) : μ i ≤ 1 := by + rw [← μ.total] + exact single_le_sum (fun j _ => μ.nonneg j) (mem_univ i) + +def move (μ : Law ι) (P : ι → Law κ) : Law κ where + mass j := ∑ i, μ i*P i j + nonneg j := sum_nonneg fun i _ => mul_nonneg (μ.nonneg i) ((P i).nonneg j) + total := by + rw [sum_comm] + simp_rw [← mul_sum,(P _).total,mul_one] + exact μ.total + +lemma move_apply (μ : Law ι) (P : ι → Law κ) (j : κ) : + move μ P j = ∑ i, μ i*P i j := rfl + +def l1dist (a b : ι → ℝ) : ℝ := ∑ i, |a i-b i| +lemma l1dist_nonneg (a b : ι → ℝ) : 0 ≤ l1dist a b := sum_nonneg (fun _ _ => abs_nonneg _) +lemma l1dist_triangle (a b c : ι → ℝ) : l1dist a c ≤ l1dist a b+l1dist b c := by + unfold l1dist + rw [← sum_add_distrib] + exact sum_le_sum fun i _ => abs_sub_le (a i) (b i) (c i) + +/-- Stochastic matrices contract the l1 norm of every signed row difference. -/ +theorem move_contract (μ ν : Law ι) (P : ι → Law κ) : + l1dist (move μ P) (move ν P) ≤ l1dist μ ν := by + unfold l1dist + calc + _ = ∑ j, |∑ i, (μ i-ν i)*P i j| := by + apply sum_congr rfl + intro j _ + congr 1 + simp only [move_apply,sub_mul,sum_sub_distrib] + _ ≤ ∑ j, ∑ i, |μ i-ν i| *P i j := by + apply sum_le_sum + intro j _ + calc + _ ≤ ∑ i, |(μ i-ν i)*P i j| := abs_sum_le_sum_abs _ _ + _ = _ := by simp only [abs_mul,abs_of_nonneg ((P _).nonneg _)] + _ = _ := by + rw [sum_comm] + simp_rw [← mul_sum,(P _).total,mul_one] + +lemma move_rows (μ : Law ι) (P Q : ι → Law κ) : + l1dist (move μ P) (move μ Q) ≤ ∑ i, μ i*l1dist (P i) (Q i) := by + unfold l1dist + calc + _ = ∑ j, |∑ i, μ i*(P i j-Q i j)| := by + apply sum_congr rfl + intro j _ + congr 1 + simp only [move_apply,mul_sub,sum_sub_distrib] + _ ≤ ∑ j, ∑ i, μ i*|P i j-Q i j| := by + apply sum_le_sum + intro j _ + calc + _ ≤ ∑ i, |μ i*(P i j-Q i j)| := abs_sum_le_sum_abs _ _ + _ = _ := by simp only [abs_mul,abs_of_nonneg (μ.nonneg _)] + _ = _ := by rw [sum_comm]; simp_rw [mul_sum] + +lemma move_compare (μ ν : Law ι) (P Q : ι → Law κ) : + l1dist (move μ P) (move ν Q) ≤ l1dist μ ν+∑ i, ν i*l1dist (P i) (Q i) := by + exact (l1dist_triangle _ (move ν P) _).trans (add_le_add (move_contract μ ν P) (move_rows ν P Q)) + +lemma expectation_difference (μ ν : Law ι) {a : ι → ℝ} {C : ℝ} + (ha : ∀ i, |a i| ≤ C) : + |(∑ i, μ i*a i)-(∑ i, ν i*a i)| ≤ C*l1dist μ ν := by + rw [← sum_sub_distrib] + simp_rw [← sub_mul] + calc + _ ≤ ∑ i, |(μ i-ν i)*a i| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ i, C*|μ i-ν i| := sum_le_sum fun i _ => by + rw [abs_mul,mul_comm C] + exact mul_le_mul_of_nonneg_left (ha i) (abs_nonneg _) + _ = _ := by rw [← mul_sum]; rfl + +def switchRow [DecidableEq ι] (old : ι) (sample : Law κ) (target : κ → ι) + (p : κ → ℝ) (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) : Law ι where + mass j := (1-∑ z, sample z*p z)*(delta old j)+∑ z, sample z*p z*(delta (target z) j) + nonneg j := by + apply add_nonneg + · apply mul_nonneg _ ((delta old).nonneg j) + apply sub_nonneg.mpr + calc + _ ≤ ∑ z, sample z*1 := sum_le_sum fun z _ => mul_le_mul_of_nonneg_left (hp1 z) (sample.nonneg z) + _ = 1 := by simp only [mul_one]; exact sample.total + · exact sum_nonneg fun z _ => mul_nonneg (mul_nonneg (sample.nonneg z) (hp0 z)) ((delta _).nonneg j) + total := by + rw [sum_add_distrib,← mul_sum,(delta old).total,sum_comm] + simp_rw [← mul_sum,(delta _).total,mul_one] + ring + +lemma switchRow_formula [DecidableEq ι] (old : ι) (sample : Law κ) (target : κ → ι) + (p : κ → ℝ) (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) (j : ι) : + switchRow old sample target p hp0 hp1 j = + delta old j+∑ z, sample z*p z*(delta (target z) j-delta old j) := by + change (_-_) * _ + _ = _ + simp only [mul_sub,sum_sub_distrib,← sum_mul] + ring + +lemma delta_distance [DecidableEq ι] (i j : ι) : l1dist (delta i) (delta j) ≤ 2 := by + unfold l1dist + calc + _ ≤ ∑ k, (delta i k+delta j k) := sum_le_sum fun k _ => by + exact abs_sub_le_iff.mpr ⟨by linarith [(delta j).nonneg k],by linarith [(delta i).nonneg k]⟩ + _ = 2 := by rw [sum_add_distrib,(delta i).total,(delta j).total]; norm_num + +/-- The row difference is paid by the actual switched mass, not by a bare +Lipschitz constant. This is essential to the spatial comparison argument. -/ +theorem switchRow_distance [DecidableEq ι] (old : ι) (sample sample' : Law κ) + (target : κ → ι) (p : κ → ℝ) (hp0 : ∀ z, 0 ≤ p z) (hp1 : ∀ z, p z ≤ 1) : + l1dist (switchRow old sample target p hp0 hp1) (switchRow old sample' target p hp0 hp1) + ≤ 2*∑ z, |sample z-sample' z| *p z := by + unfold l1dist + simp_rw [switchRow_formula,add_sub_add_left_eq_sub,← sum_sub_distrib] + calc + _ = ∑ j, |∑ z, (sample z-sample' z)*p z*(delta (target z) j-delta old j)| := by + apply sum_congr rfl + intro j _ + congr 1 + apply sum_congr rfl + intro z _ + ring + _ ≤ ∑ j, ∑ z, |sample z-sample' z| *p z*|delta (target z) j-delta old j| := by + apply sum_le_sum + intro j _ + calc + _ ≤ ∑ z, |(sample z-sample' z)*p z*(delta (target z) j-delta old j)| := abs_sum_le_sum_abs _ _ + _ = _ := by simp only [abs_mul,abs_of_nonneg (hp0 _)] + _ = ∑ z, (|sample z-sample' z| *p z)*l1dist (delta (target z)) (delta old) := by + rw [sum_comm] + simp only [l1dist,mul_sum] + _ ≤ ∑ z, (|sample z-sample' z| *p z)*2 := sum_le_sum fun z _ => + mul_le_mul_of_nonneg_left (delta_distance _ _) (mul_nonneg (abs_nonneg _) (hp0 z)) + _ = _ := by rw [← sum_mul,mul_comm] + +end FiniteLabels + +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology + +namespace PlanePotential + +def greenScalar (ψ : ℂ → ℝ) (x y : ℂ) : ℝ := + ∫ t in Ioc (0:ℝ) 1, ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ) +def green (ψ : ℂ → ℝ) (x y : ℂ) : ℂ := -greenScalar ψ x y • (y-x) + +lemma segment_support {ψ : ℂ → ℝ} {R X : ℝ} + (hψ : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) {x y : ℂ} (hx : ‖x‖ ≤ X) + {t : ℝ} (ht : 0 < t) (hn : ψ (x+t⁻¹ • (y-x)) ≠ 0) : + ‖y-x‖ ≤ t*(R+X) := by + have heq : y-x = t • ((x+t⁻¹ • (y-x))-x) := by + simp [ht.ne'] + calc + ‖y-x‖ = t*‖(x+t⁻¹ • (y-x))-x‖ := by + conv_lhs => rw [heq] + rw [norm_smul,Real.norm_eq_abs,abs_of_pos ht] + _ ≤ t*(‖x+t⁻¹ • (y-x)‖+‖x‖) := + mul_le_mul_of_nonneg_left (norm_sub_le _ _) ht.le + _ ≤ t*(R+X) := mul_le_mul_of_nonneg_left (add_le_add (hψ _ hn) hx) ht.le + +lemma integrable_power_cutoff {q δ B : ℝ} (hq : q < -1) (hδ : 0 < δ) : + Integrable ((Ioi δ).indicator (fun t : ℝ => B*t^q)) := by + apply (integrable_indicator_iff measurableSet_Ioi).mpr + exact (integrableOn_Ioi_rpow_of_lt hq hδ).const_mul B + +lemma integral_power_cutoff {q δ B : ℝ} (hq : q < -1) (hδ : 0 < δ) : + (∫ t : ℝ, (Ioi δ).indicator (fun t : ℝ => B*t^q) t) = B*(-δ^(q+1)/(q+1)) := by + rw [integral_indicator measurableSet_Ioi,integral_const_mul,integral_Ioi_rpow_of_lt hq hδ] + +/-- A singular segment integral is genuinely integrable because of its geometric +lower cutoff. The bound retains the exact power, rather than a supremum times 1. -/ +lemma singular_integral_bound {F : ℝ → ℝ} (hFm : Measurable F) + {q δ B : ℝ} (hq : q < -1) (hδ : 0 < δ) (hB : 0 ≤ B) + (hzero : ∀ t ∈ Ioc (0:ℝ) 1, t < δ → F t = 0) + (hbound : ∀ t ∈ Ioc (0:ℝ) 1, |F t| ≤ B*t^q) : + IntegrableOn F (Ioc (0:ℝ) 1) ∧ + |∫ t in Ioc (0:ℝ) 1, F t| ≤ B*(-(δ/2)^(q+1)/(q+1)) := by + let H := (Ioi (δ/2)).indicator (fun t : ℝ => B*t^q) + have hH : Integrable H := integrable_power_cutoff hq (by linarith) + have hH0 (t : ℝ) : 0 ≤ H t := by + unfold H + apply indicator_nonneg + intro t ht + exact mul_nonneg hB (Real.rpow_nonneg (by change δ/2 < t at ht; linarith) _) + have hle : ∀ t ∈ Ioc (0:ℝ) 1, |F t| ≤ H t := by + intro t ht + by_cases hd : t < δ + · rw [hzero t ht hd] + simpa only [abs_zero] using hH0 t + · have htδ : t ∈ Ioi (δ/2) := by change δ/2 < t; linarith + change |F t| ≤ (Ioi (δ/2)).indicator (fun t : ℝ => B*t^q) t + rw [indicator_of_mem htδ] + exact hbound t ht + have hFi : IntegrableOn F (Ioc (0:ℝ) 1) := by + apply hH.integrableOn.mono' hFm.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht + simpa only [Real.norm_eq_abs] using hle t ht + refine ⟨hFi,?_⟩ + calc + _ ≤ ∫ t in Ioc (0:ℝ) 1, |F t| := abs_integral_le_integral_abs + _ ≤ ∫ t in Ioc (0:ℝ) 1, H t := integral_mono_ae hFi.abs hH.integrableOn (by + filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht using hle t ht) + _ ≤ ∫ t, H t := integral_mono_measure Measure.restrict_le_self (ae_of_all _ hH0) hH + _ = _ := integral_power_cutoff hq (by linarith) + +lemma greenScalar_measurable (ψ : ℂ → ℝ) (hψ : Measurable ψ) : + Measurable (fun p : ℂ × ℂ => greenScalar ψ p.1 p.2) := by + unfold greenScalar + apply StronglyMeasurable.measurable + apply StronglyMeasurable.integral_prod_right + have harg : Measurable (fun p : (ℂ × ℂ) × ℝ => p.1.1+p.2⁻¹ • (p.1.2-p.1.1)) := by measurability + exact ((hψ.comp harg).mul (measurable_snd.pow_const _)).stronglyMeasurable + +lemma green_measurable (ψ : ℂ → ℝ) (hψ : Measurable ψ) : + Measurable (fun p : ℂ × ℂ => green ψ p.1 p.2) := by + exact (greenScalar_measurable ψ hψ).neg.smul (measurable_snd.sub measurable_fst) + +/-- Quantitative kernel size on every observation ball, with an explicit constant. -/ +theorem green_norm_bound {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) {x y : ℂ} (hx : ‖x‖ ≤ X) (hxy : y ≠ x) : + ‖green ψ x y‖ ≤ 2*B*(R+X)^2/‖y-x‖ := by + have hd : 0 < ‖y-x‖ := norm_pos_iff.mpr (sub_ne_zero.mpr hxy) + let δ := ‖y-x‖/(R+X) + have hδ : 0 < δ := div_pos hd hM + have hFm : Measurable (fun t : ℝ => ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ)) := by + apply Measurable.mul + · apply hψm.comp + measurability + · exact measurable_id.pow_const _ + have hzero : ∀ t ∈ Ioc (0:ℝ) 1, t < δ → ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ) = 0 := by + intro t ht hlt + have hψ0 : ψ (x+t⁻¹ • (y-x)) = 0 := by + by_contra hn + have hs := segment_support hψs hx ht.1 hn + have : t*(R+X) < ‖y-x‖ := (lt_div_iff₀ hM).mp hlt + linarith + rw [hψ0,zero_mul] + have hb : ∀ t ∈ Ioc (0:ℝ) 1, + |ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ)| ≤ B*t^(-3:ℝ) := by + intro t ht + rw [abs_mul,abs_of_nonneg (Real.rpow_nonneg ht.1.le _)] + exact mul_le_mul_of_nonneg_right (hψB _) (Real.rpow_nonneg ht.1.le _) + have h := (singular_integral_bound hFm (by norm_num : (-3:ℝ) < -1) hδ hB hzero hb).2 + change |greenScalar ψ x y| ≤ _ at h + have hrpow : (δ/2)^((-3:ℝ)+1) = (δ/2)^(-2:ℤ) := by norm_num [Real.rpow_intCast] + rw [hrpow,zpow_neg,zpow_ofNat] at h + have hs : |greenScalar ψ x y| ≤ 2*B*(R+X)^2/‖y-x‖^2 := by + convert h using 1 + dsimp [δ] + field_simp + ring + rw [green,norm_smul,Real.norm_eq_abs,abs_neg] + calc + _ ≤ (2*B*(R+X)^2/‖y-x‖^2)*‖y-x‖ := mul_le_mul_of_nonneg_right hs hd.le + _ = _ := by field_simp + +lemma segment_integrand_measurable {ψ : ℂ → ℝ} (hψ : Measurable ψ) (x y : ℂ) : + Measurable (fun t : ℝ => ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ)) := by + apply Measurable.mul + · apply hψ.comp + measurability + · exact measurable_id.pow_const _ + +lemma scalar_data {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B δ : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) (hδ : 0 < δ) + {x y : ℂ} (hx : ‖x‖ ≤ X) (hd : δ*(R+X) ≤ ‖y-x‖) : + IntegrableOn (fun t : ℝ => ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ)) (Ioc (0:ℝ) 1) ∧ + |greenScalar ψ x y| ≤ 2*B/δ^2 := by + have hz : ∀ t ∈ Ioc (0:ℝ) 1, t < δ → ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ) = 0 := by + intro t ht hlt + have : ψ (x+t⁻¹ • (y-x)) = 0 := by + by_contra hn + have hs := segment_support hψs hx ht.1 hn + have := mul_lt_mul_of_pos_right hlt hM + linarith + rw [this,zero_mul] + have hb : ∀ t ∈ Ioc (0:ℝ) 1, + |ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ)| ≤ B*t^(-3:ℝ) := by + intro t ht + rw [abs_mul,abs_of_nonneg (Real.rpow_nonneg ht.1.le _)] + exact mul_le_mul_of_nonneg_right (hψB _) (Real.rpow_nonneg ht.1.le _) + obtain ⟨hi,h⟩ := singular_integral_bound (segment_integrand_measurable hψm x y) + (by norm_num : (-3:ℝ) < -1) hδ hB hz hb + refine ⟨hi, h.trans_eq ?_⟩ + rw [show (-3:ℝ)+1 = -2 by norm_num, show (δ/2)^(-2:ℝ) = (δ/2)^(-2:ℤ) by norm_num [Real.rpow_intCast],zpow_neg,zpow_ofNat] + norm_num + field_simp + +/-- A difference bound proves the needed cancellation estimate without hiding +any differentiation under the singular integral. -/ +theorem green_difference_bound {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B L : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hψL : ∀ u v, |ψ u-ψ v| ≤ L*‖u-v‖) + (hM : 0 < R+X) (hB : 0 ≤ B) (hL : 0 ≤ L) + {x y z : ℂ} (hx : ‖x‖ ≤ X) (hzx : z ≠ x) (hyz : ‖y-z‖ ≤ ‖z-x‖/2) : + ‖green ψ x y-green ψ x z‖ ≤ + (8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)*‖y-z‖/‖z-x‖^2 := by + let d := ‖z-x‖ + let a := ‖y-z‖ + let M := R+X + let δ := d/(2*M) + have hd : 0 < d := norm_pos_iff.mpr (sub_ne_zero.mpr hzx) + have ha : 0 ≤ a := norm_nonneg _ + have hδ : 0 < δ := div_pos hd (mul_pos (by norm_num) hM) + have hnear : d/2 ≤ ‖y-x‖ := by + have ht := norm_sub_le_norm_sub_add_norm_sub z y x + rw [norm_sub_rev z y] at ht + dsimp [d] at * + linarith + have hcut : δ*M = d/2 := by dsimp [δ]; field_simp [show M ≠ 0 from hM.ne'] + have hdy : δ*(R+X) ≤ ‖y-x‖ := by change δ*M ≤ _; rw [hcut]; exact hnear + have hdz : δ*(R+X) ≤ ‖z-x‖ := by change δ*M ≤ d; rw [hcut]; linarith + obtain ⟨hIy,hKy⟩ := scalar_data hψm hψs hψB hM hB hδ hx hdy + obtain ⟨hIz,_⟩ := scalar_data hψm hψs hψB hM hB hδ hx hdz + let F := fun t : ℝ => (ψ (x+t⁻¹ • (y-x))-ψ (x+t⁻¹ • (z-x)))*t^(-3:ℝ) + have hFm : Measurable F := by + change Measurable (fun t : ℝ => _) + have hm (v : ℂ) : Measurable (fun t : ℝ => ψ (x+t⁻¹ • (v-x))) := by + apply hψm.comp + measurability + exact ((hm y).sub (hm z)).mul (measurable_id.pow_const _) + have hzero : ∀ t ∈ Ioc (0:ℝ) 1, t < δ → F t = 0 := by + intro t ht htδ + have h0 (v : ℂ) (hv : δ*M ≤ ‖v-x‖) : ψ (x+t⁻¹ • (v-x)) = 0 := by + by_contra hn + have hs := segment_support hψs hx ht.1 hn + have := mul_lt_mul_of_pos_right htδ hM + dsimp [M] at hv + linarith + change (ψ (x+t⁻¹ • (y-x))-ψ (x+t⁻¹ • (z-x)))*t^(-3:ℝ) = 0 + rw [h0 y hdy,h0 z hdz,sub_self,zero_mul] + have hbound : ∀ t ∈ Ioc (0:ℝ) 1, |F t| ≤ (L*a)*t^(-4:ℝ) := by + intro t ht + have harg : (x+t⁻¹ • (y-x))-(x+t⁻¹ • (z-x)) = t⁻¹ • (y-z) := by module + have hLip := hψL (x+t⁻¹ • (y-x)) (x+t⁻¹ • (z-x)) + rw [harg,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr ht.1)] at hLip + calc + |F t| = |ψ (x+t⁻¹ • (y-x))-ψ (x+t⁻¹ • (z-x))| *t^(-3:ℝ) := by + change |(ψ (x+t⁻¹ • (y-x))-ψ (x+t⁻¹ • (z-x)))*t^(-3:ℝ)| = _ + rw [abs_mul,abs_of_nonneg (Real.rpow_nonneg ht.1.le _)] + _ ≤ (L*(t⁻¹*a))*t^(-3:ℝ) := mul_le_mul_of_nonneg_right hLip (Real.rpow_nonneg ht.1.le _) + _ = (L*a)*t^(-4:ℝ) := by + rw [← Real.rpow_neg_one t] + calc + _ = (L*a)*(t^(-1:ℝ)*t^(-3:ℝ)) := by ring + _ = _ := by rw [← Real.rpow_add ht.1]; norm_num + have hdiff := (singular_integral_bound hFm (by norm_num : (-4:ℝ) < -1) + hδ (mul_nonneg hL ha) hzero hbound).2 + have hIF : (∫ t in Ioc (0:ℝ) 1, F t) = greenScalar ψ x y-greenScalar ψ x z := by + simp only [F,sub_mul,greenScalar] + exact integral_sub hIy hIz + rw [hIF] at hdiff + have hKd : |greenScalar ψ x y-greenScalar ψ x z| ≤ (64/3:ℝ)*L*a*M^3/d^3 := by + refine hdiff.trans_eq ?_ + rw [show (-4:ℝ)+1 = -3 by norm_num, show (δ/2)^(-3:ℝ) = (δ/2)^(-3:ℤ) by norm_num [Real.rpow_intCast],zpow_neg,zpow_ofNat] + dsimp [δ] + field_simp + ring + have hKy' : |greenScalar ψ x y| ≤ 8*B*M^2/d^2 := by + refine hKy.trans_eq ?_ + dsimp [δ] + field_simp + ring + have heq : green ψ x y-green ψ x z = + (-greenScalar ψ x y) • (y-z) - (greenScalar ψ x y-greenScalar ψ x z) • (z-x) := by + unfold green + module + rw [heq] + calc + _ ≤ ‖(-greenScalar ψ x y) • (y-z)‖ + + ‖(greenScalar ψ x y-greenScalar ψ x z) • (z-x)‖ := norm_sub_le _ _ + _ = |greenScalar ψ x y| *a + |greenScalar ψ x y-greenScalar ψ x z| *d := by + simp only [norm_smul,Real.norm_eq_abs,abs_neg,a,d] + _ ≤ (8*B*M^2/d^2)*a + ((64/3:ℝ)*L*a*M^3/d^3)*d := + add_le_add (mul_le_mul_of_nonneg_right hKy' ha) (mul_le_mul_of_nonneg_right hKd hd.le) + _ = _ := by change _ = (8*B*M^2+(64/3:ℝ)*L*M^3)*a/d^2; field_simp + +end PlanePotential + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/PlanePotential2.lean b/lean/OAI/Analysis/SignedDisk/PlanePotential2.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe6534ba9b6ecae57b91932dd5d3ccd1c14acdfc --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/PlanePotential2.lean @@ -0,0 +1,481 @@ +import OAI.Analysis.SignedDisk.VectorRefinement1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace + +noncomputable section + +namespace SignedDisk + +namespace PlanePotential + +theorem kernel_column_lp {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] + (μ : Measure α) (ν : Measure β) [SFinite μ] [SFinite ν] + {K : α × β → ℝ≥0∞} (hK : Measurable K) {C : ℝ≥0∞} + (hC : ∀ᵐ y ∂ν, (∫⁻ x, (K (x,y))^(3/2:ℝ) ∂μ) ≤ C) : + (∫⁻ x, (∫⁻ y, K (x,y) ∂ν)^(3/2:ℝ) ∂μ) ≤ C*(ν univ)^(3/2:ℝ) := by + have hpq : Real.HolderConjugate (3/2) 3 := by rw [Real.holderConjugate_iff]; norm_num + have hpoint (x : α) : (∫⁻ y, K (x,y) ∂ν)^(3/2:ℝ) ≤ + (∫⁻ y, K (x,y)^(3/2:ℝ) ∂ν)*(ν univ)^(1/2:ℝ) := by + have h := ENNReal.lintegral_mul_le_Lp_mul_Lq ν hpq (f := fun y => K (x,y)) (g := fun _ => 1) + ((hK.comp (measurable_const.prodMk measurable_id)).aemeasurable) + (aemeasurable_const (b := (1:ℝ≥0∞))) + simp only [Pi.mul_apply,mul_one,ENNReal.one_rpow,lintegral_const,one_mul] at h + have h' := ENNReal.rpow_le_rpow h (by norm_num : (0:ℝ) ≤ 3/2) + simpa only [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num : (0:ℝ) ≤ 3/2),← ENNReal.rpow_mul, + show (1/(3/2:ℝ))*(3/2)=1 by norm_num, + show (1/(3:ℝ))*(3/2)=1/2 by norm_num,ENNReal.rpow_one,one_mul] using h' + calc + _ ≤ ∫⁻ x, (∫⁻ y, K (x,y)^(3/2:ℝ) ∂ν)*(ν univ)^(1/2:ℝ) ∂μ := + lintegral_mono hpoint + _ = (∫⁻ y, ∫⁻ x, K (x,y)^(3/2:ℝ) ∂μ ∂ν)*(ν univ)^(1/2:ℝ) := by + rw [lintegral_mul_const _ (hK.pow_const _).lintegral_prod_right, + lintegral_lintegral_swap (hK.pow_const _).aemeasurable] + _ ≤ (C*ν univ)*(ν univ)^(1/2:ℝ) := + mul_le_mul_left ((lintegral_mono_ae hC).trans_eq (lintegral_const _)) _ + _ = _ := by + rw [mul_assoc] + congr 1 + calc + _ = (ν univ)^(1:ℝ)*(ν univ)^(1/2:ℝ) := by rw [ENNReal.rpow_one] + _ = (ν univ)^((1:ℝ)+1/2) := + (ENNReal.rpow_add_of_nonneg 1 (1/2) (by norm_num) (by norm_num)).symm + _ = _ := by norm_num + +/-- No pointwise integrability assertion for the singular kernel is needed +in this domination: the Bochner integral is bounded by the nonnegative integral. -/ +lemma potential_domination {L : ℂ → ℂ} (hL : Measurable L) {b : ℂ → ℂ} + (hb : Integrable b) : + ENNReal.ofReal |∫ y, ⟪L y,b y⟫| ≤ + ∫⁻ y, ENNReal.ofReal ‖L y‖ ∂volume.withDensity (fun y => ENNReal.ofReal ‖b y‖) := by + rw [lintegral_withDensity_eq_lintegral_mul₀' hb.aestronglyMeasurable.norm.aemeasurable.ennreal_ofReal + hL.norm.ennreal_ofReal.aemeasurable] + calc + _ = ‖∫ y, ⟪L y,b y⟫‖ₑ := by rw [← ofReal_norm,Real.norm_eq_abs] + _ ≤ ∫⁻ y, ‖⟪L y,b y⟫‖ₑ := enorm_integral_le_lintegral_enorm _ + _ ≤ _ := by + apply lintegral_mono + intro y + dsimp only [Pi.mul_apply] + rw [← ofReal_norm] + change ENNReal.ofReal ‖⟪L y,b y⟫‖ ≤ ENNReal.ofReal ‖b y‖ * ENNReal.ofReal ‖L y‖ + rw [← ENNReal.ofReal_mul (norm_nonneg _)] + exact ENNReal.ofReal_le_ofReal ((norm_inner_le_norm _ _).trans_eq (mul_comm _ _)) + +theorem cancelled_potential_lp {ψ : ℂ → ℝ} {β : ℂ → ℂ} + (hψm : Measurable ψ) {R X B L a : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hψL : ∀ u v, |ψ u-ψ v| ≤ L*‖u-v‖) + (hM : 0 < R+X) (hB : 0 ≤ B) (hL : 0 ≤ L) (ha : 0 < a) + (z : ℂ) (hβ : Integrable β) (hβs : ∀ y, β y ≠ 0 → ‖y-z‖ ≤ a) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, + (ENNReal.ofReal |∫ y, ⟪cancelledGreen ψ z a x y,β y⟫|)^(3/2:ℝ)) ≤ + (ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(4*a)^(1/2:ℝ))) + + ENNReal.ofReal (((8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)*a)^(3/2:ℝ) * + (2*Real.pi/(2*a)))) * (ENNReal.ofReal (∫ y, ‖β y‖))^(3/2:ℝ) := by + let ν := volume.withDensity (fun y => ENNReal.ofReal ‖β y‖) + have hν : ν univ = ENNReal.ofReal (∫ y, ‖β y‖) := by + dsimp only [ν] + rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ] + exact (ofReal_integral_eq_lintegral_ofReal hβ.norm + (Filter.Eventually.of_forall (fun _ => norm_nonneg _))).symm + have : IsFiniteMeasure ν := ⟨by rw [hν]; exact ENNReal.ofReal_lt_top⟩ + have hm := cancelledGreen_measurable hψm z a + have hcol := kernel_column_lp (volume.restrict {x : ℂ | ‖x‖ ≤ X}) ν hm.norm.ennreal_ofReal + (C := ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(4*a)^(1/2:ℝ))) + + ENNReal.ofReal (((8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)*a)^(3/2:ℝ)*(2*Real.pi/(2*a)))) + (by + rw [ae_withDensity_iff' hβ.aestronglyMeasurable.norm.aemeasurable.ennreal_ofReal] + filter_upwards with y hy + apply green_piece_column hψm hψs hψB hψL hM hB hL ha z y + apply hβs y + intro hy0 + simp [hy0] at hy) + rw [hν] at hcol + apply le_trans _ hcol + apply lintegral_mono + intro x + exact ENNReal.rpow_le_rpow (potential_domination + (hm.comp (measurable_const.prodMk measurable_id)) hβ) (by norm_num) + +lemma zero_mass_kernel_shift {L : ℂ → ℂ} {β : ℂ → ℂ} (hβ : Integrable β) + (hzero : ∫ y, β y = 0) (c : ℂ) : + (∫ y, ⟪L y,β y⟫) = ∫ y, ⟪L y-c,β y⟫ := by + have hc : Integrable (fun y => ⟪c,β y⟫) := hβ.const_inner c + have hci : (∫ y, ⟪c,β y⟫) = 0 := by rw [integral_inner hβ,hzero,inner_zero_right] + simp only [inner_sub_left] + by_cases hi : Integrable (fun y => ⟪L y,β y⟫) + · rw [integral_sub hi hc,hci,sub_zero] + · rw [integral_undef hi,integral_undef] + intro hs + have hh := hs.add hc + change Integrable (fun y => (⟪L y,β y⟫-⟪c,β y⟫)+⟪c,β y⟫) at hh + simp only [sub_add_cancel] at hh + exact hi hh + +lemma cancelled_potential_eq {ψ : ℂ → ℝ} {β : ℂ → ℂ} (hβ : Integrable β) + (hzero : ∫ y, β y = 0) (z : ℂ) (a : ℝ) (x : ℂ) : + (∫ y, ⟪green ψ x y,β y⟫) = ∫ y, ⟪cancelledGreen ψ z a x y,β y⟫ := by + by_cases hx : ‖x-z‖ ≤ 2*a + · simp only [cancelledGreen,ite_eq_left hx] + · simp only [cancelledGreen,ite_eq_right hx] + exact zero_mass_kernel_shift hβ hzero _ + +/-- Uniform scaling of the exact p-th power column constant: in dimension two +and at p=3/2 its radius dependence is precisely a^(1/2). -/ +lemma column_scaling {K D a : ℝ} (hD : 0 ≤ D) (ha : 0 < a) : + K^(3/2:ℝ)*(4*Real.pi*(4*a)^(1/2:ℝ)) + + (D*a)^(3/2:ℝ)*(2*Real.pi/(2*a)) = + (8*Real.pi*K^(3/2:ℝ)+Real.pi*D^(3/2:ℝ))*a^(1/2:ℝ) := by + rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 4) ha.le,Real.mul_rpow hD ha.le] + have hfour : (4:ℝ)^(1/2:ℝ) = 2 := by norm_num [← Real.sqrt_eq_rpow] + have hpow : a^(3/2:ℝ)/a = a^(1/2:ℝ) := by + rw [← Real.rpow_sub_one ha.ne'] + norm_num + rw [hfour] + calc + _ = 8*Real.pi*K^(3/2:ℝ)*a^(1/2:ℝ)+Real.pi*D^(3/2:ℝ)*(a^(3/2:ℝ)/a) := by ring + _ = _ := by rw [hpow]; ring + +theorem green_zero_piece_lp {ψ : ℂ → ℝ} {β : ℂ → ℂ} + (hψm : Measurable ψ) {R X B L a : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hψL : ∀ u v, |ψ u-ψ v| ≤ L*‖u-v‖) + (hM : 0 < R+X) (hB : 0 ≤ B) (hL : 0 ≤ L) (ha : 0 < a) + (z : ℂ) (hβ : Integrable β) (hzero : ∫ y, β y = 0) + (hβs : ∀ y, β y ≠ 0 → ‖y-z‖ ≤ a) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, + (ENNReal.ofReal |∫ y, ⟪green ψ x y,β y⟫|)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((8*Real.pi*(2*B*(R+X)^2)^(3/2:ℝ)+ + Real.pi*(8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)^(3/2:ℝ))*a^(1/2:ℝ)) * + (ENNReal.ofReal (∫ y, ‖β y‖))^(3/2:ℝ) := by + simp_rw [cancelled_potential_eq hβ hzero z a] + have h := cancelled_potential_lp hψm hψs hψB hψL hM hB hL ha z hβ hβs + rw [← ENNReal.ofReal_add (by positivity) (by positivity), + column_scaling (by positivity) ha] at h + exact h + +end PlanePotential + +open scoped RealInnerProductSpace + +namespace IntrinsicMarks + +section + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +def direction (e v : E) : E := by + classical + exact if v = 0 then e else ‖v‖⁻¹ • v + +lemma norm_direction {e : E} (he : ‖e‖ = 1) (v : E) : ‖direction e v‖ = 1 := by + by_cases hv : v = 0 + · simp [direction,hv,he] + · rw [direction,ite_eq_right hv,norm_smul,Real.norm_eq_abs,abs_of_nonneg (inv_nonneg.mpr (norm_nonneg _))] + exact inv_mul_cancel₀ (norm_ne_zero_iff.mpr hv) + +lemma mass_direction (e v : E) : ‖v‖ • direction e v = v := by + by_cases hv : v = 0 + · simp [hv] + · simp [direction,hv,smul_smul,norm_ne_zero_iff.mpr hv] + +lemma debt_identity {e n : E} (he : ‖e‖ = 1) (hn : ‖n‖ = 1) (v : E) : + 2*(‖v‖-⟪v,n⟫) = ‖v‖*‖direction e v-n‖^2 := by + have hi : ‖v‖*⟪direction e v,n⟫ = ⟪v,n⟫ := by + rw [← real_inner_smul_left,mass_direction] + rw [norm_sub_sq_real,norm_direction he,hn] + nlinarith + +lemma marked_mass_le {e n : E} (he : ‖e‖ = 1) (hn : ‖n‖ = 1) + (v : E) {δ : ℝ} (hδ : 0 < δ) (hmark : δ < ‖direction e v-n‖) : + ‖v‖ ≤ (2/δ^2)*(‖v‖-⟪v,n⟫) := by + have hs : δ^2 ≤ ‖direction e v-n‖^2 := + (sq_le_sq₀ hδ.le (norm_nonneg _)).mpr hmark.le + have hm := mul_le_mul_of_nonneg_left hs (norm_nonneg v) + have hid := debt_identity he hn v + have hd : 0 < δ^2 := sq_pos_of_pos hδ + rw [div_mul_eq_mul_div,le_div_iff₀ hd] + nlinarith + +/-- Finite uniform branching includes each finite positive-refinement path forest +by padding absent children with zero vectors. No triangle defect is assumed. -/ +inductive Tree (ι : Type*) (E : Type*) where + | leaf : E → Tree ι E + | branch : (ι → Tree ι E) → Tree ι E + +variable {ι : Type*} [Fintype ι] + +def vector : Tree ι E → E + | .leaf v => v + | .branch t => ∑ i, vector (t i) + +def terminalMass : Tree ι E → ℝ + | .leaf v => ‖v‖ + | .branch t => ∑ i, terminalMass (t i) + +omit [InnerProductSpace ℝ E] in +lemma norm_vector_le_terminalMass (t : Tree ι E) : ‖vector t‖ ≤ terminalMass t := by + induction t with + | leaf v => exact le_rfl + | branch t ih => + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun i _ => ih i) + +/-- Only the first crossing from the most recent marked direction is counted; +a crossing resets the anchor before descending further. -/ +def markedCost (e : E) (δ : ℝ) : Tree ι E → E → ℝ + | .leaf v, n => if δ < ‖direction e v-n‖ then ‖v‖ else 0 + | .branch t, n => + let v := ∑ i, vector (t i) + if δ < ‖direction e v-n‖ then + ‖v‖ + ∑ i, markedCost e δ (t i) (direction e v) + else ∑ i, markedCost e δ (t i) n + +theorem markedCost_le {e : E} (he : ‖e‖ = 1) {δ : ℝ} (hδ : 0 < δ) + (t : Tree ι E) {n : E} (hn : ‖n‖ = 1) : + markedCost e δ t n ≤ (2/δ^2)*(terminalMass t-⟪vector t,n⟫) := by + induction t generalizing n with + | leaf v => + dsimp [markedCost,terminalMass,vector] + split_ifs with hm + · exact marked_mass_le he hn v hδ hm + · have hi : ⟪v,n⟫ ≤ ‖v‖ := by simpa only [hn,mul_one] using real_inner_le_norm v n + exact mul_nonneg (by positivity) (sub_nonneg.mpr hi) + | branch t ih => + let v := ∑ i, vector (t i) + have hs (u : E) (hu : ‖u‖ = 1) : + (∑ i, markedCost e δ (t i) u) ≤ + (2/δ^2)*((∑ i, terminalMass (t i))-⟪v,u⟫) := by + calc + _ ≤ ∑ i, (2/δ^2)*(terminalMass (t i)-⟪vector (t i),u⟫) := + Finset.sum_le_sum (fun i _ => ih i hu) + _ = _ := by simp only [Finset.mul_sum,Finset.sum_sub_distrib,sum_inner,v,mul_sub] + have hv := norm_direction he v + change (if δ < ‖direction e v-n‖ then + ‖v‖ + ∑ i, markedCost e δ (t i) (direction e v) + else ∑ i, markedCost e δ (t i) n) ≤ _ + split_ifs with hm + · have hms := marked_mass_le he hn v hδ hm + have hss := hs (direction e v) hv + have hinner : ⟪v,direction e v⟫ = ‖v‖ := by + calc + _ = ⟪‖v‖ • direction e v,direction e v⟫ := congrArg (fun w => ⟪w,direction e v⟫) (mass_direction e v).symm + _ = _ := by rw [real_inner_smul_left,real_inner_self_eq_norm_sq,hv]; ring + rw [hinner] at hss + change _ ≤ (2/δ^2)*((∑ i, terminalMass (t i))-⟪v,n⟫) + nlinarith + · exact hs n hn + +def costWithRoot (e : E) (δ : ℝ) : Tree ι E → ℝ + | .leaf v => ‖v‖ + | .branch t => + let v := ∑ i, vector (t i) + ‖v‖+∑ i, markedCost e δ (t i) (direction e v) + +theorem costWithRoot_le {e : E} (he : ‖e‖ = 1) {δ : ℝ} (hδ : 0 < δ) + (t : Tree ι E) : costWithRoot e δ t ≤ (1+2/δ^2)*terminalMass t := by + cases t with + | leaf v => + change ‖v‖ ≤ (1+2/δ^2)*‖v‖ + nlinarith [mul_nonneg (show 0 ≤ 2/δ^2 by positivity) (norm_nonneg v)] + | branch t => + let v := ∑ i, vector (t i) + have hv := norm_direction he v + have hinner : ⟪v,direction e v⟫ = ‖v‖ := by + calc + _ = ⟪‖v‖ • direction e v,direction e v⟫ := congrArg (fun w => ⟪w,direction e v⟫) (mass_direction e v).symm + _ = _ := by rw [real_inner_smul_left,real_inner_self_eq_norm_sq,hv]; ring + have hs : (∑ i, markedCost e δ (t i) (direction e v)) ≤ + (2/δ^2)*((∑ i, terminalMass (t i))-‖v‖) := by + calc + _ ≤ ∑ i, (2/δ^2)*(terminalMass (t i)-⟪vector (t i),direction e v⟫) := + Finset.sum_le_sum (fun i _ => markedCost_le he hδ (t i) hv) + _ = _ := by rw [← Finset.mul_sum,Finset.sum_sub_distrib,← sum_inner,hinner] + have hn : ‖v‖ ≤ ∑ i, terminalMass (t i) := norm_vector_le_terminalMass (.branch t) + change ‖v‖+∑ i, markedCost e δ (t i) (direction e v) ≤ + (1+2/δ^2)*(∑ i, terminalMass (t i)) + nlinarith [mul_nonneg (show 0 ≤ 2/δ^2 by positivity) (norm_nonneg v)] + +end + +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] + +/-- The fraction of the child capacity occupied by particles already alive. -/ +def survival (t : ι → Tree ι E) : ℝ := + ‖∑ i, vector (t i)‖ / ∑ i, ‖vector (t i)‖ + +lemma survival_nonneg (t : ι → Tree ι E) : 0 ≤ survival t := by + unfold survival + positivity + +lemma survival_le_one (t : ι → Tree ι E) : survival t ≤ 1 := by + unfold survival + exact div_le_one_of_le₀ (norm_sum_le _ _) (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) + +lemma survival_capacity (t : ι → Tree ι E) : + survival t * (∑ i, ‖vector (t i)‖) = ‖∑ i, vector (t i)‖ := by + unfold survival + by_cases h : (∑ i, ‖vector (t i)‖) = 0 + · have hn : ‖∑ i, vector (t i)‖ = 0 := by + apply le_antisymm _ (norm_nonneg _) + simpa only [h] using norm_sum_le Finset.univ (fun i => vector (t i)) + simp [h,hn] + · exact div_mul_cancel₀ _ h + +/-- Explicit finite weighted evaluation on terminal paths, for the population +born at the current root. Every branching has its true capacity ratio. -/ +def rootEval : Tree ι E → (List ι → ℝ) → ℝ + | .leaf v, F => ‖v‖ * F [] + | .branch t, F => survival t * ∑ i, rootEval (t i) (fun p => F (i::p)) + +/-- Explicit finite evaluation of populations born strictly below this root. +The complete prefix is retained, including the part before birth. -/ +def lateEval : Tree ι E → (List ι → ℕ → ℝ) → ℝ + | .leaf _, _ => 0 + | .branch t, F => + (1-survival t) * (∑ i, rootEval (t i) (fun p => F (i::p) 1)) + + ∑ i, lateEval (t i) (fun p b => F (i::p) (b+1)) + +def particleEval (t : Tree ι E) (F : List ι → ℕ → ℝ) : ℝ := + rootEval t (fun p => F p 0) + lateEval t F + +lemma rootEval_nonneg (t : Tree ι E) {F : List ι → ℝ} (hF : ∀ p, 0 ≤ F p) : + 0 ≤ rootEval t F := by + induction t generalizing F with + | leaf v => exact mul_nonneg (norm_nonneg _) (hF _) + | branch t ih => + exact mul_nonneg (survival_nonneg t) (Finset.sum_nonneg fun i _ => ih i (fun p => hF (i::p))) + +lemma lateEval_nonneg (t : Tree ι E) {F : List ι → ℕ → ℝ} (hF : ∀ p b, 0 ≤ F p b) : + 0 ≤ lateEval t F := by + induction t generalizing F with + | leaf v => exact le_rfl + | branch t ih => + exact add_nonneg (mul_nonneg (sub_nonneg.mpr (survival_le_one t)) + (Finset.sum_nonneg (fun i _ => rootEval_nonneg (t i) (fun p => hF (i::p) 1)))) + (Finset.sum_nonneg (fun i _ => ih i (fun p b => hF (i::p) (b+1)))) + +lemma particleEval_nonneg (t : Tree ι E) {F : List ι → ℕ → ℝ} (hF : ∀ p b, 0 ≤ F p b) : + 0 ≤ particleEval t F := add_nonneg (rootEval_nonneg t (fun p => hF p 0)) (lateEval_nonneg t hF) + +lemma rootEval_const (t : Tree ι E) (c : ℝ) : + rootEval t (fun _ => c) = ‖vector t‖*c := by + induction t with + | leaf _ => rfl + | branch t ih => + change survival t * (∑ i, rootEval (t i) (fun _ => c)) = _ + simp only [ih,← Finset.sum_mul] + rw [← mul_assoc,survival_capacity] + rfl + +lemma rootEval_add (t : Tree ι E) (F G : List ι → ℝ) : + rootEval t (fun p => F p+G p) = rootEval t F+rootEval t G := by + induction t generalizing F G with + | leaf _ => exact mul_add _ _ _ + | branch t ih => simp only [rootEval,ih,Finset.sum_add_distrib,mul_add] + +lemma rootEval_smul (t : Tree ι E) (c : ℝ) (F : List ι → ℝ) : + rootEval t (fun p => c*F p) = c*rootEval t F := by + induction t generalizing F with + | leaf _ => dsimp [rootEval]; ring + | branch t ih => simp only [rootEval,ih,← Finset.mul_sum]; ring + +lemma lateEval_const (t : Tree ι E) (c : ℝ) : + lateEval t (fun _ _ => c) = (terminalMass t-‖vector t‖)*c := by + induction t with + | leaf _ => simp [lateEval,terminalMass,vector] + | branch t ih => + change (1-survival t)*(∑ i, rootEval (t i) (fun _ => c)) + + (∑ i, lateEval (t i) (fun _ _ => c)) = _ + simp only [ih,rootEval_const,← Finset.sum_mul,Finset.sum_sub_distrib] + rw [sub_mul,one_mul,← mul_assoc,survival_capacity] + simp only [terminalMass,vector] + ring + +lemma particleEval_const (t : Tree ι E) (c : ℝ) : + particleEval t (fun _ _ => c) = terminalMass t*c := by + rw [particleEval,rootEval_const,lateEval_const] + ring + +lemma lateEval_add (t : Tree ι E) (F G : List ι → ℕ → ℝ) : + lateEval t (fun p b => F p b+G p b) = lateEval t F+lateEval t G := by + induction t generalizing F G with + | leaf _ => simp [lateEval] + | branch t ih => simp only [lateEval,rootEval_add,ih,Finset.sum_add_distrib,mul_add]; ring + +lemma lateEval_smul (t : Tree ι E) (c : ℝ) (F : List ι → ℕ → ℝ) : + lateEval t (fun p b => c*F p b) = c*lateEval t F := by + induction t generalizing F with + | leaf _ => simp [lateEval] + | branch t ih => simp only [lateEval,rootEval_smul,ih,← Finset.mul_sum]; ring + +lemma particleEval_add (t : Tree ι E) (F G : List ι → ℕ → ℝ) : + particleEval t (fun p b => F p b+G p b) = particleEval t F+particleEval t G := by + simp only [particleEval,rootEval_add,lateEval_add] + ring + +lemma particleEval_smul (t : Tree ι E) (c : ℝ) (F : List ι → ℕ → ℝ) : + particleEval t (fun p b => c*F p b) = c*particleEval t F := by + simp only [particleEval,rootEval_smul,lateEval_smul,mul_add] + +lemma particleEval_mono (t : Tree ι E) {F G : List ι → ℕ → ℝ} + (hFG : ∀ p b, F p b ≤ G p b) : particleEval t F ≤ particleEval t G := by + have hn := particleEval_nonneg t (F := fun p b => G p b-F p b) (fun p b => sub_nonneg.mpr (hFG p b)) + have h := particleEval_add t G (fun p b => -1*F p b) + simp only [neg_one_mul] at h + have hn' : particleEval t (fun p b => G p b-F p b) = particleEval t G-particleEval t F := by + calc + _ = particleEval t G+particleEval t (fun p b => -1*F p b) := by simpa only [neg_one_mul,sub_eq_add_neg] using h + _ = _ := by rw [particleEval_smul]; ring + rw [hn'] at hn + linarith + +/-- Sum a node charge only at and after the particle's birth. -/ +def pathCharge (C : List ι → ℝ) : List ι → ℕ → ℝ + | [], 0 => C [] + | [], _+1 => 0 + | i::p, 0 => C [] + pathCharge (fun q => C (i::q)) p 0 + | i::p, b+1 => pathCharge (fun q => C (i::q)) p b + +def nodeCharge : Tree ι E → (List ι → ℝ) → ℝ + | .leaf v, C => ‖v‖*C [] + | .branch t, C => ‖∑ i, vector (t i)‖*C [] + ∑ i, nodeCharge (t i) (fun p => C (i::p)) + +/-- Exact occupancy identity for every node charge. This includes all levels, +not only the terminal mass; populations created later are not charged earlier. -/ +theorem particle_occupancy (t : Tree ι E) (C : List ι → ℝ) : + particleEval t (pathCharge C) = nodeCharge t C := by + induction t generalizing C with + | leaf v => simp [particleEval,rootEval,lateEval,pathCharge,nodeCharge] + | branch t ih => + simp only [particleEval,rootEval,lateEval,pathCharge,rootEval_add,rootEval_const, + Finset.sum_add_distrib] + have hs : (∑ i, particleEval (t i) (pathCharge (fun q => C (i::q)))) = + ∑ i, nodeCharge (t i) (fun q => C (i::q)) := + Finset.sum_congr rfl (fun i _ => ih i _) + simp only [particleEval,Finset.sum_add_distrib] at hs + rw [← Finset.sum_mul,mul_add,← mul_assoc,survival_capacity] + change _ = ‖∑ i, vector (t i)‖*C []+∑ i, nodeCharge (t i) (fun q => C (i::q)) + linarith + +end IntrinsicMarks + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/ScalarCancellation1.lean b/lean/OAI/Analysis/SignedDisk/ScalarCancellation1.lean new file mode 100644 index 0000000000000000000000000000000000000000..5be5e7e7e6306d44e7c56b54db91c5cfafd48086 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/ScalarCancellation1.lean @@ -0,0 +1,411 @@ +import OAI.Analysis.SignedDisk.DiskMaximalTools1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal + +noncomputable section + +namespace SignedDisk + +namespace ScalarCancellation +open Finset +variable {α ι : Type*} [MeasurableSpace α] {μ : Measure α} [Fintype ι] + +lemma scalar_defect_sum (w : ℕ → ι → ι → ℝ) (hw : ∀ k q s, 0 ≤ w k q s) + (hcol : ∀ k s, ∑ q, w k q s = 1) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (k : ℕ) : + (∑ q, ∫ x, |errors μ w f (k+1) q x| ∂μ) ≤ + (∑ q, |∫ x, refined w f k q x ∂μ|)-(∑ q, |∫ x, refined w f (k+1) q x ∂μ|) := by + calc + _ ≤ ∑ q, ((∑ s, w k q s*|∫ x, refined w f k s x ∂μ|)-|∫ x, refined w f (k+1) q x ∂μ|) := + sum_le_sum (fun q _ => errors_cost w hw hf k q) + _ = _ := by + rw [sum_sub_distrib,sum_comm] + congr 1 + apply sum_congr rfl + intro s _ + rw [← sum_mul,hcol,one_mul] + +/-- The total cancellation cost of all levels is bounded by the actual scalar +input mass, independently of the number of refinement levels. -/ +theorem errors_total_cost (w : ℕ → ι → ι → ℝ) (hw : ∀ k q s, 0 ≤ w k q s) + (hcol : ∀ k s, ∑ q, w k q s = 1) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (n : ℕ) : + (∑ k ∈ range (n+1), ∑ q, ∫ x, |errors μ w f k q x| ∂μ) + + (∑ q, |∫ x, refined w f n q x ∂μ|) ≤ ∑ q, ∫ x, |f q x| ∂μ := by + induction n with + | zero => + simp only [Nat.zero_add,range_one,sum_singleton,errors_terminal_cost w hf,refined,sum_sub_distrib] + exact (sub_add_cancel _ _).le + | succ n ih => + rw [sum_range_succ] + have hstep := scalar_defect_sum w hw hcol hf n + linarith + +lemma errors_total_cost_le (w : ℕ → ι → ι → ℝ) (hw : ∀ k q s, 0 ≤ w k q s) + (hcol : ∀ k s, ∑ q, w k q s = 1) {f : ι → α → ℝ} + (hf : ∀ q, Integrable (f q) μ) (n : ℕ) : + (∑ k ∈ range (n+1), ∑ q, ∫ x, |errors μ w f k q x| ∂μ) ≤ ∑ q, ∫ x, |f q x| ∂μ := by + have h := errors_total_cost w hw hcol hf n + have hx : 0 ≤ ∑ q, |∫ x, refined w f n q x ∂μ| := sum_nonneg (fun _ _ => abs_nonneg _) + linarith + +/-- Exact expansion in a coherent family of refinement coefficients. The +finite zero-mass pieces are the explicitly constructed `errors`, not merely +scalar mass certificates. -/ +theorem telescoped_decomposition [DecidableEq ι] (w : ℕ → ι → ι → ℝ) (f : ι → α → ℝ) + (Λ : ℕ → ℕ → ι → ι → ℝ) + (hdiag : ∀ k q s, Λ k k q s = if q = s then 1 else 0) + (hstep : ∀ k j q s, j ≤ k → Λ (k+1) j q s = ∑ a, w k q a*Λ k j a s) + (k : ℕ) (q : ι) (x : α) : + refined w f k q x = roots μ w f k q x + + ∑ j ∈ range (k+1), ∑ s, Λ k j q s*errors μ w f j s x := by + classical + induction k generalizing q with + | zero => + simp only [Nat.zero_add,Finset.range_one,sum_singleton,hdiag,ite_mul,one_mul,zero_mul] + rw [sum_ite_eq univ q] + simp only [Finset.mem_univ,ite_true,errors,refined] + ring + | succ k ih => + rw [sum_range_succ] + have hlast : (∑ s, Λ (k+1) (k+1) q s*errors μ w f (k+1) s x) = errors μ w f (k+1) q x := by + simp only [hdiag,ite_mul,one_mul,zero_mul] + simp + rw [hlast,errors,refined] + simp_rw [ih] + simp only [mul_add,sum_add_distrib] + have hsum : (∑ a, w k q a*(∑ j ∈ range (k+1), ∑ s, Λ k j a s*errors μ w f j s x)) = + ∑ j ∈ range (k+1), ∑ s, Λ (k+1) j q s*errors μ w f j s x := by + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro j hj + rw [sum_comm] + apply sum_congr rfl + intro s _ + rw [hstep k j q s (Nat.le_of_lt_succ (mem_range.mp hj)),sum_mul] + apply sum_congr rfl + intro a _ + ring + rw [hsum] + ring + +end ScalarCancellation + +open MeasureTheory Set +open scoped ENNReal NNReal Topology + +namespace DyadicHats + +def tent (x : ℝ) : ℝ := max (1-|x|) 0 + +lemma tent_nonneg (x : ℝ) : 0 ≤ tent x := le_max_right _ _ +lemma tent_le_one (x : ℝ) : tent x ≤ 1 := max_le (by linarith [abs_nonneg x]) (by norm_num) +lemma tent_pos_iff (x : ℝ) : 0 < tent x ↔ |x| < 1 := by + unfold tent + rw [lt_max_iff] + constructor + · intro h; rcases h with h|h <;> linarith + · intro h; exact Or.inl (by linarith) +lemma tent_eq_zero_of_one_le {x : ℝ} (hx : 1 ≤ |x|) : tent x = 0 := by + exact max_eq_right (by linarith) +lemma tent_of_nonneg {x : ℝ} (hx : 0 ≤ x) (hx1 : x ≤ 1) : tent x = 1-x := by + simp only [tent, abs_of_nonneg hx, max_eq_left (sub_nonneg.mpr hx1)] +lemma tent_of_nonpos {x : ℝ} (hx : x ≤ 0) (hx1 : -1 ≤ x) : tent x = 1+x := by + rw [tent,abs_of_nonpos hx,max_eq_left (by linarith)] + ring +lemma tent_neg (x : ℝ) : tent (-x) = tent x := by simp only [tent,abs_neg] + +lemma lipschitz_tent : LipschitzWith 1 tent := by + have hn : LipschitzWith 1 (fun x : ℝ => |x|) := by + change LipschitzWith 1 (norm : ℝ → ℝ) + exact lipschitzWith_one_norm + have h : LipschitzWith 1 (fun x : ℝ => 1-|x|) := by + simpa only [zero_add] using (LipschitzWith.const (1:ℝ)).sub hn + change LipschitzWith 1 (fun x : ℝ => max (1-|x|) 0) + simpa only [max_eq_left (by norm_num : (0:ℝ≥0) ≤ 1)] using h.max (LipschitzWith.const (0:ℝ)) + +theorem tent_refine (x : ℝ) : + tent x = (1/2)*tent (2*x+1)+tent (2*x)+(1/2)*tent (2*x-1) := by + wlog hx : 0 ≤ x generalizing x + · have h := this (-x) (by linarith) + rw [tent_neg] at h + have heq1 : 2*(-x)+1 = -(2*x-1) := by ring + have heq2 : 2*(-x) = -(2*x) := by ring + have heq3 : 2*(-x)-1 = -(2*x+1) := by ring + rw [heq1,heq3,heq2,tent_neg,tent_neg,tent_neg] at h + linarith + have hplus : tent (2*x+1) = 0 := tent_eq_zero_of_one_le (by rw [abs_of_nonneg (by linarith)]; linarith) + rw [hplus,mul_zero,zero_add] + by_cases hx1 : x ≤ 1/2 + · rw [tent_of_nonneg hx (by linarith),tent_of_nonneg (by linarith) (by linarith), + tent_of_nonpos (by linarith) (by linarith)] + ring + · by_cases hx2 : x ≤ 1 + · rw [tent_of_nonneg hx hx2,tent_eq_zero_of_one_le (by rw [abs_of_nonneg (by linarith)]; linarith), + tent_of_nonneg (by linarith) (by linarith)] + ring + · rw [tent_eq_zero_of_one_le (by rw [abs_of_nonneg hx]; linarith), + tent_eq_zero_of_one_le (by rw [abs_of_nonneg (by linarith)]; linarith), + tent_eq_zero_of_one_le (by rw [abs_of_nonneg (by linarith)]; linarith)] + ring + +lemma tent_floor (x : ℝ) : tent (x-⌊x⌋) = 1-(x-⌊x⌋) := + tent_of_nonneg (sub_nonneg.mpr (Int.floor_le x)) (by linarith [Int.lt_floor_add_one x]) +lemma tent_floor_succ (x : ℝ) : tent (x-(⌊x⌋+1)) = x-⌊x⌋ := by + rw [tent_of_nonpos (by linarith [Int.lt_floor_add_one x]) (by linarith [Int.floor_le x])] + ring +lemma tent_floor_partition (x : ℝ) : tent (x-⌊x⌋)+tent (x-(⌊x⌋+1)) = 1 := by + rw [tent_floor,tent_floor_succ]; ring + +lemma tent_eq_zero_of_ne_floor {x : ℝ} {j : ℤ} + (hj : j ≠ ⌊x⌋) (hj' : j ≠ ⌊x⌋+1) : tent (x-j) = 0 := by + apply tent_eq_zero_of_one_le + have hcases : j < ⌊x⌋ ∨ ⌊x⌋+1 < j := by omega + rcases hcases with h|h + · have hjle : (j:ℝ)+1 ≤ ⌊x⌋ := by exact_mod_cast h + rw [abs_of_nonneg (by linarith [Int.floor_le x])] + linarith [Int.floor_le x] + · have hjle : (⌊x⌋:ℝ)+2 ≤ j := by exact_mod_cast (show ⌊x⌋+2 ≤ j by omega) + rw [abs_of_nonpos (by linarith [Int.lt_floor_add_one x])] + linarith [Int.lt_floor_add_one x] + +lemma summable_tent (x : ℝ) : Summable (fun j : ℤ => tent (x-j)) := by + apply summable_of_ne_finset_zero (s := {⌊x⌋,⌊x⌋+1}) + intro j hj + simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hj + exact tent_eq_zero_of_ne_floor hj.1 hj.2 + +/-- Partition of unity on the complete integer grid, including grid boundaries. -/ +theorem tsum_tent (x : ℝ) : (∑' j : ℤ, tent (x-j)) = 1 := by + rw [tsum_eq_sum (s := {⌊x⌋,⌊x⌋+1}) (fun j hj => by + simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hj + exact tent_eq_zero_of_ne_floor hj.1 hj.2)] + rw [Finset.sum_insert (by simp),Finset.sum_singleton] + simpa only [Int.cast_add,Int.cast_one] using tent_floor_partition x + +/-- Actual Euclidean-plane product hats at a positive physical scale. -/ +def hat (r : ℝ) (p : ℤ × ℤ) (x : ℂ) : ℝ := + tent (x.re/r-p.1)*tent (x.im/r-p.2) +lemma hat_nonneg (r : ℝ) (p : ℤ × ℤ) (x : ℂ) : 0 ≤ hat r p x := + mul_nonneg (tent_nonneg _) (tent_nonneg _) +lemma hat_le_one (r : ℝ) (p : ℤ × ℤ) (x : ℂ) : hat r p x ≤ 1 := by + calc + _ ≤ 1*1 := mul_le_mul (tent_le_one _) (tent_le_one _) (tent_nonneg _) (by norm_num) + _ = _ := one_mul _ +lemma continuous_hat (r : ℝ) (p : ℤ × ℤ) : Continuous (hat r p) := by + unfold hat + exact (lipschitz_tent.continuous.comp (by fun_prop)).mul + (lipschitz_tent.continuous.comp (by fun_prop)) + +lemma summable_hat (r : ℝ) (x : ℂ) : Summable (fun p : ℤ × ℤ => hat r p x) := + (summable_tent (x.re/r)).mul_of_nonneg (summable_tent (x.im/r)) + (fun _ => tent_nonneg _) (fun _ => tent_nonneg _) + +theorem tsum_hat (r : ℝ) (x : ℂ) : (∑' p : ℤ × ℤ, hat r p x) = 1 := by + rw [Summable.tsum_prod (summable_hat r x)] + simp_rw [hat,tsum_mul_left,tsum_tent,mul_one] + exact tsum_tent _ + +/-- One-dimensional refinement written with the actual interpolation weights. -/ +lemma tent_half_integer {j : ℤ} (hj : j ∉ Finset.Icc (-1) 1) : tent ((j:ℝ)/2) = 0 := by + apply tent_eq_zero_of_one_le + simp only [Finset.mem_Icc,not_and_or,not_le] at hj + rcases hj with hj|hj + · have h : (j:ℝ) ≤ -2 := by exact_mod_cast (show j ≤ -2 by omega) + rw [abs_of_nonpos (by linarith)] + linarith + · have h : (2:ℝ) ≤ j := by exact_mod_cast (show 2 ≤ j by omega) + rw [abs_of_nonneg (by linarith)] + linarith + +lemma tent_half_refine (x : ℝ) : + tent (x/2) = ∑ j ∈ Finset.Icc (-1:ℤ) 1, tent ((j:ℝ)/2)*tent (x-j) := by + rw [show Finset.Icc (-1:ℤ) 1 = {-1,0,1} by decide] + simp only [Finset.sum_insert,Finset.sum_singleton,Finset.mem_insert, + Finset.mem_singleton,Int.reduceEq,or_self,not_false_eq_true, + Int.cast_neg,Int.cast_one,Int.cast_zero,sub_neg_eq_add,sub_zero] + norm_num [tent] at ⊢ + have h := tent_refine (x/2) + unfold tent at h + convert h using 1 + ring_nf + +lemma tent_half_tsum_refine (x : ℝ) (p : ℤ) : + tent (x/2-p) = ∑' j : ℤ, tent ((j:ℝ)/2-p)*tent (x-j) := by + have heq : (∑' j : ℤ, tent ((j:ℝ)/2-p)*tent (x-j)) = + ∑' j : ℤ, tent ((j:ℝ)/2)*tent ((x-2*p)-j) := by + rw [← (Equiv.addRight (2*p)).tsum_eq] + apply tsum_congr + intro j + simp only [Equiv.coe_addRight,Int.cast_add,Int.cast_mul,Int.cast_ofNat] + congr 2 <;> ring + rw [heq,tsum_eq_sum (s := Finset.Icc (-1:ℤ) 1)] + · convert tent_half_refine (x-2*p) using 1 + congr 1 + ring + · intro j hj + rw [tent_half_integer hj,zero_mul] + +lemma summable_tent_weight (x : ℝ) (a : ℤ → ℝ) : + Summable (fun j : ℤ => a j*tent (x-j)) := by + apply summable_of_ne_finset_zero (s := {⌊x⌋,⌊x⌋+1}) + intro j hj + simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hj + rw [tent_eq_zero_of_ne_floor hj.1 hj.2,mul_zero] + +/-- Positive interpolation coefficients, indexed by coarse and fine grid indices. -/ +def step (p q : ℤ × ℤ) : ℝ := + tent ((q.1:ℝ)/2-p.1)*tent ((q.2:ℝ)/2-p.2) +lemma step_nonneg (p q : ℤ × ℤ) : 0 ≤ step p q := + mul_nonneg (tent_nonneg _) (tent_nonneg _) +lemma step_column (q : ℤ × ℤ) : (∑' p : ℤ × ℤ, step p q) = 1 := by + calc + _ = ∑' p, hat 1 p (((q.1:ℝ)/2 : ℂ)+((q.2:ℝ)/2 : ℂ)*Complex.I) := by + apply tsum_congr + intro p + simp [step,hat] + _ = 1 := tsum_hat _ _ + +lemma summable_step_hat (p : ℤ × ℤ) (r : ℝ) (x : ℂ) : + Summable (fun q : ℤ × ℤ => step p q*hat r q x) := by + have h1 := summable_tent_weight (x.re/r) (fun j => tent ((j:ℝ)/2-p.1)) + have h2 := summable_tent_weight (x.im/r) (fun j => tent ((j:ℝ)/2-p.2)) + convert h1.mul_of_nonneg h2 (fun j => mul_nonneg (tent_nonneg _) (tent_nonneg _)) + (fun j => mul_nonneg (tent_nonneg _) (tent_nonneg _)) using 1 + funext q + simp only [step,hat] + ring + +/-- Exact planar hat refinement; no grid truncation is hidden in the identity. -/ +theorem hat_refine (r : ℝ) (p : ℤ × ℤ) (x : ℂ) : + hat (2*r) p x = ∑' q : ℤ × ℤ, step p q*hat r q x := by + rw [Summable.tsum_prod (summable_step_hat p r x)] + have heq : (fun j : ℤ => ∑' k : ℤ, + step p (j,k)*hat r (j,k) x) = fun j : ℤ => + (tent ((j:ℝ)/2-p.1)*tent (x.re/r-j))* + ∑' k : ℤ, tent ((k:ℝ)/2-p.2)*tent (x.im/r-k) := by + funext j + rw [← tsum_mul_left] + apply tsum_congr + intro k + simp only [step,hat] + ring + rw [heq,tsum_mul_right,← tent_half_tsum_refine,← tent_half_tsum_refine] + unfold hat + congr 2 <;> ring + +end DyadicHats + +open MeasureTheory Set Metric +open scoped ENNReal NNReal + +namespace PlanePotential + +lemma dim_complex : Module.finrank ℝ ℂ = 2 := Complex.finrank_real_complex + +lemma volume_real_unit_ball : volume.real (ball (0:ℂ) 1) = Real.pi := by + rw [measureReal_def,Complex.volume_ball] + simp + +lemma integral_radial (f : ℝ → ℝ) : + (∫ x : ℂ, f ‖x‖) = 2*Real.pi * ∫ r in Ioi (0:ℝ), r*f r := by + rw [integral_fun_norm_addHaar volume f] + simp only [dim_complex,show (2:ℕ)-1=1 by rfl,pow_one,smul_eq_mul,volume_real_unit_ball, + nsmul_eq_mul,Nat.cast_ofNat] + ring + +lemma integrable_radial_iff (f : ℝ → ℝ) : + Integrable (fun x : ℂ => f ‖x‖) ↔ IntegrableOn (fun r => r*f r) (Ioi (0:ℝ)) := by + simpa only [dim_complex,show (2:ℕ)-1=1 by rfl,pow_one,smul_eq_mul] using + integrable_fun_norm_addHaar (E := ℂ) volume (f := f) + +lemma radial_near_identity (a r : ℝ) {t : ℝ} (ht : 0 < t) : + t * (Iio r).indicator (fun u : ℝ => u^a) t = (Ioo 0 r).indicator (fun u : ℝ => u^(a+1)) t := by + by_cases htr : t < r + · simp only [indicator_of_mem (show t ∈ Iio r from htr),indicator_of_mem (show t ∈ Ioo 0 r from ⟨ht,htr⟩)] + rw [Real.rpow_add ht,Real.rpow_one,mul_comm] + · simp only [indicator_of_notMem (show t ∉ Iio r from htr),indicator_of_notMem (show t ∉ Ioo 0 r by simp [htr]),mul_zero] + +lemma integrable_norm_rpow_near {a r : ℝ} (ha : -2 < a) (hr : 0 < r) : + IntegrableOn (fun x : ℂ => ‖x‖^a) (ball 0 r) := by + rw [integrableOn_fun_norm_addHaar volume (f := fun t : ℝ => t^a)] + simp only [dim_complex,show (2:ℕ)-1=1 by rfl,pow_one,smul_eq_mul] + have hi : IntegrableOn (fun t : ℝ => t^(a+1)) (Ioo 0 r) := + (intervalIntegral.integrableOn_Ioo_rpow_iff hr).mpr (by linarith) + apply hi.congr_fun _ measurableSet_Ioo + intro t ht + change t^(a+1) = t*t^a + rw [Real.rpow_add ht.1,Real.rpow_one,mul_comm] + +/-- Exact planar singular-kernel integral; the center point is not excluded by +an unproved integrability convention. -/ +theorem integral_norm_rpow_near {a r : ℝ} (ha : -2 < a) (hr : 0 < r) : + (∫ x in ball (0:ℂ) r, ‖x‖^a) = 2*Real.pi * (r^(a+2)/(a+2)) := by + have heq : (ball (0:ℂ) r).indicator (fun x => ‖x‖^a) = + fun x : ℂ => (Iio r).indicator (fun t : ℝ => t^a) ‖x‖ := by + funext x + by_cases hx : ‖x‖ < r <;> simp [indicator,hx] + rw [← integral_indicator measurableSet_ball,heq,integral_radial] + have hinner : (∫ t in Ioi (0:ℝ), t*(Iio r).indicator (fun u : ℝ => u^a) t) = + ∫ t in Ioo 0 r, t^(a+1) := by + rw [setIntegral_congr_fun measurableSet_Ioi (fun t ht => radial_near_identity a r ht)] + rw [integral_indicator measurableSet_Ioo,Measure.restrict_restrict measurableSet_Ioo, + inter_eq_left.mpr (Ioo_subset_Ioi_self)] + rw [hinner,← integral_Ioc_eq_integral_Ioo,← intervalIntegral.integral_of_le hr.le, + integral_rpow (Or.inl (by linarith : -1 < a+1))] + rw [show a+1+1=a+2 by ring,Real.zero_rpow (by linarith : a+2 ≠ 0),sub_zero] + +lemma radial_far_identity (a r : ℝ) {t : ℝ} (ht : 0 < t) : + t*(Ioi r).indicator (fun u : ℝ => u^a) t = (Ioi r).indicator (fun u : ℝ => u^(a+1)) t := by + by_cases htr : r < t + · simp only [indicator_of_mem (show t ∈ Ioi r from htr)] + rw [Real.rpow_add ht,Real.rpow_one,mul_comm] + · simp only [indicator_of_notMem (show t ∉ Ioi r from htr),mul_zero] + +lemma integrable_norm_rpow_far {a r : ℝ} (ha : a < -2) (hr : 0 < r) : + IntegrableOn (fun x : ℂ => ‖x‖^a) {x | r < ‖x‖} := by + rw [← integrable_indicator_iff (measurableSet_lt measurable_const measurable_norm)] + have heq : ({x : ℂ | r < ‖x‖}).indicator (fun x => ‖x‖^a) = + fun x : ℂ => (Ioi r).indicator (fun t : ℝ => t^a) ‖x‖ := by rfl + rw [heq,integrable_radial_iff] + have hi : IntegrableOn (fun t : ℝ => t^(a+1)) (Ioi r) := + integrableOn_Ioi_rpow_of_lt (by linarith) hr + have hi' : Integrable ((Ioi r).indicator (fun t : ℝ => t^(a+1))) := + (integrable_indicator_iff measurableSet_Ioi).mpr hi + apply hi'.integrableOn.congr_fun _ measurableSet_Ioi + intro t ht + exact (radial_far_identity a r ht).symm + +theorem integral_norm_rpow_far {a r : ℝ} (ha : a < -2) (hr : 0 < r) : + (∫ x : ℂ in {x | r < ‖x‖}, ‖x‖^a) = 2*Real.pi * (-r^(a+2)/(a+2)) := by + have heq : ({x : ℂ | r < ‖x‖}).indicator (fun x => ‖x‖^a) = + fun x : ℂ => (Ioi r).indicator (fun t : ℝ => t^a) ‖x‖ := by rfl + rw [← integral_indicator (measurableSet_lt measurable_const measurable_norm),heq,integral_radial] + rw [setIntegral_congr_fun measurableSet_Ioi (fun t ht => radial_far_identity a r ht)] + rw [integral_indicator measurableSet_Ioi,Measure.restrict_restrict measurableSet_Ioi, + inter_eq_left.mpr (Ioi_subset_Ioi hr.le),integral_Ioi_rpow_of_lt (by linarith : a+1 < -1) hr] + congr 2 + rw [show a+1+1 = a+2 by ring] + ring + +end PlanePotential + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/SignedRuns1.lean b/lean/OAI/Analysis/SignedDisk/SignedRuns1.lean new file mode 100644 index 0000000000000000000000000000000000000000..36cddc9a0ea0ac47918d63f9222541cfea4147f9 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/SignedRuns1.lean @@ -0,0 +1,426 @@ +import OAI.Analysis.SignedDisk.PhysicalCells1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace SignedRuns +open DiskMoments RadiusEnvelope ActualLabels ConeCoordinates + +structure Run where + dir : Label + first : ℕ + last : ℕ + +/-- Completed runs, in reverse chronological order. -/ +def closedRuns : List Label → List Run + | [] => [] + | [_] => [] + | n::old::p => if n = old then closedRuns (old::p) + else ⟨old,activeStart (old::p),p.length⟩::closedRuns (old::p) + +def runs : List Label → List Run + | [] => [] + | n::p => ⟨n,activeStart (n::p),p.length⟩::closedRuns (n::p) + +lemma closedRuns_bounds (n : Label) (p : List Label) : + ∀ a ∈ closedRuns (n::p), a.first ≤ a.last ∧ a.last < p.length := by + induction p generalizing n with + | nil => simp [closedRuns] + | cons old p ih => + simp only [closedRuns] + split_ifs with h + · intro a ha + exact ⟨(ih old a ha).1,(ih old a ha).2.trans (by simp)⟩ + · intro a ha + rcases List.mem_cons.mp ha with ha | ha + · subst a + exact ⟨activeStart_le old p,by simp⟩ + · exact ⟨(ih old a ha).1,(ih old a ha).2.trans (by simp)⟩ + +lemma runs_bounds (n : Label) (p : List Label) : + ∀ a ∈ runs (n::p), a.first ≤ a.last ∧ a.last ≤ p.length := by + intro a ha + rcases List.mem_cons.mp ha with ha | ha + · subst a + exact ⟨activeStart_le n p,le_rfl⟩ + · exact ⟨(closedRuns_bounds n p a ha).1,(closedRuns_bounds n p a ha).2.le⟩ + +lemma runs_cover (n : Label) (p : List Label) (k : ℕ) (hk : k ≤ p.length) : + ∃ a ∈ runs (n::p), a.first ≤ k ∧ k ≤ a.last := by + induction p generalizing n k with + | nil => + have hk0 : k = 0 := by simpa using hk + subst k + exact ⟨⟨n,0,0⟩,by simp [runs,activeStart],le_rfl,le_rfl⟩ + | cons old p ih => + by_cases h : n = old + · subst n + by_cases hs : activeStart (old::p) ≤ k + · refine ⟨⟨old,activeStart (old::p),p.length+1⟩,?_,hs,?_⟩ + · simp [runs,activeStart] + · simpa using hk + · have hk' : k ≤ p.length := (le_of_not_ge hs).trans (activeStart_le old p) + obtain ⟨a,ha,hak,hka⟩ := ih old k hk' + have hac : a ∈ closedRuns (old::p) := by + rcases List.mem_cons.mp ha with ha | ha + · subst a + exact False.elim (hs hak) + · exact ha + exact ⟨a,by simp [runs,closedRuns,hac],hak,hka⟩ + · by_cases hk' : k ≤ p.length + · obtain ⟨a,ha,hak,hka⟩ := ih old k hk' + exact ⟨a,by simpa only [runs,closedRuns,h,ite_false,List.mem_cons] using Or.inr ha,hak,hka⟩ + · have he : k = p.length+1 := by simp only [List.length_cons] at hk; omega + subst k + exact ⟨⟨n,p.length+1,p.length+1⟩,by simp [runs,activeStart,h],le_rfl,le_rfl⟩ + +lemma potential_eq_runs (g : ℂ → ℝ) (r : ℕ → ℝ) (x : ℂ) (n : Label) (p : List Label) : + potential g r x (n::p) = ((runs (n::p)).map fun a => + (runEnvelope g r a.first a.last x-signedAverage g x (r a.first)) • (a.dir:ℂ)).sum := by + induction p generalizing n with + | nil => simp [potential,runs,closedRuns,activeStart] + | cons old p ih => + rw [potential,ih] + by_cases h : n = old + · subst n + simp only [runs,closedRuns,activeStart,ite_true,List.length_cons,List.map_cons,List.sum_cons] + module + · simp only [runs,closedRuns,activeStart,h,ite_false,List.length_cons,List.map_cons,List.sum_cons] + abel + +lemma radius_in_bin (r : ℕ → ℝ) + (hstep : ∀ k, 2*r (k+1) = r k) (j : ℕ) {t : ℝ} (ht : t ∈ Icc (r j) (2*r 0)) : + ∃ k ≤ j, t ∈ Icc (r k) (2*r k) := by + induction j with + | zero => exact ⟨0,le_rfl,ht⟩ + | succ j ih => + by_cases h : r j ≤ t + · obtain ⟨k,hk,hkt⟩ := ih ⟨h,ht.2⟩ + exact ⟨k,hk.trans (Nat.le_succ j),hkt⟩ + · exact ⟨j+1,le_rfl,ht.1,by linarith [hstep j]⟩ + +lemma runs_cover_radius (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) + (hstep : ∀ k, 2*r (k+1) = r k) (n : Label) (p : List Label) {t : ℝ} + (ht : t ∈ Icc (r p.length) (2*r 0)) : + ∃ a ∈ runs (n::p), t ∈ Icc (r a.last) (2*r a.first) := by + obtain ⟨k,hk,hkt⟩ := radius_in_bin r hstep p.length ht + obtain ⟨a,ha,hi,hj⟩ := runs_cover n p k hk + refine ⟨a,ha,?_,?_⟩ + · exact (radius_antitone r hr hstep hj).trans hkt.1 + · have hh := radius_antitone r hr hstep hi + linarith [hkt.2] + +/-- Every history has an actually attaining winning run. No radius selection +is differentiated. -/ +lemma winning_run (g : ℂ → ℝ) (r : ℕ → ℝ) (hg : ContDiff ℝ 1 g) + (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (n : Label) (p : List Label) (x : ℂ) : + ∃ a ∈ runs (n::p), ∃ t ∈ Icc (r a.last) (2*r a.first), + runEnvelope g r 0 p.length x = signedAverage g x t ∧ + runEnvelope g r a.first a.last x = signedAverage g x t := by + obtain ⟨t,ht,he,hmax⟩ := runEnvelope_attains g r hg hr hstep (Nat.zero_le _) x + obtain ⟨a,ha,hat⟩ := runs_cover_radius r hr hstep n p ht + refine ⟨a,ha,t,hat,he,le_antisymm ?_ ?_⟩ + · obtain ⟨s,hs,hsval,_⟩ := runEnvelope_attains g r hg hr hstep (runs_bounds n p a ha).1 x + rw [hsval] + apply hmax + constructor + · exact (radius_antitone r hr hstep (runs_bounds n p a ha).2).trans hs.1 + · have hh := radius_antitone r hr hstep (Nat.zero_le a.first) + linarith [hs.2] + · exact le_envelope (u := fun t y => signedAverage g y t) hat x (signedAverage_radius_continuousOn hg x (hr a.last)) + +end SignedRuns + +namespace FiniteLabels +lemma Law.ext_mass {ι : Type*} [Fintype ι] {μ ν : Law ι} (h : μ.mass = ν.mass) : μ = ν := by + cases μ + cases ν + cases h + rfl +end FiniteLabels + +namespace SignedAssembly +open Finset FiniteLabels +variable {ι : Type*} [Fintype ι] + +/-- The zero row-sum is obtained by differentiating the actual stochastic +partition of unity, not postulated for the row derivatives. -/ +def RowJet.ofLawAt (P : ℂ → Law ι) (x : ℂ) + (hd : ∀ i, DifferentiableAt ℝ (fun y => P y i) x) : RowJet ι ℂ where + law := P x + grad i := gradient (fun y => P y i) x + total_grad := by + have ht : (fun y => ∑ i, P y i) = fun _ => (1:ℝ) := funext fun y => (P y).total + have hs : (∑ i, fderiv ℝ (fun y => P y i) x) = 0 := by + rw [← fderiv_fun_sum (fun i _ => hd i),ht] + exact fderiv_const_apply (1:ℝ) + simp only [gradient,← _root_.map_sum,hs,map_zero] +end SignedAssembly + +namespace ActualLabels +open FiniteLabels SignedAssembly Finset ConeCoordinates + +/-- Observation time zero is the true initial spatial row. Subsequent times +are the true state-dependent spatial switch rows. -/ +def observation (h : ℂ → ℂ) (r : ℕ → ℝ) : ℕ → ℂ → Label → Law Label + | 0,x,_ => initial h (r 0) x + | k+1,x,n => row h (r (k+1)) x n + +def before (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) : ℕ → Law Label + | 0 => delta old + | k+1 => marginal h r k x + +lemma before_move (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) (k : ℕ) : + before h r old x (k+1) = move (before h r old x k) (observation h r k x) := by + cases k with + | zero => + apply Law.ext_mass + funext j + change initial h (r 0) x j = ∑ n, delta old n*initial h (r 0) x j + rw [← sum_mul,(delta old).total,one_mul] + | succ k => rfl + +lemma observation_lipschitz (h : ℂ → ℂ) (r : ℕ → ℝ) (k : ℕ) (hr : 0 < r k) + (n j : Label) : LipschitzWith (Real.toNNReal (16/r k)) (fun x => observation h r k x n j) := by + cases k with + | zero => + simpa only [mul_one,observation,initial,row] using spatialRow_component_lipschitz (quantize 1 (by norm_num)) + (target h (r 0)) (fun _ => 1) (fun _ => zero_le_one) (fun _ => le_rfl) hr + (by norm_num : (0:ℝ) ≤ 1) (fun _ => le_rfl) j + | succ k => + simpa only [mul_one,observation,initial,row] using spatialRow_component_lipschitz n (target h (r (k+1))) + (switchChance h (r (k+1)) n) (switchChance_nonneg h (r (k+1)) n) + (switchChance_le_one h (r (k+1)) n) hr (by norm_num : (0:ℝ) ≤ 1) + (switchChance_le_one h (r (k+1)) n) j + +lemma observation_ae_diff (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) : + ∀ᵐ x, ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x := by + simp only [ae_all_iff] + intro k n j + exact (observation_lipschitz h r k (hr k) n j).ae_differentiableAt + +def observationJet (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) + (hd : ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x) + (k : ℕ) (n : Label) : RowJet Label ℂ := + RowJet.ofLawAt (fun y => observation h r k y n) x (hd k n) + +/-- The jet's expected absolute row derivative is exactly T_k/r_k from the +physical spatial packing theorem. -/ +lemma observationJet_cost (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (hd : ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x) + (k : ℕ) (hr : 0 < r k) : + expect (before h r old x k) (fun n => ∑ j, ‖(observationJet h r x hd k n).grad j‖) = + derivativeCost h r x k/r k := by + cases k with + | zero => + change expect (delta old) (fun _ => ∑ j, ‖gradient (fun y => initial h (r 0) y j) x‖) = _ + rw [FiniteLabels.expect_const,derivativeCost,mul_div_cancel_left₀ _ hr.ne'] + | succ k => + simp only [observationJet,RowJet.ofLawAt,observation,before,derivativeCost,rowDerivative,FiniteLabels.expect] + rw [Finset.sum_div] + apply sum_congr rfl + intro n _ + field_simp +end ActualLabels + +namespace SignedRuns +open ActualLabels FiniteLabels SignedAssembly Finset + +def weight (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) : List Label → ℝ + | [] => 1 + | n::p => weight h r old x p*observation h r p.length x (p.headD old) n + +lemma weight_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) (p : List Label) : + 0 ≤ weight h r old x p := by + induction p with + | nil => exact zero_le_one + | cons n p ih => exact mul_nonneg ih ((observation h r p.length x (p.headD old)).nonneg n) + +lemma weight_le_one (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) (p : List Label) : + weight h r old x p ≤ 1 := by + induction p with + | nil => exact le_rfl + | cons n p ih => + apply (mul_le_mul ih (law_le_one (observation h r p.length x (p.headD old)) n) + ((observation h r p.length x (p.headD old)).nonneg n) zero_le_one).trans_eq + exact one_mul 1 + +lemma lipschitz_bounded_mul {f g : ℂ → ℝ} {K L : ℝ≥0} (hf : LipschitzWith K f) + (hg : LipschitzWith L g) (hfb : ∀ x, ‖f x‖ ≤ 1) (hgb : ∀ x, ‖g x‖ ≤ 1) : + LipschitzWith (K+L) (fun x => f x*g x) := by + rw [lipschitzWith_iff_norm_sub_le] at hf hg ⊢ + intro x y + calc + ‖f x*g x-f y*g y‖ = ‖f x*(g x-g y)+g y*(f x-f y)‖ := by congr 1; ring + _ ≤ ‖f x*(g x-g y)‖+‖g y*(f x-f y)‖ := norm_add_le _ _ + _ = ‖f x‖*‖g x-g y‖+‖g y‖*‖f x-f y‖ := by rw [norm_mul,norm_mul] + _ ≤ 1*((L:ℝ)*‖x-y‖)+1*((K:ℝ)*‖x-y‖) := by + gcongr + · exact hfb x + · exact hg x y + · exact hgb y + · exact hf x y + _ = ((K+L:ℝ≥0):ℝ)*‖x-y‖ := by push_cast; ring + +lemma weight_lipschitz (h : ℂ → ℂ) (r : ℕ → ℝ) (hr : ∀ k, 0 < r k) + (old : Label) (p : List Label) : ∃ K, LipschitzWith K (fun x => weight h r old x p) := by + induction p with + | nil => exact ⟨0,LipschitzWith.const 1⟩ + | cons n p ih => + obtain ⟨K,hK⟩ := ih + refine ⟨_,lipschitz_bounded_mul hK (observation_lipschitz h r p.length (hr _) _ n) ?_ ?_⟩ + · intro x + rw [Real.norm_eq_abs,abs_of_nonneg (weight_nonneg h r old x p)] + exact weight_le_one h r old x p + · intro x + rw [Real.norm_eq_abs,abs_of_nonneg ((observation h r p.length x (p.headD old)).nonneg n)] + exact law_le_one (observation h r p.length x (p.headD old)) n + +lemma weight_diff (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (hd : ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x) + (p : List Label) : DifferentiableAt ℝ (fun y => weight h r old y p) x := by + induction p with + | nil => exact differentiableAt_const 1 + | cons n p ih => exact ih.mul (hd p.length (p.headD old) n) + +lemma gradient_weight_cons (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (hd : ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x) + (n : Label) (p : List Label) : + gradient (fun y => weight h r old y (n::p)) x = + weight h r old x p • (observationJet h r x hd p.length (p.headD old)).grad n+ + observation h r p.length x (p.headD old) n • gradient (fun y => weight h r old y p) x := by + simp only [weight,observationJet,RowJet.ofLawAt,gradient] + rw [fderiv_fun_mul (weight_diff h r old x hd p) (hd p.length (p.headD old) n)] + simp only [map_add,map_smul] + +def leafSum {E : Type*} [AddCommMonoid E] (f : List Label → E) : ℕ → List Label → E + | 0,p => f p + | d+1,p => ∑ n, leafSum f d (n::p) + +lemma flux_eq_weightedLeaves (g : ℂ → ℝ) (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) + (x : ℂ) (hd : ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x) + (v : ℕ → ℝ) (d : ℕ) (p : List Label) : + pathFlux (jet g r x (observationJet h r x hd) v d p (p.headD old)) + (weight h r old x p) (gradient (fun y => weight h r old y p) x) = + leafSum (fun q => inner ℝ (gradient (fun y => weight h r old y q) x) (potential g r x q)) d p := by + induction d generalizing p with + | zero => rfl + | succ d ih => + simp only [jet,pathFlux,leafSum] + apply sum_congr rfl + intro n _ + change pathFlux _ (weight h r old x (n::p)) + (weight h r old x p • (observationJet h r x hd p.length (p.headD old)).grad n+ + observation h r p.length x (p.headD old) n • gradient (fun y => weight h r old y p) x) = _ + rw [← gradient_weight_cons h r old x hd n p] + exact ih (n::p) + +/-- The signed flux bound for derivatives of the actual spatial history +weights, with the true initial row and forward marginal derivatives. -/ +theorem actual_signed_flux_bound (g : ℂ → ℝ) (h : ℂ → ℂ) (r : ℕ → ℝ) + (hg : ContDiff ℝ 1 g) (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (old : Label) (x : ℂ) + (hd : ∀ k n j, DifferentiableAt ℝ (fun y => observation h r k y n j) x) + (v : ℕ → ℝ) + (hv : ∀ k t t', 0 < t → t ≤ 4*r k → 0 < t' → t' ≤ 4*r k → + |DiskMoments.signedAverage g x t-DiskMoments.signedAverage g x t'| ≤ v k) + (m : ℕ) : + |leafSum (fun q => inner ℝ (gradient (fun y => weight h r old y q) x) (potential g r x q)) m []| ≤ + ∑ k ∈ range m, (derivativeCost h r x k/r k)*(∑ l ∈ Ico k m, v l) := by + have hh := run_signed_flux_bound g r x (observationJet h r x hd) v hg hr hstep hv m old + (before h r old x) rfl (before_move h r old x) + have he := flux_eq_weightedLeaves g h r old x hd v m [] + simp only [List.headD_nil,weight] at he + rw [show gradient (fun _ : ℂ => (1:ℝ)) x = 0 from gradient_const x 1] at he + rw [he] at hh + simpa only [observationJet_cost h r old x hd _ (hr _)] using hh + +open DiskMoments RadiusEnvelope ActualLabels ConeCoordinates + +lemma run_gradient_touching {g : ℂ → ℝ} {r : ℕ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) (hr : ∀ k, 0 < r k) {i j : ℕ} {x : ℂ} + (hd : DifferentiableAt ℝ (runEnvelope g r i j) x) {t : ℝ} + (ht : t ∈ Icc (r j) (2*r i)) (he : runEnvelope g r i j x = signedAverage g x t) : + gradient (runEnvelope g r i j) x = gradient (fun y => signedAverage g y t) x := by + obtain ⟨K,hK⟩ := hg.lipschitzWith_of_hasCompactSupport hgc one_ne_zero + have hu := hasFDerivAt_signedAverage hg (fun y => norm_fderiv_le_of_lipschitz ℝ hK) x + ((hr j).trans_le ht.1) + unfold gradient runEnvelope + rw [RadiusEnvelope.fderiv_touching ht (fun y => signedAverage_radius_continuousOn hg y (hr j)) he hd hu.differentiableAt] + +lemma runs_ae_diff {g : ℂ → ℝ} {r : ℕ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) : + ∀ᵐ x, ∀ i j, i ≤ j → DifferentiableAt ℝ (runEnvelope g r i j) x := by + simp only [ae_all_iff] + intro i j hij + have hab : r j ≤ 2*r i := by + have := radius_antitone r hr hstep hij + linarith [hr i] + obtain ⟨L,hL⟩ := run_envelope_lipschitz hg hgc (hr j) hab + exact hL.ae_differentiableAt + +def coneContribution (n : Label) (z : ℂ) : ℝ := + inner ℝ (n:ℂ) z+max 0 (-inner ℝ (axis n 1) z)+max 0 (-inner ℝ (axis n (-1)) z) + +lemma coneContribution_nonneg (n : Label) (z : ℂ) : 0 ≤ coneContribution n z := by + have hc := cone_algebra (label_unit n) z + change ‖z‖ ≤ 12*coneContribution n z at hc + linarith [norm_nonneg z] + +theorem run_master {g : ℂ → ℝ} {r : ℕ → ℝ} (hg : ContDiff ℝ 1 g) + (hgc : HasCompactSupport g) (hr : ∀ k, 0 < r k) (hstep : ∀ k, 2*r (k+1) = r k) + (n : Label) (p : List Label) (x : ℂ) + (hd : ∀ i j, i ≤ j → DifferentiableAt ℝ (runEnvelope g r i j) x) : + ‖gradient (runEnvelope g r 0 p.length) x‖ ≤ + 12*((runs (n::p)).map fun a => coneContribution a.dir + (gradient (runEnvelope g r a.first a.last) x)).sum := by + obtain ⟨a,ha,t,ht,hgval,haval⟩ := winning_run g r hg hr hstep n p x + have hab := runs_bounds n p a ha + have htg : t ∈ Icc (r p.length) (2*r 0) := by + constructor + · exact (radius_antitone r hr hstep hab.2).trans ht.1 + · have hh := radius_antitone r hr hstep (Nat.zero_le a.first) + linarith [ht.2] + have he : gradient (runEnvelope g r 0 p.length) x = gradient (runEnvelope g r a.first a.last) x := + (run_gradient_touching hg hgc hr (hd 0 p.length (Nat.zero_le _)) htg hgval).trans + (run_gradient_touching hg hgc hr (hd a.first a.last hab.1) ht haval).symm + rw [he] + apply (cone_algebra (label_unit a.dir) _).trans + apply mul_le_mul_of_nonneg_left _ (by norm_num : (0:ℝ) ≤ 12) + apply List.single_le_sum + · intro z hz + obtain ⟨b,_,rfl⟩ := List.mem_map.mp hz + exact coneContribution_nonneg b.dir _ + · exact List.mem_map.mpr ⟨a,ha,rfl⟩ +end SignedRuns + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/SignedRuns2.lean b/lean/OAI/Analysis/SignedDisk/SignedRuns2.lean new file mode 100644 index 0000000000000000000000000000000000000000..566b19897816a29b68a5c1e96d2885768f2223eb --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/SignedRuns2.lean @@ -0,0 +1,423 @@ +import OAI.Analysis.SignedDisk.DiskMoments1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset +open scoped ENNReal NNReal RealInnerProductSpace +open scoped ContDiff +open MeasureTheory Set Metric Filter +open scoped ENNReal NNReal RealInnerProductSpace ContDiff Topology +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal NNReal Topology RealInnerProductSpace ContDiff +open MeasureTheory Set Metric Filter Finset + +noncomputable section + +namespace SignedDisk + +namespace SignedRuns +open ActualLabels FiniteLabels Finset + +lemma leafSum_succ_last {E : Type*} [AddCommMonoid E] (f : List Label → E) + (m : ℕ) (p : List Label) : + leafSum f (m+1) p = leafSum (fun q => ∑ n, f (n::q)) m p := by + induction m generalizing p with + | zero => rfl + | succ m ih => + change (∑ n, leafSum f (m+1) (n::p)) = + ∑ n, leafSum (fun q => ∑ j, f (j::q)) m (n::p) + simp_rw [ih] + +lemma leafSum_sum {E : Type*} [AddCommMonoid E] {ι : Type*} + (s : Finset ι) (f : ι → List Label → E) (m : ℕ) (p : List Label) : + leafSum (fun q => ∑ i ∈ s, f i q) m p = ∑ i ∈ s, leafSum (f i) m p := by + induction m generalizing p with + | zero => rfl + | succ m ih => simp only [leafSum,ih]; exact sum_comm + +/-- The exact head law obtained from the genuine finite-history products. -/ +lemma leafSum_headLaw (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (m : ℕ) (F : Label → ℝ) : + leafSum (fun q => weight h r old x q*F (q.headD old)) m [] = + expect (before h r old x m) F := by + induction m generalizing F with + | zero => simp only [leafSum,weight,List.headD_nil,one_mul,before,expect_delta] + | succ m ih => + rw [leafSum_succ_last,before_move,expect_move] + have he (q : List Label) : + (∑ n, weight h r old x (n::q)*F ((n::q).headD old)) = + weight h r old x q*expect (observation h r q.length x (q.headD old)) F := by + simp only [weight,List.headD_cons,FiniteLabels.expect,mul_assoc,mul_sum] + simp_rw [he] + have hc := leafSum_congr + (fun q => weight h r old x q*expect (observation h r q.length x (q.headD old)) F) + (fun q => weight h r old x q*expect (observation h r m x (q.headD old)) F) m [] + (by + intro q hq + have hqm : q.length = m := by simpa using hq + rw [hqm]) + rw [hc] + exact ih (fun n => FiniteLabels.expect (observation h r m x n) F) + +/-- Additive reward along a reversed history, with its true previous state. -/ +def pathReward (old : Label) (A : ℕ → Label → Label → ℝ) : List Label → ℝ + | [] => 0 + | n::p => pathReward old A p+A p.length (p.headD old) n + +lemma leafSum_pathReward (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (A : ℕ → Label → Label → ℝ) (m : ℕ) : + leafSum (fun q => weight h r old x q*pathReward old A q) m [] = + ∑ k ∈ range m, expect (before h r old x k) + (fun n => expect (observation h r k x n) (A k n)) := by + induction m with + | zero => simp [leafSum,pathReward] + | succ m ih => + rw [leafSum_succ_last,sum_range_succ] + have he (q : List Label) : + (∑ n, weight h r old x (n::q)*pathReward old A (n::q)) = + weight h r old x q*pathReward old A q+ + weight h r old x q*expect (observation h r q.length x (q.headD old)) (A q.length (q.headD old)) := by + simp only [weight,pathReward,mul_add,sum_add_distrib,← sum_mul,← mul_sum,FiniteLabels.expect,mul_assoc] + rw [(observation h r q.length x (q.headD old)).total,one_mul] + simp_rw [he] + rw [leafSum_add,ih] + congr 1 + have hc := leafSum_congr + (fun q => weight h r old x q*expect (observation h r q.length x (q.headD old)) (A q.length (q.headD old))) + (fun q => weight h r old x q*expect (observation h r m x (q.headD old)) (A m (q.headD old))) m [] + (by + intro q hq + have hqm : q.length = m := by simpa using hq + rw [hqm]) + rw [hc] + exact leafSum_headLaw h r old x m (fun n => FiniteLabels.expect (observation h r m x n) (A m n)) + +lemma pathReward_add (old : Label) (A B : ℕ → Label → Label → ℝ) (q : List Label) : + pathReward old (fun k n j => A k n j+B k n j) q = + pathReward old A q+pathReward old B q := by + induction q with + | nil => simp [pathReward] + | cons n p ih => simp only [pathReward,ih]; ring + +lemma pathReward_nonneg (old : Label) (A : ℕ → Label → Label → ℝ) + (hA : ∀ k n j, 0 ≤ A k n j) (q : List Label) : 0 ≤ pathReward old A q := by + induction q with + | nil => exact le_rfl + | cons n p ih => exact add_nonneg ih (hA _ _ _) + +open ActualLabels FiniteLabels Finset + +lemma run_span_sum (H : ℕ → Label → ℝ) (old : Label) (p : List Label) : + ((runs p).map fun a => ∑ k ∈ Icc a.first a.last, H k a.dir).sum = + pathReward old (fun k _ n => H k n) p := by + cases p with + | nil => rfl + | cons n p => + induction p generalizing n with + | nil => simp [runs,closedRuns,activeStart,pathReward] + | cons n' p ih => + by_cases hn : n = n' + · subst n + have hsum : (∑ k ∈ Icc (activeStart (n'::p)) (p.length+1), H k n') = + (∑ k ∈ Icc (activeStart (n'::p)) p.length, H k n')+H (p.length+1) n' := by + exact sum_Icc_succ_top ((activeStart_le n' p).trans (Nat.le_succ _)) _ + have hh := ih n' + simp only [runs,List.map_cons,List.sum_cons] at hh + simp only [runs,closedRuns,activeStart,ite_true,List.length_cons,List.map_cons,List.sum_cons,pathReward] + rw [hsum] + simp only [pathReward] at hh + linarith + · have hh := ih n' + simp only [runs,List.map_cons,List.sum_cons] at hh + simp only [runs,closedRuns,activeStart,hn,ite_false,List.length_cons,List.map_cons,List.sum_cons,pathReward, + Finset.Icc_self,sum_singleton] + simp only [pathReward] at hh + linarith + +def startReward (J : ℕ → ℝ) : ℕ → Label → Label → ℝ + | 0,_,_ => J 0 + | k+1,n,j => if j = n then 0 else J (k+1) + +def boundaryReward (J : ℕ → ℝ) : ℕ → Label → Label → ℝ + | 0,_,_ => J 0 + | k+1,n,j => if j = n then 0 else J k+J (k+1) + +lemma run_start_sum (J : ℕ → ℝ) (old : Label) (p : List Label) : + ((runs p).map fun a => J a.first).sum = pathReward old (startReward J) p := by + cases p with + | nil => rfl + | cons n p => + induction p generalizing n with + | nil => simp [runs,activeStart,closedRuns,pathReward,startReward] + | cons n' p ih => + have hh := ih n' + simp only [runs,List.map_cons,List.sum_cons] at hh + simp only [pathReward,startReward] at hh + by_cases hn : n = n' + · subst n + simpa only [runs,closedRuns,activeStart,ite_true,List.length_cons,List.map_cons,List.sum_cons, + pathReward,startReward,List.headD_cons,add_zero] using hh + · simp only [runs,closedRuns,activeStart,hn,ite_false,List.length_cons,List.map_cons,List.sum_cons, + pathReward,startReward,List.headD_cons] + linarith + +lemma run_boundary_sum (J : ℕ → ℝ) (old n : Label) (p : List Label) : + ((runs (n::p)).map fun a => J a.first+J a.last).sum = + pathReward old (boundaryReward J) (n::p)+J p.length := by + induction p generalizing n with + | nil => simp [runs,activeStart,closedRuns,pathReward,boundaryReward] + | cons n' p ih => + have hh := ih n' + simp only [runs,List.map_cons,List.sum_cons,pathReward,boundaryReward] at hh + by_cases hn : n = n' + · subst n + simp only [runs,closedRuns,activeStart,ite_true,List.length_cons,List.map_cons,List.sum_cons, + pathReward,boundaryReward,List.headD_cons] + linarith + · simp only [runs,closedRuns,activeStart,hn,ite_false,List.length_cons,List.map_cons,List.sum_cons, + pathReward,boundaryReward,List.headD_cons] + linarith + +lemma startReward_nonneg (J : ℕ → ℝ) (hJ : ∀ k, 0 ≤ J k) (k : ℕ) (n j : Label) : + 0 ≤ startReward J k n j := by + cases k with + | zero => exact hJ 0 + | succ k => simp only [startReward]; split_ifs <;> first | exact le_rfl | exact hJ _ + +lemma boundaryReward_nonneg (J : ℕ → ℝ) (hJ : ∀ k, 0 ≤ J k) (k : ℕ) (n j : Label) : + 0 ≤ boundaryReward J k n j := by + cases k with + | zero => exact hJ 0 + | succ k => simp only [boundaryReward]; split_ifs <;> first | exact le_rfl | exact add_nonneg (hJ _) (hJ _) + +end SignedRuns + +namespace ActualLabels +open FiniteLabels DyadicHats Finset + +lemma row_change_le_rate (h : ℂ → ℂ) (r : ℝ) (x : ℂ) (n : Label) : + expect (row h r x n) (fun j => if j = n then 0 else 1) ≤ rate h r x n := by + rw [row,spatialRow_expect] + simp only [ite_true,sub_zero,zero_add] + apply interpolate_mono + intro z + split_ifs <;> simp [switchChance_nonneg] + +lemma observation_startReward_le (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (J : ℕ → ℝ) (hJ : ∀ k, 0 ≤ J k) (k : ℕ) : + expect (before h r old x k) + (fun n => expect (observation h r k x n) (SignedRuns.startReward J k n)) ≤ + switchCost h r x k*J k := by + cases k with + | zero => + change (expect (delta old) fun _ => expect (initial h (r 0) x) (fun _ => J 0)) ≤ 1*J 0 + rw [FiniteLabels.expect_const,FiniteLabels.expect_const,one_mul] + | succ k => + change expect (marginal h r k x) (fun n => expect (row h (r (k+1)) x n) + (fun j => if j = n then 0 else J (k+1))) ≤ _ + have he (n : Label) : (fun j : Label => if j = n then (0:ℝ) else J (k+1)) = + fun j => J (k+1)*(if j = n then 0 else 1) := by funext j; split_ifs <;> simp + simp_rw [he,FiniteLabels.expect_mul] + rw [switchCost,mul_comm _ (J (k+1))] + apply mul_le_mul_of_nonneg_left _ (hJ _) + exact expect_mono _ (fun n => row_change_le_rate h (r (k+1)) x n) + +open FiniteLabels Finset + +def boundaryCost (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (m k : ℕ) : ℝ := + switchCost h r x k+(if k=m then 1 else switchCost h r x (k+1)) + +lemma boundaryCost_nonneg (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (m k : ℕ) : + 0 ≤ boundaryCost h r x m k := by + unfold boundaryCost + apply add_nonneg (switchCost_nonneg h r x k) + split_ifs + · exact zero_le_one + · exact switchCost_nonneg h r x (k+1) + +lemma observation_boundaryReward_le (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (J : ℕ → ℝ) (hJ : ∀ k, 0 ≤ J k) (k : ℕ) : + expect (before h r old x k) + (fun n => expect (observation h r k x n) (SignedRuns.boundaryReward J k n)) ≤ + (match k with | 0 => J 0 | l+1 => switchCost h r x (l+1)*(J l+J (l+1))) := by + cases k with + | zero => + change (expect (delta old) fun _ => expect (initial h (r 0) x) (fun _ => J 0)) ≤ J 0 + rw [FiniteLabels.expect_const,FiniteLabels.expect_const] + | succ k => + change expect (marginal h r k x) (fun n => expect (row h (r (k+1)) x n) + (fun j => if j = n then 0 else J k+J (k+1))) ≤ _ + have he (n : Label) : (fun j : Label => if j = n then (0:ℝ) else J k+J (k+1)) = + fun j => (J k+J (k+1))*(if j = n then 0 else 1) := by funext j; split_ifs <;> simp + simp_rw [he,FiniteLabels.expect_mul] + rw [switchCost,mul_comm _ (J k+J (k+1))] + apply mul_le_mul_of_nonneg_left _ (add_nonneg (hJ _) (hJ _)) + exact expect_mono _ (fun n => row_change_le_rate h (r (k+1)) x n) + +lemma boundary_reward_sum (h : ℂ → ℂ) (r : ℕ → ℝ) (x : ℂ) (J : ℕ → ℝ) (m : ℕ) : + (∑ k ∈ range (m+1), (match k with | 0 => J 0 | l+1 => switchCost h r x (l+1)*(J l+J (l+1))))+J m = + ∑ k ∈ range (m+1), boundaryCost h r x m k*J k := by + induction m with + | zero => simp [boundaryCost,switchCost]; ring + | succ m ih => + conv_lhs => rw [sum_range_succ] + conv_rhs => rw [sum_range_succ] + have he : (∑ k ∈ range (m+1), boundaryCost h r x (m+1) k*J k) = + (∑ k ∈ range (m+1), boundaryCost h r x m k*J k)+ + (switchCost h r x (m+1)-1)*J m := by + conv_lhs => rw [sum_range_succ] + conv_rhs => rw [sum_range_succ] + have hh : (∑ k ∈ range m, boundaryCost h r x (m+1) k*J k) = + ∑ k ∈ range m, boundaryCost h r x m k*J k := by + apply sum_congr rfl + intro k hk + have hk' := mem_range.mp hk + simp only [boundaryCost,ite_eq_right (by omega : k ≠ m+1),ite_eq_right (by omega : k ≠ m)] + rw [hh] + simp only [boundaryCost,ite_eq_right (by omega : m ≠ m+1),ite_true] + ring + rw [he,← ih] + simp only [boundaryCost,ite_true] + ring +end ActualLabels + +namespace SignedRuns +open ActualLabels FiniteLabels Finset + +lemma expected_start_sum_bound (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (J : ℕ → ℝ) (hJ : ∀ k, 0 ≤ J k) (m : ℕ) : + leafSum (fun q => weight h r old x q*((runs q).map fun a => J a.first).sum) (m+1) [] ≤ + ∑ k ∈ range (m+1), switchCost h r x k*J k := by + simp_rw [run_start_sum J old] + rw [leafSum_pathReward] + exact sum_le_sum (fun k _ => observation_startReward_le h r old x J hJ k) + +lemma expected_boundary_sum_bound (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (J : ℕ → ℝ) (hJ : ∀ k, 0 ≤ J k) (m : ℕ) : + leafSum (fun q => weight h r old x q*((runs q).map fun a => J a.first+J a.last).sum) (m+1) [] ≤ + ∑ k ∈ range (m+1), boundaryCost h r x m k*J k := by + have he := leafSum_congr + (fun q => weight h r old x q*((runs q).map fun a => J a.first+J a.last).sum) + (fun q => weight h r old x q*pathReward old (boundaryReward J) q+weight h r old x q*J m) + (m+1) [] (by + intro q hq + cases q with + | nil => simp at hq + | cons n p => + have hp : p.length = m := by simpa using hq + rw [run_boundary_sum J old, hp,mul_add]) + rw [he,leafSum_add,leafSum_pathReward,leafSum_mul_const,leafSum_weight,weight,one_mul] + rw [← boundary_reward_sum] + exact add_le_add (sum_le_sum (fun k _ => observation_boundaryReward_le h r old x J hJ k)) le_rfl + +lemma expected_span_sum (h : ℂ → ℂ) (r : ℕ → ℝ) (old : Label) (x : ℂ) + (H : ℕ → Label → ℝ) (m : ℕ) : + leafSum (fun q => weight h r old x q*((runs q).map fun a => ∑ k ∈ Icc a.first a.last, H k a.dir).sum) (m+1) [] = + ∑ k ∈ range (m+1), expect (marginal h r k x) (H k) := by + simp_rw [run_span_sum H old] + rw [leafSum_pathReward] + apply sum_congr rfl + intro k _ + rw [← expect_move,← before_move] + rfl + +end SignedRuns + +namespace PhysicalCells +open DyadicHats DirectionNeighbors CommonPrices Finset + +def gridIndex (r : ℝ) (y : ℂ) : ℤ × ℤ := (⌊y.re/r⌋,⌊y.im/r⌋) + +lemma toUnit_point_re (r : ℝ) (hr : r ≠ 0) (p : ℤ × ℤ) (y : ℂ) : + (toUnit (point r p) r y).re = y.re/r-p.1 := by + simp only [toUnit,Complex.smul_re,Complex.sub_re,point,smul_eq_mul] + field_simp + +lemma toUnit_point_im (r : ℝ) (hr : r ≠ 0) (p : ℤ × ℤ) (y : ℂ) : + (toUnit (point r p) r y).im = y.im/r-p.2 := by + simp only [toUnit,Complex.smul_im,Complex.sub_im,point,smul_eq_mul] + field_simp + +lemma mem_index_cell {r : ℝ} (hr : 0 < r) (y : ℂ) : + y ∈ cell (point r (gridIndex r y)) r := by + change (toUnit _ r y).re ∈ Set.Ico (0:ℝ) 1 ∧ (toUnit _ r y).im ∈ Set.Ico (0:ℝ) 1 + rw [toUnit_point_re r hr.ne',toUnit_point_im r hr.ne'] + refine ⟨⟨?_,?_⟩,⟨?_,?_⟩⟩ + · exact sub_nonneg.mpr (Int.floor_le _) + · dsimp only [gridIndex]; linarith [Int.lt_floor_add_one (y.re/r)] + · exact sub_nonneg.mpr (Int.floor_le _) + · dsimp only [gridIndex]; linarith [Int.lt_floor_add_one (y.im/r)] + +lemma cells_cover {r : ℝ} (hr : 0 < r) : (⋃ p : ℤ × ℤ, cell (point r p) r) = Set.univ := by + apply Set.eq_univ_of_forall + intro y + exact Set.mem_iUnion.mpr ⟨gridIndex r y,mem_index_cell hr y⟩ + +lemma mem_cell_box {r : ℝ} (hr : 0 < r) {p : ℤ × ℤ} {y : ℂ} + (hy : y ∈ cell (point r p) r) : boxNorm (y-point r p) ≤ r := by + change (toUnit _ r y).re ∈ Set.Ico (0:ℝ) 1 ∧ (toUnit _ r y).im ∈ Set.Ico (0:ℝ) 1 at hy + rw [toUnit_point_re r hr.ne',toUnit_point_im r hr.ne'] at hy + have h (a : ℝ) (b : ℤ) (hab : a/r-b ∈ Set.Ico (0:ℝ) 1) : |a-r*b| ≤ r := by + have hl : (b:ℝ) ≤ a/r := by linarith [hab.1] + have hu : a/r < (b:ℝ)+1 := by linarith [hab.2] + have hl' := (le_div_iff₀ hr).mp hl + have hu' := (div_lt_iff₀ hr).mp hu + apply abs_le.mpr + constructor <;> nlinarith + exact max_le (h y.re p.1 hy.1) (h y.im p.2 hy.2) + +lemma cell_subset_root_neighborhood {N : ℕ} {r : ℝ} (hr : 0 < r) + (p : ℤ × ℤ) (q : Grid N) (hq : q ∈ cellRoots N p) : + cell (point r p) r ⊆ neighborhood r q := by + intro y hy + have hqp : boxNorm (point r p-point r q) ≤ 20*r := by + rw [boxNorm_sub_comm] + exact (mem_window_iff hr 20 p q).mp (mem_filter.mp hq).2 + have hb := boxNorm_add_le (y-point r p) (point r p-point r q) + rw [sub_add_sub_cancel] at hb + have hc := mem_cell_box hr hy + change boxNorm (y-point r q) ≤ 25*r + linarith + +lemma lintegral_le_cells {r : ℝ} (hr : 0 < r) (F : ℂ → ℝ≥0∞) : + (∫⁻ y, F y) ≤ ∑' p : ℤ × ℤ, ∫⁻ y in cell (point r p) r, F y := by + have h := lintegral_iUnion_le (μ := (volume : Measure ℂ)) (fun p : ℤ × ℤ => cell (point r p) r) F + simpa only [cells_cover hr,Measure.restrict_univ] using h + +lemma tsum_ofReal_le {ι : Type*} (B : ι → ℝ) (hB : ∀ i, 0 ≤ B i) (A : ℝ) + (hbudget : ∀ s : Finset ι, ∑ i ∈ s, B i ≤ A) : + (∑' i, ENNReal.ofReal (B i)) ≤ ENNReal.ofReal A := by + rw [ENNReal.tsum_eq_iSup_sum] + apply iSup_le + intro s + rw [← ENNReal.ofReal_sum_of_nonneg (fun i _ => hB i)] + exact ENNReal.ofReal_le_ofReal (hbudget s) + +/-- Global integration over the actual full lattice. The budget is tested on +arbitrary finite sets, so neither support cutoffs nor omitted cells enter. -/ +lemma integral_cell_budget {r : ℝ} (hr : 0 < r) (F : ℂ → ℝ≥0∞) + (B : (ℤ × ℤ) → ℝ) (hB : ∀ p, 0 ≤ B p) (A : ℝ) + (hcell : ∀ p, (∫⁻ y in cell (point r p) r, F y) ≤ ENNReal.ofReal (B p)) + (hbudget : ∀ s : Finset (ℤ × ℤ), ∑ p ∈ s, B p ≤ A) : + (∫⁻ y, F y) ≤ ENNReal.ofReal A := + (lintegral_le_cells hr F).trans ((ENNReal.tsum_le_tsum hcell).trans (tsum_ofReal_le B hB A hbudget)) + +end PhysicalCells + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SignedDisk/VectorRefinement1.lean b/lean/OAI/Analysis/SignedDisk/VectorRefinement1.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c762ded0de06ebe539573cd88da937b76d3c634 --- /dev/null +++ b/lean/OAI/Analysis/SignedDisk/VectorRefinement1.lean @@ -0,0 +1,484 @@ +import OAI.Analysis.SignedDisk.PlanePotential1 + +namespace OAI + +open MeasureTheory Set +open scoped ENNReal NNReal Topology ContDiff +open scoped RealInnerProductSpace +open MeasureTheory Set Filter +open scoped Topology ENNReal +open scoped Real RealInnerProductSpace +open scoped Topology RealInnerProductSpace ContDiff +open scoped Topology Interval NNReal +open scoped Topology NNReal Real +open MeasureTheory Set Metric +open scoped ENNReal NNReal Topology +open scoped ENNReal NNReal +open Finset + +noncomputable section + +namespace SignedDisk + +open MeasureTheory Set +open scoped ENNReal NNReal RealInnerProductSpace + +namespace VectorRefinement + +/-- Exact quadratic defect of a positive vector refinement, including zero parent mass. -/ +theorem quadratic_defect {ι E : Type*} [Fintype ι] + [NormedAddCommGroup E] [InnerProductSpace ℝ E] + (w a : ι → ℝ) (θ : ι → E) (n : E) (A : ℝ) + (hn : ‖n‖ = 1) (hθ : ∀ i, ‖θ i‖ = 1) + (href : A • n = ∑ i, (w i*a i) • θ i) : + (∑ i, w i*a i)-A = (1/2:ℝ)*∑ i, w i*a i*‖θ i-n‖^2 := by + have hinner : A = ∑ i, w i*a i*⟪θ i,n⟫ := by + have h := congrArg (fun v : E => ⟪v,n⟫) href + simpa only [real_inner_smul_left,sum_inner,real_inner_self_eq_norm_sq,hn,one_pow,mul_one] using h + rw [hinner,← Finset.sum_sub_distrib,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + rw [norm_sub_sq_real,hθ i,hn] + ring + +lemma sq_norm_triangle {E : Type*} [SeminormedAddCommGroup E] (x y z : E) : + ‖x-z‖^2 ≤ 2*(‖x-y‖^2+‖z-y‖^2) := by + have h := norm_sub_le_norm_sub_add_norm_sub x y z + rw [norm_sub_rev y z] at h + have hsq := (sq_le_sq₀ (norm_nonneg _) (by positivity)).mpr h + nlinarith [sq_nonneg (‖x-y‖-‖z-y‖)] + +/-- Two sufficiently represented children cannot have a large angular disagreement +without spending the actual parent's triangle defect. -/ +theorem pair_defect_bound {ι E : Type*} [Fintype ι] [DecidableEq ι] + [NormedAddCommGroup E] [InnerProductSpace ℝ E] + (w a : ι → ℝ) (θ : ι → E) (n : E) (A : ℝ) + (hw : ∀ i, 0 ≤ w i) (ha : ∀ i, 0 ≤ a i) + (hn : ‖n‖ = 1) (hθ : ∀ i, ‖θ i‖ = 1) + (href : A • n = ∑ i, (w i*a i) • θ i) + {q s : ι} (hwaq : 1/4 ≤ w q) (hwas : 9/64 ≤ w s) (has : a q ≤ a s) : + a q*‖θ q-θ s‖^2 ≤ 48*((∑ i, w i*a i)-A) := by + let D := (∑ i, w i*a i)-A + have hD := quadratic_defect w a θ n A hn hθ href + have hi (i : ι) : w i*a i*‖θ i-n‖^2 ≤ 2*D := by + have hs : w i*a i*‖θ i-n‖^2 ≤ ∑ j, w j*a j*‖θ j-n‖^2 := + Finset.single_le_sum (fun j _ => mul_nonneg (mul_nonneg (hw j) (ha j)) (sq_nonneg ‖θ j-n‖)) (Finset.mem_univ i) + dsimp [D] + linarith + have hD0 : 0 ≤ D := by + have hs : 0 ≤ ∑ i, w i*a i*‖θ i-n‖^2 := Finset.sum_nonneg fun i _ => + mul_nonneg (mul_nonneg (hw i) (ha i)) (sq_nonneg _) + dsimp [D]; linarith + have hq : a q*‖θ q-n‖^2 ≤ 8*D := by + have hm := mul_le_mul_of_nonneg_right hwaq (mul_nonneg (ha q) (sq_nonneg ‖θ q-n‖)) + nlinarith [hi q] + have hs : a q*‖θ s-n‖^2 ≤ (128/9:ℝ)*D := by + have hm := mul_le_mul_of_nonneg_right hwas (mul_nonneg (ha s) (sq_nonneg ‖θ s-n‖)) + have hmas := mul_le_mul_of_nonneg_right has (sq_nonneg ‖θ s-n‖) + nlinarith [hi s] + have ht := mul_le_mul_of_nonneg_left (sq_norm_triangle (θ q) n (θ s)) (ha q) + change _ ≤ 48*D + nlinarith + +end VectorRefinement + +open MeasureTheory Set +open scoped ENNReal NNReal Topology + +namespace PlanePotential + +lemma integral_affine (F : ℂ → ℝ) (x : ℂ) (t : ℝ) : + (∫ z : ℂ, F (x+t • (z-x))) = (t^2)⁻¹ * ∫ y : ℂ, F y := by + calc + _ = ∫ w : ℂ, F (x+t • w) := by + simpa only [sub_eq_add_neg] using + integral_add_right_eq_self (fun w : ℂ => F (x+t • w)) (-x) + _ = |(t^2)⁻¹| * ∫ y, F (x+y) := by + simpa only [Complex.finrank_real_complex,smul_eq_mul] using + Measure.integral_comp_smul volume (fun y : ℂ => F (x+y)) t + _ = _ := by rw [abs_of_nonneg (inv_nonneg.mpr (sq_nonneg t)),integral_add_left_eq_self] + +lemma integrable_affine_iff (F : ℂ → ℝ) (x : ℂ) {t : ℝ} (ht : t ≠ 0) : + Integrable (fun z : ℂ => F (x+t • (z-x))) ↔ Integrable F := by + constructor + · intro h + have h1 : Integrable (fun z : ℂ => F (x+t • z)) := by + simpa only [add_sub_cancel_right] using h.comp_add_right x + have h2 := (integrable_comp_smul_iff volume (fun z : ℂ => F (x+z)) ht).mp h1 + simpa only [add_neg_cancel_left] using h2.comp_add_left (-x) + · intro h + simpa only [sub_eq_add_neg] using ((h.comp_add_left x).comp_smul ht).comp_add_right (-x) + +lemma integral_affine_reverse (F : ℂ → ℝ) (x : ℂ) {t : ℝ} (ht : t ≠ 0) : + (∫ y : ℂ, F y) = t^2 * ∫ z : ℂ, F (x+t • (z-x)) := by + rw [integral_affine] + field_simp + +lemma segment_ftc {g : ℂ → ℝ} (hg : ContDiff ℝ 1 g) (x z : ℂ) : + (∫ t in Ioc (0:ℝ) 1, fderiv ℝ g (x+t • (z-x)) (z-x)) = g z-g x := by + have hd (t : ℝ) : HasDerivAt (fun s : ℝ => g (x+s • (z-x))) + (fderiv ℝ g (x+t • (z-x)) (z-x)) t := by + have hline : HasDerivAt (fun s : ℝ => x+s • (z-x)) (z-x) t := by + simpa only [one_smul,id_eq] using ((hasDerivAt_id t).smul_const (z-x)).const_add x + exact ((hg.differentiable (by norm_num) _).hasFDerivAt).comp_hasDerivAt t hline + have hc : Continuous (fun t : ℝ => fderiv ℝ g (x+t • (z-x)) (z-x)) := by + exact ((hg.continuous_fderiv (by norm_num)).comp (by fun_prop)).clm_apply continuous_const + simpa only [intervalIntegral.integral_of_le (by norm_num : (0:ℝ) ≤ 1),one_smul, + add_sub_cancel,zero_smul,add_zero] using + intervalIntegral.integral_eq_sub_of_hasDerivAt (fun t _ => hd t) (hc.intervalIntegrable 0 1) + +def segmentForm (ψ g : ℂ → ℝ) (x : ℂ) (t : ℝ) (z : ℂ) : ℝ := + ψ z*fderiv ℝ g (x+t • (z-x)) (z-x) +def pullbackForm (ψ g : ℂ → ℝ) (x : ℂ) (t : ℝ) (y : ℂ) : ℝ := + ψ (x+t⁻¹ • (y-x))*t^(-3:ℝ)*fderiv ℝ g y (y-x) + +lemma pullback_identity (ψ g : ℂ → ℝ) (x z : ℂ) {t : ℝ} (ht : 0 < t) : + pullbackForm ψ g x t (x+t • (z-x)) = (t^2)⁻¹*segmentForm ψ g x t z := by + have ha : x+t⁻¹ • (x+t • (z-x)-x) = z := by simp [ht.ne'] + unfold pullbackForm segmentForm + rw [ha,add_sub_cancel_left,map_smul,smul_eq_mul] + have hp : t^(-3:ℝ) = (t^3)⁻¹ := by + rw [show (-3:ℝ) = ((-3:ℤ):ℝ) by norm_num,Real.rpow_intCast,zpow_neg,zpow_ofNat] + rw [hp] + field_simp + +lemma segmentForm_continuous {ψ g : ℂ → ℝ} (hψ : Continuous ψ) (hg : ContDiff ℝ 1 g) (x : ℂ) : + Continuous (fun p : ℝ × ℂ => segmentForm ψ g x p.1 p.2) := by + unfold segmentForm + exact (hψ.comp continuous_snd).mul + (((hg.continuous_fderiv (by norm_num)).comp (by fun_prop)).clm_apply (by fun_prop)) + +lemma segmentForm_integrable_column {ψ g : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (hg : ContDiff ℝ 1 g) (x : ℂ) (t : ℝ) : + Integrable (segmentForm ψ g x t) := by + apply ((segmentForm_continuous hψ hg x).comp (continuous_const.prodMk continuous_id)).integrable_of_hasCompactSupport + exact hψc.mul_right + +lemma pullbackForm_measurable {ψ g : ℂ → ℝ} (hψ : Continuous ψ) (hg : ContDiff ℝ 1 g) (x : ℂ) : + Measurable (fun p : ℝ × ℂ => pullbackForm ψ g x p.1 p.2) := by + unfold pullbackForm + have ha : Measurable (fun p : ℝ × ℂ => x+p.1⁻¹ • (p.2-x)) := by measurability + exact ((hψ.measurable.comp ha).mul (measurable_fst.pow_const _)).mul + ((((hg.continuous_fderiv (by norm_num)).comp continuous_snd).clm_apply (by fun_prop)).measurable) + +lemma pullbackForm_integrable_column {ψ g : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (hg : ContDiff ℝ 1 g) (x : ℂ) {t : ℝ} (ht : 0 < t) : + Integrable (pullbackForm ψ g x t) := by + apply (integrable_affine_iff _ x ht.ne').mp + simpa only [pullback_identity ψ g x _ ht] using + (segmentForm_integrable_column hψ hψc hg x t).const_mul ((t^2)⁻¹) + +lemma pullback_column_integral (ψ g : ℂ → ℝ) (x : ℂ) {t : ℝ} (ht : 0 < t) : + (∫ y, pullbackForm ψ g x t y) = ∫ z, segmentForm ψ g x t z := by + rw [integral_affine_reverse _ x ht.ne'] + simp_rw [pullback_identity ψ g x _ ht] + rw [integral_const_mul] + field_simp + +lemma pullback_column_norm (ψ g : ℂ → ℝ) (x : ℂ) {t : ℝ} (ht : 0 < t) : + (∫ y, ‖pullbackForm ψ g x t y‖) = ∫ z, ‖segmentForm ψ g x t z‖ := by + rw [integral_affine_reverse _ x ht.ne'] + simp_rw [pullback_identity ψ g x _ ht,norm_mul,Real.norm_eq_abs, + abs_of_nonneg (inv_nonneg.mpr (sq_nonneg t))] + rw [integral_const_mul] + field_simp + +lemma segmentForm_bound {ψ g : ℂ → ℝ} {D : ℝ} (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) + (x : ℂ) (t : ℝ) (z : ℂ) : + ‖segmentForm ψ g x t z‖ ≤ |ψ z| *D*‖z-x‖ := by + rw [segmentForm,norm_mul,Real.norm_eq_abs] + calc + _ ≤ |ψ z| *(‖fderiv ℝ g (x+t • (z-x))‖*‖z-x‖) := + mul_le_mul_of_nonneg_left ((fderiv ℝ g _).le_opNorm _) (abs_nonneg _) + _ ≤ |ψ z| *(D*‖z-x‖) := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right (hD _) (norm_nonneg _)) (abs_nonneg _) + _ = _ := by ring + +lemma segment_weight_integrable {ψ : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (x : ℂ) (D : ℝ) : + Integrable (fun z : ℂ => |ψ z| *D*‖z-x‖) := by + apply (show Continuous (fun z : ℂ => |ψ z| *D*‖z-x‖) by fun_prop).integrable_of_hasCompactSupport + exact (hψc.norm.mul_right).mul_right + +/-- Absolute integrability justifies the double integral even at t approaching zero. -/ +theorem pullbackForm_integrable {ψ g : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (x : ℂ) : + Integrable (fun p : ℝ × ℂ => pullbackForm ψ g x p.1 p.2) + ((volume.restrict (Ioc (0:ℝ) 1)).prod volume) := by + have hm := (pullbackForm_measurable hψ hg x).stronglyMeasurable + rw [integrable_prod_iff hm.aestronglyMeasurable] + constructor + · filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht + exact pullbackForm_integrable_column hψ hψc hg x ht.1 + · have hweight := segment_weight_integrable hψ hψc x D + let C := ∫ z : ℂ, |ψ z| *D*‖z-x‖ + apply (integrable_const C).mono' hm.norm.integral_prod_right'.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht + rw [pullback_column_norm ψ g x ht.1,Real.norm_eq_abs,abs_of_nonneg (integral_nonneg (fun _ => norm_nonneg _))] + exact integral_mono (segmentForm_integrable_column hψ hψc hg x t).norm hweight + (segmentForm_bound hD x t) + +lemma segmentForm_integrable {ψ g : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (x : ℂ) : + Integrable (fun p : ℝ × ℂ => segmentForm ψ g x p.1 p.2) + ((volume.restrict (Ioc (0:ℝ) 1)).prod volume) := by + have hm := (segmentForm_continuous hψ hg x).stronglyMeasurable + rw [integrable_prod_iff hm.aestronglyMeasurable] + constructor + · exact ae_of_all _ (fun t => segmentForm_integrable_column hψ hψc hg x t) + · have hweight := segment_weight_integrable hψ hψc x D + let C := ∫ z : ℂ, |ψ z| * D*‖z-x‖ + apply (integrable_const C).mono' hm.norm.integral_prod_right'.aestronglyMeasurable + filter_upwards with t + rw [Real.norm_eq_abs,abs_of_nonneg (integral_nonneg (fun _ => norm_nonneg _))] + exact integral_mono (segmentForm_integrable_column hψ hψc hg x t).norm hweight + (segmentForm_bound hD x t) + +lemma green_pullback (ψ g : ℂ → ℝ) (x y : ℂ) : + fderiv ℝ g y (green ψ x y) = -∫ t in Ioc (0:ℝ) 1, pullbackForm ψ g x t y := by + simp only [green,map_smul,smul_eq_mul,greenScalar,pullbackForm,integral_mul_const,neg_mul] + +/-- The true segment-kernel representation, with Fubini justified absolutely. -/ +theorem green_representation {ψ g : ℂ → ℝ} (hψ : Continuous ψ) + (hψc : HasCompactSupport ψ) (hg : ContDiff ℝ 1 g) {D : ℝ} + (hD : ∀ y, ‖fderiv ℝ g y‖ ≤ D) (hψ1 : ∫ z, ψ z = 1) (x : ℂ) : + (∫ y, fderiv ℝ g y (green ψ x y)) = g x-∫ z, ψ z*g z := by + have hseg := segmentForm_integrable hψ hψc hg hD x + have hpull := pullbackForm_integrable hψ hψc hg hD x + have hψi : Integrable ψ := hψ.integrable_of_hasCompactSupport hψc + have hψgi : Integrable (fun z => ψ z*g z) := + (hψ.mul hg.continuous).integrable_of_hasCompactSupport hψc.mul_right + calc + _ = -(∫ y, ∫ t in Ioc (0:ℝ) 1, pullbackForm ψ g x t y) := by + simp_rw [green_pullback]; rw [integral_neg] + _ = -(∫ t in Ioc (0:ℝ) 1, ∫ y, pullbackForm ψ g x t y) := by + rw [← integral_integral_swap hpull] + _ = -(∫ t in Ioc (0:ℝ) 1, ∫ z, segmentForm ψ g x t z) := by + congr 1 + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht + exact pullback_column_integral ψ g x ht.1 + _ = -(∫ z, ∫ t in Ioc (0:ℝ) 1, segmentForm ψ g x t z) := by + rw [integral_integral_swap hseg] + _ = -(∫ z, ψ z*(g z-g x)) := by + simp_rw [segmentForm,integral_const_mul,segment_ftc hg] + _ = _ := by + simp_rw [mul_sub] + rw [integral_sub hψgi (hψi.mul_const _),integral_mul_const,hψ1] + ring + +end PlanePotential + +open MeasureTheory Set Metric +open scoped ENNReal NNReal RealInnerProductSpace + +namespace PlanePotential +lemma lintegral_norm_rpow_near {a r : ℝ} (ha : -2 < a) (hr : 0 < r) : + (∫⁻ x in ball (0:ℂ) r, ENNReal.ofReal (‖x‖^a)) = + ENNReal.ofReal (2*Real.pi*(r^(a+2)/(a+2))) := by + rw [← ofReal_integral_eq_lintegral_ofReal (integrable_norm_rpow_near ha hr) + (ae_of_all _ (fun x => Real.rpow_nonneg (norm_nonneg x) a)),integral_norm_rpow_near ha hr] + +lemma lintegral_norm_rpow_far {a r : ℝ} (ha : a < -2) (hr : 0 < r) : + (∫⁻ x : ℂ in {x | r < ‖x‖}, ENNReal.ofReal (‖x‖^a)) = + ENNReal.ofReal (2*Real.pi*(-r^(a+2)/(a+2))) := by + rw [← ofReal_integral_eq_lintegral_ofReal (integrable_norm_rpow_far ha hr) + (ae_of_all _ (fun x => Real.rpow_nonneg (norm_nonneg x) a)),integral_norm_rpow_far ha hr] + +lemma lintegral_translated_near {a r : ℝ} (ha : -2 < a) (hr : 0 < r) (y : ℂ) : + (∫⁻ x in ball y r, ENNReal.ofReal (‖x-y‖^a)) = + ENNReal.ofReal (2*Real.pi*(r^(a+2)/(a+2))) := by + rw [← lintegral_norm_rpow_near ha hr,← lintegral_indicator measurableSet_ball, + ← lintegral_indicator measurableSet_ball] + have heq : (ball y r).indicator (fun x => ENNReal.ofReal (‖x-y‖^a)) = + fun x => (ball (0:ℂ) r).indicator (fun w => ENNReal.ofReal (‖w‖^a)) (x-y) := by + funext x + simp only [indicator,mem_ball,dist_eq_norm,sub_zero] + rw [heq] + exact lintegral_add_right_eq_self (fun x : ℂ => (ball 0 r).indicator + (fun w => ENNReal.ofReal (‖w‖^a)) x) (-y) + +lemma lintegral_translated_far {a r : ℝ} (ha : a < -2) (hr : 0 < r) (y : ℂ) : + (∫⁻ x : ℂ in {x | r < ‖x-y‖}, ENNReal.ofReal (‖x-y‖^a)) = + ENNReal.ofReal (2*Real.pi*(-r^(a+2)/(a+2))) := by + rw [← lintegral_norm_rpow_far ha hr, + ← lintegral_indicator (show MeasurableSet {x : ℂ | r < ‖x-y‖} from measurableSet_lt measurable_const (by fun_prop)), + ← lintegral_indicator (measurableSet_lt measurable_const measurable_norm)] + exact lintegral_add_right_eq_self (fun x : ℂ => ({x | r < ‖x‖}).indicator + (fun w => ENNReal.ofReal (‖w‖^a)) x) (-y) + +lemma norm_power_bound {F : ℂ → ℂ} {C q : ℝ} (hC : 0 ≤ C) (x y : ℂ) + (hF : ‖F x‖ ≤ C*‖x-y‖^q) : + (ENNReal.ofReal ‖F x‖)^(3/2:ℝ) ≤ + ENNReal.ofReal (C^(3/2:ℝ))*ENNReal.ofReal (‖x-y‖^(q*(3/2:ℝ))) := by + calc + _ = ENNReal.ofReal (‖F x‖^(3/2:ℝ)) := + ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) (by norm_num) + _ ≤ ENNReal.ofReal ((C*‖x-y‖^q)^(3/2:ℝ)) := + ENNReal.ofReal_le_ofReal (Real.rpow_le_rpow (norm_nonneg _) hF (by norm_num)) + _ = _ := by + rw [Real.mul_rpow hC (Real.rpow_nonneg (norm_nonneg _) _),← Real.rpow_mul (norm_nonneg _), + ENNReal.ofReal_mul (Real.rpow_nonneg hC _)] + +lemma kernel_near_three_halves {F : ℂ → ℂ} {E : Set ℂ} {C r : ℝ} (hC : 0 ≤ C) + (hr : 0 < r) (y : ℂ) (hE : E ⊆ ball y r) + (hF : ∀ x ∈ E, ‖F x‖ ≤ C*‖x-y‖^(-1:ℝ)) : + (∫⁻ x in E, (ENNReal.ofReal ‖F x‖)^(3/2:ℝ)) ≤ + ENNReal.ofReal (C^(3/2:ℝ)*(4*Real.pi*r^(1/2:ℝ))) := by + calc + _ ≤ ∫⁻ x in E, ENNReal.ofReal (C^(3/2:ℝ))*ENNReal.ofReal (‖x-y‖^(-3/2:ℝ)) := by + apply setLIntegral_mono (by fun_prop) + intro x hx + convert norm_power_bound hC x y (hF x hx) using 1 + norm_num + _ ≤ ∫⁻ x in ball y r, ENNReal.ofReal (C^(3/2:ℝ))*ENNReal.ofReal (‖x-y‖^(-3/2:ℝ)) := + lintegral_mono_set hE + _ = _ := by + rw [lintegral_const_mul _ (by fun_prop),lintegral_translated_near (by norm_num : (-2:ℝ) < -3/2) hr y, + ← ENNReal.ofReal_mul (Real.rpow_nonneg hC _)] + congr 1 + norm_num + exact Or.inl (by ring) + +lemma kernel_far_three_halves {F : ℂ → ℂ} {E : Set ℂ} {C r : ℝ} (hC : 0 ≤ C) + (hr : 0 < r) (y : ℂ) (hE : E ⊆ {x | r < ‖x-y‖}) + (hF : ∀ x ∈ E, ‖F x‖ ≤ C*‖x-y‖^(-2:ℝ)) : + (∫⁻ x in E, (ENNReal.ofReal ‖F x‖)^(3/2:ℝ)) ≤ + ENNReal.ofReal (C^(3/2:ℝ)*(2*Real.pi/r)) := by + calc + _ ≤ ∫⁻ x in E, ENNReal.ofReal (C^(3/2:ℝ))*ENNReal.ofReal (‖x-y‖^(-3:ℝ)) := by + apply setLIntegral_mono (by fun_prop) + intro x hx + convert norm_power_bound hC x y (hF x hx) using 1 + norm_num + _ ≤ ∫⁻ x : ℂ in {x | r < ‖x-y‖}, ENNReal.ofReal (C^(3/2:ℝ))*ENNReal.ofReal (‖x-y‖^(-3:ℝ)) := + lintegral_mono_set hE + _ = _ := by + rw [lintegral_const_mul _ (by fun_prop),lintegral_translated_far (by norm_num : (-3:ℝ) < -2) hr y, + ← ENNReal.ofReal_mul (Real.rpow_nonneg hC _)] + congr 1 + norm_num [Real.rpow_neg_one] + exact Or.inl (by ring) + +end PlanePotential + +open scoped RealInnerProductSpace +namespace PlanePotential + +lemma green_diagonal (ψ : ℂ → ℝ) (x : ℂ) : green ψ x x = 0 := by + simp [green] + +lemma green_size_all {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) {x y : ℂ} (hx : ‖x‖ ≤ X) : + ‖green ψ x y‖ ≤ (2*B*(R+X)^2)*‖x-y‖^(-1:ℝ) := by + by_cases hxy : y = x + · subst y + simp [green_diagonal] + · simpa only [Real.rpow_neg_one,div_eq_mul_inv,norm_sub_rev] using + green_norm_bound hψm hψs hψB hM hB hx hxy + +lemma green_near_column {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B a : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hM : 0 < R+X) (hB : 0 ≤ B) (ha : 0 < a) (z y : ℂ) (hy : ‖y-z‖ ≤ a) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X ∧ ‖x-z‖ ≤ 2*a}, + (ENNReal.ofReal ‖green ψ x y‖)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(4*a)^(1/2:ℝ))) := by + apply kernel_near_three_halves (by positivity) (by positivity : 0 < 4*a) y + · intro x hx + rw [mem_ball,dist_eq_norm] + have ht := norm_sub_le (x-z) (y-z) + rw [sub_sub_sub_cancel_right] at ht + linarith [hx.2] + · intro x hx + exact green_size_all hψm hψs hψB hM hB hx.1 + +lemma green_far_column {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B L a : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hψL : ∀ u v, |ψ u-ψ v| ≤ L*‖u-v‖) + (hM : 0 < R+X) (hB : 0 ≤ B) (hL : 0 ≤ L) (ha : 0 < a) + (z y : ℂ) (hy : ‖y-z‖ ≤ a) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X ∧ 2*a < ‖x-z‖}, + (ENNReal.ofReal ‖green ψ x y-green ψ x z‖)^(3/2:ℝ)) ≤ + ENNReal.ofReal (((8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)*a)^(3/2:ℝ) * + (2*Real.pi/(2*a))) := by + apply kernel_far_three_halves (by positivity) (by positivity : 0 < 2*a) z + · exact fun _ hx => hx.2 + · intro x hx + have hzx : z ≠ x := by + intro h + have hh := hx.2 + rw [← h,sub_self,norm_zero] at hh + linarith + have hn : ‖z-x‖ = ‖x-z‖ := norm_sub_rev z x + have h := green_difference_bound (x := x) (y := y) (z := z) hψm hψs hψB hψL hM hB hL hx.1 hzx (by + rw [hn] + linarith [hx.2]) + rw [hn] at h + calc + _ ≤ (8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)*a/‖x-z‖^2 := + h.trans (div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hy (by positivity)) (sq_nonneg _)) + _ = _ := by + rw [show ‖x-z‖^(-2:ℝ) = ‖x-z‖^(-2:ℤ) by norm_num [Real.rpow_intCast],zpow_neg,zpow_ofNat] + rfl + +/-- The center is subtracted only off the near region, so this measurable +kernel retains integrability at the center and realizes zero-mass cancellation. -/ +def cancelledGreen (ψ : ℂ → ℝ) (z : ℂ) (a : ℝ) (x y : ℂ) : ℂ := + if ‖x-z‖ ≤ 2*a then green ψ x y else green ψ x y-green ψ x z + +lemma cancelledGreen_measurable {ψ : ℂ → ℝ} (hψ : Measurable ψ) (z : ℂ) (a : ℝ) : + Measurable (fun p : ℂ × ℂ => cancelledGreen ψ z a p.1 p.2) := by + apply Measurable.ite + · exact measurableSet_le (by fun_prop) measurable_const + · exact green_measurable ψ hψ + · exact (green_measurable ψ hψ).sub + ((green_measurable ψ hψ).comp (measurable_fst.prodMk measurable_const)) + +lemma green_piece_column {ψ : ℂ → ℝ} (hψm : Measurable ψ) {R X B L a : ℝ} + (hψs : ∀ z, ψ z ≠ 0 → ‖z‖ ≤ R) (hψB : ∀ z, |ψ z| ≤ B) + (hψL : ∀ u v, |ψ u-ψ v| ≤ L*‖u-v‖) + (hM : 0 < R+X) (hB : 0 ≤ B) (hL : 0 ≤ L) (ha : 0 < a) + (z y : ℂ) (hy : ‖y-z‖ ≤ a) : + (∫⁻ x in {x : ℂ | ‖x‖ ≤ X}, + (ENNReal.ofReal ‖cancelledGreen ψ z a x y‖)^(3/2:ℝ)) ≤ + ENNReal.ofReal ((2*B*(R+X)^2)^(3/2:ℝ)*(4*Real.pi*(4*a)^(1/2:ℝ))) + + ENNReal.ofReal (((8*B*(R+X)^2+(64/3:ℝ)*L*(R+X)^3)*a)^(3/2:ℝ) * + (2*Real.pi/(2*a))) := by + let E := {x : ℂ | ‖x‖ ≤ X} + let N := {x : ℂ | ‖x-z‖ ≤ 2*a} + have hN : MeasurableSet N := measurableSet_le (by fun_prop) measurable_const + have hE : MeasurableSet E := measurableSet_le measurable_norm measurable_const + have hsplit := lintegral_add_compl (μ := volume.restrict E) + (fun x => (ENNReal.ofReal ‖cancelledGreen ψ z a x y‖)^(3/2:ℝ)) hN + rw [← hsplit] + have hn : (∫⁻ x in N, (ENNReal.ofReal ‖cancelledGreen ψ z a x y‖)^(3/2:ℝ) ∂volume.restrict E) = + ∫⁻ x in {x : ℂ | ‖x‖ ≤ X ∧ ‖x-z‖ ≤ 2*a}, (ENNReal.ofReal ‖green ψ x y‖)^(3/2:ℝ) := by + rw [Measure.restrict_restrict hN,inter_comm] + apply setLIntegral_congr_fun (hE.inter hN) + intro x hx + have hxN : ‖x-z‖ ≤ 2*a := hx.2 + simp only [cancelledGreen,ite_eq_left hxN] + have hf : (∫⁻ x in Nᶜ, (ENNReal.ofReal ‖cancelledGreen ψ z a x y‖)^(3/2:ℝ) ∂volume.restrict E) = + ∫⁻ x in {x : ℂ | ‖x‖ ≤ X ∧ 2*a < ‖x-z‖}, (ENNReal.ofReal ‖green ψ x y-green ψ x z‖)^(3/2:ℝ) := by + rw [Measure.restrict_restrict hN.compl,inter_comm] + have he : E ∩ Nᶜ = {x : ℂ | ‖x‖ ≤ X ∧ 2*a < ‖x-z‖} := by ext x; simp [E,N] + rw [he] + apply setLIntegral_congr_fun ((measurableSet_le measurable_norm measurable_const).inter + (measurableSet_lt measurable_const ((measurable_id.sub_const z).norm))) + intro x hx + have hxF : 2*a < ‖x-z‖ := hx.2 + simp only [cancelledGreen,ite_eq_right (not_le.mpr hxF)] + rw [hn,hf] + exact add_le_add (green_near_column hψm hψs hψB hM hB ha z y hy) + (green_far_column hψm hψs hψB hψL hM hB hL ha z y hy) + +end PlanePotential + +end SignedDisk + +end + +end OAI diff --git a/lean/OAI/Analysis/SolenoidalShears/Affine.lean b/lean/OAI/Analysis/SolenoidalShears/Affine.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b01c9f2bfface2c44e46ba1303829e9f27da7bc --- /dev/null +++ b/lean/OAI/Analysis/SolenoidalShears/Affine.lean @@ -0,0 +1,144 @@ +import Mathlib + +namespace OAI + +/-! Four affine shears, intermediate excursion bounds and endpoint identities. -/ + +namespace Solenoidal +namespace Shear +abbrev Plane := ℝ × ℝ + +def X (a : ℝ) (p : Plane) : Plane := (p.1 + a * p.2, p.2) +def Y (a : ℝ) (p : Plane) : Plane := (p.1, p.2 + a * p.1) + + +noncomputable def endpoint (lam : ℝ) (p : Plane) : Fin 5 → Plane := + ![p, Y (-lam) p, X (lam⁻¹ - 1) (Y (-lam) p), + Y 1 (X (lam⁻¹ - 1) (Y (-lam) p)), + X (lam - 1) (Y 1 (X (lam⁻¹ - 1) (Y (-lam) p)))] + + +noncomputable def partialStage (lam : ℝ) (j : Fin 4) (θ : ℝ) (p : Plane) : Plane := + let q := endpoint lam p j.castSucc + match j with + | 0 => Y (θ * (-lam)) q + | 1 => X (θ * (lam⁻¹ - 1)) q + | 2 => Y θ q + | 3 => X (θ * (lam - 1)) q + +def interpolate (p q : Plane) (θ : ℝ) : Plane := + ((1 - θ) * p.1 + θ * q.1, (1 - θ) * p.2 + θ * q.2) + + +theorem partialStage_interpolate (lam : ℝ) (j : Fin 4) (θ : ℝ) (p : Plane) : + partialStage lam j θ p = + interpolate (endpoint lam p j.castSucc) (endpoint lam p j.succ) θ := by + fin_cases j <;> apply Prod.ext <;> dsimp [partialStage, endpoint, X, Y, interpolate] <;> ring + +theorem endpoint_one (lam r s : ℝ) : endpoint lam (r, s) 1 = (r, s - lam * r) := by + apply Prod.ext <;> dsimp [endpoint, X, Y] + ring + +theorem endpoint_two (lam r s : ℝ) (hlam : lam ≠ 0) : + endpoint lam (r, s) 2 = (lam * r + (lam⁻¹ - 1) * s, s - lam * r) := by + apply Prod.ext <;> dsimp [endpoint, X, Y] <;> field_simp <;> ring + +theorem endpoint_three (lam r s : ℝ) (hlam : lam ≠ 0) : + endpoint lam (r, s) 3 = (lam * r + (lam⁻¹ - 1) * s, s / lam) := by + apply Prod.ext <;> dsimp [endpoint, X, Y] <;> field_simp <;> ring + + +theorem four_shears (lam r s : ℝ) (hlam : lam ≠ 0) : + endpoint lam (r, s) 4 = (lam * r, s / lam) := by + apply Prod.ext <;> dsimp [endpoint, X, Y] <;> field_simp <;> ring + + +theorem middle_term_bound {lam s h : ℝ} (hlam : 0 < lam) + (hs : |s| ≤ h) (hslam : |s / lam| ≤ h) : |(lam⁻¹ - 1) * s| ≤ h := by + have heq : (lam⁻¹ - 1) * s = s / lam - s := by ring + rw [heq] + rcases abs_le.mp hs with ⟨hs₀, hs₁⟩ + rcases abs_le.mp hslam with ⟨hdiv₀, hdiv₁⟩ + apply abs_le.mpr + by_cases hsign : 0 ≤ s + · have hdiv := div_nonneg hsign hlam.le + constructor <;> linarith + · have hneg : s ≤ 0 := le_of_not_ge hsign + have hdiv : s / lam ≤ 0 := div_nonpos_of_nonpos_of_nonneg hneg hlam.le + constructor <;> linarith + + +theorem endpoint_bound {lam r s h : ℝ} (hlam : 0 < lam) (hh : 0 < h) + (hr : |r| ≤ h) (hs : |s| ≤ h) (hlamr : |lam * r| ≤ h) (hslam : |s / lam| ≤ h) + (j : Fin 5) : + |(endpoint lam (r, s) j).1| ≤ 2 * h ∧ |(endpoint lam (r, s) j).2| ≤ 2 * h := by + have hsub : |s - lam * r| ≤ 2 * h := by + calc + |s - lam * r| ≤ |s| + |lam * r| := abs_sub _ _ + _ ≤ h + h := add_le_add hs hlamr + _ = 2 * h := by ring + have hmid : |lam * r + (lam⁻¹ - 1) * s| ≤ 2 * h := by + calc + |lam * r + (lam⁻¹ - 1) * s| ≤ |lam * r| + |(lam⁻¹ - 1) * s| := abs_add_le _ _ + _ ≤ h + h := add_le_add hlamr (middle_term_bound hlam hs hslam) + _ = 2 * h := by ring + have hle : h ≤ 2 * h := by linarith + fin_cases j + · exact ⟨hr.trans hle, hs.trans hle⟩ + · change |(endpoint lam (r, s) 1).1| ≤ 2 * h ∧ + |(endpoint lam (r, s) 1).2| ≤ 2 * h + rw [endpoint_one] + exact ⟨hr.trans hle, hsub⟩ + · change |(endpoint lam (r, s) 2).1| ≤ 2 * h ∧ + |(endpoint lam (r, s) 2).2| ≤ 2 * h + rw [endpoint_two lam r s hlam.ne'] + exact ⟨hmid, hsub⟩ + · change |(endpoint lam (r, s) 3).1| ≤ 2 * h ∧ + |(endpoint lam (r, s) 3).2| ≤ 2 * h + rw [endpoint_three lam r s hlam.ne'] + exact ⟨hmid, hslam.trans hle⟩ + · change |(endpoint lam (r, s) 4).1| ≤ 2 * h ∧ + |(endpoint lam (r, s) 4).2| ≤ 2 * h + rw [four_shears lam r s hlam.ne'] + exact ⟨hlamr.trans hle, hslam.trans hle⟩ + +theorem abs_interpolate_le {a b C θ : ℝ} (ha : |a| ≤ C) (hb : |b| ≤ C) + (hθ₀ : 0 ≤ θ) (hθ₁ : θ ≤ 1) : |(1 - θ) * a + θ * b| ≤ C := by + calc + |(1 - θ) * a + θ * b| ≤ |(1 - θ) * a| + |θ * b| := abs_add_le _ _ + _ = (1 - θ) * |a| + θ * |b| := by + rw [abs_mul, abs_mul, abs_of_nonneg (sub_nonneg.mpr hθ₁), abs_of_nonneg hθ₀] + _ ≤ (1 - θ) * C + θ * C := + add_le_add (mul_le_mul_of_nonneg_left ha (sub_nonneg.mpr hθ₁)) + (mul_le_mul_of_nonneg_left hb hθ₀) + _ = C := by ring + + +theorem excursion {lam r s h : ℝ} (hlam : 0 < lam) (hh : 0 < h) + (hr : |r| ≤ h) (hs : |s| ≤ h) (hlamr : |lam * r| ≤ h) (hslam : |s / lam| ≤ h) : + endpoint lam (r, s) 4 = (lam * r, s / lam) ∧ + (∀ j : Fin 5, |(endpoint lam (r, s) j).1| ≤ 2 * h ∧ + |(endpoint lam (r, s) j).2| ≤ 2 * h) ∧ + (∀ (j : Fin 4) (θ : ℝ), θ ∈ Set.Icc 0 1 → + |(partialStage lam j θ (r, s)).1| ≤ 2 * h ∧ + |(partialStage lam j θ (r, s)).2| ≤ 2 * h) := by + have hb := endpoint_bound hlam hh hr hs hlamr hslam + refine ⟨four_shears lam r s hlam.ne', hb, ?_⟩ + intro j θ hθ + rw [partialStage_interpolate] + exact ⟨abs_interpolate_le (hb j.castSucc).1 (hb j.succ).1 hθ.1 hθ.2, + abs_interpolate_le (hb j.castSucc).2 (hb j.succ).2 hθ.1 hθ.2⟩ + +@[simp] theorem partialStage_zero (lam : ℝ) (j : Fin 4) (p : Plane) : + partialStage lam j 0 p = endpoint lam p j.castSucc := by + rw [partialStage_interpolate] + apply Prod.ext <;> dsimp [interpolate] <;> ring + +@[simp] theorem partialStage_one (lam : ℝ) (j : Fin 4) (p : Plane) : + partialStage lam j 1 p = endpoint lam p j.succ := by + rw [partialStage_interpolate] + apply Prod.ext <;> dsimp [interpolate] <;> ring +end Shear +end Solenoidal + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/AlignedConfiguration.lean b/lean/OAI/Analysis/SphereIsometry/AlignedConfiguration.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b02e4f23efb541ae8353aa22ae4a4b583d867b4 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/AlignedConfiguration.lean @@ -0,0 +1,234 @@ +import OAI.Analysis.SphereIsometry.Basic + +namespace OAI + +/-! +# Aligned sphere chords + +The record retains the four actual endpoint equations. Its inverse exchanges the +endpoints and negates the two direction vectors literally; it uses no oddness +property of the sphere isometry. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +structure AlignedConfiguration + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) (t M : ℝ) where + x : UnitSphere X + z : UnitSphere X + v : UnitSphere X + w : UnitSphere Y + p : ℝ + r : ℝ + s : ℝ + u : ℝ + p_pos : 0 < p + r_pos : 0 < r + s_pos : 0 < s + u_pos : 0 < u + x_eq : (x : X) = t • (y : X) + p • (v : X) + z_eq : (z : X) = t • (y : X) - r • (v : X) + fx_eq : (f x : Y) = t • (f y : Y) + s • (w : Y) + fz_eq : (f z : Y) = t • (f y : Y) - u • (w : Y) + s_sub_p : s - p = M + r_sub_u : r - u = M + chord_sum : p + r = s + u + chord_le_two : p + r ≤ 2 + +theorem unit_radius_bounds_of_norm_sub + (x y : UnitSphere X) {t p : ℝ} (ht : 0 ≤ t) + (hd : ‖(x : X) - t • (y : X)‖ = p) : + 1 - t ≤ p ∧ p ≤ 1 + t := by + have hty : ‖t • (y : X)‖ = t := by + simp only [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht, + UnitSphere.norm_coe, mul_one] + constructor + · simpa only [UnitSphere.norm_coe, hty, hd] using + norm_sub_norm_le (x : X) (t • (y : X)) + · simpa only [UnitSphere.norm_coe, hty, hd] using + norm_sub_le (x : X) (t • (y : X)) + +theorem unit_radius_bounds_of_eq_add + (x y v : UnitSphere X) {t p : ℝ} (ht : 0 ≤ t) (hp : 0 ≤ p) + (hx : (x : X) = t • (y : X) + p • (v : X)) : + 1 - t ≤ p ∧ p ≤ 1 + t := by + have hv : (x : X) - t • (y : X) = p • (v : X) := by + rw [hx] + abel + have hd : ‖(x : X) - t • (y : X)‖ = p := by + rw [hv] + simp only [norm_smul, Real.norm_eq_abs, abs_of_nonneg hp, + UnitSphere.norm_coe, mul_one] + exact unit_radius_bounds_of_norm_sub x y ht hd + +theorem unit_radius_bounds_of_eq_sub + (x y v : UnitSphere X) {t p : ℝ} (ht : 0 ≤ t) (hp : 0 ≤ p) + (hx : (x : X) = t • (y : X) - p • (v : X)) : + 1 - t ≤ p ∧ p ≤ 1 + t := by + have hv : (x : X) - t • (y : X) = -(p • (v : X)) := by + rw [hx] + abel + have hd : ‖(x : X) - t • (y : X)‖ = p := by + rw [hv, norm_neg] + simp only [norm_smul, Real.norm_eq_abs, abs_of_nonneg hp, + UnitSphere.norm_coe, mul_one] + exact unit_radius_bounds_of_norm_sub x y ht hd + +namespace AlignedConfiguration + +variable {f : UnitSphere X ≃ᵢ UnitSphere Y} {y : UnitSphere X} {t M : ℝ} +variable (C : AlignedConfiguration f y t M) + +def d : ℝ := C.p + C.r + +def A : ℝ := C.p / C.d + +def B : ℝ := C.u / C.d + +theorem d_pos : 0 < C.d := add_pos C.p_pos C.r_pos + +theorem d_ne_zero : C.d ≠ 0 := ne_of_gt C.d_pos + +theorem d_le_two : C.d ≤ 2 := C.chord_le_two + +theorem d_eq_s_add_u : C.d = C.s + C.u := C.chord_sum + +theorem A_pos : 0 < C.A := div_pos C.p_pos C.d_pos + +theorem B_pos : 0 < C.B := div_pos C.u_pos C.d_pos + +theorem A_lt_one : C.A < 1 := by + apply (div_lt_one C.d_pos).2 + dsimp only [d] + linarith [C.r_pos] + +theorem B_lt_one : C.B < 1 := by + apply (div_lt_one C.d_pos).2 + rw [C.d_eq_s_add_u] + linarith [C.s_pos] + +theorem A_add_B : C.A + C.B = 1 - M / C.d := by + dsimp only [A, B] + rw [← add_div, eq_sub_iff_add_eq, ← add_div] + have hsum : C.p + C.u + M = C.d := by + dsimp only [d] + linarith [C.r_sub_u] + rw [hsum, div_self C.d_ne_zero] + +theorem A_add_B_lt_one (hM : 0 < M) : C.A + C.B < 1 := by + rw [C.A_add_B] + have hMd := div_pos hM C.d_pos + linarith + +theorem one_sub_B : 1 - C.B = C.s / C.d := by + apply (eq_div_iff C.d_ne_zero).2 + dsimp only [B] + rw [sub_mul, one_mul, div_mul_cancel₀ _ C.d_ne_zero, C.d_eq_s_add_u] + ring + +theorem one_sub_A : 1 - C.A = C.r / C.d := by + apply (eq_div_iff C.d_ne_zero).2 + dsimp only [A] + rw [sub_mul, one_mul, div_mul_cancel₀ _ C.d_ne_zero] + dsimp only [d] + ring + +theorem p_eq_d_mul_A : C.p = C.d * C.A := by + simpa only [A, mul_comm] using (div_mul_cancel₀ C.p C.d_ne_zero).symm + +theorem u_eq_d_mul_B : C.u = C.d * C.B := by + simpa only [B, mul_comm] using (div_mul_cancel₀ C.u C.d_ne_zero).symm + +theorem chord_identity : C.s * C.r - C.u * C.p = M * C.d := by + calc + C.s * C.r - C.u * C.p = (C.s - C.p) * C.r + C.p * (C.r - C.u) := by ring + _ = M * C.r + C.p * M := by rw [C.s_sub_p, C.r_sub_u] + _ = M * C.d := by dsimp only [d]; ring + +theorem norm_x_sub_z : ‖(C.x : X) - (C.z : X)‖ = C.d := by + have he : (C.x : X) - (C.z : X) = C.d • (C.v : X) := by + rw [C.x_eq, C.z_eq] + dsimp only [d] + rw [add_smul] + abel + rw [he, norm_smul, Real.norm_eq_abs, abs_of_pos C.d_pos, + UnitSphere.norm_coe, mul_one] + +theorem p_bounds (ht : 0 ≤ t) : 1 - t ≤ C.p ∧ C.p ≤ 1 + t := + unit_radius_bounds_of_eq_add C.x y C.v ht C.p_pos.le C.x_eq + +theorem r_bounds (ht : 0 ≤ t) : 1 - t ≤ C.r ∧ C.r ≤ 1 + t := + unit_radius_bounds_of_eq_sub C.z y C.v ht C.r_pos.le C.z_eq + +theorem s_bounds (ht : 0 ≤ t) : 1 - t ≤ C.s ∧ C.s ≤ 1 + t := + unit_radius_bounds_of_eq_add (f C.x) (f y) C.w ht C.s_pos.le C.fx_eq + +theorem u_bounds (ht : 0 ≤ t) : 1 - t ≤ C.u ∧ C.u ≤ 1 + t := + unit_radius_bounds_of_eq_sub (f C.z) (f y) C.w ht C.u_pos.le C.fz_eq + +/-- Exchange the endpoints and literally negate both chord directions. -/ +def inverse : AlignedConfiguration f.symm (f y) t M where + x := f C.z + z := f C.x + v := ⟨-(C.w : Y), by simp⟩ + w := ⟨-(C.v : X), by simp⟩ + p := C.u + r := C.s + s := C.r + u := C.p + p_pos := C.u_pos + r_pos := C.s_pos + s_pos := C.r_pos + u_pos := C.p_pos + x_eq := by simpa only [smul_neg, sub_eq_add_neg] using C.fz_eq + z_eq := by simpa only [smul_neg, sub_neg_eq_add] using C.fx_eq + fx_eq := by + simpa only [IsometryEquiv.symm_apply_apply, smul_neg, sub_eq_add_neg] using C.z_eq + fz_eq := by + simpa only [IsometryEquiv.symm_apply_apply, smul_neg, sub_neg_eq_add] using C.x_eq + s_sub_p := C.r_sub_u + r_sub_u := C.s_sub_p + chord_sum := by linarith [C.chord_sum] + chord_le_two := by linarith [C.chord_sum, C.chord_le_two] + +@[simp] theorem inverse_x : C.inverse.x = f C.z := rfl + +@[simp] theorem inverse_z : C.inverse.z = f C.x := rfl + +@[simp] theorem inverse_v_coe : (C.inverse.v : Y) = -(C.w : Y) := rfl + +@[simp] theorem inverse_w_coe : (C.inverse.w : X) = -(C.v : X) := rfl + +@[simp] theorem inverse_p : C.inverse.p = C.u := rfl + +@[simp] theorem inverse_r : C.inverse.r = C.s := rfl + +@[simp] theorem inverse_s : C.inverse.s = C.r := rfl + +@[simp] theorem inverse_u : C.inverse.u = C.p := rfl + +@[simp] theorem inverse_d : C.inverse.d = C.d := by + change C.u + C.s = C.p + C.r + linarith [C.chord_sum] + +@[simp] theorem inverse_A : C.inverse.A = C.B := by + simp only [A, B, inverse_p, inverse_d] + +@[simp] theorem inverse_B : C.inverse.B = C.A := by + simp only [A, B, inverse_u, inverse_d] + +end AlignedConfiguration + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/Alignment.lean b/lean/OAI/Analysis/SphereIsometry/Alignment.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d9dfe4560005e9a5f669195b7a5995ef39386e6 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Alignment.lean @@ -0,0 +1,107 @@ +import OAI.Analysis.SphereIsometry.AlignmentSet +import OAI.Analysis.SphereIsometry.ReturnMapEstimate +import OAI.Analysis.SphereIsometry.ReturnMapFixedPoint +import OAI.Analysis.SphereIsometry.AlignedConfiguration + +namespace OAI + +/-! +# Alignment from an attained positive defect + +The actual positive schedule supplies the invariant convex set; the actual +return-map estimate and the proved fixed-point theorem supply its fixed point. +The original center and scalar remain unchanged throughout the construction. +-/ + +noncomputable section + +namespace Tingley + +variable {X Y : Type*} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- A fixed point of the genuine sphere return map gives the exact four chords. -/ +def aligned_of_return_fixed + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) + (t M : ℝ) (ht : 0 < t ∧ t < 1) (hb : HasDefectBound f M) + (v : UnitSphere X) (hv : v ∈ extremalSphere f y t ht M) + (hfixed : returnSphere f y t ht v = v) : AlignedConfiguration f y t M where + x := xPoint f y t ht v + z := zPoint f y t ht v + v := v + w := wDirection f y t ht v + p := pRadius f y t ht v + r := rRadius f y t ht v + s := sRadius f y t ht v + u := uRadius f y t ht v + p_pos := pRadius_pos f y t ht v + r_pos := rRadius_pos f y t ht v + s_pos := sRadius_pos f y t ht v + u_pos := uRadius_pos f y t ht v + x_eq := xPoint_eq f y t ht v + z_eq := by simpa only [hfixed] using zPoint_eq f y t ht v + fx_eq := fxPoint_eq f y t ht v + fz_eq := fzPoint_eq f y t ht v + s_sub_p := hv + r_sub_u := (extremal_radius_identities f y t ht M hb hv).1 + chord_sum := (extremal_radius_identities f y t ht M hb hv).2.1 + chord_le_two := by + calc + pRadius f y t ht v + rRadius f y t ht v = + ‖pRadius f y t ht v • (v : X) + + rRadius f y t ht v • (returnSphere f y t ht v : X)‖ := + (extremal_radius_identities f y t ht M hb hv).2.2.symm + _ = ‖(xPoint f y t ht v : X) - (zPoint f y t ht v : X)‖ := + (norm_xPoint_sub_zPoint f y t ht v).symm + _ ≤ ‖(xPoint f y t ht v : X)‖ + ‖(zPoint f y t ht v : X)‖ := norm_sub_le _ _ + _ = 2 := by rw [UnitSphere.norm_coe, UnitSphere.norm_coe]; norm_num + +/-- Alignment has no supplied invariant-set, contraction or fixed-point premise. -/ +theorem exists_alignedConfiguration [CompleteSpace X] + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y x₀ : UnitSphere X) + (t M : ℝ) (ht : 0 < t ∧ t < 1) (hM : 0 < M) + (hb : HasDefectBound f M) (hatt : signedDefect f t x₀ y = M) : + Nonempty (AlignedConfiguration f y t M) := by + obtain ⟨C, hCne, hCclosed, hCb, hCconvex, hCE, hg, hgC⟩ := + exists_return_invariant_convex f y x₀ t M ht hb hatt + have hbounds : ∀ v ∈ C, + (1 - t ≤ pAmbient f y t ht v ∧ pAmbient f y t ht v ≤ 1 + t) ∧ + (1 - t ≤ sAmbient f y t ht v ∧ sAmbient f y t ht v ≤ 1 + t) ∧ + (1 - t ≤ uAmbient f y t ht v ∧ uAmbient f y t ht v ≤ 1 + t) ∧ + (1 - t ≤ rAmbient f y t ht v ∧ rAmbient f y t ht v ≤ 1 + t) := by + intro v hv + obtain ⟨a, _, rfl⟩ := hCE hv + simpa only [pAmbient_coe, sAmbient_coe, uAmbient_coe, rAmbient_coe, Set.mem_Icc] using + radii_bounds f y t ht a + have hs : ∀ v ∈ C, sAmbient f y t ht v = pAmbient f y t ht v + M := by + intro v hv + obtain ⟨a, ha, rfl⟩ := hCE hv + simpa only [sAmbient_coe, pAmbient_coe] using sRadius_eq_add f y t ht M ha + have hr : ∀ v ∈ C, rAmbient f y t ht v = uAmbient f y t ht v + M := by + intro v hv + obtain ⟨a, ha, rfl⟩ := hCE hv + simpa only [rAmbient_coe, uAmbient_coe] using rRadius_eq_add f y t ht M hb ha + have hpair : ∀ v ∈ C, ∀ v' ∈ C, + dist (returnAmbient f y t ht v) (returnAmbient f y t ht v') ≤ + (uAmbient f y t ht v * pAmbient f y t ht v / + (rAmbient f y t ht v * sAmbient f y t ht v)) * dist v v' + + 2 * |uAmbient f y t ht v - uAmbient f y t ht v'| / rAmbient f y t ht v + + 2 * uAmbient f y t ht v * |pAmbient f y t ht v - pAmbient f y t ht v'| / + (rAmbient f y t ht v * sAmbient f y t ht v) := by + intro v hv v' hv' + simpa only [dist_eq_norm] using + returnAmbient_pair_estimate_on f y t ht M hb C hCE hv hv' + obtain ⟨v, hv, hfixed⟩ := exists_fixedPoint_of_return_estimate + ht.1 ht.2 hM hCne hCclosed hCb hCconvex hg hgC hbounds hs hr hpair + obtain ⟨a, ha, rfl⟩ := hCE hv + have hfixedSphere : returnSphere f y t ht a = a := by + apply Subtype.ext + simpa only [returnAmbient_coe] using hfixed + exact ⟨aligned_of_return_fixed f y t M ht hb a ha hfixedSphere⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/AlignmentSet.lean b/lean/OAI/Analysis/SphereIsometry/AlignmentSet.lean new file mode 100644 index 0000000000000000000000000000000000000000..a050a98982eba8f8873c819e0e2c9f875d766793 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/AlignmentSet.lean @@ -0,0 +1,44 @@ +import OAI.Analysis.SphereIsometry.ExtremalPropagation +import OAI.Analysis.SphereIsometry.InvariantConvexSet + +namespace OAI + +/-! +# The actual closed convex invariant subset of the extremal sphere + +The generic positive scheduling theorem is instantiated with the proved +common-support hull growth. No convexity of the full extremal set is assumed. +-/ + +noncomputable section + +namespace Tingley + +variable {X Y : Type*} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +theorem exists_return_invariant_convex + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y x₀ : UnitSphere X) + (t M : ℝ) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hatt : signedDefect f t x₀ y = M) : + ∃ C : Set X, C.Nonempty ∧ IsClosed C ∧ Bornology.IsBounded C ∧ + Convex ℝ C ∧ C ⊆ extremalSet f y t ht M ∧ + ContinuousOn (returnAmbient f y t ht) C ∧ + Set.MapsTo (returnAmbient f y t ht) C C := by + obtain ⟨v₀, hv₀⟩ := extremalSet_nonempty_of_attained f y t ht M x₀ hatt + have hcont : ContinuousOn (returnAmbient f y t ht) (extremalSet f y t ht M) := + (continuousOn_returnAmbient f y t ht).mono + (fun _ hv => norm_eq_one_of_mem_extremalSet f y t ht M hv) + obtain ⟨C, hCne, hCc, hCb, hCconv, hCE, hGC⟩ := + exists_invariant_closed_convex (returnAmbient f y t ht) + (extremalSet f y t ht M) v₀ hv₀ (isClosed_extremalSet f y t ht M) + (fun _ hv => norm_eq_one_of_mem_extremalSet f y t ht M hv) hcont + (positive_prefix_extension f y t ht M hb) + exact ⟨C, hCne, hCc, hCb, hCconv, hCE, hcont.mono hCE, hGC⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricBasic.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..24b2d492f8ee3757cc34c220576b96154949aad7 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricBasic.lean @@ -0,0 +1,85 @@ +import Mathlib.Analysis.Convex.Combination +import Mathlib.Analysis.Normed.Module.Basic + +namespace OAI + +/-! +# Finite barycenters + +The point attached to a nonempty face in barycentric subdivision is its +ordinary finite average. The definition also assigns zero to the empty set. +-/ + +noncomputable section + +open scoped BigOperators + +namespace Tingley + +variable {V W E F : Type*} +variable [NormedAddCommGroup E] [NormedSpace ℝ E] +variable [NormedAddCommGroup F] [NormedSpace ℝ F] + +def finiteBarycenter (p : V → E) (S : Finset V) : E := + (S.card : ℝ)⁻¹ • ∑ v ∈ S, p v + +theorem finiteBarycenter_eq_centerMass (p : V → E) (S : Finset V) : + finiteBarycenter p S = S.centerMass (fun _ => (1 : ℝ)) p := by + simp [finiteBarycenter, Finset.centerMass] + +@[simp] theorem finiteBarycenter_empty (p : V → E) : + finiteBarycenter p ∅ = 0 := by + simp [finiteBarycenter] + +@[simp] theorem finiteBarycenter_singleton (p : V → E) (v : V) : + finiteBarycenter p {v} = p v := by + simp [finiteBarycenter] + +theorem finiteBarycenter_congr {p q : V → E} {S : Finset V} + (h : ∀ v ∈ S, p v = q v) : + finiteBarycenter p S = finiteBarycenter q S := by + unfold finiteBarycenter + congr 1 + exact Finset.sum_congr rfl h + +theorem finiteBarycenter_mem_convex {K : Set E} (hK : Convex ℝ K) + {p : V → E} {S : Finset V} (hs : S.Nonempty) + (hp : ∀ v ∈ S, p v ∈ K) : finiteBarycenter p S ∈ K := by + rw [finiteBarycenter_eq_centerMass] + apply hK.centerMass_mem + · intro v hv + exact zero_le_one + · simpa using (Nat.cast_pos.mpr (Finset.card_pos.mpr hs) : 0 < (S.card : ℝ)) + · exact hp + +theorem finiteBarycenter_mem_convexHull {p : V → E} {S T : Finset V} + (hs : S.Nonempty) (hst : S ⊆ T) : + finiteBarycenter p S ∈ convexHull ℝ (p '' (↑T : Set V)) := by + apply finiteBarycenter_mem_convex (convex_convexHull ℝ _) hs + intro v hv + exact subset_convexHull ℝ _ ⟨v, hst hv, rfl⟩ + +theorem map_finiteBarycenter (L : E →ₗ[ℝ] F) (p : V → E) (S : Finset V) : + L (finiteBarycenter p S) = finiteBarycenter (L ∘ p) S := by + simp [finiteBarycenter] + +theorem finiteBarycenter_map (e : V ↪ W) (p : W → E) (S : Finset V) : + finiteBarycenter p (S.map e) = finiteBarycenter (p ∘ e) S := by + simp [finiteBarycenter] + +theorem finiteBarycenter_map_of_eq (e : V ↪ W) (p : V → E) (q : W → E) + (S : Finset V) (h : ∀ v ∈ S, q (e v) = p v) : + finiteBarycenter q (S.map e) = finiteBarycenter p S := by + rw [finiteBarycenter_map] + exact finiteBarycenter_congr h + +theorem finiteBarycenter_apply {ι : Type*} [Fintype ι] + (p : V → ι → ℝ) (S : Finset V) (i : ι) : + finiteBarycenter p S i = (S.card : ℝ)⁻¹ * ∑ v ∈ S, p v i := by + simp [finiteBarycenter, Finset.sum_apply] + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricFlags.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricFlags.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c74fca566754f0e0a33383241155c8dc38c2225 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricFlags.lean @@ -0,0 +1,138 @@ +import OAI.Analysis.SphereIsometry.FiniteComplex +import Mathlib.Data.Finset.Max +import Mathlib.Order.Interval.Finset.Nat +import Lean.Elab.Tactic.Omega + +namespace OAI + +/-! # Ranks and carriers of finite face-chains -/ + +noncomputable section + +namespace Tingley.FiniteComplex + +universe u v +variable {V : Type u} [Fintype V] [DecidableEq V] +variable {K : FiniteComplex V} + +theorem chain_eq_of_card_eq {c : Finset (FaceVertex K)} (hc : K.chain c) + {a b : FaceVertex K} (ha : a ∈ c) (hb : b ∈ c) (h : a.val.card = b.val.card) : + a = b := by + apply Subtype.ext + rcases hc a ha b hb with hab | hba + · exact Finset.eq_of_subset_of_card_le hab h.ge + · exact (Finset.eq_of_subset_of_card_le hba h.le).symm + +theorem chain_subset_of_card_le {c : Finset (FaceVertex K)} (hc : K.chain c) + {a b : FaceVertex K} (ha : a ∈ c) (hb : b ∈ c) (h : a.val.card ≤ b.val.card) : + a.val ⊆ b.val := by + rcases hc a ha b hb with hab | hba + · exact hab + · intro x hx + rw [Finset.eq_of_subset_of_card_le hba h] + exact hx + +def ranks (K : FiniteComplex V) (c : Finset (FaceVertex K)) : Finset ℕ := + c.image (fun a => a.val.card) + +@[simp] theorem mem_ranks {c : Finset (FaceVertex K)} {r : ℕ} : + r ∈ K.ranks c ↔ ∃ a ∈ c, a.val.card = r := + Finset.mem_image + +theorem card_ranks {c : Finset (FaceVertex K)} (hc : K.chain c) : + (K.ranks c).card = c.card := by + apply Finset.card_image_of_injOn + intro a ha b hb hab + exact chain_eq_of_card_eq hc ha hb hab + +theorem ranks_subset {m : ℕ} (hK : K.CardBound m) (c : Finset (FaceVertex K)) : + K.ranks c ⊆ Finset.Icc 1 (m + 1) := by + intro r hr + obtain ⟨a, _, rfl⟩ := mem_ranks.mp hr + exact Finset.mem_Icc.mpr + ⟨Finset.card_pos.mpr a.property.2, hK a.val a.property.1⟩ + +theorem sd_cardBound {m : ℕ} (hK : K.CardBound m) : K.sd.CardBound m := by + intro c hc + have h := Finset.card_le_card (ranks_subset hK c) + rw [card_ranks (mem_sd_iff.mp hc)] at h + simpa using h + +theorem top_ranks {m : ℕ} (hK : K.CardBound m) {c : Finset (FaceVertex K)} + (hc : c ∈ K.sd.topCells m) : K.ranks c = Finset.Icc 1 (m + 1) := by + obtain ⟨hc, hcard⟩ := mem_topCells.mp hc + apply Finset.eq_of_subset_of_card_le (ranks_subset hK c) + rw [card_ranks (mem_sd_iff.mp hc), hcard] + simp + +theorem missing_rank {m : ℕ} (hK : K.CardBound m) {c : Finset (FaceVertex K)} + (hc : c ∈ K.sd.codimFaces m) : + ∃ r, 1 ≤ r ∧ r ≤ m + 1 ∧ K.ranks c = (Finset.Icc 1 (m + 1)).erase r := by + obtain ⟨hchain, hcard⟩ := mem_codimFaces.mp hc + have hsub := ranks_subset hK c + have hd : ((Finset.Icc 1 (m + 1)) \ K.ranks c).card = 1 := by + rw [Finset.card_sdiff_of_subset hsub, card_ranks (mem_sd_iff.mp hchain), hcard] + simp + obtain ⟨r, hr⟩ := Finset.card_eq_one.mp hd + have hrmem : r ∈ (Finset.Icc 1 (m + 1)) \ K.ranks c := by + rw [hr] + exact Finset.mem_singleton_self _ + obtain ⟨hrI, hrnot⟩ := Finset.mem_sdiff.mp hrmem + refine ⟨r, (Finset.mem_Icc.mp hrI).1, (Finset.mem_Icc.mp hrI).2, ?_⟩ + ext q + constructor + · intro hq + exact Finset.mem_erase.mpr ⟨fun hqr => hrnot (hqr ▸ hq), hsub hq⟩ + · intro hq + obtain ⟨hqr, hqI⟩ := Finset.mem_erase.mp hq + by_contra hnot + have : q ∈ (Finset.Icc 1 (m + 1)) \ K.ranks c := + Finset.mem_sdiff.mpr ⟨hqI, hnot⟩ + rw [hr] at this + exact hqr (Finset.mem_singleton.mp this) + +theorem exists_greatest {c : Finset (FaceVertex K)} (hc : K.chain c) + (hne : c.Nonempty) : ∃ a ∈ c, ∀ b ∈ c, b.val ⊆ a.val := by + obtain ⟨a, ha, hmax⟩ := c.exists_max_image (fun b => b.val.card) hne + exact ⟨a, ha, fun b hb => chain_subset_of_card_le hc hb ha (hmax b hb)⟩ + +theorem card_le_greatest {c : Finset (FaceVertex K)} (hc : K.chain c) + {a : FaceVertex K} (_ha : a ∈ c) (hmax : ∀ b ∈ c, b.val ⊆ a.val) : + c.card ≤ a.val.card := by + have hsub : K.ranks c ⊆ Finset.Icc 1 a.val.card := by + intro r hr + obtain ⟨b, hb, rfl⟩ := mem_ranks.mp hr + exact Finset.mem_Icc.mpr + ⟨Finset.card_pos.mpr b.property.2, Finset.card_le_card (hmax b hb)⟩ + have h := Finset.card_le_card hsub + rw [card_ranks hc] at h + simpa using h + +variable {I : Type v} [DecidableEq I] + +theorem faceCarrier_sd_eq_greatest {carrier : V → Finset I} + {c : Finset (FaceVertex K)} {a : FaceVertex K} (ha : a ∈ c) + (hmax : ∀ b ∈ c, b.val ⊆ a.val) : + faceCarrier (K.sdCarrier carrier) c = faceCarrier carrier a.val := by + apply Finset.Subset.antisymm + · intro i hi + obtain ⟨b, hb, hbi⟩ := mem_faceCarrier.mp hi + exact faceCarrier_mono carrier (hmax b hb) hbi + · intro i hi + exact mem_faceCarrier.mpr ⟨a, ha, hi⟩ + +theorem sd_card_le_carrier {carrier : V → Finset I} + (hK : ∀ s ∈ K.faces, s.card ≤ (faceCarrier carrier s).card) + {c : Finset (FaceVertex K)} (hc : c ∈ K.sd.faces) : + c.card ≤ (faceCarrier (K.sdCarrier carrier) c).card := by + rcases c.eq_empty_or_nonempty with rfl | hne + · simp + · obtain ⟨a, ha, hmax⟩ := exists_greatest (mem_sd_iff.mp hc) hne + rw [faceCarrier_sd_eq_greatest ha hmax] + exact (card_le_greatest (mem_sd_iff.mp hc) ha hmax).trans (hK a.val a.property.1) + +end Tingley.FiniteComplex + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricIncidence.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..fda114aaf6c6d7d63d89923eb309bfa3ef302f55 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricIncidence.lean @@ -0,0 +1,311 @@ +import OAI.Analysis.SphereIsometry.BarycentricFlags + +namespace OAI + +/-! +# Codimension-one incidence in the actual face-chain subdivision + +Completions of a flag are counted by inserting its unique missing rank. +An interior missing rank has two completions. A missing top rank inherits +the incidence count of the greatest old face. +-/ + +noncomputable section + +namespace Tingley.FiniteComplex + +universe u +variable {V : Type u} [Fintype V] [DecidableEq V] +variable {K : FiniteComplex V} + +theorem chain_insert_iff {c : Finset (FaceVertex K)} {a : FaceVertex K} : + K.chain (insert a c) ↔ K.chain c ∧ + ∀ b ∈ c, a.val ⊆ b.val ∨ b.val ⊆ a.val := by + classical + constructor + · intro h + exact ⟨K.chain_mono h (Finset.subset_insert _ _), + fun b hb => h a (Finset.mem_insert_self _ _) b (Finset.mem_insert_of_mem hb)⟩ + · rintro ⟨hc, ha⟩ b hb d hd + rcases Finset.mem_insert.mp hb with hba | hbc + · subst b + rcases Finset.mem_insert.mp hd with hda | hdc + · subst d + exact Or.inl (Finset.Subset.refl _) + · exact ha d hdc + · rcases Finset.mem_insert.mp hd with hda | hdc + · subst d + exact (ha b hbc).symm + · exact hc b hbc d hdc + +def insertionVertices (K : FiniteComplex V) (c : Finset (FaceVertex K)) : + Finset (FaceVertex K) := by + classical + exact Finset.univ.filter (fun a => a ∉ c ∧ K.chain (insert a c)) + +@[simp] theorem mem_insertionVertices {c : Finset (FaceVertex K)} {a : FaceVertex K} : + a ∈ K.insertionVertices c ↔ a ∉ c ∧ K.chain (insert a c) := by + classical + simp [insertionVertices] + +theorem incidentTop_sd_eq_image_insert {m : ℕ} {c : Finset (FaceVertex K)} + (hc : c.card = m) : + K.sd.incidentTop m c = (K.insertionVertices c).image (fun a => insert a c) := by + classical + ext d + constructor + · intro hd + obtain ⟨hdface, hdcard, hcd⟩ := mem_incidentTop.mp hd + obtain ⟨a, ha, had⟩ := Finset.exists_eq_insert_iff.mpr + (show c ⊆ d ∧ c.card + 1 = d.card from ⟨hcd, by omega⟩) + apply Finset.mem_image.mpr + refine ⟨a, mem_insertionVertices.mpr ⟨ha, ?_⟩, had⟩ + rw [had] + exact mem_sd_iff.mp hdface + · intro hd + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hd + obtain ⟨ha, hchain⟩ := mem_insertionVertices.mp ha + exact mem_incidentTop.mpr ⟨mem_sd_iff.mpr hchain, + by rw [Finset.card_insert_of_notMem ha, hc], Finset.subset_insert _ _⟩ + +theorem incidentTop_sd_card_eq_insertionVertices {m : ℕ} + {c : Finset (FaceVertex K)} (hc : c.card = m) : + (K.sd.incidentTop m c).card = (K.insertionVertices c).card := by + classical + rw [incidentTop_sd_eq_image_insert hc] + apply Finset.card_image_of_injOn + intro a ha b hb hab + exact (Finset.insert_inj (mem_insertionVertices.mp ha).1).mp hab + +theorem rank_ne_of_missing {m r : ℕ} {c : Finset (FaceVertex K)} + (hr : K.ranks c = (Finset.Icc 1 (m + 1)).erase r) + {a : FaceVertex K} (ha : a ∈ c) : a.val.card ≠ r := by + have h : a.val.card ∈ K.ranks c := mem_ranks.mpr ⟨a, ha, rfl⟩ + rw [hr] at h + exact (Finset.mem_erase.mp h).1 + +theorem missing_rank_unique {m r s : ℕ} {c : Finset (FaceVertex K)} + (hr₁ : 1 ≤ r) (hr₂ : r ≤ m + 1) + (hr : K.ranks c = (Finset.Icc 1 (m + 1)).erase r) + (hs : K.ranks c = (Finset.Icc 1 (m + 1)).erase s) : r = s := by + by_contra hrs + have hmem : r ∈ K.ranks c := by + rw [hs] + exact Finset.mem_erase.mpr ⟨hrs, Finset.mem_Icc.mpr ⟨hr₁, hr₂⟩⟩ + rw [hr] at hmem + exact (Finset.mem_erase.mp hmem).1 rfl + +theorem insertionVertices_card_eq_missing {m r : ℕ} (hK : K.CardBound m) + {c : Finset (FaceVertex K)} + (hr : K.ranks c = (Finset.Icc 1 (m + 1)).erase r) + {a : FaceVertex K} (ha : a ∈ K.insertionVertices c) : a.val.card = r := by + classical + obtain ⟨hanot, hchain⟩ := mem_insertionVertices.mp ha + by_contra har + have hmem : a.val.card ∈ K.ranks c := by + rw [hr] + exact Finset.mem_erase.mpr ⟨har, Finset.mem_Icc.mpr + ⟨Finset.card_pos.mpr a.property.2, hK a.val a.property.1⟩⟩ + obtain ⟨b, hb, hba⟩ := mem_ranks.mp hmem + have hab : a = b := chain_eq_of_card_eq hchain (Finset.mem_insert_self _ _) + (Finset.mem_insert_of_mem hb) hba.symm + apply hanot + rw [hab] + exact hb + +/-- Count possible inserted old faces between two consecutive retained ranks. -/ +theorem card_insertionVertices_eq_sdiff {c : Finset (FaceVertex K)} + {L U : Finset V} (hU : U ∈ K.faces) (hLU : L ⊆ U) + (hmem : ∀ a : FaceVertex K, a ∈ K.insertionVertices c ↔ + L ⊆ a.val ∧ a.val ⊆ U ∧ a.val.card = L.card + 1) : + (K.insertionVertices c).card = (U \ L).card := by + classical + let f : ∀ a ∈ U \ L, FaceVertex K := fun a ha => + ⟨insert a L, + K.down_closed hU (Finset.insert_subset_iff.mpr ⟨(Finset.mem_sdiff.mp ha).1, hLU⟩), + ⟨a, Finset.mem_insert_self _ _⟩⟩ + have hf : ∀ a ha, f a ha ∈ K.insertionVertices c := by + intro a ha + apply (hmem _).mpr + exact ⟨Finset.subset_insert _ _, + Finset.insert_subset_iff.mpr ⟨(Finset.mem_sdiff.mp ha).1, hLU⟩, + Finset.card_insert_of_notMem (Finset.mem_sdiff.mp ha).2⟩ + have hinj : ∀ a ha b hb, f a ha = f b hb → a = b := by + intro a ha b hb hab + have heq : insert a L = insert b L := congrArg Subtype.val hab + exact (Finset.insert_inj (Finset.mem_sdiff.mp ha).2).mp heq + have hsurj : ∀ b ∈ K.insertionVertices c, ∃ a ha, f a ha = b := by + intro b hb + obtain ⟨hLb, hbU, hbcard⟩ := (hmem b).mp hb + obtain ⟨a, haL, hab⟩ := Finset.exists_eq_insert_iff.mpr + (show L ⊆ b.val ∧ L.card + 1 = b.val.card from ⟨hLb, hbcard.symm⟩) + have haU : a ∈ U := by + apply hbU + rw [← hab] + exact Finset.mem_insert_self _ _ + refine ⟨a, Finset.mem_sdiff.mpr ⟨haU, haL⟩, ?_⟩ + apply Subtype.ext + exact hab + exact (Finset.card_bij f hf hinj hsurj).symm + +/-- An omitted rank strictly below the top has exactly two completions. -/ +theorem incidentTop_sd_card_two_of_missing_rank {m r : ℕ} (hK : K.CardBound m) + {c : Finset (FaceVertex K)} (hc : c ∈ K.sd.codimFaces m) + (hr₁ : 1 ≤ r) (hrm : r ≤ m) + (hr : K.ranks c = (Finset.Icc 1 (m + 1)).erase r) : + (K.sd.incidentTop m c).card = 2 := by + classical + obtain ⟨hcface, hccard⟩ := mem_codimFaces.mp hc + have hcchain := mem_sd_iff.mp hcface + have hUr : r + 1 ∈ K.ranks c := by + rw [hr] + exact Finset.mem_erase.mpr ⟨by omega, Finset.mem_Icc.mpr ⟨by omega, by omega⟩⟩ + obtain ⟨U, hUc, hUcard⟩ := mem_ranks.mp hUr + obtain ⟨L, hLcard, hLU, hLmem, hgap⟩ : + ∃ L : Finset V, L.card + 1 = r ∧ L ⊆ U.val ∧ + (L = ∅ ∨ ∃ a ∈ c, a.val = L) ∧ + ∀ b ∈ c, b.val ⊆ L ∨ U.val ⊆ b.val := by + by_cases hrone : r = 1 + · refine ⟨∅, by simp [hrone], Finset.empty_subset _, Or.inl rfl, ?_⟩ + intro b hb + right + apply chain_subset_of_card_le hcchain hUc hb + have hbpos := Finset.card_pos.mpr b.property.2 + have hbne := rank_ne_of_missing hr hb + omega + · have hLr : r - 1 ∈ K.ranks c := by + rw [hr] + exact Finset.mem_erase.mpr ⟨by omega, Finset.mem_Icc.mpr ⟨by omega, by omega⟩⟩ + obtain ⟨L, hLc, hLc_card⟩ := mem_ranks.mp hLr + refine ⟨L.val, by omega, + chain_subset_of_card_le hcchain hLc hUc (by omega), + Or.inr ⟨L, hLc, rfl⟩, ?_⟩ + intro b hb + have hbne := rank_ne_of_missing hr hb + by_cases hbsmall : b.val.card ≤ L.val.card + · exact Or.inl (chain_subset_of_card_le hcchain hb hLc hbsmall) + · exact Or.inr (chain_subset_of_card_le hcchain hUc hb (by omega)) + have hmem : ∀ a : FaceVertex K, a ∈ K.insertionVertices c ↔ + L ⊆ a.val ∧ a.val ⊆ U.val ∧ a.val.card = L.card + 1 := by + intro a + constructor + · intro ha + have hacard := insertionVertices_card_eq_missing hK hr ha + have hachain := (mem_insertionVertices.mp ha).2 + refine ⟨?_, chain_subset_of_card_le hachain (Finset.mem_insert_self _ _) + (Finset.mem_insert_of_mem hUc) (by omega), by omega⟩ + rcases hLmem with hLempty | ⟨b, hbc, hbL⟩ + · rw [hLempty] + exact Finset.empty_subset _ + · rw [← hbL] + apply chain_subset_of_card_le hachain (Finset.mem_insert_of_mem hbc) + (Finset.mem_insert_self _ _) + have hbcard : b.val.card = L.card := congrArg Finset.card hbL + omega + · rintro ⟨hLa, haU, hacard⟩ + apply mem_insertionVertices.mpr + refine ⟨?_, chain_insert_iff.mpr ⟨hcchain, ?_⟩⟩ + · intro hac + exact rank_ne_of_missing hr hac (by omega) + · intro b hb + rcases hgap b hb with hbL | hUb + · exact Or.inr (hbL.trans hLa) + · exact Or.inl (haU.trans hUb) + rw [incidentTop_sd_card_eq_insertionVertices hccard, + card_insertionVertices_eq_sdiff U.property.1 hLU hmem, + Finset.card_sdiff_of_subset hLU, hUcard] + omega + +/-- If the omitted rank is the top rank, completions are exactly the old +top faces containing the retained rank-`m` face. -/ +theorem incidentTop_sd_card_eq_of_missing_top {m : ℕ} (hK : K.CardBound m) + {c : Finset (FaceVertex K)} (hc : c ∈ K.sd.codimFaces m) + (hr : K.ranks c = (Finset.Icc 1 (m + 1)).erase (m + 1)) + {T : FaceVertex K} (hTc : T ∈ c) (hTcard : T.val.card = m) : + (K.sd.incidentTop m c).card = (K.incidentTop m T.val).card := by + classical + obtain ⟨hcface, hccard⟩ := mem_codimFaces.mp hc + have hcchain := mem_sd_iff.mp hcface + have hmax : ∀ b ∈ c, b.val ⊆ T.val := by + intro b hb + apply chain_subset_of_card_le hcchain hb hTc + have hbcard := hK b.val b.property.1 + have hbne := rank_ne_of_missing hr hb + omega + let f : ∀ W ∈ K.incidentTop m T.val, FaceVertex K := fun W hW => + ⟨W, (mem_incidentTop.mp hW).1, + Finset.card_pos.mp (by have h := (mem_incidentTop.mp hW).2.1; omega)⟩ + have hf : ∀ W hW, f W hW ∈ K.insertionVertices c := by + intro W hW + obtain ⟨hWface, hWcard, hTW⟩ := mem_incidentTop.mp hW + apply mem_insertionVertices.mpr + refine ⟨?_, chain_insert_iff.mpr ⟨hcchain, ?_⟩⟩ + · intro hWc + have hle := Finset.card_le_card (hmax (f W hW) hWc) + change W.card ≤ T.val.card at hle + omega + · intro b hb + exact Or.inr ((hmax b hb).trans hTW) + have hinj : ∀ W hW U hU, f W hW = f U hU → W = U := by + intro W hW U hU h + exact congrArg Subtype.val h + have hsurj : ∀ a ∈ K.insertionVertices c, + ∃ W hW, f W hW = a := by + intro a ha + have hacard := insertionVertices_card_eq_missing hK hr ha + have hTa : T.val ⊆ a.val := + chain_subset_of_card_le (mem_insertionVertices.mp ha).2 + (Finset.mem_insert_of_mem hTc) (Finset.mem_insert_self _ _) (by omega) + have hav : a.val ∈ K.incidentTop m T.val := + mem_incidentTop.mpr ⟨a.property.1, hacard, hTa⟩ + exact ⟨a.val, hav, Subtype.ext rfl⟩ + rw [incidentTop_sd_card_eq_insertionVertices hccard] + exact (Finset.card_bij f hf hinj hsurj).symm + +theorem incidentTop_sd_missing_top_data {m : ℕ} (hm : 0 < m) (hK : K.CardBound m) + {c : Finset (FaceVertex K)} (hc : c ∈ K.sd.codimFaces m) + (hr : K.ranks c = (Finset.Icc 1 (m + 1)).erase (m + 1)) : + ∃ T ∈ c, T.val.card = m ∧ (∀ b ∈ c, b.val ⊆ T.val) ∧ + (K.sd.incidentTop m c).card = (K.incidentTop m T.val).card := by + have hmrank : m ∈ K.ranks c := by + rw [hr] + exact Finset.mem_erase.mpr ⟨by omega, Finset.mem_Icc.mpr ⟨hm, by omega⟩⟩ + obtain ⟨T, hTc, hTcard⟩ := mem_ranks.mp hmrank + refine ⟨T, hTc, hTcard, ?_, incidentTop_sd_card_eq_of_missing_top hK hc hr hTc hTcard⟩ + intro b hb + apply chain_subset_of_card_le (mem_sd_iff.mp (mem_codimFaces.mp hc).1) hb hTc + have hbcard := hK b.val b.property.1 + have hbne := rank_ne_of_missing hr hb + omega + +/-- The complete positive-dimensional codimension-one alternative. The first +case also records a retained old top face for transferring carrier information. -/ +theorem incidentTop_sd_cases {m : ℕ} (hm : 0 < m) (hK : K.CardBound m) + {c : Finset (FaceVertex K)} (hc : c ∈ K.sd.codimFaces m) : + ((K.sd.incidentTop m c).card = 2 ∧ + ∃ T ∈ c, T.val.card = m + 1 ∧ ∀ b ∈ c, b.val ⊆ T.val) ∨ + (∃ T ∈ c, T.val.card = m ∧ (∀ b ∈ c, b.val ⊆ T.val) ∧ + (K.sd.incidentTop m c).card = (K.incidentTop m T.val).card) := by + obtain ⟨r, hr₁, hr₂, hr⟩ := missing_rank hK hc + by_cases hrm : r ≤ m + · left + refine ⟨incidentTop_sd_card_two_of_missing_rank hK hc hr₁ hrm hr, ?_⟩ + have hmrank : m + 1 ∈ K.ranks c := by + rw [hr] + exact Finset.mem_erase.mpr ⟨by omega, Finset.mem_Icc.mpr ⟨by omega, le_rfl⟩⟩ + obtain ⟨T, hTc, hTcard⟩ := mem_ranks.mp hmrank + refine ⟨T, hTc, hTcard, ?_⟩ + intro b hb + apply chain_subset_of_card_le (mem_sd_iff.mp (mem_codimFaces.mp hc).1) hb hTc + rw [hTcard] + exact hK b.val b.property.1 + · right + have hre : r = m + 1 := by omega + subst r + exact incidentTop_sd_missing_top_data hm hK hc hr + +end Tingley.FiniteComplex + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricMesh.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricMesh.lean new file mode 100644 index 0000000000000000000000000000000000000000..80392123279a8c9b6ed5249d89bd7036ba180774 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricMesh.lean @@ -0,0 +1,163 @@ +import OAI.Analysis.SphereIsometry.BarycentricBasic +import OAI.Analysis.SphereIsometry.ConvexDiameter +import Mathlib.Tactic.Abel +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# The mesh estimate for barycentric subdivision + +The larger face is split into the smaller face and its complement. Its +barycenter is the corresponding weighted average, giving the exact factor +`1 - S.card / T.card`. A dimension bound gives the uniform contraction. +-/ + +noncomputable section + +open scoped BigOperators + +namespace Tingley + +variable {V E : Type*} [DecidableEq V] [NormedAddCommGroup E] [NormedSpace ℝ E] + +omit [DecidableEq V] in +theorem norm_finiteBarycenter_sub_le_of_subsets {p : V → E} + {S R T : Finset V} {D : ℝ} (hs : S.Nonempty) (hr : R.Nonempty) + (hst : S ⊆ T) (hrt : R ⊆ T) + (hpair : ∀ u ∈ T, ∀ v ∈ T, ‖p u - p v‖ ≤ D) : + ‖finiteBarycenter p S - finiteBarycenter p R‖ ≤ D := by + have hdiam : DiameterLE (p '' (↑T : Set V)) D := by + rintro x ⟨u, hu, rfl⟩ y ⟨v, hv, rfl⟩ + simpa only [dist_eq_norm] using hpair u hu v hv + have h := hdiam.convexHull + (finiteBarycenter p S) (finiteBarycenter_mem_convexHull hs hst) + (finiteBarycenter p R) (finiteBarycenter_mem_convexHull hr hrt) + simpa only [dist_eq_norm] using h + +theorem finiteBarycenter_partition {p : V → E} {S T : Finset V} + (hs : S.Nonempty) (hst : S ⊆ T) (hr : (T \ S).Nonempty) : + finiteBarycenter p T = + ((S.card : ℝ) / (T.card : ℝ)) • finiteBarycenter p S + + (((T \ S).card : ℝ) / (T.card : ℝ)) • finiteBarycenter p (T \ S) := by + classical + have hs0 : (S.card : ℝ) ≠ 0 := + ne_of_gt (Nat.cast_pos.mpr (Finset.card_pos.mpr hs)) + have hr0 : ((T \ S).card : ℝ) ≠ 0 := + ne_of_gt (Nat.cast_pos.mpr (Finset.card_pos.mpr hr)) + have ht0 : (T.card : ℝ) ≠ 0 := + ne_of_gt (Nat.cast_pos.mpr (Finset.card_pos.mpr (hs.mono hst))) + have hS : ((S.card : ℝ) / (T.card : ℝ)) • finiteBarycenter p S = + (T.card : ℝ)⁻¹ • ∑ v ∈ S, p v := by + rw [finiteBarycenter, smul_smul] + congr 1 + field_simp [hs0, ht0] + have hR : (((T \ S).card : ℝ) / (T.card : ℝ)) • + finiteBarycenter p (T \ S) = + (T.card : ℝ)⁻¹ • ∑ v ∈ T \ S, p v := by + rw [finiteBarycenter, smul_smul] + congr 1 + field_simp [hr0, ht0] + rw [hS, hR, ← smul_add] + unfold finiteBarycenter + congr 1 + simpa only [add_comm] using (Finset.sum_sdiff (f := p) hst).symm + +theorem norm_finiteBarycenter_sub_le_card {p : V → E} + {S T : Finset V} {D : ℝ} (hs : S.Nonempty) (hst : S ⊆ T) + (hpair : ∀ u ∈ T, ∀ v ∈ T, ‖p u - p v‖ ≤ D) : + ‖finiteBarycenter p S - finiteBarycenter p T‖ ≤ + (1 - (S.card : ℝ) / (T.card : ℝ)) * D := by + classical + have ht : T.Nonempty := hs.mono hst + have htpos : 0 < (T.card : ℝ) := Nat.cast_pos.mpr (Finset.card_pos.mpr ht) + by_cases heq : S = T + · subst S + simp [ne_of_gt htpos] + have hr : (T \ S).Nonempty := Finset.sdiff_nonempty.mpr (by + intro hts + exact heq (Finset.Subset.antisymm hst hts)) + have hcard : ((T \ S).card : ℝ) + (S.card : ℝ) = (T.card : ℝ) := by + exact_mod_cast Finset.card_sdiff_add_card_eq_card hst + have hfrac : ((T \ S).card : ℝ) / (T.card : ℝ) = + 1 - (S.card : ℝ) / (T.card : ℝ) := by + apply (div_eq_iff (ne_of_gt htpos)).2 + rw [sub_mul, one_mul, div_mul_cancel₀ _ (ne_of_gt htpos)] + linarith + have hnonneg : 0 ≤ ((T \ S).card : ℝ) / (T.card : ℝ) := + div_nonneg (Nat.cast_nonneg _) htpos.le + have hid : finiteBarycenter p S - finiteBarycenter p T = + (((T \ S).card : ℝ) / (T.card : ℝ)) • + (finiteBarycenter p S - finiteBarycenter p (T \ S)) := by + calc + finiteBarycenter p S - finiteBarycenter p T = + (1 - (S.card : ℝ) / (T.card : ℝ)) • finiteBarycenter p S - + (((T \ S).card : ℝ) / (T.card : ℝ)) • + finiteBarycenter p (T \ S) := by + rw [finiteBarycenter_partition hs hst hr, sub_smul, one_smul] + abel + _ = _ := by rw [← hfrac, smul_sub] + rw [hid, norm_smul, Real.norm_eq_abs, abs_of_nonneg hnonneg] + calc + ((T \ S).card : ℝ) / (T.card : ℝ) * + ‖finiteBarycenter p S - finiteBarycenter p (T \ S)‖ ≤ + ((T \ S).card : ℝ) / (T.card : ℝ) * D := + mul_le_mul_of_nonneg_left + (norm_finiteBarycenter_sub_le_of_subsets hs hr hst Finset.sdiff_subset hpair) + hnonneg + _ = _ := by rw [hfrac] + +theorem norm_finiteBarycenter_sub_le_mesh {p : V → E} + {S T : Finset V} {D : ℝ} (m : ℕ) (hD : 0 ≤ D) + (hs : S.Nonempty) (hst : S ⊆ T) (hcard : T.card ≤ m + 1) + (hpair : ∀ u ∈ T, ∀ v ∈ T, ‖p u - p v‖ ≤ D) : + ‖finiteBarycenter p S - finiteBarycenter p T‖ ≤ + ((m : ℝ) / (m + 1 : ℝ)) * D := by + have ht : T.Nonempty := hs.mono hst + have htpos : 0 < (T.card : ℝ) := Nat.cast_pos.mpr (Finset.card_pos.mpr ht) + have hmpos : 0 < (m + 1 : ℝ) := by positivity + have hsone : (1 : ℝ) ≤ (S.card : ℝ) := by + exact_mod_cast (Nat.succ_le_iff.mpr (Finset.card_pos.mpr hs)) + have htcard : (T.card : ℝ) ≤ (m + 1 : ℝ) := by exact_mod_cast hcard + have hlow : 1 / (m + 1 : ℝ) ≤ (S.card : ℝ) / (T.card : ℝ) := by + calc + 1 / (m + 1 : ℝ) ≤ 1 / (T.card : ℝ) := + one_div_le_one_div_of_le htpos htcard + _ ≤ (S.card : ℝ) / (T.card : ℝ) := + (div_le_div_iff_of_pos_right htpos).2 hsone + have hfactor : 1 - (S.card : ℝ) / (T.card : ℝ) ≤ + (m : ℝ) / (m + 1 : ℝ) := by + have heq : (m : ℝ) / (m + 1 : ℝ) = 1 - 1 / (m + 1 : ℝ) := by + apply (div_eq_iff (ne_of_gt hmpos)).2 + rw [sub_mul, one_mul, div_mul_cancel₀ _ (ne_of_gt hmpos)] + ring + rw [heq] + linarith + exact (norm_finiteBarycenter_sub_le_card hs hst hpair).trans + (mul_le_mul_of_nonneg_right hfactor hD) + +theorem norm_finiteBarycenter_sub_le_of_comparable {p : V → E} + {S T U : Finset V} {D : ℝ} (m : ℕ) (hD : 0 ≤ D) + (hs : S.Nonempty) (ht : T.Nonempty) (hsu : S ⊆ U) (htu : T ⊆ U) + (hcmp : S ⊆ T ∨ T ⊆ S) (hcard : U.card ≤ m + 1) + (hpair : ∀ u ∈ U, ∀ v ∈ U, ‖p u - p v‖ ≤ D) : + ‖finiteBarycenter p S - finiteBarycenter p T‖ ≤ + ((m : ℝ) / (m + 1 : ℝ)) * D := by + rcases hcmp with hst | hts + · exact norm_finiteBarycenter_sub_le_mesh m hD hs hst + ((Finset.card_le_card htu).trans hcard) + (fun u hu v hv => hpair u (htu hu) v (htu hv)) + · simpa only [norm_sub_rev] using + norm_finiteBarycenter_sub_le_mesh m hD ht hts + ((Finset.card_le_card hsu).trans hcard) + (fun u hu v hv => hpair u (hsu hu) v (hsu hv)) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricPoints.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricPoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1819f4cb3da56f22ef2e3ccc6658c44eeb0cba6 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricPoints.lean @@ -0,0 +1,9 @@ +import OAI.Analysis.SphereIsometry.BarycentricSupport +import OAI.Analysis.SphereIsometry.BarycentricMesh + +/-! +# Geometric vertices of barycentric subdivision + +Finite averages give simplex membership, exact coordinate support, +naturality, and shrinking mesh. +-/ diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricPurity.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricPurity.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbc8904c227181c7651db8e0a6ca6cea9e6cf10d --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricPurity.lean @@ -0,0 +1,140 @@ +import OAI.Analysis.SphereIsometry.BarycentricIncidence +import OAI.Analysis.SphereIsometry.SubdivisionData + +namespace OAI + +/-! +# Purity of the actual finite face-chain subdivision + +A finite chain can be completed at any positive rank below a retained upper +face. A chain of maximum cardinality among the extensions of a given face +therefore has every rank up to the dimension of an old top face. +-/ + +noncomputable section + +namespace Tingley.FiniteComplex + +universe u +variable {V : Type u} [Fintype V] [DecidableEq V] +variable {K : FiniteComplex V} + +/-- Insert an old face of a prescribed positive rank, provided the flag +already contains some old face of at least that rank. The inserted face is +allowed to be already present. -/ +theorem chain_exists_insert_rank {c : Finset (FaceVertex K)} (hc : K.chain c) + {r : ℕ} (hr : 0 < r) (hupper : ∃ U ∈ c, r ≤ U.val.card) : + ∃ a : FaceVertex K, a.val.card = r ∧ K.chain (insert a c) := by + classical + let upper := c.filter (fun b => r ≤ b.val.card) + have hupp : upper.Nonempty := by + obtain ⟨U, hUc, hUr⟩ := hupper + exact ⟨U, Finset.mem_filter.mpr ⟨hUc, hUr⟩⟩ + obtain ⟨U, hUupper, hUmin⟩ := upper.exists_min_image (fun b => b.val.card) hupp + have hUc : U ∈ c := (Finset.mem_filter.mp hUupper).1 + have hUr : r ≤ U.val.card := (Finset.mem_filter.mp hUupper).2 + obtain ⟨L, hLU, hLcard, hLmax⟩ : + ∃ L : Finset V, L ⊆ U.val ∧ L.card ≤ r ∧ + ∀ b ∈ c, b.val.card < r → b.val ⊆ L := by + let lower := c.filter (fun b => b.val.card < r) + by_cases hlower : lower.Nonempty + · obtain ⟨L, hLlower, hLmax⟩ := lower.exists_max_image (fun b => b.val.card) hlower + have hLc : L ∈ c := (Finset.mem_filter.mp hLlower).1 + have hLr : L.val.card < r := (Finset.mem_filter.mp hLlower).2 + refine ⟨L.val, chain_subset_of_card_le hc hLc hUc (by omega), + hLr.le, ?_⟩ + intro b hb hbr + exact chain_subset_of_card_le hc hb hLc + (hLmax b (Finset.mem_filter.mpr ⟨hb, hbr⟩)) + · refine ⟨∅, Finset.empty_subset _, by simp, ?_⟩ + intro b hb hbr + exact False.elim (hlower ⟨b, Finset.mem_filter.mpr ⟨hb, hbr⟩⟩) + obtain ⟨W, hLW, hWU, hWcard⟩ := Finset.exists_subsuperset_card_eq hLU hLcard hUr + let a : FaceVertex K := + ⟨W, K.down_closed U.property.1 hWU, Finset.card_pos.mp (by omega)⟩ + refine ⟨a, hWcard, chain_insert_iff.mpr ⟨hc, ?_⟩⟩ + intro b hb + rcases lt_or_ge b.val.card r with hbr | hrb + · exact Or.inr ((hLmax b hb hbr).trans hLW) + · have hUb : U.val ⊆ b.val := + chain_subset_of_card_le hc hUc hb + (hUmin b (Finset.mem_filter.mpr ⟨hb, hrb⟩)) + exact Or.inl (hWU.trans hUb) + +/-- In a pure old complex, every flag has a common old top face above it. -/ +theorem chain_exists_top_upper {m : ℕ} (hK : K.Pure m) + {c : Finset (FaceVertex K)} (hc : K.chain c) : + ∃ T : FaceVertex K, T.val.card = m + 1 ∧ ∀ b ∈ c, b.val ⊆ T.val := by + classical + obtain ⟨s, hs, hmax⟩ : ∃ s ∈ K.topCells m, ∀ b ∈ c, b.val ⊆ s := by + rcases c.eq_empty_or_nonempty with rfl | hne + · obtain ⟨s, hs, _⟩ := hK ∅ K.empty_mem + refine ⟨s, hs, ?_⟩ + intro b hb + simp at hb + · obtain ⟨a, ha, hamax⟩ := exists_greatest hc hne + obtain ⟨s, hs, has⟩ := hK a.val a.property.1 + exact ⟨s, hs, fun b hb => (hamax b hb).trans has⟩ + let T : FaceVertex K := + ⟨s, (mem_topCells.mp hs).1, + Finset.card_pos.mp (by have h := (mem_topCells.mp hs).2; omega)⟩ + exact ⟨T, (mem_topCells.mp hs).2, hmax⟩ + +/-- Every face of the subdivision extends to an actual top flag. -/ +theorem sd_pure {m : ℕ} (hK : K.Pure m) : K.sd.Pure m := by + classical + intro c hc + let extensions := K.sd.faces.filter (fun d => c ⊆ d) + have hcExt : c ∈ extensions := + Finset.mem_filter.mpr ⟨hc, Finset.Subset.refl _⟩ + obtain ⟨d, hdExt, hdmax⟩ := extensions.exists_max_image Finset.card ⟨c, hcExt⟩ + have hdface : d ∈ K.sd.faces := (Finset.mem_filter.mp hdExt).1 + have hcd : c ⊆ d := (Finset.mem_filter.mp hdExt).2 + have hdchain := mem_sd_iff.mp hdface + have hclosed : ∀ a : FaceVertex K, K.chain (insert a d) → a ∈ d := by + intro a ha + by_contra hanot + have hinsert : insert a d ∈ extensions := + Finset.mem_filter.mpr ⟨mem_sd_iff.mpr ha, hcd.trans (Finset.subset_insert _ _)⟩ + have hle := hdmax (insert a d) hinsert + rw [Finset.card_insert_of_notMem hanot] at hle + omega + obtain ⟨T, hTcard, hTmax⟩ := chain_exists_top_upper hK hdchain + have hTd : T ∈ d := hclosed T (chain_insert_iff.mpr + ⟨hdchain, fun b hb => Or.inr (hTmax b hb)⟩) + have hranks : K.ranks d = Finset.Icc 1 (m + 1) := by + apply Finset.Subset.antisymm (ranks_subset hK.cardBound d) + intro r hr + obtain ⟨hrpos, hrtop⟩ := Finset.mem_Icc.mp hr + obtain ⟨a, hacard, hainsert⟩ := chain_exists_insert_rank hdchain + (show 0 < r by omega) (show ∃ U ∈ d, r ≤ U.val.card from + ⟨T, hTd, by rw [hTcard]; exact hrtop⟩) + exact mem_ranks.mpr ⟨a, hclosed a hainsert, hacard⟩ + have hdcard : d.card = m + 1 := by + rw [← card_ranks hdchain, hranks] + simp + exact ⟨d, mem_topCells.mpr ⟨hdface, hdcard⟩, hcd⟩ + +end Tingley.FiniteComplex + +namespace Tingley + +/-- Every face of every iterated subdivision of the simplex extends to a +top-dimensional face. The dimension-zero case is included. -/ +theorem iter_pure (m k : ℕ) : (iterData (Fin (m + 1)) k).complex.Pure m := by + classical + induction k with + | zero => + intro s hs + refine ⟨Finset.univ, FiniteComplex.mem_topCells.mpr ⟨?_, ?_⟩, + Finset.subset_univ _⟩ + · exact FiniteComplex.mem_full _ + · change (Finset.univ : Finset (Fin (m + 1))).card = m + 1 + exact Finset.card_fin (m + 1) + | succ k ih => exact FiniteComplex.sd_pure ih + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricRestriction.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1bf79cdde5bfbbca58577c1a9dbb7148b37f7ea --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricRestriction.lean @@ -0,0 +1,153 @@ +import OAI.Analysis.SphereIsometry.BarycentricFlags + +namespace OAI + +/-! # Embeddings of complexes and exact restriction under subdivision -/ + +noncomputable section + +namespace Tingley.FiniteComplex + +universe u v w z +variable {V : Type u} {W : Type v} [Fintype V] [Fintype W] +variable [DecidableEq V] [DecidableEq W] + +structure Embedding (K : FiniteComplex V) (L : FiniteComplex W) where + toEmbedding : V ↪ W + map_mem_iff : ∀ s : Finset V, s.map toEmbedding ∈ L.faces ↔ s ∈ K.faces + +namespace Embedding + +variable {K : FiniteComplex V} {L : FiniteComplex W} + +def full (e : V ↪ W) : Embedding (FiniteComplex.full : FiniteComplex V) + (FiniteComplex.full : FiniteComplex W) where + toEmbedding := e + map_mem_iff := fun _ => by simp + +def faceMap (e : Embedding K L) : FaceVertex K ↪ FaceVertex L where + toFun s := ⟨s.val.map e.toEmbedding, + (e.map_mem_iff s.val).mpr s.property.1, Finset.map_nonempty.mpr s.property.2⟩ + inj' := by + intro a b h + apply Subtype.ext + exact Finset.map_injective e.toEmbedding (congrArg Subtype.val h) + +@[simp] theorem faceMap_val (e : Embedding K L) (s : FaceVertex K) : + (e.faceMap s).val = s.val.map e.toEmbedding := rfl + +def sd (e : Embedding K L) : Embedding K.sd L.sd where + toEmbedding := e.faceMap + map_mem_iff := by + intro c + rw [mem_sd_iff, mem_sd_iff] + constructor + · intro hc a ha b hb + have h := hc (e.faceMap a) (Finset.mem_map.mpr ⟨a, ha, rfl⟩) + (e.faceMap b) (Finset.mem_map.mpr ⟨b, hb, rfl⟩) + exact h.imp Finset.map_subset_map.mp Finset.map_subset_map.mp + · intro hc a ha b hb + obtain ⟨a', ha', rfl⟩ := Finset.mem_map.mp ha + obtain ⟨b', hb', rfl⟩ := Finset.mem_map.mp hb + exact (hc a' ha' b' hb').imp Finset.map_subset_map.mpr Finset.map_subset_map.mpr + +def preimage (e : Embedding K L) (s : Finset W) : Finset V := + Finset.univ.filter (fun v => e.toEmbedding v ∈ s) + +@[simp] theorem mem_preimage (e : Embedding K L) {s : Finset W} {v : V} : + v ∈ e.preimage s ↔ e.toEmbedding v ∈ s := by + simp [preimage] + +theorem map_preimage (e : Embedding K L) (s : Finset W) + (hs : ∀ w ∈ s, ∃ v, e.toEmbedding v = w) : + (e.preimage s).map e.toEmbedding = s := by + ext w + constructor + · intro hw + obtain ⟨v, hv, rfl⟩ := Finset.mem_map.mp hw + exact (e.mem_preimage).mp hv + · intro hw + obtain ⟨v, rfl⟩ := hs w hw + exact Finset.mem_map.mpr ⟨v, e.mem_preimage.mpr hw, rfl⟩ + +theorem exists_face_preimage (e : Embedding K L) {s : Finset W} (hs : s ∈ L.faces) + (hrange : ∀ w ∈ s, ∃ v, e.toEmbedding v = w) : + ∃ t ∈ K.faces, t.map e.toEmbedding = s := by + refine ⟨e.preimage s, ?_, e.map_preimage s hrange⟩ + apply (e.map_mem_iff _).mp + rwa [e.map_preimage s hrange] + +variable {I : Type w} {J : Type z} [DecidableEq I] [DecidableEq J] + +theorem faceCarrier_map (e : Embedding K L) (i : I ↪ J) + {cV : V → Finset I} {cW : W → Finset J} + (h : ∀ v, cW (e.toEmbedding v) = (cV v).map i) (s : Finset V) : + faceCarrier cW (s.map e.toEmbedding) = (faceCarrier cV s).map i := by + ext j + constructor + · intro hj + obtain ⟨w, hw, hj⟩ := mem_faceCarrier.mp hj + obtain ⟨v, hv, rfl⟩ := Finset.mem_map.mp hw + rw [h] at hj + obtain ⟨a, ha, rfl⟩ := Finset.mem_map.mp hj + exact Finset.mem_map.mpr ⟨a, mem_faceCarrier.mpr ⟨v, hv, ha⟩, rfl⟩ + · intro hj + obtain ⟨a, ha, rfl⟩ := Finset.mem_map.mp hj + obtain ⟨v, hv, ha⟩ := mem_faceCarrier.mp ha + refine mem_faceCarrier.mpr ⟨e.toEmbedding v, + Finset.mem_map.mpr ⟨v, hv, rfl⟩, ?_⟩ + rw [h] + exact Finset.mem_map.mpr ⟨a, ha, rfl⟩ + +theorem sdCarrier_faceMap (e : Embedding K L) (i : I ↪ J) + {cV : V → Finset I} {cW : W → Finset J} + (h : ∀ v, cW (e.toEmbedding v) = (cV v).map i) (s : FaceVertex K) : + L.sdCarrier cW (e.faceMap s) = (K.sdCarrier cV s).map i := + e.faceCarrier_map i h s.val + +theorem faceMap_range_iff (e : Embedding K L) {cW : W → Finset J} {A : Finset J} + (h : ∀ w, cW w ⊆ A ↔ ∃ v, e.toEmbedding v = w) (s : FaceVertex L) : + L.sdCarrier cW s ⊆ A ↔ ∃ t : FaceVertex K, e.faceMap t = s := by + constructor + · intro hs + have hvertices : ∀ w ∈ s.val, ∃ v, e.toEmbedding v = w := by + intro w hw + apply (h w).mp + intro j hj + exact hs (mem_faceCarrier.mpr ⟨w, hw, hj⟩) + obtain ⟨t, ht, hts⟩ := e.exists_face_preimage s.property.1 hvertices + have hne : t.Nonempty := by + have : (t.map e.toEmbedding).Nonempty := hts.symm ▸ s.property.2 + exact Finset.map_nonempty.mp this + refine ⟨⟨t, ht, hne⟩, ?_⟩ + exact Subtype.ext hts + · rintro ⟨t, rfl⟩ + intro j hj + obtain ⟨w, hw, hj⟩ := mem_faceCarrier.mp hj + obtain ⟨v, hv, rfl⟩ := Finset.mem_map.mp hw + exact (h _).mpr ⟨v, rfl⟩ hj + +theorem face_range_iff (e : Embedding K L) {cW : W → Finset J} {A : Finset J} + (h : ∀ w, cW w ⊆ A ↔ ∃ v, e.toEmbedding v = w) {s : Finset W} + (hs : s ∈ L.faces) : + faceCarrier cW s ⊆ A ↔ ∃ t ∈ K.faces, t.map e.toEmbedding = s := by + constructor + · intro hsub + apply e.exists_face_preimage hs + intro w hw + apply (h w).mp + intro j hj + exact hsub (mem_faceCarrier.mpr ⟨w, hw, hj⟩) + · rintro ⟨t, ht, rfl⟩ + intro j hj + obtain ⟨w, hw, hj⟩ := mem_faceCarrier.mp hj + obtain ⟨v, hv, rfl⟩ := Finset.mem_map.mp hw + exact (h _).mpr ⟨v, rfl⟩ hj + +end Embedding + +end Tingley.FiniteComplex + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricSupport.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c6346e51745023ed21636efb4811c645f14a9b8 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricSupport.lean @@ -0,0 +1,124 @@ +import OAI.Analysis.SphereIsometry.BarycentricBasic +import Mathlib.Data.Finset.Union +import OAI.Analysis.SphereIsometry.ProbabilitySimplex + +namespace OAI + +/-! +# Supports of finite barycenters + +A nonempty average of simplex vectors is a simplex vector. Its strict-positive +coordinate support is exactly the union of the supports being averaged. +These statements concern the actual finite average and require no geometric +coverage assumption. +-/ + +noncomputable section + +open scoped BigOperators Classical + +namespace Tingley + +variable {V ι : Type*} [Fintype ι] + +/-- The coordinates at which a vector is strictly positive. -/ +def positiveCarrier (x : ι → ℝ) : Finset ι := + Finset.univ.filter (fun i => 0 < x i) + +@[simp] theorem mem_positiveCarrier {x : ι → ℝ} {i : ι} : + i ∈ positiveCarrier x ↔ 0 < x i := by + simp [positiveCarrier] + +/-- Outside the positive carrier, a nonnegative vector has zero coordinates. -/ +theorem not_mem_positiveCarrier_iff {x : ι → ℝ} (hx : ∀ i, 0 ≤ x i) (i : ι) : + i ∉ positiveCarrier x ↔ x i = 0 := by + rw [mem_positiveCarrier, not_lt] + exact ⟨fun h => le_antisymm h (hx i), fun h => h.le⟩ + +/-- Containment in a coordinate face is exactly vanishing outside that face. -/ +theorem positiveCarrier_subset_iff {x : ι → ℝ} (hx : ∀ i, 0 ≤ x i) + (I : Finset ι) : + positiveCarrier x ⊆ I ↔ ∀ i, i ∉ I → x i = 0 := by + constructor + · intro h i hi + apply (not_mem_positiveCarrier_iff hx i).mp + intro hix + exact hi (h hix) + · intro h i hi + by_contra hn + have hzero := h i hn + have hpos := mem_positiveCarrier.mp hi + rw [hzero] at hpos + exact (lt_irrefl (0 : ℝ)) hpos + +/-- Finite averaging preserves nonnegative coordinates, including for the empty set. -/ +theorem finiteBarycenter_apply_nonneg (p : V → ι → ℝ) (S : Finset V) + (hp : ∀ v ∈ S, ∀ i, 0 ≤ p v i) (i : ι) : + 0 ≤ finiteBarycenter p S i := by + rw [finiteBarycenter_apply] + exact mul_nonneg (inv_nonneg.mpr (Nat.cast_nonneg S.card)) + (Finset.sum_nonneg (fun v hv => hp v hv i)) + +/-- A nonempty finite average stays in the standard simplex. -/ +theorem finiteBarycenter_mem_stdSimplex (p : V → ι → ℝ) {S : Finset V} + (hs : S.Nonempty) (hp : ∀ v ∈ S, p v ∈ probabilitySimplexSet ι) : + finiteBarycenter p S ∈ probabilitySimplexSet ι := by + exact finiteBarycenter_mem_convex (convex_probabilitySimplexSet ι) hs hp + +/-- A coordinate of a nonempty nonnegative average is positive exactly when +one of the averaged coordinates is positive. -/ +theorem finiteBarycenter_pos_iff (p : V → ι → ℝ) {S : Finset V} + (hs : S.Nonempty) (hp : ∀ v ∈ S, ∀ i, 0 ≤ p v i) (i : ι) : + 0 < finiteBarycenter p S i ↔ ∃ v ∈ S, 0 < p v i := by + have hcard : 0 < (S.card : ℝ) := Nat.cast_pos.mpr (Finset.card_pos.mpr hs) + have hinv : 0 < (S.card : ℝ)⁻¹ := inv_pos.mpr hcard + rw [finiteBarycenter_apply] + constructor + · intro h + have hsum : 0 < ∑ v ∈ S, p v i := pos_of_mul_pos_right h hinv.le + by_contra hn + have hzero : ∀ v ∈ S, p v i = 0 := by + intro v hv + apply le_antisymm _ (hp v hv i) + exact le_of_not_gt (fun hpos => hn ⟨v, hv, hpos⟩) + have heq : ∑ v ∈ S, p v i = 0 := Finset.sum_eq_zero hzero + rw [heq] at hsum + exact (lt_irrefl (0 : ℝ)) hsum + · intro h + exact mul_pos hinv (Finset.sum_pos' (fun v hv => hp v hv i) h) + +/-- The support of a nonempty nonnegative average is the exact support union. -/ +theorem positiveCarrier_finiteBarycenter (p : V → ι → ℝ) {S : Finset V} + (hs : S.Nonempty) (hp : ∀ v ∈ S, ∀ i, 0 ≤ p v i) : + positiveCarrier (finiteBarycenter p S) = + S.biUnion (fun v => positiveCarrier (p v)) := by + ext i + simp only [mem_positiveCarrier, Finset.mem_biUnion] + exact finiteBarycenter_pos_iff p hs hp i + +/-- The new vertex belongs to an original coordinate face exactly when every +averaged vertex belongs to that face. -/ +theorem positiveCarrier_finiteBarycenter_subset_iff (p : V → ι → ℝ) + {S : Finset V} (hs : S.Nonempty) (hp : ∀ v ∈ S, ∀ i, 0 ≤ p v i) + (I : Finset ι) : + positiveCarrier (finiteBarycenter p S) ⊆ I ↔ + ∀ v ∈ S, positiveCarrier (p v) ⊆ I := by + rw [positiveCarrier_finiteBarycenter p hs hp] + exact Finset.biUnion_subset + +/-- A simplex vector has a positive coordinate because its total mass is one. -/ +theorem positiveCarrier_nonempty_of_mem_stdSimplex {x : ι → ℝ} + (hx : x ∈ probabilitySimplexSet ι) : (positiveCarrier x).Nonempty := by + by_contra hn + have hzero : ∀ i, x i = 0 := by + intro i + apply le_antisymm _ (hx.1 i) + exact le_of_not_gt (fun hpos => hn ⟨i, mem_positiveCarrier.mpr hpos⟩) + have hsum : ∑ i, x i = 0 := Finset.sum_eq_zero (fun i _ => hzero i) + exact one_ne_zero (hx.2.symm.trans hsum) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/BarycentricZero.lean b/lean/OAI/Analysis/SphereIsometry/BarycentricZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e6c72637f2f2e0f0b88e87cb44cd4b992a407b0 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/BarycentricZero.lean @@ -0,0 +1,119 @@ +import OAI.Analysis.SphereIsometry.BarycentricFlags +import OAI.Analysis.SphereIsometry.SubdivisionData + +namespace OAI + +/-! +# The zero-dimensional subdivision and its empty codimension-one face + +The subdivision of a zero-dimensional complex has one vertex for each old +singleton face. In particular, iterated subdivision of the point has one +top face, incident to its unique empty codimension-one face. +-/ + +noncomputable section + +namespace Tingley.FiniteComplex + +universe u +variable {V : Type u} [Fintype V] [DecidableEq V] +variable {K : FiniteComplex V} + +@[simp] theorem incidentTop_empty (K : FiniteComplex V) (m : ℕ) : + K.incidentTop m ∅ = K.topCells m := by + classical + ext s + simp [incidentTop] + +theorem sd_topCells_zero_card (hK : K.CardBound 0) : + (K.sd.topCells 0).card = (K.topCells 0).card := by + classical + let v : ∀ s ∈ K.topCells 0, FaceVertex K := fun s hs => + ⟨s, (mem_topCells.mp hs).1, + Finset.card_pos.mp (by have h := (mem_topCells.mp hs).2; omega)⟩ + let f : ∀ s ∈ K.topCells 0, Finset (FaceVertex K) := fun s hs => {v s hs} + have hf : ∀ s hs, f s hs ∈ K.sd.topCells 0 := by + intro s hs + apply mem_topCells.mpr + constructor + · apply mem_sd_iff.mpr + change K.chain {v s hs} + simp [chain] + · change ({v s hs} : Finset (FaceVertex K)).card = 0 + 1 + simp + have hinj : ∀ s hs t ht, f s hs = f t ht → s = t := by + intro s hs t ht h + have hv : v s hs = v t ht := Finset.singleton_inj.mp h + exact congrArg Subtype.val hv + have hsurj : ∀ c ∈ K.sd.topCells 0, ∃ s hs, f s hs = c := by + intro c hc + obtain ⟨hcface, hccard⟩ := mem_topCells.mp hc + obtain ⟨a, rfl⟩ := Finset.card_eq_one.mp (show c.card = 1 by omega) + have hacard : a.val.card = 0 + 1 := by + have hlo := Finset.card_pos.mpr a.property.2 + have hhi := hK a.val a.property.1 + omega + have ha : a.val ∈ K.topCells 0 := mem_topCells.mpr ⟨a.property.1, hacard⟩ + refine ⟨a.val, ha, ?_⟩ + change ({v a.val ha} : Finset (FaceVertex K)) = {a} + congr 1 + exact (Finset.card_bij f hf hinj hsurj).symm + +theorem sd_pure_zero (hK : K.Pure 0) : K.sd.Pure 0 := by + classical + intro c hc + rcases c.eq_empty_or_nonempty with rfl | hne + · obtain ⟨s, hs, _⟩ := hK ∅ K.empty_mem + let a : FaceVertex K := ⟨s, (mem_topCells.mp hs).1, + Finset.card_pos.mp (by have h := (mem_topCells.mp hs).2; omega)⟩ + refine ⟨{a}, mem_topCells.mpr ⟨mem_sd_iff.mpr ?_, by simp⟩, + Finset.empty_subset _⟩ + simp [chain] + · refine ⟨c, mem_topCells.mpr ⟨hc, ?_⟩, Finset.Subset.refl _⟩ + have hlo := Finset.card_pos.mpr hne + have hhi := sd_cardBound hK.cardBound c hc + omega + +end Tingley.FiniteComplex + +namespace Tingley + +theorem iter_topCells_zero_card (k : ℕ) : (topCells 0 k).card = 1 := by + classical + induction k with + | zero => + change ((FiniteComplex.full : FiniteComplex (Fin 1)).topCells 0).card = 1 + have hfull : (FiniteComplex.full : FiniteComplex (Fin 1)).topCells 0 = + {Finset.univ} := by + ext s + simp only [FiniteComplex.mem_topCells, FiniteComplex.mem_full, + true_and, Finset.mem_singleton] + constructor + · intro hs + apply Finset.eq_of_subset_of_card_le (Finset.subset_univ _) + simpa using hs.ge + · rintro rfl + simp + rw [hfull] + simp + | succ k ih => + change (((iterData (Fin 1) k).complex).sd.topCells 0).card = 1 + have hK : (iterData (Fin 1) k).complex.CardBound 0 := by + intro s hs + exact iter_card_le (m := 0) (k := k) hs + rw [FiniteComplex.sd_topCells_zero_card hK] + exact ih + +theorem iter_incidentTop_zero_card (k : ℕ) {c : Finset (IterVertex 0 k)} + (hc : c ∈ codimFaces 0 k) : (incidentTop 0 k c).card = 1 := by + have hczero : c = ∅ := Finset.card_eq_zero.mp (mem_codimFaces.mp hc).2 + subst c + change ((iterData (Fin 1) k).complex.incidentTop 0 ∅).card = 1 + rw [FiniteComplex.incidentTop_empty] + exact iter_topCells_zero_card k + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/Basic.lean b/lean/OAI/Analysis/SphereIsometry/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..556114282eab92007048272cd929fc18903066e3 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Basic.lean @@ -0,0 +1,176 @@ +import OAI.Analysis.SphereIsometry.Model +import Mathlib.Tactic.Abel +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +namespace OAI + +/-! +# Sphere maps and the maximal cross-radius defect + +The sphere carries the ambient distance. All defects below use the actual sphere +isometry and ordinary real scalar multiplication; no extension law is assumed. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +omit [NormedSpace ℝ X] in +@[simp] theorem UnitSphere.norm_coe (x : UnitSphere X) : ‖(x : X)‖ = 1 := x.property + +omit [NormedSpace ℝ X] in +theorem UnitSphere.coe_ne_zero (x : UnitSphere X) : (x : X) ≠ 0 := by + intro h + have hx := x.property + simp [h] at hx + +@[simp] theorem normalize_coe (x : X) (hx : x ≠ 0) : + (normalize x hx : X) = ‖x‖⁻¹ • x := rfl + +theorem norm_smul_normalize (x : X) (hx : x ≠ 0) : + ‖x‖ • (normalize x hx : X) = x := by + rw [normalize_coe, smul_smul, mul_inv_cancel₀ (norm_ne_zero_iff.mpr hx), one_smul] + +instance UnitSphere.instNonempty [Nontrivial X] : Nonempty (UnitSphere X) := by + obtain ⟨x, hx⟩ := exists_ne (0 : X) + exact ⟨normalize x hx⟩ + +omit [NormedSpace ℝ X] [NormedSpace ℝ Y] in +theorem sphere_norm_sub (f : UnitSphere X ≃ᵢ UnitSphere Y) (x y : UnitSphere X) : + ‖(f x : Y) - (f y : Y)‖ = ‖(x : X) - (y : X)‖ := by + simpa only [Subtype.dist_eq, dist_eq_norm] using f.dist_eq x y + +def signedDefect (f : UnitSphere X ≃ᵢ UnitSphere Y) (q : ℝ) + (x y : UnitSphere X) : ℝ := + ‖(f x : Y) - q • (f y : Y)‖ - ‖(x : X) - q • (y : X)‖ + +def HasDefectBound (f : UnitSphere X ≃ᵢ UnitSphere Y) (M : ℝ) : Prop := + ∀ q ∈ Set.Icc (0 : ℝ) 1, ∀ x y : UnitSphere X, |signedDefect f q x y| ≤ M + +def absoluteDefects (f : UnitSphere X ≃ᵢ UnitSphere Y) : Set ℝ := + {d | ∃ q ∈ Set.Icc (0 : ℝ) 1, ∃ x y : UnitSphere X, d = |signedDefect f q x y|} + +def maxDefect (f : UnitSphere X ≃ᵢ UnitSphere Y) : ℝ := sSup (absoluteDefects f) + +@[simp] theorem signedDefect_zero (f : UnitSphere X ≃ᵢ UnitSphere Y) + (x y : UnitSphere X) : signedDefect f 0 x y = 0 := by + simp [signedDefect] + +@[simp] theorem signedDefect_one (f : UnitSphere X ≃ᵢ UnitSphere Y) + (x y : UnitSphere X) : signedDefect f 1 x y = 0 := by + simp [signedDefect, sphere_norm_sub] + +theorem signedDefect_symm (f : UnitSphere X ≃ᵢ UnitSphere Y) + (q : ℝ) (x y : UnitSphere X) : + signedDefect f.symm q (f x) (f y) = -signedDefect f q x y := by + simp only [signedDefect, IsometryEquiv.symm_apply_apply] + ring + +theorem HasDefectBound.symm {f : UnitSphere X ≃ᵢ UnitSphere Y} {M : ℝ} + (h : HasDefectBound f M) : HasDefectBound f.symm M := by + intro q hq x y + obtain ⟨a, rfl⟩ := f.surjective x + obtain ⟨b, rfl⟩ := f.surjective y + simpa only [signedDefect_symm, abs_neg] using h q hq a b + +theorem norm_sub_smul_lipschitz (x : X) (y : UnitSphere X) (q r : ℝ) : + |‖x - q • (y : X)‖ - ‖x - r • (y : X)‖| ≤ |q - r| := by + calc + |‖x - q • (y : X)‖ - ‖x - r • (y : X)‖| ≤ + ‖(x - q • (y : X)) - (x - r • (y : X))‖ := abs_norm_sub_norm_le _ _ + _ = ‖(r - q) • (y : X)‖ := by + congr 1 + rw [sub_smul] + abel + _ = |q - r| := by simp [norm_smul, Real.norm_eq_abs, abs_sub_comm] + +theorem signedDefect_lipschitz (f : UnitSphere X ≃ᵢ UnitSphere Y) + (q r : ℝ) (x y : UnitSphere X) : + |signedDefect f q x y - signedDefect f r x y| ≤ 2 * |q - r| := by + have hx := norm_sub_smul_lipschitz (x : X) y q r + have hy := norm_sub_smul_lipschitz (f x : Y) (f y) q r + have ht := abs_sub + (‖(f x : Y) - q • (f y : Y)‖ - ‖(f x : Y) - r • (f y : Y)‖) + (‖(x : X) - q • (y : X)‖ - ‖(x : X) - r • (y : X)‖) + have he : signedDefect f q x y - signedDefect f r x y = + (‖(f x : Y) - q • (f y : Y)‖ - ‖(f x : Y) - r • (f y : Y)‖) - + (‖(x : X) - q • (y : X)‖ - ‖(x : X) - r • (y : X)‖) := by + unfold signedDefect + ring + rw [he] + linarith + +theorem signedDefect_le_endpoints (f : UnitSphere X ≃ᵢ UnitSphere Y) + {q : ℝ} (hq : q ∈ Set.Icc (0 : ℝ) 1) (x y : UnitSphere X) : + |signedDefect f q x y| ≤ 2 * q ∧ + |signedDefect f q x y| ≤ 2 * (1 - q) := by + constructor + · simpa [abs_of_nonneg hq.1] using signedDefect_lipschitz f q 0 x y + · simpa [abs_of_nonpos (sub_nonpos.mpr hq.2)] using + signedDefect_lipschitz f q 1 x y + +theorem signedDefect_abs_le_one (f : UnitSphere X ≃ᵢ UnitSphere Y) + {q : ℝ} (hq : q ∈ Set.Icc (0 : ℝ) 1) (x y : UnitSphere X) : + |signedDefect f q x y| ≤ 1 := by + obtain ⟨h0, h1⟩ := signedDefect_le_endpoints f hq x y + linarith + +theorem absoluteDefects_bddAbove (f : UnitSphere X ≃ᵢ UnitSphere Y) : + BddAbove (absoluteDefects f) := by + refine ⟨1, ?_⟩ + rintro d ⟨q, hq, x, y, rfl⟩ + exact signedDefect_abs_le_one f hq x y + +theorem zero_mem_absoluteDefects [Nonempty (UnitSphere X)] + (f : UnitSphere X ≃ᵢ UnitSphere Y) : 0 ∈ absoluteDefects f := by + let x : UnitSphere X := Classical.choice inferInstance + exact ⟨0, ⟨le_rfl, zero_le_one⟩, x, x, by simp⟩ + +theorem hasDefectBound_maxDefect (f : UnitSphere X ≃ᵢ UnitSphere Y) : + HasDefectBound f (maxDefect f) := by + intro q hq x y + exact le_csSup (absoluteDefects_bddAbove f) ⟨q, hq, x, y, rfl⟩ + +theorem maxDefect_nonneg [Nonempty (UnitSphere X)] + (f : UnitSphere X ≃ᵢ UnitSphere Y) : 0 ≤ maxDefect f := + le_csSup (absoluteDefects_bddAbove f) (zero_mem_absoluteDefects f) + +theorem maxDefect_le_one [Nonempty (UnitSphere X)] + (f : UnitSphere X ≃ᵢ UnitSphere Y) : maxDefect f ≤ 1 := by + apply csSup_le ⟨0, zero_mem_absoluteDefects f⟩ + rintro d ⟨q, hq, x, y, rfl⟩ + exact signedDefect_abs_le_one f hq x y + +theorem absoluteDefects_symm (f : UnitSphere X ≃ᵢ UnitSphere Y) : + absoluteDefects f.symm = absoluteDefects f := by + ext d + constructor + · rintro ⟨q, hq, x, y, hd⟩ + obtain ⟨a, rfl⟩ := f.surjective x + obtain ⟨b, rfl⟩ := f.surjective y + exact ⟨q, hq, a, b, by simpa only [signedDefect_symm, abs_neg] using hd⟩ + · rintro ⟨q, hq, x, y, hd⟩ + exact ⟨q, hq, f x, f y, by simpa only [signedDefect_symm, abs_neg] using hd⟩ + +@[simp] theorem maxDefect_symm (f : UnitSphere X ≃ᵢ UnitSphere Y) : + maxDefect f.symm = maxDefect f := by + unfold maxDefect + rw [absoluteDefects_symm] + +theorem signedDefect_eq_zero_of_bound_zero {f : UnitSphere X ≃ᵢ UnitSphere Y} + (h : HasDefectBound f 0) {q : ℝ} (hq : q ∈ Set.Icc (0 : ℝ) 1) + (x y : UnitSphere X) : signedDefect f q x y = 0 := by + exact abs_nonpos_iff.mp (h q hq x y) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ChordContradiction.lean b/lean/OAI/Analysis/SphereIsometry/ChordContradiction.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c2abe0267c10351b50972ba7e798a9ba4f1acec --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ChordContradiction.lean @@ -0,0 +1,52 @@ +import OAI.Analysis.SphereIsometry.LargeChord +import OAI.Analysis.SphereIsometry.SmallChord + +namespace OAI + +/-! A genuinely aligned positive-defect configuration is impossible. -/ + +namespace Tingley + +variable {X Y : Type*} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] +variable {f : UnitSphere X ≃ᵢ UnitSphere Y} {y : UnitSphere X} {t M : ℝ} + +/-- The global bound and the actual aligned chords contradict one another. +The two small-regime inequalities are proved from the original and literal +inverse configurations; neither is an additional caller premise. -/ +theorem alignedConfiguration_impossible (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (C : AlignedConfiguration f y t M) : False := by + obtain ⟨hA, hB⟩ := C.small_ratios hM ht hb + have heA := C.small_secant_product hM ht hb hB + have heB : 1 - t ≤ C.d * C.B * (1 - C.A) := by + have hA' : C.inverse.B ≤ 1 - t := by + simpa only [AlignedConfiguration.inverse_B] using hA + have h := C.inverse.small_secant_product hM ht hb.symm hA' + simpa only [AlignedConfiguration.inverse_d, AlignedConfiguration.inverse_A, + AlignedConfiguration.inverse_B] using h + have hx : ‖t • (y : X) + C.p • (C.v : X)‖ = 1 := by + rw [← C.x_eq] + exact C.x.property + have hfx : ‖t • (f y : Y) + C.s • (C.w : Y)‖ = 1 := by + rw [← C.fx_eq] + exact (f C.x).property + have hleft : (1 - t) • (y : X) + C.r • (C.v : X) = (y : X) - (C.z : X) := by + rw [C.z_eq] + module + have hright : (1 - t) • (f y : Y) + C.u • (C.w : Y) = + (f y : Y) - (f C.z : Y) := by + rw [C.fz_eq] + module + have hiso : ‖(1 - t) • (y : X) + C.r • (C.v : X)‖ = + ‖(1 - t) • (f y : Y) + C.u • (C.w : Y)‖ := by + rw [hleft, hright] + exact (sphere_norm_sub f y C.z).symm + exact smallChord_contradiction (y : X) (C.v : X) (f y : Y) (C.w : Y) + (t := t) (ε := 1 - t) (d := C.d) (A := C.A) (B := C.B) + ht.2 rfl C.p_pos C.r_pos C.s_pos C.u_pos rfl C.chord_sum C.chord_le_two + rfl rfl (C.A_add_B_lt_one hM) hA hB heA heB y.property (f y).property hx hfx hiso + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ChordSecant.lean b/lean/OAI/Analysis/SphereIsometry/ChordSecant.lean new file mode 100644 index 0000000000000000000000000000000000000000..74cc73674e7ee9ef902215b123be2c2006001811 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ChordSecant.lean @@ -0,0 +1,271 @@ +import OAI.Analysis.SphereIsometry.AlignedConfiguration +import OAI.Analysis.SphereIsometry.Supports +import Mathlib.Analysis.Normed.Module.RCLike.Real +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Module +import Mathlib.Tactic.Positivity + +namespace OAI + +/-! The secant estimate for every supporting functional of an aligned chord. -/ + +noncomputable section + +namespace Tingley + +variable {X Y : Type*} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- The lower support bound uses the actual unit endpoint, and holds for every +support at an earlier positive point of the same affine line. -/ +theorem support_direction_lower {v y : X} {p t θ : ℝ} + (hy : ‖y‖ = 1) (hp : 0 < p) (ht : 0 < t) + (hθ : 0 < θ) (hθβ : θ ≤ t / p) + (hx : ‖p • v + t • y‖ = 1) + (φ : X →L[ℝ] ℝ) (hφ : SupportAt φ (v + θ • y)) : + (1 - t) / p ≤ φ v := by + have hpb : p * (t / p) = t := by field_simp [hp.ne'] + have hscale : p • (v + (t / p) • y) = p • v + t • y := by + rw [smul_add, smul_smul, hpb] + have hn : p * ‖v + (t / p) • y‖ = 1 := by + rw [← norm_smul_of_nonneg hp.le, hscale, hx] + have endpoint_lower : ∀ ψ : X →L[ℝ] ℝ, + SupportAt ψ (v + (t / p) • y) → 1 - t ≤ p * ψ v := by + intro ψ hψ + have hyψ : ψ y ≤ 1 := by simpa only [hy] using apply_le_norm hψ.1 y + have he := congrArg (fun a : ℝ => p * a) hψ.2 + simp only [map_add, map_smul, smul_eq_mul] at he + rw [mul_add, ← mul_assoc, hpb, hn] at he + have htψ := mul_le_mul_of_nonneg_left hyψ ht.le + nlinarith + apply (div_le_iff₀ hp).2 + rcases lt_or_eq_of_le hθβ with hlt | heq + · obtain ⟨ψ, hψ⟩ := exists_support (v + (t / p) • y) + have h₁ := apply_le_norm hφ.1 (v + (t / p) • y) + have h₂ := apply_le_norm hψ.1 (v + θ • y) + rw [← hψ.2] at h₁ + rw [← hφ.2] at h₂ + simp only [map_add, map_smul, smul_eq_mul] at h₁ h₂ + have hk : 0 ≤ ψ y - φ y := by + by_contra hk + have hprod := mul_neg_of_pos_of_neg (sub_pos.mpr hlt) (lt_of_not_ge hk) + nlinarith + have hprod := mul_nonneg hθ.le hk + have hv : ψ v ≤ φ v := by nlinarith + have hvp := mul_le_mul_of_nonneg_left hv hp.le + have hend := endpoint_lower ψ hψ + nlinarith + · have hend := endpoint_lower φ (by simpa only [heq] using hφ) + nlinarith + +namespace AlignedConfiguration + +variable {f : UnitSphere X ≃ᵢ UnitSphere Y} {y : UnitSphere X} {t M : ℝ} +variable (C : AlignedConfiguration f y t M) + +def secantStep : ℝ := min (t / C.s) ((1 - t) / C.u) +def secantTheta : ℝ := C.secantStep * C.s / C.p +def secantSlope : ℝ := + (‖(C.r / C.u) • (C.v : X) + C.secantStep • (y : X)‖ - + ‖(C.p / C.s) • (C.v : X) + C.secantStep • (y : X)‖) / + (C.r / C.u - C.p / C.s) + +theorem secantStep_pos (ht : 0 < t ∧ t < 1) : 0 < C.secantStep := + lt_min (div_pos ht.1 C.s_pos) (div_pos (sub_pos.mpr ht.2) C.u_pos) + +theorem secantTheta_pos (ht : 0 < t ∧ t < 1) : 0 < C.secantTheta := + div_pos (mul_pos (C.secantStep_pos ht) C.s_pos) C.p_pos + +theorem secantTheta_le (_ht : 0 < t ∧ t < 1) : C.secantTheta ≤ t / C.p := by + apply (div_le_div_iff_of_pos_right C.p_pos).2 + calc + C.secantStep * C.s ≤ (t / C.s) * C.s := + mul_le_mul_of_nonneg_right (min_le_left _ _) C.s_pos.le + _ = t := div_mul_cancel₀ _ C.s_pos.ne' + +theorem secant_denominator_pos (hM : 0 < M) : 0 < C.r / C.u - C.p / C.s := by + have hid := C.chord_identity + have hprod : 0 < M * C.d := mul_pos hM C.d_pos + have hlt : C.p / C.s < C.r / C.u := by + apply (div_lt_div_iff₀ C.s_pos C.u_pos).2 + nlinarith + exact sub_pos.mpr hlt + +theorem step_comparison_iff : t / C.s ≤ (1 - t) / C.u ↔ C.B ≤ 1 - t := by + rw [div_le_div_iff₀ C.s_pos C.u_pos] + change t * C.u ≤ (1 - t) * C.s ↔ C.u / C.d ≤ 1 - t + rw [div_le_iff₀ C.d_pos] + have hd : C.d = C.s + C.u := C.chord_sum + rw [hd] + constructor <;> intro h <;> nlinarith + +theorem secantStep_eq_smallB (hB : C.B ≤ 1 - t) : C.secantStep = t / C.s := + min_eq_left ((C.step_comparison_iff).2 hB) + +theorem secantStep_eq_largeB (_ht : 0 < t ∧ t < 1) (hB : 1 - t < C.B) : + C.secantStep = (1 - t) / C.u := by + apply min_eq_right + exact (lt_of_not_ge fun h => (not_le_of_gt hB) ((C.step_comparison_iff).1 h)).le + +theorem secant_radii_mem (ht : 0 < t ∧ t < 1) : + t - C.s * C.secantStep ∈ Set.Icc (0 : ℝ) 1 ∧ + t + C.u * C.secantStep ∈ Set.Icc (0 : ℝ) 1 := by + have hh := (C.secantStep_pos ht).le + have hs := mul_le_mul_of_nonneg_right + (show C.secantStep ≤ t / C.s from min_le_left _ _) C.s_pos.le + have hu := mul_le_mul_of_nonneg_right + (show C.secantStep ≤ (1 - t) / C.u from min_le_right _ _) C.u_pos.le + rw [div_mul_cancel₀ _ C.s_pos.ne'] at hs + rw [div_mul_cancel₀ _ C.u_pos.ne'] at hu + have hsh := mul_nonneg C.s_pos.le hh + have huh := mul_nonneg C.u_pos.le hh + constructor <;> constructor <;> nlinarith [ht.1, ht.2] + +theorem secant_defect_first : + signedDefect f (t - C.s * C.secantStep) C.x y = + C.s * (‖(C.w : Y) + C.secantStep • (f y : Y)‖ - + ‖(C.p / C.s) • (C.v : X) + C.secantStep • (y : X)‖) := by + have hsp : C.s * (C.p / C.s) = C.p := by field_simp [C.s_pos.ne'] + have hx : (C.x : X) - (t - C.s * C.secantStep) • (y : X) = + C.s • ((C.p / C.s) • (C.v : X) + C.secantStep • (y : X)) := by + rw [C.x_eq, smul_add, smul_smul, hsp] + module + have hfx : (f C.x : Y) - (t - C.s * C.secantStep) • (f y : Y) = + C.s • ((C.w : Y) + C.secantStep • (f y : Y)) := by + rw [C.fx_eq] + module + rw [signedDefect, hx, hfx, norm_smul_of_nonneg C.s_pos.le, + norm_smul_of_nonneg C.s_pos.le] + ring + +theorem secant_defect_opposite : + -signedDefect f (t + C.u * C.secantStep) C.z y = + C.u * (‖(C.r / C.u) • (C.v : X) + C.secantStep • (y : X)‖ - + ‖(C.w : Y) + C.secantStep • (f y : Y)‖) := by + have hur : C.u * (C.r / C.u) = C.r := by field_simp [C.u_pos.ne'] + have hz : (C.z : X) - (t + C.u * C.secantStep) • (y : X) = + -(C.u • ((C.r / C.u) • (C.v : X) + C.secantStep • (y : X))) := by + rw [C.z_eq, smul_add, smul_smul, hur] + module + have hfz : (f C.z : Y) - (t + C.u * C.secantStep) • (f y : Y) = + -(C.u • ((C.w : Y) + C.secantStep • (f y : Y))) := by + rw [C.fz_eq] + module + rw [signedDefect, hz, hfz, norm_neg, norm_neg, + norm_smul_of_nonneg C.u_pos.le, norm_smul_of_nonneg C.u_pos.le] + ring + +theorem secant_weighted_identity (hM : 0 < M) : + M * C.secantSlope = + (C.u * signedDefect f (t - C.s * C.secantStep) C.x y + + C.s * (-signedDefect f (t + C.u * C.secantStep) C.z y)) / C.d := by + rw [C.secant_defect_first, C.secant_defect_opposite] + unfold secantSlope + have hd : C.r / C.u - C.p / C.s = M * C.d / (C.u * C.s) := by + have hid := C.chord_identity + field_simp [C.u_pos.ne', C.s_pos.ne'] + nlinarith + rw [hd] + field_simp [hM.ne', C.d_pos.ne', C.u_pos.ne', C.s_pos.ne'] + ring + +theorem secant_upper_smallB (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hB : C.B ≤ 1 - t) : + C.secantSlope ≤ 1 - C.B := by + have hq := (C.secant_radii_mem ht).2 + have hd := (abs_le.mp (hb _ hq C.z y)).1 + have hz : t - C.s * C.secantStep = 0 := by + rw [C.secantStep_eq_smallB hB] + field_simp [C.s_pos.ne'] + ring + have hi := C.secant_weighted_identity hM + rw [hz, signedDefect_zero, mul_zero, zero_add] at hi + have hle : C.s * (-signedDefect f (t + C.u * C.secantStep) C.z y) ≤ + C.s * M := mul_le_mul_of_nonneg_left (by linarith) C.s_pos.le + have hi' := (eq_div_iff C.d_pos.ne').1 hi + rw [C.one_sub_B] + apply (le_div_iff₀ C.d_pos).2 + apply (mul_le_mul_iff_right₀ hM).mp + calc + M * (C.secantSlope * C.d) = (M * C.secantSlope) * C.d := by ring + _ = C.s * (-signedDefect f (t + C.u * C.secantStep) C.z y) := hi' + _ ≤ C.s * M := hle + _ = M * C.s := mul_comm _ _ + +theorem secant_upper_largeB (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hB : 1 - t < C.B) : + C.secantSlope ≤ C.B := by + have hq := (C.secant_radii_mem ht).1 + have hd := (abs_le.mp (hb _ hq C.x y)).2 + have ho : t + C.u * C.secantStep = 1 := by + rw [C.secantStep_eq_largeB ht hB] + field_simp [C.u_pos.ne'] + ring + have hi := C.secant_weighted_identity hM + rw [ho, signedDefect_one, neg_zero, mul_zero, add_zero] at hi + have hle := mul_le_mul_of_nonneg_left hd C.u_pos.le + have hi' := (eq_div_iff C.d_pos.ne').1 hi + change C.secantSlope ≤ C.u / C.d + apply (le_div_iff₀ C.d_pos).2 + apply (mul_le_mul_iff_right₀ hM).mp + calc + M * (C.secantSlope * C.d) = (M * C.secantSlope) * C.d := by ring + _ = C.u * signedDefect f (t - C.s * C.secantStep) C.x y := hi' + _ ≤ C.u * M := hle + _ = M * C.u := mul_comm _ _ + +/-- No support is selected in this statement: it applies to every norm-bounded +functional norming the displayed vector, including the support reused in the +strictness argument. -/ +theorem secant_bounds (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (φ : X →L[ℝ] ℝ) + (hφ : SupportAt φ ((C.v : X) + C.secantTheta • (y : X))) : + (1 - t) / C.p ≤ φ C.v ∧ φ C.v ≤ C.secantSlope ∧ + (C.B ≤ 1 - t → C.secantSlope ≤ 1 - C.B) ∧ + (1 - t < C.B → C.secantSlope ≤ C.B) := by + have hlower : (1 - t) / C.p ≤ φ C.v := by + apply support_direction_lower y.property C.p_pos ht.1 + (C.secantTheta_pos ht) (C.secantTheta_le ht) _ φ hφ + rw [add_comm, ← C.x_eq] + exact C.x.property + have hα : 0 < C.p / C.s := div_pos C.p_pos C.s_pos + have hαθ : (C.p / C.s) * C.secantTheta = C.secantStep := by + unfold secantTheta + field_simp [C.p_pos.ne', C.s_pos.ne'] + have hscale : (C.p / C.s) • ((C.v : X) + C.secantTheta • (y : X)) = + (C.p / C.s) • (C.v : X) + C.secantStep • (y : X) := by + rw [smul_add, smul_smul, hαθ] + have hlo : SupportAt φ + ((C.p / C.s) • (C.v : X) + C.secantStep • (y : X)) := by + rw [← hscale] + exact hφ.smul_nonneg hα.le + have hdiff : + ((C.r / C.u) • (C.v : X) + C.secantStep • (y : X)) - + ((C.p / C.s) • (C.v : X) + C.secantStep • (y : X)) = + (C.r / C.u - C.p / C.s) • (C.v : X) := by module + have hsec := hlo.subgradient + ((C.r / C.u) • (C.v : X) + C.secantStep • (y : X)) + rw [hdiff, map_smul, smul_eq_mul] at hsec + have hupper : φ C.v ≤ C.secantSlope := by + apply (le_div_iff₀ (C.secant_denominator_pos hM)).2 + nlinarith + exact ⟨hlower, hupper, C.secant_upper_smallB hM ht hb, + C.secant_upper_largeB hM ht hb⟩ + +theorem small_secant_product (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hB : C.B ≤ 1 - t) : + 1 - t ≤ C.d * C.A * (1 - C.B) := by + obtain ⟨φ, hφ⟩ := exists_support ((C.v : X) + C.secantTheta • (y : X)) + obtain ⟨hlower, hsec, hsmall, _⟩ := C.secant_bounds hM ht hb φ hφ + have hle := hlower.trans (hsec.trans (hsmall hB)) + calc + 1 - t ≤ (1 - C.B) * C.p := (div_le_iff₀ C.p_pos).1 hle + _ = C.d * C.A * (1 - C.B) := by rw [← C.p_eq_d_mul_A]; ring + +end AlignedConfiguration +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/CoefficientBins.lean b/lean/OAI/Analysis/SphereIsometry/CoefficientBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..473f053a28b9a4cb1e4ffda755c24c30b8f2e72a --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/CoefficientBins.lean @@ -0,0 +1,94 @@ +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Algebra.Order.Floor.Semiring +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Data.Fintype.Pi +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Finite bins for probability coefficients + +An integer floor grid partitions the coefficient simplex into finitely many +parts of arbitrarily small l1 diameter. The proof uses only the Archimedean +property and finite sums, and also applies when the coefficient index is empty. +-/ + +open scoped BigOperators + +namespace Tingley + +/-- Nonnegative coefficients with total mass one. -/ +def CoefficientSimplex (n : ℕ) : Set (Fin n → ℝ) := + {w | (∀ i, 0 ≤ w i) ∧ ∑ i, w i = 1} + +private theorem coefficient_le_one {n : ℕ} {w : Fin n → ℝ} + (hw : w ∈ CoefficientSimplex n) (i : Fin n) : w i ≤ 1 := by + calc + w i ≤ ∑ j, w j := + Finset.single_le_sum (fun j _ => hw.1 j) (Finset.mem_univ i) + _ = 1 := hw.2 + +private theorem abs_sub_lt_of_same_floor {K a b : ℝ} {q : ℕ} + (hK : 0 < K) (ha : 0 ≤ a) (hb : 0 ≤ b) + (hqa : Nat.floor (K * a) = q) (hqb : Nat.floor (K * b) = q) : + |a - b| < 1 / K := by + have ha' := (Nat.floor_eq_iff (mul_nonneg hK.le ha)).mp hqa + have hb' := (Nat.floor_eq_iff (mul_nonneg hK.le hb)).mp hqb + have hab : a - b < 1 / K := by + apply (lt_div_iff₀' hK).mpr + nlinarith only [ha'.2, hb'.1] + have hba : b - a < 1 / K := by + apply (lt_div_iff₀' hK).mpr + nlinarith only [hb'.2, ha'.1] + exact abs_lt.mpr ⟨by linarith only [hba], hab⟩ + +/-- A finite family of coefficient bins with l1 diameter at most `η`. + +The label type has `(K + 1)^n` elements. The last coordinate label retains +coefficients equal to one. For `n = 0`, the simplex and all bins are empty; +no nonemptiness hypothesis on the coefficient index is needed. +-/ +theorem exists_coefficient_bins (n : ℕ) (η : ℝ) (hη : 0 < η) : + ∃ K : ℕ, ∃ bins : (Fin n → Fin (K + 1)) → Set (Fin n → ℝ), + (∀ w ∈ CoefficientSimplex n, ∃ q, w ∈ bins q) ∧ + (∀ q, ∀ w ∈ bins q, ∀ v ∈ bins q, ∑ i, |w i - v i| ≤ η) := by + obtain ⟨K, hgrid⟩ := exists_nat_gt ((n : ℝ) / η) + have hK : (0 : ℝ) < K := + lt_of_le_of_lt (div_nonneg (Nat.cast_nonneg n) hη.le) hgrid + have hsmall : (n : ℝ) / K < η := by + apply (div_lt_iff₀ hK).mpr + simpa only [mul_comm] using (div_lt_iff₀ hη).mp hgrid + let bins : (Fin n → Fin (K + 1)) → Set (Fin n → ℝ) := fun q => + {w | w ∈ CoefficientSimplex n ∧ + ∀ i, Nat.floor ((K : ℝ) * w i) = (q i).val} + refine ⟨K, bins, ?_, ?_⟩ + · intro w hw + have hcode (i : Fin n) : Nat.floor ((K : ℝ) * w i) < K + 1 := by + apply Nat.lt_succ_of_le + apply Nat.floor_le_of_le + simpa only [mul_one] using + mul_le_mul_of_nonneg_left (coefficient_le_one hw i) hK.le + let q : Fin n → Fin (K + 1) := fun i => + ⟨Nat.floor ((K : ℝ) * w i), hcode i⟩ + refine ⟨q, ?_⟩ + change w ∈ CoefficientSimplex n ∧ + ∀ i, Nat.floor ((K : ℝ) * w i) = (q i).val + exact ⟨hw, fun _ => rfl⟩ + · intro q w hw v hv + change (w ∈ CoefficientSimplex n ∧ + ∀ i, Nat.floor ((K : ℝ) * w i) = (q i).val) at hw + change (v ∈ CoefficientSimplex n ∧ + ∀ i, Nat.floor ((K : ℝ) * v i) = (q i).val) at hv + have hcoord (i : Fin n) : |w i - v i| < 1 / (K : ℝ) := + abs_sub_lt_of_same_floor hK (hw.1.1 i) (hv.1.1 i) (hw.2 i) (hv.2 i) + calc + ∑ i, |w i - v i| ≤ ∑ _i : Fin n, 1 / (K : ℝ) := + Finset.sum_le_sum (fun i _ => (hcoord i).le) + _ = (n : ℝ) / K := by + rw [Finset.sum_const, Finset.card_fin, nsmul_eq_mul, mul_one_div] + _ ≤ η := hsmall.le + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/CompactApproximation.lean b/lean/OAI/Analysis/SphereIsometry/CompactApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..626a065ae76bd3f057bfc75d3669edec0c4b44e3 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/CompactApproximation.lean @@ -0,0 +1,192 @@ +import OAI.Analysis.SphereIsometry.SimplexFixedPoint +import Mathlib.Analysis.Convex.Combination +import Mathlib.Analysis.Normed.Module.Basic +import Mathlib.Topology.MetricSpace.Pseudo.Basic +import Mathlib.Topology.Algebra.GroupWithZero +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Finite-net approximate fixed points on a compact convex set + +The coefficient map is the explicit normalization of the weights +`max (δ - dist (P i) y) 0`. The simplex fixed point is applied to this +actual map composed with the actual barycenter and the given self-map. +-/ + +noncomputable section + +namespace Tingley + +open Set +open scoped BigOperators + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] +variable {ι : Type*} [Fintype ι] + +def compactNetWeight (P : ι → E) (δ : ℝ) (y : E) (i : ι) : ℝ := + max (δ - dist (P i) y) 0 + +def compactNetTotal (P : ι → E) (δ : ℝ) (y : E) : ℝ := + ∑ i, compactNetWeight P δ y i + +def compactNetCoefficients (P : ι → E) (δ : ℝ) (y : E) (i : ι) : ℝ := + compactNetWeight P δ y i / compactNetTotal P δ y + +omit [NormedSpace ℝ E] [Fintype ι] in +theorem compactNetWeight_nonneg (P : ι → E) (δ : ℝ) (y : E) (i : ι) : + 0 ≤ compactNetWeight P δ y i := le_max_right _ _ + +omit [NormedSpace ℝ E] [Fintype ι] in +theorem compactNetWeight_pos {P : ι → E} {δ : ℝ} {y : E} {i : ι} + (hi : dist (P i) y < δ) : 0 < compactNetWeight P δ y i := + (sub_pos.mpr hi).trans_le (le_max_left _ _) + +omit [NormedSpace ℝ E] in +theorem compactNetTotal_pos {P : ι → E} {δ : ℝ} {y : E} + (hnet : ∃ i, dist (P i) y < δ) : 0 < compactNetTotal P δ y := by + obtain ⟨i, hi⟩ := hnet + apply Finset.sum_pos' + · intro j _hj + exact compactNetWeight_nonneg P δ y j + · exact ⟨i, Finset.mem_univ i, compactNetWeight_pos hi⟩ + +omit [NormedSpace ℝ E] in +theorem compactNetCoefficients_nonneg {P : ι → E} {δ : ℝ} {y : E} + (hnet : ∃ i, dist (P i) y < δ) (i : ι) : + 0 ≤ compactNetCoefficients P δ y i := + div_nonneg (compactNetWeight_nonneg P δ y i) (compactNetTotal_pos hnet).le + +omit [NormedSpace ℝ E] in +theorem compactNetCoefficients_sum {P : ι → E} {δ : ℝ} {y : E} + (hnet : ∃ i, dist (P i) y < δ) : + ∑ i, compactNetCoefficients P δ y i = 1 := by + unfold compactNetCoefficients + simp only [div_eq_mul_inv, ← Finset.sum_mul] + exact mul_inv_cancel₀ (compactNetTotal_pos hnet).ne' + +omit [NormedSpace ℝ E] in +theorem compactNetCoefficients_pos {P : ι → E} {δ : ℝ} {y : E} {i : ι} + (hnet : ∃ j, dist (P j) y < δ) (hi : dist (P i) y < δ) : + 0 < compactNetCoefficients P δ y i := + div_pos (compactNetWeight_pos hi) (compactNetTotal_pos hnet) + +omit [NormedSpace ℝ E] in +theorem compactNetCoefficients_active {P : ι → E} {δ : ℝ} {y : E} {i : ι} + (hi : 0 < compactNetCoefficients P δ y i) : dist (P i) y < δ := by + by_contra h + have hw : compactNetWeight P δ y i = 0 := + max_eq_right (sub_nonpos.mpr (le_of_not_gt h)) + simp only [compactNetCoefficients, hw, zero_div] at hi + exact (lt_irrefl 0) hi + +def compactNetCoefficientMap (P : ι → E) (δ : ℝ) {K : Set E} + (hnet : ∀ y ∈ K, ∃ i, dist (P i) y < δ) : K → ProbabilitySimplex ι := + fun y => ⟨compactNetCoefficients P δ (y : E), + compactNetCoefficients_nonneg (hnet y y.property), + compactNetCoefficients_sum (hnet y y.property)⟩ + +omit [NormedSpace ℝ E] in +theorem continuous_compactNetCoefficientMap (P : ι → E) (δ : ℝ) {K : Set E} + (hnet : ∀ y ∈ K, ∃ i, dist (P i) y < δ) : + Continuous (compactNetCoefficientMap P δ hnet) := by + have hw (i : ι) : Continuous (fun y : K => compactNetWeight P δ (y : E) i) := + (continuous_const.sub (continuous_const.dist continuous_subtype_val)).max continuous_const + have hD : Continuous (fun y : K => compactNetTotal P δ (y : E)) := + continuous_finsetSum Finset.univ (fun i _hi => hw i) + apply Continuous.subtype_mk + apply continuous_pi + intro i + exact (hw i).div₀ hD (fun y => (compactNetTotal_pos (hnet y y.property)).ne') + +def compactNetBarycenter (P : ι → E) (a : ProbabilitySimplex ι) : E := + ∑ i, (a : ι → ℝ) i • P i + +theorem compactNetBarycenter_mem {K : Set E} (hconv : Convex ℝ K) + {P : ι → E} (hP : ∀ i, P i ∈ K) (a : ProbabilitySimplex ι) : + compactNetBarycenter P a ∈ K := + hconv.sum_mem (fun i _hi => a.property.1 i) a.property.2 (fun i _hi => hP i) + +theorem continuous_compactNetBarycenter (P : ι → E) : + Continuous (compactNetBarycenter P) := by + apply continuous_finsetSum Finset.univ + intro i _hi + exact ((continuous_apply i).comp continuous_subtype_val).smul continuous_const + +/-- The normalized finite-net average is strictly less than the net radius +away from its argument. Zero weights are allowed. -/ +theorem compactNet_sum_sub_lt {P : ι → E} {δ : ℝ} {y : E} + (hnet : ∃ i, dist (P i) y < δ) : + ‖(∑ i, compactNetCoefficients P δ y i • P i) - y‖ < δ := by + have hs := compactNetCoefficients_sum hnet + have hn := compactNetCoefficients_nonneg hnet + have heq : (∑ i, compactNetCoefficients P δ y i • P i) - y = + ∑ i, compactNetCoefficients P δ y i • (P i - y) := by + simp only [smul_sub, Finset.sum_sub_distrib, ← Finset.sum_smul, hs, one_smul] + have hle (i : ι) : compactNetCoefficients P δ y i * dist (P i) y ≤ + compactNetCoefficients P δ y i * δ := by + by_cases hi : compactNetCoefficients P δ y i = 0 + · simp only [hi, zero_mul, le_refl] + · have hip : 0 < compactNetCoefficients P δ y i := + lt_of_le_of_ne (hn i) (Ne.symm hi) + exact (mul_lt_mul_of_pos_left (compactNetCoefficients_active hip) hip).le + obtain ⟨i, hi⟩ := hnet + have his : compactNetCoefficients P δ y i * dist (P i) y < + compactNetCoefficients P δ y i * δ := + mul_lt_mul_of_pos_left hi (compactNetCoefficients_pos ⟨i, hi⟩ hi) + calc + ‖(∑ j, compactNetCoefficients P δ y j • P j) - y‖ = + ‖∑ j, compactNetCoefficients P δ y j • (P j - y)‖ := congrArg norm heq + _ ≤ ∑ j, ‖compactNetCoefficients P δ y j • (P j - y)‖ := norm_sum_le _ _ + _ = ∑ j, compactNetCoefficients P δ y j * dist (P j) y := by + apply Finset.sum_congr rfl + intro j _hj + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (hn j), dist_eq_norm] + _ < ∑ j, compactNetCoefficients P δ y j * δ := + Finset.sum_lt_sum (fun j _hj => hle j) ⟨i, Finset.mem_univ i, his⟩ + _ = δ := by rw [← Finset.sum_mul, hs, one_mul] + +/-- The simplex theorem, applied to the actual normalized net weights, +produces approximate fixed points for any compact convex self-map. -/ +theorem exists_approximate_fixedPoint_of_isCompact_convex + {K : Set E} (hK : IsCompact K) (hne : K.Nonempty) (hconv : Convex ℝ K) + {g : E → E} (hg : ContinuousOn g K) (hmap : MapsTo g K K) + {δ : ℝ} (hδ : 0 < δ) : ∃ x ∈ K, ‖x - g x‖ < δ := by + classical + obtain ⟨S, hSK, hSfinite, hcover⟩ := hK.finite_cover_balls hδ + let : Fintype S := hSfinite.fintype + let P : S → E := Subtype.val + have hnet : ∀ y ∈ K, ∃ i : S, dist (P i) y < δ := by + intro y hy + obtain ⟨p, hp⟩ := Set.mem_iUnion.mp (hcover hy) + obtain ⟨hpS, hpy⟩ := Set.mem_iUnion.mp hp + exact ⟨⟨p, hpS⟩, Metric.mem_ball'.mp hpy⟩ + obtain ⟨y₀, hy₀⟩ := hne + obtain ⟨i₀, _hi₀⟩ := hnet y₀ hy₀ + let : Nonempty S := ⟨i₀⟩ + have hP : ∀ i, P i ∈ K := fun i => hSK i.property + let bary : ProbabilitySimplex S → K := + fun a => ⟨compactNetBarycenter P a, compactNetBarycenter_mem hconv hP a⟩ + have hbary : Continuous bary := (continuous_compactNetBarycenter P).subtype_mk _ + let gK : K → K := hmap.restrict g K K + have hgK : Continuous gK := hg.mapsToRestrict hmap + let Q : ProbabilitySimplex S → ProbabilitySimplex S := + compactNetCoefficientMap P δ hnet ∘ gK ∘ bary + have hQ : Continuous Q := + (continuous_compactNetCoefficientMap P δ hnet).comp (hgK.comp hbary) + obtain ⟨a, ha⟩ := continuous_probabilitySimplex_fixedPoint Q hQ + have hcoeff : (a : S → ℝ) = compactNetCoefficients P δ (g (bary a : E)) := by + have hh := congrArg (fun z : ProbabilitySimplex S => (z : S → ℝ)) ha + change compactNetCoefficients P δ (g (bary a : E)) = (a : S → ℝ) at hh + exact hh.symm + refine ⟨(bary a : E), (bary a).property, ?_⟩ + have happ := compactNet_sum_sub_lt (hnet (g (bary a : E)) (hmap (bary a).property)) + rw [← hcoeff] at happ + exact happ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/CompactConvexFixedPoint.lean b/lean/OAI/Analysis/SphereIsometry/CompactConvexFixedPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..adc7ff98471bd7c97f8170d2c76a59df8ccf6767 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/CompactConvexFixedPoint.lean @@ -0,0 +1,91 @@ +import OAI.Analysis.SphereIsometry.CompactApproximation +import Mathlib.Topology.Order.Compact + +namespace OAI + +/-! +# Compact convex fixed points + +Finite-net approximate fixed points force the minimum of the continuous +displacement function to be zero. Ambient completeness is not required. +-/ + +noncomputable section + +namespace Tingley + +open Set + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +omit [NormedSpace ℝ E] in +theorem exists_fixedPoint_of_isCompact_of_approximate + {K : Set E} (hK : IsCompact K) (hne : K.Nonempty) + {g : E → E} (hg : ContinuousOn g K) + (happrox : ∀ δ : ℝ, 0 < δ → ∃ x ∈ K, ‖x - g x‖ < δ) : + ∃ x ∈ K, g x = x := by + have hd : ContinuousOn (fun x => ‖x - g x‖) K := (continuousOn_id.sub hg).norm + obtain ⟨z, hz, hmin⟩ := hK.exists_isMinOn hne hd + have hzero : ‖z - g z‖ = 0 := by + by_contra hnezero + have hpos : 0 < ‖z - g z‖ := + lt_of_le_of_ne (norm_nonneg _) (Ne.symm hnezero) + obtain ⟨x, hx, hsmall⟩ := happrox ‖z - g z‖ hpos + exact (not_lt_of_ge ((isMinOn_iff.mp hmin) x hx)) hsmall + exact ⟨z, hz, (sub_eq_zero.mp (norm_eq_zero.mp hzero)).symm⟩ + +/-- The compact-convex fixed-point theorem, obtained from the explicit +finite-net coefficient map and the proved simplex theorem. -/ +theorem exists_fixedPoint_of_isCompact_convex + {K : Set E} (hK : IsCompact K) (hne : K.Nonempty) (hconv : Convex ℝ K) + {g : E → E} (hg : ContinuousOn g K) (hmap : MapsTo g K K) : + ∃ x ∈ K, g x = x := by + apply exists_fixedPoint_of_isCompact_of_approximate hK hne hg + intro δ hδ + exact exists_approximate_fixedPoint_of_isCompact_convex hK hne hconv hg hmap hδ + +/-- An explicit ambient representative of a subtype self-map. Its values +outside the subtype are immaterial; only continuity on that subtype is used. -/ +def extendSelfMap {K : Set E} (g : K → K) (x : E) : E := by + classical + exact if hx : x ∈ K then (g ⟨x, hx⟩ : E) else x + +omit [NormedAddCommGroup E] [NormedSpace ℝ E] in +theorem extendSelfMap_of_mem {K : Set E} (g : K → K) {x : E} (hx : x ∈ K) : + extendSelfMap g x = (g ⟨x, hx⟩ : E) := by + simp only [extendSelfMap, dite_eq_left hx] + +omit [NormedAddCommGroup E] [NormedSpace ℝ E] in +@[simp] theorem extendSelfMap_coe {K : Set E} (g : K → K) (x : K) : + extendSelfMap g (x : E) = (g x : E) := + extendSelfMap_of_mem g x.property + +omit [NormedAddCommGroup E] [NormedSpace ℝ E] in +theorem extendSelfMap_mapsTo {K : Set E} (g : K → K) : + MapsTo (extendSelfMap g) K K := by + intro x hx + rw [extendSelfMap_of_mem g hx] + exact (g ⟨x, hx⟩).property + +omit [NormedSpace ℝ E] in +theorem continuousOn_extendSelfMap {K : Set E} {g : K → K} (hg : Continuous g) : + ContinuousOn (extendSelfMap g) K := by + apply continuousOn_iff_continuous_domRestrict.mpr + have h : Continuous (fun x : K => (g x : E)) := continuous_subtype_val.comp hg + exact h.congr (fun x => (extendSelfMap_coe g x).symm) + +/-- Subtype formulation of the compact-convex fixed-point theorem. -/ +theorem continuous_compactConvex_fixedPoint + {K : Set E} (hK : IsCompact K) (hne : K.Nonempty) (hconv : Convex ℝ K) + (g : K → K) (hg : Continuous g) : ∃ x, g x = x := by + obtain ⟨x, hx, heq⟩ := exists_fixedPoint_of_isCompact_convex hK hne hconv + (continuousOn_extendSelfMap hg) (extendSelfMap_mapsTo g) + refine ⟨⟨x, hx⟩, Subtype.ext ?_⟩ + rw [extendSelfMap_of_mem g hx] at heq + exact heq + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/CondensingFixedPoint.lean b/lean/OAI/Analysis/SphereIsometry/CondensingFixedPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cd8bc6090d1e1f0f504fbba59dddc608fb59639 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/CondensingFixedPoint.lean @@ -0,0 +1,92 @@ +import OAI.Analysis.SphereIsometry.CompactConvexFixedPoint +import OAI.Analysis.SphereIsometry.CondensingIteration +import OAI.Analysis.SphereIsometry.KuratowskiNested + +namespace OAI + +/-! +# Fixed points from a Kuratowski contraction + +The compact invariant set is the intersection of the actual iterated +closed-convex images. All of its required properties are proved from the +original closed bounded convex invariant set and the all-subsets estimate. +-/ + +noncomputable section + +namespace Tingley + +open Set Filter +open scoped Topology + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] + +/-- A continuous self-map satisfying the actual all-subsets Kuratowski +contraction has a fixed point. No compactness premise on `C` is required. -/ +theorem exists_fixedPoint_of_kuratowski_contraction + {C : Set E} (hne : C.Nonempty) (hclosed : IsClosed C) + (hbounded : Bornology.IsBounded C) (hconv : Convex ℝ C) + {g : E → E} (hg : ContinuousOn g C) (hmap : MapsTo g C C) + {γ : ℝ} (hγ0 : 0 ≤ γ) (hγ1 : γ < 1) + (hχ : ∀ H : Set E, H ⊆ C → chi (g '' H) ≤ γ * chi H) : + ∃ x ∈ C, g x = x := by + let K : Set E := ⋂ n, condensingSequence C g n + have hdecay := condensingSequence_chi_tendsto_zero hclosed hconv hmap hbounded hγ0 hγ1 hχ + obtain ⟨hKne, hKcompact⟩ := nonempty_isCompact_iInter_of_chi_tendsto_zero + (condensingSequence C g) + (condensingSequence_antitone hclosed hconv hmap) + (condensingSequence_nonempty g hne) + (condensingSequence_isClosed g hclosed) + hbounded hdecay + have hKconv : Convex ℝ K := convex_iInter (condensingSequence_convex g hconv) + have hKC : K ⊆ C := by + intro x hx + exact (mem_iInter.mp hx) 0 + have hKmap : MapsTo g K K := by + intro x hx + apply mem_iInter.mpr + intro n + exact condensingSequence_mapsTo hclosed hconv hmap n ((mem_iInter.mp hx) n) + obtain ⟨x, hx, hfix⟩ := exists_fixedPoint_of_isCompact_convex hKcompact hKne hKconv + (hg.mono hKC) hKmap + exact ⟨x, hKC hx, hfix⟩ + +/-- The subtype formulation measures the actual ambient images of subsets +of the carrier, and transports them through the explicit ambient map. -/ +theorem continuous_condensing_fixedPoint + {C : Set E} (hne : C.Nonempty) (hclosed : IsClosed C) + (hbounded : Bornology.IsBounded C) (hconv : Convex ℝ C) + (g : C → C) (hg : Continuous g) {γ : ℝ} (hγ0 : 0 ≤ γ) (hγ1 : γ < 1) + (hχ : ∀ H : Set C, + chi ((fun x : C => (g x : E)) '' H) ≤ γ * chi (Subtype.val '' H)) : + ∃ x, g x = x := by + have hext : ∀ H : Set E, H ⊆ C → + chi (extendSelfMap g '' H) ≤ γ * chi H := by + intro H hHC + let H' : Set C := {x | (x : E) ∈ H} + have hdomain : (Subtype.val : C → E) '' H' = H := by + ext x + constructor + · rintro ⟨y, hy, rfl⟩ + exact hy + · intro hx + exact ⟨⟨x, hHC hx⟩, hx, rfl⟩ + have himage : (fun x : C => (g x : E)) '' H' = extendSelfMap g '' H := by + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + exact ⟨(x : E), hx, extendSelfMap_coe g x⟩ + · rintro ⟨x, hx, rfl⟩ + exact ⟨⟨x, hHC hx⟩, hx, (extendSelfMap_of_mem g (hHC hx)).symm⟩ + simpa only [hdomain, himage] using hχ H' + obtain ⟨x, hx, hfix⟩ := exists_fixedPoint_of_kuratowski_contraction hne hclosed + hbounded hconv (continuousOn_extendSelfMap hg) (extendSelfMap_mapsTo g) hγ0 hγ1 hext + refine ⟨⟨x, hx⟩, Subtype.ext ?_⟩ + rw [extendSelfMap_of_mem g hx] at hfix + exact hfix + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/CondensingIteration.lean b/lean/OAI/Analysis/SphereIsometry/CondensingIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3e7ed8ff13a615334af6c5b35995c964552e901 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/CondensingIteration.lean @@ -0,0 +1,177 @@ +import OAI.Analysis.SphereIsometry.KuratowskiConvexHull +import Mathlib.Analysis.Convex.Topology +import Mathlib.Analysis.SpecificLimits.Basic +import Mathlib.Topology.MetricSpace.Pseudo.Lemmas + +namespace OAI + +/-! +# The closed-convex image iteration + +Starting from a closed convex invariant set `C`, the actual successor set is +the closure of the convex hull of its image under `g`. All boundedness claims +come from containment in `C`. No boundedness-preservation property of an +arbitrary continuous map is used. +-/ + +noncomputable section + +namespace Tingley + +open Set Filter +open scoped Topology + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +/-- The literal closed-convex image operator used in the condensing argument. -/ +def condensingStep (g : E → E) (H : Set E) : Set E := + closure (convexHull ℝ (g '' H)) + +/-- The iteration begins at `C` and takes actual closed-convex images. -/ +def condensingSequence (C : Set E) (g : E → E) : ℕ → Set E + | 0 => C + | n + 1 => condensingStep g (condensingSequence C g n) + +@[simp] theorem condensingSequence_zero (C : Set E) (g : E → E) : + condensingSequence C g 0 = C := rfl + +@[simp] theorem condensingSequence_succ (C : Set E) (g : E → E) (n : ℕ) : + condensingSequence C g (n + 1) = condensingStep g (condensingSequence C g n) := rfl + +theorem condensingStep_mono (g : E → E) : Monotone (condensingStep g) := by + intro H J hHJ + exact closure_mono (convexHull_mono (image_mono hHJ)) + +theorem image_subset_condensingStep (g : E → E) (H : Set E) : + g '' H ⊆ condensingStep g H := + (subset_convexHull ℝ (g '' H)).trans subset_closure + +theorem condensingStep_subset {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) : + condensingStep g C ⊆ C := by + apply closure_minimal _ hclosed + apply convexHull_min _ hconv + rintro y ⟨x, hx, rfl⟩ + exact hmap hx + +theorem condensingSequence_succ_subset {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) (n : ℕ) : + condensingSequence C g (n + 1) ⊆ condensingSequence C g n := by + induction n with + | zero => exact condensingStep_subset hclosed hconv hmap + | succ n ih => exact condensingStep_mono g ih + +theorem condensingSequence_antitone {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) : + Antitone (condensingSequence C g) := + antitone_nat_of_succ_le (condensingSequence_succ_subset hclosed hconv hmap) + +theorem condensingSequence_subset {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) (n : ℕ) : + condensingSequence C g n ⊆ C := + condensingSequence_antitone hclosed hconv hmap (Nat.zero_le n) + +/-- Every image point belongs to the next set, before using antitonicity. -/ +theorem condensingSequence_image_subset_succ (C : Set E) (g : E → E) (n : ℕ) : + g '' condensingSequence C g n ⊆ condensingSequence C g (n + 1) := + image_subset_condensingStep g (condensingSequence C g n) + +theorem condensingSequence_nonempty {C : Set E} (g : E → E) + (hne : C.Nonempty) (n : ℕ) : (condensingSequence C g n).Nonempty := by + induction n with + | zero => exact hne + | succ n ih => + obtain ⟨x, hx⟩ := ih + exact ⟨g x, condensingSequence_image_subset_succ C g n (mem_image_of_mem g hx)⟩ + +theorem condensingSequence_isClosed {C : Set E} (g : E → E) + (hclosed : IsClosed C) (n : ℕ) : IsClosed (condensingSequence C g n) := by + cases n with + | zero => exact hclosed + | succ n => exact isClosed_closure + +theorem condensingSequence_convex {C : Set E} (g : E → E) + (hconv : Convex ℝ C) (n : ℕ) : Convex ℝ (condensingSequence C g n) := by + cases n with + | zero => exact hconv + | succ n => exact (convex_convexHull ℝ (g '' condensingSequence C g n)).closure + +theorem condensingSequence_isBounded {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) (n : ℕ) : + Bornology.IsBounded (condensingSequence C g n) := + hbounded.subset (condensingSequence_subset hclosed hconv hmap n) + +theorem condensingSequence_mapsTo {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) (n : ℕ) : + MapsTo g (condensingSequence C g n) (condensingSequence C g n) := by + intro x hx + exact condensingSequence_succ_subset hclosed hconv hmap n + (condensingSequence_image_subset_succ C g n (mem_image_of_mem g hx)) + +theorem condensingSequence_image_subset {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) (n : ℕ) : + g '' condensingSequence C g n ⊆ C := by + rintro y ⟨x, hx, rfl⟩ + exact hmap (condensingSequence_subset hclosed hconv hmap n hx) + +theorem condensingSequence_image_isBounded {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) (n : ℕ) : + Bornology.IsBounded (g '' condensingSequence C g n) := + hbounded.subset (condensingSequence_image_subset hclosed hconv hmap n) + +/-- The hull step leaves the actual Kuratowski measure of its bounded image unchanged. -/ +theorem condensingSequence_chi_succ_eq {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) (n : ℕ) : + chi (condensingSequence C g (n + 1)) = chi (g '' condensingSequence C g n) := by + exact chi_closedConvexHull + (condensingSequence_image_isBounded hclosed hconv hmap hbounded n) + +theorem condensingSequence_chi_succ_le {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) {γ : ℝ} + (hχ : ∀ H : Set E, H ⊆ C → chi (g '' H) ≤ γ * chi H) (n : ℕ) : + chi (condensingSequence C g (n + 1)) ≤ γ * chi (condensingSequence C g n) := by + rw [condensingSequence_chi_succ_eq hclosed hconv hmap hbounded n] + exact hχ _ (condensingSequence_subset hclosed hconv hmap n) + +/-- Geometric decay allows `γ = 0`; no division by the contraction factor occurs. -/ +theorem condensingSequence_chi_le {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) {γ : ℝ} (hγ0 : 0 ≤ γ) + (hχ : ∀ H : Set E, H ⊆ C → chi (g '' H) ≤ γ * chi H) (n : ℕ) : + chi (condensingSequence C g n) ≤ γ ^ n * chi C := by + induction n with + | zero => simp + | succ n ih => + calc + chi (condensingSequence C g (n + 1)) ≤ γ * chi (condensingSequence C g n) := + condensingSequence_chi_succ_le hclosed hconv hmap hbounded hχ n + _ ≤ γ * (γ ^ n * chi C) := mul_le_mul_of_nonneg_left ih hγ0 + _ = γ ^ (n + 1) * chi C := by rw [pow_succ', mul_assoc] + +theorem condensingSequence_chi_nonneg {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) (n : ℕ) : + 0 ≤ chi (condensingSequence C g n) := + chi_nonneg (condensingSequence_isBounded hclosed hconv hmap hbounded n) + +/-- The actual sequence has Kuratowski measure tending to zero for `0 ≤ γ < 1`. -/ +theorem condensingSequence_chi_tendsto_zero {C : Set E} {g : E → E} + (hclosed : IsClosed C) (hconv : Convex ℝ C) (hmap : MapsTo g C C) + (hbounded : Bornology.IsBounded C) {γ : ℝ} (hγ0 : 0 ≤ γ) (hγ1 : γ < 1) + (hχ : ∀ H : Set E, H ⊆ C → chi (g '' H) ≤ γ * chi H) : + Tendsto (fun n => chi (condensingSequence C g n)) atTop (𝓝 0) := by + apply squeeze_zero + (condensingSequence_chi_nonneg hclosed hconv hmap hbounded) + (condensingSequence_chi_le hclosed hconv hmap hbounded hγ0 hχ) + simpa only [zero_mul] using + (tendsto_pow_atTop_nhds_zero_of_lt_one hγ0 hγ1).mul_const (chi C) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ConvexCoverRegroup.lean b/lean/OAI/Analysis/SphereIsometry/ConvexCoverRegroup.lean new file mode 100644 index 0000000000000000000000000000000000000000..f21273b844d38ab587ff8ea342d3f270bacb972a --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ConvexCoverRegroup.lean @@ -0,0 +1,93 @@ +import Mathlib.Analysis.Convex.Combination +import Mathlib.Basic.Real.Basic + +namespace OAI + +/-! +# Regrouping a convex hull over a finite cover + +For a finite family of nonempty sets, every point in the convex hull of their +union is a convex combination with one point from each individual convex hull. +The proof establishes convexity of the represented set. Zero coefficients are +handled by choosing points inside the corresponding sets, without assuming +that those sets contain the origin. +-/ + +namespace Tingley + +open scoped BigOperators + +variable {E ι : Type*} [AddCommGroup E] [Module ℝ E] [Fintype ι] + +/-- Points represented by probability weights and one point in each member of +a finite family of sets. Membership is required even at zero-weight indices. -/ +def finiteMixtures (B : ι → Set E) : Set E := + {x | ∃ (w : ι → ℝ) (z : ι → E), + (∀ i, 0 ≤ w i) ∧ (∑ i, w i) = 1 ∧ + (∀ i, z i ∈ B i) ∧ (∑ i, w i • z i) = x} + +/-- Mixing probability-weighted representations preserves representation when +each coordinate set is convex. No nonemptiness premise is needed here. -/ +theorem convex_finiteMixtures (B : ι → Set E) (hB : ∀ i, Convex ℝ (B i)) : + Convex ℝ (finiteMixtures B) := by + classical + rintro x ⟨wx, zx, hwx, hwxsum, hzx, hx⟩ + y ⟨wy, zy, hwy, hwysum, hzy, hy⟩ a b ha hb hab + have hex (i : ι) : + ∃ u ∈ B i, (a * wx i + b * wy i) • u = + (a * wx i) • zx i + (b * wy i) • zy i := + (hB i).exists_mem_add_smul_eq (hzx i) (hzy i) + (mul_nonneg ha (hwx i)) (mul_nonneg hb (hwy i)) + choose u hu hueq using hex + refine ⟨fun i => a * wx i + b * wy i, u, ?_, ?_, hu, ?_⟩ + · intro i + exact add_nonneg (mul_nonneg ha (hwx i)) (mul_nonneg hb (hwy i)) + · calc + (∑ i, (a * wx i + b * wy i)) = + a * (∑ i, wx i) + b * (∑ i, wy i) := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] + _ = 1 := by simp only [hwxsum, hwysum, mul_one, hab] + · calc + (∑ i, (a * wx i + b * wy i) • u i) = + ∑ i, ((a * wx i) • zx i + (b * wy i) • zy i) := + Finset.sum_congr rfl fun i _ => hueq i + _ = a • (∑ i, wx i • zx i) + b • (∑ i, wy i • zy i) := by + simp only [Finset.sum_add_distrib, mul_smul, Finset.smul_sum] + _ = a • x + b • y := by rw [hx, hy] + +/-- Regroup a point of a convex hull along an arbitrary finite cover by +nonempty sets. Cover members may be infinite, overlapping, or nonclosed. -/ +theorem convexHull_cover_representation + (H : Set E) (A : ι → Set E) + (hne : ∀ i, (A i).Nonempty) + (hcover : ∀ x ∈ H, ∃ i, x ∈ A i) + {x : E} (hx : x ∈ convexHull ℝ H) : + ∃ (w : ι → ℝ) (z : ι → E), + (∀ i, 0 ≤ w i) ∧ (∑ i, w i) = 1 ∧ + (∀ i, z i ∈ convexHull ℝ (A i)) ∧ + (∑ i, w i • z i) = x := by + classical + choose base hbase using hne + have hcontains : H ⊆ finiteMixtures (fun i => convexHull ℝ (A i)) := by + intro y hy + obtain ⟨j, hj⟩ := hcover y hy + refine ⟨fun i => if i = j then 1 else 0, + fun i => if i = j then y else base i, ?_, ?_, ?_, ?_⟩ + · intro i + by_cases hij : i = j <;> simp [hij] + · simp + · intro i + by_cases hij : i = j + · subst i + simpa only [ite_eq_left rfl, ite_true] using subset_convexHull ℝ (A j) hj + · simpa only [ite_eq_right hij] using subset_convexHull ℝ (A i) (hbase i) + · rw [Finset.sum_eq_single_of_mem j (Finset.mem_univ j)] + · simp + · intro i _ hij + simp [hij] + exact convexHull_min hcontains + (convex_finiteMixtures _ fun i => convex_convexHull ℝ (A i)) hx + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ConvexDiameter.lean b/lean/OAI/Analysis/SphereIsometry/ConvexDiameter.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ce2c2c36c7d6f380d55040f63ab510b13f6e816 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ConvexDiameter.lean @@ -0,0 +1,33 @@ +import OAI.Analysis.SphereIsometry.DiameterBounds +import Mathlib.Analysis.Normed.Module.Convex + +namespace OAI + +/-! # Diameter bounds for convex hulls + +Convex hulls preserve diameter bounds. +-/ + +namespace Tingley + +variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] + +/-- Taking a convex hull preserves a pairwise diameter bound. -/ +theorem DiameterLE.convexHull {A : Set E} {δ : ℝ} (h : DiameterLE A δ) : + DiameterLE (convexHull ℝ A) δ := by + intro x hx y hy + obtain ⟨x', hx', y', hy', hxy⟩ := convexHull_exists_dist_ge2 hx hy + exact hxy.trans (h x' hx' y' hy') + +/-- A norm bound on a set also holds on its convex hull. -/ +theorem norm_le_of_mem_convexHull {A : Set E} {R : ℝ} + (hR : ∀ x ∈ A, ‖x‖ ≤ R) {x : E} (hx : x ∈ convexHull ℝ A) : ‖x‖ ≤ R := by + have hsub : A ⊆ Metric.closedBall (0 : E) R := by + intro y hy + simpa only [Metric.mem_closedBall, dist_zero_right] using hR y hy + have hxball := convexHull_min hsub (convex_closedBall (0 : E) R) hx + simpa only [Metric.mem_closedBall, dist_zero_right] using hxball + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/DefectAttainment.lean b/lean/OAI/Analysis/SphereIsometry/DefectAttainment.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9ed055d31daf25bc32631311e836c7fbf157d49 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/DefectAttainment.lean @@ -0,0 +1,79 @@ +import OAI.Analysis.SphereIsometry.UltraSphere +import OAI.Analysis.SphereIsometry.DefectSequence +import OAI.Analysis.SphereIsometry.SphereCompletion + +namespace OAI + +/-! +# Positive maximal defect is attained on actual completed ultranorm spaces + +The final spaces, sphere isometry, inverse, and bound are all constructed. The +orientation disjunction keeps the same original maximal absolute defect. +-/ + +noncomputable section +namespace Tingley +open Filter +open scoped Topology + +universe u v +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] [Nontrivial X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] [Nontrivial Y] + +/-- The actual coordinatewise sphere equivalence followed by ambient completion. -/ +def completedUltraSphereEquiv (U : Ultrafilter ℕ) (f : UnitSphere X ≃ᵢ UnitSphere Y) : + UnitSphere (UltraCompletion U X) ≃ᵢ UnitSphere (UltraCompletion U Y) := + completedSphereEquiv (ultraSphereEquiv U f) + +@[simp] theorem completedUltraSphereEquiv_symm (U : Ultrafilter ℕ) + (f : UnitSphere X ≃ᵢ UnitSphere Y) : + (completedUltraSphereEquiv U f).symm = completedUltraSphereEquiv U f.symm := by + simp only [completedUltraSphereEquiv, completedSphereEquiv_symm, ultraSphereEquiv_symm] + +/-- Exact fixed-radius formula on the canonical embedded unit classes. -/ +theorem signedDefect_completedUltraSphereEquiv (U : Ultrafilter ℕ) + (f : UnitSphere X ≃ᵢ UnitSphere Y) (q : ℝ) (s t : ℕ → UnitSphere X) : + signedDefect (completedUltraSphereEquiv U f) q + (sphereCoe (UltraQuotient U X) (unitClass U s)) + (sphereCoe (UltraQuotient U X) (unitClass U t)) = + realULim U (fun n => signedDefect f q (s n) (t n)) := by + exact (signedDefect_completedSphereEquiv_coe (ultraSphereEquiv U f) q + (unitClass U s) (unitClass U t)).trans (signedDefect_ultraSphereEquiv U f q s t) + +theorem HasDefectBound.completedUltraSphereEquiv + {f : UnitSphere X ≃ᵢ UnitSphere Y} {M : ℝ} (h : HasDefectBound f M) + (U : Ultrafilter ℕ) : HasDefectBound (completedUltraSphereEquiv U f) M := + (h.ultraSphereEquiv U).completedSphereEquiv + +/-- Positive original maximal absolute defect is attained, with the same global +bound, in one orientation on explicitly constructed nonzero real Banach spaces. -/ +theorem positive_maxDefect_attained_or_inverse + (f : UnitSphere X ≃ᵢ UnitSphere Y) (hM : 0 < maxDefect f) : + let F := completedUltraSphereEquiv freeUltrafilter f + HasDefectBound F (maxDefect f) ∧ + HasDefectBound F.symm (maxDefect f) ∧ + ∃ t : ℝ, t ∈ Set.Ioo (0 : ℝ) 1 ∧ + ((∃ x y : UnitSphere (UltraCompletion freeUltrafilter X), + signedDefect F t x y = maxDefect f) ∨ + (∃ x y : UnitSphere (UltraCompletion freeUltrafilter Y), + signedDefect F.symm t x y = maxDefect f)) := by + have hbound := (hasDefectBound_maxDefect f).completedUltraSphereEquiv freeUltrafilter + refine ⟨hbound, hbound.symm, ?_⟩ + obtain ⟨t, ht, hseq | hseq⟩ := exists_fixed_radius_defect_sequence f hM + · obtain ⟨s, r, hlim⟩ := hseq + refine ⟨t, ht, Or.inl ⟨sphereCoe _ (unitClass freeUltrafilter s), + sphereCoe _ (unitClass freeUltrafilter r), ?_⟩⟩ + rw [signedDefect_completedUltraSphereEquiv] + exact realULim_eq_of_tendsto freeUltrafilter hlim + · obtain ⟨s, r, hlim⟩ := hseq + refine ⟨t, ht, Or.inr ⟨sphereCoe _ (unitClass freeUltrafilter s), + sphereCoe _ (unitClass freeUltrafilter r), ?_⟩⟩ + rw [completedUltraSphereEquiv_symm, signedDefect_completedUltraSphereEquiv] + exact realULim_eq_of_tendsto freeUltrafilter hlim + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/DefectSequence.lean b/lean/OAI/Analysis/SphereIsometry/DefectSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..9027e10548cbba1c6b09dee830ee65c24432537f --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/DefectSequence.lean @@ -0,0 +1,121 @@ +import OAI.Analysis.SphereIsometry.Basic +import OAI.Analysis.SphereIsometry.UltraRealLimit +import Mathlib.Topology.Order.IsLUB + +namespace OAI + +/-! +# A positive signed extremal sequence at a fixed radius + +One fixed free ultrafilter chooses the orientation and the radius. The conclusion +is convergence along that actual filter, not an asserted compactness of spheres. +-/ + +noncomputable section +namespace Tingley +open Filter +open scoped Topology + +universe u v +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- Uniform radius control replaces a varying radius by its actual scalar limit. -/ +theorem tendsto_signedDefect_fixed_radius + (f : UnitSphere X ≃ᵢ UnitSphere Y) (x y : ℕ → UnitSphere X) + (q : ℕ → ℝ) {l : Filter ℕ} {t M : ℝ} + (hq : Tendsto q l (𝓝 t)) + (hD : Tendsto (fun n => signedDefect f (q n) (x n) (y n)) l (𝓝 M)) : + Tendsto (fun n => signedDefect f t (x n) (y n)) l (𝓝 M) := by + have herr : Tendsto (fun n => 2 * |q n - t|) l (𝓝 0) := by + simpa using ((hq.sub (tendsto_const_nhds (x := t))).abs.const_mul 2) + have hlo := hD.sub herr + have hhi := hD.add herr + simp only [sub_zero, add_zero] at hlo hhi + apply tendsto_of_tendsto_of_tendsto_of_le_of_le hlo hhi + · intro n + change signedDefect f (q n) (x n) (y n) - 2 * |q n - t| ≤ + signedDefect f t (x n) (y n) + have h := (abs_le.mp (signedDefect_lipschitz f (q n) t (x n) (y n))).2 + linarith + · intro n + change signedDefect f t (x n) (y n) ≤ + signedDefect f (q n) (x n) (y n) + 2 * |q n - t| + have h := (abs_le.mp (signedDefect_lipschitz f (q n) t (x n) (y n))).1 + linarith + +/-- Positive limiting defect forces a strictly interior radius. -/ +theorem radius_interior_of_positive_defect_limit + (f : UnitSphere X ≃ᵢ UnitSphere Y) (x y : ℕ → UnitSphere X) + (U : Ultrafilter ℕ) {t M : ℝ} (ht : t ∈ Set.Icc (0 : ℝ) 1) + (hM : 0 < M) + (hD : Tendsto (fun n => signedDefect f t (x n) (y n)) (U : Filter ℕ) (𝓝 M)) : + t ∈ Set.Ioo (0 : ℝ) 1 := by + have habs : Tendsto (fun n => |signedDefect f t (x n) (y n)|) + (U : Filter ℕ) (𝓝 M) := by + simpa only [abs_of_pos hM] using hD.abs + have h0 : M ≤ 2 * t := + le_of_tendsto_of_tendsto' habs tendsto_const_nhds + (fun n => (signedDefect_le_endpoints f ht (x n) (y n)).1) + have h1 : M ≤ 2 * (1 - t) := + le_of_tendsto_of_tendsto' habs tendsto_const_nhds + (fun n => (signedDefect_le_endpoints f ht (x n) (y n)).2) + constructor <;> linarith + +/-- The absolute supremum has actual fixed-radius signed witnesses in one orientation. -/ +theorem exists_fixed_radius_defect_sequence [Nontrivial X] + (f : UnitSphere X ≃ᵢ UnitSphere Y) (hM : 0 < maxDefect f) : + ∃ t : ℝ, t ∈ Set.Ioo (0 : ℝ) 1 ∧ + ((∃ x y : ℕ → UnitSphere X, + Tendsto (fun n => signedDefect f t (x n) (y n)) + (freeUltrafilter : Filter ℕ) (𝓝 (maxDefect f))) ∨ + (∃ x y : ℕ → UnitSphere Y, + Tendsto (fun n => signedDefect f.symm t (x n) (y n)) + (freeUltrafilter : Filter ℕ) (𝓝 (maxDefect f)))) := by + classical + obtain ⟨d, _, hdlim, hdmem⟩ := exists_seq_tendsto_sSup + (show (absoluteDefects f).Nonempty from ⟨0, zero_mem_absoluteDefects f⟩) + (absoluteDefects_bddAbove f) + change ∀ n, ∃ q ∈ Set.Icc (0 : ℝ) 1, + ∃ x y : UnitSphere X, d n = |signedDefect f q x y| at hdmem + choose q hq x y hd using hdmem + have habs : Tendsto (fun n => |signedDefect f (q n) (x n) (y n)|) + (freeUltrafilter : Filter ℕ) (𝓝 (maxDefect f)) := by + have h := tendsto_freeUltrafilter_of_tendsto_atTop hdlim + have heq : d = fun n => |signedDefect f (q n) (x n) (y n)| := funext hd + simpa only [heq, maxDefect] using h + have hqb : RealSeqBounded q := by + refine ⟨1, fun n => ?_⟩ + simpa only [abs_of_nonneg (hq n).1] using (hq n).2 + let t := realULim freeUltrafilter q + have hqt : Tendsto q (freeUltrafilter : Filter ℕ) (𝓝 t) := + tendsto_realULim freeUltrafilter hqb + have ht : t ∈ Set.Icc (0 : ℝ) 1 := by + exact ⟨le_of_tendsto_of_tendsto' tendsto_const_nhds hqt (fun n => (hq n).1), + le_of_tendsto_of_tendsto' hqt tendsto_const_nhds (fun n => (hq n).2)⟩ + rcases freeUltrafilter.em (fun n => 0 ≤ signedDefect f (q n) (x n) (y n)) with hpos | hneg + · have hsign : Tendsto (fun n => signedDefect f (q n) (x n) (y n)) + (freeUltrafilter : Filter ℕ) (𝓝 (maxDefect f)) := by + apply habs.congr' + filter_upwards [hpos] with n hn + exact abs_of_nonneg hn + have hfixed := tendsto_signedDefect_fixed_radius f x y q hqt hsign + exact ⟨t, radius_interior_of_positive_defect_limit f x y freeUltrafilter ht hM hfixed, + Or.inl ⟨x, y, hfixed⟩⟩ + · have hsign : Tendsto (fun n => signedDefect f.symm (q n) (f (x n)) (f (y n))) + (freeUltrafilter : Filter ℕ) (𝓝 (maxDefect f)) := by + apply habs.congr' + filter_upwards [hneg] with n hn + rw [signedDefect_symm, abs_of_nonpos (le_of_lt (lt_of_not_ge hn))] + have hfixed := tendsto_signedDefect_fixed_radius f.symm + (fun n => f (x n)) (fun n => f (y n)) q hqt hsign + exact ⟨t, radius_interior_of_positive_defect_limit f.symm + (fun n => f (x n)) (fun n => f (y n)) freeUltrafilter ht hM hfixed, + Or.inr ⟨_, _, hfixed⟩⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/DiameterBounds.lean b/lean/OAI/Analysis/SphereIsometry/DiameterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..885b9bf91ec0d08581014da79ec4b2c592a8727a --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/DiameterBounds.lean @@ -0,0 +1,38 @@ +import Mathlib.Topology.MetricSpace.Bounded + +namespace OAI + +/-! # Pairwise diameter bounds + +The predicate records the distance between every pair of points. It does not +use the real-valued diameter of a possibly unbounded set. +-/ + +namespace Tingley + +variable {E : Type*} [PseudoMetricSpace E] + +/-- Every pair of points in a set is at distance at most the given radius. -/ +def DiameterLE (A : Set E) (δ : ℝ) : Prop := + ∀ x ∈ A, ∀ y ∈ A, dist x y ≤ δ + +namespace DiameterLE + +variable {A B : Set E} {δ ε : ℝ} + +theorem mono_set (h : DiameterLE B δ) (hAB : A ⊆ B) : DiameterLE A δ := + fun x hx y hy => h x (hAB hx) y (hAB hy) + +theorem mono_radius (h : DiameterLE A δ) (hδε : δ ≤ ε) : DiameterLE A ε := + fun x hx y hy => (h x hx y hy).trans hδε + +theorem closure (h : DiameterLE A δ) : DiameterLE (closure A) δ := by + intro x hx y hy + exact isClosed_Iic.closure_subset + (map_mem_closure₂ continuous_dist hx hy (fun _ ha _ hb => h _ ha _ hb)) + +end DiameterLE + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/Extension.lean b/lean/OAI/Analysis/SphereIsometry/Extension.lean new file mode 100644 index 0000000000000000000000000000000000000000..e36a6391a16f2b9e9ca06063858d4ceffcda0d07 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Extension.lean @@ -0,0 +1,120 @@ +import OAI.Analysis.SphereIsometry.DefectAttainment +import OAI.Analysis.SphereIsometry.Alignment +import OAI.Analysis.SphereIsometry.ChordContradiction +import OAI.Analysis.SphereIsometry.RadialExtension + +namespace OAI + +/-! +# The unique real-linear extension of an onto sphere isometry + +The intermediate hypotheses of the separate constructions are discharged here: +positive original defect produces an actual attained defect in completed normed +quotients, alignment produces actual opposite chords, and the chord theorem +rules them out. The original radial extension consequently preserves distance. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] [CompleteSpace Y] + +theorem no_attained_positive_defect + {X : Type u} {Y : Type v} + [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] [CompleteSpace Y] + (f : UnitSphere X ≃ᵢ UnitSphere Y) (t M : ℝ) + (ht : 0 < t ∧ t < 1) (hM : 0 < M) (hb : HasDefectBound f M) + (x y : UnitSphere X) (hatt : signedDefect f t x y = M) : False := by + obtain ⟨C⟩ := exists_alignedConfiguration f y x t M ht hM hb hatt + exact alignedConfiguration_impossible hM ht hb C + +variable [Nontrivial X] [Nontrivial Y] + +theorem maxDefect_eq_zero + {X : Type u} {Y : Type v} + [NormedAddCommGroup X] [NormedSpace ℝ X] [CompleteSpace X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] [CompleteSpace Y] + [Nontrivial X] [Nontrivial Y] + (f : UnitSphere X ≃ᵢ UnitSphere Y) : maxDefect f = 0 := by + apply le_antisymm ?_ (maxDefect_nonneg f) + by_contra hn + have hM : 0 < maxDefect f := lt_of_not_ge hn + obtain ⟨hb, hi, t, ht, ha⟩ := positive_maxDefect_attained_or_inverse f hM + rcases ha with ⟨x, y, hxy⟩ | ⟨x, y, hxy⟩ + · exact no_attained_positive_defect _ t (maxDefect f) ⟨ht.1, ht.2⟩ hM hb x y hxy + · exact no_attained_positive_defect _ t (maxDefect f) ⟨ht.1, ht.2⟩ hM hi x y hxy + +theorem hasDefectBound_zero (f : UnitSphere X ≃ᵢ UnitSphere Y) : HasDefectBound f 0 := by + simpa only [maxDefect_eq_zero] using hasDefectBound_maxDefect f + +theorem existsUnique_linearIsometryEquiv + (f : UnitSphere X ≃ᵢ UnitSphere Y) : + ∃! T : X ≃ₗᵢ[ℝ] Y, ∀ x : UnitSphere X, T (x : X) = (f x : Y) := by + exact existsUnique_linearIsometryEquiv_of_zero_defect f (hasDefectBound_zero f) + +/-- The actual unconditional extension, with the original radial function. -/ +def extension (f : UnitSphere X ≃ᵢ UnitSphere Y) : X ≃ₗᵢ[ℝ] Y := + radialLinearIsometryEquiv f (hasDefectBound_zero f) + +@[simp] theorem extension_apply (f : UnitSphere X ≃ᵢ UnitSphere Y) (x : X) : + extension f x = radialExtension f x := rfl + +@[simp] theorem extension_zero (f : UnitSphere X ≃ᵢ UnitSphere Y) : + extension f 0 = 0 := radialExtension_zero f + +@[simp] theorem extension_unit (f : UnitSphere X ≃ᵢ UnitSphere Y) (x : UnitSphere X) : + extension f (x : X) = (f x : Y) := radialExtension_unit f x + +theorem extension_radial (f : UnitSphere X ≃ᵢ UnitSphere Y) (x : X) (hx : x ≠ 0) : + extension f x = ‖x‖ • (f (normalize x hx) : Y) := + radialExtension_of_ne_zero f x hx + +theorem extension_surjective (f : UnitSphere X ≃ᵢ UnitSphere Y) : + Function.Surjective (extension f) := (extension f).surjective + +theorem extension_unique (f : UnitSphere X ≃ᵢ UnitSphere Y) + (L : X →ₗ[ℝ] Y) (hL : ∀ x : UnitSphere X, L (x : X) = (f x : Y)) : + L = (extension f).toLinearEquiv.toLinearMap := by + apply LinearMap.ext + intro x + exact linear_extension_eq_radial f L hL x + +/-- An ordinary onto sphere isometry is a genuine sphere isometry equivalence. -/ +def sphereIsometryEquiv (f : UnitSphere X → UnitSphere Y) + (hf : Isometry f) (hs : Function.Surjective f) : UnitSphere X ≃ᵢ UnitSphere Y where + toEquiv := Equiv.ofBijective f ⟨hf.injective, hs⟩ + isometry_toFun := hf + +/-- Every onto isometry of unit spheres extends uniquely to a real-linear isometry. -/ +theorem tingley_sphere_isometry + (f : UnitSphere X → UnitSphere Y) (hf : Isometry f) (hs : Function.Surjective f) : + ∃! T : X ≃ₗᵢ[ℝ] Y, ∀ x : UnitSphere X, T (x : X) = (f x : Y) := by + exact existsUnique_linearIsometryEquiv (sphereIsometryEquiv f hf hs) + +/-- Radial formula, surjectivity, and uniqueness among all real-linear extensions. -/ +theorem tingley_sphere_isometry_full + (f : UnitSphere X → UnitSphere Y) (hf : Isometry f) (hs : Function.Surjective f) : + ∃ T : X ≃ₗᵢ[ℝ] Y, + (∀ u : UnitSphere X, T (u : X) = (f u : Y)) ∧ + T 0 = 0 ∧ + (∀ x : X, ∀ hx : x ≠ 0, T x = ‖x‖ • (f (normalize x hx) : Y)) ∧ + Function.Surjective T ∧ + (∀ L : X →ₗ[ℝ] Y, (∀ u : UnitSphere X, L (u : X) = (f u : Y)) → + L = T.toLinearEquiv.toLinearMap) := by + let e := sphereIsometryEquiv f hf hs + refine ⟨extension e, extension_unit e, extension_zero e, + extension_radial e, extension_surjective e, ?_⟩ + intro L hL + exact extension_unique e L hL + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ExtremalPropagation.lean b/lean/OAI/Analysis/SphereIsometry/ExtremalPropagation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba64723a4d258478b0fb39ad2935a8b684f1661b --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ExtremalPropagation.lean @@ -0,0 +1,251 @@ +import OAI.Analysis.SphereIsometry.ReturnMap +import OAI.Analysis.SphereIsometry.PositiveConvexFace +import Mathlib.Data.Fin.Tuple.Basic +import Mathlib.Topology.Constructions + +namespace OAI + +/-! +# The actual extremal return set and finite-hull propagation + +The set is defined by equality in the original sphere-map defect. Its +closedness, return identities and simultaneous support propagation are proved +from that definition and the global absolute defect bound. +-/ + +noncomputable section + +open Set +open scoped BigOperators + +namespace Tingley + +variable {X Y : Type*} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +variable (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) +variable (t : ℝ) (ht : 0 < t ∧ t < 1) (M : ℝ) + +def extremalSphere : Set (UnitSphere X) := + {v | sRadius f y t ht v - pRadius f y t ht v = M} + +def extremalSet : Set X := + Subtype.val '' extremalSphere f y t ht M + +@[simp] theorem mem_extremalSet_coe (v : UnitSphere X) : + (v : X) ∈ extremalSet f y t ht M ↔ v ∈ extremalSphere f y t ht M := by + constructor + · rintro ⟨w, hw, heq⟩ + have : w = v := Subtype.ext heq + simpa only [this] using hw + · intro hv + exact ⟨v, hv, rfl⟩ + +theorem norm_eq_one_of_mem_extremalSet {v : X} + (hv : v ∈ extremalSet f y t ht M) : ‖v‖ = 1 := by + obtain ⟨w, _, rfl⟩ := hv + exact w.property + +theorem isClosed_extremalSphere : IsClosed (extremalSphere f y t ht M) := + isClosed_eq ((continuous_sRadius f y t ht).sub (continuous_pRadius f y t ht)) + continuous_const + +theorem isClosed_extremalSet : IsClosed (extremalSet f y t ht M) := by + have hs : IsClosed {v : X | ‖v‖ = 1} := isClosed_eq continuous_norm continuous_const + exact hs.isClosedMap_subtype_val _ (isClosed_extremalSphere f y t ht M) + +theorem sRadius_eq_add {v : UnitSphere X} + (hv : v ∈ extremalSphere f y t ht M) : + sRadius f y t ht v = pRadius f y t ht v + M := by + change sRadius f y t ht v - pRadius f y t ht v = M at hv + linarith + +theorem signedDefect_xPoint (v : UnitSphere X) : + signedDefect f t (xPoint f y t ht v) y = + sRadius f y t ht v - pRadius f y t ht v := by + unfold signedDefect + rw [norm_xPoint_sub_center] + rfl + +theorem extremalSphere_nonempty_of_attained (x₀ : UnitSphere X) + (hatt : signedDefect f t x₀ y = M) : + (extremalSphere f y t ht M).Nonempty := by + obtain ⟨v, hv⟩ := xPoint_surjective f y t ht x₀ + refine ⟨v, ?_⟩ + change sRadius f y t ht v - pRadius f y t ht v = M + rw [← signedDefect_xPoint, hv] + exact hatt + +theorem extremalSet_nonempty_of_attained (x₀ : UnitSphere X) + (hatt : signedDefect f t x₀ y = M) : + (extremalSet f y t ht M).Nonempty := by + obtain ⟨v, hv⟩ := extremalSphere_nonempty_of_attained f y t ht M x₀ hatt + exact ⟨(v : X), (mem_extremalSet_coe f y t ht M v).mpr hv⟩ + +theorem norm_fzPoint_sub_center (v : UnitSphere X) : + ‖(f (zPoint f y t ht v) : Y) - t • (f y : Y)‖ = uRadius f y t ht v := by + rw [fzPoint_eq] + have he : t • (f y : Y) - uRadius f y t ht v • (wDirection f y t ht v : Y) - + t • (f y : Y) = -(uRadius f y t ht v • (wDirection f y t ht v : Y)) := by + abel + rw [he, norm_neg, norm_smul, Real.norm_of_nonneg (uRadius_pos f y t ht v).le, + UnitSphere.norm_coe, mul_one] + +theorem signedDefect_zPoint (v : UnitSphere X) : + signedDefect f t (zPoint f y t ht v) y = + uRadius f y t ht v - rRadius f y t ht v := by + unfold signedDefect + rw [norm_fzPoint_sub_center, norm_zPoint_sub_center] + +theorem norm_xPoint_sub_zPoint (v : UnitSphere X) : + ‖(xPoint f y t ht v : X) - (zPoint f y t ht v : X)‖ = + ‖pRadius f y t ht v • (v : X) + + rRadius f y t ht v • (returnSphere f y t ht v : X)‖ := by + congr 1 + rw [xPoint_eq, zPoint_eq] + abel + +theorem norm_fxPoint_sub_fzPoint (v : UnitSphere X) : + ‖(f (xPoint f y t ht v) : Y) - (f (zPoint f y t ht v) : Y)‖ = + sRadius f y t ht v + uRadius f y t ht v := by + rw [fxPoint_eq, fzPoint_eq] + have he : (t • (f y : Y) + sRadius f y t ht v • (wDirection f y t ht v : Y)) - + (t • (f y : Y) - uRadius f y t ht v • (wDirection f y t ht v : Y)) = + (sRadius f y t ht v + uRadius f y t ht v) • (wDirection f y t ht v : Y) := by + rw [add_smul] + abel + rw [he, norm_smul, Real.norm_of_nonneg + (add_nonneg (sRadius_pos f y t ht v).le (uRadius_pos f y t ht v).le), + UnitSphere.norm_coe, mul_one] + +theorem extremal_radius_identities (hb : HasDefectBound f M) {v : UnitSphere X} + (hv : v ∈ extremalSphere f y t ht M) : + rRadius f y t ht v - uRadius f y t ht v = M ∧ + pRadius f y t ht v + rRadius f y t ht v = + sRadius f y t ht v + uRadius f y t ht v ∧ + ‖pRadius f y t ht v • (v : X) + + rRadius f y t ht v • (returnSphere f y t ht v : X)‖ = + pRadius f y t ht v + rRadius f y t ht v := by + have hback := (abs_le.mp (hb t ⟨ht.1.le, ht.2.le⟩ (zPoint f y t ht v) y)).1 + rw [signedDefect_zPoint] at hback + have hs := sRadius_eq_add f y t ht M hv + have hn : ‖pRadius f y t ht v • (v : X) + + rRadius f y t ht v • (returnSphere f y t ht v : X)‖ = + sRadius f y t ht v + uRadius f y t ht v := by + rw [← norm_xPoint_sub_zPoint, ← sphere_norm_sub f, norm_fxPoint_sub_fzPoint] + have htri := norm_add_le (pRadius f y t ht v • (v : X)) + (rRadius f y t ht v • (returnSphere f y t ht v : X)) + simp only [norm_smul, Real.norm_of_nonneg (pRadius_pos f y t ht v).le, + Real.norm_of_nonneg (rRadius_pos f y t ht v).le, UnitSphere.norm_coe, + mul_one] at htri + have hr : rRadius f y t ht v - uRadius f y t ht v = M := by linarith + have hsum : pRadius f y t ht v + rRadius f y t ht v = + sRadius f y t ht v + uRadius f y t ht v := by linarith + exact ⟨hr, hsum, hn.trans hsum.symm⟩ + +theorem rRadius_eq_add (hb : HasDefectBound f M) {v : UnitSphere X} + (hv : v ∈ extremalSphere f y t ht M) : + rRadius f y t ht v = uRadius f y t ht v + M := by + have h := (extremal_radius_identities f y t ht M hb hv).1 + linarith + +theorem extremal_common_support (hb : HasDefectBound f M) {v : UnitSphere X} + (hv : v ∈ extremalSphere f y t ht M) : + ∃ φ : X →L[ℝ] ℝ, ‖φ‖ ≤ 1 ∧ φ (v : X) = 1 ∧ + φ (returnSphere f y t ht v : X) = 1 := + common_support_of_norm_add_eq v.property (returnSphere f y t ht v).property + (pRadius_pos f y t ht v) (rRadius_pos f y t ht v) + (extremal_radius_identities f y t ht M hb hv).2.2 + +theorem mem_extremal_of_common_support_return (hb : HasDefectBound f M) + {v : UnitSphere X} (hv : v ∈ extremalSphere f y t ht M) + (l : UnitSphere X) (φ : X →L[ℝ] ℝ) (hφ : ‖φ‖ ≤ 1) + (hl : φ (l : X) = 1) (hg : φ (returnSphere f y t ht v : X) = 1) : + l ∈ extremalSphere f y t ht M := by + have hlow : pRadius f y t ht l + rRadius f y t ht v ≤ + ‖(xPoint f y t ht l : X) - (zPoint f y t ht v : X)‖ := by + have he : (xPoint f y t ht l : X) - (zPoint f y t ht v : X) = + pRadius f y t ht l • (l : X) + + rRadius f y t ht v • (returnSphere f y t ht v : X) := by + rw [xPoint_eq, zPoint_eq] + abel + rw [he] + have heval : φ (pRadius f y t ht l • (l : X) + + rRadius f y t ht v • (returnSphere f y t ht v : X)) = + pRadius f y t ht l + rRadius f y t ht v := by + simp only [map_add, map_smul, smul_eq_mul, hl, hg, mul_one] + rw [← heval] + exact apply_le_norm hφ _ + have hupp : ‖(xPoint f y t ht l : X) - (zPoint f y t ht v : X)‖ ≤ + sRadius f y t ht l + uRadius f y t ht v := by + rw [← sphere_norm_sub f, fxPoint_eq, fzPoint_eq] + have he : (t • (f y : Y) + sRadius f y t ht l • (wDirection f y t ht l : Y)) - + (t • (f y : Y) - uRadius f y t ht v • (wDirection f y t ht v : Y)) = + sRadius f y t ht l • (wDirection f y t ht l : Y) + + uRadius f y t ht v • (wDirection f y t ht v : Y) := by abel + rw [he] + simpa only [norm_smul, Real.norm_of_nonneg (sRadius_pos f y t ht l).le, + Real.norm_of_nonneg (uRadius_pos f y t ht v).le, UnitSphere.norm_coe, + mul_one] using norm_add_le + (sRadius f y t ht l • (wDirection f y t ht l : Y)) + (uRadius f y t ht v • (wDirection f y t ht v : Y)) + have hdef := (abs_le.mp (hb t ⟨ht.1.le, ht.2.le⟩ (xPoint f y t ht l) y)).2 + rw [signedDefect_xPoint] at hdef + have hr := (extremal_radius_identities f y t ht M hb hv).1 + change sRadius f y t ht l - pRadius f y t ht l = M + linarith + +theorem returnSphere_mem_extremal (hb : HasDefectBound f M) {v : UnitSphere X} + (hv : v ∈ extremalSphere f y t ht M) : + returnSphere f y t ht v ∈ extremalSphere f y t ht M := by + obtain ⟨φ, hφ, _, hg⟩ := extremal_common_support f y t ht M hb hv + exact mem_extremal_of_common_support_return f y t ht M hb hv + (returnSphere f y t ht v) φ hφ hg hg + +theorem positive_prefix_extension (hb : HasDefectBound f M) + (n : ℕ) (V : Fin (n + 1) → X) (weights : Fin (n + 1) → ℝ) + (hV : convexHull ℝ (Set.range V) ⊆ extremalSet f y t ht M) + (hpos : ∀ i, 0 < weights i) (hsum : ∑ i, weights i = 1) : + convexHull ℝ (Set.range (Fin.snoc V + (returnAmbient f y t ht (∑ i, weights i • V i)))) ⊆ extremalSet f y t ht M := by + let a : X := ∑ i, weights i • V i + have haE : a ∈ extremalSet f y t ht M := hV + (mem_convexHull_of_exists_fintype weights V (fun i => (hpos i).le) hsum + (fun i => ⟨i, rfl⟩) rfl) + have ha : ‖a‖ = 1 := norm_eq_one_of_mem_extremalSet f y t ht M haE + let av : UnitSphere X := ⟨a, ha⟩ + have hav : av ∈ extremalSphere f y t ht M := + (mem_extremalSet_coe f y t ht M av).mp haE + obtain ⟨φ, hφ, hφa, hφg⟩ := extremal_common_support f y t ht M hb hav + have hG : returnAmbient f y t ht a = (returnSphere f y t ht av : X) := + returnAmbient_coe f y t ht av + have hfaces : convexHull ℝ + (insert (returnAmbient f y t ht a) (Set.range V)) ⊆ extremalSet f y t ht M := by + apply convexHull_insert_subset_of_common_support φ hφ weights V + (returnAmbient f y t ht a) (extremalSet f y t ht M) hpos hsum + · intro i + exact norm_eq_one_of_mem_extremalSet f y t ht M + (hV (subset_convexHull ℝ (Set.range V) ⟨i, rfl⟩)) + · rw [hG] + exact (returnSphere f y t ht av).property + · exact hφa + · rw [hG] + exact hφg + · intro x hx hφx + have hext := mem_extremal_of_common_support_return f y t ht M hb hav + ⟨x, hx⟩ φ hφ hφx hφg + exact (mem_extremalSet_coe f y t ht M ⟨x, hx⟩).mpr hext + apply Set.Subset.trans (convexHull_mono ?_) hfaces + rintro x ⟨i, rfl⟩ + refine Fin.lastCases ?_ (fun j => ?_) i + · simp only [Fin.snoc_last] + exact Set.mem_insert _ _ + · simp only [Fin.snoc_castSucc] + exact Set.mem_insert_of_mem _ ⟨j, rfl⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/FiniteComplex.lean b/lean/OAI/Analysis/SphereIsometry/FiniteComplex.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9c686b29cf7c5cf7f8e63a4ac388fbd46a85461 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/FiniteComplex.lean @@ -0,0 +1,141 @@ +import Mathlib.Data.Fintype.Powerset +import Mathlib.Data.Finset.Card +import Mathlib.Data.Finset.Union + +namespace OAI + +/-! +# Finite complexes and their actual face-chain subdivision + +The empty face is included. A subdivision vertex is always a nonempty old +face, and a subdivision face is an actual finite inclusion-chain. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +structure FiniteComplex (V : Type u) [Fintype V] [DecidableEq V] where + faces : Finset (Finset V) + empty_mem : ∅ ∈ faces + down_closed : ∀ {s t}, s ∈ faces → t ⊆ s → t ∈ faces + +namespace FiniteComplex + +variable {V : Type u} [Fintype V] [DecidableEq V] + +def full : FiniteComplex V where + faces := Finset.univ + empty_mem := Finset.mem_univ _ + down_closed := fun _ _ => Finset.mem_univ _ + +@[simp] theorem mem_full (s : Finset V) : s ∈ (full : FiniteComplex V).faces := + Finset.mem_univ _ + +abbrev FaceVertex (K : FiniteComplex V) := + {s : Finset V // s ∈ K.faces ∧ s.Nonempty} + +instance (K : FiniteComplex V) : Fintype (FaceVertex K) := by + classical + unfold FaceVertex + infer_instance + +def chain (K : FiniteComplex V) (c : Finset (FaceVertex K)) : Prop := + ∀ a ∈ c, ∀ b ∈ c, a.val ⊆ b.val ∨ b.val ⊆ a.val + +theorem chain_mono {K : FiniteComplex V} {c d : Finset (FaceVertex K)} + (hc : K.chain c) (hd : d ⊆ c) : K.chain d := + fun a ha b hb => hc a (hd ha) b (hd hb) + +def sd (K : FiniteComplex V) : FiniteComplex (FaceVertex K) := by + classical + exact + { faces := Finset.univ.filter K.chain + empty_mem := by simp [chain] + down_closed := by + intro s t hs hts + exact Finset.mem_filter.mpr + ⟨Finset.mem_univ _, K.chain_mono (Finset.mem_filter.mp hs).2 hts⟩ } + +@[simp] theorem mem_sd_iff {K : FiniteComplex V} {c : Finset (FaceVertex K)} : + c ∈ K.sd.faces ↔ K.chain c := by + classical + simp [sd] + +def topCells (K : FiniteComplex V) (m : ℕ) : Finset (Finset V) := + K.faces.filter (fun s => s.card = m + 1) + +def codimFaces (K : FiniteComplex V) (m : ℕ) : Finset (Finset V) := + K.faces.filter (fun s => s.card = m) + +def incidentTop (K : FiniteComplex V) (m : ℕ) (s : Finset V) : Finset (Finset V) := + (K.topCells m).filter (fun t => s ⊆ t) + +@[simp] theorem mem_topCells {K : FiniteComplex V} {m : ℕ} {s : Finset V} : + s ∈ K.topCells m ↔ s ∈ K.faces ∧ s.card = m + 1 := + Finset.mem_filter + +@[simp] theorem mem_codimFaces {K : FiniteComplex V} {m : ℕ} {s : Finset V} : + s ∈ K.codimFaces m ↔ s ∈ K.faces ∧ s.card = m := + Finset.mem_filter + +@[simp] theorem mem_incidentTop {K : FiniteComplex V} {m : ℕ} + {s t : Finset V} : + t ∈ K.incidentTop m s ↔ t ∈ K.faces ∧ t.card = m + 1 ∧ s ⊆ t := by + simp [incidentTop, and_assoc] + +def CardBound (K : FiniteComplex V) (m : ℕ) : Prop := + ∀ s ∈ K.faces, s.card ≤ m + 1 + +def Pure (K : FiniteComplex V) (m : ℕ) : Prop := + ∀ s ∈ K.faces, ∃ t ∈ K.topCells m, s ⊆ t + +theorem Pure.cardBound {K : FiniteComplex V} {m : ℕ} (h : K.Pure m) : + K.CardBound m := by + intro s hs + obtain ⟨t, ht, hst⟩ := h s hs + exact (Finset.card_le_card hst).trans_eq (mem_topCells.mp ht).2 + +variable {I : Type v} [DecidableEq I] + +def faceCarrier (carrier : V → Finset I) (s : Finset V) : Finset I := + s.biUnion carrier + +omit [Fintype V] [DecidableEq V] in +@[simp] theorem mem_faceCarrier {carrier : V → Finset I} {s : Finset V} {i : I} : + i ∈ faceCarrier carrier s ↔ ∃ v ∈ s, i ∈ carrier v := + Finset.mem_biUnion + +omit [Fintype V] [DecidableEq V] in +theorem faceCarrier_mono (carrier : V → Finset I) {s t : Finset V} (h : s ⊆ t) : + faceCarrier carrier s ⊆ faceCarrier carrier t := + Finset.biUnion_subset_biUnion_of_subset_left _ h + +omit [Fintype V] [DecidableEq V] in +@[simp] theorem faceCarrier_empty (carrier : V → Finset I) : + faceCarrier carrier ∅ = ∅ := rfl + +omit [Fintype V] [DecidableEq V] in +@[simp] theorem faceCarrier_singleton (carrier : V → Finset I) (v : V) : + faceCarrier carrier {v} = carrier v := by + simp [faceCarrier] + +def sdCarrier (K : FiniteComplex V) (carrier : V → Finset I) : + FaceVertex K → Finset I := fun s => faceCarrier carrier s.val + +theorem sdCarrier_nonempty {K : FiniteComplex V} {carrier : V → Finset I} + (h : ∀ v, (carrier v).Nonempty) (s : FaceVertex K) : + (K.sdCarrier carrier s).Nonempty := by + obtain ⟨v, hv⟩ := s.property.2 + obtain ⟨i, hi⟩ := h v + exact ⟨i, mem_faceCarrier.mpr ⟨v, hv, hi⟩⟩ + +end FiniteComplex + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/InvariantConvexSet.lean b/lean/OAI/Analysis/SphereIsometry/InvariantConvexSet.lean new file mode 100644 index 0000000000000000000000000000000000000000..c22359377a5c9f906e7b0b09cb3019cec73b8f59 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/InvariantConvexSet.lean @@ -0,0 +1,164 @@ +import OAI.Analysis.SphereIsometry.PositiveScheduling +import Mathlib.Data.Fin.Tuple.Basic + +namespace OAI + +/-! +A closed invariant convex set from proved finite-prefix growth. The input +growth theorem is instantiated by the geometric common-support argument; +the recursion, positive scheduling, density and invariance are proved here. +-/ + +noncomputable section + +open scoped BigOperators +open Set + +namespace Tingley + +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + +/-- Ordinary finite-prefix recursion; no admissibility proof enters the data. -/ +def recursivePrefix (G : X → X) (v₀ : X) : (n : ℕ) → (Fin (n+1) → X) + | 0 => fun _ => v₀ + | n+1 => Fin.snoc (α := fun _ : Fin (n+2) => X) (recursivePrefix G v₀ n) + (G (∑ i, positiveStageWeights n i • recursivePrefix G v₀ n i)) + +def recursiveVector (G : X → X) (v₀ : X) (n : ℕ) : X := + recursivePrefix G v₀ n (Fin.last n) + +@[simp] theorem recursiveVector_zero (G : X → X) (v₀ : X) : + recursiveVector G v₀ 0 = v₀ := rfl + +theorem recursivePrefix_eq_vector (G : X → X) (v₀ : X) + (n : ℕ) (i : Fin (n+1)) : + recursivePrefix G v₀ n i = recursiveVector G v₀ i.val := by + induction n with + | zero => + have hi : i.val = 0 := by omega + simp [recursivePrefix] + | succ n ih => + refine Fin.lastCases ?_ (fun j => ?_) i + · rfl + · simpa only [recursivePrefix, Fin.snoc_castSucc, Fin.val_castSucc] using ih j + +theorem recursiveVector_succ (G : X → X) (v₀ : X) (n : ℕ) : + recursiveVector G v₀ (n+1) = G (stageMean (recursiveVector G v₀) n) := by + unfold recursiveVector + rw [recursivePrefix, Fin.snoc_last] + congr 1 + apply Finset.sum_congr rfl + intro i _ + rw [recursivePrefix_eq_vector] + rfl + +/-- The geometric one-step conclusion for the invariant convex set. -/ +def PositivePrefixGrowth (G : X → X) (E : Set X) : Prop := + ∀ (n : ℕ) (p : Fin (n+1) → X) (w : Fin (n+1) → ℝ), + convexHull ℝ (Set.range p) ⊆ E → + (∀ i, 0 < w i) → (∑ i, w i = 1) → + convexHull ℝ (Set.range + (Fin.snoc (α := fun _ : Fin (n+2) => X) p (G (∑ i, w i • p i)))) ⊆ E + +theorem recursivePrefix_hull_subset (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hstep : PositivePrefixGrowth G E) (n : ℕ) : + convexHull ℝ (Set.range (recursivePrefix G v₀ n)) ⊆ E := by + induction n with + | zero => + have hr : Set.range (recursivePrefix G v₀ 0) = {v₀} := by + ext x + constructor + · rintro ⟨i, rfl⟩; rfl + · intro hx + exact ⟨0, hx.symm⟩ + rw [hr, convexHull_singleton] + exact Set.singleton_subset_iff.mpr hv₀ + | succ n ih => + exact hstep n (recursivePrefix G v₀ n) (positiveStageWeights n) ih + (positiveStageWeights_pos n) (positiveStageWeights_sum n) + +theorem recursiveVector_prefix_hull_subset (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hstep : PositivePrefixGrowth G E) (n : ℕ) : + convexHull ℝ (Set.range (fun i : Fin (n+1) => recursiveVector G v₀ i.val)) ⊆ E := by + have he : (fun i : Fin (n+1) => recursiveVector G v₀ i.val) = + recursivePrefix G v₀ n := by + funext i + exact (recursivePrefix_eq_vector G v₀ n i).symm + rw [he] + exact recursivePrefix_hull_subset G E v₀ hv₀ hstep n + +theorem recursiveVector_mem (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hstep : PositivePrefixGrowth G E) (n : ℕ) : + recursiveVector G v₀ n ∈ E := + recursivePrefix_hull_subset G E v₀ hv₀ hstep n + (subset_convexHull ℝ _ ⟨Fin.last n, rfl⟩) + +theorem recursiveStageMean_mem (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hstep : PositivePrefixGrowth G E) (n : ℕ) : + stageMean (recursiveVector G v₀) n ∈ E := by + apply recursiveVector_prefix_hull_subset G E v₀ hv₀ hstep n + exact mem_convexHull_of_exists_fintype (positiveStageWeights n) + (fun i : Fin (n+1) => recursiveVector G v₀ i.val) + (fun i => (positiveStageWeights_pos n i).le) (positiveStageWeights_sum n) + (fun i => ⟨i, rfl⟩) rfl + +/-- The closed convex hull of the one actual recursively constructed sequence. -/ +def recursiveConvexSet (G : X → X) (v₀ : X) : Set X := + closure (convexHull ℝ (Set.range (recursiveVector G v₀))) + +theorem recursiveConvexSet_subset (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hE : IsClosed E) (hstep : PositivePrefixGrowth G E) : + recursiveConvexSet G v₀ ⊆ E := by + apply closure_minimal _ hE + exact convexHull_range_subset_of_prefixes _ E + (recursiveVector_prefix_hull_subset G E v₀ hv₀ hstep) + +theorem recursiveConvexSet_nonempty (G : X → X) (v₀ : X) : + (recursiveConvexSet G v₀).Nonempty := by + refine ⟨recursiveVector G v₀ 0, subset_closure ?_⟩ + exact subset_convexHull ℝ _ ⟨0, rfl⟩ + +theorem isClosed_recursiveConvexSet (G : X → X) (v₀ : X) : + IsClosed (recursiveConvexSet G v₀) := isClosed_closure + +theorem convex_recursiveConvexSet (G : X → X) (v₀ : X) : + Convex ℝ (recursiveConvexSet G v₀) := (convex_convexHull ℝ _).closure + +theorem recursiveConvexSet_invariant (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hE : IsClosed E) (hunit : ∀ x ∈ E, ‖x‖ = 1) + (hG : ContinuousOn G E) (hstep : PositivePrefixGrowth G E) : + Set.MapsTo G (recursiveConvexSet G v₀) (recursiveConvexSet G v₀) := by + let v := recursiveVector G v₀ + have hv : ∀ n, ‖v n‖ ≤ (1 : ℝ) := + fun n => (hunit _ (recursiveVector_mem G E v₀ hv₀ hstep n)).le + have hdense : closure (Set.range (stageMean v)) = recursiveConvexSet G v₀ := + closure_range_stageMean_eq v 1 (by norm_num) hv + have himage : Set.MapsTo G (Set.range (stageMean v)) (recursiveConvexSet G v₀) := by + rintro x ⟨n, rfl⟩ + rw [← recursiveVector_succ G v₀ n] + exact subset_closure (subset_convexHull ℝ _ ⟨n+1, rfl⟩) + have hcont : ContinuousOn G (closure (Set.range (stageMean v))) := by + rw [hdense] + exact hG.mono (recursiveConvexSet_subset G E v₀ hv₀ hE hstep) + have h := himage.closure_of_continuousOn hcont + rw [hdense, (isClosed_recursiveConvexSet G v₀).closure_eq] at h + exact h + +/-- No density or invariant-set premise: both are obtained from the positive recursion. -/ +theorem exists_invariant_closed_convex (G : X → X) (E : Set X) (v₀ : X) + (hv₀ : v₀ ∈ E) (hE : IsClosed E) (hunit : ∀ x ∈ E, ‖x‖ = 1) + (hG : ContinuousOn G E) (hstep : PositivePrefixGrowth G E) : + ∃ C : Set X, C.Nonempty ∧ IsClosed C ∧ Bornology.IsBounded C ∧ + Convex ℝ C ∧ C ⊆ E ∧ Set.MapsTo G C C := by + have hsub := recursiveConvexSet_subset G E v₀ hv₀ hE hstep + refine ⟨recursiveConvexSet G v₀, recursiveConvexSet_nonempty G v₀, + isClosed_recursiveConvexSet G v₀, ?_, convex_recursiveConvexSet G v₀, hsub, + recursiveConvexSet_invariant G E v₀ hv₀ hE hunit hG hstep⟩ + apply isBounded_iff_forall_norm_le.mpr + exact ⟨1, fun x hx => (hunit x (hsub hx)).le⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/IteratedPoints.lean b/lean/OAI/Analysis/SphereIsometry/IteratedPoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b3278ba48f064af48c837d25fdb53a3d9372010 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/IteratedPoints.lean @@ -0,0 +1,143 @@ +import OAI.Analysis.SphereIsometry.SubdivisionData +import OAI.Analysis.SphereIsometry.BarycentricPoints + +namespace OAI + +/-! +# Actual geometric points of iterated subdivision + +Initial vertices are coordinate unit vectors. Every later vertex is the finite +barycenter of the nonempty old face that it represents. Simplex membership, +exact carriers, and the geometric mesh bound follow from this recursive formula. +-/ + +noncomputable section + +namespace Tingley + +/-- The actual geometric realization of every recursively constructed vertex. -/ +def iterDataPoint (I : Type) [Fintype I] [DecidableEq I] : + (k : ℕ) → (iterData I k).Vertex → I → ℝ + | 0, v => Pi.single v 1 + | k + 1, v => finiteBarycenter (iterDataPoint I k) v.val + +@[simp] theorem iterDataPoint_zero (I : Type) [Fintype I] [DecidableEq I] (v : I) : + iterDataPoint I 0 v = Pi.single v 1 := rfl + +@[simp] theorem iterDataPoint_succ (I : Type) [Fintype I] [DecidableEq I] + (k : ℕ) (v : (iterData I (k + 1)).Vertex) : + iterDataPoint I (k + 1) v = finiteBarycenter (iterDataPoint I k) v.val := rfl + +/-- The recursion produces simplex vectors at every level. -/ +theorem iterDataPoint_mem_stdSimplex (I : Type) [Fintype I] [DecidableEq I] : + ∀ (k : ℕ) (v : (iterData I k).Vertex), + iterDataPoint I k v ∈ probabilitySimplexSet I := by + intro k + induction k with + | zero => + intro v + exact single_mem_probabilitySimplexSet v + | succ k ih => + intro v + exact finiteBarycenter_mem_stdSimplex (iterDataPoint I k) v.property.2 + (fun u _ => ih u) + +/-- The recursively defined combinatorial carrier is exactly the set of +strict-positive coordinates of the actual recursive point. -/ +theorem positiveCarrier_iterDataPoint (I : Type) [Fintype I] [DecidableEq I] : + ∀ (k : ℕ) (v : (iterData I k).Vertex), + positiveCarrier (iterDataPoint I k v) = (iterData I k).carrier v := by + intro k + induction k with + | zero => + intro v + change positiveCarrier (Pi.single v (1 : ℝ)) = {v} + ext i + by_cases hi : v = i + · subst i + simp [positiveCarrier] + · simp [positiveCarrier, Pi.single_apply, Ne.symm hi] + | succ k ih => + intro v + change positiveCarrier (finiteBarycenter (iterDataPoint I k) v.val) = + v.val.biUnion (fun u => (iterData I k).carrier u) + rw [positiveCarrier_finiteBarycenter (iterDataPoint I k) v.property.2 + (fun u _ i => (iterDataPoint_mem_stdSimplex I k u).1 i)] + ext i + simp only [Finset.mem_biUnion, ih] + +/-- The coordinate form used by the simplex fixed-point argument. -/ +abbrev iterPoint (m k : ℕ) : IterVertex m k → Fin (m + 1) → ℝ := + iterDataPoint (Fin (m + 1)) k + +@[simp] theorem iterPoint_zero (m : ℕ) (v : Fin (m + 1)) : + iterPoint m 0 v = Pi.single v 1 := rfl + +@[simp] theorem iterPoint_succ (m k : ℕ) (v : IterVertex m (k + 1)) : + iterPoint m (k + 1) v = finiteBarycenter (iterPoint m k) v.val := rfl + +theorem iterPoint_mem_stdSimplex (m k : ℕ) (v : IterVertex m k) : + iterPoint m k v ∈ probabilitySimplexSet (Fin (m + 1)) := + iterDataPoint_mem_stdSimplex (Fin (m + 1)) k v + +theorem positiveCarrier_iterPoint (m k : ℕ) (v : IterVertex m k) : + positiveCarrier (iterPoint m k v) = iterCarrier m k v := + positiveCarrier_iterDataPoint (Fin (m + 1)) k v + +/-- Exact boundary compatibility of the coordinate labelling rule. -/ +theorem iterPoint_pos_iff (m k : ℕ) (v : IterVertex m k) (i : Fin (m + 1)) : + 0 < iterPoint m k v i ↔ i ∈ iterCarrier m k v := by + rw [← mem_positiveCarrier, positiveCarrier_iterPoint] + +/-- Any two probability vectors have distance at most one in the ambient sup norm. -/ +theorem norm_sub_le_one_of_mem_stdSimplex {I : Type*} [Fintype I] + {x y : I → ℝ} (hx : x ∈ probabilitySimplexSet I) (hy : y ∈ probabilitySimplexSet I) : + ‖x - y‖ ≤ 1 := by + rw [← dist_eq_norm] + apply (dist_pi_le_iff zero_le_one).mpr + intro i + have hxi := mem_Icc_of_mem_probabilitySimplexSet hx i + have hyi := mem_Icc_of_mem_probabilitySimplexSet hy i + rw [Real.dist_eq] + apply abs_le.mpr + constructor <;> linarith [hxi.1, hxi.2, hyi.1, hyi.2] + +/-- The mesh of each actual level-k face is bounded by the kth power of the +barycentric contraction factor. No face coverage assertion is assumed. -/ +theorem iterPoint_mesh (m : ℕ) : + ∀ (k : ℕ) (s : Finset (IterVertex m k)), s ∈ iterComplex m k → + ∀ u ∈ s, ∀ v ∈ s, + ‖iterPoint m k u - iterPoint m k v‖ ≤ + ((m : ℝ) / (m + 1 : ℝ)) ^ k := by + intro k + induction k with + | zero => + intro s _ u _ v _ + simpa only [pow_zero] using norm_sub_le_one_of_mem_stdSimplex + (iterPoint_mem_stdSimplex m 0 u) (iterPoint_mem_stdSimplex m 0 v) + | succ k ih => + intro s hs u hu v hv + have hchain : (iterData (Fin (m + 1)) k).complex.chain s := + FiniteComplex.mem_sd_iff.mp hs + have hD : 0 ≤ ((m : ℝ) / (m + 1 : ℝ)) ^ k := + pow_nonneg (div_nonneg (Nat.cast_nonneg m) + (add_nonneg (Nat.cast_nonneg m) zero_le_one)) k + rcases hchain u hu v hv with huv | hvu + · have h := norm_finiteBarycenter_sub_le_mesh (p := iterPoint m k) m hD + u.property.2 huv (iter_card_le (m := m) (k := k) v.property.1) + (ih v.val v.property.1) + simpa only [iterPoint_succ, pow_succ'] using h + · have h := norm_finiteBarycenter_sub_le_mesh (p := iterPoint m k) m hD + v.property.2 hvu (iter_card_le (m := m) (k := k) u.property.1) + (ih u.val u.property.1) + calc + ‖iterPoint m (k + 1) u - iterPoint m (k + 1) v‖ = + ‖iterPoint m (k + 1) v - iterPoint m (k + 1) u‖ := norm_sub_rev _ _ + _ ≤ ((m : ℝ) / (m + 1 : ℝ)) ^ (k + 1) := by + simpa only [iterPoint_succ, pow_succ'] using h + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/IteratedSubdivision.lean b/lean/OAI/Analysis/SphereIsometry/IteratedSubdivision.lean new file mode 100644 index 0000000000000000000000000000000000000000..d687091f9e65a9b243c8f25231557b56bec94625 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/IteratedSubdivision.lean @@ -0,0 +1,15 @@ +import OAI.Analysis.SphereIsometry.SubdivisionData +import OAI.Analysis.SphereIsometry.SubdivisionIncidence +import OAI.Analysis.SphereIsometry.SubdivisionRestriction +import OAI.Analysis.SphereIsometry.BarycentricZero +import OAI.Analysis.SphereIsometry.IteratedPoints +import OAI.Analysis.SphereIsometry.SubdivisionPointRestriction + +/-! +# Actual subdivisions used in the geometric Sperner argument + +The finite recursion satisfies incidence, boundary restriction, zero-dimensional +counting, coordinate support, and shrinking mesh properties. These yield the +geometric Sperner and simplex fixed-point theorems without additional +triangulation or incidence assumptions. +-/ diff --git a/lean/OAI/Analysis/SphereIsometry/KuratowskiBasic.lean b/lean/OAI/Analysis/SphereIsometry/KuratowskiBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d81ff8d82bb99096c4d77e7610bb650837fbff5 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/KuratowskiBasic.lean @@ -0,0 +1,134 @@ +import OAI.Analysis.SphereIsometry.DiameterBounds +import Mathlib.Data.Fintype.EquivFin +import Mathlib.Order.ConditionallyCompleteLattice.Basic +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! # The Kuratowski measure from finite diameter covers + +The infimum uses positive real radii. The boundedness +hypotheses ensure that its defining set is nonempty. No compactness theorem +or fixed-point principle is part of this definition. +-/ + +namespace Tingley + +variable {E : Type*} [PseudoMetricSpace E] + +/-- A finite family of sets of pairwise diameter at most the given radius. -/ +def FiniteDiameterCover (H : Set E) (δ : ℝ) : Prop := + ∃ n : ℕ, ∃ A : Fin n → Set E, + (H ⊆ ⋃ i, A i) ∧ ∀ i, DiameterLE (A i) δ + +namespace FiniteDiameterCover + +variable {H A B : Set E} {δ ε : ℝ} + +theorem of_fintype {ι : Type*} [Fintype ι] (U : ι → Set E) + (hc : H ⊆ ⋃ i, U i) (hd : ∀ i, DiameterLE (U i) δ) : + FiniteDiameterCover H δ := by + classical + let e := Fintype.equivFin ι + refine ⟨Fintype.card ι, fun j => U (e.symm j), ?_, fun j => hd (e.symm j)⟩ + intro x hx + obtain ⟨i, hi⟩ := Set.mem_iUnion.mp (hc hx) + exact Set.mem_iUnion.mpr ⟨e i, by simpa only [Equiv.symm_apply_apply] using hi⟩ + +theorem of_finite {ι : Type*} [Finite ι] (U : ι → Set E) + (hc : H ⊆ ⋃ i, U i) (hd : ∀ i, DiameterLE (U i) δ) : + FiniteDiameterCover H δ := by + classical + let := Fintype.ofFinite ι + exact of_fintype U hc hd + +theorem empty (δ : ℝ) : FiniteDiameterCover (∅ : Set E) δ := by + refine ⟨0, fun _ => ∅, Set.empty_subset _, ?_⟩ + intro i + exact Fin.elim0 i + +theorem mono_set (hc : FiniteDiameterCover B δ) (hAB : A ⊆ B) : + FiniteDiameterCover A δ := by + obtain ⟨n, U, hcover, hd⟩ := hc + exact ⟨n, U, hAB.trans hcover, hd⟩ + +theorem mono_radius (hc : FiniteDiameterCover H δ) (hδε : δ ≤ ε) : + FiniteDiameterCover H ε := by + obtain ⟨n, U, hcover, hd⟩ := hc + exact ⟨n, U, hcover, fun i => (hd i).mono_radius hδε⟩ + +theorem closure (hc : FiniteDiameterCover H δ) : + FiniteDiameterCover (closure H) δ := by + obtain ⟨n, U, hcover, hd⟩ := hc + refine ⟨n, fun i => _root_.closure (U i), ?_, fun i => (hd i).closure⟩ + intro x hx + have hx' : x ∈ _root_.closure (⋃ i, U i) := closure_mono hcover hx + simpa only [closure_iUnion_of_finite] using hx' + +end FiniteDiameterCover + +/-- Positive radii admitting a finite diameter cover. -/ +def coverRadii (H : Set E) : Set ℝ := + {δ | 0 < δ ∧ FiniteDiameterCover H δ} + +/-- The Kuratowski measure of noncompactness, on bounded sets. -/ +noncomputable def chi (H : Set E) : ℝ := sInf (coverRadii H) + +theorem coverRadii_bddBelow (H : Set E) : BddBelow (coverRadii H) := + ⟨0, fun _ hδ => hδ.1.le⟩ + +theorem coverRadii_nonempty {H : Set E} (hH : Bornology.IsBounded H) : + (coverRadii H).Nonempty := by + obtain ⟨R, hR⟩ := Metric.isBounded_iff.mp hH + have hc : FiniteDiameterCover H (max R 1) := by + refine ⟨1, fun _ => H, ?_, ?_⟩ + · intro x hx + exact Set.mem_iUnion.mpr ⟨0, hx⟩ + · intro i x hx y hy + exact (hR hx hy).trans (le_max_left R 1) + exact ⟨max R 1, lt_of_lt_of_le zero_lt_one (le_max_right R 1), hc⟩ + +theorem chi_nonneg {H : Set E} (hH : Bornology.IsBounded H) : 0 ≤ chi H := + le_csInf (coverRadii_nonempty hH) (fun _ hδ => hδ.1.le) + +theorem chi_le_of_cover {H : Set E} {δ : ℝ} + (hδ : 0 ≤ δ) (hc : FiniteDiameterCover H δ) : chi H ≤ δ := by + by_contra hnot + have hlt : δ < chi H := lt_of_not_ge hnot + let ε : ℝ := (chi H - δ) / 2 + have hε : 0 < ε := by dsimp only [ε]; linarith + have hmem : δ + ε ∈ coverRadii H := + ⟨by linarith, hc.mono_radius (by linarith)⟩ + have hupper : chi H ≤ δ + ε := csInf_le (coverRadii_bddBelow H) hmem + dsimp only [ε] at hupper + linarith + +@[simp] theorem chi_empty : chi (∅ : Set E) = 0 := by + apply le_antisymm + · exact chi_le_of_cover le_rfl (FiniteDiameterCover.empty 0) + · exact chi_nonneg Bornology.isBounded_empty + +theorem chi_mono {A B : Set E} (hB : Bornology.IsBounded B) (hAB : A ⊆ B) : + chi A ≤ chi B := by + apply csInf_le_csInf (coverRadii_bddBelow A) (coverRadii_nonempty hB) + intro δ hδ + exact ⟨hδ.1, hδ.2.mono_set hAB⟩ + +theorem exists_cover_of_chi_lt {H : Set E} {ε : ℝ} + (hH : Bornology.IsBounded H) (hε : chi H < ε) : + ∃ δ : ℝ, 0 < δ ∧ δ < ε ∧ FiniteDiameterCover H δ := by + obtain ⟨δ, hδ, hδε⟩ := + (csInf_lt_iff (coverRadii_bddBelow H) (coverRadii_nonempty hH)).mp hε + exact ⟨δ, hδ.1, hδε, hδ.2⟩ + +theorem chi_closure {H : Set E} (hH : Bornology.IsBounded H) : + chi (closure H) = chi H := by + apply le_antisymm + · apply le_csInf (coverRadii_nonempty hH) + intro δ hδ + exact chi_le_of_cover hδ.1.le hδ.2.closure + · exact chi_mono hH.closure subset_closure + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/KuratowskiConvexHull.lean b/lean/OAI/Analysis/SphereIsometry/KuratowskiConvexHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..4db7ac0328fa0440153973604b15ef9b230c3fe6 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/KuratowskiConvexHull.lean @@ -0,0 +1,149 @@ +import OAI.Analysis.SphereIsometry.KuratowskiBasic +import OAI.Analysis.SphereIsometry.ConvexDiameter +import OAI.Analysis.SphereIsometry.CoefficientBins +import OAI.Analysis.SphereIsometry.ConvexCoverRegroup +import Mathlib.Analysis.Normed.Group.Bounded +import Mathlib.Algebra.BigOperators.Ring.Finset + +namespace OAI + +/-! # Convex-hull invariance of the Kuratowski measure + +Finite coefficient bins give actual finite covers of a convex hull. Cover +pieces are first intersected with the bounded original set; empty pieces are +replaced by a singleton from that set. Thus every coordinate has a valid point, +including coordinates with zero weight, and one norm bound controls all pieces. +-/ + +namespace Tingley + +open scoped BigOperators + +variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] + +/-- A diameter bound and a coefficient `l1` bound control finite mixtures. -/ +theorem dist_weighted_mixtures_le {ι : Type*} [Fintype ι] + (w v : ι → ℝ) (z u : ι → E) (δ R η : ℝ) + (hw : ∀ i, 0 ≤ w i) (hmass : (∑ i, w i) = 1) + (hdiam : ∀ i, dist (z i) (u i) ≤ δ) + (hnorm : ∀ i, ‖u i‖ ≤ R) (hR : 0 ≤ R) + (hcoeff : (∑ i, |w i - v i|) ≤ η) : + dist (∑ i, w i • z i) (∑ i, v i • u i) ≤ δ + R * η := by + have hterm (i : ι) : + ‖w i • z i - v i • u i‖ ≤ w i * δ + |w i - v i| * R := by + calc + ‖w i • z i - v i • u i‖ = + ‖w i • (z i - u i) + (w i - v i) • u i‖ := by + rw [smul_sub, sub_smul, sub_add_sub_cancel] + _ ≤ ‖w i • (z i - u i)‖ + ‖(w i - v i) • u i‖ := norm_add_le _ _ + _ = w i * dist (z i) (u i) + |w i - v i| * ‖u i‖ := by + rw [norm_smul, norm_smul, Real.norm_of_nonneg (hw i), + Real.norm_eq_abs, ← dist_eq_norm] + _ ≤ w i * δ + |w i - v i| * R := + add_le_add (mul_le_mul_of_nonneg_left (hdiam i) (hw i)) + (mul_le_mul_of_nonneg_left (hnorm i) (abs_nonneg _)) + calc + dist (∑ i, w i • z i) (∑ i, v i • u i) = + ‖∑ i, (w i • z i - v i • u i)‖ := by + rw [dist_eq_norm, Finset.sum_sub_distrib] + _ ≤ ∑ i, ‖w i • z i - v i • u i‖ := norm_sum_le _ _ + _ ≤ ∑ i, (w i * δ + |w i - v i| * R) := + Finset.sum_le_sum fun i _ => hterm i + _ = (∑ i, w i) * δ + (∑ i, |w i - v i|) * R := by + rw [Finset.sum_add_distrib, ← Finset.sum_mul, ← Finset.sum_mul] + _ = δ + R * (∑ i, |w i - v i|) := by + rw [hmass, one_mul, mul_comm (∑ i, |w i - v i|) R] + _ ≤ δ + R * η := + add_le_add_right (mul_le_mul_of_nonneg_left hcoeff hR) δ + +/-- Construct a finite convex-hull cover with arbitrarily small coefficient +error, using a fixed norm bound on the original set. -/ +theorem finiteDiameterCover_convexHull_of_norm_le + {H : Set E} {δ R η : ℝ} + (hδ : 0 ≤ δ) (hR : 0 ≤ R) (hη : 0 < η) + (hnorm : ∀ x ∈ H, ‖x‖ ≤ R) (hc : FiniteDiameterCover H δ) : + FiniteDiameterCover (convexHull ℝ H) (δ + R * η) := by + classical + by_cases hH : H.Nonempty + · obtain ⟨x₀, hx₀⟩ := hH + obtain ⟨n, U, hcover, hdiam⟩ := hc + let A : Fin n → Set E := fun i => + if (U i ∩ H).Nonempty then U i ∩ H else {x₀} + have hne (i : Fin n) : (A i).Nonempty := by + by_cases hi : (U i ∩ H).Nonempty + · simpa only [A, ite_eq_left hi] using hi + · simp only [A, ite_eq_right hi, Set.singleton_nonempty] + have hsub (i : Fin n) : A i ⊆ H := by + intro x hx + by_cases hi : (U i ∩ H).Nonempty + · have hx' : x ∈ U i ∩ H := by simpa only [A, ite_eq_left hi] using hx + exact hx'.2 + · have hx' : x = x₀ := by + simpa only [A, ite_eq_right hi, Set.mem_singleton_iff] using hx + simpa only [hx'] using hx₀ + have hAdiam (i : Fin n) : DiameterLE (A i) δ := by + intro x hx y hy + by_cases hi : (U i ∩ H).Nonempty + · have hx' : x ∈ U i ∩ H := by simpa only [A, ite_eq_left hi] using hx + have hy' : y ∈ U i ∩ H := by simpa only [A, ite_eq_left hi] using hy + exact hdiam i x hx'.1 y hy'.1 + · have hx' : x = x₀ := by + simpa only [A, ite_eq_right hi, Set.mem_singleton_iff] using hx + have hy' : y = x₀ := by + simpa only [A, ite_eq_right hi, Set.mem_singleton_iff] using hy + simpa only [hx', hy', dist_self] using hδ + have hAcover : ∀ x ∈ H, ∃ i, x ∈ A i := by + intro x hx + obtain ⟨i, hi⟩ := Set.mem_iUnion.mp (hcover hx) + have hni : (U i ∩ H).Nonempty := ⟨x, hi, hx⟩ + exact ⟨i, by simpa only [A, ite_eq_left hni] using (show x ∈ U i ∩ H from ⟨hi, hx⟩)⟩ + have hAnorm (i : Fin n) {x : E} (hx : x ∈ convexHull ℝ (A i)) : ‖x‖ ≤ R := + norm_le_of_mem_convexHull (fun y hy => hnorm y (hsub i hy)) hx + obtain ⟨K, bins, hbins_cover, hbins_diam⟩ := exists_coefficient_bins n η hη + let B : (Fin n → Fin (K + 1)) → Set E := fun q => + {x | ∃ (w : Fin n → ℝ) (z : Fin n → E), + w ∈ bins q ∧ (∀ i, 0 ≤ w i) ∧ (∑ i, w i) = 1 ∧ + (∀ i, z i ∈ convexHull ℝ (A i)) ∧ (∑ i, w i • z i) = x} + apply FiniteDiameterCover.of_fintype B + · intro x hx + obtain ⟨w, z, hw, hsum, hz, hrepr⟩ := + convexHull_cover_representation H A hne hAcover hx + obtain ⟨q, hq⟩ := hbins_cover w ⟨hw, hsum⟩ + exact Set.mem_iUnion.mpr ⟨q, w, z, hq, hw, hsum, hz, hrepr⟩ + · intro q x hx y hy + obtain ⟨w, z, hwbin, hw, hwsum, hz, hxrepr⟩ := hx + obtain ⟨v, u, hvbin, hv, hvsum, hu, hyrepr⟩ := hy + rw [← hxrepr, ← hyrepr] + exact dist_weighted_mixtures_le w v z u δ R η hw hwsum + (fun i => (hAdiam i).convexHull (z i) (hz i) (u i) (hu i)) + (fun i => hAnorm i (hu i)) hR (hbins_diam q w hwbin v hvbin) + · have hHe : H = ∅ := Set.not_nonempty_iff_eq_empty.mp hH + simpa only [hHe, convexHull_empty] using + (FiniteDiameterCover.empty (E := E) (δ + R * η)) + +/-- Convexification preserves the Kuratowski measure of every bounded set. -/ +theorem chi_convexHull {H : Set E} (hH : Bornology.IsBounded H) : + chi (convexHull ℝ H) = chi H := by + apply le_antisymm + · obtain ⟨R, hR, hnorm⟩ := hH.exists_pos_norm_le + apply le_csInf (coverRadii_nonempty hH) + intro δ hδ + apply le_of_forall_pos_le_add + intro ε hε + have hc := finiteDiameterCover_convexHull_of_norm_le hδ.1.le hR.le + (div_pos hε hR) hnorm hδ.2 + have hrad : δ + R * (ε / R) = δ + ε := by + rw [mul_div_cancel₀ ε hR.ne'] + have hb := chi_le_of_cover (add_nonneg hδ.1.le + (mul_nonneg hR.le (div_pos hε hR).le)) hc + simpa only [hrad] using hb + · exact chi_mono (isBounded_convexHull.mpr hH) (subset_convexHull ℝ H) + +/-- Taking the closed convex hull also preserves the Kuratowski measure. -/ +theorem chi_closedConvexHull {H : Set E} (hH : Bornology.IsBounded H) : + chi (closure (convexHull ℝ H)) = chi H := by + rw [chi_closure (isBounded_convexHull.mpr hH), chi_convexHull hH] + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/KuratowskiNested.lean b/lean/OAI/Analysis/SphereIsometry/KuratowskiNested.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6d484e66ffae3da07f225cd32ba6202e0576d64 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/KuratowskiNested.lean @@ -0,0 +1,102 @@ +import OAI.Analysis.SphereIsometry.KuratowskiTotalBounded +import Mathlib.Topology.Compactness.Compact +import Mathlib.Topology.MetricSpace.Defs +import Mathlib.Topology.UniformSpace.Cauchy +import Mathlib.Topology.Order.Basic + +namespace OAI + +/-! +# Nested sets with vanishing Kuratowski measure + +Small finite diameter covers make the range of a selected sequence totally +bounded. Its compact closure supplies a point in all the nested closed sets. +The whole intersection is compact by its own arbitrarily fine finite covers. +-/ + +noncomputable section + +open Filter Set +open scoped Topology + +namespace Tingley + +section Pseudometric + +variable {E : Type*} [PseudoMetricSpace E] [CompleteSpace E] + +/-- A nested sequence with arbitrarily fine finite diameter covers has a +nonempty compact intersection. No original member is assumed compact. -/ +theorem nonempty_isCompact_iInter_of_finiteDiameterCover + (C : ℕ → Set E) (hanti : Antitone C) + (hne : ∀ n, (C n).Nonempty) + (hclosed : ∀ n, IsClosed (C n)) + (hsmall : ∀ ε : ℝ, 0 < ε → + ∃ N : ℕ, FiniteDiameterCover (C N) ε) : + (⋂ n, C n).Nonempty ∧ IsCompact (⋂ n, C n) := by + classical + let x : ℕ → E := fun n => Classical.choose (hne n) + have hx : ∀ n, x n ∈ C n := fun n => Classical.choose_spec (hne n) + have htotal : TotallyBounded (range x) := + totallyBounded_range_of_nested_finiteDiameterCover C hanti x hx hsmall + let K : Set E := closure (range x) + have hKclosed : IsClosed K := isClosed_closure + have hKcompact : IsCompact K := + TotallyBounded.isCompact_of_isClosed htotal.closure hKclosed + let D : ℕ → Set E := fun n => K ∩ C n + have hDanti : ∀ n, D (n + 1) ⊆ D n := by + intro n z hz + exact ⟨hz.1, hanti (Nat.le_succ n) hz.2⟩ + have hDnonempty : ∀ n, (D n).Nonempty := by + intro n + exact ⟨x n, subset_closure (mem_range_self n), hx n⟩ + have hDclosed : ∀ n, IsClosed (D n) := + fun n => hKclosed.inter (hclosed n) + have hDcompact : IsCompact (D 0) := hKcompact.inter_right (hclosed 0) + have hnonempty : (⋂ n, C n).Nonempty := by + obtain ⟨z, hz⟩ := + IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed + D hDanti hDnonempty hDcompact hDclosed + refine ⟨z, mem_iInter.mpr ?_⟩ + intro n + exact (mem_iInter.mp hz n).2 + have hinter : TotallyBounded (⋂ n, C n) := by + apply totallyBounded_iff_finiteDiameterCover.mpr + intro ε hε + obtain ⟨N, hN⟩ := hsmall ε hε + exact hN.mono_set (fun z hz => mem_iInter.mp hz N) + exact ⟨hnonempty, + TotallyBounded.isCompact_of_isClosed hinter (isClosed_iInter hclosed)⟩ + +end Pseudometric + +section Metric + +variable {E : Type*} [MetricSpace E] [CompleteSpace E] + +/-- A decreasing sequence of nonempty closed sets in a complete metric space +has a nonempty compact intersection when its Kuratowski measures tend to zero. +Boundedness of the first set supplies boundedness at every later index. -/ +theorem nonempty_isCompact_iInter_of_chi_tendsto_zero + (C : ℕ → Set E) + (hanti : Antitone C) + (hne : ∀ n, (C n).Nonempty) + (hclosed : ∀ n, IsClosed (C n)) + (hbound : Bornology.IsBounded (C 0)) + (hchi : Tendsto (fun n => chi (C n)) atTop (𝓝 0)) : + (⋂ n, C n).Nonempty ∧ IsCompact (⋂ n, C n) := by + have hbounded : ∀ n, Bornology.IsBounded (C n) := + fun n => hbound.subset (hanti (Nat.zero_le n)) + apply nonempty_isCompact_iInter_of_finiteDiameterCover C hanti hne hclosed + intro ε hε + obtain ⟨N, hN⟩ := (hchi.eventually (gt_mem_nhds hε)).exists + obtain ⟨δ, _hδ, hδε, hcover⟩ := exists_cover_of_chi_lt (hbounded N) hN + exact ⟨N, hcover.mono_radius hδε.le⟩ + +end Metric + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/KuratowskiTotalBounded.lean b/lean/OAI/Analysis/SphereIsometry/KuratowskiTotalBounded.lean new file mode 100644 index 0000000000000000000000000000000000000000..a575e882e35942c09bc421a2c1a0fc2a0b47a1a5 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/KuratowskiTotalBounded.lean @@ -0,0 +1,131 @@ +import OAI.Analysis.SphereIsometry.KuratowskiBasic +import Mathlib.Algebra.Order.Field.Basic +import Mathlib.Data.Fintype.Basic +import Mathlib.Data.Fintype.Sum +import Mathlib.Topology.MetricSpace.Pseudo.Basic + +namespace OAI + +/-! +# Finite diameter covers and total boundedness + +The Kuratowski cover predicate is equivalent to arbitrarily fine finite metric +covers. Its zero value characterizes total boundedness on bounded sets. A +selected point from each member of a nested family has totally bounded range +when sufficiently late members admit arbitrarily fine diameter covers. +-/ + +noncomputable section + +open Set + +namespace Tingley + +universe u + +variable {E : Type u} [PseudoMetricSpace E] + +/-- Total boundedness is equivalent to finite pairwise-diameter covers at every +positive scale. No completeness or nonemptiness hypothesis is needed. -/ +theorem totallyBounded_iff_finiteDiameterCover {H : Set E} : + TotallyBounded H ↔ ∀ ε : ℝ, 0 < ε → FiniteDiameterCover H ε := by + classical + constructor + · intro hH ε hε + obtain ⟨t, ht, hcover⟩ := + Metric.totallyBounded_iff.mp hH (ε / 2) (half_pos hε) + let : Fintype t := ht.fintype + refine FiniteDiameterCover.of_fintype + (fun c : t => Metric.ball (c : E) (ε / 2)) ?_ ?_ + · intro x hx + obtain ⟨c, hct, hxc⟩ := Set.mem_iUnion₂.mp (hcover hx) + exact Set.mem_iUnion.mpr ⟨⟨c, hct⟩, hxc⟩ + · intro c x hx y hy + have hxy : dist x y < ε := calc + dist x y ≤ dist x (c : E) + dist y (c : E) := dist_triangle_right _ _ _ + _ < ε / 2 + ε / 2 := + add_lt_add (Metric.mem_ball.mp hx) (Metric.mem_ball.mp hy) + _ = ε := add_halves ε + exact hxy.le + · intro hcover + apply Metric.totallyBounded_of_finite_discretization + intro ε hε + obtain ⟨n, A, hA, hdiam⟩ := hcover (ε / 2) (half_pos hε) + have hmem : ∀ x : H, ∃ i : Fin n, (x : E) ∈ A i := + fun x => Set.mem_iUnion.mp (hA x.property) + let label : H → Fin n := fun x => Classical.choose (hmem x) + have hlabel : ∀ x : H, (x : E) ∈ A (label x) := + fun x => Classical.choose_spec (hmem x) + refine ⟨ULift.{u} (Fin n), inferInstance, + (fun x => ⟨label x⟩), ?_⟩ + intro x y hxy + have heq : label x = label y := + congrArg (fun z : ULift.{u} (Fin n) => z.down) hxy + have hy : (y : E) ∈ A (label x) := by + rw [heq] + exact hlabel y + exact (hdiam (label x) (x : E) (hlabel x) (y : E) hy).trans_lt + (half_lt_self hε) + +/-- On bounded sets, vanishing Kuratowski measure is exactly total boundedness. +The boundedness premise ensures that the real infimum defining `chi` has +genuine admissible cover radii. -/ +theorem chi_eq_zero_iff_totallyBounded {H : Set E} + (hH : Bornology.IsBounded H) : chi H = 0 ↔ TotallyBounded H := by + constructor + · intro hzero + apply totallyBounded_iff_finiteDiameterCover.mpr + intro ε hε + have hχε : chi H < ε := by + rw [hzero] + exact hε + obtain ⟨δ, _hδ, hδε, hc⟩ := exists_cover_of_chi_lt hH hχε + exact hc.mono_radius hδε.le + · intro htb + have hle : chi H ≤ 0 := by + by_contra h + have hpos : 0 < chi H := lt_of_not_ge h + have hhalf : 0 < chi H / 2 := half_pos hpos + have hcover := totallyBounded_iff_finiteDiameterCover.mp htb (chi H / 2) hhalf + have hbound := chi_le_of_cover hhalf.le hcover + exact (not_le_of_gt (half_lt_self hpos)) hbound + exact le_antisymm hle (chi_nonneg hH) + +/-- Cover the entire selected range by finitely many prefix singletons and a +small cover of a sufficiently late member. The cutoff may depend on the scale; +no fixed member of the original family is assumed totally bounded. -/ +theorem totallyBounded_range_of_nested_finiteDiameterCover + (C : ℕ → Set E) (hanti : Antitone C) + (x : ℕ → E) (hx : ∀ n, x n ∈ C n) + (hsmall : ∀ ε : ℝ, 0 < ε → + ∃ N : ℕ, FiniteDiameterCover (C N) ε) : + TotallyBounded (Set.range x) := by + classical + apply totallyBounded_iff_finiteDiameterCover.mpr + intro ε hε + obtain ⟨N, k, A, hcover, hdiam⟩ := hsmall ε hε + let B : Sum (Fin N) (Fin k) → Set E := + Sum.elim (fun i => {x (i : ℕ)}) A + refine FiniteDiameterCover.of_fintype B ?_ ?_ + · rintro y ⟨n, rfl⟩ + by_cases hn : n < N + · exact Set.mem_iUnion.mpr ⟨Sum.inl ⟨n, hn⟩, rfl⟩ + · have hxn : x n ∈ C N := hanti (Nat.le_of_not_gt hn) (hx n) + obtain ⟨i, hi⟩ := Set.mem_iUnion.mp (hcover hxn) + exact Set.mem_iUnion.mpr ⟨Sum.inr i, hi⟩ + · intro i + cases i with + | inl i => + change DiameterLE ({x (i : ℕ)} : Set E) ε + intro y hy z hz + rcases Set.mem_singleton_iff.mp hy with rfl + rcases Set.mem_singleton_iff.mp hz with rfl + simpa only [dist_self] using hε.le + | inr i => + exact hdiam i + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/LargeChord.lean b/lean/OAI/Analysis/SphereIsometry/LargeChord.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c7d9b3fb1d19ec8d1aedb2581b63809c4e16bf0 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/LargeChord.lean @@ -0,0 +1,177 @@ +import OAI.Analysis.SphereIsometry.ChordSecant +import OAI.Analysis.SphereIsometry.RadialPerturbation + +namespace OAI + +/-! +# Excluding large aligned-chord ratios + +The secant estimate holds for every support. Reusing a support in the equality +case makes the sign strict, and the literal inverse configuration gives the +opposite image sign. A small radial perturbation then violates the actual defect +bound. No compactness assumption on either ambient space is used here. +-/ + +noncomputable section + +namespace Tingley +namespace AlignedConfiguration + +variable {X Y : Type*} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] +variable {f : UnitSphere X ≃ᵢ UnitSphere Y} {y : UnitSphere X} {t M : ℝ} +variable (C : AlignedConfiguration f y t M) + +/-- The large-ratio secant bound controls both the product and the size of the +support perturbation. All quantities come from the given configuration. -/ +theorem largeB_product_bounds (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hlarge : 1 - t < C.B) : + 1 - t ≤ C.A * C.u ∧ C.secantTheta ≤ 1 - C.B := by + obtain ⟨φ, hφ⟩ := exists_support ((C.v : X) + C.secantTheta • (y : X)) + have hs := C.secant_bounds hM ht hb φ hφ + have hle : (1 - t) / C.p ≤ C.B := + hs.1.trans (hs.2.1.trans (hs.2.2.2 hlarge)) + have hproduct : 1 - t ≤ C.A * C.u := by + calc + 1 - t ≤ C.B * C.p := (div_le_iff₀ C.p_pos).mp hle + _ = C.A * C.u := by unfold A B; ring + refine ⟨hproduct, ?_⟩ + rw [secantTheta, C.secantStep_eq_largeB ht hlarge, C.one_sub_B] + apply (div_le_iff₀ C.p_pos).mpr + calc + ((1 - t) / C.u) * C.s ≤ C.A * C.s := + mul_le_mul_of_nonneg_right ((div_le_iff₀ C.u_pos).mpr hproduct) C.s_pos.le + _ = (C.s / C.d) * C.p := by unfold A; ring + +/-- A large `B` makes every support at the original chord direction strictly +negative on the base vector, and forces `A` into the same large regime. -/ +theorem largeB_forces_largeA_and_negative_support + (hM : 0 < M) (ht : 0 < t ∧ t < 1) (hb : HasDefectBound f M) + (hlarge : 1 - t < C.B) : + 1 - t < C.A ∧ + ∀ L : X →L[ℝ] ℝ, SupportAt L (C.v : X) → L (y : X) < 0 := by + obtain ⟨hproduct, hθB⟩ := C.largeB_product_bounds hM ht hb hlarge + have hθ : 0 < C.secantTheta := C.secantTheta_pos ht + have hnegative : ∀ L : X →L[ℝ] ℝ, + SupportAt L (C.v : X) → L (y : X) < 0 := by + intro L hL + have hLv : L (C.v : X) = 1 := hL.2.trans C.v.property + obtain ⟨φ, hφ⟩ := exists_support ((C.v : X) + C.secantTheta • (y : X)) + have hs := C.secant_bounds hM ht hb φ hφ + have hφv : φ (C.v : X) ≤ C.B := hs.2.1.trans (hs.2.2.2 hlarge) + have hφy : φ (y : X) ≤ 1 := by + simpa only [UnitSphere.norm_coe] using apply_le_norm hφ.1 (y : X) + have hφeval : φ (C.v : X) + C.secantTheta * φ (y : X) = + ‖(C.v : X) + C.secantTheta • (y : X)‖ := by + simpa only [map_add, map_smul, smul_eq_mul] using hφ.2 + have hleft : 1 + C.secantTheta * L (y : X) ≤ + ‖(C.v : X) + C.secantTheta • (y : X)‖ := by + simpa only [map_add, map_smul, smul_eq_mul, hLv] using + apply_le_norm hL.1 ((C.v : X) + C.secantTheta • (y : X)) + have hφterm : C.secantTheta * φ (y : X) ≤ C.secantTheta := by + simpa only [mul_one] using mul_le_mul_of_nonneg_left hφy hθ.le + have hnorm : ‖(C.v : X) + C.secantTheta • (y : X)‖ ≤ + C.B + C.secantTheta := by + linarith only [hφeval, hφv, hφterm] + have hstrict : 1 + C.secantTheta * L (y : X) - C.secantTheta < C.B := by + by_contra hnot + have hLperturbed : SupportAt L ((C.v : X) + C.secantTheta • (y : X)) := by + refine ⟨hL.1, ?_⟩ + simp only [map_add, map_smul, smul_eq_mul, hLv] + have hreverse := le_of_not_gt hnot + linarith only [hleft, hnorm, hreverse] + have hsL := C.secant_bounds hM ht hb L hLperturbed + have hbad : 1 ≤ C.B := by + simpa only [hLv] using hsL.2.1.trans (hsL.2.2.2 hlarge) + exact (not_le_of_gt C.B_lt_one) hbad + have hmul : C.secantTheta * L (y : X) < C.secantTheta * 0 := by + linarith only [hstrict, hθB] + exact (mul_lt_mul_iff_right₀ hθ).mp hmul + refine ⟨?_, hnegative⟩ + obtain ⟨L, hL⟩ := exists_support (C.v : X) + have hj : L (y : X) < 0 := hnegative L hL + have hLv : L (C.v : X) = 1 := hL.2.trans C.v.property + have hz : C.r • (C.v : X) - t • (y : X) = -(C.z : X) := by + rw [C.z_eq] + abel + have hznorm : ‖C.r • (C.v : X) - t • (y : X)‖ = 1 := by + rw [hz, norm_neg, UnitSphere.norm_coe] + have hr : C.r - t * L (y : X) ≤ 1 := by + simpa only [map_sub, map_smul, smul_eq_mul, hLv, mul_one, hznorm] using + apply_le_norm hL.1 (C.r • (C.v : X) - t • (y : X)) + have htj : t * L (y : X) < 0 := mul_neg_of_pos_of_neg ht.1 hj + have hr1 : C.r < 1 := by linarith only [hr, htj] + have hu1 : C.u < 1 := by linarith only [hr1, C.r_sub_u, hM] + have hproduct_lt : C.A * C.u < C.A := by + simpa only [mul_one] using mul_lt_mul_of_pos_left hu1 C.A_pos + exact hproduct.trans_lt hproduct_lt + +/-- The inverse uses literal negated directions. In particular, obtaining the +positive image sign does not assume that the sphere map preserves antipodes. -/ +theorem largeB_support_signs (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hlarge : 1 - t < C.B) : + (∀ L : X →L[ℝ] ℝ, SupportAt L (C.v : X) → L (y : X) < 0) ∧ + (∀ K : Y →L[ℝ] ℝ, SupportAt K (C.w : Y) → 0 < K (f y : Y)) := by + obtain ⟨hA, hnegative⟩ := + C.largeB_forces_largeA_and_negative_support hM ht hb hlarge + have hlarge_inverse : 1 - t < C.inverse.B := by + simpa only [inverse_B] using hA + have hinverse := + (C.inverse.largeB_forces_largeA_and_negative_support hM ht hb.symm + hlarge_inverse).2 + refine ⟨hnegative, ?_⟩ + intro K hK + have hKneg : SupportAt (-K) (C.inverse.v : Y) := by + simpa only [inverse_v_coe] using hK.neg + have h := hinverse (-K) hKneg + change -(K (f y : Y)) < 0 at h + linarith only [h] + +/-- A small decrease of the radius strictly increases both contributions to the +signed defect, contradicting its global bound. -/ +theorem largeB_impossible (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) (hlarge : 1 - t < C.B) : False := by + obtain ⟨hnegative, hpositive⟩ := C.largeB_support_signs hM ht hb hlarge + obtain ⟨η, hη, hηt, hshort⟩ := + exists_radial_perturbation_lt_with_cap C.v.property C.p_pos ht.1 hnegative + obtain ⟨K, hK⟩ := exists_support (C.w : Y) + have hKw : K (C.w : Y) = 1 := hK.2.trans C.w.property + have hKb : 0 < K (f y : Y) := hpositive K hK + have hlong : C.s < ‖C.s • (C.w : Y) + η • (f y : Y)‖ := by + have hle := apply_le_norm hK.1 (C.s • (C.w : Y) + η • (f y : Y)) + simp only [map_add, map_smul, smul_eq_mul, hKw, mul_one] at hle + have hterm : 0 < η * K (f y : Y) := mul_pos hη hKb + linarith only [hle, hterm] + have hq : t - η ∈ Set.Icc (0 : ℝ) 1 := by + constructor + · exact (sub_pos.mpr hηt).le + · linarith only [ht.2, hη] + have hx : (C.x : X) - (t - η) • (y : X) = + C.p • (C.v : X) + η • (y : X) := by + rw [C.x_eq, sub_smul] + abel + have hfx : (f C.x : Y) - (t - η) • (f y : Y) = + C.s • (C.w : Y) + η • (f y : Y) := by + rw [C.fx_eq, sub_smul] + abel + have hbound := (abs_le.mp (hb (t - η) hq C.x y)).2 + rw [signedDefect, hfx, hx] at hbound + linarith only [hbound, hshort, hlong, C.s_sub_p] + +/-- Both ratios lie in the small regime. The first component is obtained by +applying the already-proved contradiction to the exact inverse configuration. -/ +theorem small_ratios (hM : 0 < M) (ht : 0 < t ∧ t < 1) + (hb : HasDefectBound f M) : C.A ≤ 1 - t ∧ C.B ≤ 1 - t := by + constructor + · have h : C.inverse.B ≤ 1 - t := + le_of_not_gt (C.inverse.largeB_impossible hM ht hb.symm) + simpa only [inverse_B] using h + · exact le_of_not_gt (C.largeB_impossible hM ht hb) + +end AlignedConfiguration +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/Main.lean b/lean/OAI/Analysis/SphereIsometry/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..48aa3a4d261df92e9bde8eacdc60eb5fa4c445dc --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Main.lean @@ -0,0 +1,4 @@ +import OAI.Analysis.SphereIsometry.Extension +import OAI.Analysis.SphereIsometry.BarycentricPurity +import OAI.Analysis.SphereIsometry.IteratedSubdivision +import OAI.Analysis.SphereIsometry.SubdivisionPointRestriction diff --git a/lean/OAI/Analysis/SphereIsometry/Model.lean b/lean/OAI/Analysis/SphereIsometry/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..c807d92e46551ac761b79424ae6388d696e80468 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Model.lean @@ -0,0 +1,25 @@ +import Mathlib.Analysis.Normed.Module.RCLike.Basic +import Mathlib.Topology.MetricSpace.Isometry + +namespace OAI + +noncomputable section + +namespace Tingley + +universe u v + +abbrev UnitSphere (X : Type u) [NormedAddCommGroup X] := {x : X // ‖x‖ = 1} + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +def normalize (x : X) (hx : x ≠ 0) : UnitSphere X := + ⟨‖x‖⁻¹ • x, norm_smul_inv_norm hx⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/PositiveConvexFace.lean b/lean/OAI/Analysis/SphereIsometry/PositiveConvexFace.lean new file mode 100644 index 0000000000000000000000000000000000000000..495d1d95e317006d3d0084c0bb5887d510e15cb7 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/PositiveConvexFace.lean @@ -0,0 +1,208 @@ +import OAI.Analysis.SphereIsometry.Supports +import Mathlib.Analysis.Normed.Module.Convex +import Mathlib.Algebra.Order.BigOperators.Group.Finset + +namespace OAI + +/-! +# Positive combinations in a common support face + +A norm-bounded functional that is one on a strictly positive barycenter is +one on every vertex. The resulting simultaneous support keeps the enlarged +convex hull in the unit sphere. For an infinite sequence, finite-prefix hull +containment passes to a closed ambient set without choosing a common support +for the entire sequence. +-/ + +noncomputable section + +open scoped BigOperators +open Set + +namespace Tingley + +section Scalar + +variable {ι : Type*} [Fintype ι] + +theorem eq_one_of_positive_weighted_sum (weights b : ι → ℝ) + (hpos : ∀ i, 0 < weights i) (hsum : ∑ i, weights i = 1) + (hb : ∀ i, b i ≤ 1) (hsaturated : ∑ i, weights i * b i = 1) : + ∀ i, b i = 1 := by + classical + have hnonneg : ∀ i ∈ (Finset.univ : Finset ι), 0 ≤ weights i * (1 - b i) := + fun i _ => mul_nonneg (hpos i).le (sub_nonneg.mpr (hb i)) + have hzero : ∑ i, weights i * (1 - b i) = 0 := by + calc + _ = (∑ i, weights i) - ∑ i, weights i * b i := by + simp only [mul_sub, mul_one, Finset.sum_sub_distrib] + _ = 0 := by rw [hsum, hsaturated, sub_self] + intro i + have hi := (Finset.sum_eq_zero_iff_of_nonneg hnonneg).mp hzero i + (Finset.mem_univ i) + exact (sub_eq_zero.mp ((mul_eq_zero.mp hi).resolve_left (ne_of_gt (hpos i)))).symm + +end Scalar + +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + +section FiniteCombination + +variable {ι : Type*} [Fintype ι] + +theorem support_eq_one_of_positive_sum (φ : X →L[ℝ] ℝ) (hφ : ‖φ‖ ≤ 1) + (weights : ι → ℝ) (v : ι → X) + (hpos : ∀ i, 0 < weights i) (hsum : ∑ i, weights i = 1) + (hv : ∀ i, ‖v i‖ ≤ 1) (ha : φ (∑ i, weights i • v i) = 1) : + ∀ i, φ (v i) = 1 := by + apply eq_one_of_positive_weighted_sum weights (fun i => φ (v i)) hpos hsum + · exact fun i => (apply_le_norm hφ (v i)).trans (hv i) + · simpa only [map_sum, map_smul, smul_eq_mul] using ha + +theorem SupportAt.eq_one_of_positive_sum {φ : X →L[ℝ] ℝ} + (weights : ι → ℝ) (v : ι → X) + (hφ : SupportAt φ (∑ i, weights i • v i)) + (hpos : ∀ i, 0 < weights i) (hsum : ∑ i, weights i = 1) + (hv : ∀ i, ‖v i‖ ≤ 1) (ha : ‖∑ i, weights i • v i‖ = 1) : + ∀ i, φ (v i) = 1 := + support_eq_one_of_positive_sum φ hφ.1 weights v hpos hsum hv (hφ.2.trans ha) + +end FiniteCombination + +/-- The closed unit ball cut by the level-one hyperplane of one functional. -/ +def supportFace (φ : X →L[ℝ] ℝ) : Set X := + {x | ‖x‖ ≤ 1 ∧ φ x = 1} + +theorem convex_supportFace (φ : X →L[ℝ] ℝ) : Convex ℝ (supportFace φ) := by + rintro x ⟨hx, hφx⟩ y ⟨hy, hφy⟩ a b ha hb hab + constructor + · calc + ‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _ + _ = a * ‖x‖ + b * ‖y‖ := by + rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb] + _ ≤ a * 1 + b * 1 := + add_le_add (mul_le_mul_of_nonneg_left hx ha) (mul_le_mul_of_nonneg_left hy hb) + _ = 1 := by simpa only [mul_one] using hab + · simpa only [map_add, map_smul, smul_eq_mul, hφx, hφy, mul_one] using hab + +theorem isClosed_supportFace (φ : X →L[ℝ] ℝ) : IsClosed (supportFace φ) := + (isClosed_le continuous_norm continuous_const).inter + (isClosed_eq φ.continuous continuous_const) + +theorem supportFace_subset_sphere (φ : X →L[ℝ] ℝ) (hφ : ‖φ‖ ≤ 1) : + supportFace φ ⊆ {x : X | ‖x‖ = 1} := by + intro x hx + exact le_antisymm hx.1 (hx.2 ▸ apply_le_norm hφ x) + +theorem convexHull_subset_supportFace (φ : X →L[ℝ] ℝ) + {S : Set X} (hS : S ⊆ supportFace φ) : + convexHull ℝ S ⊆ supportFace φ := + convexHull_min hS (convex_supportFace φ) + +theorem closure_convexHull_subset_supportFace (φ : X →L[ℝ] ℝ) + {S : Set X} (hS : S ⊆ supportFace φ) : + closure (convexHull ℝ S) ⊆ supportFace φ := + closure_minimal (convexHull_subset_supportFace φ hS) (isClosed_supportFace φ) + +section Enlargement + +variable {ι : Type*} [Fintype ι] + +theorem enlarged_convexHull_in_supportFace (φ : X →L[ℝ] ℝ) (hφ : ‖φ‖ ≤ 1) + (weights : ι → ℝ) (v : ι → X) (w : X) + (hpos : ∀ i, 0 < weights i) (hsum : ∑ i, weights i = 1) + (hv : ∀ i, ‖v i‖ = 1) (hw : ‖w‖ = 1) + (ha : φ (∑ i, weights i • v i) = 1) (hwφ : φ w = 1) : + convexHull ℝ (insert w (Set.range v)) ⊆ {x : X | ‖x‖ = 1 ∧ φ x = 1} := by + have hall := support_eq_one_of_positive_sum φ hφ weights v hpos hsum + (fun i => (hv i).le) ha + have hvertices : insert w (Set.range v) ⊆ supportFace φ := by + intro x hx + rcases hx with rfl | ⟨i, rfl⟩ + · exact ⟨hw.le, hwφ⟩ + · exact ⟨(hv i).le, hall i⟩ + intro x hx + have hxface := convexHull_subset_supportFace φ hvertices hx + exact ⟨supportFace_subset_sphere φ hφ hxface, hxface.2⟩ + +/-- The actual geometric propagation rule can now be applied to every new hull point. -/ +theorem convexHull_insert_subset_of_common_support (φ : X →L[ℝ] ℝ) (hφ : ‖φ‖ ≤ 1) + (weights : ι → ℝ) (v : ι → X) (w : X) (E : Set X) + (hpos : ∀ i, 0 < weights i) (hsum : ∑ i, weights i = 1) + (hv : ∀ i, ‖v i‖ = 1) (hw : ‖w‖ = 1) + (ha : φ (∑ i, weights i • v i) = 1) (hwφ : φ w = 1) + (hprop : ∀ x, ‖x‖ = 1 → φ x = 1 → x ∈ E) : + convexHull ℝ (insert w (Set.range v)) ⊆ E := by + intro x hx + have h := enlarged_convexHull_in_supportFace φ hφ weights v w hpos hsum hv hw ha hwφ hx + exact hprop x h.1 h.2 + +end Enlargement + +/-- The actual values at indices zero through n; repeated values are allowed. -/ +def prefixVertices (v : ℕ → X) (n : ℕ) : Set X := v '' {i : ℕ | i ≤ n} + +omit [NormedAddCommGroup X] [NormedSpace ℝ X] in +theorem prefixVertices_mono (v : ℕ → X) : Monotone (prefixVertices v) := by + intro n m hnm x hx + obtain ⟨i, hi, rfl⟩ := hx + exact ⟨i, hi.trans hnm, rfl⟩ + +omit [NormedAddCommGroup X] [NormedSpace ℝ X] in +theorem prefixVertices_subset_range (v : ℕ → X) (n : ℕ) : + prefixVertices v n ⊆ Set.range v := by + rintro x ⟨i, _, rfl⟩ + exact ⟨i, rfl⟩ + +omit [NormedAddCommGroup X] [NormedSpace ℝ X] in +theorem prefixVertices_eq_range_fin (v : ℕ → X) (n : ℕ) : + prefixVertices v n = Set.range (fun i : Fin (n + 1) => v i.val) := by + ext x + constructor + · rintro ⟨i, hi, rfl⟩ + exact ⟨⟨i, Nat.lt_succ_iff.mpr hi⟩, rfl⟩ + · rintro ⟨i, rfl⟩ + exact ⟨i.val, Nat.lt_succ_iff.mp i.isLt, rfl⟩ + +theorem convexHull_range_eq_iUnion_prefix (v : ℕ → X) : + convexHull ℝ (Set.range v) = ⋃ n, convexHull ℝ (prefixVertices v n) := by + have hmono : Monotone (fun n => convexHull ℝ (prefixVertices v n)) := + fun _ _ hnm => convexHull_mono (prefixVertices_mono v hnm) + have hdir : Directed (· ⊆ ·) (fun n => convexHull ℝ (prefixVertices v n)) := + fun n m => ⟨max n m, hmono (le_max_left n m), hmono (le_max_right n m)⟩ + apply Set.Subset.antisymm + · apply convexHull_min + · rintro x ⟨i, rfl⟩ + exact Set.mem_iUnion.mpr ⟨i, + subset_convexHull ℝ (prefixVertices v i) ⟨i, (by change i ≤ i; exact le_rfl), rfl⟩⟩ + · exact hdir.convex_iUnion (fun {n} => convex_convexHull ℝ (prefixVertices v n)) + · intro x hx + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hx + exact convexHull_mono (prefixVertices_subset_range v n) hn + +theorem closure_convexHull_range_subset_of_prefix (v : ℕ → X) + {E : Set X} (hE : IsClosed E) + (hprefix : ∀ n, convexHull ℝ (prefixVertices v n) ⊆ E) : + closure (convexHull ℝ (Set.range v)) ⊆ E := by + apply closure_minimal _ hE + rw [convexHull_range_eq_iUnion_prefix] + exact Set.iUnion_subset hprefix + +theorem closed_convex_extremal_hull (v : ℕ → X) + {E : Set X} (hE : IsClosed E) (hEsphere : E ⊆ {x : X | ‖x‖ = 1}) + (hprefix : ∀ n, convexHull ℝ (prefixVertices v n) ⊆ E) : + (closure (convexHull ℝ (Set.range v))).Nonempty ∧ + IsClosed (closure (convexHull ℝ (Set.range v))) ∧ + Convex ℝ (closure (convexHull ℝ (Set.range v))) ∧ + Bornology.IsBounded (closure (convexHull ℝ (Set.range v))) ∧ + closure (convexHull ℝ (Set.range v)) ⊆ E := by + have hsub := closure_convexHull_range_subset_of_prefix v hE hprefix + refine ⟨⟨v 0, subset_closure (subset_convexHull ℝ (Set.range v) ⟨0, rfl⟩)⟩, + isClosed_closure, (convex_convexHull ℝ (Set.range v)).closure, ?_, hsub⟩ + exact isBounded_iff_forall_norm_le.mpr ⟨1, fun x hx => (hEsphere (hsub hx)).le⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/PositiveScheduling.lean b/lean/OAI/Analysis/SphereIsometry/PositiveScheduling.lean new file mode 100644 index 0000000000000000000000000000000000000000..75c65469528b1d3ec674252d8baa2914e0a2cd35 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/PositiveScheduling.lean @@ -0,0 +1,380 @@ +import Mathlib.Analysis.Convex.Combination +import Mathlib.Analysis.Convex.Topology +import Mathlib.Analysis.Normed.Group.Bounded +import Mathlib.Analysis.Normed.Module.Basic +import Mathlib.Data.Rat.Encodable +import Mathlib.Data.Rat.BigOperators +import Mathlib.Logic.Encodable.Pi +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Ring +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Abel +import Lean.Elab.Tactic.Omega + +namespace OAI + +/-! A fixed positive coefficient schedule, dense for every bounded sequence. -/ + +noncomputable section + +open scoped BigOperators +open Set Finset + +namespace Tingley + +/-- A rational probability vector on an initial, nonempty list of indices. -/ +abbrev RationalPrefix := + Σ m : ℕ, {q : Fin (m + 1) → ℚ // (∀ i, 0 ≤ q i) ∧ ∑ i, q i = 1} + +/-- Extend a finite vector by zero, using the actual natural-number indices. -/ +def prefixZeroExtend {A : Type*} [Zero A] {k : ℕ} (f : Fin k → A) (i : ℕ) : A := + if h : i < k then f ⟨i, h⟩ else 0 + +@[simp] theorem prefixZeroExtend_apply {A : Type*} [Zero A] {k : ℕ} + (f : Fin k → A) (i : Fin k) : prefixZeroExtend f i.val = f i := by + simp [prefixZeroExtend, i.isLt] + +theorem sum_prefixZeroExtend {A : Type*} [AddCommMonoid A] {k n : ℕ} + (f : Fin k → A) (hkn : k ≤ n) : + (∑ i : Fin n, prefixZeroExtend f i.val) = ∑ i, f i := by + rw [Fin.sum_univ_eq_sum_range, Finset.sum_fin_eq_sum_range] + symm + apply Finset.sum_subset (Finset.range_mono hkn) + intro i _ hi + simp only [Finset.mem_range] at hi + simp [hi] + +/-- A failed or premature code is replaced by the point mass at the first index. -/ +def baseStageWeights (n : ℕ) : Fin (n + 1) → ℚ := + match Encodable.decode (α := RationalPrefix) (Nat.unpair n).1 with + | none => fun i => if i = 0 then 1 else 0 + | some q => if q.1 ≤ n then fun i => prefixZeroExtend q.2.val i.val + else fun i => if i = 0 then 1 else 0 + +theorem baseStageWeights_nonneg (n : ℕ) (i : Fin (n + 1)) : + 0 ≤ baseStageWeights n i := by + cases hdecode : Encodable.decode (α := RationalPrefix) (Nat.unpair n).1 with + | none => + simp only [baseStageWeights, hdecode] + split_ifs <;> norm_num + | some q => + by_cases h : q.1 ≤ n + · simp only [baseStageWeights, hdecode, ite_eq_left h] + unfold prefixZeroExtend + split_ifs + · exact q.2.property.1 _ + · exact le_rfl + · simp only [baseStageWeights, hdecode, ite_eq_right h] + split_ifs <;> norm_num + +theorem baseStageWeights_sum (n : ℕ) : ∑ i, baseStageWeights n i = 1 := by + cases hdecode : Encodable.decode (α := RationalPrefix) (Nat.unpair n).1 with + | none => simp [baseStageWeights, hdecode] + | some q => + by_cases h : q.1 ≤ n + · simp only [baseStageWeights, hdecode, ite_eq_left h] + rw [sum_prefixZeroExtend q.2.val (Nat.add_le_add_right h 1)] + exact q.2.property.2 + · simp [baseStageWeights, hdecode, h] + +theorem baseStageWeights_pair (q : RationalPrefix) (r : ℕ) (hr : q.1 ≤ r) : + baseStageWeights (Nat.pair (Encodable.encode q) r) = + fun i => prefixZeroExtend q.2.val i.val := by + have hq : q.1 ≤ Nat.pair (Encodable.encode q) r := hr.trans (Nat.right_le_pair _ _) + simp [baseStageWeights, hq] + +def stageMixing (n : ℕ) : ℝ := 1 / ((n : ℝ) + 2) + +theorem stageMixing_pos (n : ℕ) : 0 < stageMixing n := by + unfold stageMixing + positivity + +theorem stageMixing_lt_one (n : ℕ) : stageMixing n < 1 := by + unfold stageMixing + rw [div_lt_one (by positivity : (0 : ℝ) < (n : ℝ) + 2)] + linarith [show (0 : ℝ) ≤ (n : ℝ) from Nat.cast_nonneg n] + +/-- Mix with the uniform vector on *all* available indices. -/ +def positiveStageWeights (n : ℕ) (i : Fin (n + 1)) : ℝ := + (1 - stageMixing n) * (baseStageWeights n i : ℝ) + + stageMixing n / ((n : ℝ) + 1) + +theorem positiveStageWeights_pos (n : ℕ) (i : Fin (n + 1)) : + 0 < positiveStageWeights n i := by + have hb : (0 : ℝ) ≤ (baseStageWeights n i : ℝ) := by + exact_mod_cast baseStageWeights_nonneg n i + exact add_pos_of_nonneg_of_pos + (mul_nonneg (sub_nonneg.mpr (stageMixing_lt_one n).le) hb) + (div_pos (stageMixing_pos n) (by positivity)) + +theorem positiveStageWeights_sum (n : ℕ) : ∑ i, positiveStageWeights n i = 1 := by + have hb : (∑ i, (baseStageWeights n i : ℝ)) = 1 := by + exact_mod_cast baseStageWeights_sum n + have hn : (n : ℝ) + 1 ≠ 0 := by positivity + simp only [positiveStageWeights, Finset.sum_add_distrib, ← Finset.mul_sum, + hb, mul_one, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, + Nat.cast_one] + field_simp [hn] + ring + +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + +def stageMean (v : ℕ → X) (n : ℕ) : X := + ∑ i : Fin (n + 1), positiveStageWeights n i • v i.val + +def rationalPrefixMean (v : ℕ → X) (q : RationalPrefix) : X := + ∑ i : Fin (q.1 + 1), (q.2.val i : ℝ) • v i.val + +theorem norm_probability_sum_le {ι : Type*} [Fintype ι] + (w : ι → ℝ) (z : ι → X) (hw : ∀ i, 0 ≤ w i) + (hsum : ∑ i, w i = 1) (B : ℝ) (hz : ∀ i, ‖z i‖ ≤ B) : + ‖∑ i, w i • z i‖ ≤ B := by + calc + ‖∑ i, w i • z i‖ ≤ ∑ i, ‖w i • z i‖ := norm_sum_le _ _ + _ = ∑ i, w i * ‖z i‖ := by simp [norm_smul, Real.norm_eq_abs, abs_of_nonneg, hw] + _ ≤ ∑ i, w i * B := Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left (hz i) (hw i) + _ = B := by rw [← Finset.sum_mul, hsum, one_mul] + +private theorem sum_padded_mean (v : ℕ → X) (q : RationalPrefix) {n : ℕ} + (hq : q.1 ≤ n) : + (∑ i : Fin (n+1), (prefixZeroExtend (A := ℚ) q.2.val i.val : ℝ) • v i.val) = + rationalPrefixMean v q := by + have he (i : ℕ) : (prefixZeroExtend (A := ℚ) q.2.val i : ℝ) • v i = + prefixZeroExtend (fun j : Fin (q.1+1) => (q.2.val j : ℝ) • v j.val) i := by + unfold prefixZeroExtend + split <;> simp + simp_rw [he] + exact sum_prefixZeroExtend _ (Nat.add_le_add_right hq 1) + +private theorem norm_stageMean_sub_rational_le (v : ℕ → X) + (B : ℝ) (hv : ∀ i, ‖v i‖ ≤ B) (q : RationalPrefix) (r : ℕ) (hr : q.1 ≤ r) : + ‖stageMean v (Nat.pair (Encodable.encode q) r) - rationalPrefixMean v q‖ ≤ + 2 * B / ((Nat.pair (Encodable.encode q) r : ℝ) + 2) := by + let n := Nat.pair (Encodable.encode q) r + let U : X := ∑ i : Fin (n+1), (1 / ((n : ℝ)+1)) • v i.val + have hq : q.1 ≤ n := hr.trans (Nat.right_le_pair _ _) + have hQ : ‖rationalPrefixMean v q‖ ≤ B := by + refine norm_probability_sum_le (fun i => (q.2.val i : ℝ)) + (fun i => v i.val) ?_ ?_ B ?_ + · intro i + exact_mod_cast q.2.property.1 i + · exact_mod_cast q.2.property.2 + · intro i; exact hv i.val + have hU : ‖U‖ ≤ B := by + refine norm_probability_sum_le (fun _ : Fin (n+1) => 1 / ((n : ℝ)+1)) + (fun i => v i.val) ?_ ?_ B ?_ + · intro i; positivity + · simp [Finset.sum_const, nsmul_eq_mul, Nat.cast_add, Nat.cast_one, + ne_of_gt (show (0 : ℝ) < (n : ℝ)+1 by positivity)] + · intro i; exact hv i.val + have hbase := baseStageWeights_pair q r hr + have he : stageMean v n = + (1-stageMixing n) • rationalPrefixMean v q + stageMixing n • U := by + unfold stageMean positiveStageWeights + rw [hbase] + simp_rw [add_smul, mul_smul, div_eq_mul_inv, mul_smul] + rw [Finset.sum_add_distrib, ← Finset.smul_sum, ← Finset.smul_sum] + rw [sum_padded_mean v q hq] + simp [U, div_eq_mul_inv] + have hd : stageMean v n - rationalPrefixMean v q = + stageMixing n • (U-rationalPrefixMean v q) := by + rw [he, sub_smul, one_smul, smul_sub] + abel + calc + ‖stageMean v n-rationalPrefixMean v q‖ = + stageMixing n * ‖U-rationalPrefixMean v q‖ := by + rw [hd, norm_smul, Real.norm_eq_abs, abs_of_pos (stageMixing_pos n)] + _ ≤ stageMixing n * (B+B) := + mul_le_mul_of_nonneg_left ((norm_sub_le _ _).trans (add_le_add hU hQ)) + (stageMixing_pos n).le + _ = 2*B/((n:ℝ)+2) := by unfold stageMixing; ring + +theorem exists_late_stageMean_close_rational + (v : ℕ → X) (B : ℝ) (hB : 0 ≤ B) (hv : ∀ i, ‖v i‖ ≤ B) + (q : RationalPrefix) (δ : ℝ) (hδ : 0 < δ) (N : ℕ) : + ∃ n, N ≤ n ∧ ‖stageMean v n-rationalPrefixMean v q‖ < δ := by + obtain ⟨K, hK⟩ := exists_nat_gt (2*B/δ) + let r := max K (max N q.1) + let n := Nat.pair (Encodable.encode q) r + have hrK : K ≤ r := le_max_left _ _ + have hrN : N ≤ r := (le_max_left _ _).trans (le_max_right _ _) + have hrq : q.1 ≤ r := (le_max_right _ _).trans (le_max_right _ _) + have hrn : r ≤ n := Nat.right_le_pair _ _ + refine ⟨n, hrN.trans hrn, (norm_stageMean_sub_rational_le v B hv q r hrq).trans_lt ?_⟩ + have hKn : (K : ℝ) ≤ (n : ℝ) := by exact_mod_cast hrK.trans hrn + apply (div_lt_iff₀ (show (0 : ℝ) < (n : ℝ)+2 by positivity)).2 + have hk' : 2*B < (K:ℝ)*δ := (div_lt_iff₀ hδ).1 hK + nlinarith + +/-- Rational simplex approximation by flooring the tail and assigning the residual to index zero. -/ +theorem exists_rational_simplex_l1_close + (m : ℕ) (α : Fin (m+1) → ℝ) (hα : ∀ i, 0 ≤ α i) + (hsum : ∑ i, α i = 1) (δ : ℝ) (hδ : 0 < δ) : + ∃ q : Fin (m+1) → ℚ, (∀ i, 0 ≤ q i) ∧ (∑ i, q i = 1) ∧ + (∑ i, |(q i : ℝ)-α i|) < δ := by + obtain ⟨N, hN⟩ := exists_nat_gt (2*((m:ℝ)+1)/δ) + have hNpos : (0 : ℝ) < (N:ℝ) := + lt_trans (by positivity : (0:ℝ) < 2*((m:ℝ)+1)/δ) hN + have hN0 : (N:ℝ) ≠ 0 := ne_of_gt hNpos + let b : Fin m → ℚ := fun i => (⌊(N:ℝ)*α i.succ⌋₊ : ℚ) / (N:ℚ) + have hb0 (i : Fin m) : 0 ≤ b i := by dsimp [b]; positivity + have hbcast (i : Fin m) : (b i : ℝ) = + (⌊(N:ℝ)*α i.succ⌋₊ : ℝ)/(N:ℝ) := by simp [b] + have hble (i : Fin m) : (b i : ℝ) ≤ α i.succ := by + rw [hbcast, div_le_iff₀ hNpos] + simpa [mul_comm] using Nat.floor_le (mul_nonneg hNpos.le (hα i.succ)) + have hberr (i : Fin m) : α i.succ-(b i : ℝ) < 1/(N:ℝ) := by + rw [hbcast] + have hf := Nat.lt_floor_add_one ((N:ℝ)*α i.succ) + apply (lt_div_iff₀ hNpos).2 + rw [sub_mul, div_mul_cancel₀ _ hN0] + nlinarith + have hsumα : α 0 + ∑ i : Fin m, α i.succ = 1 := by + simpa only [Fin.sum_univ_succ] using hsum + have htail : (∑ i : Fin m, (b i : ℝ)) ≤ ∑ i : Fin m, α i.succ := + Finset.sum_le_sum fun i _ => hble i + have hres : (0 : ℝ) ≤ 1-∑ i : Fin m, (b i : ℝ) := by + have := hα 0 + linarith + let q : Fin (m+1) → ℚ := Fin.cons (1-∑ i, b i) b + refine ⟨q, ?_, ?_, ?_⟩ + · intro i + refine Fin.cases ?_ (fun j => hb0 j) i + change (0:ℚ) ≤ 1-∑ i, b i + exact_mod_cast hres + · simp [q, Fin.sum_univ_succ] + · have herrsum : (∑ i : Fin m, (α i.succ-(b i : ℝ))) ≤ (m:ℝ)/(N:ℝ) := by + calc + _ ≤ ∑ _i : Fin m, 1/(N:ℝ) := Finset.sum_le_sum fun i _ => (hberr i).le + _ = _ := by simp [nsmul_eq_mul, div_eq_mul_inv] + have hfirst : (1-∑ i : Fin m, (b i : ℝ))-α 0 = + ∑ i : Fin m, (α i.succ-(b i : ℝ)) := by + rw [Finset.sum_sub_distrib] + linarith + have hfirst0 : 0 ≤ (1-∑ i : Fin m, (b i : ℝ))-α 0 := by + rw [hfirst] + exact Finset.sum_nonneg fun i _ => sub_nonneg.mpr (hble i) + have hnorm : (∑ i, |(q i : ℝ)-α i|) = + 2 * ∑ i : Fin m, (α i.succ-(b i : ℝ)) := by + rw [Fin.sum_univ_succ] + simp only [q, Fin.cons_zero, Fin.cons_succ, Rat.cast_sub, Rat.cast_one, + Rat.cast_sum, abs_of_nonneg hfirst0] + rw [hfirst] + have htailabs : (∑ i : Fin m, |(b i : ℝ)-α i.succ|) = + ∑ i : Fin m, (α i.succ-(b i : ℝ)) := by + apply Finset.sum_congr rfl + intro i _ + rw [abs_of_nonpos (sub_nonpos.mpr (hble i))] + ring + rw [htailabs] + ring + rw [hnorm] + have hsmall : 2*(m:ℝ)/(N:ℝ) < δ := by + apply (div_lt_iff₀ hNpos).2 + have := (div_lt_iff₀ hδ).1 hN + nlinarith + calc + _ ≤ 2*((m:ℝ)/(N:ℝ)) := mul_le_mul_of_nonneg_left herrsum (by norm_num) + _ = 2*(m:ℝ)/(N:ℝ) := by ring + _ < δ := hsmall + +theorem stageMean_mem_convexHull (v : ℕ → X) (n : ℕ) : + stageMean v n ∈ convexHull ℝ (Set.range v) := by + exact mem_convexHull_of_exists_fintype (positiveStageWeights n) + (fun i => v i.val) (fun i => (positiveStageWeights_pos n i).le) + (positiveStageWeights_sum n) (fun i => ⟨i.val, rfl⟩) rfl + +theorem rationalPrefixMean_mem_closure (v : ℕ → X) (B : ℝ) + (hB : 0 ≤ B) (hv : ∀ i, ‖v i‖ ≤ B) (q : RationalPrefix) : + rationalPrefixMean v q ∈ closure (Set.range (stageMean v)) := by + apply Metric.mem_closure_iff.2 + intro δ hδ + obtain ⟨n, _, hn⟩ := exists_late_stageMean_close_rational v B hB hv q δ hδ 0 + exact ⟨stageMean v n, ⟨n, rfl⟩, by simpa [dist_eq_norm, norm_sub_rev] using hn⟩ + +theorem prefixMean_mem_closure (v : ℕ → X) (B : ℝ) + (hB : 0 ≤ B) (hv : ∀ i, ‖v i‖ ≤ B) (m : ℕ) + (α : Fin (m+1) → ℝ) (hα : ∀ i, 0 ≤ α i) (hsum : ∑ i, α i = 1) : + (∑ i : Fin (m+1), α i • v i.val) ∈ closure (Set.range (stageMean v)) := by + apply closure_minimal (fun _ hx => hx) isClosed_closure + apply Metric.mem_closure_iff.2 + intro δ hδ + have hBp : 0 < B+1 := by linarith + obtain ⟨q, hq0, hq1, hqerr⟩ := + exists_rational_simplex_l1_close m α hα hsum (δ/(B+1)) (div_pos hδ hBp) + let Q : RationalPrefix := ⟨m, q, hq0, hq1⟩ + refine ⟨rationalPrefixMean v Q, rationalPrefixMean_mem_closure v B hB hv Q, ?_⟩ + have hbary : ‖(∑ i : Fin (m+1), α i • v i.val)-rationalPrefixMean v Q‖ ≤ + (∑ i, |(q i : ℝ)-α i|)*(B+1) := by + unfold rationalPrefixMean + change ‖(∑ i : Fin (m+1), α i • v i.val)-∑ i, (q i : ℝ) • v i.val‖ ≤ _ + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ i : Fin (m+1), ‖α i • v i.val-(q i:ℝ) • v i.val‖ := norm_sum_le _ _ + _ = ∑ i : Fin (m+1), |(q i:ℝ)-α i| *‖v i.val‖ := by + apply Finset.sum_congr rfl + intro i _ + rw [← sub_smul, norm_smul, Real.norm_eq_abs, abs_sub_comm] + _ ≤ ∑ i : Fin (m+1), |(q i:ℝ)-α i| *(B+1) := by + apply Finset.sum_le_sum + intro i _ + exact mul_le_mul_of_nonneg_left ((hv i.val).trans (by linarith)) (abs_nonneg _) + _ = _ := by rw [Finset.sum_mul] + rw [dist_eq_norm] + exact hbary.trans_lt ((lt_div_iff₀ hBp).1 hqerr) + +/-- Every finite convex combination of a sequence fits in one initial prefix. -/ +theorem convexHull_range_subset_of_prefixes (v : ℕ → X) (E : Set X) + (hprefix : ∀ n, convexHull ℝ (Set.range (fun i : Fin (n+1) => v i.val)) ⊆ E) : + convexHull ℝ (Set.range v) ⊆ E := by + let H (n : ℕ) := convexHull ℝ (Set.range (fun i : Fin (n+1) => v i.val)) + have hmono : Monotone H := by + intro n m hnm + apply convexHull_mono + rintro x ⟨i, rfl⟩ + exact ⟨⟨i.val, lt_of_lt_of_le i.isLt (Nat.add_le_add_right hnm 1)⟩, rfl⟩ + have hdir : Directed (· ⊆ ·) H := fun n m => + ⟨max n m, hmono (le_max_left _ _), hmono (le_max_right _ _)⟩ + have hconv : Convex ℝ (⋃ n, H n) := hdir.convex_iUnion (fun _ => convex_convexHull _ _) + have hbase : Set.range v ⊆ ⋃ n, H n := by + rintro x ⟨n, rfl⟩ + exact Set.mem_iUnion.2 ⟨n, subset_convexHull ℝ _ ⟨Fin.last n, rfl⟩⟩ + intro x hx + obtain ⟨n, hn⟩ := Set.mem_iUnion.1 (convexHull_min hbase hconv hx) + exact hprefix n hn + +theorem closure_range_stageMean_eq (v : ℕ → X) (B : ℝ) + (hB : 0 ≤ B) (hv : ∀ i, ‖v i‖ ≤ B) : + closure (Set.range (stageMean v)) = closure (convexHull ℝ (Set.range v)) := by + apply Set.Subset.antisymm + · apply closure_mono + rintro x ⟨n, rfl⟩ + exact stageMean_mem_convexHull v n + · apply closure_minimal _ isClosed_closure + apply convexHull_range_subset_of_prefixes v + intro m x hx + rw [convexHull_range_eq_exists_affineCombination] at hx + obtain ⟨s, w, hw0, hw1, hcomb⟩ := hx + let α : Fin (m+1) → ℝ := fun i => if i ∈ s then w i else 0 + have hα0 : ∀ i, 0 ≤ α i := by + intro i + dsimp [α] + split_ifs with hi + · exact hw0 i hi + · exact le_rfl + have hα1 : ∑ i, α i = 1 := by simpa [α] using hw1 + have he : (∑ i, α i • v i.val) = x := by + rw [Finset.affineCombination_eq_linear_combination _ _ _ hw1] at hcomb + simpa [α, ite_smul] using hcomb + rw [← he] + exact prefixMean_mem_closure v B hB hv m α hα0 hα1 + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ProbabilitySimplex.lean b/lean/OAI/Analysis/SphereIsometry/ProbabilitySimplex.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce3a69c414bdf3d7746ef394ff4f68a184c7e38c --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ProbabilitySimplex.lean @@ -0,0 +1,123 @@ +import Mathlib.Analysis.Convex.Basic +import Mathlib.Analysis.Convex.StdSimplex +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Basic.Real.Basic + +namespace OAI + +/-! +# Finite probability simplices + +The coordinates are nonnegative real numbers with sum one. The positive-coordinate +selection lemma is the boundary-compatible labelling rule used in Sperner's argument. +-/ + +open scoped BigOperators + +namespace Tingley + +def probabilitySimplexSet (ι : Type*) [Fintype ι] : Set (ι → ℝ) := + {weights | (∀ index, 0 ≤ weights index) ∧ ∑ index, weights index = 1} + +theorem convex_probabilitySimplexSet (ι : Type*) [Fintype ι] : + Convex ℝ (probabilitySimplexSet ι) := by + intro left hleft right hright first second hfirst hsecond hsum + refine ⟨fun index => add_nonneg (mul_nonneg hfirst (hleft.1 index)) + (mul_nonneg hsecond (hright.1 index)), ?_⟩ + simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul, Finset.sum_add_distrib, + ← Finset.mul_sum, hleft.2, hright.2, mul_one, hsum] + +theorem single_mem_probabilitySimplexSet {ι : Type*} [Fintype ι] [DecidableEq ι] + (index : ι) : Pi.single index 1 ∈ probabilitySimplexSet ι := + ⟨le_update_iff.2 ⟨zero_le_one, fun _ _ => le_rfl⟩, by simp⟩ + +theorem mem_Icc_of_mem_probabilitySimplexSet {ι : Type*} [Fintype ι] + {weights : ι → ℝ} (hweights : weights ∈ probabilitySimplexSet ι) (index : ι) : + weights index ∈ Set.Icc (0 : ℝ) 1 := + ⟨hweights.1 index, hweights.2 ▸ + Finset.single_le_sum (fun other _ => hweights.1 other) (Finset.mem_univ index)⟩ + +abbrev ProbabilitySimplex (ι : Type*) [Fintype ι] := ↥(probabilitySimplexSet ι) + +instance probabilitySimplex_compactSpace (ι : Type*) [Fintype ι] : + CompactSpace (ProbabilitySimplex ι) := by + apply isCompact_iff_compactSpace.mp + apply IsCompact.of_isClosed_subset + (isCompact_Icc : IsCompact (Set.Icc (0 : ι → ℝ) 1)) + · change IsClosed ({weights : ι → ℝ | ∀ index, 0 ≤ weights index} ∩ + {weights | ∑ index, weights index = 1}) + apply IsClosed.inter + · rw [Set.ofPred_forall] + exact isClosed_iInter fun index => + isClosed_le continuous_const (continuous_apply index) + · exact isClosed_eq (by fun_prop) continuous_const + · intro weights hweights + exact ⟨fun index => (mem_Icc_of_mem_probabilitySimplexSet hweights index).1, + fun index => (mem_Icc_of_mem_probabilitySimplexSet hweights index).2⟩ + +namespace ProbabilitySimplex + +variable {ι : Type*} [Fintype ι] + +theorem coordinate_nonneg (a : ProbabilitySimplex ι) (i : ι) : 0 ≤ a.val i := + a.property.1 i + +theorem sum_coordinates (a : ProbabilitySimplex ι) : ∑ i, a.val i = 1 := + a.property.2 + +noncomputable def pointMass (i : ι) : ProbabilitySimplex ι := by + classical + exact ⟨Pi.single i 1, single_mem_probabilitySimplexSet i⟩ + +instance [Nonempty ι] : Nonempty (ProbabilitySimplex ι) := + ⟨pointMass (Classical.choice ‹Nonempty ι›)⟩ + +theorem exists_positive_coordinate (a : ProbabilitySimplex ι) : + ∃ i, 0 < a.val i := by + classical + by_contra h + have hz : a.val = 0 := by + funext i + exact le_antisymm (le_of_not_gt (fun hi => h ⟨i, hi⟩)) (a.coordinate_nonneg i) + have hs := a.sum_coordinates + simp [hz] at hs + +theorem eq_of_coordinate_le (a b : ProbabilitySimplex ι) + (hab : ∀ i, a.val i ≤ b.val i) : a = b := by + classical + have hnonneg : ∀ i ∈ (Finset.univ : Finset ι), 0 ≤ b.val i - a.val i := + fun i _ => sub_nonneg.mpr (hab i) + have hsum : ∑ i, (b.val i - a.val i) = 0 := by + rw [Finset.sum_sub_distrib, b.sum_coordinates, a.sum_coordinates, sub_self] + have hz := (Finset.sum_eq_zero_iff_of_nonneg hnonneg).mp hsum + apply Subtype.ext + funext i + exact (sub_eq_zero.mp (hz i (Finset.mem_univ i))).symm + +end ProbabilitySimplex + +theorem exists_positive_dominating_coordinate {ι : Type*} [Fintype ι] + (a b : ProbabilitySimplex ι) : + ∃ i, 0 < a.val i ∧ b.val i ≤ a.val i := by + classical + by_contra h + have hstrict : ∀ i, 0 < a.val i → a.val i < b.val i := by + intro i hi + exact lt_of_not_ge (fun hle => h ⟨i, hi, hle⟩) + have hweak : ∀ i, a.val i ≤ b.val i := by + intro i + by_cases hi : 0 < a.val i + · exact (hstrict i hi).le + · have hz : a.val i = 0 := + le_antisymm (le_of_not_gt hi) (a.coordinate_nonneg i) + rw [hz] + exact b.coordinate_nonneg i + obtain ⟨i, hi⟩ := a.exists_positive_coordinate + have hsum : (∑ j, a.val j) < ∑ j, b.val j := + Finset.sum_lt_sum (fun j _ => hweak j) ⟨i, Finset.mem_univ i, hstrict i hi⟩ + rw [a.sum_coordinates, b.sum_coordinates] at hsum + exact (lt_irrefl (1 : ℝ)) hsum + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/RadialContact.lean b/lean/OAI/Analysis/SphereIsometry/RadialContact.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a25eed1c58d70133861ba79f1ffe24755a5fe30 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/RadialContact.lean @@ -0,0 +1,208 @@ +import OAI.Analysis.SphereIsometry.Basic +import Mathlib.Topology.Order.IntermediateValue +import Mathlib.Topology.MetricSpace.Lipschitz + +namespace OAI + +/-! +# Contact of a ray from an interior point with the unit sphere + +The contact radius exists by the intermediate value theorem on a real interval. +A quantitative comparison proves both uniqueness and Lipschitz continuity. No +compactness of the ambient unit ball or support functional is used. +-/ + +noncomputable section + +namespace Tingley + +universe u + +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace ℝ X] + +/-- Comparison of two contacts, with the radii in increasing order. The vectors +need not be unit vectors for this estimate. -/ +theorem contact_comparison_ordered (c v w : X) {r s : ℝ} + (hr : 0 ≤ r) (hrs : r ≤ s) + (hvr : ‖c + r • v‖ = 1) (hws : ‖c + s • w‖ = 1) : + (1 - ‖c‖) * (s - r) ≤ (r * s) * ‖v - w‖ := by + have hs : 0 ≤ s := hr.trans hrs + have hsr : 0 ≤ s - r := sub_nonneg.mpr hrs + have hprod : 0 ≤ r * s := mul_nonneg hr hs + have he : s • (c + r • v) = + (s - r) • c + r • (c + s • w) + (r * s) • (v - w) := by + simp only [smul_add, sub_smul, smul_sub, smul_smul, mul_comm s r] + abel + have hbound : s ≤ (s - r) * ‖c‖ + r + (r * s) * ‖v - w‖ := by + calc + s = ‖s • (c + r • v)‖ := by + rw [norm_smul, Real.norm_of_nonneg hs, hvr, mul_one] + _ = ‖(s - r) • c + r • (c + s • w) + (r * s) • (v - w)‖ := + congrArg norm he + _ ≤ ‖(s - r) • c + r • (c + s • w)‖ + ‖(r * s) • (v - w)‖ := + norm_add_le _ _ + _ ≤ (‖(s - r) • c‖ + ‖r • (c + s • w)‖) + ‖(r * s) • (v - w)‖ := + add_le_add_left (norm_add_le _ _) _ + _ = (s - r) * ‖c‖ + r + (r * s) * ‖v - w‖ := by + simp only [norm_smul, Real.norm_of_nonneg hsr, Real.norm_of_nonneg hr, + Real.norm_of_nonneg hprod, hws, mul_one] + nlinarith [hbound] + +/-- A symmetric contact comparison, still independent of unit-norm assumptions +on the two direction vectors. -/ +theorem contact_comparison (c v w : X) {r s : ℝ} + (hr : 0 ≤ r) (hs : 0 ≤ s) + (hvr : ‖c + r • v‖ = 1) (hws : ‖c + s • w‖ = 1) : + (1 - ‖c‖) * |r - s| ≤ (r * s) * ‖v - w‖ := by + rcases le_total r s with hrs | hsr + · calc + (1 - ‖c‖) * |r - s| = (1 - ‖c‖) * (s - r) := by + rw [abs_of_nonpos (sub_nonpos.mpr hrs)] + ring + _ ≤ (r * s) * ‖v - w‖ := contact_comparison_ordered c v w hr hrs hvr hws + · rw [abs_of_nonneg (sub_nonneg.mpr hsr)] + simpa only [mul_comm s r, norm_sub_rev w v] using + contact_comparison_ordered c w v hs hsr hws hvr + +/-- Nonnegative contacts in the same direction are unique when the center is +strictly inside the unit ball. -/ +theorem contact_unique (c : X) (hc : ‖c‖ < 1) (v : X) {r s : ℝ} + (hr : 0 ≤ r) (hs : 0 ≤ s) + (hvr : ‖c + r • v‖ = 1) (hvs : ‖c + s • v‖ = 1) : r = s := by + have h := contact_comparison c v v hr hs hvr hvs + rw [sub_self, norm_zero, mul_zero] at h + have hL : 0 < 1 - ‖c‖ := sub_pos.mpr hc + have hz : |r - s| ≤ 0 := by + apply le_of_not_gt + intro hpos + exact (not_lt_of_ge h) (mul_pos hL hpos) + exact sub_eq_zero.mp (abs_eq_zero.mp (le_antisymm hz (abs_nonneg _))) + +/-- Every nonnegative contact in a unit direction has the exact radial +bounds, independently of how the contact was obtained. -/ +theorem contact_bounds (c : X) (v : UnitSphere X) {r : ℝ} + (hr : 0 ≤ r) (hcontact : ‖c + r • (v : X)‖ = 1) : + 1 - ‖c‖ ≤ r ∧ r ≤ 1 + ‖c‖ := by + have hn : ‖r • (v : X)‖ = r := by + rw [norm_smul, Real.norm_of_nonneg hr, v.property, mul_one] + have hlo := norm_add_le c (r • (v : X)) + rw [hcontact, hn] at hlo + have hhi := norm_sub_le (c + r • (v : X)) c + have he : (c + r • (v : X)) - c = r • (v : X) := by abel + rw [he, hn, hcontact] at hhi + constructor <;> linarith + +/-- The genuine positive contact on each ray from an interior center. Existence +uses only a compact real interval, never compactness of the ambient sphere. -/ +theorem existsUnique_radialContact (c : X) (hc : ‖c‖ < 1) + (v : UnitSphere X) : ∃! r : ℝ, 0 < r ∧ ‖c + r • (v : X)‖ = 1 := by + have hL : 0 < 1 - ‖c‖ := sub_pos.mpr hc + have hU : 0 ≤ 1 + ‖c‖ := by linarith [norm_nonneg c] + have hLU : 1 - ‖c‖ ≤ 1 + ‖c‖ := by linarith [norm_nonneg c] + have hleft : ‖c + (1 - ‖c‖) • (v : X)‖ ≤ 1 := by + calc + ‖c + (1 - ‖c‖) • (v : X)‖ ≤ ‖c‖ + ‖(1 - ‖c‖) • (v : X)‖ := + norm_add_le _ _ + _ = 1 := by + rw [norm_smul, Real.norm_of_nonneg hL.le, v.property, mul_one] + ring + have hright : 1 ≤ ‖c + (1 + ‖c‖) • (v : X)‖ := by + have h := norm_sub_le (c + (1 + ‖c‖) • (v : X)) c + have he : (c + (1 + ‖c‖) • (v : X)) - c = (1 + ‖c‖) • (v : X) := by abel + rw [he, norm_smul, Real.norm_of_nonneg hU, v.property, mul_one] at h + linarith + have hcont : Continuous (fun t : ℝ => ‖c + t • (v : X)‖) := + (continuous_const.add (continuous_id.smul continuous_const)).norm + obtain ⟨r, hr, hcontact⟩ := + intermediate_value_Icc hLU hcont.continuousOn ⟨hleft, hright⟩ + have hrpos : 0 < r := hL.trans_le hr.1 + refine ⟨r, ⟨hrpos, hcontact⟩, ?_⟩ + intro s hs + exact contact_unique c hc (v : X) hs.1.le hrpos.le hs.2 hcontact + +/-- The radius is chosen from the proved existence theorem. -/ +def radialRadius (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : ℝ := + Classical.choose (existsUnique_radialContact c hc v).exists + +theorem radialRadius_spec (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : + 0 < radialRadius c hc v ∧ ‖c + radialRadius c hc v • (v : X)‖ = 1 := + Classical.choose_spec (existsUnique_radialContact c hc v).exists + +theorem radialRadius_pos (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : + 0 < radialRadius c hc v := (radialRadius_spec c hc v).1 + +theorem norm_radialRadius (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : + ‖c + radialRadius c hc v • (v : X)‖ = 1 := (radialRadius_spec c hc v).2 + +theorem radialRadius_bounds (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : + 1 - ‖c‖ ≤ radialRadius c hc v ∧ radialRadius c hc v ≤ 1 + ‖c‖ := + contact_bounds c v (radialRadius_pos c hc v).le (norm_radialRadius c hc v) + +theorem radialRadius_unique (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) + {r : ℝ} (hr : 0 ≤ r) (hcontact : ‖c + r • (v : X)‖ = 1) : + r = radialRadius c hc v := + contact_unique c hc (v : X) hr (radialRadius_pos c hc v).le + hcontact (norm_radialRadius c hc v) + +/-- The quantitative comparison for the chosen contact radii. -/ +theorem radialRadius_comparison (c : X) (hc : ‖c‖ < 1) (v w : UnitSphere X) : + (1 - ‖c‖) * |radialRadius c hc v - radialRadius c hc w| ≤ + (radialRadius c hc v * radialRadius c hc w) * ‖(v : X) - (w : X)‖ := + contact_comparison c (v : X) (w : X) + (radialRadius_pos c hc v).le (radialRadius_pos c hc w).le + (norm_radialRadius c hc v) (norm_radialRadius c hc w) + +theorem radialRadius_sub_le (c : X) (hc : ‖c‖ < 1) (v w : UnitSphere X) : + |radialRadius c hc v - radialRadius c hc w| ≤ + ((1 + ‖c‖)^2 / (1 - ‖c‖)) * ‖(v : X) - (w : X)‖ := by + have hU : 0 ≤ 1 + ‖c‖ := by linarith [norm_nonneg c] + have hproduct : radialRadius c hc v * radialRadius c hc w ≤ (1 + ‖c‖)^2 := by + calc + radialRadius c hc v * radialRadius c hc w ≤ (1 + ‖c‖) * radialRadius c hc w := + mul_le_mul_of_nonneg_right (radialRadius_bounds c hc v).2 + (radialRadius_pos c hc w).le + _ ≤ (1 + ‖c‖) * (1 + ‖c‖) := + mul_le_mul_of_nonneg_left (radialRadius_bounds c hc w).2 hU + _ = (1 + ‖c‖)^2 := by ring + have hscaled : |radialRadius c hc v - radialRadius c hc w| * (1 - ‖c‖) ≤ + (1 + ‖c‖)^2 * ‖(v : X) - (w : X)‖ := by + calc + |radialRadius c hc v - radialRadius c hc w| * (1 - ‖c‖) = + (1 - ‖c‖) * |radialRadius c hc v - radialRadius c hc w| := mul_comm _ _ + _ ≤ (radialRadius c hc v * radialRadius c hc w) * ‖(v : X) - (w : X)‖ := + radialRadius_comparison c hc v w + _ ≤ (1 + ‖c‖)^2 * ‖(v : X) - (w : X)‖ := + mul_le_mul_of_nonneg_right hproduct (norm_nonneg _) + calc + |radialRadius c hc v - radialRadius c hc w| ≤ + ((1 + ‖c‖)^2 * ‖(v : X) - (w : X)‖) / (1 - ‖c‖) := + (le_div_iff₀ (sub_pos.mpr hc)).mpr hscaled + _ = ((1 + ‖c‖)^2 / (1 - ‖c‖)) * ‖(v : X) - (w : X)‖ := by ring + +/-- The radius is globally Lipschitz on the unit sphere for each fixed interior +center, even in an infinite-dimensional normed space. -/ +theorem lipschitz_radialRadius (c : X) (hc : ‖c‖ < 1) : + LipschitzWith (Real.toNNReal ((1 + ‖c‖)^2 / (1 - ‖c‖))) (radialRadius c hc) := by + apply LipschitzWith.of_dist_le' + intro v w + simpa only [Real.dist_eq, Subtype.dist_eq, dist_eq_norm, Real.norm_eq_abs] using radialRadius_sub_le c hc v w + +theorem continuous_radialRadius (c : X) (hc : ‖c‖ < 1) : + Continuous (radialRadius c hc) := (lipschitz_radialRadius c hc).continuous + +/-- The actual point of contact, retaining its unit-sphere subtype proof. -/ +def radialContact (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : UnitSphere X := + ⟨c + radialRadius c hc v • (v : X), norm_radialRadius c hc v⟩ + +@[simp] theorem radialContact_coe (c : X) (hc : ‖c‖ < 1) (v : UnitSphere X) : + (radialContact c hc v : X) = c + radialRadius c hc v • (v : X) := rfl + +theorem continuous_radialContact (c : X) (hc : ‖c‖ < 1) : + Continuous (radialContact c hc) := + (continuous_const.add ((continuous_radialRadius c hc).smul continuous_subtype_val)).subtype_mk _ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/RadialExtension.lean b/lean/OAI/Analysis/SphereIsometry/RadialExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..263c7e4a08b6832fb2130d8cc8684a3b47616cce --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/RadialExtension.lean @@ -0,0 +1,214 @@ +import OAI.Analysis.SphereIsometry.Basic +import Mathlib.Analysis.Normed.Module.RCLike.Real +import Mathlib.Analysis.Normed.Affine.MazurUlam + +namespace OAI + +/-! +# The radial extension of a sphere isometry with zero defect + +The extension is defined on actual vectors, including zero. A zero cross-radius +bound gives its all-pairs isometry; sphere surjectivity gives its surjectivity. +Mazur–Ulam then supplies real linearity. Uniqueness is proved against arbitrary +real-linear extensions, without assuming they are continuous or surjective. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- The actual radial extension, with a separate zero branch. -/ +def radialExtension (f : UnitSphere X ≃ᵢ UnitSphere Y) (x : X) : Y := by + classical + exact if hx : x = 0 then 0 else ‖x‖ • (f (normalize x hx) : Y) + +@[simp] theorem radialExtension_zero (f : UnitSphere X ≃ᵢ UnitSphere Y) : + radialExtension f 0 = 0 := by + simp [radialExtension] + +theorem radialExtension_of_ne_zero (f : UnitSphere X ≃ᵢ UnitSphere Y) + (x : X) (hx : x ≠ 0) : + radialExtension f x = ‖x‖ • (f (normalize x hx) : Y) := by + simp only [radialExtension, dite_eq_right hx] + +@[simp] theorem radialExtension_norm (f : UnitSphere X ≃ᵢ UnitSphere Y) (x : X) : + ‖radialExtension f x‖ = ‖x‖ := by + by_cases hx : x = 0 + · subst x + simp only [radialExtension_zero, norm_zero] + · rw [radialExtension_of_ne_zero f x hx, + norm_smul_of_nonneg (norm_nonneg x), UnitSphere.norm_coe, mul_one] + +/-- Every nonnegative radial representation has the expected image. -/ +theorem radialExtension_smul_unit (f : UnitSphere X ≃ᵢ UnitSphere Y) + (r : ℝ) (hr : 0 ≤ r) (u : UnitSphere X) : + radialExtension f (r • (u : X)) = r • (f u : Y) := by + by_cases hr0 : r = 0 + · subst r + simp only [zero_smul, radialExtension_zero] + · have hn : ‖r • (u : X)‖ = r := by + rw [norm_smul_of_nonneg hr, UnitSphere.norm_coe, mul_one] + have hne : r • (u : X) ≠ 0 := by + intro h + apply hr0 + rw [← hn, h, norm_zero] + have hnormalize : normalize (r • (u : X)) hne = u := by + apply Subtype.ext + change ‖r • (u : X)‖⁻¹ • (r • (u : X)) = (u : X) + rw [hn, smul_smul, inv_mul_cancel₀ hr0, one_smul] + rw [radialExtension_of_ne_zero f _ hne, hn, hnormalize] + +@[simp] theorem radialExtension_unit (f : UnitSphere X ≃ᵢ UnitSphere Y) + (u : UnitSphere X) : radialExtension f (u : X) = (f u : Y) := by + simpa only [one_smul] using radialExtension_smul_unit f 1 zero_le_one u + +/-- The zero bound gives exact preservation at every radius in the closed unit interval. -/ +theorem crossRadius_eq_of_zero_defect (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) (q : ℝ) (hq : q ∈ Set.Icc (0 : ℝ) 1) + (u v : UnitSphere X) : + ‖(f u : Y) - q • (f v : Y)‖ = ‖(u : X) - q • (v : X)‖ := by + exact sub_eq_zero.mp (signedDefect_eq_zero_of_bound_zero h0 hq u v) + +/-- Factor by the larger positive radius; the smaller radius may be zero. -/ +theorem scaled_norm_sub_eq (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) (u v : UnitSphere X) (a b : ℝ) + (ha : 0 < a) (hb : 0 ≤ b) (hba : b ≤ a) : + ‖a • (f u : Y) - b • (f v : Y)‖ = ‖a • (u : X) - b • (v : X)‖ := by + have hq : b / a ∈ Set.Icc (0 : ℝ) 1 := + ⟨div_nonneg hb ha.le, (div_le_one ha).mpr hba⟩ + have hab : a * (b / a) = b := by + rw [div_eq_mul_inv, mul_left_comm, mul_inv_cancel₀ (ne_of_gt ha), mul_one] + calc + ‖a • (f u : Y) - b • (f v : Y)‖ = + ‖a • ((f u : Y) - (b / a) • (f v : Y))‖ := by + rw [smul_sub, smul_smul, hab] + _ = a * ‖(f u : Y) - (b / a) • (f v : Y)‖ := + norm_smul_of_nonneg ha.le _ + _ = a * ‖(u : X) - (b / a) • (v : X)‖ := by + rw [crossRadius_eq_of_zero_defect f h0 (b / a) hq u v] + _ = ‖a • ((u : X) - (b / a) • (v : X))‖ := + (norm_smul_of_nonneg ha.le _).symm + _ = ‖a • (u : X) - b • (v : X)‖ := by + rw [smul_sub, smul_smul, hab] + +/-- Every pair is covered, including zero vectors and either order of radii. -/ +theorem radialExtension_norm_sub (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) (x y : X) : + ‖radialExtension f x - radialExtension f y‖ = ‖x - y‖ := by + by_cases hx : x = 0 + · subst x + simpa only [radialExtension_zero, zero_sub, norm_neg] using radialExtension_norm f y + by_cases hy : y = 0 + · subst y + simpa only [radialExtension_zero, sub_zero] using radialExtension_norm f x + have hordered (a b : X) (ha : a ≠ 0) (hb : b ≠ 0) (hba : ‖b‖ ≤ ‖a‖) : + ‖radialExtension f a - radialExtension f b‖ = ‖a - b‖ := by + have h := scaled_norm_sub_eq f h0 (normalize a ha) (normalize b hb) + ‖a‖ ‖b‖ (norm_pos_iff.mpr ha) (norm_nonneg b) hba + rw [norm_smul_normalize, norm_smul_normalize] at h + simpa only [radialExtension_of_ne_zero f a ha, + radialExtension_of_ne_zero f b hb] using h + rcases le_total ‖y‖ ‖x‖ with hle | hle + · exact hordered x y hx hy hle + · calc + ‖radialExtension f x - radialExtension f y‖ = + ‖radialExtension f y - radialExtension f x‖ := norm_sub_rev _ _ + _ = ‖y - x‖ := hordered y x hy hx hle + _ = ‖x - y‖ := norm_sub_rev _ _ + +theorem radialExtension_isometry (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) : Isometry (radialExtension f) := by + apply Isometry.of_dist_eq + intro x y + simpa only [dist_eq_norm] using radialExtension_norm_sub f h0 x y + +/-- Surjectivity follows directly from the actual inverse on unit spheres. -/ +theorem radialExtension_surjective (f : UnitSphere X ≃ᵢ UnitSphere Y) : + Function.Surjective (radialExtension f) := by + intro y + by_cases hy : y = 0 + · subst y + exact ⟨0, radialExtension_zero f⟩ + · refine ⟨‖y‖ • (f.symm (normalize y hy) : X), ?_⟩ + rw [radialExtension_smul_unit f ‖y‖ (norm_nonneg y), f.apply_symm_apply] + exact norm_smul_normalize y hy + +/-- The metric equivalence is built only after isometry and surjectivity are proved. -/ +def radialIsometryEquiv (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) : X ≃ᵢ Y where + toEquiv := Equiv.ofBijective (radialExtension f) + ⟨(radialExtension_isometry f h0).injective, radialExtension_surjective f⟩ + isometry_toFun := radialExtension_isometry f h0 + +@[simp] theorem coe_radialIsometryEquiv (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) : ⇑(radialIsometryEquiv f h0) = radialExtension f := rfl + +@[simp] theorem radialIsometryEquiv_apply (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) (x : X) : + radialIsometryEquiv f h0 x = radialExtension f x := rfl + +/-- Mazur–Ulam applied to the derived whole-space isometry fixing zero. -/ +def radialLinearIsometryEquiv (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) : X ≃ₗᵢ[ℝ] Y := + (radialIsometryEquiv f h0).toRealLinearIsometryEquivOfMapZero + (by change radialExtension f 0 = 0; exact radialExtension_zero f) + +@[simp] theorem coe_radialLinearIsometryEquiv (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) : + ⇑(radialLinearIsometryEquiv f h0) = radialExtension f := rfl + +@[simp] theorem radialLinearIsometryEquiv_apply (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) (x : X) : + radialLinearIsometryEquiv f h0 x = radialExtension f x := rfl + +@[simp] theorem radialLinearIsometryEquiv_unit (f : UnitSphere X ≃ᵢ UnitSphere Y) + (h0 : HasDefectBound f 0) (u : UnitSphere X) : + radialLinearIsometryEquiv f h0 (u : X) = (f u : Y) := + radialExtension_unit f u + +/-- Any real-linear extension has the radial formula, without additional hypotheses on it. -/ +theorem linear_extension_eq_radial (f : UnitSphere X ≃ᵢ UnitSphere Y) + (L : X →ₗ[ℝ] Y) (hL : ∀ u : UnitSphere X, L (u : X) = (f u : Y)) (x : X) : + L x = radialExtension f x := by + by_cases hx : x = 0 + · subst x + simp only [map_zero, radialExtension_zero] + · calc + L x = L (‖x‖ • (normalize x hx : X)) := + congrArg L (norm_smul_normalize x hx).symm + _ = ‖x‖ • L (normalize x hx : X) := L.map_smul _ _ + _ = ‖x‖ • (f (normalize x hx) : Y) := by rw [hL] + _ = radialExtension f x := (radialExtension_of_ne_zero f x hx).symm + +theorem linear_extension_unique (f : UnitSphere X ≃ᵢ UnitSphere Y) + (L K : X →ₗ[ℝ] Y) + (hL : ∀ u : UnitSphere X, L (u : X) = (f u : Y)) + (hK : ∀ u : UnitSphere X, K (u : X) = (f u : Y)) : L = K := by + apply LinearMap.ext + intro x + exact (linear_extension_eq_radial f L hL x).trans + (linear_extension_eq_radial f K hK x).symm + +/-- The conditional extension endpoint; the main theorem supplies the proved zero bound. -/ +theorem existsUnique_linearIsometryEquiv_of_zero_defect + (f : UnitSphere X ≃ᵢ UnitSphere Y) (h0 : HasDefectBound f 0) : + ∃! L : X ≃ₗᵢ[ℝ] Y, ∀ u : UnitSphere X, L (u : X) = (f u : Y) := by + refine ⟨radialLinearIsometryEquiv f h0, ?_, ?_⟩ + · exact radialLinearIsometryEquiv_unit f h0 + · intro L hL + apply LinearIsometryEquiv.ext + intro x + change L x = radialExtension f x + exact linear_extension_eq_radial f L.toLinearEquiv.toLinearMap hL x + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/RadialPerturbation.lean b/lean/OAI/Analysis/SphereIsometry/RadialPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab00f4ee3d8f8427511f40aa79bfe18ecd67718f --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/RadialPerturbation.lean @@ -0,0 +1,126 @@ +import OAI.Analysis.SphereIsometry.Supports +import Mathlib.Analysis.Normed.Module.FiniteDimension +import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps +import Mathlib.Topology.Order.Compact +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Small radial perturbations from strict support signs + +Compactness is used only on the continuous dual of the span of two vectors. +The public result has no finite-dimensional or completeness hypothesis on the +ambient real normed space. +-/ + +noncomputable section + +namespace Tingley + +private theorem exists_dual_gap_of_supportAt_neg + {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + [FiniteDimensional ℝ V] {v y : V} + (hv : ‖v‖ = 1) + (hneg : ∀ φ : V →L[ℝ] ℝ, SupportAt φ v → φ y < 0) : + ∃ c : ℝ, 0 ≤ c ∧ c < 1 ∧ + ∀ φ : V →L[ℝ] ℝ, ‖φ‖ ≤ 1 → 0 ≤ φ y → φ v ≤ c := by + classical + let K : Set (V →L[ℝ] ℝ) := + Metric.closedBall 0 1 ∩ {φ | 0 ≤ φ y} + have heval (z : V) : Continuous (fun φ : V →L[ℝ] ℝ => φ z) := + continuous_id.clm_apply continuous_const + have hK : IsCompact K := + (isCompact_closedBall (0 : V →L[ℝ] ℝ) 1).inter_right + (isClosed_le continuous_const (heval y)) + have hzero : (0 : V →L[ℝ] ℝ) ∈ K := by simp [K] + obtain ⟨φ₀, hφ₀, hmax⟩ := hK.exists_isMaxOn ⟨0, hzero⟩ (heval v).continuousOn + have hφnorm : ‖φ₀‖ ≤ 1 := by + simpa only [mem_closedBall_zero_iff] using hφ₀.1 + have hc_le : φ₀ v ≤ 1 := by + simpa only [hv] using apply_le_norm hφnorm v + have hc_lt : φ₀ v < 1 := by + by_contra hnot + have heq : φ₀ v = 1 := le_antisymm hc_le (le_of_not_gt hnot) + have hs : SupportAt φ₀ v := ⟨hφnorm, heq.trans hv.symm⟩ + exact (not_lt_of_ge hφ₀.2) (hneg φ₀ hs) + refine ⟨φ₀ v, ?_, hc_lt, ?_⟩ + · simpa using (isMaxOn_iff.mp hmax) 0 hzero + · intro φ hφ hy + apply (isMaxOn_iff.mp hmax) φ + exact ⟨mem_closedBall_zero_iff.mpr hφ, hy⟩ + +private theorem exists_radial_perturbation_lt_finiteDimensional + {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] + [FiniteDimensional ℝ V] {v y : V} {p : ℝ} + (hv : ‖v‖ = 1) (hp : 0 < p) + (hneg : ∀ φ : V →L[ℝ] ℝ, SupportAt φ v → φ y < 0) : + ∃ δ : ℝ, 0 < δ ∧ ∀ η : ℝ, 0 < η → η < δ → + ‖p • v + η • y‖ < p := by + obtain ⟨c, _hc0, hc, hgap⟩ := exists_dual_gap_of_supportAt_neg hv hneg + have hden : 0 < ‖y‖ + 1 := by linarith [norm_nonneg y] + refine ⟨p * (1 - c) / (‖y‖ + 1), + div_pos (mul_pos hp (sub_pos.mpr hc)) hden, ?_⟩ + intro η hη hηδ + obtain ⟨φ, hφ⟩ := exists_support (p • v + η • y) + have hnorm : ‖p • v + η • y‖ = p * φ v + η * φ y := by + calc + ‖p • v + η • y‖ = φ (p • v + η • y) := hφ.2.symm + _ = p * φ v + η * φ y := by simp only [map_add, map_smul, smul_eq_mul] + rw [hnorm] + by_cases hnegative : φ y < 0 + · have hunit : φ v ≤ 1 := by simpa only [hv] using apply_le_norm hφ.1 v + have hfirst : p * φ v ≤ p * 1 := mul_le_mul_of_nonneg_left hunit hp.le + have hsecond : η * φ y < 0 := mul_neg_of_pos_of_neg hη hnegative + nlinarith only [hfirst, hsecond] + · have hvbound : φ v ≤ c := hgap φ hφ.1 (le_of_not_gt hnegative) + have hybound : φ y ≤ ‖y‖ := apply_le_norm hφ.1 y + have hfirst : p * φ v ≤ p * c := mul_le_mul_of_nonneg_left hvbound hp.le + have hsecond : η * φ y ≤ η * ‖y‖ := mul_le_mul_of_nonneg_left hybound hη.le + have hmul : η * (‖y‖ + 1) < p * (1 - c) := (lt_div_iff₀ hden).mp hηδ + have hstrict : p * c + η * ‖y‖ < p := by nlinarith only [hmul, hη] + linarith only [hfirst, hsecond, hstrict] + +/-- Strict negativity on the perturbing vector for every support at a unit +vector makes all sufficiently small positive radial perturbations shorter. +Only the span of the two specified vectors is made finite-dimensional. -/ +theorem exists_radial_perturbation_lt + {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + {v y : X} {p : ℝ} (hv : ‖v‖ = 1) (hp : 0 < p) + (hneg : ∀ φ : X →L[ℝ] ℝ, SupportAt φ v → φ y < 0) : + ∃ δ : ℝ, 0 < δ ∧ ∀ η : ℝ, 0 < η → η < δ → + ‖p • v + η • y‖ < p := by + classical + let V : Submodule ℝ X := Submodule.span ℝ ({v, y} : Set X) + have hv_mem : v ∈ V := Submodule.subset_span (by simp) + have hy_mem : y ∈ V := Submodule.subset_span (by simp) + let v₀ : V := ⟨v, hv_mem⟩ + let y₀ : V := ⟨y, hy_mem⟩ + have : FiniteDimensional ℝ V := + FiniteDimensional.span_of_finite ℝ ((Set.finite_singleton y).insert v) + have hv₀ : ‖v₀‖ = 1 := hv + have hneg₀ : ∀ φ : V →L[ℝ] ℝ, SupportAt φ v₀ → φ y₀ < 0 := + (forall_supportAt_apply_iff_submodule V v₀ y₀ (fun r : ℝ => r < 0)).mp hneg + obtain ⟨δ, hδ, hsmall⟩ := exists_radial_perturbation_lt_finiteDimensional hv₀ hp hneg₀ + refine ⟨δ, hδ, ?_⟩ + intro η hη hηδ + exact hsmall η hη hηδ + +/-- The perturbation may also be chosen below any prescribed positive cap. -/ +theorem exists_radial_perturbation_lt_with_cap + {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + {v y : X} {p t : ℝ} (hv : ‖v‖ = 1) (hp : 0 < p) (ht : 0 < t) + (hneg : ∀ φ : X →L[ℝ] ℝ, SupportAt φ v → φ y < 0) : + ∃ η : ℝ, 0 < η ∧ η < t ∧ ‖p • v + η • y‖ < p := by + obtain ⟨δ, hδ, hsmall⟩ := exists_radial_perturbation_lt hv hp hneg + have hm : 0 < min t δ := lt_min ht hδ + have hη : 0 < min t δ / 2 := by linarith + have hηt : min t δ / 2 < t := by linarith [min_le_left t δ] + have hηδ : min t δ / 2 < δ := by linarith [min_le_right t δ] + exact ⟨min t δ / 2, hη, hηt, hsmall _ hη hηδ⟩ + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ReturnMap.lean b/lean/OAI/Analysis/SphereIsometry/ReturnMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..07c6de1b0e4d4472543eda900253c50c2dbd23be --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ReturnMap.lean @@ -0,0 +1,353 @@ +import OAI.Analysis.SphereIsometry.RadialContact +import Mathlib.Topology.Algebra.GroupWithZero +import Mathlib.Topology.ContinuousOn + +namespace OAI + +/-! +# The actual radial return map + +For fixed `f`, `y` and `0 < t < 1`, the two interior centers are `t • y` +and `t • f y`. The map follows the two radial contacts. +The opposite direction is literal vector negation, with no antipodality +assumption on `f`. The ambient extensions are continuous on the unit sphere; +no continuity away from that sphere is asserted. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- Literal negation of a unit vector. -/ +def sphereNeg (v : UnitSphere X) : UnitSphere X := + ⟨-(v : X), by simpa only [norm_neg] using v.property⟩ + +omit [NormedSpace ℝ X] in +@[simp] theorem sphereNeg_coe (v : UnitSphere X) : + (sphereNeg v : X) = -(v : X) := rfl + +omit [NormedSpace ℝ X] in +theorem continuous_sphereNeg : Continuous (sphereNeg : UnitSphere X → UnitSphere X) := + continuous_subtype_val.neg.subtype_mk _ + +theorem norm_smul_unitSphere (y : UnitSphere X) (t : ℝ) (ht : 0 ≤ t) : + ‖t • (y : X)‖ = t := by + rw [norm_smul, Real.norm_of_nonneg ht, y.property, mul_one] + +theorem returnCenter_lt_one (y : UnitSphere X) (t : ℝ) (ht : 0 < t ∧ t < 1) : + ‖t • (y : X)‖ < 1 := by + rw [norm_smul_unitSphere y t ht.1.le] + exact ht.2 + +/-- Distances from any unit point to either interior center have uniform bounds. -/ +theorem norm_unit_sub_center_bounds (x y : UnitSphere X) (t : ℝ) (ht : 0 ≤ t) : + 1 - t ≤ ‖(x : X) - t • (y : X)‖ ∧ + ‖(x : X) - t • (y : X)‖ ≤ 1 + t := by + constructor + · simpa only [x.property, norm_smul_unitSphere y t ht] using + norm_sub_norm_le (x : X) (t • (y : X)) + · simpa only [x.property, norm_smul_unitSphere y t ht] using + norm_sub_le (x : X) (t • (y : X)) + +theorem unit_sub_center_ne_zero (x y : UnitSphere X) (t : ℝ) + (ht : 0 < t ∧ t < 1) : (x : X) - t • (y : X) ≠ 0 := by + intro h + have hbound := (norm_unit_sub_center_bounds x y t ht.1.le).1 + rw [h, norm_zero] at hbound + linarith [ht.2] + +theorem center_sub_unit_ne_zero (x y : UnitSphere X) (t : ℝ) + (ht : 0 < t ∧ t < 1) : t • (y : X) - (x : X) ≠ 0 := + sub_ne_zero.mpr (Ne.symm (sub_ne_zero.mp (unit_sub_center_ne_zero x y t ht))) + +/-- The first radial radius. The isometry is an explicit common parameter even +though this first contact only uses the domain center. -/ +def pRadius (_f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) + (t : ℝ) (ht : 0 < t ∧ t < 1) (v : UnitSphere X) : ℝ := + radialRadius (t • (y : X)) (returnCenter_lt_one y t ht) v + +variable (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) +variable (t : ℝ) (ht : 0 < t ∧ t < 1) + +/-- The first contact point `t y + p v`. -/ +def xPoint (v : UnitSphere X) : UnitSphere X := + ⟨t • (y : X) + pRadius f y t ht v • (v : X), + norm_radialRadius (t • (y : X)) (returnCenter_lt_one y t ht) v⟩ + +def sRadius (v : UnitSphere X) : ℝ := + ‖(f (xPoint f y t ht v) : Y) - t • (f y : Y)‖ + +/-- The image-side outward unit direction. -/ +def wDirection (v : UnitSphere X) : UnitSphere Y := + normalize ((f (xPoint f y t ht v) : Y) - t • (f y : Y)) + (unit_sub_center_ne_zero (f (xPoint f y t ht v)) (f y) t ht) + +/-- The second radial contact uses the negative of the actual direction `w`. -/ +def uRadius (v : UnitSphere X) : ℝ := + radialRadius (t • (f y : Y)) (returnCenter_lt_one (f y) t ht) + (sphereNeg (wDirection f y t ht v)) + +def zPoint (v : UnitSphere X) : UnitSphere X := + f.symm (radialContact (t • (f y : Y)) (returnCenter_lt_one (f y) t ht) + (sphereNeg (wDirection f y t ht v))) + +def rRadius (v : UnitSphere X) : ℝ := + ‖(zPoint f y t ht v : X) - t • (y : X)‖ + +/-- The genuine return map on the unit sphere. -/ +def returnSphere (v : UnitSphere X) : UnitSphere X := + normalize (t • (y : X) - (zPoint f y t ht v : X)) + (center_sub_unit_ne_zero (zPoint f y t ht v) y t ht) + +omit [NormedSpace ℝ Y] in +theorem pRadius_pos (v : UnitSphere X) : 0 < pRadius f y t ht v := + radialRadius_pos (t • (y : X)) (returnCenter_lt_one y t ht) v + +omit [NormedSpace ℝ Y] in +theorem pRadius_bounds (v : UnitSphere X) : + 1 - t ≤ pRadius f y t ht v ∧ pRadius f y t ht v ≤ 1 + t := by + simpa only [pRadius, norm_smul_unitSphere y t ht.1.le] using + radialRadius_bounds (t • (y : X)) (returnCenter_lt_one y t ht) v + +theorem sRadius_bounds (v : UnitSphere X) : + 1 - t ≤ sRadius f y t ht v ∧ sRadius f y t ht v ≤ 1 + t := + norm_unit_sub_center_bounds (f (xPoint f y t ht v)) (f y) t ht.1.le + +theorem sRadius_pos (v : UnitSphere X) : 0 < sRadius f y t ht v := + (sub_pos.mpr ht.2).trans_le (sRadius_bounds f y t ht v).1 + +theorem uRadius_pos (v : UnitSphere X) : 0 < uRadius f y t ht v := + radialRadius_pos (t • (f y : Y)) (returnCenter_lt_one (f y) t ht) + (sphereNeg (wDirection f y t ht v)) + +theorem uRadius_bounds (v : UnitSphere X) : + 1 - t ≤ uRadius f y t ht v ∧ uRadius f y t ht v ≤ 1 + t := by + simpa only [uRadius, norm_smul_unitSphere (f y) t ht.1.le] using + radialRadius_bounds (t • (f y : Y)) (returnCenter_lt_one (f y) t ht) + (sphereNeg (wDirection f y t ht v)) + +theorem rRadius_bounds (v : UnitSphere X) : + 1 - t ≤ rRadius f y t ht v ∧ rRadius f y t ht v ≤ 1 + t := + norm_unit_sub_center_bounds (zPoint f y t ht v) y t ht.1.le + +theorem rRadius_pos (v : UnitSphere X) : 0 < rRadius f y t ht v := + (sub_pos.mpr ht.2).trans_le (rRadius_bounds f y t ht v).1 + +theorem radii_pos (v : UnitSphere X) : + 0 < pRadius f y t ht v ∧ 0 < sRadius f y t ht v ∧ + 0 < uRadius f y t ht v ∧ 0 < rRadius f y t ht v := + ⟨pRadius_pos f y t ht v, sRadius_pos f y t ht v, + uRadius_pos f y t ht v, rRadius_pos f y t ht v⟩ + +theorem radii_bounds (v : UnitSphere X) : + pRadius f y t ht v ∈ Set.Icc (1 - t) (1 + t) ∧ + sRadius f y t ht v ∈ Set.Icc (1 - t) (1 + t) ∧ + uRadius f y t ht v ∈ Set.Icc (1 - t) (1 + t) ∧ + rRadius f y t ht v ∈ Set.Icc (1 - t) (1 + t) := + ⟨pRadius_bounds f y t ht v, sRadius_bounds f y t ht v, + uRadius_bounds f y t ht v, rRadius_bounds f y t ht v⟩ + +omit [NormedSpace ℝ Y] in +theorem xPoint_eq (v : UnitSphere X) : + (xPoint f y t ht v : X) = t • (y : X) + pRadius f y t ht v • (v : X) := rfl + +theorem fxPoint_eq (v : UnitSphere X) : + (f (xPoint f y t ht v) : Y) = + t • (f y : Y) + sRadius f y t ht v • (wDirection f y t ht v : Y) := by + have h : sRadius f y t ht v • (wDirection f y t ht v : Y) = + (f (xPoint f y t ht v) : Y) - t • (f y : Y) := + norm_smul_normalize _ _ + rw [h] + abel + +theorem fzPoint_eq (v : UnitSphere X) : + (f (zPoint f y t ht v) : Y) = + t • (f y : Y) - uRadius f y t ht v • (wDirection f y t ht v : Y) := by + simp only [zPoint, IsometryEquiv.apply_symm_apply, radialContact_coe, + sphereNeg_coe, smul_neg, sub_eq_add_neg, uRadius] + +theorem zPoint_eq (v : UnitSphere X) : + (zPoint f y t ht v : X) = + t • (y : X) - rRadius f y t ht v • (returnSphere f y t ht v : X) := by + have h : ‖t • (y : X) - (zPoint f y t ht v : X)‖ • + (returnSphere f y t ht v : X) = t • (y : X) - (zPoint f y t ht v : X) := + norm_smul_normalize _ _ + rw [norm_sub_rev] at h + change rRadius f y t ht v • (returnSphere f y t ht v : X) = _ at h + rw [h] + abel + +omit [NormedSpace ℝ Y] in +theorem norm_xPoint_sub_center (v : UnitSphere X) : + ‖(xPoint f y t ht v : X) - t • (y : X)‖ = pRadius f y t ht v := by + rw [xPoint_eq, add_sub_cancel_left, norm_smul, + Real.norm_of_nonneg (pRadius_pos f y t ht v).le, v.property, mul_one] + +theorem norm_fxPoint_sub_center (v : UnitSphere X) : + ‖(f (xPoint f y t ht v) : Y) - t • (f y : Y)‖ = sRadius f y t ht v := rfl + +theorem norm_zPoint_sub_center (v : UnitSphere X) : + ‖(zPoint f y t ht v : X) - t • (y : X)‖ = rRadius f y t ht v := rfl + +omit [NormedSpace ℝ Y] in +/-- Radial uniqueness recovers any given unit endpoint from its direction. -/ +theorem pRadius_normalize_sub (x : UnitSphere X) : + pRadius f y t ht (normalize ((x : X) - t • (y : X)) + (unit_sub_center_ne_zero x y t ht)) = ‖(x : X) - t • (y : X)‖ := by + symm + apply radialRadius_unique (t • (y : X)) (returnCenter_lt_one y t ht) _ (norm_nonneg _) + rw [norm_smul_normalize] + have he : t • (y : X) + ((x : X) - t • (y : X)) = (x : X) := by abel + rw [he] + exact x.property + +omit [NormedSpace ℝ Y] in +theorem xPoint_normalize_sub (x : UnitSphere X) : + xPoint f y t ht (normalize ((x : X) - t • (y : X)) + (unit_sub_center_ne_zero x y t ht)) = x := by + apply Subtype.ext + rw [xPoint_eq, pRadius_normalize_sub, norm_smul_normalize] + abel + +omit [NormedSpace ℝ Y] in +theorem xPoint_surjective : Function.Surjective (xPoint f y t ht) := by + intro x + exact ⟨normalize ((x : X) - t • (y : X)) (unit_sub_center_ne_zero x y t ht), + xPoint_normalize_sub f y t ht x⟩ + +/-- Normalizing a continuous everywhere-nonzero map preserves continuity. -/ +theorem continuous_normalize_map {A : Type*} [TopologicalSpace A] + (g : A → X) (hg : Continuous g) (hzero : ∀ a, g a ≠ 0) : + Continuous (fun a => normalize (g a) (hzero a)) := by + exact ((hg.norm.inv₀ (fun a => norm_ne_zero_iff.mpr (hzero a))).smul hg).subtype_mk _ + +omit [NormedSpace ℝ Y] in +theorem continuous_pRadius : Continuous (pRadius f y t ht) := + continuous_radialRadius (t • (y : X)) (returnCenter_lt_one y t ht) + +omit [NormedSpace ℝ Y] in +theorem continuous_xPoint : Continuous (xPoint f y t ht) := + continuous_radialContact (t • (y : X)) (returnCenter_lt_one y t ht) + +theorem continuous_sRadius : Continuous (sRadius f y t ht) := + ((continuous_subtype_val.comp (f.continuous.comp (continuous_xPoint f y t ht))).sub + continuous_const).norm + +theorem continuous_wDirection : Continuous (wDirection f y t ht) := + continuous_normalize_map _ + ((continuous_subtype_val.comp (f.continuous.comp (continuous_xPoint f y t ht))).sub + continuous_const) + (fun v => unit_sub_center_ne_zero (f (xPoint f y t ht v)) (f y) t ht) + +theorem continuous_uRadius : Continuous (uRadius f y t ht) := + (continuous_radialRadius (t • (f y : Y)) (returnCenter_lt_one (f y) t ht)).comp + (continuous_sphereNeg.comp (continuous_wDirection f y t ht)) + +theorem continuous_zPoint : Continuous (zPoint f y t ht) := + f.symm.continuous.comp + ((continuous_radialContact (t • (f y : Y)) (returnCenter_lt_one (f y) t ht)).comp + (continuous_sphereNeg.comp (continuous_wDirection f y t ht))) + +theorem continuous_rRadius : Continuous (rRadius f y t ht) := + ((continuous_subtype_val.comp (continuous_zPoint f y t ht)).sub continuous_const).norm + +theorem continuous_returnSphere : Continuous (returnSphere f y t ht) := + continuous_normalize_map _ + (continuous_const.sub (continuous_subtype_val.comp (continuous_zPoint f y t ht))) + (fun v => center_sub_unit_ne_zero (zPoint f y t ht v) y t ht) + +/-- Total ambient functions, used only on the sphere by the convex-set argument. -/ +def pAmbient (v : X) : ℝ := + if hv : ‖v‖ = 1 then pRadius f y t ht ⟨v, hv⟩ else 0 + +def sAmbient (v : X) : ℝ := + if hv : ‖v‖ = 1 then sRadius f y t ht ⟨v, hv⟩ else 0 + +def uAmbient (v : X) : ℝ := + if hv : ‖v‖ = 1 then uRadius f y t ht ⟨v, hv⟩ else 0 + +def rAmbient (v : X) : ℝ := + if hv : ‖v‖ = 1 then rRadius f y t ht ⟨v, hv⟩ else 0 + +def returnAmbient (v : X) : X := + if hv : ‖v‖ = 1 then (returnSphere f y t ht ⟨v, hv⟩ : X) else 0 + +omit [NormedSpace ℝ Y] in +@[simp] theorem pAmbient_coe (v : UnitSphere X) : + pAmbient f y t ht (v : X) = pRadius f y t ht v := by + simp only [pAmbient, v.property, dite_eq_left] + +@[simp] theorem sAmbient_coe (v : UnitSphere X) : + sAmbient f y t ht (v : X) = sRadius f y t ht v := by + simp only [sAmbient, v.property, dite_eq_left] + +@[simp] theorem uAmbient_coe (v : UnitSphere X) : + uAmbient f y t ht (v : X) = uRadius f y t ht v := by + simp only [uAmbient, v.property, dite_eq_left] + +@[simp] theorem rAmbient_coe (v : UnitSphere X) : + rAmbient f y t ht (v : X) = rRadius f y t ht v := by + simp only [rAmbient, v.property, dite_eq_left] + +@[simp] theorem returnAmbient_coe (v : UnitSphere X) : + returnAmbient f y t ht (v : X) = (returnSphere f y t ht v : X) := by + simp only [returnAmbient, v.property, dite_eq_left] + +omit [NormedSpace ℝ Y] in +theorem continuousOn_pAmbient : + ContinuousOn (pAmbient f y t ht) {v : X | ‖v‖ = 1} := by + apply continuousOn_iff_continuous_domRestrict.mpr + have he : ({v : X | ‖v‖ = 1}).domRestrict (pAmbient f y t ht) = pRadius f y t ht := by + funext v + exact pAmbient_coe f y t ht v + rw [he] + exact continuous_pRadius f y t ht + +theorem continuousOn_sAmbient : + ContinuousOn (sAmbient f y t ht) {v : X | ‖v‖ = 1} := by + apply continuousOn_iff_continuous_domRestrict.mpr + have he : ({v : X | ‖v‖ = 1}).domRestrict (sAmbient f y t ht) = sRadius f y t ht := by + funext v + exact sAmbient_coe f y t ht v + rw [he] + exact continuous_sRadius f y t ht + +theorem continuousOn_uAmbient : + ContinuousOn (uAmbient f y t ht) {v : X | ‖v‖ = 1} := by + apply continuousOn_iff_continuous_domRestrict.mpr + have he : ({v : X | ‖v‖ = 1}).domRestrict (uAmbient f y t ht) = uRadius f y t ht := by + funext v + exact uAmbient_coe f y t ht v + rw [he] + exact continuous_uRadius f y t ht + +theorem continuousOn_rAmbient : + ContinuousOn (rAmbient f y t ht) {v : X | ‖v‖ = 1} := by + apply continuousOn_iff_continuous_domRestrict.mpr + have he : ({v : X | ‖v‖ = 1}).domRestrict (rAmbient f y t ht) = rRadius f y t ht := by + funext v + exact rAmbient_coe f y t ht v + rw [he] + exact continuous_rRadius f y t ht + +theorem continuousOn_returnAmbient : + ContinuousOn (returnAmbient f y t ht) {v : X | ‖v‖ = 1} := by + apply continuousOn_iff_continuous_domRestrict.mpr + have he : ({v : X | ‖v‖ = 1}).domRestrict (returnAmbient f y t ht) = + fun v : UnitSphere X => (returnSphere f y t ht v : X) := by + funext v + exact returnAmbient_coe f y t ht v + rw [he] + exact continuous_subtype_val.comp (continuous_returnSphere f y t ht) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ReturnMapBounds.lean b/lean/OAI/Analysis/SphereIsometry/ReturnMapBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..56b4e97b9c5912e0e2e6ad1ff361319b63919e65 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ReturnMapBounds.lean @@ -0,0 +1,110 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Ring + +namespace OAI + +/-! Scalar estimates for the return map, before taking finite diameter covers. -/ + +namespace Tingley + +theorem radius_ratio_le_factor {p s M U : ℝ} (hs : 0 < s) + (hM : 0 ≤ M) (hsU : s ≤ U) (hsp : s = p + M) : + p / s ≤ 1 - M / U := by + calc + p / s = (s - M) / s := congrArg (fun q : ℝ => q / s) (by linarith) + _ = 1 - M / s := by rw [sub_div, div_self (ne_of_gt hs)] + _ ≤ 1 - M / U := + sub_le_sub_left (div_le_div_of_nonneg_left hM hs hsU) 1 + +theorem return_coefficient_le {p s u r M U : ℝ} + (hp : 0 ≤ p) (_hu : 0 ≤ u) (hr : 0 < r) (hs : 0 < s) + (hM : 0 ≤ M) (hrU : r ≤ U) (hsU : s ≤ U) + (hrm : r = u + M) (hsm : s = p + M) : + u * p / (r * s) ≤ (1 - M / U) ^ 2 := by + have hpq := radius_ratio_le_factor hs hM hsU hsm + have huq := radius_ratio_le_factor hr hM hrU hrm + have hp0 : 0 ≤ p / s := div_nonneg hp hs.le + have hq0 : 0 ≤ 1 - M / U := hp0.trans hpq + calc + u * p / (r * s) = (u / r) * (p / s) := by rw [div_mul_div_comm] + _ ≤ (1 - M / U) * (1 - M / U) := mul_le_mul huq hpq hp0 hq0 + _ = (1 - M / U) ^ 2 := by ring + +theorem return_pair_error_le {a r s u du dp : ℝ} + (ha : 0 < a) (har : a ≤ r) (has : a ≤ s) + (hur : u ≤ r) (hdu : 0 ≤ du) (hdp : 0 ≤ dp) : + 2 * du / r + 2 * u * dp / (r * s) ≤ (2 / a) * (du + dp) := by + have hr : 0 < r := ha.trans_le har + have hs : 0 < s := ha.trans_le has + have he₁ : 2 * du / r ≤ 2 * du / a := + div_le_div_of_nonneg_left (mul_nonneg zero_le_two hdu) ha har + have he₂ : 2 * u * dp / (r * s) ≤ 2 * dp / a := by + calc + 2 * u * dp / (r * s) = (u / r) * (2 * dp / s) := by + field_simp [ne_of_gt hr, ne_of_gt hs] + _ ≤ 1 * (2 * dp / s) := + mul_le_mul_of_nonneg_right ((div_le_one₀ hr).mpr hur) + (div_nonneg (mul_nonneg zero_le_two hdp) hs.le) + _ = 2 * dp / s := one_mul _ + _ ≤ 2 * dp / a := + div_le_div_of_nonneg_left (mul_nonneg zero_le_two hdp) ha has + calc + 2 * du / r + 2 * u * dp / (r * s) ≤ 2 * du / a + 2 * dp / a := + add_le_add he₁ he₂ + _ = (2 / a) * (du + dp) := by ring + +theorem return_pair_uniform_bound {a U M p s u r D Dg du dp : ℝ} + (ha : 0 < a) (hM : 0 ≤ M) + (hp : 0 ≤ p) (hu : 0 ≤ u) + (har : a ≤ r) (has : a ≤ s) (hrU : r ≤ U) (hsU : s ≤ U) + (hrm : r = u + M) (hsm : s = p + M) + (hD : 0 ≤ D) (hdu : 0 ≤ du) (hdp : 0 ≤ dp) + (hpair : Dg ≤ (u * p / (r * s)) * D + + 2 * du / r + 2 * u * dp / (r * s)) : + Dg ≤ (1 - M / U) ^ 2 * D + (2 / a) * (du + dp) := by + have hr : 0 < r := ha.trans_le har + have hs : 0 < s := ha.trans_le has + have hur : u ≤ r := by linarith + have hcoeff := return_coefficient_le hp hu hr hs hM hrU hsU hrm hsm + have herr := return_pair_error_le ha har has hur hdu hdp + calc + Dg ≤ (u * p / (r * s)) * D + + 2 * du / r + 2 * u * dp / (r * s) := hpair + _ = (u * p / (r * s)) * D + + (2 * du / r + 2 * u * dp / (r * s)) := by ring + _ ≤ (1 - M / U) ^ 2 * D + (2 / a) * (du + dp) := + add_le_add (mul_le_mul_of_nonneg_right hcoeff hD) herr + +/-- The exact square factor, with its strict upper bound. -/ +theorem return_factor_mem_Ico {t M : ℝ} (ht0 : 0 < t) + (hM : 0 < M) (hMU : M < 1 + t) : + (1 - M / (1 + t)) ^ 2 ∈ Set.Ico (0 : ℝ) 1 := by + have hU : 0 < 1 + t := by linarith + have hq0 : 0 < M / (1 + t) := div_pos hM hU + have hq1 : M / (1 + t) < 1 := by + apply (div_lt_iff₀ hU).mpr + simpa using hMU + have hprod : 0 < (1 - M / (1 + t)) * (M / (1 + t)) := + mul_pos (by linarith) hq0 + exact ⟨sq_nonneg _, by nlinarith⟩ + +/-- Nonemptiness is used only to bound M by one actual positive radius. -/ +theorem return_contraction_factor_mem_Ico {X : Type*} + {C : Set X} {p s : X → ℝ} {t M : ℝ} + (ht0 : 0 < t) (ht1 : t < 1) (hM : 0 < M) (hCne : C.Nonempty) + (hp : ∀ v ∈ C, 1 - t ≤ p v) + (hsU : ∀ v ∈ C, s v ≤ 1 + t) + (hsm : ∀ v ∈ C, s v = p v + M) : + (1 - M / (1 + t)) ^ 2 ∈ Set.Ico (0 : ℝ) 1 := by + obtain ⟨v, hv⟩ := hCne + have hpv := hp v hv + have hsv := hsU v hv + have heq := hsm v hv + apply return_factor_mem_Ico ht0 hM + linarith + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ReturnMapEstimate.lean b/lean/OAI/Analysis/SphereIsometry/ReturnMapEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd83c771b8feeaee3df6033d37e757f1443b6978 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ReturnMapEstimate.lean @@ -0,0 +1,205 @@ +import OAI.Analysis.SphereIsometry.ExtremalPropagation +import Mathlib.Tactic.FieldSimp + +namespace OAI + +/-! +# The actual return map's two-point estimate + +The two triangle-inequality comparisons retain the unprimed radius multiplying +both direction differences. The sphere isometry connects the actual endpoints; +no pairwise estimate for an arbitrary map is assumed. +-/ + +noncomputable section + +namespace Tingley + +universe u v + +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- Changing both the scalar and a unit vector, retaining the first scalar +in front of the direction difference. -/ +theorem norm_smul_sub_smul_le_first (a b : ℝ) (ha : 0 ≤ a) + (v w : UnitSphere X) : + ‖a • (v : X) - b • (w : X)‖ ≤ a * ‖(v : X) - (w : X)‖ + |a - b| := by + have he : a • (v : X) - b • (w : X) = + a • ((v : X) - (w : X)) + (a - b) • (w : X) := by + simp only [smul_sub, sub_smul] + abel + calc + ‖a • (v : X) - b • (w : X)‖ = + ‖a • ((v : X) - (w : X)) + (a - b) • (w : X)‖ := congrArg norm he + _ ≤ ‖a • ((v : X) - (w : X))‖ + ‖(a - b) • (w : X)‖ := norm_add_le _ _ + _ = a * ‖(v : X) - (w : X)‖ + |a - b| := by + rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_eq_abs, + w.property, mul_one] + +/-- Recovering the direction difference from two differently scaled unit +vectors, again retaining the first scalar. -/ +theorem first_mul_norm_sub_le_smul_sub (a b : ℝ) (ha : 0 ≤ a) + (v w : UnitSphere X) : + a * ‖(v : X) - (w : X)‖ ≤ ‖a • (v : X) - b • (w : X)‖ + |a - b| := by + have he : a • ((v : X) - (w : X)) = + (a • (v : X) - b • (w : X)) + (b - a) • (w : X) := by + simp only [smul_sub, sub_smul] + abel + calc + a * ‖(v : X) - (w : X)‖ = ‖a • ((v : X) - (w : X))‖ := by + rw [norm_smul, Real.norm_of_nonneg ha] + _ = ‖(a • (v : X) - b • (w : X)) + (b - a) • (w : X)‖ := + congrArg norm he + _ ≤ ‖a • (v : X) - b • (w : X)‖ + ‖(b - a) • (w : X)‖ := norm_add_le _ _ + _ = ‖a • (v : X) - b • (w : X)‖ + |a - b| := by + rw [norm_smul, Real.norm_eq_abs, w.property, mul_one, abs_sub_comm b a] + +/-- The scalar elimination used after the two actual endpoint comparisons. +Only the radii by which we divide require strict positivity. -/ +theorem return_pair_scalar_elimination + (r s u p A B Dg Dw Dv : ℝ) (hr : 0 < r) (hs : 0 < s) (hu : 0 ≤ u) + (hg : r * Dg ≤ 2 * A + u * Dw) + (hw : s * Dw ≤ 2 * B + p * Dv) : + Dg ≤ (u * p / (r * s)) * Dv + 2 * A / r + 2 * u * B / (r * s) := by + have hw' : Dw ≤ (2 * B + p * Dv) / s := by + apply (le_div_iff₀ hs).2 + simpa only [mul_comm Dw s] using hw + calc + Dg ≤ (2 * A + u * Dw) / r := by + apply (le_div_iff₀ hr).2 + simpa only [mul_comm Dg r] using hg + _ ≤ (2 * A + u * ((2 * B + p * Dv) / s)) / r := + div_le_div_of_nonneg_right + (add_le_add_right (mul_le_mul_of_nonneg_left hw' hu) _) hr.le + _ = (u * p / (r * s)) * Dv + 2 * A / r + 2 * u * B / (r * s) := by + field_simp [ne_of_gt hr, ne_of_gt hs] + ring + +/-- The exact two-point estimate for the constructed return map on its actual +extremal sphere set. Both endpoint comparisons use the original sphere isometry. -/ +theorem returnSphere_pair_estimate + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) + (t : ℝ) (ht : 0 < t ∧ t < 1) (M : ℝ) (hb : HasDefectBound f M) + {v v' : UnitSphere X} + (hv : v ∈ extremalSphere f y t ht M) + (hv' : v' ∈ extremalSphere f y t ht M) : + ‖(returnSphere f y t ht v : X) - (returnSphere f y t ht v' : X)‖ ≤ + (uRadius f y t ht v * pRadius f y t ht v / + (rRadius f y t ht v * sRadius f y t ht v)) * ‖(v : X) - (v' : X)‖ + + 2 * |uRadius f y t ht v - uRadius f y t ht v'| / rRadius f y t ht v + + 2 * uRadius f y t ht v * |pRadius f y t ht v - pRadius f y t ht v'| / + (rRadius f y t ht v * sRadius f y t ht v) := by + let p := pRadius f y t ht + let s := sRadius f y t ht + let u := uRadius f y t ht + let r := rRadius f y t ht + let g := returnSphere f y t ht + let w := wDirection f y t ht + let x := xPoint f y t ht + let z := zPoint f y t ht + have hx (a : UnitSphere X) : (x a : X) = t • (y : X) + p a • (a : X) := + xPoint_eq f y t ht a + have hz (a : UnitSphere X) : (z a : X) = t • (y : X) - r a • (g a : X) := + zPoint_eq f y t ht a + have hfx (a : UnitSphere X) : (f (x a) : Y) = + t • (f y : Y) + s a • (w a : Y) := fxPoint_eq f y t ht a + have hfz (a : UnitSphere X) : (f (z a) : Y) = + t • (f y : Y) - u a • (w a : Y) := fzPoint_eq f y t ht a + have hr : 0 < r v := rRadius_pos f y t ht v + have hs : 0 < s v := sRadius_pos f y t ht v + have hu : 0 ≤ u v := (uRadius_pos f y t ht v).le + have hp : 0 ≤ p v := (pRadius_pos f y t ht v).le + have hrdiff : r v - r v' = u v - u v' := by + have h := rRadius_eq_add f y t ht M hb hv + have h' := rRadius_eq_add f y t ht M hb hv' + change r v = u v + M at h + change r v' = u v' + M at h' + linarith + have hsdiff : s v - s v' = p v - p v' := by + have h := sRadius_eq_add f y t ht M hv + have h' := sRadius_eq_add f y t ht M hv' + change s v = p v + M at h + change s v' = p v' + M at h' + linarith + have hR : ‖r v • (g v : X) - r v' • (g v' : X)‖ = + ‖u v • (w v : Y) - u v' • (w v' : Y)‖ := by + calc + ‖r v • (g v : X) - r v' • (g v' : X)‖ = ‖(z v' : X) - (z v : X)‖ := by + congr 1 + rw [hz v', hz v] + abel + _ = ‖(f (z v') : Y) - (f (z v) : Y)‖ := + (sphere_norm_sub f (z v') (z v)).symm + _ = ‖u v • (w v : Y) - u v' • (w v' : Y)‖ := by + congr 1 + rw [hfz v', hfz v] + abel + have hS : ‖s v • (w v : Y) - s v' • (w v' : Y)‖ = + ‖p v • (v : X) - p v' • (v' : X)‖ := by + calc + ‖s v • (w v : Y) - s v' • (w v' : Y)‖ = + ‖(f (x v) : Y) - (f (x v') : Y)‖ := by + congr 1 + rw [hfx v, hfx v'] + abel + _ = ‖(x v : X) - (x v' : X)‖ := sphere_norm_sub f (x v) (x v') + _ = ‖p v • (v : X) - p v' • (v' : X)‖ := by + congr 1 + rw [hx v, hx v'] + abel + have hG : r v * ‖(g v : X) - (g v' : X)‖ ≤ + 2 * |u v - u v'| + u v * ‖(w v : Y) - (w v' : Y)‖ := by + have h₁ := first_mul_norm_sub_le_smul_sub (r v) (r v') hr.le (g v) (g v') + have h₂ := norm_smul_sub_smul_le_first (u v) (u v') hu (w v) (w v') + rw [hR, hrdiff] at h₁ + linarith + have hW : s v * ‖(w v : Y) - (w v' : Y)‖ ≤ + 2 * |p v - p v'| + p v * ‖(v : X) - (v' : X)‖ := by + have h₁ := first_mul_norm_sub_le_smul_sub (s v) (s v') hs.le (w v) (w v') + have h₂ := norm_smul_sub_smul_le_first (p v) (p v') hp v v' + rw [hS, hsdiff] at h₁ + linarith + exact return_pair_scalar_elimination (r v) (s v) (u v) (p v) + |u v - u v'| |p v - p v'| ‖(g v : X) - (g v' : X)‖ + ‖(w v : Y) - (w v' : Y)‖ ‖(v : X) - (v' : X)‖ hr hs hu hG hW + +/-- The same estimate for the totalized ambient map. Membership in the actual +extremal set ensures that every ambient function takes its sphere branch. -/ +theorem returnAmbient_pair_estimate + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) + (t : ℝ) (ht : 0 < t ∧ t < 1) (M : ℝ) (hb : HasDefectBound f M) + {v v' : X} (hv : v ∈ extremalSet f y t ht M) + (hv' : v' ∈ extremalSet f y t ht M) : + ‖returnAmbient f y t ht v - returnAmbient f y t ht v'‖ ≤ + (uAmbient f y t ht v * pAmbient f y t ht v / + (rAmbient f y t ht v * sAmbient f y t ht v)) * ‖v - v'‖ + + 2 * |uAmbient f y t ht v - uAmbient f y t ht v'| / rAmbient f y t ht v + + 2 * uAmbient f y t ht v * |pAmbient f y t ht v - pAmbient f y t ht v'| / + (rAmbient f y t ht v * sAmbient f y t ht v) := by + obtain ⟨a, ha, rfl⟩ := hv + obtain ⟨b, hb', rfl⟩ := hv' + simpa only [returnAmbient_coe, pAmbient_coe, sAmbient_coe, uAmbient_coe, + rAmbient_coe] using returnSphere_pair_estimate f y t ht M hb ha hb' + +/-- Restriction to any subset of the actual extremal set, including the closed +invariant convex set constructed from the positive schedule. -/ +theorem returnAmbient_pair_estimate_on + (f : UnitSphere X ≃ᵢ UnitSphere Y) (y : UnitSphere X) + (t : ℝ) (ht : 0 < t ∧ t < 1) (M : ℝ) (hb : HasDefectBound f M) + (C : Set X) (hC : C ⊆ extremalSet f y t ht M) + {v v' : X} (hv : v ∈ C) (hv' : v' ∈ C) : + ‖returnAmbient f y t ht v - returnAmbient f y t ht v'‖ ≤ + (uAmbient f y t ht v * pAmbient f y t ht v / + (rAmbient f y t ht v * sAmbient f y t ht v)) * ‖v - v'‖ + + 2 * |uAmbient f y t ht v - uAmbient f y t ht v'| / rAmbient f y t ht v + + 2 * uAmbient f y t ht v * |pAmbient f y t ht v - pAmbient f y t ht v'| / + (rAmbient f y t ht v * sAmbient f y t ht v) := + returnAmbient_pair_estimate f y t ht M hb (hC hv) (hC hv') + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ReturnMapFixedPoint.lean b/lean/OAI/Analysis/SphereIsometry/ReturnMapFixedPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..cadb0583cd348cbf9222605608db6fcf14ee5b5d --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ReturnMapFixedPoint.lean @@ -0,0 +1,51 @@ +import OAI.Analysis.SphereIsometry.ReturnMapNoncompactness +import OAI.Analysis.SphereIsometry.CondensingFixedPoint + +namespace OAI + +/-! +# A fixed point from the return map's radius estimates + +The finite-bin noncompactness estimate and the proved condensing fixed-point +theorem discharge the analytic step from the elementary geometric data. +Continuity is needed only on the actual invariant closed convex set. +-/ + +namespace Tingley + +variable {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [CompleteSpace X] + +/-- The radius bounds and two-point estimate imply an actual fixed point. +The hypotheses contain neither a noncompactness estimate nor a fixed-point +principle: both are supplied by the preceding constructive proofs. -/ +theorem exists_fixedPoint_of_return_estimate + {C : Set X} {g : X → X} {p s u r : X → ℝ} {t M : ℝ} + (ht0 : 0 < t) (ht1 : t < 1) (hM : 0 < M) + (hCne : C.Nonempty) (hCclosed : IsClosed C) + (hCb : Bornology.IsBounded C) (hCconvex : Convex ℝ C) + (hg : ContinuousOn g C) (hgC : Set.MapsTo g C C) + (hbounds : ∀ v ∈ C, + (1 - t ≤ p v ∧ p v ≤ 1 + t) ∧ + (1 - t ≤ s v ∧ s v ≤ 1 + t) ∧ + (1 - t ≤ u v ∧ u v ≤ 1 + t) ∧ + (1 - t ≤ r v ∧ r v ≤ 1 + t)) + (hs : ∀ v ∈ C, s v = p v + M) + (hr : ∀ v ∈ C, r v = u v + M) + (hpair : ∀ v ∈ C, ∀ v' ∈ C, + dist (g v) (g v') ≤ + (u v * p v / (r v * s v)) * dist v v' + + 2 * |u v - u v'| / r v + + 2 * u v * |p v - p v'| / (r v * s v)) : + ∃ x ∈ C, g x = x := by + have hfactor := return_contraction_factor_mem_Ico ht0 ht1 hM hCne + (fun v hv => (hbounds v hv).1.1) + (fun v hv => (hbounds v hv).2.1.2) hs + apply exists_fixedPoint_of_kuratowski_contraction hCne hCclosed hCb + hCconvex hg hgC hfactor.1 hfactor.2 + intro H hHC + exact chi_return_image_le ht0 ht1 hM hCne hCb hgC hbounds hs hr hpair hHC + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ReturnMapNoncompactness.lean b/lean/OAI/Analysis/SphereIsometry/ReturnMapNoncompactness.lean new file mode 100644 index 0000000000000000000000000000000000000000..396d121c21bbd1c0cdba84e3b4a55d749154a0b9 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ReturnMapNoncompactness.lean @@ -0,0 +1,136 @@ +import OAI.Analysis.SphereIsometry.KuratowskiBasic +import OAI.Analysis.SphereIsometry.ReturnMapBounds +import OAI.Analysis.SphereIsometry.ScalarBins +import Mathlib.Data.Fintype.Prod + +namespace OAI + +/-! +# The return map contracts noncompactness on every subset + +Finite scalar bins refine diameter covers after each piece is intersected +with the given subset. A positive-error argument then passes to the exact +Kuratowski infimum. Neither the subset nor its covering pieces need be compact. +-/ + +noncomputable section + +namespace Tingley + +/-- A finite refinement by two bounded scalar observables. -/ +theorem finiteDiameterCover_image_of_scalar_bins + {X Y : Type*} [PseudoMetricSpace X] [PseudoMetricSpace Y] + {C H : Set X} {g : X → Y} {p u : X → ℝ} {U a γ δ η : ℝ} + (hHC : H ⊆ C) (hU : 0 ≤ U) (ha : 0 < a) (hγ : 0 ≤ γ) + (hp : ∀ v ∈ C, p v ∈ Set.Icc 0 U) + (hu : ∀ v ∈ C, u v ∈ Set.Icc 0 U) + (hpair : ∀ v ∈ C, ∀ v' ∈ C, + dist (g v) (g v') ≤ γ * dist v v' + + (2 / a) * (|u v - u v'| + |p v - p v'|)) + (hc : FiniteDiameterCover H δ) (hη : 0 < η) : + FiniteDiameterCover (g '' H) (γ * δ + 4 * η / a) := by + obtain ⟨n, A, hcover, hdiam⟩ := hc + obtain ⟨N, B, hBcover, hBdiam⟩ := exists_finite_scalar_bins hU hη + let Q : (Fin n × Fin N × Fin N) → Set X := fun ijk => + H ∩ A ijk.1 ∩ p ⁻¹' B ijk.2.1 ∩ u ⁻¹' B ijk.2.2 + apply FiniteDiameterCover.of_fintype (fun ijk => g '' Q ijk) + · rintro y ⟨v, hvH, rfl⟩ + obtain ⟨i, hvi⟩ := Set.mem_iUnion.mp (hcover hvH) + obtain ⟨j, hvj⟩ := Set.mem_iUnion.mp (hBcover (hp v (hHC hvH))) + obtain ⟨k, hvk⟩ := Set.mem_iUnion.mp (hBcover (hu v (hHC hvH))) + exact Set.mem_iUnion.mpr + ⟨(i, j, k), v, ⟨⟨⟨hvH, hvi⟩, hvj⟩, hvk⟩, rfl⟩ + · rintro ijk y ⟨v, hv, rfl⟩ z ⟨v', hv', rfl⟩ + change v ∈ H ∩ A ijk.1 ∩ p ⁻¹' B ijk.2.1 ∩ u ⁻¹' B ijk.2.2 at hv + change v' ∈ H ∩ A ijk.1 ∩ p ⁻¹' B ijk.2.1 ∩ u ⁻¹' B ijk.2.2 at hv' + rcases hv with ⟨⟨⟨hvH, hvA⟩, hvp⟩, hvu⟩ + rcases hv' with ⟨⟨⟨hvH', hvA'⟩, hvp'⟩, hvu'⟩ + have hpd : |p v - p v'| ≤ η := hBdiam ijk.2.1 _ hvp _ hvp' + have hud : |u v - u v'| ≤ η := hBdiam ijk.2.2 _ hvu _ hvu' + have herr : (2 / a) * (|u v - u v'| + |p v - p v'|) ≤ 4 * η / a := by + calc + (2 / a) * (|u v - u v'| + |p v - p v'|) ≤ (2 / a) * (η + η) := + mul_le_mul_of_nonneg_left (add_le_add hud hpd) (div_nonneg zero_le_two ha.le) + _ = 4 * η / a := by ring + exact (hpair v (hHC hvH) v' (hHC hvH')).trans + (add_le_add (mul_le_mul_of_nonneg_left (hdiam ijk.1 v hvA v' hvA') hγ) herr) + +/-- The exact all-subsets contraction, including the empty subset. The scalar +relations and the two-point estimate are supplied by the actual return map. -/ +theorem chi_return_image_le + {X : Type*} [PseudoMetricSpace X] + {C : Set X} {g : X → X} {p s u r : X → ℝ} {t M : ℝ} + (ht0 : 0 < t) (ht1 : t < 1) (hM : 0 < M) + (hCne : C.Nonempty) (hCb : Bornology.IsBounded C) + (_hgC : Set.MapsTo g C C) + (hbounds : ∀ v ∈ C, + (1 - t ≤ p v ∧ p v ≤ 1 + t) ∧ + (1 - t ≤ s v ∧ s v ≤ 1 + t) ∧ + (1 - t ≤ u v ∧ u v ≤ 1 + t) ∧ + (1 - t ≤ r v ∧ r v ≤ 1 + t)) + (hs : ∀ v ∈ C, s v = p v + M) + (hr : ∀ v ∈ C, r v = u v + M) + (hpair : ∀ v ∈ C, ∀ v' ∈ C, + dist (g v) (g v') ≤ + (u v * p v / (r v * s v)) * dist v v' + + 2 * |u v - u v'| / r v + + 2 * u v * |p v - p v'| / (r v * s v)) + {H : Set X} (hHC : H ⊆ C) : + chi (g '' H) ≤ (1 - M / (1 + t)) ^ 2 * chi H := by + let γ : ℝ := (1 - M / (1 + t)) ^ 2 + have ha : 0 < 1 - t := sub_pos.mpr ht1 + have hU : 0 ≤ 1 + t := by linarith + have hfactor := return_contraction_factor_mem_Ico ht0 ht1 hM hCne + (fun v hv => (hbounds v hv).1.1) + (fun v hv => (hbounds v hv).2.1.2) hs + have hγ : 0 ≤ γ := hfactor.1 + have hγ1 : γ ≤ 1 := hfactor.2.le + have hp : ∀ v ∈ C, p v ∈ Set.Icc 0 (1 + t) := by + intro v hv + exact ⟨ha.le.trans (hbounds v hv).1.1, (hbounds v hv).1.2⟩ + have hu : ∀ v ∈ C, u v ∈ Set.Icc 0 (1 + t) := by + intro v hv + exact ⟨ha.le.trans (hbounds v hv).2.2.1.1, (hbounds v hv).2.2.1.2⟩ + have hpair' : ∀ v ∈ C, ∀ v' ∈ C, + dist (g v) (g v') ≤ γ * dist v v' + + (2 / (1 - t)) * (|u v - u v'| + |p v - p v'|) := by + intro v hv v' hv' + exact return_pair_uniform_bound ha hM.le (hp v hv).1 (hu v hv).1 + (hbounds v hv).2.2.2.1 (hbounds v hv).2.1.1 + (hbounds v hv).2.2.2.2 (hbounds v hv).2.1.2 + (hr v hv) (hs v hv) dist_nonneg (abs_nonneg _) (abs_nonneg _) + (hpair v hv v' hv') + have happrox : ∀ ε : ℝ, 0 < ε → chi (g '' H) ≤ γ * chi H + ε := by + intro ε hε + have hε2 : 0 < ε / 2 := half_pos hε + obtain ⟨δ, hδ0, hδ, hc⟩ := exists_cover_of_chi_lt (hCb.subset hHC) + (show chi H < chi H + ε / 2 by linarith) + let η : ℝ := ε * (1 - t) / 8 + have hη : 0 < η := div_pos (mul_pos hε ha) (by norm_num) + have hc' := finiteDiameterCover_image_of_scalar_bins hHC hU ha hγ hp hu hpair' hc hη + have hR : 0 ≤ γ * δ + 4 * η / (1 - t) := + add_nonneg (mul_nonneg hγ hδ0.le) + (div_nonneg (mul_nonneg (by norm_num) hη.le) ha.le) + have herror : 4 * η / (1 - t) = ε / 2 := by + dsimp only [η] + field_simp [ne_of_gt ha] + ring + calc + chi (g '' H) ≤ γ * δ + 4 * η / (1 - t) := chi_le_of_cover hR hc' + _ = γ * δ + ε / 2 := by rw [herror] + _ ≤ γ * (chi H + ε / 2) + ε / 2 := + add_le_add_left (mul_le_mul_of_nonneg_left hδ.le hγ) _ + _ ≤ γ * chi H + ε := by + have hh := mul_le_mul_of_nonneg_right hγ1 hε2.le + nlinarith + change chi (g '' H) ≤ γ * chi H + by_contra hnot + have hgap : 0 < chi (g '' H) - γ * chi H := sub_pos.mpr (lt_of_not_ge hnot) + have hh := happrox ((chi (g '' H) - γ * chi H) / 2) (half_pos hgap) + linarith + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/ScalarBins.lean b/lean/OAI/Analysis/SphereIsometry/ScalarBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d23b1c4c4b8b91c21791cb7c39edf63457d1278 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/ScalarBins.lean @@ -0,0 +1,46 @@ +import Mathlib.Algebra.Order.Floor.Semiring +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Data.Fintype.Basic +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Finite scalar bins + +A bounded interval is covered by explicitly indexed half-open intervals of +length `η`. The extra final bin includes the top endpoint even when `U / η` +is an integer. +-/ + +namespace Tingley + +/-- Cover `[0,U]` by finitely many scalar bins with pairwise distance at most +`η` inside each bin. The construction also works when `U = 0`. -/ +theorem exists_finite_scalar_bins {U η : ℝ} (_hU : 0 ≤ U) (hη : 0 < η) : + ∃ N : ℕ, ∃ B : Fin N → Set ℝ, + Set.Icc 0 U ⊆ ⋃ k, B k ∧ + ∀ k, ∀ x ∈ B k, ∀ y ∈ B k, |x - y| ≤ η := by + let N : ℕ := Nat.floor (U / η) + 1 + let B : Fin N → Set ℝ := fun k => + Set.Ico ((k.val : ℝ) * η) (((k.val : ℝ) + 1) * η) + refine ⟨N, B, ?_, ?_⟩ + · intro x hx + have hkU : Nat.floor (x / η) ≤ Nat.floor (U / η) := + Nat.floor_mono (div_le_div_of_nonneg_right hx.2 hη.le) + have hkN : Nat.floor (x / η) < N := Nat.lt_succ_of_le hkU + refine Set.mem_iUnion.mpr ⟨⟨Nat.floor (x / η), hkN⟩, ?_⟩ + change (Nat.floor (x / η) : ℝ) * η ≤ x ∧ + x < ((Nat.floor (x / η) : ℝ) + 1) * η + exact ⟨(le_div_iff₀ hη).mp (Nat.floor_le (div_nonneg hx.1 hη.le)), + (div_lt_iff₀ hη).mp (Nat.lt_floor_add_one (x / η))⟩ + · intro k x hx y hy + change (k.val : ℝ) * η ≤ x ∧ x < ((k.val : ℝ) + 1) * η at hx + change (k.val : ℝ) * η ≤ y ∧ y < ((k.val : ℝ) + 1) * η at hy + rw [add_mul, one_mul] at hx hy + apply abs_le.mpr + constructor <;> linarith only [hx.1, hx.2, hy.1, hy.2] + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SimplexFixedPoint.lean b/lean/OAI/Analysis/SphereIsometry/SimplexFixedPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..88e33d4becc7510f020c00b90d2e8d9ea2b91a9c --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SimplexFixedPoint.lean @@ -0,0 +1,105 @@ +import OAI.Analysis.SphereIsometry.SimplexLimit +import OAI.Analysis.SphereIsometry.IteratedPoints +import OAI.Analysis.SphereIsometry.Sperner +import Mathlib.Analysis.SpecificLimits.Basic +import Mathlib.Data.Fintype.EquivFin + +namespace OAI + +/-! +# Fixed points in finite probability simplexes + +The finite-coordinate theorem constructs its approximating points from the actual iterated +subdivision and the proved Sperner theorem. Positive coordinates enforce the boundary condition +on labels. The shrinking mesh and the labelled inequalities then give an exact fixed point. +Coordinate reindexing transports the result to every nonempty finite index type. +-/ + +open Filter +open scoped Topology + +namespace Tingley + +/-- Every continuous self-map of a probability simplex with `m + 1` coordinates has a fixed +point. The construction includes `m = 0`, the one-point simplex. -/ +theorem continuous_fin_probabilitySimplex_fixedPoint (m : ℕ) + (P : ProbabilitySimplex (Fin (m + 1)) → ProbabilitySimplex (Fin (m + 1))) + (hP : Continuous P) : ∃ a, P a = a := by + classical + let point : (k : ℕ) → IterVertex m k → ProbabilitySimplex (Fin (m + 1)) := + fun k v => ⟨iterPoint m k v, iterPoint_mem_stdSimplex m k v⟩ + let label : (k : ℕ) → IterVertex m k → Fin (m + 1) := + fun k v => Classical.choose + (exists_positive_dominating_coordinate (point k v) (P (point k v))) + have hlabel (k : ℕ) (v : IterVertex m k) : + 0 < (point k v).val (label k v) ∧ + (P (point k v)).val (label k v) ≤ (point k v).val (label k v) := + Classical.choose_spec + (exists_positive_dominating_coordinate (point k v) (P (point k v))) + have hcarrier (k : ℕ) (v : IterVertex m k) : label k v ∈ iterCarrier m k v := + (iterPoint_pos_iff m k v (label k v)).mp (hlabel k v).1 + have hcells (k : ℕ) : + ∃ s, s ∈ topCells m k ∧ s.image (label k) = Finset.univ := + iterated_sperner_exists m k (label k) (hcarrier k) + let cell (k : ℕ) : Finset (IterVertex m k) := Classical.choose (hcells k) + have hcell_mem (k : ℕ) : cell k ∈ topCells m k := + (Classical.choose_spec (hcells k)).1 + have hcell_labels (k : ℕ) : (cell k).image (label k) = Finset.univ := + (Classical.choose_spec (hcells k)).2 + have hvertices (k : ℕ) (i : Fin (m + 1)) : + ∃ v, v ∈ cell k ∧ label k v = i := by + apply Finset.mem_image.mp + rw [hcell_labels k] + exact Finset.mem_univ i + let vertex (k : ℕ) (i : Fin (m + 1)) : IterVertex m k := + Classical.choose (hvertices k i) + have hvertex_mem (k : ℕ) (i : Fin (m + 1)) : vertex k i ∈ cell k := + (Classical.choose_spec (hvertices k i)).1 + have hvertex_label (k : ℕ) (i : Fin (m + 1)) : label k (vertex k i) = i := + (Classical.choose_spec (hvertices k i)).2 + let a : ℕ → Fin (m + 1) → ProbabilitySimplex (Fin (m + 1)) := + fun k i => point k (vertex k i) + have hden : (0 : ℝ) < (m : ℝ) + 1 := + add_pos_of_nonneg_of_pos (Nat.cast_nonneg m) zero_lt_one + have hq₀ : (0 : ℝ) ≤ (m : ℝ) / ((m : ℝ) + 1) := + div_nonneg (Nat.cast_nonneg m) hden.le + have hq₁ : (m : ℝ) / ((m : ℝ) + 1) < 1 := + (div_lt_one hden).mpr (lt_add_of_pos_right (m : ℝ) zero_lt_one) + apply probabilitySimplex_fixedPoint_of_shrinking_family P hP a + (fun k => ((m : ℝ) / ((m : ℝ) + 1)) ^ k) + (tendsto_pow_atTop_nhds_zero_of_lt_one hq₀ hq₁) + · intro k i j + change dist (iterPoint m k (vertex k i)) (iterPoint m k (vertex k j)) ≤ + ((m : ℝ) / ((m : ℝ) + 1)) ^ k + rw [dist_eq_norm] + exact iterPoint_mesh m k (cell k) (mem_topCells.mp (hcell_mem k)).1 + (vertex k i) (hvertex_mem k i) (vertex k j) (hvertex_mem k j) + · intro k i + change (P (point k (vertex k i))).val i ≤ (point k (vertex k i)).val i + simpa only [hvertex_label k i] using (hlabel k (vertex k i)).2 + +/-- Every continuous self-map of a probability simplex indexed by a nonempty finite type has +a fixed point. All geometric and finite-incidence inputs are discharged by the finite theorem. -/ +theorem continuous_probabilitySimplex_fixedPoint + {ι : Type*} [Fintype ι] [Nonempty ι] + (P : ProbabilitySimplex ι → ProbabilitySimplex ι) (hP : Continuous P) : + ∃ a, P a = a := by + classical + let m := Fintype.card ι - 1 + have hc : Fintype.card ι = m + 1 := by + dsimp [m] + exact (Nat.sub_add_cancel (Nat.succ_le_of_lt + (Fintype.card_pos : 0 < Fintype.card ι))).symm + let e : ι ≃ Fin (m + 1) := Fintype.equivFinOfCardEq hc + let h := probabilitySimplexReindex e + let Q : ProbabilitySimplex (Fin (m + 1)) → ProbabilitySimplex (Fin (m + 1)) := + fun b => h (P (h.symm b)) + have hQ : Continuous Q := + h.continuous.comp (hP.comp h.symm.continuous) + obtain ⟨b, hb⟩ := continuous_fin_probabilitySimplex_fixedPoint m Q hQ + refine ⟨h.symm b, ?_⟩ + simpa only [Q, Homeomorph.symm_apply_apply] using congrArg h.symm hb + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SimplexLimit.lean b/lean/OAI/Analysis/SphereIsometry/SimplexLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ff6e6a5a9a3c38473061a3ab70f2f42051b9da9 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SimplexLimit.lean @@ -0,0 +1,99 @@ +import OAI.Analysis.SphereIsometry.ProbabilitySimplex +import Mathlib.Analysis.Convex.Topology +import Mathlib.Topology.MetricSpace.Pseudo.Lemmas +import Mathlib.Topology.Sequences + +namespace OAI + +/-! +# Extracting a fixed point from shrinking labelled simplex cells + +The analytic limit step of the simplex fixed-point argument starts with +a concrete family of simplex points, one for each coordinate at every subdivision level. +The finite Sperner argument supplies this family, and the subdivision estimates supply its +shrinking diameter. No fixed-point principle is assumed here. +-/ + +open Filter +open scoped BigOperators Topology + +namespace Tingley + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +/-- Relabelling the coordinates is a homeomorphism of probability simplexes. -/ +def probabilitySimplexReindex (e : ι ≃ κ) : ProbabilitySimplex ι ≃ₜ ProbabilitySimplex κ where + toFun x := + ⟨fun j => x.val (e.symm j), + ⟨fun j => x.property.1 _, (e.symm.sum_comp x.val).trans x.property.2⟩⟩ + invFun y := + ⟨fun i => y.val (e i), + ⟨fun i => y.property.1 _, (e.sum_comp y.val).trans y.property.2⟩⟩ + left_inv x := by + apply Subtype.ext + funext i + exact congrArg x.val (e.symm_apply_apply i) + right_inv y := by + apply Subtype.ext + funext j + exact congrArg y.val (e.apply_symm_apply j) + continuous_toFun := by + apply Continuous.subtype_mk + exact continuous_pi fun j => + (continuous_apply (e.symm j)).comp continuous_subtype_val + continuous_invFun := by + apply Continuous.subtype_mk + exact continuous_pi fun i => + (continuous_apply (e i)).comp continuous_subtype_val + +@[simp] +theorem probabilitySimplexReindex_apply_val (e : ι ≃ κ) (x : ProbabilitySimplex ι) (j : κ) : + (probabilitySimplexReindex e x).val j = x.val (e.symm j) := rfl + +@[simp] +theorem probabilitySimplexReindex_symm_apply_val (e : ι ≃ κ) (y : ProbabilitySimplex κ) (i : ι) : + ((probabilitySimplexReindex e).symm y).val i = y.val (e i) := rfl + +variable [Nonempty ι] + +/-- Coordinate inequalities at points in shrinking cells produce an actual fixed point. + +Only one sequence is passed to compactness. The mesh estimate forces all the coordinate-labelled +sequences along that same subsequence to converge to the same simplex point. -/ +theorem probabilitySimplex_fixedPoint_of_shrinking_family + (P : ProbabilitySimplex ι → ProbabilitySimplex ι) (hP : Continuous P) + (a : ℕ → ι → ProbabilitySimplex ι) (δ : ℕ → ℝ) + (hδ : Tendsto δ atTop (𝓝 0)) + (hmesh : ∀ k i j, dist (a k i) (a k j) ≤ δ k) + (hcoordinate : ∀ k i, (P (a k i)).val i ≤ (a k i).val i) : + ∃ x, P x = x := by + classical + let i₀ : ι := Classical.choice inferInstance + obtain ⟨x, φ, hφ, hx⟩ := CompactSpace.tendsto_subseq (fun k => a k i₀) + have hδφ : Tendsto (fun k => δ (φ k)) atTop (𝓝 0) := + hδ.comp hφ.tendsto_atTop + have ha : ∀ i, Tendsto (fun k => a (φ k) i) atTop (𝓝 x) := by + intro i + apply hx.congr_dist + exact squeeze_zero (fun _ => dist_nonneg) + (fun k => hmesh (φ k) i₀ i) hδφ + have hle : ∀ i, (P x).val i ≤ x.val i := by + intro i + have hc : Continuous (fun y : ProbabilitySimplex ι => y.val i) := + (continuous_apply i).comp continuous_subtype_val + exact le_of_tendsto_of_tendsto' + (((hc.comp hP).tendsto x).comp (ha i)) + ((hc.tendsto x).comp (ha i)) + (fun k => hcoordinate (φ k) i) + have hsum : (∑ i, (x.val i - (P x).val i)) = 0 := by + rw [Finset.sum_sub_distrib, x.property.2, (P x).property.2, sub_self] + have hzero : ∀ i ∈ Finset.univ, x.val i - (P x).val i = 0 := + (Finset.sum_eq_zero_iff_of_nonneg (fun i _ => sub_nonneg.mpr (hle i))).mp hsum + refine ⟨x, ?_⟩ + apply Subtype.ext + funext i + exact (sub_eq_zero.mp (hzero i (Finset.mem_univ i))).symm + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SmallChord.lean b/lean/OAI/Analysis/SphereIsometry/SmallChord.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fc08d1115a87daa59eaefea7246628aaa32a3bf --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SmallChord.lean @@ -0,0 +1,161 @@ +import Mathlib.Analysis.Normed.Module.RCLike.Real +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Module + +namespace OAI + +/-! +# The small-chord contradiction + +The scalar estimates imply nonnegative coefficients in two exact identities +between the actual chord vectors. Applying the norm triangle inequality to +those identities contradicts preservation of the distance between the base +point and the opposite endpoint. No convexity or monotonicity property of an +abstract auxiliary function is assumed. +-/ + +namespace Tingley + +/-- The two small-regime estimates and the strict chord imbalance force the +radial deficit to be strictly below one half. -/ +theorem smallChord_epsilon_lt_half {A B d ε : ℝ} + (hA : 0 < A) (hB : 0 < B) (hAB : A + B < 1) (hd : d ≤ 2) + (heA : ε ≤ d * A * (1 - B)) (heB : ε ≤ d * B * (1 - A)) : + ε < 1 / 2 := by + have step (a b : ℝ) (ha : 0 < a) (hab : a ≤ b) (hsum : a + b < 1) + (he : ε ≤ d * a * (1 - b)) : ε < 1 / 2 := by + have hahalf : a < 1 / 2 := by linarith + have hb1 : b < 1 := by linarith + have hprod0 : 0 ≤ a * (1 - b) := + mul_nonneg ha.le (sub_nonneg.mpr hb1.le) + have hprod : a * (1 - b) ≤ a * (1 - a) := + mul_le_mul_of_nonneg_left (by linarith) ha.le + have hsquare : 0 < (1 / 2 - a) ^ 2 := + sq_pos_of_pos (by linarith) + have hquarter : a * (1 - b) < 1 / 4 := by nlinarith + have hscale : d * (a * (1 - b)) ≤ 2 * (a * (1 - b)) := + mul_le_mul_of_nonneg_right hd hprod0 + nlinarith [he, hscale, hquarter] + rcases le_total A B with h | h + · exact step A B hA h hAB heA + · exact step B A hB h (by linarith) heB + +/-- The scalar conclusions needed by the two actual vector identities. +The second coefficient is permitted to vanish. -/ +theorem smallChord_coefficients {A B d ε t p r s u : ℝ} + (hA : 0 < A) (hB : 0 < B) (hAB : A + B < 1) + (hd : 0 < d) (hd2 : d ≤ 2) (hεt : ε + t = 1) + (hdr : d = p + r) (hds : d = s + u) + (hpA : p = d * A) (huB : u = d * B) + (hAe : A ≤ ε) (hBe : B ≤ ε) + (heA : ε ≤ d * A * (1 - B)) (heB : ε ≤ d * B * (1 - A)) : + ε < 1 / 2 ∧ 0 < r * t - p * ε ∧ 0 ≤ s * ε - u * t ∧ p < s := by + have hehalf := smallChord_epsilon_lt_half hA hB hAB hd2 heA heB + have hAt : A < t := by linarith + have hr : r = d - p := by linarith + have hs : s = d - u := by linarith + have he : ε = 1 - t := by linarith + have ht : t = 1 - ε := by linarith + have hα : r * t - p * ε = d * (t - A) := by + rw [hr, hpA, he] + ring + have hβ : s * ε - u * t = d * (ε - B) := by + rw [hs, huB, ht] + ring + have hgap : s - p = d * (1 - A - B) := by + rw [hs, hpA, huB] + ring + refine ⟨hehalf, ?_, ?_, ?_⟩ + · rw [hα] + exact mul_pos hd (sub_pos.mpr hAt) + · rw [hβ] + exact mul_nonneg hd.le (sub_nonneg.mpr hBe) + · have hgap_pos : 0 < s - p := by + rw [hgap] + exact mul_pos hd (by linarith) + linarith + +/-- Two norm triangle inequalities on the actual chord vectors are incompatible +with the chord imbalance and the preserved base-to-endpoint distance. -/ +theorem smallChord_norm_contradiction + {X Y : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] + (y v : X) (b w : Y) {t ε p r s u d : ℝ} + (hεt : ε + t = 1) (hε : 0 < ε) (hd : 0 < d) + (hp : 0 < p) (hr : 0 < r) (hs : 0 < s) (hu : 0 < u) + (hdr : d = p + r) (hds : d = s + u) (hps : p < s) + (hy : ‖y‖ = 1) (hb : ‖b‖ = 1) + (hx : ‖t • y + p • v‖ = 1) (hfx : ‖t • b + s • w‖ = 1) + (hα : 0 ≤ r * t - p * ε) (hβ : 0 ≤ s * ε - u * t) + (hiso : ‖ε • y + r • v‖ = ‖ε • b + u • w‖) : False := by + let V : X := ε • y + r • v + let W : Y := ε • b + u • w + have hVW : ‖V‖ = ‖W‖ := hiso + have hleftId : r • (t • y + p • v) = p • V + (r * t - p * ε) • y := by + dsimp only [V] + module + have hrightId : s • W = u • (t • b + s • w) + (s * ε - u * t) • b := by + dsimp only [W] + module + have hleft : r ≤ p * ‖V‖ + (r * t - p * ε) := by + calc + r = ‖r • (t • y + p • v)‖ := by + rw [norm_smul_of_nonneg hr.le, hx, mul_one] + _ = ‖p • V + (r * t - p * ε) • y‖ := congrArg norm hleftId + _ ≤ ‖p • V‖ + ‖(r * t - p * ε) • y‖ := norm_add_le _ _ + _ = p * ‖V‖ + (r * t - p * ε) := by + rw [norm_smul_of_nonneg hp.le, norm_smul_of_nonneg hα, hy, mul_one] + have hright : s * ‖W‖ ≤ u + (s * ε - u * t) := by + calc + s * ‖W‖ = ‖s • W‖ := (norm_smul_of_nonneg hs.le W).symm + _ = ‖u • (t • b + s • w) + (s * ε - u * t) • b‖ := congrArg norm hrightId + _ ≤ ‖u • (t • b + s • w)‖ + ‖(s * ε - u * t) • b‖ := norm_add_le _ _ + _ = u + (s * ε - u * t) := by + simp only [norm_smul_of_nonneg hu.le, norm_smul_of_nonneg hβ, hfx, hb, mul_one] + have ht : t = 1 - ε := by linarith + have hrearrange : r - (r * t - p * ε) = ε * d := by + rw [ht, hdr] + ring + have hurearrange : u + (s * ε - u * t) = ε * d := by + rw [ht, hds] + ring + have hlower : ε * d ≤ p * ‖V‖ := by linarith + have hupper : s * ‖V‖ ≤ ε * d := by rw [hVW]; linarith + have hpositive : 0 < ε * d := mul_pos hε hd + have hVpos : 0 < ‖V‖ := by + by_contra h + have hVnonpos : ‖V‖ ≤ 0 := le_of_not_gt h + have hpV : p * ‖V‖ ≤ 0 := mul_nonpos_of_nonneg_of_nonpos hp.le hVnonpos + linarith + exact (not_lt_of_ge (hupper.trans hlower)) (mul_lt_mul_of_pos_right hps hVpos) + +/-- The small regime contradicts preservation of the actual opposite-endpoint +distance. All scalar guards of the norm argument are derived here. -/ +theorem smallChord_contradiction + {X Y : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] + (y v : X) (b w : Y) {t ε p r s u d A B : ℝ} + (ht1 : t < 1) (he : ε = 1 - t) + (hp : 0 < p) (hr : 0 < r) (hs : 0 < s) (hu : 0 < u) + (hdr : d = p + r) (hds : d = s + u) (hd2 : d ≤ 2) + (hA : A = p / d) (hB : B = u / d) (hAB : A + B < 1) + (hAe : A ≤ ε) (hBe : B ≤ ε) + (heA : ε ≤ d * A * (1 - B)) (heB : ε ≤ d * B * (1 - A)) + (hy : ‖y‖ = 1) (hb : ‖b‖ = 1) + (hx : ‖t • y + p • v‖ = 1) (hfx : ‖t • b + s • w‖ = 1) + (hiso : ‖ε • y + r • v‖ = ‖ε • b + u • w‖) : False := by + have hd : 0 < d := by rw [hdr]; exact add_pos hp hr + have hApos : 0 < A := by rw [hA]; exact div_pos hp hd + have hBpos : 0 < B := by rw [hB]; exact div_pos hu hd + have hpA : p = d * A := by rw [hA, mul_div_cancel₀ p (ne_of_gt hd)] + have huB : u = d * B := by rw [hB, mul_div_cancel₀ u (ne_of_gt hd)] + have hεt : ε + t = 1 := by linarith + have hε : 0 < ε := by linarith + obtain ⟨_, hα, hβ, hps⟩ := smallChord_coefficients hApos hBpos hAB hd hd2 hεt + hdr hds hpA huB hAe hBe heA heB + exact smallChord_norm_contradiction y v b w hεt hε hd hp hr hs hu hdr hds hps + hy hb hx hfx hα.le hβ hiso + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/Sperner.lean b/lean/OAI/Analysis/SphereIsometry/Sperner.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cc48fcad62b0dd929f0ff573870ab601224d629 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Sperner.lean @@ -0,0 +1,107 @@ +import OAI.Analysis.SphereIsometry.SpernerIncidence +import OAI.Analysis.SphereIsometry.SpernerBoundary +import OAI.Analysis.SphereIsometry.SubdivisionRestriction +import OAI.Analysis.SphereIsometry.SubdivisionIncidence +import OAI.Analysis.SphereIsometry.BarycentricZero + +namespace OAI + +/-! +# Geometric Sperner parity for the concrete iterated subdivisions + +The labels belong to the actual recursively constructed vertex carriers. +The incidence theorem and the exact original-face restriction discharge the +finite counting hypotheses. Induction on dimension proves an odd number of +fully labelled top cells at every subdivision depth. +-/ + +namespace Tingley + +theorem iterated_sperner_odd (m k : ℕ) + (label : IterVertex m k → Fin (m + 1)) + (hlabel : ∀ v, label v ∈ iterCarrier m k v) : + Odd (((topCells m k).filter + (fun σ => σ.image label = Finset.univ)).card) := by + classical + induction m with + | zero => + have hfull : ∀ σ ∈ topCells 0 k, σ.image label = Finset.univ := by + intro σ hσ + have hcard : σ.card = 1 := (mem_topCells.mp hσ).2 + have hne : σ.Nonempty := Finset.card_pos.mp (by rw [hcard]; exact Nat.zero_lt_one) + obtain ⟨v, hv⟩ := hne + apply Finset.eq_univ_iff_forall.mpr + intro i + refine Finset.mem_image.mpr ⟨v, hv, ?_⟩ + apply Fin.ext + exact (Nat.lt_one_iff.mp (label v).isLt).trans + (Nat.lt_one_iff.mp i.isLt).symm + have hfilter : (topCells 0 k).filter + (fun σ => σ.image label = Finset.univ) = topCells 0 k := + Finset.filter_eq_self.mpr hfull + rw [hfilter, iter_topCells_zero_card] + exact ⟨0, rfl⟩ + | succ m ih => + let e := lastFaceEmbedding m k + have hne : ∀ v, label (e v) ≠ Fin.last (m + 1) := by + intro v hv + have hlast : Fin.last (m + 1) ∉ iterCarrier (m + 1) k (e v) := + (lastFace_range_iff m k (e v)).mpr ⟨v, rfl⟩ + exact hlast (hv ▸ hlabel (e v)) + let lowerLabel : IterVertex m k → Fin (m + 1) := + spernerRestrictedLabel e label hne + have hcast : ∀ v, label (e v) = (lowerLabel v).castSucc := + fun v => (castSucc_spernerRestrictedLabel e label hne v).symm + have hlower : ∀ v, lowerLabel v ∈ iterCarrier m k v := by + apply restricted_label_mem_carrier e label hne (iterCarrier m k) + intro v + have h := hlabel (e v) + change label (lastFaceEmbedding m k v) ∈ + iterCarrier (m + 1) k (lastFaceEmbedding m k v) at h + rw [lastFace_carrier] at h + simpa only [e, Finset.map_eq_image, Fin.coe_castSuccEmb] using h + have hboundaryCard : + (((codimFaces (m + 1) k).filter + (fun τ => τ.image label = spernerSmallLabels (m + 1) ∧ + (faceCarrier (m + 1) k τ).card = m + 1)).card) = + (((topCells m k).filter + (fun σ => σ.image lowerLabel = Finset.univ)).card) := by + change (((codimFaces (m + 1) k).filter + (fun τ => τ.image label = spernerSmallLabels (m + 1) ∧ + (τ.biUnion (iterCarrier (m + 1) k)).card = m + 1)).card) = _ + rw [good_boundary_filter_eq_last_face_filter label + (iterCarrier (m + 1) k) (codimFaces (m + 1) k) hlabel] + exact mapped_good_family_card_of_map e label lowerLabel hcast + (topCells m k) + ((codimFaces (m + 1) k).filter + (fun τ => Fin.last (m + 1) ∉ faceCarrier (m + 1) k τ)) + (lastFace_top_image m k).symm + apply FiniteComplex.sperner_odd_of_boundary_odd + (iterData (Fin ((m + 1) + 1)) k).complex (m + 1) label + (fun τ => (faceCarrier (m + 1) k τ).card = m + 1) + · intro τ hτ + exact incidentTop_card_eq_if_boundary (Nat.succ_pos m) hτ + · change Odd (((codimFaces (m + 1) k).filter + (fun τ => τ.image label = spernerSmallLabels (m + 1) ∧ + (faceCarrier (m + 1) k τ).card = m + 1)).card) + rw [hboundaryCard] + exact ih lowerLabel hlower + +/-- Each actual subdivision contains an actual fully labelled top cell. -/ +theorem iterated_sperner_exists (m k : ℕ) + (label : IterVertex m k → Fin (m + 1)) + (hlabel : ∀ v, label v ∈ iterCarrier m k v) : + ∃ σ, σ ∈ topCells m k ∧ σ.image label = Finset.univ := by + classical + have hodd := iterated_sperner_odd m k label hlabel + have hcard : ((topCells m k).filter + (fun σ => σ.image label = Finset.univ)).card ≠ 0 := by + intro hzero + rw [hzero] at hodd + simp at hodd + obtain ⟨σ, hσ⟩ := Finset.card_ne_zero.mp hcard + exact ⟨σ, (Finset.mem_filter.mp hσ).1, (Finset.mem_filter.mp hσ).2⟩ + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SpernerBoundary.lean b/lean/OAI/Analysis/SphereIsometry/SpernerBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc72c8267cdad22d2965a158eb9f96922534b209 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SpernerBoundary.lean @@ -0,0 +1,227 @@ +import OAI.Analysis.SphereIsometry.SpernerFacet +import Mathlib.Data.Fin.Basic +import Mathlib.Data.Finset.Union + +namespace OAI + +/-! +# Boundary labels and restriction of the finite Sperner count + +Admissible labels lie in the union of the vertex carriers. A good boundary +facet therefore has exactly the carrier omitting the last coordinate. Mapping +lower-dimensional faces through a vertex embedding preserves the label count +after the coordinate embedding `Fin.castSucc`. +-/ + +namespace Tingley + +variable {V W I : Type*} [DecidableEq V] [DecidableEq W] [DecidableEq I] + +omit [DecidableEq V] in +/-- Vertexwise carrier membership implies membership in the face carrier. -/ +theorem sperner_label_image_subset_carrier (label : V → I) + (carrier : V → Finset I) (σ : Finset V) + (hlabel : ∀ v ∈ σ, label v ∈ carrier v) : + σ.image label ⊆ σ.biUnion carrier := by + intro i hi + obtain ⟨v, hv, rfl⟩ := Finset.mem_image.mp hi + exact Finset.mem_biUnion.mpr ⟨v, hv, hlabel v hv⟩ + +omit [DecidableEq V] in +/-- A good boundary facet can only lie on the original face missing the last +coordinate. The conclusion follows from containment and equal cardinality. -/ +theorem carrier_eq_spernerSmallLabels {m : ℕ} (label : V → Fin (m + 1)) + (carrier : V → Finset (Fin (m + 1))) (σ : Finset V) + (hlabel : ∀ v ∈ σ, label v ∈ carrier v) + (hgood : σ.image label = spernerSmallLabels m) + (hcard : (σ.biUnion carrier).card = m) : + σ.biUnion carrier = spernerSmallLabels m := by + have hsub : spernerSmallLabels m ⊆ σ.biUnion carrier := by + rw [← hgood] + exact sperner_label_image_subset_carrier label carrier σ hlabel + exact (Finset.eq_of_subset_of_card_le hsub + (by rw [hcard, card_spernerSmallLabels])).symm + +omit [DecidableEq V] in +/-- For a good face, the boundary cardinality condition is equivalent to +omission of the last coordinate from its carrier. -/ +theorem good_carrier_card_iff_last_not_mem {m : ℕ} (label : V → Fin (m + 1)) + (carrier : V → Finset (Fin (m + 1))) (σ : Finset V) + (hlabel : ∀ v ∈ σ, label v ∈ carrier v) + (hgood : σ.image label = spernerSmallLabels m) : + (σ.biUnion carrier).card = m ↔ Fin.last m ∉ σ.biUnion carrier := by + constructor + · intro hcard + rw [carrier_eq_spernerSmallLabels label carrier σ hlabel hgood hcard] + simp + · intro hlast + have hsub : σ.biUnion carrier ⊆ spernerSmallLabels m := by + intro i hi + apply mem_spernerSmallLabels.mpr + intro hilast + exact hlast (hilast ▸ hi) + have hsup : spernerSmallLabels m ⊆ σ.biUnion carrier := by + rw [← hgood] + exact sperner_label_image_subset_carrier label carrier σ hlabel + rw [Finset.Subset.antisymm hsub hsup, card_spernerSmallLabels] + +omit [DecidableEq V] in +/-- Among good faces, all boundary faces are exactly those on the last face. +This is the filter identity used before transporting the incidence count. -/ +theorem good_boundary_filter_eq_last_face_filter {m : ℕ} + (label : V → Fin (m + 1)) (carrier : V → Finset (Fin (m + 1))) + (faces : Finset (Finset V)) (hlabel : ∀ v, label v ∈ carrier v) : + faces.filter (fun σ => σ.image label = spernerSmallLabels m ∧ + (σ.biUnion carrier).card = m) = + (faces.filter (fun σ => Fin.last m ∉ σ.biUnion carrier)).filter + (fun σ => σ.image label = spernerSmallLabels m) := by + classical + ext σ + simp only [Finset.mem_filter] + constructor + · rintro ⟨hσ, hg, hc⟩ + exact ⟨⟨hσ, (good_carrier_card_iff_last_not_mem label carrier σ + (fun v _ => hlabel v) hg).mp hc⟩, hg⟩ + · rintro ⟨⟨hσ, hl⟩, hg⟩ + exact ⟨hσ, hg, (good_carrier_card_iff_last_not_mem label carrier σ + (fun v _ => hlabel v) hg).mpr hl⟩ + +/-- Remove the last coordinate from labels on an embedded boundary face. -/ +def spernerRestrictedLabel {n : ℕ} (e : W ↪ V) (label : V → Fin (n + 1)) + (hne : ∀ w, label (e w) ≠ Fin.last n) : W → Fin n := + fun w => (label (e w)).castPred (hne w) + +omit [DecidableEq V] [DecidableEq W] in +@[simp] theorem castSucc_spernerRestrictedLabel {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (hne : ∀ w, label (e w) ≠ Fin.last n) (w : W) : + (spernerRestrictedLabel e label hne w).castSucc = label (e w) := + Fin.castSucc_castPred _ _ + +/-- The smaller label set is exactly the image of the smaller coordinate type. -/ +theorem image_univ_castSucc_eq_spernerSmallLabels (n : ℕ) : + (Finset.univ : Finset (Fin n)).image Fin.castSucc = spernerSmallLabels n := by + ext i + constructor + · intro hi + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hi + exact mem_spernerSmallLabels.mpr j.castSucc_ne_last + · intro hi + obtain ⟨j, hj⟩ := Fin.eq_castSucc_of_ne_last (mem_spernerSmallLabels.mp hi) + exact Finset.mem_image.mpr ⟨j, Finset.mem_univ _, hj⟩ + +omit [DecidableEq W] in +/-- Compatible vertex and coordinate embeddings commute with the label image. -/ +theorem mapped_label_image_eq {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (lowerLabel : W → Fin n) + (hlabel : ∀ w, label (e w) = (lowerLabel w).castSucc) (σ : Finset W) : + (σ.map e).image label = (σ.image lowerLabel).image Fin.castSucc := by + rw [Finset.map_eq_image, Finset.image_image, Finset.image_image] + apply Finset.image_congr + intro w _ + exact hlabel w + +omit [DecidableEq W] in +/-- A mapped face is good exactly when its lower-dimensional face is full. -/ +theorem mapped_fully_labelled_iff {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (lowerLabel : W → Fin n) + (hlabel : ∀ w, label (e w) = (lowerLabel w).castSucc) (σ : Finset W) : + (σ.map e).image label = spernerSmallLabels n ↔ + σ.image lowerLabel = Finset.univ := by + rw [mapped_label_image_eq e label lowerLabel hlabel σ, + ← image_univ_castSucc_eq_spernerSmallLabels n] + exact Finset.image_inj (Fin.castSucc_injective n) + +omit [DecidableEq V] [DecidableEq W] in +/-- Restricting an admissible embedded label preserves membership in the +lower-dimensional carrier. -/ +theorem restricted_label_mem_carrier {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (hne : ∀ w, label (e w) ≠ Fin.last n) + (carrier : W → Finset (Fin n)) + (hlabel : ∀ w, label (e w) ∈ (carrier w).image Fin.castSucc) (w : W) : + spernerRestrictedLabel e label hne w ∈ carrier w := by + obtain ⟨i, hi, hieq⟩ := Finset.mem_image.mp (hlabel w) + have heq : i = spernerRestrictedLabel e label hne w := + Fin.castSucc_injective n + (hieq.trans (castSucc_spernerRestrictedLabel e label hne w).symm) + simpa only [heq] using hi + +omit [DecidableEq W] in +/-- A finite family of faces can be filtered before or after an injective +vertex map, without changing its cardinality. -/ +theorem mapped_family_filter_card (e : W ↪ V) + (lowerFamily : Finset (Finset W)) (higherFamily : Finset (Finset V)) + (p : Finset W → Prop) (q : Finset V → Prop) + [DecidablePred p] [DecidablePred q] + (hfamily : higherFamily = lowerFamily.image (fun σ => σ.map e)) + (hpred : ∀ σ ∈ lowerFamily, q (σ.map e) ↔ p σ) : + (higherFamily.filter q).card = (lowerFamily.filter p).card := by + classical + have hfilter : lowerFamily.filter (fun σ => q (σ.map e)) = lowerFamily.filter p := + Finset.filter_congr hpred + rw [hfamily, Finset.filter_image, hfilter] + exact Finset.card_image_of_injective _ (Finset.map_injective e) + +omit [DecidableEq W] in +/-- Exact transport of the good-face count under a raw face-family bijection. -/ +theorem mapped_good_family_card {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (lowerLabel : W → Fin n) + (hlabel : ∀ w, label (e w) = (lowerLabel w).castSucc) + (lowerFamily : Finset (Finset W)) (higherFamily : Finset (Finset V)) + (hfamily : higherFamily = lowerFamily.image (fun σ => σ.map e)) : + (higherFamily.filter (fun τ => τ.image label = spernerSmallLabels n)).card = + (lowerFamily.filter (fun σ => σ.image lowerLabel = Finset.univ)).card := by + classical + exact mapped_family_filter_card e lowerFamily higherFamily _ _ hfamily + (fun σ _ => mapped_fully_labelled_iff e label lowerLabel hlabel σ) + +omit [DecidableEq W] in +/-- Count transport in the `Finset.map` form produced by the subdivision +restriction theorem. -/ +theorem mapped_good_family_card_of_map {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (lowerLabel : W → Fin n) + (hlabel : ∀ w, label (e w) = (lowerLabel w).castSucc) + (lowerFamily : Finset (Finset W)) (higherFamily : Finset (Finset V)) + (hfamily : higherFamily = lowerFamily.map (Finset.mapEmbedding e).toEmbedding) : + (higherFamily.filter (fun τ => τ.image label = spernerSmallLabels n)).card = + (lowerFamily.filter (fun σ => σ.image lowerLabel = Finset.univ)).card := by + classical + apply mapped_good_family_card e label lowerLabel hlabel lowerFamily higherFamily + calc + higherFamily = lowerFamily.map (Finset.mapEmbedding e).toEmbedding := hfamily + _ = lowerFamily.image (fun σ => σ.map e) := Finset.map_eq_image _ _ + +omit [DecidableEq W] in +/-- The same count transport with a membership characterization of the raw +boundary family, rather than an equality already assembled by the caller. -/ +theorem mapped_good_family_card_of_mem_iff {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (lowerLabel : W → Fin n) + (hlabel : ∀ w, label (e w) = (lowerLabel w).castSucc) + (lowerFamily : Finset (Finset W)) (higherFamily : Finset (Finset V)) + (hfamily : ∀ τ, τ ∈ higherFamily ↔ ∃ σ ∈ lowerFamily, σ.map e = τ) : + (higherFamily.filter (fun τ => τ.image label = spernerSmallLabels n)).card = + (lowerFamily.filter (fun σ => σ.image lowerLabel = Finset.univ)).card := by + classical + apply mapped_good_family_card e label lowerLabel hlabel lowerFamily higherFamily + ext τ + exact (hfamily τ).trans Finset.mem_image.symm + +omit [DecidableEq W] in +/-- The exact good-boundary expression used in the incidence count becomes the +fully labelled lower-dimensional expression. -/ +theorem good_boundary_family_card {n : ℕ} (e : W ↪ V) + (label : V → Fin (n + 1)) (lowerLabel : W → Fin n) + (hlabel : ∀ w, label (e w) = (lowerLabel w).castSucc) + (lowerFamily : Finset (Finset W)) (higherFamily : Finset (Finset V)) + (boundary : Finset V → Prop) [DecidablePred boundary] + (hfamily : higherFamily.filter boundary = lowerFamily.image (fun σ => σ.map e)) : + (higherFamily.filter + (fun τ => τ.image label = spernerSmallLabels n ∧ boundary τ)).card = + (lowerFamily.filter (fun σ => σ.image lowerLabel = Finset.univ)).card := by + classical + simpa only [Finset.filter_filter, and_comm] using + mapped_good_family_card e label lowerLabel hlabel lowerFamily + (higherFamily.filter boundary) hfamily + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SpernerFacet.lean b/lean/OAI/Analysis/SphereIsometry/SpernerFacet.lean new file mode 100644 index 0000000000000000000000000000000000000000..19223bcf178d75eabfc07aec95a146ad659180c5 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SpernerFacet.lean @@ -0,0 +1,219 @@ +import Mathlib.Data.Finset.Powerset +import Mathlib.Data.Fintype.Card +import Mathlib.Data.ZMod.Basic + +namespace OAI + +/-! +# The local facet count in geometric Sperner's lemma + +A simplex with `m + 1` vertices has an odd number of facets labelled by all +labels except the last precisely when the simplex is fully labelled. The +proof below identifies the good facets explicitly: one in the fully labelled +case, and two whenever a good facet exists but the simplex is not full. +-/ + +namespace Tingley + +/-- The labels on the distinguished boundary face. -/ +def spernerSmallLabels (m : ℕ) : Finset (Fin (m + 1)) := + Finset.univ.erase (Fin.last m) + +@[simp] theorem mem_spernerSmallLabels {m : ℕ} {i : Fin (m + 1)} : + i ∈ spernerSmallLabels m ↔ i ≠ Fin.last m := by + simp [spernerSmallLabels] + +@[simp] theorem card_spernerSmallLabels (m : ℕ) : + (spernerSmallLabels m).card = m := by + simp [spernerSmallLabels] + +variable {V : Type*} [DecidableEq V] {m : ℕ} + +/-- The codimension-one subsets carrying every label except the last. -/ +def spernerGoodFacets (m : ℕ) (label : V → Fin (m + 1)) (σ : Finset V) : + Finset (Finset V) := + σ.powerset.filter fun τ => τ.card = m ∧ τ.image label = spernerSmallLabels m + +omit [DecidableEq V] in +@[simp] theorem mem_spernerGoodFacets {label : V → Fin (m + 1)} + {σ τ : Finset V} : + τ ∈ spernerGoodFacets m label σ ↔ + τ ⊆ σ ∧ τ.card = m ∧ τ.image label = spernerSmallLabels m := by + simp [spernerGoodFacets] + +omit [DecidableEq V] in +/-- A good facet has one vertex of each of its labels. -/ +theorem spernerGoodFacet_injOn {label : V → Fin (m + 1)} + {σ τ : Finset V} (hτ : τ ∈ spernerGoodFacets m label σ) : + Set.InjOn label (↑τ : Set V) := by + obtain ⟨_, hc, hi⟩ := mem_spernerGoodFacets.mp hτ + apply Finset.card_image_iff.mp + rw [hi, card_spernerSmallLabels, hc] + +/-- A fully labelled simplex has exactly one distinguished good facet. -/ +theorem spernerGoodFacets_card_of_full (label : V → Fin (m + 1)) + (σ : Finset V) (hσ : σ.card = m + 1) + (hfull : σ.image label = Finset.univ) : + (spernerGoodFacets m label σ).card = 1 := by + classical + have hinj : Set.InjOn label (↑σ : Set V) := by + apply Finset.card_image_iff.mp + simp [hfull, hσ] + have hlast : Fin.last m ∈ σ.image label := by + rw [hfull] + exact Finset.mem_univ _ + obtain ⟨w, hwσ, hwlabel⟩ := Finset.mem_image.mp hlast + have hcard : (σ.erase w).card = m := by + simpa [hσ] using (Finset.card_erase_of_mem hwσ) + have himage : (σ.erase w).image label = spernerSmallLabels m := by + ext i + constructor + · intro hi + obtain ⟨v, hv, rfl⟩ := Finset.mem_image.mp hi + apply mem_spernerSmallLabels.mpr + intro hvl + exact (Finset.mem_erase.mp hv).1 + (hinj (Finset.mem_erase.mp hv).2 hwσ (hvl.trans hwlabel.symm)) + · intro hi + have hine : i ≠ Fin.last m := mem_spernerSmallLabels.mp hi + have hiσ : i ∈ σ.image label := by simp [hfull] + obtain ⟨v, hvσ, hvi⟩ := Finset.mem_image.mp hiσ + refine Finset.mem_image.mpr ⟨v, Finset.mem_erase.mpr ⟨?_, hvσ⟩, hvi⟩ + intro hvw + apply hine + calc + i = label v := hvi.symm + _ = label w := congrArg label hvw + _ = Fin.last m := hwlabel + have hgood : σ.erase w ∈ spernerGoodFacets m label σ := + mem_spernerGoodFacets.mpr ⟨Finset.erase_subset _ _, hcard, himage⟩ + have hfamily : spernerGoodFacets m label σ = {σ.erase w} := by + ext τ + constructor + · intro hτ + obtain ⟨hτσ, hτcard, hτimage⟩ := mem_spernerGoodFacets.mp hτ + have hwnot : w ∉ τ := by + intro hwτ + have hwmem : label w ∈ spernerSmallLabels m := by + rw [← hτimage] + exact Finset.mem_image.mpr ⟨w, hwτ, rfl⟩ + exact (mem_spernerSmallLabels.mp hwmem) hwlabel + have hsub : τ ⊆ σ.erase w := Finset.subset_erase.mpr ⟨hτσ, hwnot⟩ + apply Finset.mem_singleton.mpr + exact Finset.eq_of_subset_of_card_le hsub (by rw [hcard, hτcard]) + · intro hτ + have hτeq : τ = σ.erase w := Finset.mem_singleton.mp hτ + simpa [hτeq] using hgood + rw [hfamily, Finset.card_singleton] + +/-- In a non-full simplex, one good facet determines exactly two good facets. +The second is obtained by exchanging the extra vertex with its equal-label +partner in the first facet. -/ +theorem spernerGoodFacets_card_of_nonempty_not_full + (label : V → Fin (m + 1)) (σ : Finset V) (hσ : σ.card = m + 1) + (hfull : σ.image label ≠ Finset.univ) + (hne : (spernerGoodFacets m label σ).Nonempty) : + (spernerGoodFacets m label σ).card = 2 := by + classical + obtain ⟨τ, hτ⟩ := hne + obtain ⟨hτσ, hτcard, hτimage⟩ := mem_spernerGoodFacets.mp hτ + obtain ⟨w, hwτ, hwσeq⟩ := Finset.exists_eq_insert_iff.mpr + (show τ ⊆ σ ∧ τ.card + 1 = σ.card from ⟨hτσ, by rw [hτcard, hσ]⟩) + have hwσ : w ∈ σ := hwσeq ▸ Finset.mem_insert_self w τ + have hwlabel : label w ≠ Fin.last m := by + intro hwlast + apply hfull + rw [← hwσeq, Finset.image_insert, hwlast, hτimage, spernerSmallLabels] + exact Finset.insert_erase (Finset.mem_univ _) + have hwimage : label w ∈ τ.image label := by + rw [hτimage] + exact mem_spernerSmallLabels.mpr hwlabel + obtain ⟨u, huτ, hulabel⟩ := Finset.mem_image.mp hwimage + have huw : u ≠ w := by + intro huw + exact hwτ (huw ▸ huτ) + let υ : Finset V := insert w (τ.erase u) + have hwυ : w ∈ υ := Finset.mem_insert_self _ _ + have hυcard : υ.card = m := by + have hw : w ∉ τ.erase u := fun h => hwτ (Finset.erase_subset _ _ h) + dsimp only [υ] + rw [Finset.card_insert_of_notMem hw, Finset.card_erase_add_one huτ, hτcard] + have hυimage : υ.image label = spernerSmallLabels m := by + calc + υ.image label = insert (label w) ((τ.erase u).image label) := + Finset.image_insert _ _ _ + _ = insert (label u) ((τ.erase u).image label) := by rw [hulabel] + _ = (insert u (τ.erase u)).image label := (Finset.image_insert _ _ _).symm + _ = τ.image label := by rw [Finset.insert_erase huτ] + _ = spernerSmallLabels m := hτimage + have hυσ : υ ⊆ σ := by + intro v hv + rcases Finset.mem_insert.mp hv with hv | hv + · exact hv.symm ▸ hwσ + · exact hτσ (Finset.erase_subset _ _ hv) + have hυgood : υ ∈ spernerGoodFacets m label σ := + mem_spernerGoodFacets.mpr ⟨hυσ, hυcard, hυimage⟩ + have hτυ : τ ≠ υ := by + intro heq + exact hwτ (heq.symm ▸ hwυ) + have hfamily : spernerGoodFacets m label σ = {τ, υ} := by + ext η + constructor + · intro hη + obtain ⟨hησ, hηcard, _⟩ := mem_spernerGoodFacets.mp hη + have hηinsert : η ⊆ insert w τ := by simpa only [hwσeq] using hησ + by_cases hwη : w ∈ η + · have huη : u ∉ η := by + intro huη + exact huw ((spernerGoodFacet_injOn hη) huη hwη hulabel) + have hηυ : η ⊆ υ := by + intro v hvη + rcases Finset.mem_insert.mp (hηinsert hvη) with hvw | hvτ + · exact Finset.mem_insert.mpr (Or.inl hvw) + · apply Finset.mem_insert.mpr + right + apply Finset.mem_erase.mpr + refine ⟨?_, hvτ⟩ + intro hvu + exact huη (hvu ▸ hvη) + have hηeq : η = υ := Finset.eq_of_subset_of_card_le hηυ + (by rw [hυcard, hηcard]) + simp only [Finset.mem_insert, Finset.mem_singleton] + exact Or.inr hηeq + · have hητ : η ⊆ τ := by + intro v hvη + rcases Finset.mem_insert.mp (hηinsert hvη) with hvw | hvτ + · exact False.elim (hwη (hvw ▸ hvη)) + · exact hvτ + have hηeq : η = τ := Finset.eq_of_subset_of_card_le hητ + (by rw [hτcard, hηcard]) + simp only [Finset.mem_insert, Finset.mem_singleton] + exact Or.inl hηeq + · intro hη + rcases Finset.mem_insert.mp hη with hη | hη + · simpa [hη] using hτ + · have hηeq : η = υ := Finset.mem_singleton.mp hη + simpa [hηeq] using hυgood + rw [hfamily] + simp [hτυ] + +/-- The local mod-two incidence identity, valid also in dimension zero. -/ +theorem spernerGoodFacets_card_mod_two (label : V → Fin (m + 1)) + (σ : Finset V) (hσ : σ.card = m + 1) : + ((spernerGoodFacets m label σ).card : ZMod 2) = + if σ.image label = Finset.univ then 1 else 0 := by + classical + by_cases hfull : σ.image label = Finset.univ + · simpa only [ite_eq_left hfull, spernerGoodFacets_card_of_full label σ hσ hfull] + using (Nat.cast_one : ((1 : ℕ) : ZMod 2) = 1) + · rw [ite_eq_right hfull] + by_cases hne : (spernerGoodFacets m label σ).Nonempty + · simpa only [spernerGoodFacets_card_of_nonempty_not_full label σ hσ hfull hne] + using (ZMod.natCast_self 2) + · have hempty : spernerGoodFacets m label σ = ∅ := + Finset.not_nonempty_iff_eq_empty.mp hne + simp [hempty] + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SpernerIncidence.lean b/lean/OAI/Analysis/SphereIsometry/SpernerIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7366673e7167178bac3f8fa2b817bf999d5d913 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SpernerIncidence.lean @@ -0,0 +1,102 @@ +import OAI.Analysis.SphereIsometry.FiniteComplex +import OAI.Analysis.SphereIsometry.SpernerFacet +import Mathlib.Algebra.BigOperators.Ring.Finset + +namespace OAI + +/-! +# Counting labelled incidences in a finite complex + +The two orders of summation count the same actual top-cell/facet pairs. Local +facet parity leaves the fully labelled top cells on one side. Degree two +facets cancel on the other side, leaving only the degree one boundary facets. +-/ + +open scoped BigOperators + +namespace Tingley.FiniteComplex + +variable {V : Type*} [Fintype V] [DecidableEq V] + +theorem goodFacets_eq_codim_filter (K : FiniteComplex V) (m : ℕ) + (label : V → Fin (m + 1)) {σ : Finset V} (hσ : σ ∈ K.topCells m) : + (K.codimFaces m).filter + (fun τ => τ ⊆ σ ∧ τ.image label = spernerSmallLabels m) = + spernerGoodFacets m label σ := by + classical + ext τ + rw [Finset.mem_filter, mem_spernerGoodFacets] + constructor + · rintro ⟨hτ, hsub, hlabel⟩ + exact ⟨hsub, (mem_codimFaces.mp hτ).2, hlabel⟩ + · rintro ⟨hsub, hcard, hlabel⟩ + exact ⟨mem_codimFaces.mpr + ⟨K.down_closed (mem_topCells.mp hσ).1 hsub, hcard⟩, hsub, hlabel⟩ + +/-- Finite incidence parity, before the boundary restriction is identified with +the lower-dimensional simplex. All hypotheses concern finite face incidence. -/ +theorem sperner_count_mod_two (K : FiniteComplex V) (m : ℕ) + (label : V → Fin (m + 1)) (boundary : Finset V → Prop) + [DecidablePred boundary] + (hdegree : ∀ τ ∈ K.codimFaces m, + (K.incidentTop m τ).card = if boundary τ then 1 else 2) : + (((K.topCells m).filter (fun σ => σ.image label = Finset.univ)).card : ZMod 2) = + (((K.codimFaces m).filter + (fun τ => τ.image label = spernerSmallLabels m ∧ boundary τ)).card : ZMod 2) := by + classical + have hrow : ∀ σ ∈ K.topCells m, + (∑ τ ∈ K.codimFaces m, + if τ ⊆ σ ∧ τ.image label = spernerSmallLabels m then (1 : ZMod 2) else 0) = + if σ.image label = Finset.univ then 1 else 0 := by + intro σ hσ + rw [Finset.sum_boole, goodFacets_eq_codim_filter K m label hσ] + exact spernerGoodFacets_card_mod_two label σ (mem_topCells.mp hσ).2 + have hcolumn : ∀ τ ∈ K.codimFaces m, + (∑ σ ∈ K.topCells m, + if τ ⊆ σ ∧ τ.image label = spernerSmallLabels m then (1 : ZMod 2) else 0) = + if τ.image label = spernerSmallLabels m ∧ boundary τ then 1 else 0 := by + intro τ hτ + by_cases hg : τ.image label = spernerSmallLabels m + · simp only [hg, and_true, true_and] + rw [Finset.sum_boole] + change ((K.incidentTop m τ).card : ZMod 2) = if boundary τ then 1 else 0 + rw [hdegree τ hτ] + by_cases hb : boundary τ + · simp [hb] + · simp only [hb, ite_false] + exact ZMod.natCast_self 2 + · simp [hg] + calc + (((K.topCells m).filter (fun σ => σ.image label = Finset.univ)).card : ZMod 2) = + ∑ σ ∈ K.topCells m, + if σ.image label = Finset.univ then (1 : ZMod 2) else 0 := + Finset.natCast_card_filter _ _ + _ = ∑ σ ∈ K.topCells m, ∑ τ ∈ K.codimFaces m, + if τ ⊆ σ ∧ τ.image label = spernerSmallLabels m then (1 : ZMod 2) else 0 := + Finset.sum_congr rfl (fun σ hσ => (hrow σ hσ).symm) + _ = ∑ τ ∈ K.codimFaces m, ∑ σ ∈ K.topCells m, + if τ ⊆ σ ∧ τ.image label = spernerSmallLabels m then (1 : ZMod 2) else 0 := + Finset.sum_comm + _ = ∑ τ ∈ K.codimFaces m, + if τ.image label = spernerSmallLabels m ∧ boundary τ then (1 : ZMod 2) else 0 := + Finset.sum_congr rfl hcolumn + _ = (((K.codimFaces m).filter + (fun τ => τ.image label = spernerSmallLabels m ∧ boundary τ)).card : ZMod 2) := + Finset.sum_boole _ _ + +/-- An odd number of good boundary facets gives an odd number of fully labelled cells. -/ +theorem sperner_odd_of_boundary_odd (K : FiniteComplex V) (m : ℕ) + (label : V → Fin (m + 1)) (boundary : Finset V → Prop) + [DecidablePred boundary] + (hdegree : ∀ τ ∈ K.codimFaces m, + (K.incidentTop m τ).card = if boundary τ then 1 else 2) + (hboundary : Odd (((K.codimFaces m).filter + (fun τ => τ.image label = spernerSmallLabels m ∧ boundary τ)).card)) : + Odd (((K.topCells m).filter (fun σ => σ.image label = Finset.univ)).card) := by + apply ZMod.natCast_eq_one_iff_odd.mp + rw [sperner_count_mod_two K m label boundary hdegree] + exact ZMod.natCast_eq_one_iff_odd.mpr hboundary + +end Tingley.FiniteComplex + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SphereCompletion.lean b/lean/OAI/Analysis/SphereIsometry/SphereCompletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..d73ecfbcd532d9a9ff78ef480d79d5d67ee5a708 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SphereCompletion.lean @@ -0,0 +1,215 @@ +import OAI.Analysis.SphereIsometry.Basic +import Mathlib.Analysis.Normed.Module.Completion + +namespace OAI + +/-! +# Unit spheres and completion + +The unit sphere of a normed space is dense in the unit sphere of its ambient +completion. This identifies its metric completion with that completed sphere. +An actual sphere isometry and its inverse therefore extend to the completed +spheres, with exact preservation of the ambient fixed-radius defect. + +No completeness of the original spaces, compactness, or separability is used. +-/ + +noncomputable section + +open UniformSpace + +namespace Tingley + +universe u v + +variable {E : Type u} {F : Type v} +variable [NormedAddCommGroup E] [NormedSpace ℝ E] +variable [NormedAddCommGroup F] [NormedSpace ℝ F] + +/-- A unit sphere is complete when its ambient normed space is complete. -/ +instance UnitSphere.instCompleteSpace [CompleteSpace E] : CompleteSpace (UnitSphere E) := + (isClosed_eq continuous_norm continuous_const).completeSpace_coe + +/-- The canonical ambient completion embedding restricted to the unit sphere. -/ +def sphereCoe (E : Type u) [NormedAddCommGroup E] : + UnitSphere E → UnitSphere (Completion E) := fun x => + ⟨(x : E), by simpa only [Completion.norm_coe] using x.property⟩ + +omit [NormedSpace ℝ E] in +@[simp] theorem sphereCoe_val (x : UnitSphere E) : + (sphereCoe E x : Completion E) = ((x : E) : Completion E) := rfl + +theorem sphereCoe_isometry (E : Type u) [NormedAddCommGroup E] : + Isometry (sphereCoe E) := by + apply Isometry.of_dist_eq + intro x y + change dist ((x : E) : Completion E) ((y : E) : Completion E) = + dist (x : E) (y : E) + exact Completion.dist_eq (x : E) (y : E) + +private theorem norm_normalize_sub (x : E) (hx : x ≠ 0) : + ‖(normalize x hx : E) - x‖ = |1 - ‖x‖| := by + calc + _ = ‖(1 - ‖x‖) • (normalize x hx : E)‖ := by + congr 1 + rw [sub_smul, one_smul, norm_smul_normalize] + _ = |1 - ‖x‖| := by + rw [norm_smul, Real.norm_eq_abs, UnitSphere.norm_coe, mul_one] + +/-- Normalizing close old vectors proves density in the completed unit sphere. -/ +theorem sphereCoe_denseRange (E : Type u) [NormedAddCommGroup E] [NormedSpace ℝ E] : + DenseRange (sphereCoe E) := by + refine Metric.denseRange_iff.mpr ?_ + intro z ε hε + have hδ : 0 < min (1 : ℝ) (ε / 2) := lt_min zero_lt_one (by linarith) + obtain ⟨x, hdx⟩ := + (Completion.denseRange_coe : DenseRange ((↑) : E → Completion E)).exists_dist_lt + (z : Completion E) hδ + have habs : |1 - ‖x‖| ≤ dist (z : Completion E) (x : Completion E) := by + simpa only [UnitSphere.norm_coe, Completion.norm_coe, dist_eq_norm] using + abs_norm_sub_norm_le (z : Completion E) (x : Completion E) + have hnorm : 0 < ‖x‖ := by + have ha := (le_abs_self (1 - ‖x‖)).trans habs + have hb := hdx.trans_le (min_le_left (1 : ℝ) (ε / 2)) + linarith + have hx : x ≠ 0 := norm_pos_iff.mp hnorm + have hrad : dist (x : Completion E) ((normalize x hx : E) : Completion E) = + |1 - ‖x‖| := by + rw [dist_comm, Completion.dist_eq, dist_eq_norm, norm_normalize_sub] + have hsmall := hdx.trans_le (min_le_right (1 : ℝ) (ε / 2)) + refine ⟨normalize x hx, ?_⟩ + change dist (z : Completion E) ((normalize x hx : E) : Completion E) < ε + calc + _ ≤ dist (z : Completion E) (x : Completion E) + + dist (x : Completion E) ((normalize x hx : E) : Completion E) := + dist_triangle _ _ _ + _ = dist (z : Completion E) (x : Completion E) + |1 - ‖x‖| := by rw [hrad] + _ ≤ 2 * dist (z : Completion E) (x : Completion E) := by linarith + _ < ε := by linarith + +private def sphereCompletionMap (E : Type u) [NormedAddCommGroup E] : + Completion (UnitSphere E) → UnitSphere (Completion E) := + Completion.extension (sphereCoe E) + +private theorem sphereCompletionMap_isometry (E : Type u) [NormedAddCommGroup E] : + Isometry (sphereCompletionMap E) := + (sphereCoe_isometry E).completion_extension + +omit [NormedSpace ℝ E] in +private theorem sphereCompletionMap_coe (x : UnitSphere E) : + sphereCompletionMap E (x : Completion (UnitSphere E)) = sphereCoe E x := + Completion.extension_coe (sphereCoe_isometry E).uniformContinuous x + +private theorem sphereCompletionMap_surjective + (E : Type u) [NormedAddCommGroup E] [NormedSpace ℝ E] : + Function.Surjective (sphereCompletionMap E) := by + have hclosed : IsClosed (Set.range (sphereCompletionMap E)) := + (sphereCompletionMap_isometry E).isClosedEmbedding.isClosed_range + exact isClosed_property (sphereCoe_denseRange E) hclosed fun x => + ⟨(x : Completion (UnitSphere E)), sphereCompletionMap_coe x⟩ + +/-- The metric completion of the old sphere is the sphere of the ambient completion. -/ +def sphereCompletionEquiv (E : Type u) [NormedAddCommGroup E] [NormedSpace ℝ E] : + Completion (UnitSphere E) ≃ᵢ UnitSphere (Completion E) := + { Equiv.ofBijective (sphereCompletionMap E) + ⟨(sphereCompletionMap_isometry E).injective, sphereCompletionMap_surjective E⟩ with + isometry_toFun := sphereCompletionMap_isometry E } + +@[simp] theorem sphereCompletionEquiv_coe (x : UnitSphere E) : + sphereCompletionEquiv E (x : Completion (UnitSphere E)) = sphereCoe E x := + sphereCompletionMap_coe x + +@[simp] theorem sphereCompletionEquiv_symm_coe (x : UnitSphere E) : + (sphereCompletionEquiv E).symm (sphereCoe E x) = + (x : Completion (UnitSphere E)) := by + apply (sphereCompletionEquiv E).injective + simp only [IsometryEquiv.apply_symm_apply, sphereCompletionEquiv_coe] + +private def sphereIsometryCompletion (f : UnitSphere E ≃ᵢ UnitSphere F) : + Completion (UnitSphere E) ≃ᵢ Completion (UnitSphere F) where + toFun := Completion.map f + invFun := Completion.map f.symm + left_inv x := by + have h := congr_fun + (Completion.map_comp f.symm.isometry.uniformContinuous f.isometry.uniformContinuous) x + rw [f.symm_comp_self, Completion.map_id] at h + exact h + right_inv y := by + have h := congr_fun + (Completion.map_comp f.isometry.uniformContinuous f.symm.isometry.uniformContinuous) y + rw [f.self_comp_symm, Completion.map_id] at h + exact h + isometry_toFun := f.isometry.completion_map + +/-- Extend the actual sphere isometry and its inverse through the sphere completions. -/ +def completedSphereEquiv (f : UnitSphere E ≃ᵢ UnitSphere F) : + UnitSphere (Completion E) ≃ᵢ UnitSphere (Completion F) := + ((sphereCompletionEquiv E).symm.trans (sphereIsometryCompletion f)).trans + (sphereCompletionEquiv F) + +@[simp] theorem completedSphereEquiv_coe (f : UnitSphere E ≃ᵢ UnitSphere F) + (x : UnitSphere E) : + completedSphereEquiv f (sphereCoe E x) = sphereCoe F (f x) := by + change sphereCompletionEquiv F + (Completion.map f ((sphereCompletionEquiv E).symm (sphereCoe E x))) = sphereCoe F (f x) + rw [sphereCompletionEquiv_symm_coe, Completion.map_coe f.isometry.uniformContinuous, + sphereCompletionEquiv_coe] + +@[simp] theorem completedSphereEquiv_symm (f : UnitSphere E ≃ᵢ UnitSphere F) : + (completedSphereEquiv f).symm = completedSphereEquiv f.symm := by + apply IsometryEquiv.ext + intro y + rfl + +/-- The canonical ambient embedding preserves all real scalar difference norms. -/ +theorem norm_completion_sub_smul (x y : E) (q : ℝ) : + ‖(x : Completion E) - q • (y : Completion E)‖ = ‖x - q • y‖ := by + rw [← Completion.coe_smul, ← Completion.coe_sub, Completion.norm_coe] + +/-- The defect on embedded old points is preserved for every real scalar. -/ +@[simp] theorem signedDefect_completedSphereEquiv_coe + (f : UnitSphere E ≃ᵢ UnitSphere F) (q : ℝ) (x y : UnitSphere E) : + signedDefect (completedSphereEquiv f) q (sphereCoe E x) (sphereCoe E y) = + signedDefect f q x y := by + unfold signedDefect + rw [completedSphereEquiv_coe, completedSphereEquiv_coe] + simp only [sphereCoe_val, norm_completion_sub_smul] + +/-- The fixed-radius signed defect is continuous on pairs of unit points. -/ +theorem continuous_signedDefect_pair (f : UnitSphere E ≃ᵢ UnitSphere F) (q : ℝ) : + Continuous (fun p : UnitSphere E × UnitSphere E => signedDefect f q p.1 p.2) := by + have hx : Continuous (fun p : UnitSphere E × UnitSphere E => (p.1 : E)) := + continuous_subtype_val.comp continuous_fst + have hy : Continuous (fun p : UnitSphere E × UnitSphere E => (p.2 : E)) := + continuous_subtype_val.comp continuous_snd + have hfx : Continuous (fun p : UnitSphere E × UnitSphere E => (f p.1 : F)) := + continuous_subtype_val.comp (f.continuous.comp continuous_fst) + have hfy : Continuous (fun p : UnitSphere E × UnitSphere E => (f p.2 : F)) := + continuous_subtype_val.comp (f.continuous.comp continuous_snd) + exact (hfx.sub (hfy.const_smul q)).norm.sub (hx.sub (hy.const_smul q)).norm + +/-- Every fixed-radius bound passes to all pairs in the completed spheres. -/ +theorem HasDefectBound.completedSphereEquiv {f : UnitSphere E ≃ᵢ UnitSphere F} {M : ℝ} + (h : HasDefectBound f M) : HasDefectBound (completedSphereEquiv f) M := by + intro q hq x y + have hclosed : IsClosed {p : UnitSphere (Completion E) × UnitSphere (Completion E) | + |signedDefect (Tingley.completedSphereEquiv f) q p.1 p.2| ≤ M} := + isClosed_le (continuous_signedDefect_pair (Tingley.completedSphereEquiv f) q).abs continuous_const + exact isClosed_property2 + (p := fun a b : UnitSphere (Completion E) => + |signedDefect (Tingley.completedSphereEquiv f) q a b| ≤ M) + (sphereCoe_denseRange E) hclosed + (fun a b => by simpa only [signedDefect_completedSphereEquiv_coe] using h q hq a b) x y + +/-- An attained signed defect remains attained at the same embedded points and scalar. -/ +theorem attainedDefect_completedSphereEquiv (f : UnitSphere E ≃ᵢ UnitSphere F) + {q M : ℝ} {x y : UnitSphere E} (h : signedDefect f q x y = M) : + signedDefect (completedSphereEquiv f) q (sphereCoe E x) (sphereCoe E y) = M := by + rw [signedDefect_completedSphereEquiv_coe] + exact h + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SubdivisionData.lean b/lean/OAI/Analysis/SphereIsometry/SubdivisionData.lean new file mode 100644 index 0000000000000000000000000000000000000000..e04b8214e2b3fa47badf3a0ed190760ebe9f8e4e --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SubdivisionData.lean @@ -0,0 +1,128 @@ +import OAI.Analysis.SphereIsometry.BarycentricFlags + +namespace OAI + +/-! # The concrete recursively iterated subdivision of a finite simplex -/ + +noncomputable section + +namespace Tingley + +structure CarrierComplex (I : Type) [DecidableEq I] where + Vertex : Type + [vertexFintype : Fintype Vertex] + [vertexDecidableEq : DecidableEq Vertex] + complex : FiniteComplex Vertex + carrier : Vertex → Finset I + +attribute [instance] CarrierComplex.vertexFintype CarrierComplex.vertexDecidableEq + +namespace CarrierComplex + +variable {I : Type} [DecidableEq I] + +def sd (D : CarrierComplex I) : CarrierComplex I where + Vertex := FiniteComplex.FaceVertex D.complex + complex := D.complex.sd + carrier := D.complex.sdCarrier D.carrier + +def initial (I : Type) [Fintype I] [DecidableEq I] : CarrierComplex I where + Vertex := I + complex := FiniteComplex.full + carrier := fun i => {i} + +end CarrierComplex + +def iterData (I : Type) [Fintype I] [DecidableEq I] : ℕ → CarrierComplex I + | 0 => CarrierComplex.initial I + | n + 1 => (iterData I n).sd + +abbrev IterVertex (m k : ℕ) := (iterData (Fin (m + 1)) k).Vertex + +def iterComplex (m k : ℕ) : Finset (Finset (IterVertex m k)) := + (iterData (Fin (m + 1)) k).complex.faces + +def iterCarrier (m k : ℕ) : IterVertex m k → Finset (Fin (m + 1)) := + (iterData (Fin (m + 1)) k).carrier + +def topCells (m k : ℕ) : Finset (Finset (IterVertex m k)) := + (iterData (Fin (m + 1)) k).complex.topCells m + +def codimFaces (m k : ℕ) : Finset (Finset (IterVertex m k)) := + (iterData (Fin (m + 1)) k).complex.codimFaces m + +def faceCarrier (m k : ℕ) (s : Finset (IterVertex m k)) : Finset (Fin (m + 1)) := + FiniteComplex.faceCarrier (iterCarrier m k) s + +def incidentTop (m k : ℕ) (s : Finset (IterVertex m k)) : + Finset (Finset (IterVertex m k)) := + (iterData (Fin (m + 1)) k).complex.incidentTop m s + +@[simp] theorem mem_topCells {m k : ℕ} {s : Finset (IterVertex m k)} : + s ∈ topCells m k ↔ s ∈ iterComplex m k ∧ s.card = m + 1 := + FiniteComplex.mem_topCells + +@[simp] theorem mem_codimFaces {m k : ℕ} {s : Finset (IterVertex m k)} : + s ∈ codimFaces m k ↔ s ∈ iterComplex m k ∧ s.card = m := + FiniteComplex.mem_codimFaces + +@[simp] theorem mem_incidentTop {m k : ℕ} {s t : Finset (IterVertex m k)} : + t ∈ incidentTop m k s ↔ + t ∈ iterComplex m k ∧ t.card = m + 1 ∧ s ⊆ t := + FiniteComplex.mem_incidentTop + +theorem iterComplex_empty_mem (m k : ℕ) : ∅ ∈ iterComplex m k := + (iterData (Fin (m + 1)) k).complex.empty_mem + +theorem iterComplex_down_closed {m k : ℕ} {s t : Finset (IterVertex m k)} + (hs : s ∈ iterComplex m k) (ht : t ⊆ s) : t ∈ iterComplex m k := + (iterData (Fin (m + 1)) k).complex.down_closed hs ht + +theorem iterData_carrier_nonempty (I : Type) [Fintype I] [DecidableEq I] (k : ℕ) : + ∀ v : (iterData I k).Vertex, ((iterData I k).carrier v).Nonempty := by + induction k with + | zero => intro v; exact Finset.singleton_nonempty v + | succ k ih => exact FiniteComplex.sdCarrier_nonempty ih + +theorem iterData_card_le_carrier (I : Type) [Fintype I] [DecidableEq I] (k : ℕ) : + ∀ s ∈ (iterData I k).complex.faces, + s.card ≤ (FiniteComplex.faceCarrier (iterData I k).carrier s).card := by + induction k with + | zero => + intro s hs + simp [iterData, CarrierComplex.initial, FiniteComplex.faceCarrier] + exact (congrArg (fun t : Finset I => t.card) + (Finset.biUnion_singleton_eq_self (s := s))).ge + | succ k ih => + intro s hs + exact FiniteComplex.sd_card_le_carrier ih hs + +theorem iter_card_le_carrier {m k : ℕ} {s : Finset (IterVertex m k)} + (hs : s ∈ iterComplex m k) : s.card ≤ (faceCarrier m k s).card := + iterData_card_le_carrier (Fin (m + 1)) k s hs + +theorem iter_card_le {m k : ℕ} {s : Finset (IterVertex m k)} + (hs : s ∈ iterComplex m k) : s.card ≤ m + 1 := by + have h := (iter_card_le_carrier hs).trans (Finset.card_le_univ (faceCarrier m k s)) + simpa using h + +theorem top_faceCarrier {m k : ℕ} {s : Finset (IterVertex m k)} + (hs : s ∈ topCells m k) : faceCarrier m k s = Finset.univ := by + obtain ⟨hs, hcard⟩ := mem_topCells.mp hs + apply Finset.eq_of_subset_of_card_le (Finset.subset_univ _) + simpa [hcard] using iter_card_le_carrier hs + +theorem codim_faceCarrier_card {m k : ℕ} {s : Finset (IterVertex m k)} + (hs : s ∈ codimFaces m k) : + (faceCarrier m k s).card = m ∨ (faceCarrier m k s).card = m + 1 := by + obtain ⟨hs, hcard⟩ := mem_codimFaces.mp hs + have hlo := iter_card_le_carrier hs + have hhi : (faceCarrier m k s).card ≤ m + 1 := by + simpa using Finset.card_le_univ (faceCarrier m k s) + omega + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SubdivisionIncidence.lean b/lean/OAI/Analysis/SphereIsometry/SubdivisionIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..66cfd39ac73575ae86921737c389885d641ee275 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SubdivisionIncidence.lean @@ -0,0 +1,85 @@ +import OAI.Analysis.SphereIsometry.SubdivisionData +import OAI.Analysis.SphereIsometry.BarycentricIncidence + +namespace OAI + +/-! +# Incidence counts for the concrete iterated simplex + +The missing-rank alternative for an actual flag transports the old boundary +count, or gives two completions around a retained old top face. Iteration +therefore gives one incident top cell on the original boundary and two in +the interior. +-/ + +noncomputable section + +namespace Tingley + +/-- At depth zero the unique top cell is the full original vertex set. -/ +theorem incidentTop_zero_eq_singleton (m : ℕ) (s : Finset (IterVertex m 0)) : + incidentTop m 0 s = {Finset.univ} := by + classical + change Finset (Fin (m + 1)) at s + change (FiniteComplex.full : FiniteComplex (Fin (m + 1))).incidentTop m s = + {Finset.univ} + ext t + rw [FiniteComplex.mem_incidentTop, Finset.mem_singleton] + constructor + · rintro ⟨_, ht, _⟩ + exact t.eq_univ_of_card (by simpa only [Fintype.card_fin] using ht) + · rintro rfl + exact ⟨FiniteComplex.mem_full _, Finset.card_fin _, Finset.subset_univ _⟩ + +/-- The initial carrier of a face is that face itself. -/ +theorem faceCarrier_zero (m : ℕ) (s : Finset (IterVertex m 0)) : + faceCarrier m 0 s = s := by + change Finset (Fin (m + 1)) at s + change s.biUnion (fun i => {i}) = s + exact Finset.biUnion_singleton_eq_self + +/-- Actual codimension-one incidence for every positive-dimensional iterated +standard simplex. The boundary condition refers to the original coordinates. -/ +theorem incidentTop_card_eq_if_boundary {m k : ℕ} (hm : 0 < m) : + ∀ {s : Finset (IterVertex m k)}, s ∈ codimFaces m k → + (incidentTop m k s).card = + if (faceCarrier m k s).card = m then 1 else 2 := by + classical + induction k with + | zero => + intro s hs + have hcard := (mem_codimFaces.mp hs).2 + have hface : (faceCarrier m 0 s).card = m := + (congrArg (fun t : Finset (Fin (m + 1)) => t.card) + (faceCarrier_zero m s)).trans hcard + rw [incidentTop_zero_eq_singleton, Finset.card_singleton, ite_eq_left hface] + | succ k ih => + intro s hs + let K := (iterData (Fin (m + 1)) k).complex + have hK : K.CardBound m := by + intro t ht + exact iter_card_le ht + change s ∈ K.sd.codimFaces m at hs + rcases FiniteComplex.incidentTop_sd_cases hm hK hs with + ⟨hcount, T, hTs, hTcard, hmax⟩ | ⟨T, hTs, hTcard, hmax, hcount⟩ + · have hcarrier : faceCarrier m (k + 1) s = faceCarrier m k T.val := + FiniteComplex.faceCarrier_sd_eq_greatest hTs hmax + have htop : T.val ∈ topCells m k := + mem_topCells.mpr ⟨T.property.1, hTcard⟩ + have hnot : (Finset.univ : Finset (Fin (m + 1))).card ≠ m := by simp + rw [hcarrier, top_faceCarrier htop, ite_eq_right hnot] + exact hcount + · have hcarrier : faceCarrier m (k + 1) s = faceCarrier m k T.val := + FiniteComplex.faceCarrier_sd_eq_greatest hTs hmax + have hcodim : T.val ∈ codimFaces m k := + mem_codimFaces.mpr ⟨T.property.1, hTcard⟩ + calc + (incidentTop m (k + 1) s).card = (incidentTop m k T.val).card := hcount + _ = if (faceCarrier m k T.val).card = m then 1 else 2 := ih hcodim + _ = if (faceCarrier m (k + 1) s).card = m then 1 else 2 := by rw [hcarrier] + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SubdivisionPointRestriction.lean b/lean/OAI/Analysis/SphereIsometry/SubdivisionPointRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b8df6714a9a4505ba3898baaf2f2b2e0bb7c21c --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SubdivisionPointRestriction.lean @@ -0,0 +1,70 @@ +import OAI.Analysis.SphereIsometry.SubdivisionRestriction +import OAI.Analysis.SphereIsometry.IteratedPoints + +namespace OAI + +/-! # Coordinate compatibility of original-face restriction -/ + +noncomputable section + +open scoped BigOperators + +namespace Tingley + +variable {I J : Type} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] + +theorem iterDataPoint_embedding_apply (e : I ↪ J) : + ∀ (k : ℕ) (v : (iterData I k).Vertex) (i : I), + iterDataPoint J k ((iterEmbedding e k).toEmbedding v) (e i) = + iterDataPoint I k v i := by + intro k + induction k with + | zero => + intro v i + change (Pi.single (e v) 1 : J → ℝ) (e i) = (Pi.single v 1 : I → ℝ) i + by_cases h : i = v + · subst i + exact (Pi.single_eq_same (M := fun _ : J => ℝ) (e v) 1).trans + (Pi.single_eq_same (M := fun _ : I => ℝ) v 1).symm + · have he : e i ≠ e v := fun he => h (e.injective he) + exact (Pi.single_eq_of_ne (M := fun _ : J => ℝ) he 1).trans + (Pi.single_eq_of_ne (M := fun _ : I => ℝ) h 1).symm + | succ k ih => + intro v i + change finiteBarycenter (iterDataPoint J k) + (v.val.map (iterEmbedding e k).toEmbedding) (e i) = + finiteBarycenter (iterDataPoint I k) v.val i + rw [finiteBarycenter_apply, finiteBarycenter_apply, Finset.card_map] + congr 1 + rw [Finset.sum_map] + exact Finset.sum_congr rfl (fun w _ => ih w i) + +theorem iterDataPoint_embedding_eq_zero (e : I ↪ J) (k : ℕ) + (v : (iterData I k).Vertex) {j : J} (hj : j ∉ Set.range e) : + iterDataPoint J k ((iterEmbedding e k).toEmbedding v) j = 0 := by + apply le_antisymm + · apply le_of_not_gt + intro hpos + have hmem : j ∈ positiveCarrier + (iterDataPoint J k ((iterEmbedding e k).toEmbedding v)) := + mem_positiveCarrier.mpr hpos + rw [positiveCarrier_iterDataPoint, iterEmbedding_carrier] at hmem + obtain ⟨i, _, hij⟩ := Finset.mem_map.mp hmem + exact hj ⟨i, hij⟩ + · exact (iterDataPoint_mem_stdSimplex J k ((iterEmbedding e k).toEmbedding v)).1 j + +theorem lastFace_point_castSucc (m k : ℕ) (v : IterVertex m k) (i : Fin (m + 1)) : + iterPoint (m + 1) k (lastFaceEmbedding m k v) i.castSucc = iterPoint m k v i := + iterDataPoint_embedding_apply Fin.castSuccEmb k v i + +theorem lastFace_point_last (m k : ℕ) (v : IterVertex m k) : + iterPoint (m + 1) k (lastFaceEmbedding m k v) (Fin.last (m + 1)) = 0 := by + apply iterDataPoint_embedding_eq_zero Fin.castSuccEmb k v + rintro ⟨i, hi⟩ + exact Fin.castSucc_ne_last i hi + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/SubdivisionRestriction.lean b/lean/OAI/Analysis/SphereIsometry/SubdivisionRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..58eb52fa08fc47b318b1321ede29753cb7a9d6d1 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/SubdivisionRestriction.lean @@ -0,0 +1,125 @@ +import OAI.Analysis.SphereIsometry.SubdivisionData +import OAI.Analysis.SphereIsometry.BarycentricRestriction + +namespace OAI + +/-! # The exact original-face restriction of every concrete subdivision -/ + +noncomputable section + +namespace Tingley + +variable {I J : Type} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] + +def iterEmbedding (e : I ↪ J) : (k : ℕ) → + FiniteComplex.Embedding (iterData I k).complex (iterData J k).complex + | 0 => FiniteComplex.Embedding.full e + | k + 1 => (iterEmbedding e k).sd + +theorem iterEmbedding_carrier (e : I ↪ J) (k : ℕ) + (v : (iterData I k).Vertex) : + (iterData J k).carrier ((iterEmbedding e k).toEmbedding v) = + ((iterData I k).carrier v).map e := by + induction k with + | zero => + change I at v + change ({e v} : Finset J) = ({v} : Finset I).map e + exact (Finset.map_singleton e v).symm + | succ k ih => + exact (iterEmbedding e k).sdCarrier_faceMap e ih v + +theorem iterEmbedding_range_iff (e : I ↪ J) (k : ℕ) + (v : (iterData J k).Vertex) : + (iterData J k).carrier v ⊆ Finset.univ.map e ↔ + ∃ w, (iterEmbedding e k).toEmbedding w = v := by + induction k with + | zero => + change J at v + change ({v} : Finset J) ⊆ Finset.univ.map e ↔ ∃ w : I, e w = v + simp only [Finset.singleton_subset_iff, Finset.mem_map, + Finset.mem_univ, true_and] + | succ k ih => exact (iterEmbedding e k).faceMap_range_iff ih v + +theorem iterEmbedding_faceCarrier (e : I ↪ J) (k : ℕ) + (s : Finset (iterData I k).Vertex) : + FiniteComplex.faceCarrier (iterData J k).carrier + (s.map (iterEmbedding e k).toEmbedding) = + (FiniteComplex.faceCarrier (iterData I k).carrier s).map e := + (iterEmbedding e k).faceCarrier_map e (iterEmbedding_carrier e k) s + +theorem iterEmbedding_face_range_iff (e : I ↪ J) (k : ℕ) + {s : Finset (iterData J k).Vertex} (hs : s ∈ (iterData J k).complex.faces) : + FiniteComplex.faceCarrier (iterData J k).carrier s ⊆ Finset.univ.map e ↔ + ∃ t ∈ (iterData I k).complex.faces, t.map (iterEmbedding e k).toEmbedding = s := + (iterEmbedding e k).face_range_iff (iterEmbedding_range_iff e k) hs + +def lastFaceEmbedding (m k : ℕ) : IterVertex m k ↪ IterVertex (m + 1) k := + (iterEmbedding (Fin.castSuccEmb : Fin (m + 1) ↪ Fin ((m + 1) + 1)) k).toEmbedding + +theorem lastFace_carrier (m k : ℕ) (v : IterVertex m k) : + iterCarrier (m + 1) k (lastFaceEmbedding m k v) = + (iterCarrier m k v).map Fin.castSuccEmb := + iterEmbedding_carrier Fin.castSuccEmb k v + +theorem lastFace_faceCarrier (m k : ℕ) (s : Finset (IterVertex m k)) : + faceCarrier (m + 1) k (s.map (lastFaceEmbedding m k)) = + (faceCarrier m k s).map Fin.castSuccEmb := + iterEmbedding_faceCarrier Fin.castSuccEmb k s + +theorem lastFace_range_iff (m k : ℕ) (v : IterVertex (m + 1) k) : + Fin.last (m + 1) ∉ iterCarrier (m + 1) k v ↔ + ∃ w, lastFaceEmbedding m k w = v := by + have h := iterEmbedding_range_iff + (Fin.castSuccEmb : Fin (m + 1) ↪ Fin ((m + 1) + 1)) k v + simpa only [iterCarrier, lastFaceEmbedding, Finset.map_eq_image, + Fin.coe_castSuccEmb, Fin.image_castSucc, Finset.subset_compl_singleton] using h + +theorem lastFace_mem_iff (m k : ℕ) (s : Finset (IterVertex m k)) : + s.map (lastFaceEmbedding m k) ∈ iterComplex (m + 1) k ↔ s ∈ iterComplex m k := + (iterEmbedding Fin.castSuccEmb k).map_mem_iff s + +theorem lastFace_face_range_iff {m k : ℕ} {s : Finset (IterVertex (m + 1) k)} + (hs : s ∈ iterComplex (m + 1) k) : + Fin.last (m + 1) ∉ faceCarrier (m + 1) k s ↔ + ∃ t ∈ iterComplex m k, t.map (lastFaceEmbedding m k) = s := by + have h := iterEmbedding_face_range_iff + (Fin.castSuccEmb : Fin (m + 1) ↪ Fin ((m + 1) + 1)) k hs + simpa only [faceCarrier, iterCarrier, iterComplex, lastFaceEmbedding, + Finset.map_eq_image, Fin.coe_castSuccEmb, Fin.image_castSucc, + Finset.subset_compl_singleton] using h + +theorem lastFace_map_top_mem (m k : ℕ) {s : Finset (IterVertex m k)} + (hs : s ∈ topCells m k) : + s.map (lastFaceEmbedding m k) ∈ codimFaces (m + 1) k := by + obtain ⟨hsface, hscard⟩ := mem_topCells.mp hs + exact mem_codimFaces.mpr ⟨(lastFace_mem_iff m k s).mpr hsface, by simpa using hscard⟩ + +theorem lastFace_top_image (m k : ℕ) : + (topCells m k).map (Finset.mapEmbedding (lastFaceEmbedding m k)).toEmbedding = + (codimFaces (m + 1) k).filter + (fun s => Fin.last (m + 1) ∉ faceCarrier (m + 1) k s) := by + ext s + constructor + · intro hs + obtain ⟨t, ht, rfl⟩ := Finset.mem_map.mp hs + apply Finset.mem_filter.mpr + refine ⟨lastFace_map_top_mem m k ht, ?_⟩ + change Fin.last (m + 1) ∉ faceCarrier (m + 1) k (t.map (lastFaceEmbedding m k)) + rw [lastFace_faceCarrier] + simp only [Finset.mem_map, not_exists, not_and] + intro i hi + exact Fin.castSucc_ne_last i + · intro hs + obtain ⟨hscodim, hboundary⟩ := Finset.mem_filter.mp hs + obtain ⟨hsface, hscard⟩ := mem_codimFaces.mp hscodim + obtain ⟨t, htface, hts⟩ := (lastFace_face_range_iff hsface).mp hboundary + apply Finset.mem_map.mpr + refine ⟨t, mem_topCells.mpr ⟨htface, ?_⟩, hts⟩ + have hcard := congrArg Finset.card hts + simpa [hscard] using hcard + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/Supports.lean b/lean/OAI/Analysis/SphereIsometry/Supports.lean new file mode 100644 index 0000000000000000000000000000000000000000..752a8f86f4806c72ab82310a044da4d2916c2f5f --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/Supports.lean @@ -0,0 +1,171 @@ +import OAI.Analysis.SphereIsometry.Basic +import Mathlib.Analysis.Normed.Module.HahnBanach + +namespace OAI + +/-! +# Supporting functionals + +Supports are continuous real linear functionals of norm at most one which attain +the norm at the specified vector. Hahn–Banach supplies supports and extends them +from any subspace. Restriction and extension relate assertions about every ambient +support to assertions about every support on a finite span. + +The results here hold in arbitrary real normed spaces, including the zero space. +-/ + +namespace Tingley + +universe u + +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace ℝ X] + +/-- A norm-bounded real functional attaining the norm at a vector. -/ +def SupportAt (φ : X →L[ℝ] ℝ) (a : X) : Prop := + ‖φ‖ ≤ 1 ∧ φ a = ‖a‖ + +/-- The norm-at-most-one formulation also supplies a support at zero. -/ +theorem exists_support (a : X) : ∃ φ : X →L[ℝ] ℝ, SupportAt φ a := + exists_dual_vector'' ℝ a + +theorem abs_apply_le_norm {φ : X →L[ℝ] ℝ} (hφ : ‖φ‖ ≤ 1) (x : X) : + |φ x| ≤ ‖x‖ := by + simpa only [Real.norm_eq_abs, one_mul] using φ.le_of_opNorm_le hφ x + +theorem apply_le_norm {φ : X →L[ℝ] ℝ} (hφ : ‖φ‖ ≤ 1) (x : X) : + φ x ≤ ‖x‖ := + (le_abs_self (φ x)).trans (abs_apply_le_norm hφ x) + +@[simp] theorem supportAt_zero_iff (φ : X →L[ℝ] ℝ) : + SupportAt φ (0 : X) ↔ ‖φ‖ ≤ 1 := by + simp [SupportAt] + +theorem SupportAt.smul_nonneg {φ : X →L[ℝ] ℝ} {a : X} + (h : SupportAt φ a) {c : ℝ} (hc : 0 ≤ c) : SupportAt φ (c • a) := by + refine ⟨h.1, ?_⟩ + simp only [map_smul, smul_eq_mul, norm_smul, Real.norm_eq_abs, abs_of_nonneg hc, h.2] + +theorem supportAt_pos_smul_iff (φ : X →L[ℝ] ℝ) (a : X) + {c : ℝ} (hc : 0 < c) : SupportAt φ (c • a) ↔ SupportAt φ a := by + constructor + · intro h + refine ⟨h.1, ?_⟩ + have heq := h.2 + rw [map_smul, smul_eq_mul, norm_smul, Real.norm_eq_abs, abs_of_pos hc] at heq + exact mul_left_cancel₀ (ne_of_gt hc) heq + · intro h + exact h.smul_nonneg hc.le + +@[simp] theorem supportAt_neg_iff (φ : X →L[ℝ] ℝ) (a : X) : + SupportAt (-φ) (-a) ↔ SupportAt φ a := by + simp [SupportAt] + +theorem SupportAt.neg {φ : X →L[ℝ] ℝ} {a : X} (h : SupportAt φ a) : + SupportAt (-φ) (-a) := + (supportAt_neg_iff φ a).2 h + +theorem SupportAt.subgradient {φ : X →L[ℝ] ℝ} {a : X} + (h : SupportAt φ a) (z : X) : φ (z - a) ≤ ‖z‖ - ‖a‖ := by + rw [map_sub, h.2] + exact sub_le_sub_right (apply_le_norm h.1 z) ‖a‖ + +/-- Hahn–Banach extends from any real subspace without changing the norm. -/ +theorem extension_norm_eq (U : Submodule ℝ X) (φ : U →L[ℝ] ℝ) : + ∃ Φ : X →L[ℝ] ℝ, (∀ u : U, Φ (u : X) = φ u) ∧ ‖Φ‖ = ‖φ‖ := + _root_.exists_extension_norm_eq U φ + +theorem supportAt_extension (U : Submodule ℝ X) (a : U) + (φ : U →L[ℝ] ℝ) (h : SupportAt φ a) : + ∃ Φ : X →L[ℝ] ℝ, + (∀ u : U, Φ (u : X) = φ u) ∧ SupportAt Φ (a : X) := by + obtain ⟨Φ, hΦ, hnorm⟩ := extension_norm_eq U φ + exact ⟨Φ, hΦ, ⟨hnorm.trans_le h.1, (hΦ a).trans h.2⟩⟩ + +theorem norm_restrict_le (U : Submodule ℝ X) (φ : X →L[ℝ] ℝ) : + ‖φ.comp U.subtypeL‖ ≤ ‖φ‖ := + (φ.comp U.subtypeL).opNorm_le_bound (norm_nonneg φ) fun u => φ.le_opNorm (u : X) + +theorem SupportAt.restrict (U : Submodule ℝ X) + {φ : X →L[ℝ] ℝ} (a : U) (h : SupportAt φ (a : X)) : + SupportAt (φ.comp U.subtypeL) a := + ⟨(norm_restrict_le U φ).trans h.1, h.2⟩ + +/-- Extending to an enlargement retains even the exact operator norm. -/ +theorem exists_extension_norm_eq_of_le {U V : Submodule ℝ X} + (hUV : U ≤ V) (φ : U →L[ℝ] ℝ) : + ∃ ψ : V →L[ℝ] ℝ, + (∀ u : U, ψ ⟨(u : X), hUV u.property⟩ = φ u) ∧ ‖ψ‖ = ‖φ‖ := by + obtain ⟨Φ, hΦ, hnorm⟩ := extension_norm_eq U φ + let ψ : V →L[ℝ] ℝ := Φ.comp V.subtypeL + have hagree (u : U) : ψ ⟨(u : X), hUV u.property⟩ = φ u := hΦ u + refine ⟨ψ, hagree, le_antisymm ?_ ?_⟩ + · exact (norm_restrict_le V Φ).trans_eq hnorm + · apply φ.opNorm_le_bound (norm_nonneg ψ) + intro u + rw [← hagree u] + exact ψ.le_opNorm ⟨(u : X), hUV u.property⟩ + +/-- In particular, a support extends to every specified finite enlargement. +The stronger statement does not need either subspace to be finite-dimensional. -/ +theorem supportAt_finite_enlargement (U V : Submodule ℝ X) (hUV : U ≤ V) + (a : U) (φ : U →L[ℝ] ℝ) (h : SupportAt φ a) : + ∃ ψ : V →L[ℝ] ℝ, + (∀ u : U, ψ ⟨(u : X), hUV u.property⟩ = φ u) ∧ + SupportAt ψ ⟨(a : X), hUV a.property⟩ := by + obtain ⟨ψ, hψ, hnorm⟩ := exists_extension_norm_eq_of_le hUV φ + exact ⟨ψ, hψ, ⟨hnorm.trans_le h.1, (hψ a).trans h.2⟩⟩ + +/-- Universal assertions about support evaluations can be made on any subspace +containing the two vectors. This permits using the dual of their finite span. -/ +theorem forall_supportAt_apply_iff_submodule (U : Submodule ℝ X) + (a b : U) (P : ℝ → Prop) : + (∀ φ : X →L[ℝ] ℝ, SupportAt φ (a : X) → P (φ (b : X))) ↔ + (∀ ψ : U →L[ℝ] ℝ, SupportAt ψ a → P (ψ b)) := by + constructor + · intro h ψ hψ + obtain ⟨Φ, hΦ, hsupport⟩ := supportAt_extension U a ψ hψ + simpa only [hΦ b] using h Φ hsupport + · intro h Φ hΦ + exact h (Φ.comp U.subtypeL) (SupportAt.restrict U a hΦ) + +/-- Triangle equality is equivalent to the existence of a common support. -/ +theorem norm_add_eq_iff_exists_common_supportAt (x y : X) : + ‖x + y‖ = ‖x‖ + ‖y‖ ↔ + ∃ φ : X →L[ℝ] ℝ, SupportAt φ x ∧ SupportAt φ y := by + constructor + · intro heq + obtain ⟨φ, hφ⟩ := exists_support (x + y) + have hx := apply_le_norm hφ.1 x + have hy := apply_le_norm hφ.1 y + have hsum : φ x + φ y = ‖x‖ + ‖y‖ := by + calc + φ x + φ y = φ (x + y) := (map_add φ x y).symm + _ = ‖x + y‖ := hφ.2 + _ = ‖x‖ + ‖y‖ := heq + refine ⟨φ, ⟨hφ.1, ?_⟩, ⟨hφ.1, ?_⟩⟩ + · linarith + · linarith + · rintro ⟨φ, hx, hy⟩ + apply le_antisymm (norm_add_le x y) + have h := apply_le_norm hx.1 (x + y) + rwa [map_add, hx.2, hy.2] at h + +/-- Positive weighted triangle equality for unit vectors gives one functional +taking value one at both vectors. No strict convexity is required. -/ +theorem common_support_of_norm_add_eq {v w : X} + (hv : ‖v‖ = 1) (hw : ‖w‖ = 1) {α β : ℝ} + (hα : 0 < α) (hβ : 0 < β) + (heq : ‖α • v + β • w‖ = α + β) : + ∃ φ : X →L[ℝ] ℝ, ‖φ‖ ≤ 1 ∧ φ v = 1 ∧ φ w = 1 := by + have hsum : ‖α • v + β • w‖ = ‖α • v‖ + ‖β • w‖ := by + simpa only [norm_smul, Real.norm_eq_abs, abs_of_pos hα, abs_of_pos hβ, + hv, hw, mul_one] using heq + obtain ⟨φ, hvφ, hwφ⟩ := + (norm_add_eq_iff_exists_common_supportAt (α • v) (β • w)).mp hsum + have hv' := (supportAt_pos_smul_iff φ v hα).mp hvφ + have hw' := (supportAt_pos_smul_iff φ w hβ).mp hwφ + exact ⟨φ, hv'.1, hv'.2.trans hv, hw'.2.trans hw⟩ + +end Tingley + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/UltraNormed.lean b/lean/OAI/Analysis/SphereIsometry/UltraNormed.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b6449c5ea2d207c42c157408f0756770c5af047 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/UltraNormed.lean @@ -0,0 +1,217 @@ +import OAI.Analysis.SphereIsometry.UltraRealLimit +import Mathlib.Algebra.Module.TransferInstance +import Mathlib.Analysis.Normed.Module.Seminorm.Basic +import Mathlib.Analysis.Normed.Module.Completion +import Mathlib.Analysis.Normed.Group.SeparationQuotient + +namespace OAI + +/-! +# Bounded sequences with the ultralimit seminorm + +The carrier below is a fresh wrapper, not the bounded submodule with its +inherited product topology. Only algebra is transported to the wrapper. Its +topology is then constructed from the ultralimit seminorm. The separation +quotient therefore identifies zero ultradistance, not eventual equality. +-/ + +noncomputable section + +namespace Tingley + +universe u + +variable (X : Type u) [NormedAddCommGroup X] [NormedSpace ℝ X] + +/-- The algebraic submodule of uniformly bounded sequences. -/ +def boundedSequenceSubmodule : Submodule ℝ (ℕ → X) where + carrier := {a | ∃ B : ℝ, 0 ≤ B ∧ ∀ n, ‖a n‖ ≤ B} + zero_mem' := ⟨0, le_rfl, by simp⟩ + add_mem' := by + rintro a b ⟨A, hA, ha⟩ ⟨B, hB, hb⟩ + refine ⟨A + B, add_nonneg hA hB, fun n => ?_⟩ + exact (norm_add_le (a n) (b n)).trans (add_le_add (ha n) (hb n)) + smul_mem' := by + rintro r a ⟨A, hA, ha⟩ + refine ⟨‖r‖ * A, mul_nonneg (norm_nonneg r) hA, fun n => ?_⟩ + simpa only [Pi.smul_apply, norm_smul] using + mul_le_mul_of_nonneg_left (ha n) (norm_nonneg r) + +/-- A fresh carrier on which only the ultralimit topology will be installed. -/ +structure UltraSequence (U : Ultrafilter ℕ) (X : Type u) + [NormedAddCommGroup X] [NormedSpace ℝ X] where + val : boundedSequenceSubmodule X + +namespace UltraSequence + +variable (U : Ultrafilter ℕ) + +/-- Algebraic identification; it transports no topology. -/ +def algebraEquiv : UltraSequence U X ≃ boundedSequenceSubmodule X where + toFun := UltraSequence.val + invFun := UltraSequence.mk + left_inv a := by cases a; rfl + right_inv a := rfl + +instance instAddCommGroup : AddCommGroup (UltraSequence U X) := + (algebraEquiv X U).addCommGroup + +instance instModule : Module ℝ (UltraSequence U X) := + ({ algebraEquiv X U with map_add' := fun _ _ => rfl } : + UltraSequence U X ≃+ boundedSequenceSubmodule X).module ℝ + +instance instCoeFun : CoeFun (UltraSequence U X) (fun _ => ℕ → X) := + ⟨fun a => a.val.val⟩ + +variable {X U} + +@[ext] theorem ext {a b : UltraSequence U X} (h : ∀ n, a n = b n) : a = b := by + have hv : a.val = b.val := Subtype.ext (funext h) + cases a + cases b + cases hv + rfl + +/-- Construct a sequence from an actual uniform norm bound. -/ +def ofBounded (U : Ultrafilter ℕ) (a : ℕ → X) + (ha : ∃ B : ℝ, 0 ≤ B ∧ ∀ n, ‖a n‖ ≤ B) : UltraSequence U X := + ⟨⟨a, ha⟩⟩ + +@[simp] theorem ofBounded_apply (U : Ultrafilter ℕ) (a : ℕ → X) + (ha : ∃ B : ℝ, 0 ≤ B ∧ ∀ n, ‖a n‖ ≤ B) (n : ℕ) : + ofBounded U a ha n = a n := rfl + +@[simp] theorem zero_apply (n : ℕ) : (0 : UltraSequence U X) n = 0 := rfl + +@[simp] theorem add_apply (a b : UltraSequence U X) (n : ℕ) : + (a + b) n = a n + b n := rfl + +@[simp] theorem neg_apply (a : UltraSequence U X) (n : ℕ) : (-a) n = -a n := rfl + +@[simp] theorem sub_apply (a b : UltraSequence U X) (n : ℕ) : + (a - b) n = a n - b n := rfl + +@[simp] theorem smul_apply (r : ℝ) (a : UltraSequence U X) (n : ℕ) : + (r • a) n = r • a n := rfl + +theorem bounded (a : UltraSequence U X) : + ∃ B : ℝ, 0 ≤ B ∧ ∀ n, ‖a n‖ ≤ B := a.val.property + +theorem norm_bounded (a : UltraSequence U X) : RealSeqBounded (fun n => ‖a n‖) := by + obtain ⟨B, _, hB⟩ := a.bounded + exact ⟨B, fun n => by simpa only [abs_norm] using hB n⟩ + +/-- The actual ultralimit of coordinate norms. -/ +def ultranorm (a : UltraSequence U X) : ℝ := realULim U (fun n => ‖a n‖) + +theorem ultranorm_add_le (a b : UltraSequence U X) : + ultranorm (a + b) ≤ ultranorm a + ultranorm b := by + have h := realULim_le_realULim U (a + b).norm_bounded + (a.norm_bounded.add b.norm_bounded) + (Filter.Eventually.of_forall (fun n => norm_add_le (a n) (b n))) + simpa only [ultranorm, add_apply, realULim_add U a.norm_bounded b.norm_bounded] using h + +theorem ultranorm_smul (r : ℝ) (a : UltraSequence U X) : + ultranorm (r • a) = ‖r‖ * ultranorm a := by + simp only [ultranorm, smul_apply, norm_smul] + exact realULim_const_mul U ‖r‖ a.norm_bounded + +variable (X U) + +/-- The proved seminorm; no bounded-vector convergence is asserted. -/ +def seminorm : Seminorm ℝ (UltraSequence U X) := + Seminorm.of ultranorm ultranorm_add_le ultranorm_smul + +instance instSeminormedAddCommGroup : SeminormedAddCommGroup (UltraSequence U X) := + (seminorm X U).toAddGroupSeminorm.toSeminormedAddCommGroup + +instance instNormedSpace : NormedSpace ℝ (UltraSequence U X) where + norm_smul_le r a := (ultranorm_smul r a).le + +variable {X U} + +theorem norm_eq_realULim (a : UltraSequence U X) : + ‖a‖ = realULim U (fun n => ‖a n‖) := rfl + +/-- Constant bounded sequences. -/ +def constant (U : Ultrafilter ℕ) (x : X) : UltraSequence U X := + ofBounded U (fun _ => x) ⟨‖x‖, norm_nonneg x, fun _ => le_rfl⟩ + +@[simp] theorem constant_apply (U : Ultrafilter ℕ) (x : X) (n : ℕ) : + constant U x n = x := rfl + +end UltraSequence + +/-- The normed space obtained by identifying sequences at zero ultradistance. -/ +abbrev UltraQuotient (U : Ultrafilter ℕ) (X : Type u) + [NormedAddCommGroup X] [NormedSpace ℝ X] := + SeparationQuotient (UltraSequence U X) + +variable {X} (U : Ultrafilter ℕ) + +/-- Projection to the zero-ultranorm quotient. -/ +def classOf (a : UltraSequence U X) : UltraQuotient U X := SeparationQuotient.mk a + +theorem classOf_surjective (X : Type u) [NormedAddCommGroup X] [NormedSpace ℝ X] : + Function.Surjective (classOf U (X := X)) := + SeparationQuotient.surjective_mk + +@[simp] theorem classOf_zero : classOf U (0 : UltraSequence U X) = 0 := rfl + +@[simp] theorem classOf_add (a b : UltraSequence U X) : + classOf U (a + b) = classOf U a + classOf U b := rfl + +@[simp] theorem classOf_neg (a : UltraSequence U X) : classOf U (-a) = -classOf U a := rfl + +@[simp] theorem classOf_sub (a b : UltraSequence U X) : + classOf U (a - b) = classOf U a - classOf U b := rfl + +@[simp] theorem classOf_smul (r : ℝ) (a : UltraSequence U X) : + classOf U (r • a) = r • classOf U a := rfl + +theorem norm_classOf (a : UltraSequence U X) : + ‖classOf U a‖ = realULim U (fun n => ‖a n‖) := rfl + +theorem norm_sub_classOf (a b : UltraSequence U X) : + ‖classOf U a - classOf U b‖ = realULim U (fun n => ‖a n - b n‖) := by + rw [← classOf_sub, norm_classOf] + rfl + +theorem classOf_eq_iff (a b : UltraSequence U X) : + classOf U a = classOf U b ↔ realULim U (fun n => ‖a n - b n‖) = 0 := by + rw [← norm_sub_classOf, norm_eq_zero, sub_eq_zero] + +/-- Constant sequences embed the original space isometrically and linearly. -/ +def constantEmbedding : X →ₗᵢ[ℝ] UltraQuotient U X where + toFun x := classOf U (UltraSequence.constant U x) + map_add' x y := by + rw [← classOf_add] + congr 1 + map_smul' r x := by + rw [← classOf_smul] + congr 1 + norm_map' x := by + change ‖classOf U (UltraSequence.constant U x)‖ = ‖x‖ + rw [norm_classOf] + exact realULim_const U ‖x‖ + +@[simp] theorem constantEmbedding_apply (x : X) : + constantEmbedding U x = classOf U (UltraSequence.constant U x) := rfl + +instance ultraQuotient_nontrivial [Nontrivial X] : Nontrivial (UltraQuotient U X) := + (constantEmbedding U (X := X)).injective.nontrivial + +/-- The actual Banach completion of the normed ultralimit quotient. -/ +abbrev UltraCompletion (U : Ultrafilter ℕ) (X : Type u) + [NormedAddCommGroup X] [NormedSpace ℝ X] := + UniformSpace.Completion (UltraQuotient U X) + +instance ultraCompletion_nontrivial [Nontrivial X] : Nontrivial (UltraCompletion U X) := + (UniformSpace.Completion.toComplₗᵢ : UltraQuotient U X →ₗᵢ[ℝ] + UltraCompletion U X).injective.nontrivial + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/UltraRealLimit.lean b/lean/OAI/Analysis/SphereIsometry/UltraRealLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f7fd3b504aba0f0eb9820df26b43fa687d6ffae --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/UltraRealLimit.lean @@ -0,0 +1,162 @@ +import Mathlib.Order.Filter.Ultrafilter.Basic +import Mathlib.Topology.Algebra.Ring.Real +import Mathlib.Topology.Order.Compact +import Mathlib.Topology.Separation.Hausdorff + +namespace OAI + +/-! +# Real ultralimits of bounded sequences + +Every bounded real sequence converges along an ultrafilter, by compactness of a +closed real interval. All identities below use this convergence or an explicitly +given limit, so they do not depend on the fallback value of `limUnder`. +-/ + +noncomputable section + +open Filter +open scoped Topology + +namespace Tingley + +/-- A real sequence has a uniform absolute-value bound. -/ +def RealSeqBounded (f : ℕ → ℝ) : Prop := + ∃ B : ℝ, ∀ n, |f n| ≤ B + +namespace RealSeqBounded + +variable {f g : ℕ → ℝ} + +theorem exists_nonneg_bound (hf : RealSeqBounded f) : + ∃ B : ℝ, 0 ≤ B ∧ ∀ n, |f n| ≤ B := by + obtain ⟨B, hB⟩ := hf + exact ⟨B, (abs_nonneg (f 0)).trans (hB 0), hB⟩ + +theorem const (c : ℝ) : RealSeqBounded (fun _ : ℕ => c) := + ⟨|c|, fun _ => le_rfl⟩ + +theorem add (hf : RealSeqBounded f) (hg : RealSeqBounded g) : + RealSeqBounded (fun n => f n + g n) := by + obtain ⟨B, hB⟩ := hf + obtain ⟨C, hC⟩ := hg + exact ⟨B + C, fun n => (abs_add_le (f n) (g n)).trans (add_le_add (hB n) (hC n))⟩ + +theorem neg (hf : RealSeqBounded f) : RealSeqBounded (fun n => -f n) := by + obtain ⟨B, hB⟩ := hf + refine ⟨B, fun n => ?_⟩ + simpa only [abs_neg] using hB n + +theorem sub (hf : RealSeqBounded f) (hg : RealSeqBounded g) : + RealSeqBounded (fun n => f n - g n) := by + simpa only [sub_eq_add_neg] using hf.add hg.neg + +theorem const_mul (c : ℝ) (hf : RealSeqBounded f) : + RealSeqBounded (fun n => c * f n) := by + obtain ⟨B, hB⟩ := hf + refine ⟨|c| * B, fun n => ?_⟩ + rw [abs_mul] + exact mul_le_mul_of_nonneg_left (hB n) (abs_nonneg c) + +theorem abs (hf : RealSeqBounded f) : RealSeqBounded (fun n => |f n|) := by + obtain ⟨B, hB⟩ := hf + refine ⟨B, fun n => ?_⟩ + simpa only [abs_abs] using hB n + +end RealSeqBounded + +/-- The chosen real limit along an ultrafilter. Use `tendsto_realULim` to establish +that this value is a limit for a bounded sequence. -/ +def realULim (U : Ultrafilter ℕ) (f : ℕ → ℝ) : ℝ := + Filter.limUnder (U : Filter ℕ) f + +variable {f g : ℕ → ℝ} + +/-- Bounded real sequences converge along every ultrafilter. -/ +theorem tendsto_realULim (U : Ultrafilter ℕ) (hf : RealSeqBounded f) : + Tendsto f (U : Filter ℕ) (𝓝 (realULim U f)) := by + obtain ⟨B, hB⟩ := hf + have hmem : Set.Icc (-B) B ∈ Ultrafilter.map f U := by + change ∀ᶠ n in (U : Filter ℕ), f n ∈ Set.Icc (-B) B + exact Filter.Eventually.of_forall fun n => abs_le.mp (hB n) + obtain ⟨a, _ha, hlim⟩ := + isCompact_Icc.ultrafilter_le_nhds' (Ultrafilter.map f U) hmem + have ha : Tendsto f (U : Filter ℕ) (𝓝 a) := hlim + exact tendsto_nhds_limUnder ⟨a, ha⟩ + +/-- A known limit determines the chosen ultralimit, without a boundedness premise. -/ +theorem realULim_eq_of_tendsto (U : Ultrafilter ℕ) {a : ℝ} + (h : Tendsto f (U : Filter ℕ) (𝓝 a)) : realULim U f = a := + h.limUnder_eq + +@[simp] +theorem realULim_const (U : Ultrafilter ℕ) (c : ℝ) : + realULim U (fun _ : ℕ => c) = c := + realULim_eq_of_tendsto U tendsto_const_nhds + +theorem realULim_add (U : Ultrafilter ℕ) (hf : RealSeqBounded f) + (hg : RealSeqBounded g) : + realULim U (fun n => f n + g n) = realULim U f + realULim U g := + realULim_eq_of_tendsto U ((tendsto_realULim U hf).add (tendsto_realULim U hg)) + +theorem realULim_neg (U : Ultrafilter ℕ) (hf : RealSeqBounded f) : + realULim U (fun n => -f n) = -realULim U f := + realULim_eq_of_tendsto U (tendsto_realULim U hf).neg + +theorem realULim_sub (U : Ultrafilter ℕ) (hf : RealSeqBounded f) + (hg : RealSeqBounded g) : + realULim U (fun n => f n - g n) = realULim U f - realULim U g := + realULim_eq_of_tendsto U ((tendsto_realULim U hf).sub (tendsto_realULim U hg)) + +theorem realULim_const_mul (U : Ultrafilter ℕ) (c : ℝ) (hf : RealSeqBounded f) : + realULim U (fun n => c * f n) = c * realULim U f := + realULim_eq_of_tendsto U ((tendsto_realULim U hf).const_mul c) + +theorem realULim_abs (U : Ultrafilter ℕ) (hf : RealSeqBounded f) : + realULim U (fun n => |f n|) = |realULim U f| := + realULim_eq_of_tendsto U (tendsto_realULim U hf).abs + +/-- Eventual inequalities pass to the limits of bounded real sequences. -/ +theorem realULim_le_realULim (U : Ultrafilter ℕ) (hf : RealSeqBounded f) + (hg : RealSeqBounded g) (h : ∀ᶠ n in (U : Filter ℕ), f n ≤ g n) : + realULim U f ≤ realULim U g := + le_of_tendsto_of_tendsto (tendsto_realULim U hf) (tendsto_realULim U hg) h + +theorem realULim_le_of_eventually_le (U : Ultrafilter ℕ) (hf : RealSeqBounded f) + {c : ℝ} (h : ∀ᶠ n in (U : Filter ℕ), f n ≤ c) : realULim U f ≤ c := + le_of_tendsto (tendsto_realULim U hf) h + +theorem le_realULim_of_eventually_le (U : Ultrafilter ℕ) (hf : RealSeqBounded f) + {c : ℝ} (h : ∀ᶠ n in (U : Filter ℕ), c ≤ f n) : c ≤ realULim U f := by + have hlim := realULim_le_realULim U (RealSeqBounded.const c) hf h + simpa only [realULim_const] using hlim + +/-- The actual free ultrafilter used for the bounded-sequence quotient. -/ +def freeUltrafilter : Ultrafilter ℕ := Filter.hyperfilter ℕ + +theorem freeUltrafilter_le_cofinite : + (freeUltrafilter : Filter ℕ) ≤ Filter.cofinite := + Filter.hyperfilter_le_cofinite + +theorem freeUltrafilter_le_atTop : (freeUltrafilter : Filter ℕ) ≤ Filter.atTop := + Nat.hyperfilter_le_atTop + +theorem not_mem_freeUltrafilter_of_finite {s : Set ℕ} (hs : s.Finite) : + s ∉ freeUltrafilter := + Filter.notMem_hyperfilter_of_finite hs + +/-- Ordinary sequential convergence also holds along the fixed free ultrafilter. -/ +theorem tendsto_freeUltrafilter_of_tendsto_atTop {α : Type*} [TopologicalSpace α] + {a : ℕ → α} {x : α} (h : Tendsto a atTop (𝓝 x)) : + Tendsto a (freeUltrafilter : Filter ℕ) (𝓝 x) := + h.mono_left freeUltrafilter_le_atTop + +theorem realULim_freeUltrafilter_eq_of_tendsto_atTop {a : ℝ} + (h : Tendsto f atTop (𝓝 a)) : realULim freeUltrafilter f = a := + realULim_eq_of_tendsto freeUltrafilter (tendsto_freeUltrafilter_of_tendsto_atTop h) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/UltraSphere.lean b/lean/OAI/Analysis/SphereIsometry/UltraSphere.lean new file mode 100644 index 0000000000000000000000000000000000000000..8589b8f427e1dda6512581f2762d4c59073a0979 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/UltraSphere.lean @@ -0,0 +1,180 @@ +import OAI.Analysis.SphereIsometry.UnitRepresentatives +import OAI.Analysis.SphereIsometry.UltraNormed + +namespace OAI + +/-! +# The actual sphere map on the ultranorm quotient + +Unit representatives exist even when the original coordinates vanish. The map +and its inverse are induced coordinatewise, and every fixed real radius has the +exact ultralimit defect formula. +-/ + +noncomputable section +namespace Tingley +open Filter +open scoped Topology + +universe u v +variable {X : Type u} {Y : Type v} +variable [NormedAddCommGroup X] [NormedSpace ℝ X] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +/-- Every sequence of unit vectors is uniformly bounded. -/ +def unitSequence (U : Ultrafilter ℕ) (s : ℕ → UnitSphere X) : UltraSequence U X := + UltraSequence.ofBounded U (fun n => (s n : X)) ⟨1, zero_le_one, fun n => by simp⟩ + +@[simp] theorem unitSequence_apply (U : Ultrafilter ℕ) (s : ℕ → UnitSphere X) (n : ℕ) : + unitSequence U s n = (s n : X) := rfl + +/-- The actual class of a sequence of unit vectors. -/ +def unitClass (U : Ultrafilter ℕ) (s : ℕ → UnitSphere X) : UnitSphere (UltraQuotient U X) := + ⟨classOf U (unitSequence U s), by simp only [norm_classOf, unitSequence_apply, + UnitSphere.norm_coe, realULim_const]⟩ + +@[simp] theorem unitClass_val (U : Ultrafilter ℕ) (s : ℕ → UnitSphere X) : + (unitClass U s : UltraQuotient U X) = classOf U (unitSequence U s) := rfl + +theorem norm_sub_unitClass (U : Ultrafilter ℕ) (s t : ℕ → UnitSphere X) : + ‖(unitClass U s : UltraQuotient U X) - (unitClass U t : UltraQuotient U X)‖ = + realULim U (fun n => ‖(s n : X) - (t n : X)‖) := by + simpa only [unitClass_val, unitSequence_apply] using + norm_sub_classOf U (unitSequence U s) (unitSequence U t) + +theorem unitClass_eq_iff (U : Ultrafilter ℕ) (s t : ℕ → UnitSphere X) : + unitClass U s = unitClass U t ↔ realULim U (fun n => ‖(s n : X) - (t n : X)‖) = 0 := by + rw [Subtype.ext_iff] + exact classOf_eq_iff U (unitSequence U s) (unitSequence U t) + +theorem unitClass_surjective [Nontrivial X] (U : Ultrafilter ℕ) : + Function.Surjective (unitClass U : (ℕ → UnitSphere X) → UnitSphere (UltraQuotient U X)) := by + classical + intro z + obtain ⟨a, ha⟩ := classOf_surjective U X (z : UltraQuotient U X) + let e : UnitSphere X := Classical.choice inferInstance + let s : ℕ → UnitSphere X := fun n => unitize e (a n) + have ha1 : realULim U (fun n => ‖a n‖) = 1 := by + rw [← norm_classOf, ha] + exact z.property + have hlim : Tendsto (fun n => ‖a n‖) (U : Filter ℕ) (𝓝 (1 : ℝ)) := by + simpa only [ha1] using tendsto_realULim U (UltraSequence.norm_bounded a) + have he : realULim U (fun n => ‖a n - (s n : X)‖) = 0 := by + apply realULim_eq_of_tendsto U + simpa only [s, norm_sub_unitize, sub_self, abs_zero] using + (hlim.sub (tendsto_const_nhds (x := (1 : ℝ)))).abs + refine ⟨s, ?_⟩ + apply Subtype.ext + change classOf U (unitSequence U s) = (z : UltraQuotient U X) + rw [← ha] + exact ((classOf_eq_iff U a (unitSequence U s)).2 he).symm + +/-- Choice selects actual unit representatives after surjectivity is proved. -/ +def unitRep [Nontrivial X] (U : Ultrafilter ℕ) (z : UnitSphere (UltraQuotient U X)) : + ℕ → UnitSphere X := + Classical.choose (unitClass_surjective U z) + +@[simp] theorem unitRep_spec [Nontrivial X] (U : Ultrafilter ℕ) + (z : UnitSphere (UltraQuotient U X)) : unitClass U (unitRep U z) = z := + Classical.choose_spec (unitClass_surjective U z) + +theorem unitClass_map_eq (U : Ultrafilter ℕ) (f : UnitSphere X ≃ᵢ UnitSphere Y) + (s t : ℕ → UnitSphere X) (h : unitClass U s = unitClass U t) : + unitClass U (fun n => f (s n)) = unitClass U (fun n => f (t n)) := by + apply (unitClass_eq_iff U _ _).2 + simpa only [sphere_norm_sub] using (unitClass_eq_iff U s t).1 h + +def ultraSphereMap [Nontrivial X] (U : Ultrafilter ℕ) (f : UnitSphere X ≃ᵢ UnitSphere Y) + (z : UnitSphere (UltraQuotient U X)) : UnitSphere (UltraQuotient U Y) := + unitClass U (fun n => f (unitRep U z n)) + +@[simp] theorem ultraSphereMap_unitClass [Nontrivial X] (U : Ultrafilter ℕ) + (f : UnitSphere X ≃ᵢ UnitSphere Y) (s : ℕ → UnitSphere X) : + ultraSphereMap U f (unitClass U s) = unitClass U (fun n => f (s n)) := + unitClass_map_eq U f _ s (unitRep_spec U (unitClass U s)) + +theorem ultraSphereMap_isometry [Nontrivial X] (U : Ultrafilter ℕ) + (f : UnitSphere X ≃ᵢ UnitSphere Y) : Isometry (ultraSphereMap U f) := by + apply Isometry.of_dist_eq + intro z w + calc + dist (ultraSphereMap U f z) (ultraSphereMap U f w) = + dist (unitClass U (unitRep U z)) (unitClass U (unitRep U w)) := by + simp only [ultraSphereMap, Subtype.dist_eq, dist_eq_norm, norm_sub_unitClass, + sphere_norm_sub] + _ = dist z w := by rw [unitRep_spec, unitRep_spec] + +/-- Surjectivity comes from the actual coordinatewise inverse, not from isometry alone. -/ +def ultraSphereEquiv [Nontrivial X] [Nontrivial Y] (U : Ultrafilter ℕ) + (f : UnitSphere X ≃ᵢ UnitSphere Y) : + UnitSphere (UltraQuotient U X) ≃ᵢ UnitSphere (UltraQuotient U Y) where + toFun := ultraSphereMap U f + invFun := ultraSphereMap U f.symm + left_inv z := by + obtain ⟨s, rfl⟩ := unitClass_surjective U z + simp only [ultraSphereMap_unitClass, IsometryEquiv.symm_apply_apply] + right_inv z := by + obtain ⟨s, rfl⟩ := unitClass_surjective U z + simp only [ultraSphereMap_unitClass, IsometryEquiv.apply_symm_apply] + isometry_toFun := ultraSphereMap_isometry U f + +@[simp] theorem ultraSphereEquiv_unitClass [Nontrivial X] [Nontrivial Y] + (U : Ultrafilter ℕ) (f : UnitSphere X ≃ᵢ UnitSphere Y) (s : ℕ → UnitSphere X) : + ultraSphereEquiv U f (unitClass U s) = unitClass U (fun n => f (s n)) := + ultraSphereMap_unitClass U f s + +@[simp] theorem ultraSphereEquiv_symm [Nontrivial X] [Nontrivial Y] + (U : Ultrafilter ℕ) (f : UnitSphere X ≃ᵢ UnitSphere Y) : + (ultraSphereEquiv U f).symm = ultraSphereEquiv U f.symm := by + ext z + rfl + +/-- The radius-scaled norm is inherited from the linear quotient projection. -/ +theorem norm_sub_smul_unitClass (U : Ultrafilter ℕ) (q : ℝ) (s t : ℕ → UnitSphere X) : + ‖(unitClass U s : UltraQuotient U X) - q • (unitClass U t : UltraQuotient U X)‖ = + realULim U (fun n => ‖(s n : X) - q • (t n : X)‖) := by + change ‖classOf U (unitSequence U s) - q • classOf U (unitSequence U t)‖ = _ + rw [← classOf_smul, ← classOf_sub, norm_classOf] + rfl + +theorem unitPairNorm_bounded (q : ℝ) (s t : ℕ → UnitSphere X) : + RealSeqBounded (fun n => ‖(s n : X) - q • (t n : X)‖) := by + refine ⟨1 + |q|, fun n => ?_⟩ + rw [abs_of_nonneg (norm_nonneg _)] + calc + ‖(s n : X) - q • (t n : X)‖ ≤ ‖(s n : X)‖ + ‖q • (t n : X)‖ := norm_sub_le _ _ + _ = 1 + |q| := by simp only [norm_smul, Real.norm_eq_abs, UnitSphere.norm_coe, mul_one] + +theorem signedDefect_sequence_bounded (f : UnitSphere X ≃ᵢ UnitSphere Y) + (q : ℝ) (s t : ℕ → UnitSphere X) : + RealSeqBounded (fun n => signedDefect f q (s n) (t n)) := + (unitPairNorm_bounded q (fun n => f (s n)) (fun n => f (t n))).sub + (unitPairNorm_bounded q s t) + +/-- Exact defect formula at every fixed real radius. -/ +theorem signedDefect_ultraSphereEquiv [Nontrivial X] [Nontrivial Y] + (U : Ultrafilter ℕ) (f : UnitSphere X ≃ᵢ UnitSphere Y) (q : ℝ) + (s t : ℕ → UnitSphere X) : + signedDefect (ultraSphereEquiv U f) q (unitClass U s) (unitClass U t) = + realULim U (fun n => signedDefect f q (s n) (t n)) := by + simp only [signedDefect, ultraSphereEquiv_unitClass, norm_sub_smul_unitClass] + exact (realULim_sub U + (unitPairNorm_bounded q (fun n => f (s n)) (fun n => f (t n))) + (unitPairNorm_bounded q s t)).symm + +/-- One ultrafilter transfers the bound for each arbitrarily chosen real radius. -/ +theorem HasDefectBound.ultraSphereEquiv [Nontrivial X] [Nontrivial Y] + {f : UnitSphere X ≃ᵢ UnitSphere Y} {M : ℝ} (h : HasDefectBound f M) + (U : Ultrafilter ℕ) : HasDefectBound (ultraSphereEquiv U f) M := by + intro q hq z w + obtain ⟨s, rfl⟩ := unitClass_surjective U z + obtain ⟨t, rfl⟩ := unitClass_surjective U w + rw [signedDefect_ultraSphereEquiv, ← realULim_abs U (signedDefect_sequence_bounded f q s t)] + exact realULim_le_of_eventually_le U (signedDefect_sequence_bounded f q s t).abs + (Filter.Eventually.of_forall fun n => h q hq (s n) (t n)) + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/SphereIsometry/UnitRepresentatives.lean b/lean/OAI/Analysis/SphereIsometry/UnitRepresentatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fb9f5f285d4a4ddb710996c090764f9967f9112 --- /dev/null +++ b/lean/OAI/Analysis/SphereIsometry/UnitRepresentatives.lean @@ -0,0 +1,48 @@ +import OAI.Analysis.SphereIsometry.Basic + +namespace OAI + +/-! +# Unit representatives, including the zero vector + +The fallback unit vector is used only at zero. The exact error identity permits +normalization of arbitrary representatives of a unit ultranorm class. +-/ + +noncomputable section +namespace Tingley + +universe u +variable {X : Type u} [NormedAddCommGroup X] [NormedSpace ℝ X] + +def unitize (e : UnitSphere X) (a : X) : UnitSphere X := by + classical + exact if ha : a = 0 then e else normalize a ha + +@[simp] theorem unitize_zero (e : UnitSphere X) : unitize e 0 = e := by + simp [unitize] + +theorem unitize_of_ne_zero (e : UnitSphere X) {a : X} (ha : a ≠ 0) : + unitize e a = normalize a ha := by + simp [unitize, ha] + +theorem norm_smul_unitize (e : UnitSphere X) (a : X) : + ‖a‖ • (unitize e a : X) = a := by + by_cases ha : a = 0 + · simp [ha] + · rw [unitize_of_ne_zero e ha] + exact norm_smul_normalize a ha + +theorem sub_unitize (e : UnitSphere X) (a : X) : + a - (unitize e a : X) = (‖a‖ - 1) • (unitize e a : X) := by + rw [sub_smul, norm_smul_unitize, one_smul] + +theorem norm_sub_unitize (e : UnitSphere X) (a : X) : + ‖a - (unitize e a : X)‖ = |‖a‖ - 1| := by + rw [sub_unitize, norm_smul, Real.norm_eq_abs, UnitSphere.norm_coe, mul_one] + +end Tingley + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Adaptive.lean b/lean/OAI/Analysis/Steinitz/Adaptive.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffa114fce2a93ae14f56d3db727245aa99554f01 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Adaptive.lean @@ -0,0 +1,199 @@ +import OAI.Analysis.Steinitz.LiftedRearrangement + +namespace OAI + +/-! Energy-preserving sections and adaptive coordinate selection. -/ + +section + +open MeasureTheory Set Filter +open scoped ENNReal NNReal Topology +namespace ShiftedSections +open HeatL2 HeatL2.Diagonal +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma section_crossing {K : Set (EuclideanSpace ℝ ι)} (hKm : MeasurableSet K) + (hKc : Convex ℝ K) (hB : Bound K hKm (1/10000)) (j : ι) : + ∃ r ∈ activeHeights K (EuclideanSpace.single j 1) (5/2),1 < r := by + obtain ⟨f,hf,_,G,_,hG,hGs,hn,hH,hh,_⟩ := lifted_test hKm hKc hB j + (η := 1/4) (ε := 1/10000) (by norm_num) le_rfl (by norm_num) le_rfl + exact height_above_one _ _ hG hn hH (by linarith) hGs + +omit [DecidableEq ι] in +lemma symbol_mul (t : ℝ≥0) (v : ι → ℝ≥0) : + GaussianKernel.symbol (fun i => t*v i) = fun ξ => (t:ℝ)*GaussianKernel.symbol v ξ := by + funext ξ + simp only [GaussianKernel.symbol,NNReal.coe_mul] + rw [← mul_div_assoc,Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro i _ + ring + +lemma section_rate_le {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (hKc : Convex ℝ K) + (hB : Bound K hKo.measurableSet (1/10000)) (j : ι) + (v : ι → ℝ≥0) (hv : ∀ i,0 < v i) : + sectionRate K hKo (EuclideanSpace.single j 1) (5/2) v 1 ≤ + ((1/10000:ℝ)/2)*∑ i,(v i:ℝ) := by + let e := EuclideanSpace.single j (1:ℝ) + let h := sectionRate K hKo e (5/2) v 1 + have hr := section_crossing hKo.measurableSet hKc hB j + obtain ⟨h0,h1⟩ := activeHeights_contains_one hKc e (5/2) hr + obtain ⟨a,ha,hline⟩ := EuclideanSteinitz.convex_supporting_line + (sectionRate_convex hKo hKb hKc e (5/2) v (fun i => (hv i).ne')) + (sectionRate_monotone hKo hKb hKc e (5/2) v) h0 h1 hr + let L := h+a*(5/2) + have hh : 0 ≤ h := sectionRate_nonneg hKo hKb e (5/2) v h1 + have hL : 0 ≤ L := by dsimp [L]; positivity + have hstep : ∀ ε : ℝ, 0 < ε → ε ≤ 1/10000 → + h ≤ (1+ε*L)*(((1/10000)+ε)/2)*(∑ i,(v i:ℝ)) := by + intro ε hε hε1 + obtain ⟨η,hη,hη1,hηt⟩ := exists_coordinate_time v hv hε + obtain ⟨f,hf,hE,G,hGm,hG,hGs,hn,hH,hheight,hcon⟩ := + lifted_test hKo.measurableSet hKc hB j hη hη1 hε hε1 + let εn : ℝ≥0 := ⟨ε,hε.le⟩ + let A := GaussianKernel.scaleMap (fun i => εn*v i) + have hA : gaussianSymbol A = fun ξ => ε*GaussianKernel.symbol v ξ := by + rw [GaussianKernel.symbol_eq,symbol_mul] + rfl + have hlow := integrated_section_rate hKo hKb e (by norm_num : (0:ℝ) ≤ 5/2) + v hh ha hline hε (by linarith) A hA hGm hG hGs hn hH (by linarith) + have hupp := integral_sliceEnergy_le hG hf A hcon + rw [hA] at hupp + have hweight := energy_weighted_density hf hη v hε.le hηt (fun i => (hE i).le) + have hboth := hlow.trans (hupp.trans hweight) + change ε/(1+ε*L)*h ≤ ε*((1/10000)+ε)/2*(∑ i,(v i:ℝ)) at hboth + have hd : 0 < 1+ε*L := by positivity + have hc : 0 < ε/(1+ε*L) := by positivity + apply (mul_le_mul_iff_of_pos_left hc).mp + calc + ε/(1+ε*L)*h ≤ ε*((1/10000)+ε)/2*(∑ i,(v i:ℝ)) := hboth + _ = ε/(1+ε*L)*((1+ε*L)*(((1/10000)+ε)/2)*(∑ i,(v i:ℝ))) := by field_simp + have hcont : Continuous (fun ε : ℝ => (1+ε*L)*(((1/10000)+ε)/2)*(∑ i,(v i:ℝ))) := by fun_prop + apply ge_of_tendsto ((hcont.tendsto' 0 _ (by ring)).mono_left (show 𝓝[>] (0:ℝ) ≤ 𝓝 0 from nhdsWithin_le_nhds)) + filter_upwards [Ioo_mem_nhdsGT (show (0:ℝ) < 1/10000 by norm_num)] with ε hε + exact hstep ε hε.1 hε.2.le + +lemma section_bound_positive {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (hKc : Convex ℝ K) + (hB : Bound K hKo.measurableSet (1/10000)) (j : ι) + (v : ι → ℝ≥0) (hv : ∀ i,0 < v i) : + Real.exp (-((1/10000:ℝ)/2)*∑ i,(v i:ℝ)) ≤ + sectionNorm K hKo (EuclideanSpace.single j 1) (5/2) 1 v := by + have h1 := (activeHeights_contains_one hKc _ _ (section_crossing hKo.measurableSet hKc hB j)).2 + have hp := sectionNorm_pos hKo hKb (EuclideanSpace.single j 1) (5/2) v h1 + have hh := section_rate_le hKo hKb hKc hB j v hv + rw [← Real.exp_log hp] + apply Real.exp_le_exp.mpr + change -Real.log (sectionNorm K hKo (EuclideanSpace.single j 1) (5/2) 1 v) ≤ _ at hh + linarith + +lemma section_bound {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (hKc : Convex ℝ K) + (hB : Bound K hKo.measurableSet (1/10000)) (j : ι) : + Bound (sectionDomain K (EuclideanSpace.single j 1) (5/2) 1) + (section_open hKo _ _ _).measurableSet (1/10000) := by + intro v + let e := EuclideanSpace.single j (1:ℝ) + let D := sectionDomain K e (5/2) 1 + have hstep : ∀ δ : ℝ,0 < δ → + Real.exp (-((1/10000:ℝ)/2)*(∑ i,((v i:ℝ)+δ))) ≤ + sectionNorm K hKo e (5/2) 1 v := by + intro δ hδ + let w : ι → ℝ≥0 := fun i => v i+⟨δ,hδ.le⟩ + have hw : ∀ i,0 < w i := by intro i; change 0 < (v i:ℝ)+δ; positivity + have hb := section_bound_positive hKo hKb hKc hB j w hw + have hm : ∀ ξ,GaussianKernel.symbol v ξ ≤ GaussianKernel.symbol w ξ := by + intro ξ + unfold GaussianKernel.symbol + apply div_le_div_of_nonneg_right _ (by norm_num : (0:ℝ) ≤ 2) + apply Finset.sum_le_sum + intro i _ + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + change (v i:ℝ) ≤ (v i:ℝ)+δ + linarith + exact hb.trans (compressed_norm_mono_symbol D (section_open hKo e (5/2) 1).measurableSet + _ _ (GaussianKernel.symbol_continuous v).aestronglyMeasurable + (GaussianKernel.symbol_continuous w).aestronglyMeasurable + (GaussianKernel.symbol_nonneg v) (GaussianKernel.symbol_nonneg w) hm) + have hc : Continuous (fun δ : ℝ => Real.exp (-((1/10000:ℝ)/2)*(∑ i,((v i:ℝ)+δ)))) := by fun_prop + apply le_of_tendsto ((hc.tendsto' 0 _ (by simp)).mono_left (show 𝓝[>] (0:ℝ) ≤ 𝓝 0 from nhdsWithin_le_nhds)) + filter_upwards [self_mem_nhdsWithin] with δ hδ + exact hstep δ hδ + +end ShiftedSections + +end + +section + +open MeasureTheory Set +namespace ShiftedSections +open HeatL2.Diagonal +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +abbrev Coeff := EuclideanSpace ℝ ι + +structure Good (K : Set (Coeff (ι := ι))) : Prop where + nonempty : K.Nonempty + isOpen : IsOpen K + bounded : Bornology.IsBounded K + convex : Convex ℝ K + symmetric : ∀ x ∈ K,-x ∈ K + bound : Bound K isOpen.measurableSet (1/10000) + +omit [DecidableEq ι] in +lemma Good.zero_mem {K : Set (Coeff (ι := ι))} (hK : Good K) : (0:Coeff) ∈ K := + zero_mem_of_symmetric_convex hK.convex hK.symmetric hK.nonempty + +lemma Good.section {K : Set (Coeff (ι := ι))} (hK : Good K) (j : ι) : + Good (sectionDomain K (EuclideanSpace.single j 1) (5/2) 1) := by + refine ⟨?_,section_open hK.isOpen _ _ _,section_bounded hK.bounded _ (by norm_num), + section_convex hK.convex _ _ _,section_symmetric hK.symmetric _ _ _, + section_bound hK.isOpen hK.bounded hK.convex hK.bound j⟩ + exact (activeHeights_contains_one hK.convex _ _ + (section_crossing hK.isOpen.measurableSet hK.convex hK.bound j)).2.2 + +noncomputable def backward : {n : ℕ} → (Fin n → ι) → Set (Coeff (ι := ι)) → Set (Coeff (ι := ι)) + | 0,_,K => K + | _+1,j,K => sectionDomain (backward (fun i => j i.succ) K) (EuclideanSpace.single (j 0) 1) (5/2) 1 + +lemma backward_good {n : ℕ} (j : Fin n → ι) {K : Set (Coeff (ι := ι))} (hK : Good K) : + Good (backward j K) := by + induction n with + | zero => exact hK + | succ n ih => exact (ih (fun i => j i.succ)).section (j 0) + +noncomputable def walk : {n : ℕ} → (Fin n → ι) → (Fin n → Coeff (ι := ι) → ℝ) → + (Fin n → ℝ) → Coeff (ι := ι) → Coeff (ι := ι) + | 0,_,_,_,x => x + | _+1,j,q,ε,x => walk (fun i => j i.succ) (fun i => q i.succ) (fun i => ε i.succ) + (x+(q 0 x+ε 0) • EuclideanSpace.single (j 0) 1) + +lemma exists_walk {n : ℕ} (j : Fin n → ι) (q : Fin n → Coeff (ι := ι) → ℝ) + (hq : ∀ i x,|q i x| ≤ 1/4) {K : Set (Coeff (ι := ι))} (hK : Good K) + {x : Coeff (ι := ι)} (hx : x ∈ backward j K) : + ∃ ε : Fin n → ℝ,(∀ i,ε i = -1 ∨ ε i=1) ∧ walk j q ε x ∈ K := by + induction n generalizing x with + | zero => exact ⟨Fin.elim0,fun i => i.elim0,hx⟩ + | succ n ih => + have htail := backward_good (fun i : Fin n => j i.succ) hK + obtain ⟨e,he,hxe⟩ := shifted_step htail.convex (EuclideanSpace.single (j 0) 1) hx (hq 0 x) + obtain ⟨ε,hε,hend⟩ := ih (fun i => j i.succ) (fun i => q i.succ) + (fun i x => hq i.succ x) hxe + refine ⟨Fin.cons e ε,?_,?_⟩ + · intro i + refine Fin.cases he (fun i => ?_) i + exact hε i + · simpa only [walk,Fin.cons_zero,Fin.cons_succ] using hend + +lemma adaptive_signs {n : ℕ} (j : Fin n → ι) (q : Fin n → Coeff (ι := ι) → ℝ) + (hq : ∀ i x,|q i x| ≤ 1/4) {K : Set (Coeff (ι := ι))} (hK : Good K) : + ∃ ε : Fin n → ℝ,(∀ i,ε i = -1 ∨ ε i=1) ∧ walk j q ε 0 ∈ K := + exists_walk j q hq hK (backward_good j hK).zero_mem + +end ShiftedSections + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Chaining.lean b/lean/OAI/Analysis/Steinitz/Chaining.lean new file mode 100644 index 0000000000000000000000000000000000000000..81193e973441b68a7af052d18c46d91ed2a44a09 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Chaining.lean @@ -0,0 +1,749 @@ +import OAI.Analysis.Steinitz.GaussianProcess + +namespace OAI + +/-! Gaussian chaining, finite nets, and uniform process bounds. -/ + +section + +open Matrix MeasureTheory ProbabilityTheory Filter +open scoped RealInnerProductSpace ENNReal BigOperators +namespace GaussianChaining + +noncomputable def radius (A : ℝ) (j l : ℕ) : ℝ := + 100*(A+1)*(2:ℝ)^j*(l+1)*(1/2:ℝ)^l +noncomputable def variance (A : ℝ) (j l : ℕ) : ℝ := + A*((2:ℝ)^j)^2*((1/2:ℝ)^l)^4 + +def exponent (j l : ℕ) : ℕ := j+25*(l+1)+4 + +lemma nat_add_one_le_two_pow (j : ℕ) : (j:ℝ)+1 ≤ (2:ℝ)^j := by + exact_mod_cast j.lt_two_pow_self + +lemma exponent_le (j l : ℕ) : (exponent j l : ℝ) ≤ 30*(2:ℝ)^j*(l+1) := by + have hj := nat_add_one_le_two_pow j + have h0 : (0:ℝ) ≤ j := Nat.cast_nonneg j + have h1 : (0:ℝ) ≤ l := Nat.cast_nonneg l + have hp : 0 ≤ (j:ℝ)*l := mul_nonneg h0 h1 + calc + _ ≤ 30*((j:ℝ)+1)*(l+1) := by simp only [exponent,Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_one]; nlinarith + _ ≤ _ := by gcongr + +lemma radius_nonneg {A : ℝ} (hA : 0 ≤ A) (j l : ℕ) : 0 ≤ radius A j l := by + unfold radius + positivity + +lemma tail_threshold_le {A : ℝ} (hA : 1 ≤ A) (j l : ℕ) : + 2*variance A j l+8*Real.sqrt (variance A j l)*(exponent j l) ≤ (radius A j l)^2 := by + let p : ℝ := (2:ℝ)^j + let z : ℝ := (1/2:ℝ)^l + let m : ℝ := l+1 + have hp : 0 ≤ p := by dsimp [p]; positivity + have hz : 0 ≤ z := by dsimp [z]; positivity + have hz1 : z ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) + have hz2 : z^2 ≤ 1 := by nlinarith + have hm : 1 ≤ m := by dsimp [m]; have := Nat.cast_nonneg (α := ℝ) l; linarith + have hs : Real.sqrt (variance A j l) = Real.sqrt A*p*z^2 := by + unfold variance + rw [Real.sqrt_mul (mul_nonneg (by linarith) (sq_nonneg _)),Real.sqrt_mul (by linarith : 0 ≤ A)] + rw [Real.sqrt_sq hp,show (((1/2:ℝ)^l)^4) = (((1/2:ℝ)^l)^2)^2 by ring, + Real.sqrt_sq (sq_nonneg _)] + have hr : (exponent j l : ℝ) ≤ 30*p*m := exponent_le j l + have ha : 0 ≤ A := by linarith + have hsa : Real.sqrt A ≤ A+1 := by + have := Real.sq_sqrt ha + have := Real.sqrt_nonneg A + nlinarith [sq_nonneg (A-1)] + have hc : 2*A+240*Real.sqrt A*m ≤ (100*(A+1)*m)^2 := by + calc + _ ≤ 2*(A+1)*m^2+240*(A+1)*m^2 := by + apply add_le_add + · have hm2 : 1 ≤ m^2 := by nlinarith + nlinarith [mul_nonneg (by linarith : 0 ≤ A+1) (sub_nonneg.mpr hm2)] + · have hm2 : m ≤ m^2 := by nlinarith + exact (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hsa (by norm_num)) (by linarith)).trans + (mul_le_mul_of_nonneg_left hm2 (by positivity)) + _ ≤ _ := by + have h : 242*(A+1) ≤ 10000*(A+1)^2 := by nlinarith [sq_nonneg (A+1)] + nlinarith [mul_nonneg (sub_nonneg.mpr h) (sq_nonneg m)] + rw [hs] + calc + _ ≤ 2*(A*p^2*z^4)+8*(Real.sqrt A*p*z^2)*(30*p*m) := by + unfold variance + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left hr (by positivity)) + _ ≤ (2*A+240*Real.sqrt A*m)*(p*z)^2 := by + have hh : A*p^2*z^2*z^2 ≤ A*p^2*z^2 := + mul_le_of_le_one_right (by positivity) hz2 + nlinarith + _ ≤ (100*(A+1)*m)^2*(p*z)^2 := mul_le_mul_of_nonneg_right hc (sq_nonneg _) + _ = _ := by dsimp [radius,p,z,m]; ring + +lemma exp_exponent_le (j l : ℕ) : + Real.exp (-(exponent j l : ℝ)) ≤ (1/2:ℝ)^(exponent j l) := by + rw [show -(exponent j l : ℝ) = (exponent j l : ℝ)*(-1) by ring,Real.exp_nat_mul] + apply pow_le_pow_left₀ (Real.exp_pos _).le + have h : (2:ℝ) ≤ Real.exp 1 := by have := Real.add_one_le_exp (1:ℝ); linarith + rw [Real.exp_neg] + simpa only [one_div] using one_div_le_one_div_of_le (by norm_num : (0:ℝ)<2) h + +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] + +lemma edge_failure (B : Matrix κ ι ℝ) {A : ℝ} (hA : 1 ≤ A) (j l : ℕ) + (hS : GaussianTail.squareMass B ≤ variance A j l) + (hB : ∀ x : EuclideanSpace ℝ ι, ‖GaussianTail.matrixMap B x‖^2 ≤ 4*‖x‖^2) : + stdGaussian (EuclideanSpace ℝ ι) {x | radius A j l < ‖GaussianTail.matrixMap B x‖} ≤ + ENNReal.ofReal ((1/2:ℝ)^(exponent j l)) := by + apply le_trans (measure_mono (show {x | radius A j l < ‖GaussianTail.matrixMap B x‖} ⊆ + {x | 2*variance A j l+8*Real.sqrt (variance A j l)*(exponent j l) ≤ + ‖GaussianTail.matrixMap B x‖^2} from ?_)) + ((GaussianTail.interpolated_tail B (by unfold variance; positivity) hS hB _).trans + (ENNReal.ofReal_le_ofReal (exp_exponent_le j l))) + intro x hx + have hn := norm_nonneg (GaussianTail.matrixMap B x) + have hr := radius_nonneg (by linarith : 0 ≤ A) j l + have ht := tail_threshold_le hA j l + change radius A j l < ‖GaussianTail.matrixMap B x‖ at hx + change 2*variance A j l+8*Real.sqrt (variance A j l)*(exponent j l) ≤ _ + nlinarith + +lemma entropy_weight (j l : ℕ) : + (2:ℝ≥0∞)^(24*(l+1)) * (1/2:ℝ≥0∞)^(exponent j l) = + (1/2:ℝ≥0∞)^(j+l+5) := by + rw [show exponent j l = 24*(l+1)+(j+l+5) by simp [exponent]; omega,pow_add,← mul_assoc,← mul_pow] + norm_num only [one_div] + rw [ENNReal.mul_inv_cancel (by norm_num) (by norm_num),one_pow,one_mul] + +lemma weight_sum (j : ℕ) : + (∑' l : ℕ, (1/2:ℝ≥0∞)^(j+l+5)) = (1/2:ℝ≥0∞)^(j+4) := by + have he (l : ℕ) : j+l+5 = (j+4)+(l+1) := by omega + simp only [he,pow_add,pow_succ] + rw [ENNReal.tsum_mul_left,ENNReal.tsum_mul_right,ENNReal.tsum_geometric] + norm_num only [one_div,inv_inv] + norm_num + rw [ENNReal.mul_inv_cancel (by norm_num) (by norm_num),mul_one] + +lemma weight_sum_all : (∑' j : ℕ, (1/2:ℝ≥0∞)^(j+4)) = 1/8 := by + simp only [pow_add] + rw [ENNReal.tsum_mul_right,ENNReal.tsum_geometric] + norm_num + calc + _ = ((2:ℝ≥0∞)*2⁻¹)*(2⁻¹)^3 := by ring + _ = _ := by rw [ENNReal.mul_inv_cancel (by norm_num) (by norm_num),one_mul,← ENNReal.inv_pow]; norm_num + +lemma level_failure (S : Finset (Matrix κ ι ℝ)) {A : ℝ} (hA : 1 ≤ A) (j l : ℕ) + (hcard : S.card ≤ 2^(24*(l+1))) + (hS : ∀ B ∈ S, GaussianTail.squareMass B ≤ variance A j l) + (hB : ∀ B ∈ S, ∀ x : EuclideanSpace ℝ ι, ‖GaussianTail.matrixMap B x‖^2 ≤ 4*‖x‖^2) : + stdGaussian (EuclideanSpace ℝ ι) (⋃ B ∈ S, {x | radius A j l < ‖GaussianTail.matrixMap B x‖}) ≤ + (1/2:ℝ≥0∞)^(j+l+5) := by + calc + _ ≤ ∑ B ∈ S, stdGaussian (EuclideanSpace ℝ ι) {x | radius A j l < ‖GaussianTail.matrixMap B x‖} := + measure_biUnion_finset_le _ _ + _ ≤ ∑ _B ∈ S, ENNReal.ofReal ((1/2:ℝ)^(exponent j l)) := + Finset.sum_le_sum fun B h => edge_failure B hA j l (hS B h) (hB B h) + _ = (S.card:ℝ≥0∞)*(1/2:ℝ≥0∞)^(exponent j l) := by + simp [ENNReal.ofReal_pow,ENNReal.inv_pow] + _ ≤ (2:ℝ≥0∞)^(24*(l+1))*(1/2:ℝ≥0∞)^(exponent j l) := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact_mod_cast hcard + _ = _ := entropy_weight j l + +lemma all_edges_failure (S : ℕ → ℕ → Finset (Matrix κ ι ℝ)) {A : ℝ} (hA : 1 ≤ A) + (hcard : ∀ j l, (S j l).card ≤ 2^(24*(l+1))) + (hS : ∀ j l B, B ∈ S j l → GaussianTail.squareMass B ≤ variance A j l) + (hB : ∀ j l B, B ∈ S j l → ∀ x : EuclideanSpace ℝ ι, + ‖GaussianTail.matrixMap B x‖^2 ≤ 4*‖x‖^2) : + stdGaussian (EuclideanSpace ℝ ι) (⋃ j, ⋃ l, ⋃ B ∈ S j l, + {x | radius A j l < ‖GaussianTail.matrixMap B x‖}) ≤ 1/8 := by + apply (measure_iUnion_le _).trans + calc + _ ≤ ∑' j : ℕ, ∑' l : ℕ, (1/2:ℝ≥0∞)^(j+l+5) := by + apply ENNReal.tsum_le_tsum + intro j + apply (measure_iUnion_le _).trans + exact ENNReal.tsum_le_tsum fun l => level_failure (S j l) hA j l (hcard j l) (hS j l) (hB j l) + _ = _ := by simp only [weight_sum,weight_sum_all] + +lemma radius_sum (A : ℝ) (j : ℕ) : + (∑' l : ℕ, radius A j l) = 400*(A+1)*(2:ℝ)^j := by + have he (l : ℕ) : radius A j l = (100*(A+1)*(2:ℝ)^j)*((l+1)*(1/2:ℝ)^l) := by + dsimp [radius]; ring + simp only [he] + rw [tsum_mul_left] + have hs : (∑' l : ℕ, ((l:ℝ)+1)*(1/2:ℝ)^l) = 4 := by + have h1 := hasSum_coe_mul_geometric_of_norm_lt_one (r := (1/2:ℝ)) (by norm_num) + have h2 := hasSum_geometric_of_norm_lt_one (ξ := (1/2:ℝ)) (by norm_num) + have ht := (h1.add h2).tsum_eq + norm_num at ht + simpa only [add_mul,one_mul] using ht + rw [hs] + ring + +end GaussianChaining + +end + +section + +open Filter +open scoped Topology BigOperators +namespace GridNets + +noncomputable def cell (l : ℕ) (a : ℝ) : ℕ := ⌊(64:ℝ)^l*a⌋₊ + +def InSquare (p : ℝ × ℝ) : Prop := 0 ≤ p.1 ∧ p.1 ≤ 1 ∧ 0 ≤ p.2 ∧ p.2 ≤ 1 + +noncomputable def cellPair (l : ℕ) (p : ℝ × ℝ) : ℕ × ℕ := (cell l p.1,cell l p.2) + +def grid (l : ℕ) : Finset (ℕ × ℕ) := Finset.range (64^l+1) ×ˢ Finset.range (64^l+1) + +lemma cell_le (l : ℕ) {a : ℝ} (ha : a ≤ 1) : cell l a ≤ 64^l := by + apply Nat.floor_le_of_le + push_cast + exact mul_le_of_le_one_right (by positivity) ha + +lemma cellPair_mem {k l : ℕ} (hkl : k ≤ l) {p : ℝ × ℝ} (hp : InSquare p) : + cellPair k p ∈ grid l := by + have hn : 64^k ≤ 64^l := Nat.pow_le_pow_right (by norm_num) hkl + simp only [grid,cellPair,Finset.mem_product,Finset.mem_range] + exact ⟨Nat.lt_succ_of_le ((cell_le k hp.2.1).trans hn), + Nat.lt_succ_of_le ((cell_le k hp.2.2.2).trans hn)⟩ + +lemma abs_sub_lt_width (l : ℕ) {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + (h : cell l a = cell l b) : |a-b| < (1/64:ℝ)^l := by + have hp : 0 < (64:ℝ)^l := by positivity + have hfa := Nat.floor_le (mul_nonneg hp.le ha) + have hfb := Nat.floor_le (mul_nonneg hp.le hb) + have hga := Nat.lt_floor_add_one ((64:ℝ)^l*a) + have hgb := Nat.lt_floor_add_one ((64:ℝ)^l*b) + change ⌊(64:ℝ)^l*a⌋₊ = ⌊(64:ℝ)^l*b⌋₊ at h + rw [h] at hfa hga + rw [div_pow,one_pow,abs_lt] + constructor + · have hh : b-a < 1/(64:ℝ)^l := (lt_div_iff₀ hp).mpr (by nlinarith) + linarith + · apply (lt_div_iff₀ hp).mpr + nlinarith + +lemma eventually_cell_separates {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) : + ∀ᶠ l : ℕ in atTop, cell l a = cell l b → a = b := by + by_cases hab : a = b + · exact Eventually.of_forall fun _ _ => hab + · have hp : 0 < |a-b| := abs_pos.mpr (sub_ne_zero.mpr hab) + have hlim := tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0:ℝ) ≤ 1/64) + (by norm_num : (1/64:ℝ)<1) + filter_upwards [hlim.eventually (gt_mem_nhds hp)] with l hl he + exact False.elim ((not_lt_of_ge (le_of_lt hl)) (abs_sub_lt_width l ha hb he)) + +variable {I : Type*} [Fintype I] [Nonempty I] + +noncomputable def point (p : I → ℝ × ℝ) (l : ℕ) (c : ℕ × ℕ) : I := + if h : ∃ i, cellPair l (p i) = c then h.choose else Classical.arbitrary I + +noncomputable def rep (p : I → ℝ × ℝ) (l : ℕ) (i : I) : I := point p l (cellPair l (p i)) + +lemma rep_cell (p : I → ℝ × ℝ) (l : ℕ) (i : I) : + cellPair l (p (rep p l i)) = cellPair l (p i) := by + dsimp [rep,point] + rw [dite_eq_left ⟨i,rfl⟩] + exact Classical.choose_spec (show ∃ k, cellPair l (p k) = cellPair l (p i) from ⟨i,rfl⟩) + +lemma rep_distance (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) (l : ℕ) (i : I) : + |(p (rep p l i)).1-(p i).1| < (1/64:ℝ)^l ∧ + |(p (rep p l i)).2-(p i).2| < (1/64:ℝ)^l := by + have he := rep_cell p l i + exact ⟨abs_sub_lt_width l (hp _).1 (hp _).1 (congrArg Prod.fst he), + abs_sub_lt_width l (hp _).2.2.1 (hp _).2.2.1 (congrArg Prod.snd he)⟩ + +lemma eventually_rep_eq (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) : + ∀ᶠ l : ℕ in atTop, ∀ i, p (rep p l i) = p i := by + have hall : ∀ᶠ l : ℕ in atTop, ∀ i k, cellPair l (p i) = cellPair l (p k) → p i = p k := by + apply eventually_all.mpr + intro i + apply eventually_all.mpr + intro k + filter_upwards [eventually_cell_separates (hp i).1 (hp k).1, + eventually_cell_separates (hp i).2.2.1 (hp k).2.2.1] with l h1 h2 h + exact Prod.ext (h1 (congrArg Prod.fst h)) (h2 (congrArg Prod.snd h)) + filter_upwards [hall] with l hl i + exact hl _ _ (rep_cell p l i) + +lemma grid_card (l : ℕ) : (grid l).card = (64^l+1)^2 := by simp [grid,pow_two] + +lemma grid_card_square_le (l : ℕ) : (grid l).card^2 ≤ 2^(24*(l+1)) := by + rw [grid_card] + have hp : 1 ≤ 64^l := Nat.one_le_pow l 64 (by norm_num) + calc + ((64^l+1)^2)^2 ≤ ((2*64^l)^2)^2 := by gcongr; omega + _ = 2^(24*l+4) := by + rw [← pow_mul, mul_pow, show (64:ℕ)=2^6 by norm_num,← pow_mul,← pow_mul,← pow_add] + congr 1 + omega + _ ≤ _ := Nat.pow_le_pow_right (by norm_num) (by omega) + +lemma image_pair_card_le {α : Type*} [DecidableEq α] (p : I → ℝ × ℝ) + (hp : ∀ i, InSquare (p i)) (l : ℕ) (f : I → I → α) : + (Finset.univ.image (fun i => f (rep p l i) (rep p (l-1) i))).card ≤ 2^(24*(l+1)) := by + classical + have hs : Finset.univ.image (fun i => f (rep p l i) (rep p (l-1) i)) ⊆ + (grid l ×ˢ grid l).image (fun c => f (point p l c.1) (point p (l-1) c.2)) := by + intro a ha + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp ha + exact Finset.mem_image.mpr ⟨(cellPair l (p i),cellPair (l-1) (p i)), + Finset.mem_product.mpr ⟨cellPair_mem le_rfl (hp i),cellPair_mem (Nat.sub_le _ _) (hp i)⟩,rfl⟩ + exact ((Finset.card_le_card hs).trans Finset.card_image_le).trans (by + simpa only [Finset.card_product,pow_two] using grid_card_square_le l) + +end GridNets + +end + +section + +open Matrix MeasureTheory ProbabilityTheory Filter +open scoped RealInnerProductSpace ENNReal BigOperators Topology +namespace GaussianTail +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] + +@[simp] lemma matrixMap_add (B C : Matrix κ ι ℝ) (x : EuclideanSpace ℝ ι) : + matrixMap (B+C) x = matrixMap B x+matrixMap C x := by + apply WithLp.ofLp_injective + exact Matrix.add_mulVec _ _ _ +@[simp] lemma matrixMap_sub (B C : Matrix κ ι ℝ) (x : EuclideanSpace ℝ ι) : + matrixMap (B-C) x = matrixMap B x-matrixMap C x := by + apply WithLp.ofLp_injective + exact Matrix.sub_mulVec _ _ _ +@[simp] lemma matrixMap_zero (x : EuclideanSpace ℝ ι) : matrixMap (0 : Matrix κ ι ℝ) x = 0 := by + apply WithLp.ofLp_injective + exact Matrix.zero_mulVec _ + +omit [DecidableEq ι] in +lemma squareMass_eq_zero {B : Matrix κ ι ℝ} (h : squareMass B = 0) : B = 0 := by + have h1 := (Finset.sum_eq_zero_iff_of_nonneg (fun i _ => + Finset.sum_nonneg (fun k _ => sq_nonneg (B i k)))).mp h + ext i k + have h2 := (Finset.sum_eq_zero_iff_of_nonneg (fun k _ => sq_nonneg (B i k))).mp (h1 i (by simp)) k (by simp) + simpa only [sq_eq_zero_iff,Matrix.zero_apply] using h2 + +lemma difference_operator (B C : Matrix κ ι ℝ) + (hB : ∀ x : EuclideanSpace ℝ ι, ‖matrixMap B x‖^2 ≤ ‖x‖^2) + (hC : ∀ x : EuclideanSpace ℝ ι, ‖matrixMap C x‖^2 ≤ ‖x‖^2) : + ∀ x : EuclideanSpace ℝ ι, ‖matrixMap (B-C) x‖^2 ≤ 4*‖x‖^2 := by + intro x + have hb : ‖matrixMap B x‖ ≤ ‖x‖ := by nlinarith [hB x,norm_nonneg x,norm_nonneg (matrixMap B x)] + have hc : ‖matrixMap C x‖ ≤ ‖x‖ := by nlinarith [hC x,norm_nonneg x,norm_nonneg (matrixMap C x)] + rw [matrixMap_sub] + have h := norm_sub_le (matrixMap B x) (matrixMap C x) + have h0 := norm_nonneg (matrixMap B x-matrixMap C x) + nlinarith +end GaussianTail + +namespace GaussianChaining +open GaussianTail GridNets + +lemma width_power (n : ℕ) : ((1/64:ℝ)^n)^(2/3:ℝ) = ((1/2:ℝ)^n)^4 := by + rw [show (1/64:ℝ)=(1/2)^6 by norm_num,← pow_mul,← Real.rpow_natCast,← Real.rpow_mul (by norm_num), + ← pow_mul,← Real.rpow_natCast] + congr 1 + push_cast + ring + +lemma coordinate_power_bound (n : ℕ) {a : ℝ} (ha : 0 ≤ a) (hab : a ≤ 2*(1/64:ℝ)^n) : + a^(2/3:ℝ) ≤ 2*((1/2:ℝ)^n)^4 := by + have h2 : (2:ℝ)^(2/3:ℝ) ≤ 2 := by + simpa using Real.rpow_le_rpow_of_exponent_le (by norm_num : (1:ℝ)≤2) (by norm_num : (2/3:ℝ)≤1) + calc + _ ≤ (2*(1/64:ℝ)^n)^(2/3:ℝ) := Real.rpow_le_rpow ha hab (by norm_num) + _ = (2:ℝ)^(2/3:ℝ)*((1/2:ℝ)^n)^4 := by rw [Real.mul_rpow (by norm_num) (by positivity),width_power] + _ ≤ _ := mul_le_mul_of_nonneg_right h2 (by positivity) + +lemma width_le_quarter (n : ℕ) : (1/64:ℝ)^n ≤ ((1/2:ℝ)^n)^4 := by + rw [← pow_mul, mul_comm n 4,pow_mul] + apply pow_le_pow_left₀ (by norm_num) + norm_num + +variable {ι κ I : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [Fintype I] [Nonempty I] + +noncomputable def netEnd (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (l : ℕ) (i : I) : Matrix κ ι ℝ := + B (rep p l i) + +noncomputable def netEdge (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) : ℕ → I → Matrix κ ι ℝ + | 0,i => netEnd B p 0 i + | l+1,i => netEnd B p (l+1) i-netEnd B p l i + +noncomputable def edgeSet (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (l : ℕ) : Finset (Matrix κ ι ℝ) := + Finset.univ.image (netEdge B p l) + +omit [DecidableEq ι] in +lemma edgeSet_card (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) (l : ℕ) : + (edgeSet B p l).card ≤ 2^(24*(l+1)) := by + classical + cases l with + | zero => exact image_pair_card_le p hp 0 (fun i _ => B i) + | succ l => + change (Finset.univ.image (fun i => B (rep p (l+1) i)-B (rep p l i))).card ≤ _ + simpa only [Nat.add_sub_cancel] using image_pair_card_le p hp (l+1) (fun i k => B i-B k) + +lemma adjacent_distance (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) (l : ℕ) (i : I) : + |(p (rep p (l+1) i)).1-(p (rep p l i)).1| ≤ 2*(1/64:ℝ)^l ∧ + |(p (rep p (l+1) i)).2-(p (rep p l i)).2| ≤ 2*(1/64:ℝ)^l := by + have h1 := rep_distance p hp (l+1) i + have h2 := rep_distance p hp l i + have hw : (1/64:ℝ)^(l+1) ≤ (1/64:ℝ)^l := by + rw [pow_succ] + exact mul_le_of_le_one_right (by positivity) (by norm_num) + constructor + · have ht := abs_sub_le (p (rep p (l+1) i)).1 (p i).1 (p (rep p l i)).1 + rw [abs_sub_comm (p i).1] at ht + linarith [h1.1,h2.1] + · have ht := abs_sub_le (p (rep p (l+1) i)).2 (p i).2 (p (rep p l i)).2 + rw [abs_sub_comm (p i).2] at ht + linarith [h1.2,h2.2] + +omit [DecidableEq ι] in +lemma netEdge_variance (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) + {C : ℝ} (hC : 0 ≤ C) (j : ℕ) + (hbase : ∀ i, squareMass (B i) ≤ C*((2:ℝ)^j)^2) + (hdiff : ∀ i k, squareMass (B i-B k) ≤ C*((2:ℝ)^j)^2* + (|(p i).1-(p k).1|^(2/3:ℝ)+|(p i).2-(p k).2|)) + (l : ℕ) (i : I) : squareMass (netEdge B p l i) ≤ variance (64*C+1) j l := by + cases l with + | zero => + apply (hbase _).trans + dsimp [variance] + simp only [pow_zero,one_pow,mul_one] + exact mul_le_mul_of_nonneg_right (by linarith) (sq_nonneg _) + | succ l => + have hd := adjacent_distance p hp l i + have hh : |(p (rep p (l+1) i)).1-(p (rep p l i)).1|^(2/3:ℝ)+ + |(p (rep p (l+1) i)).2-(p (rep p l i)).2| ≤ 4*((1/2:ℝ)^l)^4 := by + have h1 := coordinate_power_bound l (abs_nonneg _) hd.1 + have h2 := width_le_quarter l + linarith [hd.2] + calc + _ ≤ C*((2:ℝ)^j)^2*(|(p (rep p (l+1) i)).1-(p (rep p l i)).1|^(2/3:ℝ)+ + |(p (rep p (l+1) i)).2-(p (rep p l i)).2|) := hdiff _ _ + _ ≤ C*((2:ℝ)^j)^2*(4*((1/2:ℝ)^l)^4) := mul_le_mul_of_nonneg_left hh (by positivity) + _ ≤ variance (64*C+1) j (l+1) := by + dsimp [variance] + rw [pow_succ (1/2:ℝ) l] + have hn : 0 ≤ ((2:ℝ)^j)^2*((1/2:ℝ)^l)^4 := by positivity + nlinarith + +lemma netEdge_operator (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) + (hop : ∀ i x, ‖matrixMap (B i) x‖^2 ≤ ‖x‖^2) (l : ℕ) (i : I) : + ∀ x, ‖matrixMap (netEdge B p l i) x‖^2 ≤ 4*‖x‖^2 := by + cases l with + | zero => intro x; exact (hop _ x).trans (by nlinarith [sq_nonneg ‖x‖]) + | succ l => exact difference_operator _ _ (hop _) (hop _) + +omit [Fintype ι] [DecidableEq ι] [Fintype κ] in +lemma netEdge_sum (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (i : I) (n : ℕ) : + ∑ l ∈ Finset.range (n+1), netEdge B p l i = netEnd B p n i := by + induction n with + | zero => simp [netEdge] + | succ n ih => rw [Finset.sum_range_succ,ih,netEdge]; abel + +omit [DecidableEq ι] in +lemma eventually_netEnd_eq (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) + {C : ℝ} (j : ℕ) (hdiff : ∀ i k, squareMass (B i-B k) ≤ C*((2:ℝ)^j)^2* + (|(p i).1-(p k).1|^(2/3:ℝ)+|(p i).2-(p k).2|)) : + ∀ᶠ l : ℕ in atTop, ∀ i, netEnd B p l i = B i := by + filter_upwards [eventually_rep_eq p hp] with l hl i + apply sub_eq_zero.mp + apply squareMass_eq_zero + apply le_antisymm _ (squareMass_nonneg _) + have h := hdiff (rep p l i) i + simpa only [netEnd,hl i, sub_self,abs_zero,Real.zero_rpow (by norm_num : (2/3:ℝ)≠0),add_zero,mul_zero] using h + +lemma radius_summable (A : ℝ) (j : ℕ) : Summable (fun l : ℕ => radius A j l) := by + have h1 := (hasSum_coe_mul_geometric_of_norm_lt_one (r := (1/2:ℝ)) (by norm_num)).summable + have h2 := (hasSum_geometric_of_norm_lt_one (ξ := (1/2:ℝ)) (by norm_num)).summable + have h := (h1.add h2).mul_left (100*(A+1)*(2:ℝ)^j) + apply h.congr + intro l + dsimp [radius] + ring + +lemma netEnd_norm_le (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) {A : ℝ} (hA : 0 ≤ A) (j : ℕ) + (x : EuclideanSpace ℝ ι) + (h : ∀ l i, ‖matrixMap (netEdge B p l i) x‖ ≤ radius A j l) (n : ℕ) (i : I) : + ‖matrixMap (netEnd B p n i) x‖ ≤ 400*(A+1)*(2:ℝ)^j := by + have hs : matrixMap (netEnd B p n i) x = + ∑ l ∈ Finset.range (n+1), matrixMap (netEdge B p l i) x := by + rw [← netEdge_sum B p i n] + simp only [matrixMap, map_sum, _root_.sum_apply] + rw [hs] + calc + _ ≤ ∑ l ∈ Finset.range (n+1), ‖matrixMap (netEdge B p l i) x‖ := norm_sum_le _ _ + _ ≤ ∑ l ∈ Finset.range (n+1), radius A j l := Finset.sum_le_sum fun l _ => h l i + _ ≤ ∑' l, radius A j l := (radius_summable A j).sum_le_tsum _ (fun l _ => radius_nonneg hA j l) + _ = _ := radius_sum A j + +lemma class_failure (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) + {C : ℝ} (hC : 0 ≤ C) (j : ℕ) + (hbase : ∀ i, squareMass (B i) ≤ C*((2:ℝ)^j)^2) + (hdiff : ∀ i k, squareMass (B i-B k) ≤ C*((2:ℝ)^j)^2* + (|(p i).1-(p k).1|^(2/3:ℝ)+|(p i).2-(p k).2|)) + (hop : ∀ i x, ‖matrixMap (B i) x‖^2 ≤ ‖x‖^2) : + stdGaussian (EuclideanSpace ℝ ι) {x | ∃ i,400*(64*C+2)*(2:ℝ)^j < ‖matrixMap (B i) x‖} ≤ + (1/2:ℝ≥0∞)^(j+4) := by + have hA : 1 ≤ 64*C+1 := by linarith + have hsub : {x | ∃ i,400*(64*C+2)*(2:ℝ)^j < ‖matrixMap (B i) x‖} ⊆ + ⋃ l, ⋃ D ∈ edgeSet B p l, {x | radius (64*C+1) j l < ‖matrixMap D x‖} := by + intro x hx + by_contra hbad + have he : ∀ l i, ‖matrixMap (netEdge B p l i) x‖ ≤ radius (64*C+1) j l := by + intro l i + apply le_of_not_gt + intro hg + apply hbad + simp only [Set.mem_iUnion,Set.mem_ofPred_eq] + refine ⟨l,netEdge B p l i,?_,hg⟩ + exact Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + obtain ⟨n,hn⟩ := (eventually_netEnd_eq B p hp j hdiff).exists + obtain ⟨i,hi⟩ := hx + have hb := netEnd_norm_le B p (by linarith : 0 ≤ 64*C+1) j x he n i + rw [hn i] at hb + have hconst : 64*C+1+1=64*C+2 := by ring + rw [hconst] at hb + exact not_lt_of_ge hb hi + apply (measure_mono hsub).trans + calc + _ ≤ ∑' l : ℕ, (1/2:ℝ≥0∞)^(j+l+5) := by + apply (measure_iUnion_le _).trans + apply ENNReal.tsum_le_tsum + intro l + apply level_failure (edgeSet B p l) hA j l (edgeSet_card B p hp l) + · intro D hD + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hD + exact netEdge_variance B p hp hC j hbase hdiff l i + · intro D hD + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hD + exact netEdge_operator B p hop l i + _ = _ := weight_sum j + +end GaussianChaining + +end + +section + +open Matrix +open scoped RealInnerProductSpace +namespace GaussianTail +variable {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν] + [DecidableEq ι] [DecidableEq κ] [DecidableEq ν] + +omit [DecidableEq κ] in +lemma matrixMap_mul (B : Matrix κ ι ℝ) (C : Matrix ι ν ℝ) (x : EuclideanSpace ℝ ν) : + matrixMap (B*C) x=matrixMap B (matrixMap C x) := by + apply WithLp.ofLp_injective + exact (Matrix.mulVec_mulVec (WithLp.ofLp x) B C).symm + +lemma inner_matrixMap (B : Matrix κ ι ℝ) (x : EuclideanSpace ℝ ι) (y : EuclideanSpace ℝ κ) : + ⟪matrixMap B x,y⟫=⟪x,matrixMap B.transpose y⟫ := by + simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial] + change y.ofLp ⬝ᵥ (B.mulVec x.ofLp) = (B.transpose.mulVec y.ofLp) ⬝ᵥ x.ofLp + rw [Matrix.dotProduct_mulVec,Matrix.mulVec_transpose] + +lemma coisometry_operator (B : Matrix κ ι ℝ) (hB : B*B.transpose=1) : + ∀ x : EuclideanSpace ℝ ι, ‖matrixMap B x‖^2 ≤ ‖x‖^2 := by + intro x + have ht : ∀ y : EuclideanSpace ℝ κ, ‖matrixMap B.transpose y‖=‖y‖ := by + intro y + have hh := gram_form B.transpose y + rw [Matrix.transpose_transpose,hB] at hh + have he : toEuclideanCLM (𝕜 := ℝ) (1 : Matrix κ κ ℝ) y=y := by + apply WithLp.ofLp_injective + exact Matrix.one_mulVec _ + rw [he,real_inner_self_eq_norm_sq] at hh + nlinarith [norm_nonneg (matrixMap B.transpose y),norm_nonneg y] + have hi := real_inner_le_norm (x := x) (y := matrixMap B.transpose (matrixMap B x)) + rw [← inner_matrixMap,real_inner_self_eq_norm_sq,ht] at hi + have hn : ‖matrixMap B x‖ ≤ ‖x‖ := by + nlinarith [norm_nonneg (matrixMap B x),norm_nonneg x] + nlinarith [norm_nonneg (matrixMap B x),norm_nonneg x] + +end GaussianTail + +end + +section + +open Matrix MeasureTheory ProbabilityTheory Filter +open scoped RealInnerProductSpace ENNReal NNReal BigOperators Topology +namespace GaussianChaining +open GaussianTail GridNets +variable {ι κ I : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [Fintype I] + +lemma classified_failure (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) + (J : I → ℕ) {C : ℝ} (hC : 0 ≤ C) + (hbase : ∀ i, squareMass (B i) ≤ C*((2:ℝ)^(J i))^2) + (hdiff : ∀ i k, J i=J k → squareMass (B i-B k) ≤ C*((2:ℝ)^(J i))^2* + (|(p i).1-(p k).1|^(2/3:ℝ)+|(p i).2-(p k).2|)) + (hop : ∀ i x, ‖matrixMap (B i) x‖^2 ≤ ‖x‖^2) : + stdGaussian (EuclideanSpace ℝ ι) {x | ∃ i,400*(64*C+2)*(2:ℝ)^(J i) < ‖matrixMap (B i) x‖} ≤ + 1/8 := by + classical + have hj (j : ℕ) : stdGaussian (EuclideanSpace ℝ ι) + {x | ∃ i, J i=j ∧ 400*(64*C+2)*(2:ℝ)^j < ‖matrixMap (B i) x‖} ≤ (1/2:ℝ≥0∞)^(j+4) := by + by_cases h : Nonempty {i // J i=j} + · let := h + have hh := class_failure (fun i : {i // J i=j} => B i) (fun i => p i) + (fun i => hp i) hC j + (fun i => by simpa only [i.property] using hbase i) + (fun i k => by simpa only [i.property] using hdiff i k (i.property.trans k.property.symm)) + (fun i => hop i) + convert hh using 1 + congr 1 + ext x + simp only [Set.mem_ofPred_eq] + constructor + · rintro ⟨i,hi,hh⟩; exact ⟨⟨i,hi⟩,hh⟩ + · rintro ⟨⟨i,hi⟩,hh⟩; exact ⟨i,hi,hh⟩ + · have he : {x : EuclideanSpace ℝ ι | ∃ i, J i=j ∧ 400*(64*C+2)*(2:ℝ)^j < ‖matrixMap (B i) x‖} = ∅ := by + ext x + simp only [Set.mem_ofPred_eq,Set.mem_empty_iff_false,iff_false] + rintro ⟨i,hi,_⟩ + exact h ⟨⟨i,hi⟩⟩ + rw [he,measure_empty] + positivity + have hs : {x | ∃ i,400*(64*C+2)*(2:ℝ)^(J i) < ‖matrixMap (B i) x‖} ⊆ + ⋃ j : ℕ, {x | ∃ i, J i=j ∧ 400*(64*C+2)*(2:ℝ)^j < ‖matrixMap (B i) x‖} := by + rintro x ⟨i,hi⟩ + exact Set.mem_iUnion.mpr ⟨J i,i,rfl,hi⟩ + apply (measure_mono hs).trans + apply (measure_iUnion_le _).trans + exact (ENNReal.tsum_le_tsum hj).trans_eq weight_sum_all + +lemma classified_survival (B : I → Matrix κ ι ℝ) (p : I → ℝ × ℝ) (hp : ∀ i, InSquare (p i)) + (J : I → ℕ) {C : ℝ} (hC : 0 ≤ C) + (hbase : ∀ i, squareMass (B i) ≤ C*((2:ℝ)^(J i))^2) + (hdiff : ∀ i k, J i=J k → squareMass (B i-B k) ≤ C*((2:ℝ)^(J i))^2* + (|(p i).1-(p k).1|^(2/3:ℝ)+|(p i).2-(p k).2|)) + (hop : ∀ i x, ‖matrixMap (B i) x‖^2 ≤ ‖x‖^2) : + (1/2:ℝ≥0∞) ≤ stdGaussian (EuclideanSpace ℝ ι) + {x | ∀ i, ‖matrixMap (B i) x‖ ≤ 400*(64*C+2)*(2:ℝ)^(J i)} := by + let S := {x : EuclideanSpace ℝ ι | ∀ i, ‖matrixMap (B i) x‖ ≤ 400*(64*C+2)*(2:ℝ)^(J i)} + have hm : MeasurableSet S := by + simp only [S,Set.ofPred_forall] + exact MeasurableSet.iInter fun i => + measurableSet_le (matrixMap (B i)).continuous.norm.measurable measurable_const + have hc : Sᶜ = {x | ∃ i,400*(64*C+2)*(2:ℝ)^(J i) < ‖matrixMap (B i) x‖} := by + ext x; simp [S,not_forall] + have hf := classified_failure B p hp J hC hbase hdiff hop + rw [← hc,measure_compl hm (measure_ne_top _ _),measure_univ] at hf + have ht : (1:ℝ≥0∞) ≤ stdGaussian (EuclideanSpace ℝ ι) S + 1/8 := by + exact tsub_le_iff_left.mp hf + have hn : (1/2:ℝ≥0∞)+1/8 ≤ 1 := by + apply (ENNReal.toReal_le_toReal (by finiteness) (by finiteness)).mp + rw [ENNReal.toReal_add (by finiteness) (by finiteness)] + norm_num + change (1/2:ℝ≥0∞) ≤ stdGaussian (EuclideanSpace ℝ ι) S + exact (ENNReal.add_le_add_iff_right (by norm_num : (1/8:ℝ≥0∞)≠⊤)).mp (hn.trans ht) + +noncomputable def sizeClass (k : ℝ) : ℕ := + if hk : 1/4 ≤ k then (exists_nat_pow_near (by linarith : (1:ℝ) ≤ 4*k) (by norm_num : (1:ℝ)<4)).choose else 0 + +lemma sizeClass_bounds {k : ℝ} (hk : 1/4 ≤ k) : + ((2:ℝ)^(sizeClass k))^2 ≤ 4*k ∧ k < ((2:ℝ)^(sizeClass k))^2 := by + unfold sizeClass + rw [dite_eq_left hk] + set j := (exists_nat_pow_near (by linarith : (1:ℝ) ≤ 4*k) (by norm_num : (1:ℝ)<4)).choose + have hj := (exists_nat_pow_near (by linarith : (1:ℝ) ≤ 4*k) (by norm_num : (1:ℝ)<4)).choose_spec + change (4:ℝ)^j ≤ 4*k ∧ 4*k < 4^(j+1) at hj + have he : ((2:ℝ)^j)^2 = 4^j := by rw [← pow_mul,mul_comm j 2,pow_mul]; norm_num + rw [he] + constructor + · exact hj.1 + · rw [pow_succ] at hj; linarith [hj.2] + +lemma sizeClass_sqrt {k : ℝ} (hk : 1/4 ≤ k) : + (2:ℝ)^(sizeClass k) ≤ 2*Real.sqrt k := by + have hs := Real.sq_sqrt (by linarith : 0 ≤ k) + have hh := (sizeClass_bounds hk).1 + have h0 := Real.sqrt_nonneg k + have hp : (0:ℝ) ≤ 2^(sizeClass k) := by positivity + nlinarith + +end GaussianChaining + +end + +section + +open Matrix MeasureTheory ProbabilityTheory +open scoped ENNReal RealInnerProductSpace BigOperators +namespace GaussianAR +open GaussianTail GaussianChaining +variable {ι κ I : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + [Fintype I] + +omit [DecidableEq κ] in +lemma block_survival (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (n : ℕ) (F : I → Matrix κ ι ℝ) (t : I → Fin (n+1)) + (a b k : I → ℝ) (ha : ∀ i,a i ∈ Set.Icc (0:ℝ) 1) (hb : ∀ i,b i ∈ Set.Icc (0:ℝ) 1) + (hk : ∀ i,1/4 ≤ k i) {C θ : ℝ} (hC : 0 ≤ C) + (hs : ∀ i,squareMass (F i) ≤ C*k i) + (hi : ∀ i j, squareMass (F i-F j) ≤ C*(1+k i+k j)*|a i-a j|^(2/3:ℝ)) + (ht : ∀ i,(F i*diagonal (fun j => 1-r j)*(F i).transpose).trace ≤ C*k i*θ) + (hbtime : ∀ i j, θ*|((t i).val:ℝ)-(t j).val| ≤ |b i-b j|) + (hop : ∀ i x,‖matrixMap (F i) x‖^2 ≤ ‖x‖^2) : + (1/2:ℝ≥0∞) ≤ stdGaussian (EuclideanSpace ℝ (Fin (n+1)×ι)) + {x | ∀ i, ‖matrixMap (F i*evaluation r n (t i)) x‖ ≤ + 800*(640*C+2)*Real.sqrt (k i)} := by + let B i := F i*evaluation r n (t i) + let J i := sizeClass (k i) + have hJ (i) : k i < ((2:ℝ)^(J i))^2 := (sizeClass_bounds (hk i)).2 + have hJ1 (i) : (1:ℝ) ≤ ((2:ℝ)^(J i))^2 := by + exact one_le_pow₀ (one_le_pow₀ (by norm_num)) + have hbase (i) : squareMass (B i) ≤ (10*C)*((2:ℝ)^(J i))^2 := by + dsimp [B] + rw [squareMass_evaluation _ r hr hr1] + have hh := mul_le_mul_of_nonneg_left (hJ i).le hC + have hn : 0 ≤ C*((2:ℝ)^(J i))^2 := by positivity + linarith [hs i] + have hd (i j) (hij : J i=J j) : squareMass (B i-B j) ≤ + (10*C)*((2:ℝ)^(J i))^2*(|a i-a j|^(2/3:ℝ)+|b i-b j|) := by + have he : B i-B j=(F i-F j)*evaluation r n (t i)+ + F j*(evaluation r n (t i)-evaluation r n (t j)) := by + dsimp [B]; rw [Matrix.sub_mul,Matrix.mul_sub]; abel + rw [he] + apply (squareMass_add_le _ _).trans + rw [squareMass_evaluation _ r hr hr1] + have hti := squareMass_time_le (F j) r hr hr1 n (t i) (t j) + have hmul := mul_le_mul_of_nonneg_left (ht j) (by positivity : 0 ≤ 2*|((t i).val:ℝ)-(t j).val|) + have hk0 : 0 ≤ k j := le_trans (by norm_num) (hk j) + have hbt := mul_le_mul_of_nonneg_left (hbtime i j) (by positivity : 0 ≤ 2*C*k j) + have htime : squareMass (F j*(evaluation r n (t i)-evaluation r n (t j))) ≤ + 2*C*k j*|b i-b j| := by + nlinarith [hti] + have hjval : k j < ((2:ℝ)^(J i))^2 := by rw [hij]; exact hJ j + have hh0 : C*(1+k i+k j) ≤ 3*C*((2:ℝ)^(J i))^2 := by + nlinarith [mul_nonneg hC (sub_nonneg.mpr (hJ1 i)), + mul_nonneg hC (sub_nonneg.mpr (hJ i).le),mul_nonneg hC (sub_nonneg.mpr hjval.le)] + have hh := mul_le_mul_of_nonneg_right hh0 (by positivity : 0 ≤ |a i-a j|^(2/3:ℝ)) + have hh1 := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hjval.le (by positivity : 0 ≤ 2*C)) (abs_nonneg (b i-b j)) + have hn1 : 0 ≤ C*((2:ℝ)^(J i))^2*|a i-a j|^(2/3:ℝ) := by positivity + have hn2 : 0 ≤ C*((2:ℝ)^(J i))^2*|b i-b j| := by positivity + nlinarith [hi i j] + have hopB (i) (x : EuclideanSpace ℝ (Fin (n+1)×ι)) : ‖matrixMap (B i) x‖^2 ≤ ‖x‖^2 := by + dsimp [B] + rw [matrixMap_mul] + exact (hop i _).trans (coisometry_operator _ (evaluation_coisometry r hr hr1 n (t i)) x) + have hh := classified_survival B (fun i => (a i,b i)) (fun i => ⟨(ha i).1,(ha i).2,(hb i).1,(hb i).2⟩) J + (by positivity : 0 ≤ 10*C) hbase hd hopB + apply hh.trans (measure_mono ?_) + intro x hx i + apply (hx i).trans + have hm := mul_le_mul_of_nonneg_left (sizeClass_sqrt (hk i)) + (by positivity : 0 ≤ 400*(64*(10*C)+2)) + nlinarith + +end GaussianAR + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Coefficients.lean b/lean/OAI/Analysis/Steinitz/Coefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1a68ce2636f38b2a527a26c36c65c3b39487a81 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Coefficients.lean @@ -0,0 +1,893 @@ +import OAI.Analysis.Steinitz.Gain + +namespace OAI + +/-! Filtered coefficients and their quadratic energy bounds. -/ + +namespace EuclideanSteinitz.Gain +open Matrix MatrixEnergy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma relativeMoment_controls_gain {Z V : Matrix ι ι ℝ} + (hZ : Z.PosSemidef) (hV : V.PosSemidef) {q : ℝ} (hq : 0 ≤ q) + (hG : relativeMoment (1 + Z) V ≤ q ^ exponent) : + V ≤ q • (1 + Z) := by + have hS : ((1 : Matrix ι ι ℝ) + Z).PosDef := Matrix.PosDef.one.add_posSemidef hZ + have hA := trace_power_bound (sandwich_psd hV (1 + Z)) exponent_pos hq hG + have h := congruence_mono hA (CFC.sqrt (1 + Z)) + rw [sqrt_transpose] at h + have he : CFC.sqrt (1 + Z) * (inverseSqrt (1 + Z) * V * inverseSqrt (1 + Z)) * + CFC.sqrt (1 + Z) = V := by + simp only [← Matrix.mul_assoc, sqrt_mul_inverseSqrt hS, Matrix.one_mul] + rw [Matrix.mul_assoc, inverseSqrt_mul_sqrt hS, Matrix.mul_one] + rw [he] at h + simpa only [Matrix.mul_smul, Matrix.smul_mul, Matrix.mul_one, + CFC.sqrt_mul_sqrt_self _ hS.posSemidef.nonneg] using h + +lemma accumulated_gain_bound {Y : Matrix ι ι ℝ} (hY : Y.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) {E : ℝ} + (hcost : gainCost Y ps ≤ E) (hsmall : E ≤ 1 / (16 * gainConstant)) : + let q := (gainConstant * E) ^ (1 / exponent) + 0 ≤ q ∧ q < 1 / 4 ∧ + (follow Y 0 ps).2 ≤ q • (1 + (follow Y 0 ps).1) ∧ + (follow Y 0 ps).2 ≤ q • (1 + ((follow Y 0 ps).1 + (follow Y 0 ps).2)) := by + have hE : 0 ≤ E := (gainCost_nonneg hY hp).trans hcost + have hc : 0 ≤ gainConstant * E := mul_nonneg gainConstant_pos.le hE + have hce : gainConstant * E ≤ 1 / 16 := by + have hd := (le_div_iff₀ (mul_pos (by norm_num : (0 : ℝ) < 16) gainConstant_pos)).mp hsmall + nlinarith + let q := (gainConstant * E) ^ (1 / exponent) + have hq : 0 ≤ q := Real.rpow_nonneg hc _ + have hpow : q ^ exponent = gainConstant * E := by + dsimp only [q] + rw [← Real.rpow_mul hc] + rw [one_div_mul_cancel (ne_of_gt exponent_pos), Real.rpow_one] + have hquarter : (1 / 16 : ℝ) < (1 / 4 : ℝ) ^ exponent := by + rw [show (1 / 4 : ℝ) = (1 / 2 : ℝ) ^ 2 by norm_num, ← Real.rpow_natCast_mul (by norm_num)] + norm_num [exponent, Real.rpow_natCast] + have hqsmall : q < 1 / 4 := by + apply (Real.rpow_lt_rpow_iff hq (by norm_num) exponent_pos).mp + rw [hpow] + exact hce.trans_lt hquarter + have hb : relativeMoment (1 + Y) 0 + gainConstant * gainCost (Y + 0) ps ≤ 1 / 4 := by + rw [relativeMoment_zero, zero_add, add_zero] + have hh := mul_le_mul_of_nonneg_left hcost gainConstant_pos.le + linarith + have hg := relativeMoment_path hY Matrix.PosSemidef.zero hp hb + rw [relativeMoment_zero, zero_add, add_zero] at hg + have hpsd := follow_psd hY Matrix.PosSemidef.zero hp + have hG : relativeMoment (1 + (follow Y 0 ps).1) (follow Y 0 ps).2 ≤ q ^ exponent := by + rw [hpow] + exact hg.trans (mul_le_mul_of_nonneg_left hcost gainConstant_pos.le) + have hbound := relativeMoment_controls_gain hpsd.1 hpsd.2 hq hG + refine ⟨hq, hqsmall, hbound, hbound.trans ?_⟩ + apply smul_le_smul_of_nonneg_left _ hq + exact add_le_add le_rfl (le_add_of_nonneg_right hpsd.2.nonneg) + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz.PotentialScalar +open MatrixEnergy + +noncomputable def rate (x : ℝ) : ℝ := min (Real.sqrt x) ((max 1 x)⁻¹ ^ 2) +noncomputable def primitive (x : ℝ) : ℝ := ∫ u in (0 : ℝ)..x, rate u + +lemma continuous_rate : Continuous rate := by + unfold rate + apply Continuous.min Real.continuous_sqrt + apply Continuous.pow + apply Continuous.inv₀ (continuous_const.max continuous_id) + intro x + exact ne_of_gt (lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (le_max_left _ _)) + +lemma rate_nonneg (x : ℝ) : 0 ≤ rate x := le_min (Real.sqrt_nonneg _) (sq_nonneg _) + +lemma rate_small {x : ℝ} (hx : x ≤ 1) : rate x = Real.sqrt x := by + unfold rate + rw [max_eq_left hx] + norm_num only [inv_one, one_pow] + exact min_eq_left (Real.sqrt_le_one.mpr hx) + +lemma rate_large {x : ℝ} (hx : 1 ≤ x) : rate x = x⁻¹ ^ 2 := by + unfold rate + rw [max_eq_right hx] + apply min_eq_right + have hx0 : 0 < x := lt_of_lt_of_le (by norm_num) hx + have hi : x⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hx + have his : x⁻¹ ^ 2 ≤ 1 := pow_le_one₀ (inv_nonneg.mpr hx0.le) hi + exact his.trans (Real.one_le_sqrt.mpr hx) + +lemma rate_eq {x : ℝ} (hx : 0 ≤ x) : rate x = weight x / x := by + by_cases h1 : x ≤ 1 + · rw [rate_small h1, integrand_of_le_one hx h1, Real.sqrt_eq_rpow] + · have h1' : 1 ≤ x := (lt_of_not_ge h1).le + rw [rate_large h1', integrand_of_one_le h1'] + rw [show (-2 : ℝ) = -1 * 2 by norm_num, Real.rpow_mul hx, Real.rpow_neg_one, + Real.rpow_two] + +lemma rate_zero_of_nonpos {x : ℝ} (hx : x ≤ 0) : rate x = 0 := by + rw [rate_small (hx.trans (by norm_num)), Real.sqrt_eq_zero_of_nonpos hx] + +lemma primitive_eq {x : ℝ} (hx : 0 ≤ x) : primitive x = potential x := by + apply intervalIntegral.integral_congr + intro u hu + rw [Set.uIcc_of_le hx] at hu + exact rate_eq hu.1 + +lemma primitive_derivative (x : ℝ) : HasDerivAt primitive (rate x) x := by + exact intervalIntegral.integral_hasDerivAt_right + (continuous_rate.intervalIntegrable 0 x) + continuous_rate.stronglyMeasurable.stronglyMeasurableAtFilter continuous_rate.continuousAt + +lemma primitive_monotone : Monotone primitive := by + apply monotone_of_hasDerivAt_nonneg primitive_derivative + exact rate_nonneg + +lemma primitive_zero_of_nonpos {x : ℝ} (hx : x ≤ 0) : primitive x = 0 := by + unfold primitive + calc + _ = ∫ u in (0 : ℝ)..x, (0 : ℝ) := by + apply intervalIntegral.integral_congr + intro u hu + rw [Set.uIcc_of_ge hx] at hu + exact rate_zero_of_nonpos hu.2 + _ = 0 := by simp + +lemma large_add_linear_monotone : MonotoneOn (fun x : ℝ => x⁻¹ ^ 2 + 2 * x) (Set.Ici 1) := by + apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ici 1) + (f' := fun x => -2 * x⁻¹ ^ 3 + 2) + · have hne : ∀ x ∈ Set.Ici (1 : ℝ), x ≠ 0 := fun x hx => ne_of_gt (lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) hx) + exact (((continuousOn_id.inv₀ hne).pow 2).add + (continuous_const.mul continuous_id).continuousOn) + · intro x hx + rw [interior_Ici] at hx + change 1 < x at hx + have hxn : x ≠ 0 := ne_of_gt (by linarith : 0 < x) + have h := (((hasDerivAt_id x).inv hxn).fun_pow 2).fun_add (hasDerivAt_const_mul (x := x) 2) + convert! h.hasDerivWithinAt using 1 + simp + ring + · intro x hx + rw [interior_Ici] at hx + change 1 < x at hx + have hi : x⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hx.le + have hp : x⁻¹ ^ 3 ≤ 1 := pow_le_one₀ (inv_nonneg.mpr (by linarith)) hi + linarith + +lemma rate_add_linear_monotone : Monotone (fun x : ℝ => rate x + 2 * x) := by + intro x y hxy + change rate x + 2 * x ≤ rate y + 2 * y + by_cases hx : x ≤ 1 + · by_cases hy : y ≤ 1 + · rw [rate_small hx, rate_small hy] + exact add_le_add (Real.sqrt_le_sqrt hxy) (by linarith) + · have hy' : 1 ≤ y := (lt_of_not_ge hy).le + have hl : rate x + 2 * x ≤ 3 := by + rw [rate_small hx] + have hs := Real.sqrt_le_one.mpr hx + linarith + have hr := large_add_linear_monotone (show (1 : ℝ) ≤ 1 by norm_num) hy' hy' + rw [rate_large hy'] + norm_num only [inv_one, one_pow, mul_one, show (1 : ℝ) + 2 = 3 by norm_num] at hr + exact hl.trans hr + · have hx' : 1 ≤ x := (lt_of_not_ge hx).le + have hy' := hx'.trans hxy + rw [rate_large hx', rate_large hy'] + exact large_add_linear_monotone hx' hy' hxy + +lemma convexified_derivative (x : ℝ) : + HasDerivAt (fun u : ℝ => primitive u + u ^ 2) (rate x + 2 * x) x := by + simpa using! (primitive_derivative x).fun_add ((hasDerivAt_id x).fun_pow 2) + +lemma convexified_convex : ConvexOn ℝ Set.univ (fun x : ℝ => primitive x + x ^ 2) := by + apply Monotone.convexOn_univ_of_deriv (fun x => (convexified_derivative x).differentiableAt) + have he : deriv (fun x : ℝ => primitive x + x ^ 2) = (fun x => rate x + 2 * x) := by + funext x + exact (convexified_derivative x).deriv + rw [he] + exact rate_add_linear_monotone + +end EuclideanSteinitz.PotentialScalar + +namespace EuclideanSteinitz.PotentialScalar +open MatrixEnergy + +lemma sizeWeight_small {x : ℝ} (hx : 0 ≤ x) (hx1 : x ≤ 1) : sizeWeight x = Real.sqrt x := by + rw [sizeWeight, show exponent - 1 = (1 / 2 : ℝ) by norm_num [exponent], ← Real.sqrt_eq_rpow] + rcases hx.eq_or_lt with rfl | hx + · norm_num + · apply min_eq_left + exact (Real.sqrt_le_one.mpr hx1).trans ((one_le_inv₀ hx).mpr hx1) + +lemma sizeWeight_large {x : ℝ} (hx : 1 ≤ x) : sizeWeight x = x⁻¹ := by + rw [sizeWeight, show exponent - 1 = (1 / 2 : ℝ) by norm_num [exponent], ← Real.sqrt_eq_rpow] + exact min_eq_right ((inv_le_one_of_one_le₀ hx).trans (Real.one_le_sqrt.mpr hx)) + +lemma primitive_small {x : ℝ} (hx : 0 ≤ x) (hx1 : x ≤ 1) : + primitive x = (2 / 3 : ℝ) * x * Real.sqrt x := by + rw [primitive_eq hx, potential_small hx hx1, + show exponent = (1 / 2 : ℝ) + 1 by norm_num [exponent], + Real.rpow_add_one' hx (by norm_num : (1 / 2 : ℝ) + 1 ≠ 0), ← Real.sqrt_eq_rpow] + ring + +lemma primitive_nonneg (x : ℝ) : 0 ≤ primitive x := by + by_cases hx : 0 ≤ x + · have h := primitive_monotone hx + simpa only [primitive_zero_of_nonpos (le_refl (0 : ℝ))] using h + · rw [primitive_zero_of_nonpos (le_of_not_ge hx)] + +lemma primitive_sub_le {x z M : ℝ} (hzx : z ≤ x) + (hM : ∀ u ∈ Set.Icc z x, rate u ≤ M) : primitive x - primitive z ≤ (x - z) * M := by + have he := intervalIntegral.integral_add_adjacent_intervals (μ := MeasureTheory.volume) + (continuous_rate.intervalIntegrable 0 z) (continuous_rate.intervalIntegrable z x) + have hi := intervalIntegral.integral_mono_on hzx (continuous_rate.intervalIntegrable z x) + (intervalIntegrable_const : IntervalIntegrable (fun _ : ℝ => M) MeasureTheory.volume z x) hM + simp only [intervalIntegral.integral_const, smul_eq_mul] at hi + unfold primitive + linarith + +lemma rate_le_inverse_sq {u : ℝ} (hu : 0 < u) : rate u ≤ u⁻¹ ^ 2 := by + apply (min_le_right _ _).trans + exact pow_le_pow_left₀ (by positivity) + (inv_le_inv₀ (lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (le_max_left 1 u)) hu |>.mpr + (le_max_right _ _)) 2 + +lemma direct_scalar_bound {x q : ℝ} (hx : 0 ≤ x) (hq : 0 ≤ q) (hq1 : q ≤ 1 / 4) : + primitive x - primitive ((1 - q) * x - q) ≤ 8 * q * sizeWeight x := by + let z := (1 - q) * x - q + have hzx : z ≤ x := by dsimp [z]; nlinarith + have hd : x - z = q * (1 + x) := by dsimp [z]; ring + by_cases hsmall : x ≤ 4 * q + · have hx1 : x ≤ 1 := by linarith + rw [sizeWeight_small hx hx1, primitive_small hx hx1] + have hp := primitive_nonneg z + have hm := mul_le_mul_of_nonneg_right hsmall (Real.sqrt_nonneg x) + have hqs := mul_nonneg hq (Real.sqrt_nonneg x) + change _ - primitive z ≤ _ + nlinarith + · have hlarge : 4 * q < x := lt_of_not_ge hsmall + have hx0 : 0 < x := by linarith + have hhalf : x / 2 ≤ z := by + dsimp [z] + have hqx := mul_le_mul_of_nonneg_right hq1 hx + nlinarith + by_cases hx1 : x ≤ 1 + · have hi := primitive_sub_le hzx (M := Real.sqrt x) (fun u hu => + (min_le_left _ _).trans (Real.sqrt_le_sqrt hu.2)) + rw [hd] at hi + rw [sizeWeight_small hx hx1] + have hm := mul_le_mul_of_nonneg_left hx1 hq + have hs := Real.sqrt_nonneg x + change _ - primitive z ≤ _ + nlinarith [mul_nonneg (by linarith : 0 ≤ 8 * q - q * (1 + x)) hs] + · have hx1' : 1 ≤ x := (lt_of_not_ge hx1).le + have hrate : ∀ u ∈ Set.Icc z x, rate u ≤ 4 * x⁻¹ ^ 2 := by + intro u hu + have hu0 : 0 < u := lt_of_lt_of_le (by linarith : 0 < x / 2) (hhalf.trans hu.1) + have hi : u⁻¹ ≤ 2 * x⁻¹ := by + calc + u⁻¹ ≤ (x / 2)⁻¹ := (inv_le_inv₀ hu0 (half_pos hx0)).mpr (hhalf.trans hu.1) + _ = 2 * x⁻¹ := by simp [div_eq_mul_inv] + have hh := pow_le_pow_left₀ (inv_nonneg.mpr hu0.le) hi 2 + exact (rate_le_inverse_sq hu0).trans (by nlinarith) + have hi := primitive_sub_le hzx hrate + rw [hd] at hi + rw [sizeWeight_large hx1'] + change _ - primitive z ≤ _ + have he : x * x⁻¹ = 1 := mul_inv_cancel₀ (ne_of_gt hx0) + have him : x⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hx1' + have hin : 0 ≤ x⁻¹ := inv_nonneg.mpr hx + have hs : x * x⁻¹ ^ 2 = x⁻¹ := by calc + _ = (x * x⁻¹) * x⁻¹ := by ring + _ = x⁻¹ := by rw [he, one_mul] + have hsq : x⁻¹ ^ 2 ≤ x⁻¹ := by nlinarith + have hc := mul_le_mul_of_nonneg_left hsq (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hq) + nlinarith + +end EuclideanSteinitz.PotentialScalar + +namespace EuclideanSteinitz.Spectral +open Matrix MatrixEnergy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma trace_primitive_monotone {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (_hB : B.IsHermitian) (hAB : A ≤ B) : + (cfc PotentialScalar.primitive A).trace ≤ (cfc PotentialScalar.primitive B).trace := by + have hH := Matrix.le_iff.mp hAB + have hd (t : ℝ) := trace_semiconvex_affine_derivative hA hH.1 + PotentialScalar.primitive PotentialScalar.rate PotentialScalar.continuous_rate + PotentialScalar.primitive_derivative PotentialScalar.convexified_convex t + have hm := monotone_of_hasDerivAt_nonneg hd (fun t => by + apply MatrixEnergy.trace_mul_nonneg _ hH + apply Matrix.nonneg_iff_posSemidef.mp + exact cfc_nonneg (fun x _ => PotentialScalar.rate_nonneg x)) + have h := hm (show (0 : ℝ) ≤ 1 by norm_num) + simpa only [zero_smul, one_smul, add_zero, add_sub_cancel] using h + +lemma cfc_primitive_eq {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + cfc PotentialScalar.primitive A = cfc potential A := by + apply cfc_congr + intro x hx + exact PotentialScalar.primitive_eq (spectrum_nonneg_of_nonneg hA.nonneg hx) + +lemma trace_potential_direct {X Z : Matrix ι ι ℝ} (hX : X.PosSemidef) (hZ : Z.PosSemidef) + {q : ℝ} (hq : 0 ≤ q) (hq1 : q ≤ 1 / 4) + (hXZ : X - Z ≤ q • (1 + X)) : + (cfc potential X).trace - (cfc potential Z).trace ≤ 8 * q * (cfc sizeWeight X).trace := by + let A : Matrix ι ι ℝ := (1 - q) • X - q • 1 + have hA : A.IsHermitian := (hX.1.smul (IsSelfAdjoint.all _)).sub (isHermitian_one.smul (IsSelfAdjoint.all _)) + have hAZ : A ≤ Z := by + apply Matrix.le_iff.mpr + have hh := Matrix.le_iff.mp hXZ + convert! hh using 1 + dsimp only [A] + module + have hm := trace_primitive_monotone hA hZ.1 hAZ + have he : cfc (fun x : ℝ => (1 - q) * x - q) X = A := by + rw [cfc_sub (fun x : ℝ => (1 - q) * x) (fun _ => q) X (by fun_prop) (by fun_prop), + cfc_const_mul (1 - q) (fun x : ℝ => x) X (by fun_prop), cfc_id' ℝ X hX.1.isSelfAdjoint, + cfc_const q X hX.1.isSelfAdjoint, Algebra.algebraMap_eq_smul_one] + have hf : Continuous PotentialScalar.primitive := continuous_iff_continuousAt.mpr + (fun x => (PotentialScalar.primitive_derivative x).continuousAt) + have hcomp : cfc (fun x : ℝ => PotentialScalar.primitive ((1 - q) * x - q)) X = + cfc PotentialScalar.primitive A := by + rw [← he] + exact cfc_comp PotentialScalar.primitive (fun x : ℝ => (1 - q) * x - q) X + hX.1.isSelfAdjoint hf.continuousOn (by fun_prop) + have hb : (cfc PotentialScalar.primitive X).trace - (cfc PotentialScalar.primitive A).trace ≤ + 8 * q * (cfc sizeWeight X).trace := by + rw [← hcomp, trace_cfc hX.1, trace_cfc hX.1, trace_cfc hX.1, + ← Finset.sum_sub_distrib, Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + exact PotentialScalar.direct_scalar_bound (hX.eigenvalues_nonneg i) hq hq1 + rw [cfc_primitive_eq hX] at hb + rw [cfc_primitive_eq hZ] at hm + linarith + +end EuclideanSteinitz.Spectral + +namespace EuclideanSteinitz.Endpoint +open Matrix MatrixEnergy Spectral +open scoped MatrixOrder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [Fintype ι] [DecidableEq ι] in +lemma diag_le {A B : Matrix ι ι ℝ} (hAB : A ≤ B) (i : ι) : A i i ≤ B i i := by + have h := (Matrix.le_iff.mp hAB).diag_nonneg (i := i) + simpa only [Matrix.sub_apply, sub_nonneg] using h + +lemma diagonalize {A : Matrix ι ι ℝ} (hA : A.IsHermitian) : + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * A * hA.eigenvectorUnitary = + diagonal hA.eigenvalues := by + conv_lhs => arg 1; arg 2; rw [real_spectral hA] + simp only [← Matrix.mul_assoc, unitary_transpose_mul, Matrix.one_mul] + rw [Matrix.mul_assoc, unitary_transpose_mul, Matrix.mul_one] + +lemma inverse_spectral {A : Matrix ι ι ℝ} (hA : A.PosDef) : + A⁻¹ = (hA.1.eigenvectorUnitary : Matrix ι ι ℝ) * + diagonal (fun i => (hA.1.eigenvalues i)⁻¹) * + (hA.1.eigenvectorUnitary : Matrix ι ι ℝ).transpose := by + rw [nonsing_inv_eq_ringInverse, ← cfc_ringInverse_id (R := ℝ) A hA.isUnit hA.1.isSelfAdjoint] + exact real_cfc hA.1 _ + +lemma sandwich_diagonal_apply (M : Matrix ι ι ℝ) (w : ι → ℝ) (i : ι) : + (M * diagonal w * M.transpose) i i = ∑ j, (M i j) ^ 2 * w j := by + simp only [Matrix.mul_apply (M := M * diagonal w), mul_diagonal, transpose_apply] + apply Finset.sum_congr rfl + intro j _ + ring + +lemma overlap_conjugate {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) : + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * B * hA.eigenvectorUnitary = + (overlapBasis hA hB : Matrix ι ι ℝ) * diagonal hB.eigenvalues * + (overlapBasis hA hB : Matrix ι ι ℝ).transpose := by + conv_lhs => rw [real_spectral hB] + rw [overlapBasis_coe, Matrix.transpose_mul, Matrix.transpose_transpose] + simp only [Matrix.mul_assoc] + +lemma overlap_row_weight {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (hBA : B ≤ A) (i : ι) : + ∑ j, (overlapBasis hA hB i j) ^ 2 * hB.eigenvalues j ≤ hA.eigenvalues i := by + have h := Gain.congruence_mono hBA (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose + simp only [Matrix.transpose_transpose, diagonalize hA, overlap_conjugate hA hB] at h + have hd := diag_le h i + simpa only [sandwich_diagonal_apply, diagonal_apply_eq] using hd + +lemma overlap_inverse_conjugate {A B : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.IsHermitian) : + (hB.eigenvectorUnitary : Matrix ι ι ℝ).transpose * A⁻¹ * hB.eigenvectorUnitary = + (overlapBasis hA.1 hB : Matrix ι ι ℝ).transpose * + diagonal (fun i => (hA.1.eigenvalues i)⁻¹) * overlapBasis hA.1 hB := by + rw [inverse_spectral hA, overlapBasis_coe, Matrix.transpose_mul, Matrix.transpose_transpose] + simp only [Matrix.mul_assoc] + +lemma diagonalize_inverse {A : Matrix ι ι ℝ} (hA : A.PosDef) : + (hA.1.eigenvectorUnitary : Matrix ι ι ℝ).transpose * A⁻¹ * hA.1.eigenvectorUnitary = + diagonal (fun i => (hA.1.eigenvalues i)⁻¹) := by + rw [inverse_spectral hA] + simp only [← Matrix.mul_assoc, unitary_transpose_mul, Matrix.one_mul] + rw [Matrix.mul_assoc, unitary_transpose_mul, Matrix.mul_one] + +lemma overlap_col_inverse_weight {A B : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hBA : B ≤ A) (j : ι) : + ∑ i, (overlapBasis hA.1 hB.1 i j) ^ 2 / hA.1.eigenvalues i ≤ + (hB.1.eigenvalues j)⁻¹ := by + have h := Gain.congruence_mono (MatrixEnergy.inv_le_inv hB hA hBA) + (hB.1.eigenvectorUnitary : Matrix ι ι ℝ).transpose + simp only [Matrix.transpose_transpose, diagonalize_inverse hB, + overlap_inverse_conjugate hA hB.1] at h + have hd := diag_le h j + have he := sandwich_diagonal_apply (overlapBasis hA.1 hB.1 : Matrix ι ι ℝ).transpose + (fun i => (hA.1.eigenvalues i)⁻¹) j + simp only [Matrix.transpose_transpose, transpose_apply] at he + rw [he, diagonal_apply_eq] at hd + simpa only [div_eq_mul_inv] using hd + +lemma overlap_ratio_row {A B : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hBA : B ≤ A) (i : ι) : + ∑ j, (overlapBasis hA.1 hB.1 i j) ^ 2 * hB.1.eigenvalues j / + hA.1.eigenvalues i ≤ 1 := by + rw [← Finset.sum_div, div_le_one (hA.eigenvalues_pos i)] + exact overlap_row_weight hA.1 hB.1 hBA i + +lemma overlap_ratio_col {A B : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hBA : B ≤ A) (j : ι) : + ∑ i, (overlapBasis hA.1 hB.1 i j) ^ 2 * hB.1.eigenvalues j / + hA.1.eigenvalues i ≤ 1 := by + have h := mul_le_mul_of_nonneg_right (overlap_col_inverse_weight hA hB hBA j) + (hB.eigenvalues_pos j).le + rw [inv_mul_cancel₀ (ne_of_gt (hB.eigenvalues_pos j)), Finset.sum_mul] at h + calc + _ = ∑ i, ((overlapBasis hA.1 hB.1 i j) ^ 2 / hA.1.eigenvalues i) * + hB.1.eigenvalues j := by + apply Finset.sum_congr rfl + intro i _ + exact mul_div_right_comm _ _ _ + _ ≤ 1 := h + +lemma trace_cfc_mul_diag {A : Matrix ι ι ℝ} (hA : A.IsHermitian) + (B : Matrix ι ι ℝ) (f : ℝ → ℝ) : + (cfc f A * B).trace = ∑ i, f (hA.eigenvalues i) * + ((hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * B * hA.eigenvectorUnitary) i i := by + rw [real_cfc hA f] + calc + _ = (diagonal (fun i => f (hA.eigenvalues i)) * + ((hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * B * + hA.eigenvectorUnitary)).trace := by + simp only [Matrix.mul_assoc] + rw [trace_mul_comm (hA.eigenvectorUnitary : Matrix ι ι ℝ)] + simp only [Matrix.mul_assoc] + _ = _ := by simp only [Matrix.trace, Matrix.diag, diagonal_mul] + +lemma gain_new_coordinates {A B : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.IsHermitian) : + (cfc (fun x => cutoff x ^ 2) A * (A - B)).trace = + ∑ i, hA.1.eigenvalues i * + (1 - ∑ j, (overlapBasis hA.1 hB i j) ^ 2 * hB.eigenvalues j / + hA.1.eigenvalues i) * cutoff (hA.1.eigenvalues i) ^ 2 := by + rw [trace_cfc_mul_diag hA.1] + simp only [Matrix.mul_sub, Matrix.sub_mul, diagonalize hA.1, + overlap_conjugate hA.1 hB, Matrix.sub_apply, diagonal_apply_eq, + sandwich_diagonal_apply] + apply Finset.sum_congr rfl + intro i _ + rw [← Finset.sum_div] + field_simp [ne_of_gt (hA.eigenvalues_pos i)] + +lemma gain_endpoint {A B : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hBA : B ≤ A) : + ((cfc cutoff A - cfc cutoff B) * cfc (fun (x : ℝ) => 1 + x) B * + (cfc cutoff A - cfc cutoff B).transpose).trace + + (cfc (fun x => cutoff x ^ 2) A * (A - B)).trace ≤ + 115200 * ((cfc potential A).trace - (cfc potential B).trace) := by + rw [weighted_cfc_distance hA.1 hB.1, gain_new_coordinates hA hB.1, + trace_cfc hA.1, trace_cfc hB.1] + exact gain_spectral_bound hA.1.eigenvalues hB.1.eigenvalues + (fun i j => (overlapBasis hA.1 hB.1 i j) ^ 2) + (fun i j => (overlapBasis hA.1 hB.1 i j) ^ 2 * hB.1.eigenvalues j / + hA.1.eigenvalues i) + hA.eigenvalues_pos hB.eigenvalues_pos (fun i j => sq_nonneg _) + (sum_row_squares _) (sum_col_squares _) (fun _ _ => rfl) + (overlap_ratio_row hA hB hBA) (overlap_ratio_col hA hB hBA) + +end EuclideanSteinitz.Endpoint + +namespace EuclideanSteinitz.Endpoint +open Matrix MatrixEnergy Spectral +open scoped MatrixOrder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def transportBasis {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (C : Matrix ι ι ℝ) : Matrix ι ι ℝ := + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * C * hB.eigenvectorUnitary + +lemma transport_row_matrix {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (C : Matrix ι ι ℝ) : + transportBasis hA hB C * (transportBasis hA hB C).transpose = + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * (C * C.transpose) * + hA.eigenvectorUnitary := by + simp only [transportBasis, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + simp only [← Matrix.mul_assoc, unitary_mul_transpose, Matrix.mul_one] + +lemma transport_col_matrix {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (C : Matrix ι ι ℝ) : + (transportBasis hA hB C).transpose * transportBasis hA hB C = + (hB.eigenvectorUnitary : Matrix ι ι ℝ).transpose * (C.transpose * C) * + hB.eigenvectorUnitary := by + simp only [transportBasis, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + simp only [← Matrix.mul_assoc, unitary_mul_transpose, Matrix.mul_one] + +lemma transport_row_bound {A B C : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (hC : C * C.transpose ≤ 1) (i : ι) : + ∑ j, transportBasis hA hB C i j ^ 2 ≤ 1 := by + have h := Gain.congruence_mono hC (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose + simp only [Matrix.transpose_transpose, Matrix.mul_one, unitary_transpose_mul, + ← transport_row_matrix hA hB C] at h + have hd := diag_le h i + simpa only [Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply_eq, sq] using hd + +lemma transport_col_bound {A B C : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (hC : C * C.transpose ≤ 1) (j : ι) : + ∑ i, transportBasis hA hB C i j ^ 2 ≤ 1 := by + have h := Gain.congruence_mono (transpose_contraction hC) + (hB.eigenvectorUnitary : Matrix ι ι ℝ).transpose + simp only [Matrix.transpose_transpose, Matrix.mul_one, unitary_transpose_mul, + ← transport_col_matrix hA hB C] at h + have hd := diag_le h j + simpa only [Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply_eq, sq] using hd + +lemma transport_spectral {A B C : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (heq : A = C * B * C.transpose) : + transportBasis hA hB C * diagonal hB.eigenvalues * (transportBasis hA hB C).transpose = + diagonal hA.eigenvalues := by + rw [← diagonalize hA] + conv_rhs => arg 1; arg 2; rw [heq, real_spectral hB] + simp only [transportBasis, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + +lemma transport_row_weight {A B C : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (heq : A = C * B * C.transpose) (i : ι) : + ∑ j, transportBasis hA hB C i j ^ 2 * hB.eigenvalues j = hA.eigenvalues i := by + have h := congr_fun (congr_fun (transport_spectral hA hB heq) i) i + simpa only [sandwich_diagonal_apply, diagonal_apply_eq] using h + +lemma congruence_inverse {A B C : Matrix ι ι ℝ} + (hC : IsUnit C) (heq : A = C * B * C.transpose) : + C.transpose * A⁻¹ * C = B⁻¹ := by + have hd := (Matrix.isUnit_iff_isUnit_det C).mp hC + have ht := Matrix.isUnit_det_transpose C hd + rw [heq, Matrix.mul_inv_rev, Matrix.mul_inv_rev] + simp only [← Matrix.mul_assoc, Matrix.mul_nonsing_inv _ ht, Matrix.one_mul] + rw [Matrix.mul_assoc, Matrix.nonsing_inv_mul _ hd, Matrix.mul_one] + +lemma transport_inverse_spectral {A B C : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hC : IsUnit C) + (heq : A = C * B * C.transpose) : + (transportBasis hA.1 hB.1 C).transpose * + diagonal (fun i => (hA.1.eigenvalues i)⁻¹) * transportBasis hA.1 hB.1 C = + diagonal (fun i => (hB.1.eigenvalues i)⁻¹) := by + rw [← diagonalize_inverse hB, ← congruence_inverse hC heq, inverse_spectral hA] + simp only [transportBasis, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + +lemma transport_col_inverse_weight {A B C : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hC : IsUnit C) + (heq : A = C * B * C.transpose) (j : ι) : + ∑ i, transportBasis hA.1 hB.1 C i j ^ 2 / hA.1.eigenvalues i = + (hB.1.eigenvalues j)⁻¹ := by + have h := congr_fun (congr_fun (transport_inverse_spectral hA hB hC heq) j) j + have hh := sandwich_diagonal_apply (transportBasis hA.1 hB.1 C).transpose + (fun i => (hA.1.eigenvalues i)⁻¹) j + simp only [Matrix.transpose_transpose, Matrix.transpose_apply] at hh + rw [hh, diagonal_apply_eq] at h + simpa only [div_eq_mul_inv] using h + +lemma transport_ratio_row {A B C : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.IsHermitian) (heq : A = C * B * C.transpose) (i : ι) : + ∑ j, transportBasis hA.1 hB C i j ^ 2 * hB.eigenvalues j / hA.1.eigenvalues i = 1 := by + rw [← Finset.sum_div, transport_row_weight hA.1 hB heq, + div_self (ne_of_gt (hA.eigenvalues_pos i))] + +lemma transport_ratio_col {A B C : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hC : IsUnit C) + (heq : A = C * B * C.transpose) (j : ι) : + ∑ i, transportBasis hA.1 hB.1 C i j ^ 2 * hB.1.eigenvalues j / hA.1.eigenvalues i = 1 := by + calc + _ = (∑ i, transportBasis hA.1 hB.1 C i j ^ 2 / hA.1.eigenvalues i) * + hB.1.eigenvalues j := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + exact mul_div_right_comm _ _ _ + _ = 1 := by rw [transport_col_inverse_weight hA hB hC heq, + inv_mul_cancel₀ (ne_of_gt (hB.eigenvalues_pos j))] + +lemma trace_cfc_transport_product {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (C : Matrix ι ι ℝ) (f g : ℝ → ℝ) : + (cfc f A * C * cfc g B * C.transpose).trace = ∑ i, ∑ j, + transportBasis hA hB C i j ^ 2 * f (hA.eigenvalues i) * g (hB.eigenvalues j) := by + rw [real_cfc hA f, real_cfc hB g] + calc + _ = (diagonal (fun i => f (hA.eigenvalues i)) * transportBasis hA hB C * + diagonal (fun j => g (hB.eigenvalues j)) * (transportBasis hA hB C).transpose).trace := by + simp only [transportBasis, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + rw [trace_mul_comm (hA.eigenvectorUnitary : Matrix ι ι ℝ)] + simp only [Matrix.mul_assoc] + _ = _ := by + rw [trace_diagonal_product] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +omit [DecidableEq ι] in +lemma contraction_distance_identity {κ : Type*} [Fintype κ] + (x : ι → ℝ) (y : κ → ℝ) (m : ι → κ → ℝ) (f : ι → ℝ) (g : κ → ℝ) + (hrow : ∀ i, ∑ j, m i j * y j = x i) : + (∑ i, (1 + x i) * f i ^ 2) + (∑ j, (1 + y j) * g j ^ 2) - + 2 * (∑ i, ∑ j, m i j * (1 + y j) * f i * g j) = + (∑ i, ∑ j, m i j * (1 + y j) * (f i - g j) ^ 2) + + (∑ i, (1 - ∑ j, m i j) * f i ^ 2) + + (∑ j, (1 - ∑ i, m i j) * (1 + y j) * g j ^ 2) := by + have h1 : (∑ i, ∑ j, m i j * (1 + y j) * f i ^ 2) = + (∑ i, (1 + x i) * f i ^ 2) - (∑ i, (1 - ∑ j, m i j) * f i ^ 2) := by + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i _ + rw [← Finset.sum_mul] + simp only [mul_add, mul_one, Finset.sum_add_distrib, hrow] + ring + have h2 : (∑ i, ∑ j, m i j * (1 + y j) * g j ^ 2) = + (∑ j, (1 + y j) * g j ^ 2) - + (∑ j, (1 - ∑ i, m i j) * (1 + y j) * g j ^ 2) := by + rw [Finset.sum_comm, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro j _ + rw [← Finset.sum_mul, ← Finset.sum_mul] + ring + have hexpand (i : ι) (j : κ) : m i j * (1 + y j) * (f i - g j) ^ 2 = + m i j * (1 + y j) * f i ^ 2 + m i j * (1 + y j) * g j ^ 2 - + 2 * (m i j * (1 + y j) * f i * g j) := by ring + simp_rw [hexpand, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum] + rw [h1, h2] + ring + +lemma contraction_endpoint_spectral {A B C : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hC : IsUnit C) (hContract : C * C.transpose ≤ 1) + (heq : A = C * B * C.transpose) : + (cfc (fun x => (1 + x) * cutoff x ^ 2) A).trace + + (cfc (fun x => (1 + x) * cutoff x ^ 2) B).trace - + 2 * (cfc cutoff A * C * cfc (fun x => (1 + x) * cutoff x) B * C.transpose).trace ≤ + 115200 * ((cfc potential B).trace - (cfc potential A).trace) := by + rw [trace_cfc hA.1, trace_cfc hB.1, trace_cfc_transport_product hA.1 hB.1, + trace_cfc hA.1, trace_cfc hB.1] + have hx : (∑ i, ∑ j, transportBasis hA.1 hB.1 C i j ^ 2 * cutoff (hA.1.eigenvalues i) * + ((1 + hB.1.eigenvalues j) * cutoff (hB.1.eigenvalues j))) = + ∑ i, ∑ j, transportBasis hA.1 hB.1 C i j ^ 2 * (1 + hB.1.eigenvalues j) * + cutoff (hA.1.eigenvalues i) * cutoff (hB.1.eigenvalues j) := by + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + rw [hx, contraction_distance_identity _ _ _ _ _ (transport_row_weight hA.1 hB.1 heq)] + exact contraction_spectral_bound hA.1.eigenvalues hB.1.eigenvalues + (fun i j => transportBasis hA.1 hB.1 C i j ^ 2) + (fun i j => transportBasis hA.1 hB.1 C i j ^ 2 * hB.1.eigenvalues j / hA.1.eigenvalues i) + hA.eigenvalues_pos hB.eigenvalues_pos (fun _ _ => sq_nonneg _) + (transport_row_bound hA.1 hB.1 hContract) (transport_col_bound hA.1 hB.1 hContract) + (fun _ _ => rfl) (transport_ratio_row hA hB.1 heq) (transport_ratio_col hA hB hC heq) + +end EuclideanSteinitz.Endpoint + +namespace EuclideanSteinitz.Coefficient +open Matrix MatrixEnergy Spectral Endpoint +open scoped MatrixOrder +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +noncomputable def lift (R : Matrix ι κ ℝ) (A : Matrix ι ι ℝ) : Matrix κ κ ℝ := + R.transpose * A * R + +noncomputable def weightedSq (D : Matrix ι κ ℝ) (W : Matrix κ κ ℝ) : ℝ := + (D * W * D.transpose).trace + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weightedSq_nonneg (D : Matrix ι κ ℝ) {W : Matrix κ κ ℝ} (hW : W.PosSemidef) : + 0 ≤ weightedSq D W := by + have h : (D * W * D.transpose).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using hW.mul_mul_conjTranspose_same D + exact h.trace_nonneg + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weightedSq_weight_add (D : Matrix ι κ ℝ) (W V : Matrix κ κ ℝ) : + weightedSq D (W + V) = weightedSq D W + weightedSq D V := by + simp only [weightedSq, Matrix.mul_add, Matrix.add_mul, Matrix.trace_add] + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weighted_cross_symm (D E : Matrix ι κ ℝ) {W : Matrix κ κ ℝ} (hW : W.transpose = W) : + (D * W * E.transpose).trace = (E * W * D.transpose).trace := by + rw [← Matrix.trace_transpose (D * W * E.transpose)] + simp only [Matrix.transpose_mul, Matrix.transpose_transpose, hW, Matrix.mul_assoc] + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weightedSq_sub (D E : Matrix ι κ ℝ) {W : Matrix κ κ ℝ} (hW : W.transpose = W) : + weightedSq (D - E) W = weightedSq D W + weightedSq E W - + 2 * (D * W * E.transpose).trace := by + simp only [weightedSq, Matrix.transpose_sub, Matrix.sub_mul, Matrix.mul_sub, Matrix.trace_sub] + rw [weighted_cross_symm E D hW] + ring + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weightedSq_triangle (D E : Matrix ι κ ℝ) {W : Matrix κ κ ℝ} (hW : W.PosSemidef) : + weightedSq (D + E) W ≤ 2 * weightedSq D W + 2 * weightedSq E W := by + have hn := weightedSq_nonneg (D - E) hW + have hi : weightedSq (D + E) W + weightedSq (D - E) W = + 2 * weightedSq D W + 2 * weightedSq E W := by + simp only [weightedSq, Matrix.transpose_add, Matrix.transpose_sub, Matrix.add_mul, + Matrix.sub_mul, Matrix.mul_add, Matrix.mul_sub, Matrix.trace_add, Matrix.trace_sub] + ring + linarith only [hn, hi] + +omit [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma lift_transpose (R : Matrix ι κ ℝ) (A : Matrix ι ι ℝ) : + (lift R A).transpose = lift R A.transpose := by + simp only [lift, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + +omit [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma lift_sub (R : Matrix ι κ ℝ) (A B : Matrix ι ι ℝ) : + lift R (A - B) = lift R A - lift R B := by + simp only [lift, Matrix.mul_sub, Matrix.sub_mul] + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weighted_lift_cross (R S : Matrix ι κ ℝ) (A B : Matrix ι ι ℝ) + (W : Matrix κ κ ℝ) : + (lift R A * W * (lift S B).transpose).trace = + (A * (R * W * S.transpose) * B.transpose * (S * R.transpose)).trace := by + simp only [lift, Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.mul_assoc] + rw [Matrix.trace_mul_comm R.transpose] + simp only [Matrix.mul_assoc] + +omit [DecidableEq κ] in +lemma weighted_lift (R : Matrix ι κ ℝ) (hR : R * R.transpose = 1) + (A : Matrix ι ι ℝ) (W : Matrix κ κ ℝ) : + weightedSq (lift R A) W = weightedSq A (R * W * R.transpose) := by + unfold weightedSq + rw [weighted_lift_cross, hR, Matrix.mul_one] + +lemma cfc_transpose {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (f : ℝ → ℝ) : + (cfc f A).transpose = cfc f A := by + rw [real_cfc hA f] + simp only [Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.diagonal_transpose, + Matrix.mul_assoc] + +lemma cfc_square {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (f : ℝ → ℝ) : + cfc f A * cfc f A = cfc (fun x => f x ^ 2) A := by + rw [real_cfc hA f, real_cfc hA (fun x => f x ^ 2)] + simp only [Matrix.mul_assoc] + simp only [← Matrix.mul_assoc, unitary_transpose_mul, Matrix.one_mul] + congr 1 + simp only [Matrix.mul_assoc] + rw [Matrix.diagonal_mul_diagonal] + simp only [sq] + +lemma cfc_affine {A : Matrix ι ι ℝ} (hA : A.IsHermitian) : + cfc (fun x : ℝ => 1 + x) A = 1 + A := by + rw [cfc_add A (fun _ : ℝ => 1) (fun x : ℝ => x) continuousOn_const continuousOn_id, + cfc_const_one ℝ A, cfc_id' ℝ A hA.isSelfAdjoint] + +lemma weightedSq_cfc {A : Matrix ι ι ℝ} (hA : A.IsHermitian) + (f : ℝ → ℝ) (W : Matrix ι ι ℝ) : + weightedSq (cfc f A) W = (cfc (fun x => f x ^ 2) A * W).trace := by + unfold weightedSq + rw [cfc_transpose hA f, Matrix.trace_mul_cycle, cfc_square hA] + +lemma cfc_mul_same {A : Matrix ι ι ℝ} (_hA : A.IsHermitian) (f g : ℝ → ℝ) : + cfc f A * cfc g A = cfc (fun x => f x * g x) A := by + have hf : ContinuousOn f (spectrum ℝ A) := Gain.finite_spectrum_continuous _ _ + have hg : ContinuousOn g (spectrum ℝ A) := Gain.finite_spectrum_continuous _ _ + exact (cfc_mul f g A hf hg).symm + +lemma weightedSq_cfc_affine {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (f : ℝ → ℝ) : + weightedSq (cfc f A) (1 + A) = (cfc (fun x => (1 + x) * f x ^ 2) A).trace := by + rw [weightedSq_cfc hA, ← cfc_affine hA, cfc_mul_same hA] + congr 2 + funext x + exact mul_comm _ _ + +omit [DecidableEq κ] in +lemma contraction_endpoint {A B C : Matrix ι ι ℝ} + (hA : A.PosDef) (hB : B.PosDef) (hC : IsUnit C) (hContract : C * C.transpose ≤ 1) + (heq : A = C * B * C.transpose) + (R S : Matrix ι κ ℝ) (hR : R * R.transpose = 1) (hS : S * S.transpose = 1) + (W : Matrix κ κ ℝ) (hW : W.transpose = W) + (hRW : R * W * R.transpose = 1 + A) (hSW : S * W * S.transpose = 1 + B) + (hRS : R * S.transpose = C) (hRWS : R * W * S.transpose = C * (1 + B)) : + weightedSq (lift R (cfc cutoff A) - lift S (cfc cutoff B)) W ≤ + 115200 * ((cfc potential B).trace - (cfc potential A).trace) := by + have hSR : S * R.transpose = C.transpose := by + rw [← hRS, Matrix.transpose_mul, Matrix.transpose_transpose] + have haff : (1 + B) * cfc cutoff B = cfc (fun x => (1 + x) * cutoff x) B := by + rw [← cfc_affine hB.1, cfc_mul_same hB.1] + have hcross : (lift R (cfc cutoff A) * W * (lift S (cfc cutoff B)).transpose).trace = + (cfc cutoff A * C * cfc (fun x => (1 + x) * cutoff x) B * C.transpose).trace := by + rw [weighted_lift_cross, hRWS, cfc_transpose hB.1, hSR, ← haff] + simp only [Matrix.mul_assoc] + rw [weightedSq_sub _ _ hW, weighted_lift R hR, weighted_lift S hS, hRW, hSW, + weightedSq_cfc_affine hA.1, weightedSq_cfc_affine hB.1, hcross] + exact contraction_endpoint_spectral hA hB hC hContract heq + +omit [DecidableEq ι] [DecidableEq κ] in +lemma weightedSq_sub_zero (D E : Matrix ι κ ℝ) {W : Matrix κ κ ℝ} + (hW : W.transpose = W) (hEW : E * W = 0) : + weightedSq (D - E) W = weightedSq D W := by + rw [weightedSq_sub _ _ hW, weighted_cross_symm D E hW] + simp only [weightedSq, hEW, Matrix.zero_mul, Matrix.trace_zero, mul_zero, add_zero, sub_zero] + +lemma gain_endpoint_lift {X Z : Matrix ι ι ℝ} + (hX : X.PosDef) (hZ : Z.PosDef) (hZX : Z ≤ X) + (R : Matrix ι κ ℝ) (hR : R * R.transpose = 1) + (E Qold Qnew : Matrix κ κ ℝ) (hNew : Qnew.transpose = Qnew) + (hEq : E * Qnew = 0) + (hOld : R * Qold * R.transpose = Z) (hNewState : R * Qnew * R.transpose = X - Z) : + weightedSq (lift R (cfc cutoff X) - lift R (cfc cutoff Z)) (1 + Qold) + + weightedSq (lift R (cfc cutoff X) - E) Qnew ≤ + 115200 * ((cfc potential X).trace - (cfc potential Z).trace) := by + rw [← lift_sub, weighted_lift R hR, + Matrix.mul_add, Matrix.add_mul, Matrix.mul_one, hR, hOld, + weightedSq_sub_zero _ _ hNew hEq, weighted_lift R hR, hNewState, + weightedSq_cfc hX.1, ← cfc_affine hZ.1] + exact gain_endpoint hX hZ hZX + +lemma endpoint_comparison {X Y Z C : Matrix ι ι ℝ} + (hX : X.PosDef) (hY : Y.PosDef) (hZ : Z.PosDef) + (hC : IsUnit C) (hContract : C * C.transpose ≤ 1) + (hZeq : Z = C * Y * C.transpose) + (T S : Matrix ι κ ℝ) (hT : T * T.transpose = 1) (hS : S * S.transpose = 1) + (Qold Qnew : Matrix κ κ ℝ) (hOldPSD : Qold.PosSemidef) (hNewPSD : Qnew.PosSemidef) + (hOldS : S * Qold * S.transpose = Y) (hOldT : T * Qold * T.transpose = Z) + (hTS : T * S.transpose = C) (hCross : T * Qold * S.transpose = C * Y) + (hNewT : T * Qnew * T.transpose = X - Z) + (hZero : lift S (cfc cutoff Y) * Qnew = 0) : + weightedSq (lift T (cfc cutoff X) - lift S (cfc cutoff Y)) ((1 + Qold) + Qnew) ≤ + 230400 * (((cfc potential Y).trace - (cfc potential Z).trace) + + ((cfc potential X).trace - (cfc potential Z).trace)) := by + let F1 := lift T (cfc cutoff X) + let Fm := lift T (cfc cutoff Z) + let F0 := lift S (cfc cutoff Y) + let W := (1 : Matrix κ κ ℝ) + Qold + have hWPSD : W.PosSemidef := Matrix.PosSemidef.one.add hOldPSD + have hWsymm : W.transpose = W := by + simpa only [Matrix.IsHermitian, conjTranspose_eq_transpose_of_trivial] using hWPSD.1 + have hNewSymm : Qnew.transpose = Qnew := by + simpa only [Matrix.IsHermitian, conjTranspose_eq_transpose_of_trivial] using hNewPSD.1 + have hTW : T * W * T.transpose = 1 + Z := by + simp only [W, Matrix.mul_add, Matrix.add_mul, Matrix.mul_one, hT, hOldT] + have hSW : S * W * S.transpose = 1 + Y := by + simp only [W, Matrix.mul_add, Matrix.add_mul, Matrix.mul_one, hS, hOldS] + have hTWS : T * W * S.transpose = C * (1 + Y) := by + simp only [W, Matrix.mul_add, Matrix.add_mul, Matrix.mul_one, hTS, hCross] + have hZX : Z ≤ X := by + apply Matrix.le_iff.mpr + rw [← hNewT] + simpa only [conjTranspose_eq_transpose_of_trivial] using hNewPSD.mul_mul_conjTranspose_same T + have hcontr := contraction_endpoint hZ hY hC hContract hZeq T S hT hS W hWsymm + hTW hSW hTS hTWS + change weightedSq (Fm - F0) W ≤ _ at hcontr + have hgain := gain_endpoint_lift hX hZ hZX T hT F0 Qold Qnew hNewSymm hZero hOldT hNewT + change weightedSq (F1 - Fm) W + weightedSq (F1 - F0) Qnew ≤ _ at hgain + have hpos := weightedSq_nonneg (F1 - F0) hNewPSD + have htri : weightedSq (F1 - F0) W ≤ + 2 * weightedSq (F1 - Fm) W + 2 * weightedSq (Fm - F0) W := by + have heq : F1 - F0 = (F1 - Fm) + (Fm - F0) := by abel + conv_lhs => rw [heq] + exact weightedSq_triangle _ _ hWPSD + change weightedSq (F1 - F0) (W + Qnew) ≤ _ + rw [weightedSq_weight_add] + linarith only [htri, hgain, hcontr, hpos] + +end EuclideanSteinitz.Coefficient + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Correlation.lean b/lean/OAI/Analysis/Steinitz/Correlation.lean new file mode 100644 index 0000000000000000000000000000000000000000..8505ba1e97ba87928039e88ed6b5aa64a5de8095 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Correlation.lean @@ -0,0 +1,1419 @@ +import OAI.Analysis.Steinitz.Chaining + +namespace OAI + +/-! Gaussian correlation and symmetric convex events. -/ + +section + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix Gain +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +omit [Fintype κ] [DecidableEq κ] in +lemma one_le_det {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (h : 1 ≤ A) : + 1 ≤ A.det := by + rw [hA.det_eq_prod_eigenvalues] + have hs : ∀ x ∈ spectrum ℝ A, 1 ≤ x := + (algebraMap_le_iff_le_spectrum (R := ℝ) hA.isSelfAdjoint).mp (by simpa using h) + simpa using Finset.one_le_prod₀ (fun i (_ : i ∈ (Finset.univ : Finset ι)) => + hs _ (hA.spectrum_real_eq_range_eigenvalues.symm ▸ Set.mem_range_self i)) + +omit [Fintype κ] [DecidableEq κ] in +lemma det_mono {A B : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) (h : A ≤ B) : + A.det ≤ B.det := by + let S := inverseSqrt A + have hS : S.PosSemidef := inverseSqrt_psd A + have hSA : S * A * S = 1 := inverseSqrt_sandwich hA + have hSB : (S * B * S).PosDef := by + simpa only [Matrix.star_eq_conjTranspose, conjTranspose_eq_transpose_of_trivial, + inverseSqrt_transpose] using + (inverseSqrt_unit hA).posDef_star_right_conjugate_iff.mpr hB + have hAB' : 1 ≤ S * B * S := by + have hm := congruence_mono h S + simpa only [S, inverseSqrt_transpose, inverseSqrt_sandwich hA] using hm + have hd := one_le_det hSB.1 hAB' + have hdet : S.det * A.det * S.det = 1 := by simpa only [det_mul, det_one] using congrArg det hSA + rw [det_mul, det_mul] at hd + nlinarith [hA.det_pos, hS.det_nonneg, sq_nonneg S.det] + +def blockCov (A : Matrix ι ι ℝ) (B : Matrix ι κ ℝ) (D : Matrix κ κ ℝ) (t : ℝ) : + Matrix (ι ⊕ κ) (ι ⊕ κ) ℝ := fromBlocks A (t • B) (t • B.transpose) D + +lemma blockCov_schur {A : Matrix ι ι ℝ} (hA : A.PosDef) + (B : Matrix ι κ ℝ) (D : Matrix κ κ ℝ) (t : ℝ) : + (blockCov A B D t).det = A.det * (D - t ^ 2 • (B.transpose * A⁻¹ * B)).det := by + let _ := hA.isUnit.invertible + rw [blockCov, det_fromBlocks₁₁, invOf_eq_nonsing_inv] + congr 2 + simp only [Matrix.smul_mul, Matrix.mul_smul, smul_smul, pow_two] + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma blockCov_affine (A : Matrix ι ι ℝ) (B : Matrix ι κ ℝ) (D : Matrix κ κ ℝ) + (t : ℝ) : + blockCov A B D t = t • blockCov A B D 1 + (1 - t) • blockCov A B D 0 := by + ext (i | i) (j | j) <;> simp [blockCov, fromBlocks] <;> ring + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma blockCov_diag_posDef {A : Matrix ι ι ℝ} {B : Matrix ι κ ℝ} + {D : Matrix κ κ ℝ} (h : (blockCov A B D 1).PosDef) : A.PosDef ∧ D.PosDef := by + constructor + · exact h.submatrix Sum.inl_injective + · exact h.submatrix Sum.inr_injective + +lemma schur_posDef {A : Matrix ι ι ℝ} {B : Matrix ι κ ℝ} {D : Matrix κ κ ℝ} + (h : (blockCov A B D 1).PosDef) : (D - B.transpose * A⁻¹ * B).PosDef := by + have hA := (blockCov_diag_posDef h).1 + let _ := hA.isUnit.invertible + have he : blockCov A B D 1 = fromBlocks A B Bᴴ D := by + simp only [blockCov, one_smul, conjTranspose_eq_transpose_of_trivial] + have hs : (D - B.transpose * A⁻¹ * B).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using + (hA.fromBlocks₁₁ B D).mp (he ▸ h.posSemidef) + apply hs.posDef_iff_det_ne_zero.mpr + intro hz + have hd := blockCov_schur hA B D 1 + simp only [one_pow, one_smul, hz, mul_zero] at hd + exact h.det_pos.ne' hd + +lemma blockCov_posDef {A : Matrix ι ι ℝ} {B : Matrix ι κ ℝ} {D : Matrix κ κ ℝ} + (h : (blockCov A B D 1).PosDef) {t : ℝ} (ht : t ∈ Set.Icc 0 1) : + (blockCov A B D t).PosDef := by + have hA := (blockCov_diag_posDef h).1 + let _ := hA.isUnit.invertible + have hK : (B.transpose * A⁻¹ * B).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using + hA.posSemidef.inv.conjTranspose_mul_mul_same B + have he : D - t ^ 2 • (B.transpose * A⁻¹ * B) = + (D - B.transpose * A⁻¹ * B) + (1 - t ^ 2) • (B.transpose * A⁻¹ * B) := by + module + have hs : (D - t ^ 2 • (B.transpose * A⁻¹ * B)).PosDef := by + rw [he] + exact (schur_posDef h).add_posSemidef (hK.smul (by nlinarith [ht.1, ht.2])) + have he' : blockCov A B D t = fromBlocks A (t • B) (t • B)ᴴ D := by + simp only [blockCov, conjTranspose_eq_transpose_of_trivial, transpose_smul] + have hp : (blockCov A B D t).PosSemidef := by + rw [he', hA.fromBlocks₁₁] + simpa only [conjTranspose_eq_transpose_of_trivial, transpose_smul, + Matrix.smul_mul, Matrix.mul_smul, smul_smul, ← pow_two] using hs.posSemidef + apply hp.posDef_iff_det_ne_zero.mpr + rw [blockCov_schur hA] + exact mul_ne_zero hA.det_pos.ne' hs.det_pos.ne' + +lemma blockCov_det_antitone {A : Matrix ι ι ℝ} {B : Matrix ι κ ℝ} {D : Matrix κ κ ℝ} + (h : (blockCov A B D 1).PosDef) : + AntitoneOn (fun t => (blockCov A B D t).det) (Set.Icc 0 1) := by + intro s hs t ht hst + have hA := (blockCov_diag_posDef h).1 + have hK : (B.transpose * A⁻¹ * B).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using + hA.posSemidef.inv.conjTranspose_mul_mul_same B + have hpos (r : ℝ) (hr : r ∈ Set.Icc 0 1) : + (D - r ^ 2 • (B.transpose * A⁻¹ * B)).PosDef := by + have he : D - r ^ 2 • (B.transpose * A⁻¹ * B) = + (D - B.transpose * A⁻¹ * B) + (1 - r ^ 2) • (B.transpose * A⁻¹ * B) := by module + rw [he] + exact (schur_posDef h).add_posSemidef (hK.smul (by nlinarith [hr.1, hr.2])) + dsimp only + rw [blockCov_schur hA, blockCov_schur hA] + apply mul_le_mul_of_nonneg_left _ hA.det_pos.le + apply det_mono (hpos t ht) (hpos s hs) + apply sub_le_sub_left + exact smul_le_smul_of_nonneg_right (by nlinarith [hs.1, ht.1]) hK.nonneg + +def interpolate (p : ι → Bool) (R : Matrix ι ι ℝ) (t : ℝ) : Matrix ι ι ℝ := + fun i j => if p i = p j then R i j else t * R i j + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma interpolate_one (p : ι → Bool) (R : Matrix ι ι ℝ) : interpolate p R 1 = R := by + ext i j + simp [interpolate] + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma interpolate_blocks (p : ι → Bool) {R : Matrix ι ι ℝ} (hR : R.IsHermitian) (t : ℝ) : + let e := Equiv.sumCompl (fun i => p i = true) + (interpolate p R t).submatrix e e = + blockCov (R.submatrix (Subtype.val : {i // p i = true} → ι) Subtype.val) + (R.submatrix (Subtype.val : {i // p i = true} → ι) + (Subtype.val : {i // ¬ p i = true} → ι)) + (R.submatrix (Subtype.val : {i // ¬ p i = true} → ι) Subtype.val) t := by + dsimp only + ext (i | i) (j | j) <;> dsimp [interpolate, blockCov, fromBlocks, Equiv.sumCompl] + · simp only [i.prop, j.prop, ↓reduceIte] + · simp only [i.prop, Bool.eq_false_iff.mpr j.prop, Bool.true_eq_false, ↓reduceIte] + · simp only [Bool.eq_false_iff.mpr i.prop, j.prop, Bool.false_eq_true, ↓reduceIte] + rw [show R (↑i) (↑j) = R (↑j) (↑i) from (hR.apply _ _).symm] + · simp only [Bool.eq_false_iff.mpr i.prop, Bool.eq_false_iff.mpr j.prop, ↓reduceIte] + +omit [Fintype κ] [DecidableEq κ] in +lemma interpolate_posDef (p : ι → Bool) {R : Matrix ι ι ℝ} (hR : R.PosDef) + {t : ℝ} (ht : t ∈ Set.Icc 0 1) : (interpolate p R t).PosDef := by + let e := Equiv.sumCompl (fun i => p i = true) + have h : ((interpolate p R 1).submatrix e e).PosDef := by + rw [interpolate_one] + exact hR.submatrix e.injective + rw [interpolate_blocks p hR.1 1] at h + have ht' := blockCov_posDef h ht + rw [← interpolate_blocks p hR.1 t] at ht' + have hp := ht'.submatrix e.symm.injective + have he : ((interpolate p R t).submatrix e e).submatrix e.symm e.symm = + interpolate p R t := by ext i j; simp [submatrix] + exact he ▸ hp + +omit [Fintype κ] [DecidableEq κ] in +lemma interpolate_det_antitone (p : ι → Bool) {R : Matrix ι ι ℝ} (hR : R.PosDef) : + AntitoneOn (fun t => (interpolate p R t).det) (Set.Icc 0 1) := by + let e := Equiv.sumCompl (fun i => p i = true) + have he (t : ℝ) : (interpolate p R t).det = ((interpolate p R t).submatrix e e).det := + (det_submatrix_equiv_self e _).symm + have h : ((interpolate p R 1).submatrix e e).PosDef := by + rw [interpolate_one] + exact hR.submatrix e.injective + rw [interpolate_blocks p hR.1 1] at h + simp only [he] + dsimp only [e] + simpa only [interpolate_blocks p hR.1] using blockCov_det_antitone h + +omit [Fintype κ] [DecidableEq κ] in +lemma interpolate_det_differentiable (p : ι → Bool) (R : Matrix ι ι ℝ) : + Differentiable ℝ (fun t => (interpolate p R t).det) := by + have he (i j : ι) : Differentiable ℝ (fun t => interpolate p R t i j) := by + dsimp [interpolate] + split_ifs <;> fun_prop + simp only [Matrix.det_apply'] + apply Differentiable.fun_sum + intro σ _ + apply Differentiable.const_mul + exact Differentiable.fun_finsetProd (fun i _ => he _ _) + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma interpolate_submatrix {η : Type*} (p : ι → Bool) (R : Matrix ι ι ℝ) + (f : η → ι) (t : ℝ) : + (interpolate p R t).submatrix f f = interpolate (p ∘ f) (R.submatrix f f) t := rfl + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma principal_minor_deriv_nonpos (p : ι → Bool) {R : Matrix ι ι ℝ} (hR : R.PosDef) + (S : Finset ι) {t : ℝ} (ht : t ∈ Set.Ioo 0 1) : + deriv (fun u => ((interpolate p R u).submatrix (Subtype.val : S → ι) Subtype.val).det) t ≤ 0 := by + simp only [interpolate_submatrix] + have hm := interpolate_det_antitone (p ∘ (Subtype.val : S → ι)) + (hR.submatrix Subtype.val_injective) + have hd := hm.derivWithin_nonpos (x := t) + rwa [derivWithin_of_mem_nhds (Icc_mem_nhds ht.1 ht.2)] at hd + +omit [Fintype κ] [DecidableEq κ] in +lemma det_diagonal_mul_add_one (R : Matrix ι ι ℝ) (z : ι → ℝ) : + (diagonal z * R + 1).det = ∑ S : Finset ι, + (∏ i ∈ S, z i) * (R.submatrix (Subtype.val : S → ι) Subtype.val).det := by + change detRowAlternating ((fun i j => (diagonal z * R) i j) + + (fun i j => (1 : Matrix ι ι ℝ) i j)) = _ + rw [detRowAlternating.map_add_univ] + apply Finset.sum_congr rfl + intro S _ + have he : S.piecewise (diagonal z * R) (1 : Matrix ι ι ℝ) = + fun i => (if i ∈ S then z i else 1) • S.piecewise R (1 : Matrix ι ι ℝ) i := by + ext i j + simp only [Finset.piecewise, Pi.smul_apply, smul_eq_mul] + split_ifs <;> simp_all + rw [he, detRowAlternating.map_smul_univ] + simp only [Finset.prod_ite_mem, Finset.univ_inter] + change _ * (Matrix.of (S.piecewise R.row (1 : Matrix ι ι ℝ).row)).det = _ + rw [det_piecewise_one_eq_submatrix_det] + +omit [Fintype κ] [DecidableEq κ] in +lemma det_interpolate_derivative (p : ι → Bool) (R : Matrix ι ι ℝ) (z : ι → ℝ) (t : ℝ) : + HasDerivAt (fun u => (diagonal z * interpolate p R u + 1).det) + (∑ S : Finset ι, (∏ i ∈ S, z i) * + deriv (fun u => ((interpolate p R u).submatrix + (Subtype.val : S → ι) Subtype.val).det) t) t := by + simp only [det_diagonal_mul_add_one] + apply HasDerivAt.fun_sum + intro S _ + apply HasDerivAt.const_mul + have hd := (interpolate_det_differentiable (p ∘ (Subtype.val : S → ι)) + (R.submatrix Subtype.val Subtype.val) t).hasDerivAt + simpa only [interpolate_submatrix] using hd + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory +open scoped NNReal MatrixOrder Matrix.Norms.L2Operator + +lemma integral_exp_square_gaussian {t : ℝ} (ht : 0 ≤ t) : + (∫ x : ℝ, Real.exp (-t * x ^ 2 / 2) ∂gaussianReal 0 1) = + (Real.sqrt (1 + t))⁻¹ := by + rw [integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0)] + have he (x : ℝ) : gaussianPDFReal 0 1 x * Real.exp (-t * x ^ 2 / 2) = + (Real.sqrt (2 * Real.pi))⁻¹ * Real.exp (-((1 + t) / 2) * x ^ 2) := by + simp only [gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero] + rw [mul_assoc, ← Real.exp_add] + congr 2 + ring + simp only [smul_eq_mul, he, integral_const_mul, integral_gaussian] + rw [show Real.pi / ((1 + t) / 2) = (2 * Real.pi) / (1 + t) by rw [div_div_eq_mul_div]; ring] + rw [Real.sqrt_div (by positivity : 0 ≤ 2 * Real.pi)] + have hp : Real.sqrt (2 * Real.pi) ≠ 0 := by positivity + field_simp + +lemma integrable_exp_square_gaussian {t : ℝ} (ht : 0 ≤ t) : + Integrable (fun x : ℝ => Real.exp (-t * x ^ 2 / 2)) (gaussianReal 0 1) := by + apply Integrable.mono' (integrable_const (1 : ℝ)) (by fun_prop) + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + apply Real.exp_le_one_iff.mpr + exact div_nonpos_of_nonpos_of_nonneg + (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr ht) (sq_nonneg _)) (by norm_num) + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +open scoped RealInnerProductSpace + +lemma eigenvector_toEuclideanCLM {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (i : ι) : + toEuclideanCLM (𝕜 := ℝ) A (hA.eigenvectorBasis i) = + hA.eigenvalues i • hA.eigenvectorBasis i := by + apply WithLp.ofLp_injective + exact hA.mulVec_eigenvectorBasis i + +lemma quadratic_eigenbasis {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (x : ι → ℝ) : + ⟪∑ i, x i • hA.eigenvectorBasis i, + toEuclideanCLM (𝕜 := ℝ) A (∑ i, x i • hA.eigenvectorBasis i)⟫ = + ∑ i, hA.eigenvalues i * x i ^ 2 := by + simp only [map_sum, map_smul, eigenvector_toEuclideanCLM, smul_smul, + sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right, + hA.eigenvectorBasis.inner_eq_ite] + simp [mul_ite, ite_mul, pow_two, mul_comm, mul_left_comm, mul_assoc] + +lemma det_one_add_eigenvalues {A : Matrix ι ι ℝ} (hA : A.IsHermitian) : + (1 + A).det = ∏ i, (1 + hA.eigenvalues i) := by + have he : 1 + A = (Unitary.conjStarAlgAut ℝ _ hA.eigenvectorUnitary) + (diagonal (fun i => 1 + hA.eigenvalues i)) := by + rw [show diagonal (fun i => 1 + hA.eigenvalues i) = + 1 + diagonal (RCLike.ofReal ∘ hA.eigenvalues) by + simp only [Function.comp_def, RCLike.ofReal_real_eq_id, id_eq, + ← diagonal_one, ← diagonal_add]] + rw [map_add, map_one, ← hA.spectral_theorem] + rw [he] + simp only [Matrix.det_map', det_diagonal] + +lemma quadratic_laplace_stdGaussian {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + (∫ x : EuclideanSpace ℝ ι, Real.exp (-⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ / 2) + ∂stdGaussian (EuclideanSpace ℝ ι)) = (Real.sqrt (1 + A).det)⁻¹ := by + have he (x : ι → ℝ) : + Real.exp (-⟪∑ i, x i • hA.1.eigenvectorBasis i, + toEuclideanCLM (𝕜 := ℝ) A (∑ i, x i • hA.1.eigenvectorBasis i)⟫ / 2) = + ∏ i, Real.exp (-hA.1.eigenvalues i * x i ^ 2 / 2) := by + rw [quadratic_eigenbasis, ← Real.exp_sum] + congr 1 + simp only [Finset.sum_div, neg_mul, Finset.sum_neg_distrib, neg_div] + rw [stdGaussian_eq_map_pi_orthonormalBasis hA.1.eigenvectorBasis, + integral_map (Measurable.aemeasurable (by fun_prop)) (by fun_prop)] + simp only [he] + rw [integral_fintype_prod_eq_prod + (f := fun i (x : ℝ) => Real.exp (-hA.1.eigenvalues i * x ^ 2 / 2))] + simp_rw [integral_exp_square_gaussian (hA.eigenvalues_nonneg _)] + rw [det_one_add_eigenvalues hA.1, Real.sqrt_prod] + · simp + · intro i _ + linarith [hA.eigenvalues_nonneg i] + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory +open scoped RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma quadratic_diagonal (z : ι → ℝ) (x : EuclideanSpace ℝ ι) : + ⟪x, toEuclideanCLM (𝕜 := ℝ) (diagonal z) x⟫ = ∑ i, z i * x i ^ 2 := by + rw [inner_toEuclideanCLM] + simp only [dotProduct, mulVec_diagonal, pow_two] + congr 1 + ext i + ring + +lemma quadratic_sandwich (S D : Matrix ι ι ℝ) (hS : S.IsHermitian) + (x : EuclideanSpace ℝ ι) : + ⟪toEuclideanCLM (𝕜 := ℝ) S x, + toEuclideanCLM (𝕜 := ℝ) D (toEuclideanCLM (𝕜 := ℝ) S x)⟫ = + ⟪x, toEuclideanCLM (𝕜 := ℝ) (S * D * S) x⟫ := by + have hs : IsSelfAdjoint (toEuclideanCLM (𝕜 := ℝ) S) := hS.isSelfAdjoint.map _ + rw [← ContinuousLinearMap.adjoint_inner_right, hs.adjoint_eq] + simp only [map_mul, mul_apply_eq_comp] + +lemma sqrt_sandwich_psd {R : Matrix ι ι ℝ} (z : ι → ℝ) (hz : ∀ i, 0 ≤ z i) : + (CFC.sqrt R * diagonal z * CFC.sqrt R).PosSemidef := by + have hD : (diagonal z).PosSemidef := posSemidef_diagonal_iff.mpr hz + have hS : (CFC.sqrt R).IsHermitian := (CFC.sqrt_nonneg R).isSelfAdjoint + simpa only [hS.eq] using hD.conjTranspose_mul_mul_same (CFC.sqrt R) + +lemma det_one_add_sqrt_sandwich {R : Matrix ι ι ℝ} (hR : R.PosSemidef) (z : ι → ℝ) : + (1 + CFC.sqrt R * diagonal z * CFC.sqrt R).det = (diagonal z * R + 1).det := by + rw [Matrix.mul_assoc, det_one_add_mul_comm (CFC.sqrt R) (diagonal z * CFC.sqrt R), + Matrix.mul_assoc, CFC.sqrt_mul_sqrt_self R hR.nonneg, add_comm] + +lemma det_diagonal_mul_add_one_pos {R : Matrix ι ι ℝ} (hR : R.PosSemidef) + {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) : 0 < (diagonal z * R + 1).det := by + rw [← det_one_add_sqrt_sandwich hR z] + exact ((show (1 : Matrix ι ι ℝ).PosDef from Matrix.PosDef.one).add_posSemidef (sqrt_sandwich_psd z hz)).det_pos + +lemma quadratic_laplace_multivariateGaussian {R : Matrix ι ι ℝ} (hR : R.PosSemidef) + {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) : + (∫ x : EuclideanSpace ℝ ι, Real.exp (-(∑ i, z i * x i ^ 2) / 2) + ∂multivariateGaussian 0 R) = (Real.sqrt (diagonal z * R + 1).det)⁻¹ := by + rw [multivariateGaussian, + integral_map (Measurable.aemeasurable (by fun_prop)) (by fun_prop)] + simp only [zero_add, ← quadratic_diagonal, + quadratic_sandwich _ _ (CFC.sqrt_nonneg R).isSelfAdjoint] + rw [quadratic_laplace_stdGaussian (sqrt_sandwich_psd z hz), + det_one_add_sqrt_sandwich hR z] + +lemma integrable_quadratic_exp {R : Matrix ι ι ℝ} + {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) : + Integrable (fun x : EuclideanSpace ℝ ι => Real.exp (-(∑ i, z i * x i ^ 2) / 2)) + (multivariateGaussian 0 R) := by + apply Integrable.mono' (integrable_const (1 : ℝ)) (by fun_prop) + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + apply Real.exp_le_one_iff.mpr + have hsum : 0 ≤ ∑ i, z i * x i ^ 2 := Finset.sum_nonneg (fun i _ => + mul_nonneg (hz i) (sq_nonneg _)) + linarith + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def laplaceKernel (z x : ι → ℝ) : ℝ := Real.exp (-∑ i, z i * x i) + +omit [DecidableEq ι] in +lemma laplaceKernel_nonneg (z x : ι → ℝ) : 0 ≤ laplaceKernel z x := + (Real.exp_pos _).le + +omit [DecidableEq ι] in +lemma laplaceKernel_le_one {z x : ι → ℝ} (hz : ∀ i, 0 ≤ z i) (hx : ∀ i, 0 ≤ x i) : + laplaceKernel z x ≤ 1 := by + apply Real.exp_le_one_iff.mpr + exact neg_nonpos.mpr (Finset.sum_nonneg (fun i _ => mul_nonneg (hz i) (hx i))) + +omit [DecidableEq ι] in +lemma laplaceKernel_add (z x y : ι → ℝ) : + laplaceKernel z (x + y) = laplaceKernel z x * laplaceKernel z y := by + simp only [laplaceKernel, Pi.add_apply, mul_add, Finset.sum_add_distrib, + neg_add, Real.exp_add] + +omit [DecidableEq ι] in +lemma continuous_laplaceKernel (z : ι → ℝ) : Continuous (laplaceKernel z) := by + unfold laplaceKernel + fun_prop + +omit [DecidableEq ι] in +lemma measurableSet_nonnegative : MeasurableSet {x : ι → ℝ | ∀ i, 0 ≤ x i} := by + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => measurableSet_le measurable_const (measurable_pi_apply i)) + +noncomputable def squareLaw (R : Matrix ι ι ℝ) : Measure (ι → ℝ) := + (multivariateGaussian 0 R).map (fun x : EuclideanSpace ℝ ι => fun i => x i ^ 2 / 2) + +instance squareLaw_isProbabilityMeasure (R : Matrix ι ι ℝ) : + IsProbabilityMeasure (squareLaw R) := + by + unfold squareLaw + infer_instance + +lemma squareLaw_nonneg (R : Matrix ι ι ℝ) : + ∀ᵐ x ∂squareLaw R, ∀ i, 0 ≤ x i := by + rw [squareLaw, ae_map_iff (by fun_prop) measurableSet_nonnegative] + filter_upwards [] with x i + positivity + +omit [DecidableEq ι] in +lemma integrable_laplaceKernel {μ : Measure (ι → ℝ)} [IsFiniteMeasure μ] + (hμ : ∀ᵐ x ∂μ, ∀ i, 0 ≤ x i) {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) : + Integrable (laplaceKernel z) μ := by + apply Integrable.mono' (integrable_const (1 : ℝ)) (continuous_laplaceKernel _).aestronglyMeasurable + filter_upwards [hμ] with x hx + rw [Real.norm_eq_abs, abs_of_nonneg (laplaceKernel_nonneg _ _)] + exact laplaceKernel_le_one hz hx + +lemma laplace_squareLaw {R : Matrix ι ι ℝ} (hR : R.PosSemidef) + {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) : + (∫ x, laplaceKernel z x ∂squareLaw R) = + (Real.sqrt (diagonal z * R + 1).det)⁻¹ := by + rw [squareLaw, integral_map (Measurable.aemeasurable (by fun_prop)) + (continuous_laplaceKernel _).aestronglyMeasurable] + simp only [laplaceKernel, ← mul_div_assoc, ← Finset.sum_div] + simpa only [neg_div] using quadratic_laplace_multivariateGaussian hR hz + +noncomputable def sumLaw (μ ν : Measure (ι → ℝ)) : Measure (ι → ℝ) := + (μ.prod ν).map (fun x => x.1 + x.2) + +instance sumLaw_isProbabilityMeasure (μ ν : Measure (ι → ℝ)) + [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] : IsProbabilityMeasure (sumLaw μ ν) := + by + unfold sumLaw + infer_instance + +omit [DecidableEq ι] in +lemma sumLaw_nonneg {μ ν : Measure (ι → ℝ)} [SFinite μ] [SFinite ν] + (hμ : ∀ᵐ x ∂μ, ∀ i, 0 ≤ x i) (hν : ∀ᵐ x ∂ν, ∀ i, 0 ≤ x i) : + ∀ᵐ x ∂sumLaw μ ν, ∀ i, 0 ≤ x i := by + rw [sumLaw, ae_map_iff (by fun_prop) measurableSet_nonnegative] + apply (Measure.ae_prod_iff_ae_ae (measurableSet_nonnegative.preimage (by fun_prop))).mpr + filter_upwards [hμ] with x hx + filter_upwards [hν] with y hy + exact fun i => add_nonneg (hx i) (hy i) + +omit [DecidableEq ι] in +lemma laplace_sumLaw {μ ν : Measure (ι → ℝ)} [IsFiniteMeasure μ] [IsFiniteMeasure ν] + (z : ι → ℝ) : + (∫ x, laplaceKernel z x ∂sumLaw μ ν) = + (∫ x, laplaceKernel z x ∂μ) * (∫ x, laplaceKernel z x ∂ν) := by + rw [sumLaw, integral_map (Measurable.aemeasurable (by fun_prop)) + (continuous_laplaceKernel _).aestronglyMeasurable] + simp only [laplaceKernel_add] + exact integral_prod_mul _ _ + +noncomputable def tripleSquareLaw (R : Matrix ι ι ℝ) : Measure (ι → ℝ) := + sumLaw (squareLaw R) (sumLaw (squareLaw R) (squareLaw R)) + +instance tripleSquareLaw_isProbabilityMeasure (R : Matrix ι ι ℝ) : + IsProbabilityMeasure (tripleSquareLaw R) := inferInstanceAs + (IsProbabilityMeasure (sumLaw (squareLaw R) (sumLaw (squareLaw R) (squareLaw R)))) + +lemma tripleSquareLaw_nonneg (R : Matrix ι ι ℝ) : + ∀ᵐ x ∂tripleSquareLaw R, ∀ i, 0 ≤ x i := + sumLaw_nonneg (squareLaw_nonneg R) + (sumLaw_nonneg (squareLaw_nonneg R) (squareLaw_nonneg R)) + +lemma laplace_tripleSquareLaw {R : Matrix ι ι ℝ} (hR : R.PosSemidef) + {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) : + (∫ x, laplaceKernel z x ∂tripleSquareLaw R) = + ((Real.sqrt (diagonal z * R + 1).det)⁻¹) ^ 3 := by + rw [tripleSquareLaw, laplace_sumLaw, laplace_sumLaw, + laplace_squareLaw hR hz] + ring + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory Polynomial +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma polynomial_euler_eval (p : ℝ[X]) (y : ℝ) : + y * p.derivative.eval y = + ∑ k : Fin (p.natDegree + 1), p.coeff k * (k : ℝ) * y ^ (k : ℕ) := by + have he := congrArg (fun q : ℝ[X] => y * q.derivative.eval y) p.as_sum_range + rw [he] + simp only [Polynomial.derivative_sum, Polynomial.eval_finsetSum, Finset.mul_sum] + have hm (k : ℕ) : y * ((monomial k) (p.coeff k)).derivative.eval y = + p.coeff k * (k : ℝ) * y ^ k := by + cases k with + | zero => simp + | succ k => simp [pow_succ]; ring + simp only [hm, Finset.sum_range] + +lemma polynomial_eval_exp (p : ℝ[X]) (x : ℝ) : + p.eval (Real.exp (-x)) = ∑ k : Fin (p.natDegree + 1), + p.coeff k * Real.exp (-(k : ℝ) * x) := by + rw [Polynomial.eval_eq_sum_range] + simp only [← Real.exp_nat_mul, Finset.sum_range, mul_neg, neg_mul] + +lemma polynomial_euler_exp (p : ℝ[X]) (x : ℝ) : + Real.exp (-x) * p.derivative.eval (Real.exp (-x)) = + ∑ k : Fin (p.natDegree + 1), p.coeff k * (k : ℝ) * Real.exp (-(k : ℝ) * x) := by + rw [polynomial_euler_eval] + simp only [← Real.exp_nat_mul, mul_neg, neg_mul] + +abbrev PolynomialIndex (p : ι → ℝ[X]) := ∀ i, Fin ((p i).natDegree + 1) + +def polynomialWeight (p : ι → ℝ[X]) (k : PolynomialIndex p) : ℝ := + ∏ i, (p i).coeff (k i) + +def exponentVector {p : ι → ℝ[X]} (k : PolynomialIndex p) : ι → ℝ := fun i => (k i : ℝ) + +def mixedMultiplier {p : ι → ℝ[X]} (k : PolynomialIndex p) (S : Finset ι) : ℝ := + ∏ i ∈ S, (k i : ℝ) + +noncomputable def mixedPolynomial (p : ι → ℝ[X]) (S : Finset ι) (x : ι → ℝ) : ℝ := + ∏ i, if i ∈ S then Real.exp (-x i) * (p i).derivative.eval (Real.exp (-x i)) + else (p i).eval (Real.exp (-x i)) + +lemma mixedPolynomial_expansion (p : ι → ℝ[X]) (S : Finset ι) (x : ι → ℝ) : + mixedPolynomial p S x = ∑ k : PolynomialIndex p, + polynomialWeight p k * mixedMultiplier k S * laplaceKernel (exponentVector k) x := by + have hf (i : ι) : + (if i ∈ S then Real.exp (-x i) * (p i).derivative.eval (Real.exp (-x i)) + else (p i).eval (Real.exp (-x i))) = + ∑ k : Fin ((p i).natDegree + 1), (p i).coeff k * + (if i ∈ S then (k : ℝ) else 1) * Real.exp (-(k : ℝ) * x i) := by + split_ifs with hi + · exact polynomial_euler_exp _ _ + · simpa only [mul_one] using polynomial_eval_exp (p i) (x i) + rw [mixedPolynomial] + simp_rw [hf] + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro k _ + simp only [Finset.prod_mul_distrib, Finset.prod_ite_mem, Finset.univ_inter, + polynomialWeight, mixedMultiplier, laplaceKernel, exponentVector, + ← Real.exp_sum, Finset.sum_neg_distrib, neg_mul] + +lemma mixedPolynomial_nonneg (p : ι → ℝ[X]) (S : Finset ι) + (hp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).eval y) + (hdp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).derivative.eval y) + {x : ι → ℝ} (hx : ∀ i, 0 ≤ x i) : 0 ≤ mixedPolynomial p S x := by + apply Finset.prod_nonneg + intro i _ + have hy : Real.exp (-x i) ∈ Set.Icc (0 : ℝ) 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hx i))⟩ + split_ifs + · exact mul_nonneg (Real.exp_pos _).le (hdp i _ hy) + · exact hp i _ hy + +lemma integrable_mixedPolynomial {μ : Measure (ι → ℝ)} [IsFiniteMeasure μ] + (hμ : ∀ᵐ x ∂μ, ∀ i, 0 ≤ x i) (p : ι → ℝ[X]) (S : Finset ι) : + Integrable (mixedPolynomial p S) μ := by + simp_rw [show mixedPolynomial p S = fun x => ∑ k : PolynomialIndex p, + polynomialWeight p k * mixedMultiplier k S * laplaceKernel (exponentVector k) x + from funext (mixedPolynomial_expansion p S)] + apply integrable_finsetSum + intro k _ + exact (integrable_laplaceKernel hμ (fun i => by simp [exponentVector])).const_mul _ + +lemma integral_mixedPolynomial {μ : Measure (ι → ℝ)} [IsFiniteMeasure μ] + (hμ : ∀ᵐ x ∂μ, ∀ i, 0 ≤ x i) (p : ι → ℝ[X]) (S : Finset ι) : + (∫ x, mixedPolynomial p S x ∂μ) = ∑ k : PolynomialIndex p, + polynomialWeight p k * mixedMultiplier k S * + ∫ x, laplaceKernel (exponentVector k) x ∂μ := by + simp_rw [mixedPolynomial_expansion] + rw [integral_finsetSum] + · simp only [integral_const_mul] + · intro k _ + exact (integrable_laplaceKernel hμ (fun i => by simp [exponentVector])).const_mul _ + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory Polynomial +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def royenCoefficient (p : ι → Bool) (R : Matrix ι ι ℝ) + (S : Finset ι) (t : ℝ) : ℝ := + -(deriv (fun u => ((interpolate p R u).submatrix + (Subtype.val : S → ι) Subtype.val).det) t) / 2 + +omit [Fintype ι] in +lemma royenCoefficient_nonneg (p : ι → Bool) {R : Matrix ι ι ℝ} (hR : R.PosDef) + (S : Finset ι) {t : ℝ} (ht : t ∈ Set.Ioo 0 1) : 0 ≤ royenCoefficient p R S t := + div_nonneg (neg_nonneg.mpr (principal_minor_deriv_nonpos p hR S ht)) (by norm_num) + +lemma laplace_interpolate_derivative (p : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosDef) {z : ι → ℝ} (hz : ∀ i, 0 ≤ z i) {t : ℝ} + (ht : t ∈ Set.Icc 0 1) : + HasDerivAt (fun u => (Real.sqrt (diagonal z * interpolate p R u + 1).det)⁻¹) + (∑ S : Finset ι, royenCoefficient p R S t * (∏ i ∈ S, z i) * + ((Real.sqrt (diagonal z * interpolate p R t + 1).det)⁻¹)^3) t := by + have hpos := det_diagonal_mul_add_one_pos (interpolate_posDef p hR ht).posSemidef hz + have hspos := Real.sqrt_pos.mpr hpos + have hd := ((det_interpolate_derivative p R z t).sqrt hpos.ne').inv hspos.ne' + apply hd.congr_deriv + symm + rw [← Finset.sum_mul] + have he : (∑ S : Finset ι, royenCoefficient p R S t * ∏ i ∈ S, z i) = + -(∑ S : Finset ι, (∏ i ∈ S, z i) * deriv (fun u => + ((interpolate p R u).submatrix (Subtype.val : S → ι) Subtype.val).det) t) / 2 := by + simp only [royenCoefficient] + rw [← Finset.sum_neg_distrib, Finset.sum_div] + apply Finset.sum_congr rfl + intro S _ + ring + rw [he] + field_simp + +noncomputable def polynomialExpectation (p : ι → ℝ[X]) (R : Matrix ι ι ℝ) : ℝ := + ∑ k : PolynomialIndex p, polynomialWeight p k * + (Real.sqrt (diagonal (exponentVector k) * R + 1).det)⁻¹ + +lemma polynomialExpectation_eq_integral (p : ι → ℝ[X]) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) : polynomialExpectation p R = + ∫ x, mixedPolynomial p ∅ x ∂squareLaw R := by + rw [integral_mixedPolynomial (squareLaw_nonneg R)] + unfold polynomialExpectation + apply Finset.sum_congr rfl + intro k _ + simp only [mixedMultiplier, Finset.prod_empty, mul_one] + rw [laplace_squareLaw hR (z := exponentVector k) (fun i => Nat.cast_nonneg (k i).val)] + +lemma polynomialExpectation_derivative (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosDef) (p : ι → ℝ[X]) {t : ℝ} (ht : t ∈ Set.Icc 0 1) : + HasDerivAt (fun u => polynomialExpectation p (interpolate b R u)) + (∑ S : Finset ι, royenCoefficient b R S t * + ∫ x, mixedPolynomial p S x ∂tripleSquareLaw (interpolate b R t)) t := by + have hd := HasDerivAt.fun_sum (u := Finset.univ) (fun (k : PolynomialIndex p) _ => + (laplace_interpolate_derivative b hR (z := exponentVector k) + (fun i => by simp [exponentVector]) ht).const_mul (polynomialWeight p k)) + apply hd.congr_deriv + have he (S : Finset ι) : + (∫ x, mixedPolynomial p S x ∂tripleSquareLaw (interpolate b R t)) = + ∑ k : PolynomialIndex p, polynomialWeight p k * mixedMultiplier k S * + ((Real.sqrt (diagonal (exponentVector k) * interpolate b R t + 1).det)⁻¹)^3 := by + rw [integral_mixedPolynomial (tripleSquareLaw_nonneg _)] + apply Finset.sum_congr rfl + intro k _ + rw [laplace_tripleSquareLaw (interpolate_posDef b hR ht).posSemidef + (z := exponentVector k) (fun i => Nat.cast_nonneg (k i).val)] + simp_rw [he, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S _ + apply Finset.sum_congr rfl + intro k _ + simp only [mixedMultiplier, exponentVector] + ring + +lemma polynomialExpectation_monotone (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosDef) (p : ι → ℝ[X]) + (hp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).eval y) + (hdp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).derivative.eval y) : + MonotoneOn (fun t => polynomialExpectation p (interpolate b R t)) (Set.Icc 0 1) := by + have hd := fun t ht => polynomialExpectation_derivative b hR p (t := t) ht + apply monotoneOn_of_deriv_nonneg (convex_Icc _ _) + · intro t ht + exact (hd t ht).continuousAt.continuousWithinAt + · intro t ht + exact (hd t (interior_subset ht)).differentiableAt.differentiableWithinAt + · intro t ht + have ht' : t ∈ Set.Ioo 0 1 := by simpa only [interior_Icc] using ht + rw [(hd t ⟨ht'.1.le, ht'.2.le⟩).deriv] + apply Finset.sum_nonneg + intro S _ + apply mul_nonneg (royenCoefficient_nonneg b hR S ht') + apply integral_nonneg_of_ae + filter_upwards [tripleSquareLaw_nonneg (interpolate b R t)] with x hx + exact mixedPolynomial_nonneg p S hp hdp hx + +lemma polynomial_correlation_interpolate (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosDef) (p : ι → ℝ[X]) + (hp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).eval y) + (hdp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).derivative.eval y) : + (∫ x, mixedPolynomial p ∅ x ∂squareLaw (interpolate b R 0)) ≤ + ∫ x, mixedPolynomial p ∅ x ∂squareLaw R := by + have hm := polynomialExpectation_monotone b hR p hp hdp + have he := hm (a := 0) (b := 1) (by norm_num) (by norm_num) (by norm_num) + dsimp only at he + rw [interpolate_one, polynomialExpectation_eq_integral p hR.posSemidef, + polynomialExpectation_eq_integral p + (interpolate_posDef b hR (by norm_num : (0 : ℝ) ∈ Set.Icc 0 1)).posSemidef] at he + exact he + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Polynomial _root_.Filter +open scoped unitInterval Topology + +noncomputable def bernsteinP (n : ℕ) (a : ℕ → ℝ) : ℝ[X] := + ∑ k ∈ Finset.range (n + 1), C (a k) * bernsteinPolynomial ℝ n k + +lemma bernsteinP_derivative (n : ℕ) (a : ℕ → ℝ) : + (bernsteinP (n + 1) a).derivative = + C (n + 1 : ℝ) * ∑ k ∈ Finset.range (n + 1), + C (a (k + 1) - a k) * bernsteinPolynomial ℝ n k := by + have hend : bernsteinPolynomial ℝ n (n + 1) = 0 := by + simp [bernsteinPolynomial] + have ht : (∑ k ∈ Finset.range (n + 1), C (a (k + 1)) * bernsteinPolynomial ℝ n (k + 1)) = + (∑ k ∈ Finset.range (n + 1), C (a k) * bernsteinPolynomial ℝ n k) - + C (a 0) * bernsteinPolynomial ℝ n 0 := by + have he := Finset.sum_range_succ' (fun k => C (a k) * bernsteinPolynomial ℝ n k) (n+1) + rw [Finset.sum_range_succ, hend, mul_zero, add_zero] at he + exact eq_sub_iff_add_eq.mpr he.symm + rw [bernsteinP, Finset.sum_range_succ'] + simp only [Polynomial.derivative_sum, + Polynomial.derivative_C_mul, bernsteinPolynomial.derivative_succ_aux, + bernsteinPolynomial.derivative_zero, Nat.add_sub_cancel, + map_add, map_natCast, map_one, Nat.cast_add, Nat.cast_one] + simp only [mul_sub, Finset.sum_sub_distrib, map_sub] + simp only [show ∀ k, C (a (k + 1)) * ((n + 1) * bernsteinPolynomial ℝ n k) = + (n + 1) * (C (a (k + 1)) * bernsteinPolynomial ℝ n k) from fun k => by ring, + show ∀ k, C (a (k + 1)) * ((n + 1) * bernsteinPolynomial ℝ n (k + 1)) = + (n + 1) * (C (a (k + 1)) * bernsteinPolynomial ℝ n (k + 1)) from fun k => by ring, + ← Finset.mul_sum, ht] + simp only [sub_mul, Finset.sum_sub_distrib] + ring + +lemma bernsteinP_eval (n : ℕ) (f : C(ℝ, ℝ)) (x : I) : + (bernsteinP n (fun k => f ((k : ℝ) / n))).eval (x : ℝ) = + bernsteinApproximation n (f.comp ⟨Subtype.val, continuous_subtype_val⟩) x := by + simp only [bernsteinP, Polynomial.eval_finsetSum, Polynomial.eval_mul, + Polynomial.eval_C, bernsteinApproximation.apply, smul_eq_mul, ContinuousMap.comp_apply, + ContinuousMap.coe_mk, bernstein.z, Finset.sum_range] + apply Finset.sum_congr rfl + intro k _ + rw [mul_comm] + rfl + +lemma bernsteinP_eval_nonneg (n : ℕ) (f : C(ℝ, ℝ)) + (hf : ∀ x ∈ Set.Icc (0 : ℝ) 1, 0 ≤ f x) {x : ℝ} (hx : x ∈ Set.Icc (0 : ℝ) 1) : + 0 ≤ (bernsteinP n (fun k => f ((k : ℝ) / n))).eval x := by + have he := bernsteinP_eval n f ⟨x, hx⟩ + rw [he, bernsteinApproximation.apply] + apply Finset.sum_nonneg + intro k _ + exact mul_nonneg bernstein_nonneg (hf _ (bernstein.z k).prop) + +lemma bernsteinP_eval_le_one (n : ℕ) (f : C(ℝ, ℝ)) + (hf : ∀ x ∈ Set.Icc (0 : ℝ) 1, f x ≤ 1) {x : ℝ} (hx : x ∈ Set.Icc (0 : ℝ) 1) : + (bernsteinP n (fun k => f ((k : ℝ) / n))).eval x ≤ 1 := by + have he := bernsteinP_eval n f ⟨x, hx⟩ + rw [he, bernsteinApproximation.apply, ← bernstein.probability n ⟨x, hx⟩] + apply Finset.sum_le_sum + intro k _ + exact mul_le_of_le_one_right bernstein_nonneg (hf _ (bernstein.z k).prop) + +lemma bernsteinP_derivative_nonneg (n : ℕ) (f : C(ℝ, ℝ)) + (hf : MonotoneOn f (Set.Icc (0 : ℝ) 1)) + {x : ℝ} (hx : x ∈ Set.Icc (0 : ℝ) 1) : + 0 ≤ (bernsteinP n (fun k => f ((k : ℝ) / n))).derivative.eval x := by + cases n with + | zero => simp [bernsteinP, bernsteinPolynomial] + | succ n => + rw [bernsteinP_derivative] + simp only [Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_finsetSum] + apply mul_nonneg (by positivity) + apply Finset.sum_nonneg + intro k hk + have hk' : k < n + 1 := Finset.mem_range.mp hk + have hn : (0 : ℝ) < n + 1 := by positivity + have hk0 : (0 : ℝ) ≤ k / (n + 1) := div_nonneg (Nat.cast_nonneg _) hn.le + have hk1 : (k : ℝ) / (n + 1) ≤ 1 := (div_le_one hn).mpr (by exact_mod_cast hk'.le) + have hks0 : (0 : ℝ) ≤ (k + 1) / (n + 1) := by positivity + have hks1 : (k + 1 : ℝ) / (n + 1) ≤ 1 := + (div_le_one hn).mpr (by exact_mod_cast hk') + have hmono := hf ⟨hk0, hk1⟩ ⟨hks0, hks1⟩ (by gcongr; linarith) + apply mul_nonneg + · simpa only [Nat.cast_add, Nat.cast_one] using sub_nonneg.mpr hmono + · exact @bernstein_nonneg n k ⟨x, hx⟩ + +lemma bernsteinP_tendsto (f : C(ℝ, ℝ)) {x : ℝ} (hx : x ∈ Set.Icc (0 : ℝ) 1) : + Tendsto (fun n => (bernsteinP n (fun k => f ((k : ℝ) / n))).eval x) + atTop (𝓝 (f x)) := by + simp_rw [bernsteinP_eval _ _ ⟨x, hx⟩] + exact (continuous_eval_const ⟨x, hx⟩).continuousAt.tendsto.comp + (bernsteinApproximation_uniform (f.comp ⟨Subtype.val, continuous_subtype_val⟩)) + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory Polynomial _root_.Filter +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator Topology +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma interpolate_zero_posSemidef (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) : (interpolate b R 0).PosSemidef := by + let A : Matrix ι ι ℝ := diagonal (fun i => if b i = true then 1 else 0) + let B : Matrix ι ι ℝ := diagonal (fun i => if b i = true then 0 else 1) + have he : interpolate b R 0 = A * R * Aᴴ + B * R * Bᴴ := by + ext i j + simp only [interpolate, zero_mul, A, B, diagonal_conjTranspose, + star_trivial, diagonal_mul, mul_diagonal, Matrix.add_apply] + cases b i <;> cases b j <;> simp + rw [he] + exact (hR.mul_mul_conjTranspose_same A).add (hR.mul_mul_conjTranspose_same B) + +omit [Fintype ι] [DecidableEq ι] in +lemma interpolate_continuous (b : ι → Bool) (t : ℝ) : + Continuous (fun R : Matrix ι ι ℝ => interpolate b R t) := by + apply continuous_pi + intro i + apply continuous_pi + intro j + dsimp only [interpolate] + split_ifs <;> fun_prop + +lemma polynomialExpectation_continuousAt (p : ι → ℝ[X]) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) : ContinuousAt (polynomialExpectation p) R := by + unfold polynomialExpectation + apply tendsto_finsetSum + intro k _ + apply ContinuousAt.const_mul + apply ContinuousAt.inv₀ + · exact (Continuous.sqrt (by fun_prop)).continuousAt + · exact (Real.sqrt_pos.mpr (det_diagonal_mul_add_one_pos hR + (fun i => Nat.cast_nonneg (k i).val))).ne' + +lemma polynomial_correlation_psd (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) (p : ι → ℝ[X]) + (hp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).eval y) + (hdp : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → 0 ≤ (p i).derivative.eval y) : + (∫ x, mixedPolynomial p ∅ x ∂squareLaw (interpolate b R 0)) ≤ + ∫ x, mixedPolynomial p ∅ x ∂squareLaw R := by + let Rn (n : ℕ) := R + (1 / ((n : ℝ) + 1)) • (1 : Matrix ι ι ℝ) + have hn (n : ℕ) : (Rn n).PosDef := + Matrix.PosDef.posSemidef_add hR (Matrix.PosDef.one.smul (by positivity)) + have ht : Tendsto Rn atTop (𝓝 R) := by + simpa only [zero_smul, add_zero] using + (tendsto_const_nhds (x := R)).add + ((tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).smul + (tendsto_const_nhds (x := (1 : Matrix ι ι ℝ)))) + rw [← polynomialExpectation_eq_integral p hR, + ← polynomialExpectation_eq_integral p (interpolate_zero_posSemidef b hR)] + exact le_of_tendsto_of_tendsto' + ((polynomialExpectation_continuousAt p (interpolate_zero_posSemidef b hR)).tendsto.comp + ((interpolate_continuous b 0).continuousAt.tendsto.comp ht)) + ((polynomialExpectation_continuousAt p hR).tendsto.comp ht) + (fun n => by + have he := polynomial_correlation_interpolate b (hn n) p hp hdp + simpa only [← polynomialExpectation_eq_integral p (hn n).posSemidef, + ← polynomialExpectation_eq_integral p + (interpolate_zero_posSemidef b (hn n).posSemidef)] using! he) + +noncomputable def continuousProduct (f : ι → C(ℝ, ℝ)) (x : ι → ℝ) : ℝ := + ∏ i, f i (Real.exp (-x i)) + +lemma bernstein_integral_tendsto {μ : Measure (ι → ℝ)} [IsFiniteMeasure μ] + (hμ : ∀ᵐ x ∂μ, ∀ i, 0 ≤ x i) (f : ι → C(ℝ, ℝ)) + (hf : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → f i y ∈ Set.Icc (0 : ℝ) 1) : + Tendsto (fun n : ℕ => ∫ x, mixedPolynomial + (fun i => bernsteinP n (fun k => f i ((k : ℝ) / n))) ∅ x ∂μ) + atTop (𝓝 (∫ x, continuousProduct f x ∂μ)) := by + apply tendsto_integral_of_dominated_convergence (fun _ => (1 : ℝ)) + · intro n + exact (integrable_mixedPolynomial hμ _ ∅).aestronglyMeasurable + · exact integrable_const _ + · intro n + filter_upwards [hμ] with x hx + have hy (i : ι) : Real.exp (-x i) ∈ Set.Icc (0 : ℝ) 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hx i))⟩ + have hnon (i : ι) := bernsteinP_eval_nonneg n (f i) (fun y hy => (hf i y hy).1) (hy i) + have hone (i : ι) := bernsteinP_eval_le_one n (f i) (fun y hy => (hf i y hy).2) (hy i) + simp only [mixedPolynomial, Finset.notMem_empty, ↓reduceIte, Real.norm_eq_abs] + rw [abs_of_nonneg (Finset.prod_nonneg (fun i _ => hnon i))] + exact Finset.prod_le_one₀ (fun i _ => hnon i) (fun i _ => hone i) + · filter_upwards [hμ] with x hx + simp only [mixedPolynomial, Finset.notMem_empty, ↓reduceIte, continuousProduct] + apply tendsto_finsetProd + intro i _ + exact bernsteinP_tendsto (f i) + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hx i))⟩ + +lemma continuous_correlation_interpolate (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) (f : ι → C(ℝ, ℝ)) + (hf : ∀ i y, y ∈ Set.Icc (0 : ℝ) 1 → f i y ∈ Set.Icc (0 : ℝ) 1) + (hm : ∀ i, MonotoneOn (f i) (Set.Icc (0 : ℝ) 1)) : + (∫ x, continuousProduct f x ∂squareLaw (interpolate b R 0)) ≤ + ∫ x, continuousProduct f x ∂squareLaw R := by + apply le_of_tendsto_of_tendsto' + (bernstein_integral_tendsto (squareLaw_nonneg _) f hf) + (bernstein_integral_tendsto (squareLaw_nonneg _) f hf) + intro n + apply polynomial_correlation_psd b hR + · intro i y hy + exact bernsteinP_eval_nonneg n (f i) (fun y hy => (hf i y hy).1) hy + · intro i y hy + exact bernsteinP_derivative_nonneg n (f i) (hm i) hy + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory _root_.Filter +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator Topology +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def upperCutoff (n : ℕ) (a : ℝ) : C(ℝ, ℝ) := + ⟨fun y => min 1 (max 0 (1 + ((n : ℝ) + 1) * (y - a))), by fun_prop⟩ + +lemma upperCutoff_bounds (n : ℕ) (a y : ℝ) : + upperCutoff n a y ∈ Set.Icc (0 : ℝ) 1 := by + exact ⟨le_min zero_le_one (le_max_left _ _), min_le_left _ _⟩ + +lemma upperCutoff_monotone (n : ℕ) (a : ℝ) : Monotone (upperCutoff n a) := by + intro x y hxy + dsimp only [upperCutoff, ContinuousMap.coe_mk] + gcongr + +lemma upperCutoff_tendsto (a y : ℝ) : + Tendsto (fun n => upperCutoff n a y) atTop (𝓝 (if a ≤ y then (1 : ℝ) else 0)) := by + by_cases h : a ≤ y + · have he (n : ℕ) : upperCutoff n a y = 1 := by + apply min_eq_left + exact (by nlinarith [show (0 : ℝ) ≤ n by positivity] : (1:ℝ) ≤ + 1 + ((n : ℝ)+1) * (y-a)) |>.trans (le_max_right _ _) + simp only [he, ite_eq_left h] + exact tendsto_const_nhds + · have ha : 0 < a - y := sub_pos.mpr (lt_of_not_ge h) + obtain ⟨N, hN⟩ := exists_nat_gt (1 / (a - y)) + have he : ∀ᶠ n : ℕ in atTop, upperCutoff n a y = 0 := by + filter_upwards [eventually_ge_atTop N] with n hn + have hnn : (N : ℝ) ≤ n := by exact_mod_cast hn + have hb : 1 ≤ ((n : ℝ) + 1) * (a-y) := by + have := (div_lt_iff₀ ha).mp hN + nlinarith + simp only [upperCutoff, ContinuousMap.coe_mk] + rw [max_eq_left (by nlinarith), min_eq_right zero_le_one] + simp only [ite_eq_right h] + exact tendsto_const_nhds.congr' (Filter.EventuallyEq.symm he) + +noncomputable def exponentialBox (a : ι → ℝ) : Set (ι → ℝ) := + {x | ∀ i, a i ≤ Real.exp (-x i)} + +omit [DecidableEq ι] in +lemma measurableSet_exponentialBox (a : ι → ℝ) : MeasurableSet (exponentialBox a) := by + unfold exponentialBox + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => measurableSet_le measurable_const (by fun_prop)) + +omit [DecidableEq ι] in +lemma cutoffProduct_tendsto (a x : ι → ℝ) : + Tendsto (fun n => continuousProduct (fun i => upperCutoff n (a i)) x) atTop + (𝓝 ((exponentialBox a).indicator (fun _ => (1 : ℝ)) x)) := by + have ht := tendsto_finsetProd Finset.univ + (fun i _ => upperCutoff_tendsto (a i) (Real.exp (- x i))) + convert ht using 1 + congr 1 + by_cases h : x ∈ exponentialBox a + · rw [Set.indicator_of_mem h] + have hi (i : ι) : a i ≤ Real.exp (-x i) := h i + simp [hi] + · rw [Set.indicator_of_notMem h] + have hi : ∃ i, ¬ a i ≤ Real.exp (-x i) := by simpa [exponentialBox] using h + obtain ⟨i, hi⟩ := hi + symm + exact congrArg nhds (Finset.prod_eq_zero (f := fun j => if a j ≤ Real.exp (-x j) then (1 : ℝ) else 0) + (Finset.mem_univ i) (ite_eq_right hi)) + +omit [DecidableEq ι] in +lemma cutoff_integral_tendsto {μ : Measure (ι → ℝ)} [IsFiniteMeasure μ] (a : ι → ℝ) : + Tendsto (fun n => ∫ x, continuousProduct (fun i => upperCutoff n (a i)) x ∂μ) + atTop (𝓝 (μ.real (exponentialBox a))) := by + rw [← integral_indicator_one (measurableSet_exponentialBox a)] + apply tendsto_integral_of_dominated_convergence (fun _ => (1 : ℝ)) + · intro n + exact Continuous.aestronglyMeasurable (by unfold continuousProduct; fun_prop) + · exact integrable_const _ + · intro n + filter_upwards [] with x + have hn (i : ι) := (upperCutoff_bounds n (a i) (Real.exp (-x i))).1 + have ho (i : ι) := (upperCutoff_bounds n (a i) (Real.exp (-x i))).2 + rw [continuousProduct, Real.norm_eq_abs, abs_of_nonneg (Finset.prod_nonneg (fun i _ => hn i))] + exact Finset.prod_le_one₀ (fun i _ => hn i) (fun i _ => ho i) + · exact Filter.Eventually.of_forall (cutoffProduct_tendsto a) + +lemma rectangle_correlation_interpolate (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) (a : ι → ℝ) : + (squareLaw (interpolate b R 0)).real (exponentialBox a) ≤ + (squareLaw R).real (exponentialBox a) := by + apply le_of_tendsto_of_tendsto' (cutoff_integral_tendsto a) (cutoff_integral_tendsto a) + intro n + exact continuous_correlation_interpolate b hR (fun i => upperCutoff n (a i)) + (fun i y _ => upperCutoff_bounds n (a i) y) + (fun i => (upperCutoff_monotone n (a i)).monotoneOn _) + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory _root_.Filter +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator Topology +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +noncomputable def coordinatePi (f : κ → ι) : EuclideanSpace ℝ ι →L[ℝ] (κ → ℝ) := + ContinuousLinearMap.pi (fun i => EuclideanSpace.proj (f i)) + +noncomputable def coordinateCLM (f : κ → ι) : EuclideanSpace ℝ ι →L[ℝ] EuclideanSpace ℝ κ := + (PiLp.continuousLinearEquiv 2 ℝ (fun _ : κ => ℝ)).symm.toContinuousLinearMap.comp + (coordinatePi f) + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +@[simp] lemma coordinateCLM_apply (f : κ → ι) (x : EuclideanSpace ℝ ι) (i : κ) : + coordinateCLM f x i = x (f i) := rfl + +lemma map_coordinate_multivariateGaussian (f : κ → ι) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) : + (multivariateGaussian 0 R).map (coordinateCLM f) = + multivariateGaussian 0 (R.submatrix f f) := by + apply IsGaussian.ext + · simp only [id_eq, integral_id_multivariateGaussian] + rw [ContinuousLinearMap.integral_id_map IsGaussian.integrable_id, + integral_id_multivariateGaussian, map_zero] + rw [← ContinuousLinearMap.toBilinForm_inj] + refine LinearMap.BilinForm.ext_basis (EuclideanSpace.basisFun κ ℝ).toBasis fun i j => ?_ + rw [ContinuousLinearMap.toBilinForm_apply, ContinuousLinearMap.toBilinForm_apply, + covarianceBilin_apply_eq_cov, covariance_map] + · have he (i : κ) : (fun u => ⟪(EuclideanSpace.basisFun κ ℝ).toBasis i, u⟫) ∘ + coordinateCLM f = fun u => u (f i) := by + ext u + simp [PiLp.inner_apply] + simp_rw [he, covariance_eval_multivariateGaussian hR, + covarianceBilin_multivariateGaussian (hR.submatrix _)] + simp + any_goals exact Measurable.aestronglyMeasurable (by fun_prop) + · fun_prop + · exact IsGaussian.memLp_two_id + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma block_submatrix_eq (b : ι → Bool) (v : Bool) (R : Matrix ι ι ℝ) : + (interpolate b R 0).submatrix (fun i : {i // b i = v} => i.val) + (fun i : {i // b i = v} => i.val) = + R.submatrix (fun i : {i // b i = v} => i.val) (fun i : {i // b i = v} => i.val) := by + ext i j + simp [Matrix.submatrix, interpolate, i.prop, j.prop] + +omit [Fintype κ] [DecidableEq κ] in +lemma gaussian_blocks_independent (b : ι → Bool) {R : Matrix ι ι ℝ} (hR : R.PosSemidef) : + IndepFun (coordinatePi (fun i : {i // b i = true} => i.val)) + (coordinatePi (fun i : {i // b i = false} => i.val)) + (multivariateGaussian 0 (interpolate b R 0)) := by + apply HasGaussianLaw.indepFun_of_covariance_eval + · exact IsGaussian.hasGaussianLaw_id.map + ((coordinatePi (fun i : {i // b i = true} => i.val)).prod + (coordinatePi (fun i : {i // b i = false} => i.val))) + · intro i j + change cov[fun x => x i.val, fun x => x j.val; + multivariateGaussian 0 (interpolate b R 0)] = 0 + rw [covariance_eval_multivariateGaussian (interpolate_zero_posSemidef b hR)] + simp [interpolate, i.prop, j.prop] + +noncomputable def quadraticBox (t : ι → ℝ) : Set (EuclideanSpace ℝ ι) := + {x | ∀ i, x i ^ 2 / 2 ≤ t i} + +omit [DecidableEq ι] [Fintype κ] [DecidableEq κ] in +lemma measurableSet_quadraticBox (t : ι → ℝ) : MeasurableSet (quadraticBox t) := by + unfold quadraticBox + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => measurableSet_le (by fun_prop) measurable_const) + +omit [Fintype κ] [DecidableEq κ] in +lemma squareLaw_exponentialBox (R : Matrix ι ι ℝ) (t : ι → ℝ) : + (squareLaw R).real (exponentialBox (fun i => Real.exp (-t i))) = + (multivariateGaussian 0 R).real (quadraticBox t) := by + unfold Measure.real squareLaw + rw [Measure.map_apply (by fun_prop) (measurableSet_exponentialBox _)] + congr 2 + ext x + simp [exponentialBox, quadraticBox, Real.exp_le_exp] + +omit [Fintype κ] [DecidableEq κ] in +lemma quadratic_correlation_interpolate (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) (t : ι → ℝ) : + (multivariateGaussian 0 (interpolate b R 0)).real (quadraticBox t) ≤ + (multivariateGaussian 0 R).real (quadraticBox t) := by + simpa only [squareLaw_exponentialBox] using + rectangle_correlation_interpolate b hR (fun i => Real.exp (-t i)) + +omit [Fintype κ] [DecidableEq κ] in +lemma block_marginal_eq (b : ι → Bool) (v : Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) (S : Set (EuclideanSpace ℝ {i // b i = v})) (hS : MeasurableSet S) : + (multivariateGaussian 0 (interpolate b R 0)) ((coordinateCLM Subtype.val) ⁻¹' S) = + (multivariateGaussian 0 R) ((coordinateCLM Subtype.val) ⁻¹' S) := by + rw [← Measure.map_apply (coordinateCLM Subtype.val).measurable hS, + ← Measure.map_apply (coordinateCLM Subtype.val).measurable hS, + map_coordinate_multivariateGaussian _ (interpolate_zero_posSemidef b hR), + map_coordinate_multivariateGaussian _ hR, block_submatrix_eq] + +omit [Fintype κ] [DecidableEq κ] in +lemma gaussian_quadraticBox_correlation (b : ι → Bool) {R : Matrix ι ι ℝ} + (hR : R.PosSemidef) (t : ι → ℝ) : + (multivariateGaussian 0 R).real {x | ∀ i, b i = true → x i ^ 2 / 2 ≤ t i} * + (multivariateGaussian 0 R).real {x | ∀ i, b i = false → x i ^ 2 / 2 ≤ t i} ≤ + (multivariateGaussian 0 R).real (quadraticBox t) := by + let S : Set ({i // b i = true} → ℝ) := {x | ∀ i, x i ^ 2 / 2 ≤ t i.val} + let T : Set ({i // b i = false} → ℝ) := {x | ∀ i, x i ^ 2 / 2 ≤ t i.val} + have hS : MeasurableSet S := by + dsimp only [S] + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => measurableSet_le (by fun_prop) measurable_const) + have hT : MeasurableSet T := by + dsimp only [T] + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => measurableSet_le (by fun_prop) measurable_const) + have he := (gaussian_blocks_independent b hR).measure_inter_preimage_eq_mul S T hS hT + have hi : (coordinatePi (fun i : {i // b i = true} => i.val)) ⁻¹' S ∩ + (coordinatePi (fun i : {i // b i = false} => i.val)) ⁻¹' T = quadraticBox t := by + ext x + simp only [Set.mem_inter_iff, Set.mem_preimage, S, T, Set.mem_ofPred_eq, + coordinatePi, ContinuousLinearMap.pi_apply, + quadraticBox, Subtype.forall] + constructor + · rintro ⟨ht, hf⟩ i + cases hi : b i + · exact hf i hi + · exact ht i hi + · exact fun h => ⟨fun i _ => h i, fun i _ => h i⟩ + have hs (v : Bool) : + (coordinateCLM (fun i : {i // b i = v} => i.val)) ⁻¹' + quadraticBox (fun i => t i.val) = + {x : EuclideanSpace ℝ ι | ∀ i, b i = v → x i ^ 2 / 2 ≤ t i} := by + ext x + simp [quadraticBox, Subtype.forall] + have hm (v : Bool) := block_marginal_eq b v hR _ + (measurableSet_quadraticBox (fun i : {i // b i = v} => t i.val)) + simp_rw [hs] at hm + have hps : (coordinatePi (fun i : {i // b i = true} => i.val)) ⁻¹' S = + {x : EuclideanSpace ℝ ι | ∀ i, b i = true → x i ^ 2 / 2 ≤ t i} := by + ext x + simp [S, coordinatePi, Subtype.forall] + have hpt : (coordinatePi (fun i : {i // b i = false} => i.val)) ⁻¹' T = + {x : EuclideanSpace ℝ ι | ∀ i, b i = false → x i ^ 2 / 2 ≤ t i} := by + ext x + simp [T, coordinatePi, Subtype.forall] + rw [hi, hps, hpt, hm true, hm false] at he + have her := congrArg ENNReal.toReal he + rw [ENNReal.toReal_mul] at her + change (multivariateGaussian 0 R).real _ * (multivariateGaussian 0 R).real _ ≤ _ + unfold Measure.real + rw [← her] + exact quadratic_correlation_interpolate b hR t + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory _root_.Filter +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator Topology +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +noncomputable def innerCoordinates (u : ι → E) : E →L[ℝ] EuclideanSpace ℝ ι := + (PiLp.continuousLinearEquiv 2 ℝ (fun _ : ι => ℝ)).symm.toContinuousLinearMap.comp + (ContinuousLinearMap.pi (fun i => innerSL ℝ (u i))) + +omit [Fintype ι] [DecidableEq ι] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +@[simp] lemma innerCoordinates_apply (u : ι → E) (x : E) (i : ι) : + innerCoordinates u x i = ⟪u i, x⟫ := rfl + +lemma map_innerCoordinates_stdGaussian (u : ι → E) : + (stdGaussian E).map (innerCoordinates u) = multivariateGaussian 0 (gram ℝ u) := by + apply IsGaussian.ext + · simp only [id_eq, integral_id_multivariateGaussian] + rw [ContinuousLinearMap.integral_id_map IsGaussian.integrable_id, + integral_id_stdGaussian, map_zero] + rw [← ContinuousLinearMap.toBilinForm_inj] + refine LinearMap.BilinForm.ext_basis (EuclideanSpace.basisFun ι ℝ).toBasis fun i j => ?_ + rw [ContinuousLinearMap.toBilinForm_apply, ContinuousLinearMap.toBilinForm_apply, + covarianceBilin_apply_eq_cov, covariance_map] + · have he (i : ι) : (fun y => ⟪(EuclideanSpace.basisFun ι ℝ).toBasis i, y⟫) ∘ + innerCoordinates u = fun x => ⟪u i, x⟫ := by + ext x + simp [PiLp.inner_apply] + simp_rw [he] + rw [← covarianceBilin_apply_eq_cov IsGaussian.memLp_two_id, + covarianceBilin_stdGaussian, + covarianceBilin_multivariateGaussian (posSemidef_gram ℝ u)] + simp + rfl + any_goals exact Measurable.aestronglyMeasurable (by fun_prop) + · fun_prop + · exact IsGaussian.memLp_two_id + +lemma stdGaussian_finite_slabs_correlation (b : ι → Bool) (u : ι → E) (r : ι → ℝ) + (hr : ∀ i, 0 ≤ r i) : + (stdGaussian E).real {x | ∀ i, b i = true → |⟪u i, x⟫| ≤ r i} * + (stdGaussian E).real {x | ∀ i, b i = false → |⟪u i, x⟫| ≤ r i} ≤ + (stdGaussian E).real {x | ∀ i, |⟪u i, x⟫| ≤ r i} := by + have he := gaussian_quadraticBox_correlation b (posSemidef_gram ℝ u) (fun i => r i ^ 2 / 2) + rw [← map_innerCoordinates_stdGaussian u] at he + have hmeas (v : Bool) : MeasurableSet + {x : EuclideanSpace ℝ ι | ∀ i, b i = v → x i ^ 2 / 2 ≤ r i ^ 2 / 2} := by + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => MeasurableSet.iInter (fun _ => + measurableSet_le (by fun_prop) measurable_const)) + unfold Measure.real at he ⊢ + rw [Measure.map_apply (innerCoordinates u).measurable (hmeas true), + Measure.map_apply (innerCoordinates u).measurable (hmeas false), + Measure.map_apply (innerCoordinates u).measurable (measurableSet_quadraticBox _)] at he + have hsq (i : ι) (x : E) : ⟪u i, x⟫ ^ 2 / 2 ≤ r i ^ 2 / 2 ↔ |⟪u i, x⟫| ≤ r i := by + rw [div_le_div_iff_of_pos_right (by norm_num : (0:ℝ)<2)] + exact (sq_le_sq₀ (abs_nonneg _) (hr i)).symm.trans (by rw [sq_abs]) |>.symm + simpa only [Set.preimage_ofPred_eq, innerCoordinates_apply, quadraticBox, hsq] using he + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open Matrix MeasureTheory ProbabilityTheory _root_.Filter InnerProductSpace +open scoped NNReal RealInnerProductSpace MatrixOrder Matrix.Norms.L2Operator Topology +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +omit [MeasurableSpace E] [BorelSpace E] in +lemma closed_symmetric_convex_countable_slabs {K : Set E} (hK : IsClosed K) + (hc : Convex ℝ K) (hs : ∀ x ∈ K, -x ∈ K) (h0 : (0:E) ∈ K) : + ∃ (u : ℕ → E) (r : ℕ → ℝ), (∀ n, 0 ≤ r n) ∧ + K = ⋂ n, {x | |⟪u n, x⟫| ≤ r n} := by + let I := {p : StrongDual ℝ E × ℝ // ∀ x ∈ K, |p.1 x| ≤ p.2} + let : Nonempty I := ⟨⟨(0, 0), by intro x _; simp⟩⟩ + let U (p : I) : Set E := {x | |p.val.1 x| ≤ p.val.2}ᶜ + have ho (p : I) : IsOpen (U p) := (isClosed_le (p.val.1.continuous.abs) continuous_const).isOpen_compl + have hcover : Kᶜ ⊆ ⋃ p, U p := by + intro x hx + obtain ⟨f, r, hf, hr⟩ := geometric_hahn_banach_closed_point hc hK hx + have hb : ∀ y ∈ K, |f y| ≤ r := by + intro y hy + apply abs_le.mpr + have hneg := hf (-y) (hs y hy) + simp only [map_neg] at hneg + exact ⟨by linarith, (hf y hy).le⟩ + refine Set.mem_iUnion.mpr ⟨⟨(f, r), hb⟩, ?_⟩ + change ¬ |f x| ≤ r + exact not_le.mpr (lt_of_lt_of_le hr (le_abs_self _)) + obtain ⟨g, hg⟩ := (HereditarilyLindelofSpace.isLindelof Kᶜ).indexed_countable_subcover U ho hcover + refine ⟨fun n => (toDual ℝ E).symm (g n).val.1, fun n => (g n).val.2, ?_, ?_⟩ + · intro n + simpa using (g n).prop 0 h0 + · ext x + simp only [Set.mem_iInter, Set.mem_ofPred_eq, toDual_symm_apply] + constructor + · exact fun hx n => (g n).prop x hx + · intro hx + by_contra hn + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp (hg hn) + exact hn (hx n) + +noncomputable def partialSlabs (u : ℕ → E) (r : ℕ → ℝ) (n : ℕ) : Set E := + {x | ∀ i, i < n → |⟪u i, x⟫| ≤ r i} + +omit [FiniteDimensional ℝ E] in +lemma measurableSet_partialSlabs (u : ℕ → E) (r : ℕ → ℝ) (n : ℕ) : + MeasurableSet (partialSlabs u r n) := by + unfold partialSlabs + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter (fun i => MeasurableSet.iInter (fun _ => + measurableSet_le (by fun_prop) measurable_const)) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma partialSlabs_antitone (u : ℕ → E) (r : ℕ → ℝ) : Antitone (partialSlabs u r) := by + intro n m hnm x hx i hi + exact hx i (hi.trans_le hnm) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma partialSlabs_iInter (u : ℕ → E) (r : ℕ → ℝ) : + (⋂ n, partialSlabs u r n) = ⋂ n, {x | |⟪u n, x⟫| ≤ r n} := by + ext x + simp only [Set.mem_iInter, partialSlabs, Set.mem_ofPred_eq] + constructor + · exact fun h i => h (i+1) i (Nat.lt_succ_self i) + · exact fun h _ i _ => h i + +lemma stdGaussian_partialSlabs_correlation (u v : ℕ → E) (r s : ℕ → ℝ) + (hr : ∀ n, 0 ≤ r n) (hs : ∀ n, 0 ≤ s n) (n : ℕ) : + (stdGaussian E).real (partialSlabs u r n) * (stdGaussian E).real (partialSlabs v s n) ≤ + (stdGaussian E).real (partialSlabs u r n ∩ partialSlabs v s n) := by + let b : Fin n ⊕ Fin n → Bool := Sum.elim (fun _ => true) (fun _ => false) + let w : Fin n ⊕ Fin n → E := Sum.elim (fun i => u i.val) (fun i => v i.val) + let t : Fin n ⊕ Fin n → ℝ := Sum.elim (fun i => r i.val) (fun i => s i.val) + have ht : ∀ i, 0 ≤ t i := by intro i; cases i with + | inl i => exact hr i.val + | inr i => exact hs i.val + have he := stdGaussian_finite_slabs_correlation b w t ht + have hleft : {x : E | ∀ i, b i = true → |⟪w i, x⟫| ≤ t i} = partialSlabs u r n := by + ext x + simp [b, w, t, partialSlabs, Sum.forall, Fin.forall_iff] + have hright : {x : E | ∀ i, b i = false → |⟪w i, x⟫| ≤ t i} = partialSlabs v s n := by + ext x + simp [b, w, t, partialSlabs, Sum.forall, Fin.forall_iff] + have hboth : {x : E | ∀ i, |⟪w i, x⟫| ≤ t i} = + partialSlabs u r n ∩ partialSlabs v s n := by + ext x + simp [w, t, partialSlabs, Sum.forall, Fin.forall_iff] + simpa only [hleft, hright, hboth] using he + +omit [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] in +lemma tendsto_real_measure_decreasing {μ : Measure E} [IsFiniteMeasure μ] {S : ℕ → Set E} + (hS : ∀ n, MeasurableSet (S n)) (hm : Antitone S) : + Tendsto (fun n => μ.real (S n)) atTop (𝓝 (μ.real (⋂ n, S n))) := by + exact (ENNReal.tendsto_toReal (measure_ne_top _ _)).comp + (tendsto_measure_iInter_atTop (fun n => (hS n).nullMeasurableSet) hm + ⟨0, measure_ne_top _ _⟩) + +lemma stdGaussian_closed_convex_correlation {K L : Set E} + (hK : IsClosed K) (hL : IsClosed L) (hcK : Convex ℝ K) (hcL : Convex ℝ L) + (hsK : ∀ x ∈ K, -x ∈ K) (hsL : ∀ x ∈ L, -x ∈ L) : + (stdGaussian E).real K * (stdGaussian E).real L ≤ (stdGaussian E).real (K ∩ L) := by + by_cases hKe : K.Nonempty + swap + · rw [Set.not_nonempty_iff_eq_empty.mp hKe] + simp + by_cases hLe : L.Nonempty + swap + · rw [Set.not_nonempty_iff_eq_empty.mp hLe] + simp + have hz (S : Set E) (hSc : Convex ℝ S) (hSs : ∀ x ∈ S, -x ∈ S) (hSe : S.Nonempty) : + (0:E) ∈ S := by + obtain ⟨x, hx⟩ := hSe + simpa using hSc hx (hSs x hx) (a := (1/2:ℝ)) (b := (1/2:ℝ)) + (by norm_num) (by norm_num) (by norm_num) + obtain ⟨u, r, hr, hKr⟩ := closed_symmetric_convex_countable_slabs hK hcK hsK (hz K hcK hsK hKe) + obtain ⟨v, s, hs, hLs⟩ := closed_symmetric_convex_countable_slabs hL hcL hsL (hz L hcL hsL hLe) + have hKt := tendsto_real_measure_decreasing (μ := stdGaussian E) + (measurableSet_partialSlabs u r) (partialSlabs_antitone u r) + have hLt := tendsto_real_measure_decreasing (μ := stdGaussian E) + (measurableSet_partialSlabs v s) (partialSlabs_antitone v s) + have hIt := tendsto_real_measure_decreasing (μ := stdGaussian E) + (fun n => (measurableSet_partialSlabs u r n).inter (measurableSet_partialSlabs v s n)) + (fun _ _ h => Set.inter_subset_inter (partialSlabs_antitone u r h) (partialSlabs_antitone v s h)) + have he := le_of_tendsto_of_tendsto' (hKt.mul hLt) hIt + (stdGaussian_partialSlabs_correlation u v r s hr hs) + simpa only [Set.iInter_inter_distrib, partialSlabs_iInter, ← hKr, ← hLs] using he + +end EuclideanSteinitz.GaussianCorrelation + +namespace EuclideanSteinitz.GaussianCorrelation +open MeasureTheory ProbabilityTheory +open scoped RealInnerProductSpace + +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F] + +lemma linear_image_closed_convex_correlation (A : E →L[ℝ] F) {K L : Set F} + (hK : IsClosed K) (hL : IsClosed L) (hcK : Convex ℝ K) (hcL : Convex ℝ L) + (hsK : ∀ x ∈ K, -x ∈ K) (hsL : ∀ x ∈ L, -x ∈ L) : + ((stdGaussian E).map A).real K * ((stdGaussian E).map A).real L ≤ + ((stdGaussian E).map A).real (K ∩ L) := by + simp only [Measure.real, Measure.map_apply A.continuous.measurable hK.measurableSet, + Measure.map_apply A.continuous.measurable hL.measurableSet, + Measure.map_apply A.continuous.measurable (hK.inter hL).measurableSet, + Set.preimage_inter] + apply stdGaussian_closed_convex_correlation + (hK.preimage A.continuous) (hL.preimage A.continuous) + (hcK.linear_preimage A.toLinearMap) (hcL.linear_preimage A.toLinearMap) + · intro x hx + simpa using hsK (A x) hx + · intro x hx + simpa using hsL (A x) hx + +lemma linear_image_finite_correlation {ι : Type*} (A : E →L[ℝ] F) + (s : Finset ι) (K : ι → Set F) + (hK : ∀ i ∈ s, IsClosed (K i)) (hcK : ∀ i ∈ s, Convex ℝ (K i)) + (hsK : ∀ i ∈ s, ∀ x ∈ K i, -x ∈ K i) : + ∏ i ∈ s, ((stdGaussian E).map A).real (K i) ≤ + ((stdGaussian E).map A).real (⋂ i ∈ s, K i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => + rw [Finset.prod_insert ha] + have ih' := ih (fun i hi => hK i (Finset.mem_insert_of_mem hi)) + (fun i hi => hcK i (Finset.mem_insert_of_mem hi)) + (fun i hi => hsK i (Finset.mem_insert_of_mem hi)) + apply (mul_le_mul_of_nonneg_left ih' (measureReal_nonneg)).trans + have he := linear_image_closed_convex_correlation A + (hK a (Finset.mem_insert_self _ _)) + (isClosed_iInter fun i => isClosed_iInter fun hi => hK i (Finset.mem_insert_of_mem hi)) + (hcK a (Finset.mem_insert_self _ _)) + (convex_iInter fun i => convex_iInter fun hi => hcK i (Finset.mem_insert_of_mem hi)) + (hsK a (Finset.mem_insert_self _ _)) + (fun x hx => by + simp only [Set.mem_iInter] at hx ⊢ + exact fun i hi => hsK i (Finset.mem_insert_of_mem hi) x (hx i hi)) + simpa only [Finset.set_biInter_insert] using he + +end EuclideanSteinitz.GaussianCorrelation + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Energy.lean b/lean/OAI/Analysis/Steinitz/Energy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3605ce35d7d3c1b2fcf63394c07204af2502d97 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Energy.lean @@ -0,0 +1,252 @@ +import OAI.Analysis.Steinitz.Coefficients + +namespace OAI + +/-! Telescoping matrix energy and trace budgets. -/ + +namespace EuclideanSteinitz.Energy +open Matrix MatrixEnergy Gain Spectral +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def pTrace (A : Matrix ι ι ℝ) : ℝ := (cfc potential A).trace +noncomputable def hTrace (A : Matrix ι ι ℝ) : ℝ := pTrace A + gainValue A + +lemma pTrace_mono {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) (hB : B.PosSemidef) + (hAB : A ≤ B) : pTrace A ≤ pTrace B := by + dsimp only [pTrace] + rw [← cfc_primitive_eq hA, ← cfc_primitive_eq hB] + exact trace_primitive_monotone hA.1 hB.1 hAB + +lemma gainValue_mono {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) (hAB : A ≤ B) : + gainValue A ≤ gainValue B := by + have h := gainValue_monotone hA (Matrix.le_iff.mp hAB) + (show (0 : ℝ) ≤ 0 by rfl) (show (0 : ℝ) ≤ 1 by norm_num) (show (0 : ℝ) ≤ 1 by norm_num) + simpa only [zero_smul, one_smul, add_zero, add_sub_cancel] using h + +lemma trace_contraction {f : ℝ → ℝ} + (hf : ∀ {A B : Matrix ι ι ℝ}, A.PosSemidef → B.PosSemidef → A ≤ B → + (cfc f A).trace ≤ (cfc f B).trace) + {A C : Matrix ι ι ℝ} (hA : A.PosSemidef) (hC : C * C.transpose ≤ 1) : + (cfc f (C * A * C.transpose)).trace ≤ (cfc f A).trace := by + let S := CFC.sqrt A + have hS : S.IsHermitian := (CFC.sqrt_nonneg A).posSemidef.1 + have hSS : S * S = A := by simpa only [← sq] using CFC.sq_sqrt A hA.nonneg + have hCA : (C * A * C.transpose).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using hA.mul_mul_conjTranspose_same C + have hSC : (S * (C.transpose * C) * S).PosSemidef := by + have hp : (C.transpose * C).PosSemidef := by + simpa only [star_eq_conjTranspose, conjTranspose_eq_transpose_of_trivial] using + (star_mul_self_nonneg C : (0 : Matrix ι ι ℝ) ≤ star C * C).posSemidef + simpa only [hS.eq] using hp.conjTranspose_mul_mul_same S + have hle : S * (C.transpose * C) * S ≤ A := by + have hp := (Matrix.le_iff.mp (transpose_contraction hC)).conjTranspose_mul_mul_same S + rw [hS.eq] at hp + apply Matrix.le_iff.mpr + simpa only [Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_one, hSS] using hp + have heq : (C * A * C.transpose).charpoly = (S * (C.transpose * C) * S).charpoly := by + rw [← hSS] + convert charpoly_mul_comm (C * S) (S * C.transpose) using 1 <;> simp only [Matrix.mul_assoc] + rw [trace_cfc_eq_of_charpoly hCA.1 hSC.1 heq] + exact hf hSC hA hle + +lemma pTrace_contraction {A C : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hC : C * C.transpose ≤ 1) : pTrace (C * A * C.transpose) ≤ pTrace A := + trace_contraction (fun hA hB hAB => pTrace_mono hA hB hAB) hA hC + +lemma gainValue_contraction {A C : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hC : C * C.transpose ≤ 1) : gainValue (C * A * C.transpose) ≤ gainValue A := + trace_contraction (fun hA _ hAB => gainValue_mono hA hAB) hA hC + +noncomputable def stepCost (p : Move ι) (D : Matrix ι ι ℝ) : ℝ := + hTrace D - hTrace (p.old D) + hTrace (p.next D) - hTrace (p.old D) + +noncomputable def cost (D : Matrix ι ι ℝ) : List (Move ι) → ℝ + | [] => 0 + | p :: ps => stepCost p D + cost (p.next D) ps + +noncomputable def finish (D : Matrix ι ι ℝ) : List (Move ι) → Matrix ι ι ℝ + | [] => D + | p :: ps => finish (p.next D) ps + +lemma Move.old_le_next {p : Move ι} (hp : p.Admissible) (D : Matrix ι ι ℝ) : + p.old D ≤ p.next D := by + exact le_add_of_nonneg_right hp.2.nonneg + +lemma step_bounds {D : Matrix ι ι ℝ} (hD : D.PosSemidef) {p : Move ι} + (hp : p.Admissible) : + 0 ≤ pTrace D - pTrace (p.old D) ∧ + 0 ≤ gainValue D - gainValue (p.old D) ∧ + 0 ≤ pTrace (p.next D) - pTrace (p.old D) ∧ + 0 ≤ gainValue (p.next D) - gainValue (p.old D) := by + exact ⟨sub_nonneg.mpr (pTrace_contraction hD hp.1), + sub_nonneg.mpr (gainValue_contraction hD hp.1), + sub_nonneg.mpr (pTrace_mono (p.old_psd hD) (p.next_psd hp hD) (Move.old_le_next hp D)), + p.gain_nonneg hp hD⟩ + +lemma stepCost_nonneg {D : Matrix ι ι ℝ} (hD : D.PosSemidef) {p : Move ι} + (hp : p.Admissible) : 0 ≤ stepCost p D := by + obtain ⟨h₁,h₂,h₃,h₄⟩ := step_bounds hD hp + dsimp only [stepCost, hTrace] + linarith + +lemma cost_nonneg {D : Matrix ι ι ℝ} (hD : D.PosSemidef) {ps : List (Move ι)} + (hp : ∀ p ∈ ps, p.Admissible) : 0 ≤ cost D ps := by + induction ps generalizing D with + | nil => rfl + | cons p ps ih => + have hp₀ := hp p (List.mem_cons_self ..) + exact add_nonneg (stepCost_nonneg hD hp₀) + (ih (p.next_psd hp₀ hD) (fun q hq => hp q (List.mem_cons_of_mem p hq))) + +lemma gainCost_le_cost {D : Matrix ι ι ℝ} (hD : D.PosSemidef) {ps : List (Move ι)} + (hp : ∀ p ∈ ps, p.Admissible) : gainCost D ps ≤ cost D ps := by + induction ps generalizing D with + | nil => rfl + | cons p ps ih => + have hp₀ := hp p (List.mem_cons_self ..) + have hi := ih (p.next_psd hp₀ hD) (fun q hq => hp q (List.mem_cons_of_mem p hq)) + obtain ⟨h₁,h₂,h₃,h₄⟩ := step_bounds hD hp₀ + dsimp only [gainCost, cost, stepCost, hTrace] + linarith + +lemma trace_change_le_cost {D : Matrix ι ι ℝ} (hD : D.PosSemidef) {ps : List (Move ι)} + (hp : ∀ p ∈ ps, p.Admissible) : pTrace D - pTrace (finish D ps) ≤ cost D ps := by + induction ps generalizing D with + | nil => simp only [finish, cost, sub_self, le_refl] + | cons p ps ih => + have hp₀ := hp p (List.mem_cons_self ..) + have hi := ih (p.next_psd hp₀ hD) (fun q hq => hp q (List.mem_cons_of_mem p hq)) + obtain ⟨h₁,h₂,h₃,h₄⟩ := step_bounds hD hp₀ + dsimp only [finish, cost, stepCost, hTrace] + linarith + +omit [DecidableEq ι] in +lemma finish_eq_follow (Z V : Matrix ι ι ℝ) (ps : List (Move ι)) : + finish (Z + V) ps = (follow Z V ps).1 + (follow Z V ps).2 := by + induction ps generalizing Z V with + | nil => rfl + | cons p ps ih => + simp only [finish, follow] + rw [show p.next (Z + V) = p.old Z + p.next V by simp [Move.next, p.old_add, add_assoc]] + exact ih _ _ + +omit [DecidableEq ι] in +lemma finish_eq_follow_zero (Y : Matrix ι ι ℝ) (ps : List (Move ι)) : + finish Y ps = (follow Y 0 ps).1 + (follow Y 0 ps).2 := by + simpa only [add_zero] using finish_eq_follow Y 0 ps + +lemma endpoint_cost {Y : Matrix ι ι ℝ} (hY : Y.PosSemidef) {ps : List (Move ι)} + (hp : ∀ p ∈ ps, p.Admissible) {E : ℝ} (hcost : cost Y ps ≤ E) + (hsmall : E ≤ 1 / (16 * gainConstant)) : + let Z := (follow Y 0 ps).1 + let X := finish Y ps + (pTrace Y - pTrace Z) + (pTrace X - pTrace Z) ≤ + E + 16 * (gainConstant * E) ^ (1 / exponent) * (cfc sizeWeight X).trace := by + dsimp only + have hbound := accumulated_gain_bound hY hp ((gainCost_le_cost hY hp).trans hcost) hsmall + obtain ⟨hq, hq₁, _, hb⟩ := hbound + have hpsd := follow_psd hY Matrix.PosSemidef.zero hp + have hX : (finish Y ps).PosSemidef := by + rw [finish_eq_follow_zero] + exact hpsd.1.add hpsd.2 + have hXZ : finish Y ps - (follow Y 0 ps).1 ≤ + (gainConstant * E) ^ (1 / exponent) • (1 + finish Y ps) := by + rw [finish_eq_follow_zero, add_sub_cancel_left] + exact hb + have hg := trace_potential_direct hX hpsd.1 hq hq₁.le hXZ + have ht := (trace_change_le_cost hY hp).trans hcost + change pTrace (finish Y ps) - pTrace (follow Y 0 ps).1 ≤ _ at hg + linarith + +lemma gainConstant_one_le : 1 ≤ gainConstant := by + have hs : 1 ≤ Real.sqrt 8 := by + exact (Real.le_sqrt (by norm_num) (by norm_num)).mpr (by norm_num) + rw [gainConstant, two_rpow_exponent] + norm_num [exponent] + nlinarith + +lemma sizeTrace_nonneg {X : Matrix ι ι ℝ} (hX : X.PosSemidef) : + 0 ≤ (cfc sizeWeight X).trace := by + apply Matrix.PosSemidef.trace_nonneg + apply Matrix.nonneg_iff_posSemidef.mp + apply cfc_nonneg + intro x hx + have hx₀ := spectrum_nonneg_of_nonneg hX.nonneg hx + exact le_min (Real.rpow_nonneg hx₀ _) (inv_nonneg.mpr hx₀) + +noncomputable def incrementConstant : ℝ := + 230400 * (1 + 16 * gainConstant ^ (1 / exponent)) + +lemma incrementConstant_pos : 0 < incrementConstant := by + have hc := gainConstant_pos + unfold incrementConstant + positivity + +lemma cost_power_bound {E k : ℝ} (hE : 0 ≤ E) (hk : 0 ≤ k) + (hsmall : E ≤ 1 / (16 * gainConstant)) : + E + 16 * (gainConstant * E) ^ (1 / exponent) * k ≤ + (1 + 16 * gainConstant ^ (1 / exponent)) * (1 + k) * E ^ (1 / exponent) := by + have hc := gainConstant_one_le + have hE1 : E ≤ 1 := by + have hh := (le_div_iff₀ (mul_pos (by norm_num : (0 : ℝ) < 16) gainConstant_pos)).mp hsmall + nlinarith + have he := Real.self_le_rpow_of_le_one hE hE1 (show 1 / exponent ≤ 1 by norm_num [exponent]) + have hr : 0 ≤ E ^ (1 / exponent) := Real.rpow_nonneg hE _ + have hc₀ : 0 ≤ gainConstant ^ (1 / exponent) := Real.rpow_nonneg gainConstant_pos.le _ + rw [Real.mul_rpow gainConstant_pos.le hE] + nlinarith [mul_nonneg (mul_nonneg hc₀ hr) (by norm_num : (0 : ℝ) ≤ 16), mul_nonneg hk hr] + +lemma endpoint_cost_power {Y : Matrix ι ι ℝ} (hY : Y.PosSemidef) {ps : List (Move ι)} + (hp : ∀ p ∈ ps, p.Admissible) {E : ℝ} (hcost : cost Y ps ≤ E) + (hsmall : E ≤ 1 / (16 * gainConstant)) : + let Z := (follow Y 0 ps).1 + let X := finish Y ps + (pTrace Y - pTrace Z) + (pTrace X - pTrace Z) ≤ + (1 + 16 * gainConstant ^ (1 / exponent)) * (1 + (cfc sizeWeight X).trace) * + E ^ (1 / exponent) := by + dsimp only + have hpsd := follow_psd hY Matrix.PosSemidef.zero hp + have hX : (finish Y ps).PosSemidef := by + rw [finish_eq_follow_zero] + exact hpsd.1.add hpsd.2 + exact (endpoint_cost hY hp hcost hsmall).trans + (cost_power_bound ((cost_nonneg hY hp).trans hcost) (sizeTrace_nonneg hX) hsmall) + +end EuclideanSteinitz.Energy + +namespace EuclideanSteinitz.Coefficient +open Matrix MatrixEnergy Gain Energy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +lemma weighted_increment {X Y Z C : Matrix ι ι ℝ} + (hX : X.PosDef) (hY : Y.PosDef) (hZ : Z.PosDef) + (hC : IsUnit C) (hContract : C * C.transpose ≤ 1) + (hZeq : Z = C * Y * C.transpose) + (T S : Matrix ι κ ℝ) (hT : T * T.transpose = 1) (hS : S * S.transpose = 1) + (Qold Qnew : Matrix κ κ ℝ) (hOldPSD : Qold.PosSemidef) (hNewPSD : Qnew.PosSemidef) + (hOldS : S * Qold * S.transpose = Y) (hOldT : T * Qold * T.transpose = Z) + (hTS : T * S.transpose = C) (hCross : T * Qold * S.transpose = C * Y) + (hNewT : T * Qnew * T.transpose = X - Z) + (hZero : lift S (cfc cutoff Y) * Qnew = 0) + (ps : List (Move ι)) (hp : ∀ p ∈ ps, p.Admissible) + (hEndX : X = finish Y ps) (hEndZ : Z = (follow Y 0 ps).1) + {E : ℝ} (hCost : cost Y ps ≤ E) (hSmall : E ≤ 1 / (16 * gainConstant)) : + weightedSq (lift T (cfc cutoff X) - lift S (cfc cutoff Y)) ((1 + Qold) + Qnew) ≤ + incrementConstant * (1 + (cfc sizeWeight X).trace) * E ^ (1 / exponent) := by + have h₁ := endpoint_comparison hX hY hZ hC hContract hZeq T S hT hS Qold Qnew + hOldPSD hNewPSD hOldS hOldT hTS hCross hNewT hZero + have h₂ := endpoint_cost_power hY.posSemidef hp hCost hSmall + dsimp only at h₂ + rw [← hEndX, ← hEndZ] at h₂ + have h₃ := mul_le_mul_of_nonneg_left h₂ (by norm_num : (0 : ℝ) ≤ 230400) + dsimp only [pTrace] at h₃ + unfold incrementConstant + calc + _ ≤ _ := h₁.trans h₃ + _ = _ := by ring + +end EuclideanSteinitz.Coefficient + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Filter.lean b/lean/OAI/Analysis/Steinitz/Filter.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0df1106d708661b37f005b427e3b3bf30334514 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Filter.lean @@ -0,0 +1,380 @@ +import OAI.Analysis.Steinitz.Energy + +namespace OAI + +/-! Symmetric contraction updates and filtered matrix states. -/ + +namespace EuclideanSteinitz.Filter +open Matrix MatrixEnergy Gain Energy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +structure Step (ι κ : Type*) where + C : Matrix ι ι ℝ + b : ι → ℝ + j : κ + +noncomputable def insert (b : ι → ℝ) (j : κ) : Matrix ι κ ℝ := + fun i k => if k = j then b i else 0 + +noncomputable def Step.apply (p : Step ι κ) (R : Matrix ι κ ℝ) : Matrix ι κ ℝ := + p.C * R + insert p.b p.j + +noncomputable def Step.move (p : Step ι κ) (q : κ → ℝ) : Move ι := + ⟨p.C, q p.j • vecMulVec p.b p.b⟩ + +def Step.Good (p : Step ι κ) : Prop := + IsUnit p.C ∧ p.C * p.C.transpose + vecMulVec p.b p.b = 1 + +noncomputable def run (R : Matrix ι κ ℝ) : List (Step ι κ) → Matrix ι κ ℝ + | [] => R + | p :: ps => run (p.apply R) ps + +noncomputable def product : List (Step ι κ) → Matrix ι ι ℝ + | [] => 1 + | p :: ps => product ps * p.C + +noncomputable def state (q : κ → ℝ) (R : Matrix ι κ ℝ) : Matrix ι ι ℝ := + R * diagonal q * R.transpose + +def Fresh (R : Matrix ι κ ℝ) (ps : List (Step ι κ)) : Prop := + ∀ p ∈ ps, ∀ i, R i p.j = 0 + +omit [Fintype ι] [DecidableEq ι] in +lemma insert_mul_transpose (b : ι → ℝ) (j : κ) : + insert b j * (insert b j).transpose = vecMulVec b b := by + ext i k + simp [Matrix.mul_apply, insert, Matrix.transpose_apply, vecMulVec_apply] + +omit [Fintype ι] [DecidableEq ι] in +lemma mul_insert_transpose (R : Matrix ι κ ℝ) (b : ι → ℝ) (j : κ) : + R * (insert b j).transpose = vecMulVec (fun i => R i j) b := by + ext i k + simp [Matrix.mul_apply, insert, Matrix.transpose_apply, vecMulVec_apply] + +omit [Fintype ι] [DecidableEq ι] in +lemma insert_mul_transpose_zero (R : Matrix ι κ ℝ) (b : ι → ℝ) (j : κ) + (hR : ∀ i, R i j = 0) : insert b j * R.transpose = 0 := by + apply Matrix.transpose_injective + simp only [Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.transpose_zero, + mul_insert_transpose] + ext i k + simp only [vecMulVec_apply, hR, zero_mul, Matrix.zero_apply] + +omit [Fintype κ] [DecidableEq ι] in +lemma step_apply_column (p : Step ι κ) (R : Matrix ι κ ℝ) {j : κ} + (hj : j ≠ p.j) (hR : ∀ i, R i j = 0) : ∀ i, p.apply R i j = 0 := by + intro i + simp [Step.apply, Matrix.mul_apply, insert, hj, hR] + +lemma Step.coisometry {p : Step ι κ} (hp : p.Good) {R : Matrix ι κ ℝ} + (hR : R * R.transpose = 1) (hf : ∀ i, R i p.j = 0) : + p.apply R * (p.apply R).transpose = 1 := by + have hz : R * (insert p.b p.j).transpose = 0 := by + rw [mul_insert_transpose] + ext i k + simp [vecMulVec_apply, hf] + have hz' := insert_mul_transpose_zero R p.b p.j hf + have h₁ : p.C * R * (p.C * R).transpose = p.C * p.C.transpose := by + rw [Matrix.transpose_mul, Matrix.mul_assoc p.C R, ← Matrix.mul_assoc R, hR, Matrix.one_mul] + have h₂ : p.C * R * (insert p.b p.j).transpose = 0 := by + rw [Matrix.mul_assoc, hz, Matrix.mul_zero] + have h₃ : insert p.b p.j * (p.C * R).transpose = 0 := by + rw [Matrix.transpose_mul, ← Matrix.mul_assoc, hz', Matrix.zero_mul] + simpa only [Step.apply, Matrix.transpose_add, Matrix.mul_add, Matrix.add_mul, + h₁, h₂, h₃, insert_mul_transpose, add_zero, zero_add] using hp.2 + +omit [Fintype κ] [DecidableEq κ] [DecidableEq ι] in +lemma rankOne_psd (b : ι → ℝ) : (vecMulVec b b).PosSemidef := by + have h := Matrix.PosSemidef.one.mul_mul_conjTranspose_same (insert (κ := Unit) b ()) + simpa only [conjTranspose_eq_transpose_of_trivial, Matrix.mul_one, insert_mul_transpose] using h + +omit [Fintype κ] [DecidableEq κ] in +lemma Step.contract {p : Step ι κ} (hp : p.Good) : p.C * p.C.transpose ≤ 1 := by + rw [← hp.2] + exact le_add_of_nonneg_right (rankOne_psd p.b).nonneg + +omit [Fintype κ] [DecidableEq κ] in +lemma Step.admissible {p : Step ι κ} (hp : p.Good) {q : κ → ℝ} (hq : ∀ j, 0 ≤ q j) : + (p.move q).Admissible := + ⟨Step.contract hp, (rankOne_psd p.b).smul (hq p.j)⟩ + +omit [Fintype κ] [DecidableEq ι] in +lemma Step.fresh_tail {p : Step ι κ} {ps : List (Step ι κ)} {R : Matrix ι κ ℝ} + (hf : Fresh R (p :: ps)) (hd : ∀ r ∈ ps, p.j ≠ r.j) : Fresh (p.apply R) ps := by + intro r hr + exact step_apply_column p R (Ne.symm (hd r hr)) (hf r (List.mem_cons_of_mem p hr)) + +lemma run_coisometry {R : Matrix ι κ ℝ} (hR : R * R.transpose = 1) + {ps : List (Step ι κ)} (hp : ∀ p ∈ ps, p.Good) (hf : Fresh R ps) + (hd : (ps.map Step.j).Nodup) : run R ps * (run R ps).transpose = 1 := by + induction ps generalizing R with + | nil => exact hR + | cons p ps ih => + have hd' := List.nodup_cons.mp hd + have htail : ∀ r ∈ ps, p.j ≠ r.j := by + intro r hr he + apply hd'.1 + exact List.mem_map.mpr ⟨r, hr, he.symm⟩ + exact ih (Step.coisometry (hp p (List.mem_cons_self ..)) hR (hf p (List.mem_cons_self ..))) + (fun r hr => hp r (List.mem_cons_of_mem p hr)) (Step.fresh_tail hf htail) hd'.2 + +omit [Fintype κ] [DecidableEq κ] in +lemma product_contract {ps : List (Step ι κ)} (hp : ∀ p ∈ ps, p.Good) : + product ps * (product ps).transpose ≤ 1 := by + induction ps with + | nil => simp [product] + | cons p ps ih => + have hp₀ := Step.contract (hp p (List.mem_cons_self ..)) + have hps := ih (fun r hr => hp r (List.mem_cons_of_mem p hr)) + have hh := Gain.congruence_mono hp₀ (product ps) + simp only [Matrix.mul_one] at hh + have he : product (p :: ps) * (product (p :: ps)).transpose ≤ + product ps * (product ps).transpose := by + simpa only [product, Matrix.transpose_mul, Matrix.mul_assoc] using hh + exact he.trans hps + +omit [Fintype κ] [DecidableEq κ] in +lemma product_unit {ps : List (Step ι κ)} (hp : ∀ p ∈ ps, p.Good) : IsUnit (product ps) := by + induction ps with + | nil => exact isUnit_one + | cons p ps ih => + exact (ih (fun r hr => hp r (List.mem_cons_of_mem p hr))).mul (hp p (List.mem_cons_self ..)).1 + +lemma state_posDef {R : Matrix ι κ ℝ} (hR : R * R.transpose = 1) + {q : κ → ℝ} (hq : ∀ j, 0 < q j) : (state q R).PosDef := by + have hi : Function.Injective R.vecMul := by + intro x y hxy + have hh := congrArg (fun v => R.transpose.vecMul v) hxy + simpa only [Matrix.vecMul_vecMul, hR, Matrix.vecMul_one] using hh + simpa only [state, conjTranspose_eq_transpose_of_trivial] using + (Matrix.PosDef.diagonal hq).mul_mul_conjTranspose_same hi + +omit [Fintype ι] [DecidableEq ι] in +lemma insert_diagonal (b : ι → ℝ) (j : κ) (q : κ → ℝ) : + insert b j * diagonal q = q j • insert b j := by + ext i k + simp only [Matrix.mul_diagonal, insert, Matrix.smul_apply, smul_eq_mul] + by_cases h : k = j + · simp [h, mul_comm] + · simp [h] + +omit [DecidableEq ι] in +lemma Step.state_next {R : Matrix ι κ ℝ} (p : Step ι κ) (q : κ → ℝ) + (hf : ∀ i, R i p.j = 0) : state q (p.apply R) = (p.move q).next (state q R) := by + have hz : R * diagonal q * (insert p.b p.j).transpose = 0 := by + rw [mul_insert_transpose] + ext i k + simp [vecMulVec_apply, Matrix.mul_diagonal, hf] + have hz' : insert p.b p.j * diagonal q * R.transpose = 0 := by + rw [insert_diagonal, Matrix.smul_mul, insert_mul_transpose_zero R p.b p.j hf, smul_zero] + have h₁ : p.C * R * diagonal q * (p.C * R).transpose = + p.C * state q R * p.C.transpose := by + simp only [state, Matrix.transpose_mul, Matrix.mul_assoc] + have h₂ : p.C * R * diagonal q * (insert p.b p.j).transpose = 0 := by + simpa only [Matrix.mul_assoc, Matrix.mul_zero] using congrArg (fun M => p.C * M) hz + have h₃ : insert p.b p.j * diagonal q * (p.C * R).transpose = 0 := by + rw [Matrix.transpose_mul, ← Matrix.mul_assoc, hz', Matrix.zero_mul] + have h₄ : insert p.b p.j * diagonal q * (insert p.b p.j).transpose = + q p.j • vecMulVec p.b p.b := by + rw [insert_diagonal, Matrix.smul_mul, insert_mul_transpose] + simp only [state, Step.apply, Matrix.transpose_add, Matrix.add_mul, Matrix.mul_add, + h₁, h₂, h₃, h₄, add_zero, zero_add] + rfl + +omit [DecidableEq ι] in +lemma run_state {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} (q : κ → ℝ) + (hf : Fresh R ps) (hd : (ps.map Step.j).Nodup) : + state q (run R ps) = finish (state q R) (ps.map (fun p => p.move q)) := by + induction ps generalizing R with + | nil => rfl + | cons p ps ih => + have hd' := List.nodup_cons.mp hd + have htail : ∀ r ∈ ps, p.j ≠ r.j := by + intro r hr he + exact hd'.1 (List.mem_map.mpr ⟨r, hr, he.symm⟩) + simp only [run, List.map_cons, finish] + rw [ih (Step.fresh_tail hf htail) hd'.2, + Step.state_next p q (hf p (List.mem_cons_self ..))] + +omit [Fintype κ] [DecidableEq κ] in +lemma follow_old (Z V : Matrix ι ι ℝ) (ps : List (Step ι κ)) (q : κ → ℝ) : + (follow Z V (ps.map (fun p => p.move q))).1 = product ps * Z * (product ps).transpose := by + induction ps generalizing Z V with + | nil => simp [follow, product] + | cons p ps ih => + change (follow ((p.move q).old Z) ((p.move q).next V) + (ps.map (fun p => p.move q))).1 = _ + rw [ih] + simp only [product, Step.move, Move.old, Matrix.transpose_mul, Matrix.mul_assoc] + +omit [Fintype ι] [DecidableEq ι] in +lemma insert_mul_zero {μ : Type*} (b : ι → ℝ) (j : κ) (B : Matrix κ μ ℝ) + (hz : ∀ l, B j l = 0) : insert b j * B = 0 := by + ext i l + simp [Matrix.mul_apply, insert, hz] + +lemma run_mul {μ : Type*} (R : Matrix ι κ ℝ) (ps : List (Step ι κ)) (B : Matrix κ μ ℝ) + (hz : ∀ p ∈ ps, ∀ l, B p.j l = 0) : run R ps * B = product ps * R * B := by + induction ps generalizing R with + | nil => simp [run, product] + | cons p ps ih => + simp only [run] + rw [ih _ (fun r hr => hz r (List.mem_cons_of_mem p hr))] + simp only [Step.apply, product, Matrix.mul_add, Matrix.add_mul] + rw [Matrix.mul_assoc (product ps) (insert p.b p.j), + insert_mul_zero _ _ _ (hz p (List.mem_cons_self ..)), Matrix.mul_zero, add_zero] + simp only [Matrix.mul_assoc] + +omit [Fintype ι] [DecidableEq ι] in +noncomputable def newSet (ps : List (Step ι κ)) : Finset κ := (ps.map Step.j).toFinset + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] in +lemma mem_newSet {p : Step ι κ} {ps : List (Step ι κ)} (hp : p ∈ ps) : p.j ∈ newSet ps := by + exact List.mem_toFinset.mpr (List.mem_map.mpr ⟨p, hp, rfl⟩) + +noncomputable def oldMask (J : Finset κ) : Matrix κ κ ℝ := diagonal (fun j => if j ∈ J then 0 else 1) +noncomputable def oldQ (J : Finset κ) (q : κ → ℝ) : Matrix κ κ ℝ := + diagonal (fun j => if j ∈ J then 0 else q j) +noncomputable def newQ (J : Finset κ) (q : κ → ℝ) : Matrix κ κ ℝ := + diagonal (fun j => if j ∈ J then q j else 0) + +lemma oldQ_eq (J : Finset κ) (q : κ → ℝ) : + oldQ J q = oldMask J * diagonal q * (oldMask J).transpose := by + simp only [oldQ, oldMask, Matrix.diagonal_transpose, Matrix.diagonal_mul_diagonal] + congr 1 + funext j + split <;> simp_all + +omit [Fintype κ] in +lemma oldQ_add_newQ (J : Finset κ) (q : κ → ℝ) : oldQ J q + newQ J q = diagonal q := by + rw [oldQ, newQ, Matrix.diagonal_add] + congr 1 + funext j + split <;> simp_all + +omit [Fintype κ] in +lemma oldQ_psd (J : Finset κ) {q : κ → ℝ} (hq : ∀ j, 0 ≤ q j) : (oldQ J q).PosSemidef := by + apply Matrix.PosSemidef.diagonal + intro j + dsimp only + split <;> simp_all + +omit [Fintype κ] in +lemma newQ_psd (J : Finset κ) {q : κ → ℝ} (hq : ∀ j, 0 ≤ q j) : (newQ J q).PosSemidef := by + apply Matrix.PosSemidef.diagonal + intro j + dsimp only + split <;> simp_all + +omit [Fintype ι] [DecidableEq ι] in +lemma oldQ_sandwich (A B : Matrix ι κ ℝ) (J : Finset κ) (q : κ → ℝ) : + A * oldQ J q * B.transpose = + (A * oldMask J) * diagonal q * (B * oldMask J).transpose := by + rw [oldQ_eq, Matrix.transpose_mul] + simp only [Matrix.mul_assoc] + +omit [Fintype ι] [DecidableEq ι] in +lemma fresh_oldMask {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} (hf : Fresh R ps) : + R * oldMask (newSet ps) = R := by + ext i j + simp only [oldMask, Matrix.mul_diagonal] + by_cases hj : j ∈ newSet ps + · obtain ⟨p, hp, rfl⟩ := List.mem_map.mp (List.mem_toFinset.mp hj) + simp only [ite_eq_left hj, mul_zero, hf p hp i] + · simp [hj] + +omit [Fintype ι] [DecidableEq ι] in +lemma fresh_newQ {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} (hf : Fresh R ps) (q : κ → ℝ) : + R * newQ (newSet ps) q = 0 := by + ext i j + simp only [newQ, Matrix.mul_diagonal, Matrix.zero_apply] + by_cases hj : j ∈ newSet ps + · obtain ⟨p, hp, rfl⟩ := List.mem_map.mp (List.mem_toFinset.mp hj) + simp only [ite_eq_left hj, hf p hp i, zero_mul] + · simp [hj] + +lemma run_oldMask {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} (hf : Fresh R ps) : + run R ps * oldMask (newSet ps) = product ps * R := by + rw [run_mul] + · rw [Matrix.mul_assoc, fresh_oldMask hf] + · intro p hp l + simp only [oldMask, Matrix.diagonal_apply] + by_cases h : p.j = l + · subst l + simp [mem_newSet hp] + · simp [h] + +lemma run_cross {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} (hf : Fresh R ps) + (hR : R * R.transpose = 1) : run R ps * R.transpose = product ps := by + rw [run_mul R ps R.transpose (fun p hp l => hf p hp l), Matrix.mul_assoc, hR, Matrix.mul_one] + +omit [Fintype ι] [DecidableEq ι] in +lemma old_state {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} + (hf : Fresh R ps) (q : κ → ℝ) : + R * oldQ (newSet ps) q * R.transpose = state q R := by + rw [oldQ_sandwich, fresh_oldMask hf] + rfl + +lemma run_old_state {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} + (hf : Fresh R ps) (q : κ → ℝ) : + run R ps * oldQ (newSet ps) q * (run R ps).transpose = + product ps * state q R * (product ps).transpose := by + rw [oldQ_sandwich, run_oldMask hf] + simp only [state, Matrix.transpose_mul, Matrix.mul_assoc] + +lemma run_old_cross {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} + (hf : Fresh R ps) (q : κ → ℝ) : + run R ps * oldQ (newSet ps) q * R.transpose = product ps * state q R := by + rw [oldQ_sandwich, run_oldMask hf, fresh_oldMask hf] + simp only [state, Matrix.mul_assoc] + +lemma run_new_state {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} + (hf : Fresh R ps) (q : κ → ℝ) : + run R ps * newQ (newSet ps) q * (run R ps).transpose = + state q (run R ps) - product ps * state q R * (product ps).transpose := by + have he : run R ps * oldQ (newSet ps) q * (run R ps).transpose + + run R ps * newQ (newSet ps) q * (run R ps).transpose = state q (run R ps) := by + rw [← Matrix.add_mul, ← Matrix.mul_add, oldQ_add_newQ] + rfl + rw [run_old_state hf] at he + exact eq_sub_of_add_eq' he + +omit [DecidableEq ι] in +lemma fresh_lift_new_zero {R : Matrix ι κ ℝ} {ps : List (Step ι κ)} + (hf : Fresh R ps) (q : κ → ℝ) (A : Matrix ι ι ℝ) : + Coefficient.lift R A * newQ (newSet ps) q = 0 := by + rw [Coefficient.lift, Matrix.mul_assoc, fresh_newQ hf q, Matrix.mul_zero] + +lemma weighted_increment {R : Matrix ι κ ℝ} (hR : R * R.transpose = 1) + {ps : List (Step ι κ)} (hp : ∀ p ∈ ps, p.Good) (hf : Fresh R ps) + (hd : (ps.map Step.j).Nodup) {q : κ → ℝ} (hq : ∀ j, 0 < q j) + {E : ℝ} (hCost : cost (state q R) (ps.map (fun p => p.move q)) ≤ E) + (hSmall : E ≤ 1 / (16 * gainConstant)) : + Coefficient.weightedSq + (Coefficient.lift (run R ps) (cfc cutoff (state q (run R ps))) - + Coefficient.lift R (cfc cutoff (state q R))) (1 + diagonal q) ≤ + incrementConstant * (1 + (cfc sizeWeight (state q (run R ps))).trace) * + E ^ (1 / exponent) := by + have hT := run_coisometry hR hp hf hd + have hY := state_posDef hR hq + have hX := state_posDef hT hq + have hC := product_unit hp + have hZ : (product ps * state q R * (product ps).transpose).PosDef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using + hY.mul_mul_conjTranspose_same (Matrix.vecMul_injective_of_isUnit hC) + have hMoves : ∀ p ∈ ps.map (fun p => p.move q), p.Admissible := by + intro p hp' + obtain ⟨r, hr, rfl⟩ := List.mem_map.mp hp' + exact Step.admissible (hp r hr) (fun j => (hq j).le) + have he := Coefficient.weighted_increment hX hY hZ hC (product_contract hp) rfl + (run R ps) R hT hR (oldQ (newSet ps) q) (newQ (newSet ps) q) + (oldQ_psd _ (fun j => (hq j).le)) (newQ_psd _ (fun j => (hq j).le)) + (old_state hf q) (run_old_state hf q) (run_cross hf hR) (run_old_cross hf q) + (run_new_state hf q) (fresh_lift_new_zero hf q _) _ hMoves + (run_state q hf hd) (follow_old _ _ _ _).symm hCost hSmall + simpa only [add_assoc, oldQ_add_newQ] using he + +end EuclideanSteinitz.Filter + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/FilterMoments.lean b/lean/OAI/Analysis/Steinitz/FilterMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..41f5729cf46666d285b7dec4e781f74aa62e92c3 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/FilterMoments.lean @@ -0,0 +1,493 @@ +import OAI.Analysis.Steinitz.GaussianTail + +namespace OAI + +/-! Filtered moments, prefix bounds, and rank-one contractions. -/ + +section + +open Matrix GaussianTail +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +open MatrixEnergy Spectral Coefficient +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +lemma cutoff_size {x : ℝ} (hx : 0 ≤ x) (hf : cutoff x≠0) : 1/4 ≤ sizeWeight x := by + have hb : 1/2 ≤ x ∧ x ≤ 4 := by + by_contra h + exact hf (cutoff_zero_of_not_band h) + have hp : 0 by norm_num) + rw [ht] at he + nlinarith [norm_nonneg R] + +lemma cutoff_norm_le (X : Matrix ι ι ℝ) : ‖cfc cutoff X‖ ≤ 1 := by + apply norm_cfc_le (by norm_num) + intro x _ + rw [Real.norm_eq_abs,abs_of_nonneg (cutoff_nonneg x)] + exact cutoff_le_one x + +lemma lift_cutoff_contract {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {X : Matrix ι ι ℝ} (_hX : X.IsHermitian) (x : EuclideanSpace ℝ κ) : + ‖matrixMap (lift R (cfc cutoff X)) x‖^2 ≤ ‖x‖^2 := by + have hr := coisometry_norm_le hR + have ht : ‖R.transpose‖ ≤ 1 := by + simpa only [conjTranspose_eq_transpose_of_trivial] using + (Matrix.l2_opNorm_conjTranspose R).le.trans hr + have hn : ‖lift R (cfc cutoff X)‖ ≤ 1 := by + exact (Matrix.l2_opNorm_mul _ _).trans ((mul_le_mul + ((Matrix.l2_opNorm_mul _ _).trans ((mul_le_mul ht (cutoff_norm_le X) + (norm_nonneg _) (by norm_num)).trans_eq (one_mul _))) hr + (norm_nonneg _) (by norm_num)).trans_eq (one_mul _)) + have hv : ‖matrixMap (lift R (cfc cutoff X)) x‖ ≤ ‖x‖ := by + exact (Matrix.l2_opNorm_mulVec _ x).trans + ((mul_le_mul_of_nonneg_right hn (norm_nonneg x)).trans_eq (one_mul _)) + exact pow_le_pow_left₀ (norm_nonneg _) hv 2 + +lemma lift_cutoff_mass {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {X : Matrix ι ι ℝ} (hX : X.PosSemidef) : + squareMass (lift R (cfc cutoff X)) ≤ 4*(cfc sizeWeight X).trace := by + rw [squareMass_weighted,weighted_lift R hR,Matrix.mul_one,hR, + weightedSq_cfc hX.1,Matrix.mul_one,trace_cfc hX.1,trace_cfc hX.1,Finset.mul_sum] + exact Finset.sum_le_sum fun i _ => cutoff_square_size (hX.eigenvalues_nonneg i) + +omit [Fintype κ] [DecidableEq κ] in +lemma lift_cutoff_size {R : Matrix ι κ ℝ} {X : Matrix ι ι ℝ} (hX : X.PosSemidef) + (hf : lift R (cfc cutoff X)≠0) : 1/4 ≤ (cfc sizeWeight X).trace := by + have he : ∃ i,cutoff (hX.1.eigenvalues i)≠0 := by + by_contra! h + apply hf + rw [real_cfc hX.1] + simp [h,lift] + obtain ⟨i,hi⟩ := he + rw [trace_cfc hX.1] + exact (cutoff_size (hX.eigenvalues_nonneg i) hi).trans + (Finset.single_le_sum (fun j _ => Scale.size_nonneg (hX.eigenvalues_nonneg j)) (Finset.mem_univ i)) + +omit [DecidableEq κ] in +lemma weightedSq_diagonal_mono (B : Matrix κ ι ℝ) {q r : ι → ℝ} + (hqr : ∀ i,q i ≤ r i) : weightedSq B (diagonal q) ≤ weightedSq B (diagonal r) := by + have hp : (diagonal (fun i => r i-q i)).PosSemidef := + PosSemidef.diagonal (fun i => sub_nonneg.mpr (hqr i)) + have hh := weightedSq_nonneg B hp + have he : diagonal r=diagonal q+diagonal (fun i => r i-q i) := by + rw [diagonal_add]; congr 1; funext i; simp + rw [he,weightedSq_weight_add] + linarith + +lemma lift_cutoff_time {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {q : κ → ℝ} (hq : ∀ j,0 q j/θ) R))) (diagonal q) ≤ + 16*(cfc sizeWeight (state (fun j => q j/θ) R)).trace*θ := by + let X := state (fun j => q j/θ) R + have hX : X.PosDef := state_posDef hR (fun j => div_pos (hq j) hθ) + have he : R*diagonal q*R.transpose=θ • X := by + dsimp [X,state] + have hd : θ • diagonal (fun j => q j/θ)=diagonal q := by + rw [← Matrix.diagonal_smul] + congr 1 + funext j + change θ*(q j/θ)=q j + field_simp + rw [← Matrix.smul_mul,← Matrix.mul_smul,hd] + have hec : cfc (fun x => cutoff x^2) X*X=cfc (fun x => cutoff x^2*x) X := by + conv_lhs => arg 2; rw [← cfc_id' ℝ X hX.1.isSelfAdjoint] + exact cfc_mul_same hX.1 _ _ + rw [weighted_lift R hR,he,weightedSq_cfc hX.1,Matrix.mul_smul,Matrix.trace_smul,hec, + trace_cfc hX.1,trace_cfc hX.1] + change θ*(∑ i,cutoff (hX.1.eigenvalues i)^2*hX.1.eigenvalues i) ≤ _ + have hh := Finset.sum_le_sum (fun (i : ι) (_ : i∈Finset.univ) => + cutoff_scaled_size (hX.eigenvalues_pos i).le) + rw [← Finset.mul_sum] at hh + have hh' : (∑ i,cutoff (hX.1.eigenvalues i)^2*hX.1.eigenvalues i) ≤ + 16*∑ i,sizeWeight (hX.1.eigenvalues i) := by simpa only [mul_comm] using hh + nlinarith + +end EuclideanSteinitz.Filter + +end + +section + +namespace EuclideanSteinitz.Energy +open Matrix Gain +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [DecidableEq ι] in +lemma finish_append (A : Matrix ι ι ℝ) (ps qs : List (Move ι)) : + finish A (ps++qs)=finish (finish A ps) qs := by + induction ps generalizing A with + | nil => rfl + | cons p ps ih => exact ih (p.next A) + +lemma cost_append (A : Matrix ι ι ℝ) (ps qs : List (Move ι)) : + cost A (ps++qs)=cost A ps+cost (finish A ps) qs := by + induction ps generalizing A with + | nil => simp [cost,finish] + | cons p ps ih => simp only [List.cons_append,cost,finish,ih,add_assoc] + +lemma cost_prefix {A : Matrix ι ι ℝ} (hA : A.PosSemidef) {ps qs : List (Move ι)} + (hp : ∀ p∈qs,p.Admissible) (h : ps <+: qs) : cost A ps ≤ cost A qs := by + obtain ⟨rs,rfl⟩ := h + rw [cost_append] + exact le_add_of_nonneg_right (cost_nonneg + (EuclideanSteinitz.ScaleEnergy.finish_psd hA (fun p h => hp p (List.mem_append_left _ h))) + (fun p h => hp p (List.mem_append_right _ h))) + +end EuclideanSteinitz.Energy + +namespace EuclideanSteinitz.Filter +open Matrix MatrixEnergy Gain Energy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +omit [Fintype κ] [DecidableEq ι] in +lemma run_append (R : Matrix ι κ ℝ) (ps qs : List (Step ι κ)) : + run R (ps++qs)=run (run R ps) qs := by + induction ps generalizing R with + | nil => rfl + | cons p ps ih => exact ih (p.apply R) + +omit [Fintype κ] [DecidableEq ι] in +lemma run_fresh_append {R : Matrix ι κ ℝ} {ps qs : List (Step ι κ)} + (hf : Fresh R (ps++qs)) (hd : ((ps++qs).map Step.j).Nodup) : Fresh (run R ps) qs := by + induction ps generalizing R with + | nil => exact hf + | cons p ps ih => + have hh := List.nodup_cons.mp hd + apply ih (R := p.apply R) _ hh.2 + apply Step.fresh_tail hf + intro q hq he + exact hh.1 (List.mem_map.mpr ⟨q,hq,he.symm⟩) + +omit [Fintype κ] [DecidableEq κ] in +lemma good_prefix {ps qs : List (Step ι κ)} (hp : ∀ p∈qs,p.Good) (h : ps <+: qs) : + ∀ p∈ps,p.Good := fun p hp' => hp p (h.subset hp') + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma fresh_prefix {R : Matrix ι κ ℝ} {ps qs : List (Step ι κ)} (hf : Fresh R qs) (h : ps <+: qs) : + Fresh R ps := fun p hp => hf p (h.subset hp) + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma nodup_prefix {ps qs : List (Step ι κ)} (hd : (qs.map Step.j).Nodup) (h : ps <+: qs) : + (ps.map Step.j).Nodup := (h.map _).sublist.nodup hd + +omit [Fintype κ] [DecidableEq κ] in +lemma moves_good {ps : List (Step ι κ)} (hp : ∀ p∈ps,p.Good) {q : κ → ℝ} (hq : ∀ j,0≤q j) : + ∀ p∈ps.map (fun p => p.move q),p.Admissible := by + intro p hp' + obtain ⟨r,hr,rfl⟩ := List.mem_map.mp hp' + exact Step.admissible (hp r hr) hq + +lemma cost_prefix_difference {R : Matrix ι κ ℝ} {ps qs : List (Step ι κ)} + (hf : Fresh R (ps++qs)) (hd : ((ps++qs).map Step.j).Nodup) (q : κ → ℝ) : + cost (state q R) ((ps++qs).map (fun p => p.move q)) - + cost (state q R) (ps.map (fun p => p.move q)) = + cost (state q (run R ps)) (qs.map (fun p => p.move q)) := by + rw [List.map_append,cost_append,← run_state q (fresh_prefix hf (List.prefix_append _ _)) + (nodup_prefix hd (List.prefix_append _ _))] + ring + +lemma local_prefix_increment {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {L : List (Step ι κ)} (hp : ∀ p∈L,p.Good) (hf : Fresh R L) (hd : (L.map Step.j).Nodup) + {ps qs : List (Step ι κ)} (hps : ps <+: qs) (hqs : qs <+: L) + {q : κ → ℝ} (hq : ∀ j,0 p.move q)) - + cost (state q R) (ps.map (fun p => p.move q)) ≤ 1/(16*gainConstant)) : + Coefficient.weightedSq + (Coefficient.lift (run R qs) (cfc cutoff (state q (run R qs))) - + Coefficient.lift (run R ps) (cfc cutoff (state q (run R ps)))) (1+diagonal q) ≤ + incrementConstant*(1+(cfc sizeWeight (state q (run R qs))).trace)* + (cost (state q R) (qs.map (fun p => p.move q)) - + cost (state q R) (ps.map (fun p => p.move q)))^(1/exponent) := by + obtain ⟨rs,rfl⟩ := hps + have hp' := good_prefix hp hqs + have hf' := fresh_prefix hf hqs + have hd' := nodup_prefix hd hqs + have hc := cost_prefix_difference hf' hd' q + rw [hc] at hsmall ⊢ + rw [run_append] + exact weighted_increment + (run_coisometry hR (good_prefix hp' (List.prefix_append _ _)) + (fresh_prefix hf' (List.prefix_append _ _)) (nodup_prefix hd' (List.prefix_append _ _))) + (fun p h => hp' p (List.mem_append_right _ h)) (run_fresh_append hf' hd') + (by rw [List.map_append] at hd'; exact (List.nodup_append.mp hd').2.1) + hq le_rfl hsmall + +end EuclideanSteinitz.Filter + +end + +section + +open Matrix GaussianTail +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +open MatrixEnergy Spectral Coefficient ScaleEnergy Energy +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +lemma coisometry_column {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) (j : κ) : + (∑ i,R i j^2) ≤ 1 := by + have h := Matrix.l2_opNorm_mulVec R (EuclideanSpace.single j (1:ℝ)) + have hn : ‖(EuclideanSpace.single j (1:ℝ))‖=1 := by simp + rw [hn,mul_one] at h + have hh : ‖matrixMap R (EuclideanSpace.single j 1)‖≤1 := h.trans (coisometry_norm_le hR) + have hs := pow_le_pow_left₀ (norm_nonneg _) hh 2 + rw [EuclideanSpace.real_norm_sq_eq] at hs + simpa [matrixMap,Matrix.toEuclideanLin,Matrix.mulVec,PiLp.single_apply] using hs + +lemma state_trace_le {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {q : κ → ℝ} (hq : ∀ j,0≤q j) : (state q R).trace ≤ ∑ j,q j := by + calc + _ = ∑ j,q j*(∑ i,R i j^2) := by + change (∑ i,∑ j,(R*diagonal q) i j*R.transpose j i)=_ + simp only [Matrix.mul_diagonal,Matrix.transpose_apply] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ ≤ ∑ j,q j := Finset.sum_le_sum fun j _ => by + simpa only [mul_one] using mul_le_mul_of_nonneg_left (coisometry_column hR j) (hq j) + +omit [Fintype κ] [DecidableEq κ] in +lemma Step.b_square_le {p : Step ι κ} (hp : p.Good) : ∑ i,p.b i^2 ≤ 1 := by + have hc : (p.C*p.C.transpose).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using posSemidef_self_mul_conjTranspose p.C + have he : p.C*p.C.transpose = 1-vecMulVec p.b p.b := by rw [← hp.2]; abel + rw [he] at hc + have hh := hc.dotProduct_mulVec_nonneg p.b + simp only [star_trivial,Matrix.sub_mulVec,Matrix.one_mulVec,dotProduct_sub, + Matrix.vecMulVec_mulVec,dotProduct_smul,op_smul_eq_mul] at hh + have hbb : p.b ⬝ᵥ p.b=∑ i,p.b i^2 := by simp only [dotProduct,pow_two] + rw [hbb] at hh + nlinarith [Finset.sum_nonneg (fun i (_ : i∈Finset.univ) => sq_nonneg (p.b i))] + +lemma gains_le_total {L : List (Step ι κ)} (hp : ∀ p∈L,p.Good) (hd : (L.map Step.j).Nodup) + {q : κ → ℝ} (hq : ∀ j,0≤q j) : gainSum (L.map (fun p => p.move q)) ≤ ∑ j,q j := by + have hterm (p : Step ι κ) (h : p∈L) : (p.move q).gain.trace ≤ q p.j := by + change (q p.j • vecMulVec p.b p.b).trace ≤ _ + rw [Matrix.trace_smul] + have ht : (vecMulVec p.b p.b).trace=∑ i,p.b i^2 := by simp [Matrix.trace,vecMulVec_apply,pow_two] + rw [ht,smul_eq_mul] + simpa only [mul_one] using mul_le_mul_of_nonneg_left (Step.b_square_le (hp p h)) (hq p.j) + calc + gainSum (L.map (fun p => p.move q)) = (L.map (fun p => (p.move q).gain.trace)).sum := by simp only [gainSum,List.map_map,Function.comp_def] + _ ≤ (L.map (fun p => q p.j)).sum := List.sum_le_sum hterm + _ = ∑ j∈(L.map Step.j).toFinset,q j := by + rw [List.sum_toFinset _ hd] + simp only [List.map_map,Function.comp_def] + _ ≤ ∑ j,q j := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun j _ _ => hq j) + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma move_scale (p : Step ι κ) (q : κ → ℝ) (θ : ℝ) : + p.move (fun j => q j/θ) = rescale θ⁻¹ (p.move q) := by + cases p + simp only [Step.move,rescale] + congr 1 + rw [smul_smul] + congr 1 + simp [div_eq_mul_inv,mul_comm] + +lemma sum_epoch_cost {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {L : List (Step ι κ)} (hp : ∀ p∈L,p.Good) (hd : (L.map Step.j).Nodup) + {q : κ → ℝ} (hq : ∀ j,0≤q j) (S : Finset ℤ) : + (∑ k∈S,(2:ℝ)^k*cost (((2:ℝ)^k)⁻¹ • state q R) + (L.map (fun p => p.move (fun j => q j/(2:ℝ)^k)))) ≤ 84*(∑ j,q j) := by + simp only [move_scale,show ∀ c, L.map (fun p => rescale c (p.move q)) = + (L.map (fun p => p.move q)).map (rescale c) from fun c => by simp only [List.map_map,Function.comp_def]] + have hstate : (state q R).PosSemidef := by + change (R*diagonal q*R.transpose).PosSemidef + simpa only [conjTranspose_eq_transpose_of_trivial] using (PosSemidef.diagonal hq).mul_mul_conjTranspose_same R + exact (scale_energy_bound hstate (moves_good hp hq) S).trans (by + have h₁ := state_trace_le hR hq + have h₂ := gains_le_total hp hd hq + linarith) + +lemma sum_dyadic_le {S : Finset ℤ} {b : ℝ} (hb : 0≤b) (hS : ∀ k∈S,(2:ℝ)^k≤b) : + (∑ k∈S,(2:ℝ)^k) ≤ 2*b := by + classical + by_cases hne : S.Nonempty + · let M := S.max' hne + have hM k (hk : k∈S) : k≤M := Finset.le_max' S k hk + let f := fun k : ℤ => (M-k).toNat + have hinj : Set.InjOn f S := by + intro k hk l hl h + have hk' := Int.toNat_of_nonneg (sub_nonneg.mpr (hM k hk)) + have hl' := Int.toNat_of_nonneg (sub_nonneg.mpr (hM l hl)) + have := congrArg (fun n : ℕ => (n:ℤ)) h + dsimp [f] at this + omega + have he k (hk : k∈S) : (2:ℝ)^k = (2:ℝ)^M*(1/2:ℝ)^(f k) := by + have hk' := Int.toNat_of_nonneg (sub_nonneg.mpr (hM k hk)) + rw [one_div,inv_pow,← zpow_natCast] + dsimp [f] + rw [hk',← _root_.zpow_neg,← zpow_add₀ (by norm_num)] + congr 1 + ring + have hsum : (∑ k∈S,(1/2:ℝ)^(f k)) ≤ 2 := by + rw [← Finset.sum_image hinj] + have hs := hasSum_geometric_of_lt_one (by norm_num : (0:ℝ)≤1/2) (by norm_num : (1/2:ℝ)<1) + have hh := hs.summable.sum_le_tsum (S.image f) (fun n _ => by positivity) + rw [hs.tsum_eq] at hh + norm_num at hh + exact hh + calc + _ = (2:ℝ)^M*∑ k∈S,(1/2:ℝ)^(f k) := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl he + _ ≤ (2:ℝ)^M*2 := mul_le_mul_of_nonneg_left hsum (zpow_pos (by norm_num) _).le + _ ≤ 2*b := by nlinarith [hS M (Finset.max'_mem S hne)] + · simp only [Finset.not_nonempty_iff_eq_empty.mp hne,Finset.sum_empty] + positivity + +end EuclideanSteinitz.Filter + +end + +section + +open Matrix GaussianTail +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def vectorMass (b : ι → ℝ) : ℝ := ∑ i,b i^2 +noncomputable def eta (b : ι → ℝ) : ℝ := 1/(1+Real.sqrt (1-vectorMass b)) +noncomputable def symmetricContraction (b : ι → ℝ) : Matrix ι ι ℝ := 1-eta b • vecMulVec b b +noncomputable def symmetricStep (b : ι → ℝ) (j : κ) : Step ι κ := ⟨symmetricContraction b,b,j⟩ + +omit [DecidableEq ι] in +lemma vectorMass_nonneg (b : ι → ℝ) : 0≤vectorMass b := Finset.sum_nonneg fun i _ => sq_nonneg (b i) +omit [DecidableEq ι] in +lemma eta_pos (b : ι → ℝ) : 0 x ⬝ᵥ(A*ᵥx)) hgram + rw [← Matrix.mulVec_mulVec,Matrix.dotProduct_mulVec,Matrix.vecMul_transpose, + Matrix.sub_mulVec,Matrix.one_mulVec,dotProduct_sub,Matrix.vecMulVec_mulVec,dotProduct_smul,op_smul_eq_mul] at hh + rw [dotProduct_comm x b] at hh + simp only [dotProduct,← pow_two] at hh + unfold vectorMass + simp only [dotProduct] + nlinarith [hh] + +lemma contraction_apply (b x : ι → ℝ) : + symmetricContraction b*ᵥx = x-(eta b*(b ⬝ᵥ x)) • b := by + unfold symmetricContraction + rw [Matrix.sub_mulVec,Matrix.one_mulVec,Matrix.smul_mulVec,Matrix.vecMulVec_mulVec] + ext i + simp only [Pi.sub_apply,Pi.smul_apply,smul_eq_mul,op_smul_eq_mul] + ring + +end EuclideanSteinitz.Filter + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/FilteredBody.lean b/lean/OAI/Analysis/Steinitz/FilteredBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecbf034c61ad83c3b72e8be1a3fa6cacfde84f95 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/FilteredBody.lean @@ -0,0 +1,194 @@ +import OAI.Analysis.Steinitz.Adaptive + +namespace OAI + +/-! Filtered-body energy and the predictor slab budget. -/ + +section + +open Matrix GaussianTail MeasureTheory ProbabilityTheory Set +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace Pointwise NNReal +namespace GaussianEvents +variable {E F I : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [Fintype I] +noncomputable def openConstraints (A : I → E →L[ℝ] F) (R : I → ℝ) : Set E := + {x | ∀ i,‖A i x‖ < R i} +lemma openConstraints_open (A : I → E →L[ℝ] F) (R : I → ℝ) : IsOpen (openConstraints A R) := by + simp only [openConstraints,Set.ofPred_forall] + exact isOpen_iInter_of_finite fun i => isOpen_lt (A i).continuous.norm continuous_const +omit [Fintype I] in +lemma openConstraints_convex (A : I → E →L[ℝ] F) (R : I → ℝ) : Convex ℝ (openConstraints A R) := by + have he : openConstraints A R = ⋂ i,(A i) ⁻¹' Metric.ball 0 (R i) := by + ext x; simp [openConstraints,Metric.mem_ball,dist_zero_right] + rw [he] + exact convex_iInter fun i => (convex_ball (0:F) (R i)).linear_preimage (A i).toLinearMap +omit [Fintype I] in +lemma openConstraints_symmetric (A : I → E →L[ℝ] F) (R : I → ℝ) : + ∀ x∈openConstraints A R,-x∈openConstraints A R := by + intro x hx i + simpa only [map_neg,norm_neg] using hx i +omit [Fintype I] in +lemma openConstraints_zero (A : I → E →L[ℝ] F) {R : I → ℝ} (hR : ∀ i,0 matrixMap (Rt t)) (fun _ => 2*stateRadius*Real.sqrt (Fintype.card ι)) ∩ + Metric.ball 0 (2*stateRadius*Real.sqrt (Fintype.card κ)) ∩ + openConstraints (fun j => matrixMap (H j)) (fun _ => 2*slabRadius) + +omit [DecidableEq ι] [Nonempty ι] [Nonempty κ] in +lemma applicationDomain_open (Rt : T → Matrix ι κ ℝ) (H : J → Matrix Unit κ ℝ) : + IsOpen (applicationDomain Rt H) := + ((openConstraints_open _ _).inter Metric.isOpen_ball).inter (openConstraints_open _ _) +omit [DecidableEq ι] [Nonempty ι] [Nonempty κ] [Fintype T] [Fintype J] in +lemma applicationDomain_convex (Rt : T → Matrix ι κ ℝ) (H : J → Matrix Unit κ ℝ) : + Convex ℝ (applicationDomain Rt H) := + ((openConstraints_convex _ _).inter (convex_ball _ _)).inter (openConstraints_convex _ _) +omit [DecidableEq ι] [Fintype T] [Fintype J] [Nonempty ι] [Nonempty κ] in +lemma applicationDomain_bounded (Rt : T → Matrix ι κ ℝ) (H : J → Matrix Unit κ ℝ) : + Bornology.IsBounded (applicationDomain Rt H) := + (Metric.isBounded_ball (x := (0:EuclideanSpace ℝ κ)) (r := _)).subset (fun _ hx => hx.1.2) +omit [DecidableEq ι] [Nonempty ι] [Nonempty κ] [Fintype T] [Fintype J] in +lemma applicationDomain_symmetric (Rt : T → Matrix ι κ ℝ) (H : J → Matrix Unit κ ℝ) : + ∀ x∈applicationDomain Rt H,-x∈applicationDomain Rt H := by + intro x hx + refine ⟨⟨openConstraints_symmetric _ _ x hx.1.1,?_⟩,openConstraints_symmetric _ _ x hx.2⟩ + simpa only [Metric.mem_ball,dist_zero_right,norm_neg] using hx.1.2 +omit [DecidableEq ι] [Fintype T] [Fintype J] in +lemma applicationDomain_zero (Rt : T → Matrix ι κ ℝ) (H : J → Matrix Unit κ ℝ) : + (0:EuclideanSpace ℝ κ)∈applicationDomain Rt H := by + have hι : (0:ℝ) mul_pos (mul_pos (by norm_num) stateRadius_pos) (Real.sqrt_pos.mpr hι)),?_⟩,openConstraints_zero _ (fun _ => mul_pos (by norm_num) slabRadius_pos)⟩ + simp only [Metric.mem_ball,dist_self] + exact mul_pos (mul_pos (by norm_num) stateRadius_pos) (Real.sqrt_pos.mpr hκ) + +omit [Nonempty κ] in +lemma slabs_rate (H : J → Matrix Unit κ ℝ) (hH : ∀ i,∑ j, (H j () i)^2 ≤ 1) + {q : κ → ℝ} (hq : ∀ i,0≤q i) : + (∑ j,weightedSq (H j) (diagonal q)) ≤ ∑ i,q i := by + simp only [weighted_diagonal_eq,Fintype.sum_unique] + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro i _ + rw [← Finset.mul_sum] + simpa only [mul_one] using mul_le_mul_of_nonneg_left (hH i) (hq i) + +lemma applicationDomain_survival {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {L : List (Step ι κ)} (hp : ∀ p∈L,p.Good) (hf : Fresh R L) (hd : (L.map Step.j).Nodup) + (ps : T → List (Step ι κ)) (hps : ∀ t,ps t <+: L) + (H : J → Matrix Unit κ ℝ) (hH : ∀ j,squareMass (H j)≤1) (hcol : ∀ i,∑ j,(H j () i)^2≤1) + {q : κ → ℝ} (hq : ∀ i,0 (1+q i)⁻¹) n u) x ∈ + applicationDomain (fun t => run R (ps t)) H} := by + let r : κ → ℝ := fun i => (1+q i)⁻¹ + have hr i : 0≤r i := inv_nonneg.mpr (by linarith [hq i]) + have hr1 i : r i≤1 := (inv_le_one₀ (by linarith [hq i])).mpr (by linarith [hq i]) + have hrq i : 1-r i≤q i := by + dsimp [r] + have hh : 1-q i≤1/(1+q i) := (le_div_iff₀ (by linarith [hq i])).mpr (by nlinarith [sq_nonneg (q i)]) + rw [one_div] at hh + linarith + obtain ⟨a,ha⟩ := state_survival hR hp hf hd ps hps hq r hr hr1 hrq + obtain ⟨b,hb⟩ := state_survival (ι := κ) (R := 1) (by simp) (L := []) (by simp) + (by simp [Fresh]) (by simp) (fun _ : Unit => []) (by simp) hq r hr hr1 hrq + let w := ∑ j,weightedSq (H j) (diagonal q) + have hw : w≤∑ i,q i := slabs_rate H hcol (fun i => (hq i).le) + refine ⟨a+b+Fintype.card J,fun n => ?_⟩ + let A := constraints (fun p : T×Fin (n+1) => matrixMap (run R (ps p.1)*evaluation r n p.2)) + (fun _ => stateRadius*Real.sqrt (Fintype.card ι)) + let B := constraints (fun u : Fin (n+1) => matrixMap (evaluation r n u)) + (fun _ => stateRadius*Real.sqrt (Fintype.card κ)) + let C := constraints (fun p : J×Fin (n+1) => matrixMap (H p.1*evaluation r n p.2)) (fun _ => slabRadius) + have hpa : Real.exp (-a-stateRate*(∑ i,q i)*n)≤(stdGaussian _).real A := by + simpa only [A,constraints,Prod.forall] using ha n + have hpb : Real.exp (-b-stateRate*(∑ i,q i)*n)≤(stdGaussian _).real B := by + simpa only [B,constraints,run,Matrix.one_mul,forall_const] using hb n + have hpc : Real.exp (-(Fintype.card J:ℝ)-w*n)≤(stdGaussian _).real C := by + simpa only [C,constraints,Prod.forall,w] using slabs_survival H hH r hr hr1 q (fun i => (hq i).le) hrq n + have hab := GaussianCorrelation.stdGaussian_closed_convex_correlation + (constraints_closed _ _) (constraints_closed _ _) (constraints_convex _ _) (constraints_convex _ _) + (constraints_symmetric _ _) (constraints_symmetric _ _) (K := A) (L := B) + have habc := GaussianCorrelation.stdGaussian_closed_convex_correlation + ((constraints_closed _ _).inter (constraints_closed _ _)) (constraints_closed _ _) + ((constraints_convex _ _).inter (constraints_convex _ _)) (constraints_convex _ _) + (fun x hx => ⟨constraints_symmetric _ _ x hx.1,constraints_symmetric _ _ x hx.2⟩) + (constraints_symmetric _ _) (K := A∩B) (L := C) + have hlow : Real.exp (-(a+b+Fintype.card J)-bodyRate*(∑ i,q i)*n) ≤ + Real.exp (-a-stateRate*(∑ i,q i)*n)*Real.exp (-b-stateRate*(∑ i,q i)*n)*Real.exp (-(Fintype.card J:ℝ)-w*n) := by + rw [← Real.exp_add,← Real.exp_add] + apply Real.exp_le_exp.mpr + unfold bodyRate + nlinarith [mul_le_mul_of_nonneg_right hw (Nat.cast_nonneg n : (0:ℝ)≤n)] + apply hlow.trans + apply le_trans (mul_le_mul (mul_le_mul hpa hpb (Real.exp_pos _).le (measureReal_nonneg)) hpc (Real.exp_pos _).le (mul_nonneg measureReal_nonneg measureReal_nonneg)) + apply le_trans (mul_le_mul_of_nonneg_right hab measureReal_nonneg) + apply habc.trans + apply measureReal_mono _ (measure_ne_top _ _) + intro x hx u + have hι : 0 run R (ps t)) H) := by + let D := applicationDomain (fun t => run R (ps t)) H + let s : ℝ≥0 := ⟨bodyScale,bodyScale_pos.le⟩ + have ho := applicationDomain_open (fun t => run R (ps t)) H + have hb := applicationDomain_bounded (fun t => run R (ps t)) H + have hso := ho.smul₀ bodyScale_pos.ne' + have hsb := hb.smul₀ bodyScale + let : IsFiniteMeasure (volume.restrict D) := isFiniteMeasure_restrict.mpr hb.measure_lt_top.ne + let : IsFiniteMeasure (volume.restrict ((s:ℝ) • D)) := isFiniteMeasure_restrict.mpr hsb.measure_lt_top.ne + refine ⟨?_,hso,hsb,(applicationDomain_convex _ _).smul bodyScale,?_,?_⟩ + · exact ⟨0,Set.mem_smul_set.mpr ⟨0,applicationDomain_zero _ _,smul_zero _⟩⟩ + · intro x hx + obtain ⟨y,hy,rfl⟩ := Set.mem_smul_set.mp hx + exact Set.mem_smul_set.mpr ⟨-y,applicationDomain_symmetric _ _ y hy,smul_neg _ _⟩ + · have hh := dilated_bound_of_survival (s := s) bodyScale_pos D + ho.measurableSet hso.measurableSet bodyRate + (fun q hq => applicationDomain_survival hR hp hf hd ps hps H hH hcol hq) + exact hh.mono_const bodyScale_bound + +end EuclideanSteinitz.Filter + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Gain.lean b/lean/OAI/Analysis/Steinitz/Gain.lean new file mode 100644 index 0000000000000000000000000000000000000000..37c1d5862f3eacfdb60506df38b4088077a02059 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Gain.lean @@ -0,0 +1,830 @@ +import OAI.Analysis.Steinitz.Spectral + +namespace OAI + +/-! Contraction and gain potentials for positive semidefinite matrices. -/ + +namespace EuclideanSteinitz.Gain +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma transpose_bound {C : Matrix ι ι ℝ} {r : ℝ} + (hC : C * C.transpose ≤ r • (1 : Matrix ι ι ℝ)) : + C.transpose * C ≤ r • (1 : Matrix ι ι ℝ) := by + have h₁ : (C * C.transpose).IsHermitian := by + simpa only [conjTranspose_eq_transpose_of_trivial] using isHermitian_mul_conjTranspose_self C + have h₂ : (C.transpose * C).IsHermitian := by + simpa only [conjTranspose_eq_transpose_of_trivial] using isHermitian_conjTranspose_mul_self C + have heq := (h₂.eigenvalues_eq_eigenvalues_iff h₁).mpr (charpoly_mul_comm C.transpose C) + rw [← Algebra.algebraMap_eq_smul_one, le_algebraMap_iff_spectrum_le h₂.isSelfAdjoint] + rw [← Algebra.algebraMap_eq_smul_one, le_algebraMap_iff_spectrum_le h₁.isSelfAdjoint] at hC + intro x hx + rw [h₂.spectrum_real_eq_range_eigenvalues, heq, ← h₁.spectrum_real_eq_range_eigenvalues] at hx + exact hC x hx + +lemma cube_le_eight {K : Matrix ι ι ℝ} (hK : K.PosSemidef) + (hK₂ : K ≤ (2 : ℝ) • (1 : Matrix ι ι ℝ)) : + K ^ 3 ≤ (8 : ℝ) • (1 : Matrix ι ι ℝ) := by + rw [← cfc_pow_id (R := ℝ) K 3 hK.1.isSelfAdjoint, ← Algebra.algebraMap_eq_smul_one, + ← cfc_const (R := ℝ) (8 : ℝ) K hK.1.isSelfAdjoint, + cfc_le_iff _ _ _ (by fun_prop) (by fun_prop) hK.1.isSelfAdjoint] + rw [← Algebra.algebraMap_eq_smul_one, le_algebraMap_iff_spectrum_le hK.1.isSelfAdjoint] at hK₂ + intro x hx + have hx₀ := spectrum_nonneg_of_nonneg hK.nonneg hx + have hx₂ := hK₂ x hx + nlinarith [mul_nonneg hx₀ (sq_nonneg (x - 2)), sq_nonneg (x - 2)] + +lemma relative_sqrt_bound {T H A : Matrix ι ι ℝ} + (hT : IsUnit T) (hH : H.PosSemidef) (hA : A.PosSemidef) + (hAeq : A = T * H * T.transpose) + (hTT : T * T.transpose = 1 + A) (hA₁ : A ≤ 1) : + T.transpose * CFC.sqrt A * T ≤ Real.sqrt 8 • CFC.sqrt H := by + let K := T.transpose * T + let B := T.transpose * CFC.sqrt A * T + let R := CFC.sqrt A + have hTt : IsUnit T.transpose := (Matrix.isUnit_transpose T).mpr hT + let _ := hTt.invertible + have hK : K.PosSemidef := by + simpa only [K, star_eq_conjTranspose, conjTranspose_eq_transpose_of_trivial] using + (star_mul_self_nonneg T : (0 : Matrix ι ι ℝ) ≤ star T * T).posSemidef + have hKH : K * H = K - 1 := by + have h := congrArg (fun M : Matrix ι ι ℝ => T.transpose * M * T.transpose⁻¹) hTT + rw [hAeq] at h + simp only [Matrix.mul_add, Matrix.mul_one, Matrix.add_mul, Matrix.mul_assoc, + Matrix.mul_inv_of_invertible, Matrix.mul_one] at h + change K = 1 + T.transpose * (T * H) at h + rw [← Matrix.mul_assoc] at h + exact eq_sub_iff_add_eq.mpr (by simpa only [add_comm] using h.symm) + have hHK : H * K = K - 1 := by + have h := congrArg Matrix.conjTranspose hKH + simpa only [conjTranspose_mul, conjTranspose_sub, conjTranspose_one, + hH.1.eq, hK.1.eq] using h + have hcomm : Commute H K := by exact hHK.trans hKH.symm + have hK₂ : K ≤ (2 : ℝ) • (1 : Matrix ι ι ℝ) := by + apply transpose_bound + rw [hTT, two_smul] + exact add_le_add le_rfl hA₁ + have hB : B.PosSemidef := by + simpa only [B, conjTranspose_eq_transpose_of_trivial] using + (CFC.sqrt_nonneg A).posSemidef.conjTranspose_mul_mul_same T + have hRR : R * R = A := CFC.sqrt_mul_sqrt_self A hA.nonneg + have hBB : B * B = H * K ^ 3 := by + calc + B * B = T.transpose * (R * (T * T.transpose) * R) * T := by + dsimp [B, R]; simp only [Matrix.mul_assoc] + _ = T.transpose * (A * (1 + A)) * T := by + rw [hTT, Matrix.mul_add, Matrix.add_mul, Matrix.mul_one, hRR] + have hr : R * A * R = A * A := by + rw [← hRR]; simp only [Matrix.mul_assoc] + rw [hr] + noncomm_ring + _ = K * H * K * K := by + rw [← hTT, hAeq] + dsimp [K] + simp only [Matrix.mul_assoc] + _ = H * K ^ 3 := by rw [hcomm.eq.symm]; noncomm_ring + have hsq : B * B ≤ (8 : ℝ) • H := by + have hp := hcomm.pow_right 3 + have hc : Commute H ((8 : ℝ) • (1 : Matrix ι ι ℝ) - K ^ 3) := + (Commute.one_right H).smul_right 8 |>.sub_right hp + have hh := hc.mul_nonneg hH.nonneg (sub_nonneg.mpr (cube_le_eight hK hK₂)) + rw [Matrix.mul_sub, Matrix.mul_smul, Matrix.mul_one, ← hBB] at hh + exact sub_nonneg.mp hh + have hroot : (Real.sqrt 8 • CFC.sqrt H : Matrix ι ι ℝ).PosSemidef := + (smul_nonneg (Real.sqrt_nonneg 8) (CFC.sqrt_nonneg H)).posSemidef + apply MatrixEnergy.le_of_square_le hB hroot + simpa only [smul_mul_assoc, mul_smul_comm, smul_smul, Real.mul_self_sqrt (by norm_num : (0 : ℝ) ≤ 8), + CFC.sqrt_mul_sqrt_self H hH.nonneg] using hsq + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz.Gain +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def inverseSqrt (M : Matrix ι ι ℝ) : Matrix ι ι ℝ := (CFC.sqrt M)⁻¹ + +lemma inverseSqrt_psd (M : Matrix ι ι ℝ) : (inverseSqrt M).PosSemidef := + (CFC.sqrt_nonneg M).posSemidef.inv + +lemma inverseSqrt_transpose (M : Matrix ι ι ℝ) : (inverseSqrt M).transpose = inverseSqrt M := by + simpa only [conjTranspose_eq_transpose_of_trivial] using (inverseSqrt_psd M).1.eq + +lemma sqrt_transpose (M : Matrix ι ι ℝ) : (CFC.sqrt M).transpose = CFC.sqrt M := by + simpa only [conjTranspose_eq_transpose_of_trivial] using (CFC.sqrt_nonneg M).posSemidef.1.eq + +lemma inverseSqrt_mul_sqrt {M : Matrix ι ι ℝ} (hM : M.PosDef) : + inverseSqrt M * CFC.sqrt M = 1 := by + have h := (CFC.isUnit_sqrt_iff M hM.posSemidef.nonneg).mpr hM.isUnit + let _ := h.invertible + exact Matrix.inv_mul_of_invertible _ + +lemma sqrt_mul_inverseSqrt {M : Matrix ι ι ℝ} (hM : M.PosDef) : + CFC.sqrt M * inverseSqrt M = 1 := by + have h := (CFC.isUnit_sqrt_iff M hM.posSemidef.nonneg).mpr hM.isUnit + let _ := h.invertible + exact Matrix.mul_inv_of_invertible _ + +lemma inverseSqrt_sandwich {M : Matrix ι ι ℝ} (hM : M.PosDef) : + inverseSqrt M * M * inverseSqrt M = 1 := by + calc + _ = inverseSqrt M * (CFC.sqrt M * CFC.sqrt M) * inverseSqrt M := by + rw [CFC.sqrt_mul_sqrt_self M hM.posSemidef.nonneg] + _ = 1 := by rw [← Matrix.mul_assoc, inverseSqrt_mul_sqrt hM, Matrix.one_mul, + sqrt_mul_inverseSqrt hM] + +lemma inverseSqrt_unit {M : Matrix ι ι ℝ} (hM : M.PosDef) : IsUnit (inverseSqrt M) := by + rw [inverseSqrt, nonsing_inv_eq_ringInverse, isUnit_ringInverse] + exact (CFC.isUnit_sqrt_iff M hM.posSemidef.nonneg).mpr hM.isUnit + +omit [DecidableEq ι] in +lemma congruence_mono {A B : Matrix ι ι ℝ} (hAB : A ≤ B) (L : Matrix ι ι ℝ) : + L * A * L.transpose ≤ L * B * L.transpose := by + apply Matrix.le_iff.mpr + simpa only [Matrix.mul_sub, Matrix.sub_mul, conjTranspose_eq_transpose_of_trivial] + using (Matrix.le_iff.mp hAB).mul_mul_conjTranspose_same L + +lemma trace_power_bound {A : Matrix ι ι ℝ} (hA : A.PosSemidef) {a q : ℝ} + (ha : 0 < a) (hq : 0 ≤ q) (htr : (cfc (fun x : ℝ => x ^ a) A).trace ≤ q ^ a) : + A ≤ q • (1 : Matrix ι ι ℝ) := by + rw [← Algebra.algebraMap_eq_smul_one, le_algebraMap_iff_spectrum_le hA.1.isSelfAdjoint] + rw [Spectral.trace_cfc hA.1] at htr + intro x hx + rw [hA.1.spectrum_real_eq_range_eigenvalues] at hx + obtain ⟨i, rfl⟩ := hx + have hs := Finset.single_le_sum (s := Finset.univ) + (f := fun j => hA.1.eigenvalues j ^ a) + (fun j _ => Real.rpow_nonneg (hA.eigenvalues_nonneg j) a) (Finset.mem_univ i) + exact (Real.rpow_le_rpow_iff (hA.eigenvalues_nonneg i) hq ha).mp (hs.trans htr) + +lemma direct_coefficient_bound {S V D : Matrix ι ι ℝ} + (hS : S.PosDef) (hV : V.PosSemidef) (hD : D.PosSemidef) + (hVD : V ≤ D) (hJ : 1 + D = S + V) + (hA : inverseSqrt S * V * inverseSqrt S ≤ 1) : + inverseSqrt S * CFC.sqrt (inverseSqrt S * V * inverseSqrt S) * inverseSqrt S ≤ + Real.sqrt 8 • (inverseSqrt (1 + D) * + CFC.sqrt (inverseSqrt (1 + D) * D * inverseSqrt (1 + D)) * inverseSqrt (1 + D)) := by + let J := (1 : Matrix ι ι ℝ) + D + let A := inverseSqrt S * V * inverseSqrt S + let H := inverseSqrt J * V * inverseSqrt J + let T := inverseSqrt S * CFC.sqrt J + have hJp : J.PosDef := Matrix.PosDef.one.add_posSemidef hD + have hAp : A.PosSemidef := by + simpa only [A, inverseSqrt_transpose, conjTranspose_eq_transpose_of_trivial] + using hV.mul_mul_conjTranspose_same (inverseSqrt S) + have hHp : H.PosSemidef := by + simpa only [H, inverseSqrt_transpose, conjTranspose_eq_transpose_of_trivial] + using hV.mul_mul_conjTranspose_same (inverseSqrt J) + have hTt : T.transpose = CFC.sqrt J * inverseSqrt S := by + simp only [T, Matrix.transpose_mul, sqrt_transpose, inverseSqrt_transpose] + have hAe : A = T * H * T.transpose := by + rw [hTt] + dsimp [T, H] + simp only [Matrix.mul_assoc] + rw [← Matrix.mul_assoc (CFC.sqrt J), sqrt_mul_inverseSqrt hJp, Matrix.one_mul] + rw [← Matrix.mul_assoc (inverseSqrt J), inverseSqrt_mul_sqrt hJp, Matrix.one_mul] + simp only [A, Matrix.mul_assoc] + have hTT : T * T.transpose = 1 + A := by + rw [hTt] + dsimp only [T] + rw [Matrix.mul_assoc, ← Matrix.mul_assoc (CFC.sqrt J), + CFC.sqrt_mul_sqrt_self J hJp.posSemidef.nonneg, ← Matrix.mul_assoc] + change inverseSqrt S * ((1 : Matrix ι ι ℝ) + D) * inverseSqrt S = 1 + A + rw [hJ, Matrix.mul_add, Matrix.add_mul, inverseSqrt_sandwich hS] + have hTu : IsUnit T := (inverseSqrt_unit hS).mul + ((CFC.isUnit_sqrt_iff J hJp.posSemidef.nonneg).mpr hJp.isUnit) + have hrel := relative_sqrt_bound hTu hHp hAp hAe hTT hA + have hh := congruence_mono hrel (inverseSqrt J) + rw [inverseSqrt_transpose, hTt] at hh + dsimp only [T] at hh + simp only [← Matrix.mul_assoc, inverseSqrt_mul_sqrt hJp, Matrix.one_mul] at hh + simp only [Matrix.mul_assoc, sqrt_mul_inverseSqrt hJp, Matrix.mul_one] at hh + have hp : (inverseSqrt J * D * inverseSqrt J).PosSemidef := by + simpa only [inverseSqrt_transpose, conjTranspose_eq_transpose_of_trivial] + using hD.mul_mul_conjTranspose_same (inverseSqrt J) + have hm : H ≤ inverseSqrt J * D * inverseSqrt J := by + simpa only [H, inverseSqrt_transpose] using congruence_mono hVD (inverseSqrt J) + have hsqrt := MatrixEnergy.sqrt_le_sqrt hHp hp hm + have hout := congruence_mono hsqrt (inverseSqrt J) + rw [inverseSqrt_transpose] at hout + have hs := smul_le_smul_of_nonneg_left hout (Real.sqrt_nonneg 8) + have hleft : inverseSqrt S * CFC.sqrt A * inverseSqrt S ≤ + Real.sqrt 8 • (inverseSqrt J * CFC.sqrt H * inverseSqrt J) := by + simpa only [Matrix.mul_smul, Matrix.smul_mul, Matrix.mul_assoc] using hh + exact hleft.trans hs + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz.GainScalar +open MatrixEnergy + +noncomputable def rate (x : ℝ) : ℝ := + Real.sqrt x / ((1 + x) * Real.sqrt (1 + x)) + +noncomputable def extendedRate (x : ℝ) : ℝ := rate (max 0 x) + +noncomputable def primitive (x : ℝ) : ℝ := ∫ u in (0 : ℝ)..x, extendedRate u + +lemma rate_eq {x : ℝ} (hx : 0 ≤ x) : + rate x = x ^ (exponent - 1) / (1 + x) ^ exponent := by + have hx1 : 0 < 1 + x := by positivity + have hp : (1 + x) ^ exponent = (1 + x) * Real.sqrt (1 + x) := by + rw [show exponent = 1 + (1 / 2 : ℝ) by norm_num [exponent], + Real.rpow_add hx1, Real.rpow_one, ← Real.sqrt_eq_rpow] + rw [hp, show exponent - 1 = (1 / 2 : ℝ) by norm_num [exponent], ← Real.sqrt_eq_rpow] + rfl + +lemma extendedRate_eq {x : ℝ} (hx : 0 ≤ x) : extendedRate x = rate x := by + simp only [extendedRate, max_eq_right hx] + +lemma continuous_extendedRate : Continuous extendedRate := by + unfold extendedRate rate + fun_prop (disch := intro x; positivity) + +lemma rate_continuousOn : ContinuousOn rate (Set.Ici 0) := by + refine continuous_extendedRate.continuousOn.congr ?_ + intro x hx + exact (extendedRate_eq hx).symm + +lemma primitive_eq {x : ℝ} (hx : 0 ≤ x) : primitive x = gainPotential x := by + apply intervalIntegral.integral_congr + intro u hu + rw [Set.uIcc_of_le hx] at hu + rw [extendedRate_eq hu.1, rate_eq hu.1] + +lemma primitive_derivative (x : ℝ) : HasDerivAt primitive (extendedRate x) x := by + exact intervalIntegral.integral_hasDerivAt_right + (continuous_extendedRate.intervalIntegrable 0 x) + continuous_extendedRate.stronglyMeasurable.stronglyMeasurableAtFilter + continuous_extendedRate.continuousAt + +lemma rate_derivative {x : ℝ} (hx : 0 < x) : + HasDerivAt rate ((1 - 2 * x) / (2 * Real.sqrt x * (1 + x) ^ 2 * Real.sqrt (1 + x))) x := by + have hx1 : 0 < 1 + x := by positivity + have hs : HasDerivAt (fun x : ℝ => Real.sqrt (1 + x)) (1 / (2 * Real.sqrt (1 + x))) x := by + simpa only [Function.comp_def, mul_one] using (Real.hasDerivAt_sqrt (ne_of_gt hx1)).comp x + ((hasDerivAt_id x).const_add 1) + have h := (Real.hasDerivAt_sqrt (ne_of_gt hx)).div + (((hasDerivAt_id x).const_add 1).mul hs) (by positivity : (1 + x) * Real.sqrt (1 + x) ≠ 0) + convert! h using 1 + simp only [Pi.mul_apply, id_eq] + field_simp + ring_nf + rw [Real.sq_sqrt hx.le, Real.sq_sqrt hx1.le] + ring + +lemma rate_derivative_lower {x : ℝ} (hx : 0 < x) : + -1 ≤ (1 - 2 * x) / (2 * Real.sqrt x * (1 + x) ^ 2 * Real.sqrt (1 + x)) := by + have hx1 : 0 < 1 + x := by positivity + have hxs : 0 < Real.sqrt x := Real.sqrt_pos.mpr hx + have hys : 0 < Real.sqrt (1 + x) := Real.sqrt_pos.mpr hx1 + have hs : Real.sqrt x ≤ Real.sqrt (1 + x) := Real.sqrt_le_sqrt (by linarith) + have hprod : x ≤ Real.sqrt x * Real.sqrt (1 + x) := by + nlinarith [Real.sq_sqrt hx.le] + have hsq : (1 : ℝ) ≤ (1 + x) ^ 2 := by nlinarith + have hp : x ≤ Real.sqrt x * Real.sqrt (1 + x) * (1 + x) ^ 2 := by + nlinarith [mul_le_mul_of_nonneg_left hsq (mul_nonneg hxs.le hys.le)] + apply (le_div_iff₀ (by positivity)).mpr + nlinarith + +lemma rate_add_linear_monotone : MonotoneOn (fun x : ℝ => rate x + 2 * x) (Set.Ici 0) := by + apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ici 0) + (rate_continuousOn.add (continuous_const.mul continuous_id).continuousOn) + (f' := fun x => (1 - 2 * x) / (2 * Real.sqrt x * (1 + x) ^ 2 * Real.sqrt (1 + x)) + 2) + · intro x hx + rw [interior_Ici] at hx + exact ((rate_derivative hx).fun_add (hasDerivAt_const_mul (x := x) 2)).hasDerivWithinAt + · intro x hx + rw [interior_Ici] at hx + have h := rate_derivative_lower hx + linarith + +lemma extendedRate_add_linear_monotone : Monotone (fun x : ℝ => extendedRate x + 2 * x) := by + intro x y hxy + change extendedRate x + 2 * x ≤ extendedRate y + 2 * y + by_cases hx : 0 ≤ x + · have hy : 0 ≤ y := hx.trans hxy + simpa only [extendedRate_eq hx, extendedRate_eq hy] using rate_add_linear_monotone hx hy hxy + · have hxn : x ≤ 0 := le_of_not_ge hx + by_cases hy : 0 ≤ y + · have he : extendedRate x = 0 := by simp [extendedRate, max_eq_left hxn, rate] + have heg : 0 ≤ extendedRate y := by rw [extendedRate_eq hy]; unfold rate; positivity + rw [he] + linarith + · have hyn : y ≤ 0 := le_of_not_ge hy + simp only [extendedRate, max_eq_left hxn, max_eq_left hyn] + linarith + +lemma convexified_derivative (x : ℝ) : + HasDerivAt (fun u : ℝ => primitive u + u ^ 2) (extendedRate x + 2 * x) x := by + simpa using! (primitive_derivative x).fun_add ((hasDerivAt_id x).fun_pow 2) + +lemma convexified_convex : ConvexOn ℝ Set.univ (fun x : ℝ => primitive x + x ^ 2) := by + apply Monotone.convexOn_univ_of_deriv (fun x => (convexified_derivative x).differentiableAt) + have he : deriv (fun x : ℝ => primitive x + x ^ 2) = (fun x => extendedRate x + 2 * x) := by + funext x + exact (convexified_derivative x).deriv + rw [he] + exact extendedRate_add_linear_monotone + +end EuclideanSteinitz.GainScalar + +namespace EuclideanSteinitz.Gain +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma finite_spectrum_continuous (f : ℝ → ℝ) (A : Matrix ι ι ℝ) : + ContinuousOn f (spectrum ℝ A) := by + rw [continuousOn_iff_continuous_domRestrict] + fun_prop + +lemma sqrt_eq_cfc_real {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + CFC.sqrt A = cfc Real.sqrt A := by + rw [CFC.sqrt_eq_rpow, CFC.rpow_eq_cfc_real hA.nonneg] + congr 1 + funext x + exact (Real.sqrt_eq_rpow x).symm + +lemma inverseSqrt_add_one {D : Matrix ι ι ℝ} (hD : D.PosSemidef) : + inverseSqrt (1 + D) = cfc (fun x : ℝ => (Real.sqrt (1 + x))⁻¹) D := by + have hJ : ((1 : Matrix ι ι ℝ) + D).PosSemidef := Matrix.PosSemidef.one.add hD + have he : cfc (fun x : ℝ => 1 + x) D = 1 + D := by + rw [cfc_const_add (1 : ℝ) (fun x : ℝ => x) D continuousOn_id hD.1.isSelfAdjoint, + cfc_id' ℝ D hD.1.isSelfAdjoint, map_one] + rw [inverseSqrt, sqrt_eq_cfc_real hJ, ← he, ← cfc_comp Real.sqrt (fun x : ℝ => 1 + x) D] + rw [cfc_inv (fun x : ℝ => Real.sqrt (1 + x)) D] + · exact nonsing_inv_eq_ringInverse _ + · intro x hx + have hx₀ := spectrum_nonneg_of_nonneg hD.nonneg hx + exact ne_of_gt (Real.sqrt_pos.mpr (by positivity)) + +lemma relative_rate_coefficient {D : Matrix ι ι ℝ} (hD : D.PosSemidef) : + inverseSqrt (1 + D) * + CFC.sqrt (inverseSqrt (1 + D) * D * inverseSqrt (1 + D)) * inverseSqrt (1 + D) = + cfc GainScalar.rate D := by + let f : ℝ → ℝ := fun x => (Real.sqrt (1 + x))⁻¹ + have hfc : ContinuousOn f (spectrum ℝ D) := finite_spectrum_continuous _ _ + have hs : (inverseSqrt (1 + D) * D * inverseSqrt (1 + D)).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial, inverseSqrt_transpose] + using hD.mul_mul_conjTranspose_same (inverseSqrt (1 + D)) + rw [sqrt_eq_cfc_real hs, inverseSqrt_add_one hD] + change cfc f D * cfc Real.sqrt (cfc f D * D * cfc f D) * cfc f D = _ + have hmid : cfc f D * D * cfc f D = cfc (fun x => f x * id x * f x) D := by + rw [cfc_mul (fun x => f x * id x) f D (finite_spectrum_continuous _ _) hfc, + cfc_mul f id D hfc continuousOn_id, cfc_id ℝ D hD.1.isSelfAdjoint] + rw [hmid, ← cfc_comp Real.sqrt (fun x => f x * id x * f x) D] + rw [← cfc_mul f (Real.sqrt ∘ (fun x => f x * id x * f x)) D hfc + (finite_spectrum_continuous _ _), + ← cfc_mul (fun x => f x * (Real.sqrt ∘ (fun x => f x * id x * f x)) x) f D + (finite_spectrum_continuous _ _) hfc] + apply cfc_congr + intro x hx + have hx₀ := spectrum_nonneg_of_nonneg hD.nonneg hx + have hx1 : 0 < 1 + x := by positivity + have hs1 : Real.sqrt (1 + x) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hx1) + have he : f x * id x * f x = x / (1 + x) := by + dsimp [f] + field_simp + rw [Real.sq_sqrt hx1.le] + simp only [Function.comp_apply, he, Real.sqrt_div hx₀] + dsimp [f, GainScalar.rate] + field_simp + rw [Real.sq_sqrt hx1.le] + +lemma direct_coefficient_bound_rate {S V D : Matrix ι ι ℝ} + (hS : S.PosDef) (hV : V.PosSemidef) (hD : D.PosSemidef) + (hVD : V ≤ D) (hJ : 1 + D = S + V) + (hA : inverseSqrt S * V * inverseSqrt S ≤ 1) : + inverseSqrt S * CFC.sqrt (inverseSqrt S * V * inverseSqrt S) * inverseSqrt S ≤ + Real.sqrt 8 • cfc GainScalar.rate D := by + simpa only [relative_rate_coefficient hD] using direct_coefficient_bound hS hV hD hVD hJ hA + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz.Spectral +open Matrix +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma trace_semiconvex_affine_derivative {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) (f g : ℝ → ℝ) + (hg : Continuous g) (hder : ∀ x, HasDerivAt f (g x) x) + (hconv : ConvexOn ℝ Set.univ (fun x : ℝ => f x + x ^ 2)) (t : ℝ) : + HasDerivAt (fun u : ℝ => (cfc f (A + u • H)).trace) + (cfc g (A + t • H) * H).trace t := by + have hf : Continuous f := continuous_iff_continuousAt.mpr (fun x => (hder x).continuousAt) + have hgf : Continuous (fun x : ℝ => g x + 2 * x) := by fun_prop + have hdf (x : ℝ) : HasDerivAt (fun u : ℝ => f u + u ^ 2) (g x + 2 * x) x := by + simpa using! (hder x).fun_add ((hasDerivAt_id x).fun_pow 2) + have hd := trace_cfc_affine_derivative hA hH (fun x : ℝ => f x + x ^ 2) + (fun x : ℝ => g x + 2 * x) (T := Set.univ) (S := Set.univ) (Set.mem_univ t) + (fun _ _ => Set.subset_univ _) (fun x hx y hy => + convex_tangent hconv hx hy (hdf y).hasDerivWithinAt) + (continuous_cfc_affine hA hH hgf).continuousWithinAt + have hs := trace_cfc_affine_derivative hA hH (fun x : ℝ => x ^ 2) + (fun x : ℝ => 2 * x) (T := Set.univ) (S := Set.univ) (Set.mem_univ t) + (fun _ _ => Set.subset_univ _) (fun x _ y _ => by nlinarith [sq_nonneg (x - y)]) + (continuous_cfc_affine hA hH (by fun_prop)).continuousWithinAt + have hh := (hasDerivWithinAt_univ.mp hd).sub (hasDerivWithinAt_univ.mp hs) + convert! hh using 1 + · funext u + dsimp only [Pi.sub_apply] + rw [cfc_add (A + u • H) f (fun x : ℝ => x ^ 2) hf.continuousOn (by fun_prop), trace_add] + ring + · rw [cfc_add (A + t • H) g (fun x : ℝ => 2 * x) hg.continuousOn (by fun_prop), Matrix.add_mul, trace_add] + ring + +lemma trace_gainPotential_affine_derivative {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) {T : Set ℝ} {t : ℝ} (ht : t ∈ T) + (hpos : ∀ u ∈ T, (A + u • H).PosSemidef) : + HasDerivWithinAt (fun u : ℝ => (cfc MatrixEnergy.gainPotential (A + u • H)).trace) + (cfc (fun x : ℝ => x ^ (MatrixEnergy.exponent - 1) / (1 + x) ^ MatrixEnergy.exponent) + (A + t • H) * H).trace T t := by + have hd := trace_semiconvex_affine_derivative hA hH GainScalar.primitive + GainScalar.extendedRate GainScalar.continuous_extendedRate + GainScalar.primitive_derivative GainScalar.convexified_convex t + have he (u : ℝ) (hu : u ∈ T) : + cfc GainScalar.primitive (A + u • H) = cfc MatrixEnergy.gainPotential (A + u • H) := by + apply cfc_congr + intro x hx + exact GainScalar.primitive_eq (spectrum_nonneg_of_nonneg (hpos u hu).nonneg hx) + have hr : cfc GainScalar.extendedRate (A + t • H) = + cfc (fun x : ℝ => x ^ (MatrixEnergy.exponent - 1) / (1 + x) ^ MatrixEnergy.exponent) + (A + t • H) := by + apply cfc_congr + intro x hx + have hx₀ := spectrum_nonneg_of_nonneg (hpos t ht).nonneg hx + rw [GainScalar.extendedRate_eq hx₀, GainScalar.rate_eq hx₀] + rw [hr] at hd + exact hd.hasDerivWithinAt.congr (fun u hu => congrArg Matrix.trace (he u hu).symm) + (congrArg Matrix.trace (he t ht).symm) + +end EuclideanSteinitz.Spectral + +namespace EuclideanSteinitz.Gain +open Matrix MatrixEnergy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def relativeMoment (S V : Matrix ι ι ℝ) : ℝ := + (cfc (fun x : ℝ => x ^ exponent) (inverseSqrt S * V * inverseSqrt S)).trace + +noncomputable def gainValue (D : Matrix ι ι ℝ) : ℝ := (cfc gainPotential D).trace + +noncomputable def gainConstant : ℝ := exponent * 2 ^ exponent + +lemma two_rpow_exponent : (2 : ℝ) ^ exponent = Real.sqrt 8 := by + rw [show exponent = 1 + (1 / 2 : ℝ) by norm_num [exponent], + Real.rpow_add (by norm_num : (0 : ℝ) < 2), Real.rpow_one, ← Real.sqrt_eq_rpow] + have h := Real.sqrt_mul (show (0 : ℝ) ≤ 4 by norm_num) 2 + norm_num at h + exact h.symm + +lemma gainConstant_pos : 0 < gainConstant := by + unfold gainConstant + exact mul_pos exponent_pos (Real.rpow_pos_of_pos (by norm_num) _) + +lemma sandwich_psd {V : Matrix ι ι ℝ} (hV : V.PosSemidef) (S : Matrix ι ι ℝ) : + (inverseSqrt S * V * inverseSqrt S).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial, inverseSqrt_transpose] + using hV.mul_mul_conjTranspose_same (inverseSqrt S) + +lemma sandwich_affine (S V W : Matrix ι ι ℝ) (u : ℝ) : + inverseSqrt S * (V + u • W) * inverseSqrt S = + inverseSqrt S * V * inverseSqrt S + u • (inverseSqrt S * W * inverseSqrt S) := by + simp only [Matrix.mul_add, Matrix.add_mul, Matrix.mul_smul, Matrix.smul_mul] + +lemma relativeMoment_derivative {S V W : Matrix ι ι ℝ} + (hV : V.PosSemidef) (hW : W.PosSemidef) {t : ℝ} (ht : 0 ≤ t) : + HasDerivWithinAt (fun u => relativeMoment S (V + u • W)) + (exponent * ((inverseSqrt S * CFC.sqrt (inverseSqrt S * (V + t • W) * inverseSqrt S) * + inverseSqrt S) * W).trace) (Set.Ici 0) t := by + have hVt : (V + t • W).PosSemidef := hV.add (hW.smul ht) + have hd := Spectral.trace_rpow_affine_derivative (sandwich_psd hV S).1 + (sandwich_psd hW S).1 (show (1 : ℝ) ≤ exponent by norm_num [exponent]) + (T := Set.Ici 0) ht (fun u hu => by + rw [← sandwich_affine] + exact sandwich_psd (hV.add (hW.smul hu)) S) + have hh : cfc (fun x : ℝ => x ^ (exponent - 1)) + (inverseSqrt S * V * inverseSqrt S + t • (inverseSqrt S * W * inverseSqrt S)) = + CFC.sqrt (inverseSqrt S * (V + t • W) * inverseSqrt S) := by + rw [← sandwich_affine, sqrt_eq_cfc_real (sandwich_psd hVt S)] + congr 1 + funext x + rw [show exponent - 1 = (1 / 2 : ℝ) by norm_num [exponent], Real.sqrt_eq_rpow] + rw [hh] at hd + convert! hd using 1 + · funext u + simp only [relativeMoment, sandwich_affine] + · congr 1 + let A := CFC.sqrt (inverseSqrt S * (V + t • W) * inverseSqrt S) + change ((inverseSqrt S * A * inverseSqrt S) * W).trace = + (A * (inverseSqrt S * W * inverseSqrt S)).trace + calc + _ = (inverseSqrt S * (A * inverseSqrt S * W)).trace := by + simp only [Matrix.mul_assoc] + _ = ((A * inverseSqrt S * W) * inverseSqrt S).trace := Matrix.trace_mul_comm _ _ + _ = _ := by simp only [Matrix.mul_assoc] + +lemma gainValue_derivative {D W : Matrix ι ι ℝ} + (hD : D.PosSemidef) (hW : W.PosSemidef) {t : ℝ} (ht : 0 ≤ t) : + HasDerivWithinAt (fun u => gainValue (D + u • W)) + (cfc GainScalar.rate (D + t • W) * W).trace (Set.Ici 0) t := by + have hd := Spectral.trace_gainPotential_affine_derivative hD.1 hW.1 + (T := Set.Ici 0) ht (fun u hu => hD.add (hW.smul hu)) + have he : cfc (fun x : ℝ => x ^ (exponent - 1) / (1 + x) ^ exponent) (D + t • W) = + cfc GainScalar.rate (D + t • W) := by + apply cfc_congr + intro x hx + exact (GainScalar.rate_eq (spectrum_nonneg_of_nonneg (hD.add (hW.smul ht)).nonneg hx)).symm + rwa [he] at hd + +lemma rate_nonneg {D : Matrix ι ι ℝ} (hD : D.PosSemidef) : + (cfc GainScalar.rate D).PosSemidef := by + apply Matrix.nonneg_iff_posSemidef.mp + apply cfc_nonneg + intro x hx + have hx₀ := spectrum_nonneg_of_nonneg hD.nonneg hx + unfold GainScalar.rate + positivity + +lemma gainValue_monotone {D W : Matrix ι ι ℝ} + (hD : D.PosSemidef) (hW : W.PosSemidef) : + MonotoneOn (fun u : ℝ => gainValue (D + u • W)) (Set.Ici 0) := by + apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ici 0) + (fun u hu => (gainValue_derivative hD hW hu).continuousWithinAt) + (f' := fun t => (cfc GainScalar.rate (D + t • W) * W).trace) + · intro t ht + exact (gainValue_derivative hD hW (interior_subset ht)).mono interior_subset + · intro t ht + exact MatrixEnergy.trace_mul_nonneg (rate_nonneg (hD.add (hW.smul (interior_subset ht)))) hW + +lemma gain_derivative_bound {Z V W : Matrix ι ι ℝ} + (hZ : Z.PosSemidef) (hV : V.PosSemidef) (hW : W.PosSemidef) + (hG : relativeMoment (1 + Z) V ≤ 1) : + exponent * ((inverseSqrt (1 + Z) * + CFC.sqrt (inverseSqrt (1 + Z) * V * inverseSqrt (1 + Z)) * inverseSqrt (1 + Z)) * W).trace ≤ + gainConstant * (cfc GainScalar.rate (Z + V) * W).trace := by + have hS : ((1 : Matrix ι ι ℝ) + Z).PosDef := Matrix.PosDef.one.add_posSemidef hZ + have hA : inverseSqrt (1 + Z) * V * inverseSqrt (1 + Z) ≤ 1 := by + have ht : (cfc (fun x : ℝ => x ^ exponent) + (inverseSqrt (1 + Z) * V * inverseSqrt (1 + Z))).trace ≤ (1 : ℝ) ^ exponent := by + simpa only [Real.one_rpow, relativeMoment] using hG + simpa only [one_smul] using trace_power_bound (sandwich_psd hV (1 + Z)) exponent_pos + (show (0 : ℝ) ≤ 1 by norm_num) ht + have hVD : V ≤ Z + V := by + exact le_add_of_nonneg_left hZ.nonneg + have hc := direct_coefficient_bound_rate hS hV (hZ.add hV) hVD (by abel) hA + have ht := MatrixEnergy.trace_mul_mono_right hc hW + simp only [Matrix.smul_mul, Matrix.trace_smul, smul_eq_mul] at ht + have h := mul_le_mul_of_nonneg_left ht exponent_pos.le + simpa only [gainConstant, two_rpow_exponent, mul_assoc] using h + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz + +lemma conditional_derivative_comparison {f f' g g' : ℝ → ℝ} + (hf : ContinuousOn f (Set.Icc 0 1)) (hg : ContinuousOn g (Set.Icc 0 1)) + (hfd : ∀ x ∈ Set.Ico 0 1, HasDerivWithinAt f (f' x) (Set.Ici x) x) + (hgd : ∀ x ∈ Set.Ico 0 1, HasDerivWithinAt g (g' x) (Set.Ici x) x) + (hbudget : ∀ x ∈ Set.Icc 0 1, f 0 + g x - g 0 ≤ 1 / 4) + (hbound : ∀ x ∈ Set.Ico 0 1, f x ≤ 1 → f' x ≤ g' x) : + ∀ x ∈ Set.Icc 0 1, f x ≤ f 0 + g x - g 0 := by + have hB : ContinuousOn (fun x => f 0 + g x - g 0 + x / 2) (Set.Icc 0 1) := + ((continuousOn_const.add hg).sub continuousOn_const).add + (continuous_id.div_const 2).continuousOn + have hBd (x : ℝ) (hx : x ∈ Set.Ico 0 1) : + HasDerivWithinAt (fun x => f 0 + g x - g 0 + x / 2) (g' x + 1 / 2) (Set.Ici x) x := by + simpa using! (((hgd x hx).const_add (f 0)).sub_const (g 0)).add + ((hasDerivAt_id x).div_const 2).hasDerivWithinAt + have hpre := image_le_of_deriv_right_lt_deriv_boundary' hf hfd + (B := fun x => f 0 + g x - g 0 + x / 2) (B' := fun x => g' x + 1 / 2) + (by simp) hB hBd (fun x hx he => by + have hb := hbudget x ⟨hx.1, hx.2.le⟩ + have hx1 : f x ≤ 1 := by rw [he]; linarith [hx.2] + linarith [hbound x hx hx1]) + have hfull (x : ℝ) (hx : x ∈ Set.Ico 0 1) : f' x ≤ g' x := by + apply hbound x hx + have hp := hpre (show x ∈ Set.Icc 0 1 from ⟨hx.1, hx.2.le⟩) + have hb := hbudget x ⟨hx.1, hx.2.le⟩ + linarith [hx.2] + apply fun x hx => image_le_of_deriv_right_le_deriv_boundary hf hfd + (B := fun x => f 0 + g x - g 0) (B' := g') (by simp) + ((continuousOn_const.add hg).sub continuousOn_const) + (fun x hx => by simpa using! ((hgd x hx).const_add (f 0)).sub_const (g 0)) hfull hx + +end EuclideanSteinitz + +namespace EuclideanSteinitz.Gain +open Matrix MatrixEnergy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma relativeMoment_gain {Z V W : Matrix ι ι ℝ} + (hZ : Z.PosSemidef) (hV : V.PosSemidef) (hW : W.PosSemidef) + (hbudget : relativeMoment (1 + Z) V + + gainConstant * (gainValue (Z + V + W) - gainValue (Z + V)) ≤ 1 / 4) : + relativeMoment (1 + Z) (V + W) ≤ relativeMoment (1 + Z) V + + gainConstant * (gainValue (Z + V + W) - gainValue (Z + V)) := by + let f : ℝ → ℝ := fun t => relativeMoment (1 + Z) (V + t • W) + let f' : ℝ → ℝ := fun t => exponent * ((inverseSqrt (1 + Z) * + CFC.sqrt (inverseSqrt (1 + Z) * (V + t • W) * inverseSqrt (1 + Z)) * + inverseSqrt (1 + Z)) * W).trace + let g : ℝ → ℝ := fun t => gainConstant * gainValue (Z + V + t • W) + let g' : ℝ → ℝ := fun t => gainConstant * (cfc GainScalar.rate (Z + V + t • W) * W).trace + have hfd (x : ℝ) (hx : 0 ≤ x) : HasDerivWithinAt f (f' x) (Set.Ici 0) x := + relativeMoment_derivative hV hW hx + have hgd (x : ℝ) (hx : 0 ≤ x) : HasDerivWithinAt g (g' x) (Set.Ici 0) x := + (gainValue_derivative (hZ.add hV) hW hx).const_mul gainConstant + have hbound : ∀ x ∈ Set.Ico 0 1, f x ≤ 1 → f' x ≤ g' x := by + intro x hx hfx + have hb := gain_derivative_bound hZ (hV.add (hW.smul hx.1)) hW hfx + simpa only [f', g', add_assoc] using hb + have hbud : ∀ x ∈ Set.Icc 0 1, f 0 + g x - g 0 ≤ 1 / 4 := by + intro x hx + have hm := gainValue_monotone (hZ.add hV) hW hx.1 (show (0 : ℝ) ≤ 1 by norm_num) hx.2 + simp only [one_smul] at hm + have hc := mul_le_mul_of_nonneg_left hm gainConstant_pos.le + dsimp only [f, g] + simp only [zero_smul, add_zero] + linarith + have hf : ContinuousOn f (Set.Icc 0 1) := fun x hx => + (hfd x hx.1).continuousWithinAt.mono (fun _ hu => hu.1) + have hg : ContinuousOn g (Set.Icc 0 1) := fun x hx => + (hgd x hx.1).continuousWithinAt.mono (fun _ hu => hu.1) + have hc := EuclideanSteinitz.conditional_derivative_comparison hf hg + (fun x hx => (hfd x hx.1).mono (Set.Ici_subset_Ici.mpr hx.1)) + (fun x hx => (hgd x hx.1).mono (Set.Ici_subset_Ici.mpr hx.1)) hbud hbound + 1 (show (1 : ℝ) ∈ Set.Icc 0 1 by norm_num) + simpa only [f, g, zero_smul, one_smul, add_zero, sub_eq_add_neg, mul_add, mul_neg, + add_assoc] using hc + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz.Gain +open Matrix MatrixEnergy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma relativeMoment_nonneg {S V : Matrix ι ι ℝ} (hV : V.PosSemidef) : + 0 ≤ relativeMoment S V := by + apply Matrix.PosSemidef.trace_nonneg + apply Matrix.nonneg_iff_posSemidef.mp + apply cfc_nonneg + intro x hx + exact Real.rpow_nonneg (spectrum_nonneg_of_nonneg (sandwich_psd hV S).nonneg hx) _ + +lemma relativeMoment_zero (S : Matrix ι ι ℝ) : relativeMoment S 0 = 0 := by + simp only [relativeMoment, Matrix.mul_zero, Matrix.zero_mul, cfc_apply_zero, + Real.zero_rpow (ne_of_gt exponent_pos), map_zero, Matrix.trace_zero] + +lemma relativeMoment_contraction {Z V C : Matrix ι ι ℝ} + (hZ : Z.PosSemidef) (hV : V.PosSemidef) (hC : C * C.transpose ≤ 1) : + relativeMoment (1 + C * Z * C.transpose) (C * V * C.transpose) ≤ + relativeMoment (1 + Z) V := by + let S : Matrix ι ι ℝ := 1 + Z + let Z' := C * Z * C.transpose + let S' : Matrix ι ι ℝ := 1 + Z' + let A := inverseSqrt S * V * inverseSqrt S + let T := inverseSqrt S' * C * CFC.sqrt S + have hS : S.PosDef := Matrix.PosDef.one.add_posSemidef hZ + have hZ' : Z'.PosSemidef := by + simpa only [Z', conjTranspose_eq_transpose_of_trivial] using hZ.mul_mul_conjTranspose_same C + have hS' : S'.PosDef := Matrix.PosDef.one.add_posSemidef hZ' + have hTt : T.transpose = CFC.sqrt S * C.transpose * inverseSqrt S' := by + simp only [T, Matrix.transpose_mul, sqrt_transpose, inverseSqrt_transpose, Matrix.mul_assoc] + have he : inverseSqrt S' * (C * V * C.transpose) * inverseSqrt S' = T * A * T.transpose := by + rw [hTt] + dsimp only [T, A] + simp only [Matrix.mul_assoc] + rw [← Matrix.mul_assoc (CFC.sqrt S), sqrt_mul_inverseSqrt hS, Matrix.one_mul] + rw [← Matrix.mul_assoc (inverseSqrt S), inverseSqrt_mul_sqrt hS, Matrix.one_mul] + have hCS : C * S * C.transpose ≤ S' := by + simp only [S, S', Z', Matrix.mul_add, Matrix.mul_one, Matrix.add_mul] + exact add_le_add hC le_rfl + have hTT : T * T.transpose ≤ 1 := by + have hh := congruence_mono hCS (inverseSqrt S') + rw [inverseSqrt_transpose, inverseSqrt_sandwich hS'] at hh + convert! hh using 1 + rw [hTt] + dsimp only [T] + simp only [Matrix.mul_assoc] + rw [← Matrix.mul_assoc (CFC.sqrt S), CFC.sqrt_mul_sqrt_self S hS.posSemidef.nonneg] + have hb := Spectral.trace_rpow_contraction (sandwich_psd hV S) hTT + (show (1 : ℝ) ≤ exponent by norm_num [exponent]) + unfold relativeMoment + change (cfc (fun x : ℝ => x ^ exponent) + (inverseSqrt S' * (C * V * C.transpose) * inverseSqrt S')).trace ≤ _ + rw [he] + exact hb + +end EuclideanSteinitz.Gain + +namespace EuclideanSteinitz.Gain +open Matrix MatrixEnergy +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +structure Move (ι : Type*) where + contract : Matrix ι ι ℝ + gain : Matrix ι ι ℝ + +noncomputable def Move.old (p : Move ι) (M : Matrix ι ι ℝ) : Matrix ι ι ℝ := + p.contract * M * p.contract.transpose + +noncomputable def Move.next (p : Move ι) (M : Matrix ι ι ℝ) : Matrix ι ι ℝ := p.old M + p.gain + +def Move.Admissible (p : Move ι) : Prop := + p.contract * p.contract.transpose ≤ 1 ∧ p.gain.PosSemidef + +noncomputable def follow (Z V : Matrix ι ι ℝ) : List (Move ι) → Matrix ι ι ℝ × Matrix ι ι ℝ + | [] => (Z, V) + | p :: ps => follow (p.old Z) (p.next V) ps + +noncomputable def gainCost (D : Matrix ι ι ℝ) : List (Move ι) → ℝ + | [] => 0 + | p :: ps => gainValue (p.next D) - gainValue (p.old D) + gainCost (p.next D) ps + +omit [DecidableEq ι] in +lemma Move.old_add (p : Move ι) (A B : Matrix ι ι ℝ) : p.old (A + B) = p.old A + p.old B := by + simp only [Move.old, Matrix.mul_add, Matrix.add_mul] + +omit [DecidableEq ι] in +lemma Move.old_psd (p : Move ι) {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + (p.old A).PosSemidef := by + simpa only [Move.old, conjTranspose_eq_transpose_of_trivial] + using hA.mul_mul_conjTranspose_same p.contract + +lemma Move.next_psd {p : Move ι} (hp : p.Admissible) {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + (p.next A).PosSemidef := (p.old_psd hA).add hp.2 + +lemma Move.gain_nonneg {p : Move ι} (hp : p.Admissible) {D : Matrix ι ι ℝ} (hD : D.PosSemidef) : + 0 ≤ gainValue (p.next D) - gainValue (p.old D) := by + have h := gainValue_monotone (p.old_psd hD) hp.2 (show (0 : ℝ) ≤ 0 by rfl) + (show (0 : ℝ) ≤ 1 by norm_num) (show (0 : ℝ) ≤ 1 by norm_num) + simpa only [Move.next, zero_smul, one_smul, add_zero, sub_nonneg] using h + +lemma gainCost_nonneg {D : Matrix ι ι ℝ} (hD : D.PosSemidef) {ps : List (Move ι)} + (hp : ∀ p ∈ ps, p.Admissible) : 0 ≤ gainCost D ps := by + induction ps generalizing D with + | nil => rfl + | cons p ps ih => + have hpa := hp p (List.mem_cons_self ..) + exact add_nonneg (p.gain_nonneg hpa hD) + (ih (p.next_psd hpa hD) (fun q hq => hp q (List.mem_cons_of_mem p hq))) + +lemma follow_psd {Z V : Matrix ι ι ℝ} (hZ : Z.PosSemidef) (hV : V.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) : + (follow Z V ps).1.PosSemidef ∧ (follow Z V ps).2.PosSemidef := by + induction ps generalizing Z V with + | nil => exact ⟨hZ, hV⟩ + | cons p ps ih => + exact ih (p.old_psd hZ) (p.next_psd (hp p (List.mem_cons_self ..)) hV) + (fun q hq => hp q (List.mem_cons_of_mem p hq)) + +lemma relativeMoment_path {Z V : Matrix ι ι ℝ} (hZ : Z.PosSemidef) (hV : V.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) + (hbudget : relativeMoment (1 + Z) V + gainConstant * gainCost (Z + V) ps ≤ 1 / 4) : + relativeMoment (1 + (follow Z V ps).1) (follow Z V ps).2 ≤ + relativeMoment (1 + Z) V + gainConstant * gainCost (Z + V) ps := by + induction ps generalizing Z V with + | nil => simp only [follow, gainCost, mul_zero, add_zero, le_refl] + | cons p ps ih => + have hpa := hp p (List.mem_cons_self ..) + have hps : ∀ q ∈ ps, q.Admissible := fun q hq => hp q (List.mem_cons_of_mem p hq) + have hz := p.old_psd hZ + have hv := p.old_psd hV + have hnew := p.next_psd hpa hV + have he : p.next (Z + V) = p.old Z + p.next V := by + simp only [Move.next, p.old_add, add_assoc] + have hc := relativeMoment_contraction hZ hV hpa.1 + change relativeMoment (1 + p.old Z) (p.old V) ≤ relativeMoment (1 + Z) V at hc + have htail := gainCost_nonneg (p.next_psd hpa (hZ.add hV)) hps + have hb : relativeMoment (1 + p.old Z) (p.old V) + + gainConstant * (gainValue (p.old Z + p.old V + p.gain) - gainValue (p.old Z + p.old V)) ≤ 1 / 4 := by + simp only [gainCost, Move.next, p.old_add] at hbudget htail + nlinarith [gainConstant_pos] + have hg := relativeMoment_gain hz hv hpa.2 hb + change relativeMoment (1 + p.old Z) (p.next V) ≤ _ at hg + simp only [Move.next] at hg + have hbudget' : relativeMoment (1 + p.old Z) (p.next V) + + gainConstant * gainCost (p.old Z + p.next V) ps ≤ 1 / 4 := by + rw [← he] + simp only [gainCost] at hbudget + simp only [Move.next, p.old_add] at hbudget ⊢ + linarith + have hi := ih hz hnew hps hbudget' + change relativeMoment (1 + (follow (p.old Z) (p.next V) ps).1) + (follow (p.old Z) (p.next V) ps).2 ≤ _ + rw [← he] at hi + simp only [gainCost] + simp only [Move.next, p.old_add] at hi hg ⊢ + linarith + +end EuclideanSteinitz.Gain + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/GaussianKernel.lean b/lean/OAI/Analysis/Steinitz/GaussianKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..12cf06b593715df7cc267c78d65d3bbb14e2e65e --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/GaussianKernel.lean @@ -0,0 +1,179 @@ +import OAI.Analysis.Steinitz.Survival + +namespace OAI + +/-! Diagonal Gaussian kernels and their densities. -/ + +section + +open MeasureTheory ProbabilityTheory Set WithLp +open scoped ENNReal NNReal +namespace GaussianKernel + +variable {ι : Type*} [Fintype ι] + +noncomputable def diagonalLaw (v : ι → ℝ≥0) : Measure (EuclideanSpace ℝ ι) := + (Measure.pi (fun i => gaussianReal 0 (v i))).map (toLp 2) + +instance (v : ι → ℝ≥0) : IsProbabilityMeasure (diagonalLaw v) := + by + unfold diagonalLaw + infer_instance + +noncomputable def density (v : ι → ℝ≥0) (x : EuclideanSpace ℝ ι) : ℝ := + ∏ i, gaussianPDFReal 0 (v i) (x i) + +lemma density_nonneg (v : ι → ℝ≥0) (x : EuclideanSpace ℝ ι) : 0 ≤ density v x := by + exact Finset.prod_nonneg fun i _ => gaussianPDFReal_nonneg 0 (v i) (x i) + +lemma density_continuous (v : ι → ℝ≥0) : Continuous (density v) := by + unfold density gaussianPDFReal + fun_prop + +lemma pi_density (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) : + (Measure.pi fun i => gaussianReal 0 (v i)) = + volume.withDensity (fun x : ι → ℝ => ENNReal.ofReal (∏ i, gaussianPDFReal 0 (v i) (x i))) := by + apply Measure.pi_eq + intro s hs + rw [withDensity_apply _ (MeasurableSet.univ_pi hs), + ← ofReal_integral_eq_lintegral_ofReal + ((show Integrable (fun x : ι → ℝ => ∏ i, gaussianPDFReal 0 (v i) (x i)) volume from + by simpa only [volume_pi] using Integrable.fintype_prod (fun i => integrable_gaussianPDFReal 0 (v i))).restrict) + (ae_of_all _ fun x => Finset.prod_nonneg (fun i _ => gaussianPDFReal_nonneg 0 (v i) (x i))), + volume_pi, Measure.restrict_pi_pi, integral_fintype_prod_eq_prod, + ENNReal.ofReal_prod_of_nonneg (fun i _ => integral_nonneg (gaussianPDFReal_nonneg 0 (v i)))] + apply Finset.prod_congr rfl + intro i _ + exact (gaussianReal_apply_eq_integral 0 (hv i) (s i)).symm + +lemma diagonalLaw_density (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) : + diagonalLaw v = volume.withDensity (fun x => ENNReal.ofReal (density v x)) := by + apply Measure.ext + intro s hs + rw [diagonalLaw, Measure.map_apply (PiLp.volume_preserving_toLp ι).measurable hs, + pi_density v hv, withDensity_apply _ (hs.preimage (PiLp.volume_preserving_toLp ι).measurable), + withDensity_apply _ hs] + rw [← lintegral_indicator (hs.preimage (PiLp.volume_preserving_toLp ι).measurable), + ← lintegral_indicator hs] + have he (x : ι → ℝ) : + ((toLp 2) ⁻¹' s).indicator (fun x : ι → ℝ => ENNReal.ofReal (∏ i, gaussianPDFReal 0 (v i) (x i))) x = + s.indicator (fun x => ENNReal.ofReal (density v x)) (toLp 2 x) := by + by_cases hx : toLp 2 x ∈ s <;> simp [hx, density] + simp_rw [he] + exact (PiLp.volume_preserving_toLp ι).lintegral_comp + ((density_continuous v).measurable.ennreal_ofReal.indicator hs) + +lemma density_pos (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) (x : EuclideanSpace ℝ ι) : + 0 < density v x := by + exact Finset.prod_pos fun i _ => gaussianPDFReal_pos 0 (v i) (x i) (hv i) + +lemma density_neg (v : ι → ℝ≥0) (x : EuclideanSpace ℝ ι) : density v (-x) = density v x := by + unfold density + apply Finset.prod_congr rfl + intro i _ + simp [gaussianPDFReal] + +lemma density_le_zero (v : ι → ℝ≥0) (x : EuclideanSpace ℝ ι) : density v x ≤ density v 0 := by + unfold density + apply Finset.prod_le_prod₀ + · intro i _ + exact gaussianPDFReal_nonneg _ _ _ + · intro i _ + simp only [gaussianPDFReal, sub_zero, PiLp.zero_apply, neg_zero, zero_pow (by decide : 2 ≠ 0), + zero_div, Real.exp_zero, mul_one] + apply mul_le_of_le_one_right (by positivity) + apply Real.exp_le_one_iff.mpr + exact div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (sq_nonneg _)) (by positivity) + +lemma charFun_diagonalLaw (v : ι → ℝ≥0) (ξ : EuclideanSpace ℝ ι) : + charFun (diagonalLaw v) ξ = (Real.exp (-(∑ i, (v i : ℝ)*(ξ i)^2)/2) : ℂ) := by + rw [diagonalLaw, charFun_pi] + simp only [charFun_gaussianReal, Complex.ofReal_zero, mul_zero, zero_mul, zero_sub] + rw [← Complex.exp_sum, Complex.ofReal_exp] + congr 1 + simp only [Complex.ofReal_div, Complex.ofReal_neg, Complex.ofReal_sum, + Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_ofNat, Finset.sum_neg_distrib] + rw [← Finset.sum_div, neg_div] + +section Scale +variable [DecidableEq ι] + +noncomputable def scaleMap (v : ι → ℝ≥0) : EuclideanSpace ℝ ι →L[ℝ] EuclideanSpace ℝ ι := + Matrix.toEuclideanCLM (𝕜 := ℝ) (Matrix.diagonal (fun i => Real.sqrt (v i : ℝ))) + +lemma scaleMap_apply (v : ι → ℝ≥0) (x : EuclideanSpace ℝ ι) (i : ι) : + scaleMap v x i = Real.sqrt (v i : ℝ) * x i := by + change (Matrix.diagonal (fun i => Real.sqrt (v i : ℝ))).mulVec x.ofLp i = _ + simp only [Matrix.mulVec_diagonal] + +lemma stdGaussian_map_scale (v : ι → ℝ≥0) : + (stdGaussian (EuclideanSpace ℝ ι)).map (scaleMap v) = diagonalLaw v := by + rw [← map_pi_eq_stdGaussian, Measure.map_map (scaleMap v).measurable + (PiLp.volume_preserving_toLp ι).measurable] + have he : (scaleMap v) ∘ (toLp 2) = + (toLp 2) ∘ (fun x : ι → ℝ => fun i => Real.sqrt (v i : ℝ)*x i) := by + ext x i + exact scaleMap_apply v (toLp 2 x) i + rw [he, ← Measure.map_map (PiLp.volume_preserving_toLp ι).measurable (by fun_prop), + Measure.pi_map_pi (f := fun i (x : ℝ) => Real.sqrt (v i : ℝ)*x) + (fun i => (measurable_const.mul measurable_id).aemeasurable)] + congr 1 + apply congrArg Measure.pi + funext i + rw [gaussianReal_map_const_mul] + congr 1 + · simp + · ext + simp [Real.sq_sqrt (v i).coe_nonneg] + +end Scale + +end GaussianKernel +open MeasureTheory ProbabilityTheory Set WithLp +open scoped ENNReal NNReal +namespace GaussianKernel +variable {ι : Type*} [Fintype ι] + +lemma density_exp (v : ι → ℝ≥0) (x : EuclideanSpace ℝ ι) : + density v x = density v 0 * Real.exp (-(∑ i, (x i)^2 / (2*(v i : ℝ)))) := by + simp only [density, gaussianPDFReal, sub_zero, PiLp.zero_apply, neg_zero, + zero_pow (by decide : 2 ≠ 0), zero_div, Real.exp_zero, mul_one, + Finset.prod_mul_distrib, ← Real.exp_sum, ← Finset.sum_neg_distrib, neg_div] + +end GaussianKernel + +end + +section + +open MeasureTheory ProbabilityTheory Set +open scoped ENNReal NNReal +namespace GaussianKernel +variable {ι : Type*} [Fintype ι] + +lemma density_integrable (v : ι → ℝ≥0) : Integrable (density v) := by + apply ((PiLp.volume_preserving_toLp ι).integrable_comp + (density_continuous v).aestronglyMeasurable).mp + change Integrable (fun x : ι → ℝ => ∏ i,gaussianPDFReal 0 (v i) (x i)) + simpa only [volume_pi] using Integrable.fintype_prod (fun i => integrable_gaussianPDFReal 0 (v i)) + +lemma stdGaussian_eq_density : stdGaussian (EuclideanSpace ℝ ι) = + volume.withDensity (fun x => ENNReal.ofReal (density (fun _ : ι => 1) x)) := by + rw [← diagonalLaw_density (fun _ : ι => 1) (fun _ => by simp)] + exact map_pi_eq_stdGaussian.symm + +lemma linear_image_density (e : EuclideanSpace ℝ ι ≃L[ℝ] EuclideanSpace ℝ ι) + {S : Set (EuclideanSpace ℝ ι)} (hS : MeasurableSet S) : + (stdGaussian (EuclideanSpace ℝ ι)).map e S = + ENNReal.ofReal (∫ x in S, |e.symm.toContinuousLinearMap.det| * + density (fun _ => 1) (e.symm x)) := by + rw [stdGaussian_eq_density] + exact e.symm.toHomeomorph.toMeasurableEquiv.withDensity_ofReal_map_symm_apply_eq_integral_abs_det_fderiv_mul + volume hS (ae_of_all _ fun _ _ => density_nonneg _ _) (density_integrable _).integrableOn + (fun x _ => e.symm.toContinuousLinearMap.hasFDerivAt.hasFDerivWithinAt) + +end GaussianKernel + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/GaussianProcess.lean b/lean/OAI/Analysis/Steinitz/GaussianProcess.lean new file mode 100644 index 0000000000000000000000000000000000000000..50fce76cf34442fc9a1abebe92fc00094db002b8 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/GaussianProcess.lean @@ -0,0 +1,220 @@ +import OAI.Analysis.Steinitz.Predictor + +namespace OAI + +/-! Stationary Gaussian autoregressive rows and covariance identities. -/ + +section + +open Matrix +open scoped BigOperators +namespace GaussianAR + +noncomputable def row (r : ℝ) : ℕ → ℕ → ℝ + | 0,k => if k=0 then 1 else 0 + | t+1,k => r*row r t k + if k=t+1 then Real.sqrt (1-r^2) else 0 + +lemma row_support (r : ℝ) {t k : ℕ} (h : t simp [row,show k≠0 by omega] + | succ t ih => simp [row,ih (by omega),show k≠t+1 by omega] + +lemma row_initial (r : ℝ) (t : ℕ) : row r t 0 = r^t := by + induction t with + | zero => simp [row] + | succ t ih => simp [row,ih,pow_succ,mul_comm] + +lemma row_diag (r : ℝ) (t : ℕ) : row r (t+1) (t+1) = Real.sqrt (1-r^2) := by + simp [row,row_support r (Nat.lt_succ_self t)] + +lemma row_dot_step (r : ℝ) (n t u : ℕ) (ht : t simp [row] + | succ t ih => + have hp := ih (by omega) + have hcross : (∑ k ∈ Finset.range (n+1), row r t k*(if k=t+1 then Real.sqrt (1-r^2) else 0))=0 := by + simp only [mul_ite,mul_zero,Finset.sum_ite_eq',Finset.mem_range,show t+1 ring + simp only [he,Finset.sum_add_distrib,← Finset.mul_sum,hp,hcross,mul_zero,add_zero] + rw [Finset.sum_ite_eq'] + simp only [Finset.mem_range,show t+1 + have : u=0 := by omega + subst u + simp [row] + | succ t ih => + by_cases h : u=t+1 + · subst u + simpa only [Nat.sub_self,pow_zero,← sq] using row_norm r hr hr1 n (t+1) ht + · have hu' : u≤t := by omega + rw [row_dot_step r n t u (by omega),ih (by omega) hu',row_support r (by omega),mul_zero,add_zero] + rw [show t+1-u=(t-u)+1 by omega,pow_succ,mul_comm] + +lemma row_norm_fin (r : ℝ) (hr : 0≤r) (hr1 : r≤1) (n : ℕ) (t : Fin (n+1)) : + (∑ k : Fin (n+1), (row r t.val k.val)^2)=1 := by + rw [Fin.sum_univ_eq_sum_range (fun k => (row r t.val k)^2)] + exact row_norm r hr hr1 n t.val (by omega) + +lemma row_covariance_fin (r : ℝ) (hr : 0≤r) (hr1 : r≤1) (n : ℕ) (t u : Fin (n+1)) (hu : u≤t) : + (∑ k : Fin (n+1), row r t.val k.val*row r u.val k.val)=r^(t.val-u.val) := by + rw [Fin.sum_univ_eq_sum_range (fun k => row r t.val k*row r u.val k)] + exact row_covariance r hr hr1 n t.val u.val (by omega) hu + +lemma one_sub_pow_le (r : ℝ) (hr : 0≤r) (hr1 : r≤1) (t : ℕ) : + 1-r^t ≤ t*(1-r) := by + induction t with + | zero => simp + | succ t ih => + rw [pow_succ,Nat.cast_add,Nat.cast_one] + have hp : r^t≤1 := pow_le_one₀ hr hr1 + nlinarith + +end GaussianAR + +end + +section + +open Matrix +open scoped BigOperators RealInnerProductSpace +namespace GaussianTail +variable {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν] +lemma trace_covariance (B : Matrix κ ι ℝ) : (B*B.transpose).trace=squareMass B := by + simp only [Matrix.trace,Matrix.diag,Matrix.mul_apply,Matrix.transpose_apply,squareMass,← sq] + +lemma squareMass_mul_covariance (B : Matrix κ ι ℝ) (C : Matrix ι ν ℝ) : + squareMass (B*C) = (B*(C*C.transpose)*B.transpose).trace := by + rw [← trace_covariance,Matrix.transpose_mul] + congr 1 + simp only [Matrix.mul_assoc] + +lemma squareMass_add_le (B C : Matrix κ ι ℝ) : + squareMass (B+C) ≤ 2*squareMass B+2*squareMass C := by + unfold squareMass + simp only [Finset.mul_sum,← Finset.sum_add_distrib,Matrix.add_apply] + apply Finset.sum_le_sum + intro i _ + apply Finset.sum_le_sum + intro k _ + nlinarith [sq_nonneg (B i k-C i k)] + +lemma squareMass_neg (B : Matrix κ ι ℝ) : squareMass (-B)=squareMass B := by + simp [squareMass] + +end GaussianTail +namespace GaussianAR +open GaussianTail +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def evaluation (r : ι → ℝ) (n : ℕ) (t : Fin (n+1)) : Matrix ι (Fin (n+1)×ι) ℝ := + fun i k => if i=k.2 then row (r i) t.val k.1.val else 0 + +lemma evaluation_mul_transpose (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (n : ℕ) (t u : Fin (n+1)) (hu : u≤t) : + evaluation r n t*(evaluation r n u).transpose = diagonal (fun i => (r i)^(t.val-u.val)) := by + ext i j + simp only [Matrix.mul_apply,Matrix.transpose_apply,Fintype.sum_prod_type,evaluation] + by_cases hij : i=j + · subst j + simp only [mul_ite,ite_mul,mul_zero,zero_mul] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true,Matrix.diagonal_apply_eq] + exact row_covariance_fin (r i) (hr i) (hr1 i) n t u hu + · rw [Matrix.diagonal_apply_ne _ hij] + apply Finset.sum_eq_zero + intro k _ + apply Finset.sum_eq_zero + intro l _ + split_ifs <;> simp_all + +lemma evaluation_coisometry (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (n : ℕ) (t : Fin (n+1)) : + evaluation r n t*(evaluation r n t).transpose=1 := by + rw [evaluation_mul_transpose r hr hr1 n t t le_rfl] + simp + +lemma evaluation_cross_symmetric (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (n : ℕ) (t u : Fin (n+1)) : + evaluation r n t*(evaluation r n u).transpose = evaluation r n u*(evaluation r n t).transpose := by + rcases le_total u t with h|h + · have ht : (evaluation r n t*(evaluation r n u).transpose).transpose = + evaluation r n t*(evaluation r n u).transpose := by + rw [evaluation_mul_transpose r hr hr1 n t u h,Matrix.diagonal_transpose] + simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using ht.symm + · have ht : (evaluation r n u*(evaluation r n t).transpose).transpose = + evaluation r n u*(evaluation r n t).transpose := by + rw [evaluation_mul_transpose r hr hr1 n u t h,Matrix.diagonal_transpose] + simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using ht + +lemma evaluation_difference_covariance (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (n : ℕ) (t u : Fin (n+1)) (hu : u≤t) : + (evaluation r n t-evaluation r n u)*(evaluation r n t-evaluation r n u).transpose = + diagonal (fun i => 2*(1-(r i)^(t.val-u.val))) := by + rw [Matrix.transpose_sub,Matrix.mul_sub,Matrix.sub_mul,Matrix.sub_mul, + evaluation_coisometry r hr hr1,evaluation_coisometry r hr hr1, + ← evaluation_cross_symmetric r hr hr1 n t u,evaluation_mul_transpose r hr hr1 n t u hu] + ext i j + by_cases h : i=j + · subst j; simp; ring + · simp [h] + +lemma squareMass_evaluation {κ : Type*} [Fintype κ] (B : Matrix κ ι ℝ) + (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) (n : ℕ) (t : Fin (n+1)) : + squareMass (B*evaluation r n t)=squareMass B := by + rw [squareMass_mul_covariance,evaluation_coisometry r hr hr1,Matrix.mul_one,trace_covariance] + +lemma trace_weighted_square {κ : Type*} [Fintype κ] (B : Matrix κ ι ℝ) (w : ι → ℝ) : + (B*diagonal w*B.transpose).trace = ∑ i,∑ j,(B i j)^2*w j := by + change (∑ i,∑ j,(B*diagonal w) i j*B i j) = _ + simp only [Matrix.mul_diagonal] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma squareMass_time_le {κ : Type*} [Fintype κ] (B : Matrix κ ι ℝ) + (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) (n : ℕ) (t u : Fin (n+1)) : + squareMass (B*(evaluation r n t-evaluation r n u)) ≤ + 2*|(t.val:ℝ)-u.val| * (B*diagonal (fun i => 1-r i)*B.transpose).trace := by + wlog hu : u≤t generalizing t u + · have h := this u t (le_of_not_ge hu) + rw [show evaluation r n t-evaluation r n u= -(evaluation r n u-evaluation r n t) by abel, + Matrix.mul_neg,squareMass_neg,abs_sub_comm] + exact h + rw [squareMass_mul_covariance,evaluation_difference_covariance r hr hr1 n t u hu, + trace_weighted_square,trace_weighted_square,abs_of_nonneg (sub_nonneg.mpr (show (u.val:ℝ) ≤ t.val by exact_mod_cast hu)), + ← Nat.cast_sub hu] + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + apply Finset.sum_le_sum + intro j _ + have h := one_sub_pow_le (r j) (hr j) (hr1 j) (t.val-u.val) + nlinarith [mul_nonneg (sq_nonneg (B i j)) (sub_nonneg.mpr h)] + +end GaussianAR + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/GaussianTail.lean b/lean/OAI/Analysis/Steinitz/GaussianTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..364034a5a8c251a8171e14771aaf81da5a40903a --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/GaussianTail.lean @@ -0,0 +1,268 @@ +import OAI.Analysis.Steinitz.Scales + +namespace OAI + +/-! Scalar and matrix Gaussian tail estimates. -/ + +section + +open MeasureTheory ProbabilityTheory +open scoped RealInnerProductSpace NNReal + +namespace GaussianTail + +lemma integral_exp_square (t : ℝ) : + (∫ x : ℝ, Real.exp (-t * x ^ 2 / 2) ∂gaussianReal 0 1) = + (Real.sqrt (1 + t))⁻¹ := by + rw [integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0)] + have he (x : ℝ) : gaussianPDFReal 0 1 x * Real.exp (-t * x ^ 2 / 2) = + (Real.sqrt (2 * Real.pi))⁻¹ * Real.exp (-((1 + t) / 2) * x ^ 2) := by + simp only [gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero] + rw [mul_assoc, ← Real.exp_add] + congr 2 + ring + simp only [smul_eq_mul, he, integral_const_mul, integral_gaussian] + rw [show Real.pi / ((1 + t) / 2) = (2 * Real.pi) / (1 + t) by rw [div_div_eq_mul_div]; ring] + rw [Real.sqrt_div (by positivity : 0 ≤ 2 * Real.pi)] + have hp : Real.sqrt (2 * Real.pi) ≠ 0 := by positivity + field_simp + +lemma integrable_exp_square {t : ℝ} (ht : -1 < t) : + Integrable (fun x : ℝ => Real.exp (-t * x ^ 2 / 2)) (gaussianReal 0 1) := by + apply Integrable.of_integral_ne_zero + rw [integral_exp_square t] + exact ne_of_gt (inv_pos.mpr (Real.sqrt_pos.mpr (by linarith))) + +lemma inverse_sqrt_one_sub_le_exp {u : ℝ} (hu : 0 ≤ u) (hu' : u ≤ 1/2) : + (Real.sqrt (1-u))⁻¹ ≤ Real.exp u := by + have hpos : 0 < 1-u := by linarith + have hlog : -Real.log (1-u) ≤ 2*u := by + have h := Real.log_le_sub_one_of_pos (inv_pos.mpr hpos) + rw [Real.log_inv] at h + have hi : (1-u)⁻¹ - 1 ≤ 2*u := by + rw [inv_eq_one_div] + apply (sub_le_iff_le_add).mpr + apply (div_le_iff₀ hpos).mpr + nlinarith + exact h.trans hi + apply (Real.log_le_log_iff (inv_pos.mpr (Real.sqrt_pos.mpr hpos)) (Real.exp_pos u)).mp + rw [Real.log_inv, Real.log_sqrt hpos.le, Real.log_exp] + linarith + +open Matrix +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma quadratic_eigenbasis {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (x : ι → ℝ) : + ⟪∑ i, x i • hA.eigenvectorBasis i, + toEuclideanCLM (𝕜 := ℝ) A (∑ i, x i • hA.eigenvectorBasis i)⟫ = + ∑ i, hA.eigenvalues i * x i ^ 2 := by + have he (i : ι) : toEuclideanCLM (𝕜 := ℝ) A (hA.eigenvectorBasis i) = + hA.eigenvalues i • hA.eigenvectorBasis i := by + apply WithLp.ofLp_injective + exact hA.mulVec_eigenvectorBasis i + simp only [map_sum, map_smul, he, smul_smul, + sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right, + hA.eigenvectorBasis.inner_eq_ite] + simp [mul_ite, ite_mul, pow_two, mul_comm, mul_left_comm, mul_assoc] + +lemma quadratic_mgf_eq {A : Matrix ι ι ℝ} (hA : A.IsHermitian) : + (∫ x : EuclideanSpace ℝ ι, Real.exp (⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ / 2) + ∂stdGaussian (EuclideanSpace ℝ ι)) = ∏ i, (Real.sqrt (1-hA.eigenvalues i))⁻¹ := by + have he (x : ι → ℝ) : + Real.exp (⟪∑ i, x i • hA.eigenvectorBasis i, + toEuclideanCLM (𝕜 := ℝ) A (∑ i, x i • hA.eigenvectorBasis i)⟫ / 2) = + ∏ i, Real.exp (hA.eigenvalues i * x i ^ 2 / 2) := by + rw [quadratic_eigenbasis, ← Real.exp_sum] + congr 1 + simp only [Finset.sum_div] + rw [stdGaussian_eq_map_pi_orthonormalBasis hA.eigenvectorBasis, + integral_map (Measurable.aemeasurable (by fun_prop)) (by fun_prop)] + simp only [he] + rw [integral_fintype_prod_eq_prod + (f := fun i (x : ℝ) => Real.exp (hA.eigenvalues i * x ^ 2 / 2))] + apply Finset.prod_congr rfl + intro i _ + simpa only [neg_neg, sub_eq_add_neg] using integral_exp_square (-hA.eigenvalues i) + +lemma quadratic_mgf_le {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hEig : ∀ i, hA.1.eigenvalues i ≤ 1/2) : + (∫ x : EuclideanSpace ℝ ι, Real.exp (⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ / 2) + ∂stdGaussian (EuclideanSpace ℝ ι)) ≤ Real.exp A.trace := by + rw [quadratic_mgf_eq hA.1, hA.1.trace_eq_sum_eigenvalues, + Real.exp_sum] + apply Finset.prod_le_prod₀ + · intro i _ + positivity + · intro i _ + exact inverse_sqrt_one_sub_le_exp (hA.eigenvalues_nonneg i) (hEig i) + +lemma quadratic_mgf_integrable {A : Matrix ι ι ℝ} (hA : A.IsHermitian) + (hEig : ∀ i, hA.eigenvalues i < 1) : + Integrable (fun x : EuclideanSpace ℝ ι => Real.exp (⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ / 2)) + (stdGaussian (EuclideanSpace ℝ ι)) := by + apply Integrable.of_integral_ne_zero + rw [quadratic_mgf_eq hA] + apply ne_of_gt + exact Finset.prod_pos fun i _ => inv_pos.mpr (Real.sqrt_pos.mpr (by linarith [hEig i])) + +lemma quadratic_tail {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hEig : ∀ i, hA.1.eigenvalues i ≤ 1/2) (r : ℝ) : + stdGaussian (EuclideanSpace ℝ ι) + {x | 2*(A.trace+r) ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫} ≤ + ENNReal.ofReal (Real.exp (-r)) := by + let f := fun x : EuclideanSpace ℝ ι => + Real.exp (-A.trace-r) * Real.exp (⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫/2) + have hi : Integrable f (stdGaussian (EuclideanSpace ℝ ι)) := + (quadratic_mgf_integrable hA.1 (fun i => by linarith [hEig i])).const_mul _ + have hbound := hi.measure_le_integral (Filter.Eventually.of_forall fun x => + mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le) + (s := {x | 2*(A.trace+r) ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫}) + (fun x hx => by + dsimp only [f] + rw [← Real.exp_add] + exact Real.one_le_exp_iff.mpr (by + change 2*(A.trace+r) ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ at hx + linarith)) + apply hbound.trans + apply ENNReal.ofReal_le_ofReal + rw [show (∫ x, f x ∂stdGaussian (EuclideanSpace ℝ ι)) = + Real.exp (-A.trace-r) * ∫ x, Real.exp (⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫/2) + ∂stdGaussian (EuclideanSpace ℝ ι) by exact integral_const_mul _ _] + calc + _ ≤ Real.exp (-A.trace-r) * Real.exp A.trace := + mul_le_mul_of_nonneg_left (quadratic_mgf_le hA hEig) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +lemma eigenvalue_le_of_form_le {A : Matrix ι ι ℝ} (hA : A.IsHermitian) {b : ℝ} + (hb : ∀ x : EuclideanSpace ℝ ι, ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ ≤ b*‖x‖^2) : + ∀ i, hA.eigenvalues i ≤ b := by + intro i + have h := hb (hA.eigenvectorBasis i) + rw [hA.eigenvectorBasis.orthonormal.norm_eq_one, one_pow, mul_one] at h + have he : toEuclideanCLM (𝕜 := ℝ) A (hA.eigenvectorBasis i) = + hA.eigenvalues i • hA.eigenvectorBasis i := by + apply WithLp.ofLp_injective + exact hA.mulVec_eigenvectorBasis i + simpa [he, real_inner_smul_right, hA.eigenvectorBasis.inner_eq_ite] using h + +lemma scaled_quadratic_tail {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {b : ℝ} (hb : 0 < b) + (hform : ∀ x : EuclideanSpace ℝ ι, ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ ≤ b*‖x‖^2) + (r : ℝ) : + stdGaussian (EuclideanSpace ℝ ι) + {x | 2*A.trace+4*b*r ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫} ≤ + ENNReal.ofReal (Real.exp (-r)) := by + let S : Matrix ι ι ℝ := (1/(2*b)) • A + have hS : S.PosSemidef := hA.smul (by positivity : 0 ≤ 1/(2*b)) + have he (x : EuclideanSpace ℝ ι) : ⟪x, toEuclideanCLM (𝕜 := ℝ) S x⟫ = + (1/(2*b))*⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ := by + simp only [S, inner_toEuclideanCLM, smul_mulVec, dotProduct_smul, smul_eq_mul] + have hspec : ∀ i, hS.1.eigenvalues i ≤ 1/2 := by + apply eigenvalue_le_of_form_le hS.1 + intro x + rw [he] + have hx := mul_le_mul_of_nonneg_left (hform x) (by positivity : 0 ≤ 1/(2*b)) + apply hx.trans_eq + field_simp + have hset : {x : EuclideanSpace ℝ ι | 2*S.trace+2*r ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) S x⟫} = + {x | 2*A.trace+4*b*r ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫} := by + ext x + change (2*S.trace+2*r ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) S x⟫) ↔ + 2*A.trace+4*b*r ≤ ⟪x, toEuclideanCLM (𝕜 := ℝ) A x⟫ + simp only [he, S, trace_smul, smul_eq_mul] + constructor <;> intro h + · have hm := mul_le_mul_of_nonneg_left h (by positivity : 0 ≤ 2*b) + field_simp at hm + nlinarith + · have hm := mul_le_mul_of_nonneg_left h (by positivity : 0 ≤ 1/(2*b)) + field_simp at hm ⊢ + nlinarith + have ht := quadratic_tail hS hspec r + rw [show 2*(S.trace+r)=2*S.trace+2*r by ring, hset] at ht + exact ht + +end GaussianTail + +end + +section + +open Matrix MeasureTheory ProbabilityTheory +open scoped RealInnerProductSpace ENNReal +namespace GaussianTail +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] + +noncomputable def matrixMap (B : Matrix κ ι ℝ) : EuclideanSpace ℝ ι →L[ℝ] EuclideanSpace ℝ κ := + (Matrix.toEuclideanLin B).toContinuousLinearMap + +noncomputable def squareMass (B : Matrix κ ι ℝ) : ℝ := ∑ i,∑ j,B i j^2 + +omit [DecidableEq ι] in +lemma squareMass_nonneg (B : Matrix κ ι ℝ) : 0 ≤ squareMass B := by + exact Finset.sum_nonneg fun _ _ => Finset.sum_nonneg fun _ _ => sq_nonneg _ + +lemma gram_form (B : Matrix κ ι ℝ) (x : EuclideanSpace ℝ ι) : + ⟪x,toEuclideanCLM (𝕜 := ℝ) (B.transpose*B) x⟫ = ‖matrixMap B x‖^2 := by + rw [inner_toEuclideanCLM,← mulVec_mulVec, dotProduct_mulVec, vecMul_transpose] + rw [← real_inner_self_eq_norm_sq] + rfl + +omit [DecidableEq ι] in +lemma gram_trace (B : Matrix κ ι ℝ) : (B.transpose*B).trace = squareMass B := by + change (∑ i,∑ j,B j i*B j i) = ∑ i,∑ j,B i j^2 + simp only [← sq] + exact Finset.sum_comm + +lemma norm_sq_le_squareMass (B : Matrix κ ι ℝ) (x : EuclideanSpace ℝ ι) : + ‖matrixMap B x‖^2 ≤ squareMass B*‖x‖^2 := by + rw [EuclideanSpace.real_norm_sq_eq,EuclideanSpace.real_norm_sq_eq] + change (∑ i,(∑ j,B i j*x j)^2) ≤ (∑ i,∑ j,B i j^2)*(∑ j,x j^2) + rw [Finset.sum_mul] + exact Finset.sum_le_sum fun i _ => Finset.sum_mul_sq_le_sq_mul_sq _ _ _ + +lemma matrix_square_tail (B : Matrix κ ι ℝ) {b : ℝ} (hb : 0 < b) + (hB : ∀ x : EuclideanSpace ℝ ι,‖matrixMap B x‖^2 ≤ b*‖x‖^2) (r : ℝ) : + stdGaussian (EuclideanSpace ℝ ι) {x | 2*squareMass B+4*b*r ≤ ‖matrixMap B x‖^2} ≤ + ENNReal.ofReal (Real.exp (-r)) := by + have hA : (B.transpose*B).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using posSemidef_conjTranspose_mul_self B + simpa only [gram_trace,gram_form] using scaled_quadratic_tail hA hb + (fun x => by rw [gram_form]; exact hB x) r + +lemma interpolated_form (B : Matrix κ ι ℝ) {v : ℝ} (hv : 0 ≤ v) + (hS : squareMass B ≤ v) (hB : ∀ x : EuclideanSpace ℝ ι,‖matrixMap B x‖^2 ≤ 4*‖x‖^2) : + ∀ x : EuclideanSpace ℝ ι,‖matrixMap B x‖^2 ≤ (2*Real.sqrt v)*‖x‖^2 := by + intro x + by_cases h : v ≤ 4 + · apply (norm_sq_le_squareMass B x).trans + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + apply hS.trans + have hs := Real.sq_sqrt hv + have hp := Real.sqrt_nonneg v + have hle : Real.sqrt v ≤ 2 := (Real.sqrt_le_iff).mpr ⟨by norm_num,by nlinarith⟩ + nlinarith + · apply (hB x).trans + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + have hs := Real.sq_sqrt hv + have hp := Real.sqrt_nonneg v + have hle : 2 ≤ Real.sqrt v := (Real.le_sqrt (by norm_num) hv).mpr (by linarith) + linarith + +lemma interpolated_tail (B : Matrix κ ι ℝ) {v : ℝ} (hv : 0 < v) + (hS : squareMass B ≤ v) (hB : ∀ x : EuclideanSpace ℝ ι,‖matrixMap B x‖^2 ≤ 4*‖x‖^2) + (r : ℝ) : + stdGaussian (EuclideanSpace ℝ ι) {x | 2*v+8*Real.sqrt v*r ≤ ‖matrixMap B x‖^2} ≤ + ENNReal.ofReal (Real.exp (-r)) := by + apply (measure_mono (show {x | 2*v+8*Real.sqrt v*r ≤ ‖matrixMap B x‖^2} ⊆ + {x | 2*squareMass B+4*(2*Real.sqrt v)*r ≤ ‖matrixMap B x‖^2} from ?_)).trans + · exact matrix_square_tail B (by positivity) (interpolated_form B hv.le hS hB) r + · intro x hx + change 2*v+8*Real.sqrt v*r ≤ ‖matrixMap B x‖^2 at hx + change 2*squareMass B+4*(2*Real.sqrt v)*r ≤ ‖matrixMap B x‖^2 + linarith + +end GaussianTail + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/HeatEnergy.lean b/lean/OAI/Analysis/Steinitz/HeatEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..07ae5ee6966ed6ae323691df05167ad01df10ee1 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/HeatEnergy.lean @@ -0,0 +1,742 @@ +import OAI.Analysis.Steinitz.PathLaws + +namespace OAI + +/-! Survival-energy estimates and simultaneous diagonal separation. -/ + +section + +open MeasureTheory ProbabilityTheory Set +open scoped NNReal ENNReal BigOperators Pointwise +namespace GaussianKernel +variable {ι : Type*} [Fintype ι] + +lemma pdf_scale {s : ℝ≥0} (hs : 0 s^2*v i) ((s:ℝ) • x) = ((s:ℝ)^(Fintype.card ι))⁻¹*density v x := by + simp only [density,PiLp.smul_apply,smul_eq_mul,pdf_scale hs,Finset.prod_mul_distrib, + Finset.prod_const,Finset.card_univ,inv_pow] + +lemma chainWeight_scale {s : ℝ≥0} (hs : 0 s^2*v i)) n ((s:ℝ) • p) = + (((s:ℝ)^(Fintype.card ι))⁻¹)^n*HeatL2.chainWeight (kernel v) n p := by + rw [HeatL2.chainWeight_prod,HeatL2.chainWeight_prod] + change (∏ t : Fin n,density (fun i => s^2*v i) ((s:ℝ)•p t.succ-(s:ℝ)•p t.castSucc))=_ + simp only [← smul_sub,density_scale hs,Finset.prod_mul_distrib,Finset.prod_const, + Finset.card_univ,Fintype.card_fin] + rfl + +omit [Fintype ι] in +lemma pi_smul {T : Type*} (s : ℝ) (hs : s≠0) (D : Set (EuclideanSpace ℝ ι)) : + (univ.pi (fun _ : T => s • D))=s • (univ.pi (fun _ : T => D)) := by + ext p + rw [mem_smul_set_iff_inv_smul_mem₀ hs] + simp only [mem_pi,mem_univ,forall_const,Pi.smul_apply] + exact forall_congr' fun t => mem_smul_set_iff_inv_smul_mem₀ hs D (p t) + +lemma pathMass_scale {s : ℝ≥0} (hs : 0 s^2*v i)) n = + (s:ℝ)^(Fintype.card ι)*HeatL2.pathMass (μ := volume.restrict D) (kernel v) n := by + classical + have hs' : 0<(s:ℝ) := hs + let P : Set (Fin (n+1) → EuclideanSpace ℝ ι) := univ.pi (fun _ => D) + have hh := Measure.setIntegral_comp_smul_of_pos volume + (HeatL2.chainWeight (kernel (fun i => s^2*v i)) n) P hs' + simp only [chainWeight_scale hs,integral_const_mul,smul_eq_mul] at hh + have hdim : Module.finrank ℝ (Fin (n+1) → EuclideanSpace ℝ ι) = (n+1)*Fintype.card ι := by + simp [Module.finrank_pi_fintype] + rw [hdim,show P=univ.pi (fun _ : Fin (n+1) => D) from rfl,← pi_smul (s:ℝ) hs'.ne'] at hh + simp only [volume_pi,Measure.restrict_pi_pi,← HeatL2.pathMass_pi] at hh + have hn : (s:ℝ)^((n+1)*Fintype.card ι)≠0 := pow_ne_zero _ hs'.ne' + apply (mul_left_cancel₀ (a := ((s:ℝ)^((n+1)*Fintype.card ι))⁻¹) (inv_ne_zero hn)) + rw [← hh] + rw [Nat.mul_comm (n+1),pow_mul,pow_succ,mul_inv_rev,← inv_pow] + calc + _ = (((s:ℝ)^(Fintype.card ι))^n)⁻¹*HeatL2.pathMass (μ := volume.restrict D) (kernel v) n * + (((s:ℝ)^(Fintype.card ι))⁻¹*((s:ℝ)^(Fintype.card ι))) := by + rw [inv_mul_cancel₀ (pow_ne_zero _ hs'.ne'),mul_one] + simp only [inv_pow] + _ = _ := by ring + +end GaussianKernel + +end + +section + +open MeasureTheory FourierTransform Set Filter ComplexConjugate +open scoped ENNReal ComplexInnerProductSpace +namespace HeatL2 +section Rate +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma energy_smul (w : E → ℝ) (c : ℂ) (f : Lp ℂ 2 (volume : Measure E)) : + energy w (c • f) = ‖c‖^2 * energy w f := by + unfold energy + rw [fourier_smul, ← integral_const_mul] + apply integral_congr_ae + filter_upwards [Lp.coeFn_smul c (𝓕 f)] with x hx + simp only [hx, Pi.smul_apply, smul_eq_mul, norm_mul, mul_pow] + ring + +lemma supported_smul (D : Set E) {f : Lp ℂ 2 (volume : Measure E)} + (hf : f ∈ supported D) (c : ℂ) : c • f ∈ supported D := by + filter_upwards [hf, Lp.coeFn_smul c f] with x hx he hn + simp only [he, Pi.smul_apply, hx hn, smul_zero] + +lemma form_le_norm (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + {f : Lp ℂ 2 (volume : Measure E)} (hf : f ∈ supported D) : + ‖f‖^2 - energy w f ≤ ‖compressedHeat D hD w hw hn‖ * ‖f‖^2 := by + have hh := (positive_norm_le_iff _ (compressedHeat_positive D hD w hw hn) + (norm_nonneg _)).mp le_rfl f + rwa [compressedHeat_inner, (mask_eq_self_iff D hD f).mpr hf] at hh + +lemma normalized_energy_lt (D : Set E) (w : E → ℝ) + {f : Lp ℂ 2 (volume : Measure E)} (hfD : f ∈ supported D) (hfn : f ≠ 0) + {C : ℝ} (hf : energy w f < C*‖f‖^2) : + ∃ g : Lp ℂ 2 (volume : Measure E), g ∈ supported D ∧ ‖g‖=1 ∧ energy w g < C := by + let c : ℂ := (‖f‖⁻¹ : ℝ) + have hc : ‖c‖ = ‖f‖⁻¹ := by simp [c] + have hnz : ‖f‖ ≠ 0 := norm_ne_zero_iff.mpr hfn + have hnorm : ‖c • f‖ = 1 := by rw [norm_smul, hc, inv_mul_cancel₀ hnz] + refine ⟨c • f, supported_smul D hfD c, hnorm, ?_⟩ + rw [energy_smul, hc] + have hp : 0 < (‖f‖⁻¹)^2 := sq_pos_of_pos (inv_pos.mpr (norm_pos_iff.mpr hfn)) + calc + _ < (‖f‖⁻¹)^2 * (C*‖f‖^2) := mul_lt_mul_of_pos_left hf hp + _ = C*((‖f‖⁻¹)^2*‖f‖^2) := by ring + _ = C := by rw [inv_pow, inv_mul_cancel₀ (pow_ne_zero 2 hnz), mul_one] + +lemma exists_supported_energy_lt (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + {C : ℝ} (hC : 0 ≤ C) (h : C < ‖compressedHeat D hD w hw hn‖) : + ∃ f : Lp ℂ 2 (volume : Measure E), f ∈ supported D ∧ ‖f‖ = 1 ∧ energy w f < 1-C := by + obtain ⟨g,hg⟩ := positive_exists_form_gt _ (compressedHeat_positive D hD w hw hn) hC h + rw [compressedHeat_inner] at hg + let f := mask D hD g + change C * ‖g‖^2 < ‖f‖^2 - energy w f at hg + have hfg : ‖f‖^2 ≤ ‖g‖^2 := sq_le_sq₀ (norm_nonneg _) (norm_nonneg _) |>.mpr (mask_norm_le D hD g) + have hf : energy w f < (1-C)*‖f‖^2 := by + have hh := mul_le_mul_of_nonneg_left hfg hC + nlinarith + have hfn : f ≠ 0 := by + intro he + have := energy_nonneg w hn f + rw [he, norm_zero, zero_pow (by decide : 2 ≠ 0), mul_zero] at hf + rw [he] at this + linarith + exact normalized_energy_lt D w + ((mask_eq_self_iff D hD f).mp (mask_idempotent D hD g)) hfn hf + +lemma exists_energy_lt_of_exp_le (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + {c : ℝ} (h : Real.exp (-c) ≤ ‖compressedHeat D hD w hw hn‖) + {ε : ℝ} (hε : 0 < ε) : + ∃ f : Lp ℂ 2 (volume : Measure E), f ∈ supported D ∧ ‖f‖ = 1 ∧ energy w f < c+ε := by + have he : Real.exp (-(c+ε/2)) < ‖compressedHeat D hD w hw hn‖ := by + apply lt_of_lt_of_le _ h + apply Real.exp_lt_exp.mpr + linarith + obtain ⟨f,hf,hnf,hef⟩ := exists_supported_energy_lt D hD w hw hn + (Real.exp_pos (-(c+ε/2))).le he + refine ⟨f,hf,hnf,hef.trans_le ?_⟩ + have hbound := loss_le_self (c+ε/2) + dsimp [loss] at hbound + linarith + +lemma compressed_norm_le_of_energy (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + {C : ℝ} (hC : 0 ≤ C) + (h : ∀ f : Lp ℂ 2 (volume : Measure E), f ∈ supported D → + ‖f‖=1 → 1 - energy w f ≤ C) : + ‖compressedHeat D hD w hw hn‖ ≤ C := by + by_contra! hg + obtain ⟨f,hf,hfn,hfe⟩ := exists_supported_energy_lt D hD w hw hn hC hg + linarith [h f hf hfn] + +lemma compressed_norm_mono_symbol (D : Set E) (hD : MeasurableSet D) + (w v : E → ℝ) (hw : AEStronglyMeasurable w volume) (hv : AEStronglyMeasurable v volume) + (hwn : ∀ x, 0 ≤ w x) (hvn : ∀ x, 0 ≤ v x) (h : ∀ x, w x ≤ v x) : + ‖compressedHeat D hD v hv hvn‖ ≤ ‖compressedHeat D hD w hw hwn‖ := by + apply compressed_norm_le_of_energy D hD v hv hvn (norm_nonneg _) + intro f hf hfn + have hE : energy w f ≤ energy v f := by + rw [energy,energy] + apply integral_mono (integrable_energy w hw hwn f) (integrable_energy v hv hvn f) + intro x + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + exact sub_le_sub_left (Real.exp_le_exp.mpr (neg_le_neg (h x))) 1 + have hh := form_le_norm D hD w hw hwn hf + rw [hfn, one_pow, mul_one] at hh + linarith + +lemma compressed_norm_mono_domain (D F : Set E) (hD : MeasurableSet D) (hF : MeasurableSet F) + (hDF : D ⊆ F) (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) : + ‖compressedHeat D hD w hw hn‖ ≤ ‖compressedHeat F hF w hw hn‖ := by + apply compressed_norm_le_of_energy D hD w hw hn (norm_nonneg _) + intro f hf hfn + have hfF : f ∈ supported F := by + change ∀ᵐ x, x ∉ F → f x = 0 + change ∀ᵐ x, x ∉ D → f x = 0 at hf + filter_upwards [hf] with x hx hnot + exact hx (fun hxd => hnot (hDF hxd)) + simpa only [hfn,one_pow,mul_one] using form_le_norm F hF w hw hn hfF + +lemma compressed_norm_rpow (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : Measurable w) (hn : ∀ x, 0 ≤ w x) + {t η : ℝ} (hη : 0 < η) (hηt : η ≤ t) : + ‖compressedHeat D hD (fun ξ => η*w ξ) (hw.const_mul η).aestronglyMeasurable + (fun ξ => mul_nonneg hη.le (hn ξ))‖ ^ (t/η) ≤ + ‖compressedHeat D hD (fun ξ => t*w ξ) (hw.const_mul t).aestronglyMeasurable + (fun ξ => mul_nonneg (hη.le.trans hηt) (hn ξ))‖ := by + let A := compressedHeat D hD (fun ξ => η*w ξ) (hw.const_mul η).aestronglyMeasurable + (fun ξ => mul_nonneg hη.le (hn ξ)) + let B := compressedHeat D hD (fun ξ => t*w ξ) (hw.const_mul t).aestronglyMeasurable + (fun ξ => mul_nonneg (hη.le.trans hηt) (hn ξ)) + have hpow : 0 < t/η := div_pos (hη.trans_le hηt) hη + apply (Real.le_rpow_inv_iff_of_pos (norm_nonneg A) (norm_nonneg B) hpow).mp + apply compressed_norm_le_of_energy D hD _ _ _ (Real.rpow_nonneg (norm_nonneg B) _) + intro f hf hfn + have hh := heat_form_rpow w hw hn hη hηt f hfn + have hb := form_le_norm D hD (fun ξ => t*w ξ) (hw.const_mul t).aestronglyMeasurable + (fun ξ => mul_nonneg (hη.le.trans hηt) (hn ξ)) hf + rw [hfn, one_pow, mul_one] at hb + simp only [heat_inner, hfn, one_pow] at hh + have ha : 0 ≤ 1-energy (fun ξ => η*w ξ) f := by + have := energy_le_norm_sq (fun ξ => η*w ξ) (hw.const_mul η).aestronglyMeasurable + (fun ξ => mul_nonneg hη.le (hn ξ)) f + rw [hfn,one_pow] at this + linarith + exact (Real.le_rpow_inv_iff_of_pos ha (norm_nonneg B) hpow).mpr (hh.trans hb) + +lemma heat_form_pos (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + {f : Lp ℂ 2 (volume : Measure E)} (hf : f ≠ 0) : + 0 < (⟪f, heat w hw hn f⟫).re := by + rw [heat_inner_integral] + have hi : Integrable (fun ξ => Real.exp (-w ξ) * ‖(𝓕 f) ξ‖^2) := by + apply integrable_weight _ (Real.continuous_exp.comp_aestronglyMeasurable hw.neg) + (C := 1) _ (𝓕 f) + exact Eventually.of_forall fun ξ => by + rw [abs_of_pos (Real.exp_pos _)] + exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hn ξ)) + have hp ξ : 0 ≤ Real.exp (-w ξ) * ‖(𝓕 f) ξ‖^2 := by positivity + apply lt_of_le_of_ne (integral_nonneg hp) + intro he + have ha := (integral_eq_zero_iff_of_nonneg hp hi).mp he.symm + have hsq : (fun ξ => ‖(𝓕 f) ξ‖^2) =ᵐ[volume] 0 := by + filter_upwards [ha] with ξ hξ + exact (mul_eq_zero.mp hξ).resolve_left (Real.exp_ne_zero _) + have hz : ‖f‖^2 = 0 := by + rw [← Lp.norm_fourier_eq f, norm_sq_integral, integral_congr_ae hsq] + simp only [Pi.zero_apply, integral_zero] + exact (sq_pos_of_pos (norm_pos_iff.mpr hf)).ne' hz + +lemma compressed_norm_pos_of_supported (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + {f : Lp ℂ 2 (volume : Measure E)} (hf : f ∈ supported D) (hfn : f ≠ 0) : + 0 < ‖compressedHeat D hD w hw hn‖ := by + have hh := form_le_norm D hD w hw hn hf + have hp := heat_form_pos w hw hn hfn + rw [heat_inner] at hp + have : 0 < ‖compressedHeat D hD w hw hn‖ * ‖f‖^2 := hp.trans_le hh + exact pos_of_mul_pos_left this (sq_nonneg _) + +lemma oneLp_norm_sq {X : Type*} [MeasurableSpace X] {μ : Measure X} [IsFiniteMeasure μ] : + ‖(oneLp : Lp ℂ 2 μ)‖^2 = (μ univ).toReal := by + rw [norm_sq_integral] + calc + _ = ∫ _ : X, (1:ℝ) ∂μ := by + apply integral_congr_ae + filter_upwards [oneLp_coe (μ := μ)] with x hx + simp only [hx, norm_one, one_pow] + _ = _ := by simp [Measure.real] + +lemma compressed_norm_pos (D : Set E) (hD : MeasurableSet D) + [IsFiniteMeasure (volume.restrict D)] (hDp : 0 < volume D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) : + 0 < ‖compressedHeat D hD w hw hn‖ := by + apply compressed_norm_pos_of_supported D hD w hw hn (extendLp_supported D hD oneLp) + intro hz + have he := extendLp_norm D hD (oneLp : Lp ℂ 2 (volume.restrict D)) + rw [hz, norm_zero] at he + have hp : (0:ℝ) < (volume D).toReal := + ENNReal.toReal_pos hDp.ne' (by simpa only [Measure.restrict_apply_univ] using (measure_ne_top (volume.restrict D) univ)) + have hs := oneLp_norm_sq (μ := volume.restrict D) + rw [Measure.restrict_apply_univ, ← he, zero_pow (by decide : 2 ≠ 0)] at hs + linarith + +end Rate +end HeatL2 + +end + +section + +open Set Finset + +namespace EuclideanSteinitz + +lemma functional_eq_sum {ι : Type*} [Fintype ι] [DecidableEq ι] + (L : (ι → ℝ) →L[ℝ] ℝ) (x : ι → ℝ) : + L x = ∑ i, L (Pi.single i 1) * x i := by + have he : x = ∑ i, x i • Pi.single i 1 := by + ext j + simp [Finset.sum_apply, Pi.single_apply, apply_ite] + conv_lhs => rw [he, map_sum] + apply Finset.sum_congr rfl + intro i _ + rw [map_smul, smul_eq_mul, mul_comm] + +lemma simultaneous_approx {ι F : Type*} [Fintype ι] [Nonempty F] + (E : F → ι → ℝ) (c : ℝ) + (hconv : ∀ f g : F, ∀ t ∈ Icc (0:ℝ) 1, ∃ h : F, + ∀ i, E h i ≤ t * E f i + (1-t) * E g i) + (hweighted : ∀ q : ι → ℝ, (∀ i, 0 ≤ q i) → ∀ δ > 0, + ∃ f : F, ∑ i, q i * E f i < c * ∑ i, q i + δ) + (ε : ℝ) (hε : 0 < ε) : ∃ f : F, ∀ i, E f i < c + ε := by + classical + let A : Set (ι → ℝ) := {u | ∃ f : F, ∀ i, E f i < u i} + have hA : Convex ℝ A := by + intro u hu v hv a b ha hb hab + obtain ⟨f, hf⟩ := hu + obtain ⟨g, hg⟩ := hv + obtain ⟨h, hh⟩ := hconv f g a ⟨ha, by linarith⟩ + refine ⟨h, fun i => ?_⟩ + have hstrict : a * E f i + b * E g i < a * u i + b * v i := by + rcases eq_or_lt_of_le ha with hzero | hap + · have ha0 : a = 0 := hzero.symm + simp only [ha0, zero_add] at hab + simp only [ha0, zero_mul, zero_add, hab, one_mul] + exact hg i + · have hf' := mul_lt_mul_of_pos_left (hf i) hap + have hg' := mul_le_mul_of_nonneg_left (hg i).le hb + linarith + change E h i < a * u i + b * v i + have : 1-a=b := by linarith + rw [this] at hh + exact (hh i).trans_lt hstrict + have hAo : IsOpen A := by + have he : A = ⋃ f : F, ⋂ i : ι, {u : ι → ℝ | E f i < u i} := by + ext u + simp only [A, mem_ofPred_eq, mem_iUnion, mem_iInter] + rw [he] + apply isOpen_iUnion + intro f + apply isOpen_iInter_of_finite + intro i + exact isOpen_lt continuous_const (continuous_apply i) + let x : ι → ℝ := fun _ => c+ε + by_contra hn + have hx : x ∉ A := hn + obtain ⟨L, hL⟩ := geometric_hahn_banach_point_open hA hAo hx + let q : ι → ℝ := fun i => L (Pi.single i 1) + have hne : A.Nonempty := by + obtain ⟨f⟩ := ‹Nonempty F› + exact ⟨fun i => E f i+1, f, fun _ => by linarith⟩ + obtain ⟨u, hu⟩ := hne + have hq : ∀ i, 0 ≤ q i := by + intro i + by_contra hneg + have hqi : q i < 0 := lt_of_not_ge hneg + let r := (L u - L x + 1) / (-q i) + have hr : 0 ≤ r := by + apply div_nonneg + · linarith [hL u hu] + · exact neg_nonneg.mpr hqi.le + have huv : u + r • Pi.single i 1 ∈ A := by + obtain ⟨f, hf⟩ := hu + refine ⟨f, fun j => (hf j).trans_le ?_⟩ + change u j ≤ u j + r * (Pi.single i (1:ℝ) : ι → ℝ) j + have hs : 0 ≤ (Pi.single i (1:ℝ) : ι → ℝ) j := by simp only [Pi.single_apply]; split_ifs <;> norm_num + exact le_add_of_nonneg_right (mul_nonneg hr hs) + have hxv := hL _ huv + rw [map_add, map_smul, smul_eq_mul] at hxv + change L x < L u + r * q i at hxv + have hri : r * q i = -(L u-L x+1) := by + dsimp [r] + field_simp [ne_of_lt hqi] + linarith + have hsum : 0 < ∑ i, q i := by + have hnon := Finset.sum_nonneg (fun i (_ : i ∈ (Finset.univ : Finset ι)) => hq i) + by_contra hzero + have hz : ∑ i, q i = 0 := le_antisymm (le_of_not_gt hzero) hnon + have hqi : ∀ i, q i = 0 := by + intro i + exact (Finset.sum_eq_zero_iff_of_nonneg (fun j (_ : j ∈ (Finset.univ : Finset ι)) => hq j)).mp hz i (mem_univ _) + have hLu : L u = 0 := by rw [functional_eq_sum]; simp only [← show ∀ i, q i = L (Pi.single i 1) from fun _ => rfl, hqi, zero_mul, Finset.sum_const_zero] + have hLx : L x = 0 := by rw [functional_eq_sum]; simp only [← show ∀ i, q i = L (Pi.single i 1) from fun _ => rfl, hqi, zero_mul, Finset.sum_const_zero] + linarith [hL u hu] + obtain ⟨f, hf⟩ := hweighted q hq (ε*(∑ i, q i)/2) (by positivity) + let v : ι → ℝ := fun i => E f i + ε/2 + have hv : v ∈ A := ⟨f, fun _ => by dsimp [v]; linarith⟩ + have hvx := hL v hv + have hLx : L x = (c+ε) * ∑ i, q i := by + rw [functional_eq_sum] + change (∑ i, q i * (c+ε)) = _ + rw [← Finset.sum_mul, mul_comm] + have hLv : L v = (∑ i, q i * E f i) + (ε/2) * ∑ i, q i := by + rw [functional_eq_sum] + change (∑ i, q i * (E f i+ε/2)) = _ + simp only [mul_add, Finset.sum_add_distrib, ← Finset.sum_mul] + ring + rw [hLx, hLv] at hvx + linarith + +end EuclideanSteinitz + +end + +section + +open MeasureTheory FourierTransform Set Filter ComplexConjugate +open scoped ENNReal NNReal ComplexInnerProductSpace +namespace HeatL2 +section +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +lemma mixture_gaussian_energy_le (A : F →L[ℝ] E) (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) + (f g : Lp ℂ 2 (volume : Measure E)) : + energy (gaussianSymbol A) (mixture t ht ht' f g) ≤ + t * energy (gaussianSymbol A) f + (1-t) * energy (gaussianSymbol A) g := by + simp only [gaussian_energy_difference] + have hh := integral_mono + (integrable_difference_sq A (ProbabilityTheory.stdGaussian F) (mixture t ht ht' f g)) + (((integrable_difference_sq A (ProbabilityTheory.stdGaussian F) f).const_mul t).add + ((integrable_difference_sq A (ProbabilityTheory.stdGaussian F) g).const_mul (1-t))) + (fun z => mixture_translation_sq_le t ht ht' f g (A z)) + simp only [Pi.add_apply] at hh + rw [integral_add ((integrable_difference_sq A _ f).const_mul t) + ((integrable_difference_sq A _ g).const_mul (1-t)), integral_const_mul, integral_const_mul] at hh + linarith + +end + +section +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma mixture_diagonal_energy_le (v : ι → ℝ≥0) (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) + (f g : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι))) : + energy (GaussianKernel.symbol v) (mixture t ht ht' f g) ≤ + t * energy (GaussianKernel.symbol v) f + (1-t) * energy (GaussianKernel.symbol v) g := by + rw [← GaussianKernel.symbol_eq] + exact mixture_gaussian_energy_le _ t ht ht' f g + +end +end HeatL2 + +end + +section + +open MeasureTheory Set Filter +open scoped ENNReal NNReal ComplexInnerProductSpace +namespace HeatL2 +namespace Diagonal +variable {ι : Type*} [Fintype ι] + +noncomputable def coordSymbol (i : ι) (ξ : EuclideanSpace ℝ ι) : ℝ := (2*Real.pi*ξ i)^2 +omit [Fintype ι] in +lemma coordSymbol_nonneg (i : ι) (ξ : EuclideanSpace ℝ ι) : 0 ≤ coordSymbol i ξ := sq_nonneg _ +omit [Fintype ι] in +lemma coordSymbol_continuous (i : ι) : Continuous (coordSymbol i) := by + unfold coordSymbol + fun_prop + +lemma symbol_single [DecidableEq ι] (i : ι) (η : ℝ≥0) : + GaussianKernel.symbol (Pi.single i (2*η)) = fun ξ => (η:ℝ)*coordSymbol i ξ := by + ext ξ + simp only [GaussianKernel.symbol, coordSymbol, Pi.single_apply, apply_ite, + NNReal.coe_mul, NNReal.coe_ofNat, NNReal.coe_zero, ite_mul, zero_mul, + Finset.sum_ite_eq', Finset.mem_univ, ite_true] + ring + +def Bound (D : Set (EuclideanSpace ℝ ι)) (hD : MeasurableSet D) (c : ℝ) : Prop := + ∀ v : ι → ℝ≥0, Real.exp (-(c/2) * ∑ i, (v i:ℝ)) ≤ + ‖compressedHeat D hD (GaussianKernel.symbol v) + (GaussianKernel.symbol_continuous v).aestronglyMeasurable (GaussianKernel.symbol_nonneg v)‖ + +lemma exists_unit_of_bound {D : Set (EuclideanSpace ℝ ι)} {hD : MeasurableSet D} {c : ℝ} + (h : Bound D hD c) : + ∃ f : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι)), f ∈ supported D ∧ ‖f‖ = 1 := by + have hb := h 0 + simp only [Pi.zero_apply, NNReal.coe_zero, Finset.sum_const_zero, mul_zero] at hb + obtain ⟨f,hf,hn,_⟩ := exists_energy_lt_of_exp_le D hD _ + (GaussianKernel.symbol_continuous 0).aestronglyMeasurable + (GaussianKernel.symbol_nonneg 0) (c := 0) (by simpa only [neg_zero] using hb) (ε := 1) (by norm_num) + exact ⟨f,hf,hn⟩ + +lemma symbol_mean (η : ℝ) (hη : 0 ≤ η) (q : ι → ℝ) (hq : ∀ i, 0 ≤ q i) : + GaussianKernel.symbol (fun i => ⟨2*η*q i, mul_nonneg (mul_nonneg (by norm_num) hη) (hq i)⟩) = + fun ξ => ∑ i, q i * (η*coordSymbol i ξ) := by + ext ξ + unfold GaussianKernel.symbol coordSymbol + change (∑ i, (2*η*q i)*(2*Real.pi*ξ i)^2)/2 = _ + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro i _ + ring + +lemma coord_mixture_energy_le [DecidableEq ι] (i : ι) (η : ℝ) (hη : 0 ≤ η) + (t : ℝ) (ht : t ∈ Icc (0:ℝ) 1) + (f g : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι))) : + energy (fun ξ => η*coordSymbol i ξ) (mixture t ht.1 ht.2 f g) ≤ + t*energy (fun ξ => η*coordSymbol i ξ) f + + (1-t)*energy (fun ξ => η*coordSymbol i ξ) g := by + let ηn : ℝ≥0 := ⟨η,hη⟩ + have hh := mixture_diagonal_energy_le (Pi.single i (2*ηn)) t ht.1 ht.2 f g + rw [symbol_single i ηn] at hh + exact hh + +lemma simultaneous_coordinate_energy {D : Set (EuclideanSpace ℝ ι)} {hD : MeasurableSet D} + {c : ℝ} (hB : Bound D hD c) {η ε : ℝ} (hη : 0 < η) (hε : 0 < ε) : + ∃ f : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι)), + f ∈ supported D ∧ ‖f‖ = 1 ∧ ∀ i, energy (fun ξ => η*coordSymbol i ξ) f < η*(c+ε) := by + classical + let F := {f : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι)) | f ∈ supported D ∧ ‖f‖ = 1} + obtain ⟨f₀,hf₀,hn₀⟩ := exists_unit_of_bound hB + let fzero : F := ⟨f₀,hf₀,hn₀⟩ + let : Nonempty F := ⟨fzero⟩ + let E : F → ι → ℝ := fun f i => energy (fun ξ => η*coordSymbol i ξ) f.val + have hconv : ∀ f g : F, ∀ t ∈ Icc (0:ℝ) 1, ∃ h : F, + ∀ i, E h i ≤ t*E f i+(1-t)*E g i := by + intro f g t ht + let m := mixture t ht.1 ht.2 f.val g.val + have hm : ‖m‖=1 := by + have hh := mixture_norm_sq t ht.1 ht.2 f.val g.val + rw [f.property.2,g.property.2,one_pow] at hh + change ‖m‖^2 = _ at hh + nlinarith [norm_nonneg m] + refine ⟨⟨m,mixture_supported D t ht.1 ht.2 f.val g.val f.property.1 g.property.1,hm⟩,?_⟩ + intro i + exact coord_mixture_energy_le i η hη.le t ht f.val g.val + have hweighted : ∀ q : ι → ℝ, (∀ i,0 ≤ q i) → ∀ δ > 0, + ∃ f : F, ∑ i, q i*E f i < (η*c)*∑ i,q i+δ := by + intro q hq δ hδ + let S := ∑ i,q i + have hSn : 0 ≤ S := Finset.sum_nonneg (fun i _ => hq i) + by_cases hS : S=0 + · have hq0 : ∀ i,q i=0 := fun i => + (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => hq j)).mp hS i (Finset.mem_univ i) + refine ⟨fzero,?_⟩ + simpa only [hq0,zero_mul,Finset.sum_const_zero,mul_zero,zero_add] using hδ + have hSp : 0 < S := lt_of_le_of_ne hSn (Ne.symm hS) + let p : ι → ℝ := fun i => q i/S + have hp : ∀ i,0 ≤ p i := fun i => div_nonneg (hq i) hSn + have hpsum : ∑ i,p i=1 := by + dsimp [p] + rw [← Finset.sum_div] + exact div_self hS + let v : ι → ℝ≥0 := fun i => ⟨2*η*p i,mul_nonneg (mul_nonneg (by norm_num) hη.le) (hp i)⟩ + have hvsum : ∑ i,(v i:ℝ)=2*η := by + change (∑ i,(2*η)*p i)=2*η + rw [← Finset.mul_sum,hpsum,mul_one] + have hv := hB v + rw [hvsum] at hv + have he : -(c/2)*(2*η)=-(η*c) := by ring + rw [he] at hv + obtain ⟨f,hf,hn,henergy⟩ := exists_energy_lt_of_exp_le D hD (GaussianKernel.symbol v) + (GaussianKernel.symbol_continuous v).aestronglyMeasurable (GaussianKernel.symbol_nonneg v) + hv (div_pos hδ hSp) + have hmean := energy_mean_ge Finset.univ p (fun i ξ => η*coordSymbol i ξ) + (fun i _ => hp i) hpsum + (fun i _ => ((coordSymbol_continuous i).const_mul η).aestronglyMeasurable) + (fun i _ ξ => mul_nonneg hη.le (coordSymbol_nonneg i ξ)) f + have hve : GaussianKernel.symbol v = fun ξ => ∑ i,p i*(η*coordSymbol i ξ) := + symbol_mean η hη.le p hp + rw [← hve] at hmean + have hsum : ∑ i,q i*energy (fun ξ => η*coordSymbol i ξ) f = + S*(∑ i,p i*energy (fun ξ => η*coordSymbol i ξ) f) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + dsimp [p] + field_simp + refine ⟨⟨f,hf,hn⟩,?_⟩ + change (∑ i,q i*energy (fun ξ => η*coordSymbol i ξ) f) < (η*c)*S+δ + rw [hsum] + have hh := mul_lt_mul_of_pos_left (hmean.trans_lt henergy) hSp + have hcancel : S*(η*c+δ/S)=(η*c)*S+δ := by field_simp + exact hh.trans_eq hcancel + obtain ⟨f,hf⟩ := EuclideanSteinitz.simultaneous_approx E (η*c) hconv hweighted (η*ε) + (mul_pos hη hε) + refine ⟨f.val,f.property.1,f.property.2,fun i => ?_⟩ + simpa only [mul_add] using hf i + +end Diagonal +end HeatL2 + +end + +section + +open MeasureTheory Set Filter +open scoped NNReal Topology +namespace HeatL2.Diagonal +variable {ι : Type*} [Fintype ι] + +lemma symbol_mono {v w : ι → ℝ≥0} (h : ∀ i,v i≤w i) (ξ : EuclideanSpace ℝ ι) : + GaussianKernel.symbol v ξ ≤ GaussianKernel.symbol w ξ := by + unfold GaussianKernel.symbol + exact div_le_div_of_nonneg_right (Finset.sum_le_sum fun i _ => + mul_le_mul_of_nonneg_right (h i) (sq_nonneg _)) (by norm_num) + +lemma bound_of_positive {D : Set (EuclideanSpace ℝ ι)} {hD : MeasurableSet D} {c : ℝ} + (h : ∀ v : ι → ℝ≥0, (∀ i,0 Real.exp (-(c/2)*∑ i,((v i:ℝ)+ε))) (𝓝[>] 0) + (𝓝 (Real.exp (-(c/2)*∑ i,(v i:ℝ)))) := by + have hh : Continuous (fun ε : ℝ => Real.exp (-(c/2)*∑ i,((v i:ℝ)+ε))) := by fun_prop + simpa using (hh.continuousAt (x := 0)).tendsto.mono_left nhdsWithin_le_nhds + apply le_of_tendsto ht + filter_upwards [self_mem_nhdsWithin] with ε hε + have hε' : 0<ε := hε + let w : ι → ℝ≥0 := fun i => ⟨(v i:ℝ)+ε,by positivity⟩ + have hp := h w (fun i => by change 0<(v i:ℝ)+ε; positivity) + exact hp.trans (compressed_norm_mono_symbol D hD _ _ + (GaussianKernel.symbol_continuous v).aestronglyMeasurable + (GaussianKernel.symbol_continuous w).aestronglyMeasurable + (GaussianKernel.symbol_nonneg v) (GaussianKernel.symbol_nonneg w) + (symbol_mono (fun i => by change (v i:ℝ)≤(v i:ℝ)+ε; linarith))) + +lemma Bound.mono_const {D : Set (EuclideanSpace ℝ ι)} {hD : MeasurableSet D} {c d : ℝ} + (h : Bound D hD c) (hcd : c≤d) : Bound D hD d := by + intro v + exact (Real.exp_le_exp.mpr (by + have hh : 0≤∑ i,(v i:ℝ) := Finset.sum_nonneg fun i _ => (v i).coe_nonneg + nlinarith)).trans (h v) + +end HeatL2.Diagonal + +end + +section + +open Matrix MeasureTheory ProbabilityTheory Set +open scoped RealInnerProductSpace NNReal ENNReal Pointwise +namespace GaussianAR +open GaussianKernel HeatL2 GaussianTail +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma scaled_kernel_norm_of_survival {s : ℝ≥0} (hs : 0 s^2*w i))‖ := by + have hρ : 0 < density (fun _ : ι => 1) 0 := density_pos _ (fun _ => by simp) _ + have hc : 0 < ∏ i,(Real.sqrt (r i))⁻¹ := Finset.prod_pos fun i _ => + inv_pos.mpr (Real.sqrt_pos.mpr (hr i)) + have hs' : 0<(s:ℝ) := hs + apply norm_lower_of_pathMass_lower (kernel (fun i => s^2*w i)) (by positivity) + (c := (s:ℝ)^(Fintype.card ι)*Real.exp (-a)/density (fun _ : ι => 1) 0) (by positivity) + intro n + rw [pathMass_scale hs w D hD n] + have hn := (hsurv n).trans (survival_le_pathMass r hr hr1 w hw D hD n) + have hex : Real.exp (-a-b*n)=Real.exp (-a)*(Real.exp (-b))^n := by + rw [show -a-b*(n:ℝ)= -a+(-b)*n by ring,Real.exp_add,mul_comm (-b),Real.exp_nat_mul] + rw [hex] at hn + have hl : Real.exp (-a)/density (fun _ : ι => 1) 0 * + (Real.exp (-b)/(∏ i,(Real.sqrt (r i))⁻¹))^n ≤ pathMass (μ := volume.restrict D) (kernel w) n := by + apply (mul_le_mul_iff_left₀ (mul_pos hρ (pow_pos hc n))).mp + convert hn using 1 + · calc + _ = (Real.exp (-a)/density (fun _ : ι => 1) 0 * density (fun _ : ι => 1) 0) * + ((Real.exp (-b))^n/(∏ i,(Real.sqrt (r i))⁻¹)^n * (∏ i,(Real.sqrt (r i))⁻¹)^n) := by + rw [div_pow]; ring + _ = _ := by rw [div_mul_cancel₀ _ hρ.ne',div_mul_cancel₀ _ (pow_ne_zero n hc.ne')] + · ring + simpa only [div_eq_mul_inv,mul_assoc] using + mul_le_mul_of_nonneg_left hl (pow_nonneg hs'.le (Fintype.card ι)) + +lemma decay_sqrt_bound {q : ℝ} (_hq : 0 ≤ q) : + (Real.sqrt ((1+q)⁻¹))⁻¹ ≤ Real.exp (q/2) := by + rw [Real.sqrt_inv,inv_inv,Real.exp_half] + exact Real.sqrt_le_sqrt (by linarith [Real.add_one_le_exp q]) + +lemma dilated_bound_of_survival {s : ℝ≥0} (hs : 0 (1+q i)⁻¹) n t) x ∈ D}) : + HeatL2.Diagonal.Bound ((s:ℝ) • D) hDs ((2*B+1)/(s:ℝ)^2) := by + apply HeatL2.Diagonal.bound_of_positive + intro v hv + have hs' : 0<(s:ℝ) := hs + let q : ι → ℝ := fun i => (v i:ℝ)/(s:ℝ)^2 + have hq : ∀ i,0 div_pos (hv i) (sq_pos_of_pos hs') + let r : ι → ℝ := fun i => (1+q i)⁻¹ + have hr : ∀ i,0 inv_pos.mpr (by linarith [hq i]) + have hr1 : ∀ i,r i<1 := fun i => (inv_lt_one₀ (by linarith [hq i])).mpr (by linarith [hq i]) + let w : ι → ℝ≥0 := fun i => ⟨(1-(r i)^2)/r i,div_nonneg (by nlinarith [hr i,hr1 i]) (hr i).le⟩ + have hw : ∀ i,0 by change 0<(1-(r i)^2)/r i; exact div_pos (by nlinarith [hr i,hr1 i]) (hr i) + have hvar : ∀ i,v i≤ s^2*w i := by + intro i + change (v i:ℝ)≤(s:ℝ)^2*((1-(r i)^2)/r i) + have he : (1-(r i)^2)/r i=q i*(2+q i)/(1+q i) := by + dsimp only [r] + field_simp [ne_of_gt (show 0<1+q i by linarith [hq i])] + ring + rw [he] + have hqq : q i ≤ q i*(2+q i)/(1+q i) := by + apply (le_div_iff₀ (by linarith [hq i])).mpr + nlinarith [hq i] + have hh := mul_le_mul_of_nonneg_left hqq (sq_nonneg (s:ℝ)) + simpa only [q,mul_div_cancel₀ _ (ne_of_gt (sq_pos_of_pos hs'))] using hh + obtain ⟨a,ha⟩ := hsurv q hq + have hn := scaled_kernel_norm_of_survival hs r hr hr1 w (fun _ => rfl) D hD a + (B*(∑ i,q i)) (by simpa only [mul_assoc] using ha) + rw [kernel_norm_eq _ (fun i => mul_ne_zero (pow_ne_zero _ hs.ne') (ne_of_gt (hw i))) _ hDs] at hn + have hc : ∏ i,(Real.sqrt (r i))⁻¹ ≤ Real.exp ((∑ i,q i)/2) := by + calc + _ ≤ ∏ i,Real.exp (q i/2) := Finset.prod_le_prod₀ (fun i _ => by positivity) (fun i _ => decay_sqrt_bound (hq i).le) + _ = _ := by rw [← Real.exp_sum]; congr 1; rw [Finset.sum_div] + have hcp : 0<∏ i,(Real.sqrt (r i))⁻¹ := Finset.prod_pos fun i _ => by positivity + have he : Real.exp (-(((2*B+1)/(s:ℝ)^2)/2)*(∑ i,(v i:ℝ))) = + Real.exp (-(B*(∑ i,q i)))/Real.exp ((∑ i,q i)/2) := by + rw [← Real.exp_sub] + congr 1 + simp only [q,← Finset.sum_div] + field_simp + ring + rw [he] + exact (div_le_div_of_nonneg_left (Real.exp_pos _).le hcp hc).trans (hn.trans + (compressed_norm_mono_symbol _ hDs _ _ (symbol_continuous v).aestronglyMeasurable + (symbol_continuous (fun i => s^2*w i)).aestronglyMeasurable (symbol_nonneg v) + (symbol_nonneg _) (HeatL2.Diagonal.symbol_mono hvar))) + +end GaussianAR + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/HeatL2.lean b/lean/OAI/Analysis/Steinitz/HeatL2.lean new file mode 100644 index 0000000000000000000000000000000000000000..7578cfd04c47e8870338d8a95db70994555c6f73 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/HeatL2.lean @@ -0,0 +1,1631 @@ +import OAI.Analysis.Steinitz.GaussianKernel + +namespace OAI + +/-! Heat operators, weak coordinate derivatives, and Dirichlet energy. -/ + +section + +open MeasureTheory FourierTransform Filter ComplexConjugate +open scoped Topology ComplexInnerProductSpace + +namespace HeatL2 + +section Multiplier +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +lemma memLp_mul_bounded (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) (f : Lp ℂ 2 μ) : + MemLp (fun x => m x * f x) 2 μ := by + apply (Lp.memLp f).of_le_mul (c := C) (hm.mul (Lp.aestronglyMeasurable f)) + filter_upwards [hb] with x hx + simp only [Pi.mul_apply, norm_mul] + exact mul_le_mul_of_nonneg_right hx (norm_nonneg _) + +noncomputable def mulLp (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) (f : Lp ℂ 2 μ) : Lp ℂ 2 μ := + (memLp_mul_bounded m hm hb f).toLp _ + +lemma mulLp_coe (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) (f : Lp ℂ 2 μ) : + (mulLp m hm hb f : X → ℂ) =ᵐ[μ] fun x => m x * f x := MemLp.coeFn_toLp _ + +noncomputable def mulLinear (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) : Lp ℂ 2 μ →ₗ[ℂ] Lp ℂ 2 μ where + toFun := mulLp m hm hb + map_add' f g := by + apply Lp.ext + filter_upwards [mulLp_coe m hm hb (f+g), mulLp_coe m hm hb f, + mulLp_coe m hm hb g, Lp.coeFn_add f g, Lp.coeFn_add (mulLp m hm hb f) (mulLp m hm hb g)] with x h₁ h₂ h₃ h₄ h₅ + simp only [Pi.add_apply] at h₄ h₅ + rw [h₁, h₄, h₅, h₂, h₃, mul_add] + map_smul' c f := by + apply Lp.ext + filter_upwards [mulLp_coe m hm hb (c • f), mulLp_coe m hm hb f, + Lp.coeFn_smul c f, Lp.coeFn_smul c (mulLp m hm hb f)] with x h₁ h₂ h₃ h₄ + simp only [Pi.smul_apply, smul_eq_mul] at h₃ h₄ + simp only [RingHom.id_apply] + rw [h₁, h₃, h₄, h₂] + ring + +lemma mulLp_norm_le (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) (f : Lp ℂ 2 μ) : + ‖mulLp m hm hb f‖ ≤ C * ‖f‖ := by + apply Lp.norm_le_mul_norm_of_ae_le_mul + filter_upwards [mulLp_coe m hm hb f, hb] with x hx hbx + rw [hx, norm_mul] + exact mul_le_mul_of_nonneg_right hbx (norm_nonneg _) + +noncomputable def mulOp (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) : Lp ℂ 2 μ →L[ℂ] Lp ℂ 2 μ := + (mulLinear m hm hb).mkContinuous C (mulLp_norm_le m hm hb) + +lemma mulOp_coe (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) (f : Lp ℂ 2 μ) : + (mulOp m hm hb f : X → ℂ) =ᵐ[μ] fun x => m x * f x := mulLp_coe m hm hb f + +lemma mulOp_norm_le (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hC : 0 ≤ C) (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) : ‖mulOp m hm hb‖ ≤ C := + LinearMap.mkContinuous_norm_le _ hC _ + +lemma norm_sq_integral (f : Lp ℂ 2 μ) : ‖f‖^2 = ∫ x, ‖f x‖^2 ∂μ := by + have he := L2.inner_def (𝕜 := ℂ) f f + simp only [inner_self_eq_norm_sq_to_K] at he + change (‖f‖ : ℂ)^2 = ∫ x, (‖f x‖ : ℂ)^2 ∂μ at he + simp only [← Complex.ofReal_pow, integral_complex_ofReal] at he + exact Complex.ofReal_injective he + +lemma inner_mulOp (m : X → ℂ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖m x‖ ≤ C) (f g : Lp ℂ 2 μ) : + ⟪f, mulOp m hm hb g⟫ = ∫ x, m x * (g x * conj (f x)) ∂μ := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [mulOp_coe m hm hb g] with x hx + rw [hx] + simp only [RCLike.inner_apply] + ring + +lemma inner_real_mulOp (m : X → ℝ) (hm : AEStronglyMeasurable m μ) + {C : ℝ} (hb : ∀ᵐ x ∂μ, ‖(m x : ℂ)‖ ≤ C) (f : Lp ℂ 2 μ) : + (⟪f, mulOp (fun x => (m x : ℂ)) (Complex.continuous_ofReal.comp_aestronglyMeasurable hm) hb f⟫).re = + ∫ x, m x * ‖f x‖^2 ∂μ := by + rw [inner_mulOp] + have he : (fun x => (m x : ℂ) * (f x * conj (f x))) = + fun x => ((m x * ‖f x‖^2 : ℝ) : ℂ) := by + ext x + rw [RCLike.mul_conj] + simp + rw [he, integral_complex_ofReal] + rfl + +end Multiplier +end HeatL2 + +namespace HeatL2 +section Translation +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +noncomputable def translate (a : E) : Lp ℂ 2 (volume : Measure E) →ₗᵢ[ℂ] Lp ℂ 2 (volume : Measure E) := + Lp.compMeasurePreservingₗᵢ ℂ (fun x => x + a) (measurePreserving_add_right volume a) + +lemma translate_coe (a : E) (f : Lp ℂ 2 (volume : Measure E)) : + (translate a f : E → ℂ) =ᵐ[volume] fun x => f (x+a) := + Lp.coeFn_compMeasurePreserving f (measurePreserving_add_right volume a) + +noncomputable def phase (a ξ : E) : ℂ := Real.fourierChar (inner ℝ a ξ) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma phase_continuous (a : E) : Continuous (phase a) := + (continuous_subtype_val.comp Real.continuous_fourierChar).comp (continuous_const.inner continuous_id) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma phase_norm (a ξ : E) : ‖phase a ξ‖ = 1 := Circle.norm_coe _ + +noncomputable def phaseOp (a : E) : Lp ℂ 2 (volume : Measure E) →L[ℂ] Lp ℂ 2 (volume : Measure E) := + mulOp (phase a) (phase_continuous a).aestronglyMeasurable + (Filter.Eventually.of_forall fun ξ => (phase_norm a ξ).le) + +lemma phaseOp_coe (a : E) (f : Lp ℂ 2 (volume : Measure E)) : + (phaseOp a f : E → ℂ) =ᵐ[volume] fun ξ => phase a ξ * (f : E → ℂ) ξ := + mulOp_coe _ _ _ _ + +lemma translate_schwartz (a : E) (f : SchwartzMap E ℂ) : + translate a (f.toLp 2) = (SchwartzMap.compSubConstCLM ℂ (-a) f).toLp 2 := by + apply Lp.ext + filter_upwards [translate_coe a (f.toLp 2), + (measurePreserving_add_right volume a).quasiMeasurePreserving.ae_eq_comp (f.coeFn_toLp 2), + (SchwartzMap.compSubConstCLM ℂ (-a) f).coeFn_toLp 2] with x h₁ h₂ h₃ + simpa only [h₁, h₃, Function.comp_apply, SchwartzMap.compSubConstCLM_apply, sub_neg_eq_add] using h₂ + +lemma schwartz_fourier_translate (a : E) (f : SchwartzMap E ℂ) : + ∀ ξ, (𝓕 (SchwartzMap.compSubConstCLM ℂ (-a) f)) ξ = phase a ξ * (𝓕 f) ξ := by + intro ξ + have he := congrFun (VectorFourier.fourierIntegral_comp_add_right + Real.fourierChar volume (innerₗ E) (f : E → ℂ) a) ξ + change (∫ x, Real.fourierChar (-inner ℝ x ξ) • f (x+a)) = _ at he + change (∫ x, Real.fourierChar (-inner ℝ x ξ) • f (x - -a)) = + phase a ξ * (∫ x, Real.fourierChar (-inner ℝ x ξ) • f x) + simpa only [sub_neg_eq_add, Circle.smul_def, smul_eq_mul, phase, innerₗ_apply_apply, + VectorFourier.fourierIntegral] using he + +lemma fourier_translate (a : E) (f : Lp ℂ 2 (volume : Measure E)) : + 𝓕 (translate a f) = phaseOp a (𝓕 f) := by + refine (SchwartzMap.denseRange_toLpCLM (E := E) (F := ℂ) (p := 2) (μ := (volume : Measure E)) ENNReal.ofNat_ne_top).induction_on + (p := fun g => 𝓕 (translate a g) = phaseOp a (𝓕 g)) f ?_ ?_ + · exact isClosed_eq (continuous_fourier.comp (translate a).continuous) + ((phaseOp a).continuous.comp continuous_fourier) + · intro g + change 𝓕 (translate a (g.toLp 2)) = phaseOp a (𝓕 (g.toLp 2)) + rw [translate_schwartz, SchwartzMap.toLp_fourier_eq, SchwartzMap.toLp_fourier_eq] + apply Lp.ext + filter_upwards [(𝓕 (SchwartzMap.compSubConstCLM ℂ (-a) g)).coeFn_toLp 2, + phaseOp_coe a ((𝓕 g).toLp 2), + (𝓕 g).coeFn_toLp 2] with ξ h₁ h₂ h₃ + rw [h₁, h₂, h₃, schwartz_fourier_translate] + +lemma translate_sub_norm_sq (a : E) (f : Lp ℂ 2 (volume : Measure E)) : + ‖translate a f - f‖^2 = ∫ ξ, ‖phase a ξ - 1‖^2 * ‖(𝓕 f) ξ‖^2 := by + have hs : 𝓕 (translate a f - f) = 𝓕 (translate a f) - 𝓕 f := + (Lp.fourierTransformₗᵢ E ℂ).map_sub _ _ + rw [← Lp.norm_fourier_eq (translate a f - f), hs, fourier_translate, + norm_sq_integral] + apply integral_congr_ae + filter_upwards [Lp.coeFn_sub (phaseOp a (𝓕 f)) (𝓕 f), + phaseOp_coe a (𝓕 f)] with ξ h₁ h₂ + simp only [Pi.sub_apply] at h₁ + rw [h₁, h₂, ← sub_one_mul, norm_mul, mul_pow] + +end Translation +end HeatL2 + +namespace HeatL2 +section TranslationContinuous +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma translate_sub_translate_norm_sq (a b : E) (f : Lp ℂ 2 (volume : Measure E)) : + ‖translate a f - translate b f‖^2 = + ∫ ξ, ‖phase a ξ - phase b ξ‖^2 * ‖(𝓕 f) ξ‖^2 := by + have hs : 𝓕 (translate a f - translate b f) = 𝓕 (translate a f) - 𝓕 (translate b f) := + (Lp.fourierTransformₗᵢ E ℂ).map_sub _ _ + rw [← Lp.norm_fourier_eq (translate a f - translate b f), hs, fourier_translate, + fourier_translate, norm_sq_integral] + apply integral_congr_ae + filter_upwards [Lp.coeFn_sub (phaseOp a (𝓕 f)) (phaseOp b (𝓕 f)), + phaseOp_coe a (𝓕 f), + phaseOp_coe b (𝓕 f)] with ξ h₁ h₂ h₃ + simp only [Pi.sub_apply] at h₁ + rw [h₁, h₂, h₃, ← sub_mul, norm_mul, mul_pow] + +lemma translate_continuous (f : Lp ℂ 2 (volume : Measure E)) : + Continuous (fun a : E => translate a f) := by + rw [continuous_iff_continuousAt] + intro b + apply tendsto_iff_norm_sub_tendsto_zero.mpr + have ht : Tendsto (fun a : E => ‖translate a f - translate b f‖^2) (𝓝 b) (𝓝 0) := by + simp_rw [translate_sub_translate_norm_sq] + have hi := tendsto_integral_filter_of_dominated_convergence + (μ := (volume : Measure E)) (l := 𝓝 b) + (F := fun a ξ => ‖phase a ξ - phase b ξ‖^2 * ‖(𝓕 f) ξ‖^2) + (f := fun _ => (0 : ℝ)) (fun ξ => 4 * ‖(𝓕 f) ξ‖^2) + apply (by simpa using hi : _) + · exact Filter.Eventually.of_forall fun a => + (((phase_continuous a).sub (phase_continuous b)).norm.pow 2).aestronglyMeasurable.mul + ((Lp.aestronglyMeasurable (𝓕 f)).norm.pow 2) + · apply Filter.Eventually.of_forall + intro a + apply Filter.Eventually.of_forall + intro ξ + have hn : ‖phase a ξ - phase b ξ‖ ≤ 2 := by + calc + _ ≤ ‖phase a ξ‖ + ‖phase b ξ‖ := norm_sub_le _ _ + _ = 2 := by rw [phase_norm, phase_norm]; norm_num + have hs : ‖phase a ξ - phase b ξ‖^2 ≤ 4 := by nlinarith [norm_nonneg (phase a ξ-phase b ξ)] + simpa only [Real.norm_eq_abs, abs_mul, abs_pow, abs_norm] using + mul_le_mul_of_nonneg_right hs (sq_nonneg ‖(𝓕 f) ξ‖) + · exact ((Lp.memLp (𝓕 f)).integrable_norm_pow (by norm_num : (2:ℕ) ≠ 0)).const_mul 4 + · apply Filter.Eventually.of_forall + intro ξ + have hc : Continuous (fun a : E => phase a ξ) := + (continuous_subtype_val.comp Real.continuous_fourierChar).comp + (continuous_id.inner continuous_const) + have hc' : Continuous (fun a : E => ‖phase a ξ - phase b ξ‖^2 * ‖(𝓕 f) ξ‖^2) := + ((hc.sub continuous_const).norm.pow 2).mul continuous_const + simpa using hc'.tendsto b + simpa only [Function.comp_def, Real.sqrt_zero, Real.sqrt_sq_eq_abs, abs_norm] using + (Real.continuous_sqrt.tendsto 0).comp ht + +end TranslationContinuous +end HeatL2 + +namespace HeatL2 +section Spectral +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma integrable_weight (m : E → ℝ) (hm : AEStronglyMeasurable m volume) + {C : ℝ} (hb : ∀ᵐ x ∂volume, |m x| ≤ C) (f : Lp ℂ 2 (volume : Measure E)) : + Integrable (fun x => m x * ‖f x‖^2) := by + apply Integrable.mono' (((Lp.memLp f).integrable_norm_pow (by norm_num : (2:ℕ) ≠ 0)).const_mul C) + (hm.mul ((Lp.aestronglyMeasurable f).norm.pow 2)) + filter_upwards [hb] with x hx + simpa only [Pi.mul_apply, Pi.pow_apply, Real.norm_eq_abs, abs_mul, abs_pow, abs_norm] using + mul_le_mul_of_nonneg_right hx (sq_nonneg ‖f x‖) + +noncomputable def spectralOp (m : E → ℝ) (hm : AEStronglyMeasurable m volume) + (hb : ∀ x, |m x| ≤ 1) : Lp ℂ 2 (volume : Measure E) →L[ℂ] Lp ℂ 2 (volume : Measure E) := + (Lp.fourierTransformₗᵢ E ℂ).symm.toContinuousLinearEquiv.toContinuousLinearMap ∘L + (mulOp (fun x => (m x : ℂ)) (Complex.continuous_ofReal.comp_aestronglyMeasurable hm) + (Filter.Eventually.of_forall fun x => by simpa using hb x)) ∘L + (Lp.fourierTransformₗᵢ E ℂ).toContinuousLinearEquiv.toContinuousLinearMap + +lemma spectralOp_fourier (m : E → ℝ) (hm : AEStronglyMeasurable m volume) + (hb : ∀ x, |m x| ≤ 1) (f : Lp ℂ 2 (volume : Measure E)) : + (fun x => (𝓕 (spectralOp m hm hb f) : Lp ℂ 2 (volume : Measure E)) x) =ᵐ[volume] fun x => (m x : ℂ) * (𝓕 f) x := by + change ((Lp.fourierTransformₗᵢ E ℂ) ((Lp.fourierTransformₗᵢ E ℂ).symm _) : E → ℂ) =ᵐ[volume] _ + rw [LinearIsometryEquiv.apply_symm_apply] + exact mulOp_coe (fun x => (m x : ℂ)) + (Complex.continuous_ofReal.comp_aestronglyMeasurable hm) (C := 1) + (Filter.Eventually.of_forall fun x => by simpa using hb x) (𝓕 f) + +lemma spectralOp_norm_le (m : E → ℝ) (hm : AEStronglyMeasurable m volume) + (hb : ∀ x, |m x| ≤ 1) (f : Lp ℂ 2 (volume : Measure E)) : + ‖spectralOp m hm hb f‖ ≤ ‖f‖ := by + change ‖(Lp.fourierTransformₗᵢ E ℂ).symm _‖ ≤ _ + rw [LinearIsometryEquiv.norm_map] + change ‖mulOp (fun x => (m x : ℂ)) + (Complex.continuous_ofReal.comp_aestronglyMeasurable hm) + (Filter.Eventually.of_forall fun x => by simpa using hb x) (𝓕 f)‖ ≤ ‖f‖ + exact (mulLp_norm_le (fun x => (m x : ℂ)) + (Complex.continuous_ofReal.comp_aestronglyMeasurable hm) (C := 1) + (Filter.Eventually.of_forall fun x => by simpa using hb x) (𝓕 f)).trans_eq (by simp) + +lemma spectralOp_inner (m : E → ℝ) (hm : AEStronglyMeasurable m volume) + (hb : ∀ x, |m x| ≤ 1) (f : Lp ℂ 2 (volume : Measure E)) : + ⟪f, spectralOp m hm hb f⟫ = ((∫ x, m x * ‖(𝓕 f) x‖^2 : ℝ) : ℂ) := by + rw [← Lp.inner_fourier_eq, L2.inner_def] + have he : (fun x => inner ℂ ((𝓕 f) x) ((𝓕 (spectralOp m hm hb f)) x)) =ᵐ[volume] + fun x => ((m x * ‖(𝓕 f) x‖^2 : ℝ) : ℂ) := by + filter_upwards [spectralOp_fourier m hm hb f] with x hx + rw [hx] + simp only [RCLike.inner_apply] + rw [mul_assoc, RCLike.mul_conj] + simp + rw [integral_congr_ae he, integral_complex_ofReal] + +lemma spectralOp_positive (m : E → ℝ) (hm : AEStronglyMeasurable m volume) + (hb : ∀ x, |m x| ≤ 1) (hn : ∀ x, 0 ≤ m x) : + (spectralOp m hm hb).IsPositive := by + rw [ContinuousLinearMap.isPositive_iff_complex] + intro f + have he : ⟪spectralOp m hm hb f, f⟫ = ((∫ x, m x * ‖(𝓕 f) x‖^2 : ℝ) : ℂ) := by + rw [← inner_conj_symm, spectralOp_inner] + simp + rw [he] + exact ⟨rfl, integral_nonneg fun x => mul_nonneg (hn x) (sq_nonneg _)⟩ + +noncomputable def heat (w : E → ℝ) (hw : AEStronglyMeasurable w volume) + (hn : ∀ x, 0 ≤ w x) : Lp ℂ 2 (volume : Measure E) →L[ℂ] Lp ℂ 2 (volume : Measure E) := + spectralOp (fun x => Real.exp (-w x)) (Real.continuous_exp.comp_aestronglyMeasurable hw.neg) + (fun x => by rw [abs_of_pos (Real.exp_pos _)]; exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hn x))) + +noncomputable def energy (w : E → ℝ) (f : Lp ℂ 2 (volume : Measure E)) : ℝ := + ∫ x, (1-Real.exp (-w x)) * ‖(𝓕 f) x‖^2 + +lemma heat_inner (w : E → ℝ) (hw : AEStronglyMeasurable w volume) + (hn : ∀ x, 0 ≤ w x) (f : Lp ℂ 2 (volume : Measure E)) : + (⟪f, heat w hw hn f⟫).re = ‖f‖^2 - energy w f := by + rw [heat, spectralOp_inner] + simp only [Complex.ofReal_re] + have hb : ∀ x, |1-Real.exp (-w x)| ≤ 1 := by + intro x + rw [abs_of_nonneg (sub_nonneg.mpr (Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hn x))))] + linarith [Real.exp_pos (-w x)] + have hint : Integrable (fun x => (1-Real.exp (-w x)) * ‖(𝓕 f) x‖^2) := + integrable_weight (fun x => 1-Real.exp (-w x)) + (aestronglyMeasurable_const.sub (Real.continuous_exp.comp_aestronglyMeasurable hw.neg)) + (Filter.Eventually.of_forall hb) (𝓕 f) + rw [energy, ← Lp.norm_fourier_eq f, norm_sq_integral, + ← integral_sub ((Lp.memLp (𝓕 f)).integrable_norm_pow (by norm_num : (2:ℕ) ≠ 0)) + hint] + congr 1 + ext x + ring + +lemma energy_nonneg (w : E → ℝ) (hn : ∀ x, 0 ≤ w x) (f : Lp ℂ 2 (volume : Measure E)) : + 0 ≤ energy w f := by + apply integral_nonneg + intro x + exact mul_nonneg (sub_nonneg.mpr (Real.exp_le_one_iff.mpr (neg_nonpos.mpr (hn x)))) (sq_nonneg _) + +end Spectral +end HeatL2 +namespace HeatL2 +noncomputable def loss (x : ℝ) : ℝ := 1 - Real.exp (-x) + +lemma loss_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ loss x := by + exact sub_nonneg.mpr (Real.exp_le_one_iff.mpr (neg_nonpos.mpr hx)) + +lemma loss_le_one (x : ℝ) : loss x ≤ 1 := by + unfold loss + linarith [Real.exp_pos (-x)] + +lemma loss_le_self (x : ℝ) : loss x ≤ x := by + unfold loss + linarith [Real.add_one_le_exp (-x)] + +lemma loss_add_le {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) : + loss (x+y) ≤ loss x + loss y := by + have hp := mul_nonneg (loss_nonneg hx) (loss_nonneg hy) + simp only [loss, neg_add, Real.exp_add] at * + nlinarith + +lemma loss_sum_le {ι : Type*} (s : Finset ι) (a : ι → ℝ) (ha : ∀ i ∈ s, 0 ≤ a i) : + loss (∑ i ∈ s, a i) ≤ ∑ i ∈ s, loss (a i) := by + classical + induction s using Finset.induction_on with + | empty => simp [loss] + | @insert i s hi ih => + rw [Finset.sum_insert hi, Finset.sum_insert hi] + exact (loss_add_le (ha i (Finset.mem_insert_self _ _)) + (Finset.sum_nonneg fun j hj => ha j (Finset.mem_insert_of_mem hj))).trans + (add_le_add_right (ih fun j hj => ha j (Finset.mem_insert_of_mem hj)) _) + +lemma loss_dilate_le {c x : ℝ} (hc : 1 ≤ c) : loss (c*x) ≤ c*loss x := by + have hcpos : 0 < c := lt_of_lt_of_le zero_lt_one hc + have hci : 0 < c⁻¹ := inv_pos.mpr hcpos + have hci1 : c⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hc + have he := convexOn_exp.2 (Set.mem_univ (0:ℝ)) (Set.mem_univ (-c*x)) + (sub_nonneg.mpr hci1) hci.le (by ring : 1-c⁻¹+c⁻¹ = 1) + have harg : (1-c⁻¹)*(0:ℝ) + c⁻¹*(-c*x) = -x := by field_simp; ring + simp only [smul_eq_mul, harg, Real.exp_zero, mul_one] at he + have hm := mul_le_mul_of_nonneg_left he hcpos.le + rw [loss, loss] + have hcc : c*c⁻¹ = 1 := mul_inv_cancel₀ hcpos.ne' + simp only [mul_add, mul_sub, mul_one, ← mul_assoc, hcc, one_mul, neg_mul] at hm + linarith + +lemma loss_sum_dilate_le {ι : Type*} (s : Finset ι) (c x : ι → ℝ) + (hc : ∀ i ∈ s, 1 ≤ c i) (hx : ∀ i ∈ s, 0 ≤ x i) : + loss (∑ i ∈ s, c i*x i) ≤ ∑ i ∈ s, c i*loss (x i) := by + exact (loss_sum_le s _ (fun i hi => mul_nonneg (le_trans zero_le_one (hc i hi)) (hx i hi))).trans + (Finset.sum_le_sum fun i hi => loss_dilate_le (hc i hi)) + +lemma loss_mean_ge {ι : Type*} (s : Finset ι) (q x : ι → ℝ) + (hq : ∀ i ∈ s, 0 ≤ q i) (hs : ∑ i ∈ s, q i = 1) : + ∑ i ∈ s, q i*loss (x i) ≤ loss (∑ i ∈ s, q i*x i) := by + have he := convexOn_exp.map_sum_le hq hs (fun i hi => Set.mem_univ (-x i)) + simp only [smul_eq_mul] at he + have hneg : (∑ i ∈ s, q i * -x i) = -(∑ i ∈ s, q i*x i) := by simp [Finset.sum_neg_distrib] + rw [hneg] at he + simp only [loss, mul_sub, mul_one, Finset.sum_sub_distrib, hs] + linarith + +lemma loss_lower {x : ℝ} (hx : 0 ≤ x) : x/(1+x) ≤ loss x := by + have hp : 0 < 1+x := by linarith + have he : Real.exp (-x) ≤ (1+x)⁻¹ := by + rw [Real.exp_neg] + exact (inv_le_inv₀ (Real.exp_pos x) hp).mpr (by linarith [Real.add_one_le_exp x]) + rw [loss, div_le_iff₀ hp] + have hmul := mul_le_mul_of_nonneg_right he hp.le + rw [inv_mul_cancel₀ hp.ne'] at hmul + nlinarith + +lemma bound_by_loss {A H η z : ℝ} (hH : 0 ≤ H) (hη : 0 < η) + (hz : 0 ≤ z) (h₁ : A ≤ H*z) (h₂ : A ≤ 4) : + A ≤ (H+4*η)/η * loss (η*z) := by + have hp : 0 < 1+η*z := by positivity + have hlow := loss_lower (mul_nonneg hη.le hz) + have hc : 0 ≤ (H+4*η)/η := by positivity + have he : A ≤ (H+4*η)/η * (η*z/(1+η*z)) := by + have hr : (H+4*η)/η * (η*z/(1+η*z)) = (H*z+4*η*z)/(1+η*z) := by + field_simp + rw [hr, le_div_iff₀ hp] + have hm := mul_le_mul_of_nonneg_right h₂ (mul_nonneg hη.le hz) + nlinarith + exact he.trans (mul_le_mul_of_nonneg_left hlow hc) + +end HeatL2 + +namespace HeatL2 +section Mask +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +omit [MeasurableSpace X] in +lemma indicator_one_norm_le (D : Set X) (x : X) : ‖D.indicator (fun _ => (1 : ℂ)) x‖ ≤ 1 := by + classical + by_cases hx : x ∈ D <;> simp [hx] + +noncomputable def mask (D : Set X) (hD : MeasurableSet D) : Lp ℂ 2 μ →L[ℂ] Lp ℂ 2 μ := + mulOp (D.indicator (fun _ => (1 : ℂ))) + (aestronglyMeasurable_const.indicator hD) + (Filter.Eventually.of_forall (indicator_one_norm_le D)) + +lemma mask_coe (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) : + (mask D hD f : X → ℂ) =ᵐ[μ] D.indicator f := by + filter_upwards [mulOp_coe (D.indicator (fun _ => (1 : ℂ))) + (aestronglyMeasurable_const.indicator hD) + (Filter.Eventually.of_forall (indicator_one_norm_le D)) f] with x hx + change mulOp _ _ _ f x = _ + rw [hx] + classical + by_cases hx : x ∈ D <;> simp [hx] + +lemma mask_norm_le (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) : + ‖mask D hD f‖ ≤ ‖f‖ := by + apply le_trans (mulLp_norm_le (D.indicator (fun _ => (1 : ℂ))) + (aestronglyMeasurable_const.indicator hD) + (Filter.Eventually.of_forall (indicator_one_norm_le D)) f) + simp only [one_mul, le_refl] + +lemma mask_idempotent (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) : + mask D hD (mask D hD f) = mask D hD f := by + apply Lp.ext + filter_upwards [mask_coe D hD (mask D hD f), mask_coe D hD f] with x h₁ h₂ + classical + by_cases hx : x ∈ D <;> simp_all + +lemma mask_inner (D : Set X) (hD : MeasurableSet D) (f g : Lp ℂ 2 μ) : + ⟪mask D hD f, g⟫ = ⟪f, mask D hD g⟫ := by + rw [L2.inner_def, L2.inner_def] + apply integral_congr_ae + filter_upwards [mask_coe D hD f, mask_coe D hD g] with x h₁ h₂ + classical + by_cases hx : x ∈ D <;> simp [h₁, h₂, hx] + +lemma mask_adjoint (D : Set X) (hD : MeasurableSet D) : + (mask (μ := μ) D hD).adjoint = mask D hD := by + apply ContinuousLinearMap.ext + intro f + apply ext_inner_right ℂ + intro g + rw [ContinuousLinearMap.adjoint_inner_left] + exact (mask_inner D hD f g).symm + +noncomputable def supported (D : Set X) : Set (Lp ℂ 2 μ) := + {f | ∀ᵐ x ∂μ, x ∉ D → f x = 0} + +lemma mask_eq_self_iff (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) : + mask D hD f = f ↔ f ∈ supported D := by + classical + constructor + · intro h + have hc := mask_coe D hD f + rw [h] at hc + filter_upwards [hc] with x hx hnot + simpa [hnot] using hx + · intro h + apply Lp.ext + filter_upwards [mask_coe D hD f, h] with x hx hs + by_cases hmem : x ∈ D <;> simp [hx, hmem, hs] + +end Mask + +section PositiveNorm +variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℂ H] + +lemma positive_norm_le_iff (T : H →L[ℂ] H) (hT : T.IsPositive) {C : ℝ} (hC : 0 ≤ C) : + ‖T‖ ≤ C ↔ ∀ f, (⟪f, T f⟫).re ≤ C * ‖f‖^2 := by + constructor + · intro h f + have he := (Complex.re_le_norm ⟪f, T f⟫).trans (norm_inner_le_norm f (T f)) + have hn := T.le_opNorm f + have hm := mul_le_mul_of_nonneg_left (hn.trans + (mul_le_mul_of_nonneg_right h (norm_nonneg f))) (norm_nonneg f) + nlinarith + · intro h + rw [T.norm_eq_iSup_rayleighQuotient hT.isSymmetric] + apply ciSup_le + intro f + have hre : (⟪T f, f⟫).re = (⟪f, T f⟫).re := inner_re_symm (𝕜 := ℂ) (T f) f + change |(⟪T f, f⟫).re / ‖f‖^2| ≤ C + have hnon : 0 ≤ (⟪T f, f⟫).re := hT.re_inner_nonneg_left f + rw [abs_of_nonneg (div_nonneg hnon (sq_nonneg _)), hre] + by_cases hf : f = 0 + · simpa [hf] using hC + · exact (div_le_iff₀ (sq_pos_of_pos (norm_pos_iff.mpr hf))).mpr (h f) + +lemma positive_exists_form_gt (T : H →L[ℂ] H) (hT : T.IsPositive) {C : ℝ} + (hC : 0 ≤ C) (h : C < ‖T‖) : ∃ f, C * ‖f‖^2 < (⟪f, T f⟫).re := by + by_contra hn + push Not at hn + exact (not_le_of_gt h) ((positive_norm_le_iff T hT hC).mpr hn) + +end PositiveNorm + +section Compressed +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +noncomputable def compressedHeat (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) : + Lp ℂ 2 (volume : Measure E) →L[ℂ] Lp ℂ 2 (volume : Measure E) := + mask D hD ∘L heat w hw hn ∘L mask D hD + +lemma heat_positive (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) : + (heat w hw hn).IsPositive := spectralOp_positive _ _ _ (fun _ => (Real.exp_pos _).le) + +lemma compressedHeat_positive (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) : + (compressedHeat D hD w hw hn).IsPositive := by + have hp := (heat_positive w hw hn).adjoint_conj (mask D hD) + rwa [mask_adjoint] at hp + +lemma compressedHeat_inner (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) + (f : Lp ℂ 2 (volume : Measure E)) : + (⟪f, compressedHeat D hD w hw hn f⟫).re = + ‖mask D hD f‖^2 - energy w (mask D hD f) := by + change (⟪f, mask D hD (heat w hw hn (mask D hD f))⟫).re = _ + rw [← mask_inner, heat_inner] + +lemma compressedHeat_norm_le_one (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : AEStronglyMeasurable w volume) (hn : ∀ x, 0 ≤ w x) : + ‖compressedHeat D hD w hw hn‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ zero_le_one + intro f + change ‖mask D hD (heat w hw hn (mask D hD f))‖ ≤ 1 * ‖f‖ + rw [one_mul] + exact (mask_norm_le _ _ _).trans ((spectralOp_norm_le _ _ _ _).trans (mask_norm_le _ _ _)) + +end Compressed +end HeatL2 + +namespace HeatL2 +section Average +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +lemma integrable_translate (A : F →L[ℝ] E) (ν : Measure F) [IsFiniteMeasure ν] + (f : Lp ℂ 2 (volume : Measure E)) : Integrable (fun z => translate (A z) f) ν := by + apply Integrable.mono' (integrable_const ‖f‖) + ((translate_continuous f).comp A.continuous).aestronglyMeasurable + exact Filter.Eventually.of_forall fun z => (translate (A z)).norm_map f |>.le + +omit [FiniteDimensional ℝ F] [BorelSpace F] in +lemma average_norm_le (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] + (f : Lp ℂ 2 (volume : Measure E)) : ‖∫ z, translate (A z) f ∂ν‖ ≤ ‖f‖ := by + simpa using norm_integral_le_of_norm_le_const + (Filter.Eventually.of_forall fun z => (translate (A z)).norm_map f |>.le : + ∀ᵐ z ∂ν, ‖translate (A z) f‖ ≤ ‖f‖) + +noncomputable def averageLinear (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] : + Lp ℂ 2 (volume : Measure E) →ₗ[ℂ] Lp ℂ 2 (volume : Measure E) where + toFun f := ∫ z, translate (A z) f ∂ν + map_add' f g := by + simp only [map_add] + exact integral_add (integrable_translate A ν f) (integrable_translate A ν g) + map_smul' c f := by simp only [map_smul, integral_smul, RingHom.id_apply] + +noncomputable def average (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] : + Lp ℂ 2 (volume : Measure E) →L[ℂ] Lp ℂ 2 (volume : Measure E) := + (averageLinear A ν).mkContinuous 1 (fun f => by change ‖∫ z, translate (A z) f ∂ν‖ ≤ 1 * ‖f‖; simpa using average_norm_le A ν f) + +lemma average_apply (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] + (f : Lp ℂ 2 (volume : Measure E)) : average A ν f = ∫ z, translate (A z) f ∂ν := rfl + +lemma inner_average (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] + (f g : Lp ℂ 2 (volume : Measure E)) : + ⟪g, average A ν f⟫ = ∫ ξ, (∫ z, phase (A z) ξ ∂ν) * ((𝓕 f) ξ * conj ((𝓕 g) ξ)) := by + rw [average_apply, ← integral_inner (integrable_translate A ν f)] + have hp : Integrable (fun ξ => (𝓕 f) ξ * conj ((𝓕 g) ξ)) (volume : Measure E) := by + simpa only [RCLike.inner_apply] using L2.integrable_inner (𝕜 := ℂ) (𝓕 g) (𝓕 f) + have hm : Continuous (fun p : F × E => phase (A p.1) p.2) := + (continuous_subtype_val.comp Real.continuous_fourierChar).comp + ((A.continuous.comp continuous_fst).inner continuous_snd) + have hi : Integrable (fun p : F × E => phase (A p.1) p.2 * + ((𝓕 f) p.2 * conj ((𝓕 g) p.2))) (ν.prod volume) := by + apply Integrable.mono' (hp.norm.comp_snd ν) (hm.aestronglyMeasurable.mul hp.aestronglyMeasurable.comp_snd) + exact Filter.Eventually.of_forall fun p => by simp only [Pi.mul_apply, norm_mul, phase_norm, one_mul, le_refl] + have hinner (z : F) : ⟪g, translate (A z) f⟫ = + ∫ ξ, phase (A z) ξ * ((𝓕 f) ξ * conj ((𝓕 g) ξ)) := by + rw [← Lp.inner_fourier_eq, fourier_translate] + exact inner_mulOp _ _ _ _ _ + simp_rw [hinner] + rw [integral_integral_swap hi] + apply integral_congr_ae + exact Filter.Eventually.of_forall fun ξ => integral_mul_const _ _ + +noncomputable def gaussianSymbol (A : F →L[ℝ] E) (ξ : E) : ℝ := + ‖(2*Real.pi) • A.adjoint ξ‖^2 / 2 + +omit [MeasurableSpace E] [BorelSpace E] [MeasurableSpace F] [BorelSpace F] in +lemma gaussianSymbol_nonneg (A : F →L[ℝ] E) (ξ : E) : 0 ≤ gaussianSymbol A ξ := by + unfold gaussianSymbol + positivity + +omit [MeasurableSpace E] [BorelSpace E] [MeasurableSpace F] [BorelSpace F] in +lemma gaussianSymbol_continuous (A : F →L[ℝ] E) : Continuous (gaussianSymbol A) := by + unfold gaussianSymbol + fun_prop + +omit [MeasurableSpace E] [BorelSpace E] in +lemma integral_phase_gaussian (A : F →L[ℝ] E) (ξ : E) : + (∫ z, phase (A z) ξ ∂ProbabilityTheory.stdGaussian F) = + (Real.exp (-gaussianSymbol A ξ) : ℂ) := by + have he := ProbabilityTheory.charFun_stdGaussian ((2*Real.pi) • A.adjoint ξ) + rw [charFun_apply] at he + have hf : (fun z => phase (A z) ξ) = fun z => + Complex.exp ((inner ℝ z ((2*Real.pi) • A.adjoint ξ) : ℂ) * Complex.I) := by + ext z + rw [phase, Real.fourierChar_apply, inner_smul_right, A.adjoint_inner_right] + rw [hf, he, gaussianSymbol, Complex.ofReal_exp] + congr 1 + push_cast + ring + +lemma average_gaussian_eq_heat (A : F →L[ℝ] E) : + average A (ProbabilityTheory.stdGaussian F) = + heat (gaussianSymbol A) (gaussianSymbol_continuous A).aestronglyMeasurable + (gaussianSymbol_nonneg A) := by + apply ContinuousLinearMap.ext + intro f + apply ext_inner_left ℂ + intro g + rw [inner_average] + simp_rw [integral_phase_gaussian] + rw [← Lp.inner_fourier_eq, L2.inner_def] + apply integral_congr_ae + have hb : ∀ ξ, |Real.exp (-gaussianSymbol A ξ)| ≤ 1 := by + intro ξ + rw [abs_of_pos (Real.exp_pos _)] + exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr (gaussianSymbol_nonneg A ξ)) + filter_upwards [spectralOp_fourier (fun ξ => Real.exp (-gaussianSymbol A ξ)) + (Real.continuous_exp.comp_aestronglyMeasurable (gaussianSymbol_continuous A).aestronglyMeasurable.neg) + hb f] with ξ hξ + change _ = inner ℂ ((𝓕 g) ξ) ((𝓕 (heat _ _ _ f)) ξ) + rw [heat, hξ] + simp only [RCLike.inner_apply] + ring + +end Average +end HeatL2 + +namespace HeatL2 +section Energy +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma integrable_energy (w : E → ℝ) (hw : AEStronglyMeasurable w volume) + (hn : ∀ x, 0 ≤ w x) (f : Lp ℂ 2 (volume : Measure E)) : + Integrable (fun ξ => loss (w ξ) * ‖(𝓕 f) ξ‖^2) := by + apply integrable_weight (fun ξ => loss (w ξ)) + (aestronglyMeasurable_const.sub (Real.continuous_exp.comp_aestronglyMeasurable hw.neg)) + (C := 1) _ (𝓕 f) + exact Filter.Eventually.of_forall fun ξ => by + rw [abs_of_nonneg (loss_nonneg (hn ξ))] + exact loss_le_one _ + +lemma energy_le_norm_sq (w : E → ℝ) (hw : AEStronglyMeasurable w volume) + (hn : ∀ x, 0 ≤ w x) (f : Lp ℂ 2 (volume : Measure E)) : energy w f ≤ ‖f‖^2 := by + rw [← Lp.norm_fourier_eq f, norm_sq_integral] + apply integral_mono (integrable_energy w hw hn f) + ((Lp.memLp (𝓕 f)).integrable_norm_pow (by norm_num : (2:ℕ)≠0)) + intro ξ + exact mul_le_of_le_one_left (sq_nonneg _) (loss_le_one _) + +lemma energy_comparison {w v : E → ℝ} (hw : AEStronglyMeasurable w volume) + (hv : AEStronglyMeasurable v volume) (hwn : ∀ x, 0 ≤ w x) (hvn : ∀ x, 0 ≤ v x) + {C : ℝ} (h : ∀ ξ, loss (w ξ) ≤ C * loss (v ξ)) (f : Lp ℂ 2 (volume : Measure E)) : + energy w f ≤ C * energy v f := by + rw [energy, energy, ← integral_const_mul] + apply integral_mono (integrable_energy w hw hwn f) ((integrable_energy v hv hvn f).const_mul C) + intro ξ + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right (h ξ) (sq_nonneg ‖(𝓕 f) ξ‖) + +lemma energy_mean_ge {ι : Type*} (s : Finset ι) (q : ι → ℝ) (w : ι → E → ℝ) + (hq : ∀ i ∈ s, 0 ≤ q i) (hs : ∑ i ∈ s, q i = 1) + (hw : ∀ i ∈ s, AEStronglyMeasurable (w i) volume) + (hn : ∀ i ∈ s, ∀ ξ, 0 ≤ w i ξ) (f : Lp ℂ 2 (volume : Measure E)) : + ∑ i ∈ s, q i * energy (w i) f ≤ energy (fun ξ => ∑ i ∈ s, q i * w i ξ) f := by + have hi i (h : i ∈ s) := (integrable_energy (w i) (hw i h) (hn i h) f).const_mul (q i) + have hw' : AEStronglyMeasurable (fun ξ => ∑ i ∈ s, q i * w i ξ) volume := by + exact s.aestronglyMeasurable_fun_sum fun i hi => (hw i hi).const_mul (q i) + have hn' ξ : 0 ≤ ∑ i ∈ s, q i * w i ξ := Finset.sum_nonneg fun i hi => mul_nonneg (hq i hi) (hn i hi ξ) + have he : (∑ i ∈ s, q i * energy (w i) f) = ∫ ξ, ∑ i ∈ s, q i * (loss (w i ξ) * ‖(𝓕 f) ξ‖^2) := by + rw [integral_finsetSum s hi] + apply Finset.sum_congr rfl + intro i _ + exact (integral_const_mul _ _).symm + rw [he] + apply integral_mono (integrable_finsetSum s hi) (integrable_energy _ hw' hn' f) + intro ξ + simpa only [← mul_assoc, ← Finset.sum_mul] using + mul_le_mul_of_nonneg_right (loss_mean_ge s q (fun i => w i ξ) hq hs) (sq_nonneg ‖(𝓕 f) ξ‖) + +noncomputable def directionalSymbol (e : E) (ξ : E) : ℝ := (2*Real.pi*inner ℝ e ξ)^2 + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma directionalSymbol_nonneg (e ξ : E) : 0 ≤ directionalSymbol e ξ := sq_nonneg _ + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma directionalSymbol_continuous (e : E) : Continuous (directionalSymbol e) := by + unfold directionalSymbol + fun_prop + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma phase_sub_one_sq_le (e ξ : E) (h : ℝ) : + ‖phase (h • e) ξ - 1‖^2 ≤ h^2 * directionalSymbol e ξ := by + have hb : ‖phase (h • e) ξ - 1‖ ≤ ‖2*Real.pi*inner ℝ (h • e) ξ‖ := by + rw [phase, Real.fourierChar_apply, mul_comm _ Complex.I] + exact Real.norm_exp_I_mul_ofReal_sub_one_le + have hs := sq_le_sq₀ (norm_nonneg _) (norm_nonneg _) |>.mpr hb + have he : ‖2*Real.pi*inner ℝ (h • e) ξ‖^2 = h^2 * directionalSymbol e ξ := by + simp only [inner_smul_left, starRingEnd_apply, star_trivial, + Real.norm_eq_abs, sq_abs, directionalSymbol] + ring + exact hs.trans_eq he + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma phase_sub_one_sq_le_four (a ξ : E) : ‖phase a ξ - 1‖^2 ≤ 4 := by + have hn : ‖phase a ξ - 1‖ ≤ 2 := by + simpa only [phase_norm, norm_one, one_add_one_eq_two] using norm_sub_le (phase a ξ) (1:ℂ) + nlinarith [norm_nonneg (phase a ξ - 1)] + +lemma directional_translate_bound (e : E) (h η : ℝ) (hη : 0 < η) + (f : Lp ℂ 2 (volume : Measure E)) : + ‖translate (h • e) f - f‖^2 ≤ (h^2 + 4*η)/η * energy (fun ξ => η * directionalSymbol e ξ) f := by + rw [translate_sub_norm_sq, energy, ← integral_const_mul] + have hw : AEStronglyMeasurable (fun ξ => η * directionalSymbol e ξ) volume := + ((directionalSymbol_continuous e).const_mul η).aestronglyMeasurable + have hn ξ := mul_nonneg hη.le (directionalSymbol_nonneg e ξ) + have hleft : Integrable (fun ξ => ‖phase (h • e) ξ - 1‖^2 * ‖(𝓕 f) ξ‖^2) := by + apply integrable_weight (fun ξ => ‖phase (h • e) ξ - 1‖^2) + (((phase_continuous _).sub continuous_const).norm.pow 2).aestronglyMeasurable + (C := 4) _ (𝓕 f) + exact Filter.Eventually.of_forall fun ξ => by + simpa only [abs_pow, abs_norm] using phase_sub_one_sq_le_four (h • e) ξ + apply integral_mono hleft ((integrable_energy _ hw hn f).const_mul _) + intro ξ + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right + (bound_by_loss (sq_nonneg h) hη (directionalSymbol_nonneg e ξ) + (phase_sub_one_sq_le e ξ h) (phase_sub_one_sq_le_four (h • e) ξ)) (sq_nonneg ‖(𝓕 f) ξ‖) + +end Energy +end HeatL2 + +open MeasureTheory FourierTransform Filter ComplexConjugate +open scoped Topology ComplexInnerProductSpace + +namespace HeatL2 + +lemma sqrt_pair_sub_sq_le (a b c d : ℝ) : + (Real.sqrt (a^2+b^2) - Real.sqrt (c^2+d^2))^2 ≤ (a-c)^2+(b-d)^2 := by + have hx : 0 ≤ a^2+b^2 := add_nonneg (sq_nonneg _) (sq_nonneg _) + have hy : 0 ≤ c^2+d^2 := add_nonneg (sq_nonneg _) (sq_nonneg _) + have hs : (a*c+b*d)^2 ≤ (a^2+b^2)*(c^2+d^2) := by + nlinarith [sq_nonneg (a*d-b*c)] + have hp : (a^2+b^2)*(c^2+d^2) = + (Real.sqrt (a^2+b^2)*Real.sqrt (c^2+d^2))^2 := by + rw [mul_pow, Real.sq_sqrt hx, Real.sq_sqrt hy] + have hcs : a*c+b*d ≤ Real.sqrt (a^2+b^2)*Real.sqrt (c^2+d^2) := by + rw [hp] at hs + nlinarith [mul_nonneg (Real.sqrt_nonneg (a^2+b^2)) (Real.sqrt_nonneg (c^2+d^2))] + nlinarith [Real.sq_sqrt hx, Real.sq_sqrt hy] + +lemma sqrt_mix_sub_sq_le (t u : ℝ) (ht : 0 ≤ t) (hu : 0 ≤ u) (a b c d : ℝ) : + (Real.sqrt (t*a^2+u*b^2) - Real.sqrt (t*c^2+u*d^2))^2 ≤ t*(a-c)^2+u*(b-d)^2 := by + have he (x y : ℝ) : (Real.sqrt t*x)^2+(Real.sqrt u*y)^2=t*x^2+u*y^2 := by + rw [mul_pow, mul_pow, Real.sq_sqrt ht, Real.sq_sqrt hu] + have h := sqrt_pair_sub_sq_le (Real.sqrt t*a) (Real.sqrt u*b) (Real.sqrt t*c) (Real.sqrt u*d) + rw [he, he] at h + have hr : (Real.sqrt t*a-Real.sqrt t*c)^2+(Real.sqrt u*b-Real.sqrt u*d)^2= + t*(a-c)^2+u*(b-d)^2 := by + rw [← mul_sub, ← mul_sub, mul_pow, mul_pow, Real.sq_sqrt ht, Real.sq_sqrt hu] + exact h.trans_eq hr + +lemma sqrt_mix_bound (t u : ℝ) (ht : 0 ≤ t) (hu : 0 ≤ u) (a b : ℝ) + (ha : 0 ≤ a) (hb : 0 ≤ b) : + Real.sqrt (t*a^2+u*b^2) ≤ Real.sqrt t*a+Real.sqrt u*b := by + have hr : 0 ≤ Real.sqrt t*a+Real.sqrt u*b := by positivity + apply (Real.sqrt_le_iff).mpr + refine ⟨hr, ?_⟩ + have h₁ := Real.sq_sqrt ht + have h₂ := Real.sq_sqrt hu + nlinarith [mul_nonneg (mul_nonneg (Real.sqrt_nonneg t) ha) (mul_nonneg (Real.sqrt_nonneg u) hb)] + +section Mixture +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +noncomputable def mixFun (t : ℝ) (f g : Lp ℂ 2 μ) (x : X) : ℂ := + (Real.sqrt (t*‖f x‖^2+(1-t)*‖g x‖^2) : ℝ) + +lemma mixFun_memLp (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) (f g : Lp ℂ 2 μ) : + MemLp (mixFun t f g) 2 μ := by + have hu := sub_nonneg.mpr ht' + have hmeas : AEStronglyMeasurable (mixFun t f g) μ := by + unfold mixFun + exact Complex.continuous_ofReal.comp_aestronglyMeasurable + (Real.continuous_sqrt.comp_aestronglyMeasurable + ((((Lp.memLp f).aestronglyMeasurable.norm.pow 2).const_mul t).add + (((Lp.memLp g).aestronglyMeasurable.norm.pow 2).const_mul (1-t)))) + apply MemLp.of_le ((Lp.memLp f).norm.const_mul (Real.sqrt t) |>.add + ((Lp.memLp g).norm.const_mul (Real.sqrt (1-t)))) hmeas + exact Filter.Eventually.of_forall fun x => by + rw [mixFun, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _)] + change _ ≤ ‖Real.sqrt t * ‖f x‖ + Real.sqrt (1-t) * ‖g x‖‖ + rw [Real.norm_eq_abs, abs_of_nonneg (by positivity)] + exact sqrt_mix_bound t (1-t) ht hu _ _ (norm_nonneg _) (norm_nonneg _) + +noncomputable def mixture (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) (f g : Lp ℂ 2 μ) : Lp ℂ 2 μ := + (mixFun_memLp t ht ht' f g).toLp (mixFun t f g) + +lemma mixture_coe (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) (f g : Lp ℂ 2 μ) : + (mixture t ht ht' f g : X → ℂ) =ᵐ[μ] mixFun t f g := MemLp.coeFn_toLp _ + +lemma mixFun_norm_sq (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) (f g : Lp ℂ 2 μ) (x : X) : + ‖mixFun t f g x‖^2 = t*‖f x‖^2+(1-t)*‖g x‖^2 := by + rw [mixFun, Complex.norm_real, Real.norm_eq_abs, sq_abs, Real.sq_sqrt] + positivity + +lemma mixture_norm_sq (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) (f g : Lp ℂ 2 μ) : + ‖mixture t ht ht' f g‖^2 = t*‖f‖^2+(1-t)*‖g‖^2 := by + rw [norm_sq_integral, norm_sq_integral f, norm_sq_integral g] + have hf := (Lp.memLp f).integrable_norm_pow (by norm_num : (2:ℕ)≠0) + have hg := (Lp.memLp g).integrable_norm_pow (by norm_num : (2:ℕ)≠0) + rw [← integral_const_mul, ← integral_const_mul, ← integral_add (hf.const_mul t) (hg.const_mul (1-t))] + apply integral_congr_ae + filter_upwards [mixture_coe t ht ht' f g] with x hx + rw [hx, mixFun_norm_sq t ht ht'] + +lemma mixFun_sub_sq_le (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) (f g : Lp ℂ 2 μ) (x y : X) : + ‖mixFun t f g x - mixFun t f g y‖^2 ≤ t*‖f x-f y‖^2+(1-t)*‖g x-g y‖^2 := by + have hu := sub_nonneg.mpr ht' + have hb := sqrt_mix_sub_sq_le t (1-t) ht hu ‖f x‖ ‖g x‖ ‖f y‖ ‖g y‖ + have h₁ : (‖f x‖-‖f y‖)^2 ≤ ‖f x-f y‖^2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) (norm_nonneg _) |>.mpr (abs_norm_sub_norm_le (f x) (f y))) + have h₂ : (‖g x‖-‖g y‖)^2 ≤ ‖g x-g y‖^2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) (norm_nonneg _) |>.mpr (abs_norm_sub_norm_le (g x) (g y))) + have h := hb.trans (add_le_add (mul_le_mul_of_nonneg_left h₁ ht) (mul_le_mul_of_nonneg_left h₂ hu)) + simpa only [mixFun, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs, sq_abs] using h + +lemma mixture_supported (D : Set X) (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) + (f g : Lp ℂ 2 μ) (hf : f ∈ supported D) (hg : g ∈ supported D) : + mixture t ht ht' f g ∈ supported D := by + change ∀ᵐ x ∂μ, x ∉ D → mixture t ht ht' f g x = 0 + filter_upwards [mixture_coe t ht ht' f g, hf, hg] with x hx hf hg hnot + simp only [hx, mixFun, hf hnot, hg hnot, norm_zero, ne_eq, OfNat.ofNat_ne_zero, + not_false_eq_true, zero_pow, mul_zero, add_zero, Real.sqrt_zero, Complex.ofReal_zero] + +end Mixture + +section MixtureTranslation +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma mixture_translation_sq_le (t : ℝ) (ht : 0 ≤ t) (ht' : t ≤ 1) + (f g : Lp ℂ 2 (volume : Measure E)) (a : E) : + ‖translate a (mixture t ht ht' f g) - mixture t ht ht' f g‖^2 ≤ + t * ‖translate a f - f‖^2 + (1-t) * ‖translate a g - g‖^2 := by + rw [norm_sq_integral, norm_sq_integral (translate a f - f), norm_sq_integral (translate a g - g)] + have hf := (Lp.memLp (translate a f - f)).integrable_norm_pow (by norm_num : (2:ℕ)≠0) + have hg := (Lp.memLp (translate a g - g)).integrable_norm_pow (by norm_num : (2:ℕ)≠0) + rw [← integral_const_mul, ← integral_const_mul, ← integral_add (hf.const_mul t) (hg.const_mul (1-t))] + apply integral_mono_ae + ((Lp.memLp _).integrable_norm_pow (by norm_num : (2:ℕ)≠0)) + ((hf.const_mul t).add (hg.const_mul (1-t))) + have hm := mixture_coe t ht ht' f g + have hma := (measurePreserving_add_right (volume : Measure E) a).quasiMeasurePreserving.ae_eq_comp hm + filter_upwards [hm, hma, translate_coe a (mixture t ht ht' f g), translate_coe a f, + translate_coe a g, Lp.coeFn_sub (translate a (mixture t ht ht' f g)) (mixture t ht ht' f g), + Lp.coeFn_sub (translate a f) f, Lp.coeFn_sub (translate a g) g] with x hm hma hb hf hg hc hd he + simp only [Pi.sub_apply] at hc hd he + change mixture t ht ht' f g (x+a) = mixFun t f g (x+a) at hma + simp only [Pi.add_apply] + rw [hc, hb, hma, hm, hd, he, hf, hg] + exact mixFun_sub_sq_le t ht ht' f g (x+a) x + +end MixtureTranslation +end HeatL2 + +open MeasureTheory FourierTransform Filter ComplexConjugate +open scoped Topology ComplexInnerProductSpace + +namespace HeatL2 +section Difference +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +omit [FiniteDimensional ℝ F] in +lemma integrable_difference_sq (A : F →L[ℝ] E) (ν : Measure F) [IsFiniteMeasure ν] + (f : Lp ℂ 2 (volume : Measure E)) : + Integrable (fun z => ‖translate (A z) f - f‖^2) ν := by + apply Integrable.mono' (integrable_const (4 * ‖f‖^2)) + ((((translate_continuous f).comp A.continuous).sub continuous_const).norm.pow 2).aestronglyMeasurable + exact Filter.Eventually.of_forall fun z => by + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + have h := norm_sub_le (translate (A z) f) f + rw [(translate (A z)).norm_map] at h + change ‖translate (A z) f - f‖^2 ≤ 4 * ‖f‖^2 + nlinarith [norm_nonneg (translate (A z) f - f)] + +lemma average_difference_sq (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] + (f : Lp ℂ 2 (volume : Measure E)) : + (∫ z, ‖translate (A z) f - f‖^2 ∂ν) = 2 * (‖f‖^2 - (⟪f, average A ν f⟫).re) := by + have hi : Integrable (fun z => (⟪f, translate (A z) f⟫).re) ν := + ((integrable_translate A ν f).const_inner (𝕜 := ℂ) f).re + have he z : ‖translate (A z) f - f‖^2 = + ‖f‖^2 - 2 * (⟪f, translate (A z) f⟫).re + ‖f‖^2 := by + rw [norm_sub_sq (𝕜 := ℂ), (translate (A z)).norm_map, inner_re_symm (𝕜 := ℂ)] + rfl + simp_rw [he] + have hi' : Integrable (fun z => ‖f‖^2 - 2 * (⟪f, translate (A z) f⟫).re) ν := + (integrable_const (‖f‖^2)).sub (hi.const_mul 2) + have hr := integral_re ((integrable_translate A ν f).const_inner (𝕜 := ℂ) f) + simp only [RCLike.re_eq_complex_re] at hr + rw [integral_add hi' (integrable_const (‖f‖^2)), + integral_sub (integrable_const (‖f‖^2)) (hi.const_mul 2), integral_const_mul, + integral_const, probReal_univ, one_smul, hr, + integral_inner (integrable_translate A ν f), ← average_apply] + ring + +lemma gaussian_energy_difference (A : F →L[ℝ] E) + (f : Lp ℂ 2 (volume : Measure E)) : + energy (gaussianSymbol A) f = (1/2:ℝ) * + ∫ z, ‖translate (A z) f - f‖^2 ∂ProbabilityTheory.stdGaussian F := by + rw [average_difference_sq, average_gaussian_eq_heat, heat_inner] + ring + +end Difference +end HeatL2 + +lemma selfAdjoint_norm_pow {A : Type*} [NormedRing A] [StarRing A] [CStarRing A] + (a : A) (ha : IsSelfAdjoint a) (n : ℕ) (hn : n ≠ 0) : ‖a^n‖ = ‖a‖^n := by + by_cases hz : a = 0 + · simp [hz, zero_pow hn] + have hp : 0 < ‖a‖ := norm_pos_iff.mpr hz + have hlarge : n ≤ 2^n := Nat.le_of_lt (Nat.lt_two_pow_self (n := n)) + have hrem : 2^n-n ≠ 0 := Nat.ne_zero_of_lt (Nat.sub_pos_of_lt (Nat.lt_two_pow_self (n := n))) + have he : n + (2^n-n) = 2^n := Nat.add_sub_of_le hlarge + have h : ‖a‖^n * ‖a‖^(2^n-n) ≤ ‖a^n‖ * ‖a‖^(2^n-n) := by + calc + _ = ‖a‖^(2^n) := by rw [← pow_add, he] + _ = ‖a^(2^n)‖ := (ha.norm_pow_two_pow n).symm + _ = ‖a^n * a^(2^n-n)‖ := by rw [← pow_add, he] + _ ≤ ‖a^n‖ * ‖a^(2^n-n)‖ := norm_mul_le _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left (norm_pow_le' _ (Nat.pos_of_ne_zero hrem)) (norm_nonneg _) + exact le_antisymm (norm_pow_le' _ (Nat.pos_of_ne_zero hn)) ((mul_le_mul_iff_left₀ (pow_pos hp _)).mp h) + +open MeasureTheory Filter ComplexConjugate +open scoped ComplexInnerProductSpace ENNReal + +namespace HeatL2 +section Absolute +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +lemma abs_memLp (f : Lp ℂ 2 μ) : MemLp (fun x => (‖f x‖ : ℂ)) 2 μ := by + apply MemLp.of_le (Lp.memLp f) + (Complex.continuous_ofReal.comp_aestronglyMeasurable (Lp.memLp f).aestronglyMeasurable.norm) + exact Filter.Eventually.of_forall fun x => by simp + +noncomputable def absolute (f : Lp ℂ 2 μ) : Lp ℂ 2 μ := + (abs_memLp f).toLp (fun x => (‖f x‖ : ℂ)) + +lemma absolute_coe (f : Lp ℂ 2 μ) : (absolute f : X → ℂ) =ᵐ[μ] fun x => (‖f x‖ : ℂ) := + MemLp.coeFn_toLp _ + +lemma absolute_norm (f : Lp ℂ 2 μ) : ‖absolute f‖ = ‖f‖ := by + have he : ∀ᵐ x ∂μ, ‖absolute f x‖ = ‖f x‖ := by + filter_upwards [absolute_coe f] with x hx + simp [hx] + exact le_antisymm (Lp.norm_le_norm_of_ae_le (he.mono fun _ h => h.le)) + (Lp.norm_le_norm_of_ae_le (he.mono fun _ h => h.ge)) + +variable [IsFiniteMeasure μ] + +noncomputable def oneLp : Lp ℂ 2 μ := Lp.const 2 μ 1 + +lemma oneLp_coe : ((oneLp : Lp ℂ 2 μ) : X → ℂ) =ᵐ[μ] fun _ => 1 := Lp.coeFn_const 2 μ 1 + +lemma integral_norm_le (f : Lp ℂ 2 μ) : (∫ x, ‖f x‖ ∂μ) ≤ ‖(oneLp : Lp ℂ 2 μ)‖ * ‖f‖ := by + have he : ⟪(oneLp : Lp ℂ 2 μ), absolute f⟫ = (∫ x, ‖f x‖ ∂μ : ℝ) := by + rw [L2.inner_def, ← integral_complex_ofReal] + apply integral_congr_ae + filter_upwards [oneLp_coe (μ := μ), absolute_coe f] with x h₁ h₂ + simp only [h₁, h₂, RCLike.inner_apply, map_one, mul_one] + calc + _ = (⟪(oneLp : Lp ℂ 2 μ), absolute f⟫).re := by rw [he]; rfl + _ ≤ ‖⟪(oneLp : Lp ℂ 2 μ), absolute f⟫‖ := Complex.re_le_norm _ + _ ≤ ‖(oneLp : Lp ℂ 2 μ)‖ * ‖absolute f‖ := norm_inner_le_norm _ _ + _ = _ := by rw [absolute_norm] + +end Absolute + +structure BoundedKernel (X : Type*) [MeasurableSpace X] where + value : X × X → ℝ + measurable : Measurable value + bound : ℝ + bound_nonneg : 0 ≤ bound + nonneg : ∀ p, 0 ≤ value p + le_bound : ∀ p, value p ≤ bound + +section Kernel +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} [IsFiniteMeasure μ] +variable (k : BoundedKernel X) + +noncomputable def kernelFun (f : Lp ℂ 2 μ) (x : X) : ℂ := + ∫ y, (k.value (x,y) : ℂ) * f y ∂μ + +lemma kernel_section_integrable (f : Lp ℂ 2 μ) (x : X) : + Integrable (fun y => (k.value (x,y) : ℂ) * f y) μ := by + apply Integrable.mono' (((Lp.memLp f).integrable (by norm_num : (1:ℝ≥0∞)≤2)).norm.const_mul k.bound) + ((Complex.continuous_ofReal.comp_aestronglyMeasurable + (k.measurable.comp measurable_prodMk_left).aestronglyMeasurable).mul (Lp.memLp f).aestronglyMeasurable) + exact Filter.Eventually.of_forall fun y => by + change ‖(k.value (x,y) : ℂ) * f y‖ ≤ k.bound * ‖f y‖ + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (k.nonneg _)] + exact mul_le_mul_of_nonneg_right (k.le_bound _) (norm_nonneg _) + +lemma kernelFun_bound (f : Lp ℂ 2 μ) (x : X) : + ‖kernelFun k f x‖ ≤ k.bound * ∫ y, ‖f y‖ ∂μ := by + unfold kernelFun + apply (norm_integral_le_integral_norm _).trans + rw [← integral_const_mul] + apply integral_mono (kernel_section_integrable k f x).norm + (((Lp.memLp f).integrable (by norm_num : (1:ℝ≥0∞)≤2)).norm.const_mul k.bound) + intro y + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (k.nonneg _)] + exact mul_le_mul_of_nonneg_right (k.le_bound _) (norm_nonneg _) + +lemma kernelFun_norm_bound (f : Lp ℂ 2 μ) (x : X) : + ‖kernelFun k f x‖ ≤ k.bound * ‖(oneLp : Lp ℂ 2 μ)‖ * ‖f‖ := by + exact (kernelFun_bound k f x).trans (by + simpa only [mul_assoc] using mul_le_mul_of_nonneg_left (integral_norm_le f) k.bound_nonneg) + +lemma kernelFun_memLp (f : Lp ℂ 2 μ) : MemLp (kernelFun k f) 2 μ := by + have hm : AEStronglyMeasurable (fun p : X × X => (k.value p : ℂ) * f p.2) (μ.prod μ) := + (Complex.continuous_ofReal.comp_aestronglyMeasurable k.measurable.aestronglyMeasurable).mul + (Lp.memLp f).aestronglyMeasurable.comp_snd + apply MemLp.of_bound hm.integral_prod_right' (k.bound * ‖(oneLp : Lp ℂ 2 μ)‖ * ‖f‖) + exact Filter.Eventually.of_forall (kernelFun_norm_bound k f) + +noncomputable def kernelLp (f : Lp ℂ 2 μ) : Lp ℂ 2 μ := + (kernelFun_memLp k f).toLp (kernelFun k f) + +lemma kernelLp_coe (f : Lp ℂ 2 μ) : (kernelLp k f : X → ℂ) =ᵐ[μ] kernelFun k f := + MemLp.coeFn_toLp _ + +lemma kernelLp_add (f g : Lp ℂ 2 μ) : kernelLp k (f+g) = kernelLp k f+kernelLp k g := by + apply Lp.ext + filter_upwards [kernelLp_coe k (f+g), kernelLp_coe k f, kernelLp_coe k g, + Lp.coeFn_add (kernelLp k f) (kernelLp k g)] with x h₁ h₂ h₃ h₄ + simp only [Pi.add_apply] at h₄ + rw [h₁, h₄, h₂, h₃] + unfold kernelFun + rw [← integral_add (kernel_section_integrable k f x) (kernel_section_integrable k g x)] + apply integral_congr_ae + filter_upwards [Lp.coeFn_add f g] with y hy + simp only [hy, Pi.add_apply, mul_add] + +lemma kernelLp_smul (c : ℂ) (f : Lp ℂ 2 μ) : kernelLp k (c • f) = c • kernelLp k f := by + apply Lp.ext + filter_upwards [kernelLp_coe k (c • f), kernelLp_coe k f, Lp.coeFn_smul c (kernelLp k f)] with x h₁ h₂ h₃ + simp only [Pi.smul_apply, smul_eq_mul] at h₃ + rw [h₁, h₃, h₂] + unfold kernelFun + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [Lp.coeFn_smul c f] with y hy + simp only [hy, Pi.smul_apply, smul_eq_mul] + ring + +lemma kernelLp_norm_le (f : Lp ℂ 2 μ) : + ‖kernelLp k f‖ ≤ (k.bound * ‖(oneLp : Lp ℂ 2 μ)‖^2) * ‖f‖ := by + have h : ‖kernelLp k f‖ ≤ (k.bound * ‖(oneLp : Lp ℂ 2 μ)‖ * ‖f‖) * ‖(oneLp : Lp ℂ 2 μ)‖ := by + apply Lp.norm_le_mul_norm_of_ae_le_mul + filter_upwards [kernelLp_coe k f, oneLp_coe (μ := μ)] with x h₁ h₂ + rw [h₁, h₂, norm_one, mul_one] + exact kernelFun_norm_bound k f x + nlinarith [h] + +noncomputable def kernelLinear : Lp ℂ 2 μ →ₗ[ℂ] Lp ℂ 2 μ where + toFun := kernelLp k + map_add' := kernelLp_add k + map_smul' c f := by simpa only [RingHom.id_apply] using kernelLp_smul k c f + +noncomputable def kernelOp : Lp ℂ 2 μ →L[ℂ] Lp ℂ 2 μ := + (kernelLinear k).mkContinuous (k.bound * ‖(oneLp : Lp ℂ 2 μ)‖^2) (kernelLp_norm_le k) + +lemma kernelOp_coe (f : Lp ℂ 2 μ) : (kernelOp k f : X → ℂ) =ᵐ[μ] kernelFun k f := kernelLp_coe k f + +lemma inner_one_eq_integral (f : Lp ℂ 2 μ) : + ⟪(oneLp : Lp ℂ 2 μ), f⟫ = ∫ x, f x ∂μ := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [oneLp_coe (μ := μ)] with x hx + simp only [hx, RCLike.inner_apply, map_one, mul_one] + +lemma kernelFun_domination (f g : Lp ℂ 2 μ) + (hfg : ∀ᵐ y ∂μ, ‖f y‖ ≤ (g y).re) (x : X) : + ‖kernelFun k f x‖ ≤ (kernelFun k g x).re := by + unfold kernelFun + have hr := integral_re (kernel_section_integrable k g x) + simp only [RCLike.re_eq_complex_re] at hr + rw [← hr] + apply (norm_integral_le_integral_norm _).trans + apply integral_mono_ae (kernel_section_integrable k f x).norm + (kernel_section_integrable k g x).re + filter_upwards [hfg] with y hy + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (k.nonneg _), RCLike.re_eq_complex_re, Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, zero_mul, sub_zero] + exact mul_le_mul_of_nonneg_left hy (k.nonneg _) + +lemma kernelOp_domination (f g : Lp ℂ 2 μ) + (hfg : ∀ᵐ y ∂μ, ‖f y‖ ≤ (g y).re) : + ∀ᵐ x ∂μ, ‖kernelOp k f x‖ ≤ (kernelOp k g x).re := by + filter_upwards [kernelOp_coe k f, kernelOp_coe k g] with x hf hg + rw [hf, hg] + exact kernelFun_domination k f g hfg x + +lemma kernel_pow_domination (n : ℕ) (f g : Lp ℂ 2 μ) + (hfg : ∀ᵐ y ∂μ, ‖f y‖ ≤ (g y).re) : + ∀ᵐ x ∂μ, ‖(kernelOp k ^ n) f x‖ ≤ ((kernelOp k ^ n) g x).re := by + induction n with + | zero => simpa using hfg + | succ n hn => + simpa only [pow_succ', mul_apply_eq_comp] using kernelOp_domination k _ _ hn + +lemma kernel_norm_le_integral (f : Lp ℂ 2 μ) : + ‖kernelOp k f‖ ≤ k.bound * ‖(oneLp : Lp ℂ 2 μ)‖ * (∫ x, ‖f x‖ ∂μ) := by + have h : ‖kernelOp k f‖ ≤ (k.bound * ∫ x, ‖f x‖ ∂μ) * ‖(oneLp : Lp ℂ 2 μ)‖ := by + apply Lp.norm_le_mul_norm_of_ae_le_mul + filter_upwards [kernelOp_coe k f, oneLp_coe (μ := μ)] with x hx ho + rw [hx, ho, norm_one, mul_one] + exact kernelFun_bound k f x + nlinarith [h] + +noncomputable def pathMass (n : ℕ) : ℝ := + (⟪(oneLp : Lp ℂ 2 μ), (kernelOp k ^ n) oneLp⟫).re + +lemma pathMass_eq_integral (n : ℕ) : + pathMass (μ := μ) k n = ∫ x, (((kernelOp (μ := μ) k ^ n) (oneLp : Lp ℂ 2 μ)) x).re ∂μ := by + rw [pathMass, inner_one_eq_integral] + have hr := integral_re ((Lp.memLp ((kernelOp k ^ n) (oneLp : Lp ℂ 2 μ))).integrable (by norm_num)) + simpa only [RCLike.re_eq_complex_re] using hr.symm + +lemma pathMass_nonneg (n : ℕ) : 0 ≤ pathMass (μ := μ) k n := by + rw [pathMass_eq_integral] + apply integral_nonneg_of_ae + have h : ∀ᵐ x ∂μ, ‖(0 : Lp ℂ 2 μ) x‖ ≤ ((oneLp : Lp ℂ 2 μ) x).re := by + filter_upwards [Lp.coeFn_zero ℂ 2 μ, oneLp_coe (μ := μ)] with x hz ho + simp only [Pi.zero_apply] at hz + rw [hz, ho] + norm_num + have hd := kernel_pow_domination k n 0 oneLp h + simp only [map_zero] at hd + filter_upwards [hd, Lp.coeFn_zero ℂ 2 μ] with x hx hz + simp only [Pi.zero_apply] at hz + rwa [hz, norm_zero] at hx + +lemma pathMass_le (n : ℕ) : + pathMass (μ := μ) k n ≤ ‖(oneLp : Lp ℂ 2 μ)‖^2 * ‖(kernelOp (μ := μ) k)‖^n := by + unfold pathMass + calc + _ ≤ ‖⟪(oneLp : Lp ℂ 2 μ), (kernelOp k ^ n) oneLp⟫‖ := Complex.re_le_norm _ + _ ≤ ‖(oneLp : Lp ℂ 2 μ)‖ * ‖(kernelOp k ^ n) oneLp‖ := norm_inner_le_norm _ _ + _ ≤ ‖(oneLp : Lp ℂ 2 μ)‖ * (‖(kernelOp k ^ n : Lp ℂ 2 μ →L[ℂ] Lp ℂ 2 μ)‖ * ‖(oneLp : Lp ℂ 2 μ)‖) := + mul_le_mul_of_nonneg_left (ContinuousLinearMap.le_opNorm _ _) (norm_nonneg _) + _ ≤ ‖(oneLp : Lp ℂ 2 μ)‖ * (‖(kernelOp (μ := μ) k)‖^n * ‖(oneLp : Lp ℂ 2 μ)‖) := by + gcongr + rcases n with _ | n + · exact ContinuousLinearMap.norm_id_le + · exact norm_pow_le' _ (Nat.succ_pos _) + _ = _ := by ring + +lemma kernel_pow_norm_le_pathMass (n : ℕ) : + ‖(kernelOp (μ := μ) k ^ (n+2))‖ ≤ + k.bound^2 * ‖(oneLp : Lp ℂ 2 μ)‖^2 * pathMass (μ := μ) k n := by + apply ContinuousLinearMap.opNorm_le_bound + · exact mul_nonneg (mul_nonneg (sq_nonneg _) (sq_nonneg _)) (pathMass_nonneg k n) + intro f + let C := k.bound * ‖(oneLp : Lp ℂ 2 μ)‖ * ‖f‖ + have hf : ∀ᵐ x ∂μ, ‖kernelOp k f x‖ ≤ (((C : ℂ) • (oneLp : Lp ℂ 2 μ)) x).re := by + filter_upwards [kernelOp_coe k f, oneLp_coe (μ := μ), + Lp.coeFn_smul (C : ℂ) (oneLp : Lp ℂ 2 μ)] with x hx ho hs + rw [hx, hs] + simp only [Pi.smul_apply, smul_eq_mul, ho, mul_one, Complex.ofReal_re] + exact kernelFun_norm_bound k f x + have hd := kernel_pow_domination k n _ _ hf + rw [map_smul] at hd + have hi : (∫ x, ‖(kernelOp k ^ n) (kernelOp k f) x‖ ∂μ) ≤ + C * pathMass (μ := μ) k n := by + rw [pathMass_eq_integral, ← integral_const_mul] + have hrg : Integrable (fun x => (((kernelOp k ^ n) (oneLp : Lp ℂ 2 μ)) x).re) μ := by + simpa only [RCLike.re_eq_complex_re] using + ((Lp.memLp ((kernelOp k ^ n) (oneLp : Lp ℂ 2 μ))).integrable (by norm_num)).re + apply integral_mono_ae ((Lp.memLp ((kernelOp k ^ n) (kernelOp k f))).integrable (by norm_num)).norm + (hrg.const_mul C) + filter_upwards [hd, Lp.coeFn_smul (C : ℂ) ((kernelOp k ^ n) (oneLp : Lp ℂ 2 μ))] with x hx hs + rw [hs] at hx + simpa only [Pi.smul_apply, smul_eq_mul, Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, zero_mul, sub_zero] using hx + have he : (kernelOp k ^ (n+2)) f = kernelOp k ((kernelOp k ^ n) (kernelOp k f)) := by + rw [show n+2 = (n+1)+1 by omega, pow_succ', pow_succ, + mul_apply_eq_comp, mul_apply_eq_comp] + rw [he] + apply (kernel_norm_le_integral k _).trans + apply (mul_le_mul_of_nonneg_left hi (mul_nonneg k.bound_nonneg (norm_nonneg _))).trans + exact le_of_eq (by dsimp [C]; ring) + +lemma kernel_pair_integrable (f g : Lp ℂ 2 μ) : + Integrable (fun p : X × X => (k.value p : ℂ) * g p.2 * conj (f p.1)) (μ.prod μ) := by + have hf := ((Lp.memLp f).integrable (by norm_num : (1:ℝ≥0∞) ≤ 2)).norm + have hg := ((Lp.memLp g).integrable (by norm_num : (1:ℝ≥0∞) ≤ 2)).norm + apply Integrable.mono' ((hf.mul_prod hg).const_mul k.bound) + (((Complex.continuous_ofReal.comp_aestronglyMeasurable k.measurable.aestronglyMeasurable).mul + (Lp.memLp g).aestronglyMeasurable.comp_snd).mul + (continuous_star.comp_aestronglyMeasurable (Lp.memLp f).aestronglyMeasurable.comp_fst)) + exact Filter.Eventually.of_forall fun p => by + change ‖(k.value p : ℂ) * g p.2 * conj (f p.1)‖ ≤ k.bound * (‖f p.1‖ * ‖g p.2‖) + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (k.nonneg _), Complex.norm_conj] + calc + _ ≤ k.bound * ‖g p.2‖ * ‖f p.1‖ := by gcongr; exact k.le_bound p + _ = _ := by ring + +lemma inner_kernel (f g : Lp ℂ 2 μ) : + ⟪f, kernelOp k g⟫ = ∫ x, ∫ y, (k.value (x,y) : ℂ) * g y * conj (f x) ∂μ ∂μ := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [kernelOp_coe k g] with x hx + simp only [RCLike.inner_apply, hx, kernelFun, integral_mul_const] + +lemma kernelOp_selfAdjoint (hs : ∀ x y, k.value (x,y) = k.value (y,x)) : + IsSelfAdjoint (kernelOp (μ := μ) k) := by + apply ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mpr + intro f g + change ⟪kernelOp k f, g⟫ = ⟪f, kernelOp k g⟫ + rw [← inner_conj_symm, inner_kernel, ← integral_conj] + simp_rw [← integral_conj] + simp only [map_mul, Complex.conj_conj, Complex.conj_ofReal] + conv_rhs => rw [inner_kernel, integral_integral_swap (kernel_pair_integrable k f g)] + apply integral_congr_ae + exact Filter.Eventually.of_forall fun x => integral_congr_ae + (Filter.Eventually.of_forall fun y => by dsimp only; rw [hs x y]; ring) + +end Kernel +end HeatL2 + +open MeasureTheory Filter +open scoped ENNReal ComplexInnerProductSpace + +namespace HeatL2 + +lemma le_of_pow_le_const_mul_pow {a b C : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + (h : ∀ n : ℕ, a^n ≤ C*b^n) : a ≤ b := by + by_contra hn + have hab : b < a := lt_of_not_ge hn + have ha' : 0 < a := hb.trans_lt hab + have hr : b/a < 1 := (div_lt_one ha').mpr hab + have ht : Tendsto (fun n : ℕ => C*(b/a)^n) atTop (nhds 0) := by + simpa using tendsto_const_nhds.mul (tendsto_pow_atTop_nhds_zero_of_lt_one (div_nonneg hb ha) hr) + have hh (n : ℕ) : 1 ≤ C*(b/a)^n := by + rw [div_pow, ← mul_div_assoc, le_div_iff₀ (pow_pos ha' n)] + simpa only [one_mul] using h n + have := ge_of_tendsto' ht hh + linarith + +section Kernel +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} [IsFiniteMeasure μ] +variable (k : BoundedKernel X) + +lemma kernel_norm_pow_le_pathMass (hs : ∀ x y, k.value (x,y) = k.value (y,x)) (n : ℕ) : + ‖kernelOp (μ := μ) k‖^(n+2) ≤ + k.bound^2 * ‖(oneLp : Lp ℂ 2 μ)‖^2 * pathMass (μ := μ) k n := by + rw [← selfAdjoint_norm_pow _ (kernelOp_selfAdjoint k hs) (n+2) (by omega)] + exact kernel_pow_norm_le_pathMass k n + +lemma norm_lower_of_pathMass_lower {a c : ℝ} (ha : 0 ≤ a) (hc : 0 < c) + (h : ∀ n : ℕ, c*a^n ≤ pathMass (μ := μ) k n) : a ≤ ‖kernelOp (μ := μ) k‖ := by + apply le_of_pow_le_const_mul_pow ha (norm_nonneg _) (C := ‖(oneLp : Lp ℂ 2 μ)‖^2/c) + intro n + have hn := (h n).trans (pathMass_le k n) + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hc).mpr + simpa only [mul_comm c] using hn + +end Kernel +end HeatL2 + +open MeasureTheory Filter +open scoped ComplexInnerProductSpace ENNReal +namespace HeatL2 +section Restrict +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} +variable (D : Set X) (hD : MeasurableSet D) +noncomputable def extendLp (f : Lp ℂ 2 (μ.restrict D)) : Lp ℂ 2 μ := + ((memLp_indicator_iff_restrict hD).mpr (Lp.memLp f)).toLp (D.indicator f) +lemma extendLp_coe (f : Lp ℂ 2 (μ.restrict D)) : + (extendLp D hD f : X → ℂ) =ᵐ[μ] D.indicator f := MemLp.coeFn_toLp _ +lemma extendLp_norm (f : Lp ℂ 2 (μ.restrict D)) : ‖extendLp D hD f‖ = ‖f‖ := by + rw [Lp.norm_def, Lp.norm_def] + congr 1 + rw [eLpNorm_congr_ae (extendLp_coe D hD f), eLpNorm_indicator_eq_eLpNorm_restrict hD] +lemma extendLp_supported (f : Lp ℂ 2 (μ.restrict D)) : extendLp D hD f ∈ supported D := by + filter_upwards [extendLp_coe D hD f] with x hx hnot + simp [hx, hnot] +noncomputable def restrictLp (f : Lp ℂ 2 μ) : Lp ℂ 2 (μ.restrict D) := + ((Lp.memLp f).restrict D).toLp f +lemma restrictLp_coe (f : Lp ℂ 2 μ) : + (restrictLp D f : X → ℂ) =ᵐ[μ.restrict D] f := MemLp.coeFn_toLp _ +lemma extend_restrict (f : Lp ℂ 2 μ) : extendLp D hD (restrictLp D f) = mask D hD f := by + apply Lp.ext + have hr := (ae_restrict_iff' hD).mp (restrictLp_coe D f) + filter_upwards [extendLp_coe D hD (restrictLp D f), mask_coe D hD f, hr] with x h₁ h₂ h₃ + rw [h₁,h₂] + by_cases hx : x ∈ D + · simpa only [Set.indicator_of_mem hx] using h₃ hx + · simp [hx] +lemma extend_restrict_supported (f : Lp ℂ 2 μ) (hf : f ∈ supported D) : + extendLp D hD (restrictLp D f) = f := by + rw [extend_restrict, (mask_eq_self_iff D hD f).mpr hf] +end Restrict +end HeatL2 + +open MeasureTheory FourierTransform Filter Set +open scoped ComplexInnerProductSpace +namespace HeatL2 + +lemma weighted_rpow_jensen {X : Type*} [MeasurableSpace X] {μ : Measure X} + {g v : X → ℝ} (hg : Measurable g) (hgi : Integrable g μ) + (hgn : ∀ x, 0 ≤ g x) (hg1 : ∫ x, g x ∂μ = 1) + (hv : Measurable v) (hv01 : ∀ x, v x ∈ Icc (0:ℝ) 1) + {p : ℝ} (hp : 1 ≤ p) : + (∫ x, v x * g x ∂μ)^p ≤ ∫ x, (v x)^p * g x ∂μ := by + let ν := μ.withDensity (fun x => ENNReal.ofReal (g x)) + have : IsProbabilityMeasure ν := by + apply isProbabilityMeasure_iff.mpr + change μ.withDensity (fun x => ENNReal.ofReal (g x)) Set.univ = 1 + rw [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ, + ← ofReal_integral_eq_lintegral_ofReal hgi (ae_of_all _ hgn), hg1] + norm_num + have he (f : X → ℝ) : (∫ x, f x ∂ν) = ∫ x, f x * g x ∂μ := by + change (∫ x, f x ∂(μ.withDensity (fun x => ENNReal.ofReal (g x)))) = _ + rw [integral_withDensity_eq_integral_toReal_smul hg.ennreal_ofReal + (ae_of_all _ fun x => ENNReal.ofReal_lt_top) f] + simp only [ENNReal.toReal_ofReal (hgn _), smul_eq_mul, mul_comm (g _)] + have hcont : Continuous (fun x : ℝ => x^p) := Real.continuous_rpow_const (by positivity) + have hi : Integrable v ν := Integrable.of_bound hv.aestronglyMeasurable 1 + (ae_of_all _ fun x => by rw [Real.norm_eq_abs, abs_of_nonneg (hv01 x).1]; exact (hv01 x).2) + have hip : Integrable (fun x => (v x)^p) ν := Integrable.of_bound + (hcont.measurable.comp hv).aestronglyMeasurable 1 (ae_of_all _ fun x => by + rw [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg (hv01 x).1 _)] + exact Real.rpow_le_one (hv01 x).1 (hv01 x).2 (by linarith)) + have h := (convexOn_rpow hp).map_integral_le hcont.continuousOn isClosed_Ici + (ae_of_all ν fun x => (hv01 x).1) hi hip + simpa only [Pi.neg_apply, he] using h + +section Form +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma heat_inner_integral (w : E → ℝ) (hw : AEStronglyMeasurable w volume) + (hn : ∀ x, 0 ≤ w x) (f : Lp ℂ 2 (volume : Measure E)) : + (⟪f, heat w hw hn f⟫).re = ∫ ξ, Real.exp (-w ξ) * ‖(𝓕 f) ξ‖^2 := by + rw [heat, spectralOp_inner] + rfl + +lemma heat_form_rpow (w : E → ℝ) (hw : Measurable w) (hn : ∀ x, 0 ≤ w x) + {t η : ℝ} (hη : 0 < η) (hηt : η ≤ t) + (f : Lp ℂ 2 (volume : Measure E)) (hf : ‖f‖ = 1) : + ((⟪f, heat (fun ξ => η*w ξ) (hw.const_mul η).aestronglyMeasurable + (fun ξ => mul_nonneg hη.le (hn ξ)) f⟫).re) ^ (t/η) ≤ + (⟪f, heat (fun ξ => t*w ξ) (hw.const_mul t).aestronglyMeasurable + (fun ξ => mul_nonneg (hη.le.trans hηt) (hn ξ)) f⟫).re := by + simp only [heat_inner_integral] + have hg1 : (∫ ξ, ‖(𝓕 f) ξ‖^2) = 1 := by + rw [← norm_sq_integral, Lp.norm_fourier_eq, hf, one_pow] + have h := weighted_rpow_jensen + ((Lp.stronglyMeasurable (𝓕 f)).measurable.norm.pow_const 2) + ((Lp.memLp (𝓕 f)).integrable_norm_pow (by norm_num : (2:ℕ) ≠ 0)) + (fun _ => sq_nonneg _) hg1 ((hw.const_mul η).neg.exp) + (fun ξ => ⟨(Real.exp_pos _).le, + Real.exp_le_one_iff.mpr (neg_nonpos.mpr (mul_nonneg hη.le (hn ξ)))⟩) + ((one_le_div hη).mpr hηt) + have he (ξ : E) : Real.exp (-(η*w ξ)) ^ (t/η) = Real.exp (-(t*w ξ)) := by + rw [← Real.exp_mul] + congr 1 + field_simp + simpa only [Pi.neg_apply, he] using h + +end Form +end HeatL2 + +open MeasureTheory ComplexConjugate +open scoped ENNReal ComplexInnerProductSpace +namespace HeatL2 + +section Spatial +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +lemma inner_translate_integral (a : E) (f g : Lp ℂ 2 (volume : Measure E)) : + ⟪g, translate a f⟫ = ∫ x, f (x+a) * conj (g x) := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [translate_coe a f] with x hx + simp only [RCLike.inner_apply, hx] + +omit [FiniteDimensional ℝ F] in +lemma integrable_translate_pair (A : F →L[ℝ] E) (ν : Measure F) [IsFiniteMeasure ν] + (f g : Lp ℂ 2 (volume : Measure E)) : + Integrable (fun p : F × E => f (p.2+A p.1) * conj (g p.2)) (ν.prod volume) := by + have hm : StronglyMeasurable (fun p : F × E => f (p.2+A p.1) * conj (g p.2)) := by + exact ((Lp.stronglyMeasurable f).comp_measurable (by fun_prop)).mul + (continuous_star.comp_stronglyMeasurable ((Lp.stronglyMeasurable g).comp_measurable measurable_snd)) + apply (integrable_prod_iff hm.aestronglyMeasurable).mpr + constructor + · apply Filter.Eventually.of_forall + intro z + apply (L2.integrable_inner (𝕜 := ℂ) g (translate (A z) f)).congr + filter_upwards [translate_coe (A z) f] with x hx + simp only [RCLike.inner_apply, hx] + · apply Integrable.mono' (integrable_const (‖f‖^2+‖g‖^2)) hm.norm.aestronglyMeasurable.integral_prod_right' + apply Filter.Eventually.of_forall + intro z + rw [Real.norm_eq_abs, abs_of_nonneg (integral_nonneg fun _ => norm_nonneg _)] + have hfi : Integrable (fun x => ‖f (x+A z)‖^2) volume := (measurePreserving_add_right volume (A z)).integrable_comp_of_integrable + ((Lp.memLp f).integrable_norm_pow (by norm_num : (2:ℕ)≠0)) + have hgi := (Lp.memLp g).integrable_norm_pow (by norm_num : (2:ℕ)≠0) + calc + _ ≤ ∫ x, ‖f (x+A z)‖^2+‖g x‖^2 := by + apply integral_mono_of_nonneg (Filter.Eventually.of_forall fun _ => norm_nonneg _) + (hfi.add hgi) + apply Filter.Eventually.of_forall + intro x + change ‖f (x+A z)*conj (g x)‖ ≤ ‖f (x+A z)‖^2+‖g x‖^2 + simp only [norm_mul, Complex.norm_conj] + nlinarith [sq_nonneg (‖f (x+A z)‖-‖g x‖)] + _ = _ := by + rw [integral_add hfi hgi, integral_add_right_eq_self (fun x => ‖f x‖^2) (A z), + ← norm_sq_integral, ← norm_sq_integral] + +lemma inner_average_spatial (A : F →L[ℝ] E) (ν : Measure F) [IsProbabilityMeasure ν] + (f g : Lp ℂ 2 (volume : Measure E)) : + ⟪g, average A ν f⟫ = ∫ x, ∫ z, f (x+A z)*conj (g x) ∂ν := by + rw [average_apply, ← integral_inner (integrable_translate A ν f)] + simp_rw [inner_translate_integral] + exact integral_integral_swap (integrable_translate_pair A ν f g) + +end Spatial +section Density +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma inner_average_density (ν : Measure E) [IsProbabilityMeasure ν] + (p : E → ℝ) (hp : Measurable p) (hpn : ∀ x, 0 ≤ p x) + (hν : ν = volume.withDensity (fun x => ENNReal.ofReal (p x))) + (f g : Lp ℂ 2 (volume : Measure E)) : + ⟪g, average (ContinuousLinearMap.id ℝ E) ν f⟫ = + ∫ x, ∫ y, (p (y-x) : ℂ) * f y * conj (g x) := by + rw [inner_average_spatial] + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro x + dsimp only + rw [hν, integral_withDensity_eq_integral_toReal_smul hp.ennreal_ofReal + (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] + simp only [ENNReal.toReal_ofReal (hpn _), ContinuousLinearMap.id_apply, + Complex.real_smul, mul_assoc] + have he (z : E) : (p z : ℂ)*(f (x+z)*conj (g x)) = + (p ((z+x)-x) : ℂ)*(f (z+x)*conj (g x)) := by simp [add_comm] + simp_rw [he] + exact integral_add_right_eq_self (μ := (volume : Measure E)) + (fun y => (p (y-x) : ℂ)*(f y*conj (g x))) x + +noncomputable def densityKernel (p : E → ℝ) (hp : Measurable p) (hpn : ∀ x, 0 ≤ p x) + (hpb : ∀ x, p x ≤ p 0) : BoundedKernel E where + value xy := p (xy.2-xy.1) + measurable := hp.comp (measurable_snd.sub measurable_fst) + nonneg _ := hpn _ + bound := p 0 + bound_nonneg := hpn _ + le_bound _ := hpb _ + +variable (D : Set E) (hD : MeasurableSet D) + +lemma integral_extend_mul (f : Lp ℂ 2 (volume.restrict D)) (a : E → ℂ) : + (∫ x, a x * (extendLp D hD f) x) = ∫ x in D, a x * f x := by + calc + _ = ∫ x, D.indicator (fun y => a y*f y) x := by + apply integral_congr_ae + filter_upwards [extendLp_coe D hD f] with x hx + rw [hx] + by_cases hxD : x ∈ D <;> simp [hxD] + _ = _ := integral_indicator hD + +lemma integral_extend_conj (f : Lp ℂ 2 (volume.restrict D)) (a : E → ℂ) : + (∫ x, a x * conj ((extendLp D hD f) x)) = ∫ x in D, a x * conj (f x) := by + calc + _ = ∫ x, D.indicator (fun y => a y*conj (f y)) x := by + apply integral_congr_ae + filter_upwards [extendLp_coe D hD f] with x hx + rw [hx] + by_cases hxD : x ∈ D <;> simp [hxD] + _ = _ := integral_indicator hD + +lemma inner_extend (f : Lp ℂ 2 (volume.restrict D)) (g : Lp ℂ 2 (volume : Measure E)) : + ⟪g, extendLp D hD f⟫ = ⟪restrictLp D g, f⟫ := by + rw [L2.inner_def, L2.inner_def] + calc + _ = ∫ x in D, conj (g x)*f x := by + simpa only [RCLike.inner_apply, mul_comm] using integral_extend_mul D hD f (fun x => conj (g x)) + _ = _ := by + apply integral_congr_ae + filter_upwards [restrictLp_coe D g] with x hx + simp only [RCLike.inner_apply, hx, mul_comm] + +lemma densityKernel_inner (ν : Measure E) [IsProbabilityMeasure ν] + (p : E → ℝ) (hp : Measurable p) (hpn : ∀ x, 0 ≤ p x) (hpb : ∀ x, p x ≤ p 0) + (hν : ν = volume.withDensity (fun x => ENNReal.ofReal (p x))) + [IsFiniteMeasure (volume.restrict D)] (f g : Lp ℂ 2 (volume.restrict D)) : + ⟪extendLp D hD g, average (ContinuousLinearMap.id ℝ E) ν (extendLp D hD f)⟫ = + ⟪g, kernelOp (densityKernel p hp hpn hpb) f⟫ := by + rw [inner_average_density ν p hp hpn hν, inner_kernel] + simp only [densityKernel] + calc + _ = ∫ x, (∫ y in D, (p (y-x) : ℂ)*f y)*conj ((extendLp D hD g) x) := by + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro x + dsimp only + rw [integral_mul_const, integral_extend_mul D hD f] + _ = ∫ x in D, (∫ y in D, (p (y-x) : ℂ)*f y)*conj (g x) := + integral_extend_conj D hD g _ + _ = _ := by simp only [integral_mul_const] + +lemma extend_kernel_eq (ν : Measure E) [IsProbabilityMeasure ν] + (p : E → ℝ) (hp : Measurable p) (hpn : ∀ x, 0 ≤ p x) (hpb : ∀ x, p x ≤ p 0) + (hν : ν = volume.withDensity (fun x => ENNReal.ofReal (p x))) + [IsFiniteMeasure (volume.restrict D)] (f : Lp ℂ 2 (volume.restrict D)) : + extendLp D hD (kernelOp (densityKernel p hp hpn hpb) f) = + mask D hD (average (ContinuousLinearMap.id ℝ E) ν (extendLp D hD f)) := by + apply ext_inner_left ℂ + intro g + rw [inner_extend, ← mask_inner, ← extend_restrict, + densityKernel_inner D hD ν p hp hpn hpb hν] + +include hD in +lemma restrictLp_norm_le (f : Lp ℂ 2 (volume : Measure E)) : ‖restrictLp D f‖ ≤ ‖f‖ := by + rw [← extendLp_norm D hD (restrictLp D f), extend_restrict] + exact mask_norm_le D hD f + +lemma compressedAverage_kernel_norm (ν : Measure E) [IsProbabilityMeasure ν] + (p : E → ℝ) (hp : Measurable p) (hpn : ∀ x, 0 ≤ p x) (hpb : ∀ x, p x ≤ p 0) + (hν : ν = volume.withDensity (fun x => ENNReal.ofReal (p x))) + [IsFiniteMeasure (volume.restrict D)] : + ‖mask D hD ∘L average (ContinuousLinearMap.id ℝ E) ν ∘L mask D hD‖ = + ‖kernelOp (μ := volume.restrict D) (densityKernel p hp hpn hpb)‖ := by + let T := mask D hD ∘L average (ContinuousLinearMap.id ℝ E) ν ∘L mask D hD + let K := kernelOp (μ := volume.restrict D) (densityKernel p hp hpn hpb) + change ‖T‖ = ‖K‖ + have he f : T f = extendLp D hD (K (restrictLp D f)) := by + rw [extend_kernel_eq D hD ν p hp hpn hpb hν, extend_restrict] + rfl + have he' f : extendLp D hD (K f) = T (extendLp D hD f) := by + rw [extend_kernel_eq D hD ν p hp hpn hpb hν] + change _ = mask D hD (average _ ν (mask D hD (extendLp D hD f))) + rw [(mask_eq_self_iff D hD _).mpr (extendLp_supported D hD f)] + apply le_antisymm + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro f + rw [he, extendLp_norm] + exact (K.le_opNorm _).trans (mul_le_mul_of_nonneg_left (restrictLp_norm_le D hD f) (norm_nonneg _)) + · apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) + intro f + rw [← extendLp_norm D hD (K f), he'] + simpa only [extendLp_norm] using T.le_opNorm (extendLp D hD f) + +end Density +end HeatL2 + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/KernelConvexity.lean b/lean/OAI/Analysis/Steinitz/KernelConvexity.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b9ebb29cb8393854311a1fa46df16abfd28888e --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/KernelConvexity.lean @@ -0,0 +1,153 @@ +import OAI.Analysis.Steinitz.Prekopa + +namespace OAI + +/-! Convexity and norm inequalities for Gaussian kernels. -/ + +section + +open MeasureTheory Set Filter +open scoped ENNReal ComplexInnerProductSpace +namespace HeatL2 + +lemma le_of_shifted_pow_le_const_mul_pow {a b K : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + (h : ∀ n : ℕ, a^(n+2) ≤ K*b^n) : a ≤ b := by + by_cases hz : a = 0 + · simpa [hz] using hb + have hp : 0 < a^2 := sq_pos_of_ne_zero hz + apply le_of_pow_le_const_mul_pow ha hb (C := K/a^2) + intro n + rw [div_mul_eq_mul_div, le_div_iff₀ hp, ← pow_add] + exact h n + +section +variable {X : Type*} [MeasurableSpace X] +variable (k : BoundedKernel X) (hs : ∀ x y, k.value (x,y) = k.value (y,x)) +variable (μ ν ω : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure ν] [IsFiniteMeasure ω] + +include hs in +lemma kernel_norm_logconcave_of_pathMass {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) + (h : ∀ n, pathMass (μ := μ) k n^(1-t) * pathMass (μ := ν) k n^t ≤ pathMass (μ := ω) k n) : + ‖kernelOp (μ := μ) k‖^(1-t) * ‖kernelOp (μ := ν) k‖^t ≤ ‖kernelOp (μ := ω) k‖ := by + let A := k.bound^2 * ‖(oneLp : Lp ℂ 2 μ)‖^2 + let B := k.bound^2 * ‖(oneLp : Lp ℂ 2 ν)‖^2 + let C := ‖(oneLp : Lp ℂ 2 ω)‖^2 + have hA : 0 ≤ A := by dsimp [A]; positivity + have hB : 0 ≤ B := by dsimp [B]; positivity + apply le_of_shifted_pow_le_const_mul_pow (by positivity) (norm_nonneg _) + (K := A^(1-t)*B^t*C) + intro n + rw [mul_pow, Real.rpow_pow_comm (norm_nonneg _), Real.rpow_pow_comm (norm_nonneg _)] + calc + _ ≤ (A*pathMass (μ := μ) k n)^(1-t) * (B*pathMass (μ := ν) k n)^t := by + apply mul_le_mul + · exact Real.rpow_le_rpow (by positivity) (kernel_norm_pow_le_pathMass k hs n) (sub_nonneg.mpr ht.2) + · exact Real.rpow_le_rpow (by positivity) (kernel_norm_pow_le_pathMass k hs n) ht.1 + · exact Real.rpow_nonneg (by positivity) _ + · exact Real.rpow_nonneg (mul_nonneg hA (pathMass_nonneg k n)) _ + _ = (A^(1-t)*B^t) * (pathMass (μ := μ) k n^(1-t)*pathMass (μ := ν) k n^t) := by + rw [Real.mul_rpow hA (pathMass_nonneg k n), Real.mul_rpow hB (pathMass_nonneg k n)] + ring + _ ≤ (A^(1-t)*B^t)*pathMass (μ := ω) k n := + mul_le_mul_of_nonneg_left (h n) (mul_nonneg (Real.rpow_nonneg hA _) (Real.rpow_nonneg hB _)) + _ ≤ (A^(1-t)*B^t)*(C*‖kernelOp (μ := ω) k‖^n) := + mul_le_mul_of_nonneg_left (pathMass_le k n) (mul_nonneg (Real.rpow_nonneg hA _) (Real.rpow_nonneg hB _)) + _ = _ := by ring +end + +section Haar +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] +variable [MeasureSpace E] [BorelSpace E] +variable [(volume : Measure E).IsAddHaarMeasure] +variable (k : BoundedKernel E) (hk : Continuous k.value) (hp : ∀ z, 0 < k.value z) +variable {A B C : Set E} [IsFiniteMeasure (volume.restrict A)] + [IsFiniteMeasure (volume.restrict B)] [IsFiniteMeasure (volume.restrict C)] + +include hk hp in +lemma pathMass_logconcave_haar + (ha : Bornology.IsBounded A) (hb : Bornology.IsBounded B) (hc : Bornology.IsBounded C) + (hca : Convex ℝ A) (hcb : Convex ℝ B) (hcc : Convex ℝ C) + (hneA : A.Nonempty) (hneB : B.Nonempty) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) + (hl : ∀ x y : E × E, k.value x^(1-t)*k.value y^t ≤ k.value ((1-t)•x+t•y)) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-t)•a+t•b ∈ C) (n : ℕ) : + pathMass (μ := volume.restrict A) k n^(1-t) * pathMass (μ := volume.restrict B) k n^t ≤ + pathMass (μ := volume.restrict C) k n := by + let PA := Set.pi univ (fun _ : Fin (n+1) => A) + let PB := Set.pi univ (fun _ : Fin (n+1) => B) + let PC := Set.pi univ (fun _ : Fin (n+1) => C) + have hnePA : PA.Nonempty := by + obtain ⟨a,ha'⟩ := hneA + exact ⟨fun _ => a, fun _ _ => ha'⟩ + have hnePB : PB.Nonempty := by + obtain ⟨b,hb'⟩ := hneB + exact ⟨fun _ => b, fun _ _ => hb'⟩ + have hM : 0 < k.bound^n := by + have : 0 < k.bound := (hp (0,0)).trans_le (k.le_bound _) + positivity + have hwpos (p : Fin (n+1) → E) : 0 < chainWeight k n p := tailWeight_pos k hp n _ _ + have hh := Prekopa.bounded_weight_convex_haar (volume : Measure (Fin (n+1) → E)) + (chainWeight_continuous k hk n) hwpos hM (fun p => tailWeight_le k n (p 0) (fun i => p i.succ)) + (Bornology.IsBounded.pi (fun _ => ha)) (Bornology.IsBounded.pi (fun _ => hb)) + (Bornology.IsBounded.pi (fun _ => hc)) + (convex_pi (fun _ _ => hca)) (convex_pi (fun _ _ => hcb)) (convex_pi (fun _ _ => hcc)) + hnePA hnePB ht (chainWeight_logconcave k hl n) (by + intro a ha' b hb' i hi + exact hABC (a i) (ha' i hi) (b i) (hb' i hi)) + simpa only [pathMass_pi, volume_pi, Measure.restrict_pi_pi] using hh + +end Haar +end HeatL2 + +end + +section + +open MeasureTheory Set Filter +open scoped ENNReal NNReal ComplexInnerProductSpace +namespace GaussianKernel +variable {ι : Type*} [Fintype ι] + +lemma kernel_value_continuous (v : ι → ℝ≥0) : Continuous (kernel v).value := by + exact (density_continuous v).comp (continuous_snd.sub continuous_fst) + +lemma kernel_value_pos (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) + (z : EuclideanSpace ℝ ι × EuclideanSpace ℝ ι) : 0 < (kernel v).value z := + density_pos v hv _ + +lemma kernel_value_logconcave (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) + {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (x y : EuclideanSpace ℝ ι × EuclideanSpace ℝ ι) : + (kernel v).value x^(1-t)*(kernel v).value y^t ≤ (kernel v).value ((1-t)•x+t•y) := by + change density v (x.2-x.1)^(1-t)*density v (y.2-y.1)^t ≤ + density v (((1-t)•x+t•y).2-((1-t)•x+t•y).1) + have he : ((1-t)•x+t•y).2-((1-t)•x+t•y).1 = + (1-t)•(x.2-x.1)+t•(y.2-y.1) := by + simp only [Prod.fst_add, Prod.snd_add, Prod.smul_fst, Prod.smul_snd] + module + rw [he] + exact density_logconcave v hv ht (x.2-x.1) (y.2-y.1) + +lemma compressed_norm_logconcave (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) + {A B C : Set (EuclideanSpace ℝ ι)} (hAo : IsOpen A) (hBo : IsOpen B) (hCo : IsOpen C) + (ha : Bornology.IsBounded A) (hb : Bornology.IsBounded B) (hc : Bornology.IsBounded C) + (hca : Convex ℝ A) (hcb : Convex ℝ B) (hcc : Convex ℝ C) + (hneA : A.Nonempty) (hneB : B.Nonempty) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-t)•a+t•b ∈ C) : + ‖HeatL2.compressedHeat A hAo.measurableSet (symbol v) (symbol_continuous v).aestronglyMeasurable (symbol_nonneg v)‖^(1-t) * + ‖HeatL2.compressedHeat B hBo.measurableSet (symbol v) (symbol_continuous v).aestronglyMeasurable (symbol_nonneg v)‖^t ≤ + ‖HeatL2.compressedHeat C hCo.measurableSet (symbol v) (symbol_continuous v).aestronglyMeasurable (symbol_nonneg v)‖ := by + classical + let : IsFiniteMeasure (volume.restrict A) := isFiniteMeasure_restrict.mpr ha.measure_lt_top.ne + let : IsFiniteMeasure (volume.restrict B) := isFiniteMeasure_restrict.mpr hb.measure_lt_top.ne + let : IsFiniteMeasure (volume.restrict C) := isFiniteMeasure_restrict.mpr hc.measure_lt_top.ne + rw [← kernel_norm_eq v hv A hAo.measurableSet, ← kernel_norm_eq v hv B hBo.measurableSet, + ← kernel_norm_eq v hv C hCo.measurableSet] + apply HeatL2.kernel_norm_logconcave_of_pathMass (kernel v) (kernel_symmetric v) _ _ _ ht + intro n + exact HeatL2.pathMass_logconcave_haar (kernel v) (kernel_value_continuous v) (kernel_value_pos v hv) + ha hb hc hca hcb hcc hneA hneB ht (kernel_value_logconcave v hv ht) hABC n + +end GaussianKernel + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/LiftedRearrangement.lean b/lean/OAI/Analysis/Steinitz/LiftedRearrangement.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fe08c58278beef3e58ddaee19e0d1d973172e1b --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/LiftedRearrangement.lean @@ -0,0 +1,485 @@ +import OAI.Analysis.Steinitz.SectionEnergy + +namespace OAI + +/-! Lifted fiber rearrangement and overlap estimates. -/ + +section + +open MeasureTheory MeasureTheory.Measure Set Filter +open scoped ENNReal +namespace VerticalRearrangement +section Lift +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +noncomputable def shear (e : E) : E × ℝ ≃ₜ E × ℝ where + toFun p := (p.1+p.2 • e,p.2) + invFun p := (p.1-p.2 • e,p.2) + left_inv p := by ext <;> simp + right_inv p := by ext <;> simp + continuous_toFun := by fun_prop + continuous_invFun := by fun_prop + +lemma shear_preserving (e : E) : MeasurePreserving (shear e) + ((volume : Measure E).prod volume) (volume.prod volume) := by + have hp : MeasurePreserving (fun p : ℝ × E => (p.1,p.2+p.1 • e)) + ((volume : Measure ℝ).prod (volume : Measure E)) (volume.prod volume) := by + apply (MeasurePreserving.id (volume : Measure ℝ)).skew_product + (g := fun s y => y+s • e) (by fun_prop) + exact ae_of_all _ fun s => (measurePreserving_add_right volume (s • e)).map_eq + exact (measurePreserving_swap (μ := (volume : Measure ℝ)) (ν := (volume : Measure E))).comp + (hp.comp (measurePreserving_swap (μ := (volume : Measure E)) (ν := (volume : Measure ℝ)))) + +noncomputable def liftFunction (ell c : ℝ) (e : E) (f : E → ℝ) (p : E × ℝ) : ℝ := + (Ioo (-ell) ell).indicator (fun s => c*f (p.1+s • e)) p.2 + +lemma lift_measurable (ell c : ℝ) (e : E) {f : E → ℝ} (hf : Measurable f) : + Measurable (liftFunction ell c e f) := by + have he : liftFunction ell c e f = + ((Prod.snd ⁻¹' Ioo (-ell) ell) : Set (E × ℝ)).indicator (fun p => c*f (p.1+p.2 • e)) := by + funext p + by_cases hp : p.2 ∈ Ioo (-ell) ell <;> simp [liftFunction,indicator,hp] + rw [he] + exact (measurable_const.mul (hf.comp (by fun_prop))).indicator (measurable_snd measurableSet_Ioo) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma lift_strip (ell c : ℝ) (e : E) (f : E → ℝ) (p : E × ℝ) + (hp : ell ≤ |p.2|) : liftFunction ell c e f p = 0 := by + apply indicator_of_notMem + intro hh + exact not_lt_of_ge hp (abs_lt.mpr hh) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma lift_nonneg (ell : ℝ) {c : ℝ} (hc : 0 ≤ c) (e : E) {f : E → ℝ} + (hf : ∀ x,0 ≤ f x) (p : E × ℝ) : 0 ≤ liftFunction ell c e f p := + indicator_nonneg (fun _ _ => mul_nonneg hc (hf _)) _ + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma lift_square_eq (ell c : ℝ) (e : E) (f : E → ℝ) : + (fun p => liftFunction ell c e f p^2) = + (fun p : E × ℝ => (f p.1)^2 * (Ioo (-ell) ell).indicator (fun _ => c^2) p.2) ∘ shear e := by + funext p + change liftFunction ell c e f p^2 = + f (p.1+p.2 • e)^2 * (Ioo (-ell) ell).indicator (fun _ => c^2) p.2 + by_cases hp : p.2 ∈ Ioo (-ell) ell + · simp only [liftFunction,indicator_of_mem hp,mul_pow] + ring + · simp only [liftFunction,indicator_of_notMem hp,zero_pow (by norm_num : 2 ≠ 0),mul_zero] + +lemma lift_memLp (ell c : ℝ) (e : E) {f : E → ℝ} (hm : Measurable f) + (hf : MemLp f 2 volume) : MemLp (liftFunction ell c e f) 2 (volume.prod volume) := by + apply (memLp_two_iff_integrable_sq (lift_measurable ell c e hm).aestronglyMeasurable).mpr + rw [lift_square_eq] + apply (shear_preserving e).integrable_comp_of_integrable + exact ((memLp_two_iff_integrable_sq hf.aestronglyMeasurable).mp hf).mul_prod + ((integrableOn_const (s := Ioo (-ell) ell) (C := c^2) (hs := by simp)).integrable_indicator measurableSet_Ioo) + +lemma lift_total_square {ell : ℝ} (hell : 0 ≤ ell) (c : ℝ) (e : E) (f : E → ℝ) : + (∫ p, liftFunction ell c e f p^2 ∂(volume : Measure E).prod volume) = + (2*ell)*c^2*(∫ x,f x^2) := by + rw [lift_square_eq] + change (∫ p, ((fun p : E × ℝ => (f p.1)^2 * + (Ioo (-ell) ell).indicator (fun _ => c^2) p.2) ((shear e) p)) ∂volume.prod volume) = _ + rw [(shear_preserving e).integral_comp (shear e).measurableEmbedding + (fun p : E × ℝ => f p.1^2 * (Ioo (-ell) ell).indicator (fun _ => c^2) p.2), + integral_prod_mul (fun y : E => f y^2) ((Ioo (-ell) ell).indicator (fun _ => c^2)), + integral_indicator measurableSet_Ioo,setIntegral_const,smul_eq_mul, + Real.volume_real_Ioo_of_le (by linarith : -ell ≤ ell)] + ring + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma lift_difference_eq (ell c : ℝ) (e a : E) (f : E → ℝ) (p : E × ℝ) : + liftFunction ell c e f (p.1+a,p.2)-liftFunction ell c e f p = + liftFunction ell c e (fun y => f (y+a)-f y) p := by + by_cases hp : p.2 ∈ Ioo (-ell) ell + · simp only [liftFunction,indicator_of_mem hp,show p.1+a+p.2 • e=p.1+p.2 • e+a by abel] + ring + · simp only [liftFunction,indicator_of_notMem hp,sub_self] + +lemma lift_total_difference {ell : ℝ} (hell : 0 ≤ ell) (c : ℝ) (e a : E) (f : E → ℝ) : + (∫ p, (liftFunction ell c e f (p.1+a,p.2)-liftFunction ell c e f p)^2 + ∂(volume : Measure E).prod volume) = (2*ell)*c^2*HeatL2.realDistance f a := by + simp_rw [lift_difference_eq] + exact lift_total_square hell c e _ + +end Lift +end VerticalRearrangement + +end + +section + +open MeasureTheory MeasureTheory.Measure Set +open scoped ENNReal +namespace VerticalRearrangement +section Lifting +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma fiberStar_horizontal_difference {ell c : ℝ} (hell : 0 ≤ ell) (hc : 0 ≤ c) + (e a : E) {f : E → ℝ} (hm : Measurable f) (hf : MemLp f 2 volume) + (hfn : ∀ x,0 ≤ f x) : + (∫ p, ((fiberStar (liftFunction ell c e f) (p.1+a,p.2)).toReal- + (fiberStar (liftFunction ell c e f) p).toReal)^2 ∂(volume : Measure E).prod volume) ≤ + (2*ell)*c^2*HeatL2.realDistance f a := by + let F := liftFunction ell c e f + let G := liftFunction ell c e (fun y => f (y+a)) + have hshift : ∀ p : E × ℝ,G p=F (p.1+a,p.2) := by + intro p + dsimp [G,F,liftFunction] + congr 2 + funext s + congr 2 + abel + have hg : Measurable (fun y : E => f (y+a)) := hm.comp (by fun_prop) + have hgLp : MemLp (fun y : E => f (y+a)) 2 volume := + hf.comp_measurePreserving (measurePreserving_add_right volume a) + have hh := fiberStar_total_difference (μ := (volume : Measure E)) + (lift_measurable ell c e hg) (lift_measurable ell c e hm) + (lift_nonneg ell hc e (fun y => hfn (y+a))) (lift_nonneg ell hc e hfn) + (superlevel_measure_ne_top_of_strip (lift_strip ell c e _)) + (superlevel_measure_ne_top_of_strip (lift_strip ell c e f)) + (lift_memLp ell c e hg hgLp) (lift_memLp ell c e hm hf) + change (∫ p,((fiberStar G p).toReal-(fiberStar F p).toReal)^2 ∂volume.prod volume) ≤ (∫ p,(G p-F p)^2 ∂volume.prod volume) at hh + have hstar : ∀ p : E × ℝ,fiberStar G p=fiberStar F (p.1+a,p.2) := by + intro p + unfold fiberStar + congr 2 + funext s + exact hshift (p.1,s) + simp_rw [hstar,hshift] at hh + exact hh.trans_eq (lift_total_difference hell c e a f) + +omit [FiniteDimensional ℝ E] [BorelSpace E] in +lemma lifted_star_supported {K : Set E} (hK : Convex ℝ K) {f : E → ℝ} + (hf : ∀ y,y ∉ K → f y=0) (ell c : ℝ) (e : E) + {p : E × ℝ} (hp : p.1 ∉ ShiftedSections.sectionDomain K e ell |p.2|) : + fiberStar (liftFunction ell c e f) p=0 := by + apply ShiftedSections.fiberStar_supported hK _ hp + intro q hq + rcases hq with hq | hq + · by_cases hs : q.2 ∈ Ioo (-ell) ell + · simp only [liftFunction,indicator_of_mem hs,hf _ hq,mul_zero] + · exact indicator_of_notMem hs _ + · exact lift_strip ell c e f q hq + +end Lifting +end VerticalRearrangement + +end + +section + +open MeasureTheory MeasureTheory.Measure Set +open scoped ENNReal +namespace VerticalRearrangement +section Height +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} [SFinite μ] + +lemma fiberStar_total_height {F : X × ℝ → ℝ} (hF : Measurable F) + (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) : + (∫⁻ p,ENNReal.ofReal |p.2| *(fiberStar F p)^2 ∂μ.prod volume) = + (∫⁻ r,∫⁻ t,∫⁻ x,(ENNReal.ofReal (min (F (x,r)) (F (x,t))))^2 ∂μ)/4 := by + have hm : Measurable (fun p : X × ℝ => ENNReal.ofReal |p.2| * (fiberStar F p)^2) := + measurable_snd.abs.ennreal_ofReal.mul ((fiberStar_measurable hF).pow_const 2) + rw [lintegral_prod _ hm.aemeasurable] + have hp x := function_rearranged_height volume + (show Measurable (fun s => F (x,s)) from hF.comp measurable_prodMk_left) (hfF x) + change (∫⁻ x, (∫⁻ s,ENNReal.ofReal |s| * (fiberStar F (x,s))^2) ∂μ) = _ + simp_rw [show ∀ x, (∫⁻ s, ENNReal.ofReal |s| *(fiberStar F (x,s))^2) = + (∫⁻ r,∫⁻ t, (ENNReal.ofReal (min (F (x,r)) (F (x,t))))^2)/4 from hp, + div_eq_mul_inv] + rw [lintegral_mul_const' (4:ℝ≥0∞)⁻¹ _ (by norm_num)] + congr 1 + rw [lintegral_lintegral_swap] + · apply lintegral_congr + intro r + apply lintegral_lintegral_swap + exact (((hF.comp (measurable_fst.prodMk measurable_const)).min + (hF.comp (measurable_fst.prodMk measurable_snd))).ennreal_ofReal.pow_const 2).aemeasurable + · apply Measurable.aemeasurable + apply Measurable.lintegral_prod_right + exact (((hF.comp (measurable_fst.fst.prodMk measurable_fst.snd)).min + (hF.comp (measurable_fst.fst.prodMk measurable_snd))).ennreal_ofReal.pow_const 2) + +omit [MeasurableSpace X] in +lemma fiberStar_strip {F : X × ℝ → ℝ} {ell : ℝ} + (hstrip : ∀ p,ell ≤ |p.2| → F p=0) {p : X × ℝ} (hp : ell ≤ |p.2|) : + fiberStar F p=0 := by + apply fiberStar_eq_zero_of_measure_le + intro u + calc + volume (superlevel (fun r => F (p.1,r)) u) ≤ volume (Ioo (-ell) ell) := by + apply measure_mono + intro s hs + change 0 < u ∧ u < F (p.1,s) at hs + apply abs_lt.mp + by_contra hn + rw [hstrip (p.1,s) (not_lt.mp hn)] at hs + linarith [hs.1,hs.2] + _ = ENNReal.ofReal (2*ell) := by rw [Real.volume_Ioo]; congr 1; ring + _ ≤ ENNReal.ofReal (2*|p.2|) := ENNReal.ofReal_le_ofReal (by linarith) + +omit [SFinite μ] in +lemma fiberStar_height_integrable {F : X × ℝ → ℝ} (hF : Measurable F) + (hfn : ∀ p,0 ≤ F p) (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hiF : MemLp F 2 (μ.prod volume)) {ell : ℝ} + (hstrip : ∀ p,ell ≤ |p.2| → F p=0) : + Integrable (fun p => |p.2| *(fiberStar F p).toReal^2) (μ.prod volume) := by + have hh := fiberStar_memLp hF hfn hfF hiF + have hi := ((memLp_two_iff_integrable_sq hh.aestronglyMeasurable).mp hh).const_mul ell + apply hi.mono' ((measurable_snd.abs.mul ((fiberStar_measurable hF).ennreal_toReal.pow_const 2)).aestronglyMeasurable) + exact ae_of_all _ fun p => by + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (abs_nonneg _) (sq_nonneg _))] + by_cases hp : ell ≤ |p.2| + · have hz : fiberStar F p = 0 := fiberStar_strip hstrip hp + simp only [Pi.mul_apply,hz,ENNReal.toReal_zero,zero_pow (by norm_num : 2 ≠ 0),mul_zero,le_refl] + · exact mul_le_mul_of_nonneg_right (not_le.mp hp).le (sq_nonneg _) + +lemma fiberStar_total_height_lower {F : X × ℝ → ℝ} (hF : Measurable F) + (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + {ell m : ℝ} (hell : 0 ≤ ell) (hm : 0 ≤ m) + (hbound : ∀ r ∈ Ioo (-ell) ell, ∀ t ∈ Ioo (-ell) ell, + ENNReal.ofReal m ≤ ∫⁻ x,(ENNReal.ofReal (min (F (x,r)) (F (x,t))))^2 ∂μ) : + ENNReal.ofReal (ell^2*m) ≤ + ∫⁻ p,ENNReal.ofReal |p.2| * (fiberStar F p)^2 ∂μ.prod volume := by + rw [fiberStar_total_height hF hfF] + let I := Ioo (-ell) ell + let G := fun r t => ∫⁻ x,(ENNReal.ofReal (min (F (x,r)) (F (x,t))))^2 ∂μ + have hinner r (hr : r ∈ I) : ENNReal.ofReal m * volume I ≤ ∫⁻ t,G r t := by + calc + _ = ∫⁻ t in I,ENNReal.ofReal m := by simp + _ ≤ ∫⁻ t in I,G r t := setLIntegral_mono' measurableSet_Ioo (hbound r hr) + _ ≤ ∫⁻ t,G r t := setLIntegral_le_lintegral _ _ + have htotal : ENNReal.ofReal m * volume I * volume I ≤ ∫⁻ r,∫⁻ t,G r t := by + calc + _ = ∫⁻ r in I,ENNReal.ofReal m * volume I := by simp + _ ≤ ∫⁻ r in I,∫⁻ t,G r t := setLIntegral_mono' measurableSet_Ioo hinner + _ ≤ ∫⁻ r,∫⁻ t,G r t := setLIntegral_le_lintegral _ _ + have hvol : volume I = ENNReal.ofReal (2*ell) := by + dsimp [I] + rw [Real.volume_Ioo] + congr 1 + ring + have he : ENNReal.ofReal (ell^2*m) = + (ENNReal.ofReal m * volume I * volume I)/4 := by + rw [hvol,← ENNReal.ofReal_mul hm, + ← ENNReal.ofReal_mul (mul_nonneg hm (by positivity)), + show (4:ℝ≥0∞)=ENNReal.ofReal (4:ℝ) by norm_num,← ENNReal.ofReal_div_of_pos (by norm_num : (0:ℝ)<4)] + congr 1 + ring + rw [he] + exact ENNReal.div_le_div_right htotal 4 + +omit [SFinite μ] in +lemma fiberStar_total_real_height {F : X × ℝ → ℝ} (hF : Measurable F) + (hfn : ∀ p,0 ≤ F p) (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hiF : MemLp F 2 (μ.prod volume)) {ell : ℝ} + (hstrip : ∀ p,ell ≤ |p.2| → F p=0) : + ENNReal.ofReal (∫ p,|p.2| * (fiberStar F p).toReal^2 ∂μ.prod volume) = + ∫⁻ p,ENNReal.ofReal |p.2| * (fiberStar F p)^2 ∂μ.prod volume := by + rw [ofReal_integral_eq_lintegral_ofReal (fiberStar_height_integrable hF hfn hfF hiF hstrip) + (ae_of_all _ fun p => mul_nonneg (abs_nonneg _) (sq_nonneg _))] + have hi : (∫⁻ p,(fiberStar F p)^2 ∂μ.prod volume) ≠ ⊤ := by + rw [fiberStar_total_square hF hfF] + exact ofReal_square_integral_ne_top hiF hfn + apply lintegral_congr_ae + filter_upwards [ae_finite_of_square (fiberStar_measurable hF) hi] with p hp + rw [ENNReal.ofReal_mul (abs_nonneg _),ENNReal.ofReal_pow ENNReal.toReal_nonneg, + ENNReal.ofReal_toReal hp.ne] + +end Height +end VerticalRearrangement + +end + +section + +open MeasureTheory MeasureTheory.Measure Set +namespace VerticalRearrangement +section Overlap +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +lemma min_square_lower (u v : ℝ) : + (9/10:ℝ)*u^2-10*(u-v)^2 ≤ (min u v)^2 := by + rcases le_total u v with h | h + · rw [min_eq_left h] + nlinarith [sq_nonneg u,sq_nonneg (u-v)] + · rw [min_eq_right h] + nlinarith [sq_nonneg (u-10*(u-v)),sq_nonneg (u-v)] + +lemma min_square_integrable {f g : X → ℝ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ) + (hfn : ∀ x,0 ≤ f x) (hgn : ∀ x,0 ≤ g x) : + Integrable (fun x => (min (f x) (g x))^2) μ := by + apply ((memLp_two_iff_integrable_sq hf.aestronglyMeasurable).mp hf).mono' + ((hf.aestronglyMeasurable.aemeasurable.min hg.aestronglyMeasurable.aemeasurable).pow_const 2).aestronglyMeasurable + exact ae_of_all _ fun x => by + rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (le_min (hfn x) (hgn x)) (min_le_left _ _) _ + +lemma min_square_integral_lower {f g : X → ℝ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ) + (hfn : ∀ x,0 ≤ f x) (hgn : ∀ x,0 ≤ g x) : + (9/10:ℝ)*(∫ x,f x^2 ∂μ)-10*(∫ x,(f x-g x)^2 ∂μ) ≤ + ∫ x,(min (f x) (g x))^2 ∂μ := by + have hf2 := (memLp_two_iff_integrable_sq hf.aestronglyMeasurable).mp hf + have hd2 := (memLp_two_iff_integrable_sq (hf.sub hg).aestronglyMeasurable).mp (hf.sub hg) + simp only [Pi.sub_apply] at hd2 + rw [← integral_const_mul,← integral_const_mul,← integral_sub (hf2.const_mul _) (hd2.const_mul _)] + exact integral_mono (hf2.const_mul _ |>.sub (hd2.const_mul _)) + (min_square_integrable hf hg hfn hgn) (fun x => min_square_lower (f x) (g x)) + +end Overlap +section Translate +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma translate_pair_square (f : E → ℝ) (a b : E) : + (∫ y,(f (y+a)-f (y+b))^2) = HeatL2.realDistance f (a-b) := by + have hh := (measurePreserving_add_right volume b).integral_comp + (Homeomorph.addRight b).measurableEmbedding (fun y => (f (y+(a-b))-f y)^2) + simpa only [HeatL2.realDistance,show ∀ y:E,y+b+(a-b)=y+a by intro y; abel] using hh + +lemma translate_min_square_lower {f : E → ℝ} (hf : MemLp f 2 volume) + (hfn : ∀ x,0 ≤ f x) (hn : (∫ x,f x^2)=1) (a b : E) + (hd : HeatL2.realDistance f (a-b) ≤ 3/500) : + (21/25:ℝ) ≤ ∫ y,(min (f (y+a)) (f (y+b)))^2 := by + have hh := min_square_integral_lower + (hf.comp_measurePreserving (measurePreserving_add_right volume a)) + (hf.comp_measurePreserving (measurePreserving_add_right volume b)) + (fun y => hfn (y+a)) (fun y => hfn (y+b)) + simp only [Function.comp_apply] at hh + rw [(measurePreserving_add_right volume a).integral_comp + (Homeomorph.addRight a).measurableEmbedding (fun y => f y^2), + translate_pair_square,hn] at hh + linarith + +end Translate +end VerticalRearrangement + +end + +section + +open MeasureTheory MeasureTheory.Measure Set +open scoped ENNReal +namespace VerticalRearrangement +section LiftHeight +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma lift_min_square {ell c r t : ℝ} (hc : 0 ≤ c) (e : E) (f : E → ℝ) + (hr : r ∈ Ioo (-ell) ell) (ht : t ∈ Ioo (-ell) ell) : + (fun y => (min (liftFunction ell c e f (y,r)) (liftFunction ell c e f (y,t)))^2) = + fun y => c^2 * (min (f (y+r • e)) (f (y+t • e)))^2 := by + ext y + simp only [liftFunction,indicator_of_mem hr,indicator_of_mem ht,← mul_min_of_nonneg _ _ hc,mul_pow] + +lemma lift_height_lower {f : E → ℝ} (hm : Measurable f) (hf : MemLp f 2 volume) + (hfn : ∀ x,0 ≤ f x) (hn : (∫ x,f x^2)=1) (e : E) + (hd : ∀ r ∈ Ioo (-(5/2:ℝ)) (5/2),∀ t ∈ Ioo (-(5/2:ℝ)) (5/2), + HeatL2.realDistance f ((r-t) • e) ≤ 3/500) : + (21/20:ℝ) ≤ ∫ p,|p.2| * (fiberStar (liftFunction (5/2) (Real.sqrt (1/5)) e f) p).toReal^2 + ∂(volume : Measure E).prod volume := by + let c := Real.sqrt (1/5:ℝ) + let F := liftFunction (5/2) c e f + have hc : 0 ≤ c := Real.sqrt_nonneg _ + have hc2 : c^2=(1/5:ℝ) := Real.sq_sqrt (by norm_num) + have hFm : Measurable F := lift_measurable _ _ _ hm + have hFn : ∀ p,0 ≤ F p := lift_nonneg _ hc _ hfn + have hFi : MemLp F 2 (volume.prod volume) := lift_memLp _ _ _ hm hf + have hFs := lift_strip (5/2:ℝ) c e f + have hFfin := superlevel_measure_ne_top_of_strip hFs + have hbound : ∀ r ∈ Ioo (-(5/2:ℝ)) (5/2),∀ t ∈ Ioo (-(5/2:ℝ)) (5/2), + ENNReal.ofReal (c^2*(21/25:ℝ)) ≤ + ∫⁻ y,(ENNReal.ofReal (min (F (y,r)) (F (y,t))))^2 := by + intro r hr t ht + have hmin := translate_min_square_lower hf hfn hn (r • e) (t • e) + (by simpa only [← sub_smul] using hd r hr t ht) + have hmini := min_square_integrable + (hf.comp_measurePreserving (measurePreserving_add_right volume (r • e))) + (hf.comp_measurePreserving (measurePreserving_add_right volume (t • e))) + (fun y => hfn (y+r • e)) (fun y => hfn (y+t • e)) + have hei := ofReal_integral_eq_lintegral_ofReal (hmini.const_mul (c^2)) + (ae_of_all _ fun y => mul_nonneg (sq_nonneg c) (sq_nonneg _)) + have he : (fun y => (min (F (y,r)) (F (y,t)))^2) = + fun y => c^2*(min (f (y+r • e)) (f (y+t • e)))^2 := lift_min_square hc e f hr ht + calc + ENNReal.ofReal (c^2*(21/25:ℝ)) ≤ ENNReal.ofReal (c^2*(∫ y,(min (f (y+r • e)) (f (y+t • e)))^2)) := + ENNReal.ofReal_le_ofReal (mul_le_mul_of_nonneg_left hmin (sq_nonneg c)) + _ = ∫⁻ y,ENNReal.ofReal (c^2*(min (f (y+r • e)) (f (y+t • e)))^2) := by + rw [← integral_const_mul] + exact hei + _ = ∫⁻ y,(ENNReal.ofReal (min (F (y,r)) (F (y,t))))^2 := by + apply lintegral_congr + intro y + rw [← congrFun he y] + exact ENNReal.ofReal_pow (le_min (hFn _) (hFn _)) _ + have hH := fiberStar_total_height_lower hFm hFfin (by norm_num : (0:ℝ)≤5/2) + (by positivity : 0 ≤ c^2*(21/25:ℝ)) hbound + rw [hc2] at hH + norm_num at hH + rw [← fiberStar_total_real_height hFm hFn hFfin hFi hFs] at hH + exact (ENNReal.ofReal_le_ofReal_iff (integral_nonneg (fun p => mul_nonneg (abs_nonneg _) (sq_nonneg _)))).mp hH + +end LiftHeight +end VerticalRearrangement + +end + +section + +open MeasureTheory Set +open scoped ENNReal NNReal +namespace ShiftedSections +open VerticalRearrangement HeatL2 HeatL2.Diagonal +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma lifted_test {K : Set (EuclideanSpace ℝ ι)} (hKm : MeasurableSet K) (hKc : Convex ℝ K) + (hB : Bound K hKm (1/10000)) (j : ι) {η ε : ℝ} + (hη : 0 < η) (hη1 : η ≤ 1/4) (hε : 0 < ε) (hε1 : ε ≤ 1/10000) : + ∃ f : EuclideanSpace ℝ ι → ℝ, ∃ hf : MemLp f 2 volume, + (∀ i,energy (fun ξ => η*coordSymbol i ξ) (complexLp f hf) < η*((1/10000)+ε)) ∧ + ∃ G : EuclideanSpace ℝ ι × ℝ → ℝ, + Measurable G ∧ MemLp G 2 (volume.prod volume) ∧ + (∀ p,p.1 ∉ sectionDomain K (EuclideanSpace.single j 1) (5/2) |p.2| → G p=0) ∧ + (∫ p,G p^2 ∂volume.prod volume)=1 ∧ + Integrable (fun p => |p.2| *G p^2) (volume.prod volume) ∧ + (21/20:ℝ) ≤ ∫ p,|p.2| *G p^2 ∂volume.prod volume ∧ + ∀ a,(∫ p,(G (p.1+a,p.2)-G p)^2 ∂volume.prod volume) ≤ realDistance f a := by + obtain ⟨f,hm,hfn,hfs,hf,hn,hE⟩ := simultaneous_real_density hB hη hε + let e := EuclideanSpace.single j (1:ℝ) + let c := Real.sqrt (1/5:ℝ) + let F := liftFunction (5/2) c e f + let G := fun p => (fiberStar F p).toReal + have hc : 0 ≤ c := Real.sqrt_nonneg _ + have hc2 : c^2=(1/5:ℝ) := Real.sq_sqrt (by norm_num) + have hFm : Measurable F := lift_measurable _ _ _ hm + have hFn : ∀ p,0 ≤ F p := lift_nonneg _ hc _ hfn + have hFi : MemLp F 2 (volume.prod volume) := lift_memLp _ _ _ hm hf + have hFs := lift_strip (5/2:ℝ) c e f + have hFfin := superlevel_measure_ne_top_of_strip hFs + have hGn : (∫ p,G p^2 ∂volume.prod volume)=1 := by + rw [fiberStar_total_real_square hFm hFn hFfin (ofReal_square_integral_ne_top hFi hFn), + lift_total_square (by norm_num : (0:ℝ)≤5/2) c e f,hc2,hn] + norm_num + refine ⟨f,hf,hE,G,(fiberStar_measurable hFm).ennreal_toReal, + fiberStar_memLp hFm hFn hFfin hFi,?_,hGn,?_,?_,?_⟩ + · intro p hp + rw [show G p = (fiberStar (liftFunction (5/2) c e f) p).toReal from rfl, + lifted_star_supported hKc hfs (5/2) c e hp,ENNReal.toReal_zero] + · exact fiberStar_height_integrable hFm hFn hFfin hFi hFs + · exact lift_height_lower hm hf hfn hn e (fun r hr t ht => + real_coordinate_distance hf hη hη1 hε1 (fun i => (hE i).le) j hr ht) + · intro a + have hh := fiberStar_horizontal_difference (by norm_num : (0:ℝ)≤5/2) hc e a hm hf hfn + rw [hc2] at hh + norm_num at hh + exact hh + +end ShiftedSections + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Main.lean b/lean/OAI/Analysis/Steinitz/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..d953d9ec5929e37390a83f0aadccf7040d2f038f --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Main.lean @@ -0,0 +1,118 @@ +import OAI.Analysis.Steinitz.Transference + +namespace OAI + +/-! The Euclidean Steinitz–Bergström theorem with one absolute constant. -/ + +section + +open Matrix GaussianTail MeasureTheory Set +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace Pointwise +namespace EuclideanSteinitz.Filter +open GaussianAR +variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] + +lemma filtered_signed_prefixes {n : ℕ} (b : Fin n → ι → ℝ) + (hb : ∀ i, vectorMass (b i) ≤ signingScale^2) : + ∃ ε : Fin n → ℝ, (∀ i, ε i = -1 ∨ ε i = 1) ∧ + ∀ k : ℕ, k ≤ n → + ‖∑ i ∈ Finset.univ.filter (fun i : Fin n => i.val < k), ε i • WithLp.toLp 2 (b i)‖ ≤ + (2*bodyScale*stateRadius)*Real.sqrt (Fintype.card ι) := by + let R := initialMatrix ι (Fin n) + let L := familySteps b + let ps : Fin (n+1) → List (Step ι (ι⊕Fin n)) := fun t => L.take t.val + let H := normalizedPredictor b + let K := bodyScale • applicationDomain (fun t => run R (ps t)) H + have hlt : ∀ i,vectorMass (b i)<1 := fun i => + (hb i).trans_lt (by nlinarith [signingScale_pos,signingScale_lt_one]) + have hg : ShiftedSections.Good K := applicationDomain_good initialMatrix_coisometry + (familySteps_good hlt) (familySteps_fresh b) (familySteps_nodup b) ps + (fun t => List.take_prefix t.val L) H (normalizedPredictor_mass hb) (normalizedPredictor_column hb) + let m : Fin n → EuclideanSpace ℝ (ι⊕Fin n) →L[ℝ] ℝ := fun i => rowMap (familyPredictor b i) + have hm : ∀ i l : Fin n,i≤l → m i (EuclideanSpace.single (Sum.inr l) 1)=0 := by + intro i l hil + rw [show m i=rowMap (familyPredictor b i) from rfl,rowMap_single,familyPredictor_future b i l hil] + have hslab : ∀ x∈K,∀ i,|m i x|<1/4 := by + intro x hx i + obtain ⟨y,hy,rfl⟩ := Set.mem_smul_set.mp hx + have hh := hy.2 i + change ‖matrixMap (normalizedPredictor b i) y‖<2*slabRadius at hh + rw [normalizedPredictor_norm] at hh + have hh' := (div_lt_iff₀ signingScale_pos).mp hh + change |rowMap (familyPredictor b i) (bodyScale • y)| < _ + rw [map_smul,smul_eq_mul,abs_mul,abs_of_pos bodyScale_pos] + have hf := mul_lt_mul_of_pos_left hh' bodyScale_pos + have he : bodyScale*(2*slabRadius*signingScale)=1/4 := by + nlinarith [signingScale_cancel] + simpa only [he] using hf + obtain ⟨ε,x,hε,hx,hxout,hxeq⟩ := ShiftedSections.adaptive_linear_equations + (Sum.inr : Fin n → ι⊕Fin n) Sum.inr_injective m hm hg hslab + have hx0 : ∀ i,x (Sum.inl i)=0 := by + intro i + exact hxout (Sum.inl i) (fun j => Sum.inl_ne_inr) + have hxeq' : ∀ i,x (Sum.inr i)=rowMap (rawRow (run R (L.take i.val)) (b i)) x+ε i := by + intro i + have hh := hxeq i + change x (Sum.inr i)=rowMap (familyPredictor b i) x+ε i at hh + rw [familyPredictor_form,noiseRow_eval _ _ hx0] at hh + exact hh + have hcancel (k : ℕ) : matrixMap (run R (L.take k)) x= + ∑ i ∈ Finset.univ.filter (fun i : Fin n => i.val < k),ε i • WithLp.toLp 2 (b i) := by + have hh := run_prefix_cancel (fun i => symmetricStep (b i) (Sum.inr i)) R x ε + (fun _ => rfl) hxeq' k + rw [initialMatrix_eval x hx0,zero_add,EuclideanSteinitzBergstrom.sum_take_ofFn] at hh + exact hh + refine ⟨ε,hε,fun k hk => ?_⟩ + rw [← hcancel k] + obtain ⟨y,hy,rfl⟩ := Set.mem_smul_set.mp hx + have hh := hy.1.1 (⟨k,by omega⟩ : Fin (n+1)) + change ‖matrixMap (run R (L.take k)) y‖ < 2*stateRadius*Real.sqrt (Fintype.card ι) at hh + rw [map_smul,norm_smul,Real.norm_eq_abs,abs_of_pos bodyScale_pos] + have hf := mul_lt_mul_of_pos_left hh bodyScale_pos + nlinarith + +end EuclideanSteinitz.Filter + +namespace EuclideanSteinitzBergstrom +open EuclideanSteinitz.Filter GaussianAR + +noncomputable def universalConstant : ℝ := 2*bodyScale*stateRadius/signingScale + +theorem signed_prefix_bound : SignedPrefixBound universalConstant := by + classical + intro d N hd _hN v hv + let : Nonempty (Fin d) := ⟨⟨0,by omega⟩⟩ + let b : Fin N → Fin d → ℝ := fun i => (signingScale • v i).ofLp + have hb : ∀ i,vectorMass (b i) ≤ signingScale^2 := by + intro i + have he : vectorMass (b i)=‖signingScale • v i‖^2 := by + exact (EuclideanSpace.real_norm_sq_eq (signingScale • v i)).symm + rw [he,norm_smul,Real.norm_eq_abs,abs_of_pos signingScale_pos,mul_pow] + exact (mul_le_mul_of_nonneg_left (by nlinarith [norm_nonneg (v i),hv i] : ‖v i‖^2≤1) + (sq_nonneg signingScale)).trans_eq (mul_one _) + obtain ⟨ε,hε,hpref⟩ := filtered_signed_prefixes b hb + refine ⟨ε,hε,fun k hk => ?_⟩ + have hh := hpref k hk + have he : (∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k),ε i • WithLp.toLp 2 (b i))= + signingScale • ∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k),ε i • v i := by + rw [Finset.smul_sum] + apply Finset.sum_congr rfl + intro i _ + change ε i • (signingScale • v i)=signingScale • (ε i • v i) + exact smul_comm _ _ _ + rw [he,norm_smul,Real.norm_eq_abs,abs_of_pos signingScale_pos,Fintype.card_fin] at hh + have hc : universalConstant*Real.sqrt d=(2*bodyScale*stateRadius*Real.sqrt d)/signingScale := by + unfold universalConstant + ring + rw [hc] + apply (le_div_iff₀ signingScale_pos).mpr + nlinarith + +theorem main : ∃ C : ℝ, SignedPrefixBound C ∧ OrderingPrefixBound C := + ⟨universalConstant,signed_prefix_bound,signing_implies_ordering universalConstant signed_prefix_bound⟩ + +end EuclideanSteinitzBergstrom + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/MatrixEnergy.lean b/lean/OAI/Analysis/Steinitz/MatrixEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..faef949b7849d9ae17a88327c8a97de8359b3822 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/MatrixEnergy.lean @@ -0,0 +1,634 @@ +import OAI.Analysis.Steinitz.Model + +namespace OAI + +/-! Scalar potentials and spectral endpoint inequalities. -/ + +namespace EuclideanSteinitz.MatrixEnergy + +open Matrix +open scoped MatrixOrder + +noncomputable def exponent : ℝ := 3 / 2 + +noncomputable def cutoff (x : ℝ) : ℝ := + if x ≤ 1 / 2 then 0 else if x < 1 then 2 * x - 1 else + if x ≤ 2 then 1 else if x < 4 then 2 - x / 2 else 0 + +noncomputable def weight (x : ℝ) : ℝ := min (x ^ exponent) x⁻¹ + +noncomputable def potential (x : ℝ) : ℝ := + ∫ u in (0 : ℝ)..x, weight u / u + +noncomputable def gainPotential (x : ℝ) : ℝ := + ∫ u in (0 : ℝ)..x, u ^ (exponent - 1) / (1 + u) ^ exponent + +noncomputable def sizeWeight (x : ℝ) : ℝ := min (x ^ (exponent - 1)) x⁻¹ + +noncomputable def scalarRemainder (x y : ℝ) : ℝ := + potential x - potential y + (y / x - 1) * (weight x + weight y) / 2 + +section Scalar + +lemma exponent_pos : 0 < exponent := by norm_num [exponent] + +lemma weight_of_le_one {x : ℝ} (hx : 0 ≤ x) (h1 : x ≤ 1) : + weight x = x ^ exponent := by + rcases hx.eq_or_lt with rfl | hx + · norm_num [weight, exponent, Real.zero_rpow] + apply min_eq_left + exact (Real.rpow_le_one hx.le h1 exponent_pos.le).trans (one_le_inv₀ hx |>.mpr h1) + +lemma weight_of_one_le {x : ℝ} (hx : 1 ≤ x) : weight x = x⁻¹ := by + apply min_eq_right + exact (inv_le_one₀ (by linarith : 0 < x) |>.mpr hx).trans + (Real.one_le_rpow hx exponent_pos.le) + +lemma integrand_of_le_one {x : ℝ} (hx : 0 ≤ x) (h1 : x ≤ 1) : + weight x / x = x ^ (1 / 2 : ℝ) := by + rw [weight_of_le_one hx h1] + convert (Real.rpow_sub_one' hx (by norm_num [exponent] : exponent - 1 ≠ 0)).symm using 1 + norm_num [exponent] + +lemma integrand_of_one_le {x : ℝ} (hx : 1 ≤ x) : + weight x / x = x ^ (-2 : ℝ) := by + rw [weight_of_one_le hx] + rw [show (-2 : ℝ) = -1 - 1 by norm_num, + Real.rpow_sub_one (by linarith : x ≠ 0), Real.rpow_neg_one] + +lemma potential_small {x : ℝ} (hx : 0 ≤ x) (h1 : x ≤ 1) : + potential x = x ^ exponent / exponent := by + unfold potential + calc + _ = ∫ u in (0 : ℝ)..x, u ^ (1 / 2 : ℝ) := by + apply intervalIntegral.integral_congr + intro u hu + rw [Set.uIcc_of_le hx] at hu + exact integrand_of_le_one hu.1 (hu.2.trans h1) + _ = _ := by + rw [integral_rpow (Or.inl (by norm_num : (-1 : ℝ) < 1 / 2))] + norm_num [exponent] + +lemma small_integrable {x : ℝ} (hx : 0 ≤ x) (h1 : x ≤ 1) : + IntervalIntegrable (fun u => weight u / u) MeasureTheory.volume 0 x := by + refine IntervalIntegrable.congr ?_ + (intervalIntegral.intervalIntegrable_rpow' (by norm_num : (-1 : ℝ) < 1 / 2)) + intro u hu + rw [Set.uIoc_of_le hx] at hu + exact (integrand_of_le_one hu.1.le (hu.2.trans h1)).symm + +lemma large_integrable {x : ℝ} (hx : 1 ≤ x) : + IntervalIntegrable (fun u => weight u / u) MeasureTheory.volume 1 x := by + have hz : (0 : ℝ) ∉ Set.uIcc 1 x := by + rw [Set.uIcc_of_le hx] + simp + refine IntervalIntegrable.congr ?_ + (intervalIntegral.intervalIntegrable_rpow (Or.inr hz) : + IntervalIntegrable (fun u : ℝ => u ^ (-2 : ℝ)) MeasureTheory.volume 1 x) + intro u hu + rw [Set.uIoc_of_le hx] at hu + exact (integrand_of_one_le hu.1.le).symm + +lemma potential_large {x : ℝ} (hx : 1 ≤ x) : + potential x = 5 / 3 - x⁻¹ := by + have hsum := intervalIntegral.integral_add_adjacent_intervals + (small_integrable (show (0 : ℝ) ≤ 1 by norm_num) le_rfl) (large_integrable hx) + have hint : (∫ u in (1 : ℝ)..x, weight u / u) = 1 - x⁻¹ := by + calc + _ = ∫ u in (1 : ℝ)..x, u ^ (-2 : ℝ) := by + apply intervalIntegral.integral_congr + intro u hu + rw [Set.uIcc_of_le hx] at hu + exact integrand_of_one_le hu.1 + _ = _ := by + rw [integral_rpow (Or.inr ⟨by norm_num, ?_⟩)] + · norm_num [Real.rpow_neg_one] + ring + · rw [Set.uIcc_of_le hx] + simp + change potential 1 + _ = potential x at hsum + rw [potential_small (by norm_num) le_rfl, hint] at hsum + norm_num [exponent] at hsum + linarith + +lemma fourth_rpow_exponent {u : ℝ} (hu : 0 ≤ u) : + (u ^ 4) ^ exponent = u ^ 6 := by + rw [← Real.rpow_natCast_mul hu] + norm_num [exponent, Real.rpow_natCast] + +private noncomputable def rootWeight (u : ℝ) : ℝ := + if u ≤ 1 then u ^ 3 else (u ^ 2)⁻¹ + +private lemma weight_fourth {u : ℝ} (hu : 0 ≤ u) : + weight (u ^ 4) = rootWeight u ^ 2 := by + by_cases h : u ≤ 1 + · rw [weight_of_le_one (by positivity) (pow_le_one₀ hu h), fourth_rpow_exponent hu] + simp only [rootWeight, ite_eq_left h] + ring + · rw [weight_of_one_le (one_le_pow₀ (le_of_not_ge h))] + simp only [rootWeight, ite_eq_right h, inv_pow] + ring + +private lemma root_endpoint {u v : ℝ} (hu : 0 < u) (hv : 0 < v) : + ((rootWeight u) ^ 2 + (rootWeight v) ^ 2 - + 2 * rootWeight u * rootWeight v * (v / u) ^ 3) * (2 / 3) ≤ + potential (u ^ 4) - potential (v ^ 4) := by + have up : 0 < u ^ 4 := by positivity + have vp : 0 < v ^ 4 := by positivity + by_cases hu1 : u ≤ 1 <;> by_cases hv1 : v ≤ 1 + · rw [potential_small up.le (pow_le_one₀ hu.le hu1), + potential_small vp.le (pow_le_one₀ hv.le hv1), + fourth_rpow_exponent hu.le, fourth_rpow_exponent hv.le] + simp only [rootWeight, ite_eq_left hu1, ite_eq_left hv1, exponent] + apply le_of_eq + field_simp + ring + · rw [potential_small up.le (pow_le_one₀ hu.le hu1), + fourth_rpow_exponent hu.le, + potential_large (one_le_pow₀ (le_of_not_ge hv1))] + simp only [rootWeight, ite_eq_left hu1, ite_eq_right hv1, exponent] + have hn : 0 ≤ (v - 1) ^ 2 * (4 * v ^ 3 + 3 * v ^ 2 + 2 * v + 1) := by positivity + have hid : u ^ 6 / (3 / 2) - (5 / 3 - (v ^ 4)⁻¹) - + ((u ^ 3) ^ 2 + (v ^ 2)⁻¹ ^ 2 - 2 * u ^ 3 * (v ^ 2)⁻¹ * (v / u) ^ 3) * (2 / 3) = + ((v - 1) ^ 2 * (4 * v ^ 3 + 3 * v ^ 2 + 2 * v + 1)) / (3 * v ^ 4) := by + field_simp + ring + exact sub_nonneg.mp (hid ▸ div_nonneg hn (by positivity)) + · rw [potential_large (one_le_pow₀ (le_of_not_ge hu1)), + potential_small vp.le (pow_le_one₀ hv.le hv1), fourth_rpow_exponent hv.le] + simp only [rootWeight, ite_eq_right hu1, ite_eq_left hv1, exponent] + have hu5 : 1 ≤ u ^ 5 := one_le_pow₀ (le_of_not_ge hu1) + have hv6 : v ^ 6 ≤ 1 := pow_le_one₀ hv.le hv1 + have hn : 0 ≤ (u - 1) ^ 2 * (u ^ 3 + 2 * u ^ 2 + 3 * u + 4) + + 4 * (1 - v ^ 6) * (u ^ 5 - 1) := by positivity + have hid : (5 / 3 - (u ^ 4)⁻¹) - v ^ 6 / (3 / 2) - + ((u ^ 2)⁻¹ ^ 2 + (v ^ 3) ^ 2 - 2 * (u ^ 2)⁻¹ * v ^ 3 * (v / u) ^ 3) * (2 / 3) = + ((u - 1) ^ 2 * (u ^ 3 + 2 * u ^ 2 + 3 * u + 4) + + 4 * (1 - v ^ 6) * (u ^ 5 - 1)) / (3 * u ^ 5) := by + field_simp + ring + exact sub_nonneg.mp (hid ▸ div_nonneg hn (by positivity)) + · rw [potential_large (one_le_pow₀ (le_of_not_ge hu1)), + potential_large (one_le_pow₀ (le_of_not_ge hv1))] + simp only [rootWeight, ite_eq_right hu1, ite_eq_right hv1] + have hn : 0 ≤ (u - v) ^ 2 * (u ^ 3 + 2 * u ^ 2 * v + 3 * u * v ^ 2 + 4 * v ^ 3) := by + positivity + have hid : (5 / 3 - (u ^ 4)⁻¹) - (5 / 3 - (v ^ 4)⁻¹) - + ((u ^ 2)⁻¹ ^ 2 + (v ^ 2)⁻¹ ^ 2 - 2 * (u ^ 2)⁻¹ * (v ^ 2)⁻¹ * (v / u) ^ 3) * (2 / 3) = + ((u - v) ^ 2 * (u ^ 3 + 2 * u ^ 2 * v + 3 * u * v ^ 2 + 4 * v ^ 3)) / + (3 * u ^ 5 * v ^ 4) := by + field_simp + ring + exact sub_nonneg.mp (hid ▸ div_nonneg hn (by positivity)) + +private lemma root_remainder {u v : ℝ} (hu : 0 < u) (hv : 0 < v) : + (weight (u ^ 4) + weight (v ^ 4)) / 6 * + (v / u - 1) ^ 2 * (3 * (v / u) ^ 2 + 2 * (v / u) + 1) ≤ + scalarRemainder (u ^ 4) (v ^ 4) := by + have he := root_endpoint hu hv + have hq : 0 ≤ (rootWeight u - rootWeight v) ^ 2 * (v / u) ^ 3 * (2 / 3) := by + positivity + dsimp only [scalarRemainder] + rw [weight_fourth hu.le, weight_fourth hv.le, ← div_pow] + nlinarith only [he, hq] + +private lemma fourth_ratio_polynomial {t : ℝ} (ht : 0 ≤ t) : + (t ^ 4 - 1) ^ 2 ≤ 4 * (t - 1) ^ 2 * (3 * t ^ 2 + 2 * t + 1) * (1 + t ^ 4) := by + have h : 0 ≤ (t - 1) ^ 2 * + (11 * t ^ 6 + 6 * t ^ 5 + t ^ 2 * (t - 2) ^ 2 + 5 * t ^ 2 + 6 * t + 3) := by + positivity + nlinarith only [h] + +lemma weight_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ weight x := by + exact le_min (Real.rpow_nonneg hx _) (inv_nonneg.mpr hx) + +private lemma root_remainder_quadratic {u v : ℝ} (hu : 0 < u) (hv : 0 < v) : + (weight (u ^ 4) + weight (v ^ 4)) * (u ^ 4 - v ^ 4) ^ 2 / + (24 * u ^ 4 * (u ^ 4 + v ^ 4)) ≤ scalarRemainder (u ^ 4) (v ^ 4) := by + let w := weight (u ^ 4) + weight (v ^ 4) + have hw : 0 ≤ w := add_nonneg (weight_nonneg (by positivity)) (weight_nonneg (by positivity)) + calc + _ = w * ((v / u) ^ 4 - 1) ^ 2 / (24 * (1 + (v / u) ^ 4)) := by + dsimp only [w] + field_simp + ring + _ ≤ w / 6 * (v / u - 1) ^ 2 * (3 * (v / u) ^ 2 + 2 * (v / u) + 1) := by + apply (div_le_iff₀ (by positivity : 0 < 24 * (1 + (v / u) ^ 4))).mpr + have h := mul_le_mul_of_nonneg_left (fourth_ratio_polynomial (by positivity : 0 ≤ v / u)) hw + nlinarith only [h] + _ ≤ _ := root_remainder hu hv + +lemma scalar_remainder_lower {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + (weight x + weight y) * (x - y) ^ 2 / (24 * x * (x + y)) ≤ + scalarRemainder x y := by + let u := x ^ (1 / 4 : ℝ) + let v := y ^ (1 / 4 : ℝ) + have hu : 0 < u := Real.rpow_pos_of_pos hx _ + have hv : 0 < v := Real.rpow_pos_of_pos hy _ + have hux : u ^ 4 = x := by + simpa only [u, one_div, Nat.cast_ofNat] using Real.rpow_inv_natCast_pow (n := 4) hx.le (by norm_num) + have hvy : v ^ 4 = y := by + simpa only [v, one_div, Nat.cast_ofNat] using Real.rpow_inv_natCast_pow (n := 4) hy.le (by norm_num) + simpa only [hux, hvy] using root_remainder_quadratic hu hv + +lemma scalar_remainder_nonneg {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + 0 ≤ scalarRemainder x y := by + have hwx := weight_nonneg hx.le + have hwy := weight_nonneg hy.le + exact (by positivity : 0 ≤ (weight x + weight y) * (x - y) ^ 2 / + (24 * x * (x + y))).trans (scalar_remainder_lower hx hy) + +lemma scalar_remainder_reverse_lower {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + (weight x + weight y) * (x - y) ^ 2 / (24 * x * (x + y)) ≤ + (y / x) * scalarRemainder y x := by + calc + _ = (y / x) * ((weight y + weight x) * (y - x) ^ 2 / (24 * y * (y + x))) := by + field_simp + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (scalar_remainder_lower hy hx) (by positivity) + +lemma cutoff_nonneg (x : ℝ) : 0 ≤ cutoff x := by + unfold cutoff + split_ifs <;> linarith + +lemma cutoff_le_one (x : ℝ) : cutoff x ≤ 1 := by + unfold cutoff + split_ifs <;> linarith + +lemma cutoff_dist_le_one (x y : ℝ) : |cutoff x - cutoff y| ≤ 1 := by + have hx := cutoff_nonneg x + have hy := cutoff_nonneg y + have hx1 := cutoff_le_one x + have hy1 := cutoff_le_one y + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +private lemma cutoff_dist_of_le {x y : ℝ} (hxy : x ≤ y) : + |cutoff x - cutoff y| ≤ 2 * (y - x) := by + apply abs_le.mpr + unfold cutoff + split_ifs <;> constructor <;> linarith + +lemma cutoff_dist (x y : ℝ) : |cutoff x - cutoff y| ≤ 2 * |x - y| := by + rcases le_total x y with h | h + · rw [abs_of_nonpos (sub_nonpos.mpr h), neg_sub] + exact cutoff_dist_of_le h + · rw [abs_sub_comm (cutoff x), abs_of_nonneg (sub_nonneg.mpr h)] + exact cutoff_dist_of_le h + +lemma cutoff_zero_of_not_band {x : ℝ} (h : ¬ (1 / 2 ≤ x ∧ x ≤ 4)) : cutoff x = 0 := by + unfold cutoff + split_ifs <;> first | rfl | (exfalso; apply h; constructor <;> linarith) + +lemma cutoff_ne_band {x y : ℝ} (h : cutoff x ≠ cutoff y) : + (1 / 2 ≤ x ∧ x ≤ 4) ∨ (1 / 2 ≤ y ∧ y ≤ 4) := by + by_contra hn + have hn := not_or.mp hn + exact h (by rw [cutoff_zero_of_not_band hn.1, cutoff_zero_of_not_band hn.2]) + +lemma weight_band {x : ℝ} (hx : 1 / 2 ≤ x ∧ x ≤ 4) : 1 / 4 ≤ weight x := by + apply le_min + · calc + 1 / 4 = (1 / 2 : ℝ) ^ (2 : ℝ) := by norm_num + _ ≤ (1 / 2 : ℝ) ^ exponent := + Real.rpow_le_rpow_of_exponent_ge (by norm_num) (by norm_num) (by norm_num [exponent]) + _ ≤ x ^ exponent := Real.rpow_le_rpow (by norm_num) hx.1 exponent_pos.le + · simpa only [one_div] using one_div_le_one_div_of_le (by linarith : 0 < x) hx.2 + +private lemma cutoff_weighted_distance {x y : ℝ} (hx : 0 < x) (hy : 0 < y) + (hb : x ≤ 4 ∨ y ≤ 4) : + (1 + y) * (cutoff x - cutoff y) ^ 2 * x * (x + y) ≤ 1200 * (x - y) ^ 2 := by + let z := |x - y| + have hz : 0 ≤ z := abs_nonneg _ + have hzx : x ≤ y + z := by have := le_abs_self (x - y); dsimp only [z]; linarith + have hzy : y ≤ x + z := by have := neg_le_abs (x - y); dsimp only [z]; linarith + have hsqz : z ^ 2 = (x - y) ^ 2 := sq_abs _ + have hd : (cutoff x - cutoff y) ^ 2 ≤ 4 * z ^ 2 := by + have h := (sq_le_sq₀ (abs_nonneg (cutoff x - cutoff y)) (by positivity : 0 ≤ 2 * z)).mpr + (cutoff_dist x y) + simpa only [sq_abs, mul_pow, show (2 : ℝ) ^ 2 = 4 by norm_num] using h + have hd1 : (cutoff x - cutoff y) ^ 2 ≤ 1 := by + have h := (sq_le_sq₀ (abs_nonneg (cutoff x - cutoff y)) (by norm_num : (0 : ℝ) ≤ 1)).mpr + (cutoff_dist_le_one x y) + simpa only [sq_abs, one_pow] using h + have ha : 0 ≤ (1 + y) * x * (x + y) := by positivity + by_cases hz1 : z ≤ 1 + · have hx5 : x ≤ 5 := by rcases hb with h | h <;> linarith + have hy5 : y ≤ 5 := by rcases hb with h | h <;> linarith + have ha300 : (1 + y) * x * (x + y) ≤ 300 := by + calc + _ ≤ (6 * 5) * 10 := mul_le_mul + (mul_le_mul (by linarith : 1 + y ≤ 6) hx5 hx.le (by norm_num)) + (by linarith) (by positivity) (by norm_num) + _ = _ := by norm_num + have h := mul_le_mul ha300 hd (sq_nonneg _) (by norm_num : (0 : ℝ) ≤ 300) + nlinarith only [h, hsqz] + · have hz1 : 1 ≤ z := le_of_not_ge hz1 + have ha1200 : (1 + y) * x * (x + y) ≤ 1200 * z ^ 2 := by + rcases hb with hb | hb + · have hy5 : y ≤ 5 * z := by linarith + have h := mul_le_mul + (mul_le_mul (by linarith : 1 + y ≤ 6 * z) hb hx.le (by positivity)) + (by linarith : x + y ≤ 9 * z) (by positivity) (by positivity : 0 ≤ 6 * z * 4) + nlinarith only [h, sq_nonneg z] + · have hx5 : x ≤ 5 * z := by linarith + have h := mul_le_mul + (mul_le_mul (by linarith : 1 + y ≤ 5) hx5 hx.le (by norm_num)) + (by linarith : x + y ≤ 9 * z) (by positivity) (by positivity : 0 ≤ 5 * (5 * z)) + nlinarith only [h, sq_nonneg z] + have h := mul_le_mul ha1200 hd1 (sq_nonneg _) (by positivity : 0 ≤ 1200 * z ^ 2) + nlinarith only [h, hsqz] + +lemma scalar_comparison {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + (1 / 115200) * (1 + y) * |cutoff x - cutoff y| ^ 2 ≤ scalarRemainder x y ∧ + (1 / 115200) * (1 + y) * |cutoff x - cutoff y| ^ 2 ≤ (y / x) * scalarRemainder y x := by + by_cases hf : cutoff x = cutoff y + · simp only [hf, sub_self, abs_zero, zero_pow (by decide : (2 : ℕ) ≠ 0), mul_zero] + exact ⟨scalar_remainder_nonneg hx hy, + mul_nonneg (by positivity) (scalar_remainder_nonneg hy hx)⟩ + have hb := cutoff_ne_band hf + have hw : 1 / 4 ≤ weight x + weight y := by + have hwx := weight_nonneg hx.le + have hwy := weight_nonneg hy.le + rcases hb with hb | hb + · have := weight_band hb + linarith + · have := weight_band hb + linarith + have hd := cutoff_weighted_distance hx hy (hb.imp And.right And.right) + have ht : (1 / 115200) * (1 + y) * |cutoff x - cutoff y| ^ 2 ≤ + (weight x + weight y) * (x - y) ^ 2 / (24 * x * (x + y)) := by + apply (le_div_iff₀ (by positivity : 0 < 24 * x * (x + y))).mpr + rw [sq_abs] + have h := mul_le_mul_of_nonneg_right hw (sq_nonneg (x - y)) + nlinarith only [hd, h] + exact ⟨ht.trans (scalar_remainder_lower hx hy), ht.trans (scalar_remainder_reverse_lower hx hy)⟩ + +lemma cutoff_square_le_weight {x : ℝ} (hx : 0 < x) : cutoff x ^ 2 ≤ 4 * weight x := by + by_cases h : cutoff x = 0 + · rw [h, zero_pow (by decide : (2 : ℕ) ≠ 0)] + exact mul_nonneg (by norm_num) (weight_nonneg hx.le) + have hb : 1 / 2 ≤ x ∧ x ≤ 4 := by + by_contra hn + exact h (cutoff_zero_of_not_band hn) + have hw := weight_band hb + have hf0 := cutoff_nonneg x + have hf1 := cutoff_le_one x + nlinarith + +lemma cutoff_weighted_square_le_weight {x : ℝ} (hx : 0 < x) : + (1 + x) * cutoff x ^ 2 ≤ 20 * weight x := by + by_cases h : cutoff x = 0 + · rw [h, zero_pow (by decide : (2 : ℕ) ≠ 0), mul_zero] + exact mul_nonneg (by norm_num) (weight_nonneg hx.le) + have hb : 1 / 2 ≤ x ∧ x ≤ 4 := by + by_contra hn + exact h (cutoff_zero_of_not_band hn) + have hw := weight_band hb + have hf0 := cutoff_nonneg x + have hf1 := cutoff_le_one x + have hf2 : cutoff x ^ 2 ≤ 1 := by nlinarith + have hmul := mul_le_mul_of_nonneg_left hf2 (by positivity : 0 ≤ 1 + x) + nlinarith + +lemma cutoff_scaled_square_le_weight {x : ℝ} (hx : 0 < x) : + x * cutoff x ^ 2 ≤ 16 * weight x := by + by_cases h : cutoff x = 0 + · rw [h, zero_pow (by decide : (2 : ℕ) ≠ 0), mul_zero] + exact mul_nonneg (by norm_num) (weight_nonneg hx.le) + have hb : 1 / 2 ≤ x ∧ x ≤ 4 := by + by_contra hn + exact h (cutoff_zero_of_not_band hn) + have hw := weight_band hb + have hf0 := cutoff_nonneg x + have hf1 := cutoff_le_one x + have hf2 : cutoff x ^ 2 ≤ 1 := by nlinarith + have hmul := mul_le_mul_of_nonneg_left hf2 hx.le + nlinarith + +end Scalar + +section SpectralEndpoints + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +private lemma sum_row (m : ι → κ → ℝ) (f : ι → ℝ) : + (∑ i, ∑ j, m i j * f i) = ∑ i, (∑ j, m i j) * f i := by + simp_rw [Finset.sum_mul] + +private lemma sum_col (m : ι → κ → ℝ) (f : κ → ℝ) : + (∑ i, ∑ j, m i j * f j) = ∑ j, (∑ i, m i j) * f j := by + rw [Finset.sum_comm] + simp_rw [Finset.sum_mul] + +lemma contraction_deficit_identity + (x : ι → ℝ) (y : κ → ℝ) (m n : ι → κ → ℝ) + (hx : ∀ i, 0 < x i) (hy : ∀ j, 0 < y j) + (hn : ∀ i j, n i j = m i j * y j / x i) + (hrow : ∀ i, ∑ j, n i j = 1) (hcol : ∀ j, ∑ i, n i j = 1) : + (∑ j, potential (y j)) - (∑ i, potential (x i)) = + (∑ i, ∑ j, n i j * scalarRemainder (y j) (x i)) + + (∑ i, (1 - ∑ j, m i j) * weight (x i)) / 2 + + (∑ j, (1 - ∑ i, m i j) * weight (y j)) / 2 := by + have hp (i : ι) (j : κ) : + n i j * scalarRemainder (y j) (x i) = + n i j * potential (y j) - n i j * potential (x i) + + (m i j * weight (x i) - n i j * weight (x i)) / 2 + + (m i j * weight (y j) - n i j * weight (y j)) / 2 := by + rw [hn] + dsimp only [scalarRemainder] + field_simp [ne_of_gt (hx i), ne_of_gt (hy j)] + ring + simp_rw [hp, Finset.sum_add_distrib, ← Finset.sum_div, Finset.sum_sub_distrib] + rw [sum_col n, sum_row n, sum_row m, sum_row n, sum_col m, sum_col n] + simp_rw [hrow, hcol, one_mul, sub_mul, one_mul, Finset.sum_sub_distrib] + ring + +lemma contraction_spectral_bound + (x : ι → ℝ) (y : κ → ℝ) (m n : ι → κ → ℝ) + (hx : ∀ i, 0 < x i) (hy : ∀ j, 0 < y j) + (hm : ∀ i j, 0 ≤ m i j) + (hmrow : ∀ i, ∑ j, m i j ≤ 1) (hmcol : ∀ j, ∑ i, m i j ≤ 1) + (hn : ∀ i j, n i j = m i j * y j / x i) + (hrow : ∀ i, ∑ j, n i j = 1) (hcol : ∀ j, ∑ i, n i j = 1) : + (∑ i, ∑ j, m i j * (1 + y j) * (cutoff (x i) - cutoff (y j)) ^ 2) + + (∑ i, (1 - ∑ j, m i j) * cutoff (x i) ^ 2) + + (∑ j, (1 - ∑ i, m i j) * (1 + y j) * cutoff (y j) ^ 2) ≤ + 115200 * ((∑ j, potential (y j)) - (∑ i, potential (x i))) := by + have hp (i : ι) (j : κ) : + m i j * (1 + y j) * (cutoff (x i) - cutoff (y j)) ^ 2 ≤ + 115200 * (n i j * scalarRemainder (y j) (x i)) := by + have h := mul_le_mul_of_nonneg_left (scalar_comparison (hx i) (hy j)).2 (hm i j) + rw [sq_abs] at h + rw [hn] + simp only [div_eq_mul_inv] at h ⊢ + nlinarith only [h] + have hd (i : ι) : (1 - ∑ j, m i j) * cutoff (x i) ^ 2 ≤ + 57600 * ((1 - ∑ j, m i j) * weight (x i)) := by + have h := mul_le_mul_of_nonneg_left (cutoff_square_le_weight (hx i)) + (sub_nonneg.mpr (hmrow i)) + have hnn := mul_nonneg (sub_nonneg.mpr (hmrow i)) (weight_nonneg (hx i).le) + nlinarith only [h, hnn] + have he (j : κ) : (1 - ∑ i, m i j) * (1 + y j) * cutoff (y j) ^ 2 ≤ + 57600 * ((1 - ∑ i, m i j) * weight (y j)) := by + have h := mul_le_mul_of_nonneg_left (cutoff_weighted_square_le_weight (hy j)) + (sub_nonneg.mpr (hmcol j)) + have hnn := mul_nonneg (sub_nonneg.mpr (hmcol j)) (weight_nonneg (hy j).le) + nlinarith only [h, hnn] + have hs := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + Finset.sum_le_sum (s := Finset.univ) (fun j _ => hp i j)) + have hd := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hd i) + have he := Finset.sum_le_sum (s := Finset.univ) (fun j _ => he j) + simp_rw [← Finset.mul_sum] at hs hd he + rw [contraction_deficit_identity x y m n hx hy hn hrow hcol] + linarith only [hs, hd, he] + +lemma gain_deficit_identity + (x : ι → ℝ) (y : κ → ℝ) (m n : ι → κ → ℝ) + (hx : ∀ i, 0 < x i) + (hn : ∀ i j, n i j = m i j * y j / x i) + (hrow : ∀ i, ∑ j, m i j = 1) (hcol : ∀ j, ∑ i, m i j = 1) : + (∑ i, potential (x i)) - (∑ j, potential (y j)) = + (∑ i, ∑ j, m i j * scalarRemainder (x i) (y j)) + + (∑ i, (1 - ∑ j, n i j) * weight (x i)) / 2 + + (∑ j, (1 - ∑ i, n i j) * weight (y j)) / 2 := by + have hp (i : ι) (j : κ) : + m i j * scalarRemainder (x i) (y j) = + m i j * potential (x i) - m i j * potential (y j) + + (n i j * weight (x i) - m i j * weight (x i)) / 2 + + (n i j * weight (y j) - m i j * weight (y j)) / 2 := by + rw [hn] + dsimp only [scalarRemainder] + field_simp [ne_of_gt (hx i)] + ring + simp_rw [hp, Finset.sum_add_distrib, ← Finset.sum_div, Finset.sum_sub_distrib] + rw [sum_row m, sum_col m, sum_row n, sum_row m, sum_col n, sum_col m] + simp_rw [hrow, hcol, one_mul, sub_mul, one_mul, Finset.sum_sub_distrib] + ring + +lemma gain_spectral_bound + (x : ι → ℝ) (y : κ → ℝ) (m n : ι → κ → ℝ) + (hx : ∀ i, 0 < x i) (hy : ∀ j, 0 < y j) + (hm : ∀ i j, 0 ≤ m i j) + (hrow : ∀ i, ∑ j, m i j = 1) (hcol : ∀ j, ∑ i, m i j = 1) + (hn : ∀ i j, n i j = m i j * y j / x i) + (hnrow : ∀ i, ∑ j, n i j ≤ 1) (hncol : ∀ j, ∑ i, n i j ≤ 1) : + (∑ i, ∑ j, m i j * (1 + y j) * (cutoff (x i) - cutoff (y j)) ^ 2) + + (∑ i, x i * (1 - ∑ j, n i j) * cutoff (x i) ^ 2) ≤ + 115200 * ((∑ i, potential (x i)) - (∑ j, potential (y j))) := by + have hp (i : ι) (j : κ) : + m i j * (1 + y j) * (cutoff (x i) - cutoff (y j)) ^ 2 ≤ + 115200 * (m i j * scalarRemainder (x i) (y j)) := by + have h := mul_le_mul_of_nonneg_left (scalar_comparison (hx i) (hy j)).1 (hm i j) + rw [sq_abs] at h + nlinarith only [h] + have hd (i : ι) : x i * (1 - ∑ j, n i j) * cutoff (x i) ^ 2 ≤ + 57600 * ((1 - ∑ j, n i j) * weight (x i)) := by + have h := mul_le_mul_of_nonneg_left (cutoff_scaled_square_le_weight (hx i)) + (sub_nonneg.mpr (hnrow i)) + have hnn := mul_nonneg (sub_nonneg.mpr (hnrow i)) (weight_nonneg (hx i).le) + nlinarith only [h, hnn] + have he : 0 ≤ ∑ j, (1 - ∑ i, n i j) * weight (y j) := + Finset.sum_nonneg (fun j _ => + mul_nonneg (sub_nonneg.mpr (hncol j)) (weight_nonneg (hy j).le)) + have hs := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + Finset.sum_le_sum (s := Finset.univ) (fun j _ => hp i j)) + have hd := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hd i) + simp_rw [← Finset.mul_sum] at hs hd + rw [gain_deficit_identity x y m n hx hn hrow hcol] + linarith only [hs, hd, he] + +end SpectralEndpoints + +section RealMatrices + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def hsSquared {κ : Type*} [Fintype κ] (A : Matrix ι κ ℝ) : ℝ := + (A * A.transpose).trace + +omit [DecidableEq ι] in +lemma hermitian_dot (A : Matrix ι ι ℝ) (hA : A.IsHermitian) + (x y : ι → ℝ) : x ⬝ᵥ (A *ᵥ y) = (A *ᵥ x) ⬝ᵥ y := by + have ht : A.transpose = A := by + simpa only [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial] using hA + have hx : x ᵥ* A = A *ᵥ x := by simpa only [ht] using Matrix.vecMul_transpose A x + rw [Matrix.dotProduct_mulVec, hx] + +lemma le_of_square_le {S T : Matrix ι ι ℝ} (hS : S.PosSemidef) + (hT : T.PosSemidef) (hst : S * S ≤ T * T) : S ≤ T := by + let D := T - S + have hD : D.IsHermitian := hT.1.sub hS.1 + change D.PosSemidef + apply hD.posSemidef_iff_eigenvalues_nonneg.mpr + intro i + let v : ι → ℝ := (hD.eigenvectorBasis i).ofLp + let eig := hD.eigenvalues i + have heig : D *ᵥ v = eig • v := hD.mulVec_eigenvectorBasis i + have hv : v ⬝ᵥ v = 1 := by + have hn := real_inner_self_eq_norm_sq (hD.eigenvectorBasis i) + simpa only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, + OrthonormalBasis.norm_eq_one, one_pow] using hn + have hs : 0 ≤ v ⬝ᵥ (S *ᵥ v) := by + simpa only [star_trivial] using hS.dotProduct_mulVec_nonneg v + have ht : 0 ≤ v ⬝ᵥ (T *ᵥ v) := by + simpa only [star_trivial] using hT.dotProduct_mulVec_nonneg v + have hd : v ⬝ᵥ (T *ᵥ v) - v ⬝ᵥ (S *ᵥ v) = eig := by + have hdv : v ⬝ᵥ (D *ᵥ v) = eig := by rw [heig, dotProduct_smul, hv]; simp + simpa only [D, Matrix.sub_mulVec, dotProduct_sub] using hdv + have hq : 0 ≤ v ⬝ᵥ ((T * T - S * S) *ᵥ v) := by + simpa only [star_trivial] using (Matrix.le_iff.mp hst).dotProduct_mulVec_nonneg v + have hid : T * T - S * S = T * D + D * S := by dsimp [D]; noncomm_ring + have hformula : v ⬝ᵥ ((T * T - S * S) *ᵥ v) = + eig * (v ⬝ᵥ (T *ᵥ v) + v ⬝ᵥ (S *ᵥ v)) := by + rw [hid, Matrix.add_mulVec, dotProduct_add, ← Matrix.mulVec_mulVec, + ← Matrix.mulVec_mulVec, heig, Matrix.mulVec_smul, dotProduct_smul, + hermitian_dot D hD, heig, smul_dotProduct] + simp only [smul_eq_mul] + ring + rw [hformula] at hq + change 0 ≤ eig + by_contra hh + have hn : eig < 0 := lt_of_not_ge hh + have hp : 0 < v ⬝ᵥ (T *ᵥ v) + v ⬝ᵥ (S *ᵥ v) := by linarith + exact (not_lt_of_ge hq) (mul_neg_of_neg_of_pos hn hp) + +lemma sqrt_le_sqrt {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hB : B.PosSemidef) (hab : A ≤ B) : CFC.sqrt A ≤ CFC.sqrt B := by + apply le_of_square_le (CFC.sqrt_nonneg A).posSemidef (CFC.sqrt_nonneg B).posSemidef + simpa only [← sq, CFC.sq_sqrt A hA.nonneg, CFC.sq_sqrt B hB.nonneg] using hab + +lemma inv_le_inv {A B : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) + (hab : A ≤ B) : B⁻¹ ≤ A⁻¹ := by + let _ := hA.isUnit.invertible + let _ := hB.isUnit.invertible + have hD : (A⁻¹ - B⁻¹).IsHermitian := hA.1.inv.sub hB.1.inv + have h₁ := hA.posSemidef.conjTranspose_mul_mul_same (A⁻¹ - B⁻¹) + rw [hD.eq] at h₁ + have h₂ := (Matrix.le_iff.mp hab).conjTranspose_mul_mul_same B⁻¹ + rw [hB.1.inv.eq] at h₂ + have hid : (A⁻¹ - B⁻¹) * A * (A⁻¹ - B⁻¹) + B⁻¹ * (B - A) * B⁻¹ = + A⁻¹ - B⁻¹ := by + simp only [Matrix.sub_mul, Matrix.mul_sub, Matrix.mul_assoc, + Matrix.mul_inv_of_invertible, Matrix.inv_mul_of_invertible, + Matrix.mul_one, Matrix.one_mul] + abel + exact Matrix.le_iff.mpr (hid ▸ h₁.add h₂) + +lemma trace_mul_nonneg {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hB : B.PosSemidef) : 0 ≤ (A * B).trace := by + have hS : (CFC.sqrt A).IsHermitian := (CFC.sqrt_nonneg A).posSemidef.1 + have h := hB.conjTranspose_mul_mul_same (CFC.sqrt A) + rw [hS.eq] at h + have ht := h.trace_nonneg + rw [Matrix.trace_mul_cycle, ← sq, CFC.sq_sqrt A hA.nonneg] at ht + exact ht + +lemma trace_mul_mono_right {A B Q : Matrix ι ι ℝ} + (hab : A ≤ B) (hQ : Q.PosSemidef) : (A * Q).trace ≤ (B * Q).trace := by + have h := trace_mul_nonneg (Matrix.le_iff.mp hab) hQ + simpa only [Matrix.sub_mul, Matrix.trace_sub, sub_nonneg] using h + +end RealMatrices +end EuclideanSteinitz.MatrixEnergy + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Model.lean b/lean/OAI/Analysis/Steinitz/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d02ce41d28b2ef37d4d9b9aa56e35d1e0a6d44f --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Model.lean @@ -0,0 +1,26 @@ +import Mathlib + +namespace OAI + +namespace EuclideanSteinitzBergstrom + +abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d) + +def SignedPrefixBound (C : ℝ) : Prop := + ∀ (d N : ℕ), 1 ≤ d → 1 ≤ N → + ∀ (v : Fin N → Vector d), (∀ i, ‖v i‖ ≤ 1) → + ∃ ε : Fin N → ℝ, (∀ i, ε i = -1 ∨ ε i = 1) ∧ + ∀ k : ℕ, k ≤ N → + ‖∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k), ε i • v i‖ ≤ + C * Real.sqrt d + +def OrderingPrefixBound (C : ℝ) : Prop := + ∀ (d N : ℕ), 1 ≤ d → 1 ≤ N → + ∀ (v : Fin N → Vector d), (∀ i, ‖v i‖ ≤ 1) → (∑ i, v i) = 0 → + ∃ π : Equiv.Perm (Fin N), ∀ k : ℕ, k ≤ N → + ‖∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k), v (π i)‖ ≤ + C * Real.sqrt d + +end EuclideanSteinitzBergstrom + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/PathLaws.lean b/lean/OAI/Analysis/Steinitz/PathLaws.lean new file mode 100644 index 0000000000000000000000000000000000000000..1741d0f0d4854c73a526f87f942f319d5bbb9e90 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/PathLaws.lean @@ -0,0 +1,567 @@ +import OAI.Analysis.Steinitz.HeatL2 + +namespace OAI + +/-! Gaussian heat kernels and autoregressive path laws. -/ + +section + +open MeasureTheory ProbabilityTheory WithLp +open scoped NNReal ENNReal RealInnerProductSpace +namespace GaussianKernel +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma scaleMap_selfAdjoint (v : ι → ℝ≥0) : IsSelfAdjoint (scaleMap v) := by + apply ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mpr + intro x y + simp only [PiLp.inner_apply, RCLike.inner_apply, conj_trivial] + apply Finset.sum_congr rfl + intro i _ + change y i * (scaleMap v x) i = (scaleMap v y) i * x i + rw [scaleMap_apply, scaleMap_apply] + ring + +noncomputable def symbol (v : ι → ℝ≥0) (ξ : EuclideanSpace ℝ ι) : ℝ := + (∑ i, (v i : ℝ)*(2*Real.pi*ξ i)^2)/2 + +lemma symbol_eq (v : ι → ℝ≥0) : HeatL2.gaussianSymbol (scaleMap v) = symbol v := by + ext ξ + rw [HeatL2.gaussianSymbol, (scaleMap_selfAdjoint v).adjoint_eq, + EuclideanSpace.real_norm_sq_eq] + unfold symbol + congr 1 + apply Finset.sum_congr rfl + intro i _ + simp only [PiLp.smul_apply, smul_eq_mul, scaleMap_apply, mul_pow, + Real.sq_sqrt (v i).coe_nonneg] + ring + +omit [DecidableEq ι] in +lemma symbol_continuous (v : ι → ℝ≥0) : Continuous (symbol v) := by + unfold symbol + fun_prop + +omit [DecidableEq ι] in +lemma symbol_nonneg (v : ι → ℝ≥0) (ξ : EuclideanSpace ℝ ι) : 0 ≤ symbol v ξ := by + unfold symbol + positivity + +lemma average_diagonal_eq (v : ι → ℝ≥0) : + HeatL2.average (ContinuousLinearMap.id ℝ (EuclideanSpace ℝ ι)) (diagonalLaw v) = + HeatL2.average (scaleMap v) (stdGaussian (EuclideanSpace ℝ ι)) := by + apply ContinuousLinearMap.ext + intro f + rw [HeatL2.average_apply, HeatL2.average_apply, ← stdGaussian_map_scale v] + change (∫ z, HeatL2.translate z f ∂(stdGaussian (EuclideanSpace ℝ ι)).map (scaleMap v)) = _ + exact integral_map (scaleMap v).measurable.aemeasurable + (HeatL2.translate_continuous f).aestronglyMeasurable + +lemma average_diagonal_heat (v : ι → ℝ≥0) : + HeatL2.average (ContinuousLinearMap.id ℝ (EuclideanSpace ℝ ι)) (diagonalLaw v) = + HeatL2.heat (symbol v) (symbol_continuous v).aestronglyMeasurable (symbol_nonneg v) := by + rw [average_diagonal_eq, HeatL2.average_gaussian_eq_heat] + congr 1 + exact symbol_eq v + +noncomputable def kernel (v : ι → ℝ≥0) : HeatL2.BoundedKernel (EuclideanSpace ℝ ι) := + HeatL2.densityKernel (density v) (density_continuous v).measurable (density_nonneg v) (density_le_zero v) + +omit [DecidableEq ι] in +lemma kernel_symmetric (v : ι → ℝ≥0) (x y : EuclideanSpace ℝ ι) : + (kernel v).value (x,y) = (kernel v).value (y,x) := by + change density v (y-x) = density v (x-y) + rw [← neg_sub y x, density_neg] + +lemma kernel_norm_eq (v : ι → ℝ≥0) (hv : ∀ i, v i ≠ 0) + (D : Set (EuclideanSpace ℝ ι)) (hD : MeasurableSet D) [IsFiniteMeasure (volume.restrict D)] : + ‖HeatL2.kernelOp (μ := volume.restrict D) (kernel v)‖ = + ‖HeatL2.compressedHeat D hD (symbol v) (symbol_continuous v).aestronglyMeasurable (symbol_nonneg v)‖ := by + unfold kernel + rw [← HeatL2.compressedAverage_kernel_norm D hD (diagonalLaw v) (density v) + (density_continuous v).measurable (density_nonneg v) (density_le_zero v) + (diagonalLaw_density v hv), average_diagonal_heat] + rfl + +end GaussianKernel + +open MeasureTheory ProbabilityTheory Set WithLp +open scoped NNReal ENNReal +namespace GaussianKernel + +lemma gaussianPDF_logconcave {v : ℝ≥0} (hv : v ≠ 0) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) + (x y : ℝ) : + gaussianPDFReal 0 v x ^ (1-t) * gaussianPDFReal 0 v y ^ t ≤ + gaussianPDFReal 0 v ((1-t)*x+t*y) := by + have hvp : (0:ℝ) gaussianPDFReal_nonneg 0 (v i) (x i)), + ← Real.finsetProd_rpow _ _ (fun i _ => gaussianPDFReal_nonneg 0 (v i) (y i)), + ← Finset.prod_mul_distrib] + apply Finset.prod_le_prod₀ + · intro i _ + exact mul_nonneg (Real.rpow_nonneg (gaussianPDFReal_nonneg _ _ _) _) + (Real.rpow_nonneg (gaussianPDFReal_nonneg _ _ _) _) + · intro i _ + exact gaussianPDF_logconcave (hv i) ht (x i) (y i) + +end GaussianKernel + +end + +section + +open MeasureTheory Set Filter +open scoped ENNReal ComplexInnerProductSpace +namespace HeatL2 + +lemma integral_pi_fin_cons {X G : Type*} [MeasurableSpace X] + [NormedAddCommGroup G] [NormedSpace ℝ G] (μ : Measure X) [SigmaFinite μ] + {n : ℕ} {f : (Fin (n+1) → X) → G} (hf : Integrable f (Measure.pi fun _ => μ)) : + (∫ p, f p ∂Measure.pi (fun _ : Fin (n+1) => μ)) = + ∫ x, ∫ p, f (Fin.cons x p) ∂Measure.pi (fun _ : Fin n => μ) ∂μ := by + let e := MeasurableEquiv.piFinSuccAbove (fun _ : Fin (n+1) => X) 0 + have he : ∀ z : X × (Fin n → X), e.symm z = Fin.cons z.1 z.2 := by + intro z + ext i + refine Fin.cases ?_ (fun j => ?_) i + · simp [e] + · simp [e] + have hp := (measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) => μ) 0).symm + have hi : Integrable (fun z : X × (Fin n → X) => f (e.symm z)) (μ.prod (Measure.pi fun _ => μ)) := + hp.integrable_comp_of_integrable hf + rw [← hp.integral_comp e.symm.measurableEmbedding f] + rw [integral_prod _ hi] + apply integral_congr_ae + exact Filter.Eventually.of_forall fun x => integral_congr_ae + (Filter.Eventually.of_forall fun p => congrArg f (he (x,p))) + +section Chain +variable {X : Type*} [MeasurableSpace X] (k : BoundedKernel X) +noncomputable def tailWeight : (n : ℕ) → X → (Fin n → X) → ℝ + | 0, _, _ => 1 + | n+1, x, p => k.value (x,p 0) * tailWeight n (p 0) (fun i => p i.succ) + +lemma tailWeight_measurable (n : ℕ) : Measurable (fun z : X × (Fin n → X) => tailWeight k n z.1 z.2) := by + induction n with + | zero => exact measurable_const + | succ n hn => + exact (k.measurable.comp (measurable_fst.prodMk ((measurable_pi_apply 0).comp measurable_snd))).mul + (hn.comp (((measurable_pi_apply 0).comp measurable_snd).prodMk + (Measurable.of_eval fun (i : Fin n) => (measurable_pi_apply i.succ).comp measurable_snd))) + +lemma tailWeight_nonneg (n : ℕ) (x : X) (p : Fin n → X) : 0 ≤ tailWeight k n x p := by + induction n generalizing x with + | zero => exact zero_le_one + | succ n hn => exact mul_nonneg (k.nonneg _) (hn _ _) + +lemma tailWeight_le (n : ℕ) (x : X) (p : Fin n → X) : tailWeight k n x p ≤ k.bound^n := by + induction n generalizing x with + | zero => exact le_rfl + | succ n hn => + rw [tailWeight, pow_succ'] + exact mul_le_mul (k.le_bound _) (hn _ _) (tailWeight_nonneg k n _ _) k.bound_nonneg + +lemma tailWeight_integrable {μ : Measure X} [IsFiniteMeasure μ] (n : ℕ) (x : X) : + Integrable (tailWeight k n x) (Measure.pi fun _ : Fin n => μ) := by + apply Integrable.mono' (integrable_const (k.bound^n)) + ((tailWeight_measurable k n).comp measurable_prodMk_left).aestronglyMeasurable + exact Filter.Eventually.of_forall fun p => by + change ‖tailWeight k n x p‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (tailWeight_nonneg k n x p)] + exact tailWeight_le k n x p + +noncomputable def walk (μ : Measure X) (n : ℕ) (x : X) : ℝ := + ∫ p, tailWeight k n x p ∂Measure.pi (fun _ : Fin n => μ) + +lemma walk_zero (μ : Measure X) (x : X) : walk k μ 0 x = 1 := by + simp [walk,tailWeight, Measure.real] + +lemma walk_succ {μ : Measure X} [IsFiniteMeasure μ] (n : ℕ) (x : X) : + walk k μ (n+1) x = ∫ y, k.value (x,y) * walk k μ n y ∂μ := by + rw [walk, integral_pi_fin_cons μ (tailWeight_integrable k (n+1) x)] + apply integral_congr_ae + refine Filter.Eventually.of_forall fun y => ?_ + simp only [tailWeight, Fin.cons_zero, Fin.cons_succ] + rw [integral_const_mul] + rfl + +lemma walk_measurable {μ : Measure X} [SigmaFinite μ] (n : ℕ) : Measurable (walk k μ n) := by + exact (tailWeight_measurable k n).stronglyMeasurable.integral_prod_right.measurable + +lemma walk_nonneg (μ : Measure X) (n : ℕ) (x : X) : 0 ≤ walk k μ n x := + integral_nonneg (fun p => tailWeight_nonneg k n x p) + +lemma walk_le {μ : Measure X} [IsFiniteMeasure μ] (n : ℕ) (x : X) : + walk k μ n x ≤ (Measure.pi (fun _ : Fin n => μ)).real univ * k.bound^n := by + change (∫ p, tailWeight k n x p ∂Measure.pi (fun _ : Fin n => μ)) ≤ _ + change _ ≤ (Measure.pi (fun _ : Fin n => μ)).real univ • (k.bound^n) + rw [← integral_const] + exact integral_mono (tailWeight_integrable k n x) (integrable_const _) (tailWeight_le k n x) + +lemma kernel_pow_one_coe {μ : Measure X} [IsFiniteMeasure μ] (n : ℕ) : + ((kernelOp (μ := μ) k ^ n) (oneLp : Lp ℂ 2 μ) : X → ℂ) =ᵐ[μ] fun x => (walk k μ n x : ℂ) := by + induction n with + | zero => simpa only [pow_zero, one_apply_eq_self, walk_zero, Complex.ofReal_one] using oneLp_coe (μ := μ) + | succ n hn => + rw [pow_succ', mul_apply_eq_comp] + filter_upwards [kernelOp_coe k ((kernelOp k ^ n) oneLp)] with x hx + rw [hx, kernelFun, walk_succ] + calc + _ = ∫ y, ((k.value (x,y) * walk k μ n y : ℝ) : ℂ) ∂μ := by + apply integral_congr_ae + filter_upwards [hn] with y hy + rw [hy, Complex.ofReal_mul] + _ = _ := integral_complex_ofReal + +noncomputable def chainWeight (n : ℕ) (p : Fin (n+1) → X) : ℝ := + tailWeight k n (p 0) (fun i => p i.succ) + +lemma chainWeight_measurable (n : ℕ) : Measurable (chainWeight k n) := by + let f : (Fin (n+1) → X) → X × (Fin n → X) := fun p => (p 0, fun i => p i.succ) + have hf : Measurable f := by + exact (measurable_pi_apply 0).prodMk + (Measurable.of_eval fun (i : Fin n) => measurable_pi_apply i.succ) + exact (tailWeight_measurable k n).comp hf + +lemma chainWeight_integrable {μ : Measure X} [IsFiniteMeasure μ] (n : ℕ) : + Integrable (chainWeight k n) (Measure.pi fun _ : Fin (n+1) => μ) := by + apply Integrable.mono' (integrable_const (k.bound^n)) (chainWeight_measurable k n).aestronglyMeasurable + exact Filter.Eventually.of_forall fun p => by + change ‖tailWeight k n (p 0) (fun i => p i.succ)‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (tailWeight_nonneg k n _ _)] + exact tailWeight_le k n _ _ + +lemma pathMass_pi {μ : Measure X} [IsFiniteMeasure μ] (n : ℕ) : + pathMass (μ := μ) k n = ∫ p, chainWeight k n p ∂Measure.pi (fun _ : Fin (n+1) => μ) := by + rw [pathMass_eq_integral, integral_pi_fin_cons μ (chainWeight_integrable k n)] + apply integral_congr_ae + filter_upwards [kernel_pow_one_coe k n] with x hx + rw [hx,Complex.ofReal_re] + simp only [chainWeight,Fin.cons_zero,Fin.cons_succ] + rfl + +end Chain +end HeatL2 + +open MeasureTheory Set +namespace HeatL2 +section ChainContinuity +variable {X : Type*} [MeasurableSpace X] [TopologicalSpace X] +variable (k : BoundedKernel X) (hc : Continuous k.value) +include hc +lemma tailWeight_continuous (n : ℕ) : Continuous (fun z : X × (Fin n → X) => tailWeight k n z.1 z.2) := by + induction n with + | zero => exact continuous_const + | succ n ih => + change Continuous (fun z : X × (Fin (n+1) → X) => + k.value (z.1,z.2 0) * tailWeight k n (z.2 0) (fun i => z.2 i.succ)) + apply Continuous.mul + · exact hc.comp (continuous_fst.prodMk ((continuous_apply 0).comp continuous_snd)) + · exact ih.comp (((continuous_apply 0).comp continuous_snd).prodMk + (continuous_pi (fun (i : Fin n) => (continuous_apply i.succ).comp continuous_snd))) + +lemma chainWeight_continuous (n : ℕ) : Continuous (chainWeight k n) := by + let f : (Fin (n+1) → X) → X × (Fin n → X) := fun p => (p 0, fun i => p i.succ) + have hf : Continuous f := by fun_prop + exact (tailWeight_continuous k hc n).comp hf +end ChainContinuity +section ChainPos +variable {X : Type*} [MeasurableSpace X] (k : BoundedKernel X) +lemma tailWeight_pos (hp : ∀ z, 0 < k.value z) (n : ℕ) (x : X) (p : Fin n → X) : + 0 < tailWeight k n x p := by + induction n generalizing x with + | zero => exact zero_lt_one + | succ n ih => exact mul_pos (hp _) (ih _ _) +end ChainPos +section ChainConcavity +variable {X : Type*} [MeasurableSpace X] [AddCommGroup X] [Module ℝ X] +variable (k : BoundedKernel X) {t : ℝ} +variable (hl : ∀ x y : X × X, k.value x^(1-t) * k.value y^t ≤ k.value ((1-t)•x+t•y)) +include hl +lemma tailWeight_logconcave (n : ℕ) (x y : X) (p q : Fin n → X) : + tailWeight k n x p^(1-t) * tailWeight k n y q^t ≤ + tailWeight k n ((1-t)•x+t•y) ((1-t)•p+t•q) := by + induction n generalizing x y with + | zero => simp [tailWeight] + | succ n ih => + simp only [tailWeight, Pi.add_apply, Pi.smul_apply] + rw [Real.mul_rpow (k.nonneg _) (tailWeight_nonneg k n _ _), + Real.mul_rpow (k.nonneg _) (tailWeight_nonneg k n _ _)] + calc + _ = (k.value (x,p 0)^(1-t) * k.value (y,q 0)^t) * + (tailWeight k n (p 0) (fun i => p i.succ)^(1-t) * + tailWeight k n (q 0) (fun i => q i.succ)^t) := by ring + _ ≤ _ := mul_le_mul (hl (x,p 0) (y,q 0)) (ih _ _ _ _) + (mul_nonneg (Real.rpow_nonneg (tailWeight_nonneg k n _ _) _) + (Real.rpow_nonneg (tailWeight_nonneg k n _ _) _)) (k.nonneg _) + +lemma chainWeight_logconcave (n : ℕ) (p q : Fin (n+1) → X) : + chainWeight k n p^(1-t) * chainWeight k n q^t ≤ chainWeight k n ((1-t)•p+t•q) := + tailWeight_logconcave k hl n (p 0) (q 0) (fun i => p i.succ) (fun i => q i.succ) +end ChainConcavity +end HeatL2 + +end + +section + +open MeasureTheory +namespace HeatL2 +variable {X : Type*} [MeasurableSpace X] + +lemma chainWeight_prod (k : BoundedKernel X) (n : ℕ) (p : Fin (n+1) → X) : + chainWeight k n p = ∏ t : Fin n,k.value (p t.castSucc,p t.succ) := by + induction n with + | zero => simp [chainWeight,tailWeight] + | succ n ih => + change k.value (p 0,p (Fin.succ 0))*chainWeight k n (fun t => p t.succ)=_ + rw [ih,Fin.prod_univ_succ] + congr 1 + +lemma fin_sum_differences {n : ℕ} (f : Fin (n+1) → ℝ) : + (∑ t : Fin n,(f t.castSucc-f t.succ))=f 0-f (Fin.last n) := by + rw [Finset.sum_sub_distrib] + have ha := Fin.sum_univ_castSucc f + have hb := Fin.sum_univ_succ f + linarith + +end HeatL2 + +end + +section + +open MeasureTheory WithLp Set +namespace GaussianAR + +lemma measurePreserving_curry (T I : Type*) [Fintype T] [Fintype I] : + MeasurePreserving (MeasurableEquiv.curry T I ℝ) := by + apply MeasurePreserving.symm (MeasurableEquiv.curry T I ℝ).symm + refine ⟨(MeasurableEquiv.curry T I ℝ).symm.measurable,?_⟩ + rw [volume_pi] + apply (Measure.pi_eq fun s hs => ?_).symm + rw [Measure.map_apply (MeasurableEquiv.curry T I ℝ).symm.measurable (MeasurableSet.univ_pi hs)] + have he : (MeasurableEquiv.curry T I ℝ).symm ⁻¹' Set.univ.pi s = + Set.univ.pi (fun t => Set.univ.pi (fun i => s (t,i))) := by ext x; simp + rw [he,volume_pi,Measure.pi_pi] + simp only [Measure.pi_pi,Fintype.prod_prod_type] + +noncomputable def unpack (T I : Type*) [Fintype T] [Fintype I] : + EuclideanSpace ℝ (T×I) ≃ᵐ (T → EuclideanSpace ℝ I) := + (MeasurableEquiv.toLp 2 (T×I → ℝ)).symm.trans ((MeasurableEquiv.curry T I ℝ).trans + (MeasurableEquiv.piCongrRight (fun _ : T => (MeasurableEquiv.toLp 2 (I → ℝ))))) + +lemma unpack_apply {T I : Type*} [Fintype T] [Fintype I] + (x : EuclideanSpace ℝ (T×I)) (t : T) (i : I) : unpack T I x t i=x (t,i) := rfl + +lemma unpack_preserving (T I : Type*) [Fintype T] [Fintype I] : + MeasurePreserving (unpack T I) := by + have hp : MeasurePreserving (MeasurableEquiv.piCongrRight + (fun _ : T => MeasurableEquiv.toLp 2 (I → ℝ))) := by + refine ⟨(MeasurableEquiv.piCongrRight (fun _ : T => MeasurableEquiv.toLp 2 (I → ℝ))).measurable,?_⟩ + change (volume : Measure (T → I → ℝ)).map (fun x t => toLp 2 (x t)) = + (volume : Measure (T → EuclideanSpace ℝ I)) + let : SigmaFinite ((volume : Measure (I → ℝ)).map (toLp 2)) := by + rw [(PiLp.volume_preserving_toLp I).map_eq] + infer_instance + rw [volume_pi,Measure.pi_map_pi (fun _ => (PiLp.volume_preserving_toLp I).measurable.aemeasurable)] + simp only [(PiLp.volume_preserving_toLp I).map_eq,← volume_pi] + exact hp.comp ((measurePreserving_curry T I).comp (PiLp.volume_preserving_ofLp (T×I))) + +end GaussianAR + +end + +section + +open Matrix MeasureTheory ProbabilityTheory WithLp +open scoped RealInnerProductSpace ENNReal NNReal BigOperators +namespace GaussianAR +open GaussianKernel +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def transition (r : ι → ℝ) (x y : EuclideanSpace ℝ ι) : ℝ := + ∏ i,(Real.sqrt (1-(r i)^2))⁻¹*gaussianPDFReal 0 1 ((y i-r i*x i)/Real.sqrt (1-(r i)^2)) + +omit [DecidableEq ι] in +lemma transition_nonneg (r : ι → ℝ) (x y : EuclideanSpace ℝ ι) : 0≤transition r x y := by + apply Finset.prod_nonneg + intro i _ + exact mul_nonneg (inv_nonneg.mpr (Real.sqrt_nonneg _)) (gaussianPDFReal_nonneg _ _ _) + +omit [DecidableEq ι] in +lemma transition_le (r : ι → ℝ) (hr : ∀ i,0 1) ((pathEquiv r hr hr1 n).symm x) = + density (fun _ => 1) (unpack (Fin (n+1)) ι x 0) * + ∏ t : Fin n,transition r (unpack (Fin (n+1)) ι x t.castSucc) (unpack (Fin (n+1)) ι x t.succ) := by + have hd : (pathEquiv r hr hr1 n).symm.toContinuousLinearMap.det = + ((∏ i,Real.sqrt (1-(r i)^2))^n)⁻¹ := by + change (pathEquiv r hr hr1 n).toLinearEquiv.symm.toLinearMap.det=_ + rw [LinearEquiv.det_coe_symm] + exact congrArg Inv.inv (pathEquiv_det r hr hr1 n) + rw [hd,abs_of_nonneg (by positivity)] + simp only [density,Fintype.prod_prod_type,Fin.prod_univ_succ,pathEquiv_symm_initial, + pathEquiv_symm_step,transition,unpack_apply,Finset.prod_mul_distrib, + Finset.prod_const,Finset.card_univ,Fintype.card_fin,← Finset.prod_inv_distrib,← inv_pow] + ring + +lemma path_density_le (r : ι → ℝ) (hr : ∀ i,0 (hr i).le) hr1 n).symm.toContinuousLinearMap.det| * + density (fun _ => 1) ((pathEquiv r (fun i => (hr i).le) hr1 n).symm x) ≤ + density (fun _ : ι => 1) 0 * (∏ i,(Real.sqrt (r i))⁻¹)^n * + HeatL2.chainWeight (kernel w) n (unpack (Fin (n+1)) ι x) := by + let p := unpack (Fin (n+1)) ι x + rw [path_density_eq] + change density (fun _ => 1) (p 0)*(∏ t : Fin n,transition r (p t.castSucc) (p t.succ))≤_ + have hp := Finset.prod_le_prod₀ (fun (t : Fin n) (_ : t∈Finset.univ) => transition_nonneg r (p t.castSucc) (p t.succ)) + (fun (t : Fin n) (_ : t∈Finset.univ) => transition_le r hr hr1 w hw (p t.castSucc) (p t.succ)) + apply (mul_le_mul_of_nonneg_left hp (density_nonneg _ _)).trans + simp only [Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ,Fintype.card_fin,← Real.exp_sum, + ← Finset.sum_div] + rw [HeatL2.fin_sum_differences (fun t => ‖p t‖^2)] + have hchain : (∏ t : Fin n,density w (p t.succ-p t.castSucc))=HeatL2.chainWeight (kernel w) n p := by + rw [HeatL2.chainWeight_prod]; rfl + rw [hchain,density_exp] + have he : Real.exp (-(∑ i,(p 0 i)^2/(2*(1:ℝ≥0)))) * + Real.exp ((‖p 0‖^2-‖p (Fin.last n)‖^2)/4) ≤ 1 := by + rw [← Real.exp_add,Real.exp_le_one_iff] + simp only [NNReal.coe_one,mul_one,← Finset.sum_div,← EuclideanSpace.real_norm_sq_eq] + nlinarith [sq_nonneg ‖p 0‖,sq_nonneg ‖p (Fin.last n)‖] + have hn : 0 ≤ density (fun _ : ι => 1) 0 * (∏ i,(Real.sqrt (r i))⁻¹)^n * + HeatL2.chainWeight (kernel w) n p := by + exact mul_nonneg (mul_nonneg (density_nonneg _ _) (by positivity)) (HeatL2.tailWeight_nonneg _ _ _ _) + nlinarith [mul_le_mul_of_nonneg_left he hn] + +end GaussianAR + +end + +section + +open Matrix MeasureTheory ProbabilityTheory Set +open scoped RealInnerProductSpace NNReal ENNReal BigOperators +namespace GaussianAR +open GaussianKernel HeatL2 GaussianTail +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma survival_le_pathMass (r : ι → ℝ) (hr : ∀ i,0 1) 0 * (∏ i,(Real.sqrt (r i))⁻¹)^n * + pathMass (μ := volume.restrict D) (kernel w) n := by + let P : Set (Fin (n+1) → EuclideanSpace ℝ ι) := univ.pi (fun _ => D) + let S := (unpack (Fin (n+1)) ι) ⁻¹' P + let e := pathEquiv r (fun i => (hr i).le) hr1 n + have hP : MeasurableSet P := MeasurableSet.univ_pi (fun _ => hD) + have hS : MeasurableSet S := hP.preimage (unpack (Fin (n+1)) ι).measurable + have heq : e ⁻¹' S = {x | ∀ t : Fin (n+1),matrixMap (evaluation r n t) x ∈ D} := by + ext x + change (∀ t ∈ univ,unpack (Fin (n+1)) ι (e x) t ∈ D) ↔ _ + have he (t : Fin (n+1)) : unpack (Fin (n+1)) ι (e x) t = matrixMap (evaluation r n t) x := by + ext i + rw [unpack_apply,pathEquiv_apply,pathMatrix_apply] + simp only [he,mem_univ,forall_const,mem_ofPred_eq] + have hprob : (stdGaussian (EuclideanSpace ℝ (Fin (n+1)×ι))).real + {x | ∀ t : Fin (n+1),matrixMap (evaluation r n t) x ∈ D} = + ∫ x in S, |e.symm.toContinuousLinearMap.det| *density (fun _ => 1) (e.symm x) := by + rw [Measure.real,← heq,← Measure.map_apply e.continuous.measurable hS, + linear_image_density e hS,ENNReal.toReal_ofReal] + exact integral_nonneg (fun x => mul_nonneg (abs_nonneg _) (density_nonneg _ _)) + have hchain : Integrable (chainWeight (kernel w) n) (volume.restrict P) := by + simpa only [P,volume_pi,Measure.restrict_pi_pi] using + (chainWeight_integrable (kernel w) (μ := volume.restrict D) n) + have hic : Integrable (fun x => chainWeight (kernel w) n (unpack (Fin (n+1)) ι x)) (volume.restrict S) := + ((unpack_preserving (Fin (n+1)) ι).restrict_preimage_emb + (unpack (Fin (n+1)) ι).measurableEmbedding P).integrable_comp_of_integrable hchain + rw [hprob] + calc + _ ≤ ∫ x in S, density (fun _ : ι => 1) 0 * (∏ i,(Real.sqrt (r i))⁻¹)^n * + chainWeight (kernel w) n (unpack (Fin (n+1)) ι x) := by + apply integral_mono_of_nonneg + (Filter.Eventually.of_forall fun x => mul_nonneg (abs_nonneg _) (density_nonneg _ _)) + (hic.const_mul _) + exact Filter.Eventually.of_forall (path_density_le r hr hr1 w hw n) + _ = _ := by + rw [integral_const_mul,(unpack_preserving (Fin (n+1)) ι).setIntegral_preimage_emb + (unpack (Fin (n+1)) ι).measurableEmbedding] + congr 1 + simp only [P,volume_pi,Measure.restrict_pi_pi,pathMass_pi] + +lemma kernel_norm_of_survival (r : ι → ℝ) (hr : ∀ i,0 1) 0 := density_pos _ (fun _ => by simp) _ + have hc : 0 < ∏ i,(Real.sqrt (r i))⁻¹ := Finset.prod_pos fun i _ => + inv_pos.mpr (Real.sqrt_pos.mpr (hr i)) + apply norm_lower_of_pathMass_lower (kernel w) (by positivity) (c := Real.exp (-a)/density (fun _ : ι => 1) 0) (by positivity) + intro n + have hn := (hs n).trans (survival_le_pathMass r hr hr1 w hw D hD n) + have hex : Real.exp (-a-b*n)=Real.exp (-a)*(Real.exp (-b))^n := by + rw [show -a-b*(n:ℝ)= -a+(-b)*n by ring,Real.exp_add,mul_comm (-b),Real.exp_nat_mul] + rw [hex] at hn + apply (mul_le_mul_iff_left₀ (mul_pos hρ (pow_pos hc n))).mp + convert hn using 1 + · calc + _ = (Real.exp (-a)/density (fun _ : ι => 1) 0 * density (fun _ : ι => 1) 0) * + ((Real.exp (-b))^n/(∏ i,(Real.sqrt (r i))⁻¹)^n * (∏ i,(Real.sqrt (r i))⁻¹)^n) := by + rw [div_pow]; ring + _ = _ := by rw [div_mul_cancel₀ _ hρ.ne',div_mul_cancel₀ _ (pow_ne_zero n hc.ne')] + · ring + +end GaussianAR + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Predictor.lean b/lean/OAI/Analysis/Steinitz/Predictor.lean new file mode 100644 index 0000000000000000000000000000000000000000..669601ca58cbcc6aeb831baecf03f8d900f93603 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Predictor.lean @@ -0,0 +1,253 @@ +import OAI.Analysis.Steinitz.FilterMoments + +namespace OAI + +/-! Predictor-column energy and exact feedback cancellation. -/ + +section + +open Matrix GaussianTail +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +noncomputable def rawRow (R : Matrix ι κ ℝ) (b : ι → ℝ) : κ → ℝ := + fun j => eta b*(b ⬝ᵥ (fun i => R i j)) +noncomputable def predictorRows (R : Matrix ι κ ℝ) : List (Step ι κ) → List (κ → ℝ) + | [] => [] + | p::ps => rawRow R p.b :: predictorRows (p.apply R) ps + +omit [Fintype κ] [DecidableEq ι] in +lemma predictorRows_length (R : Matrix ι κ ℝ) (L : List (Step ι κ)) : + (predictorRows R L).length=L.length := by + induction L generalizing R with + | nil => rfl + | cons p ps ih => simp only [predictorRows,List.length_cons,ih] + +omit [Fintype κ] [DecidableEq ι] in +lemma predictorRows_get (R : Matrix ι κ ℝ) (L : List (Step ι κ)) (k : ℕ) (hk : k simp at hk + | cons p ps ih => + cases k with + | zero => rfl + | succ k => + simpa only [predictorRows,List.getElem_cons_succ,List.take_succ_cons,run] using + ih (p.apply R) k (by simpa using hk) + +omit [DecidableEq κ] in +lemma vectorMass_vecMul {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) (b : ι → ℝ) : + vectorMass (b ᵥ* R)=vectorMass b := by + have hh := congrArg (fun A : Matrix ι ι ℝ => b ⬝ᵥ(A*ᵥb)) hR + rw [← Matrix.mulVec_mulVec,Matrix.dotProduct_mulVec,Matrix.mulVec_transpose,Matrix.one_mulVec] at hh + simpa only [vectorMass,dotProduct,← pow_two] using hh + +omit [DecidableEq κ] in +lemma rawRow_mass {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) (b : ι → ℝ) : + vectorMass (rawRow R b) ≤ vectorMass b := by + have he : vectorMass (rawRow R b)=eta b^2*vectorMass (b ᵥ* R) := by + unfold vectorMass rawRow + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + rw [mul_pow] + rfl + rw [he,vectorMass_vecMul hR] + have hh : eta b^2≤1 := by nlinarith [eta_pos b,eta_le_one b] + simpa only [one_mul] using mul_le_mul_of_nonneg_right hh (vectorMass_nonneg b) + +omit [DecidableEq ι] [Fintype κ] [DecidableEq κ] in +lemma rawRow_zero_col (R : Matrix ι κ ℝ) (b : ι → ℝ) {j : κ} (h : ∀ i,R i j=0) : + rawRow R b j=0 := by simp [rawRow,h,dotProduct] + +omit [Fintype κ] in +lemma rawRow_loss {p : Step ι κ} (hs : p.C=symmetricContraction p.b) (hb : vectorMass p.b≤1) + (R : Matrix ι κ ℝ) (hR : ∀ i,R i p.j=0) (j : κ) : + rawRow R p.b j^2+vectorMass (fun i => p.apply R i j) ≤ + vectorMass (fun i => R i j)+(if p.j=j then vectorMass p.b else 0) := by + have heta : eta p.b^2≤1 := by nlinarith [eta_pos p.b,eta_le_one p.b] + by_cases hj : p.j=j + · subst j + have he : (fun i => p.apply R i p.j)=p.b := by + ext i + simp [Step.apply,Matrix.mul_apply,insert,hR] + rw [he,rawRow_zero_col R p.b hR] + simp [vectorMass,hR] + · have he : (fun i => p.apply R i j)=symmetricContraction p.b*ᵥ(fun i => R i j) := by + ext i + simp [Step.apply,Matrix.mul_apply,insert,Ne.symm hj,hs,Matrix.mulVec,dotProduct] + rw [he,ite_eq_right hj] + have hh := contraction_loss hb (fun i => R i j) + have hm := mul_le_mul_of_nonneg_right heta (sq_nonneg (p.b ⬝ᵥ fun i => R i j)) + simp only [rawRow,mul_pow] + nlinarith + +omit [Fintype κ] in +lemma predictor_column_budget {R : Matrix ι κ ℝ} {L : List (Step ι κ)} + (hs : ∀ p∈L,p.C=symmetricContraction p.b) (hb : ∀ p∈L,vectorMass p.b≤1) + (hf : Fresh R L) (hd : (L.map Step.j).Nodup) (j : κ) : + ((predictorRows R L).map (fun m => m j^2)).sum + vectorMass (fun i => run R L i j) ≤ + vectorMass (fun i => R i j)+(L.map (fun p => if p.j=j then vectorMass p.b else 0)).sum := by + induction L generalizing R with + | nil => simp [predictorRows,run] + | cons p ps ih => + have hd' := List.nodup_cons.mp hd + have htail : ∀ r∈ps,p.j≠r.j := by + intro r hr he + exact hd'.1 (List.mem_map.mpr ⟨r,hr,he.symm⟩) + have hh := ih (fun r hr => hs r (List.mem_cons_of_mem p hr)) + (fun r hr => hb r (List.mem_cons_of_mem p hr)) (Step.fresh_tail hf htail) hd'.2 + have hstep := rawRow_loss (hs p (List.mem_cons_self ..)) (hb p (List.mem_cons_self ..)) R (hf p (List.mem_cons_self ..)) j + simp only [predictorRows,List.map_cons,List.sum_cons,run] + linarith + +omit [Fintype κ] [DecidableEq ι] in +lemma insertion_budget {L : List (Step ι κ)} (hd : (L.map Step.j).Nodup) {B : ℝ} (hB : 0≤B) + (hb : ∀ p∈L,vectorMass p.b≤B) (j : κ) : + (L.map (fun p => if p.j=j then vectorMass p.b else 0)).sum ≤ B := by + induction L with + | nil => simpa using hB + | cons p ps ih => + have hd' := List.nodup_cons.mp hd + by_cases hj : p.j=j + · have ht : ∀ r∈ps,r.j≠j := by + intro r hr he + exact hd'.1 (List.mem_map.mpr ⟨r,hr,he.trans hj.symm⟩) + have hz : (ps.map (fun p => if p.j=j then vectorMass p.b else 0)).sum=0 := by + rw [List.sum_eq_zero] + intro x hx + obtain ⟨r,hr,rfl⟩ := List.mem_map.mp hx + simp [ht r hr] + simpa only [List.map_cons,List.sum_cons,ite_eq_left hj,hz,add_zero] using hb p (List.mem_cons_self ..) + · simpa only [List.map_cons,List.sum_cons,ite_eq_right hj,zero_add] using + ih hd'.2 (fun r hr => hb r (List.mem_cons_of_mem p hr)) + +omit [Fintype κ] in +lemma predictor_column_bound {R : Matrix ι κ ℝ} {L : List (Step ι κ)} + (hs : ∀ p∈L,p.C=symmetricContraction p.b) (hb : ∀ p∈L,vectorMass p.b≤1) + (hf : Fresh R L) (hd : (L.map Step.j).Nodup) {B : ℝ} (hB : 0≤B) + (hbB : ∀ p∈L,vectorMass p.b≤B) (j : κ) (hR : ∀ i,R i j=0) : + ((predictorRows R L).map (fun m => m j^2)).sum ≤ B := by + have hh := predictor_column_budget hs hb hf hd j + have ht := insertion_budget hd hB hbB j + have hz : vectorMass (fun i => R i j)=0 := by simp [vectorMass,hR] + rw [hz,zero_add] at hh + linarith [vectorMass_nonneg (fun i => run R L i j)] + +lemma predictor_row_bound {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) {L : List (Step ι κ)} + (hp : ∀ p∈L,p.Good) (hf : Fresh R L) (hd : (L.map Step.j).Nodup) + (k : ℕ) (hk : k m) x‖=|rowMap m x| := by + have he : matrixMap (fun _ : Unit => m) x=EuclideanSpace.single () (rowMap m x) := by + ext u + cases u + simp only [PiLp.single_apply,ite_true,rowMap_apply] + rfl + rw [he,PiLp.norm_single,Real.norm_eq_abs] + +omit [DecidableEq ι] [DecidableEq κ] in +lemma rawRow_eval (R : Matrix ι κ ℝ) (b : ι → ℝ) (x : EuclideanSpace ℝ κ) : + rowMap (rawRow R b) x=eta b*(b ⬝ᵥ (R*ᵥx)) := by + rw [rowMap_apply,Matrix.dotProduct_mulVec] + simp only [dotProduct,rawRow,Matrix.vecMul,← Finset.mul_sum,mul_assoc] + +noncomputable def noiseRow {ν : Type*} (m : ι⊕ν → ℝ) : ι⊕ν → ℝ := + Sum.elim (fun _ => 0) (fun j => m (Sum.inr j)) + +omit [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +lemma noiseRow_mass {ν : Type*} [Fintype ν] (m : ι⊕ν → ℝ) : + vectorMass (noiseRow m)≤vectorMass m := by + simp only [vectorMass,Fintype.sum_sum_type,noiseRow,Sum.elim_inl,Sum.elim_inr,zero_pow (by norm_num : 2≠0),Finset.sum_const_zero,zero_add] + linarith [Finset.sum_nonneg (fun i (_ : i∈(Finset.univ : Finset ι)) => sq_nonneg (m (Sum.inl i)))] + +omit [Fintype κ] [DecidableEq κ] [DecidableEq ι] in +lemma noiseRow_eval {ν : Type*} [Fintype ν] [DecidableEq ν] (m : ι⊕ν → ℝ) + (x : EuclideanSpace ℝ (ι⊕ν)) (hx : ∀ i,x (Sum.inl i)=0) : rowMap (noiseRow m) x=rowMap m x := by + simp [rowMap_apply,dotProduct,Fintype.sum_sum_type,noiseRow,hx] + +omit [DecidableEq ι] [Fintype ι] in +lemma insert_mulVec_eq (b : ι → ℝ) (j : κ) (x : κ → ℝ) : insert b j*ᵥx=(x j) • b := by + ext i + simp [insert,Matrix.mulVec,dotProduct,mul_comm] + +lemma step_cancel {p : Step ι κ} (hs : p.C=symmetricContraction p.b) (R : Matrix ι κ ℝ) + (x : EuclideanSpace ℝ κ) (ε : ℝ) (hx : x p.j=rowMap (rawRow R p.b) x+ε) : + matrixMap (p.apply R) x=matrixMap R x+ε • WithLp.toLp 2 p.b := by + apply WithLp.ofLp_injective + change (p.C*R+insert p.b p.j)*ᵥ x=R*ᵥ x+ε • p.b + rw [Matrix.add_mulVec,← Matrix.mulVec_mulVec,hs,contraction_apply,insert_mulVec_eq,hx,rawRow_eval] + ext i + simp only [Pi.add_apply,Pi.sub_apply,Pi.smul_apply,smul_eq_mul] + ring + +lemma run_prefix_cancel {n : ℕ} (p : Fin n → Step ι κ) (R : Matrix ι κ ℝ) + (x : EuclideanSpace ℝ κ) (ε : Fin n → ℝ) + (hs : ∀ i,(p i).C=symmetricContraction (p i).b) + (hx : ∀ i,x (p i).j=rowMap (rawRow (run R ((List.ofFn p).take i.val)) (p i).b) x+ε i) + (k : ℕ) : + matrixMap (run R ((List.ofFn p).take k)) x = matrixMap R x+ + ((List.ofFn (fun i => ε i • WithLp.toLp 2 (p i).b)).take k).sum := by + induction n generalizing R k with + | zero => simp [List.ofFn_zero,run] + | succ n ih => + cases k with + | zero => simp [run] + | succ k => + have ht : ∀ i : Fin n,x (p i.succ).j= + rowMap (rawRow (run ((p 0).apply R) ((List.ofFn (fun i : Fin n => p i.succ)).take i.val)) (p i.succ).b) x+ε i.succ := by + intro i + simpa only [List.ofFn_succ,Fin.val_succ,List.take_succ_cons,run] using hx i.succ + have hrec := ih (fun i => p i.succ) ((p 0).apply R) (fun i => ε i.succ) (fun i => hs i.succ) ht k + simp only [List.ofFn_succ,List.take_succ_cons,run,List.sum_cons] + rw [hrec,step_cancel (hs 0) R x (ε 0) (by simpa only [Fin.val_zero,List.take_zero,run] using hx 0)] + abel + +end EuclideanSteinitz.Filter + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Prekopa.lean b/lean/OAI/Analysis/Steinitz/Prekopa.lean new file mode 100644 index 0000000000000000000000000000000000000000..890fbe912bca27c660e851d47f03a85b06856093 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Prekopa.lean @@ -0,0 +1,857 @@ +import OAI.Analysis.Steinitz.HeatEnergy + +namespace OAI + +/-! Prékopa inequalities and Gaussian log-concavity. -/ + +section + +open MeasureTheory Set Filter +open scoped Topology + +namespace Prekopa + +lemma continuousAt_invFun_strictMono {F : ℝ → ℝ} (hF : Continuous F) + (hmono : StrictMono F) (x : ℝ) : ContinuousAt (Function.invFun F) (F x) := by + rw [Metric.continuousAt_iff] + intro ε hε + have hl : F (x - ε) < F x := hmono (by linarith) + have hr : F x < F (x + ε) := hmono (by linarith) + refine ⟨min (F x - F (x - ε)) (F (x + ε) - F x), lt_min (by linarith) (by linarith), ?_⟩ + intro y hy + obtain ⟨hy₁, hy₂⟩ := abs_lt.mp (show |y - F x| < _ from hy) + have hyI : y ∈ Icc (F (x - ε)) (F (x + ε)) := by + constructor + · have := min_le_left (F x - F (x - ε)) (F (x + ε) - F x); linarith + · have := min_le_right (F x - F (x - ε)) (F (x + ε) - F x); linarith + obtain ⟨z, _, hz⟩ := intermediate_value_Icc (show x - ε ≤ x + ε by linarith) + hF.continuousOn hyI + have he : F (Function.invFun F y) = y := by rw [← hz]; exact Function.apply_invFun_apply + rw [Function.leftInverse_invFun hmono.injective x] + change |Function.invFun F y - x| < ε + rw [abs_lt] + constructor + · have : F (x - ε) < y := by + have := min_le_left (F x - F (x - ε)) (F (x + ε) - F x); linarith + have : x - ε < Function.invFun F y := hmono.lt_iff_lt.mp (he.symm ▸ this) + linarith + · have : y < F (x + ε) := by + have := min_le_right (F x - F (x - ε)) (F (x + ε) - F x); linarith + have : Function.invFun F y < x + ε := hmono.lt_iff_lt.mp (he.symm ▸ this) + linarith + +lemma invFun_hasDerivAt {F : ℝ → ℝ} (hF : Continuous F) (hmono : StrictMono F) + (x d : ℝ) (hd : d ≠ 0) (hder : HasDerivAt F d x) : + HasDerivAt (Function.invFun F) d⁻¹ (F x) := by + apply HasDerivAt.of_local_left_inverse (continuousAt_invFun_strictMono hF hmono x) + (by simpa [Function.leftInverse_invFun hmono.injective x] using hder) hd + have hl : F (x - 1) < F x := hmono (by linarith) + have hr : F x < F (x + 1) := hmono (by linarith) + filter_upwards [Ioo_mem_nhds hl hr] with y hy + obtain ⟨z, _, hz⟩ := intermediate_value_Icc (show x - 1 ≤ x + 1 by linarith) + hF.continuousOn ⟨hy.1.le, hy.2.le⟩ + exact by rw [← hz]; exact Function.apply_invFun_apply + +noncomputable def primitive (f : ℝ → ℝ) (a : ℝ) (x : ℝ) : ℝ := ∫ t in a..x, f t + +lemma primitive_hasDerivAt {f : ℝ → ℝ} (hf : Continuous f) (a x : ℝ) : + HasDerivAt (primitive f a) (f x) x := by + exact intervalIntegral.integral_hasDerivAt_right (hf.intervalIntegrable _ _) + (hf.stronglyMeasurableAtFilter _ _) hf.continuousAt + +lemma primitive_continuous {f : ℝ → ℝ} (hf : Continuous f) (a : ℝ) : + Continuous (primitive f a) := + continuous_iff_continuousAt.mpr fun x => (primitive_hasDerivAt hf a x).continuousAt + +lemma primitive_strictMono {f : ℝ → ℝ} (hf : Continuous f) (hpos : ∀ x, 0 < f x) + (a : ℝ) : StrictMono (primitive f a) := by + apply strictMono_of_deriv_pos + intro x + rw [(primitive_hasDerivAt hf a x).deriv] + exact hpos x + +lemma normalized_interval {f g h : ℝ → ℝ} {a b α : ℝ} + (hab : a < b) (hα : α ∈ Icc (0 : ℝ) 1) + (hf : Continuous f) (hg : Continuous g) (hh : Continuous h) + (hfpos : ∀ x, 0 < f x) (hgpos : ∀ x, 0 < g x) + (hfi : ∫ x in a..b, f x = 1) (hgi : ∫ x in a..b, g x = 1) + (hfg : ∀ x y, f x ^ (1-α) * g y ^ α ≤ h ((1-α)*x+α*y)) : + 1 ≤ ∫ x in a..b, h x := by + let F := primitive f a + let G := primitive g a + let T (x : ℝ) := Function.invFun G (F x) + have hFc : Continuous F := primitive_continuous hf a + have hGc : Continuous G := primitive_continuous hg a + have hFm : StrictMono F := primitive_strictMono hf hfpos a + have hGm : StrictMono G := primitive_strictMono hg hgpos a + have hFa : F a = 0 := by simp [F, primitive] + have hGa : G a = 0 := by simp [G, primitive] + have hFb : F b = 1 := hfi + have hGb : G b = 1 := hgi + have hGT (x : ℝ) (hx : x ∈ Icc a b) : G (T x) = F x := by + have hFx : F x ∈ Icc (G a) (G b) := by + rw [hGa, hGb, ← hFa, ← hFb] + exact ⟨hFm.monotone hx.1, hFm.monotone hx.2⟩ + obtain ⟨z, _, hz⟩ := intermediate_value_Icc hab.le hGc.continuousOn hFx + dsimp [T] + rw [← hz] + exact Function.apply_invFun_apply + have hTi (x : ℝ) (hx : x ∈ Icc a b) : T x ∈ Icc a b := by + have he := hGT x hx + constructor + · apply hGm.le_iff_le.mp + rw [he, hGa, ← hFa] + exact hFm.monotone hx.1 + · apply hGm.le_iff_le.mp + rw [he, hGb, ← hFb] + exact hFm.monotone hx.2 + have hTd (x : ℝ) (hx : x ∈ Icc a b) : HasDerivAt T (f x / g (T x)) x := by + have hi := invFun_hasDerivAt hGc hGm (T x) (g (T x)) + (ne_of_gt (hgpos _)) (primitive_hasDerivAt hg a (T x)) + rw [hGT x hx] at hi + convert! hi.comp x (primitive_hasDerivAt hf a x) using 1; + simp [T, div_eq_mul_inv, mul_comm] + have hTc : ContinuousOn T (Icc a b) := fun x hx => (hTd x hx).continuousAt.continuousWithinAt + have hTa : T a = a := by apply hGm.injective; rw [hGT a ⟨le_rfl, hab.le⟩, hFa, hGa] + have hTb : T b = b := by apply hGm.injective; rw [hGT b ⟨hab.le, le_rfl⟩, hFb, hGb] + let Z (x : ℝ) := (1-α)*x+α*T x + let Z' (x : ℝ) := (1-α)+α*(f x / g (T x)) + have hZd (x : ℝ) (hx : x ∈ Icc a b) : HasDerivAt Z (Z' x) x := by + convert! ((hasDerivAt_id x).const_mul (1-α)).add ((hTd x hx).const_mul α) using 1; + simp [Z'] + have hZc : ContinuousOn Z' (Icc a b) := by + apply ContinuousOn.add continuousOn_const + exact continuousOn_const.mul (hf.continuousOn.div (hg.comp_continuousOn hTc) + (fun x _ => ne_of_gt (hgpos _))) + have hsubst := intervalIntegral.integral_comp_mul_deriv' (a := a) (b := b) (g := h) (fun x hx => + hZd x (by simpa [uIcc_of_le hab.le] using hx)) + (by simpa [uIcc_of_le hab.le] using hZc) hh.continuousOn + have hZa : Z a = a := by dsimp [Z]; rw [hTa]; ring + have hZb : Z b = b := by dsimp [Z]; rw [hTb]; ring + rw [hZa, hZb] at hsubst + rw [← hsubst, ← hfi] + apply intervalIntegral.integral_mono_on hab.le (hf.intervalIntegrable _ _) + ((hh.comp_continuousOn (fun x hx => (hZd x hx).continuousAt.continuousWithinAt)).mul hZc + |>.intervalIntegrable_of_Icc hab.le) + intro x hx + have hp : 0 < f x / g (T x) := div_pos (hfpos _) (hgpos _) + have hmean := Real.geom_mean_le_arith_mean2_weighted + (show 0 ≤ 1-α by linarith [hα.2]) hα.1 (show (0:ℝ) ≤ 1 by norm_num) hp.le + (show (1-α)+α=1 by ring) + simp only [Real.one_rpow, one_mul, mul_one] at hmean + have hZpos : 0 ≤ Z' x := le_trans (Real.rpow_nonneg hp.le _) hmean + calc + f x = (f x ^ (1-α) * g (T x) ^ α) * ((f x / g (T x)) ^ α) := by + rw [Real.div_rpow (hfpos _).le (hgpos _).le] + have hg0 : g (T x) ^ α ≠ 0 := ne_of_gt (Real.rpow_pos_of_pos (hgpos _) _) + field_simp + rw [← Real.rpow_add (hfpos _)] + simp + _ ≤ (f x ^ (1-α) * g (T x) ^ α) * Z' x := + mul_le_mul_of_nonneg_left hmean (mul_nonneg + (Real.rpow_nonneg (hfpos _).le _) (Real.rpow_nonneg (hgpos _).le _)) + _ ≤ (h ∘ Z) x * Z' x := mul_le_mul_of_nonneg_right (hfg x (T x)) hZpos + +lemma interval {f g h : ℝ → ℝ} {a b α : ℝ} + (hab : a < b) (hα : α ∈ Icc (0 : ℝ) 1) + (hf : Continuous f) (hg : Continuous g) (hh : Continuous h) + (hfpos : ∀ x, 0 < f x) (hgpos : ∀ x, 0 < g x) + (hfg : ∀ x y, f x ^ (1-α) * g y ^ α ≤ h ((1-α)*x+α*y)) : + (∫ x in a..b, f x) ^ (1-α) * (∫ x in a..b, g x) ^ α ≤ ∫ x in a..b, h x := by + let p := ∫ x in a..b, f x + let q := ∫ x in a..b, g x + have hp : 0 < p := intervalIntegral.integral_pos hab hf.continuousOn + (fun x _ => (hfpos x).le) ⟨a, ⟨le_rfl, hab.le⟩, hfpos a⟩ + have hq : 0 < q := intervalIntegral.integral_pos hab hg.continuousOn + (fun x _ => (hgpos x).le) ⟨a, ⟨le_rfl, hab.le⟩, hgpos a⟩ + let c := p ^ (1-α) * q ^ α + have hc : 0 < c := mul_pos (Real.rpow_pos_of_pos hp _) (Real.rpow_pos_of_pos hq _) + have he := normalized_interval hab hα (hf.div_const p) (hg.div_const q) (hh.div_const c) + (fun x => div_pos (hfpos x) hp) (fun x => div_pos (hgpos x) hq) + (by rw [intervalIntegral.integral_div]; exact div_self (ne_of_gt hp)) + (by rw [intervalIntegral.integral_div]; exact div_self (ne_of_gt hq)) + (fun x y => by + rw [Real.div_rpow (hfpos x).le hp.le, Real.div_rpow (hgpos y).le hq.le] + rw [div_mul_div_comm] + exact div_le_div_of_nonneg_right (hfg x y) hc.le) + rw [intervalIntegral.integral_div] at he + have he' := (le_div_iff₀ hc).mp he + simpa only [one_mul] using he' + +lemma real {f g h : ℝ → ℝ} {α : ℝ} + (hα : α ∈ Icc (0 : ℝ) 1) + (hf : Continuous f) (hg : Continuous g) (hh : Continuous h) + (hfpos : ∀ x, 0 < f x) (hgpos : ∀ x, 0 < g x) + (hfi : Integrable f) (hgi : Integrable g) (hhi : Integrable h) + (hfg : ∀ x y, f x ^ (1-α) * g y ^ α ≤ h ((1-α)*x+α*y)) : + (∫ x, f x) ^ (1-α) * (∫ x, g x) ^ α ≤ ∫ x, h x := by + have hfl := intervalIntegral_tendsto_integral hfi tendsto_neg_atTop_atBot tendsto_id + have hgl := intervalIntegral_tendsto_integral hgi tendsto_neg_atTop_atBot tendsto_id + have hhl := intervalIntegral_tendsto_integral hhi tendsto_neg_atTop_atBot tendsto_id + apply le_of_tendsto_of_tendsto + ((hfl.rpow_const (Or.inr (by linarith [hα.2]))).mul + (hgl.rpow_const (Or.inr hα.1))) hhl + filter_upwards [eventually_gt_atTop (0 : ℝ)] with R hR + exact interval (show -R < R by linarith) hα hf hg hh hfpos hgpos hfg + +end Prekopa + +namespace Prekopa +open MeasureTheory Set Filter +open scoped Topology + +noncomputable def gauss {n : ℕ} (c : ℝ) (x : Fin n → ℝ) : ℝ := + Real.exp (-c * ∑ i, (x i)^2) + +lemma gauss_prod {n : ℕ} (c : ℝ) (x : Fin n → ℝ) : + gauss c x = ∏ i, Real.exp (-c * (x i)^2) := by + rw [gauss, ← Real.exp_sum, Finset.mul_sum] + +lemma gauss_cons {n : ℕ} (c t : ℝ) (x : Fin n → ℝ) : + gauss c (Fin.cons t x) = Real.exp (-c*t^2) * gauss c x := by + simp [gauss, Fin.sum_univ_succ, mul_add, Real.exp_add] + +lemma gauss_pos {n : ℕ} (c : ℝ) (x : Fin n → ℝ) : 0 < gauss c x := + Real.exp_pos _ + +lemma gauss_le_one {n : ℕ} {c : ℝ} (hc : 0 ≤ c) (x : Fin n → ℝ) : gauss c x ≤ 1 := by + apply Real.exp_le_one_iff.mpr + exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hc) + (Finset.sum_nonneg fun i _ => sq_nonneg _) + +lemma gauss_integrable {n : ℕ} {c : ℝ} (hc : 0 < c) : Integrable (@gauss n c) := by + simp only [funext (gauss_prod c), volume_pi] + exact Integrable.fin_nat_prod (fun _ => integrable_exp_neg_mul_sq hc) + +structure Nice {n : ℕ} (f : (Fin n → ℝ) → ℝ) : Prop where + continuous : Continuous f + positive : ∀ x, 0 < f x + bound : ∃ C c : ℝ, 0 < C ∧ 0 < c ∧ ∀ x, f x ≤ C * gauss c x + +lemma Nice.integrable {n : ℕ} {f : (Fin n → ℝ) → ℝ} (hf : Nice f) : Integrable f := by + obtain ⟨C, c, _, hc, hb⟩ := hf.bound + apply ((gauss_integrable hc).const_mul C).mono' hf.continuous.aestronglyMeasurable + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_pos (hf.positive x)] + exact hb x + +lemma continuous_cons_left {n : ℕ} (x : Fin n → ℝ) : + Continuous (fun t : ℝ => (Fin.cons t x : Fin (n+1) → ℝ)) := by + apply continuous_pi + intro i + refine Fin.cases ?_ (fun j => ?_) i + · exact continuous_id + · exact continuous_const + +noncomputable def marginal {n : ℕ} (f : (Fin (n+1) → ℝ) → ℝ) (x : Fin n → ℝ) : ℝ := + ∫ t : ℝ, f (Fin.cons t x) + +lemma Nice.section_integrable {n : ℕ} {f : (Fin (n+1) → ℝ) → ℝ} (hf : Nice f) + (x : Fin n → ℝ) : Integrable (fun t : ℝ => f (Fin.cons t x)) := by + obtain ⟨C, c, hC, hc, hb⟩ := hf.bound + apply ((integrable_exp_neg_mul_sq hc).const_mul C).mono' + (hf.continuous.comp (continuous_cons_left x)).aestronglyMeasurable + filter_upwards [] with t + change ‖f (Fin.cons t x)‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_pos (hf.positive _)] + calc + _ ≤ C * gauss c (Fin.cons t x) := hb _ + _ = (C * Real.exp (-c*t^2)) * gauss c x := by rw [gauss_cons]; ring + _ ≤ C * Real.exp (-c*t^2) := mul_le_of_le_one_right (by positivity) (gauss_le_one hc.le _) + +lemma Nice.marginal {n : ℕ} {f : (Fin (n+1) → ℝ) → ℝ} (hf : Nice f) : Nice (marginal f) := by + obtain ⟨C, c, hC, hc, hb⟩ := hf.bound + have hbd (x : Fin n → ℝ) (t : ℝ) : ‖f (Fin.cons t x)‖ ≤ C * Real.exp (-c*t^2) := by + rw [Real.norm_eq_abs, abs_of_pos (hf.positive _)] + calc + _ ≤ C * gauss c (Fin.cons t x) := hb _ + _ = (C * Real.exp (-c*t^2)) * gauss c x := by rw [gauss_cons]; ring + _ ≤ C * Real.exp (-c*t^2) := mul_le_of_le_one_right (by positivity) (gauss_le_one hc.le _) + constructor + · exact continuous_of_dominated + (fun x => (hf.continuous.comp (continuous_cons_left x)).aestronglyMeasurable) + (fun x => Filter.Eventually.of_forall (hbd x)) + ((integrable_exp_neg_mul_sq hc).const_mul C) + (Filter.Eventually.of_forall fun t => hf.continuous.comp (continuous_const.finCons continuous_id)) + · intro x + apply (integral_pos_iff_support_of_nonneg_ae (Filter.Eventually.of_forall fun t => + (hf.positive (Fin.cons t x)).le) (hf.section_integrable x)).mpr + have he : Function.support (fun t : ℝ => f (Fin.cons t x)) = Set.univ := by + ext t + simp [Function.mem_support, ne_of_gt (hf.positive _)] + rw [he] + simp + · refine ⟨C * Real.sqrt (Real.pi/c), c, mul_pos hC (by positivity), hc, ?_⟩ + intro x + calc + Prekopa.marginal f x ≤ ∫ t : ℝ, C * Real.exp (-c*t^2) * gauss c x := by + apply integral_mono (hf.section_integrable x) + (((integrable_exp_neg_mul_sq hc).const_mul C).mul_const _) + intro t + simpa only [gauss_cons, mul_assoc] using hb (Fin.cons t x) + _ = C * Real.sqrt (Real.pi/c) * gauss c x := by + rw [integral_mul_const, integral_const_mul, integral_gaussian] + +lemma integral_marginal {n : ℕ} {f : (Fin (n+1) → ℝ) → ℝ} (hf : Integrable f) : + (∫ x, f x) = ∫ x, marginal f x := by + have hm := (measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) => (volume : Measure ℝ)) 0).symm + have hi := hm.integrable_comp_emb (MeasurableEquiv.measurableEmbedding _) (g := f) + have he := hm.integral_comp' f + simp only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Equiv.coe_fn_mk, Fin.insertNth_zero, Fin.zero_succAbove, volume_pi] at he hi hf ⊢ + rw [← he] + simpa [Function.comp_apply, marginal] using integral_prod_symm _ (hi.mpr hf) + +lemma fin {n : ℕ} {f g h : (Fin n → ℝ) → ℝ} {α : ℝ} + (hα : α ∈ Icc (0 : ℝ) 1) (hf : Nice f) (hg : Nice g) (hh : Nice h) + (hfg : ∀ x y, f x ^ (1-α) * g y ^ α ≤ h ((1-α) • x + α • y)) : + (∫ x, f x) ^ (1-α) * (∫ x, g x) ^ α ≤ ∫ x, h x := by + induction n with + | zero => + simp only [integral_unique, measureReal_def, volume_pi, Measure.pi_univ, + Fin.prod_univ_zero, ENNReal.toReal_one, one_smul] + convert hfg default default using 1 + · congr 2 <;> (congr 1; exact Subsingleton.elim _ _) + · exact congrArg h (Subsingleton.elim _ _) + | succ n ih => + rw [integral_marginal hf.integrable, integral_marginal hg.integrable, + integral_marginal hh.integrable] + apply ih hf.marginal hg.marginal hh.marginal + intro x y + apply real hα + (hf.continuous.comp (continuous_cons_left x)) + (hg.continuous.comp (continuous_cons_left y)) + (hh.continuous.comp (continuous_cons_left ((1-α) • x + α • y))) + (fun t => hf.positive (Fin.cons t x)) (fun t => hg.positive (Fin.cons t y)) + (hf.section_integrable x) (hg.section_integrable y) (hh.section_integrable _) + intro r s + have he : (1-α) • Fin.cons r x + α • Fin.cons s y = + Fin.cons ((1-α)*r+α*s) ((1-α) • x + α • y) := by + ext i + refine Fin.cases ?_ (fun j => ?_) i <;> simp + simpa only [he, Function.comp_apply] using hfg (Fin.cons r x) (Fin.cons s y) + +end Prekopa + +namespace Prekopa +open MeasureTheory Set Filter Metric +open scoped Topology + +lemma infDist_combination {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [ProperSpace E] {A B C : Set E} (hA : IsClosed A) (hB : IsClosed B) + (hnA : A.Nonempty) (hnB : B.Nonempty) {α : ℝ} (hα : α ∈ Icc (0 : ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) (x y : E) : + infDist ((1-α) • x + α • y) C ≤ (1-α)*infDist x A + α*infDist y B := by + obtain ⟨a, ha, hea⟩ := hA.exists_infDist_eq_dist hnA x + obtain ⟨b, hb, heb⟩ := hB.exists_infDist_eq_dist hnB y + rw [hea, heb] + apply (infDist_le_dist_of_mem (hABC a ha b hb)).trans + rw [dist_eq_norm, dist_eq_norm, dist_eq_norm] + have he : (1-α) • x + α • y - ((1-α) • a + α • b) = + (1-α) • (x-a) + α • (y-b) := by module + rw [he] + apply (norm_add_le _ _).trans + rw [norm_smul, norm_smul, Real.norm_eq_abs, Real.norm_eq_abs, + abs_of_nonneg (sub_nonneg.mpr hα.2), abs_of_nonneg hα.1] + +lemma sum_sq_combination {n : ℕ} {α : ℝ} (hα : α ∈ Icc (0 : ℝ) 1) + (x y : Fin n → ℝ) : + (∑ i, (((1-α) • x + α • y) i)^2) ≤ (1-α)*(∑ i, (x i)^2) + α*(∑ i, (y i)^2) := by + rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro i _ + simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul] + have he := mul_nonneg (mul_nonneg hα.1 (sub_nonneg.mpr hα.2)) (sq_nonneg (x i - y i)) + nlinarith + +noncomputable def approx {n : ℕ} (c : ℝ) (k : ℕ) (A : Set (Fin n → ℝ)) + (x : Fin n → ℝ) : ℝ := gauss c x * Real.exp (-(k : ℝ) * infDist x A) + +lemma approx_nice {n : ℕ} {c : ℝ} (hc : 0 < c) (k : ℕ) (A : Set (Fin n → ℝ)) : + Nice (approx c k A) := by + constructor + · exact (Real.continuous_exp.comp (continuous_const.mul (continuous_finsetSum _ + (fun i _ => (continuous_apply i).pow 2)))).mul + (Real.continuous_exp.comp (continuous_const.mul (continuous_infDist_pt A))) + · intro x + exact mul_pos (gauss_pos _ _) (Real.exp_pos _) + · refine ⟨1, c, zero_lt_one, hc, ?_⟩ + intro x + dsimp [approx] + rw [one_mul] + exact mul_le_of_le_one_right (gauss_pos _ _).le + (Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Nat.cast_nonneg k)) infDist_nonneg)) + +lemma approx_interpolate {n : ℕ} {A B C : Set (Fin n → ℝ)} + (hA : IsClosed A) (hB : IsClosed B) (hnA : A.Nonempty) (hnB : B.Nonempty) + {α c : ℝ} (hα : α ∈ Icc (0 : ℝ) 1) (hc : 0 ≤ c) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) (k : ℕ) (x y : Fin n → ℝ) : + approx c k A x ^ (1-α) * approx c k B y ^ α ≤ approx c k C ((1-α) • x + α • y) := by + simp only [approx, gauss, ← Real.exp_add, ← Real.exp_mul] + apply Real.exp_le_exp.mpr + have h1 := mul_le_mul_of_nonneg_left (sum_sq_combination hα x y) hc + have h2 := mul_le_mul_of_nonneg_left (infDist_combination hA hB hnA hnB hα hABC x y) + (show (0 : ℝ) ≤ (k : ℝ) by positivity) + nlinarith + +lemma approx_tendsto {n : ℕ} {A : Set (Fin n → ℝ)} (hA : IsClosed A) + (hnA : A.Nonempty) (c : ℝ) (x : Fin n → ℝ) : + Tendsto (fun k => approx c k A x) atTop (𝓝 (A.indicator (gauss c) x)) := by + by_cases hx : x ∈ A + · simp [approx, infDist_zero_of_mem hx, hx] + · rw [indicator_of_notMem hx] + have hd := (hA.notMem_iff_infDist_pos hnA).mp hx + have he : Tendsto (fun k : ℕ => -(k : ℝ) * infDist x A) atTop atBot := by + have ht : Tendsto (fun k : ℕ => (k : ℝ) * infDist x A) atTop atTop := + (tendsto_natCast_atTop_atTop (R := ℝ)).atTop_mul_const hd + have hn : Tendsto (fun k : ℕ => -((k : ℝ) * infDist x A)) atTop atBot := + tendsto_neg_atTop_atBot.comp ht + convert hn using 1; simp only [neg_mul] + simpa only [mul_zero, approx, Function.comp_apply] using tendsto_const_nhds.mul (Real.tendsto_exp_atBot.comp he) + +lemma integral_approx_tendsto {n : ℕ} {A : Set (Fin n → ℝ)} (hA : IsClosed A) + (hnA : A.Nonempty) {c : ℝ} (hc : 0 < c) : + Tendsto (fun k => ∫ x, approx c k A x) atTop (𝓝 (∫ x in A, gauss c x)) := by + rw [← integral_indicator hA.measurableSet] + apply tendsto_integral_of_dominated_convergence (gauss c) + (fun k => (approx_nice hc k A).continuous.aestronglyMeasurable) (gauss_integrable hc) + · intro k + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_pos ((approx_nice hc k A).positive x)] + exact mul_le_of_le_one_right (gauss_pos _ _).le + (Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Nat.cast_nonneg k)) infDist_nonneg)) + · exact Filter.Eventually.of_forall (approx_tendsto hA hnA c) + +lemma gauss_closed_logconcave {n : ℕ} {A B C : Set (Fin n → ℝ)} + (hA : IsClosed A) (hB : IsClosed B) (hC : IsClosed C) + (hnA : A.Nonempty) (hnB : B.Nonempty) {α c : ℝ} + (hα : α ∈ Icc (0 : ℝ) 1) (hc : 0 < c) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + (∫ x in A, gauss c x) ^ (1-α) * (∫ x in B, gauss c x) ^ α ≤ ∫ x in C, gauss c x := by + have hnC : C.Nonempty := by + obtain ⟨a, ha⟩ := hnA + obtain ⟨b, hb⟩ := hnB + exact ⟨_, hABC a ha b hb⟩ + apply le_of_tendsto_of_tendsto + (((integral_approx_tendsto hA hnA hc).rpow_const (Or.inr (sub_nonneg.mpr hα.2))).mul + ((integral_approx_tendsto hB hnB hc).rpow_const (Or.inr hα.1))) + (integral_approx_tendsto hC hnC hc) + exact Filter.Eventually.of_forall fun k => fin hα (approx_nice hc k A) + (approx_nice hc k B) (approx_nice hc k C) (approx_interpolate hA hB hnA hnB hα hc.le hABC k) + +end Prekopa + +namespace Prekopa +open MeasureTheory ProbabilityTheory Set Filter +open scoped Topology + +noncomputable def normalConst (n : ℕ) : ℝ := (Real.sqrt (2 * Real.pi))⁻¹ ^ n + +lemma normalConst_pos (n : ℕ) : 0 < normalConst n := by + unfold normalConst + positivity + +lemma prod_pdf {n : ℕ} (x : Fin n → ℝ) : + ∏ i, gaussianPDFReal 0 1 (x i) = normalConst n * gauss (1/2) x := by + simp only [gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero, Finset.prod_mul_distrib, + Finset.prod_const, Finset.card_univ, Fintype.card_fin] + rw [← Real.exp_sum] + congr 1 + unfold gauss + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + +lemma piGaussian_density (n : ℕ) : + (Measure.pi fun _ : Fin n => gaussianReal 0 1) = + volume.withDensity (fun x => ENNReal.ofReal (normalConst n * gauss (1/2) x)) := by + apply Measure.pi_eq + intro s hs + rw [withDensity_apply _ (MeasurableSet.univ_pi hs), + ← ofReal_integral_eq_lintegral_ofReal + (((gauss_integrable (n := n) (by norm_num : (0:ℝ)<1/2)).const_mul _).restrict) + (ae_of_all _ fun x => mul_nonneg (normalConst_pos n).le (gauss_pos _ x).le)] + simp_rw [← prod_pdf] + rw [volume_pi, Measure.restrict_pi_pi, integral_fintype_prod_eq_prod] + rw [ENNReal.ofReal_prod_of_nonneg (fun i _ => integral_nonneg (gaussianPDFReal_nonneg 0 1))] + apply Finset.prod_congr rfl + intro i _ + exact (gaussianReal_apply_eq_integral 0 (by norm_num : (1:NNReal)≠0) (s i)).symm + +lemma piGaussian_real (n : ℕ) {A : Set (Fin n → ℝ)} (hA : MeasurableSet A) : + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real A = + normalConst n * ∫ x in A, gauss (1/2) x := by + rw [Measure.real, piGaussian_density, withDensity_apply _ hA, + ← ofReal_integral_eq_lintegral_ofReal + (((gauss_integrable (n := n) (by norm_num : (0:ℝ)<1/2)).const_mul _).restrict) + (ae_of_all _ fun x => mul_nonneg (normalConst_pos n).le (gauss_pos _ x).le), + ENNReal.toReal_ofReal (integral_nonneg fun x => + mul_nonneg (normalConst_pos n).le (gauss_pos _ x).le), integral_const_mul] + +lemma piGaussian_closed_logconcave {n : ℕ} {A B C : Set (Fin n → ℝ)} + (hA : IsClosed A) (hB : IsClosed B) (hC : IsClosed C) + (hnA : A.Nonempty) (hnB : B.Nonempty) {α : ℝ} (hα : α ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real A ^ (1-α) * + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real B ^ α ≤ + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real C := by + rw [piGaussian_real n hA.measurableSet, piGaussian_real n hB.measurableSet, + piGaussian_real n hC.measurableSet, + Real.mul_rpow (normalConst_pos n).le (integral_nonneg fun x => (gauss_pos _ x).le), + Real.mul_rpow (normalConst_pos n).le (integral_nonneg fun x => (gauss_pos _ x).le)] + have he : normalConst n ^ (1-α) * normalConst n ^ α = normalConst n := by + rw [← Real.rpow_add (normalConst_pos n), sub_add_cancel, Real.rpow_one] + calc + _ = (normalConst n ^ (1-α) * normalConst n ^ α) * + ((∫ x in A, gauss (1/2) x) ^ (1-α) * (∫ x in B, gauss (1/2) x) ^ α) := by ring + _ ≤ normalConst n * ∫ x in C, gauss (1/2) x := by + rw [he] + exact mul_le_mul_of_nonneg_left + (gauss_closed_logconcave hA hB hC hnA hnB hα (by norm_num) hABC) (normalConst_pos n).le + +end Prekopa + +namespace Prekopa +open MeasureTheory ProbabilityTheory Set + +lemma linear_image_closed_logconcave {n : ℕ} {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F] + (L : (Fin n → ℝ) →L[ℝ] F) {A B C : Set F} + (hA : IsClosed A) (hB : IsClosed B) (hC : IsClosed C) + (h0A : 0 ∈ A) (h0B : 0 ∈ B) {α : ℝ} (hα : α ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + ((Measure.pi fun _ : Fin n => gaussianReal 0 1).map L).real A ^ (1-α) * + ((Measure.pi fun _ : Fin n => gaussianReal 0 1).map L).real B ^ α ≤ + ((Measure.pi fun _ : Fin n => gaussianReal 0 1).map L).real C := by + simp only [Measure.real, Measure.map_apply L.continuous.measurable hA.measurableSet, + Measure.map_apply L.continuous.measurable hB.measurableSet, + Measure.map_apply L.continuous.measurable hC.measurableSet] + apply piGaussian_closed_logconcave + (hA.preimage L.continuous) (hB.preimage L.continuous) (hC.preimage L.continuous) + ⟨0, by simpa using h0A⟩ ⟨0, by simpa using h0B⟩ hα + intro a ha b hb + simpa using hABC (L a) ha (L b) hb + +lemma stdGaussian_linear_image_closed_logconcave {E F : Type*} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F] + (L : E →L[ℝ] F) {A B C : Set F} + (hA : IsClosed A) (hB : IsClosed B) (hC : IsClosed C) + (h0A : 0 ∈ A) (h0B : 0 ∈ B) {α : ℝ} (hα : α ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + ((stdGaussian E).map L).real A ^ (1-α) * + ((stdGaussian E).map L).real B ^ α ≤ ((stdGaussian E).map L).real C := by + let b := stdOrthonormalBasis ℝ E + let S : (Fin (Module.finrank ℝ E) → ℝ) →L[ℝ] E := + ∑ i, (ContinuousLinearMap.proj i).smulRight (b i) + have hS (x : Fin (Module.finrank ℝ E) → ℝ) : S x = ∑ i, x i • b i := by + simp [S] + have hμ : (stdGaussian E).map L = + (Measure.pi fun _ : Fin (Module.finrank ℝ E) => gaussianReal 0 1).map (L.comp S) := by + rw [stdGaussian_eq_map_pi_orthonormalBasis b] + have he : (fun x => ∑ i, x i • b i) = S := funext fun x => (hS x).symm + rw [he, Measure.map_map L.continuous.measurable S.continuous.measurable] + rfl + rw [hμ] + exact linear_image_closed_logconcave (L.comp S) hA hB hC h0A h0B hα hABC + +end Prekopa + +open MeasureTheory Set ProbabilityTheory +namespace Prekopa + +lemma convex_closure_ae {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] + (μ : Measure E) [μ.IsAddHaarMeasure] + {A : Set E} (hA : Convex ℝ A) : closure A =ᵐ[μ] A := by + have hn : ∀ᵐ x ∂μ, x ∉ frontier A := by + rw [ae_iff] + simpa using hA.addHaar_frontier μ + filter_upwards [hn] with x hx + apply propext + constructor + · intro hc + by_contra ha + exact hx ⟨hc, fun hi => ha (interior_subset hi)⟩ + · exact fun hx => subset_closure hx + +lemma combination_closure {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + {A B C : Set E} {α : ℝ} + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + ∀ a ∈ closure A, ∀ b ∈ closure B, (1-α) • a + α • b ∈ closure C := by + have hm : MapsTo (fun p : E × E => (1-α) • p.1 + α • p.2) (A ×ˢ B) C := + fun p hp => hABC p.1 hp.1 p.2 hp.2 + have hc := hm.closure_of_continuousOn (by fun_prop) + intro a ha b hb + exact hc (x := (a,b)) (by simpa only [closure_prod_eq, mem_prod] using And.intro ha hb) + +lemma piGaussian_convex_logconcave {n : ℕ} {A B C : Set (Fin n → ℝ)} + (hA : Convex ℝ A) (hB : Convex ℝ B) (hC : Convex ℝ C) + (hnA : A.Nonempty) (hnB : B.Nonempty) {α : ℝ} (hα : α ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real A ^ (1-α) * + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real B ^ α ≤ + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real C := by + have hac : (Measure.pi fun _ : Fin n => gaussianReal 0 1) ≪ volume := by + rw [piGaussian_density] + exact withDensity_absolutelyContinuous _ _ + have he (D : Set (Fin n → ℝ)) (hD : Convex ℝ D) : + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real (closure D) = + (Measure.pi fun _ : Fin n => gaussianReal 0 1).real D := by + exact congrArg ENNReal.toReal (measure_congr (hac.ae_eq (convex_closure_ae volume hD))) + have h := piGaussian_closed_logconcave isClosed_closure isClosed_closure isClosed_closure + hnA.closure hnB.closure hα (combination_closure hABC) + simpa only [he A hA, he B hB, he C hC] using h + +lemma linear_image_convex_logconcave {n : ℕ} {F : Type*} + [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F] + (L : (Fin n → ℝ) →L[ℝ] F) {A B C : Set F} + (hA : MeasurableSet A) (hB : MeasurableSet B) (hC : MeasurableSet C) + (hcA : Convex ℝ A) (hcB : Convex ℝ B) (hcC : Convex ℝ C) + (h0A : 0 ∈ A) (h0B : 0 ∈ B) {α : ℝ} (hα : α ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + ((Measure.pi fun _ : Fin n => gaussianReal 0 1).map L).real A ^ (1-α) * + ((Measure.pi fun _ : Fin n => gaussianReal 0 1).map L).real B ^ α ≤ + ((Measure.pi fun _ : Fin n => gaussianReal 0 1).map L).real C := by + simp only [Measure.real, Measure.map_apply L.continuous.measurable hA, + Measure.map_apply L.continuous.measurable hB, Measure.map_apply L.continuous.measurable hC] + apply piGaussian_convex_logconcave + (hcA.linear_preimage L.toLinearMap) (hcB.linear_preimage L.toLinearMap) + (hcC.linear_preimage L.toLinearMap) + ⟨0, by simpa using h0A⟩ ⟨0, by simpa using h0B⟩ hα + intro a ha b hb + simpa using hABC (L a) ha (L b) hb + +end Prekopa +open MeasureTheory Set ProbabilityTheory +namespace Prekopa +lemma stdGaussian_linear_image_convex_logconcave {E F : Type*} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F] + (L : E →L[ℝ] F) {A B C : Set F} + (hA : MeasurableSet A) (hB : MeasurableSet B) (hC : MeasurableSet C) + (hcA : Convex ℝ A) (hcB : Convex ℝ B) (hcC : Convex ℝ C) + (h0A : 0 ∈ A) (h0B : 0 ∈ B) {α : ℝ} (hα : α ∈ Icc (0:ℝ) 1) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + ((stdGaussian E).map L).real A ^ (1-α) * + ((stdGaussian E).map L).real B ^ α ≤ ((stdGaussian E).map L).real C := by + let b := stdOrthonormalBasis ℝ E + let S : (Fin (Module.finrank ℝ E) → ℝ) →L[ℝ] E := + ∑ i, (ContinuousLinearMap.proj i).smulRight (b i) + have hS (x : Fin (Module.finrank ℝ E) → ℝ) : S x = ∑ i, x i • b i := by + simp [S] + have hμ : (stdGaussian E).map L = + (Measure.pi fun _ : Fin (Module.finrank ℝ E) => gaussianReal 0 1).map (L.comp S) := by + rw [stdGaussian_eq_map_pi_orthonormalBasis b] + have he : (fun x => ∑ i, x i • b i) = S := funext fun x => (hS x).symm + rw [he, Measure.map_map L.continuous.measurable S.continuous.measurable] + rfl + rw [hμ] + exact linear_image_convex_logconcave (L.comp S) hA hB hC hcA hcB hcC h0A h0B hα hABC + +end Prekopa + +open MeasureTheory Set Filter Metric +open scoped Topology ENNReal +namespace Prekopa +variable {n : ℕ} +lemma weighted_approx_nice {w : (Fin n → ℝ) → ℝ} + (hw : Continuous w) (hp : ∀ x, 0 < w x) {M : ℝ} (hM : 0 < M) + (hb : ∀ x, w x ≤ M) {c : ℝ} (hc : 0 < c) (k : ℕ) (A : Set (Fin n → ℝ)) : + Nice (fun x => w x * approx c k A x) := by + constructor + · exact hw.mul (approx_nice hc k A).continuous + · intro x; exact mul_pos (hp x) ((approx_nice hc k A).positive x) + · refine ⟨M,c,hM,hc,?_⟩ + intro x + have ha : approx c k A x ≤ gauss c x := by + unfold approx + exact mul_le_of_le_one_right (gauss_pos _ _).le + (Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Nat.cast_nonneg k)) infDist_nonneg)) + exact mul_le_mul (hb x) ha ((approx_nice hc k A).positive x).le hM.le + +lemma integral_weighted_approx_tendsto {w : (Fin n → ℝ) → ℝ} + (hw : Continuous w) (hp : ∀ x, 0 < w x) {M : ℝ} (hM : 0 < M) + (hb : ∀ x, w x ≤ M) {A : Set (Fin n → ℝ)} (hA : IsClosed A) + (hnA : A.Nonempty) {c : ℝ} (hc : 0 < c) : + Tendsto (fun k => ∫ x, w x * approx c k A x) atTop + (𝓝 (∫ x in A, w x * gauss c x)) := by + rw [← integral_indicator hA.measurableSet] + apply tendsto_integral_of_dominated_convergence (fun x => M * gauss c x) + (fun k => (weighted_approx_nice hw hp hM hb hc k A).continuous.aestronglyMeasurable) + ((gauss_integrable hc).const_mul M) + · intro k + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_pos ((weighted_approx_nice hw hp hM hb hc k A).positive x)] + apply mul_le_mul (hb x) _ ((approx_nice hc k A).positive x).le hM.le + unfold approx + exact mul_le_of_le_one_right (gauss_pos _ _).le + (Real.exp_le_one_iff.mpr + (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Nat.cast_nonneg k)) infDist_nonneg)) + · filter_upwards [] with x + convert (tendsto_const_nhds.mul (approx_tendsto hA hnA c x)) using 1 + by_cases hx : x ∈ A <;> simp [hx] + +lemma weighted_gauss_closed {w : (Fin n → ℝ) → ℝ} + (hw : Continuous w) (hp : ∀ x, 0 < w x) {M : ℝ} (hM : 0 < M) + (hb : ∀ x, w x ≤ M) {A B C : Set (Fin n → ℝ)} + (hA : IsClosed A) (hB : IsClosed B) (hC : IsClosed C) + (hnA : A.Nonempty) (hnB : B.Nonempty) {α c : ℝ} + (hα : α ∈ Icc (0 : ℝ) 1) (hc : 0 < c) + (hl : ∀ x y, w x ^ (1-α) * w y ^ α ≤ w ((1-α) • x + α • y)) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + (∫ x in A, w x * gauss c x) ^ (1-α) * + (∫ x in B, w x * gauss c x) ^ α ≤ ∫ x in C, w x * gauss c x := by + have hnC : C.Nonempty := by + obtain ⟨a,ha⟩ := hnA + obtain ⟨b,hb'⟩ := hnB + exact ⟨_,hABC a ha b hb'⟩ + apply le_of_tendsto_of_tendsto + (((integral_weighted_approx_tendsto hw hp hM hb hA hnA hc).rpow_const + (Or.inr (sub_nonneg.mpr hα.2))).mul + ((integral_weighted_approx_tendsto hw hp hM hb hB hnB hc).rpow_const (Or.inr hα.1))) + (integral_weighted_approx_tendsto hw hp hM hb hC hnC hc) + apply Filter.Eventually.of_forall + intro k + apply fin hα (weighted_approx_nice hw hp hM hb hc k A) + (weighted_approx_nice hw hp hM hb hc k B) (weighted_approx_nice hw hp hM hb hc k C) + intro x y + rw [Real.mul_rpow (hp x).le ((approx_nice hc k A).positive x).le, + Real.mul_rpow (hp y).le ((approx_nice hc k B).positive y).le] + calc + _ = (w x ^ (1-α) * w y ^ α) * (approx c k A x ^ (1-α) * approx c k B y ^ α) := by ring + _ ≤ w ((1-α) • x + α • y) * approx c k C ((1-α) • x + α • y) := + mul_le_mul (hl x y) (approx_interpolate hA hB hnA hnB hα hc.le hABC k x y) + (mul_nonneg (Real.rpow_nonneg ((approx_nice hc k A).positive x).le _) + (Real.rpow_nonneg ((approx_nice hc k B).positive y).le _)) (hp _).le + +lemma integral_weighted_gauss_tendsto {w : (Fin n → ℝ) → ℝ} + (hw : Continuous w) (hp : ∀ x, 0 < w x) {M : ℝ} (_hM : 0 < M) + (hb : ∀ x, w x ≤ M) (A : Set (Fin n → ℝ)) [IsFiniteMeasure (volume.restrict A)] : + Tendsto (fun k : ℕ => ∫ x in A, w x * gauss (1/((k:ℝ)+1)) x) atTop + (𝓝 (∫ x in A, w x)) := by + apply tendsto_integral_of_dominated_convergence (fun _ => M) + (fun k => hw.aestronglyMeasurable.mul + ((Real.continuous_exp.comp (continuous_const.mul + (continuous_finsetSum _ (fun i _ => (continuous_apply i).pow 2)))).aestronglyMeasurable)) + (integrable_const M) + · intro k + filter_upwards [] with x + change ‖w x * gauss (1/((k:ℝ)+1)) x‖ ≤ M + rw [Real.norm_eq_abs, abs_of_pos (mul_pos (hp x) (gauss_pos _ _))] + exact (mul_le_of_le_one_right (hp x).le (gauss_le_one (by positivity) x)).trans (hb x) + · filter_upwards [] with x + have ht := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).neg.mul_const (∑ i, (x i)^2) + have he := Real.continuous_exp.continuousAt.tendsto.comp ht + simpa [gauss] using tendsto_const_nhds.mul he + +lemma bounded_weight_closed {w : (Fin n → ℝ) → ℝ} + (hw : Continuous w) (hp : ∀ x, 0 < w x) {M : ℝ} (hM : 0 < M) + (hb : ∀ x, w x ≤ M) {A B C : Set (Fin n → ℝ)} + (hA : IsClosed A) (hB : IsClosed B) (hC : IsClosed C) + [IsFiniteMeasure (volume.restrict A)] [IsFiniteMeasure (volume.restrict B)] + [IsFiniteMeasure (volume.restrict C)] + (hnA : A.Nonempty) (hnB : B.Nonempty) {α : ℝ} + (hα : α ∈ Icc (0 : ℝ) 1) + (hl : ∀ x y, w x ^ (1-α) * w y ^ α ≤ w ((1-α) • x + α • y)) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + (∫ x in A, w x) ^ (1-α) * (∫ x in B, w x) ^ α ≤ ∫ x in C, w x := by + apply le_of_tendsto_of_tendsto + (((integral_weighted_gauss_tendsto hw hp hM hb A).rpow_const + (Or.inr (sub_nonneg.mpr hα.2))).mul + ((integral_weighted_gauss_tendsto hw hp hM hb B).rpow_const (Or.inr hα.1))) + (integral_weighted_gauss_tendsto hw hp hM hb C) + exact Filter.Eventually.of_forall fun k => + weighted_gauss_closed hw hp hM hb hA hB hC hnA hnB hα (by positivity) hl hABC + +end Prekopa + +namespace Prekopa +open MeasureTheory Set Filter +open scoped ENNReal NNReal Topology + +lemma bounded_weight_compact_haar {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + (μ : Measure E) [μ.IsAddHaarMeasure] {w : E → ℝ} + (hw : Continuous w) (hp : ∀ x, 0 < w x) {M : ℝ} (hM : 0 < M) + (hb : ∀ x, w x ≤ M) {A B C : Set E} + (hA : IsCompact A) (hB : IsCompact B) (hC : IsCompact C) + (hnA : A.Nonempty) (hnB : B.Nonempty) {α : ℝ} + (hα : α ∈ Icc (0 : ℝ) 1) + (hl : ∀ x y, w x ^ (1-α) * w y ^ α ≤ w ((1-α) • x + α • y)) + (hABC : ∀ a ∈ A, ∀ b ∈ B, (1-α) • a + α • b ∈ C) : + (∫ x in A, w x ∂μ) ^ (1-α) * (∫ x in B, w x ∂μ) ^ α ≤ ∫ x in C, w x ∂μ := by + let e := (Module.finBasis ℝ E).equivFunL.symm + let ν : Measure E := volume.map e + let : ν.IsAddHaarMeasure := e.isAddHaarMeasure_map volume + let c : ℝ≥0 := Measure.addHaarScalarFactor ν μ + have hc : 0 < c := Measure.addHaarScalarFactor_pos_of_isAddHaarMeasure ν μ + have heμ : volume.map e = (c : ℝ≥0∞) • μ := Measure.isAddLeftInvariant_eq_smul ν μ + have hpre (D : Set E) (hD : IsCompact D) : IsCompact (e ⁻¹' D) := by + exact e.toHomeomorph.isCompact_preimage.mpr hD + have : IsFiniteMeasure (volume.restrict (e ⁻¹' A)) := ⟨by simpa using (hpre A hA).measure_lt_top⟩ + have : IsFiniteMeasure (volume.restrict (e ⁻¹' B)) := ⟨by simpa using (hpre B hB).measure_lt_top⟩ + have : IsFiniteMeasure (volume.restrict (e ⁻¹' C)) := ⟨by simpa using (hpre C hC).measure_lt_top⟩ + have hi (D : Set E) (hD : IsCompact D) : + (∫ x in e ⁻¹' D, w (e x)) = (c:ℝ) * ∫ x in D, w x ∂μ := by + rw [← setIntegral_map hD.isClosed.measurableSet hw.aestronglyMeasurable + e.continuous.measurable.aemeasurable, heμ, Measure.restrict_smul, integral_smul_measure] + simp + + have hl' : ∀ x y, w (e x) ^ (1-α) * w (e y) ^ α ≤ w (e ((1-α) • x + α • y)) := by + intro x y + simpa only [map_add,map_smul] using hl (e x) (e y) + have hcomb : ∀ a ∈ e ⁻¹' A, ∀ b ∈ e ⁻¹' B, (1-α) • a + α • b ∈ e ⁻¹' C := by + intro a ha b hb' + change e ((1-α) • a + α • b) ∈ C + simpa only [map_add,map_smul] using hABC (e a) ha (e b) hb' + have hnA' : (e ⁻¹' A).Nonempty := hnA.preimage e.surjective + have hnB' : (e ⁻¹' B).Nonempty := hnB.preimage e.surjective + have hh := bounded_weight_closed (hw.comp e.continuous) (fun x => hp (e x)) hM + (fun x => hb (e x)) (hpre A hA).isClosed (hpre B hB).isClosed (hpre C hC).isClosed + hnA' hnB' hα hl' hcomb + simp only [Function.comp_apply] at hh + rw [hi A hA, hi B hB, hi C hC, + Real.mul_rpow (by positivity) (integral_nonneg (fun x => (hp x).le)), + Real.mul_rpow (by positivity) (integral_nonneg (fun x => (hp x).le))] at hh + have hcp : (0:ℝ) y+(c-s) • e) ⁻¹' K) ∩ ((fun y : E => y+(c+s) • e) ⁻¹' K) := by + ext y + simp only [sectionDomain, mem_ofPred_eq, mem_iUnion, mem_inter_iff, mem_preimage] + aesop + rw [he] + apply isOpen_iUnion + intro c + apply isOpen_iUnion + intro _ + exact (hK.preimage (by fun_prop)).inter (hK.preimage (by fun_prop)) + +lemma section_mix {K : Set E} (hK : Convex ℝ K) (e : E) (ell : ℝ) + {y z : E} {s r a b : ℝ} (hy : y ∈ sectionDomain K e ell s) + (hz : z ∈ sectionDomain K e ell r) (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a+b=1) : + a • y+b • z ∈ sectionDomain K e ell (a*s+b*r) := by + obtain ⟨c,hc,hcl,hcr⟩ := hy + obtain ⟨d,hd,hdl,hdr⟩ := hz + refine ⟨a*c+b*d, ?_, ?_, ?_⟩ + · have hleft : |a*c+b*d| ≤ a*|c|+b*|d| := by + simpa only [abs_mul, abs_of_nonneg ha, abs_of_nonneg hb] using abs_add_le (a*c) (b*d) + have hstrict : a*(|c|+s)+b*(|d|+r) < ell := by + rcases eq_or_lt_of_le ha with he | hp + · have ha0 : a=0 := he.symm + have hb1 : b=1 := by linarith + simpa only [ha0,hb1,zero_mul,one_mul,zero_add] using hd + · have h₁ := mul_lt_mul_of_pos_left hc hp + have h₂ := mul_le_mul_of_nonneg_left hd.le hb + have he : a*ell+b*ell=ell := by rw [← add_mul, hab, one_mul] + linarith + nlinarith + · convert hK hcl hdl ha hb hab using 1; module + · convert hK hcr hdr ha hb hab using 1; module + +lemma section_convex {K : Set E} (hK : Convex ℝ K) (e : E) (ell s : ℝ) : + Convex ℝ (sectionDomain K e ell s) := by + intro y hy z hz a b ha hb hab + have h := section_mix hK e ell hy hz ha hb hab + have hs : a*s+b*s=s := by rw [← add_mul, hab, one_mul] + rwa [hs] at h + +lemma line_segment_mem {K : Set E} (hK : Convex ℝ K) {y e : E} {c z : ℝ} + (hleft : y+(c-1) • e ∈ K) (hright : y+(c+1) • e ∈ K) + (hz : c-1 ≤ z ∧ z ≤ c+1) : y+z • e ∈ K := by + have ha : 0 ≤ (c+1-z)/2 := by linarith [hz.2] + have hb : 0 ≤ (z-c+1)/2 := by linarith [hz.1] + have hab : (c+1-z)/2+(z-c+1)/2=1 := by ring + convert hK hleft hright ha hb hab using 1; module + +lemma section_symmetric {K : Set E} (hK : ∀ x ∈ K, -x ∈ K) (e : E) (ell s : ℝ) : + ∀ y ∈ sectionDomain K e ell s, -y ∈ sectionDomain K e ell s := by + intro y hy + obtain ⟨c,hc,hcl,hcr⟩ := hy + refine ⟨-c,by simpa only [abs_neg] using hc,?_,?_⟩ + · convert hK _ hcr using 1; module + · convert hK _ hcl using 1; module + +lemma shifted_step {K : Set E} (hK : Convex ℝ K) (e : E) + {y : E} (hy : y ∈ sectionDomain K e (5/2) 1) {q : ℝ} (hq : |q|≤1/4) : + ∃ ε : ℝ, (ε = -1 ∨ ε = 1) ∧ y+(q+ε) • e ∈ K := by + obtain ⟨c,hc,hcl,hcr⟩ := hy + have hca : |c|<3/2 := by linarith + have hcb : -(3/2) linarith [hcb.1,hcb.2,hqb.1,hqb.2] + · refine ⟨-1,Or.inl rfl,line_segment_mem hK hcl hcr ?_⟩ + constructor <;> linarith [hcb.1,hcb.2,hqb.1,hqb.2] + +lemma zero_mem_of_symmetric_convex {K : Set E} (hK : Convex ℝ K) + (hsym : ∀ x ∈ K, -x ∈ K) (hne : K.Nonempty) : (0:E) ∈ K := by + obtain ⟨x,hx⟩ := hne + have h := hK hx (hsym x hx) (by norm_num : (0:ℝ)≤1/2) + (by norm_num : (0:ℝ)≤1/2) (by norm_num : (1/2:ℝ)+1/2=1) + simpa only [smul_neg, add_neg_cancel] using h + +end ShiftedSections + +end + +section + +open MeasureTheory Set Filter +open scoped ENNReal +namespace VerticalRearrangement + +section Layer +variable {X U V : Type*} [MeasurableSpace X] [MeasurableSpace U] [MeasurableSpace V] + {μ : Measure X} {ν : Measure U} {ρ : Measure V} [SFinite μ] [SFinite ν] [SFinite ρ] + +lemma layer_pair (a : X → U → ℝ≥0∞) (b : X → V → ℝ≥0∞) + (ha : Measurable (Function.uncurry a)) (hb : Measurable (Function.uncurry b)) : + (∫⁻ x, (∫⁻ u, a x u ∂ν) * (∫⁻ v, b x v ∂ρ) ∂μ) = + ∫⁻ u, ∫⁻ v, ∫⁻ x, a x u * b x v ∂μ ∂ρ ∂ν := by + have hai (x : X) : Measurable (a x) := ha.comp measurable_prodMk_left + have hbi (x : X) : Measurable (b x) := hb.comp measurable_prodMk_left + simp_rw [← lintegral_mul_const _ (hai _), ← lintegral_const_mul _ (hbi _)] + rw [lintegral_lintegral_swap] + · apply lintegral_congr + intro u + apply lintegral_lintegral_swap + exact ((ha.comp (measurable_fst.prodMk measurable_const)).mul + (hb.comp (measurable_fst.prodMk measurable_snd))).aemeasurable + · apply Measurable.aemeasurable + apply Measurable.lintegral_prod_right + exact (ha.comp (measurable_fst.fst.prodMk measurable_fst.snd)).mul + (hb.comp (measurable_fst.fst.prodMk measurable_snd)) + +noncomputable def layer (S : U → Set X) (ν : Measure U) (x : X) : ℝ≥0∞ := + ∫⁻ u, (S u).indicator (fun _ => (1 : ℝ≥0∞)) x ∂ν + +lemma layer_measurable (S : U → Set X) (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) : + Measurable (layer S ν) := by + apply Measurable.lintegral_prod_right + exact measurable_const.indicator hS + +lemma layer_pair_sets (S : U → Set X) (T : V → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hT : MeasurableSet {p : X × V | p.1 ∈ T p.2}) : + (∫⁻ x, layer S ν x * layer T ρ x ∂μ) = + ∫⁻ u, ∫⁻ v, μ (S u ∩ T v) ∂ρ ∂ν := by + unfold layer + rw [layer_pair (fun x u => (S u).indicator (fun _ => (1:ℝ≥0∞)) x) + (fun x v => (T v).indicator (fun _ => (1:ℝ≥0∞)) x) + (measurable_const.indicator hS) (measurable_const.indicator hT)] + apply lintegral_congr + intro u + apply lintegral_congr + intro v + have hs : MeasurableSet (S u) := hS.preimage measurable_prodMk_right + have ht : MeasurableSet (T v) := hT.preimage measurable_prodMk_right + have he (x : X) : (S u).indicator (fun _ => (1:ℝ≥0∞)) x * + (T v).indicator (fun _ => (1:ℝ≥0∞)) x = (S u ∩ T v).indicator (fun _ => (1:ℝ≥0∞)) x := by + by_cases hx : x ∈ S u <;> by_cases hy : x ∈ T v <;> simp [hx,hy] + simp_rw [he] + rw [lintegral_indicator (hs.inter ht), lintegral_one, Measure.restrict_apply_univ] + +end Layer + +lemma measure_inter_eq_min_of_nested {X : Type*} [MeasurableSpace X] (μ : Measure X) + (S T : Set X) (h : S ⊆ T ∨ T ⊆ S) : μ (S ∩ T) = min (μ S) (μ T) := by + rcases h with h | h + · rw [inter_eq_left.mpr h, min_eq_left (measure_mono h)] + · rw [inter_eq_right.mpr h, min_eq_right (measure_mono h)] + +noncomputable def centered (a : ℝ≥0∞) : Set ℝ := + {s | |s| < a.toReal / 2} + +lemma centered_measurable (a : ℝ≥0∞) : MeasurableSet (centered a) := + measurableSet_lt measurable_id.abs measurable_const + +lemma measure_centered {a : ℝ≥0∞} (ha : a ≠ ⊤) : volume (centered a) = a := by + have he : centered a = Ioo (-(a.toReal/2)) (a.toReal/2) := by + ext s + change |s| < a.toReal / 2 ↔ -(a.toReal/2) < s ∧ s < a.toReal/2 + exact abs_lt + rw [he, Real.volume_Ioo, show a.toReal/2 - -(a.toReal/2) = a.toReal by ring, + ENNReal.ofReal_toReal ha] + +lemma centered_mono {a b : ℝ≥0∞} (ha : a ≤ b) (hb : b ≠ ⊤) : centered a ⊆ centered b := by + intro s hs + exact hs.trans_le (div_le_div_of_nonneg_right (ENNReal.toReal_mono hb ha) (by norm_num)) + +lemma centered_inter {a b : ℝ≥0∞} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : + volume (centered a ∩ centered b) = min a b := by + rcases le_total a b with h | h + · rw [inter_eq_left.mpr (centered_mono h hb), measure_centered ha, min_eq_left h] + · rw [inter_eq_right.mpr (centered_mono h ha), measure_centered hb, min_eq_right h] + +noncomputable def heightMeasure : Measure ℝ := + volume.withDensity (fun s : ℝ => ENNReal.ofReal |s|) + +instance : SFinite heightMeasure := by + unfold heightMeasure + infer_instance + +lemma integral_abs_symmetric {r : ℝ} (hr : 0 ≤ r) : + (∫ s : ℝ in -r..r, |s|) = r^2 := by + have hl : (∫ s : ℝ in -r..0, |s|) = r^2/2 := by + have he : (∫ s : ℝ in -r..0, |s|) = ∫ s : ℝ in -r..0, -s := by + apply intervalIntegral.integral_congr + intro x hx + rw [uIcc_of_le (by linarith : -r ≤ (0:ℝ))] at hx + exact abs_of_nonpos hx.2 + rw [he, intervalIntegral.integral_neg, integral_id] + ring + have hu : (∫ s : ℝ in 0..r, |s|) = r^2/2 := by + have he : (∫ s : ℝ in 0..r, |s|) = ∫ s : ℝ in 0..r, s := by + apply intervalIntegral.integral_congr + intro x hx + rw [uIcc_of_le hr] at hx + exact abs_of_nonneg hx.1 + rw [he, integral_id] + ring + rw [← intervalIntegral.integral_add_adjacent_intervals + (continuous_abs.intervalIntegrable (-r) 0) (continuous_abs.intervalIntegrable 0 r), hl, hu] + ring + +lemma heightMeasure_centered {a : ℝ≥0∞} (ha : a ≠ ⊤) : + heightMeasure (centered a) = a^2/4 := by + have he : centered a = Ioo (-(a.toReal/2)) (a.toReal/2) := by + ext s + change |s| < a.toReal/2 ↔ -(a.toReal/2) < s ∧ s < a.toReal/2 + exact abs_lt + have hi : IntegrableOn (fun s : ℝ => |s|) (centered a) := by + rw [he] + exact continuous_abs.integrableOn_Icc.mono_set Ioo_subset_Icc_self + rw [heightMeasure, withDensity_apply _ (centered_measurable a), + ← ofReal_integral_eq_lintegral_ofReal hi (Filter.Eventually.of_forall (fun _ => abs_nonneg _))] + rw [he, restrict_Ioo_eq_restrict_Ioc, ← intervalIntegral.integral_of_le (by linarith [ENNReal.toReal_nonneg (a := a)] : -(a.toReal/2) ≤ a.toReal/2), + integral_abs_symmetric (by positivity)] + rw [div_pow, ENNReal.ofReal_div_of_pos (by norm_num), ENNReal.ofReal_pow + ENNReal.toReal_nonneg, ENNReal.ofReal_toReal ha] + norm_num + +lemma heightMeasure_centered_inter {a b : ℝ≥0∞} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : + heightMeasure (centered a ∩ centered b) = (min a b)^2/4 := by + rcases le_total a b with h | h + · rw [inter_eq_left.mpr (centered_mono h hb), heightMeasure_centered ha, min_eq_left h] + · rw [inter_eq_right.mpr (centered_mono h ha), heightMeasure_centered hb, min_eq_right h] + +section Rearranged +variable {X U V : Type*} [MeasurableSpace X] [MeasurableSpace U] [MeasurableSpace V] + {μ : Measure X} {ν : Measure U} {ρ : Measure V} [SFinite μ] [SFinite ν] [SFinite ρ] + +lemma measure_family_measurable (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) : + Measurable (fun u => μ (S u)) := by + have he (u : U) : μ (S u) = ∫⁻ x, (S u).indicator (fun _ => (1:ℝ≥0∞)) x ∂μ := by + have hs : MeasurableSet (S u) := hS.preimage measurable_prodMk_right + rw [lintegral_indicator hs, lintegral_one, Measure.restrict_apply_univ] + simp_rw [he] + apply Measurable.lintegral_prod_left + exact measurable_const.indicator hS + +noncomputable def rearranged (S : U → Set X) (μ : Measure X) (ν : Measure U) : ℝ → ℝ≥0∞ := + layer (fun u => centered (μ (S u))) ν + +lemma centered_family_measurable (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) : + MeasurableSet {p : ℝ × U | p.1 ∈ centered (μ (S p.2))} := by + exact measurableSet_lt measurable_fst.abs + (((measure_family_measurable S hS).comp measurable_snd).ennreal_toReal.div_const 2) + +lemma rearranged_measurable (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) : Measurable (rearranged S μ ν) := + layer_measurable _ (centered_family_measurable S hS) + +lemma rearranged_pair (S : U → Set X) (T : V → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hT : MeasurableSet {p : X × V | p.1 ∈ T p.2}) + (hfS : ∀ u, μ (S u) ≠ ⊤) (hfT : ∀ v, μ (T v) ≠ ⊤) : + (∫⁻ s, rearranged S μ ν s * rearranged T μ ρ s) = + ∫⁻ u, ∫⁻ v, min (μ (S u)) (μ (T v)) ∂ρ ∂ν := by + unfold rearranged + rw [layer_pair_sets _ _ (centered_family_measurable S hS) (centered_family_measurable T hT)] + simp_rw [centered_inter (hfS _) (hfT _)] + +lemma rearranged_inner_ge (S : U → Set X) (T : V → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hT : MeasurableSet {p : X × V | p.1 ∈ T p.2}) + (hfS : ∀ u, μ (S u) ≠ ⊤) (hfT : ∀ v, μ (T v) ≠ ⊤) : + (∫⁻ x, layer S ν x * layer T ρ x ∂μ) ≤ + ∫⁻ s, rearranged S μ ν s * rearranged T μ ρ s := by + rw [layer_pair_sets S T hS hT, rearranged_pair S T hS hT hfS hfT] + apply lintegral_mono + intro u + apply lintegral_mono + intro v + exact le_min (measure_mono inter_subset_left) (measure_mono inter_subset_right) + +lemma rearranged_square (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hfS : ∀ u, μ (S u) ≠ ⊤) (hnest : ∀ u v, S u ⊆ S v ∨ S v ⊆ S u) : + (∫⁻ s, (rearranged S μ ν s)^2) = ∫⁻ x, (layer S ν x)^2 ∂μ := by + simp only [pow_two] + rw [rearranged_pair S S hS hS hfS hfS, layer_pair_sets S S hS hS] + simp_rw [measure_inter_eq_min_of_nested μ _ _ (hnest _ _)] + +lemma rearranged_height (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hfS : ∀ u, μ (S u) ≠ ⊤) : + (∫⁻ s, ENNReal.ofReal |s| * (rearranged S μ ν s)^2) = + ∫⁻ u, ∫⁻ v, (min (μ (S u)) (μ (S v)))^2/4 ∂ν ∂ν := by + have hm : Measurable (fun s : ℝ => (rearranged S μ ν s)^2) := + (rearranged_measurable (μ := μ) (ν := ν) S hS).pow_const 2 + have he := lintegral_withDensity_eq_lintegral_mul volume + (f := fun s : ℝ => ENNReal.ofReal |s|) (g := fun s => (rearranged S μ ν s)^2) + measurable_id.abs.ennreal_ofReal hm + change (∫⁻ s, ((fun s : ℝ => ENNReal.ofReal |s|) * + (fun s => (rearranged S μ ν s)^2)) s) = _ + rw [← he] + change (∫⁻ s, (rearranged S μ ν s)^2 ∂heightMeasure) = _ + simp only [pow_two] + unfold rearranged + rw [layer_pair_sets _ _ (centered_family_measurable S hS) (centered_family_measurable S hS)] + simp only [heightMeasure_centered_inter (hfS _) (hfS _), pow_two] + +lemma prod_family_measurable (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) : + MeasurableSet {p : (X × X) × U | p.1 ∈ S p.2 ×ˢ S p.2} := by + exact (hS.preimage (measurable_fst.fst.prodMk measurable_snd)).inter + (hS.preimage (measurable_fst.snd.prodMk measurable_snd)) + +lemma rearranged_height_pair (S : U → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hfS : ∀ u, μ (S u) ≠ ⊤) (hnest : ∀ u v, S u ⊆ S v ∨ S v ⊆ S u) : + (∫⁻ s, ENNReal.ofReal |s| * (rearranged S μ ν s)^2) = + (∫⁻ p : X × X, (layer (fun u => S u ×ˢ S u) ν p)^2 ∂μ.prod μ)/4 := by + rw [rearranged_height S hS hfS] + simp_rw [ENNReal.div_eq_inv_mul, lintegral_const_mul' _ _ (by norm_num : (4:ℝ≥0∞)⁻¹ ≠ ⊤)] + congr 1 + simp only [pow_two] + rw [layer_pair_sets _ _ (prod_family_measurable S hS) (prod_family_measurable S hS)] + simp_rw [prod_inter_prod, Measure.prod_prod, + measure_inter_eq_min_of_nested μ _ _ (hnest _ _)] + +omit [SFinite μ] [SFinite ν] in +lemma rearranged_eq_zero_of_bound (S : U → Set X) {L : ℝ≥0∞} (hL : L ≠ ⊤) + (hbound : ∀ u, μ (S u) ≤ L) {s : ℝ} (hs : s ∉ centered L) : + rearranged S μ ν s = 0 := by + unfold rearranged layer + have he (u : U) : (centered (μ (S u))).indicator (fun _ => (1:ℝ≥0∞)) s = 0 := by + apply indicator_of_notMem + exact fun h => hs (centered_mono (hbound u) hL h) + simp only [he, lintegral_zero] + +end Rearranged + +section FunctionLayers +variable {X : Type*} [MeasurableSpace X] +noncomputable def superlevel (f : X → ℝ) (u : ℝ) : Set X := {x | 0 < u ∧ u < f x} + +lemma superlevel_measurable {f : X → ℝ} (hf : Measurable f) : + MeasurableSet {p : X × ℝ | p.1 ∈ superlevel f p.2} := + (measurableSet_lt measurable_const measurable_snd).inter + (measurableSet_lt measurable_snd (hf.comp measurable_fst)) + +omit [MeasurableSpace X] in +lemma layer_superlevel (f : X → ℝ) (x : X) : layer (superlevel f) volume x = ENNReal.ofReal (f x) := by + have he (u : ℝ) : (superlevel f u).indicator (fun _ => (1:ℝ≥0∞)) x = + (Ioo 0 (f x)).indicator (fun _ => (1:ℝ≥0∞)) u := by + by_cases h : 0 < u ∧ u < f x <;> simp [superlevel, h] + simp_rw [layer, he] + rw [lintegral_indicator measurableSet_Ioo, lintegral_one, + Measure.restrict_apply_univ, Real.volume_Ioo, sub_zero] + +omit [MeasurableSpace X] in +lemma superlevel_nested (f : X → ℝ) (u v : ℝ) : + superlevel f u ⊆ superlevel f v ∨ superlevel f v ⊆ superlevel f u := by + by_cases hu : 0 < u + · by_cases hv : 0 < v + · rcases le_total u v with h | h + · exact Or.inr fun x hx => ⟨hu, h.trans_lt hx.2⟩ + · exact Or.inl fun x hx => ⟨hv, h.trans_lt hx.2⟩ + · exact Or.inr fun x hx => (hv hx.1).elim + · exact Or.inl fun x hx => (hu hx.1).elim + +omit [MeasurableSpace X] in +lemma layer_superlevel_prod (f : X → ℝ) (p : X × X) : + layer (fun u => superlevel f u ×ˢ superlevel f u) volume p = + ENNReal.ofReal (min (f p.1) (f p.2)) := by + have he : (fun u => superlevel f u ×ˢ superlevel f u) = + superlevel (fun q : X × X => min (f q.1) (f q.2)) := by + funext u + ext q + simp only [superlevel, mem_prod, mem_ofPred_eq, lt_min_iff] + tauto + rw [he, layer_superlevel] + +lemma function_rearranged_height (μ : Measure X) [SFinite μ] {f : X → ℝ} + (hf : Measurable f) (hfinite : ∀ u, μ (superlevel f u) ≠ ⊤) : + (∫⁻ s, ENNReal.ofReal |s| * (rearranged (superlevel f) μ volume s)^2) = + (∫⁻ x, ∫⁻ y, (ENNReal.ofReal (min (f x) (f y)))^2 ∂μ ∂μ)/4 := by + rw [rearranged_height_pair _ (superlevel_measurable hf) hfinite (superlevel_nested f)] + simp_rw [layer_superlevel_prod] + congr 1 + exact lintegral_prod (μ := μ) (ν := μ) _ + (((hf.comp measurable_fst).min (hf.comp measurable_snd)).ennreal_ofReal.pow_const 2).aemeasurable + +end FunctionLayers +end VerticalRearrangement + +open MeasureTheory Set Filter +open scoped ENNReal +namespace VerticalRearrangement + +section RealLayers +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +lemma ae_finite_of_square {f : X → ℝ≥0∞} (hf : Measurable f) + (hi : ∫⁻ x, (f x)^2 ∂μ ≠ ⊤) : ∀ᵐ x ∂μ, f x < ⊤ := by + filter_upwards [ae_lt_top (hf.pow_const 2) hi] with x hx + by_contra hn + have he : f x = ⊤ := not_lt_top_iff.mp hn + simp [he] at hx + +lemma toReal_memLp {f : X → ℝ≥0∞} (hf : Measurable f) + (hi : ∫⁻ x, (f x)^2 ∂μ ≠ ⊤) : MemLp (fun x => (f x).toReal) 2 μ := by + apply (memLp_two_iff_integrable_sq hf.ennreal_toReal.aestronglyMeasurable).mpr + simpa only [ENNReal.toReal_pow] using + integrable_toReal_of_lintegral_ne_top (hf.pow_const 2).aemeasurable hi + +lemma integral_toReal_square {f : X → ℝ≥0∞} (hf : Measurable f) + (hi : ∫⁻ x, (f x)^2 ∂μ ≠ ⊤) : + (∫ x, (f x).toReal^2 ∂μ) = (∫⁻ x, (f x)^2 ∂μ).toReal := by + simpa only [ENNReal.toReal_pow] using + integral_toReal (hf.pow_const 2).aemeasurable (ae_lt_top (hf.pow_const 2) hi) + +lemma lintegral_mul_ne_top_of_squares {f g : X → ℝ≥0∞} + (hf : Measurable f) (hg : Measurable g) + (hfi : ∫⁻ x, (f x)^2 ∂μ ≠ ⊤) (hgi : ∫⁻ x, (g x)^2 ∂μ ≠ ⊤) : + ∫⁻ x, f x * g x ∂μ ≠ ⊤ := by + have hi := ((toReal_memLp hf hfi).integrable_mul (toReal_memLp hg hgi)).lintegral_lt_top + have he : (fun x => ENNReal.ofReal ((f x).toReal*(g x).toReal)) =ᵐ[μ] + fun x => f x*g x := by + filter_upwards [ae_finite_of_square hf hfi, ae_finite_of_square hg hgi] with x hx hy + rw [← ENNReal.toReal_mul, ENNReal.ofReal_toReal (ENNReal.mul_ne_top hx.ne hy.ne)] + exact (lt_of_eq_of_lt (lintegral_congr_ae he).symm hi).ne + +lemma integral_toReal_mul {f g : X → ℝ≥0∞} + (hf : Measurable f) (hg : Measurable g) + (hfi : ∫⁻ x, (f x)^2 ∂μ ≠ ⊤) (hgi : ∫⁻ x, (g x)^2 ∂μ ≠ ⊤) : + (∫ x, (f x).toReal*(g x).toReal ∂μ) = (∫⁻ x, f x*g x ∂μ).toReal := by + apply (integral_congr_ae (ae_of_all _ fun _ => ENNReal.toReal_mul.symm)).trans + apply integral_toReal (hf.mul hg).aemeasurable + filter_upwards [ae_finite_of_square hf hfi, ae_finite_of_square hg hgi] with x hx hy + exact ENNReal.mul_lt_top hx hy + +end RealLayers + +lemma integral_sub_sq {Y : Type*} [MeasurableSpace Y] {ζ : Measure Y} {f g : Y → ℝ} + (hf : MemLp f 2 ζ) (hg : MemLp g 2 ζ) : + (∫ y, (f y-g y)^2 ∂ζ) = (∫ y, (f y)^2 ∂ζ)+(∫ y, (g y)^2 ∂ζ)-2*(∫ y, f y*g y ∂ζ) := by + have hff : Integrable (fun y => f y^2) ζ := (memLp_two_iff_integrable_sq hf.aestronglyMeasurable).mp hf + have hgg : Integrable (fun y => g y^2) ζ := (memLp_two_iff_integrable_sq hg.aestronglyMeasurable).mp hg + have hfg : Integrable (fun y => f y*g y) ζ := hf.integrable_mul hg + simp_rw [show ∀ y, (f y-g y)^2 = f y^2+g y^2-2*(f y*g y) by intro y; ring] + have hsum : Integrable (fun y => f y^2+g y^2) ζ := hff.add hgg + have htwo : Integrable (fun y => 2*(f y*g y)) ζ := hfg.const_mul 2 + rw [integral_sub hsum htwo, integral_add hff hgg, integral_const_mul] + +section L2 +variable {X U V : Type*} [MeasurableSpace X] [MeasurableSpace U] [MeasurableSpace V] + {μ : Measure X} {ν : Measure U} {ρ : Measure V} [SFinite μ] [SFinite ν] [SFinite ρ] +variable (S : U → Set X) (T : V → Set X) + (hS : MeasurableSet {p : X × U | p.1 ∈ S p.2}) + (hT : MeasurableSet {p : X × V | p.1 ∈ T p.2}) + (hfS : ∀ u, μ (S u) ≠ ⊤) (hfT : ∀ v, μ (T v) ≠ ⊤) + (hnS : ∀ u v, S u ⊆ S v ∨ S v ⊆ S u) + (hnT : ∀ u v, T u ⊆ T v ∨ T v ⊆ T u) + (hiS : ∫⁻ x, (layer S ν x)^2 ∂μ ≠ ⊤) + (hiT : ∫⁻ x, (layer T ρ x)^2 ∂μ ≠ ⊤) + +include hS hfS hnS hiS in +lemma rearranged_real_memLp : MemLp (fun s => (rearranged S μ ν s).toReal) 2 volume := by + apply toReal_memLp (rearranged_measurable (μ := μ) (ν := ν) S hS) + simpa only [rearranged_square S hS hfS hnS] using hiS + +include hS hfS hnS hiS in +lemma rearranged_real_square : + (∫ s, (rearranged S μ ν s).toReal^2) = ∫ x, (layer S ν x).toReal^2 ∂μ := by + rw [integral_toReal_square (rearranged_measurable (μ := μ) (ν := ν) S hS) + (by simpa only [rearranged_square S hS hfS hnS] using hiS), + integral_toReal_square (layer_measurable S hS) hiS, + rearranged_square S hS hfS hnS] + +include hS hT hfS hfT hnS hnT hiS hiT in +lemma rearranged_real_inner : + (∫ x, (layer S ν x).toReal*(layer T ρ x).toReal ∂μ) ≤ + ∫ s, (rearranged S μ ν s).toReal*(rearranged T μ ρ s).toReal := by + have hs := rearranged_measurable (μ := μ) (ν := ν) S hS + have ht := rearranged_measurable (μ := μ) (ν := ρ) T hT + have his : ∫⁻ s, (rearranged S μ ν s)^2 ≠ ⊤ := by simpa only [rearranged_square S hS hfS hnS] using hiS + have hit : ∫⁻ s, (rearranged T μ ρ s)^2 ≠ ⊤ := by simpa only [rearranged_square T hT hfT hnT] using hiT + rw [integral_toReal_mul (layer_measurable S hS) (layer_measurable T hT) hiS hiT, + integral_toReal_mul hs ht his hit] + exact ENNReal.toReal_mono (lintegral_mul_ne_top_of_squares hs ht his hit) + (rearranged_inner_ge S T hS hT hfS hfT) + +include hS hT hfS hfT hnS hnT hiS hiT in +lemma rearranged_real_difference : + (∫ s, ((rearranged S μ ν s).toReal-(rearranged T μ ρ s).toReal)^2) ≤ + ∫ x, ((layer S ν x).toReal-(layer T ρ x).toReal)^2 ∂μ := by + have hls := toReal_memLp (layer_measurable (ν := ν) S hS) hiS + have hlt := toReal_memLp (layer_measurable (ν := ρ) T hT) hiT + have hrs := rearranged_real_memLp S hS hfS hnS hiS + have hrt := rearranged_real_memLp T hT hfT hnT hiT + rw [integral_sub_sq hrs hrt, integral_sub_sq hls hlt, rearranged_real_square S hS hfS hnS hiS, + rearranged_real_square T hT hfT hnT hiT] + linarith [rearranged_real_inner S T hS hT hfS hfT hnS hnT hiS hiT] + +end L2 +end VerticalRearrangement + +end + +section + +open MeasureTheory Set Filter +open scoped ENNReal +namespace VerticalRearrangement +section Fibers +variable {X : Type*} [MeasurableSpace X] + +noncomputable def fiberStar (F : X × ℝ → ℝ) (p : X × ℝ) : ℝ≥0∞ := + rearranged (superlevel (fun s => F (p.1,s))) volume volume p.2 + +lemma fiberLength_measurable {F : X × ℝ → ℝ} (hF : Measurable F) : + Measurable (fun p : X × ℝ => volume (superlevel (fun s => F (p.1,s)) p.2)) := by + apply measure_family_measurable + change MeasurableSet {p : ℝ × (X × ℝ) | 0 < p.2.2 ∧ p.2.2 < F (p.2.1,p.1)} + exact (measurableSet_lt measurable_const measurable_snd.snd).inter + (measurableSet_lt measurable_snd.snd (hF.comp (measurable_snd.fst.prodMk measurable_fst))) + +lemma fiberStar_measurable {F : X × ℝ → ℝ} (hF : Measurable F) : + Measurable (fiberStar F) := by + unfold fiberStar rearranged layer + apply Measurable.lintegral_prod_right + apply measurable_const.indicator + change MeasurableSet {p : (X × ℝ) × ℝ | + |p.1.2| < (volume (superlevel (fun r => F (p.1.1,r)) p.2)).toReal / 2} + exact measurableSet_lt measurable_fst.snd.abs + (((fiberLength_measurable hF).comp (measurable_fst.fst.prodMk measurable_snd)).ennreal_toReal.div_const 2) + +omit [MeasurableSpace X] in +lemma superlevel_measure_ne_top_of_strip {F : X × ℝ → ℝ} {ell : ℝ} + (hstrip : ∀ p, ell ≤ |p.2| → F p = 0) (x : X) (u : ℝ) : + volume (superlevel (fun s => F (x,s)) u) ≠ ⊤ := by + apply ne_top_of_le_ne_top (measure_Ioo_lt_top (μ := (volume : Measure ℝ)) (a := -ell) (b := ell)).ne + apply measure_mono + intro s hs + change 0 < u ∧ u < F (x,s) at hs + have h : |s| < ell := by + by_contra hn + rw [hstrip (x,s) (not_lt.mp hn)] at hs + linarith [hs.1,hs.2] + exact abs_lt.mp h + +lemma fiberStar_square {F : X × ℝ → ℝ} (hF : Measurable F) + (hfinite : ∀ x u, volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) (x : X) : + (∫⁻ s, (fiberStar F (x,s))^2) = ∫⁻ s, (ENNReal.ofReal (F (x,s)))^2 := by + change (∫⁻ s, (rearranged (superlevel (fun r => F (x,r))) volume volume s)^2) = _ + have hx : Measurable (fun s => F (x,s)) := hF.comp measurable_prodMk_left + rw [rearranged_square _ (superlevel_measurable hx) + (hfinite x) (superlevel_nested _)] + simp only [layer_superlevel] + +variable {μ : Measure X} +lemma fiberStar_total_square {F : X × ℝ → ℝ} (hF : Measurable F) + (hfinite : ∀ x u, volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) : + (∫⁻ p, (fiberStar F p)^2 ∂μ.prod volume) = + ∫⁻ p, (ENNReal.ofReal (F p))^2 ∂μ.prod volume := by + rw [lintegral_prod _ ((fiberStar_measurable hF).pow_const 2).aemeasurable, + lintegral_prod _ (hF.ennreal_ofReal.pow_const 2).aemeasurable] + apply lintegral_congr + exact fiberStar_square hF hfinite + +lemma fiberStar_toReal_memLp {F : X × ℝ → ℝ} (hF : Measurable F) + (hfinite : ∀ x u, volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hi : ∫⁻ p, (ENNReal.ofReal (F p))^2 ∂μ.prod volume ≠ ⊤) : + MemLp (fun p => (fiberStar F p).toReal) 2 (μ.prod volume) := by + apply toReal_memLp (fiberStar_measurable hF) + rwa [fiberStar_total_square hF hfinite] + +lemma fiberStar_total_real_square {F : X × ℝ → ℝ} (hF : Measurable F) + (hFn : ∀ p, 0 ≤ F p) + (hfinite : ∀ x u, volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hi : ∫⁻ p, (ENNReal.ofReal (F p))^2 ∂μ.prod volume ≠ ⊤) : + (∫ p, (fiberStar F p).toReal^2 ∂μ.prod volume) = ∫ p, F p^2 ∂μ.prod volume := by + rw [integral_toReal_square (fiberStar_measurable hF) + (by rwa [fiberStar_total_square hF hfinite]), fiberStar_total_square hF hfinite] + simpa only [ENNReal.toReal_ofReal (hFn _)] using + (integral_toReal_square hF.ennreal_ofReal hi).symm + +omit [MeasurableSpace X] in +lemma fiberStar_eq_zero_of_measure_le {F : X × ℝ → ℝ} (x : X) (s : ℝ) + (h : ∀ u, volume (superlevel (fun r => F (x,r)) u) ≤ ENNReal.ofReal (2*|s|)) : + fiberStar F (x,s) = 0 := by + unfold fiberStar rearranged layer + have hz (u : ℝ) : (centered (volume (superlevel (fun r => F (x,r)) u))).indicator + (fun _ => (1:ℝ≥0∞)) s = 0 := by + apply indicator_of_notMem + change ¬ |s| < (volume (superlevel (fun r => F (x,r)) u)).toReal/2 + have hh := ENNReal.toReal_le_of_le_ofReal (by positivity : 0 ≤ 2*|s|) (h u) + linarith + simp only [hz,lintegral_zero] + +lemma ofReal_square_integral_ne_top {F : X → ℝ} (hF : MemLp F 2 μ) (hFn : ∀ x,0 ≤ F x) : + ∫⁻ x, (ENNReal.ofReal (F x))^2 ∂μ ≠ ⊤ := by + have hh := ((memLp_two_iff_integrable_sq hF.aestronglyMeasurable).mp hF).lintegral_lt_top.ne + simpa only [ENNReal.ofReal_pow (hFn _)] using hh + +lemma fiberStar_difference {F G : X × ℝ → ℝ} (hF : Measurable F) (hG : Measurable G) + (hFn : ∀ p,0 ≤ F p) (hGn : ∀ p,0 ≤ G p) + (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hfG : ∀ x u,volume (superlevel (fun s => G (x,s)) u) ≠ ⊤) + (x : X) (hiF : MemLp (fun s => F (x,s)) 2 volume) + (hiG : MemLp (fun s => G (x,s)) 2 volume) : + (∫ s, ((fiberStar F (x,s)).toReal-(fiberStar G (x,s)).toReal)^2) ≤ + ∫ s, (F (x,s)-G (x,s))^2 := by + have hmF := superlevel_measurable (f := fun r => F (x,r)) (hF.comp measurable_prodMk_left) + have hmG := superlevel_measurable (f := fun r => G (x,r)) (hG.comp measurable_prodMk_left) + have hF' : ∫⁻ s, (layer (superlevel (fun r => F (x,r))) volume s)^2 ≠ ⊤ := by + simpa only [layer_superlevel] using ofReal_square_integral_ne_top hiF (fun s => hFn (x,s)) + have hG' : ∫⁻ s, (layer (superlevel (fun r => G (x,r))) volume s)^2 ≠ ⊤ := by + simpa only [layer_superlevel] using ofReal_square_integral_ne_top hiG (fun s => hGn (x,s)) + simpa only [fiberStar,layer_superlevel,ENNReal.toReal_ofReal (hFn _), + ENNReal.toReal_ofReal (hGn _)] using + rearranged_real_difference _ _ hmF hmG (hfF x) (hfG x) + (superlevel_nested _) (superlevel_nested _) hF' hG' + +lemma fiberStar_memLp {F : X × ℝ → ℝ} (hF : Measurable F) (hFn : ∀ p,0 ≤ F p) + (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hiF : MemLp F 2 (μ.prod volume)) : + MemLp (fun p => (fiberStar F p).toReal) 2 (μ.prod volume) := + fiberStar_toReal_memLp hF hfF (ofReal_square_integral_ne_top hiF hFn) + +lemma fiberStar_total_difference [SFinite μ] {F G : X × ℝ → ℝ} + (hF : Measurable F) (hG : Measurable G) (hFn : ∀ p,0 ≤ F p) (hGn : ∀ p,0 ≤ G p) + (hfF : ∀ x u,volume (superlevel (fun s => F (x,s)) u) ≠ ⊤) + (hfG : ∀ x u,volume (superlevel (fun s => G (x,s)) u) ≠ ⊤) + (hiF : MemLp F 2 (μ.prod volume)) (hiG : MemLp G 2 (μ.prod volume)) : + (∫ p, ((fiberStar F p).toReal-(fiberStar G p).toReal)^2 ∂μ.prod volume) ≤ + ∫ p, (F p-G p)^2 ∂μ.prod volume := by + have hF2 := (memLp_two_iff_integrable_sq hiF.aestronglyMeasurable).mp hiF + have hG2 := (memLp_two_iff_integrable_sq hiG.aestronglyMeasurable).mp hiG + have hS := (fiberStar_memLp hF hFn hfF hiF).sub (fiberStar_memLp hG hGn hfG hiG) + have hD := hiF.sub hiG + have hS2 := (memLp_two_iff_integrable_sq hS.aestronglyMeasurable).mp hS + have hD2 := (memLp_two_iff_integrable_sq hD.aestronglyMeasurable).mp hD + simp only [Pi.sub_apply] at hS2 hD2 + rw [integral_prod _ hS2,integral_prod _ hD2] + apply integral_mono_ae hS2.integral_prod_left hD2.integral_prod_left + filter_upwards [hF2.prod_right_ae,hG2.prod_right_ae] with x hx hy + exact fiberStar_difference hF hG hFn hGn hfF hfG x + ((memLp_two_iff_integrable_sq (hF.comp measurable_prodMk_left).aestronglyMeasurable).mpr hx) + ((memLp_two_iff_integrable_sq (hG.comp measurable_prodMk_left).aestronglyMeasurable).mpr hy) + +end Fibers +end VerticalRearrangement + +end + +section + +open Set MeasureTheory +open scoped ENNReal +namespace ShiftedSections +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +lemma line_interval_mem {K : Set E} (hK : Convex ℝ K) {y e : E} {r t z : ℝ} + (hr : y+r • e ∈ K) (ht : y+t • e ∈ K) (hz : z ∈ Icc r t) : y+z • e ∈ K := by + have hc : Convex ℝ {a : ℝ | y+a • e ∈ K} := by + intro a ha b hb u v hu hv huv + change y+(u*a+v*b) • e ∈ K + have hvu : v=1-u := by linarith + subst v + convert hK ha hb hu hv huv using 1; module + exact hc.ordConnected.out hr ht hz + +lemma section_mono {K : Set E} (hK : Convex ℝ K) (e : E) (ell : ℝ) + {s t : ℝ} (hs : 0 ≤ s) (hst : s ≤ t) : + sectionDomain K e ell t ⊆ sectionDomain K e ell s := by + rintro y ⟨c,hc,hl,hr⟩ + refine ⟨c,lt_of_le_of_lt (add_le_add_right hst _) hc, + line_interval_mem hK hl hr ⟨?_,?_⟩,line_interval_mem hK hl hr ⟨?_,?_⟩⟩ <;> linarith + +lemma section_of_fiber_pair {K : Set E} (hK : Convex ℝ K) {y e : E} {ell r t s : ℝ} + (hr : |r| < ell) (ht : |t| < ell) (hry : y+r • e ∈ K) (hty : y+t • e ∈ K) + (hs : 0 ≤ s) (hst : 2*s < t-r) : y ∈ sectionDomain K e ell s := by + refine ⟨(r+t)/2,?_,line_interval_mem hK hry hty ⟨?_,?_⟩, + line_interval_mem hK hry hty ⟨?_,?_⟩⟩ + · rw [← lt_sub_iff_add_lt,abs_lt] + constructor + · linarith [(abs_lt.mp hr).1] + · linarith [(abs_lt.mp ht).2] + all_goals linarith + +lemma fiber_measure_le_of_not_section {K : Set E} (hK : Convex ℝ K) + {y e : E} {ell s : ℝ} (hs : 0 ≤ s) (hy : y ∉ sectionDomain K e ell s) : + volume {r : ℝ | |r| < ell ∧ y+r • e ∈ K} ≤ ENNReal.ofReal (2*s) := by + apply (Real.volume_le_diam _).trans + apply Metric.ediam_le_of_forall_dist_le + intro r hr t ht + rw [Real.dist_eq] + by_contra! hh + rcases lt_or_ge r t with hrt | htr + · rw [abs_of_nonpos (sub_nonpos.mpr hrt.le)] at hh + exact hy (section_of_fiber_pair hK hr.1 ht.1 hr.2 ht.2 hs (by linarith)) + · rw [abs_of_nonneg (sub_nonneg.mpr htr)] at hh + exact hy (section_of_fiber_pair hK ht.1 hr.1 ht.2 hr.2 hs hh) + +lemma section_bounded {K : Set E} (hK : Bornology.IsBounded K) (e : E) {ell s : ℝ} + (hs : 0 ≤ s) : Bornology.IsBounded (sectionDomain K e ell s) := by + obtain ⟨R,hR⟩ := hK.subset_closedBall (0:E) + apply Metric.isBounded_iff_subset_closedBall (0:E) |>.mpr + refine ⟨R+|ell| * ‖e‖,?_⟩ + rintro y ⟨c,hc,hl,hr⟩ + have hcs : |c-s| < ell := by + have hh := abs_sub c s + rw [abs_of_nonneg hs] at hh + exact hh.trans_lt hc + have he : ‖(c-s) • e‖ ≤ |ell| * ‖e‖ := by + rw [norm_smul,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hcs.le.trans (le_abs_self ell)) (norm_nonneg e) + have hm : ‖y+(c-s) • e‖ ≤ R := by simpa only [Metric.mem_closedBall,dist_zero_right] using hR hl + rw [Metric.mem_closedBall,dist_zero_right] + calc + ‖y‖ = ‖(y+(c-s) • e)-(c-s) • e‖ := by rw [add_sub_cancel_right] + _ ≤ ‖y+(c-s) • e‖+‖(c-s) • e‖ := norm_sub_le _ _ + _ ≤ R+|ell| * ‖e‖ := add_le_add hm he + +lemma fiberStar_supported {K : Set E} (hK : Convex ℝ K) {e : E} {ell : ℝ} + [MeasurableSpace E] {F : E × ℝ → ℝ} + (hF : ∀ p, p.1+p.2 • e ∉ K ∨ ell ≤ |p.2| → F p = 0) + {y : E} {s : ℝ} (hy : y ∉ sectionDomain K e ell |s|) : + VerticalRearrangement.fiberStar F (y,s) = 0 := by + apply VerticalRearrangement.fiberStar_eq_zero_of_measure_le + intro u + apply le_trans (measure_mono ?_) (fiber_measure_le_of_not_section hK (abs_nonneg s) hy) + intro r hr + change 0 < u ∧ u < F (y,r) at hr + have hnot : ¬ (y+r • e ∉ K ∨ ell ≤ |r|) := by + intro hn + rw [hF (y,r) hn] at hr + linarith [hr.1,hr.2] + push Not at hnot + exact ⟨hnot.2,hnot.1⟩ + +end ShiftedSections + +end + +section + +open Set +namespace EuclideanSteinitz + +lemma convex_supporting_line {J : Set ℝ} {h : ℝ → ℝ} (hc : ConvexOn ℝ J h) + (hm : MonotoneOn h J) (h0 : 0 ∈ J) (h1 : 1 ∈ J) + (hr : ∃ r ∈ J,1 < r) : + ∃ a : ℝ, 0 ≤ a ∧ ∀ x ∈ J, h 1+a*(x-1) ≤ h x := by + obtain ⟨r,hrJ,hr1⟩ := hr + let L : Set ℝ := {a | ∃ x ∈ J,x<1 ∧ a=slope h x 1} + have hL0 : slope h 0 1 ∈ L := ⟨0,h0,by norm_num,rfl⟩ + have hLne : L.Nonempty := ⟨_,hL0⟩ + have hLb : BddAbove L := by + refine ⟨slope h 1 r,?_⟩ + rintro a ⟨x,hx,hx1,rfl⟩ + simpa only [slope_def_field] using hc.slope_mono_adjacent hx hrJ hx1 hr1 + refine ⟨sSup L,?_,?_⟩ + · have hh := le_csSup hLb hL0 + have hm01 := hm h0 h1 (by norm_num : (0:ℝ)≤1) + simp only [slope_def_field,sub_zero,div_one] at hh + linarith + · intro x hx + rcases lt_trichotomy x 1 with hx1 | rfl | h1x + · have hh := le_csSup hLb (show slope h x 1 ∈ L from ⟨x,hx,hx1,rfl⟩) + rw [slope_def_field,div_le_iff₀ (by linarith : 0 < 1-x)] at hh + nlinarith + · simp + · have hh : sSup L ≤ slope h 1 x := by + apply csSup_le hLne + rintro a ⟨y,hy,hy1,rfl⟩ + simpa only [slope_def_field] using hc.slope_mono_adjacent hy hx hy1 h1x + rw [slope_def_field,le_div_iff₀ (by linarith : 0 < x-1)] at hh + linarith + +end EuclideanSteinitz + +end + +section + +open MeasureTheory Set +open scoped ENNReal NNReal +namespace ShiftedSections +variable {ι : Type*} [Fintype ι] + +noncomputable def sectionNorm (K : Set (EuclideanSpace ℝ ι)) (hK : IsOpen K) + (e : EuclideanSpace ℝ ι) (ell s : ℝ) (v : ι → ℝ≥0) : ℝ := + ‖HeatL2.compressedHeat (sectionDomain K e ell s) (section_open hK e ell s).measurableSet + (GaussianKernel.symbol v) (GaussianKernel.symbol_continuous v).aestronglyMeasurable + (GaussianKernel.symbol_nonneg v)‖ + +noncomputable def sectionRate (K : Set (EuclideanSpace ℝ ι)) (hK : IsOpen K) + (e : EuclideanSpace ℝ ι) (ell : ℝ) (v : ι → ℝ≥0) (s : ℝ) : ℝ := + -Real.log (sectionNorm K hK e ell s v) + +def activeHeights (K : Set (EuclideanSpace ℝ ι)) (e : EuclideanSpace ℝ ι) (ell : ℝ) : Set ℝ := + {s | 0 ≤ s ∧ (sectionDomain K e ell s).Nonempty} + +lemma activeHeights_convex {K : Set (EuclideanSpace ℝ ι)} (hK : Convex ℝ K) + (e : EuclideanSpace ℝ ι) (ell : ℝ) : Convex ℝ (activeHeights K e ell) := by + rintro s ⟨hs,ys,hys⟩ t ⟨ht,yt,hyt⟩ a b ha hb hab + exact ⟨add_nonneg (mul_nonneg ha hs) (mul_nonneg hb ht), + ⟨a • ys+b • yt,section_mix hK e ell hys hyt ha hb hab⟩⟩ + +lemma sectionNorm_pos {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (e : EuclideanSpace ℝ ι) (ell : ℝ) (v : ι → ℝ≥0) + {s : ℝ} (hs : s ∈ activeHeights K e ell) : 0 < sectionNorm K hKo e ell s v := by + let D := sectionDomain K e ell s + have hDb := section_bounded hKb e (ell := ell) hs.1 + let : IsFiniteMeasure (volume.restrict D) := isFiniteMeasure_restrict.mpr hDb.measure_lt_top.ne + apply HeatL2.compressed_norm_pos D (section_open hKo e ell s).measurableSet + exact (section_open hKo e ell s).measure_pos volume hs.2 + +lemma sectionNorm_le_one {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (e : EuclideanSpace ℝ ι) (ell s : ℝ) (v : ι → ℝ≥0) : sectionNorm K hKo e ell s v ≤ 1 := + HeatL2.compressedHeat_norm_le_one _ _ _ _ _ + +lemma sectionRate_nonneg {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (e : EuclideanSpace ℝ ι) (ell : ℝ) (v : ι → ℝ≥0) + {s : ℝ} (hs : s ∈ activeHeights K e ell) : 0 ≤ sectionRate K hKo e ell v s := by + exact neg_nonneg.mpr (Real.log_nonpos (sectionNorm_pos hKo hKb e ell v hs).le + (sectionNorm_le_one hKo e ell s v)) + +lemma sectionRate_monotone {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (hKc : Convex ℝ K) (e : EuclideanSpace ℝ ι) + (ell : ℝ) (v : ι → ℝ≥0) : MonotoneOn (sectionRate K hKo e ell v) (activeHeights K e ell) := by + intro s hs t ht hst + apply neg_le_neg + apply Real.log_le_log (sectionNorm_pos hKo hKb e ell v ht) + exact HeatL2.compressed_norm_mono_domain _ _ _ _ (section_mono hKc e ell hs.1 hst) _ _ _ + +lemma sectionRate_convex {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (hKc : Convex ℝ K) (e : EuclideanSpace ℝ ι) + (ell : ℝ) (v : ι → ℝ≥0) (hv : ∀ i,v i ≠ 0) : + ConvexOn ℝ (activeHeights K e ell) (sectionRate K hKo e ell v) := by + refine ⟨activeHeights_convex hKc e ell,?_⟩ + intro s hs r hr a b ha hb hab + have hbe : a=1-b := by linarith + have hb1 : b ∈ Icc (0:ℝ) 1 := ⟨hb,by linarith⟩ + have hsr := activeHeights_convex hKc e ell hs hr ha hb hab + have hh := GaussianKernel.compressed_norm_logconcave v hv + (section_open hKo e ell s) (section_open hKo e ell r) + (section_open hKo e ell (a*s+b*r)) + (section_bounded hKb e hs.1) (section_bounded hKb e hr.1) + (section_bounded hKb e hsr.1) (section_convex hKc e ell s) + (section_convex hKc e ell r) (section_convex hKc e ell (a*s+b*r)) + hs.2 hr.2 hb1 (fun y hy z hz => by + rw [← hbe] + exact section_mix hKc e ell hy hz ha hb hab) + change sectionNorm K hKo e ell s v^(1-b)*sectionNorm K hKo e ell r v^b ≤ + sectionNorm K hKo e ell (a*s+b*r) v at hh + rw [← hbe] at hh + have hsp := sectionNorm_pos hKo hKb e ell v hs + have hrp := sectionNorm_pos hKo hKb e ell v hr + have hlog := Real.log_le_log (mul_pos (Real.rpow_pos_of_pos hsp _) (Real.rpow_pos_of_pos hrp _)) hh + rw [Real.log_mul (Real.rpow_pos_of_pos hsp a).ne' (Real.rpow_pos_of_pos hrp b).ne', + Real.log_rpow hsp,Real.log_rpow hrp] at hlog + change -Real.log (sectionNorm K hKo e ell (a*s+b*r) v) ≤ + a*(-Real.log (sectionNorm K hKo e ell s v))+b*(-Real.log (sectionNorm K hKo e ell r v)) + linarith + +end ShiftedSections + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Scales.lean b/lean/OAI/Analysis/Steinitz/Scales.lean new file mode 100644 index 0000000000000000000000000000000000000000..5683a681beb9c66aacf9282950230c3daf3bee89 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Scales.lean @@ -0,0 +1,457 @@ +import OAI.Analysis.Steinitz.Filter + +namespace OAI + +/-! Uniform dyadic scale-energy estimates. -/ + +namespace EuclideanSteinitz.Scale +open Matrix MatrixEnergy Gain Energy +open scoped MatrixOrder Matrix.Norms.L2Operator + +lemma size_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ sizeWeight x := + le_min (Real.rpow_nonneg hx _) (inv_nonneg.mpr hx) + +lemma size_le_sqrt (x : ℝ) : sizeWeight x ≤ Real.sqrt x := by + unfold sizeWeight + rw [show exponent - 1 = (1 / 2 : ℝ) by norm_num [exponent], ← Real.sqrt_eq_rpow] + exact min_le_left _ _ + +lemma size_le_inv (x : ℝ) : sizeWeight x ≤ x⁻¹ := min_le_right _ _ + +lemma size_dyadic_nat {y : ℝ} (_hy : 0 ≤ y) (hy2 : y ≤ 2) (n : ℕ) : + sizeWeight (y / (2 : ℝ) ^ n) ≤ 2 * (3 / 4 : ℝ) ^ n := by + apply (size_le_sqrt _).trans + have hn : (1 / 2 : ℝ) ^ n ≤ ((3 / 4 : ℝ) ^ 2) ^ n := + pow_le_pow_left₀ (by norm_num) (by norm_num) n + have hsq : y / (2 : ℝ) ^ n ≤ (2 * (3 / 4 : ℝ) ^ n) ^ 2 := by + calc + _ = y * (1 / 2 : ℝ) ^ n := by rw [div_pow, one_pow]; ring + _ ≤ 4 * ((3 / 4 : ℝ) ^ 2) ^ n := + mul_le_mul (by linarith : y ≤ 4) hn (by positivity) (by norm_num) + _ = _ := by rw [mul_pow, ← pow_mul, ← pow_mul]; norm_num; ring + exact (Real.sqrt_le_iff).mpr ⟨by positivity, hsq⟩ + +lemma size_dyadic_neg_nat {y : ℝ} (hy : 1 ≤ y) (n : ℕ) : + sizeWeight (y / (2 : ℝ) ^ (-(n : ℤ))) ≤ 2 * (3 / 4 : ℝ) ^ n := by + have hy0 : 0 < y := by linarith + apply (size_le_inv _).trans + have he : (y / (2 : ℝ) ^ (-(n : ℤ)))⁻¹ = y⁻¹ * (1 / 2 : ℝ) ^ n := by + rw [_root_.zpow_neg, zpow_natCast, inv_div, div_eq_mul_inv, ← inv_pow] + norm_num + ring + rw [he] + have h₁ : y⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hy + have h₂ : (1 / 2 : ℝ) ^ n ≤ (3 / 4 : ℝ) ^ n := pow_le_pow_left₀ (by norm_num) (by norm_num) n + have h := mul_le_mul h₁ h₂ (by positivity) (by norm_num : (0 : ℝ) ≤ 1) + nlinarith [pow_nonneg (by norm_num : (0 : ℝ) ≤ 3 / 4) n] + +lemma size_normalized {y : ℝ} (hy : 1 ≤ y) (hy2 : y ≤ 2) (n : ℤ) : + sizeWeight (y / (2 : ℝ) ^ n) ≤ 2 * (3 / 4 : ℝ) ^ n.natAbs := by + obtain ⟨m, rfl | rfl⟩ := n.eq_nat_or_neg + · simpa only [zpow_natCast, Int.natAbs_natCast] using size_dyadic_nat (by linarith) hy2 m + · simpa only [Int.natAbs_neg, Int.natAbs_natCast] using size_dyadic_neg_nat hy m + +lemma dyadic_normalize {x : ℝ} (hx : 0 < x) : + ∃ k : ℤ, 1 ≤ x / (2 : ℝ) ^ k ∧ x / (2 : ℝ) ^ k ≤ 2 := by + obtain ⟨k, hk, hk'⟩ := exists_mem_Ico_zpow hx (by norm_num : (1 : ℝ) < 2) + refine ⟨k, (le_div_iff₀ (zpow_pos (by norm_num) k)).mpr (by simpa using hk), ?_⟩ + apply (div_le_iff₀ (zpow_pos (by norm_num) k)).mpr + calc + x ≤ (2 : ℝ) ^ (k + 1) := hk'.le + _ = 2 * (2 : ℝ) ^ k := by rw [zpow_add_one₀ (by norm_num)]; ring + +lemma size_shifted {x : ℝ} {k : ℤ} (hk : 1 ≤ x / (2 : ℝ) ^ k) + (hk2 : x / (2 : ℝ) ^ k ≤ 2) (n : ℤ) : + sizeWeight (x / (2 : ℝ) ^ n) ≤ 2 * (3 / 4 : ℝ) ^ (n - k).natAbs := by + have he : x / (2 : ℝ) ^ n = (x / (2 : ℝ) ^ k) / (2 : ℝ) ^ (n - k) := by + rw [zpow_sub₀ (by norm_num)] + field_simp + rw [he] + exact size_normalized hk hk2 (n - k) + +lemma hasSum_decay_nat : HasSum (fun n : ℕ => (3 / 4 : ℝ) ^ n) 4 := by + have h := hasSum_geometric_of_lt_one (by norm_num : (0 : ℝ) ≤ 3 / 4) + (by norm_num : (3 / 4 : ℝ) < 1) + norm_num at h + exact h + +lemma hasSum_decay_neg : + HasSum (fun n : ℕ => (3 / 4 : ℝ) ^ (-(n + 1 : ℤ)).natAbs) 3 := by + have h := hasSum_decay_nat.mul_right (3 / 4 : ℝ) + have he (n : ℕ) : (-(n + 1 : ℤ)).natAbs = n + 1 := by + rw [Int.natAbs_neg, ← Nat.cast_one, ← Nat.cast_add, Int.natAbs_natCast] + simp only [he, pow_succ] + norm_num at h + exact h + +lemma hasSum_decay : HasSum (fun n : ℤ => (3 / 4 : ℝ) ^ n.natAbs) 7 := by + have h₁ : HasSum (fun n : ℕ => (3 / 4 : ℝ) ^ (n : ℤ).natAbs) 4 := by + simpa only [Int.natAbs_natCast] using hasSum_decay_nat + have h : HasSum (fun n : ℤ => (3 / 4 : ℝ) ^ n.natAbs) (4 + 3) := + HasSum.of_nat_of_neg_add_one (f := fun n : ℤ => (3 / 4 : ℝ) ^ n.natAbs) h₁ hasSum_decay_neg + norm_num at h + exact h + +lemma sum_decay_shift (S : Finset ℤ) (k : ℤ) : + (∑ n ∈ S, (3 / 4 : ℝ) ^ (n - k).natAbs) ≤ 7 := by + have hs : Summable (fun n : ℤ => (3 / 4 : ℝ) ^ (n - k).natAbs) := + hasSum_decay.summable.comp_injective (Equiv.subRight k).injective + calc + _ ≤ ∑' n : ℤ, (3 / 4 : ℝ) ^ (n - k).natAbs := + hs.sum_le_tsum S (fun _ _ => by positivity) + _ = ∑' n : ℤ, (3 / 4 : ℝ) ^ n.natAbs := + by simpa only [Equiv.subRight_apply] using + (Equiv.subRight k).tsum_eq (fun n : ℤ => (3 / 4 : ℝ) ^ n.natAbs) + _ = 7 := hasSum_decay.tsum_eq + +lemma sum_size_dyadic (S : Finset ℤ) {x : ℝ} (hx : 0 < x) : + (∑ n ∈ S, sizeWeight (x / (2 : ℝ) ^ n)) ≤ 14 := by + obtain ⟨k, hk, hk2⟩ := dyadic_normalize hx + calc + _ ≤ ∑ n ∈ S, 2 * (3 / 4 : ℝ) ^ (n - k).natAbs := + Finset.sum_le_sum fun n _ => size_shifted hk hk2 n + _ = 2 * ∑ n ∈ S, (3 / 4 : ℝ) ^ (n - k).natAbs := (Finset.mul_sum ..).symm + _ ≤ 2 * 7 := mul_le_mul_of_nonneg_left (sum_decay_shift S k) (by norm_num) + _ = 14 := by norm_num + +lemma potential_rate_le_size {x : ℝ} (hx : 0 ≤ x) : + PotentialScalar.rate x ≤ sizeWeight x := by + by_cases h1 : x ≤ 1 + · rw [PotentialScalar.rate_small h1, PotentialScalar.sizeWeight_small hx h1] + · have h1' : 1 ≤ x := le_of_lt (lt_of_not_ge h1) + rw [PotentialScalar.rate_large h1', PotentialScalar.sizeWeight_large h1'] + have hi : 0 ≤ x⁻¹ := inv_nonneg.mpr hx + have hi1 : x⁻¹ ≤ 1 := inv_le_one_of_one_le₀ h1' + nlinarith + +lemma gain_rate_le_size {x : ℝ} (hx : 0 ≤ x) : + GainScalar.rate x ≤ sizeWeight x := by + have hd : 0 < (1 + x) * Real.sqrt (1 + x) := by positivity + apply le_min + · rw [show exponent - 1 = (1 / 2 : ℝ) by norm_num [exponent], ← Real.sqrt_eq_rpow] + unfold GainScalar.rate + apply (div_le_iff₀ hd).mpr + have hs : 1 ≤ Real.sqrt (1 + x) := Real.one_le_sqrt.mpr (by linarith) + have hm : 1 ≤ (1 + x) * Real.sqrt (1 + x) := by + have h := mul_le_mul (by linarith : (1 : ℝ) ≤ 1 + x) hs + (by norm_num : (0 : ℝ) ≤ 1) (by positivity : 0 ≤ 1 + x) + simpa only [one_mul] using h + nlinarith [Real.sqrt_nonneg x] + · by_cases hx0 : x = 0 + · simp [hx0, GainScalar.rate] + · have hxpos : 0 < x := lt_of_le_of_ne hx (Ne.symm hx0) + unfold GainScalar.rate + apply (div_le_iff₀ hd).mpr + apply (le_inv_mul_iff₀ hxpos).mpr + calc + x * Real.sqrt x ≤ (1 + x) * Real.sqrt (1 + x) := + mul_le_mul (by linarith) (Real.sqrt_le_sqrt (by linarith)) + (Real.sqrt_nonneg _) (by positivity) + +lemma sum_rates_dyadic (S : Finset ℤ) {x : ℝ} (hx : 0 ≤ x) : + (∑ n ∈ S, (PotentialScalar.rate (x / (2 : ℝ) ^ n) + + GainScalar.extendedRate (x / (2 : ℝ) ^ n))) ≤ 28 := by + by_cases hx0 : x = 0 + · simp [hx0, PotentialScalar.rate_zero_of_nonpos (le_refl (0 : ℝ)), + GainScalar.extendedRate, GainScalar.rate] + have hxpos : 0 < x := lt_of_le_of_ne hx (Ne.symm hx0) + calc + _ ≤ ∑ n ∈ S, 2 * sizeWeight (x / (2 : ℝ) ^ n) := by + apply Finset.sum_le_sum + intro n _ + have hn : 0 ≤ x / (2 : ℝ) ^ n := by positivity + rw [GainScalar.extendedRate_eq hn] + linarith [potential_rate_le_size hn, gain_rate_le_size hn] + _ = 2 * ∑ n ∈ S, sizeWeight (x / (2 : ℝ) ^ n) := (Finset.mul_sum ..).symm + _ ≤ 2 * 14 := mul_le_mul_of_nonneg_left (sum_size_dyadic S hxpos) (by norm_num) + _ = 28 := by norm_num + +end EuclideanSteinitz.Scale + +namespace EuclideanSteinitz.ScaleMatrix +open Matrix MatrixEnergy Gain Energy Spectral +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def primitiveTrace (A : Matrix ι ι ℝ) : ℝ := + (cfc PotentialScalar.primitive A).trace + (cfc GainScalar.primitive A).trace + +noncomputable def rateMatrix (A : Matrix ι ι ℝ) : Matrix ι ι ℝ := + cfc PotentialScalar.rate A + cfc GainScalar.extendedRate A + +noncomputable def scaleTrace (S : Finset ℤ) (A : Matrix ι ι ℝ) : ℝ := + ∑ n ∈ S, (2 : ℝ) ^ n * primitiveTrace (((2 : ℝ) ^ n)⁻¹ • A) + +noncomputable def scaleRate (S : Finset ℤ) (A : Matrix ι ι ℝ) : Matrix ι ι ℝ := + ∑ n ∈ S, rateMatrix (((2 : ℝ) ^ n)⁻¹ • A) + +lemma primitiveTrace_eq {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + primitiveTrace A = hTrace A := by + unfold primitiveTrace hTrace pTrace gainValue + rw [Spectral.cfc_primitive_eq hA] + congr 1 + congr 1 + apply cfc_congr + intro x hx + exact GainScalar.primitive_eq (spectrum_nonneg_of_nonneg hA.nonneg hx) + +lemma primitiveTrace_derivative {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) (t : ℝ) : + HasDerivAt (fun u : ℝ => primitiveTrace (A + u • H)) + (rateMatrix (A + t • H) * H).trace t := by + have hp := trace_semiconvex_affine_derivative hA hH PotentialScalar.primitive + PotentialScalar.rate PotentialScalar.continuous_rate PotentialScalar.primitive_derivative + PotentialScalar.convexified_convex t + have hg := trace_semiconvex_affine_derivative hA hH GainScalar.primitive + GainScalar.extendedRate GainScalar.continuous_extendedRate GainScalar.primitive_derivative + GainScalar.convexified_convex t + simpa only [primitiveTrace, rateMatrix, Matrix.add_mul, trace_add] using hp.fun_add hg + +lemma rateMatrix_cfc {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (n : ℤ) : + rateMatrix (((2 : ℝ) ^ n)⁻¹ • A) = + cfc (fun x : ℝ => PotentialScalar.rate (x / (2 : ℝ) ^ n) + + GainScalar.extendedRate (x / (2 : ℝ) ^ n)) A := by + let f : ℝ → ℝ := fun x => PotentialScalar.rate x + GainScalar.extendedRate x + have hf : Continuous f := PotentialScalar.continuous_rate.add GainScalar.continuous_extendedRate + have he : cfc (fun x : ℝ => x / (2 : ℝ) ^ n) A = ((2 : ℝ) ^ n)⁻¹ • A := by + simp only [div_eq_mul_inv, mul_comm _ (((2 : ℝ) ^ n)⁻¹)] + rw [cfc_const_mul (((2 : ℝ) ^ n)⁻¹) (fun x : ℝ => x) A continuousOn_id, + cfc_id' ℝ A hA.isSelfAdjoint] + have hc := cfc_comp f (fun x : ℝ => x / (2 : ℝ) ^ n) A hA.isSelfAdjoint + hf.continuousOn (by fun_prop) + rw [he] at hc + unfold rateMatrix + rw [← cfc_add _ PotentialScalar.rate GainScalar.extendedRate + PotentialScalar.continuous_rate.continuousOn GainScalar.continuous_extendedRate.continuousOn] + exact hc.symm + +lemma scaleRate_cfc {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (S : Finset ℤ) : + scaleRate S A = cfc (fun x : ℝ => ∑ n ∈ S, + (PotentialScalar.rate (x / (2 : ℝ) ^ n) + + GainScalar.extendedRate (x / (2 : ℝ) ^ n))) A := by + unfold scaleRate + simp_rw [rateMatrix_cfc hA] + symm + have he : (fun x : ℝ => ∑ n ∈ S, (PotentialScalar.rate (x / (2 : ℝ) ^ n) + + GainScalar.extendedRate (x / (2 : ℝ) ^ n))) = ∑ n ∈ S, + (fun x : ℝ => PotentialScalar.rate (x / (2 : ℝ) ^ n) + + GainScalar.extendedRate (x / (2 : ℝ) ^ n)) := by + funext x + simp only [Finset.sum_apply] + rw [he] + exact cfc_sum _ A S (fun _ _ => finite_spectrum_continuous _ _) + +lemma scaleRate_le {A : Matrix ι ι ℝ} (hA : A.PosSemidef) (S : Finset ℤ) : + scaleRate S A ≤ (28 : ℝ) • (1 : Matrix ι ι ℝ) := by + rw [scaleRate_cfc hA.1] + let f : ℝ → ℝ := fun x => ∑ n ∈ S, + (PotentialScalar.rate (x / (2 : ℝ) ^ n) + + GainScalar.extendedRate (x / (2 : ℝ) ^ n)) + have hb : 0 ≤ cfc (fun x : ℝ => 28 - f x) A := by + apply cfc_nonneg + intro x hx + exact sub_nonneg.mpr (Scale.sum_rates_dyadic S (spectrum_nonneg_of_nonneg hA.nonneg hx)) + rw [cfc_sub (fun _ : ℝ => 28) f A continuousOn_const (finite_spectrum_continuous _ _), + cfc_const (28 : ℝ) A hA.1.isSelfAdjoint, Algebra.algebraMap_eq_smul_one] at hb + exact sub_nonneg.mp hb + +lemma scaleTrace_derivative {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) (S : Finset ℤ) (t : ℝ) : + HasDerivAt (fun u : ℝ => scaleTrace S (A + u • H)) + (scaleRate S (A + t • H) * H).trace t := by + have hi (n : ℤ) : HasDerivAt + (fun u : ℝ => (2 : ℝ) ^ n * primitiveTrace (((2 : ℝ) ^ n)⁻¹ • (A + u • H))) + (rateMatrix (((2 : ℝ) ^ n)⁻¹ • (A + t • H)) * H).trace t := by + have hd := (primitiveTrace_derivative (hA.smul (IsSelfAdjoint.all (((2 : ℝ) ^ n)⁻¹))) + (hH.smul (IsSelfAdjoint.all (((2 : ℝ) ^ n)⁻¹))) t).const_mul ((2 : ℝ) ^ n) + have he (u : ℝ) : ((2 : ℝ) ^ n)⁻¹ • (A + u • H) = + ((2 : ℝ) ^ n)⁻¹ • A + u • (((2 : ℝ) ^ n)⁻¹ • H) := by + simp only [smul_add, smul_smul, mul_comm] + simp_rw [he] + convert! hd using 1 + rw [Matrix.mul_smul, trace_smul, smul_eq_mul, ← mul_assoc, + mul_inv_cancel₀ (ne_of_gt (zpow_pos (by norm_num) n)), one_mul] + have hs := HasDerivAt.sum (u := S) (fun n _ => hi n) + convert! hs using 1 + · ext u + simp only [scaleTrace, Finset.sum_apply] + · simp only [scaleRate, Matrix.sum_mul, trace_sum] + +lemma scaleTrace_mono_bound {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hAB : A ≤ B) (S : Finset ℤ) : + scaleTrace S B - scaleTrace S A ≤ 28 * (B.trace - A.trace) := by + have hH : (B - A).PosSemidef := Matrix.le_iff.mp hAB + have hd (t : ℝ) := scaleTrace_derivative hA.1 hH.1 S t + have hb (t : ℝ) (ht : t ∈ Set.Icc (0 : ℝ) 1) : + deriv (fun u : ℝ => scaleTrace S (A + u • (B - A))) t ≤ 28 * (B - A).trace := by + rw [(hd t).deriv] + have h := trace_mul_mono_right (scaleRate_le (hA.add (hH.smul ht.1)) S) hH + simpa only [Matrix.smul_mul, Matrix.one_mul, trace_smul, smul_eq_mul] using h + have hi := (convex_Icc (0 : ℝ) 1).image_sub_le_mul_sub_of_deriv_le + (fun t _ => (hd t).continuousAt.continuousWithinAt) + (fun t _ => (hd t).differentiableAt.differentiableWithinAt) + (fun t ht => hb t (interior_subset ht)) 0 (by simp) 1 (by simp) (by norm_num) + simpa only [zero_smul, one_smul, add_zero, add_sub_cancel, sub_zero, mul_one, trace_sub] using hi + +lemma cfc_scaled {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (f : ℝ → ℝ) (c : ℝ) : + cfc f (c • A) = cfc (fun x : ℝ => f (c * x)) A := by + have he : cfc (fun x : ℝ => c * x) A = c • A := by + rw [cfc_const_mul c (fun x : ℝ => x) A continuousOn_id, cfc_id' ℝ A hA.isSelfAdjoint] + have hc := cfc_comp f (fun x : ℝ => c * x) A hA.isSelfAdjoint + ((A.finite_real_spectrum.image _).continuousOn f) (by fun_prop) + rw [he] at hc + exact hc.symm + +lemma scaleTrace_charpoly {A B : Matrix ι ι ℝ} (hA : A.IsHermitian) + (hB : B.IsHermitian) (hAB : A.charpoly = B.charpoly) (S : Finset ℤ) : + scaleTrace S A = scaleTrace S B := by + unfold scaleTrace + apply Finset.sum_congr rfl + intro n _ + congr 1 + unfold primitiveTrace + rw [cfc_scaled hA, cfc_scaled hA, cfc_scaled hB, cfc_scaled hB] + rw [trace_cfc_eq_of_charpoly hA hB hAB, trace_cfc_eq_of_charpoly hA hB hAB] + +lemma trace_charpoly {A B : Matrix ι ι ℝ} (hA : A.IsHermitian) + (hB : B.IsHermitian) (hAB : A.charpoly = B.charpoly) : A.trace = B.trace := by + rw [trace_spectral hA, trace_spectral hB, + (hA.eigenvalues_eq_eigenvalues_iff hB).mpr hAB] + +lemma scaleTrace_contraction_bound {A C : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hC : C * C.transpose ≤ 1) (T : Finset ℤ) : + scaleTrace T A - scaleTrace T (C * A * C.transpose) ≤ + 28 * (A.trace - (C * A * C.transpose).trace) := by + let S := CFC.sqrt A + have hS : S.IsHermitian := (CFC.sqrt_nonneg A).posSemidef.1 + have hSS : S * S = A := by simpa only [← sq] using CFC.sq_sqrt A hA.nonneg + have hCA : (C * A * C.transpose).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using hA.mul_mul_conjTranspose_same C + have hSC : (S * (C.transpose * C) * S).PosSemidef := by + have hp : (C.transpose * C).PosSemidef := by + simpa only [star_eq_conjTranspose, conjTranspose_eq_transpose_of_trivial] using + (star_mul_self_nonneg C : (0 : Matrix ι ι ℝ) ≤ star C * C).posSemidef + simpa only [hS.eq] using hp.conjTranspose_mul_mul_same S + have hle : S * (C.transpose * C) * S ≤ A := by + have hp := (Matrix.le_iff.mp (transpose_contraction hC)).conjTranspose_mul_mul_same S + rw [hS.eq] at hp + apply Matrix.le_iff.mpr + simpa only [Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_one, hSS] using hp + have heq : (C * A * C.transpose).charpoly = (S * (C.transpose * C) * S).charpoly := by + rw [← hSS] + convert! charpoly_mul_comm (C * S) (S * C.transpose) using 1 <;> simp only [Matrix.mul_assoc] + rw [scaleTrace_charpoly hCA.1 hSC.1 heq, trace_charpoly hCA.1 hSC.1 heq] + exact scaleTrace_mono_bound hSC hle T + +lemma scaleTrace_eq {A : Matrix ι ι ℝ} (hA : A.PosSemidef) (S : Finset ℤ) : + scaleTrace S A = ∑ n ∈ S, (2 : ℝ) ^ n * hTrace (((2 : ℝ) ^ n)⁻¹ • A) := by + apply Finset.sum_congr rfl + intro n _ + rw [primitiveTrace_eq (hA.smul (by positivity))] + +end EuclideanSteinitz.ScaleMatrix + +namespace EuclideanSteinitz.ScaleEnergy +open Matrix MatrixEnergy Gain Energy ScaleMatrix +open scoped MatrixOrder Matrix.Norms.L2Operator +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def rescale (c : ℝ) (p : Move ι) : Move ι := ⟨p.contract, c • p.gain⟩ + +omit [DecidableEq ι] in +lemma rescale_old (c : ℝ) (p : Move ι) (A : Matrix ι ι ℝ) : + (rescale c p).old (c • A) = c • p.old A := by + simp only [rescale, Move.old, Matrix.mul_smul, Matrix.smul_mul] + +omit [DecidableEq ι] in +lemma rescale_next (c : ℝ) (p : Move ι) (A : Matrix ι ι ℝ) : + (rescale c p).next (c • A) = c • p.next A := by + change (rescale c p).old (c • A) + c • p.gain = c • (p.old A + p.gain) + rw [rescale_old, smul_add] + +noncomputable def aggregateCost (S : Finset ℤ) (A : Matrix ι ι ℝ) : List (Move ι) → ℝ + | [] => 0 + | p :: ps => scaleTrace S A - scaleTrace S (p.old A) + scaleTrace S (p.next A) - + scaleTrace S (p.old A) + aggregateCost S (p.next A) ps + +noncomputable def variation (A : Matrix ι ι ℝ) : List (Move ι) → ℝ + | [] => 0 + | p :: ps => A.trace - (p.old A).trace + (p.next A).trace - + (p.old A).trace + variation (p.next A) ps + +noncomputable def gainSum (ps : List (Move ι)) : ℝ := (ps.map (fun p => p.gain.trace)).sum + +lemma aggregateCost_le_variation {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) (S : Finset ℤ) : + aggregateCost S A ps ≤ 28 * variation A ps := by + induction ps generalizing A with + | nil => simp [aggregateCost, variation] + | cons p ps ih => + have hp₀ := hp p (List.mem_cons_self ..) + have h₁ := scaleTrace_contraction_bound hA hp₀.1 S + have h₂ := scaleTrace_mono_bound (p.old_psd hA) (Energy.Move.old_le_next hp₀ A) S + have ht := ih (p.next_psd hp₀ hA) (fun q hq => hp q (List.mem_cons_of_mem p hq)) + change _ ≤ 28 * (_ + variation (p.next A) ps) + dsimp only [aggregateCost] + change scaleTrace S A - scaleTrace S (p.old A) ≤ 28 * (A.trace - (p.old A).trace) at h₁ + linarith + +omit [DecidableEq ι] in +lemma variation_eq (A : Matrix ι ι ℝ) (ps : List (Move ι)) : + variation A ps = A.trace + 2 * gainSum ps - (finish A ps).trace := by + induction ps generalizing A with + | nil => simp [variation, gainSum, finish] + | cons p ps ih => + simp only [variation, gainSum, List.map_cons, List.sum_cons, finish, ih] + rw [show (p.next A).trace = (p.old A).trace + p.gain.trace by + simp only [Move.next, trace_add]] + ring + +lemma finish_psd {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) : (finish A ps).PosSemidef := by + induction ps generalizing A with + | nil => exact hA + | cons p ps ih => + exact ih (p.next_psd (hp p (List.mem_cons_self ..)) hA) + (fun q hq => hp q (List.mem_cons_of_mem p hq)) + +lemma variation_le {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) : + variation A ps ≤ A.trace + 2 * gainSum ps := by + rw [variation_eq] + exact sub_le_self _ (finish_psd hA hp).trace_nonneg + +lemma sum_stepCost_eq {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {p : Move ι} (hp : p.Admissible) (S : Finset ℤ) : + (∑ n ∈ S, (2 : ℝ) ^ n * stepCost (rescale (((2 : ℝ) ^ n)⁻¹) p) + (((2 : ℝ) ^ n)⁻¹ • A)) = + scaleTrace S A - scaleTrace S (p.old A) + scaleTrace S (p.next A) - scaleTrace S (p.old A) := by + rw [scaleTrace_eq hA, scaleTrace_eq (p.old_psd hA), scaleTrace_eq (p.next_psd hp hA)] + simp only [stepCost, rescale_old, rescale_next, mul_sub, mul_add, + Finset.sum_sub_distrib, Finset.sum_add_distrib] + +lemma aggregateCost_eq {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) (S : Finset ℤ) : + aggregateCost S A ps = ∑ n ∈ S, (2 : ℝ) ^ n * + cost (((2 : ℝ) ^ n)⁻¹ • A) (ps.map (rescale (((2 : ℝ) ^ n)⁻¹))) := by + induction ps generalizing A with + | nil => simp [aggregateCost, cost] + | cons p ps ih => + have hp₀ := hp p (List.mem_cons_self ..) + simp only [List.map_cons, cost, rescale_next, mul_add, Finset.sum_add_distrib] + rw [sum_stepCost_eq hA hp₀, ← ih (p.next_psd hp₀ hA) + (fun q hq => hp q (List.mem_cons_of_mem p hq))] + rfl + +lemma scale_energy_bound {A : Matrix ι ι ℝ} (hA : A.PosSemidef) + {ps : List (Move ι)} (hp : ∀ p ∈ ps, p.Admissible) (S : Finset ℤ) : + (∑ n ∈ S, (2 : ℝ) ^ n * + cost (((2 : ℝ) ^ n)⁻¹ • A) (ps.map (rescale (((2 : ℝ) ^ n)⁻¹)))) ≤ + 28 * (A.trace + 2 * gainSum ps) := by + rw [← aggregateCost_eq hA hp] + exact (aggregateCost_le_variation hA hp S).trans + (mul_le_mul_of_nonneg_left (variation_le hA hp) (by norm_num)) + +end EuclideanSteinitz.ScaleEnergy + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/SectionEnergy.lean b/lean/OAI/Analysis/Steinitz/SectionEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea32f727f67ed1936518d2c791da4fb20325297f --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/SectionEnergy.lean @@ -0,0 +1,618 @@ +import OAI.Analysis.Steinitz.Rearrangement + +namespace OAI + +/-! Heat and energy inequalities for affine sections. -/ + +section + +open MeasureTheory Set Filter +open scoped ENNReal ComplexInnerProductSpace +namespace HeatL2 +section RealFunctions +variable {X : Type*} [MeasurableSpace X] {μ : Measure X} + +noncomputable def complexLp (f : X → ℝ) (hf : MemLp f 2 μ) : Lp ℂ 2 μ := + hf.ofReal.toLp (fun x => (f x:ℂ)) + +lemma complexLp_coe (f : X → ℝ) (hf : MemLp f 2 μ) : + (complexLp f hf : X → ℂ) =ᵐ[μ] fun x => (f x:ℂ) := MemLp.coeFn_toLp _ + +lemma complexLp_norm_sq (f : X → ℝ) (hf : MemLp f 2 μ) : + ‖complexLp f hf‖^2 = ∫ x,f x^2 ∂μ := by + rw [norm_sq_integral] + apply integral_congr_ae + filter_upwards [complexLp_coe f hf] with x hx + simp only [hx,Complex.norm_real,Real.norm_eq_abs,sq_abs] + +noncomputable def nonnegRepresentative (D : Set X) (_hD : MeasurableSet D) (f : Lp ℂ 2 μ) : X → ℝ := + D.indicator (fun x => ‖(Lp.aestronglyMeasurable f).mk f x‖) + +lemma nonnegRepresentative_measurable (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) : + Measurable (nonnegRepresentative D hD f) := + (Lp.aestronglyMeasurable f).stronglyMeasurable_mk.norm.measurable.indicator hD + +lemma nonnegRepresentative_nonneg (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) (x : X) : + 0 ≤ nonnegRepresentative D hD f x := by + exact indicator_nonneg (fun _ _ => norm_nonneg _) x + +lemma nonnegRepresentative_zero (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) + {x : X} (hx : x ∉ D) : nonnegRepresentative D hD f x=0 := indicator_of_notMem hx _ + +lemma nonnegRepresentative_ae (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) + (hf : f ∈ supported D) : nonnegRepresentative D hD f =ᵐ[μ] fun x => ‖f x‖ := by + filter_upwards [(Lp.aestronglyMeasurable f).ae_eq_mk,hf] with x hx hfx + by_cases hxd : x ∈ D + · simp only [nonnegRepresentative,indicator_of_mem hxd,hx] + · simp only [nonnegRepresentative,indicator_of_notMem hxd,hfx hxd,norm_zero] + +lemma nonnegRepresentative_memLp (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) + (hf : f ∈ supported D) : MemLp (nonnegRepresentative D hD f) 2 μ := + (Lp.memLp f).norm.ae_eq (nonnegRepresentative_ae D hD f hf).symm + +lemma nonnegRepresentative_square (D : Set X) (hD : MeasurableSet D) (f : Lp ℂ 2 μ) + (hf : f ∈ supported D) : (∫ x,nonnegRepresentative D hD f x^2 ∂μ)=‖f‖^2 := by + rw [norm_sq_integral] + apply integral_congr_ae + filter_upwards [nonnegRepresentative_ae D hD f hf] with x hx + rw [hx] + +end RealFunctions + +section Spatial +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +noncomputable def realDistance (f : E → ℝ) (a : E) : ℝ := ∫ x,(f (x+a)-f x)^2 + +lemma realDistance_eq (f : E → ℝ) (hf : MemLp f 2 volume) (a : E) : + realDistance f a = ‖translate a (complexLp f hf)-complexLp f hf‖^2 := by + rw [norm_sq_integral] + apply integral_congr_ae + filter_upwards [Lp.coeFn_sub (translate a (complexLp f hf)) (complexLp f hf), + translate_coe a (complexLp f hf),complexLp_coe f hf, + (measurePreserving_add_right volume a).quasiMeasurePreserving.ae_eq_comp (complexLp_coe f hf)] + with x hsub htr hx hxa + simp only [Function.comp_apply] at hxa + simp only [hsub,Pi.sub_apply,htr,hx,hxa,← Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs,sq_abs] + +omit [FiniteDimensional ℝ F] in +lemma realDistance_integrable (f : E → ℝ) (hf : MemLp f 2 volume) (A : F →L[ℝ] E) + (ν : Measure F) [IsFiniteMeasure ν] : Integrable (fun z => realDistance f (A z)) ν := by + simp_rw [realDistance_eq f hf] + exact integrable_difference_sq A ν _ + +lemma realEnergy_eq (f : E → ℝ) (hf : MemLp f 2 volume) (A : F →L[ℝ] E) : + (1/2:ℝ)*(∫ z,realDistance f (A z) ∂ProbabilityTheory.stdGaussian F) = + energy (gaussianSymbol A) (complexLp f hf) := by + rw [gaussian_energy_difference] + simp_rw [realDistance_eq f hf] + +lemma norm_representative_distance_le (f : Lp ℂ 2 (volume : Measure E)) + (g : E → ℝ) (hg : MemLp g 2 volume) (he : g =ᵐ[volume] fun x => ‖f x‖) (a : E) : + realDistance g a ≤ ‖translate a f-f‖^2 := by + have hgi := ((hg.comp_measurePreserving (measurePreserving_add_right volume a)).sub hg) + have hgsq := (memLp_two_iff_integrable_sq hgi.aestronglyMeasurable).mp hgi + have hfm := (Lp.memLp (translate a f-f)).norm + have hfint := (memLp_two_iff_integrable_sq hfm.aestronglyMeasurable).mp hfm + simp only [Pi.sub_apply,Function.comp_apply] at hgsq + rw [realDistance,norm_sq_integral] + apply integral_mono_ae hgsq hfint + filter_upwards [he,(measurePreserving_add_right volume a).quasiMeasurePreserving.ae_eq_comp he, + Lp.coeFn_sub (translate a f) f,translate_coe a f] with x hx hxa hsub htr + simp only [Function.comp_apply] at hxa + simp only [hx,hxa,hsub,Pi.sub_apply,htr] + apply sq_le_sq.mpr + simpa only [abs_norm] using abs_norm_sub_norm_le (f (x+a)) (f x) + +end Spatial +end HeatL2 + +end + +section + +open MeasureTheory MeasureTheory.Measure Set +open scoped ENNReal +namespace HeatL2 +section Slice +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +lemma horizontal_translate_preserving (a : E) : + MeasurePreserving (fun p : E × ℝ => (p.1+a,p.2)) + ((volume : Measure E).prod volume) (volume.prod volume) := by + exact (measurePreserving_add_right volume a).prod (MeasurePreserving.id volume) + +lemma horizontal_difference_integrable (G : E × ℝ → ℝ) + (hG : MemLp G 2 ((volume : Measure E).prod volume)) (A : F →L[ℝ] E) + (ν : Measure F) [IsProbabilityMeasure ν] : + Integrable (fun q : F × (E × ℝ) => (G (q.2.1+A q.1,q.2.2)-G q.2)^2) + (ν.prod ((volume : Measure E).prod volume)) := by + have hp : MeasurePreserving (fun q : F × (E × ℝ) => (q.1,(q.2.1+A q.1,q.2.2))) + (ν.prod (volume.prod volume)) (ν.prod (volume.prod volume)) := + (MeasurePreserving.id ν).skew_product (by fun_prop) + (ae_of_all _ fun z => (horizontal_translate_preserving (A z)).map_eq) + have h₀ : MemLp (fun q : F × (E × ℝ) => G q.2) 2 (ν.prod (volume.prod volume)) := + hG.comp_measurePreserving measurePreserving_snd + have h₁ := h₀.comp_measurePreserving hp + have hd := h₁.sub h₀ + exact (memLp_two_iff_integrable_sq hd.aestronglyMeasurable).mp hd + +lemma slice_memLp (G : E × ℝ → ℝ) (hm : Measurable G) + (hG : MemLp G 2 ((volume : Measure E).prod volume)) : + ∀ᵐ s ∂(volume : Measure ℝ), MemLp (fun x => G (x,s)) 2 volume := by + have hi := (memLp_two_iff_integrable_sq hG.aestronglyMeasurable).mp hG + filter_upwards [hi.prod_left_ae] with s hs + exact (memLp_two_iff_integrable_sq (hm.comp (by fun_prop)).aestronglyMeasurable).mpr hs + +noncomputable def sliceEnergy (ν : Measure F) (A : F →L[ℝ] E) (G : E × ℝ → ℝ) (s : ℝ) : ℝ := + (1/2:ℝ) * ∫ z, realDistance (fun x => G (x,s)) (A z) ∂ν + +lemma sliceEnergy_integrable (G : E × ℝ → ℝ) + (hG : MemLp G 2 ((volume : Measure E).prod volume)) (A : F →L[ℝ] E) + (ν : Measure F) [IsProbabilityMeasure ν] : Integrable (sliceEnergy ν A G) volume := by + have hi := horizontal_difference_integrable G hG A ν + have ha := (measurePreserving_prodAssoc ν (volume : Measure E) + (volume : Measure ℝ)).integrable_comp_of_integrable hi + have hk := ha.integral_prod_right + apply (hk.const_mul (1/2:ℝ)).congr + filter_upwards [ha.prod_left_ae] with s hs + dsimp [sliceEnergy,realDistance] + congr 1 + exact integral_prod _ hs + +lemma integral_sliceEnergy (G : E × ℝ → ℝ) + (hG : MemLp G 2 ((volume : Measure E).prod volume)) (A : F →L[ℝ] E) + (ν : Measure F) [IsProbabilityMeasure ν] : + (∫ s,sliceEnergy ν A G s) = (1/2:ℝ) * ∫ z, + ∫ p,(G (p.1+A z,p.2)-G p)^2 ∂((volume : Measure E).prod volume) ∂ν := by + have hi := horizontal_difference_integrable G hG A ν + have hp := measurePreserving_prodAssoc ν (volume : Measure E) (volume : Measure ℝ) + have ha := hp.integrable_comp_of_integrable hi + unfold sliceEnergy + rw [integral_const_mul] + congr 1 + calc + (∫ s,∫ z,realDistance (fun x => G (x,s)) (A z) ∂ν) = + ∫ s,∫ q : F × E,(G (q.2+A q.1,s)-G (q.2,s))^2 ∂ν.prod volume := by + apply integral_congr_ae + filter_upwards [ha.prod_left_ae] with s hs + exact (integral_prod _ hs).symm + _ = ∫ q : (F × E) × ℝ,(G (q.1.2+A q.1.1,q.2)-G (q.1.2,q.2))^2 + ∂(ν.prod volume).prod volume := (integral_prod_symm _ ha).symm + _ = ∫ q : F × (E × ℝ),(G (q.2.1+A q.1,q.2.2)-G q.2)^2 + ∂ν.prod (volume.prod volume) := hp.integral_comp MeasurableEquiv.prodAssoc.measurableEmbedding + (fun q : F × (E × ℝ) => (G (q.2.1+A q.1,q.2.2)-G q.2)^2) + _ = _ := integral_prod _ hi + +lemma integral_sliceEnergy_le {G : E × ℝ → ℝ} + (hG : MemLp G 2 ((volume : Measure E).prod volume)) {f : E → ℝ} + (hf : MemLp f 2 volume) (A : F →L[ℝ] E) + (hc : ∀ a : E,(∫ p,(G (p.1+a,p.2)-G p)^2 ∂(volume : Measure E).prod volume) ≤ realDistance f a) : + (∫ s,sliceEnergy (ProbabilityTheory.stdGaussian F) A G s) ≤ + energy (gaussianSymbol A) (complexLp f hf) := by + rw [integral_sliceEnergy G hG,← realEnergy_eq] + apply mul_le_mul_of_nonneg_left _ (by norm_num) + exact integral_mono (horizontal_difference_integrable G hG A _).integral_prod_left + (realDistance_integrable f hf A _) (fun z => hc (A z)) + +end Slice +end HeatL2 + +end + +section + +open MeasureTheory Set +open scoped ENNReal NNReal +namespace ShiftedSections +variable {ι : Type*} [Fintype ι] + +noncomputable def sliceMass (G : EuclideanSpace ℝ ι × ℝ → ℝ) (s : ℝ) : ℝ := + ∫ x,G (x,s)^2 + +lemma sliceMass_nonneg (G : EuclideanSpace ℝ ι × ℝ → ℝ) (s : ℝ) : 0 ≤ sliceMass G s := + integral_nonneg fun _ => sq_nonneg _ + +lemma sliceMass_integrable {G : EuclideanSpace ℝ ι × ℝ → ℝ} + (hG : MemLp G 2 (volume.prod volume)) : Integrable (sliceMass G) volume := + ((memLp_two_iff_integrable_sq hG.aestronglyMeasurable).mp hG).integral_prod_right + +lemma integral_sliceMass {G : EuclideanSpace ℝ ι × ℝ → ℝ} + (hG : MemLp G 2 (volume.prod volume)) : + (∫ s,sliceMass G s) = ∫ p,G p^2 ∂(volume : Measure (EuclideanSpace ℝ ι)).prod volume := + (integral_prod_symm _ ((memLp_two_iff_integrable_sq hG.aestronglyMeasurable).mp hG)).symm + +lemma sliceMass_height_integrable {G : EuclideanSpace ℝ ι × ℝ → ℝ} + (hH : Integrable (fun p => |p.2| *G p^2) (volume.prod volume)) : + Integrable (fun s => |s| *sliceMass G s) volume := by + have hi := hH.integral_prod_right + simpa only [sliceMass,integral_const_mul] using hi + +lemma integral_sliceMass_height {G : EuclideanSpace ℝ ι × ℝ → ℝ} + (hH : Integrable (fun p => |p.2| *G p^2) (volume.prod volume)) : + (∫ s,|s| *sliceMass G s) = ∫ p,|p.2| *G p^2 ∂(volume : Measure (EuclideanSpace ℝ ι)).prod volume := by + rw [integral_prod_symm _ hH] + simp only [sliceMass,integral_const_mul] + +lemma height_above_one {K : Set (EuclideanSpace ℝ ι)} (e : EuclideanSpace ℝ ι) (ell : ℝ) + {G : EuclideanSpace ℝ ι × ℝ → ℝ} (hG : MemLp G 2 (volume.prod volume)) + (hn : (∫ p,G p^2 ∂volume.prod volume)=1) + (hH : Integrable (fun p => |p.2| *G p^2) (volume.prod volume)) + (hh : 1 < ∫ p,|p.2| *G p^2 ∂volume.prod volume) + (hs : ∀ p,p.1 ∉ sectionDomain K e ell |p.2| → G p=0) : + ∃ r ∈ activeHeights K e ell,1 < r := by + have hp : ∃ p : EuclideanSpace ℝ ι × ℝ, 1 < |p.2| ∧ G p ≠ 0 := by + by_contra! he + have hle : ∀ p : EuclideanSpace ℝ ι × ℝ, |p.2| *G p^2 ≤ G p^2 := by + intro p + by_cases hp : 1 < |p.2| + · simp only [he p hp,zero_pow (by norm_num : 2 ≠ 0),mul_zero,le_refl] + · exact mul_le_of_le_one_left (sq_nonneg _) (le_of_not_gt hp) + have hi := integral_mono hH ((memLp_two_iff_integrable_sq hG.aestronglyMeasurable).mp hG) hle + rw [hn] at hi + linarith + obtain ⟨p,hp,hpn⟩ := hp + refine ⟨|p.2|,⟨abs_nonneg _,⟨p.1,?_⟩⟩,hp⟩ + by_contra hx + exact hpn (hs p hx) + +lemma activeHeights_contains_one {K : Set (EuclideanSpace ℝ ι)} (hK : Convex ℝ K) + (e : EuclideanSpace ℝ ι) (ell : ℝ) (hr : ∃ r ∈ activeHeights K e ell,1 < r) : + (0:ℝ) ∈ activeHeights K e ell ∧ (1:ℝ) ∈ activeHeights K e ell := by + obtain ⟨r,hr,hr1⟩ := hr + obtain ⟨y,hy⟩ := hr.2 + exact ⟨⟨le_refl 0,⟨y,section_mono hK e ell (le_refl 0) hr.1 hy⟩⟩, + ⟨by norm_num,⟨y,section_mono hK e ell (by norm_num) hr1.le hy⟩⟩⟩ + +lemma activeHeights_lt {K : Set (EuclideanSpace ℝ ι)} (e : EuclideanSpace ℝ ι) (ell : ℝ) + {s : ℝ} (hs : s ∈ activeHeights K e ell) : s < ell := by + obtain ⟨y,c,hc,_,_⟩ := hs.2 + linarith [abs_nonneg c] + +end ShiftedSections + +end + +section + +open MeasureTheory Set +open scoped ComplexInnerProductSpace +namespace HeatL2 + +lemma loss_bounded_lower {t R L : ℝ} (ht : 0 < t) (hL : 0 ≤ L) (hRL : R ≤ L) : + t/(1+t*L)*R ≤ max 0 (loss (t*R)) := by + have hd : 0 < 1+t*L := by positivity + by_cases hR : 0 ≤ R + · apply le_trans _ (le_max_right _ _) + apply le_trans _ (loss_lower (mul_nonneg ht.le hR)) + calc + t/(1+t*L)*R = (t*R)/(1+t*L) := by ring + _ ≤ (t*R)/(1+t*R) := div_le_div_of_nonneg_left (mul_nonneg ht.le hR) + (by positivity) (by nlinarith) + · apply le_trans _ (le_max_left _ _) + exact mul_nonpos_of_nonneg_of_nonpos (div_nonneg ht.le hd.le) (le_of_not_ge hR) + +section Affine +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma compressed_norm_smalltime (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : Measurable w) (hn : ∀ x,0 ≤ w x) + {t : ℝ} (ht : 0 < t) (ht1 : t ≤ 1) : + ‖compressedHeat D hD (fun ξ => t*w ξ) (hw.const_mul t).aestronglyMeasurable + (fun ξ => mul_nonneg ht.le (hn ξ))‖ ≤ + ‖compressedHeat D hD w hw.aestronglyMeasurable hn‖^t := by + have hh := compressed_norm_rpow D hD w hw hn ht ht1 + simp only [one_mul] at hh + simpa only [one_div,inv_inv] using + (Real.le_rpow_inv_iff_of_pos (norm_nonneg _) (norm_nonneg _) (one_div_pos.mpr ht)).mpr hh + +lemma energy_lower_rate (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : Measurable w) (hn : ∀ x,0 ≤ w x) + (hnorm : 0 < ‖compressedHeat D hD w hw.aestronglyMeasurable hn‖) + {t R : ℝ} (ht : 0 < t) (ht1 : t ≤ 1) + (hR : R ≤ -Real.log ‖compressedHeat D hD w hw.aestronglyMeasurable hn‖) + {f : Lp ℂ 2 (volume : Measure E)} (hf : f ∈ supported D) : + loss (t*R)*‖f‖^2 ≤ energy (fun ξ => t*w ξ) f := by + have hs := compressed_norm_smalltime D hD w hw hn ht ht1 + have he : ‖compressedHeat D hD w hw.aestronglyMeasurable hn‖^t ≤ Real.exp (-(t*R)) := by + rw [Real.rpow_def_of_pos hnorm] + apply Real.exp_le_exp.mpr + nlinarith + have hh := form_le_norm D hD (fun ξ => t*w ξ) (hw.const_mul t).aestronglyMeasurable + (fun ξ => mul_nonneg ht.le (hn ξ)) hf + have hb := mul_le_mul_of_nonneg_right (hs.trans he) (sq_nonneg ‖f‖) + dsimp [loss] + nlinarith + +lemma energy_lower_affine (D : Set E) (hD : MeasurableSet D) + (w : E → ℝ) (hw : Measurable w) (hn : ∀ x,0 ≤ w x) + (hnorm : 0 < ‖compressedHeat D hD w hw.aestronglyMeasurable hn‖) + {t R L : ℝ} (ht : 0 < t) (ht1 : t ≤ 1) (hL : 0 ≤ L) (hRL : R ≤ L) + (hR : R ≤ -Real.log ‖compressedHeat D hD w hw.aestronglyMeasurable hn‖) + {f : Lp ℂ 2 (volume : Measure E)} (hf : f ∈ supported D) : + (t/(1+t*L)*R)*‖f‖^2 ≤ energy (fun ξ => t*w ξ) f := by + have hh := loss_bounded_lower ht hL hRL + apply (mul_le_mul_of_nonneg_right hh (sq_nonneg ‖f‖)).trans + rw [max_mul_of_nonneg _ _ (sq_nonneg ‖f‖),zero_mul] + exact max_le (energy_nonneg _ (fun ξ => mul_nonneg ht.le (hn ξ)) f) + (energy_lower_rate D hD w hw hn hnorm ht ht1 hR hf) + +end Affine +end HeatL2 + +end + +section + +open MeasureTheory Set +open scoped ENNReal NNReal +namespace ShiftedSections +open HeatL2 +variable {ι : Type*} [Fintype ι] + +lemma sliceMass_affine_integrable {G : EuclideanSpace ℝ ι × ℝ → ℝ} + (hG : MemLp G 2 (volume.prod volume)) + (hH : Integrable (fun p => |p.2| *G p^2) (volume.prod volume)) (h a : ℝ) : + Integrable (fun s => (h+a*(|s|-1))*sliceMass G s) volume := by + have he : (fun s => (h+a*(|s|-1))*sliceMass G s) = + (fun s => (h-a)*sliceMass G s+a*(|s| *sliceMass G s)) := by ext s; ring + rw [he] + exact ((sliceMass_integrable hG).const_mul (h-a)).add + ((sliceMass_height_integrable hH).const_mul a) + +lemma integral_sliceMass_affine {G : EuclideanSpace ℝ ι × ℝ → ℝ} + (hG : MemLp G 2 (volume.prod volume)) + (hH : Integrable (fun p => |p.2| *G p^2) (volume.prod volume)) + (hn : (∫ p,G p^2 ∂volume.prod volume)=1) (h a : ℝ) : + (∫ s,(h+a*(|s|-1))*sliceMass G s) = h+a*((∫ p,|p.2| *G p^2 ∂volume.prod volume)-1) := by + have he : (fun s => (h+a*(|s|-1))*sliceMass G s) = + (fun s => (h-a)*sliceMass G s+a*(|s| *sliceMass G s)) := by ext s; ring + rw [he,integral_add ((sliceMass_integrable hG).const_mul _) ((sliceMass_height_integrable hH).const_mul _), + integral_const_mul,integral_const_mul,integral_sliceMass hG,hn,integral_sliceMass_height hH] + ring + +lemma integrated_section_rate {K : Set (EuclideanSpace ℝ ι)} (hKo : IsOpen K) + (hKb : Bornology.IsBounded K) (e : EuclideanSpace ℝ ι) {ell : ℝ} (hell : 0 ≤ ell) + (v : ι → ℝ≥0) {h a : ℝ} (hh : 0 ≤ h) (ha : 0 ≤ a) + (hline : ∀ r ∈ activeHeights K e ell,h+a*(r-1) ≤ sectionRate K hKo e ell v r) + {t : ℝ} (ht : 0 < t) (ht1 : t ≤ 1) + (A : EuclideanSpace ℝ ι →L[ℝ] EuclideanSpace ℝ ι) + (hA : gaussianSymbol A = fun ξ => t*GaussianKernel.symbol v ξ) + {G : EuclideanSpace ℝ ι × ℝ → ℝ} (hGm : Measurable G) + (hG : MemLp G 2 (volume.prod volume)) + (hGs : ∀ p,p.1 ∉ sectionDomain K e ell |p.2| → G p=0) + (hn : (∫ p,G p^2 ∂volume.prod volume)=1) + (hH : Integrable (fun p => |p.2| *G p^2) (volume.prod volume)) + (hheight : 1 ≤ ∫ p,|p.2| *G p^2 ∂volume.prod volume) : + t/(1+t*(h+a*ell))*h ≤ ∫ s,sliceEnergy (ProbabilityTheory.stdGaussian _) A G s := by + let L := h+a*ell + have hL : 0 ≤ L := add_nonneg hh (mul_nonneg ha hell) + have hC : 0 ≤ t/(1+t*L) := by positivity + have hint := (sliceMass_affine_integrable hG hH h a).const_mul (t/(1+t*L)) + have hbound : ∀ᵐ s ∂(volume : Measure ℝ), + (t/(1+t*L))*((h+a*(|s|-1))*sliceMass G s) ≤ + sliceEnergy (ProbabilityTheory.stdGaussian _) A G s := by + filter_upwards [slice_memLp G hGm hG] with s hs + by_cases hact : |s| ∈ activeHeights K e ell + · let D := sectionDomain K e ell |s| + have hD : MeasurableSet D := (section_open hKo e ell |s|).measurableSet + have hsupp : complexLp (fun x => G (x,s)) hs ∈ supported D := by + filter_upwards [complexLp_coe (fun x => G (x,s)) hs] with x hx hn + rw [hx,hGs (x,s) hn,Complex.ofReal_zero] + have hb := energy_lower_affine D hD (GaussianKernel.symbol v) + (GaussianKernel.symbol_continuous v).measurable (GaussianKernel.symbol_nonneg v) + (sectionNorm_pos hKo hKb e ell v hact) ht ht1 hL + (show h+a*(|s|-1) ≤ L by + have := activeHeights_lt e ell hact + dsimp [L] + nlinarith) + (hline |s| hact) hsupp + rw [complexLp_norm_sq,← hA,← realEnergy_eq] at hb + simpa only [sliceMass,sliceEnergy,mul_assoc] using hb + · have hz : ∀ x,G (x,s)=0 := by + intro x + apply hGs (x,s) + intro hx + exact hact ⟨abs_nonneg _,⟨x,hx⟩⟩ + simp only [sliceMass,sliceEnergy,realDistance,hz,sub_self,zero_pow (by norm_num : 2 ≠ 0), + integral_zero,mul_zero,le_refl] + have hInt := integral_mono_ae hint (sliceEnergy_integrable G hG A _) hbound + rw [integral_const_mul,integral_sliceMass_affine hG hH hn h a] at hInt + apply le_trans _ hInt + apply mul_le_mul_of_nonneg_left _ hC + nlinarith + +end ShiftedSections + +end + +section + +open MeasureTheory Set FourierTransform +open scoped ENNReal NNReal ComplexInnerProductSpace +namespace HeatL2 +section Energy +variable {E F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] + [MeasurableSpace F] [BorelSpace F] + +lemma energy_sum_dilate_le {ι : Type*} (s : Finset ι) (c : ι → ℝ) (w : ι → E → ℝ) + (hc : ∀ i ∈ s,1 ≤ c i) (hw : ∀ i ∈ s,AEStronglyMeasurable (w i) volume) + (hn : ∀ i ∈ s,∀ ξ,0 ≤ w i ξ) (f : Lp ℂ 2 (volume : Measure E)) : + energy (fun ξ => ∑ i ∈ s,c i*w i ξ) f ≤ ∑ i ∈ s,c i*energy (w i) f := by + have hi i (h : i ∈ s) := (integrable_energy (w i) (hw i h) (hn i h) f).const_mul (c i) + have hw' : AEStronglyMeasurable (fun ξ => ∑ i ∈ s,c i*w i ξ) volume := + s.aestronglyMeasurable_fun_sum fun i hi => (hw i hi).const_mul (c i) + have hn' ξ : 0 ≤ ∑ i ∈ s,c i*w i ξ := Finset.sum_nonneg fun i hi => + mul_nonneg (le_trans zero_le_one (hc i hi)) (hn i hi ξ) + have he : (∑ i ∈ s,c i*energy (w i) f) = + ∫ ξ,∑ i ∈ s,c i*(loss (w i ξ)*‖(𝓕 f) ξ‖^2) := by + rw [integral_finsetSum s hi] + apply Finset.sum_congr rfl + intro i _ + exact (integral_const_mul _ _).symm + rw [he] + apply integral_mono (integrable_energy _ hw' hn' f) (integrable_finsetSum s hi) + intro ξ + simpa only [← mul_assoc,← Finset.sum_mul] using + mul_le_mul_of_nonneg_right (loss_sum_dilate_le s c (fun i => w i ξ) hc + (fun i hi => hn i hi ξ)) (sq_nonneg ‖(𝓕 f) ξ‖) + +lemma norm_representative_energy_le (f : Lp ℂ 2 (volume : Measure E)) + (g : E → ℝ) (hg : MemLp g 2 volume) (he : g =ᵐ[volume] fun x => ‖f x‖) + (A : F →L[ℝ] E) : energy (gaussianSymbol A) (complexLp g hg) ≤ energy (gaussianSymbol A) f := by + rw [← realEnergy_eq,gaussian_energy_difference] + apply mul_le_mul_of_nonneg_left _ (by norm_num) + exact integral_mono (realDistance_integrable g hg A _) (integrable_difference_sq A _ f) + (fun z => norm_representative_distance_le f g hg he _) + +end Energy +namespace Diagonal +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma directionalSymbol_single (i : ι) : directionalSymbol (EuclideanSpace.single i (1:ℝ))=coordSymbol i := by + ext ξ + simp only [directionalSymbol,coordSymbol,EuclideanSpace.inner_single_left,map_one,one_mul] + +omit [DecidableEq ι] in +lemma symbol_scaled_sum (v : ι → ℝ≥0) (t : ℝ) : + (fun ξ => t*GaussianKernel.symbol v ξ) = fun ξ => ∑ i,(t*(v i:ℝ)/2)*coordSymbol i ξ := by + ext ξ + unfold GaussianKernel.symbol coordSymbol + rw [← mul_div_assoc, Finset.mul_sum, Finset.sum_div] + apply Finset.sum_congr rfl + intro i _ + ring + +omit [DecidableEq ι] in +lemma energy_weighted_le (v : ι → ℝ≥0) {η t : ℝ} (hη : 0 < η) + (hηt : ∀ i,η ≤ t*(v i:ℝ)/2) (f : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι))) : + energy (fun ξ => t*GaussianKernel.symbol v ξ) f ≤ + ∑ i,(t*(v i:ℝ)/(2*η))*energy (fun ξ => η*coordSymbol i ξ) f := by + have he : (fun ξ => t*GaussianKernel.symbol v ξ) = + fun ξ => ∑ i,(t*(v i:ℝ)/(2*η))*(η*coordSymbol i ξ) := by + rw [symbol_scaled_sum] + ext ξ + apply Finset.sum_congr rfl + intro i _ + field_simp + rw [he] + apply energy_sum_dilate_le + · intro i _ + rw [le_div_iff₀ (by positivity : 0 < 2*η)] + linarith [hηt i] + · intro i _ + exact ((coordSymbol_continuous i).const_mul η).aestronglyMeasurable + · intro i _ ξ + exact mul_nonneg hη.le (coordSymbol_nonneg i ξ) + +lemma norm_representative_diagonal_energy_le (v : ι → ℝ≥0) + (f : Lp ℂ 2 (volume : Measure (EuclideanSpace ℝ ι))) (g : EuclideanSpace ℝ ι → ℝ) + (hg : MemLp g 2 volume) (he : g =ᵐ[volume] fun x => ‖f x‖) : + energy (GaussianKernel.symbol v) (complexLp g hg) ≤ energy (GaussianKernel.symbol v) f := by + rw [← GaussianKernel.symbol_eq] + exact norm_representative_energy_le f g hg he _ + +end Diagonal +end HeatL2 + +end + +section + +open MeasureTheory Set +open scoped ENNReal NNReal +namespace HeatL2.Diagonal +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma simultaneous_real_density {D : Set (EuclideanSpace ℝ ι)} {hD : MeasurableSet D} + {c η ε : ℝ} (hB : Bound D hD c) (hη : 0 < η) (hε : 0 < ε) : + ∃ f : EuclideanSpace ℝ ι → ℝ, Measurable f ∧ (∀ x,0 ≤ f x) ∧ + (∀ x,x ∉ D → f x=0) ∧ ∃ hf : MemLp f 2 volume, + (∫ x,f x^2)=1 ∧ ∀ i,energy (fun ξ => η*coordSymbol i ξ) (complexLp f hf) < η*(c+ε) := by + obtain ⟨F,hF,hFn,hFe⟩ := simultaneous_coordinate_energy hB hη hε + let f := nonnegRepresentative D hD F + have hf := nonnegRepresentative_memLp D hD F hF + refine ⟨f,nonnegRepresentative_measurable D hD F,nonnegRepresentative_nonneg D hD F, + fun x hx => nonnegRepresentative_zero D hD F hx,hf,?_,?_⟩ + · rw [nonnegRepresentative_square D hD F hF,hFn,one_pow] + · intro i + let ηn : ℝ≥0 := ⟨η,hη.le⟩ + have hh := norm_representative_diagonal_energy_le (Pi.single i (2*ηn)) F f hf + (nonnegRepresentative_ae D hD F hF) + rw [symbol_single i ηn] at hh + exact hh.trans_lt (hFe i) + +lemma real_coordinate_distance {f : EuclideanSpace ℝ ι → ℝ} (hf : MemLp f 2 volume) + {η ε : ℝ} (hη : 0 < η) (hη1 : η ≤ 1/4) (hε : ε ≤ 1/10000) + (hEn : ∀ i,energy (fun ξ => η*coordSymbol i ξ) (complexLp f hf) ≤ η*((1/10000)+ε)) + (j : ι) {r t : ℝ} (hr : r ∈ Ioo (-(5/2:ℝ)) (5/2)) (ht : t ∈ Ioo (-(5/2:ℝ)) (5/2)) : + realDistance f ((r-t) • EuclideanSpace.single j 1) ≤ 3/500 := by + rw [realDistance_eq f hf] + have hh := directional_translate_bound (EuclideanSpace.single j (1:ℝ)) (r-t) η hη (complexLp f hf) + rw [directionalSymbol_single] at hh + have hnn : 0 ≤ ((r-t)^2+4*η)/η := div_nonneg (by positivity) hη.le + have he := mul_le_mul_of_nonneg_left (hEn j) hnn + have heq : (((r-t)^2+4*η)/η)*(η*((1/10000)+ε)) = ((r-t)^2+4*η)*((1/10000)+ε) := by + field_simp + rw [heq] at he + apply hh.trans (he.trans ?_) + have hd : (r-t)^2 ≤ 25 := by + have hx : -(5:ℝ) ≤ r-t ∧ r-t ≤ 5 := by constructor <;> linarith [hr.1,hr.2,ht.1,ht.2] + nlinarith [sq_nonneg (r-t+5),sq_nonneg (r-t-5)] + have hA : (r-t)^2+4*η ≤ 26 := by linarith + have hB : (1/10000:ℝ)+ε ≤ 1/5000 := by linarith + have hmul := mul_le_mul_of_nonneg_left hB (by positivity : 0 ≤ (r-t)^2+4*η) + nlinarith + +omit [DecidableEq ι] in +lemma energy_weighted_density {f : EuclideanSpace ℝ ι → ℝ} (hf : MemLp f 2 volume) + {η c t : ℝ} (hη : 0 < η) (v : ι → ℝ≥0) (ht : 0 ≤ t) + (hηt : ∀ i,η ≤ t*(v i:ℝ)/2) + (hE : ∀ i,energy (fun ξ => η*coordSymbol i ξ) (complexLp f hf) ≤ η*c) : + energy (fun ξ => t*GaussianKernel.symbol v ξ) (complexLp f hf) ≤ (t*c/2)*∑ i,(v i:ℝ) := by + classical + apply (energy_weighted_le v hη hηt _).trans + calc + (∑ i,t*(v i:ℝ)/(2*η)*energy (fun ξ => η*coordSymbol i ξ) (complexLp f hf)) ≤ + ∑ i,t*(v i:ℝ)/(2*η)*(η*c) := Finset.sum_le_sum fun i _ => + mul_le_mul_of_nonneg_left (hE i) (by positivity) + _ = (t*c/2)*∑ i,(v i:ℝ) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + field_simp + +omit [DecidableEq ι] in +lemma exists_coordinate_time (v : ι → ℝ≥0) (hv : ∀ i,0 < v i) {t : ℝ} (ht : 0 < t) : + ∃ η : ℝ,0 < η ∧ η ≤ 1/4 ∧ ∀ i,η ≤ t*(v i:ℝ)/2 := by + have hh : ∀ s : Finset ι,∃ η : ℝ,0 < η ∧ η ≤ 1/4 ∧ ∀ i ∈ s,η ≤ t*(v i:ℝ)/2 := by + intro s + classical + induction s using Finset.induction_on with + | empty => exact ⟨1/4,by norm_num,le_rfl,by simp⟩ + | @insert i s hi ih => + obtain ⟨η,hη,hη1,hηs⟩ := ih + have hvi : (0:ℝ) < v i := hv i + refine ⟨min η (t*(v i:ℝ)/2),lt_min hη (by positivity), + (min_le_left _ _).trans hη1,?_⟩ + intro j hj + rcases Finset.mem_insert.mp hj with rfl | hj + · exact min_le_right _ _ + · exact (min_le_left _ _).trans (hηs j hj) + obtain ⟨η,hη,hη1,hηs⟩ := hh Finset.univ + exact ⟨η,hη,hη1,fun i => hηs i (Finset.mem_univ i)⟩ + +end HeatL2.Diagonal + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/SigningData.lean b/lean/OAI/Analysis/Steinitz/SigningData.lean new file mode 100644 index 0000000000000000000000000000000000000000..abf2cbb2c4465cd1e41e2676a8c6e29bf7a15cae --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/SigningData.lean @@ -0,0 +1,225 @@ +import OAI.Analysis.Steinitz.FilteredBody + +namespace OAI + +/-! Normalized predictors and backward-forward shifted walks. -/ + +section + +open Matrix GaussianTail +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +variable {ι ν : Type*} [Fintype ι] [DecidableEq ι] [Fintype ν] [DecidableEq ν] + +noncomputable def initialMatrix (ι ν : Type*) [DecidableEq ι] : Matrix ι (ι⊕ν) ℝ := Matrix.fromCols 1 0 +omit [DecidableEq ν] in +lemma initialMatrix_coisometry : initialMatrix ι ν*(initialMatrix ι ν).transpose=1 := by + simp [initialMatrix,Matrix.transpose_fromCols,Matrix.fromCols_mul_fromRows] +lemma initialMatrix_eval (x : EuclideanSpace ℝ (ι⊕ν)) (hx : ∀ i,x (Sum.inl i)=0) : + matrixMap (initialMatrix ι ν) x=0 := by + apply WithLp.ofLp_injective + change (Matrix.fromCols 1 0)*ᵥx=0 + simp only [Matrix.fromCols_mulVec,Matrix.one_mulVec,Matrix.zero_mulVec,add_zero] + exact funext hx + +noncomputable def familySteps {n : ℕ} (b : Fin n → ι → ℝ) : List (Step ι (ι⊕Fin n)) := + List.ofFn (fun i => symmetricStep (b i) (Sum.inr i)) +noncomputable def familyPredictor {n : ℕ} (b : Fin n → ι → ℝ) (i : Fin n) : ι⊕Fin n → ℝ := + noiseRow ((predictorRows (initialMatrix ι (Fin n)) (familySteps b))[i.val]' + (by rw [predictorRows_length]; simpa only [familySteps,List.length_ofFn] using i.isLt)) + +lemma familySteps_good {n : ℕ} {b : Fin n → ι → ℝ} (hb : ∀ i,vectorMass (b i)<1) : + ∀ p∈familySteps b,p.Good := by + intro p hp + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hp + exact symmetricStep_good (hb i) _ +lemma familySteps_symmetric {n : ℕ} (b : Fin n → ι → ℝ) : + ∀ p∈familySteps b,p.C=symmetricContraction p.b := by + intro p hp + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hp + rfl +lemma familySteps_mass {n : ℕ} {b : Fin n → ι → ℝ} {B : ℝ} (hb : ∀ i,vectorMass (b i)≤B) : + ∀ p∈familySteps b,vectorMass p.b≤B := by + intro p hp + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hp + exact hb i +lemma familySteps_fresh {n : ℕ} (b : Fin n → ι → ℝ) : Fresh (initialMatrix ι (Fin n)) (familySteps b) := by + intro p hp k + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hp + simp [initialMatrix,symmetricStep] +lemma familySteps_nodup {n : ℕ} (b : Fin n → ι → ℝ) : ((familySteps b).map Step.j).Nodup := by + simpa only [familySteps,List.map_ofFn,Function.comp_def,symmetricStep] using + (List.nodup_ofFn.mpr (Sum.inr_injective : Function.Injective (Sum.inr : Fin n → ι⊕Fin n))) + +lemma familyPredictor_form {n : ℕ} (b : Fin n → ι → ℝ) (i : Fin n) : + familyPredictor b i=noiseRow (rawRow (run (initialMatrix ι (Fin n)) ((familySteps b).take i.val)) (b i)) := by + unfold familyPredictor + rw [predictorRows_get _ _ _ (by simpa only [familySteps,List.length_ofFn] using i.isLt)] + simp only [familySteps,List.getElem_ofFn,symmetricStep] + +lemma familyPredictor_future {n : ℕ} (b : Fin n → ι → ℝ) (i l : Fin n) (hil : i≤l) : + familyPredictor b i (Sum.inr l)=0 := by + have hh := predictor_future_zero (familySteps_fresh b) (familySteps_nodup b) i.val l.val hil + (by simpa only [familySteps,List.length_ofFn] using l.isLt) + simpa only [familyPredictor,noiseRow,Sum.elim_inr,familySteps,List.getElem_ofFn,symmetricStep] using hh + +lemma familyPredictor_mass {n : ℕ} {b : Fin n → ι → ℝ} (hb : ∀ i,vectorMass (b i)<1) (i : Fin n) : + vectorMass (familyPredictor b i)≤vectorMass (b i) := by + apply (noiseRow_mass _).trans + have hh := predictor_row_bound (initialMatrix_coisometry (ι := ι) (ν := Fin n)) + (familySteps_good hb) (familySteps_fresh b) (familySteps_nodup b) i.val + (by simpa only [familySteps,List.length_ofFn] using i.isLt) + simpa only [familySteps,List.getElem_ofFn,symmetricStep] using hh + +lemma sum_getElem_of_length {α : Type*} (L : List α) {n : ℕ} (hL : L.length=n) (f : α → ℝ) : + (∑ i : Fin n,f (L[i.val]'(by omega)))=(L.map f).sum := by + subst n + rw [← List.sum_ofFn,List.ofFn_getElem_eq_map] + +lemma familyPredictor_column {n : ℕ} {b : Fin n → ι → ℝ} (hb : ∀ i,vectorMass (b i)<1) + {B : ℝ} (hB : 0≤B) (hbB : ∀ i,vectorMass (b i)≤B) (k : ι⊕Fin n) : + (∑ i,(familyPredictor b i k)^2)≤B := by + cases k with + | inl k => simpa only [familyPredictor,noiseRow,Sum.elim_inl,zero_pow (by norm_num : 2≠0),Finset.sum_const_zero] using hB + | inr k => + have hh := predictor_column_bound (familySteps_symmetric b) (familySteps_mass (fun i => (hb i).le)) + (familySteps_fresh b) (familySteps_nodup b) hB (familySteps_mass hbB) (Sum.inr k) + (by intro i; simp [initialMatrix]) + have hlen : (predictorRows (initialMatrix ι (Fin n)) (familySteps b)).length=n := by + rw [predictorRows_length]; simp [familySteps] + simpa only [familyPredictor,noiseRow,Sum.elim_inr,sum_getElem_of_length _ hlen (fun m => m (Sum.inr k)^2)] using hh + +noncomputable def signingScale : ℝ := 1/(8*bodyScale*GaussianAR.slabRadius) +lemma signingScale_pos : 0 < signingScale := div_pos (by norm_num) (mul_pos (mul_pos (by norm_num) bodyScale_pos) GaussianAR.slabRadius_pos) +lemma signingScale_lt_one : signingScale<1 := by + unfold signingScale + apply (div_lt_one (mul_pos (mul_pos (by norm_num) bodyScale_pos) GaussianAR.slabRadius_pos)).mpr + have hs : 1≤GaussianAR.slabRadius := by norm_num [GaussianAR.slabRadius] + nlinarith [bodyScale_ge_one] +lemma signingScale_cancel : 2*bodyScale*GaussianAR.slabRadius*signingScale=1/4 := by + unfold signingScale + field_simp [bodyScale_pos.ne',GaussianAR.slabRadius_pos.ne'] + ring + +noncomputable def normalizedPredictor {n : ℕ} (b : Fin n → ι → ℝ) (i : Fin n) : Matrix Unit (ι⊕Fin n) ℝ := + fun _ k => familyPredictor b i k / signingScale + +lemma normalizedPredictor_mass {n : ℕ} {b : Fin n → ι → ℝ} + (hb : ∀ i,vectorMass (b i)≤ signingScale^2) (i : Fin n) : squareMass (normalizedPredictor b i)≤1 := by + have hlt : ∀ i,vectorMass (b i)<1 := fun i => (hb i).trans_lt (by nlinarith [signingScale_pos,signingScale_lt_one]) + change (∑ _ : Unit,∑ k,(familyPredictor b i k/signingScale)^2)≤1 + simp only [Fintype.sum_unique,div_pow,← Finset.sum_div] + apply (div_le_one (sq_pos_of_pos signingScale_pos)).mpr + exact (familyPredictor_mass hlt i).trans (hb i) + +lemma normalizedPredictor_column {n : ℕ} {b : Fin n → ι → ℝ} + (hb : ∀ i,vectorMass (b i)≤ signingScale^2) (k : ι⊕Fin n) : + (∑ i,(normalizedPredictor b i () k)^2)≤1 := by + have hlt : ∀ i,vectorMass (b i)<1 := fun i => (hb i).trans_lt (by nlinarith [signingScale_pos,signingScale_lt_one]) + simp only [normalizedPredictor,div_pow,← Finset.sum_div] + apply (div_le_one (sq_pos_of_pos signingScale_pos)).mpr + exact familyPredictor_column hlt (sq_nonneg _) hb k + +lemma normalizedPredictor_norm {n : ℕ} (b : Fin n → ι → ℝ) (i : Fin n) (x : EuclideanSpace ℝ (ι⊕Fin n)) : + ‖matrixMap (normalizedPredictor b i) x‖=|rowMap (familyPredictor b i) x|/signingScale := by + change ‖matrixMap (fun _ : Unit => fun k => familyPredictor b i k/signingScale) x‖=_ + rw [rowMatrix_norm,rowMap_apply,rowMap_apply] + simp only [dotProduct,div_mul_eq_mul_div,← Finset.sum_div,abs_div,abs_of_pos signingScale_pos] + +end EuclideanSteinitz.Filter + +end + +section + +open MeasureTheory Set +namespace ShiftedSections +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def clip (u : ℝ) : ℝ := max (-(1/4)) (min u (1/4)) +lemma clip_bound (u : ℝ) : |clip u|≤1/4 := by + rw [abs_le] + exact ⟨le_max_left _ _,max_le (by norm_num) (min_le_right _ _)⟩ +lemma clip_eq {u : ℝ} (hu : |u|<1/4) : clip u=u := by + obtain ⟨hl,hr⟩ := abs_lt.mp hu + rw [clip,min_eq_left hr.le,max_eq_right hl.le] + +omit [Fintype ι] in +lemma walk_linear_invariant {n : ℕ} (j : Fin n → ι) (q : Fin n → Coeff (ι := ι) → ℝ) + (ε : Fin n → ℝ) (x : Coeff (ι := ι)) (f : Coeff (ι := ι) →L[ℝ] ℝ) + (hf : ∀ i,f (EuclideanSpace.single (j i) 1)=0) : f (walk j q ε x)=f x := by + induction n generalizing x with + | zero => rfl + | succ n ih => + rw [walk,ih (fun i => j i.succ) (fun i => q i.succ) (fun i => ε i.succ) _ (fun i => hf i.succ)] + simp only [map_add,map_smul,hf 0,smul_zero,add_zero] + +omit [Fintype ι] in +lemma walk_coordinate_outside {n : ℕ} (j : Fin n → ι) (q : Fin n → Coeff (ι := ι) → ℝ) + (ε : Fin n → ℝ) (x : Coeff (ι := ι)) (k : ι) (hk : ∀ i,k≠j i) : + (walk j q ε x) k=x k := by + exact walk_linear_invariant j q ε x (EuclideanSpace.proj k) (by intro i; simp [hk i]) + +omit [Fintype ι] in +lemma walk_coordinate_equations {n : ℕ} (j : Fin n → ι) (hj : Function.Injective j) + (m : Fin n → Coeff (ι := ι) →L[ℝ] ℝ) + (hm : ∀ i l : Fin n,i≤l → m i (EuclideanSpace.single (j l) 1)=0) + (ε : Fin n → ℝ) (x : Coeff (ι := ι)) : + ∀ i,(walk j (fun i y => clip (m i y)) ε x) (j i)=x (j i)+clip (m i (walk j (fun i y => clip (m i y)) ε x))+ε i := by + induction n generalizing x with + | zero => intro i; exact i.elim0 + | succ n ih => + let jt := fun i : Fin n => j i.succ + let mt := fun i : Fin n => m i.succ + let et := fun i : Fin n => ε i.succ + let x' := x+(clip (m 0 x)+ε 0) • EuclideanSpace.single (j 0) 1 + have htail : Function.Injective jt := fun i l h => Fin.succ_injective n (hj h) + have hmt : ∀ i l : Fin n,i≤l → mt i (EuclideanSpace.single (jt l) 1)=0 := + fun i l h => hm i.succ l.succ (Fin.succ_le_succ_iff.mpr h) + have hx0 : ∀ i : Fin n,j 0≠jt i := by + intro i he + exact Fin.succ_ne_zero i (hj he).symm + have hout := walk_coordinate_outside jt (fun i y => clip (mt i y)) et x' (j 0) hx0 + have hinv := walk_linear_invariant jt (fun i y => clip (mt i y)) et x' (m 0) + (fun i => hm 0 i.succ (Fin.zero_le _)) + have hzero : m 0 x'=m 0 x := by + simp only [x',map_add,map_smul,hm 0 0 le_rfl,smul_zero,add_zero] + have hrec := ih jt htail mt hmt et x' + intro i + refine Fin.cases ?_ (fun i => ?_) i + · change (walk jt (fun i y => clip (mt i y)) et x') (j 0) = _ + rw [hout] + change x' (j 0)=x (j 0)+clip (m 0 (walk jt (fun i y => clip (mt i y)) et x'))+ε 0 + rw [hinv,hzero] + simp only [x',PiLp.add_apply,PiLp.smul_apply,PiLp.single_apply,ite_true,smul_eq_mul,mul_one] + ring + · change (walk jt (fun i y => clip (mt i y)) et x') (jt i)= _ + rw [hrec i] + have he : x' (jt i)=x (j i.succ) := by + simp only [x',PiLp.add_apply,PiLp.smul_apply,PiLp.single_apply,ite_eq_right (Ne.symm (hx0 i)),smul_eq_mul,mul_zero,add_zero] + rfl + rw [he] + rfl + +lemma adaptive_linear_equations {n : ℕ} (j : Fin n → ι) (hj : Function.Injective j) + (m : Fin n → Coeff (ι := ι) →L[ℝ] ℝ) + (hm : ∀ i l : Fin n,i≤l → m i (EuclideanSpace.single (j l) 1)=0) + {K : Set (Coeff (ι := ι))} (hK : Good K) (hslab : ∀ x∈K,∀ i,|m i x|<1/4) : + ∃ ε : Fin n → ℝ,∃ x : Coeff (ι := ι), + (∀ i,ε i = -1 ∨ ε i=1) ∧ x∈K ∧ + (∀ k,(∀ i,k≠j i) → x k=0) ∧ (∀ i,x (j i)=m i x+ε i) := by + obtain ⟨ε,hε,hx⟩ := adaptive_signs j (fun i y => clip (m i y)) (fun i y => clip_bound _) hK + let x := walk j (fun i y => clip (m i y)) ε 0 + refine ⟨ε,x,hε,hx,?_,?_⟩ + · intro k hk + exact walk_coordinate_outside j (fun i y => clip (m i y)) ε 0 k hk + · intro i + have hh := walk_coordinate_equations j hj m hm ε 0 i + change x (j i)=(0:Coeff) (j i)+clip (m i x)+ε i at hh + simpa only [PiLp.zero_apply,zero_add,clip_eq (hslab x hx i)] using hh + +end ShiftedSections + +end + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Spectral.lean b/lean/OAI/Analysis/Steinitz/Spectral.lean new file mode 100644 index 0000000000000000000000000000000000000000..b50a222a24cef96dc146fdcc63ac4f09a2f6216b --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Spectral.lean @@ -0,0 +1,407 @@ +import OAI.Analysis.Steinitz.MatrixEnergy + +namespace OAI + +/-! Real spectral calculus and noncommuting matrix inequalities. -/ + +namespace EuclideanSteinitz.Spectral +open Matrix +open scoped MatrixOrder + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma unitary_transpose_mul (U : unitaryGroup ι ℝ) : + (U : Matrix ι ι ℝ).transpose * U = 1 := by + simpa only [star_eq_conjTranspose, conjTranspose_eq_transpose_of_trivial] using + Unitary.coe_star_mul_self U + +lemma unitary_mul_transpose (U : unitaryGroup ι ℝ) : + (U : Matrix ι ι ℝ) * (U : Matrix ι ι ℝ).transpose = 1 := by + simpa only [Unitary.coe_star, star_eq_conjTranspose, + conjTranspose_eq_transpose_of_trivial] using Unitary.coe_mul_star_self U + +lemma real_spectral {A : Matrix ι ι ℝ} (hA : A.IsHermitian) : + A = (hA.eigenvectorUnitary : Matrix ι ι ℝ) * diagonal hA.eigenvalues * + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose := by + simpa only [Unitary.conjStarAlgAut_apply, star_eq_conjTranspose, + conjTranspose_eq_transpose_of_trivial, RCLike.ofReal_real_eq_id, id_eq, Function.comp_def] + using hA.spectral_theorem + +lemma real_cfc {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (f : ℝ → ℝ) : + cfc f A = (hA.eigenvectorUnitary : Matrix ι ι ℝ) * + diagonal (fun i => f (hA.eigenvalues i)) * + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose := by + rw [hA.cfc_eq, Matrix.IsHermitian.cfc] + simp only [Unitary.conjStarAlgAut_apply, star_eq_conjTranspose, + conjTranspose_eq_transpose_of_trivial, RCLike.ofReal_real_eq_id, id_eq, Function.comp_def] + +lemma trace_cfc {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (f : ℝ → ℝ) : + (cfc f A).trace = ∑ i, f (hA.eigenvalues i) := by + rw [real_cfc hA f, trace_mul_cycle, unitary_transpose_mul, one_mul, trace_diagonal] + +lemma trace_spectral {A : Matrix ι ι ℝ} (hA : A.IsHermitian) : + A.trace = ∑ i, hA.eigenvalues i := by + conv_lhs => rw [real_spectral hA] + rw [trace_mul_cycle, unitary_transpose_mul, one_mul, trace_diagonal] + +lemma trace_conjugate (U : unitaryGroup ι ℝ) (A : Matrix ι ι ℝ) : + ((U : Matrix ι ι ℝ) * A * (U : Matrix ι ι ℝ).transpose).trace = A.trace := by + rw [trace_mul_cycle, unitary_transpose_mul, one_mul] + +lemma trace_transpose_conjugate (U : unitaryGroup ι ℝ) (A : Matrix ι ι ℝ) : + ((U : Matrix ι ι ℝ).transpose * A * U).trace = A.trace := by + rw [trace_mul_cycle, unitary_mul_transpose, one_mul] + +lemma sum_row_squares (U : unitaryGroup ι ℝ) (i : ι) : + ∑ j, (U i j) ^ 2 = 1 := by + have h := congr_fun (congr_fun (unitary_mul_transpose U) i) i + simpa only [Matrix.mul_apply, transpose_apply, Matrix.one_apply_eq, sq] using h + +lemma sum_col_squares (U : unitaryGroup ι ℝ) (j : ι) : + ∑ i, (U i j) ^ 2 = 1 := by + have h := congr_fun (congr_fun (unitary_transpose_mul U) j) j + simpa only [Matrix.mul_apply, transpose_apply, Matrix.one_apply_eq, sq] using h + +lemma orthostochastic_sums (U : unitaryGroup ι ℝ) : + (∀ i, ∑ j, (U i j) ^ 2 = 1) ∧ (∀ j, ∑ i, (U i j) ^ 2 = 1) := + ⟨sum_row_squares U, sum_col_squares U⟩ + +noncomputable def overlapBasis {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) : unitaryGroup ι ℝ := + star hA.eigenvectorUnitary * hB.eigenvectorUnitary + +lemma overlapBasis_coe {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) : + (overlapBasis hA hB : Matrix ι ι ℝ) = + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * hB.eigenvectorUnitary := by + simp only [overlapBasis, Submonoid.coe_mul, Unitary.coe_star, star_eq_conjTranspose, + conjTranspose_eq_transpose_of_trivial] + +lemma cfc_mixed_basis {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (f g : ℝ → ℝ) : + (hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * (cfc f A - cfc g B) * + hB.eigenvectorUnitary = + diagonal (fun i => f (hA.eigenvalues i)) * overlapBasis hA hB - + (overlapBasis hA hB : Matrix ι ι ℝ) * diagonal (fun j => g (hB.eigenvalues j)) := by + rw [Matrix.mul_sub, Matrix.sub_mul, real_cfc hA f, real_cfc hB g, overlapBasis_coe] + simp only [← Matrix.mul_assoc, unitary_transpose_mul, Matrix.one_mul] + simp only [Matrix.mul_assoc, unitary_transpose_mul, Matrix.mul_one] + +lemma cfc_mixed_basis_apply {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (f g : ℝ → ℝ) (i j : ι) : + ((hA.eigenvectorUnitary : Matrix ι ι ℝ).transpose * (cfc f A - cfc g B) * + hB.eigenvectorUnitary) i j = + (f (hA.eigenvalues i) - g (hB.eigenvalues j)) * overlapBasis hA hB i j := by + rw [cfc_mixed_basis, Matrix.sub_apply, diagonal_mul, mul_diagonal] + ring + +omit [DecidableEq ι] in +lemma trace_sandwich_diagonal {κ : Type*} [Fintype κ] [DecidableEq κ] + (D : Matrix ι κ ℝ) (w : κ → ℝ) : + (D * diagonal w * D.transpose).trace = ∑ i, ∑ j, w j * (D i j) ^ 2 := by + simp only [Matrix.trace, Matrix.diag] + simp_rw [mul_apply (M := D * diagonal w), mul_diagonal, transpose_apply] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma trace_weighted_basis {κ : Type*} [Fintype κ] [DecidableEq κ] + (U : unitaryGroup ι ℝ) (V : unitaryGroup κ ℝ) + (D : Matrix ι κ ℝ) (w : κ → ℝ) : + (D * ((V : Matrix κ κ ℝ) * diagonal w * (V : Matrix κ κ ℝ).transpose) * + D.transpose).trace = + ∑ i, ∑ j, w j * ((U : Matrix ι ι ℝ).transpose * D * (V : Matrix κ κ ℝ)) i j ^ 2 := by + rw [← trace_sandwich_diagonal, Matrix.transpose_mul, Matrix.transpose_mul, + Matrix.transpose_transpose] + rw [← trace_transpose_conjugate U + (D * ((V : Matrix κ κ ℝ) * diagonal w * (V : Matrix κ κ ℝ).transpose) * + D.transpose)] + simp only [Matrix.mul_assoc] + +lemma weighted_cfc_distance {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (f g w : ℝ → ℝ) : + ((cfc f A - cfc g B) * cfc w B * (cfc f A - cfc g B).transpose).trace = + ∑ i, ∑ j, (overlapBasis hA hB i j) ^ 2 * w (hB.eigenvalues j) * + (f (hA.eigenvalues i) - g (hB.eigenvalues j)) ^ 2 := by + rw [real_cfc hB w, trace_weighted_basis hA.eigenvectorUnitary hB.eigenvectorUnitary] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + rw [cfc_mixed_basis_apply] + ring + +lemma trace_diagonal_product (M : Matrix ι ι ℝ) (a b : ι → ℝ) : + (diagonal a * M * diagonal b * M.transpose).trace = + ∑ i, ∑ j, a i * b j * (M i j) ^ 2 := by + simp only [Matrix.trace, Matrix.diag] + simp_rw [mul_apply (M := diagonal a * M * diagonal b), mul_diagonal, + diagonal_mul, transpose_apply] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma trace_cfc_product {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (f g : ℝ → ℝ) : + (cfc f A * cfc g B).trace = ∑ i, ∑ j, + (overlapBasis hA hB i j) ^ 2 * f (hA.eigenvalues i) * g (hB.eigenvalues j) := by + rw [real_cfc hA f, real_cfc hB g] + calc + _ = (diagonal (fun i => f (hA.eigenvalues i)) * + (overlapBasis hA hB : Matrix ι ι ℝ) * + diagonal (fun j => g (hB.eigenvalues j)) * + (overlapBasis hA hB : Matrix ι ι ℝ).transpose).trace := by + rw [overlapBasis_coe, Matrix.transpose_mul, Matrix.transpose_transpose] + simp only [Matrix.mul_assoc] + rw [trace_mul_comm (hA.eigenvectorUnitary : Matrix ι ι ℝ)] + simp only [Matrix.mul_assoc] + _ = _ := by + rw [trace_diagonal_product] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma overlap_sum_left (U : unitaryGroup ι ℝ) (f : ι → ℝ) : + (∑ i, ∑ j, (U i j) ^ 2 * f i) = ∑ i, f i := by + simp only [← Finset.sum_mul, sum_row_squares, one_mul] + +lemma overlap_sum_right (U : unitaryGroup ι ℝ) (g : ι → ℝ) : + (∑ i, ∑ j, (U i j) ^ 2 * g j) = ∑ j, g j := by + rw [Finset.sum_comm] + simp only [← Finset.sum_mul, sum_col_squares, one_mul] + +lemma trace_cfc_remainder {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (f f' : ℝ → ℝ) : + (cfc f A).trace - (cfc f B).trace - (cfc f' B * (A - B)).trace = + ∑ i, ∑ j, (overlapBasis hA hB i j) ^ 2 * + (f (hA.eigenvalues i) - f (hB.eigenvalues j) - + f' (hB.eigenvalues j) * (hA.eigenvalues i - hB.eigenvalues j)) := by + have hprod := trace_cfc_product hA hB id f' + rw [cfc_id ℝ A hA.isSelfAdjoint] at hprod + rw [Matrix.mul_sub, Matrix.trace_sub, + Matrix.trace_mul_comm (cfc f' B) A, hprod] + have hs : (cfc f' B * B).trace = ∑ j, f' (hB.eigenvalues j) * hB.eigenvalues j := by + calc + _ = (cfc f' B * cfc (id : ℝ → ℝ) B).trace := by + rw [cfc_id ℝ B hB.isSelfAdjoint] + _ = _ := by + have hf : ContinuousOn f' (spectrum ℝ B) := by + rw [continuousOn_iff_continuous_domRestrict] + fun_prop + rw [← cfc_mul f' id B hf continuousOn_id, trace_cfc hB] + rfl + rw [hs, trace_cfc hA, trace_cfc hB] + conv_lhs => + arg 1 + arg 1 + rw [← overlap_sum_left (overlapBasis hA hB) (fun i => f (hA.eigenvalues i))] + rw [← overlap_sum_right (overlapBasis hA hB) (fun j => f (hB.eigenvalues j)), + ← overlap_sum_right (overlapBasis hA hB) + (fun j => f' (hB.eigenvalues j) * hB.eigenvalues j)] + simp only [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + simp only [id_eq] + ring + +omit [Fintype ι] [DecidableEq ι] in +lemma convex_tangent {S : Set ℝ} {f : ℝ → ℝ} {x y d : ℝ} + (hf : ConvexOn ℝ S f) (hx : x ∈ S) (hy : y ∈ S) + (hd : HasDerivWithinAt f d S y) : d * (x - y) ≤ f x - f y := by + rcases lt_trichotomy x y with h | rfl | h + · have hs := hf.slope_le_of_hasDerivWithinAt hx hy h hd + rw [slope_def_field, div_le_iff₀ (sub_pos.mpr h)] at hs + nlinarith + · simp + · have hs := hf.le_slope_of_hasDerivWithinAt hy hx h hd + rwa [slope_def_field, le_div_iff₀ (sub_pos.mpr h)] at hs + +lemma trace_tangent_le {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (f f' : ℝ → ℝ) + {S : Set ℝ} (hAS : ∀ i, hA.eigenvalues i ∈ S) + (hBS : ∀ j, hB.eigenvalues j ∈ S) + (htan : ∀ x ∈ S, ∀ y ∈ S, f' y * (x - y) ≤ f x - f y) : + (cfc f' B * (A - B)).trace ≤ (cfc f A).trace - (cfc f B).trace := by + apply sub_nonneg.mp + rw [trace_cfc_remainder hA hB] + apply Finset.sum_nonneg + intro i _ + apply Finset.sum_nonneg + intro j _ + exact mul_nonneg (sq_nonneg _) (sub_nonneg.mpr (htan _ (hAS i) _ (hBS j))) + +omit [Fintype ι] [DecidableEq ι] in +lemma hasDerivWithinAt_of_tangents {p d : ℝ → ℝ} {T : Set ℝ} {t : ℝ} + (hd : ContinuousWithinAt d T t) + (hl : ∀ u ∈ T, d t * (u - t) ≤ p u - p t) + (hu : ∀ u ∈ T, p u - p t ≤ d u * (u - t)) : + HasDerivWithinAt p (d t) T t := by + rw [hasDerivWithinAt_iff_tendsto] + apply squeeze_zero' (Filter.Eventually.of_forall (fun u => by positivity)) + · filter_upwards [self_mem_nhdsWithin] with u hut + have hlo := hl u hut + have hup := hu u hut + have he : 0 ≤ p u - p t - (u - t) * d t := by linarith + have he' : p u - p t - (u - t) * d t ≤ (u - t) * (d u - d t) := by nlinarith + have hnorm : ‖p u - p t - (u - t) • d t‖ ≤ ‖u - t‖ * ‖d u - d t‖ := by + rw [smul_eq_mul, Real.norm_of_nonneg he, ← norm_mul] + exact he'.trans (le_abs_self _) + calc + _ ≤ ‖u - t‖⁻¹ * (‖u - t‖ * ‖d u - d t‖) := + mul_le_mul_of_nonneg_left hnorm (inv_nonneg.mpr (norm_nonneg _)) + _ ≤ ‖d u - d t‖ := by + by_cases h : u = t + · simp [h] + · rw [← mul_assoc, inv_mul_cancel₀ (norm_ne_zero_iff.mpr (sub_ne_zero.mpr h)), one_mul] + · simpa only [sub_self, norm_zero] using (hd.tendsto.sub (tendsto_const_nhds : Filter.Tendsto + (fun _ : ℝ => d t) (nhdsWithin t T) (nhds (d t)))).norm + +open scoped Matrix.Norms.L2Operator in +lemma trace_cfc_affine_derivative {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) (f f' : ℝ → ℝ) + {T S : Set ℝ} {t : ℝ} (ht : t ∈ T) + (hS : ∀ u ∈ T, spectrum ℝ (A + u • H) ⊆ S) + (htan : ∀ x ∈ S, ∀ y ∈ S, f' y * (x - y) ≤ f x - f y) + (hc : ContinuousWithinAt (fun u : ℝ => cfc f' (A + u • H)) T t) : + HasDerivWithinAt (fun u : ℝ => (cfc f (A + u • H)).trace) + (cfc f' (A + t • H) * H).trace T t := by + have herm (u : ℝ) : (A + u • H).IsHermitian := + hA.add (hH.smul (IsSelfAdjoint.all u)) + have mem (u : ℝ) (hu : u ∈ T) (i : ι) : + (herm u).eigenvalues i ∈ S := hS u hu ((herm u).eigenvalues_mem_spectrum_real i) + have htrace : Continuous (Matrix.trace : Matrix ι ι ℝ → ℝ) := + (Matrix.traceLinearMap ι ℝ ℝ).continuous_of_finiteDimensional + have hc' : ContinuousWithinAt (fun u : ℝ => (cfc f' (A + u • H) * H).trace) T t := by + exact htrace.continuousAt.comp_continuousWithinAt (hc.mul continuousWithinAt_const) + apply hasDerivWithinAt_of_tangents hc' + · intro u hu + have h := trace_tangent_le (herm u) (herm t) f f' (mem u hu) (mem t ht) htan + have heq : A + u • H - (A + t • H) = (u - t) • H := by module + simpa only [heq, Matrix.mul_smul, Matrix.trace_smul, smul_eq_mul, mul_comm] using h + · intro u hu + have h := trace_tangent_le (herm t) (herm u) f f' (mem t ht) (mem u hu) htan + have heq : A + t • H - (A + u • H) = (t - u) • H := by module + simp only [heq, Matrix.mul_smul, Matrix.trace_smul, smul_eq_mul] at h + nlinarith + +open scoped Matrix.Norms.L2Operator in +lemma continuous_cfc_affine {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) {f : ℝ → ℝ} (hf : Continuous f) : + Continuous (fun u : ℝ => cfc f (A + u • H)) := by + apply Continuous.cfc_of_mem_nhdsSet (s := Set.univ) f (by simp) + (continuous_const.add (continuous_id.smul continuous_const)) + (fun u => (hA.add (hH.smul (IsSelfAdjoint.all u))).isSelfAdjoint) hf.continuousOn + +open scoped Matrix.Norms.L2Operator in + +lemma trace_rpow_affine_derivative {A H : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hH : H.IsHermitian) {a : ℝ} (ha : 1 ≤ a) + {T : Set ℝ} {t : ℝ} (ht : t ∈ T) + (hpos : ∀ u ∈ T, (A + u • H).PosSemidef) : + HasDerivWithinAt (fun u : ℝ => (cfc (fun x : ℝ => x ^ a) (A + u • H)).trace) + (a * (cfc (fun x : ℝ => x ^ (a - 1)) (A + t • H) * H).trace) T t := by + have hf' : Continuous (fun x : ℝ => a * x ^ (a - 1)) := + continuous_const.mul (Real.continuous_rpow_const (sub_nonneg.mpr ha)) + have hd := trace_cfc_affine_derivative hA hH (fun x : ℝ => x ^ a) + (fun x : ℝ => a * x ^ (a - 1)) (S := Set.Ici 0) ht + (fun u hu x hx => spectrum_nonneg_of_nonneg (hpos u hu).nonneg hx) + (fun x hx y hy => convex_tangent (convexOn_rpow ha) hx hy + (Real.hasDerivAt_rpow_const (Or.inr ha)).hasDerivWithinAt) + (continuous_cfc_affine hA hH hf').continuousWithinAt + simpa only [cfc_const_mul a (fun x : ℝ => x ^ (a - 1)) _ + (Real.continuous_rpow_const (sub_nonneg.mpr ha)).continuousOn, + Matrix.smul_mul, Matrix.trace_smul, smul_eq_mul] using hd + +lemma trace_psd_pairing {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hB : B.PosSemidef) : 0 ≤ (A * B).trace := by + have hS : (CFC.sqrt A).IsHermitian := (CFC.sqrt_nonneg A).posSemidef.1 + have h := hB.conjTranspose_mul_mul_same (CFC.sqrt A) + rw [hS.eq] at h + have ht := h.trace_nonneg + rw [Matrix.trace_mul_cycle, ← sq, CFC.sq_sqrt A hA.nonneg] at ht + exact ht + +lemma trace_convex_monotone {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (hAB : A ≤ B) + (f f' : ℝ → ℝ) {S : Set ℝ} + (hAS : ∀ i, hA.eigenvalues i ∈ S) (hBS : ∀ i, hB.eigenvalues i ∈ S) + (hfp : ∀ y ∈ S, 0 ≤ f' y) + (htan : ∀ x ∈ S, ∀ y ∈ S, f' y * (x - y) ≤ f x - f y) : + (cfc f A).trace ≤ (cfc f B).trace := by + have hp : (cfc f' A).PosSemidef := by + apply Matrix.nonneg_iff_posSemidef.mp + apply cfc_nonneg + intro x hx + rw [hA.spectrum_real_eq_range_eigenvalues] at hx + obtain ⟨i, rfl⟩ := hx + exact hfp _ (hAS i) + have h := trace_tangent_le hB hA f f' hBS hAS htan + have h0 := trace_psd_pairing hp (Matrix.le_iff.mp hAB) + linarith + +lemma trace_rpow_monotone {A B : Matrix ι ι ℝ} + (hA : A.PosSemidef) (hB : B.PosSemidef) (hAB : A ≤ B) + {a : ℝ} (ha : 1 ≤ a) : + (cfc (fun x : ℝ => x ^ a) A).trace ≤ (cfc (fun x : ℝ => x ^ a) B).trace := by + apply trace_convex_monotone hA.1 hB.1 hAB _ (fun x => a * x ^ (a - 1)) + (S := Set.Ici 0) (fun i => hA.eigenvalues_nonneg i) (fun i => hB.eigenvalues_nonneg i) + · intro y hy + exact mul_nonneg (by linarith) (Real.rpow_nonneg hy _) + · intro x hx y hy + exact convex_tangent (convexOn_rpow ha) hx hy + (Real.hasDerivAt_rpow_const (Or.inr ha)).hasDerivWithinAt + +lemma trace_cfc_eq_of_charpoly {A B : Matrix ι ι ℝ} + (hA : A.IsHermitian) (hB : B.IsHermitian) (h : A.charpoly = B.charpoly) + (f : ℝ → ℝ) : (cfc f A).trace = (cfc f B).trace := by + rw [trace_cfc hA, trace_cfc hB, (hA.eigenvalues_eq_eigenvalues_iff hB).mpr h] + +lemma transpose_contraction {C : Matrix ι ι ℝ} (hC : C * C.transpose ≤ 1) : + C.transpose * C ≤ 1 := by + have h₁ : (C * C.transpose).IsHermitian := by + simpa only [conjTranspose_eq_transpose_of_trivial] using isHermitian_mul_conjTranspose_self C + have h₂ : (C.transpose * C).IsHermitian := by + simpa only [conjTranspose_eq_transpose_of_trivial] using isHermitian_conjTranspose_mul_self C + have heq := (h₂.eigenvalues_eq_eigenvalues_iff h₁).mpr (charpoly_mul_comm C.transpose C) + rw [CFC.le_one_iff (R := ℝ) _ h₂.isSelfAdjoint] + rw [CFC.le_one_iff (R := ℝ) _ h₁.isSelfAdjoint] at hC + intro x hx + rw [h₂.spectrum_real_eq_range_eigenvalues, heq, ← h₁.spectrum_real_eq_range_eigenvalues] at hx + exact hC x hx + +lemma trace_rpow_contraction {A C : Matrix ι ι ℝ} (hA : A.PosSemidef) + (hC : C * C.transpose ≤ 1) {a : ℝ} (ha : 1 ≤ a) : + (cfc (fun x : ℝ => x ^ a) (C * A * C.transpose)).trace ≤ + (cfc (fun x : ℝ => x ^ a) A).trace := by + let S := CFC.sqrt A + have hS : S.IsHermitian := (CFC.sqrt_nonneg A).posSemidef.1 + have hSS : S * S = A := by simpa only [← sq] using CFC.sq_sqrt A hA.nonneg + have hCA : (C * A * C.transpose).PosSemidef := by + simpa only [conjTranspose_eq_transpose_of_trivial] using hA.mul_mul_conjTranspose_same C + have hSC : (S * (C.transpose * C) * S).PosSemidef := by + have hp : (C.transpose * C).PosSemidef := by + simpa only [star_eq_conjTranspose, conjTranspose_eq_transpose_of_trivial] using + (star_mul_self_nonneg C : (0 : Matrix ι ι ℝ) ≤ star C * C).posSemidef + simpa only [hS.eq] using hp.conjTranspose_mul_mul_same S + have hle : S * (C.transpose * C) * S ≤ A := by + have hp := (Matrix.le_iff.mp (transpose_contraction hC)).conjTranspose_mul_mul_same S + rw [hS.eq] at hp + apply Matrix.le_iff.mpr + simpa only [Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_one, hSS] using hp + have heq : (C * A * C.transpose).charpoly = (S * (C.transpose * C) * S).charpoly := by + rw [← hSS] + convert charpoly_mul_comm (C * S) (S * C.transpose) using 1 <;> simp only [Matrix.mul_assoc] + rw [trace_cfc_eq_of_charpoly hCA.1 hSC.1 heq] + exact trace_rpow_monotone hSC hA hle ha + +end EuclideanSteinitz.Spectral + +end OAI diff --git a/lean/OAI/Analysis/Steinitz/Survival.lean b/lean/OAI/Analysis/Steinitz/Survival.lean new file mode 100644 index 0000000000000000000000000000000000000000..a26a5300b19c5c230e7ba8f6ecf53797a927c257 --- /dev/null +++ b/lean/OAI/Analysis/Steinitz/Survival.lean @@ -0,0 +1,773 @@ +import OAI.Analysis.Steinitz.Correlation + +namespace OAI + +/-! Gaussian path survival with slab and state constraints. -/ + +section + +open MeasureTheory ProbabilityTheory Set +open scoped RealInnerProductSpace ENNReal +namespace GaussianEvents +variable {E F I : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] + +noncomputable def constraints (A : I → E →L[ℝ] F) (R : I → ℝ) : Set E := + {x | ∀ i,‖A i x‖ ≤ R i} + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma constraints_closed (A : I → E →L[ℝ] F) (R : I → ℝ) : IsClosed (constraints A R) := by + simp only [constraints,Set.ofPred_forall] + exact isClosed_iInter fun i => isClosed_le (A i).continuous.norm continuous_const + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma constraints_convex (A : I → E →L[ℝ] F) (R : I → ℝ) : Convex ℝ (constraints A R) := by + have he : constraints A R = ⋂ i,(A i) ⁻¹' Metric.closedBall 0 (R i) := by + ext x; simp [constraints,Metric.mem_closedBall,dist_zero_right] + rw [he] + exact convex_iInter fun i => (convex_closedBall (0:F) (R i)).linear_preimage (A i).toLinearMap + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma constraints_symmetric (A : I → E →L[ℝ] F) (R : I → ℝ) : + ∀ x ∈ constraints A R,-x ∈ constraints A R := by + intro x hx i + simpa only [map_neg,norm_neg] using hx i + +lemma finite_half {J : Type*} [Fintype J] (K : J → Set E) + (hc : ∀ i,IsClosed (K i)) (hv : ∀ i,Convex ℝ (K i)) + (hs : ∀ i,∀ x∈K i,-x∈K i) + (hp : ∀ i,(1/2:ℝ≥0∞) ≤ stdGaussian E (K i)) : + (1/2:ℝ)^(Fintype.card J) ≤ (stdGaussian E).real (⋂ i,K i) := by + classical + have h := EuclideanSteinitz.GaussianCorrelation.linear_image_finite_correlation + (ContinuousLinearMap.id ℝ E) Finset.univ K (fun i _ => hc i) (fun i _ => hv i) (fun i _ => hs i) + have he : (stdGaussian E).map (ContinuousLinearMap.id ℝ E) = stdGaussian E := Measure.map_id + rw [he] at h + have hh : (∏ i,(stdGaussian E).real (K i)) ≤ (stdGaussian E).real (⋂ i,K i) := by + simpa using h + apply le_trans _ hh + change (1/2:ℝ)^(Finset.univ : Finset J).card ≤ _ + rw [← Finset.prod_const] + exact Finset.prod_le_prod₀ (fun _ _ => by norm_num) (fun i _ => by + have hh := ENNReal.toReal_mono (measure_ne_top _ _) (hp i) + norm_num [Measure.real] at hh ⊢ + exact hh) + +end GaussianEvents + +end + +section + +open Matrix MeasureTheory ProbabilityTheory +open scoped ENNReal RealInnerProductSpace BigOperators +namespace GaussianAR +open GaussianTail +variable {ι κ I : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [Fintype I] + +lemma epoch_survival (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (n : ℕ) (F : I → Matrix κ ι ℝ) (h k : I → ℝ) + {H C θ : ℝ} (hH : 0≤H) (hC : 0≤C) (hθ : 0≤θ) + (hh : ∀ i,h i ∈ Set.Icc (0:ℝ) H) (hk : ∀ i,1/4≤k i) + (hs : ∀ i,squareMass (F i) ≤ C*k i) + (hi : ∀ i j,⌊h i⌋₊=⌊h j⌋₊ → squareMass (F i-F j) ≤ + C*(1+k i+k j)*|h i-h j|^(2/3:ℝ)) + (ht : ∀ i,(F i*diagonal (fun j => 1-r j)*(F i).transpose).trace ≤ C*k i*θ) + (hop : ∀ i x,‖matrixMap (F i) x‖^2 ≤ ‖x‖^2) : + Real.exp (-(H+1)*(θ*n+1)) ≤ + (stdGaussian (EuclideanSpace ℝ (Fin (n+1)×ι))).real + {x | ∀ i (t : Fin (n+1)), ‖matrixMap (F i*evaluation r n t) x‖ ≤ + 800*(640*C+2)*Real.sqrt (k i)} := by + classical + let J := Fin (⌊H⌋₊+1) × Fin (⌊θ*n⌋₊+1) + let label (p : I × Fin (n+1)) : J := + (⟨⌊h p.1⌋₊,Nat.lt_succ_of_le (Nat.floor_mono (hh p.1).2)⟩, + ⟨⌊θ*(p.2.val:ℝ)⌋₊,Nat.lt_succ_of_le (Nat.floor_mono + (mul_le_mul_of_nonneg_left (by exact_mod_cast Nat.le_of_lt_succ p.2.isLt) hθ))⟩) + let B (j : J) := {p : I × Fin (n+1) // label p=j} + let A (j : J) (p : B j) := matrixMap (F p.val.1*evaluation r n p.val.2) + let R (j : J) (p : B j) := 800*(640*C+2)*Real.sqrt (k p.val.1) + let K (j : J) := GaussianEvents.constraints (A j) (R j) + have hp (j : J) : (1/2:ℝ≥0∞) ≤ stdGaussian (EuclideanSpace ℝ (Fin (n+1)×ι)) (K j) := by + let a (p : B j) := h p.val.1-(j.1.val:ℝ) + let b (p : B j) := θ*(p.val.2.val:ℝ)-(j.2.val:ℝ) + have hla (p : B j) : ⌊h p.val.1⌋₊=j.1.val := congrArg (fun z : J => z.1.val) p.property + have hlb (p : B j) : ⌊θ*(p.val.2.val:ℝ)⌋₊=j.2.val := congrArg (fun z : J => z.2.val) p.property + have ha (p : B j) : a p ∈ Set.Icc (0:ℝ) 1 := by + dsimp [a]; rw [← hla p] + exact ⟨sub_nonneg.mpr (Nat.floor_le (hh p.val.1).1),by linarith [Nat.lt_floor_add_one (h p.val.1)]⟩ + have hb (p : B j) : b p ∈ Set.Icc (0:ℝ) 1 := by + dsimp [b]; rw [← hlb p] + exact ⟨sub_nonneg.mpr (Nat.floor_le (by positivity)),by linarith [Nat.lt_floor_add_one (θ*(p.val.2.val:ℝ))]⟩ + have hinc (p q : B j) : squareMass (F p.val.1-F q.val.1) ≤ + C*(1+k p.val.1+k q.val.1)*|a p-a q|^(2/3:ℝ) := by + simpa only [a,sub_sub_sub_cancel_right] using hi p.val.1 q.val.1 ((hla p).trans (hla q).symm) + have htime (p q : B j) : θ*|((p.val.2).val:ℝ)-(q.val.2).val| ≤ |b p-b q| := by + dsimp [b] + rw [sub_sub_sub_cancel_right,← mul_sub,abs_mul,abs_of_nonneg hθ] + exact block_survival r hr hr1 n (fun p : B j => F p.val.1) (fun p => p.val.2) + a b (fun p => k p.val.1) ha hb (fun p => hk p.val.1) hC + (fun p => hs p.val.1) hinc (fun p => ht p.val.1) htime (fun p => hop p.val.1) + have hprob := GaussianEvents.finite_half K + (fun j => GaussianEvents.constraints_closed (A j) (R j)) + (fun j => GaussianEvents.constraints_convex (A j) (R j)) + (fun j => GaussianEvents.constraints_symmetric (A j) (R j)) hp + have he : (⋂ j,K j)={x | ∀ i (t : Fin (n+1)), ‖matrixMap (F i*evaluation r n t) x‖ ≤ + 800*(640*C+2)*Real.sqrt (k i)} := by + ext x + simp only [Set.mem_iInter,Set.mem_ofPred_eq,K,GaussianEvents.constraints] + constructor + · intro hx i t; exact hx (label (i,t)) ⟨(i,t),rfl⟩ + · intro hx j p; exact hx p.val.1 p.val.2 + rw [he] at hprob + apply le_trans _ hprob + have hcard : (Fintype.card J:ℝ) ≤ (H+1)*(θ*n+1) := by + simp only [J,Fintype.card_prod,Fintype.card_fin,Nat.cast_mul,Nat.cast_add,Nat.cast_one] + exact mul_le_mul (by linarith [Nat.floor_le hH]) (by linarith [Nat.floor_le (show 0≤θ*n by positivity)]) + (by positivity) (by linarith) + calc + _ ≤ Real.exp (-(Fintype.card J:ℝ)) := Real.exp_le_exp.mpr (by nlinarith) + _ = (Real.exp (-1))^(Fintype.card J) := by rw [← Real.exp_nat_mul]; congr 1; ring + _ ≤ _ := pow_le_pow_left₀ (by positivity) (by + have hg := Real.add_one_le_exp (1:ℝ) + rw [Real.exp_neg] + exact (inv_le_comm₀ (Real.exp_pos _) (by norm_num)).mpr (by norm_num; linarith)) _ + +end GaussianAR + +end + +section + +open Matrix MeasureTheory ProbabilityTheory +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +open MatrixEnergy Spectral Coefficient Gain Energy GaussianTail GaussianAR +variable {ι κ T : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] [Fintype T] + +noncomputable def epochFactor : ℝ := 1+16*gainConstant +noncomputable def momentConstant : ℝ := incrementConstant+20 +noncomputable def survivalRadius : ℝ := 800*(640*momentConstant+2) + +lemma epochFactor_ge_one : 1≤epochFactor := by + unfold epochFactor + linarith [gainConstant_pos] +lemma momentConstant_ge : 16≤ momentConstant := by + unfold momentConstant + linarith [incrementConstant_pos] +lemma survivalRadius_pos : 0 q j/θ + let F := fun t => lift (run R (ps t)) (cfc cutoff (state qθ (run R (ps t)))) + let k := fun t => (cfc sizeWeight (state qθ (run R (ps t)))).trace + Real.exp (-(epochFactor*cost (state qθ R) (L.map (fun p => p.move qθ))+1)*(θ*n+1)) ≤ + (stdGaussian (EuclideanSpace ℝ (Fin (n+1)×κ))).real + {x | ∀ t (u : Fin (n+1)), ‖matrixMap (F t*evaluation r n u) x‖ ≤ survivalRadius*Real.sqrt (k t)} := by + classical + dsimp only + let qθ := fun j => q j/θ + let F := fun t => lift (run R (ps t)) (cfc cutoff (state qθ (run R (ps t)))) + let k := fun t => (cfc sizeWeight (state qθ (run R (ps t)))).trace + let e := fun t => cost (state qθ R) ((ps t).map (fun p => p.move qθ)) + let H := epochFactor*cost (state qθ R) (L.map (fun p => p.move qθ)) + let h := fun t => epochFactor*e t + have hqθ : ∀ j,0 div_pos (hq j) hθ + have hR' (t : T) : run R (ps t)*(run R (ps t)).transpose=1 := + run_coisometry hR (good_prefix hp (hps t)) (fresh_prefix hf (hps t)) (nodup_prefix hd (hps t)) + have hX (t : T) : (state qθ (run R (ps t))).PosDef := state_posDef (hR' t) hqθ + have hk0 (t : T) : 0≤k t := by + change 0 ≤ (cfc sizeWeight (state qθ (run R (ps t)))).trace + rw [trace_cfc (hX t).1] + exact Finset.sum_nonneg fun i _ => Scale.size_nonneg ((hX t).eigenvalues_pos i).le + have he0 (t : T) : 0≤e t := cost_nonneg (state_posDef hR hqθ).posSemidef + (moves_good (good_prefix hp (hps t)) (fun j => (hqθ j).le)) + have hfac : 0 (hqθ j).le))) + have hh (t : T) : h t ∈ Set.Icc (0:ℝ) H := by + refine ⟨mul_nonneg hfac.le (he0 t),mul_le_mul_of_nonneg_left ?_ hfac.le⟩ + exact cost_prefix (state_posDef hR hqθ).posSemidef (moves_good hp (fun j => (hqθ j).le)) + ((hps t).map _) + have he_mono {s t : T} (hst : ps s <+: ps t) : e s≤e t := + cost_prefix (state_posDef hR hqθ).posSemidef + (moves_good (good_prefix hp (hps t)) (fun j => (hqθ j).le)) (hst.map _) + have hlocal {s t : T} (hst : ps s <+: ps t) (hab : ⌊h s⌋₊=⌊h t⌋₊) : + squareMass (F t-F s) ≤ momentConstant*(1+k s+k t)*|h s-h t|^(2/3:ℝ) := by + have hen : 0≤e t-e s := sub_nonneg.mpr (he_mono hst) + have hex : |h s-h t|=epochFactor*(e t-e s) := by + rw [abs_sub_comm,abs_of_nonneg (sub_nonneg.mpr + (mul_le_mul_of_nonneg_left (he_mono hst) hfac.le))] + ring + have hsmall : e t-e s ≤ 1/(16*gainConstant) := by + have ht := Nat.lt_floor_add_one (h t) + rw [← hab] at ht + have hss := Nat.floor_le (hh s).1 + have hdiff : epochFactor*(e t-e s) ≤ 1 := by dsimp [h] at ht hss; linarith + apply (le_div_iff₀ (mul_pos (by norm_num) gainConstant_pos)).mpr + have hscale : 16*gainConstant≤epochFactor := by unfold epochFactor; linarith + nlinarith [mul_le_mul_of_nonneg_right hscale hen] + have hi := local_prefix_increment hR hp hf hd hst (hps t) hqθ hsmall + have hip : (e t-e s)^(1/exponent) ≤ |h s-h t|^(2/3:ℝ) := by + rw [show 1/exponent=(2/3:ℝ) by norm_num [exponent]] + apply Real.rpow_le_rpow hen + · rw [hex]; nlinarith [epochFactor_ge_one] + · norm_num + have hinc : incrementConstant*(1+k t) ≤ momentConstant*(1+k s+k t) := by + have hc : incrementConstant≤ momentConstant := by unfold momentConstant; linarith + exact mul_le_mul hc (by linarith [hk0 s]) (by linarith [hk0 t]) (by linarith [momentConstant_ge]) + exact (squareMass_le_weighted (F t-F s) (fun j => (hqθ j).le)).trans + (hi.trans (mul_le_mul hinc hip (Real.rpow_nonneg hen _) (mul_nonneg (by linarith [momentConstant_ge]) (by linarith [hk0 s,hk0 t])))) + let I := {t : T // F t≠0} + have hbound := epoch_survival r hr hr1 n (fun t : I => F t.val) (fun t => h t.val) + (fun t => k t.val) hH (show 0≤ momentConstant by linarith [momentConstant_ge]) hθ.le + (fun t => hh t.val) (fun t => lift_cutoff_size (hX t.val).posSemidef t.property) + (fun t => (lift_cutoff_mass (hR' t.val) (hX t.val).posSemidef).trans + (mul_le_mul_of_nonneg_right (by linarith [momentConstant_ge]) (hk0 t.val))) + (by + intro s t hab + rcases List.prefix_or_prefix_of_prefix (hps s.val) (hps t.val) with hst|hts + · rw [squareMass_sub_comm] + exact hlocal hst hab + · have hu := hlocal hts hab.symm + simpa only [abs_sub_comm,add_comm,add_left_comm,add_assoc] using hu) + (by + intro t + change weightedSq (F t.val) (diagonal (fun j => 1-r j))≤_ + exact (weightedSq_diagonal_mono _ hrq).trans ((lift_cutoff_time (hR' t.val) hq hθ).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right + (by linarith [momentConstant_ge]) (hk0 t.val)) hθ.le))) + (fun t => lift_cutoff_contract (hR' t.val) (hX t.val).1) + apply hbound.trans + refine measureReal_mono ?_ (measure_ne_top _ _) + intro x hx t u + change ‖matrixMap (F t*evaluation r n u) x‖ ≤ survivalRadius*Real.sqrt (k t) + by_cases ht : F t=0 + · simp only [ht,Matrix.zero_mul,matrixMap,map_zero,_root_.zero_apply,norm_zero] + exact mul_nonneg survivalRadius_pos.le (Real.sqrt_nonneg _) + · exact hx ⟨t,ht⟩ u + +end EuclideanSteinitz.Filter + +end + +section + +open Matrix GaussianTail +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +open MatrixEnergy Spectral Coefficient ScaleMatrix ScaleEnergy +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +omit [Fintype ι] [DecidableEq ι] in +lemma state_scale (q : κ → ℝ) (R : Matrix ι κ ℝ) (θ : ℝ) : + state (fun j => q j/θ) R = θ⁻¹ • state q R := by + unfold state + have he : diagonal (fun j => q j/θ) = θ⁻¹ • diagonal q := by + rw [← Matrix.diagonal_smul] + congr 1 + ext j + simp [div_eq_mul_inv,mul_comm] + rw [he,Matrix.mul_smul,Matrix.smul_mul] + +lemma sum_scale_size {A : Matrix ι ι ℝ} (hA : A.PosDef) (S : Finset ℤ) : + (∑ k ∈ S,(cfc sizeWeight (((2:ℝ)^k)⁻¹ • A)).trace) ≤ 14*Fintype.card ι := by + simp only [cfc_scaled hA.1,trace_cfc hA.1] + rw [Finset.sum_comm] + calc + _ ≤ ∑ i : ι,(14:ℝ) := Finset.sum_le_sum fun i _ => by + simpa only [div_eq_mul_inv,mul_comm] using Scale.sum_size_dyadic S (hA.eigenvalues_pos i) + _ = _ := by simp [mul_comm] + +lemma form_mono {A B : Matrix ι ι ℝ} (hAB : A≤B) (x : EuclideanSpace ℝ ι) : + ⟪x,toEuclideanCLM (𝕜 := ℝ) A x⟫ ≤ ⟪x,toEuclideanCLM (𝕜 := ℝ) B x⟫ := by + have h := (Matrix.le_iff.mp hAB).dotProduct_mulVec_nonneg (WithLp.ofLp x) + simpa only [star_trivial,Matrix.sub_mulVec,dotProduct_sub,inner_toEuclideanCLM,sub_nonneg] using h + +lemma cutoff_cover {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (S : Finset ℤ) + (hS : ∀ i,∃ k∈S,1≤hA.eigenvalues i/(2:ℝ)^k ∧ hA.eigenvalues i/(2:ℝ)^k≤2) : + (1 : Matrix ι ι ℝ) ≤ ∑ k∈S,cfc cutoff (((2:ℝ)^k)⁻¹ • A)*cfc cutoff (((2:ℝ)^k)⁻¹ • A) := by + have he (k : ℤ) : cfc cutoff (((2:ℝ)^k)⁻¹ • A)*cfc cutoff (((2:ℝ)^k)⁻¹ • A) = + cfc (fun x => cutoff (x/(2:ℝ)^k)^2) A := by + rw [cfc_scaled hA,cfc_mul_same hA] + congr 1 + ext x + simp [div_eq_mul_inv,mul_comm,pow_two] + simp only [he] + rw [← cfc_sum _ A S (fun _ _ => Gain.finite_spectrum_continuous _ _)] + rw [← cfc_const_one ℝ A] + apply (cfc_le_iff _ _ A continuousOn_const (Gain.finite_spectrum_continuous _ _) hA.isSelfAdjoint).mpr + intro x hx + obtain ⟨i,rfl⟩ := hA.spectrum_real_eq_range_eigenvalues ▸ hx + obtain ⟨k,hk,hk1,hk2⟩ := hS i + simp only [Finset.sum_apply] + change 1≤∑ k∈S,cutoff (hA.eigenvalues i/(2:ℝ)^k)^2 + have hh := Finset.single_le_sum (fun j (_ : j∈S) => sq_nonneg (cutoff (hA.eigenvalues i/(2:ℝ)^j))) hk + have hone : cutoff (hA.eigenvalues i/(2:ℝ)^k)=1 := by + simp [cutoff,show (2:ℝ)⁻¹ < hA.eigenvalues i/(2:ℝ)^k by norm_num; linarith,not_lt.mpr hk1,hk2] + rwa [hone,one_pow] at hh + +omit [DecidableEq κ] in +lemma lift_gram {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {A : Matrix ι ι ℝ} (hA : A.transpose=A) : + (lift R A).transpose*lift R A = R.transpose*(A*A)*R := by + simp only [lift,Matrix.transpose_mul,Matrix.transpose_transpose,hA] + calc + _ = R.transpose*A*(R*R.transpose)*A*R := by simp only [Matrix.mul_assoc] + _ = _ := by rw [hR,Matrix.mul_one]; simp only [Matrix.mul_assoc] + +lemma norm_sq_reconstruct {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {A : Matrix ι ι ℝ} (hA : A.IsHermitian) (S : Finset ℤ) + (hS : ∀ i,∃ k∈S,1≤hA.eigenvalues i/(2:ℝ)^k ∧ hA.eigenvalues i/(2:ℝ)^k≤2) + (x : EuclideanSpace ℝ κ) : + ‖matrixMap R x‖^2 ≤ ∑ k∈S,‖matrixMap (lift R (cfc cutoff (((2:ℝ)^k)⁻¹ • A))) x‖^2 := by + have hp := (Matrix.le_iff.mp (cutoff_cover hA S hS)).mul_mul_conjTranspose_same R.transpose + simp only [conjTranspose_eq_transpose_of_trivial,transpose_transpose,Matrix.mul_sub,Matrix.sub_mul, + Matrix.mul_one,Matrix.mul_sum,Matrix.sum_mul] at hp + have hh := form_mono (Matrix.le_iff.mpr hp) x + rw [gram_form] at hh + have he (k : ℤ) : R.transpose*(cfc cutoff (((2:ℝ)^k)⁻¹ • A)*cfc cutoff (((2:ℝ)^k)⁻¹ • A))*R = + (lift R (cfc cutoff (((2:ℝ)^k)⁻¹ • A))).transpose*lift R (cfc cutoff (((2:ℝ)^k)⁻¹ • A)) := + (lift_gram hR (cfc_transpose (hA.smul (IsSelfAdjoint.all _)) cutoff)).symm + simp only [he,map_sum,_root_.sum_apply,inner_sum,gram_form] at hh + exact hh + +lemma exists_finite_scales {T : Type*} [Fintype T] (A : T → Matrix ι ι ℝ) + (hA : ∀ t,(A t).PosDef) : + ∃ S : Finset ℤ, (∀ t i,∃ k∈S,1≤(hA t).1.eigenvalues i/(2:ℝ)^k ∧ + (hA t).1.eigenvalues i/(2:ℝ)^k≤2) ∧ + (∀ k∈S,∃ t i,(2:ℝ)^k≤(hA t).1.eigenvalues i) := by + classical + choose f hf using fun t i => Scale.dyadic_normalize ((hA t).eigenvalues_pos i) + refine ⟨Finset.univ.image (fun p : T×ι => f p.1 p.2),?_,?_⟩ + · intro t i + exact ⟨f t i,Finset.mem_image.mpr ⟨(t,i),Finset.mem_univ _,rfl⟩,hf t i⟩ + · intro k hk + obtain ⟨⟨t,i⟩,_,rfl⟩ := Finset.mem_image.mp hk + exact ⟨t,i,(le_div_iff₀ (zpow_pos (by norm_num) _)).mp (hf t i).1 |>.trans' (by simp)⟩ + +end EuclideanSteinitz.Filter + +end + +section + +open Matrix MeasureTheory ProbabilityTheory Set +open scoped RealInnerProductSpace +namespace GaussianEvents +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma finite_exp {J : Type*} [Fintype J] (K : J → Set E) (c : J → ℝ) + (hc : ∀ i,IsClosed (K i)) (hv : ∀ i,Convex ℝ (K i)) + (hs : ∀ i,∀ x∈K i,-x∈K i) + (hp : ∀ i,Real.exp (-c i) ≤ (stdGaussian E).real (K i)) : + Real.exp (-(∑ i,c i)) ≤ (stdGaussian E).real (⋂ i,K i) := by + classical + have hh := EuclideanSteinitz.GaussianCorrelation.linear_image_finite_correlation + (ContinuousLinearMap.id ℝ E) Finset.univ K (fun i _ => hc i) (fun i _ => hv i) (fun i _ => hs i) + have he : (stdGaussian E).map (ContinuousLinearMap.id ℝ E) = stdGaussian E := Measure.map_id + rw [he] at hh + have hp' : (∏ i,Real.exp (-c i)) ≤ ∏ i,(stdGaussian E).real (K i) := + Finset.prod_le_prod₀ (fun _ _ => (Real.exp_pos _).le) (fun i _ => hp i) + simpa only [← Real.exp_sum,Finset.sum_neg_distrib,Finset.mem_univ,Set.iInter_true] using hp'.trans hh + +end GaussianEvents + +namespace GaussianAR +open GaussianTail EuclideanSteinitz.Coefficient EuclideanSteinitz.Filter +variable {ι κ J : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [Fintype J] +noncomputable def slabRadius : ℝ := 800*(640+2) +lemma slabRadius_pos : 0 A) (fun _ => 0) (fun _ => 1) + (H := 0) (C := 1) (θ := weightedSq A (diagonal q)) (by norm_num) (by norm_num) ht + (fun _ => by simp) (fun _ => by norm_num) (fun _ => by simpa using hA) + (by intros; simp [squareMass]) + (fun _ => by + change weightedSq A (diagonal (fun i => 1-r i)) ≤ 1*1*weightedSq A (diagonal q) + simpa only [one_mul] using weightedSq_diagonal_mono A hrq) + (fun _ x => (norm_sq_le_squareMass A x).trans (by nlinarith [sq_nonneg ‖x‖])) + simpa only [zero_add,neg_mul,one_mul,Real.sqrt_one,mul_one,forall_const,slabRadius] using hh + +lemma slabs_survival (A : J → Matrix κ ι ℝ) (hA : ∀ j,squareMass (A j) ≤ 1) + (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i≤1) + (q : ι → ℝ) (hq : ∀ i,0≤q i) (hrq : ∀ i,1-r i≤q i) (n : ℕ) : + Real.exp (-(Fintype.card J:ℝ)-(∑ j,weightedSq (A j) (diagonal q))*n) ≤ + (stdGaussian (EuclideanSpace ℝ (Fin (n+1)×ι))).real + {x | ∀ j (t : Fin (n+1)),‖matrixMap (A j*evaluation r n t) x‖ ≤ slabRadius} := by + let K := fun j => GaussianEvents.constraints (fun t : Fin (n+1) => matrixMap (A j*evaluation r n t)) (fun _ => slabRadius) + have hh := GaussianEvents.finite_exp K (fun j => weightedSq (A j) (diagonal q)*n+1) + (fun j => GaussianEvents.constraints_closed _ _) (fun j => GaussianEvents.constraints_convex _ _) + (fun j => GaussianEvents.constraints_symmetric _ _) (fun j => one_slab_survival (A j) (hA j) r hr hr1 q hq hrq n) + have he : (⋂ j,K j)={x | ∀ j (t : Fin (n+1)),‖matrixMap (A j*evaluation r n t) x‖ ≤ slabRadius} := by + ext x; simp only [K,GaussianEvents.constraints,Set.mem_iInter,Set.mem_ofPred_eq] + rw [he] at hh + convert hh using 1 + congr 1 + simp only [Finset.sum_add_distrib,Finset.sum_mul,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_one] + ring + +end GaussianAR + +end + +section + +open Matrix GaussianTail MeasureTheory ProbabilityTheory +open scoped MatrixOrder Matrix.Norms.L2Operator RealInnerProductSpace +namespace EuclideanSteinitz.Filter +open MatrixEnergy Spectral Coefficient ScaleMatrix ScaleEnergy Energy GaussianAR +variable {ι κ T : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] [Fintype T] + +noncomputable def stateRadius : ℝ := 4*survivalRadius +noncomputable def stateRate : ℝ := 84*epochFactor+2 +lemma stateRadius_pos : 0 < stateRadius := mul_pos (by norm_num) survivalRadius_pos +lemma stateRate_nonneg : 0 ≤ stateRate := by unfold stateRate; linarith [epochFactor_ge_one] + +omit [DecidableEq ι] in +lemma matrixMap_mul_apply {ν : Type*} [Fintype ν] [DecidableEq ν] + (A : Matrix ι κ ℝ) (B : Matrix κ ν ℝ) (x : EuclideanSpace ℝ ν) : + matrixMap (A*B) x = matrixMap A (matrixMap B x) := by + apply WithLp.ofLp_injective + exact Matrix.mulVec_mulVec x A B |>.symm + +lemma reconstruction_bound {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {q : κ → ℝ} (hq : ∀ j,0 q j/(2:ℝ)^k) R))) x‖ ≤ + survivalRadius*Real.sqrt ((cfc sizeWeight (state (fun j => q j/(2:ℝ)^k) R)).trace)) : + ‖matrixMap R x‖ ≤ stateRadius*Real.sqrt (Fintype.card ι) := by + have hA := state_posDef hR hq + have hrec := norm_sq_reconstruct hR hA.1 S hS x + have hk (k : ℤ) : 0≤(cfc sizeWeight (((2:ℝ)^k)⁻¹ • state q R)).trace := by + rw [cfc_scaled hA.1,trace_cfc hA.1] + exact Finset.sum_nonneg fun i _ => Scale.size_nonneg (mul_nonneg (inv_nonneg.mpr (zpow_pos (by norm_num) _).le) (hA.eigenvalues_pos i).le) + have hb : (∑ k∈S,‖matrixMap (lift R (cfc cutoff (((2:ℝ)^k)⁻¹ • state q R))) x‖^2) ≤ + survivalRadius^2*(14*Fintype.card ι) := by + calc + _ ≤ ∑ k∈S,survivalRadius^2*(cfc sizeWeight (((2:ℝ)^k)⁻¹ • state q R)).trace := by + apply Finset.sum_le_sum + intro k hkS + have hh := pow_le_pow_left₀ (norm_nonneg _) (hx k hkS) 2 + simpa only [state_scale,mul_pow,Real.sq_sqrt (hk k)] using hh + _ = survivalRadius^2*(∑ k∈S,(cfc sizeWeight (((2:ℝ)^k)⁻¹ • state q R)).trace) := (Finset.mul_sum ..).symm + _ ≤ _ := mul_le_mul_of_nonneg_left (sum_scale_size hA S) (sq_nonneg _) + have hs := Real.sq_sqrt (show (0:ℝ)≤Fintype.card ι by positivity) + have hp : 0 ≤ stateRadius*Real.sqrt (Fintype.card ι) := mul_nonneg stateRadius_pos.le (Real.sqrt_nonneg _) + have ht : ‖matrixMap R x‖^2 ≤ (stateRadius*Real.sqrt (Fintype.card ι))^2 := by + apply hrec.trans (hb.trans _) + rw [mul_pow,hs,stateRadius] + nlinarith [mul_nonneg (sq_nonneg survivalRadius) (show (0:ℝ)≤Fintype.card ι by positivity)] + exact (sq_le_sq₀ (norm_nonneg _) hp).mp ht + +lemma state_survival {R : Matrix ι κ ℝ} (hR : R*R.transpose=1) + {L : List (Step ι κ)} (hp : ∀ p∈L,p.Good) (hf : Fresh R L) (hd : (L.map Step.j).Nodup) + (ps : T → List (Step ι κ)) (hps : ∀ t,ps t <+: L) + {q : κ → ℝ} (hq : ∀ j,0 run R (ps t) + have hRt (t : T) : Rt t*(Rt t).transpose=1 := + run_coisometry hR (good_prefix hp (hps t)) (fresh_prefix hf (hps t)) (nodup_prefix hd (hps t)) + let A := fun t => state q (Rt t) + have hA (t : T) : (A t).PosDef := state_posDef (hRt t) hq + obtain ⟨S,hS,hS'⟩ := exists_finite_scales A hA + let e := fun k : ℤ => cost (state (fun j => q j/(2:ℝ)^k) R) (L.map (fun p => p.move (fun j => q j/(2:ℝ)^k))) + let c := fun k : ℤ => epochFactor*e k+1 + have htq : 0≤∑ j,q j := Finset.sum_nonneg fun j _ => (hq j).le + have hθ (k : ℤ) (hk : k∈S) : (2:ℝ)^k ≤ ∑ j,q j := by + obtain ⟨t,i,hi⟩ := hS' k hk + apply hi.trans + have htrace : (hA t).1.eigenvalues i ≤ (A t).trace := by + rw [trace_spectral (hA t).1] + exact Finset.single_le_sum (fun j _ => (hA t).eigenvalues_pos j |>.le) (Finset.mem_univ i) + exact htrace.trans (state_trace_le (hRt t) (fun j => (hq j).le)) + have hrate : (∑ k : S,c k.val*(2:ℝ)^k.val) ≤ stateRate*(∑ j,q j) := by + have he := sum_epoch_cost hR hp hd (fun j => (hq j).le) S + have ht := sum_dyadic_le htq hθ + simp only [← state_scale] at he + have hsum : (∑ k : S,c k.val*(2:ℝ)^k.val) = + epochFactor*(∑ k∈S,(2:ℝ)^k*e k)+(∑ k∈S,(2:ℝ)^k) := by + rw [Finset.sum_coe_sort S (fun k => c k*(2:ℝ)^k),Finset.mul_sum,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro k _ + dsimp [c] + ring + rw [hsum] + unfold stateRate + nlinarith [mul_le_mul_of_nonneg_left he (show 0≤epochFactor by linarith [epochFactor_ge_one])] + refine ⟨∑ k : S,c k.val,fun n => ?_⟩ + let F := fun k : S => fun t => lift (Rt t) (cfc cutoff (state (fun j => q j/(2:ℝ)^k.val) (Rt t))) + let w := fun k : S => fun t => survivalRadius*Real.sqrt ((cfc sizeWeight (state (fun j => q j/(2:ℝ)^k.val) (Rt t))).trace) + let K := fun k : S => GaussianEvents.constraints + (fun p : T×Fin (n+1) => matrixMap (F k p.1*evaluation r n p.2)) (fun p => w k p.1) + have hprob := GaussianEvents.finite_exp K (fun k : S => c k.val*((2:ℝ)^k.val*n+1)) + (fun k => GaussianEvents.constraints_closed _ _) (fun k => GaussianEvents.constraints_convex _ _) + (fun k => GaussianEvents.constraints_symmetric _ _) (fun k => by + have hh := filtered_epoch_survival hR hp hf hd ps hps hq (θ := (2:ℝ)^k.val) (zpow_pos (by norm_num) k.val) r hr hr1 hrq n + dsimp only at hh + convert hh using 1 + · dsimp [c,e]; congr 1; ring + · congr 1 + ext x + simp only [K,GaussianEvents.constraints,Set.mem_ofPred_eq,Prod.forall] + rfl) + have hlow : Real.exp (-(∑ k : S,c k.val)-stateRate*(∑ j,q j)*n) ≤ + Real.exp (-(∑ k : S,c k.val*((2:ℝ)^k.val*n+1))) := by + apply Real.exp_le_exp.mpr + have heq : (∑ k : S,c k.val*((2:ℝ)^k.val*n+1)) = + (∑ k : S,c k.val)+(∑ k : S,c k.val*(2:ℝ)^k.val)*n := by + simp only [mul_add,mul_one,Finset.sum_add_distrib,← mul_assoc,← Finset.sum_mul] + ring + rw [heq] + nlinarith [mul_le_mul_of_nonneg_right hrate (Nat.cast_nonneg n : (0:ℝ)≤n)] + apply hlow.trans (hprob.trans _) + apply measureReal_mono _ (measure_ne_top _ _) + intro x hx t u + rw [matrixMap_mul_apply] + apply reconstruction_bound (hRt t) hq S (hS t) (matrixMap (evaluation r n u) x) + intro k hk + have hh := Set.mem_iInter.mp hx (⟨k,hk⟩ : S) (t,u) + change ‖matrixMap (F ⟨k,hk⟩ t*evaluation r n u) x‖≤_ at hh + rw [matrixMap_mul_apply] at hh + exact hh + +end EuclideanSteinitz.Filter + +end + +section + +open Matrix +open scoped BigOperators +namespace GaussianAR +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def pathMatrix (r : ι → ℝ) (n : ℕ) : Matrix (Fin (n+1)×ι) (Fin (n+1)×ι) ℝ := + fun i j => evaluation r n i.1 i.2 j + +lemma pathMatrix_det (r : ι → ℝ) (n : ℕ) : + (pathMatrix r n).det = (∏ i,Real.sqrt (1-(r i)^2))^n := by + have htri : (pathMatrix r n).transpose.BlockTriangular (fun p => p.1) := by + intro a b hab + change (if b.2=a.2 then row (r b.2) b.1.val a.1.val else 0)=0 + split_ifs + · exact row_support _ hab + · rfl + rw [← Matrix.det_transpose,htri.det_fintype] + have hb (t : Fin (n+1)) : ((pathMatrix r n).transpose.toSquareBlock (fun p => p.1) t).det = + ∏ i, row (r i) t.val t.val := by + let e : ι ≃ {p : Fin (n+1)×ι // p.1=t} := + { toFun := fun i => ⟨(t,i),rfl⟩ + invFun := fun p => p.val.2 + left_inv := fun _ => rfl + right_inv := fun p => by ext <;> simp [p.property] } + rw [← Matrix.det_reindex_self e.symm] + have he : Matrix.reindex e.symm e.symm + ((pathMatrix r n).transpose.toSquareBlock (fun p => p.1) t) = + diagonal (fun i => row (r i) t.val t.val) := by + ext i j + simp only [Matrix.reindex_apply,Matrix.submatrix_apply,Matrix.toSquareBlock_def, + Matrix.transpose_apply,pathMatrix,e,evaluation,Matrix.diagonal_apply] + split_ifs with h <;> simp_all [eq_comm] + rw [he,Matrix.det_diagonal] + simp_rw [hb] + rw [Fin.prod_univ_succ] + simp only [Fin.val_zero,row,ite_true,Fin.val_succ,row_diag,Finset.prod_const_one,one_mul] + simp + +lemma pathMatrix_det_pos (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i<1) (n : ℕ) : + 0 < (pathMatrix r n).det := by + rw [pathMatrix_det] + apply pow_pos + exact Finset.prod_pos fun i _ => Real.sqrt_pos.mpr (by nlinarith [hr i,hr1 i]) + +lemma evaluation_apply (r : ι → ℝ) (n : ℕ) (t : Fin (n+1)) + (x : EuclideanSpace ℝ (Fin (n+1)×ι)) (i : ι) : + GaussianTail.matrixMap (evaluation r n t) x i = + ∑ u : Fin (n+1),row (r i) t.val u.val*x (u,i) := by + change (∑ u,evaluation r n t i u*x u)=_ + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro u _ + simp only [evaluation,ite_mul,zero_mul,Finset.sum_ite_eq,Finset.mem_univ,ite_true] + +lemma pathMatrix_apply (r : ι → ℝ) (n : ℕ) + (x : EuclideanSpace ℝ (Fin (n+1)×ι)) (t : Fin (n+1)) (i : ι) : + GaussianTail.matrixMap (pathMatrix r n) x (t,i) = + GaussianTail.matrixMap (evaluation r n t) x i := rfl + +lemma path_initial (r : ι → ℝ) (n : ℕ) (x : EuclideanSpace ℝ (Fin (n+1)×ι)) (i : ι) : + GaussianTail.matrixMap (pathMatrix r n) x (0,i)=x (0,i) := by + rw [pathMatrix_apply,evaluation_apply] + simp only [Fin.val_zero,row,ite_mul,one_mul,zero_mul,Fin.val_eq_zero_iff, + Finset.sum_ite_eq',Finset.mem_univ,ite_true] + +lemma path_step (r : ι → ℝ) (n : ℕ) (x : EuclideanSpace ℝ (Fin (n+1)×ι)) + (t : Fin n) (i : ι) : + GaussianTail.matrixMap (pathMatrix r n) x (t.succ,i)= + r i*GaussianTail.matrixMap (pathMatrix r n) x (t.castSucc,i)+ + Real.sqrt (1-(r i)^2)*x (t.succ,i) := by + simp only [pathMatrix_apply,evaluation_apply,Fin.val_succ,Fin.val_castSucc,row, + add_mul,ite_mul,zero_mul,mul_assoc,Finset.sum_add_distrib,← Finset.mul_sum] + congr 1 + have he (u : Fin (n+1)) : (u.val=t.val+1) ↔ u=t.succ := by + exact (show (u.val=t.succ.val) ↔ u=t.succ from Fin.ext_iff.symm) + simp only [he,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + +lemma pathMatrix_lin_det (r : ι → ℝ) (n : ℕ) : + (Matrix.toEuclideanLin (pathMatrix r n)).det=(pathMatrix r n).det := by + rw [Matrix.toEuclideanLin_eq_toLin_orthonormal,LinearMap.det_toLin] + +noncomputable def pathEquiv (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i<1) (n : ℕ) : + EuclideanSpace ℝ (Fin (n+1)×ι) ≃L[ℝ] EuclideanSpace ℝ (Fin (n+1)×ι) := + (LinearMap.equivOfIsUnitDet (show IsUnit (Matrix.toEuclideanLin (pathMatrix r n)).det from by + rw [pathMatrix_lin_det] + exact isUnit_iff_ne_zero.mpr (pathMatrix_det_pos r hr hr1 n).ne')).toContinuousLinearEquiv + +lemma pathEquiv_apply (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i<1) (n : ℕ) + (x : EuclideanSpace ℝ (Fin (n+1)×ι)) : + pathEquiv r hr hr1 n x = GaussianTail.matrixMap (pathMatrix r n) x := by + simp only [pathEquiv,LinearEquiv.coe_toContinuousLinearEquiv',LinearMap.equivOfIsUnitDet_apply] + rfl + +lemma pathEquiv_symm_initial (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i<1) (n : ℕ) + (x : EuclideanSpace ℝ (Fin (n+1)×ι)) (i : ι) : + (pathEquiv r hr hr1 n).symm x (0,i) = x (0,i) := by + have hs := congrArg (fun x : EuclideanSpace ℝ (Fin (n+1)×ι) => x (0,i)) + ((pathEquiv r hr hr1 n).apply_symm_apply x) + rw [pathEquiv_apply,path_initial] at hs + exact hs + +lemma pathEquiv_symm_step (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i<1) (n : ℕ) + (x : EuclideanSpace ℝ (Fin (n+1)×ι)) (t : Fin n) (i : ι) : + (pathEquiv r hr hr1 n).symm x (t.succ,i) = + (x (t.succ,i)-r i*x (t.castSucc,i))/Real.sqrt (1-(r i)^2) := by + have hpos : 0 < Real.sqrt (1-(r i)^2) := Real.sqrt_pos.mpr (by nlinarith [hr i,hr1 i]) + have hs := path_step r n ((pathEquiv r hr hr1 n).symm x) t i + simp only [← pathEquiv_apply r hr hr1,(pathEquiv r hr hr1 n).apply_symm_apply] at hs + apply (eq_div_iff hpos.ne').mpr + linarith + +lemma pathEquiv_det (r : ι → ℝ) (hr : ∀ i,0≤r i) (hr1 : ∀ i,r i<1) (n : ℕ) : + (pathEquiv r hr hr1 n).toContinuousLinearMap.det=(∏ i,Real.sqrt (1-(r i)^2))^n := by + change (pathEquiv r hr hr1 n).toLinearEquiv.toLinearMap.det=_ + simp only [pathEquiv,LinearEquiv.toLinearEquiv_toContinuousLinearEquiv, + LinearMap.coe_equivOfIsUnitDet,pathMatrix_lin_det,pathMatrix_det] + +end GaussianAR + +end + +section + +open ProbabilityTheory +namespace GaussianAR + +lemma transition_scalar {r w : ℝ} (hr : 0 i.val < k), v i + +section Lists + +variable {α E : Type*} + +lemma sum_take_ofFn [AddCommMonoid E] {N : ℕ} (v : Fin N → E) (k : ℕ) : + ((List.ofFn v).take k).sum = + ∑ i ∈ Finset.univ.filter (fun i : Fin N => i.val < k), v i := by + induction N generalizing k with + | zero => simp + | succ N ih => + cases k with + | zero => simp + | succ k => + simp only [List.ofFn_succ, List.take_succ_cons, List.sum_cons, + Finset.sum_filter, Fin.sum_univ_succ] + simp only [Fin.val_zero, Nat.zero_lt_succ, ite_true, Fin.val_succ, + Nat.succ_lt_succ_iff] + rw [ih] + rw [Finset.sum_filter] + +lemma take_filter_eq_filter_take (p : α → Bool) (l : List α) (k : ℕ) : + ∃ j ≤ l.length, (l.filter p).take k = (l.take j).filter p := by + induction l generalizing k with + | nil => exact ⟨0, by simp, by simp⟩ + | cons a l ih => + by_cases ha : p a = true + · cases k with + | zero => exact ⟨0, by simp, by simp⟩ + | succ k => + obtain ⟨j, hj, he⟩ := ih k + exact ⟨j + 1, by simpa using hj, by simp [ha, he]⟩ + · obtain ⟨j, hj, he⟩ := ih k + exact ⟨j + 1, by simpa using hj, by simp [ha, he]⟩ + +def signedOrder (p : α → Bool) (l : List α) : List α := + l.filter p ++ (l.filter fun a => !p a).reverse + +lemma signedOrder_perm (p : α → Bool) (l : List α) : + (signedOrder p l).Perm l := by + exact ((List.Perm.refl (l.filter p)).append (List.reverse_perm _)).trans + (List.filter_append_perm p l) + +lemma signedOrder_prefix [AddCommGroup E] (p : α → Bool) (l : List α) + (v : α → E) (hzero : (l.map v).sum = 0) (k : ℕ) : + (∃ j ≤ l.length, + (((signedOrder p l).take k).map v).sum = (((l.take j).filter p).map v).sum) ∨ + (∃ j ≤ l.length, + (((signedOrder p l).take k).map v).sum = + -((((l.take j).filter fun a => !p a).map v).sum)) := by + by_cases hk : k ≤ (l.filter p).length + · left + obtain ⟨j, hj, he⟩ := take_filter_eq_filter_take p l k + refine ⟨j, hj, ?_⟩ + simp only [signedOrder, List.take_append_of_le_length hk, he] + · right + let q : α → Bool := fun a => !p a + have hz : ((signedOrder p l).map v).sum = 0 := by + rw [((signedOrder_perm p l).map v).sum_eq, hzero] + have hd : + (((signedOrder p l).drop k).map v).sum = + ((((l.filter q).take ((l.filter q).length - (k - (l.filter p).length)))).map v).sum := by + simp [signedOrder, List.drop_append, List.drop_eq_nil_of_le (Nat.le_of_not_ge hk), + List.drop_reverse, q] + obtain ⟨j, hj, he⟩ := take_filter_eq_filter_take q l + ((l.filter q).length - (k - (l.filter p).length)) + refine ⟨j, hj, ?_⟩ + have hs := List.sum_take_add_sum_drop ((signedOrder p l).map v) k + rw [← List.map_take, ← List.map_drop, hz, hd, he] at hs + exact eq_neg_of_add_eq_zero_left hs + +lemma signed_parts [AddCommGroup E] (p : α → Bool) (l : List α) (v : α → E) : + 2 • (((l.filter p).map v).sum) = + (l.map v).sum + (l.map fun a => if p a then v a else -v a).sum ∧ + 2 • (((l.filter fun a => !p a).map v).sum) = + (l.map v).sum - (l.map fun a => if p a then v a else -v a).sum := by + induction l with + | nil => simp + | cons a l ih => + rcases ih with ⟨ihp, ihn⟩ + cases ha : p a <;> simp_all [two_nsmul, sub_eq_add_neg] <;> abel_nf <;> simp + +lemma signedOrder_prefix_bound [NormedAddCommGroup E] [NormedSpace ℝ E] + (p : α → Bool) (l : List α) (v : α → E) (B D : ℝ) + (hzero : (l.map v).sum = 0) + (hprefix : ∀ j ≤ l.length, ‖((l.take j).map v).sum‖ ≤ B) + (hsigned : ∀ j ≤ l.length, + ‖((l.take j).map fun a => if p a then v a else -v a).sum‖ ≤ D) + (k : ℕ) : ‖(((signedOrder p l).take k).map v).sum‖ ≤ (B + D) / 2 := by + rcases signedOrder_prefix p l v hzero k with ⟨j, hj, he⟩ | ⟨j, hj, he⟩ + · rw [he] + have hparts := (signed_parts p (l.take j) v).1 + have htwice : ‖(2 : ℝ) • (((l.take j).filter p).map v).sum‖ ≤ B + D := by + rw [two_smul, ← two_nsmul, hparts] + exact (norm_add_le _ _).trans (add_le_add (hprefix j hj) (hsigned j hj)) + rw [norm_smul] at htwice + norm_num at htwice + linarith + · rw [he, norm_neg] + have hparts := (signed_parts p (l.take j) v).2 + have htwice : ‖(2 : ℝ) • (((l.take j).filter fun a => !p a).map v).sum‖ ≤ B + D := by + rw [two_smul, ← two_nsmul, hparts] + exact (norm_sub_le _ _).trans (add_le_add (hprefix j hj) (hsigned j hj)) + rw [norm_smul] at htwice + norm_num at htwice + linarith + +lemma exists_perm_of_list_perm {N : ℕ} (l : List (Fin N)) + (hl : l.Perm (List.ofFn (id : Fin N → Fin N))) : + ∃ π : Equiv.Perm (Fin N), List.ofFn π = l := by + have hlen : l.length = N := by simpa using hl.length_eq + have hnodup : l.Nodup := hl.nodup_iff.mpr (List.nodup_ofFn.mpr Function.injective_id) + have hmem : ∀ i, i ∈ l := fun i => hl.mem_iff.mpr (List.mem_ofFn.mpr ⟨i, rfl⟩) + let π := (finCongr hlen.symm).trans (List.Nodup.getEquivOfForallMemList l hnodup hmem) + refine ⟨π, List.ext_getElem (by simp [hlen]) ?_⟩ + intro i hi hj + simp [π, List.Nodup.getEquivOfForallMemList] + +end Lists + +theorem signing_implies_ordering (C : ℝ) (h : SignedPrefixBound C) : + OrderingPrefixBound C := by + classical + intro d N hd hN v hv hzero + let peak : Equiv.Perm (Fin N) → ℝ := fun π => + Finset.univ.sup' Finset.univ_nonempty (fun k : Fin (N + 1) => + ‖walkPrefix (fun i => v (π i)) k.val‖) + obtain ⟨π, _, hmin⟩ := Finset.exists_min_image Finset.univ peak Finset.univ_nonempty + have hpeak (σ : Equiv.Perm (Fin N)) (k : ℕ) (hk : k ≤ N) : + ‖walkPrefix (fun i => v (σ i)) k‖ ≤ peak σ := + Finset.le_sup' (fun k : Fin (N + 1) => ‖walkPrefix (fun i => v (σ i)) k.val‖) + (Finset.mem_univ (⟨k, by omega⟩ : Fin (N + 1))) + obtain ⟨ε, hε, hsign⟩ := h d N hd hN (fun i => v (π i)) (fun i => hv (π i)) + let p : Fin N → Bool := fun i => decide (ε i = 1) + let l : List (Fin N) := List.ofFn id + have heps (i : Fin N) : (if p i then v (π i) else -v (π i)) = ε i • v (π i) := by + rcases hε i with hi | hi <;> norm_num [p, hi] + have hz : (l.map fun i => v (π i)).sum = 0 := by + simpa [l, List.map_ofFn, List.sum_ofFn, Equiv.sum_comp] using hzero + obtain ⟨σ, hσ⟩ := exists_perm_of_list_perm (signedOrder p l) (signedOrder_perm p l) + have hpref : ∀ k ≤ l.length, ‖((l.take k).map fun i => v (π i)).sum‖ ≤ peak π := by + intro k hk + simpa [l, List.map_take, List.map_ofFn, sum_take_ofFn, walkPrefix] using + hpeak π k (by simpa [l] using hk) + have hsig : ∀ k ≤ l.length, + ‖((l.take k).map fun i => if p i then v (π i) else -v (π i)).sum‖ ≤ C * Real.sqrt d := by + intro k hk + simp_rw [heps] + simpa [l, List.map_take, List.map_ofFn, sum_take_ofFn, walkPrefix] using + hsign k (by simpa [l] using hk) + have hnew : peak (σ.trans π) ≤ (peak π + C * Real.sqrt d) / 2 := by + apply (Finset.sup'_le_iff _ _).mpr + intro k _ + have hh := signedOrder_prefix_bound p l (fun i => v (π i)) + (peak π) (C * Real.sqrt d) hz hpref hsig k.val + rw [← hσ, List.map_take, List.map_ofFn, sum_take_ofFn] at hh + exact hh + have hβ : peak π ≤ C * Real.sqrt d := by + have := hmin (σ.trans π) (Finset.mem_univ _) + linarith + exact ⟨π, fun k hk => (hpeak π k hk).trans hβ⟩ + +end EuclideanSteinitzBergstrom + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/AffineAveraging.lean b/lean/OAI/Analysis/StrictMeans/AffineAveraging.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc92ad065cc8b23d9ccf72ee218c0476cdd16f3a --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/AffineAveraging.lean @@ -0,0 +1,351 @@ +import OAI.Analysis.StrictMeans.HorizontalAveraging + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology + +open Set Filter Function MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +def expScalePoint (t : ℝ) : UpperHalfPlane := xyPoint 0 (Real.exp t) (Real.exp_pos t) + +lemma continuous_expScalePoint : Continuous expScalePoint := + continuous_xyPoint continuous_const Real.continuous_exp _ + +lemma affineProduct_expScale (s t : ℝ) : + affineProduct (expScalePoint s) (expScalePoint t) = expScalePoint (s + t) := by + simp [expScalePoint, affineProduct_xyPoint, Real.exp_add] + +lemma halfScale_expScale (t : ℝ) : + affineProduct halfScalePoint (expScalePoint (t + Real.log 2)) = expScalePoint t := by + have he : Real.exp (t + Real.log 2) = Real.exp t * 2 := by + rw [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + simp [halfScalePoint, expScalePoint, affineProduct_xyPoint, he] + congr 1 + ring + +lemma expScale_horizontal (t s : ℝ) : + affineProduct (expScalePoint t) (horizontalPoint s) = + affineProduct (horizontalPoint (Real.exp t * s)) (expScalePoint t) := by + simp [expScalePoint, horizontalPoint, affineProduct_xyPoint] + +lemma weighted_scale_periodic (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (β ρ : ℝ) + (hpower : Real.exp (β * Real.log 2) = ρ) + (hscale : ∀ φ, Λ (affineOperator halfScalePoint φ) = ρ * Λ φ) + (φ : C(DiskFamily, ℝ)) : + Periodic (fun t => Real.exp (β * t) * Λ (affineOperator (expScalePoint t) φ)) (Real.log 2) := by + intro t + have hs := hscale (affineOperator (expScalePoint (t + Real.log 2)) φ) + rw [← mul_apply_eq_comp, affineOperator_mul, halfScale_expScale] at hs + change Real.exp (β * (t + Real.log 2)) * _ = _ + rw [mul_add, Real.exp_add, hpower, mul_assoc, ← hs] + +lemma weighted_scale_bound (β a b : ℝ) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ t ∈ uIcc a b, + ‖Real.exp (β * t) • affineOperator (expScalePoint t)‖ ≤ C := by + obtain ⟨C, hC, hbound⟩ := affineOperator_compact_bound expScalePoint continuous_expScalePoint a b + let : CompactSpace (uIcc a b) := isCompact_iff_compactSpace.mp isCompact_uIcc + let W : C(uIcc a b, ℝ) := ⟨fun t => Real.exp (β * t), + Real.continuous_exp.comp (continuous_const.mul continuous_subtype_val)⟩ + refine ⟨‖W‖ * C, mul_nonneg (norm_nonneg _) hC, fun t ht => ?_⟩ + calc + ‖Real.exp (β * t) • affineOperator (expScalePoint t)‖ ≤ + ‖Real.exp (β * t)‖ * ‖affineOperator (expScalePoint t)‖ := + ContinuousLinearMap.opNorm_smul_le _ _ + _ ≤ ‖W‖ * C := mul_le_mul (W.norm_coe_le_norm ⟨t, ht⟩) (hbound t ht) + (ContinuousLinearMap.opNorm_nonneg _) (norm_nonneg _) + +def scaleAverage (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (β : ℝ) : C(DiskFamily, ℝ) →L[ℝ] ℝ := + intervalFunctional Λ (fun t => Real.exp (β * t) • affineOperator (expScalePoint t)) + (fun φ => (Real.continuous_exp.comp (continuous_const.mul continuous_id)).smul + ((continuous_affineOperator_strong φ).comp continuous_expScalePoint)) + 0 (Real.log 2) (weighted_scale_bound β 0 (Real.log 2)) + +@[simp] lemma scaleAverage_apply (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (β : ℝ) + (φ : C(DiskFamily, ℝ)) : + scaleAverage Λ β φ = ∫ t in 0..Real.log 2, + Real.exp (β * t) * Λ (affineOperator (expScalePoint t) φ) := by + simp only [scaleAverage, intervalFunctional_apply, smul_apply, map_smul, + smul_eq_mul] + +lemma scaleAverage_horizontal (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (β s : ℝ) + (hΛ : ∀ x φ, Λ (affineOperator (horizontalPoint x) φ) = Λ φ) + (φ : C(DiskFamily, ℝ)) : + scaleAverage Λ β (affineOperator (horizontalPoint s) φ) = scaleAverage Λ β φ := by + simp only [scaleAverage_apply] + congr 1 + ext t + rw [← mul_apply_eq_comp, affineOperator_mul, expScale_horizontal, ← affineOperator_mul, + mul_apply_eq_comp, hΛ] + +lemma scaleAverage_scale (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (β ρ s : ℝ) + (hpower : Real.exp (β * Real.log 2) = ρ) + (hscale : ∀ φ, Λ (affineOperator halfScalePoint φ) = ρ * Λ φ) + (φ : C(DiskFamily, ℝ)) : + scaleAverage Λ β (affineOperator (expScalePoint s) φ) = + Real.exp (-β * s) * scaleAverage Λ β φ := by + simp only [scaleAverage_apply] + have he (t : ℝ) : Real.exp (β * t) * + Λ (affineOperator (expScalePoint t) (affineOperator (expScalePoint s) φ)) = + Real.exp (-β * s) * (Real.exp (β * (t + s)) * + Λ (affineOperator (expScalePoint (t + s)) φ)) := by + rw [← mul_apply_eq_comp, affineOperator_mul, affineProduct_expScale, + ← mul_assoc, ← Real.exp_add] + congr 2 + ring + simp_rw [he] + rw [intervalIntegral.integral_const_mul] + have hp := weighted_scale_periodic Λ β ρ hpower hscale φ + have hi := intervalIntegral.integral_comp_add_right + (fun t => Real.exp (β * t) * Λ (affineOperator (expScalePoint t) φ)) s + (a := 0) (b := Real.log 2) + rw [hi, zero_add, add_comm (Real.log 2) s, hp.intervalIntegral_add_eq s 0, zero_add] + +lemma scaleAverage_affine (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (β ρ : ℝ) + (hpower : Real.exp (β * Real.log 2) = ρ) + (hscale : ∀ φ, Λ (affineOperator halfScalePoint φ) = ρ * Λ φ) + (hΛ : ∀ x φ, Λ (affineOperator (horizontalPoint x) φ) = Λ φ) + (z : UpperHalfPlane) (φ : C(DiskFamily, ℝ)) : + scaleAverage Λ β (affineOperator z φ) = z.im ^ (-β) * scaleAverage Λ β φ := by + have he : z = affineProduct (horizontalPoint z.re) (expScalePoint (Real.log z.im)) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, horizontalPoint, expScalePoint, xyPoint, + Real.exp_log z.im_pos] + exact (Complex.re_add_im (z : ℂ)).symm + conv_lhs => rw [he] + rw [← affineOperator_mul, mul_apply_eq_comp, + scaleAverage_horizontal Λ β z.re hΛ, scaleAverage_scale Λ β ρ _ hpower hscale] + congr 1 + rw [Real.rpow_def_of_pos z.im_pos] + congr 1 + ring + +end +end StrictInverseFirstPower + +open Set Filter Function MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +lemma positiveFunctional_strict (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (hΛ : Monotone Λ) + (h1 : 0 < Λ 1) (φ : C(DiskFamily, ℝ)) (hφ : ∀ f, 0 < φ f) : 0 < Λ φ := by + obtain ⟨f, _, hf⟩ := isCompact_univ.exists_isMinOn (univ_nonempty : (univ : Set DiskFamily).Nonempty) + φ.continuous.continuousOn + have hle : φ f • (1 : C(DiskFamily, ℝ)) ≤ φ := by + intro g + change φ f * 1 ≤ φ g + rw [mul_one] + exact hf (mem_univ g) + have hh := hΛ hle + rw [map_smul, smul_eq_mul] at hh + exact lt_of_lt_of_le (mul_pos (hφ f) h1) hh + +lemma positiveFunctional_affine_one (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (hΛ : Monotone Λ) + (h1 : 0 < Λ 1) (z : UpperHalfPlane) : 0 < Λ (affineOperator z 1) := by + apply positiveFunctional_strict Λ hΛ h1 + intro f + simpa using norm_pos_iff.mpr (halfPlaneQ_ne_zero f z) + +lemma horizontalAverage_monotone (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (hΛ : Monotone Λ) : + Monotone (horizontalAverage Λ) := by + intro φ ψ h + simp only [horizontalAverage_apply] + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply intervalIntegral.integral_mono (by norm_num) + (((continuous_functional_affine Λ φ).comp continuous_horizontalPoint).intervalIntegrable _ _) + (((continuous_functional_affine Λ ψ).comp continuous_horizontalPoint).intervalIntegrable _ _) + intro t + exact hΛ (affineOperator_monotone _ h) + +lemma horizontalAverage_one_pos (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (hΛ : Monotone Λ) + (h1 : 0 < Λ 1) : 0 < horizontalAverage Λ 1 := by + rw [horizontalAverage_apply] + apply mul_pos (by norm_num) + apply intervalIntegral.intervalIntegral_pos_of_pos + (((continuous_functional_affine Λ 1).comp continuous_horizontalPoint).intervalIntegrable _ _) + (fun t => positiveFunctional_affine_one Λ hΛ h1 _) (by norm_num) + +lemma scaleAverage_monotone (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (hΛ : Monotone Λ) (β : ℝ) : + Monotone (scaleAverage Λ β) := by + intro φ ψ h + simp only [scaleAverage_apply] + have hc (φ : C(DiskFamily, ℝ)) : Continuous + (fun t => Real.exp (β * t) * Λ (affineOperator (expScalePoint t) φ)) := + (Real.continuous_exp.comp (continuous_const.mul continuous_id)).mul + ((continuous_functional_affine Λ φ).comp continuous_expScalePoint) + apply intervalIntegral.integral_mono (Real.log_nonneg (by norm_num)) + ((hc φ).intervalIntegrable _ _) ((hc ψ).intervalIntegrable _ _) + intro t + exact mul_le_mul_of_nonneg_left (hΛ (affineOperator_monotone _ h)) (Real.exp_pos _).le + +lemma scaleAverage_one_pos (Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ) (hΛ : Monotone Λ) + (h1 : 0 < Λ 1) (β : ℝ) : 0 < scaleAverage Λ β 1 := by + rw [scaleAverage_apply] + have hc : Continuous (fun t => Real.exp (β * t) * Λ (affineOperator (expScalePoint t) 1)) := + (Real.continuous_exp.comp (continuous_const.mul continuous_id)).mul + ((continuous_functional_affine Λ 1).comp continuous_expScalePoint) + exact intervalIntegral.intervalIntegral_pos_of_pos (hc.intervalIntegrable _ _) + (fun t => mul_pos (Real.exp_pos _) (positiveFunctional_affine_one Λ hΛ h1 _)) + (Real.log_pos (by norm_num)) + +lemma dyadicExponent_power : Real.exp (dyadicExponent * Real.log 2) = dyadicRadius := by + unfold dyadicExponent dyadicRadius + rw [div_mul_cancel₀ _ (ne_of_gt (Real.log_pos (by norm_num : (1 : ℝ) < 2)))] + +lemma dyadicExponent_pos_iff : 0 < dyadicExponent ↔ 1 < dyadicRadius := by + rw [dyadicExponent, dyadicRadius, Real.one_lt_exp_iff, div_pos_iff_of_pos_right + (Real.log_pos (by norm_num))] + +theorem exists_exact_affine_functional (hβ : 0 < dyadicExponent) : + ∃ Λ : C(DiskFamily, ℝ) →L[ℝ] ℝ, Monotone Λ ∧ Λ 1 = 1 ∧ + ∀ (z : UpperHalfPlane) (φ : C(DiskFamily, ℝ)), + Λ (affineOperator z φ) = z.im ^ (-dyadicExponent) * Λ φ := by + obtain ⟨Λ, hΛ, h1, heigen⟩ := exists_dyadic_eigenfunctional + have hper := eigenfunctional_horizontal_period Λ dyadicRadius + (dyadicExponent_pos_iff.mp hβ) heigen + let Λh := horizontalAverage Λ + have hΛh : Monotone Λh := horizontalAverage_monotone Λ hΛ + have hh1 : 0 < Λh 1 := horizontalAverage_one_pos Λ hΛ (by rw [h1]; norm_num) + let ν := scaleAverage Λh dyadicExponent + have hν : Monotone ν := scaleAverage_monotone Λh hΛh _ + have hν1 : 0 < ν 1 := scaleAverage_one_pos Λh hΛh hh1 _ + refine ⟨(ν 1)⁻¹ • ν, ?_, ?_, ?_⟩ + · intro φ ψ h + exact mul_le_mul_of_nonneg_left (hν h) (inv_nonneg.mpr hν1.le) + · change (ν 1)⁻¹ * ν 1 = 1 + exact inv_mul_cancel₀ hν1.ne' + · intro z φ + change (ν 1)⁻¹ * ν (affineOperator z φ) = z.im ^ (-dyadicExponent) * ((ν 1)⁻¹ * ν φ) + rw [show ν (affineOperator z φ) = z.im ^ (-dyadicExponent) * ν φ from + scaleAverage_affine Λh dyadicExponent dyadicRadius dyadicExponent_power + (horizontalAverage_halfScale Λ dyadicRadius hper heigen) + (horizontalAverage_invariant Λ hper) z φ] + ring + +theorem exists_exact_affine_probability_continuous (hβ : 0 < dyadicExponent) : + ∃ μ : ProbabilityMeasure DiskFamily, ∀ (z : UpperHalfPlane) (φ : C(DiskFamily, ℝ)), + (∫ f, ‖halfPlaneQ f z‖ * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + z.im ^ (-dyadicExponent) * ∫ f, φ f ∂(μ : Measure DiskFamily) := by + obtain ⟨Λ, hΛ, h1, hlaw⟩ := exists_exact_affine_functional hβ + obtain ⟨μ, hμ⟩ := exists_probabilityMeasure_of_positiveFunctional Λ hΛ h1 + refine ⟨μ, fun z φ => ?_⟩ + change (∫ f, affineOperator z φ f ∂(μ : Measure DiskFamily)) = _ + rw [hμ, hμ, hlaw] + +end +end StrictInverseFirstPower + +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal + +namespace StrictInverseFirstPower +noncomputable section + +def weightedRebaseMeasure (μ : Measure DiskFamily) (z : UpperHalfPlane) : Measure DiskFamily := + (μ.withDensity (fun f => ‖halfPlaneQ f z‖₊)).map (fun f => rebase f z) + +lemma measurable_rebase_fixed (z : UpperHalfPlane) : Measurable (fun f => rebase f z) := + (continuous_rebase.comp (continuous_id.prodMk continuous_const)).measurable + +lemma measurable_Qnorm_fixed (z : UpperHalfPlane) : Measurable (fun f => ‖halfPlaneQ f z‖₊) := + ((continuous_halfPlaneQ.comp (continuous_id.prodMk continuous_const)).nnnorm).measurable + +instance weightedRebaseMeasure_isFinite (μ : Measure DiskFamily) [IsFiniteMeasure μ] + (z : UpperHalfPlane) : IsFiniteMeasure (weightedRebaseMeasure μ z) := by + have hi : Integrable (fun f => halfPlaneQ f z) μ := + (continuous_halfPlaneQ.comp (continuous_id.prodMk continuous_const)).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + have : IsFiniteMeasure (μ.withDensity (fun f => ‖halfPlaneQ f z‖₊)) := + isFiniteMeasure_withDensity hi.hasFiniteIntegral.ne + unfold weightedRebaseMeasure + infer_instance + +lemma weightedRebaseMeasure_integral (μ : Measure DiskFamily) (z : UpperHalfPlane) + (φ : C(DiskFamily, ℝ)) : + (∫ f, φ f ∂weightedRebaseMeasure μ z) = ∫ f, affineOperator z φ f ∂μ := by + rw [weightedRebaseMeasure, integral_map (measurable_rebase_fixed z).aemeasurable + φ.continuous.aestronglyMeasurable, integral_withDensity_eq_integral_smul (measurable_Qnorm_fixed z)] + rfl + +lemma weightedRebaseMeasure_lintegral (μ : Measure DiskFamily) (z : UpperHalfPlane) + (φ : DiskFamily → ℝ≥0∞) (hφ : Measurable φ) : + (∫⁻ f, φ f ∂weightedRebaseMeasure μ z) = + ∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂μ := by + rw [weightedRebaseMeasure, lintegral_map hφ (measurable_rebase_fixed z)] + exact lintegral_withDensity_eq_lintegral_mul _ (measurable_Qnorm_fixed z).coe_nnreal_ennreal + (hφ.comp (measurable_rebase_fixed z)) + +lemma weightedRebaseMeasure_eq_smul (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hlaw : ∀ (z : UpperHalfPlane) (φ : C(DiskFamily, ℝ)), + (∫ f, affineOperator z φ f ∂(μ : Measure DiskFamily)) = + z.im ^ (-β) * ∫ f, φ f ∂(μ : Measure DiskFamily)) (z : UpperHalfPlane) : + weightedRebaseMeasure (μ : Measure DiskFamily) z = + ENNReal.ofReal (z.im ^ (-β)) • (μ : Measure DiskFamily) := by + have : IsFiniteMeasure (ENNReal.ofReal (z.im ^ (-β)) • (μ : Measure DiskFamily)) := + ⟨by simp [Measure.smul_apply]⟩ + apply MeasureTheory.ext_of_forall_integral_eq_of_IsFiniteMeasure + intro φ + change (∫ f, φ.toContinuousMap f ∂weightedRebaseMeasure (μ : Measure DiskFamily) z) = + ∫ f, φ.toContinuousMap f ∂ENNReal.ofReal (z.im ^ (-β)) • (μ : Measure DiskFamily) + rw [weightedRebaseMeasure_integral _ _ φ.toContinuousMap, hlaw] + rw [integral_smul_measure, ENNReal.toReal_ofReal (Real.rpow_nonneg z.im_pos.le _)] + rfl + +theorem exists_exact_affine_probability (hβ : 0 < dyadicExponent) : + ∃ μ : ProbabilityMeasure DiskFamily, ∀ (z : UpperHalfPlane) + (φ : DiskFamily → ℝ≥0∞), Measurable φ → + (∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ (-dyadicExponent)) * ∫⁻ f, φ f ∂(μ : Measure DiskFamily) := by + obtain ⟨μ, hμ⟩ := exists_exact_affine_probability_continuous hβ + refine ⟨μ, fun z φ hφ => ?_⟩ + rw [← weightedRebaseMeasure_lintegral _ _ _ hφ, + weightedRebaseMeasure_eq_smul μ dyadicExponent hμ z, lintegral_smul_measure] + rfl + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/AreaCoefficients.lean b/lean/OAI/Analysis/StrictMeans/AreaCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..576731a79bf50ae84b6c455bbc959a356df2095d --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/AreaCoefficients.lean @@ -0,0 +1,639 @@ +import OAI.Analysis.StrictMeans.RectangleLog + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate + +namespace StrictInverseFirstPower +noncomputable section + +lemma norm_sq_sub_complex (w a : ℂ) : + ‖w - a‖ ^ 2 = ‖w‖ ^ 2 - 2 * (conj a * w).re + ‖a‖ ^ 2 := by + simp only [← Complex.normSq_eq_norm_sq, Complex.normSq_apply, + Complex.sub_re, Complex.sub_im, Complex.mul_re, Complex.conj_re, Complex.conj_im] + ring + +theorem norm_sq_center_le_circleAverage {f : ℂ → ℂ} {c : ℂ} {r : ℝ} + (hf : DiffContOnCl ℂ f (ball c |r|)) : + ‖f c‖ ^ 2 ≤ Real.circleAverage (fun z => ‖f z‖ ^ 2) c r := by + by_cases hr : r = 0 + · simp [hr] + have hs : ContinuousOn f (sphere c |r|) := hf.2.mono (sphere_subset_closedBall.trans (by + rw [closure_ball _ (abs_ne_zero.mpr hr)])) + have hc : ContinuousOn (fun z => (conj (f c) * f z).re) (sphere c |r|) := + Complex.continuous_re.comp_continuousOn (hs.const_mul _) + have hm : Real.circleAverage (fun z => (conj (f c) * f z).re) c r = ‖f c‖ ^ 2 := by + have hd : DiffContOnCl ℂ (fun z => conj (f c) * f z) (ball c |r|) := + ⟨fun z hz => (hf.1 z hz).const_mul _, hf.2.const_mul _⟩ + calc + _ = (Real.circleAverage (fun z => conj (f c) * f z) c r).re := + Complex.reCLM.circleAverage_comp_comm ((hs.const_mul _).circleIntegrable') + _ = (conj (f c) * f c).re := by rw [hd.circleAverage] + _ = ‖f c‖ ^ 2 := by + simp [← Complex.normSq_eq_norm_sq, Complex.normSq_apply, Complex.mul_re] + have hineq := Real.circleAverage_mono + ((hc.const_mul 2).sub (continuousOn_const (c := ‖f c‖ ^ 2))).circleIntegrable' + (hs.norm.pow 2).circleIntegrable' (fun z _ => ?_) + · rw [Real.circleAverage_sub] at hineq + change Real.circleAverage ((2 : ℝ) • (fun z => (conj (f c) * f z).re)) c r - + Real.circleAverage (fun _ => ‖f c‖ ^ 2) c r ≤ _ at hineq + rw [Real.circleAverage_smul, Real.circleAverage_const, hm] at hineq + · change 2 * ‖f c‖ ^ 2 - ‖f c‖ ^ 2 ≤ Real.circleAverage (fun z => ‖f z‖ ^ 2) c r at hineq + linarith + · exact (hc.const_mul 2).circleIntegrable' + · exact circleIntegrable_const _ _ _ + · have hn := sq_nonneg ‖f z - f c‖ + rw [norm_sq_sub_complex] at hn + change 2 * (conj (f c) * f z).re - ‖f c‖ ^ 2 ≤ ‖f z‖ ^ 2 + linarith + +lemma inverse_sq_conj_of_norm_eq {z : ℂ} {r : ℝ} (hr : 0 < r) (hz : ‖z‖ = r) : + conj (z⁻¹ ^ 2) = z ^ 2 / (r : ℂ) ^ 4 := by + have hz0 : z ≠ 0 := by intro he; simp [he] at hz; linarith + have hc0 : conj z ≠ 0 := by simpa using hz0 + have hconj : conj z * z = (r : ℂ) ^ 2 := by + rw [← Complex.normSq_eq_conj_mul_self, Complex.normSq_eq_norm_sq, hz, Complex.ofReal_pow] + have hr0 : (r : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hr.ne' + rw [map_pow, map_inv₀] + apply (eq_div_iff (pow_ne_zero 4 hr0)).mpr + calc + (conj z)⁻¹ ^ 2 * (r : ℂ) ^ 4 = (conj z)⁻¹ ^ 2 * (conj z * z) ^ 2 := by + rw [hconj]; ring + _ = z ^ 2 := by field_simp + +lemma norm_sq_inverse_sq_sub {z w : ℂ} {r : ℝ} (hr : 0 < r) (hz : ‖z‖ = r) : + ‖w - z⁻¹ ^ 2‖ ^ 2 = ‖w‖ ^ 2 + r⁻¹ ^ 4 - 2 * r⁻¹ ^ 4 * (z ^ 2 * w).re := by + rw [norm_sq_sub_complex, inverse_sq_conj_of_norm_eq hr hz, norm_pow, norm_inv, hz] + rw [div_mul_eq_mul_div, ← Complex.ofReal_pow, Complex.div_ofReal_re] + simp only [div_eq_mul_inv, inv_pow] + ring + +theorem circleAverage_norm_sq_pole {g : ℂ → ℂ} {r : ℝ} (hr : 0 < r) + (hg : DiffContOnCl ℂ g (ball 0 r)) : + Real.circleAverage (fun z => ‖g z - z⁻¹ ^ 2‖ ^ 2) 0 r = + Real.circleAverage (fun z => ‖g z‖ ^ 2) 0 r + r⁻¹ ^ 4 := by + have hs : ContinuousOn g (sphere 0 |r|) := by + rw [abs_of_pos hr] + exact hg.2.mono (sphere_subset_closedBall.trans (by rw [closure_ball _ hr.ne'])) + have hp : DiffContOnCl ℂ (fun z => z ^ 2 * g z) (ball 0 |r|) := by + rw [abs_of_pos hr] + exact ⟨fun z hz => ((differentiableAt_id.pow 2).differentiableWithinAt.mul (hg.1 z hz)), + (continuousOn_id.pow 2).mul hg.2⟩ + have hpc : CircleIntegrable (fun z => z ^ 2 * g z) 0 r := + ((continuousOn_id.pow 2).mul hs).circleIntegrable' + have hmean : Real.circleAverage (fun z => (z ^ 2 * g z).re) 0 r = 0 := by + calc + _ = (Real.circleAverage (fun z => z ^ 2 * g z) 0 r).re := + Complex.reCLM.circleAverage_comp_comm hpc + _ = 0 := by rw [hp.circleAverage]; simp + have hc : ContinuousOn (fun z => (z ^ 2 * g z).re) (sphere 0 |r|) := + Complex.continuous_re.comp_continuousOn ((continuousOn_id.pow 2).mul hs) + rw [Real.circleAverage_congr_sphere (fun z hz => + norm_sq_inverse_sq_sub hr (by simpa only [mem_sphere, dist_zero_right, abs_of_pos hr] using hz))] + rw [Real.circleAverage_fun_sub, Real.circleAverage_fun_add, Real.circleAverage_const] + · have hm : Real.circleAverage (fun z => 2 * r⁻¹ ^ 4 * (z ^ 2 * g z).re) 0 r = 0 := by + change Real.circleAverage ((2 * r⁻¹ ^ 4) • (fun z => (z ^ 2 * g z).re)) 0 r = 0 + rw [Real.circleAverage_smul, hmean, smul_zero] + rw [hm, sub_zero] + · exact (hs.norm.pow 2).circleIntegrable' + · exact circleIntegrable_const _ _ _ + · exact ((hs.norm.pow 2).add continuousOn_const).circleIntegrable' + · exact (hc.const_mul _).circleIntegrable' + +theorem circleAverage_norm_sq_pole_lower {g : ℂ → ℂ} {r : ℝ} (hr : 0 < r) + (hg : DiffContOnCl ℂ g (ball 0 r)) : + r⁻¹ ^ 4 + ‖g 0‖ ^ 2 ≤ Real.circleAverage (fun z => ‖g z - z⁻¹ ^ 2‖ ^ 2) 0 r := by + rw [circleAverage_norm_sq_pole hr hg] + have hm := norm_sq_center_le_circleAverage (r := r) (by simpa only [abs_of_pos hr] using hg) + linarith + +lemma circleAverage_eq_integral_neg_pi {f : ℂ → ℝ} {c : ℂ} {r : ℝ} : + Real.circleAverage f c r = (2 * Real.pi)⁻¹ * + ∫ θ in -Real.pi..Real.pi, f (circleMap c r θ) := by + rw [Real.circleAverage_eq_integral_add (-Real.pi), smul_eq_mul, + intervalIntegral.integral_comp_add_right (fun θ => f (circleMap c r θ)) (-Real.pi)] + congr 2 <;> ring + +lemma lintegral_circle_eq {f : ℂ → ℝ} {c : ℂ} {r : ℝ} + (hf : ContinuousOn f (sphere c |r|)) (hpos : ∀ z ∈ sphere c |r|, 0 ≤ f z) : + (∫⁻ θ in Ioo (-Real.pi) Real.pi, ENNReal.ofReal (f (circleMap c r θ))) = + ENNReal.ofReal (2 * Real.pi * Real.circleAverage f c r) := by + have hi : IntervalIntegrable (fun θ => f (circleMap c r θ)) volume (-Real.pi) Real.pi := by + apply ContinuousOn.intervalIntegrable + exact hf.comp (continuous_circleMap c r).continuousOn (fun θ _ => circleMap_mem_sphere' c r θ) + rw [circleAverage_eq_integral_neg_pi] + have he : 2 * Real.pi * ((2 * Real.pi)⁻¹ * ∫ θ in -Real.pi..Real.pi, f (circleMap c r θ)) = + ∫ θ in -Real.pi..Real.pi, f (circleMap c r θ) := by + rw [← mul_assoc, mul_inv_cancel₀ (by positivity : 2 * Real.pi ≠ 0), one_mul] + rw [he, intervalIntegral.integral_of_le (by linarith [Real.pi_pos]), + integral_Ioc_eq_integral_Ioo] + symm + apply ofReal_integral_eq_lintegral_ofReal + · exact hi.1.mono_set (Ioo_subset_Ioc_self) + · filter_upwards with θ + exact hpos _ (circleMap_mem_sphere' c r θ) + +lemma annulus_lintegral_polar_lower {f : ℂ → ℝ≥0∞} {r R : ℝ} (hr : 0 < r) (hf : Measurable f) : + (∫⁻ ρ in Icc r R, ∫⁻ θ in Ioo (-Real.pi) Real.pi, + ENNReal.ofReal ρ * f (circleMap 0 ρ θ)) ≤ + ∫⁻ z in {z : ℂ | r ≤ ‖z‖ ∧ ‖z‖ ≤ R}, f z := by + let A : Set ℂ := {z | r ≤ ‖z‖ ∧ ‖z‖ ≤ R} + have hA : MeasurableSet A := (isClosed_le continuous_const continuous_norm).measurableSet.inter + (isClosed_le continuous_norm continuous_const).measurableSet + have hpolar (p : ℝ × ℝ) : Complex.polarCoord.symm p = circleMap 0 p.1 p.2 := by + simp [Complex.polarCoord_symm_apply, circleMap, Complex.exp_mul_I] + calc + _ ≤ ∫⁻ p : ℝ × ℝ in Icc r R ×ˢ Ioo (-Real.pi) Real.pi, + ENNReal.ofReal p.1 * f (circleMap 0 p.1 p.2) := by + rw [Measure.volume_eq_prod, ← Measure.prod_restrict] + apply le_of_eq + symm + apply lintegral_prod + exact (ENNReal.measurable_ofReal.comp measurable_fst |>.mul + (hf.comp (by fun_prop [circleMap]))).aemeasurable + _ = ∫⁻ p : ℝ × ℝ in Icc r R ×ˢ Ioo (-Real.pi) Real.pi, + ENNReal.ofReal p.1 * A.indicator f (Complex.polarCoord.symm p) := by + apply setLIntegral_congr_fun (measurableSet_Icc.prod measurableSet_Ioo) + intro p hp + dsimp only + rw [indicator_of_mem, hpolar] + change r ≤ ‖Complex.polarCoord.symm p‖ ∧ ‖Complex.polarCoord.symm p‖ ≤ R + rw [Complex.norm_polarCoord_symm, abs_of_pos (lt_of_lt_of_le hr hp.1.1)] + exact hp.1 + _ ≤ ∫⁻ p in polarCoord.target, + ENNReal.ofReal p.1 * A.indicator f (Complex.polarCoord.symm p) := by + apply lintegral_mono_set + exact prod_mono (fun ρ hρ => lt_of_lt_of_le hr hρ.1) Subset.rfl + _ = ∫⁻ z in A, f z := by + rw [← lintegral_indicator hA] + exact Complex.lintegral_comp_polarCoord_symm _ + _ = _ := rfl + +lemma radial_pole_integral {r R B : ℝ} (hr : 0 < r) (hR : r ≤ R) : + (∫ ρ in r..R, 2 * Real.pi * ρ * (ρ⁻¹ ^ 4 + B ^ 2)) = + Real.pi * (r⁻¹ ^ 2 - R⁻¹ ^ 2) + Real.pi * B ^ 2 * (R ^ 2 - r ^ 2) := by + have hz : (0 : ℝ) ∉ uIcc r R := notMem_uIcc_of_lt hr (hr.trans_le hR) + have hi₁ := intervalIntegral.intervalIntegrable_zpow (μ := volume) (n := (-3 : ℤ)) (Or.inr hz) + have hi₂ : IntervalIntegrable (fun ρ : ℝ => ρ) volume r R := continuous_id.intervalIntegrable _ _ + have he : (∫ ρ in r..R, 2 * Real.pi * ρ * (ρ⁻¹ ^ 4 + B ^ 2)) = + ∫ ρ in r..R, 2 * Real.pi * (ρ ^ (-3 : ℤ) + B ^ 2 * ρ) := by + apply intervalIntegral.integral_congr + intro ρ hρ + have hρ0 : ρ ≠ 0 := by intro he; subst ρ; exact hz hρ + simp only [zpow_neg, zpow_ofNat] + field_simp + rw [he, intervalIntegral.integral_const_mul, + intervalIntegral.integral_add hi₁ (hi₂.const_mul _), intervalIntegral.integral_const_mul, + integral_zpow (Or.inr ⟨by norm_num, hz⟩), integral_id] + norm_num + ring + +lemma pole_circle_density_lower {g : ℂ → ℂ} {ρ : ℝ} (hρpos : 0 < ρ) + (hgd : DiffContOnCl ℂ g (ball 0 ρ)) : + ENNReal.ofReal (2 * Real.pi * ρ * (ρ⁻¹ ^ 4 + ‖g 0‖ ^ 2)) ≤ + ∫⁻ θ in Ioo (-Real.pi) Real.pi, ENNReal.ofReal ρ * + ENNReal.ofReal (‖g (circleMap 0 ρ θ) - (circleMap 0 ρ θ)⁻¹ ^ 2‖ ^ 2) := by + have hs : ContinuousOn g (sphere 0 |ρ|) := by + rw [abs_of_pos hρpos] + exact hgd.2.mono (sphere_subset_closedBall.trans (by rw [closure_ball _ hρpos.ne'])) + have hsi : ContinuousOn (fun z : ℂ => z⁻¹ ^ 2) (sphere 0 |ρ|) := + (continuousOn_id.inv₀ (fun z hz => by + intro he; change z = 0 at he; subst z; simp only [mem_sphere, dist_self, abs_of_pos hρpos] at hz; linarith)).pow 2 + have hsc : ContinuousOn (fun z => ‖g z - z⁻¹ ^ 2‖ ^ 2) (sphere 0 |ρ|) := + (hs.sub hsi).norm.pow 2 + have he := lintegral_circle_eq hsc (fun _ _ => sq_nonneg _) + rw [lintegral_const_mul' _ _ (by simp), he] + rw [← ENNReal.ofReal_mul hρpos.le] + apply ENNReal.ofReal_le_ofReal + have hm := circleAverage_norm_sq_pole_lower hρpos hgd + calc + _ ≤ (2 * Real.pi * ρ) * Real.circleAverage (fun z => ‖g z - z⁻¹ ^ 2‖ ^ 2) 0 ρ := + mul_le_mul_of_nonneg_left hm (by positivity) + _ = _ := by ring + +theorem annulus_pole_area_lower {g : ℂ → ℂ} {r R : ℝ} (hr : 0 < r) (hR : r ≤ R) + (hg : DiffContOnCl ℂ g (ball 0 R)) : + ENNReal.ofReal (Real.pi * (r⁻¹ ^ 2 - R⁻¹ ^ 2) + + Real.pi * ‖g 0‖ ^ 2 * (R ^ 2 - r ^ 2)) ≤ + ∫⁻ z in {z : ℂ | r ≤ ‖z‖ ∧ ‖z‖ ≤ R}, + ENNReal.ofReal (‖g z - z⁻¹ ^ 2‖ ^ 2) := by + let A : Set ℂ := {z | r ≤ ‖z‖ ∧ ‖z‖ ≤ R} + have hA : MeasurableSet A := (isClosed_le continuous_const continuous_norm).measurableSet.inter + (isClosed_le continuous_norm continuous_const).measurableSet + have hgc : ContinuousOn g A := by + apply hg.2.mono + rw [closure_ball _ (hr.trans_le hR).ne'] + exact fun z hz => by simpa only [mem_closedBall, dist_zero_right] using hz.2 + have hic : ContinuousOn (fun z : ℂ => z⁻¹ ^ 2) A := + (continuousOn_id.inv₀ (fun z hz => by intro he; change z = 0 at he; subst z; have hh : r ≤ ‖(0 : ℂ)‖ := hz.1; simpa using (hr.not_ge (by simpa using hh)))).pow 2 + let f : ℂ → ℝ≥0∞ := A.indicator (fun z => ENNReal.ofReal (‖g z - z⁻¹ ^ 2‖ ^ 2)) + have hfc : ContinuousOn (fun z => ENNReal.ofReal (‖g z - z⁻¹ ^ 2‖ ^ 2)) A := + ENNReal.continuous_ofReal.comp_continuousOn ((hgc.sub hic).norm.pow 2) + have hfm : Measurable f := by + have he : f = A.piecewise (fun z => ENNReal.ofReal (‖g z - z⁻¹ ^ 2‖ ^ 2)) (fun _ => 0) := by + funext z + by_cases hz : z ∈ A <;> simp [f, hz] + rw [he] + exact hfc.measurable_piecewise continuousOn_const hA + have hp := annulus_lintegral_polar_lower (R := R) hr hfm + have hpolar : (∫⁻ ρ in Icc r R, ENNReal.ofReal + (2 * Real.pi * ρ * (ρ⁻¹ ^ 4 + ‖g 0‖ ^ 2))) ≤ + ∫⁻ ρ in Icc r R, ∫⁻ θ in Ioo (-Real.pi) Real.pi, + ENNReal.ofReal ρ * f (circleMap 0 ρ θ) := by + apply setLIntegral_mono' measurableSet_Icc + intro ρ hρ + have hρpos : 0 < ρ := hr.trans_le hρ.1 + have hgd : DiffContOnCl ℂ g (ball 0 ρ) := hg.mono (ball_subset_ball hρ.2) + have he (θ : ℝ) : f (circleMap 0 ρ θ) = ENNReal.ofReal (‖g (circleMap 0 ρ θ) - (circleMap 0 ρ θ)⁻¹ ^ 2‖ ^ 2) := by + apply indicator_of_mem + change r ≤ ‖circleMap 0 ρ θ‖ ∧ ‖circleMap 0 ρ θ‖ ≤ R + rw [circleMap_zero, norm_mul, norm_real, Real.norm_eq_abs, Complex.norm_exp_ofReal_mul_I, mul_one, abs_of_pos hρpos] + exact hρ + simp_rw [he] + exact pole_circle_density_lower hρpos hgd + have hintegrable : IntegrableOn (fun ρ : ℝ => 2 * Real.pi * ρ * (ρ⁻¹ ^ 4 + ‖g 0‖ ^ 2)) (Icc r R) := by + apply ContinuousOn.integrableOn_Icc + exact (continuousOn_const.mul continuousOn_id).mul + (((continuousOn_id.inv₀ (fun ρ hρ => (hr.trans_le hρ.1).ne')).pow 4).add continuousOn_const) + have hid : (∫⁻ ρ in Icc r R, ENNReal.ofReal + (2 * Real.pi * ρ * (ρ⁻¹ ^ 4 + ‖g 0‖ ^ 2))) = + ENNReal.ofReal (Real.pi * (r⁻¹ ^ 2 - R⁻¹ ^ 2) + + Real.pi * ‖g 0‖ ^ 2 * (R ^ 2 - r ^ 2)) := by + rw [← ofReal_integral_eq_lintegral_ofReal hintegrable] + · rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hR, radial_pole_integral hr hR] + · filter_upwards [ae_restrict_mem measurableSet_Icc] with ρ hρ + have hρpos : 0 < ρ := hr.trans_le hρ.1 + positivity + rw [hid] at hpolar + calc + _ ≤ _ := hpolar.trans hp + _ = _ := by + apply setLIntegral_congr_fun hA + exact fun z hz => indicator_of_mem hz _ + +theorem re_le_of_forall_mem_frontier_re_le {U : Set ℂ} {f : ℂ → ℂ} {C : ℝ} + (hb : Bornology.IsBounded U) (hf : DiffContOnCl ℂ f U) + (hc : ∀ z ∈ frontier U, (f z).re ≤ C) {z : ℂ} (hz : z ∈ closure U) : + (f z).re ≤ C := by + have he := Complex.differentiable_exp.comp_diffContOnCl hf + have hn : ‖Complex.exp (f z)‖ ≤ Real.exp C := + Complex.norm_le_of_forall_mem_frontier_norm_le hb he + (fun w hw => by simpa only [Function.comp_apply, Complex.norm_exp] using Real.exp_le_exp.mpr (hc w hw)) hz + simpa only [Complex.norm_exp, Real.exp_le_exp] using hn + +theorem norm_realLinear_le_of_frontier {U : Set ℂ} {f : ℂ → ℂ} {c : ℂ} {C : ℝ} + (hb : Bornology.IsBounded U) (hf : DiffContOnCl ℂ f U) + (hc : ∀ z ∈ frontier U, ‖f z - c * conj (f z)‖ ≤ C) + {z : ℂ} (hz : z ∈ closure U) (hC : 0 ≤ C) : + ‖f z - c * conj (f z)‖ ≤ C := by + let t := f z - c * conj (f z) + let a := conj t - conj c * t + have ident (w : ℂ) : (a * w).re = (conj t * (w - c * conj w)).re := by + simp only [a, sub_mul, mul_sub, sub_re, mul_re, mul_im, conj_re, conj_im] + ring + have hbd : ∀ w ∈ frontier U, (a * f w).re ≤ ‖t‖ * C := by + intro w hw + rw [ident] + calc + (conj t * (f w - c * conj (f w))).re ≤ ‖conj t * (f w - c * conj (f w))‖ := + Complex.re_le_norm _ + _ = ‖t‖ * ‖f w - c * conj (f w)‖ := by rw [norm_mul, norm_conj] + _ ≤ ‖t‖ * C := mul_le_mul_of_nonneg_left (hc w hw) (norm_nonneg _) + have hd : DiffContOnCl ℂ (fun w => a * f w) U := ⟨fun w hw => (hf.1 w hw).const_mul a, hf.2.const_mul a⟩ + have hh := re_le_of_forall_mem_frontier_re_le hb hd hbd hz + rw [ident] at hh + change (conj t * t).re ≤ ‖t‖ * C at hh + have he : (conj t * t).re = ‖t‖ ^ 2 := by + rw [← Complex.normSq_eq_norm_sq] + simp [Complex.normSq_apply, Complex.mul_re] + rw [he] at hh + change ‖t‖ ≤ C + nlinarith [norm_nonneg t] + +theorem det_complexDerivative (a : ℂ) : + (a • (1 : ℂ →L[ℝ] ℂ)).det = ‖a‖ ^ 2 := by + change LinearMap.det (a • (1 : ℂ →L[ℝ] ℂ) : ℂ →ₗ[ℝ] ℂ) = _ + rw [← LinearMap.det_toMatrix Complex.basisOneI, Matrix.det_fin_two, + ← Complex.normSq_eq_norm_sq] + simp [LinearMap.toMatrix_apply, Complex.coe_basisOneI, Complex.coe_basisOneI_repr, + Complex.normSq_apply] + +theorem holomorphic_area {f : ℂ → ℂ} {s : Set ℂ} (hs : MeasurableSet s) + (hd : ∀ z ∈ s, DifferentiableAt ℂ f z) (hi : InjOn f s) : + (∫⁻ z in s, ENNReal.ofReal (‖deriv f z‖ ^ 2)) = volume (f '' s) := by + have hreal (z : ℂ) (hz : z ∈ s) := + (hd z hz).hasDerivAt.complexToReal_fderiv.hasFDerivWithinAt (s := s) + have h := lintegral_abs_det_fderiv_eq_addHaar_image volume hs hreal hi + simpa only [det_complexDerivative, abs_sq] using h + +theorem holomorphic_integral_image {f : ℂ → ℂ} {s : Set ℂ} (hs : MeasurableSet s) + (hd : ∀ z ∈ s, DifferentiableAt ℂ f z) (hi : InjOn f s) (g : ℂ → ℝ) : + (∫ z in f '' s, g z) = ∫ z in s, ‖deriv f z‖ ^ 2 * g (f z) := by + have hreal (z : ℂ) (hz : z ∈ s) := + (hd z hz).hasDerivAt.complexToReal_fderiv.hasFDerivWithinAt (s := s) + have h := integral_image_eq_integral_abs_det_fderiv_smul volume hs hreal hi g + simpa only [det_complexDerivative, abs_sq, smul_eq_mul] using h + +def ellipseLinear (c : ℂ) : ℂ →L[ℝ] ℂ := + 1 + c • (Complex.conjCLE : ℂ →L[ℝ] ℂ) + +@[simp] lemma ellipseLinear_apply (c z : ℂ) : ellipseLinear c z = z + c * conj z := rfl + +lemma det_ellipseLinear (c : ℂ) : + (ellipseLinear c).det = 1 - ‖c‖ ^ 2 := by + change LinearMap.det (ellipseLinear c : ℂ →ₗ[ℝ] ℂ) = _ + rw [← LinearMap.det_toMatrix Complex.basisOneI, Matrix.det_fin_two, + ← Complex.normSq_eq_norm_sq] + simp [LinearMap.toMatrix_apply, Complex.coe_basisOneI, Complex.coe_basisOneI_repr, + ellipseLinear_apply, Complex.normSq_apply] + ring + +lemma norm_ellipseLinear_lower (c z : ℂ) : + (1 - ‖c‖) * ‖z‖ ≤ ‖ellipseLinear c z‖ := by + have hn := norm_sub_le (ellipseLinear c z) (c * conj z) + rw [ellipseLinear_apply, add_sub_cancel_right, norm_mul, norm_conj] at hn + rw [ellipseLinear_apply] + nlinarith + +def ellipseInverse (c z : ℂ) : ℂ := (z - c * conj z) / (1 - ‖c‖ ^ 2 : ℝ) + +lemma ellipseLinear_inverse {c : ℂ} (hc : ‖c‖ < 1) (z : ℂ) : + ellipseLinear c (ellipseInverse c z) = z := by + have hd : (1 - ‖c‖ ^ 2 : ℝ) ≠ 0 := by nlinarith [norm_nonneg c] + have hd' : ((1 - ‖c‖ ^ 2 : ℝ) : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hd + have hcconj : c * conj c = ((‖c‖ ^ 2 : ℝ) : ℂ) := by + rw [Complex.mul_conj, Complex.normSq_eq_norm_sq] + simp only [ellipseLinear_apply, ellipseInverse, map_div₀, map_sub, map_mul, + Complex.conj_conj, Complex.conj_ofReal] + field_simp [hd'] + push_cast at hcconj ⊢ + linear_combination -z * hcconj + +lemma norm_ellipseInverse_le_two {c : ℂ} (hc : ‖c‖ ≤ 1 / 2) (z : ℂ) : + ‖ellipseInverse c z‖ ≤ 2 * ‖z‖ := by + have hn := norm_ellipseLinear_lower c (ellipseInverse c z) + rw [ellipseLinear_inverse (by linarith) z] at hn + have hnonneg := norm_nonneg (ellipseInverse c z) + nlinarith + +lemma ellipseInverse_add (c z w : ℂ) : + ellipseInverse c (z + w) = ellipseInverse c z + ellipseInverse c w := by + simp only [ellipseInverse, map_add] + ring + +lemma ellipseInverse_linear {c : ℂ} (hc : ‖c‖ < 1) (z : ℂ) : + ellipseInverse c (ellipseLinear c z) = z := by + have h := ellipseLinear_inverse hc (ellipseLinear c z) + have hn := norm_ellipseLinear_lower c (ellipseInverse c (ellipseLinear c z) - z) + rw [map_sub, h, sub_self, norm_zero] at hn + have hpos : 0 < 1 - ‖c‖ := sub_pos.mpr hc + have he : ‖ellipseInverse c (ellipseLinear c z) - z‖ = 0 := by + nlinarith [norm_nonneg (ellipseInverse c (ellipseLinear c z) - z)] + exact sub_eq_zero.mp (norm_eq_zero.mp he) + +lemma volume_ellipse_le {c : ℂ} (hc : ‖c‖ ≤ 1) (s : Set ℂ) : + volume (ellipseLinear c '' s) ≤ volume s := by + rw [Measure.addHaar_image_continuousLinearMap] + have hd : LinearMap.det (ellipseLinear c : ℂ →ₗ[ℝ] ℂ) = 1 - ‖c‖ ^ 2 := det_ellipseLinear c + rw [hd, abs_of_nonneg (by nlinarith [norm_nonneg c])] + calc + ENNReal.ofReal (1 - ‖c‖ ^ 2) * volume s ≤ 1 * volume s := by + gcongr + exact_mod_cast (by nlinarith [sq_nonneg ‖c‖] : 1 - ‖c‖ ^ 2 ≤ 1) + _ = _ := one_mul _ + +lemma norm_ellipseInverse_eq {c : ℂ} (hc : ‖c‖ < 1) (z : ℂ) : + ‖ellipseInverse c z‖ = ‖z - c * conj z‖ / (1 - ‖c‖ ^ 2) := by + have hd : 0 < 1 - ‖c‖ ^ 2 := by nlinarith [norm_nonneg c] + simp only [ellipseInverse, norm_div, norm_real, Real.norm_eq_abs, abs_of_pos hd] + +theorem ellipse_max_annulus {f : ℂ → ℂ} {r R C : ℝ} {c : ℂ} + (hc : ‖c‖ < 1) (hC : 0 ≤ C) + (hf : DifferentiableOn ℂ f {z | r < ‖z‖ ∧ ‖z‖ < R}) + (hfc : ContinuousOn f {z | r ≤ ‖z‖ ∧ ‖z‖ ≤ R}) + (hbd : ∀ z : ℂ, ‖z‖ = r ∨ ‖z‖ = R → ‖ellipseInverse c (f z)‖ ≤ C) + {z : ℂ} (hz : r ≤ ‖z‖ ∧ ‖z‖ ≤ R) : ‖ellipseInverse c (f z)‖ ≤ C := by + by_cases hi : r < ‖z‖ ∧ ‖z‖ < R + · let U : Set ℂ := {z | r < ‖z‖ ∧ ‖z‖ < R} + have hcl : closure U ⊆ {z : ℂ | r ≤ ‖z‖ ∧ ‖z‖ ≤ R} := + closure_minimal (fun z hz => ⟨hz.1.le, hz.2.le⟩) + ((isClosed_le continuous_const continuous_norm).inter (isClosed_le continuous_norm continuous_const)) + have hb : Bornology.IsBounded U := + (isBounded_ball (x := (0 : ℂ)) (r := R)).subset (fun w hw => by + simpa only [mem_ball, dist_zero_right] using hw.2) + have hfront : ∀ w ∈ frontier U, ‖w‖ = r ∨ ‖w‖ = R := by + intro w hw + rcases frontier_inter_subset {w : ℂ | r < ‖w‖} {w : ℂ | ‖w‖ < R} hw with hw | hw + · exact Or.inl ((frontier_lt_subset_eq continuous_const continuous_norm hw.1).symm) + · exact Or.inr (frontier_lt_subset_eq continuous_norm continuous_const hw.2) + have hD : 0 < 1 - ‖c‖ ^ 2 := by nlinarith [norm_nonneg c] + have hm := norm_realLinear_le_of_frontier hb (⟨hf, hfc.mono hcl⟩ : DiffContOnCl ℂ f U) + (c := c) (C := C * (1 - ‖c‖ ^ 2)) (fun w hw => ?_) + (subset_closure hi) (mul_nonneg hC hD.le) + · rw [norm_ellipseInverse_eq hc] + exact (div_le_iff₀ hD).mpr hm + · exact (div_le_iff₀ hD).mp (by simpa only [norm_ellipseInverse_eq hc] using hbd w (hfront w hw)) + · apply hbd z + push Not at hi + by_cases he : ‖z‖ = r + · exact Or.inl he + · exact Or.inr (le_antisymm hz.2 (hi (lt_of_le_of_ne hz.1 (Ne.symm he)))) + +theorem volume_image_annulus_le {f : ℂ → ℂ} {r R C : ℝ} {c : ℂ} + (hc : ‖c‖ < 1) (hC : 0 ≤ C) + (hf : DifferentiableOn ℂ f {z | r < ‖z‖ ∧ ‖z‖ < R}) + (hfc : ContinuousOn f {z | r ≤ ‖z‖ ∧ ‖z‖ ≤ R}) + (hbd : ∀ z : ℂ, ‖z‖ = r ∨ ‖z‖ = R → ‖ellipseInverse c (f z)‖ ≤ C) : + volume (f '' {z : ℂ | r ≤ ‖z‖ ∧ ‖z‖ ≤ R}) ≤ ENNReal.ofReal (Real.pi * C ^ 2) := by + have hs : f '' {z : ℂ | r ≤ ‖z‖ ∧ ‖z‖ ≤ R} ⊆ ellipseLinear c '' closedBall 0 C := by + rintro w ⟨z, hz, rfl⟩ + refine ⟨ellipseInverse c (f z), ?_, ellipseLinear_inverse hc _⟩ + simpa only [mem_closedBall, dist_zero_right] using ellipse_max_annulus hc hC hf hfc hbd hz + calc + _ ≤ volume (ellipseLinear c '' closedBall 0 C) := measure_mono hs + _ ≤ volume (closedBall 0 C) := volume_ellipse_le hc.le _ + _ = ENNReal.ofReal (Real.pi * C ^ 2) := by + rw [Complex.volume_closedBall, ENNReal.ofReal_mul Real.pi_pos.le, ENNReal.ofReal_pow hC] + have hpi : ENNReal.ofReal Real.pi = (NNReal.pi : ℝ≥0∞) := by + rw [← NNReal.coe_real_pi] + simp only [ENNReal.ofReal_coe_nnreal] + rw [hpi, mul_comm] + +lemma ellipse_pole_identity {z b : ℂ} {r : ℝ} (hr : 0 < r) (hz : ‖z‖ = r) : + ellipseLinear (b * (r : ℂ) ^ 2) z⁻¹ = z⁻¹ + b * z := by + have hz0 : z ≠ 0 := by intro he; simp [he] at hz; linarith + have hc0 : conj z ≠ 0 := by simpa using hz0 + have hn : conj z * z = (r : ℂ) ^ 2 := by + rw [← Complex.normSq_eq_conj_mul_self, Complex.normSq_eq_norm_sq, hz, Complex.ofReal_pow] + rw [ellipseLinear_apply, map_inv₀, ← hn] + field_simp + +lemma ellipse_pole_boundary {h : ℂ → ℂ} {b z : ℂ} {r ε : ℝ} + (hr : 0 < r) (hz : ‖z‖ = r) (hc : ‖b * (r : ℂ) ^ 2‖ ≤ 1 / 2) + (hh : ‖h z - b * z‖ ≤ ε * r) : + ‖ellipseInverse (b * (r : ℂ) ^ 2) (z⁻¹ + h z)‖ ≤ r⁻¹ + 2 * ε * r := by + have he : z⁻¹ + h z = ellipseLinear (b * (r : ℂ) ^ 2) z⁻¹ + (h z - b * z) := by + rw [ellipse_pole_identity hr hz] + ring + rw [he, ellipseInverse_add, ellipseInverse_linear (by linarith)] + calc + _ ≤ ‖z⁻¹‖ + ‖ellipseInverse (b * (r : ℂ) ^ 2) (h z - b * z)‖ := norm_add_le _ _ + _ ≤ r⁻¹ + 2 * ‖h z - b * z‖ := by + rw [norm_inv, hz] + exact add_le_add (le_refl _) (norm_ellipseInverse_le_two hc _) + _ ≤ _ := by linarith + +lemma deriv_diffContOnCl_inner {h : ℂ → ℂ} (hd : DifferentiableOn ℂ h (ball 0 1)) + {R : ℝ} (hR : R < 1) : DiffContOnCl ℂ (deriv h) (ball 0 R) := by + have ha := (hd.analyticOnNhd isOpen_ball).deriv + refine ⟨ha.differentiableOn.mono (ball_subset_ball hR.le), ha.continuousOn.mono ?_⟩ + exact (closure_ball_subset_closedBall).trans (closedBall_subset_ball hR) + +lemma pole_annulus_comparison {h : ℂ → ℂ} {r R C : ℝ} {c : ℂ} + (hd : DifferentiableOn ℂ h (ball 0 1)) + (hi : InjOn (fun z => z⁻¹ + h z) (ball 0 1 \ {0})) + (hr : 0 < r) (hrR : r ≤ R) (hR : R < 1) (hc : ‖c‖ < 1) (hC : 0 ≤ C) + (hbd : ∀ z : ℂ, ‖z‖ = r ∨ ‖z‖ = R → + ‖ellipseInverse c (z⁻¹ + h z)‖ ≤ C) : + Real.pi * (r⁻¹ ^ 2 - R⁻¹ ^ 2) + Real.pi * ‖deriv h 0‖ ^ 2 * (R ^ 2 - r ^ 2) ≤ + Real.pi * C ^ 2 := by + let A : Set ℂ := {z | r ≤ ‖z‖ ∧ ‖z‖ ≤ R} + have hA : MeasurableSet A := (isClosed_le continuous_const continuous_norm).measurableSet.inter + (isClosed_le continuous_norm continuous_const).measurableSet + have hsub : A ⊆ ball 0 1 \ {0} := by + intro z hz + refine ⟨?_, ?_⟩ + · simpa only [mem_ball, dist_zero_right] using hz.2.trans_lt hR + · intro he + have he' : z = 0 := he + have hh := hz.1 + rw [he', norm_zero] at hh + linarith + have hder (z : ℂ) (hz : z ∈ A) : + HasDerivAt (fun z => z⁻¹ + h z) (deriv h z - z⁻¹ ^ 2) z := by + have hd' := (hd.differentiableAt (isOpen_ball.mem_nhds (hsub hz).1)).hasDerivAt + have hn : z ≠ 0 := fun he => (hsub hz).2 he + have hsum : HasDerivAt (fun w : ℂ => w⁻¹ + h w) (-(z ^ 2)⁻¹ + deriv h z) z := + (hasDerivAt_inv hn).add hd' + convert hsum using 1; simp [inv_pow, sub_eq_add_neg, add_comm] + have hdG : ∀ z ∈ A, DifferentiableAt ℂ (fun z => z⁻¹ + h z) z := + fun z hz => (hder z hz).differentiableAt + have hU : {z : ℂ | r < ‖z‖ ∧ ‖z‖ < R} ⊆ A := fun z hz => ⟨hz.1.le, hz.2.le⟩ + have hv := volume_image_annulus_le hc hC + (fun z hz => (hdG z (hU hz)).differentiableWithinAt) + (fun z hz => (hdG z hz).continuousAt.continuousWithinAt) hbd + have hl := annulus_pole_area_lower hr hrR (deriv_diffContOnCl_inner hd hR) + have he : (∫⁻ z in A, ENNReal.ofReal (‖deriv h z - z⁻¹ ^ 2‖ ^ 2)) = + volume ((fun z => z⁻¹ + h z) '' A) := by + rw [← holomorphic_area hA hdG (hi.mono hsub)] + apply setLIntegral_congr_fun hA + intro z hz + dsimp only + rw [(hder z hz).deriv] + rw [he] at hl + exact (ENNReal.ofReal_le_ofReal_iff (by positivity)).mp (hl.trans hv) + +lemma pole_area_small_radius {h : ℂ → ℂ} + (hd : DifferentiableOn ℂ h (ball 0 1)) (h0 : h 0 = 0) + (hi : InjOn (fun z => z⁻¹ + h z) (ball 0 1 \ {0})) + {R ε : ℝ} (hRpos : 0 < R) (hR : R < 1) (hε : 0 < ε) : + ∀ᶠ r in 𝓝[>] (0 : ℝ), + ‖deriv h 0‖ ^ 2 * (R ^ 2 - r ^ 2) ≤ R⁻¹ ^ 2 + 4 * ε + 4 * ε ^ 2 * r ^ 2 := by + have hd0 := hd.differentiableAt (isOpen_ball.mem_nhds (by simp : (0 : ℂ) ∈ ball 0 1)) + have he : ∀ᶠ z in 𝓝 (0 : ℂ), ‖h z - deriv h 0 * z‖ ≤ ε * ‖z‖ := by + simpa only [h0, sub_zero, smul_eq_mul, mul_comm] using hd0.hasDerivAt.isLittleO.bound hε + obtain ⟨δ, hδ, hδbound⟩ := Metric.eventually_nhds_iff.mp he + have hcont : ContinuousOn (fun z => z⁻¹ + h z) (sphere 0 R) := by + intro z hz + have hzR : ‖z‖ = R := by simpa only [mem_sphere, dist_zero_right] using hz + have hz0 : z ≠ 0 := by intro he; simp [he] at hzR; linarith + exact ((continuousAt_inv₀ hz0).add + (hd.differentiableAt (isOpen_ball.mem_nhds (by simpa [mem_ball, dist_zero_right, hzR] using hR))).continuousAt).continuousWithinAt + obtain ⟨M, hM⟩ := (isCompact_sphere (0 : ℂ) R).exists_bound_of_continuousOn hcont + have ht : Tendsto (fun r : ℝ => r) (𝓝[>] (0 : ℝ)) (𝓝 0) := tendsto_id'.mpr nhdsWithin_le_nhds + have hts : Tendsto (fun r : ℝ => ‖deriv h 0‖ * r ^ 2) (𝓝[>] (0 : ℝ)) (𝓝 0) := by + convert ht.pow 2 |>.const_mul ‖deriv h 0‖ using 1; simp + have hsmall : ∀ᶠ r in 𝓝[>] (0 : ℝ), ‖deriv h 0‖ * r ^ 2 < 1 / 2 := + hts.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1 / 2)) + have houter : ∀ᶠ r in 𝓝[>] (0 : ℝ), 2 * M ≤ r⁻¹ := + tendsto_inv_nhdsGT_zero.eventually_ge_atTop _ + filter_upwards [eventually_mem_nhdsWithin, ht.eventually (gt_mem_nhds hRpos), + ht.eventually (gt_mem_nhds hδ), hsmall, houter] with r hr hrR hrδ hsmall houter + have hrpos : 0 < r := hr + let c : ℂ := deriv h 0 * (r : ℂ) ^ 2 + have hc : ‖c‖ ≤ 1 / 2 := by + dsimp [c] + rw [norm_mul, norm_pow, norm_real, Real.norm_eq_abs, abs_of_pos hrpos] + exact hsmall.le + have hC : 0 ≤ r⁻¹ + 2 * ε * r := by positivity + have hbd : ∀ z : ℂ, ‖z‖ = r ∨ ‖z‖ = R → + ‖ellipseInverse c (z⁻¹ + h z)‖ ≤ r⁻¹ + 2 * ε * r := by + intro z hz + rcases hz with hz | hz + · apply ellipse_pole_boundary hrpos hz hc + have hb := hδbound (y := z) (by simpa only [dist_zero_right, hz] using hrδ) + simpa only [hz] using hb + · calc + _ ≤ 2 * ‖z⁻¹ + h z‖ := norm_ellipseInverse_le_two hc _ + _ ≤ 2 * M := by + gcongr + exact hM z (by simpa only [mem_sphere, dist_zero_right] using hz) + _ ≤ r⁻¹ + 2 * ε * r := by nlinarith + have harea := pole_annulus_comparison hd hi hrpos hrR.le hR (by linarith : ‖c‖ < 1) hC hbd + have hsq : (r⁻¹ + 2 * ε * r) ^ 2 = r⁻¹ ^ 2 + 4 * ε + 4 * ε ^ 2 * r ^ 2 := by + field_simp + ring + rw [hsq] at harea + have hm : Real.pi * (r⁻¹ ^ 2 - R⁻¹ ^ 2 + ‖deriv h 0‖ ^ 2 * (R ^ 2 - r ^ 2)) ≤ + Real.pi * (r⁻¹ ^ 2 + 4 * ε + 4 * ε ^ 2 * r ^ 2) := by + nlinarith only [harea] + have hm' := (mul_le_mul_iff_right₀ Real.pi_pos).mp hm + linarith + +lemma pole_coefficient_radius {h : ℂ → ℂ} + (hd : DifferentiableOn ℂ h (ball 0 1)) (h0 : h 0 = 0) + (hi : InjOn (fun z => z⁻¹ + h z) (ball 0 1 \ {0})) + {R : ℝ} (hRpos : 0 < R) (hR : R < 1) : + ‖deriv h 0‖ ^ 2 * R ^ 2 ≤ R⁻¹ ^ 2 := by + have hb (ε : ℝ) (hε : 0 < ε) : ‖deriv h 0‖ ^ 2 * R ^ 2 ≤ R⁻¹ ^ 2 + 4 * ε := by + have hl : Tendsto (fun r : ℝ => ‖deriv h 0‖ ^ 2 * (R ^ 2 - r ^ 2)) (𝓝[>] (0 : ℝ)) + (𝓝 (‖deriv h 0‖ ^ 2 * R ^ 2)) := by + have hc : ContinuousAt (fun r : ℝ => ‖deriv h 0‖ ^ 2 * (R ^ 2 - r ^ 2)) 0 := by fun_prop + simpa using hc.tendsto.mono_left nhdsWithin_le_nhds + have hu : Tendsto (fun r : ℝ => R⁻¹ ^ 2 + 4 * ε + 4 * ε ^ 2 * r ^ 2) (𝓝[>] (0 : ℝ)) + (𝓝 (R⁻¹ ^ 2 + 4 * ε)) := by + have hc : ContinuousAt (fun r : ℝ => R⁻¹ ^ 2 + 4 * ε + 4 * ε ^ 2 * r ^ 2) 0 := by fun_prop + simpa using hc.tendsto.mono_left nhdsWithin_le_nhds + exact le_of_tendsto_of_tendsto hl hu (pole_area_small_radius hd h0 hi hRpos hR hε) + apply le_of_forall_pos_le_add + intro ε hε + have hh := hb (ε / 4) (by positivity) + linarith + +theorem pole_coefficient_le_one {h : ℂ → ℂ} + (hd : DifferentiableOn ℂ h (ball 0 1)) (h0 : h 0 = 0) + (hi : InjOn (fun z => z⁻¹ + h z) (ball 0 1 \ {0})) : + ‖deriv h 0‖ ≤ 1 := by + have hl : Tendsto (fun R : ℝ => ‖deriv h 0‖ ^ 2 * R ^ 2) (𝓝[<] (1 : ℝ)) + (𝓝 (‖deriv h 0‖ ^ 2)) := by + have hc : ContinuousAt (fun R : ℝ => ‖deriv h 0‖ ^ 2 * R ^ 2) 1 := by fun_prop + simpa using hc.tendsto.mono_left nhdsWithin_le_nhds + have hu : Tendsto (fun R : ℝ => R⁻¹ ^ 2) (𝓝[<] (1 : ℝ)) (𝓝 (1 : ℝ)) := by + have hc : ContinuousAt (fun R : ℝ => R⁻¹ ^ 2) 1 := + (continuousAt_id.inv₀ one_ne_zero).pow 2 + simpa using hc.tendsto.mono_left nhdsWithin_le_nhds + have he : ∀ᶠ R in 𝓝[<] (1 : ℝ), ‖deriv h 0‖ ^ 2 * R ^ 2 ≤ R⁻¹ ^ 2 := by + filter_upwards [eventually_mem_nhdsWithin, + (lt_mem_nhds (by norm_num : (0 : ℝ) < 1)).filter_mono nhdsWithin_le_nhds] with R hR hRpos + exact pole_coefficient_radius hd h0 hi hRpos hR + have hh := le_of_tendsto_of_tendsto hl hu he + nlinarith [norm_nonneg (deriv h 0)] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/AreaTails.lean b/lean/OAI/Analysis/StrictMeans/AreaTails.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b0f6ce151adcc43824bccd85660d8ed01b881ea --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/AreaTails.lean @@ -0,0 +1,401 @@ +import OAI.Analysis.StrictMeans.ImageBounds + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex +open scoped Topology + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +namespace StrictInverseFirstPower +noncomputable section + +def affineInversePlane (z : ℂ) : ℂ := (-(z.re : ℂ) + I) / (z.im : ℂ) + +lemma affineInversePlane_re (z : ℂ) : (affineInversePlane z).re = -z.re / z.im := by + simp [affineInversePlane, Complex.div_ofReal_re] +lemma affineInversePlane_im (z : ℂ) : (affineInversePlane z).im = 1 / z.im := by + simp [affineInversePlane, Complex.div_ofReal_im] + +lemma coe_affineInverse (z : UpperHalfPlane) : + (affineInverse z : ℂ) = affineInversePlane z := rfl + +lemma affineInversePlane_mapsTo : + MapsTo affineInversePlane {z : ℂ | 0 < z.im} {z : ℂ | 0 < z.im} := by + intro z hz + change 0 < (affineInversePlane z).im + rw [affineInversePlane_im] + exact one_div_pos.mpr hz + +lemma affineInversePlane_involution {z : ℂ} (hz : z.im ≠ 0) : + affineInversePlane (affineInversePlane z) = z := by + apply Complex.ext + · simp only [affineInversePlane_re, affineInversePlane_im] + field_simp + · simp [affineInversePlane_im] + +lemma affineInversePlane_injOn : InjOn affineInversePlane {z : ℂ | 0 < z.im} := by + intro z hz w hw he + have hh := congrArg affineInversePlane he + rwa [affineInversePlane_involution (ne_of_gt hz), + affineInversePlane_involution (ne_of_gt hw)] at hh + +lemma continuous_affineInverse : Continuous affineInverse := by + apply UpperHalfPlane.isEmbedding_coe.continuous_iff.mpr + exact (((Complex.continuous_ofReal.comp UpperHalfPlane.continuous_re).neg.add continuous_const).div + (Complex.continuous_ofReal.comp UpperHalfPlane.continuous_im) (fun z => Complex.ofReal_ne_zero.mpr z.im_ne_zero)) + +def outsideCenter : Set ℂ := {z | 0 < z.im ∧ 1 / 2 ≤ ‖cayleyToDisk z‖} + +def outsideCenterH : Set UpperHalfPlane := {z | 1 / 2 ≤ ‖cayleyToDisk z‖} + +lemma measurableSet_outsideCenter : MeasurableSet outsideCenter := by + have hc : Measurable (fun z : ℂ => ‖cayleyToDisk z‖) := by + unfold cayleyToDisk + fun_prop + exact (isOpen_halfPlane.measurableSet).inter (measurableSet_le measurable_const hc) + +lemma measurableSet_outsideCenterH : MeasurableSet outsideCenterH := by + have hc : Continuous (fun z : UpperHalfPlane => cayleyToDisk z) := + continuous_subtype_val.comp cayleyDiskMap.continuous + exact measurableSet_le measurable_const hc.norm.measurable + +lemma norm_cayley_inverse {z : ℂ} (hz : 0 < z.im) : + ‖cayleyToDisk (affineInversePlane z)‖ = ‖cayleyToDisk z‖ := by + have hy : (z.im : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hz.ne' + have hnum : affineInversePlane z - I = -(z - I) / (z.im : ℂ) := by + apply Complex.ext <;> + simp [affineInversePlane_re, affineInversePlane_im, Complex.div_ofReal_re, + Complex.div_ofReal_im]; field_simp + have hden : affineInversePlane z + I = -(conj (z + I)) / (z.im : ℂ) := by + apply Complex.ext <;> + simp [affineInversePlane_re, affineInversePlane_im, Complex.div_ofReal_re, + Complex.div_ofReal_im]; field_simp + simp only [cayleyToDisk, hnum, hden, norm_div, norm_neg, norm_conj] + exact div_div_div_cancel_right₀ (norm_ne_zero_iff.mpr hy) _ _ + +lemma affineInversePlane_outside_image : affineInversePlane '' outsideCenter = outsideCenter := by + apply Subset.antisymm + · rintro _ ⟨z, hz, rfl⟩ + exact ⟨affineInversePlane_mapsTo hz.1, by simpa only [norm_cayley_inverse hz.1] using hz.2⟩ + · intro z hz + refine ⟨affineInversePlane z, ⟨affineInversePlane_mapsTo hz.1, ?_⟩, + affineInversePlane_involution hz.1.ne'⟩ + simpa only [norm_cayley_inverse hz.1] using hz.2 + +lemma affineInversePlane_hasFDerivAt {z : ℂ} (hz : z.im ≠ 0) : + HasFDerivAt affineInversePlane + ((z.im : ℂ)⁻¹ • -(Complex.ofRealCLM.comp Complex.reCLM) - + ((-(z.re : ℂ) + I) / (z.im : ℂ)^2) • + (Complex.ofRealCLM.comp Complex.imCLM)) z := by + have h1 := ((Complex.ofRealCLM.comp Complex.reCLM).hasFDerivAt (x := z)).neg.add_const I + have h2 := (Complex.ofRealCLM.comp Complex.imCLM).hasFDerivAt (x := z) + have hinv := ((hasDerivAt_inv (Complex.ofReal_ne_zero.mpr hz)).hasFDerivAt.restrictScalars ℝ).comp z h2 + have hh := h1.mul hinv + convert hh using 1 + all_goals first | rfl | (ext w; simp [smul_eq_mul, div_eq_mul_inv]; ring) + +lemma det_affineInversePlane {z : ℂ} (hz : z.im ≠ 0) : + (fderiv ℝ affineInversePlane z).det = (z.im ^ 3)⁻¹ := by + change LinearMap.det (fderiv ℝ affineInversePlane z : ℂ →ₗ[ℝ] ℂ) = _ + rw [(affineInversePlane_hasFDerivAt hz).fderiv, real_det_eq] + simp only [ContinuousLinearMap.coe_coe, sub_apply, + smul_apply, neg_apply, + ContinuousLinearMap.comp_apply, Complex.ofRealCLM_apply, Complex.reCLM_apply, + Complex.imCLM_apply, one_re, one_im, I_re, I_im, Complex.ofReal_one, + Complex.ofReal_zero, neg_zero, smul_eq_mul, mul_zero, sub_zero, mul_one] + simp [pow_two, Complex.mul_re, Complex.mul_im, Complex.inv_re, Complex.inv_im, + Complex.div_re, Complex.div_im, Complex.normSq_apply] + field_simp [hz] + +lemma lintegral_affineInverse_outside (g : ℂ → ℝ≥0∞) : + (∫⁻ z in outsideCenter, g z) = + ∫⁻ z in outsideCenter, ENNReal.ofReal ((z.im ^ 3)⁻¹) * g (affineInversePlane z) := by + have h := lintegral_image_eq_lintegral_abs_det_fderiv_mul volume + measurableSet_outsideCenter + (fun z (hz : z ∈ outsideCenter) => + (affineInversePlane_hasFDerivAt hz.1.ne').differentiableAt.hasFDerivAt.hasFDerivWithinAt) + (affineInversePlane_injOn.mono (fun _ hz => hz.1)) g + rw [affineInversePlane_outside_image] at h + rw [h] + apply setLIntegral_congr_fun measurableSet_outsideCenter + intro z hz + dsimp only + rw [det_affineInversePlane hz.1.ne', + abs_of_pos (inv_pos.mpr (pow_pos hz.1 3))] + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +lemma holomorphic_lintegral_image {F : ℂ → ℂ} {s : Set ℂ} (hs : MeasurableSet s) + (hd : ∀ z ∈ s, DifferentiableAt ℂ F z) (hi : InjOn F s) (g : ℂ → ℝ≥0∞) : + (∫⁻ w in F '' s, g w) = ∫⁻ z in s, ENNReal.ofReal (‖deriv F z‖ ^ 2) * g (F z) := by + have hreal (z : ℂ) (hz : z ∈ s) := + (hd z hz).hasDerivAt.complexToReal_fderiv.hasFDerivWithinAt (s := s) + have h := lintegral_image_eq_lintegral_abs_det_fderiv_mul volume hs hreal hi g + simpa only [det_complexDerivative, abs_sq] using h + +lemma integrable_inverse_cube_outside {r : ℝ} (hr : 0 < r) : + IntegrableOn (fun w : ℂ => ‖w‖⁻¹ ^ 3) {w : ℂ | r ≤ ‖w‖} := by + have h1 : IntegrableOn (fun y : ℝ => y ^ (-2 : ℝ)) (Ici r) := + (integrableOn_Ici_iff_integrableOn_Ioi).mpr + (integrableOn_Ioi_rpow_of_lt (by norm_num) hr) + have h2 : Integrable ((Ici r).indicator (fun y : ℝ => y ^ (-2 : ℝ))) := + h1.integrable_indicator measurableSet_Ici + have h3 : IntegrableOn (fun y : ℝ => y ^ (Module.finrank ℝ ℂ - 1) • + (Ici r).indicator (fun t : ℝ => t⁻¹ ^ 3) y) (Ioi 0) := by + apply h2.integrableOn.congr_fun _ measurableSet_Ioi + intro y hy + by_cases hyr : r ≤ y + · simp only [indicator_of_mem (show y ∈ Ici r from hyr), Complex.finrank_real_complex, Nat.reduceSub, + pow_one, smul_eq_mul] + have he : y ^ (-2 : ℝ) = (y ^ 2)⁻¹ := by + rw [Real.rpow_neg (le_of_lt hy)] + congr 1 + exact Real.rpow_two y + rw [he] + field_simp + · simp [hyr, Complex.finrank_real_complex] + have h4 : Integrable (fun w : ℂ => (Ici r).indicator (fun t : ℝ => t⁻¹ ^ 3) ‖w‖) := + (integrable_fun_norm_addHaar volume).mpr h3 + have hset : MeasurableSet {w : ℂ | r ≤ ‖w‖} := measurableSet_le measurable_const (by fun_prop) + apply (integrable_indicator_iff hset).mp + convert h4 using 1 + all_goals rfl + +lemma inverse_cube_tail_finite {r : ℝ} (hr : 0 < r) : + (∫⁻ w : ℂ in {w : ℂ | r ≤ ‖w‖}, ENNReal.ofReal (‖w‖⁻¹ ^ 3)) < ∞ := by + exact (hasFiniteIntegral_iff_ofReal (Filter.Eventually.of_forall (fun _ => by positivity))).mp + (integrable_inverse_cube_outside hr).hasFiniteIntegral + +lemma halfPlane_area_tail_uniform (f : DiskFamily) : + (∫⁻ z in outsideCenter, ENNReal.ofReal (‖deriv (halfPlaneFunction f) z‖ ^ 2) * + ENNReal.ofReal (‖halfPlaneFunction f z‖⁻¹ ^ 3)) ≤ + ∫⁻ w : ℂ in {w : ℂ | 1 / 4 ≤ ‖w‖}, ENNReal.ofReal (‖w‖⁻¹ ^ 3) := by + rw [← holomorphic_lintegral_image measurableSet_outsideCenter + (fun z hz => (halfPlaneFunction_differentiableOn f).differentiableAt + (isOpen_halfPlane.mem_nhds hz.1)) + ((halfPlaneFunction_injOn f).mono (fun _ hz => hz.1)) + (fun w => ENNReal.ofReal (‖w‖⁻¹ ^ 3))] + apply lintegral_mono_set + rintro _ ⟨z, hz, rfl⟩ + exact halfPlaneFunction_outside_norm_lower f hz.1 hz.2 + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +def halfPlaneProjection : ℂ → UpperHalfPlane := + UpperHalfPlane.measurableEmbedding_coe.invFun + +lemma measurable_halfPlaneProjection : Measurable halfPlaneProjection := + UpperHalfPlane.measurableEmbedding_coe.measurable_invFun + +@[simp] lemma halfPlaneProjection_coe (z : UpperHalfPlane) : halfPlaneProjection z = z := + UpperHalfPlane.measurableEmbedding_coe.leftInverse_invFun z + +lemma halfPlaneProjection_of_pos {z : ℂ} (hz : 0 < z.im) : + halfPlaneProjection z = ⟨z, hz⟩ := halfPlaneProjection_coe ⟨z, hz⟩ + +lemma halfPlaneFunction_inverse_rebase (f : DiskFamily) (z : UpperHalfPlane) : + halfPlaneFunction (rebase f z) (affineInverse z) = + -halfPlaneFunction f z / ((z.im : ℂ) * deriv (halfPlaneFunction f) z) := by + rw [halfPlaneFunction_rebase f z (affineInverse z).im_pos, affineAt_inverse, + halfPlaneFunction_I, zero_sub] + +def inverseCubeValue (f : DiskFamily) (z : UpperHalfPlane) : ℝ≥0∞ := + ENNReal.ofReal (‖halfPlaneFunction f z‖⁻¹ ^ 3) + +def conformalAreaCube (f : DiskFamily) (z : UpperHalfPlane) : ℝ≥0∞ := + ENNReal.ofReal (‖deriv (halfPlaneFunction f) z‖ ^ 2) * inverseCubeValue f z + +lemma measurable_inverseCubeValue : Measurable (fun p : DiskFamily × UpperHalfPlane => + inverseCubeValue p.1 p.2) := by + exact ENNReal.measurable_ofReal.comp (continuous_halfPlaneFunction.measurable.norm.inv.pow_const 3) + +lemma measurable_conformalAreaCube : Measurable (fun p : DiskFamily × UpperHalfPlane => + conformalAreaCube p.1 p.2) := by + exact (ENNReal.measurable_ofReal.comp (continuous_halfPlaneFunction_deriv.measurable.norm.pow_const 2)).mul + measurable_inverseCubeValue + +lemma weighted_inverse_cube_rebase (f : DiskFamily) (z : UpperHalfPlane) : + (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * inverseCubeValue (rebase f z) (affineInverse z) = + ENNReal.ofReal (z.im ^ 3) * conformalAreaCube f z := by + have hd : ‖deriv (halfPlaneFunction f) z‖ ≠ 0 := + norm_ne_zero_iff.mpr (halfPlaneFunction_deriv_ne_zero f z.im_pos) + rw [inverseCubeValue, halfPlaneFunction_inverse_rebase] + simp only [norm_div, norm_neg, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_pos z.im_pos] + rw [show (‖halfPlaneQ f z‖₊ : ℝ≥0∞) = ENNReal.ofReal (‖deriv (halfPlaneFunction f) z‖⁻¹) by + rw [← ENNReal.ofReal_coe_nnreal] + simp only [coe_nnnorm, halfPlaneQ, norm_inv]] + unfold conformalAreaCube inverseCubeValue + rw [← ENNReal.ofReal_mul (inv_nonneg.mpr (norm_nonneg _)), + ← ENNReal.ofReal_mul (sq_nonneg _), ← ENNReal.ofReal_mul (pow_nonneg z.im_pos.le 3)] + congr 1 + rw [inv_div, div_pow] + field_simp + +lemma area_cube_expectation (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hlaw : ∀ (z : UpperHalfPlane) (φ : DiskFamily → ℝ≥0∞), Measurable φ → + (∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ (-β)) * ∫⁻ f, φ f ∂(μ : Measure DiskFamily)) + (z : UpperHalfPlane) : + (∫⁻ f, conformalAreaCube f z ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal ((z.im ^ 3)⁻¹) * + (ENNReal.ofReal (z.im ^ (-β)) * ∫⁻ f, inverseCubeValue f (affineInverse z) ∂(μ : Measure DiskFamily)) := by + have he := hlaw z (fun f => inverseCubeValue f (affineInverse z)) + (measurable_inverseCubeValue.comp (f := fun f : DiskFamily => (f, affineInverse z)) measurable_prodMk_right) + simp only [weighted_inverse_cube_rebase] at he + have hm : Measurable (fun f : DiskFamily => conformalAreaCube f z) := + measurable_conformalAreaCube.comp (f := fun f : DiskFamily => (f, z)) measurable_prodMk_right + rw [lintegral_const_mul (ENNReal.ofReal (z.im ^ 3)) hm] at he + rw [← he, ENNReal.ofReal_inv_of_pos (pow_pos z.im_pos 3)] + exact (ENNReal.inv_mul_cancel_left (by positivity) ENNReal.ofReal_ne_top).symm + +def weightedAreaTail (β : ℝ) (f : DiskFamily) : ℝ≥0∞ := + ∫⁻ z in outsideCenter, ENNReal.ofReal (z.im ^ β) * inverseCubeValue f (halfPlaneProjection z) + +lemma measurable_inverseCube_plane : Measurable (fun p : DiskFamily × ℂ => + inverseCubeValue p.1 (halfPlaneProjection p.2)) := + measurable_inverseCubeValue.comp (f := fun p : DiskFamily × ℂ => (p.1, halfPlaneProjection p.2)) + ((measurable_fst : Measurable (fun p : DiskFamily × ℂ => p.1)).prodMk + (measurable_halfPlaneProjection.comp measurable_snd)) + +lemma measurable_conformalArea_plane : Measurable (fun p : DiskFamily × ℂ => + conformalAreaCube p.1 (halfPlaneProjection p.2)) := + measurable_conformalAreaCube.comp (f := fun p : DiskFamily × ℂ => (p.1, halfPlaneProjection p.2)) + ((measurable_fst : Measurable (fun p : DiskFamily × ℂ => p.1)).prodMk + (measurable_halfPlaneProjection.comp measurable_snd)) + +lemma measurable_areaTail_density (β : ℝ) : Measurable (fun p : DiskFamily × ℂ => + ENNReal.ofReal (p.2.im ^ β) * inverseCubeValue p.1 (halfPlaneProjection p.2)) := + (ENNReal.measurable_ofReal.comp + ((Complex.measurable_im.comp (measurable_snd : Measurable (fun p : DiskFamily × ℂ => p.2))).pow_const β)).mul + measurable_inverseCube_plane + +lemma measurable_weightedAreaTail (β : ℝ) : Measurable (weightedAreaTail β) := + (measurable_areaTail_density β).lintegral_prod_right' (ν := volume.restrict outsideCenter) + +lemma expected_area_tail (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hlaw : ∀ (z : UpperHalfPlane) (φ : DiskFamily → ℝ≥0∞), Measurable φ → + (∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ (-β)) * ∫⁻ f, φ f ∂(μ : Measure DiskFamily)) : + (∫⁻ f, weightedAreaTail β f ∂(μ : Measure DiskFamily)) = + ∫⁻ f, (∫⁻ z in outsideCenter, conformalAreaCube f (halfPlaneProjection z)) ∂(μ : Measure DiskFamily) := by + have hm := measurable_areaTail_density β + have ha := measurable_conformalArea_plane + change (∫⁻ f, (∫⁻ z in outsideCenter, ENNReal.ofReal (z.im ^ β) * inverseCubeValue f (halfPlaneProjection z)) ∂(μ : Measure DiskFamily)) = _ + conv_lhs => rw [lintegral_lintegral_swap hm.aemeasurable] + conv_rhs => rw [lintegral_lintegral_swap ha.aemeasurable] + have hfun (z : ℂ) : + (∫⁻ f, ENNReal.ofReal (z.im ^ β) * inverseCubeValue f (halfPlaneProjection z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ β) * ∫⁻ f, inverseCubeValue f (halfPlaneProjection z) ∂(μ : Measure DiskFamily) := + lintegral_const_mul _ (measurable_inverseCubeValue.comp (f := fun f : DiskFamily => (f, halfPlaneProjection z)) measurable_prodMk_right) + simp only [hfun] + rw [lintegral_affineInverse_outside] + apply setLIntegral_congr_fun measurableSet_outsideCenter + intro z hz + have hpos := affineInversePlane_mapsTo hz.1 + dsimp only + rw [halfPlaneProjection_of_pos hz.1, + halfPlaneProjection_of_pos hpos, affineInversePlane_im] + change ENNReal.ofReal ((z.im ^ 3)⁻¹) * + (ENNReal.ofReal ((1 / z.im) ^ β) * ∫⁻ f, inverseCubeValue f (affineInverse ⟨z, hz.1⟩) ∂(μ : Measure DiskFamily)) = _ + rw [one_div, Real.inv_rpow hz.1.le, ← Real.rpow_neg hz.1.le] + exact (area_cube_expectation μ β hlaw ⟨z, hz.1⟩).symm + + theorem weightedAreaTail_ae_finite (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hlaw : ∀ (z : UpperHalfPlane) (φ : DiskFamily → ℝ≥0∞), Measurable φ → + (∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ (-β)) * ∫⁻ f, φ f ∂(μ : Measure DiskFamily)) : + ∀ᵐ f ∂(μ : Measure DiskFamily), weightedAreaTail β f < ∞ := by + have hb (f : DiskFamily) : (∫⁻ z in outsideCenter, conformalAreaCube f (halfPlaneProjection z)) ≤ + ∫⁻ w : ℂ in {w : ℂ | 1 / 4 ≤ ‖w‖}, ENNReal.ofReal (‖w‖⁻¹ ^ 3) := by + convert halfPlane_area_tail_uniform f using 1 + apply setLIntegral_congr_fun measurableSet_outsideCenter + intro z hz + dsimp only + rw [halfPlaneProjection_of_pos hz.1] + rfl + apply ae_lt_top (measurable_weightedAreaTail β) + apply ne_of_lt + rw [expected_area_tail μ β hlaw] + refine lt_of_le_of_lt (lintegral_mono (μ := (μ : Measure DiskFamily)) hb) ?_ + simpa only [lintegral_const, measure_univ, mul_one] using + inverse_cube_tail_finite (show (0 : ℝ) < 1 / 4 by norm_num) + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/AreaTransport.lean b/lean/OAI/Analysis/StrictMeans/AreaTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a2790ea6079e70f3fedb41b3f19c24c7f342b9f --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/AreaTransport.lean @@ -0,0 +1,252 @@ +import OAI.Analysis.StrictMeans.FiberSum + +namespace OAI + +section +open Set MeasureTheory Filter Function +open scoped ENNReal Topology +namespace StrictInverseFirstPower +noncomputable section + +lemma chart_measurable_fiberSum {G : ℂ → ℂ} (e : OpenPartialHomeomorph ℂ ℂ) + (he : (e : ℂ → ℂ) = G) {s : Set ℂ} (hs : MeasurableSet s) (hse : s ⊆ e.source) + {h : ℂ → ℝ≥0∞} (hh : Measurable h) : Measurable (fiberSum G s h) := by + classical + have him : MeasurableSet (G '' s) := by + rw [← he] + exact hs.image_of_continuousOn_injOn (e.continuousOn.mono hse) (e.injOn.mono hse) + let φ := e.target.piecewise e.symm (fun _ => 0) + have hφ : Measurable φ := e.continuousOn_symm.measurable_piecewise + continuousOn_const e.open_target.measurableSet + have hinv : ∀ z ∈ s, φ (G z) = z := by + intro z hz + rw [show G z = e z from congrFun he.symm z] + simp only [φ, piecewise_eq_of_mem _ _ _ (e.map_source (hse hz)), e.left_inv (hse hz)] + rw [fiberSum_eq_indicator_inverse (he ▸ e.injOn.mono hse) h φ hinv] + exact (hh.comp hφ).indicator him + +lemma chart_area_formula {G : ℂ → ℂ} {U : Set ℂ} (hU : IsOpen U) + (hG : ContDiffOn ℝ 1 G U) (e : OpenPartialHomeomorph ℂ ℂ) + (he : (e : ℂ → ℂ) = G) {s : Set ℂ} (hs : MeasurableSet s) + (hsU : s ⊆ U) (hse : s ⊆ e.source) (h : ℂ → ℝ≥0∞) : + ∫⁻ ξ, fiberSum G s h ξ = + ∫⁻ z in s, ENNReal.ofReal |(fderiv ℝ G z).det| * h z := by + classical + have hinv : ∀ z ∈ s, e.symm (G z) = z := by + intro z hz + rw [← he] + exact e.left_inv (hse hz) + have hi : InjOn G s := he ▸ e.injOn.mono hse + have hf : ∀ z ∈ s, HasFDerivWithinAt G (fderiv ℝ G z) s z := by + intro z hz + exact ((hG.contDiffAt (hU.mem_nhds (hsU hz))).differentiableAt one_ne_zero).hasFDerivAt.hasFDerivWithinAt + have him := measurable_image_of_fderivWithin hs hf hi + rw [fiberSum_eq_indicator_inverse hi h e.symm hinv,lintegral_indicator him] + rw [lintegral_image_eq_lintegral_abs_det_fderiv_mul volume hs hf hi] + apply lintegral_congr_ae + filter_upwards [ae_restrict_mem hs] with z hz + rw [hinv z hz] + +lemma regular_area_formula {G : ℂ → ℂ} {U : Set ℂ} (hU : IsOpen U) + (hG : ContDiffOn ℝ 1 G U) {s : Set ℂ} (hs : MeasurableSet s) + (hsR : s ⊆ {z ∈ U | (fderiv ℝ G z).det ≠ 0}) + {h : ℂ → ℝ≥0∞} (hh : Measurable h) : + Measurable (fiberSum G s h) ∧ + ∫⁻ ξ, fiberSum G s h ξ = ∫⁻ z in s, ENNReal.ofReal |(fderiv ℝ G z).det| * h z := by + classical + obtain ⟨C,hC,hchart,hcov⟩ := countable_regular_inverse_charts hU hG + by_cases hn : C.Nonempty + · obtain ⟨e,he⟩ := hC.exists_eq_range hn + have hem (n : ℕ) : e n ∈ C := he ▸ mem_range_self n + let A (n : ℕ) := s ∩ (e n).source + let B := disjointed A + have hmA (n : ℕ) : MeasurableSet (A n) := hs.inter (e n).open_source.measurableSet + have hmB (n : ℕ) : MeasurableSet (B n) := MeasurableSet.disjointed hmA n + have hbA (n : ℕ) : B n ⊆ A n := disjointed_le A n + have hbE (n : ℕ) : B n ⊆ (e n).source := (hbA n).trans inter_subset_right + have hbS (n : ℕ) : B n ⊆ s := (hbA n).trans inter_subset_left + have hbs : (⋃ n, B n) = s := by + rw [iUnion_disjointed] + apply Subset.antisymm + · exact iUnion_subset (fun n => inter_subset_left) + · intro z hz + obtain ⟨c,hc,hzc⟩ := mem_iUnion₂.mp (hcov (hsR hz)) + obtain ⟨n,rfl⟩ := he ▸ hc + exact mem_iUnion.mpr ⟨n,hz,hzc⟩ + have hmb (n : ℕ) : Measurable (fiberSum G (B n) h) := + chart_measurable_fiberSum (e n) (hchart _ (hem n)).1 (hmB n) (hbE n) hh + have heq : fiberSum G s h = fun ξ => ∑' n, fiberSum G (B n) h ξ := by + funext ξ + rw [← hbs] + exact fiberSum_iUnion G B h (disjoint_disjointed A) ξ + refine ⟨heq ▸ .tsum hmb,?_⟩ + rw [heq,lintegral_tsum (fun n => (hmb n).aemeasurable)] + simp_rw [chart_area_formula hU hG _ (hchart _ (hem _)).1 (hmB _) + ((hbS _).trans (fun z hz => (hsR hz).1)) (hbE _)] + rw [← lintegral_iUnion (fun n => hmB n) (disjoint_disjointed A),hbs] + · have hs0 : s = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro z hz + obtain ⟨e,he,_⟩ := mem_iUnion₂.mp (hcov (hsR hz)) + exact hn ⟨e,he⟩ + subst s + have he : fiberSum G ∅ h = 0 := by ext ξ; simp [fiberSum] + rw [he] + exact ⟨measurable_const, by simp⟩ + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +def unsignedTargetWeight (β : ℝ) (f : DiskFamily) (z : UpperHalfPlane) : ℝ≥0∞ := + ENNReal.ofReal (z.im^(β-1) * ‖halfPlaneQ f z‖^3) + +def jacobianPart (k : ℝ) (f : DiskFamily) (positive : Bool) (z : UpperHalfPlane) : ℝ := + max (if positive then jacobianExpression k (halfPlaneFunction f) z else + -jacobianExpression k (halfPlaneFunction f) z) 0 + +def sourceMassDensity (β k : ℝ) (f : DiskFamily) (positive : Bool) + (z : UpperHalfPlane) : ℝ≥0∞ := + ENNReal.ofReal (z.im^(β-1) * ‖halfPlaneQ f z‖ * jacobianPart k f positive z) + +def signedJacobianLocus (k : ℝ) (f : DiskFamily) (positive : Bool) : Set ℂ := + {z | 0 < z.im ∧ if positive then 0 < jacobianExpression k (halfPlaneFunction f) z + else jacobianExpression k (halfPlaneFunction f) z < 0} + +lemma continuous_unsignedTargetWeight (β : ℝ) : + Continuous (fun p : DiskFamily × UpperHalfPlane => unsignedTargetWeight β p.1 p.2) := by + exact ENNReal.continuous_ofReal.comp (((UpperHalfPlane.continuous_im.comp continuous_snd).rpow_const + (fun p => Or.inl p.2.im_ne_zero)).mul (continuous_halfPlaneQ.norm.pow 3)) + +lemma continuous_jacobianPart (k : ℝ) (positive : Bool) : + Continuous (fun p : DiskFamily × UpperHalfPlane => jacobianPart k p.1 positive p.2) := by + cases positive + · exact (continuous_jacobianExpression_upper k).neg.max continuous_const + · exact (continuous_jacobianExpression_upper k).max continuous_const + +lemma continuous_sourceMassDensity (β k : ℝ) (positive : Bool) : + Continuous (fun p : DiskFamily × UpperHalfPlane => sourceMassDensity β k p.1 positive p.2) := by + exact ENNReal.continuous_ofReal.comp ((((UpperHalfPlane.continuous_im.comp continuous_snd).rpow_const + (fun p => Or.inl p.2.im_ne_zero)).mul continuous_halfPlaneQ.norm).mul + (continuous_jacobianPart k positive)) + +lemma measurableSet_signedJacobianLocus (k : ℝ) (f : DiskFamily) (positive : Bool) : + MeasurableSet (signedJacobianLocus k f positive) := by + have hc : Continuous (fun z : UpperHalfPlane => (f,z)) := continuous_const.prodMk continuous_id + have hm := (continuous_jacobianExpression_upper k).comp hc + have hs : MeasurableSet {z : UpperHalfPlane | if positive then + 0 < jacobianExpression k (halfPlaneFunction f) z else + jacobianExpression k (halfPlaneFunction f) z < 0} := by + cases positive + · change MeasurableSet {z : UpperHalfPlane | jacobianExpression k (halfPlaneFunction f) z < 0} + exact measurableSet_lt hm.measurable measurable_const + · change MeasurableSet {z : UpperHalfPlane | 0 < jacobianExpression k (halfPlaneFunction f) z} + exact measurableSet_lt measurable_const hm.measurable + have he : signedJacobianLocus k f positive = UpperHalfPlane.coe '' {z : UpperHalfPlane | if positive then + 0 < jacobianExpression k (halfPlaneFunction f) z else + jacobianExpression k (halfPlaneFunction f) z < 0} := by + ext z + constructor + · intro hz + refine ⟨⟨z,hz.1⟩,?_,rfl⟩ + exact hz.2 + · rintro ⟨w,hw,rfl⟩ + exact ⟨w.im_pos,hw⟩ + rw [he] + exact UpperHalfPlane.measurableEmbedding_coe.measurableSet_image.mpr hs + +lemma criticalMap_det_eq (k : ℝ) (hk : k ≠ 0) (f : DiskFamily) {z : ℂ} (hz : 0 < z.im) : + (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det = + ‖deriv (halfPlaneFunction f) z‖^2 * jacobianExpression k (halfPlaneFunction f) z := by + have ha := (halfPlaneFunction_differentiableOn f).analyticAt (isOpen_halfPlane.mem_nhds hz) + have he := normalizedJacobian_eq hk ha.differentiableAt ha.deriv.differentiableAt + (halfPlaneFunction_deriv_ne_zero f hz) + exact (div_eq_iff (pow_ne_zero 2 (norm_ne_zero_iff.mpr + (halfPlaneFunction_deriv_ne_zero f hz)))).mp he |>.trans (mul_comm _ _) + +lemma sourceMassDensity_eq_targetWeight_det {β k : ℝ} (hk : k ≠ 0) (f : DiskFamily) + (positive : Bool) {z : ℂ} (hz : z ∈ signedJacobianLocus k f positive) : + sourceMassDensity β k f positive ⟨z,hz.1⟩ = + ENNReal.ofReal |(fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det| * + unsignedTargetWeight β f ⟨z,hz.1⟩ := by + have hJ : jacobianPart k f positive ⟨z,hz.1⟩ = |jacobianExpression k (halfPlaneFunction f) z| := by + cases positive + · simp only [signedJacobianLocus,Bool.false_eq_true,↓reduceIte,mem_ofPred_eq] at hz + simp only [jacobianPart,Bool.false_eq_true,↓reduceIte,max_eq_left (neg_nonneg.mpr hz.2.le), + abs_of_neg hz.2] + · simp only [signedJacobianLocus,↓reduceIte,mem_ofPred_eq] at hz + simp only [jacobianPart,↓reduceIte,max_eq_left hz.2.le,abs_of_pos hz.2] + have hd : ‖deriv (halfPlaneFunction f) z‖ ≠ 0 := + norm_ne_zero_iff.mpr (halfPlaneFunction_deriv_ne_zero f hz.1) + rw [sourceMassDensity,unsignedTargetWeight,hJ,criticalMap_det_eq k hk f hz.1, + ← ENNReal.ofReal_mul (abs_nonneg _)] + congr 1 + simp only [halfPlaneQ,norm_inv,abs_mul,abs_pow,abs_norm] + field_simp + +lemma sourceMassDensity_zero_of_not_sign {β k : ℝ} (f : DiskFamily) (positive : Bool) + (z : UpperHalfPlane) (hz : (z:ℂ) ∉ signedJacobianLocus k f positive) : + sourceMassDensity β k f positive z = 0 := by + have hp : jacobianPart k f positive z = 0 := by + cases positive + · have hJ : 0 ≤ jacobianExpression k (halfPlaneFunction f) z := by + simpa only [signedJacobianLocus,mem_ofPred_eq,Bool.false_eq_true,↓reduceIte, + UpperHalfPlane.coe_im, and_iff_right z.im_pos,not_lt] using hz + exact max_eq_right (neg_nonpos.mpr hJ) + · have hJ : jacobianExpression k (halfPlaneFunction f) z ≤ 0 := by + simpa only [signedJacobianLocus,mem_ofPred_eq,↓reduceIte, + UpperHalfPlane.coe_im, and_iff_right z.im_pos,not_lt] using hz + exact max_eq_right hJ + simp [sourceMassDensity,hp] + +lemma source_area_formula {β k : ℝ} (hk : k ≠ 0) (f : DiskFamily) (positive : Bool) + {h : ℂ → ℝ≥0∞} (hh : Measurable h) : + (∫⁻ z in {z : ℂ | 0 < z.im}, h z * sourceMassDensity β k f positive (halfPlaneProjection z)) = + ∫⁻ ξ, fiberSum (criticalMap k (halfPlaneFunction f)) (signedJacobianLocus k f positive) + (fun z => h z * unsignedTargetWeight β f (halfPlaneProjection z)) ξ := by + have hreg : signedJacobianLocus k f positive ⊆ + {z ∈ {z : ℂ | 0 < z.im} | (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det ≠ 0} := by + intro z hz + refine ⟨hz.1, (not_congr (jacobianExpression_zero_iff k hk f hz.1)).mp ?_⟩ + cases positive + · exact ne_of_lt hz.2 + · exact ne_of_gt hz.2 + have hG : ContDiffOn ℝ 1 (criticalMap k (halfPlaneFunction f)) {z : ℂ | 0 < z.im} := by + intro z hz + exact (criticalMap_contDiffAt k f hz).contDiffWithinAt.of_le (by norm_num) + have ht : Measurable (fun z => h z * unsignedTargetWeight β f (halfPlaneProjection z)) := hh.mul + ((continuous_unsignedTargetWeight β).measurable.comp (measurable_const.prodMk measurable_halfPlaneProjection)) + rw [(regular_area_formula isOpen_halfPlane hG (measurableSet_signedJacobianLocus k f positive) hreg ht).2] + have he : (∫⁻ z in signedJacobianLocus k f positive, + ENNReal.ofReal |(fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det| * + (h z * unsignedTargetWeight β f (halfPlaneProjection z))) = + ∫⁻ z in signedJacobianLocus k f positive, + h z * sourceMassDensity β k f positive (halfPlaneProjection z) := by + apply setLIntegral_congr_fun (measurableSet_signedJacobianLocus k f positive) + intro z hz + dsimp only + rw [halfPlaneProjection_of_pos hz.1,sourceMassDensity_eq_targetWeight_det hk f positive hz] + ring + rw [he,← lintegral_indicator (measurableSet_signedJacobianLocus k f positive), + ← lintegral_indicator isOpen_halfPlane.measurableSet] + apply lintegral_congr + intro z + by_cases hz : 0 < z.im + · rw [indicator_of_mem (show z ∈ {z : ℂ | 0 < z.im} from hz)] + by_cases hs : z ∈ signedJacobianLocus k f positive + · rw [indicator_of_mem hs] + · rw [indicator_of_notMem hs,halfPlaneProjection_of_pos hz, + sourceMassDensity_zero_of_not_sign f positive ⟨z,hz⟩ hs,mul_zero] + · rw [indicator_of_notMem (show z ∉ {z : ℂ | 0 < z.im} from hz), + indicator_of_notMem (show z ∉ signedJacobianLocus k f positive from fun hs => hz hs.1)] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/BorelRanks.lean b/lean/OAI/Analysis/StrictMeans/BorelRanks.lean new file mode 100644 index 0000000000000000000000000000000000000000..618e34d65cb2968a115807694419cf765afe0951 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/BorelRanks.lean @@ -0,0 +1,132 @@ +import OAI.Analysis.StrictMeans.DescendingRanks + +namespace OAI + +section +open Set Filter MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +lemma measurableSet_exists_closed_open {P X : Type*} + [TopologicalSpace P] [MeasurableSpace P] [BorelSpace P] + [TopologicalSpace X] [SigmaCompactSpace X] [PerfectlyNormalSpace (P × X)] + {C U : Set (P × X)} (hC : IsClosed C) (hU : IsOpen U) : + MeasurableSet {p : P | ∃ x : X, (p,x) ∈ C ∩ U} := by + obtain ⟨W,hW,hUW⟩ := hU.isClosed_compl.isGδ.eq_iInter_nat + have he : U = ⋃ n : ℕ, (W n)ᶜ := by + rw [← compl_iInter, ← hUW, compl_compl] + have hp : {p : P | ∃ x : X, (p,x) ∈ C ∩ U} = + ⋃ n : ℕ, {p : P | ∃ x : X, (p,x) ∈ C ∩ (W n)ᶜ} := by + ext p + simp only [mem_ofPred_eq,mem_iUnion,mem_inter_iff,he] + constructor + · rintro ⟨x,hx,n,hn⟩ + exact ⟨n,x,hx,hn⟩ + · rintro ⟨n,x,hx,hn⟩ + exact ⟨x,hx,n,hn⟩ + rw [hp] + exact MeasurableSet.iUnion (fun n => + measurableSet_exists_of_closed_sigmaCompact (hC.inter (hW n).isClosed_compl)) + +lemma finite_ncard_ge_iff_tuple {X : Type*} {S : Set X} (hS : S.Finite) (n : ℕ) : + n ≤ S.ncard ↔ ∃ t : Fin n → X, Function.Injective t ∧ ∀ i, t i ∈ S := by + classical + let := hS.fintype + have hc : S.ncard = Fintype.card S := by + rw [Set.ncard_eq_toFinset_card'] + exact Set.toFinset_card S + rw [hc] + constructor + · intro hn + let e : Fin n ↪ S := (Fin.castLEEmb hn).trans (Fintype.equivFin S).symm.toEmbedding + exact ⟨fun i => (e i : X), Subtype.val_injective.comp e.injective, fun i => (e i).2⟩ + · rintro ⟨t,ht,hS⟩ + simpa using Fintype.card_le_of_injective (fun i : Fin n => (⟨t i,hS i⟩ : S)) + (fun i j h => ht (congrArg Subtype.val h)) + +lemma measurable_ncard_locally_closed_fiber {P X : Type*} + [TopologicalSpace P] [MeasurableSpace P] [BorelSpace P] [TopologicalSpace.MetrizableSpace P] + [TopologicalSpace X] [TopologicalSpace.MetrizableSpace X] [SigmaCompactSpace X] + {C U : Set (P × X)} (hC : IsClosed C) (hU : IsOpen U) + (hf : ∀ p : P, {x : X | (p,x) ∈ C ∩ U}.Finite) : + Measurable (fun p : P => {x : X | (p,x) ∈ C ∩ U}.ncard) := by + apply measurable_of_Ici + intro n + let Cn : Set (P × (Fin n → X)) := {q | ∀ i, (q.1,q.2 i) ∈ C} + let Un : Set (P × (Fin n → X)) := + {q | (∀ i, (q.1,q.2 i) ∈ U) ∧ Function.Injective q.2} + have hCn : IsClosed Cn := by + change IsClosed {q : P × (Fin n → X) | ∀ i, (q.1,q.2 i) ∈ C} + simp only [ofPred_forall] + exact isClosed_iInter (fun i => hC.preimage + (continuous_fst.prodMk ((continuous_apply i).comp continuous_snd))) + have hUn : IsOpen Un := by + have hmem : IsOpen {q : P × (Fin n → X) | ∀ i, (q.1,q.2 i) ∈ U} := by + simp only [ofPred_forall] + exact isOpen_iInter_of_finite (fun i => hU.preimage + (continuous_fst.prodMk ((continuous_apply i).comp continuous_snd))) + have hinj : IsOpen {q : P × (Fin n → X) | Function.Injective q.2} := by + have he : {q : P × (Fin n → X) | Function.Injective q.2} = + {q | ∀ i j : Fin n, i ≠ j → q.2 i ≠ q.2 j} := by + ext q + simp only [mem_ofPred_eq] + constructor + · intro h i j hij heq + exact hij (h heq) + · intro h i j heq + by_contra hij + exact h i j hij heq + rw [he] + simp only [ofPred_forall] + exact isOpen_iInter_of_finite (fun i => isOpen_iInter_of_finite (fun j => + isOpen_iInter_of_finite (fun _ => isOpen_ne_fun + ((continuous_apply i).comp continuous_snd) ((continuous_apply j).comp continuous_snd)))) + exact hmem.inter hinj + have hp := measurableSet_exists_closed_open hCn hUn + convert hp using 1 + ext p + simp only [mem_preimage,mem_Ici,mem_ofPred_eq,Cn,Un,mem_inter_iff] + have htest := finite_ncard_ge_iff_tuple (hf p) n + simp only [mem_inter_iff] at htest + rw [htest] + constructor + · rintro ⟨t,ht,hm⟩ + exact ⟨t,fun i => (hm i).1,fun i => (hm i).2,ht⟩ + · rintro ⟨t,hC,hU,ht⟩ + exact ⟨t,ht,fun i => ⟨hC i,hU i⟩⟩ + +lemma measurable_of_borel_graph {P X : Type*} + [MeasurableSpace P] [MeasurableSpace X] + [StandardBorelSpace P] [StandardBorelSpace X] + {f : P → X} (hg : MeasurableSet {q : P × X | f q.1 = q.2}) : + Measurable f := by + let R : Set (P × X) := {q | f q.1 = q.2} + have : StandardBorelSpace R := hg.standardBorel + let π : R → P := fun q => q.1.1 + have hπ : MeasurableEmbedding π := + (measurable_fst.comp measurable_subtype_coe).measurableEmbedding (by + intro q r he + apply Subtype.ext + apply Prod.ext he + exact q.2.symm.trans ((congrArg f he).trans r.2)) + intro A hA + have hm : MeasurableSet {q : R | q.1.2 ∈ A} := + (measurable_snd.comp measurable_subtype_coe) hA + have hi := hπ.measurableSet_image.mpr hm + convert hi using 1 + ext p + simp only [mem_preimage,mem_image,mem_ofPred_eq,π] + constructor + · intro hp + exact ⟨⟨(p,f p),rfl⟩,hp,rfl⟩ + · rintro ⟨q,hq,rfl⟩ + rwa [q.2] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/BoundaryCells.lean b/lean/OAI/Analysis/StrictMeans/BoundaryCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..048e50c2c05e40f415d284de84acc38c1c4a650f --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/BoundaryCells.lean @@ -0,0 +1,372 @@ +import OAI.Analysis.StrictMeans.HorizontalLength + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +lemma scaled_integer_cells_disjoint {h : ℝ} (hh : 0 < h) : + Pairwise (fun i j : ℤ => Disjoint (Ico ((i : ℝ)*h) (((i : ℝ)+1)*h)) + (Ico ((j : ℝ)*h) (((j : ℝ)+1)*h))) := by + have hl (i j : ℤ) (hij : i < j) : + Disjoint (Ico ((i : ℝ)*h) (((i : ℝ)+1)*h)) + (Ico ((j : ℝ)*h) (((j : ℝ)+1)*h)) := by + have he : (i : ℝ)+1 ≤ (j : ℝ) := by exact_mod_cast (Int.add_one_le_iff.mpr hij) + apply Set.disjoint_left.mpr + intro x hx hy + have hle := mul_le_mul_of_nonneg_right he hh.le + linarith [hx.2, hy.1] + intro i j hij + rcases lt_or_gt_of_ne hij with hij' | hij' + · exact hl i j hij' + · exact (hl j i hij').symm + +lemma volume_scaled_integer_cell {h : ℝ} (j : ℤ) : + volume (Ico ((j : ℝ)*h) (((j : ℝ)+1)*h)) = ENNReal.ofReal h := by + rw [Real.volume_Ico] + congr 1 + ring + +lemma cell_disks_measure_bound {h r : ℝ} (hh : 0 < h) (hr : 0 ≤ r) + (J : Set ℤ) (c : ℤ → ℂ) {C : ℝ≥0∞} + (hC : volume (⋃ j : J, Ico (((j : ℤ) : ℝ)*h) ((((j : ℤ) : ℝ)+1)*h)) ≤ C) : + volume (⋃ j : J, closedBall (c j) r) ≤ ENNReal.ofReal (Real.pi*r^2/h) * C := by + have hd : Pairwise (fun i j : J => Disjoint + (Ico (((i : ℤ) : ℝ)*h) ((((i : ℤ) : ℝ)+1)*h)) + (Ico (((j : ℤ) : ℝ)*h) ((((j : ℤ) : ℝ)+1)*h))) := + fun i j hij => scaled_integer_cells_disjoint hh (Subtype.coe_ne_coe.mpr hij) + have he : (∑' j : J, ENNReal.ofReal h) ≤ C := by + simpa only [measure_iUnion hd (fun _ => measurableSet_Ico), volume_scaled_integer_cell] using hC + calc + _ ≤ ∑' j : J, volume (closedBall (c j) r) := measure_iUnion_le _ + _ = ∑' j : J, ENNReal.ofReal (Real.pi*r^2/h) * ENNReal.ofReal h := by + apply tsum_congr + intro j + rw [Complex.volume_closedBall] + rw [← ENNReal.ofReal_coe_nnreal] + change ENNReal.ofReal r ^ 2 * ENNReal.ofReal Real.pi = _ + rw [← ENNReal.ofReal_pow hr, ← ENNReal.ofReal_mul (sq_nonneg r), + ← ENNReal.ofReal_mul (by positivity)] + congr 1 + field_simp + _ = ENNReal.ofReal (Real.pi*r^2/h) * ∑' j : J, ENNReal.ofReal h := + ENNReal.tsum_mul_left + _ ≤ _ := by gcongr + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +def cellRectangle : Set UpperHalfPlane := + {z | |z.re| ≤ 1 ∧ 1/2 ≤ z.im ∧ z.im ≤ 1} + +lemma isCompact_cellRectangle : IsCompact cellRectangle := by + rw [UpperHalfPlane.isEmbedding_coe.isCompact_iff] + have he : ((↑) '' cellRectangle : Set ℂ) = + {z | |z.re| ≤ 1 ∧ 1/2 ≤ z.im ∧ z.im ≤ 1} := by + ext z + constructor + · rintro ⟨w, hw, rfl⟩ + exact hw + · intro hz + exact ⟨⟨z, by linarith [hz.2.1]⟩, hz, rfl⟩ + rw [he] + apply (isCompact_closedBall (0 : ℂ) 2).of_isClosed_subset + ((isClosed_le Complex.continuous_re.abs continuous_const).inter + ((isClosed_le continuous_const Complex.continuous_im).inter + (isClosed_le Complex.continuous_im continuous_const))) + intro z hz + change |z.re| ≤ 1 ∧ 1/2 ≤ z.im ∧ z.im ≤ 1 at hz + simp only [mem_closedBall, dist_zero_right] + have hn := Complex.norm_le_abs_re_add_abs_im z + rw [abs_of_nonneg (by linarith [hz.2.1] : 0 ≤ z.im)] at hn + linarith [hz.1, hz.2.2] + +lemma family_rectangle_bound : ∃ M : ℝ, 0 < M ∧ + ∀ (f : DiskFamily) (z : UpperHalfPlane), z ∈ cellRectangle → + ‖halfPlaneFunction f z‖ ≤ M := by + have hc := (isCompact_univ (X := DiskFamily)).prod isCompact_cellRectangle + obtain ⟨M, hMpos, hM⟩ := (hc.image continuous_halfPlaneFunction).isBounded.subset_ball_lt 0 (0 : ℂ) + refine ⟨M, hMpos, fun f z hz => ?_⟩ + have hh := hM (mem_image_of_mem (fun p : DiskFamily × UpperHalfPlane => halfPlaneFunction p.1 p.2) + (show (f,z) ∈ (univ : Set DiskFamily) ×ˢ cellRectangle from ⟨mem_univ _, hz⟩)) + exact (by simpa only [mem_ball, dist_zero_right] using hh : ‖halfPlaneFunction f z‖ < M).le + +lemma full_ball_halfplane_subset (z : UpperHalfPlane) : + ball (z : ℂ) z.im ⊆ {w : ℂ | 0 < w.im} := by + intro w hw + have he := im_lower_of_mem_ball hw + change z.im - z.im < w.im at he + change 0 < w.im + linarith + +lemma omitted_derivative_bound (f : DiskFamily) {ξ : ℂ} + (hξ : ξ ∉ halfPlaneFunction f '' {z : ℂ | 0 < z.im}) (z : UpperHalfPlane) : + z.im * ‖deriv (halfPlaneFunction f) z‖ ≤ 4 * ‖halfPlaneFunction f z - ξ‖ := by + let F := halfPlaneFunction f + have hd : DifferentiableOn ℂ (fun w => F w - ξ) (ball (z : ℂ) z.im) := + ((halfPlaneFunction_differentiableOn f).mono (full_ball_halfplane_subset z)).sub_const ξ + have hi : InjOn (fun w => F w - ξ) (ball (z : ℂ) z.im) := by + intro a ha b hb hab + exact halfPlaneFunction_injOn f (full_ball_halfplane_subset z ha) + (full_ball_halfplane_subset z hb) (sub_left_injective hab) + have he : deriv (fun w => F w - ξ) z = deriv F z := deriv_sub_const ξ + have hn : deriv (fun w => F w - ξ) z ≠ 0 := by + rw [he] + exact halfPlaneFunction_deriv_ne_zero f z.im_pos + have ho : 0 ∉ (fun w => F w - ξ) '' ball (z : ℂ) z.im := by + rintro ⟨w, hw, hh⟩ + exact hξ ⟨w, full_ball_halfplane_subset z hw, sub_eq_zero.mp hh⟩ + have hh := omitted_local_quarter_bound z.im_pos hd hi hn ho + rw [he] at hh + linarith + +lemma cell_rebased_mem (z : UpperHalfPlane) {h u : ℝ} (hh : 0 < h) + (hlo : h ≤ z.im) (hhi : z.im ≤ 2*h) (hu : |u-z.re| ≤ h) : + ∃ v : UpperHalfPlane, v ∈ cellRectangle ∧ affineAt z v = (u : ℂ) + (h : ℂ)*I := by + let v : ℂ := ((u-z.re : ℝ) : ℂ) / (z.im : ℂ) + (h/z.im : ℝ)*I + have hre : v.re = (u-z.re)/z.im := by simp [v] + have him : v.im = h/z.im := by simp [v] + have hv : 0 < v.im := by rw [him]; exact div_pos hh z.im_pos + refine ⟨⟨v,hv⟩, ?_, ?_⟩ + · change |v.re| ≤ 1 ∧ 1/2 ≤ v.im ∧ v.im ≤ 1 + rw [hre, him, abs_div, abs_of_pos z.im_pos] + refine ⟨(div_le_one z.im_pos).mpr (hu.trans hlo), ?_, (div_le_one z.im_pos).mpr hlo⟩ + rw [le_div_iff₀ z.im_pos] + linarith + · apply Complex.ext <;> simp only [affineAt, v, add_re, add_im, + mul_re, mul_im, div_ofReal_re, div_ofReal_im, ofReal_re, ofReal_im, I_re, I_im, + mul_zero, mul_one, zero_mul, zero_add, add_zero, sub_zero] + · field_simp + ring + · field_simp + ring + +lemma omitted_cell_comparison {M : ℝ} (hM : ∀ (f : DiskFamily) (z : UpperHalfPlane), + z ∈ cellRectangle → ‖halfPlaneFunction f z‖ ≤ M) (hM0 : 0 ≤ M) + (f : DiskFamily) {ξ : ℂ} (hξ : ξ ∉ halfPlaneFunction f '' {z : ℂ | 0 < z.im}) + (z : UpperHalfPlane) {h u : ℝ} (hh : 0 < h) + (hlo : h ≤ z.im) (hhi : z.im ≤ 2*h) (hu : |u-z.re| ≤ h) : + ‖halfPlaneFunction f ((u : ℂ)+(h : ℂ)*I)-ξ‖ ≤ + (4*M+1)*‖halfPlaneFunction f z-ξ‖ := by + obtain ⟨v, hv, he⟩ := cell_rebased_mem z hh hlo hhi hu + have hb := hM (rebase f z) v hv + rw [halfPlaneFunction_rebase f z v.im_pos, he, norm_div, norm_mul, + Complex.norm_real, Real.norm_eq_abs, abs_of_pos z.im_pos] at hb + have hd : 0 < ‖deriv (halfPlaneFunction f) z‖ := + norm_pos_iff.mpr (halfPlaneFunction_deriv_ne_zero f z.im_pos) + have hm := (div_le_iff₀ (mul_pos z.im_pos hd)).mp hb + have hq := mul_le_mul_of_nonneg_left (omitted_derivative_bound f hξ z) hM0 + have ht := norm_add_le (halfPlaneFunction f ((u : ℂ)+(h : ℂ)*I)-halfPlaneFunction f z) + (halfPlaneFunction f z-ξ) + rw [sub_add_sub_cancel] at ht + nlinarith + +lemma omitted_cell_power_bound {M k δ : ℝ} (hM : ∀ (f : DiskFamily) (z : UpperHalfPlane), + z ∈ cellRectangle → ‖halfPlaneFunction f z‖ ≤ M) (hM0 : 0 ≤ M) + (hk : 0 ≤ k) (hδ : 0 < δ) (f : DiskFamily) {ξ : ℂ} + (hξ : ξ ∉ halfPlaneFunction f '' {z : ℂ | 0 < z.im}) + (z : UpperHalfPlane) {h u : ℝ} (hh : 0 < h) + (hlo : h ≤ z.im) (hhi : z.im ≤ 2*h) (hu : |u-z.re| ≤ h) + (hw : ‖halfPlaneFunction f z-ξ‖ ≤ z.im^k/δ) : + ‖halfPlaneFunction f ((u : ℂ)+(h : ℂ)*I)-ξ‖ ≤ + ((4*M+1)*2^k/δ)*h^k := by + calc + _ ≤ (4*M+1)*‖halfPlaneFunction f z-ξ‖ := omitted_cell_comparison hM hM0 f hξ z hh hlo hhi hu + _ ≤ (4*M+1)*(z.im^k/δ) := mul_le_mul_of_nonneg_left hw (by positivity) + _ ≤ (4*M+1)*((2*h)^k/δ) := mul_le_mul_of_nonneg_left + (div_le_div_of_nonneg_right (Real.rpow_le_rpow z.im_pos.le hhi hk) hδ.le) (by positivity) + _ = _ := by rw [Real.mul_rpow (by norm_num : (0:ℝ) ≤ 2) hh.le]; ring + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +def boundaryWitness (f : DiskFamily) (k R δ h : ℝ) (ξ : ℂ) (z : UpperHalfPlane) : Prop := + ξ ∉ halfPlaneFunction f '' {w : ℂ | 0 < w.im} ∧ ‖ξ‖ ≤ R ∧ + h ≤ z.im ∧ z.im ≤ 2*h ∧ ‖halfPlaneFunction f z-ξ‖ ≤ z.im^k/δ + +def boundaryBadScale (f : DiskFamily) (k R δ h : ℝ) : Set ℂ := + {ξ | ∃ z, boundaryWitness f k R δ h ξ z} + +def boundaryMarkedCells (f : DiskFamily) (k R δ h : ℝ) : Set ℤ := + {j | ∃ ξ z, boundaryWitness f k R δ h ξ z ∧ z.re ∈ Ico ((j:ℝ)*h) (((j:ℝ)+1)*h)} + +def cellMidpointImage (f : DiskFamily) (h : ℝ) (j : ℤ) : ℂ := + halfPlaneFunction f ((((j:ℝ)+1/2)*h : ℝ) + (h:ℂ)*I) + +lemma same_cell_difference {j : ℤ} {h u v : ℝ} + (hu : u ∈ Ico ((j:ℝ)*h) (((j:ℝ)+1)*h)) + (hv : v ∈ Ico ((j:ℝ)*h) (((j:ℝ)+1)*h)) : |u-v| ≤ h := by + apply abs_le.mpr + constructor <;> nlinarith [hu.1, hu.2, hv.1, hv.2] + +lemma midpoint_mem_cell {h : ℝ} (hh : 0 < h) (j : ℤ) : + ((j:ℝ)+1/2)*h ∈ Ico ((j:ℝ)*h) (((j:ℝ)+1)*h) := by + constructor <;> nlinarith + +lemma floor_cell_mem {h : ℝ} (hh : 0 < h) (x : ℝ) : + x ∈ Ico (((⌊x/h⌋ : ℤ):ℝ)*h) ((((⌊x/h⌋ : ℤ):ℝ)+1)*h) := by + constructor + · exact (le_div_iff₀ hh).mp (Int.floor_le (x/h)) + · exact (div_lt_iff₀ hh).mp (Int.lt_floor_add_one (x/h)) + +lemma boundaryBadScale_subset_cover {M k R δ h : ℝ} + (hM : ∀ (f : DiskFamily) (z : UpperHalfPlane), z ∈ cellRectangle → ‖halfPlaneFunction f z‖ ≤ M) + (hM0 : 0 ≤ M) (hk : 0 ≤ k) (hδ : 0 < δ) (hh : 0 < h) (f : DiskFamily) : + boundaryBadScale f k R δ h ⊆ ⋃ j : boundaryMarkedCells f k R δ h, + closedBall (cellMidpointImage f h j) (((4*M+1)*2^k/δ)*h^k) := by + rintro ξ ⟨z, hz⟩ + let j : ℤ := ⌊z.re/h⌋ + have hj : j ∈ boundaryMarkedCells f k R δ h := ⟨ξ,z,hz,floor_cell_mem hh z.re⟩ + apply mem_iUnion.mpr + refine ⟨⟨j,hj⟩, ?_⟩ + rw [mem_closedBall, dist_comm, dist_eq_norm] + exact omitted_cell_power_bound hM hM0 hk hδ f hz.1 z hh hz.2.2.1 hz.2.2.2.1 + (same_cell_difference (midpoint_mem_cell hh j) (floor_cell_mem hh z.re)) hz.2.2.2.2 + +lemma marked_segments_image_bounded {M k R δ h : ℝ} + (hM : ∀ (f : DiskFamily) (z : UpperHalfPlane), z ∈ cellRectangle → ‖halfPlaneFunction f z‖ ≤ M) + (hM0 : 0 ≤ M) (hk : 0 ≤ k) (hδ : 0 < δ) (hh : 0 < h) (hh1 : h ≤ 1) (f : DiskFamily) : + (⋃ j : boundaryMarkedCells f k R δ h, + Ico (((j:ℤ):ℝ)*h) ((((j:ℤ):ℝ)+1)*h)) ⊆ + {u : ℝ | halfPlaneFunction f ((u:ℂ)+(h:ℂ)*I) ∈ closedBall 0 (R+(4*M+1)*2^k/δ)} := by + rintro u hu + obtain ⟨j,hj⟩ := mem_iUnion.mp hu + obtain ⟨ξ,z,hz,hzcell⟩ := j.property + have hb := omitted_cell_power_bound hM hM0 hk hδ f hz.1 z hh hz.2.2.1 hz.2.2.2.1 + (same_cell_difference hj hzcell) hz.2.2.2.2 + have hp : h^k ≤ 1 := Real.rpow_le_one hh.le hh1 hk + have hc : 0 ≤ (4*M+1)*2^k/δ := by positivity + have ht := norm_add_le (halfPlaneFunction f ((u:ℂ)+(h:ℂ)*I)-ξ) ξ + rw [sub_add_cancel] at ht + simp only [mem_ofPred_eq, mem_closedBall, dist_zero_right] + nlinarith [hz.2.1, mul_le_of_le_one_right hc hp] + +lemma cell_area_power_identity {h : ℝ} (hh : 0 < h) (A k : ℝ) : + Real.pi*(A*h^k)^2/h = (Real.pi*A^2)*h^(2*k-1) := by + rw [Real.rpow_sub_one hh.ne', show 2*k = k*2 by ring, + Real.rpow_mul hh.le, Real.rpow_two] + ring + +theorem boundaryBadScale_measure_bound (f : DiskFamily) (β k R δ : ℝ) + (hβ : 0 ≤ β) (hk : 0 ≤ k) (hδ : 0 < δ) (hfin : weightedAreaTail β f < ⊤) : + ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ h : ℝ, 0 < h → h ≤ 1 → + volume (boundaryBadScale f k R δ h) ≤ D * ENNReal.ofReal (h^(2*k-1)) := by + obtain ⟨M,hM0,hM⟩ := family_rectangle_bound + let A : ℝ := (4*M+1)*2^k/δ + have hA : 0 ≤ A := by dsimp [A]; positivity + obtain ⟨C,hC⟩ := horizontal_length_bound f β hβ hfin (isCompact_closedBall (0:ℂ) (R+A)) + refine ⟨ENNReal.ofReal (Real.pi*A^2)*ENNReal.ofReal C, ENNReal.mul_lt_top + ENNReal.ofReal_lt_top ENNReal.ofReal_lt_top, fun h hh hh1 => ?_⟩ + have hseg : volume (⋃ j : boundaryMarkedCells f k R δ h, + Ico (((j:ℤ):ℝ)*h) ((((j:ℤ):ℝ)+1)*h)) ≤ ENNReal.ofReal C := + (measure_mono (marked_segments_image_bounded hM hM0.le hk hδ hh hh1 f)).trans (hC h hh) + calc + _ ≤ volume (⋃ j : boundaryMarkedCells f k R δ h, + closedBall (cellMidpointImage f h j) (A*h^k)) := + measure_mono (boundaryBadScale_subset_cover hM hM0.le hk hδ hh f) + _ ≤ ENNReal.ofReal (Real.pi*(A*h^k)^2/h)*ENNReal.ofReal C := + cell_disks_measure_bound hh (by positivity) _ _ hseg + _ = _ := by rw [cell_area_power_identity hh, ENNReal.ofReal_mul (by positivity)]; ring + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/BoundaryEscape.lean b/lean/OAI/Analysis/StrictMeans/BoundaryEscape.lean new file mode 100644 index 0000000000000000000000000000000000000000..81d4aae31bce1592acac6178226138f2fb0363b3 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/BoundaryEscape.lean @@ -0,0 +1,350 @@ +import OAI.Analysis.StrictMeans.BoundaryCells + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +lemma dyadicHeight_rpow (γ : ℝ) (n : ℕ) : + (dyadicHeight n)^γ = ((1/2 : ℝ)^γ)^n := by + dsimp only [dyadicHeight] + rw [← Real.rpow_natCast_mul (by norm_num), mul_comm (n:ℝ), Real.rpow_mul_natCast (by norm_num)] + +lemma ae_eventually_dyadic_cover {α : Type*} [MeasurableSpace α] (μ : Measure α) + {s : ℕ → Set α} {D : ℝ≥0∞} (hD : D < ⊤) {γ : ℝ} (hγ : 0 < γ) + (hbound : ∀ n, μ (s n) ≤ D * ENNReal.ofReal ((dyadicHeight n)^γ)) : + ∀ᵐ x ∂μ, ∀ᶠ n in atTop, x ∉ s n := by + apply ae_eventually_notMem + apply ne_of_lt + calc + (∑' n, μ (s n)) ≤ ∑' n, D * ENNReal.ofReal ((dyadicHeight n)^γ) := ENNReal.tsum_le_tsum hbound + _ = D * (1 - ENNReal.ofReal ((1/2:ℝ)^γ))⁻¹ := by + simp only [dyadicHeight_rpow, ENNReal.ofReal_pow (Real.rpow_nonneg (by norm_num : (0:ℝ) ≤ 1/2) γ), + ENNReal.tsum_mul_left, ENNReal.tsum_geometric] + _ < ⊤ := ENNReal.mul_lt_top hD (ENNReal.inv_lt_top.mpr (by + exact tsub_pos_iff_lt.mpr (ENNReal.ofReal_lt_one.mpr + (Real.rpow_lt_one (by norm_num) (by norm_num) hγ)))) + +lemma dyadic_band_after {y : ℝ} (hy : 0 < y) (N : ℕ) (hNy : y < dyadicHeight N) : + ∃ n : ℕ, N ≤ n ∧ dyadicHeight n ≤ y ∧ y ≤ 2*dyadicHeight n := by + have hy1 : y ≤ 1 := hNy.le.trans (dyadicHeight_le_one N) + obtain ⟨m,hmlo,hmhi⟩ := exists_nat_pow_near_of_lt_one hy hy1 + (by norm_num : (0:ℝ) < 1/2) (by norm_num : (1/2:ℝ) < 1) + refine ⟨m+1, ?_, hmlo.le, ?_⟩ + · by_contra hh + have hmN : m+1 ≤ N := le_of_lt (lt_of_not_ge hh) + have hp : dyadicHeight N ≤ dyadicHeight (m+1) := + pow_le_pow_of_le_one (by norm_num) (by norm_num) hmN + exact (hNy.trans_le hp).not_ge hmlo.le + · dsimp [dyadicHeight] + rw [pow_succ] + linarith + +def boundaryEscape (k : ℝ) (F : ℂ → ℂ) (ξ : ℂ) : Prop := + ∀ δ : ℝ, 0 < δ → ∃ ε : ℝ, 0 < ε ∧ ∀ z : UpperHalfPlane, + z.im < ε → z.im^k/δ < ‖F z-ξ‖ + +lemma boundaryBadScale_ae_eventually (f : DiskFamily) (β k R δ : ℝ) + (hβ : 0 ≤ β) (hk : 1/2 < k) (hδ : 0 < δ) (hfin : weightedAreaTail β f < ⊤) : + ∀ᵐ ξ : ℂ, ∀ᶠ n in atTop, ξ ∉ boundaryBadScale f k R δ (dyadicHeight n) := by + obtain ⟨D,hD,hbound⟩ := boundaryBadScale_measure_bound f β k R δ hβ (by linarith) hδ hfin + exact ae_eventually_dyadic_cover volume hD (by linarith : 0 < 2*k-1) + (fun n => hbound _ (dyadicHeight_pos n) (dyadicHeight_le_one n)) + +theorem ae_omitted_boundary_escape (f : DiskFamily) (β k : ℝ) + (hβ : 0 ≤ β) (hk : 1/2 < k) (hfin : weightedAreaTail β f < ⊤) : + ∀ᵐ ξ : ℂ, ξ ∉ halfPlaneFunction f '' {z : ℂ | 0 < z.im} → + boundaryEscape k (halfPlaneFunction f) ξ := by + have hall : ∀ᵐ ξ : ℂ, ∀ m n : ℕ, ∀ᶠ j in atTop, + ξ ∉ boundaryBadScale f k (m:ℝ) (1/(n+1)) (dyadicHeight j) := by + apply ae_all_iff.mpr + intro m + apply ae_all_iff.mpr + intro n + exact boundaryBadScale_ae_eventually f β k m (1/(n+1)) hβ hk (by positivity) hfin + filter_upwards [hall] with ξ hξ + intro homit δ hδ + obtain ⟨m,hm⟩ := exists_nat_gt ‖ξ‖ + obtain ⟨n,hn⟩ := exists_nat_one_div_lt hδ + obtain ⟨N,hN⟩ := eventually_atTop.mp (hξ m n) + refine ⟨dyadicHeight N, dyadicHeight_pos N, fun z hz => ?_⟩ + obtain ⟨j,hj,hjlo,hjhi⟩ := dyadic_band_after z.im_pos N hz + by_contra hbad + apply hN j hj + refine ⟨z, homit, hm.le, hjlo, hjhi, ?_⟩ + calc + ‖halfPlaneFunction f z-ξ‖ ≤ z.im^k/δ := le_of_not_gt hbad + _ ≤ z.im^k/(1/(n+1:ℝ)) := by gcongr + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +lemma image_target_separated_near_boundary (f : DiskFamily) {ξ : ℂ} + (hξ : ξ ∈ halfPlaneFunction f '' {z : ℂ | 0 < z.im}) : + ∃ ε a : ℝ, 0 < ε ∧ 0 < a ∧ ∀ z : UpperHalfPlane, + z.im < ε → a ≤ ‖halfPlaneFunction f z - ξ‖ := by + obtain ⟨w,hw,rfl⟩ := hξ + change 0 < w.im at hw + let r : ℝ := w.im/2 + have hr : 0 < r := half_pos hw + have hsub : ball w r ⊆ {z : ℂ | 0 < z.im} := by + intro z hz + have he := im_lower_of_mem_ball hz + change 0 < z.im + dsimp [r] at he + linarith + have hd := (halfPlaneFunction_differentiableOn f).mono hsub + have hi := (halfPlaneFunction_injOn f).mono hsub + have hn := halfPlaneFunction_deriv_ne_zero f hw + have hq := local_koebe_quarter hr hd hi hn + refine ⟨r, r * ‖deriv (halfPlaneFunction f) w‖ / 4, hr, + div_pos (mul_pos hr (norm_pos_iff.mpr hn)) (by norm_num), ?_⟩ + intro z hz + by_contra he + have hzball : halfPlaneFunction f z ∈ + ball (halfPlaneFunction f w) (r * ‖deriv (halfPlaneFunction f) w‖ /4) := by + simpa only [mem_ball, dist_eq_norm] using lt_of_not_ge he + obtain ⟨u,hu,heu⟩ := hq hzball + have huz : u = z := halfPlaneFunction_injOn f (hsub hu) z.im_pos heu + rw [huz] at hu + have he := im_lower_of_mem_ball hu + change w.im-r < z.im at he + dsimp [r] at he hz + linarith + +lemma image_target_boundary_escape (f : DiskFamily) {k : ℝ} (hk : 0 < k) {ξ : ℂ} + (hξ : ξ ∈ halfPlaneFunction f '' {z : ℂ | 0 < z.im}) : + boundaryEscape k (halfPlaneFunction f) ξ := by + obtain ⟨ε,a,hε,ha,hsep⟩ := image_target_separated_near_boundary f hξ + intro δ hδ + have hc : ContinuousAt (fun y : ℝ => y^k / δ) 0 := + (Real.continuous_rpow_const hk.le).continuousAt.div_const δ + have he : ∀ᶠ y : ℝ in 𝓝 0, y^k/δ < a := + hc.preimage_mem_nhds (Iio_mem_nhds (by simpa [Real.zero_rpow hk.ne'] using ha)) + obtain ⟨η,hη,hb⟩ := Metric.mem_nhds_iff.mp he + refine ⟨min ε η, lt_min hε hη, fun z hz => ?_⟩ + have hzη : (z.im : ℝ) ∈ ball 0 η := by + simpa only [mem_ball, dist_zero_right, Real.norm_eq_abs, abs_of_pos z.im_pos] + using (lt_of_lt_of_le hz (min_le_right _ _)) + exact (hb hzη).trans_le (hsep z (lt_of_lt_of_le hz (min_le_left _ _))) + +lemma ae_boundary_escape (f : DiskFamily) (β k : ℝ) + (hβ : 0 ≤ β) (hk : 1/2 < k) (hfin : weightedAreaTail β f < ⊤) : + ∀ᵐ ξ : ℂ, boundaryEscape k (halfPlaneFunction f) ξ := by + filter_upwards [ae_omitted_boundary_escape f β k hβ hk hfin] with ξ hξ + by_cases hi : ξ ∈ halfPlaneFunction f '' {z : ℂ | 0 < z.im} + · exact image_target_boundary_escape f (by linarith) hi + · exact hξ hi + +lemma norm_image_at_infinity_in_strip (f : DiskFamily) (β : ℝ) (hβ : 0 ≤ β) + (hfin : weightedAreaTail β f < ⊤) {ι : Type*} {l : Filter ι} + (Z : ι → UpperHalfPlane) {ε : ℝ} (hε : 0 < ε) + (hstrip : ∀ᶠ a in l, ε ≤ (Z a).im) + (hnorm : Tendsto (fun a => ‖(Z a : ℂ)‖) l atTop) : + Tendsto (fun a => ‖halfPlaneFunction f (Z a)‖) l atTop := by + apply Filter.tendsto_atTop.2 + intro R + obtain ⟨M,hM⟩ := bounded_strip_preimage f β hβ hfin (ε := ε) (R := R) hε + filter_upwards [hstrip, hnorm.eventually_gt_atTop M] with a ha ham + by_contra h + exact (hM (Z a) ha (le_of_not_ge h)).not_gt ham + +lemma translated_escape_at_infinity_in_strip (f : DiskFamily) (β : ℝ) (hβ : 0 ≤ β) + (hfin : weightedAreaTail β f < ⊤) (ξ : ℂ) {ι : Type*} {l : Filter ι} + (Z : ι → UpperHalfPlane) {ε : ℝ} (hε : 0 < ε) + (hstrip : ∀ᶠ a in l, ε ≤ (Z a).im) + (hnorm : Tendsto (fun a => ‖(Z a : ℂ)‖) l atTop) : + Tendsto (fun a => (Z a).im ^ ((β+2)/3) / ‖halfPlaneFunction f (Z a)-ξ‖) l (𝓝 0) := by + have he := escape_at_infinity f β hβ hfin Z hnorm + have hf := norm_image_at_infinity_in_strip f β hβ hfin Z hε hstrip hnorm + have hb : ∀ᶠ a in l, (Z a).im ^ ((β+2)/3) / ‖halfPlaneFunction f (Z a)-ξ‖ ≤ + 2*((Z a).im ^ ((β+2)/3) / ‖halfPlaneFunction f (Z a)‖) := by + filter_upwards [hf.eventually_gt_atTop (2*‖ξ‖+1)] with a ha + have hn := norm_sub_norm_le (halfPlaneFunction f (Z a)) ξ + have hF : 0 < ‖halfPlaneFunction f (Z a)‖-‖ξ‖ := by linarith [norm_nonneg ξ] + have hd : 0 < ‖halfPlaneFunction f (Z a)-ξ‖ := hF.trans_le hn + rw [div_le_iff₀ hd] + have hp : 0 < ‖halfPlaneFunction f (Z a)‖ := by linarith [norm_nonneg ξ] + have ht : 2*‖halfPlaneFunction f (Z a)-ξ‖ / ‖halfPlaneFunction f (Z a)‖ ≥ 1 := by + change 1 ≤ 2*‖halfPlaneFunction f (Z a)-ξ‖ / ‖halfPlaneFunction f (Z a)‖ + rw [le_div_iff₀ hp] + linarith + have ht' := mul_le_mul_of_nonneg_left ht + (Real.rpow_nonneg (Z a).im_pos.le ((β+2)/3)) + nlinarith [show (Z a).im ^ ((β+2)/3) * (2*‖halfPlaneFunction f (Z a)-ξ‖ / ‖halfPlaneFunction f (Z a)‖) = + 2*((Z a).im ^ ((β+2)/3)/‖halfPlaneFunction f (Z a)‖)*‖halfPlaneFunction f (Z a)-ξ‖ by ring] + apply squeeze_zero' (Eventually.of_forall (fun a => div_nonneg (Real.rpow_nonneg (Z a).im_pos.le _) (norm_nonneg _))) hb + simpa using he.const_mul 2 + +def potentialSuperlevel (k : ℝ) (F : ℂ → ℂ) (ξ : ℂ) (h : ℝ) : Set ℂ := + {z | 0 < z.im ∧ ‖F z - ξ‖ ≤ z.im ^ k / h} + +lemma bounded_strip_superlevel (f : DiskFamily) (β : ℝ) (hβ : 0 ≤ β) + (hfin : weightedAreaTail β f < ⊤) (ξ : ℂ) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) : + ∃ M : ℝ, ∀ z : UpperHalfPlane, ε ≤ z.im → + ‖halfPlaneFunction f z-ξ‖ ≤ z.im^((β+2)/3)/δ → ‖(z:ℂ)‖ ≤ M := by + by_contra h + push Not at h + choose Z hZ using fun n : ℕ => h (n:ℝ) + have hn : Tendsto (fun n => ‖(Z n : ℂ)‖) atTop atTop := + tendsto_atTop_mono (fun n => (hZ n).2.2.le) tendsto_natCast_atTop_atTop + have he := translated_escape_at_infinity_in_strip f β hβ hfin ξ Z hε + (Eventually.of_forall (fun n => (hZ n).1)) hn + have hF := norm_image_at_infinity_in_strip f β hβ hfin Z hε + (Eventually.of_forall (fun n => (hZ n).1)) hn + have hlo : ∀ᶠ n in atTop, δ ≤ (Z n).im^((β+2)/3)/‖halfPlaneFunction f (Z n)-ξ‖ := by + filter_upwards [hF.eventually_gt_atTop ‖ξ‖] with n hh + have hd : 0 < ‖halfPlaneFunction f (Z n)-ξ‖ := + (sub_pos.mpr hh).trans_le (norm_sub_norm_le _ _) + rw [le_div_iff₀ hd] + have h := (le_div_iff₀ hδ).mp (hZ n).2.1 + linarith + exact hδ.not_ge (ge_of_tendsto he hlo) + +lemma compact_superlevels_of_boundary_escape (f : DiskFamily) (β : ℝ) (hβ : 0 ≤ β) + (hfin : weightedAreaTail β f < ⊤) (ξ : ℂ) + (hescape : boundaryEscape ((β+2)/3) (halfPlaneFunction f) ξ) {δ : ℝ} (hδ : 0 < δ) : + IsCompact (potentialSuperlevel ((β+2)/3) (halfPlaneFunction f) ξ δ) := by + obtain ⟨ε,hε,hbound⟩ := hescape δ hδ + have heq : potentialSuperlevel ((β+2)/3) (halfPlaneFunction f) ξ δ = + {z : ℂ | ε ≤ z.im ∧ ‖halfPlaneFunction f z-ξ‖ ≤ z.im^((β+2)/3)/δ} := by + ext z + constructor + · intro hz + refine ⟨?_,hz.2⟩ + by_contra hh + exact (hbound ⟨z,hz.1⟩ (lt_of_not_ge hh)).not_ge hz.2 + · intro hz + exact ⟨hε.trans_le hz.1,hz.2⟩ + rw [heq] + have hclosed : IsClosed {z : ℂ | ε ≤ z.im ∧ ‖halfPlaneFunction f z-ξ‖ ≤ z.im^((β+2)/3)/δ} := by + apply (isClosed_le continuous_const Complex.continuous_im).isClosed_le + · have hc : ContinuousOn (halfPlaneFunction f) {z : ℂ | ε ≤ z.im} := + (halfPlaneFunction_differentiableOn f).continuousOn.mono (fun z hz => hε.trans_le hz) + exact (hc.sub continuousOn_const).norm + · exact ((Real.continuous_rpow_const (by linarith : 0 ≤ (β+2)/3)).comp Complex.continuous_im).continuousOn.div_const δ + obtain ⟨M,hM⟩ := bounded_strip_superlevel f β hβ hfin ξ hε hδ + apply (isCompact_closedBall (0:ℂ) M).of_isClosed_subset hclosed + intro z hz + simpa only [mem_closedBall, dist_zero_right] using hM ⟨z,hε.trans_le hz.1⟩ hz.1 hz.2 + +theorem ae_compact_positive_superlevels (f : DiskFamily) (β : ℝ) (hβ : 0 ≤ β) + (hfin : weightedAreaTail β f < ⊤) : + ∀ᵐ ξ : ℂ, ∀ δ : ℝ, 0 < δ → + IsCompact (potentialSuperlevel ((β+2)/3) (halfPlaneFunction f) ξ δ) := by + filter_upwards [ae_boundary_escape f β ((β+2)/3) hβ (by linarith) hfin] with ξ hξ + exact fun δ hδ => compact_superlevels_of_boundary_escape f β hβ hfin ξ hξ hδ + +theorem affine_law_ae_compact_superlevels (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hβ : 0 ≤ β) + (hlaw : ∀ (z : UpperHalfPlane) (φ : DiskFamily → ℝ≥0∞), Measurable φ → + (∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ (-β)) * ∫⁻ f, φ f ∂(μ : Measure DiskFamily)) : + ∀ᵐ f ∂(μ : Measure DiskFamily), ∀ᵐ ξ : ℂ, ∀ δ : ℝ, 0 < δ → + IsCompact (potentialSuperlevel ((β+2)/3) (halfPlaneFunction f) ξ δ) := by + filter_upwards [weightedAreaTail_ae_finite μ β hlaw] with f hf + exact ae_compact_positive_superlevels f β hβ hf + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/BoxExtension.lean b/lean/OAI/Analysis/StrictMeans/BoxExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..94b9642900eac0aa87e44468edfe88378d08d83c --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/BoxExtension.lean @@ -0,0 +1,138 @@ +import OAI.Analysis.StrictMeans.LatticeEuler + +namespace OAI + +section +open Set Function Filter +open scoped Topology +namespace StrictInverseFirstPower.Grid +noncomputable section + +def latticeBox (N M : ℕ) : Set Lattice := {v | |(ofLex v).1|≤(N:ℤ) ∧ |(ofLex v).2|≤(M:ℤ)} + +def latticeTaxicab (v : Lattice) : ℝ := |((ofLex v).1:ℝ)|+|((ofLex v).2:ℝ)| + +lemma latticeTaxicab_nonneg (v : Lattice) : 0≤latticeTaxicab v := add_nonneg (abs_nonneg _) (abs_nonneg _) + +lemma latticeBox_finite (N M : ℕ) : (latticeBox N M).Finite := by + have he : latticeBox N M=ofLex ⁻¹' ((Icc (-(N:ℤ)) N) ×ˢ (Icc (-(M:ℤ)) M)) := by + ext v + change (|(ofLex v).1|≤(N:ℤ) ∧ |(ofLex v).2|≤(M:ℤ)) ↔ + ((-(N:ℤ)≤(ofLex v).1 ∧ (ofLex v).1≤(N:ℤ)) ∧ + (-(M:ℤ)≤(ofLex v).2 ∧ (ofLex v).2≤(M:ℤ))) + simp only [abs_le] + rw [he] + exact ((Set.finite_Icc _ _).prod (Set.finite_Icc _ _)).preimage ofLex.injective.injOn + +lemma outside_box_ascent {N M : ℕ} {v : Lattice} (hv : v∉latticeBox N M) : + ∃ w, (w=v+ex ∨ w=v+ey ∨ w=v-ex ∨ w=v-ey) ∧ w∉latticeBox N M ∧ + latticeTaxicab v.bddAbove + let D := max B c+1 + let w : Lattice → ℝ := fun v=>if v∈latticeBox N M then u v else D+latticeTaxicab v + have hlow (v : Lattice) : w v≤c ↔ v∈latticeBox N M ∧ u v≤c := by + by_cases hv : v∈latticeBox N M + · simp [w,hv] + · have hb : c(hlow v).mp hv |>.1) + have hne' : {v|w v≤c}.Nonempty := by obtain ⟨v,hv⟩:=hne; exact ⟨v,(hlow v).mpr hv⟩ + have hascent (v : Lattice) : w vhascent v) + intro S hS + have hSe : hfin.toFinset=S := by + ext v + exact hfin.mem_toFinset.trans ((hlow v).trans (hS v).symm) + rw [hSe] at he + convert he using 1 + apply Finset.sum_congr rfl + intro v hv + apply heightIndex_congr_star + intro a ha' + have hai := hstar v ((hS v).mp hv).1 ((hS v).mp hv).2 a ha' + simp [w,hai] + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/BoxSlope.lean b/lean/OAI/Analysis/StrictMeans/BoxSlope.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e3295c3c3cb585fa7ec82a78dfb00fa24942aae --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/BoxSlope.lean @@ -0,0 +1,55 @@ +import OAI.Analysis.StrictMeans.BoxTransport + +namespace OAI + +section +open Set Filter MeasureTheory +open scoped ENNReal Topology +namespace StrictInverseFirstPower +noncomputable section + +lemma slope_le_of_all_positive {a b c : ℝ} + (h : ∀ S : ℝ, 0 < S → S*a ≤ S*b+c) : a ≤ b := by + by_contra hn + have hp : 0 < a-b := sub_pos.mpr (lt_of_not_ge hn) + let S := (|c|+1)/(a-b) + have hS : 0 < S := div_pos (by positivity) hp + have he : S*(a-b)=|c|+1 := div_mul_cancel₀ _ hp.ne' + have hh := h S hS + nlinarith [le_abs_self c] + +lemma ennreal_box_slope {A d : ℝ≥0∞} (hd : d≠⊤) {N : ℝ} (hN : 1 ≤ N) + (h : ∀ S Y : ℝ, 0 < S → 1 < Y → + ENNReal.ofReal (2*S*Real.log Y)*A ≤ + ENNReal.ofReal (2*(S+N*Y)*(Real.log Y+2*Real.log N))*d) : A ≤ d := by + have hN0 : 0 < N := lt_of_lt_of_le zero_lt_one hN + have hlog : 0 ≤ Real.log N := Real.log_nonneg hN + have hA : A ≠ ⊤ := by + have hh := h 1 (Real.exp 1) zero_lt_one (Real.one_lt_exp_iff.mpr zero_lt_one) + simp only [mul_one,Real.log_exp] at hh + have hfin : ENNReal.ofReal (2 * (1+N*Real.exp 1)*(1+2*Real.log N))*d < ⊤ := + ENNReal.mul_lt_top ENNReal.ofReal_lt_top (lt_top_iff_ne_top.mpr hd) + have hx := hh.trans_lt hfin + intro ha + rw [ha,ENNReal.mul_top (by norm_num)] at hx + exact (lt_irrefl ⊤) hx + apply (ENNReal.toReal_le_toReal hA hd).mp + apply slope_le_of_all_positive (c := 2*Real.log N*d.toReal) + intro t ht + have hin (S : ℝ) (hS : 0 < S) := h S (Real.exp t) hS (Real.one_lt_exp_iff.mpr ht) + have hlin : t*A.toReal ≤ (t+2*Real.log N)*d.toReal := by + apply slope_le_of_all_positive (c := N*Real.exp t*(t+2*Real.log N)*d.toReal) + intro S hS + have hh := ENNReal.toReal_mono (ENNReal.mul_ne_top ENNReal.ofReal_ne_top hd) (hin S hS) + rw [ENNReal.toReal_mul,ENNReal.toReal_mul] at hh + simp only [Real.log_exp] at hh + rw [ENNReal.toReal_ofReal (by positivity),ENNReal.toReal_ofReal (by positivity)] at hh + nlinarith + nlinarith + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/BoxTransport.lean b/lean/OAI/Analysis/StrictMeans/BoxTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..897215036d02fa98cd3bd7dbc1b5bc9f64eb9ce3 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/BoxTransport.lean @@ -0,0 +1,91 @@ +import OAI.Analysis.StrictMeans.TransportInjection + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +def upperBox (S a b : ℝ) : Set UpperHalfPlane := UpperHalfPlane.coe ⁻¹' complexBox S a b + +lemma measurableSet_upperBox (S a b : ℝ) : MeasurableSet (upperBox S a b) := + UpperHalfPlane.measurable_coe (measurableSet_complexBox S a b) + +lemma lintegral_upperBox_inv {S a b : ℝ} (hS : 0 ≤ S) (ha : 0 < a) (hab : a ≤ b) : + (∫⁻ z in upperBox S a b, ENNReal.ofReal (z.im⁻¹) ∂upperArea) = + ENNReal.ofReal (2*S*(Real.log b-Real.log a)) := by + have hm : Measurable (fun z : UpperHalfPlane => ENNReal.ofReal (z.im⁻¹)) := + UpperHalfPlane.continuous_im.measurable.inv.ennreal_ofReal + rw [← lintegral_indicator (measurableSet_upperBox S a b), + upperArea_lintegral (hm.indicator (measurableSet_upperBox S a b))] + have he : (∫⁻ z in {z : ℂ | 0 < z.im}, + (upperBox S a b).indicator (fun w => ENNReal.ofReal (w.im⁻¹)) (halfPlaneProjection z)) = + ∫⁻ z in {z : ℂ | 0 < z.im}, + (complexBox S a b).indicator (fun w => ENNReal.ofReal (w.im⁻¹)) z := by + apply setLIntegral_congr_fun isOpen_halfPlane.measurableSet + intro z hz + dsimp only + rw [halfPlaneProjection_of_pos hz] + rfl + rw [he,lintegral_indicator (measurableSet_complexBox S a b), + Measure.restrict_restrict (measurableSet_complexBox S a b),inter_eq_left.mpr] + · exact lintegral_complexBox_inv hS ha hab + · intro z hz + exact ha.trans_le hz.2.1 + +lemma partner_mem_expanded_box {k N S Y : ℝ} (hN : 1 ≤ N) (_hY : 1 ≤ Y) + (f : DiskFamily) {z : UpperHalfPlane} (hz : z∈upperBox S 1 Y) + (hD : (f,z)∈truncatedPairingDomain k N) : + sourcePartner k (f,z)∈upperBox (S+N*Y) (1/N) (N*Y) := by + change |(sourcePartner k (f,z)).re| ≤ S+N*Y ∧ + 1/N ≤ (sourcePartner k (f,z)).im ∧ (sourcePartner k (f,z)).im ≤ N*Y + have hN0 : 0 < N := lt_of_lt_of_le zero_lt_one hN + change |z.re| ≤ S ∧ 1 ≤ z.im ∧ z.im ≤ Y at hz + have hylo := (le_div_iff₀ z.im_pos).mp hD.2.1 + have hyhi := (div_le_iff₀ z.im_pos).mp hD.2.2.1 + refine ⟨?_,?_,hyhi.trans (mul_le_mul_of_nonneg_left hz.2.2 hN0.le)⟩ + · calc + |(sourcePartner k (f,z)).re| = |(sourcePartner k (f,z)).re-z.re+z.re| := by ring_nf + _ ≤ |(sourcePartner k (f,z)).re-z.re| + |z.re| := abs_add_le _ _ + _ ≤ N*z.im+S := add_le_add hD.2.2.2 hz.1 + _ ≤ S+N*Y := by nlinarith [hz.2.2] + · nlinarith [one_div_pos.mpr hN0] + +lemma box_transport_expectation (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hlaw : AffineProbabilityLaw μ β) {k N S Y : ℝ} (hk : 0 < k) + (hβ : 3*(k-1)=β-1) (hN : 1 ≤ N) (hS : 0 < S) (hY : 1 < Y) : + ENNReal.ofReal (2*S*Real.log Y) * + (∫⁻ f, ENNReal.ofReal (jacobianPart k f true UpperHalfPlane.I) * + transportTest k N (f,UpperHalfPlane.I) ∂(μ : Measure DiskFamily)) ≤ + ENNReal.ofReal (2*(S+N*Y)*(Real.log Y+2*Real.log N)) * + ∫⁻ f, ENNReal.ofReal (jacobianPart k f false UpperHalfPlane.I) ∂(μ : Measure DiskFamily) := by + have hi := lintegral_mono (μ := (μ : Measure DiskFamily)) (fun f => + transport_set_inequality hk hβ f (measurableSet_upperBox S 1 Y) + (measurableSet_upperBox (S+N*Y) (1/N) (N*Y)) + (fun _ hz hD => partner_mem_expanded_box hN hY.le f hz hD)) + have hR := expected_source_mass μ β k hlaw false (H := fun _ => 1) + measurable_const (fun _ _ => rfl) (upperBox (S+N*Y) (1/N) (N*Y)) + simp only [mul_one] at hR + rw [expected_source_mass μ β k hlaw true (measurable_transportTest hk N) + (transportTest_rebase hk N),hR,lintegral_upperBox_inv hS.le zero_lt_one hY.le] at hi + have hN0 : 0 < N := lt_of_lt_of_le zero_lt_one hN + have hY0 : 0 < Y := lt_trans zero_lt_one hY + have hlo : 1/N ≤ N*Y := by + apply (div_le_iff₀ hN0).mpr + have hNY : 1 ≤ N*Y := by nlinarith [mul_nonneg (sub_nonneg.mpr hN) (sub_nonneg.mpr hY.le)] + simpa using mul_le_mul hNY hN (by norm_num : (0:ℝ) ≤ 1) (by positivity : 0≤N*Y) + rw [lintegral_upperBox_inv (by positivity) (one_div_pos.mpr hN0) hlo, + Real.log_one,sub_zero,Real.log_mul hN0.ne' hY0.ne',Real.log_div one_ne_zero hN0.ne', + Real.log_one] at hi + convert hi using 1 + congr 2 + ring + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CanonicalIndex.lean b/lean/OAI/Analysis/StrictMeans/CanonicalIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..044cfcaab6f4a11d0c031886527599717cfa8234 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CanonicalIndex.lean @@ -0,0 +1,59 @@ +import OAI.Analysis.StrictMeans.QuadraticLine + +namespace OAI + +section +open Set Function +namespace StrictInverseFirstPower.Grid +noncomputable section + +def canonicalMin (a b : ℝ) : Lattice → ℝ := + latticeHeight (fun i => ((i:ℝ)-a)^2) (fun j => ((j:ℝ)-b)^2) +def canonicalSaddle (a b : ℝ) : Lattice → ℝ := + latticeHeight (fun i => ((i:ℝ)-a)^2) (fun j => -((j:ℝ)-b)^2) + +def minVertex (a b : ℝ) : Lattice := toLex (⌈a-1/2⌉,⌈b-1/2⌉) +def saddleVertex (a b : ℝ) : Lattice := toLex (⌈a-1/2⌉,⌊b+1/2⌋) + +lemma canonicalMin_index (a b : ℝ) (v : Lattice) : + heightIndex (canonicalMin a b) ex ey v = if v=minVertex a b then 1 else 0 := by + rw [canonicalMin,latticeHeight_index] + change lineIndex (fun i => ((i:ℝ)-a)^2) (ofLex v).1 * + lineIndex (fun j => ((j:ℝ)-b)^2) (ofLex v).2 = _ + rw [convex_line_index,convex_line_index] + have hv : v=minVertex a b ↔ (ofLex v).1=⌈a-1/2⌉ ∧ (ofLex v).2=⌈b-1/2⌉ := by + change v=toLex _ ↔ _ + rw [← ofLex_inj] + exact Prod.ext_iff + simp only [hv] + split_ifs <;> simp_all + +lemma canonicalSaddle_index (a b : ℝ) (v : Lattice) : + heightIndex (canonicalSaddle a b) ex ey v = if v=saddleVertex a b then -1 else 0 := by + rw [canonicalSaddle,latticeHeight_index] + change lineIndex (fun i => ((i:ℝ)-a)^2) (ofLex v).1 * + lineIndex (fun j => -((j:ℝ)-b)^2) (ofLex v).2 = _ + rw [convex_line_index,concave_line_index] + have hv : v=saddleVertex a b ↔ (ofLex v).1=⌈a-1/2⌉ ∧ (ofLex v).2=⌊b+1/2⌋ := by + change v=toLex _ ↔ _ + rw [← ofLex_inj] + exact Prod.ext_iff + simp only [hv] + split_ifs <;> simp_all + +lemma canonicalMin_sum (a b : ℝ) {S : Finset Lattice} (h : minVertex a b∈S) : + ∑ v ∈ S, heightIndex (canonicalMin a b) ex ey v = 1 := by + simp only [canonicalMin_index] + simp [h] + +lemma canonicalSaddle_sum (a b : ℝ) {S : Finset Lattice} (h : saddleVertex a b∈S) : + ∑ v ∈ S, heightIndex (canonicalSaddle a b) ex ey v = -1 := by + simp only [canonicalSaddle_index] + simp [h] + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CircleBounds.lean b/lean/OAI/Analysis/StrictMeans/CircleBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c05d1495f30c9b161a421ccbdec7b9124886bc53 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CircleBounds.lean @@ -0,0 +1,520 @@ +import OAI.Analysis.StrictMeans.DyadicGap + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +def horizontalQMean (y : ℝ) (hy : 0 < y) : C(DiskFamily, ℝ) := + (1/2:ℝ) • ∫ x in (-1:ℝ)..1, affineOperator (xyPoint x y hy) 1 + +lemma continuous_Q_slice (y : ℝ) (hy : 0 < y) : + Continuous (fun x : ℝ => affineOperator (xyPoint x y hy) 1) := + (continuous_affineOperator_strong 1).comp (continuous_xyPoint continuous_id continuous_const _) + +lemma horizontalQMean_apply (y : ℝ) (hy : 0 < y) (f : DiskFamily) : + horizontalQMean y hy f = (1/2:ℝ) * ∫ x in (-1:ℝ)..1, ‖halfPlaneQ f (xyPoint x y hy)‖ := by + have he := (ContinuousMap.evalCLM ℝ f).intervalIntegral_comp_comm (μ := volume) + ((continuous_Q_slice y hy).intervalIntegrable (-1) 1) + simp only [ContinuousMap.evalCLM_apply, affineOperator_apply, + ContinuousMap.one_apply, mul_one] at he + change (1/2:ℝ) * _ = _ + rw [← he] + +lemma continuous_Q_slice_apply (f : DiskFamily) (y : ℝ) (hy : 0 < y) : + Continuous (fun x : ℝ => ‖halfPlaneQ f (xyPoint x y hy)‖) := by + have hh := (ContinuousMap.evalCLM ℝ f).continuous.comp (continuous_Q_slice y hy) + change Continuous (fun x => (ContinuousMap.evalCLM ℝ f) (affineOperator (xyPoint x y hy) 1)) at hh + simpa only [ContinuousMap.evalCLM_apply, affineOperator_apply, ContinuousMap.one_apply, mul_one] using hh + +lemma dyadic_left_xy (x y : ℝ) (hy : 0 < y) : + affineProduct dyadicLeft (xyPoint x y hy) = + xyPoint ((1/2:ℝ)*x-1/2) (y/2) (half_pos hy) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, dyadicLeft, xyPoint] + ring + +lemma dyadic_right_xy (x y : ℝ) (hy : 0 < y) : + affineProduct dyadicRight (xyPoint x y hy) = + xyPoint ((1/2:ℝ)*x+1/2) (y/2) (half_pos hy) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, dyadicRight, xyPoint] + ring + +lemma horizontalQMean_half (y : ℝ) (hy : 0 < y) : + horizontalQMean (y/2) (half_pos hy) = dyadicOperator (horizontalQMean y hy) := by + let A : ℝ → C(DiskFamily, ℝ) := fun x => affineOperator (xyPoint x (y/2) (half_pos hy)) 1 + have hA : Continuous A := continuous_Q_slice (y/2) (half_pos hy) + have hleft : (∫ x in (-1:ℝ)..1, + affineOperator dyadicLeft (affineOperator (xyPoint x y hy) 1)) = + (2:ℝ) • ∫ x in (-1:ℝ)..0, A x := by + simp_rw [← mul_apply_eq_comp, affineOperator_mul, dyadic_left_xy] + have hh := intervalIntegral.integral_comp_mul_add (a := (-1:ℝ)) (b := 1) A + (by norm_num : (1/2:ℝ) ≠ 0) (-1/2) + norm_num only at hh + simpa only [sub_eq_add_neg] using hh + have hright : (∫ x in (-1:ℝ)..1, + affineOperator dyadicRight (affineOperator (xyPoint x y hy) 1)) = + (2:ℝ) • ∫ x in (0:ℝ)..1, A x := by + simp_rw [← mul_apply_eq_comp, affineOperator_mul, dyadic_right_xy] + have hh := intervalIntegral.integral_comp_mul_add (a := (-1:ℝ)) (b := 1) A + (by norm_num : (1/2:ℝ) ≠ 0) (1/2) + norm_num only at hh + simpa only [sub_eq_add_neg] using hh + unfold horizontalQMean dyadicOperator + rw [smul_apply, add_apply, + map_smul, map_smul, + ← (affineOperator dyadicLeft).intervalIntegral_comp_comm ((continuous_Q_slice y hy).intervalIntegrable _ _), + ← (affineOperator dyadicRight).intervalIntegral_comp_comm ((continuous_Q_slice y hy).intervalIntegrable _ _), + hleft, hright, smul_smul, smul_smul] + norm_num + rw [← intervalIntegral.integral_add_adjacent_intervals (hA.intervalIntegrable (-1) 0) + (hA.intervalIntegrable 0 1)] + exact smul_add _ _ _ + +lemma horizontalQMean_dyadic (n : ℕ) : + horizontalQMean (dyadicHeight n) (dyadicHeight_pos n) = + (dyadicOperator^n) (horizontalQMean 1 zero_lt_one) := by + induction n with + | zero => simp [dyadicHeight] + | succ n ih => + simp only [dyadicHeight_succ] + rw [horizontalQMean_half (dyadicHeight n) (dyadicHeight_pos n), ih, pow_succ', mul_apply_eq_comp] + +lemma horizontalQMean_bound (n : ℕ) (f : DiskFamily) : + (∫ x in (-1:ℝ)..1, ‖halfPlaneQ f (xyPoint x (dyadicHeight n) (dyadicHeight_pos n))‖) ≤ + (2 * ‖horizontalQMean 1 zero_lt_one‖) * ‖dyadicOperator^n‖ := by + have hh := (horizontalQMean (dyadicHeight n) (dyadicHeight_pos n)).norm_coe_le_norm f + have hb := (dyadicOperator^n).le_opNorm (horizontalQMean 1 zero_lt_one) + rw [← horizontalQMean_dyadic] at hb + rw [horizontalQMean_apply, Real.norm_eq_abs] at hh + have hle := (le_abs_self _).trans (hh.trans hb) + nlinarith + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +def arcDenom (r t : ℝ) : ℝ := 1 + 2*r*Real.cos t + r^2 +def arcX (r t : ℝ) : ℝ := 2*r*Real.sin t / arcDenom r t +def arcY (r t : ℝ) : ℝ := (1-r^2) / arcDenom r t +def arcXDeriv (r t : ℝ) : ℝ := + (2*r*(1+r^2)*Real.cos t+4*r^2)/(arcDenom r t)^2 + +lemma arcDenom_pos {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) (t : ℝ) : + 0 < arcDenom r t := by + have hh := mul_nonneg hr0 (show 0 ≤ 1+Real.cos t by linarith [Real.neg_one_le_cos t]) + have hs := sq_pos_of_pos (show 0 < 1-r by linarith) + dsimp [arcDenom] + nlinarith + +lemma arcDenom_le_four {r : ℝ} (hr0 : 0 ≤ r) (hr : r ≤ 1) (t : ℝ) : + arcDenom r t ≤ 4 := by + have hh := mul_le_mul_of_nonneg_left (Real.cos_le_one t) hr0 + dsimp [arcDenom] + nlinarith + +lemma arcDenom_ge_one {r : ℝ} (hr0 : 0 ≤ r) {t : ℝ} + (ht : t ∈ Icc (-(Real.pi/2)) (Real.pi/2)) : 1 ≤ arcDenom r t := by + have hc : 0 ≤ Real.cos t := Real.cos_nonneg_of_mem_Icc ⟨by linarith [ht.1], ht.2⟩ + have hh := mul_nonneg hr0 hc + dsimp [arcDenom] + nlinarith + +lemma arcX_continuous {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) : Continuous (arcX r) := by + exact ((continuous_const.mul continuous_const).mul Real.continuous_sin).div + ((continuous_const.add ((continuous_const.mul continuous_const).mul Real.continuous_cos)).add + continuous_const) (fun t => (arcDenom_pos hr0 hr t).ne') + +lemma arcY_continuous {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) : Continuous (arcY r) := by + exact continuous_const.div + ((continuous_const.add ((continuous_const.mul continuous_const).mul Real.continuous_cos)).add + continuous_const) (fun t => (arcDenom_pos hr0 hr t).ne') + +lemma arcX_hasDerivAt {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) (t : ℝ) : + HasDerivAt (arcX r) (arcXDeriv r t) t := by + have hn := (Real.hasDerivAt_sin t).const_mul (2*r) + have hd := (((Real.hasDerivAt_cos t).const_mul (2*r)).const_add 1).add_const (r^2) + have hh : HasDerivAt (arcX r) + ((2*r*Real.cos t * arcDenom r t - 2*r*Real.sin t*(2*r*(-Real.sin t))) / (arcDenom r t)^2) t := + hn.div hd (arcDenom_pos hr0 hr t).ne' + convert hh using 1 + dsimp [arcXDeriv,arcDenom] + congr 1 + linear_combination -(4*r^2)*(Real.sin_sq_add_cos_sq t) + +lemma arcXDeriv_continuous {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) : Continuous (arcXDeriv r) := by + exact ((continuous_const.mul Real.continuous_cos).add continuous_const).div + (((continuous_const.add ((continuous_const.mul continuous_const).mul Real.continuous_cos)).add + continuous_const).pow 2) (fun t => pow_ne_zero _ (arcDenom_pos hr0 hr t).ne') + +lemma arcXDeriv_lower {r : ℝ} (hr0 : 1/2 ≤ r) (hr : r < 1) {t : ℝ} + (ht : t ∈ Icc (-(Real.pi/2)) (Real.pi/2)) : (1/16:ℝ) ≤ arcXDeriv r t := by + have hrp : 0 ≤ r := by linarith + have hc : 0 ≤ Real.cos t := Real.cos_nonneg_of_mem_Icc ⟨by linarith [ht.1], ht.2⟩ + have hd := arcDenom_pos hrp hr t + have hu := arcDenom_le_four hrp hr.le t + have hn : 0 ≤ 2*r*(1+r^2)*Real.cos t := by positivity + rw [arcXDeriv, le_div_iff₀ (sq_pos_of_pos hd)] + nlinarith + +lemma arcX_bounds {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) {t : ℝ} + (ht : t ∈ Icc (-(Real.pi/2)) (Real.pi/2)) : -1 ≤ arcX r t ∧ arcX r t ≤ 1 := by + have hd := arcDenom_pos hr0 hr t + have hc : 0 ≤ Real.cos t := Real.cos_nonneg_of_mem_Icc ⟨by linarith [ht.1], ht.2⟩ + have hc' := mul_nonneg hr0 hc + have ha := mul_le_mul_of_nonneg_left (Real.sin_le_one t) hr0 + have hb := mul_le_mul_of_nonneg_left (Real.neg_one_le_sin t) hr0 + constructor + · rw [arcX, le_div_iff₀ hd] + dsimp [arcDenom] + nlinarith [sq_nonneg (1-r)] + · rw [arcX, div_le_iff₀ hd] + dsimp [arcDenom] + nlinarith [sq_nonneg (1-r)] + +lemma arcY_pos {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) (t : ℝ) : 0 < arcY r t := by + apply div_pos _ (arcDenom_pos hr0 hr t) + nlinarith + +lemma arcY_scale_bounds {r v : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) + (hv : v ≤ 1-r) (hrv : 1-r ≤ 2*v) {t : ℝ} + (ht : t ∈ Icc (-(Real.pi/2)) (Real.pi/2)) : v/4 ≤ arcY r t ∧ arcY r t ≤ 4*v := by + have hvp : 0 < v := by linarith + have hd := arcDenom_pos hr0 hr t + have hu := arcDenom_le_four hr0 hr.le t + have hl := arcDenom_ge_one hr0 ht + have hprod := mul_le_mul_of_nonneg_left hu hvp.le + have hprod' := mul_le_mul_of_nonneg_left hl hvp.le + constructor + · rw [arcY, le_div_iff₀ hd] + nlinarith + · rw [arcY, div_le_iff₀ hd] + nlinarith [sq_nonneg (1-r)] + +lemma cayley_leftArc (r t : ℝ) : + cayleyToHalfPlane (-(r:ℂ)*Complex.exp ((t:ℂ)*I)) = + (arcX r t:ℂ) + (arcY r t:ℂ)*I := by + apply Complex.ext + all_goals simp only [cayleyToHalfPlane, Complex.div_re, Complex.div_im, + Complex.exp_mul_I, Complex.neg_re, Complex.neg_im, Complex.ofReal_re, + Complex.ofReal_im, Complex.mul_re, Complex.mul_im, Complex.add_re, Complex.add_im, + Complex.sub_re, Complex.sub_im, Complex.one_re, Complex.one_im, + Complex.I_re, Complex.I_im, Complex.cos_ofReal_re, Complex.sin_ofReal_re, + Complex.cos_ofReal_im, Complex.sin_ofReal_im, Complex.normSq_apply, + mul_zero, zero_mul, add_zero, zero_add, mul_one, neg_zero, sub_zero] + all_goals dsimp [arcX, arcY, arcDenom] + all_goals have hs := congrArg (fun a : ℝ => r^2*a) (Real.sin_sq_add_cos_sq t) + all_goals have hd : (1 - -r * Real.cos t) * (1 - -r * Real.cos t) + + (0 - -r * Real.sin t) * (0 - -r * Real.sin t) = 1 + 2*r*Real.cos t + r^2 := by nlinarith [hs] + all_goals rw [hd] + · rw [← add_div] + congr 1 + ring + · rw [← sub_div] + congr 1 + nlinarith [hs] + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +lemma uniform_vertical_Q_bound : + ∃ K : ℝ, 0 < K ∧ ∀ (f : DiskFamily) (s : ℝ) (hs : 0 < s), + 1/4 ≤ s → s ≤ 4 → ‖halfPlaneQ f (xyPoint 0 s hs)‖ ≤ K := by + let X := DiskFamily × Icc (1/4:ℝ) 4 + let W : C(X, ℝ) := ⟨fun p => ‖halfPlaneQ p.1 (xyPoint 0 p.2 (by have hh := p.2.property.1; linarith))‖, + (continuous_halfPlaneQ.comp (continuous_fst.prodMk + ((continuous_const.add + ((Complex.continuous_ofReal.comp (continuous_subtype_val.comp continuous_snd)).mul_const I)).upperHalfPlaneMk _))).norm⟩ + refine ⟨‖W‖+1, by positivity, ?_⟩ + intro f s hs hlo hhi + have hh := W.norm_coe_le_norm (f,⟨s,hlo,hhi⟩) + change ‖‖halfPlaneQ f (xyPoint 0 s hs)‖‖ ≤ ‖W‖ at hh + rw [norm_norm] at hh + linarith + +lemma vertical_Q_comparison {K : ℝ} + (hK : ∀ (f : DiskFamily) (s : ℝ) (hs : 0 < s), + 1/4 ≤ s → s ≤ 4 → ‖halfPlaneQ f (xyPoint 0 s hs)‖ ≤ K) + (f : DiskFamily) (x y v : ℝ) (hy : 0 < y) (hv : 0 < v) + (hlo : v/4 ≤ y) (hhi : y ≤ 4*v) : + ‖halfPlaneQ f (xyPoint x y hy)‖ ≤ K * ‖halfPlaneQ f (xyPoint x v hv)‖ := by + have hp : 0 < y/v := div_pos hy hv + have hlow : 1/4 ≤ y/v := (le_div_iff₀ hv).mpr (by linarith) + have hupp : y/v ≤ 4 := (div_le_iff₀ hv).mpr hhi + have he : affineProduct (xyPoint x v hv) (xyPoint 0 (y/v) hp) = xyPoint x y hy := by + simp only [affineProduct_xyPoint,mul_zero,add_zero,mul_div_cancel₀ _ hv.ne'] + have hh := hK (rebase f (xyPoint x v hv)) (y/v) hp hlow hupp + rw [halfPlaneQ_rebase,he,norm_div] at hh + exact (div_le_iff₀ (norm_pos_iff.mpr (halfPlaneQ_ne_zero f _))).mp hh + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +lemma arc_integral_change_bound (f : DiskFamily) {r v : ℝ} + (hr0 : 1/2 ≤ r) (hr : r < 1) (hv : 0 < v) : + (∫ t in -(Real.pi/2)..(Real.pi/2), + ‖halfPlaneQ f (xyPoint (arcX r t) v hv)‖) ≤ + 16 * ∫ x in (-1:ℝ)..1, ‖halfPlaneQ f (xyPoint x v hv)‖ := by + let g : ℝ → ℝ := fun x => ‖halfPlaneQ f (xyPoint x v hv)‖ + have hg : Continuous g := continuous_Q_slice_apply f v hv + have hrp : 0 ≤ r := by linarith + have hab : -(Real.pi/2) ≤ Real.pi/2 := by linarith [Real.pi_pos] + have hxc := arcX_continuous hrp hr + have hdc := arcXDeriv_continuous hrp hr + have hsub := intervalIntegral.integral_comp_mul_deriv + (a := -(Real.pi/2)) (b := Real.pi/2) + (fun t _ => arcX_hasDerivAt hrp hr t) hdc.continuousOn hg + have hmono : (∫ t in -(Real.pi/2)..(Real.pi/2), g (arcX r t)) ≤ + ∫ t in -(Real.pi/2)..(Real.pi/2), 16 * (g (arcX r t) * arcXDeriv r t) := by + apply intervalIntegral.integral_mono_on hab + ((hg.comp hxc).intervalIntegrable _ _) + ((continuous_const.mul ((hg.comp hxc).mul hdc)).intervalIntegrable _ _) + intro t ht + have hd := arcXDeriv_lower hr0 hr ht + have hp : 0 ≤ g (arcX r t) := norm_nonneg _ + change g (arcX r t) ≤ 16 * (g (arcX r t) * arcXDeriv r t) + nlinarith + simp only [Function.comp_apply] at hsub + rw [intervalIntegral.integral_const_mul, hsub] at hmono + have hxle : arcX r (-(Real.pi/2)) ≤ arcX r (Real.pi/2) := by + have hh := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc (-(Real.pi/2)) (Real.pi/2)) + hxc.continuousOn (fun t _ => (arcX_hasDerivAt hrp hr t).hasDerivWithinAt) + (fun t ht => (by + exact le_trans (by norm_num : (0:ℝ) ≤ 1/16) (arcXDeriv_lower hr0 hr (interior_subset ht)))) + exact hh ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab + have he0 := arcX_bounds hrp hr (show -(Real.pi/2) ∈ Icc (-(Real.pi/2)) (Real.pi/2) from ⟨le_rfl,hab⟩) + have he1 := arcX_bounds hrp hr (show Real.pi/2 ∈ Icc (-(Real.pi/2)) (Real.pi/2) from ⟨hab,le_rfl⟩) + exact hmono.trans (mul_le_mul_of_nonneg_left + (intervalIntegral.integral_mono_interval he0.1 hxle he1.2 + (ae_of_all _ (fun x => norm_nonneg _)) (hg.intervalIntegrable (-1) 1)) (by norm_num)) + +lemma inverse_disk_deriv_cayley_bound (f : DiskFamily) (z : UpperHalfPlane) : + ‖deriv (diskExtension f.val) (cayleyToDisk z)‖⁻¹ ≤ 4 * ‖halfPlaneQ f z‖ := by + have hd := halfPlaneFunction_deriv f z.im_pos + have hn : ‖deriv (halfPlaneFunction f) z‖ = + 4 * ‖deriv (diskExtension f.val) (cayleyToDisk z)‖ / ‖(z:ℂ)+I‖^2 := by + rw [hd] + simp only [norm_mul,norm_div,norm_pow,Complex.norm_I,norm_ofNat,mul_one] + ring + have hsq : 1 ≤ ‖(z:ℂ)+I‖^2 := by + have hi := Complex.abs_im_le_norm ((z:ℂ)+I) + have hz : 0 < (z:ℂ).im := z.im_pos + simp only [Complex.add_im,Complex.I_im] at hi + have hl := (le_abs_self _).trans hi + nlinarith [norm_nonneg ((z:ℂ)+I)] + have hp : 0 < ‖deriv (diskExtension f.val) (cayleyToDisk z)‖ := + norm_pos_iff.mpr (diskFamily_derivative_ne_zero f ⟨_,cayleyToDisk_mem z.im_pos⟩) + simp only [halfPlaneQ,norm_inv,hn] + rw [inv_div] + field_simp + exact hsq + +lemma half_arc_inverse_bound {K : ℝ} (hK0 : 0 < K) + (hK : ∀ (f : DiskFamily) (s : ℝ) (hs : 0 < s), + 1/4 ≤ s → s ≤ 4 → ‖halfPlaneQ f (xyPoint 0 s hs)‖ ≤ K) + (f : DiskFamily) {r v : ℝ} (hr0 : 1/2 ≤ r) (hr : r < 1) + (hv : v ≤ 1-r) (hrv : 1-r ≤ 2*v) : + (∫ t in -(Real.pi/2)..(Real.pi/2), + ‖deriv (diskExtension f.val) (-(r:ℂ)*Complex.exp ((t:ℂ)*I))‖⁻¹) ≤ + 64*K * ∫ x in (-1:ℝ)..1, + ‖halfPlaneQ f (xyPoint x v (by linarith))‖ := by + have hrp : 0 ≤ r := by linarith + have hvp : 0 < v := by linarith + let γ : ℝ → UpperHalfPlane := fun t => xyPoint (arcX r t) (arcY r t) (arcY_pos hrp hr t) + have hcγ : Continuous γ := + ((Complex.continuous_ofReal.comp (arcX_continuous hrp hr)).add + ((Complex.continuous_ofReal.comp (arcY_continuous hrp hr)).mul_const I)).upperHalfPlaneMk _ + have he (t : ℝ) : cayleyToDisk (γ t) = -(r:ℂ)*Complex.exp ((t:ℂ)*I) := by + rw [show (γ t : ℂ) = cayleyToHalfPlane (-(r:ℂ)*Complex.exp ((t:ℂ)*I)) from + (cayley_leftArc r t).symm] + apply cayleyToDisk_toHalfPlane + simp only [mem_ball,dist_zero_right,norm_mul,norm_neg,Complex.norm_real, + Real.norm_eq_abs,abs_of_nonneg hrp,Complex.norm_exp_ofReal_mul_I,mul_one] + exact hr + have hcont : Continuous (fun t : ℝ => ‖deriv (diskExtension f.val) + (-(r:ℂ)*Complex.exp ((t:ℂ)*I))‖⁻¹) := by + simp_rw [← he] + exact ((continuous_diskFamily_derivative.comp + (continuous_const.prodMk (cayleyDiskMap.continuous.comp hcγ))).norm).inv₀ + (fun t => norm_ne_zero_iff.mpr (diskFamily_derivative_ne_zero f _)) + have hab : -(Real.pi/2) ≤ Real.pi/2 := by linarith [Real.pi_pos] + have haux : Continuous (fun t => ‖halfPlaneQ f (xyPoint (arcX r t) v hvp)‖) := + (continuous_Q_slice_apply f v hvp).comp (arcX_continuous hrp hr) + have hb : (∫ t in -(Real.pi/2)..(Real.pi/2), + ‖deriv (diskExtension f.val) (-(r:ℂ)*Complex.exp ((t:ℂ)*I))‖⁻¹) ≤ + ∫ t in -(Real.pi/2)..(Real.pi/2), + (4*K) * ‖halfPlaneQ f (xyPoint (arcX r t) v hvp)‖ := by + apply intervalIntegral.integral_mono_on hab (hcont.intervalIntegrable _ _) + ((continuous_const.mul haux).intervalIntegrable _ _) + intro t ht + rw [← he] + refine (inverse_disk_deriv_cayley_bound f (γ t)).trans ?_ + change 4 * ‖halfPlaneQ f (γ t)‖ ≤ (4*K)*‖halfPlaneQ f (xyPoint (arcX r t) v hvp)‖ + have hs := arcY_scale_bounds hrp hr hv hrv ht + have hcmp := vertical_Q_comparison hK f (arcX r t) (arcY r t) v + (arcY_pos hrp hr t) hvp hs.1 hs.2 + exact le_trans (mul_le_mul_of_nonneg_left hcmp (by norm_num)) (le_of_eq (by ring)) + rw [intervalIntegral.integral_const_mul] at hb + exact hb.trans (by + have hh := mul_le_mul_of_nonneg_left (arc_integral_change_bound f hr0 hr hvp) + (show 0 ≤ 4*K by positivity) + convert hh using 1 + ring) + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +def diskNegateMap (f : C(UnitDisk,ℂ)) : C(UnitDisk,ℂ) := + ⟨fun z => -f ⟨-z,by simpa only [mem_ball,dist_zero_right,norm_neg] using z.property⟩, + (f.continuous.comp ((continuous_subtype_val.neg).subtype_mk _)).neg⟩ + +lemma diskNegateMap_extension (f : C(UnitDisk,ℂ)) (z : ℂ) : + diskExtension (diskNegateMap f) z = -diskExtension f (-z) := by + classical + by_cases hz : z ∈ ball (0:ℂ) 1 + · have hm : -z ∈ ball (0:ℂ) 1 := by simpa using hz + simp only [diskExtension,dite_eq_left hz,dite_eq_left hm] + rfl + · have hm : -z ∉ ball (0:ℂ) 1 := by simpa using hz + simp only [diskExtension,dite_eq_right hz,dite_eq_right hm,neg_zero] + +lemma diskNegateMap_hasDerivAt (f : DiskFamily) {z : ℂ} (hz : z ∈ ball (0:ℂ) 1) : + HasDerivAt (diskExtension (diskNegateMap f.val)) (deriv (diskExtension f.val) (-z)) z := by + have hm : -z ∈ ball (0:ℂ) 1 := by simpa using hz + have hh := ((f.property.1.differentiableAt (isOpen_ball.mem_nhds hm)).hasDerivAt.comp z + (hasDerivAt_id z).neg).neg + simp only [mul_neg,mul_one,neg_neg] at hh + rw [show diskExtension (diskNegateMap f.val) = (fun w => -diskExtension f.val (-w)) from + funext (diskNegateMap_extension f.val)] + exact hh + +def diskNegateFamily (f : DiskFamily) : DiskFamily := ⟨diskNegateMap f.val, by + refine ⟨fun z hz => (diskNegateMap_hasDerivAt f hz).differentiableAt.differentiableWithinAt, + ?_, ?_, ?_⟩ + · intro z hz w hw he + simp only [diskNegateMap_extension,neg_inj] at he + exact neg_injective (f.property.2.1 (by simpa using hz) (by simpa using hw) he) + · simp [diskNegateMap_extension,f.property.2.2.1] + · simpa only [neg_zero,f.property.2.2.2] using + (diskNegateMap_hasDerivAt f (mem_ball_self zero_lt_one)).deriv⟩ + +def circleInverseDensity (f : DiskFamily) (r t : ℝ) : ℝ := + ‖deriv (diskExtension f.val) ((r:ℂ)*Complex.exp ((t:ℂ)*I))‖⁻¹ + +def leftArcInverseDensity (f : DiskFamily) (r t : ℝ) : ℝ := + ‖deriv (diskExtension f.val) (-(r:ℂ)*Complex.exp ((t:ℂ)*I))‖⁻¹ + +lemma circlePoint_mem_disk {r : ℝ} (hr0 : 0 ≤ r) (hr : r < 1) (t : ℝ) : + (r:ℂ)*Complex.exp ((t:ℂ)*I) ∈ ball (0:ℂ) 1 := by + simpa only [mem_ball,dist_zero_right,norm_mul,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg hr0,Complex.norm_exp_ofReal_mul_I,mul_one] using hr + +lemma circleInverseDensity_continuous (f : DiskFamily) {r : ℝ} + (hr0 : 0 ≤ r) (hr : r < 1) : Continuous (circleInverseDensity f r) := by + have hp : Continuous (fun t : ℝ => (⟨(r:ℂ)*Complex.exp ((t:ℂ)*I), + circlePoint_mem_disk hr0 hr t⟩ : UnitDisk)) := + (continuous_const.mul (Complex.continuous_exp.comp (Complex.continuous_ofReal.mul_const I))).subtype_mk _ + exact (continuous_diskFamily_derivative.comp (continuous_const.prodMk hp)).norm.inv₀ + (fun t => norm_ne_zero_iff.mpr (diskFamily_derivative_ne_zero f _)) + +lemma circleInverseDensity_periodic (f : DiskFamily) (r : ℝ) : + Function.Periodic (circleInverseDensity f r) (2*Real.pi) := by + intro t + unfold circleInverseDensity + congr 3 + push_cast + rw [add_mul,Complex.exp_add] + have hh : Complex.exp (((2:ℂ)*Real.pi)*I) = 1 := by + convert Complex.exp_two_pi_mul_I using 1 + rw [hh,mul_one] + +lemma circleInverseDensity_shift_pi (f : DiskFamily) (r t : ℝ) : + circleInverseDensity f r (t+Real.pi) = leftArcInverseDensity f r t := by + unfold circleInverseDensity leftArcInverseDensity + congr 3 + push_cast + rw [add_mul,Complex.exp_add,Complex.exp_pi_mul_I] + ring + +lemma leftArcInverseDensity_negate (f : DiskFamily) {r : ℝ} + (hr0 : 0 ≤ r) (hr : r < 1) (t : ℝ) : + leftArcInverseDensity (diskNegateFamily f) r t = circleInverseDensity f r t := by + unfold leftArcInverseDensity circleInverseDensity + change ‖deriv (diskExtension (diskNegateMap f.val)) _‖⁻¹ = _ + have hm : -(r:ℂ)*Complex.exp ((t:ℂ)*I) ∈ ball (0:ℂ) 1 := by + simpa only [neg_mul,mem_ball,dist_zero_right,norm_neg] using circlePoint_mem_disk hr0 hr t + rw [(diskNegateMap_hasDerivAt f hm).deriv] + simp only [neg_mul,neg_neg] + +lemma wholeCircle_eq_two_left_arcs (f : DiskFamily) {r : ℝ} + (hr0 : 0 ≤ r) (hr : r < 1) : + (∫ t in -Real.pi..Real.pi, circleInverseDensity f r t) = + (∫ t in -(Real.pi/2)..Real.pi/2, leftArcInverseDensity f r t) + + ∫ t in -(Real.pi/2)..Real.pi/2, leftArcInverseDensity (diskNegateFamily f) r t := by + have hc := circleInverseDensity_continuous f hr0 hr + simp_rw [leftArcInverseDensity_negate f hr0 hr] + have hp := (circleInverseDensity_periodic f r).intervalIntegral_add_eq + (-Real.pi) (-(Real.pi/2)) + have hshift := intervalIntegral.integral_comp_add_right + (circleInverseDensity f r) Real.pi (a := -(Real.pi/2)) (b := Real.pi/2) + simp only [circleInverseDensity_shift_pi] at hshift + have he1 : -Real.pi+2*Real.pi = Real.pi := by ring + have he2 : -(Real.pi/2)+Real.pi = Real.pi/2 := by ring + have he3 : Real.pi/2+Real.pi = -(Real.pi/2)+2*Real.pi := by ring + rw [he1] at hp + rw [he2,he3] at hshift + rw [hp,← intervalIntegral.integral_add_adjacent_intervals (hc.intervalIntegrable _ _) (hc.intervalIntegrable _ _),← hshift] + exact add_comm _ _ + +lemma whole_circle_dyadic_operator_bound : + ∃ C : ℝ, 0 < C ∧ ∀ (f : DiskFamily) (r : ℝ) (n : ℕ), + 1/2 ≤ r → r < 1 → dyadicHeight n ≤ 1-r → 1-r ≤ 2*dyadicHeight n → + (∫ t in -Real.pi..Real.pi, circleInverseDensity f r t) ≤ C * ‖dyadicOperator^n‖ := by + obtain ⟨K,hK0,hK⟩ := uniform_vertical_Q_bound + let A := 2*‖horizontalQMean 1 zero_lt_one‖+1 + have hA : 0 < A := by dsimp [A]; positivity + refine ⟨128*K*A,by positivity,?_⟩ + intro f r n hr0 hr hv hrv + have h0 := half_arc_inverse_bound hK0 hK f hr0 hr hv hrv + have h1 := half_arc_inverse_bound hK0 hK (diskNegateFamily f) hr0 hr hv hrv + have hb0 := horizontalQMean_bound n f + have hb1 := horizontalQMean_bound n (diskNegateFamily f) + have hb0' := h0.trans (mul_le_mul_of_nonneg_left hb0 (show 0 ≤ 64*K by positivity)) + have hb1' := h1.trans (mul_le_mul_of_nonneg_left hb1 (show 0 ≤ 64*K by positivity)) + rw [wholeCircle_eq_two_left_arcs f (by linarith) hr] + change (∫ t in -(Real.pi/2)..Real.pi/2, leftArcInverseDensity f r t) ≤ _ at hb0' + change (∫ t in -(Real.pi/2)..Real.pi/2, leftArcInverseDensity (diskNegateFamily f) r t) ≤ _ at hb1' + have hs := add_le_add hb0' hb1' + refine hs.trans ?_ + dsimp [A] + nlinarith [mul_nonneg hK0.le (norm_nonneg (dyadicOperator^n))] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CompactFamily.lean b/lean/OAI/Analysis/StrictMeans/CompactFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4a3b561df7751b7745efef9ff3da9eb249223a2 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CompactFamily.lean @@ -0,0 +1,309 @@ +import OAI.Analysis.StrictMeans.DerivativeDistortion + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +theorem locallyUniformLimit_zero_eventually {ι : Type*} {l : Filter ι} [l.NeBot] + {U : Set ℂ} {F : ι → ℂ → ℂ} {f : ℂ → ℂ} {z : ℂ} + (hU : IsOpen U) (hz : z ∈ U) + (hlim : TendstoLocallyUniformlyOn F f l U) + (hF : ∀ᶠ n in l, DifferentiableOn ℂ (F n) U) + (hzero : ∀ᶠ n in l, ∀ w ∈ U, F n w ≠ 0) + (hfz : f z = 0) : ∀ᶠ w in 𝓝 z, f w = 0 := by + have hfd := hlim.differentiableOn hF hU + have hfa := hfd.analyticAt (hU.mem_nhds hz) + by_contra hn + have hnz := hfa.eventually_eq_zero_or_eventually_ne_zero.resolve_left hn + have hne : ∀ᶠ w in 𝓝 z, w ∈ U ∧ (w ≠ z → f w ≠ 0) := + Filter.Eventually.and (hU.mem_nhds hz) (eventually_nhdsWithin_iff.mp hnz) + obtain ⟨R, hR, hRi⟩ := Metric.eventually_nhds_iff.mp hne + let r : ℝ := R / 2 + have hr : 0 < r := half_pos hR + have hrR : r < R := half_lt_self hR + have hc : closedBall z r ⊆ U := fun w hw => (hRi (closedBall_subset_ball hrR hw)).1 + have hsne : ∀ w ∈ sphere z r, f w ≠ 0 := by + intro w hw + exact (hRi (closedBall_subset_ball hrR (sphere_subset_closedBall hw))).2 + (ne_of_mem_sphere hw hr.ne') + have hcont : ContinuousOn (fun w => ‖f w‖) (sphere z r) := + (hfd.continuousOn.mono (sphere_subset_closedBall.trans hc)).norm + obtain ⟨a, ha, hamin⟩ := (isCompact_sphere z r).exists_isMinOn + (NormedSpace.sphere_nonempty.mpr hr.le) hcont + let δ := ‖f a‖ + have hδ : 0 < δ := norm_pos_iff.mpr (hsne a ha) + have hb : ∀ w ∈ sphere z r, δ ≤ ‖f w‖ := fun w hw => hamin hw + have hu : TendstoUniformlyOn F f l (sphere z r) := + (tendstoLocallyUniformlyOn_iff_forall_isCompact hU).mp hlim _ + (sphere_subset_closedBall.trans hc) (isCompact_sphere z r) + have he1 : ∀ᶠ n in l, ∀ w ∈ sphere z r, dist (f w) (F n w) < δ / 2 := + tendstoUniformlyOn_iff.mp hu (δ / 2) (half_pos hδ) + have hc0 : Tendsto (fun n => ‖F n z‖) l (𝓝 0) := by + simpa only [hfz, norm_zero] using (hlim.tendsto_at hz).norm + have he2 : ∀ᶠ n in l, ‖F n z‖ < δ / 2 := + hc0.eventually (eventually_lt_nhds (half_pos hδ)) + obtain ⟨n, hfn, hnzero, hnsph, hnz⟩ := (hF.and (hzero.and (he1.and he2))).exists + have hginv : DifferentiableOn ℂ (fun w => (F n w)⁻¹) U := hfn.inv hnzero + have hmax : ‖(F n z)⁻¹‖ ≤ 2 / δ := by + apply Complex.norm_le_of_forall_mem_frontier_norm_le isBounded_ball + (hginv.diffContOnCl_ball hc) + · intro w hw + rw [frontier_ball _ hr.ne'] at hw + have htri := norm_le_norm_add_norm_sub (F n w) (f w) + rw [norm_sub_rev (F n w) (f w)] at htri + have hclose : ‖f w - F n w‖ < δ / 2 := by simpa only [dist_eq_norm] using hnsph w hw + have hl : δ / 2 ≤ ‖F n w‖ := by linarith [hb w hw] + rw [norm_inv] + calc + ‖F n w‖⁻¹ ≤ (δ / 2)⁻¹ := inv_anti₀ (half_pos hδ) hl + _ = 2 / δ := by field_simp + · exact subset_closure (mem_ball_self hr) + rw [norm_inv, inv_eq_one_div, div_le_div_iff₀ (norm_pos_iff.mpr (hnzero z hz)) hδ] at hmax + linarith + +theorem locallyUniformLimit_injOn_or_constant {ι : Type*} {l : Filter ι} [l.NeBot] + {U : Set ℂ} {F : ι → ℂ → ℂ} {f : ℂ → ℂ} + (hU : IsOpen U) (hconn : IsPreconnected U) + (hlim : TendstoLocallyUniformlyOn F f l U) + (hF : ∀ᶠ n in l, DifferentiableOn ℂ (F n) U) + (hinj : ∀ᶠ n in l, InjOn (F n) U) : + InjOn f U ∨ ∃ c : ℂ, EqOn f (fun _ => c) U := by + classical + by_cases hi : InjOn f U + · exact Or.inl hi + right + rw [Set.InjOn] at hi + push Not at hi + obtain ⟨a, ha, b, hb, hab, hne⟩ := hi + have hconst : TendstoUniformlyOn (fun n (_ : ℂ) => F n a) (fun _ => f a) l U := by + rw [tendstoUniformlyOn_iff] + intro ε hε + filter_upwards [Metric.tendsto_nhds.mp (hlim.tendsto_at ha) ε hε] with n hn w _ + simpa only [dist_comm] using hn + have hsub : TendstoLocallyUniformlyOn (fun n w => F n w - F n a) + (fun w => f w - f a) l U := + (uniformContinuous_fst.sub uniformContinuous_snd).comp_tendstoLocallyUniformlyOn + (hlim.prodMk hconst.tendstoLocallyUniformlyOn) + have hopen : IsOpen (U \ {a}) := hU.sdiff isClosed_singleton + have hb' : b ∈ U \ {a} := ⟨hb, by simpa only [mem_singleton_iff] using hne.symm⟩ + have hd : ∀ᶠ n in l, DifferentiableOn ℂ (fun w => F n w - F n a) (U \ {a}) := by + filter_upwards [hF] with n hn + exact (hn.sub_const _).mono sdiff_subset + have hnonzero : ∀ᶠ n in l, ∀ w ∈ U \ {a}, F n w - F n a ≠ 0 := by + filter_upwards [hinj] with n hn w hw + exact sub_ne_zero.mpr (fun he => hw.2 (hn hw.1 ha he)) + have he := locallyUniformLimit_zero_eventually hopen hb' (hsub.mono sdiff_subset) + hd hnonzero (sub_eq_zero.mpr hab.symm) + have hfd := hlim.differentiableOn hF hU + have han : AnalyticOnNhd ℂ (fun w => f w - f a) U := + (hfd.analyticOnNhd hU).sub analyticOnNhd_const + have hz := han.eqOn_zero_of_preconnected_of_eventuallyEq_zero hconn hb he + exact ⟨f a, fun w hw => sub_eq_zero.mp (hz hw)⟩ + +theorem locallyUniformLimit_injOn {ι : Type*} {l : Filter ι} [l.NeBot] + {U : Set ℂ} {F : ι → ℂ → ℂ} {f : ℂ → ℂ} {z : ℂ} + (hU : IsOpen U) (hconn : IsPreconnected U) (hz : z ∈ U) + (hlim : TendstoLocallyUniformlyOn F f l U) + (hF : ∀ᶠ n in l, DifferentiableOn ℂ (F n) U) + (hinj : ∀ᶠ n in l, InjOn (F n) U) (hderiv : deriv f z ≠ 0) : InjOn f U := by + obtain hi | ⟨c, hc⟩ := locallyUniformLimit_injOn_or_constant hU hconn hlim hF hinj + · exact hi + exfalso + have he : f =ᶠ[𝓝 z] fun _ => c := Filter.eventually_of_mem (hU.mem_nhds hz) hc + exact hderiv (he.deriv_eq.trans (deriv_const _ _)) + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +abbrev UnitDisk := ball (0 : ℂ) 1 + +instance : LocallyCompactSpace UnitDisk := isOpen_ball.locallyCompactSpace + +def diskExtension (f : C(UnitDisk, ℂ)) (z : ℂ) : ℂ := by + classical + exact if h : z ∈ ball (0 : ℂ) 1 then f ⟨z, h⟩ else 0 + +@[simp] lemma diskExtension_coe (f : C(UnitDisk, ℂ)) (z : UnitDisk) : + diskExtension f z = f z := by simp [diskExtension] + +def DiskNormalized (f : C(UnitDisk, ℂ)) : Prop := + DifferentiableOn ℂ (diskExtension f) (ball 0 1) ∧ + InjOn (diskExtension f) (ball 0 1) ∧ + diskExtension f 0 = 0 ∧ deriv (diskExtension f) 0 = 1 + +abbrev DiskFamily := {f : C(UnitDisk, ℂ) // DiskNormalized f} + +lemma diskExtension_tendsto {ι : Type*} {l : Filter ι} + {F : ι → C(UnitDisk, ℂ)} {f : C(UnitDisk, ℂ)} (h : Tendsto F l (𝓝 f)) : + TendstoLocallyUniformlyOn (fun n => diskExtension (F n)) (diskExtension f) l + (ball 0 1) := by + rw [tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe] + simpa only [Function.comp_def, diskExtension_coe] using + ContinuousMap.tendsto_iff_tendstoLocallyUniformly.mp h + +lemma disk_derivative_bound {f : ℂ → ℂ} (hd : DifferentiableOn ℂ f (ball 0 1)) + (hi : InjOn f (ball 0 1)) (h1 : deriv f 0 = 1) {r : ℝ} (hr : r < 1) + {z : ℂ} (hz : ‖z‖ ≤ r) : ‖deriv f z‖ ≤ (1 + r) / (1 - r) ^ 3 := by + have hzr := hz.trans_lt hr + have hr0 : 0 ≤ r := (norm_nonneg z).trans hz + have hb := (derivative_distortion hd hi h1 hzr).2 + have hp : 0 < 1 - r := sub_pos.mpr hr + have hden : 0 < (1 - r) ^ 3 := pow_pos hp _ + refine hb.trans (div_le_div₀ (by positivity) (by linarith) hden ?_) + exact pow_le_pow_left₀ hp.le (by linarith) 3 + +lemma disk_lipschitz_bound {f : ℂ → ℂ} (hd : DifferentiableOn ℂ f (ball 0 1)) + (hi : InjOn f (ball 0 1)) (h1 : deriv f 0 = 1) {r : ℝ} (hr : r < 1) + {z w : ℂ} (hz : ‖z‖ ≤ r) (hw : ‖w‖ ≤ r) : + ‖f w - f z‖ ≤ ((1 + r) / (1 - r) ^ 3) * ‖w - z‖ := by + apply (convex_closedBall (0 : ℂ) r).norm_image_sub_le_of_norm_deriv_le + (fun a ha => hd.differentiableAt (isOpen_ball.mem_nhds (by + simpa only [mem_ball, dist_zero_right] using + (show ‖a‖ ≤ r from by simpa only [mem_closedBall, dist_zero_right] using ha).trans_lt hr))) + (fun a ha => disk_derivative_bound hd hi h1 hr (by + simpa only [mem_closedBall, dist_zero_right] using ha)) + · simpa using hz + · simpa using hw + +lemma disk_family_pointwise_bounded (z : UnitDisk) : + ∃ R : ℝ, ∀ f : DiskFamily, ‖f.val z‖ ≤ R := by + refine ⟨((1 + ‖(z : ℂ)‖) / (1 - ‖(z : ℂ)‖) ^ 3) * ‖(z : ℂ)‖, ?_⟩ + intro f + have h := disk_lipschitz_bound f.property.1 f.property.2.1 f.property.2.2.2 + (show ‖(z : ℂ)‖ < 1 by simpa only [mem_ball, dist_zero_right] using z.property) + (z := 0) (w := z) (by simp) (le_refl _) + simpa only [f.property.2.2.1, diskExtension_coe, sub_zero] using h + +lemma disk_family_equicontinuous : Equicontinuous (fun f : DiskFamily => (f.val : UnitDisk → ℂ)) := by + intro z + rw [Metric.equicontinuousAt_iff] + intro ε hε + let r := (1 + ‖(z : ℂ)‖) / 2 + have hz : ‖(z : ℂ)‖ < 1 := by simpa only [mem_ball, dist_zero_right] using z.property + have hzr : ‖(z : ℂ)‖ < r := by dsimp [r]; linarith + have hr : r < 1 := by dsimp [r]; linarith + have hr0 : 0 < r := (norm_nonneg _).trans_lt hzr + let C := (1 + r) / (1 - r) ^ 3 + have hC : 0 < C := div_pos (by linarith) (pow_pos (sub_pos.mpr hr) _) + refine ⟨min (r - ‖(z : ℂ)‖) (ε / C), lt_min (sub_pos.mpr hzr) (div_pos hε hC), ?_⟩ + intro w hw f + have hw' : ‖(w : ℂ) - z‖ < min (r - ‖(z : ℂ)‖) (ε / C) := by simpa only [Subtype.dist_eq, dist_eq_norm] using hw + have hwr : ‖(w : ℂ)‖ ≤ r := by + have ht := norm_le_norm_add_norm_sub (z : ℂ) (w : ℂ) + rw [norm_sub_rev (z : ℂ) (w : ℂ)] at ht + linarith [hw'.trans_le (min_le_left _ _)] + have h := disk_lipschitz_bound f.property.1 f.property.2.1 f.property.2.2.2 hr hzr.le hwr + rw [diskExtension_coe, diskExtension_coe] at h + rw [dist_eq_norm, norm_sub_rev] + refine h.trans_lt ?_ + change C * ‖(w : ℂ) - z‖ < ε + simpa only [mul_comm] using (lt_div_iff₀ hC).mp (hw'.trans_le (min_le_right _ _)) + +lemma isClosed_diskNormalized : IsClosed {f : C(UnitDisk, ℂ) | DiskNormalized f} := by + rw [isClosed_iff_forall_filter] + intro f l hl hs ht + let : l.NeBot := hl + have hlim := diskExtension_tendsto (show Tendsto id l (𝓝 f) from ht) + have hn : ∀ᶠ g in l, DiskNormalized g := le_principal_iff.mp hs + have hd : ∀ᶠ g in l, DifferentiableOn ℂ (diskExtension g) (ball 0 1) := + hn.mono (fun _ hg => hg.1) + have hz : (0 : ℂ) ∈ ball 0 1 := mem_ball_self zero_lt_one + have h0 : diskExtension f 0 = 0 := by + apply tendsto_nhds_unique (hlim.tendsto_at hz) + exact tendsto_const_nhds.congr' (hn.mono fun _ hg => hg.2.2.1.symm) + have h1 : deriv (diskExtension f) 0 = 1 := by + apply tendsto_nhds_unique ((hlim.deriv hd isOpen_ball).tendsto_at hz) + exact tendsto_const_nhds.congr' (hn.mono fun _ hg => hg.2.2.2.symm) + refine ⟨hlim.differentiableOn hd isOpen_ball, ?_, h0, h1⟩ + apply locallyUniformLimit_injOn isOpen_ball (convex_ball (0 : ℂ) 1).isPreconnected + hz hlim hd (hn.mono fun _ hg => hg.2.1) + simp only [h1, ne_eq, one_ne_zero, not_false_eq_true] + +lemma isCompact_diskNormalized : IsCompact {f : C(UnitDisk, ℂ) | DiskNormalized f} := by + let : T2Space (UniformOnFun UnitDisk ℂ {K | IsCompact K}) := + UniformOnFun.t2Space_of_covering (Set.eq_univ_iff_forall.mpr fun z => + mem_sUnion_of_mem (mem_singleton z) isCompact_singleton) + have he : Topology.IsClosedEmbedding (ContinuousMap.toUniformOnFunIsCompact : + C(UnitDisk, ℂ) → UniformOnFun UnitDisk ℂ {K | IsCompact K}) := + ContinuousMap.isUniformEmbedding_toUniformOnFunIsCompact.isClosedEmbedding + have hc := ArzelaAscoli.isCompact_closure_of_isClosedEmbedding + (F := fun f : C(UnitDisk, ℂ) => (f : UnitDisk → ℂ)) + (𝔖 := {K | IsCompact K}) (fun _ hK => hK) he + (s := {f | DiskNormalized f}) + (fun K _ => disk_family_equicontinuous.equicontinuousOn K) + (by + intro K _ z _ + obtain ⟨R, hR⟩ := disk_family_pointwise_bounded z + refine ⟨closedBall 0 R, isCompact_closedBall _ _, ?_⟩ + intro f hf + simpa only [mem_closedBall, dist_zero_right] using hR ⟨f, hf⟩) + rwa [isClosed_diskNormalized.closure_eq] at hc + +instance : CompactSpace DiskFamily := isCompact_iff_compactSpace.mp isCompact_diskNormalized + +instance : TopologicalSpace.MetrizableSpace DiskFamily := + TopologicalSpace.MetrizableSpace.subtype {f : C(UnitDisk, ℂ) | DiskNormalized f} + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +abbrev DiskHolomorphic := {f : C(UnitDisk, ℂ) // + DifferentiableOn ℂ (diskExtension f) (ball 0 1)} + +def diskDerivative (f : DiskHolomorphic) : C(UnitDisk, ℂ) := + ⟨fun z => deriv (diskExtension f.val) z, + (f.property.deriv isOpen_ball).continuousOn.comp_continuous + continuous_subtype_val (fun z => z.property)⟩ + +lemma continuous_diskDerivative : Continuous diskDerivative := by + rw [continuous_iff_continuousAt] + intro f + rw [ContinuousAt, ContinuousMap.tendsto_iff_tendstoLocallyUniformly] + have h := diskExtension_tendsto (continuous_subtype_val.tendsto f) + have hd := h.deriv (Eventually.of_forall fun g : DiskHolomorphic => g.property) isOpen_ball + rw [tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe] at hd + exact hd + +lemma continuous_diskDerivative_eval : + Continuous (fun p : DiskHolomorphic × UnitDisk => deriv (diskExtension p.1.val) p.2) := by + exact continuous_diskDerivative.comp continuous_fst |>.eval continuous_snd + +lemma continuous_diskFamily_derivative : + Continuous (fun p : DiskFamily × UnitDisk => deriv (diskExtension p.1.val) p.2) := by + exact continuous_diskDerivative_eval.comp + ((continuous_subtype_val.subtype_mk (fun f => f.property.1)).comp continuous_fst |>.prodMk continuous_snd) + +lemma diskFamily_derivative_ne_zero (f : DiskFamily) (z : UnitDisk) : + deriv (diskExtension f.val) z ≠ 0 := by + exact deriv_ne_zero_of_injOn isOpen_ball z.property f.property.2.1 f.property.1 + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CompactIndexSum.lean b/lean/OAI/Analysis/StrictMeans/CompactIndexSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..d058bca6d612da3081cc093a884c8a291593288e --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CompactIndexSum.lean @@ -0,0 +1,74 @@ +import OAI.Analysis.StrictMeans.RegularLevels + +namespace OAI + +section +open Set Function Filter +open scoped Topology +namespace StrictInverseFirstPower.Grid +noncomputable section + +lemma compact_sum_local_indices {u : ℂ → ℝ} {K : Set ℂ} (hK : IsCompact K) + (C : Finset ℂ) (r : ℂ → ℝ) (sign : ℂ → ℤ) + (hballs : ∀ p∈C, Metric.closedBall p (r p) ⊆ K) + (hdisj : (C:Set ℂ).PairwiseDisjoint (fun p=>Metric.closedBall p (r p))) + (hregular : ∀ z∈K, (∀ p∈C, r p≤dist z p) → + ContDiffAt ℝ 1 u z ∧ fderiv ℝ u z≠0) + (hlocal : ∀ p∈C, ∀ᶠ s in 𝓝 (0:ℝ), 0Metric.isOpen_ball)) + have hreg : ∀ z∈A, ∃ L : ℂ →L[ℝ] ℝ, + HasStrictFDerivAt u L z ∧ (L 1≠0 ∨ L Complex.I≠0) := by + intro z hz + have hh := hregular z hz.1 (by + intro p hp + exact le_of_not_gt (fun hb=>hz.2 (mem_iUnion.mpr ⟨p,mem_iUnion.mpr ⟨hp,hb⟩⟩))) + refine ⟨fderiv ℝ u z,hh.1.hasStrictFDerivAt one_ne_zero,?_⟩ + by_contra h + push Not at h + exact hh.2 (realCLM_eq_zero h.1 h.2) + have hg := compact_regular_star hA (by simp : ‖(1:ℂ)‖≤1) (by simp : ‖Complex.I‖≤1) hreg + have hl := (C.eventually_all).mpr hlocal + filter_upwards [hg,hl] with s hs hs' + intro hspos o S hS + let L : ℂ → Finset Lattice := fun p=>(meshPoint_bounded_preimage (o:=o) hspos.ne' + (Metric.isBounded_closedBall (x:=p) (r:=r p))).toFinset + have hL (p : ℂ) (v : Lattice) : v∈L p ↔ dist (meshPoint o s v) p≤r p := by + simp only [L,Set.Finite.mem_toFinset,mem_preimage,Metric.mem_closedBall] + let T := C.biUnion L + have hTS : T⊆S := by + intro v hv + obtain ⟨p,hp,hv⟩ := Finset.mem_biUnion.mp hv + exact (hS v).mpr (hballs p hp ((hL p v).mp hv)) + have hzero : ∀ v∈S, v∉T → heightIndex (u ∘ meshPoint o s) ex ey v=0 := by + intro v hv hvt + have hva : meshPoint o s v∈A := by + refine ⟨(hS v).mp hv,?_⟩ + intro hm + obtain ⟨p,hp,hm⟩ := mem_iUnion₂.mp hm + apply hvt + exact Finset.mem_biUnion.mpr ⟨p,hp,(hL p v).mpr hm.le⟩ + exact RegularStar.index_zero ((hs _ hva hspos).toRegularStar) + have hpair : (C:Set ℂ).PairwiseDisjoint L := by + intro p hp q hq hpq + apply Finset.disjoint_left.mpr + intro v hvp hvq + exact Set.disjoint_left.mp (hdisj hp hq hpq) ((hL p v).mp hvp) ((hL q v).mp hvq) + calc + ∑ v∈S, heightIndex (u ∘ meshPoint o s) ex ey v = ∑ v∈T, heightIndex (u ∘ meshPoint o s) ex ey v := + (Finset.sum_subset hTS (fun v hv hvt=>hzero v hv hvt)).symm + _ = ∑ p∈C, ∑ v∈L p, heightIndex (u ∘ meshPoint o s) ex ey v := Finset.sum_biUnion hpair + _ = ∑ p∈C, sign p := Finset.sum_congr rfl (fun p hp=>hs' p hp hspos o (L p) (hL p)) + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CompactMorseEuler.lean b/lean/OAI/Analysis/StrictMeans/CompactMorseEuler.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa304e9e95b6c0cb8e576a4dcb6935ad88318c72 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CompactMorseEuler.lean @@ -0,0 +1,38 @@ +import OAI.Analysis.StrictMeans.SmoothSublevelEuler + +namespace OAI + +section +open Set Function Filter +open scoped Topology +namespace StrictInverseFirstPower.Grid +noncomputable section + +lemma compact_halfPlane_morse_sum {u : ℂ → ℝ} {c : ℝ} + (hK : IsCompact {z : ℂ | 0hu z hz.1) (fun z hz=>htr z (interior_subset (hC z hz)).1) hdet + obtain ⟨s,hs,hl,he⟩ := (hlower.and heq).exists_gt + let S := (meshPoint_bounded_preimage (o:=o) hs.ne' hK.isBounded).toFinset + have hS : ∀ v, v∈S ↔ 0<(meshPoint o s v).im ∧ u (meshPoint o s v)≤c := by + intro v + exact Set.Finite.mem_toFinset _ + rw [← he hs o S hS] + exact hl hs S hS + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CompactMorseIndex.lean b/lean/OAI/Analysis/StrictMeans/CompactMorseIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b279871083a6976f039533a7bc7414460c8f0da --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CompactMorseIndex.lean @@ -0,0 +1,75 @@ +import OAI.Analysis.StrictMeans.CompactIndexSum + +namespace OAI + +section +open Set Function Filter +open scoped Topology +namespace StrictInverseFirstPower.Grid +noncomputable section + +lemma compact_morse_index_sum {u : ℂ → ℝ} {K : Set ℂ} (hK : IsCompact K) + (C : Finset ℂ) (hc : ∀ z∈K, fderiv ℝ u z=0 ↔ z∈C) + (hC : ∀ p∈C, p∈interior K) + (hu : ∀ p∈K, ContDiffAt ℝ 2 u p) + (htr : ∀ p∈C, 00, p∈C → + (Metric.closedBall p r⊆K) ∧ + (∀ q∈C, q≠p → 3*rFalse.elim (h hqp)) + · exact (gt_mem_nhds (by simpa using (div_pos (dist_pos.mpr (Ne.symm hqp)) (by norm_num : (0:ℝ)<3)))).mono + (fun _ hh _=>hh) + obtain ⟨r,hr,hrr,hrr',hrs⟩ := ((gt_mem_nhds hR).and ((gt_mem_nhds hρ).and hsep)).exists_gt + refine ⟨r,hr,fun _=>⟨?_,?_,hlocal r ⟨hr,hrr⟩⟩⟩ + · intro z hz + exact hnb (lt_of_le_of_lt hz hrr') + · intro q hq hqp + have := hrs q hq hqp + linarith + · exact ⟨1,by norm_num,fun h=>False.elim (hp h)⟩ + choose r hrpos hr using hchoose + apply compact_sum_local_indices hK C r (morseSign u) (fun p hp=>(hr p hp).1) ?_ ?_ + (fun p hp=>(hr p hp).2.2) + · intro p hp q hq hpq + apply Set.disjoint_left.mpr + intro z hpz hqz + have ha := (hr p hp).2.1 q hq hpq.symm + have hb := (hr q hq).2.1 p hp hpq + rw [dist_comm q p] at hb + have ht := dist_triangle p z q + rw [dist_comm p z] at ht + change dist z p≤r p at hpz + change dist z q≤r q at hqz + linarith [dist_nonneg (x:=p) (y:=q)] + · intro z hz hdist + refine ⟨(hu z hz).of_le (by norm_num),?_⟩ + intro hzero + have hzC := (hc z hz).mp hzero + have hd := hdist z hzC + rw [dist_self] at hd + exact (not_le_of_gt (hrpos z)) hd + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CriticalCounts.lean b/lean/OAI/Analysis/StrictMeans/CriticalCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..4949523d1b6b4654891443c4e8083a615f1a2ff8 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CriticalCounts.lean @@ -0,0 +1,182 @@ +import OAI.Analysis.StrictMeans.CompactMorseEuler + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +lemma source_morse_sign {k : ℝ} (hk : 0criticalMap_ne_image hk.ne' hz hd (hg.trans he.symm) + have hpos : 0<4*(squaredReciprocalPotential k (halfPlaneFunction f) ξ z)^2*(k^4/z.im^4) := by + rw [squaredReciprocalPotential_eq_exp hz hp] + positivity + unfold Grid.morseSign + rw [squaredReciprocalPotential_hessian_det hk.ne' hz hF hd hg] + congr 1 + apply propext + constructor + · intro h + exact ((mul_pos_iff.mp h).resolve_left (fun h' => + (not_lt_of_gt (neg_neg_of_pos hpos)) h'.1)).2 + · intro h + exact mul_pos_of_neg_of_neg (neg_neg_of_pos hpos) h + +lemma criticalCut_morse_sum {k : ℝ} (hk : 0jacobianExpression k (halfPlaneFunction f) z<0)= + (maximaCut_finite hk hg hh).toFinset := by + ext z + simp [T,maximaCut] + have hs : T.filter (fun z : UpperHalfPlane=>¬jacobianExpression k (halfPlaneFunction f) z<0)= + (saddleCut_finite hk hg hh).toFinset := by + ext z + simp only [T,Finset.mem_filter,Set.Finite.mem_toFinset,saddleCut,Set.mem_ofPred_eq] + apply and_congr_right + intro hz + rw [not_lt] + exact ⟨fun hh => lt_of_le_of_ne hh (Ne.symm (hg.2.1 z hz.1)),le_of_lt⟩ + rw [hsum,Finset.sum_ite,hm,hs] + rw [Set.ncard_eq_toFinset_card _ (maximaCut_finite hk hg hh),Set.ncard_eq_toFinset_card _ (saddleCut_finite hk hg hh)] + simp [sub_eq_add_neg] + +lemma goodPair_superlevel_count {k : ℝ} (hk : 0criticalMap_ne_image hk.ne' w.im_pos hd (hw'.1.trans he.symm) + have hhU : 0UpperHalfPlane.coe_injective he)] + exact criticalCut_morse_sum hk hg hh + have hsumP : (∑ z∈P,Grid.morseSign u z)=(P.card:ℤ) := by + have hs : (∑ z∈P, Grid.morseSign u z)=∑ _z∈P,(1:ℤ) := by + apply Finset.sum_congr rfl + intro z hz + have hp := (hP z).mp hz + have hd := squaredReciprocalPotential_hessian_det_pole (k:=k) hp.1 + ((halfPlaneFunction_differentiableOn f).analyticAt (isOpen_halfPlane.mem_nhds hp.1)) + (halfPlaneFunction_deriv_ne_zero f hp.1) hp.2 + exact ite_eq_left hd + rw [hs] + simp + have hPcard : P.card≤1 := Finset.card_le_one.mpr (by + intro z hz w hw + exact source_poles_subsingleton f ξ ((hP z).mp hz) ((hP w).mp hw)) + have hPcardZ : (P.card:ℤ)≤1 := by exact_mod_cast hPcard + change 1≤∑ z∈B∪P,Grid.morseSign u z at hlower + rw [Finset.sum_union hdisj,hsumB,hsumP] at hlower + have hhZ : ((saddleCut k f ξ h).ncard:ℤ)≤(maximaCut k f ξ h).ncard := by omega + exact_mod_cast hhZ + · rw [Set.not_nonempty_iff_eq_empty.mp hne,Set.ncard_empty] + exact Nat.zero_le _ + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CriticalCovariance.lean b/lean/OAI/Analysis/StrictMeans/CriticalCovariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..642d6e9228816ca59399c8367ecf1e9477889f56 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CriticalCovariance.lean @@ -0,0 +1,165 @@ +import OAI.Analysis.StrictMeans.RankPairing + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +def affineUpperHomeomorph (z : UpperHalfPlane) : UpperHalfPlane ≃ₜ UpperHalfPlane where + toFun := affineProduct z + invFun w := ⟨((w:ℂ) - (z.re:ℂ)) / (z.im:ℂ), by + simpa [Complex.div_ofReal_im] using div_pos w.im_pos z.im_pos⟩ + left_inv w := by + apply UpperHalfPlane.ext + change ((affineAt z w) - (z.re:ℂ)) / (z.im:ℂ) = w + simp [affineAt, z.im_ne_zero] + right_inv w := by + apply UpperHalfPlane.ext + change (z.re:ℂ) + (z.im:ℂ) * (((w:ℂ) - (z.re:ℂ)) / (z.im:ℂ)) = w + field_simp [z.im_ne_zero] + ring + continuous_toFun := + (continuous_const.add (continuous_const.mul UpperHalfPlane.continuous_coe)).upperHalfPlaneMk _ + continuous_invFun := + ((UpperHalfPlane.continuous_coe.sub continuous_const).div_const _).upperHalfPlaneMk _ + +@[simp] lemma affineUpperHomeomorph_apply (z w : UpperHalfPlane) : + affineUpperHomeomorph z w = affineProduct z w := rfl + +def targetRebase (f : DiskFamily) (z : UpperHalfPlane) (ξ : ℂ) : ℂ := + (ξ - halfPlaneFunction f z) / ((z.im:ℂ) * deriv (halfPlaneFunction f) z) + +lemma targetRebase_injective (f : DiskFamily) (z : UpperHalfPlane) : + Function.Injective (targetRebase f z) := by + intro ξ η he + have hd : (z.im:ℂ) * deriv (halfPlaneFunction f) z ≠ 0 := + mul_ne_zero (Complex.ofReal_ne_zero.mpr z.im_ne_zero) + (halfPlaneFunction_deriv_ne_zero f z.im_pos) + simpa using ((div_left_inj' hd).mp he) + +lemma criticalMap_rebase (k : ℝ) (f : DiskFamily) (z w : UpperHalfPlane) : + criticalMap k (halfPlaneFunction (rebase f z)) w = + targetRebase f z (criticalMap k (halfPlaneFunction f) (affineProduct z w)) := by + unfold criticalMap targetRebase + rw [halfPlaneFunction_rebase f z w.im_pos, halfPlaneFunction_rebase_deriv] + simp only [coe_affineProduct,affineAt_im,Complex.ofReal_mul] + by_cases hk : k = 0 + · simp [hk] + · field_simp [Complex.ofReal_ne_zero.mpr z.im_ne_zero, + halfPlaneFunction_deriv_ne_zero f z.im_pos,Complex.ofReal_ne_zero.mpr hk] + ring + +lemma criticalMap_rebase_eq_iff (k : ℝ) (f : DiskFamily) (z w : UpperHalfPlane) (ξ : ℂ) : + criticalMap k (halfPlaneFunction (rebase f z)) w = targetRebase f z ξ ↔ + criticalMap k (halfPlaneFunction f) (affineProduct z w) = ξ := by + rw [criticalMap_rebase, (targetRebase_injective f z).eq_iff] + +@[simp] lemma affineProduct_im (z w : UpperHalfPlane) : + (affineProduct z w).im = z.im * w.im := affineAt_im z w + +def heightRebaseScale (k : ℝ) (f : DiskFamily) (z : UpperHalfPlane) : ℝ := + ‖deriv (halfPlaneFunction f) z‖ / z.im^(k-1) + +lemma heightRebaseScale_pos (k : ℝ) (f : DiskFamily) (z : UpperHalfPlane) : + 0 < heightRebaseScale k f z := + div_pos (norm_pos_iff.mpr (halfPlaneFunction_deriv_ne_zero f z.im_pos)) + (Real.rpow_pos_of_pos z.im_pos _) + +lemma criticalHeight_rebase (k : ℝ) (f : DiskFamily) (z w : UpperHalfPlane) : + criticalHeight k (halfPlaneFunction (rebase f z)) w = + heightRebaseScale k f z * criticalHeight k (halfPlaneFunction f) (affineProduct z w) := by + unfold criticalHeight heightRebaseScale + rw [halfPlaneFunction_rebase_deriv] + simp only [coe_affineProduct,affineAt_im,UpperHalfPlane.coe_im,norm_inv,norm_div] + rw [Real.mul_rpow z.im_pos.le w.im_pos.le] + field_simp [(norm_pos_iff.mpr (halfPlaneFunction_deriv_ne_zero f z.im_pos)).ne', + (norm_pos_iff.mpr (halfPlaneFunction_deriv_ne_zero f (affineAt_mapsTo z w.im_pos))).ne', + (Real.rpow_pos_of_pos z.im_pos (k-1)).ne'] + +lemma reciprocalPotential_rebase (k : ℝ) (f : DiskFamily) (z w : UpperHalfPlane) (ξ : ℂ) : + reciprocalPotential k (rebase f z,targetRebase f z ξ) w = + reciprocalPotential k (f,ξ) (affineProduct z w) / heightRebaseScale k f z := by + unfold reciprocalPotential targetRebase heightRebaseScale + rw [halfPlaneFunction_rebase f z w.im_pos,← sub_div] + simp only [sub_sub_sub_cancel_right,norm_div,norm_mul,Complex.norm_real, + Real.norm_eq_abs,abs_of_pos z.im_pos,affineProduct_im,coe_affineProduct] + rw [Real.mul_rpow z.im_pos.le w.im_pos.le, + Real.rpow_sub z.im_pos,Real.rpow_one] + field_simp [z.im_ne_zero,(Real.rpow_pos_of_pos z.im_pos k).ne', + (Real.rpow_pos_of_pos w.im_pos k).ne', + (norm_pos_iff.mpr (halfPlaneFunction_deriv_ne_zero f z.im_pos)).ne'] + +lemma goodPair_rebase {k : ℝ} {f : DiskFamily} {ξ : ℂ} (hg : GoodPair k (f,ξ)) + (z : UpperHalfPlane) : GoodPair k (rebase f z,targetRebase f z ξ) := by + refine ⟨?_,?_,?_⟩ + · apply (compactPotential_iff _ _).mpr + intro r hr + have hc := (compactPotential_iff _ _).mp hg.1 + (r * heightRebaseScale k f z) (mul_pos hr (heightRebaseScale_pos k f z)) + convert (affineUpperHomeomorph z).isCompact_preimage.mpr hc using 1 + ext w + simp only [mem_ofPred_eq,mem_preimage,affineUpperHomeomorph_apply] + rw [reciprocalPotential_rebase,div_le_iff₀ (heightRebaseScale_pos k f z)] + · intro w hw + rw [jacobianExpression_rebase] + exact hg.2.1 (affineProduct z w) ((criticalMap_rebase_eq_iff k f z w ξ).mp hw) + · intro v w hv hw he + apply (affineUpperHomeomorph z).injective + apply hg.2.2 (affineProduct z v) (affineProduct z w) + ((criticalMap_rebase_eq_iff k f z v ξ).mp hv) + ((criticalMap_rebase_eq_iff k f z w ξ).mp hw) + rw [criticalHeight_rebase,criticalHeight_rebase] at he + exact mul_left_cancel₀ (heightRebaseScale_pos k f z).ne' he + +lemma goodPair_rebase_iff (k : ℝ) (f : DiskFamily) (ξ : ℂ) (z : UpperHalfPlane) : + GoodPair k (rebase f z,targetRebase f z ξ) ↔ GoodPair k (f,ξ) := by + refine ⟨fun hg => ?_,fun hg => goodPair_rebase hg z⟩ + refine ⟨?_,?_,?_⟩ + · apply (compactPotential_iff _ _).mpr + intro r hr + have hc := (compactPotential_iff _ _).mp hg.1 + (r / heightRebaseScale k f z) (div_pos hr (heightRebaseScale_pos k f z)) + convert hc.image (affineUpperHomeomorph z).continuous using 1 + ext w + constructor + · intro hw + let v := (affineUpperHomeomorph z).symm w + have hv : affineProduct z v = w := (affineUpperHomeomorph z).apply_symm_apply w + refine ⟨v,?_,hv⟩ + change reciprocalPotential k (rebase f z,targetRebase f z ξ) v ≤ _ + rw [reciprocalPotential_rebase,hv] + exact (div_le_div_iff_of_pos_right (heightRebaseScale_pos k f z)).mpr hw + · rintro ⟨v,hv,rfl⟩ + change reciprocalPotential k (rebase f z,targetRebase f z ξ) v ≤ _ at hv + rw [reciprocalPotential_rebase] at hv + exact (div_le_div_iff_of_pos_right (heightRebaseScale_pos k f z)).mp hv + · intro w hw + let v := (affineUpperHomeomorph z).symm w + have hv : affineProduct z v = w := (affineUpperHomeomorph z).apply_symm_apply w + have hc : criticalMap k (halfPlaneFunction (rebase f z)) v = targetRebase f z ξ := + (criticalMap_rebase_eq_iff k f z v ξ).mpr (hv.symm ▸ hw) + simpa only [jacobianExpression_rebase,← coe_affineProduct,hv] using hg.2.1 v hc + · intro u v hu hv he + let a := (affineUpperHomeomorph z).symm u + let b := (affineUpperHomeomorph z).symm v + have ha : affineProduct z a = u := (affineUpperHomeomorph z).apply_symm_apply u + have hb : affineProduct z b = v := (affineUpperHomeomorph z).apply_symm_apply v + have hca : criticalMap k (halfPlaneFunction (rebase f z)) a = targetRebase f z ξ := + (criticalMap_rebase_eq_iff k f z a ξ).mpr (ha.symm ▸ hu) + have hcb : criticalMap k (halfPlaneFunction (rebase f z)) b = targetRebase f z ξ := + (criticalMap_rebase_eq_iff k f z b ξ).mpr (hb.symm ▸ hv) + have hab := hg.2.2 a b hca hcb (by + rw [criticalHeight_rebase,criticalHeight_rebase,ha,hb,he]) + calc u = affineProduct z a := ha.symm + _ = affineProduct z b := congrArg (affineProduct z) hab + _ = v := hb + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CriticalPotential.lean b/lean/OAI/Analysis/StrictMeans/CriticalPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..83172f28dc4ff532c376510117a162a7583fb744 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CriticalPotential.lean @@ -0,0 +1,298 @@ +import OAI.Analysis.StrictMeans.BoundaryEscape + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +namespace StrictInverseFirstPower +noncomputable section + +def logPotential (k : ℝ) (F : ℂ → ℂ) (ξ z : ℂ) : ℝ := + k * Real.log z.im - Real.log ‖F z - ξ‖ + +lemma complex_log_norm_fderiv {F : ℂ → ℂ} {z : ℂ} + (hF : DifferentiableAt ℂ F z) (hne : F z ≠ 0) : + fderiv ℝ (fun w => Real.log ‖F w‖) z = + Complex.reCLM.comp ((ContinuousLinearMap.toSpanSingleton ℂ (deriv F z / F z)).restrictScalars ℝ) := by + have hd := hF.hasDerivAt.complexToReal_fderiv + have hn : ‖F z‖^2 ≠ 0 := pow_ne_zero _ (norm_ne_zero_iff.mpr hne) + have hh := ((hd.norm_sq).log hn).const_mul (1/2) + have he : (fun w => (1/2:ℝ) * Real.log (‖F w‖^2)) = (fun w => Real.log ‖F w‖) := by + funext w + rw [Real.log_pow] + ring + rw [he] at hh + rw [hh.fderiv] + ext v + simp only [smul_apply, ContinuousLinearMap.comp_apply, smul_eq_mul, + ContinuousLinearMap.coe_restrictScalars', ContinuousLinearMap.toSpanSingleton_apply, + Complex.reCLM_apply, innerSL_apply_apply, one_apply_eq_self] + simp only [Complex.inner, Complex.mul_re, Complex.mul_im, Complex.div_re, + Complex.div_im, Complex.conj_re, Complex.conj_im] + rw [← Complex.normSq_eq_norm_sq] + field_simp + ring + +lemma logPotential_differentiableAt {k : ℝ} {F : ℂ → ℂ} {ξ z : ℂ} + (hz : 0 < z.im) (hF : DifferentiableAt ℂ F z) (hne : F z ≠ ξ) : + DifferentiableAt ℝ (logPotential k F ξ) z := by + exact ((Complex.imCLM.differentiableAt).log hz.ne').const_mul k |>.sub + (((hF.restrictScalars (𝕜 := ℝ)).sub_const ξ).norm ℝ (sub_ne_zero.mpr hne) |>.log (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hne))) + +lemma logPotential_fderiv_apply {k : ℝ} {F : ℂ → ℂ} {ξ z : ℂ} + (hz : 0 < z.im) (hF : DifferentiableAt ℂ F z) (hne : F z ≠ ξ) (v : ℂ) : + fderiv ℝ (logPotential k F ξ) z v = + k / z.im * v.im - ((deriv F z / (F z-ξ))*v).re := by + have hu : HasFDerivAt (fun w : ℂ => Real.log w.im) ((z.im)⁻¹ • Complex.imCLM) z := by + simpa only [Complex.imCLM_apply] using (Complex.imCLM.hasFDerivAt (x := z)).log hz.ne' + have h1 := hu.const_mul k + have h2 : DifferentiableAt ℝ (fun w => Real.log ‖F w-ξ‖) z := + (((hF.restrictScalars (𝕜 := ℝ)).sub_const ξ).norm ℝ (sub_ne_zero.mpr hne)).log (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hne)) + change (fderiv ℝ ((fun w => k * Real.log w.im) - (fun w => Real.log ‖F w-ξ‖)) z) v = _ + rw [fderiv_sub h1.differentiableAt h2, h1.fderiv, + complex_log_norm_fderiv (hF.sub_const ξ) (sub_ne_zero.mpr hne)] + simp only [sub_apply, smul_apply, smul_eq_mul, Complex.imCLM_apply, + ContinuousLinearMap.comp_apply, Complex.reCLM_apply, + ContinuousLinearMap.coe_restrictScalars', ContinuousLinearMap.toSpanSingleton_apply, + deriv_sub_const] + rw [mul_comm v (deriv F z / (F z-ξ))] + congr 1 + ring + +lemma logPotential_critical_iff {k : ℝ} {F : ℂ → ℂ} {ξ z : ℂ} + (hk : k ≠ 0) (hz : 0 < z.im) (hF : DifferentiableAt ℂ F z) (hne : F z ≠ ξ) : + fderiv ℝ (logPotential k F ξ) z = 0 ↔ criticalMap k F z = ξ := by + have hkC : (k:ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hk + have hyC : (z.im:ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hz.ne' + have hFC : F z-ξ ≠ 0 := sub_ne_zero.mpr hne + let r : ℂ := deriv F z / (F z-ξ) + have hx := logPotential_fderiv_apply (k := k) hz hF hne 1 + have hy := logPotential_fderiv_apply (k := k) hz hF hne I + have hrc : fderiv ℝ (logPotential k F ξ) z = 0 ↔ r = -I * (k:ℂ)/(z.im:ℂ) := by + constructor + · intro h + rw [h] at hx hy + apply Complex.ext + · simp only [zero_apply, one_im, mul_zero, zero_sub, mul_one] at hx + simp only [Complex.div_ofReal_re, neg_mul, neg_re, Complex.mul_re, + I_re, ofReal_re, I_im, ofReal_im, zero_mul, mul_zero, sub_self, neg_zero, zero_div] + dsimp [r] + linarith + · simp only [zero_apply, I_im, mul_one, mul_I_re, sub_neg_eq_add] at hy + simp only [Complex.div_ofReal_im, neg_mul, neg_im, Complex.mul_im, + I_re, ofReal_re, I_im, ofReal_im, mul_zero, one_mul, zero_add, neg_div] + dsimp [r] + linarith + · intro h + ext v + rw [zero_apply, logPotential_fderiv_apply hz hF hne] + change k/z.im*v.im-(r*v).re=0 + rw [h] + simp [Complex.div_re, Complex.div_im, mul_re, mul_im] + field_simp + ring + rw [hrc] + dsimp [r,criticalMap] + constructor + · intro h + have he := (div_eq_iff hFC).mp h + rw [he] + field_simp + ring_nf + simp [Complex.I_sq] + · intro h + apply (div_eq_iff hFC).mpr + apply_fun (fun w : ℂ => w * (k:ℂ)) at h + field_simp at h ⊢ + linear_combination (norm := ring_nf) I*h + simp [Complex.I_sq] + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +namespace StrictInverseFirstPower +noncomputable section + +def criticalHeight (k : ℝ) (F : ℂ → ℂ) (z : ℂ) : ℝ := + k * z.im ^ (k-1) * ‖(deriv F z)⁻¹‖ + +lemma criticalMap_ne_image {k : ℝ} {F : ℂ → ℂ} {z : ℂ} + (hk : k ≠ 0) (hz : 0 < z.im) (hF : deriv F z ≠ 0) : + criticalMap k F z ≠ F z := by + intro h + have hh : I * (z.im : ℂ) * deriv F z / (k : ℂ) = 0 := by + have := sub_eq_self.mp h + exact this + exact (div_ne_zero (mul_ne_zero (mul_ne_zero I_ne_zero + (Complex.ofReal_ne_zero.mpr hz.ne')) hF) (Complex.ofReal_ne_zero.mpr hk)) hh + +lemma criticalMap_sub_image {k : ℝ} {F : ℂ → ℂ} {ξ z : ℂ} + (hg : criticalMap k F z = ξ) : + F z - ξ = I * (z.im : ℂ) * deriv F z / (k : ℂ) := by + dsimp [criticalMap] at hg + linear_combination hg + +lemma criticalHeight_pos {k : ℝ} {F : ℂ → ℂ} {z : ℂ} + (hk : 0 < k) (hz : 0 < z.im) (hF : deriv F z ≠ 0) : + 0 < criticalHeight k F z := by + exact mul_pos (mul_pos hk (Real.rpow_pos_of_pos hz _)) (norm_pos_iff.mpr (inv_ne_zero hF)) + +lemma criticalHeight_value {k : ℝ} {F : ℂ → ℂ} {ξ z : ℂ} + (hk : 0 < k) (hz : 0 < z.im) (hg : criticalMap k F z = ξ) : + z.im ^ k / ‖F z - ξ‖ = criticalHeight k F z := by + rw [criticalMap_sub_image hg] + simp only [norm_div, norm_mul, norm_I, one_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_pos hz, abs_of_pos hk, criticalHeight, norm_inv] + rw [Real.rpow_sub hz, Real.rpow_one] + simp only [div_eq_mul_inv, mul_inv_rev, inv_inv] + ring + +lemma criticalHeight_superlevel {k : ℝ} {F : ℂ → ℂ} {ξ z : ℂ} {h : ℝ} + (hk : 0 < k) (hz : 0 < z.im) (hF : deriv F z ≠ 0) (hh : 0 < h) + (hg : criticalMap k F z = ξ) : + z ∈ potentialSuperlevel k F ξ h ↔ h ≤ criticalHeight k F z := by + have hn : 0 < ‖F z - ξ‖ := by + apply norm_pos_iff.mpr + apply sub_ne_zero.mpr + intro he + exact criticalMap_ne_image hk.ne' hz hF (hg.trans he.symm) + rw [← criticalHeight_value hk hz hg] + change (0 < z.im ∧ ‖F z - ξ‖ ≤ z.im ^ k / h) ↔ _ + rw [and_iff_right hz, le_div_iff₀ hh, le_div_iff₀ hn] + rw [mul_comm] + +lemma continuous_criticalMap (k : ℝ) : + Continuous (fun p : DiskFamily × UpperHalfPlane => criticalMap k (halfPlaneFunction p.1) p.2) := by + exact continuous_halfPlaneFunction.sub ((continuous_const.mul + (Complex.continuous_ofReal.comp (UpperHalfPlane.continuous_im.comp continuous_snd))).mul + continuous_halfPlaneFunction_deriv |>.div_const _) + +lemma continuous_criticalHeight (k : ℝ) : + Continuous (fun p : DiskFamily × UpperHalfPlane => criticalHeight k (halfPlaneFunction p.1) p.2) := by + apply (continuous_const.mul ?_).mul ?_ + · exact (UpperHalfPlane.continuous_im.comp continuous_snd).rpow_const + (fun p => Or.inl p.2.im_ne_zero) + · exact (continuous_halfPlaneFunction_deriv.inv₀ + (fun p => halfPlaneFunction_deriv_ne_zero p.1 p.2.im_pos)).norm + +lemma criticalMap_contDiffAt (k : ℝ) (f : DiskFamily) {z : ℂ} (hz : 0 < z.im) : + ContDiffAt ℝ ⊤ (criticalMap k (halfPlaneFunction f)) z := by + have ha : AnalyticAt ℂ (halfPlaneFunction f) z := + (halfPlaneFunction_differentiableOn f).analyticAt (isOpen_halfPlane.mem_nhds hz) + exact (ha.restrictScalars (𝕜 := ℝ)).contDiffAt.sub + ((contDiffAt_const.mul ((Complex.ofRealCLM.contDiff.comp Complex.imCLM.contDiff).contDiffAt)).mul + (ha.deriv.restrictScalars (𝕜 := ℝ)).contDiffAt |>.div_const _) + +lemma jacobianExpression_zero_iff (k : ℝ) (hk : k ≠ 0) (f : DiskFamily) + {z : ℂ} (hz : 0 < z.im) : + jacobianExpression k (halfPlaneFunction f) z = 0 ↔ + (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det = 0 := by + have ha : AnalyticAt ℂ (halfPlaneFunction f) z := + (halfPlaneFunction_differentiableOn f).analyticAt (isOpen_halfPlane.mem_nhds hz) + rw [← normalizedJacobian_eq hk ha.differentiableAt ha.deriv.differentiableAt + (halfPlaneFunction_deriv_ne_zero f hz), normalizedJacobian] + rw [div_eq_zero_iff] + simp [halfPlaneFunction_deriv_ne_zero f hz] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/CriticalRanks.lean b/lean/OAI/Analysis/StrictMeans/CriticalRanks.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b09ab3cb697a307194a37427ce9e27339d10bd4 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/CriticalRanks.lean @@ -0,0 +1,107 @@ +import OAI.Analysis.StrictMeans.BorelRanks + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +def signedCriticalFiber (k : ℝ) (f : DiskFamily) (ξ : ℂ) (positive : Bool) : Set UpperHalfPlane := + {z | criticalMap k (halfPlaneFunction f) z = ξ ∧ + if positive then 0 < jacobianExpression k (halfPlaneFunction f) z + else jacobianExpression k (halfPlaneFunction f) z < 0} + +def criticalRank (k : ℝ) (f : DiskFamily) (ξ : ℂ) (positive : Bool) (z : UpperHalfPlane) : ℕ := + descendingRank (fun w : UpperHalfPlane => criticalHeight k (halfPlaneFunction f) w) + (signedCriticalFiber k f ξ positive) z + +lemma signedCriticalFiber_strictCut_finite {k : ℝ} (hk : 0 < k) {f : DiskFamily} {ξ : ℂ} + (hg : GoodPair k (f,ξ)) (positive : Bool) (z : UpperHalfPlane) : + {w | w ∈ signedCriticalFiber k f ξ positive ∧ + criticalHeight k (halfPlaneFunction f) z < criticalHeight k (halfPlaneFunction f) w}.Finite := by + apply (goodPair_criticalCut_finite hk hg + (criticalHeight_pos hk z.im_pos (halfPlaneFunction_deriv_ne_zero f z.im_pos))).subset + intro w hw + exact ⟨hw.1.1,hw.2.le⟩ + +lemma goodPair_criticalHeight_injOn {k : ℝ} {f : DiskFamily} {ξ : ℂ} + (hg : GoodPair k (f,ξ)) : + InjOn (fun w : UpperHalfPlane => criticalHeight k (halfPlaneFunction f) w) + {w : UpperHalfPlane | criticalMap k (halfPlaneFunction f) w = ξ} := by + intro z hz w hw he + exact hg.2.2 z w hz hw he + +lemma criticalRank_injOn {k : ℝ} (hk : 0 < k) {f : DiskFamily} {ξ : ℂ} + (hg : GoodPair k (f,ξ)) (positive : Bool) : + InjOn (criticalRank k f ξ positive) (signedCriticalFiber k f ξ positive) := by + apply descendingRank_injOn + ((goodPair_criticalHeight_injOn hg).mono (fun _ hz => hz.1)) + intro z _ + exact signedCriticalFiber_strictCut_finite hk hg positive z + +abbrev RankParameters (k : ℝ) := {p : (DiskFamily × ℂ) × UpperHalfPlane | GoodPair k p.1} + +def rankClosedRelation (k : ℝ) : Set (RankParameters k × UpperHalfPlane) := + {q | criticalMap k (halfPlaneFunction q.1.1.1.1) q.2 = q.1.1.1.2} + +def rankOpenRelation (k : ℝ) (positive : Bool) : Set (RankParameters k × UpperHalfPlane) := + {q | (if positive then 0 < jacobianExpression k (halfPlaneFunction q.1.1.1.1) q.2 + else jacobianExpression k (halfPlaneFunction q.1.1.1.1) q.2 < 0) ∧ + criticalHeight k (halfPlaneFunction q.1.1.1.1) q.1.1.2 < + criticalHeight k (halfPlaneFunction q.1.1.1.1) q.2} + +lemma continuous_rank_f (k : ℝ) : + Continuous (fun q : RankParameters k × UpperHalfPlane => q.1.1.1.1) := + continuous_fst.comp (continuous_fst.comp (continuous_subtype_val.comp continuous_fst)) + +lemma continuous_rank_z (k : ℝ) : + Continuous (fun q : RankParameters k × UpperHalfPlane => q.1.1.2) := + continuous_snd.comp (continuous_subtype_val.comp continuous_fst) + +lemma isClosed_rankClosedRelation (k : ℝ) : IsClosed (rankClosedRelation k) := by + have hG := (continuous_criticalMap k).comp ((continuous_rank_f k).prodMk continuous_snd) + have hξ : Continuous (fun q : RankParameters k × UpperHalfPlane => q.1.1.1.2) := + continuous_snd.comp (continuous_fst.comp (continuous_subtype_val.comp continuous_fst)) + exact isClosed_eq hG hξ + +lemma isOpen_rankOpenRelation (k : ℝ) (positive : Bool) : + IsOpen (rankOpenRelation k positive) := by + have hJ := (continuous_jacobianExpression_upper k).comp + ((continuous_rank_f k).prodMk continuous_snd) + have hVz := (continuous_criticalHeight k).comp + ((continuous_rank_f k).prodMk (continuous_rank_z k)) + have hVw := (continuous_criticalHeight k).comp ((continuous_rank_f k).prodMk continuous_snd) + apply IsOpen.inter _ (isOpen_lt hVz hVw) + cases positive + · exact isOpen_lt hJ continuous_const + · exact isOpen_lt continuous_const hJ + +lemma rankRelation_finite {k : ℝ} (hk : 0 < k) (positive : Bool) (p : RankParameters k) : + {w | (p,w) ∈ rankClosedRelation k ∩ rankOpenRelation k positive}.Finite := by + convert signedCriticalFiber_strictCut_finite hk p.2 positive p.1.2 using 1 + ext w + change (_ ∧ _ ∧ _) ↔ ((_ ∧ _) ∧ _) + tauto + +lemma measurable_criticalRank {k : ℝ} (hk : 0 < k) (positive : Bool) : + Measurable (fun p : RankParameters k => + criticalRank k p.1.1.1 p.1.1.2 positive p.1.2) := by + have hr := measurable_ncard_locally_closed_fiber + (isClosed_rankClosedRelation k) (isOpen_rankOpenRelation k positive) + (rankRelation_finite hk positive) + convert hr using 1 + funext p + unfold criticalRank descendingRank + congr 1 + ext w + change ((_ ∧ _) ∧ _) ↔ (_ ∧ _ ∧ _) + tauto + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/DerivativeDistortion.lean b/lean/OAI/Analysis/StrictMeans/DerivativeDistortion.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc6a8b8201d58019ed466df58fd0d3a1538c1d59 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/DerivativeDistortion.lean @@ -0,0 +1,252 @@ +import OAI.Analysis.StrictMeans.DiskAutomorphisms + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +lemma second_deriv_normalize {f : ℂ → ℂ} {z b c : ℂ} (hf : AnalyticAt ℂ f z) : + deriv (deriv (fun w => (f w - b) / c)) z = deriv (deriv f) z / c := by + have he : deriv (fun w => (f w - b) / c) =ᶠ[𝓝 z] (fun w => deriv f w / c) := by + filter_upwards [hf.eventually_analyticAt] with w hw + exact ((hw.differentiableAt.hasDerivAt.sub_const b).div_const c).deriv + have hp := hf.deriv.differentiableAt.hasDerivAt.div_const c + exact (hp.congr_of_eventuallyEq he).deriv + +theorem preSchwarzian_bound {f : ℂ → ℂ} {a : ℂ} + (hd : DifferentiableOn ℂ f (ball 0 1)) (hi : InjOn f (ball 0 1)) + (ha : ‖a‖ < 1) : + ‖(1 - (‖a‖ ^ 2 : ℝ) : ℂ) * (deriv (deriv f) a / deriv f a) - 2 * conj a‖ ≤ 4 := by + have ha' : a ∈ ball (0 : ℂ) 1 := by simpa only [mem_ball, dist_zero_right] using ha + have hfn := deriv_ne_zero_of_injOn isOpen_ball ha' hi hd + let δ : ℂ := 1 - conj a * a + have hδ : δ ≠ 0 := by + dsimp only [δ] + rw [← normSq_eq_conj_mul_self, ← ofReal_one, ← ofReal_sub, ne_eq, ofReal_eq_zero, + normSq_eq_norm_sq] + nlinarith [norm_nonneg a] + let g : ℂ → ℂ := fun w => (f (diskAutomorphism a w) - f a) / (δ * deriv f a) + have hφd := diskAutomorphism_differentiableOn ha + have hφm := diskAutomorphism_mapsTo ha + have hgd : DifferentiableOn ℂ g (ball 0 1) := + ((hd.comp hφd hφm).sub_const _).div_const _ + have hgi : InjOn g (ball 0 1) := by + intro z hz w hw he + apply diskAutomorphism_injOn ha hz hw + apply hi (hφm hz) (hφm hw) + exact sub_left_inj.mp ((div_left_inj' (mul_ne_zero hδ hfn)).mp he) + have hg0 : g 0 = 0 := by simp [g] + have hφ0 : HasDerivAt (diskAutomorphism a) δ 0 := by + convert diskAutomorphism_hasDerivAt (z := 0) ha (by simp) using 1; simp [δ] + have hfa := hd.analyticAt (isOpen_ball.mem_nhds ha') + have hfac : HasDerivAt f (deriv f a) (diskAutomorphism a 0) := by + simpa using hfa.differentiableAt.hasDerivAt + have hg1 : deriv g 0 = 1 := by + have hp := ((hfac.comp 0 hφ0).sub_const (f a)).div_const (δ * deriv f a) + convert hp.deriv using 1 + all_goals first | rfl | field_simp + have hφa := hφd.analyticAt (isOpen_ball.mem_nhds (by simp : (0 : ℂ) ∈ ball 0 1)) + have hF : AnalyticAt ℂ (f ∘ diskAutomorphism a) 0 := + (show AnalyticAt ℂ f (diskAutomorphism a 0) by simpa using hfa).comp hφa + have hg2 : deriv (deriv g) 0 = δ * (deriv (deriv f) a / deriv f a) - 2 * conj a := by + change deriv (deriv (fun w => ((f ∘ diskAutomorphism a) w - f a) / + (δ * deriv f a))) 0 = _ + rw [second_deriv_normalize hF] + rw [second_deriv_comp (by simpa using hfa) hφa] + simp only [diskAutomorphism_zero, diskAutomorphism_deriv_zero ha, + diskAutomorphism_second_deriv_zero ha] + dsimp only [δ] + dsimp only [δ] at hδ + field_simp + ring + have hb := second_deriv_norm_le_four hgd hgi hg0 hg1 + rw [hg2] at hb + simpa only [δ, ← normSq_eq_conj_mul_self, normSq_eq_norm_sq, ofReal_sub, ofReal_pow, + ofReal_one] using hb + +lemma hasDerivAt_log_norm {g : ℝ → ℂ} {g' : ℂ} {t : ℝ} + (hg : HasDerivAt g g' t) (hn : g t ≠ 0) : + HasDerivAt (fun s => Real.log ‖g s‖) (g' / g t).re t := by + have hp := (hg.norm_sq.log (pow_ne_zero 2 (norm_ne_zero_iff.mpr hn))).div_const 2 + have he : (fun s => Real.log (‖g s‖ ^ 2) / 2) = (fun s => Real.log ‖g s‖) := by + funext s + rw [Real.log_pow] + ring + have hv : (2 * inner ℝ (g t) g' / ‖g t‖ ^ 2) / 2 = (g' / g t).re := by + rw [Complex.inner, Complex.div_re, ← normSq_eq_norm_sq] + simp only [mul_re, conj_re, conj_im] + ring + convert hp using 1 + all_goals first | rfl | exact he.symm | exact hv.symm + +end +end StrictInverseFirstPower + +namespace StrictInverseFirstPower +noncomputable section + +lemma radial_preSchwarzian_bounds {f : ℂ → ℂ} {u : ℂ} {t : ℝ} + (hd : DifferentiableOn ℂ f (ball 0 1)) (hi : InjOn f (ball 0 1)) + (hu : ‖u‖ = 1) (ht : 0 ≤ t) (ht1 : t < 1) : + (2 * t - 4) / (1 - t ^ 2) ≤ + (deriv (deriv f) ((t : ℂ) * u) * u / deriv f ((t : ℂ) * u)).re ∧ + (deriv (deriv f) ((t : ℂ) * u) * u / deriv f ((t : ℂ) * u)).re ≤ + (2 * t + 4) / (1 - t ^ 2) := by + have hnorm : ‖(t : ℂ) * u‖ = t := by simp [hu, abs_of_nonneg ht] + have hsu : conj u * u = 1 := by + rw [← normSq_eq_conj_mul_self, normSq_eq_norm_sq, hu] + norm_num + have hb := preSchwarzian_bound hd hi (a := (t : ℂ) * u) (by rwa [hnorm]) + rw [hnorm] at hb + let p : ℂ := deriv (deriv f) ((t : ℂ) * u) / deriv f ((t : ℂ) * u) + have he : ((1 - (t ^ 2 : ℝ) : ℂ) * p - 2 * conj ((t : ℂ) * u)) * u = + (1 - (t ^ 2 : ℝ) : ℂ) * (p * u) - 2 * (t : ℂ) := by + simp only [map_mul, conj_ofReal, sub_mul] + calc + _ = (1 - (t ^ 2 : ℝ) : ℂ) * (p * u) - 2 * (t : ℂ) * (conj u * u) := by ring + _ = _ := by rw [hsu, mul_one]; ring + have hb' : ‖(1 - (t ^ 2 : ℝ) : ℂ) * (p * u) - 2 * (t : ℂ)‖ ≤ 4 := by + rw [← he, norm_mul, hu, mul_one] + exact hb + have hh := (Complex.abs_re_le_norm _).trans hb' + have hh' : |(1 - t ^ 2) * (p * u).re - 2 * t| ≤ 4 := by + simpa [← ofReal_pow, Complex.mul_re] using hh + have hp : 0 < 1 - t ^ 2 := by nlinarith + have hlo := (abs_le.mp hh').1 + have hhi := (abs_le.mp hh').2 + have hval : (p * u).re = + (deriv (deriv f) ((t : ℂ) * u) * u / deriv f ((t : ℂ) * u)).re := by + congr 1 + dsimp only [p] + ring + rw [← hval] + constructor + · exact (div_le_iff₀ hp).mpr (by nlinarith) + · exact (le_div_iff₀ hp).mpr (by nlinarith) + +lemma hasDerivAt_radial_log_deriv {f : ℂ → ℂ} {u : ℂ} {t : ℝ} + (hd : DifferentiableOn ℂ f (ball 0 1)) (hi : InjOn f (ball 0 1)) + (hmem : (t : ℂ) * u ∈ ball (0 : ℂ) 1) : + HasDerivAt (fun s : ℝ => Real.log ‖deriv f ((s : ℂ) * u)‖) + (deriv (deriv f) ((t : ℂ) * u) * u / deriv f ((t : ℂ) * u)).re t := by + have hdf := (hd.deriv isOpen_ball).differentiableAt (isOpen_ball.mem_nhds hmem) + have hp := (hdf.hasDerivAt.comp (t : ℂ) ((hasDerivAt_id (t : ℂ)).mul_const u)).comp_ofReal + apply hasDerivAt_log_norm _ (deriv_ne_zero_of_injOn isOpen_ball hmem hi hd) + simpa only [Function.comp_apply, id_eq, one_mul] using hp + +lemma log_derivative_distortion_radial {f : ℂ → ℂ} {u : ℂ} {r : ℝ} + (hd : DifferentiableOn ℂ f (ball 0 1)) (hi : InjOn f (ball 0 1)) + (h1 : deriv f 0 = 1) (hu : ‖u‖ = 1) (hr : 0 ≤ r) (hr1 : r < 1) : + Real.log (1 - r) - 3 * Real.log (1 + r) ≤ Real.log ‖deriv f ((r : ℂ) * u)‖ ∧ + Real.log ‖deriv f ((r : ℂ) * u)‖ ≤ Real.log (1 + r) - 3 * Real.log (1 - r) := by + let A : ℝ → ℝ := fun t => Real.log ‖deriv f ((t : ℂ) * u)‖ + let D : ℝ → ℝ := fun t => + (deriv (deriv f) ((t : ℂ) * u) * u / deriv f ((t : ℂ) * u)).re + have hrad (t : ℝ) (ht : t ∈ Icc 0 r) : (t : ℂ) * u ∈ ball (0 : ℂ) 1 := by + simpa [mem_ball, dist_zero_right, hu, abs_of_nonneg ht.1] using ht.2.trans_lt hr1 + have hA (t : ℝ) (ht : t ∈ Icc 0 r) : HasDerivAt A (D t) t := + hasDerivAt_radial_log_deriv hd hi (hrad t ht) + have hL (t : ℝ) (ht : t ∈ Icc 0 r) : + HasDerivAt (fun s : ℝ => Real.log (1 - s) - 3 * Real.log (1 + s)) + ((2 * t - 4) / (1 - t ^ 2)) t := by + have hm : 1 - t ≠ 0 := by linarith [ht.2] + have hp : 1 + t ≠ 0 := by linarith [ht.1] + have hsq : 1 - t ^ 2 ≠ 0 := by nlinarith [ht.1, ht.2] + have hdminus : HasDerivAt (fun s : ℝ => 1 - s) (-1) t := by + simpa using (hasDerivAt_id t).const_sub (1 : ℝ) + have hdplus : HasDerivAt (fun s : ℝ => 1 + s) 1 t := by + simpa using (hasDerivAt_id t).const_add (1 : ℝ) + have h := (hdminus.log hm).sub ((hdplus.log hp).const_mul 3) + convert! h using 1 + field_simp + ring + have hU (t : ℝ) (ht : t ∈ Icc 0 r) : + HasDerivAt (fun s : ℝ => Real.log (1 + s) - 3 * Real.log (1 - s)) + ((2 * t + 4) / (1 - t ^ 2)) t := by + have hm : 1 - t ≠ 0 := by linarith [ht.2] + have hp : 1 + t ≠ 0 := by linarith [ht.1] + have hsq : 1 - t ^ 2 ≠ 0 := by nlinarith [ht.1, ht.2] + have hdminus : HasDerivAt (fun s : ℝ => 1 - s) (-1) t := by + simpa using (hasDerivAt_id t).const_sub (1 : ℝ) + have hdplus : HasDerivAt (fun s : ℝ => 1 + s) 1 t := by + simpa using (hasDerivAt_id t).const_add (1 : ℝ) + have h := (hdplus.log hp).sub ((hdminus.log hm).const_mul 3) + convert! h using 1 + field_simp + ring + have hbounds (t : ℝ) (ht : t ∈ Icc 0 r) := + radial_preSchwarzian_bounds hd hi hu ht.1 (ht.2.trans_lt hr1) + have hmonoL : MonotoneOn (fun t => A t - + (Real.log (1 - t) - 3 * Real.log (1 + t))) (Icc 0 r) := by + apply monotoneOn_of_deriv_nonneg (convex_Icc 0 r) + · exact fun t ht => ((hA t ht).sub (hL t ht)).continuousAt.continuousWithinAt + · exact fun t ht => ((hA t (interior_subset ht)).sub + (hL t (interior_subset ht))).differentiableAt.differentiableWithinAt + · intro t ht + change 0 ≤ deriv (A - (fun s => Real.log (1 - s) - 3 * Real.log (1 + s))) t + rw [((hA t (interior_subset ht)).sub (hL t (interior_subset ht))).deriv] + exact sub_nonneg.mpr (hbounds t (interior_subset ht)).1 + have hmonoU : MonotoneOn (fun t => + (Real.log (1 + t) - 3 * Real.log (1 - t)) - A t) (Icc 0 r) := by + apply monotoneOn_of_deriv_nonneg (convex_Icc 0 r) + · exact fun t ht => ((hU t ht).sub (hA t ht)).continuousAt.continuousWithinAt + · exact fun t ht => ((hU t (interior_subset ht)).sub + (hA t (interior_subset ht))).differentiableAt.differentiableWithinAt + · intro t ht + change 0 ≤ deriv ((fun s => Real.log (1 + s) - 3 * Real.log (1 - s)) - A) t + rw [((hU t (interior_subset ht)).sub (hA t (interior_subset ht))).deriv] + exact sub_nonneg.mpr (hbounds t (interior_subset ht)).2 + have hlo := hmonoL (left_mem_Icc.mpr hr) (right_mem_Icc.mpr hr) hr + have hhi := hmonoU (left_mem_Icc.mpr hr) (right_mem_Icc.mpr hr) hr + simp only [A, ofReal_zero, zero_mul, h1, norm_one, Real.log_one, sub_zero, add_zero, + mul_zero, sub_self] at hlo hhi + exact ⟨sub_nonneg.mp hlo, sub_nonneg.mp hhi⟩ + +theorem derivative_distortion {f : ℂ → ℂ} {z : ℂ} + (hd : DifferentiableOn ℂ f (ball 0 1)) (hi : InjOn f (ball 0 1)) + (h1 : deriv f 0 = 1) (hz : ‖z‖ < 1) : + (1 - ‖z‖) / (1 + ‖z‖) ^ 3 ≤ ‖deriv f z‖ ∧ + ‖deriv f z‖ ≤ (1 + ‖z‖) / (1 - ‖z‖) ^ 3 := by + by_cases hz0 : z = 0 + · subst z + simp [h1] + have hr : 0 < ‖z‖ := norm_pos_iff.mpr hz0 + let u : ℂ := z / (‖z‖ : ℂ) + have hu : ‖u‖ = 1 := by simp [u, hr.ne'] + have he : (‖z‖ : ℂ) * u = z := by + dsimp only [u] + field_simp [Complex.ofReal_ne_zero.mpr hr.ne'] + have hb := log_derivative_distortion_radial hd hi h1 hu hr.le hz + rw [he] at hb + have hm : 0 < 1 - ‖z‖ := sub_pos.mpr hz + have hp : 0 < 1 + ‖z‖ := by positivity + have hdf : 0 < ‖deriv f z‖ := norm_pos_iff.mpr + (deriv_ne_zero_of_injOn isOpen_ball (by simpa using hz) hi hd) + have expL : Real.exp (Real.log (1 - ‖z‖) - 3 * Real.log (1 + ‖z‖)) = + (1 - ‖z‖) / (1 + ‖z‖) ^ 3 := by + rw [show 3 * Real.log (1 + ‖z‖) = Real.log ((1 + ‖z‖) ^ 3) by + rw [Real.log_pow]; norm_num] + rw [Real.exp_sub, Real.exp_log hm, Real.exp_log (pow_pos hp 3)] + have expU : Real.exp (Real.log (1 + ‖z‖) - 3 * Real.log (1 - ‖z‖)) = + (1 + ‖z‖) / (1 - ‖z‖) ^ 3 := by + rw [show 3 * Real.log (1 - ‖z‖) = Real.log ((1 - ‖z‖) ^ 3) by + rw [Real.log_pow]; norm_num] + rw [Real.exp_sub, Real.exp_log hp, Real.exp_log (pow_pos hm 3)] + constructor + · simpa only [expL, Real.exp_log hdf] using Real.exp_le_exp.mpr hb.1 + · simpa only [expU, Real.exp_log hdf] using Real.exp_le_exp.mpr hb.2 + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/DescendingRanks.lean b/lean/OAI/Analysis/StrictMeans/DescendingRanks.lean new file mode 100644 index 0000000000000000000000000000000000000000..a00766f4744a60faff5c47d0801929107864558b --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/DescendingRanks.lean @@ -0,0 +1,132 @@ +import OAI.Analysis.StrictMeans.CriticalCounts + +namespace OAI + +section +open Set + +namespace StrictInverseFirstPower +noncomputable section + +def descendingRank {X : Type*} (v : X → ℝ) (S : Set X) (x : X) : ℕ := + {y | y ∈ S ∧ v x < v y}.ncard + +lemma descendingRank_lt_of_value_lt {X : Type*} {v : X → ℝ} {S : Set X} + {x y : X} (hy : y ∈ S) (hxy : v x < v y) + (hfin : {z | z ∈ S ∧ v x < v z}.Finite) : + descendingRank v S y < descendingRank v S x := by + unfold descendingRank + apply Set.ncard_lt_ncard (Set.ssubset_iff_subset_ne.mpr ⟨?_, ?_⟩) hfin + · intro z hz + exact ⟨hz.1,hxy.trans hz.2⟩ + · intro he + have hyx : y ∈ {z | z ∈ S ∧ v x < v z} := ⟨hy,hxy⟩ + rw [← he] at hyx + exact lt_irrefl _ hyx.2 + +lemma descendingRank_injOn {X : Type*} {v : X → ℝ} {S : Set X} + (hv : InjOn v S) (hfin : ∀ x ∈ S, {z | z ∈ S ∧ v x < v z}.Finite) : + InjOn (descendingRank v S) S := by + intro x hx y hy he + apply hv hx hy + rcases lt_trichotomy (v x) (v y) with hlt | heq | hgt + · exact False.elim ((descendingRank_lt_of_value_lt hy hlt (hfin x hx)).ne he.symm) + · exact heq + · exact False.elim ((descendingRank_lt_of_value_lt hx hgt (hfin y hy)).ne he) + +lemma exists_descendingRank_eq_of_finite {X : Type*} {v : X → ℝ} {S : Set X} + (hS : S.Finite) (hv : InjOn v S) {n : ℕ} (hn : n < S.ncard) : + ∃ x ∈ S, descendingRank v S x = n := by + classical + induction n generalizing S with + | zero => + obtain ⟨m,hm,hmax⟩ := Set.exists_max_image S v hS (Set.nonempty_of_ncard_ne_zero (Nat.ne_of_gt hn)) + refine ⟨m,hm,?_⟩ + unfold descendingRank + have he : {y | y ∈ S ∧ v m < v y} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro y hy + exact (hmax y hy.1).not_gt hy.2 + rw [he,Set.ncard_empty] + | succ n ih => + obtain ⟨m,hm,hmax⟩ := Set.exists_max_image S v hS (Set.nonempty_of_ncard_ne_zero (Nat.ne_of_gt (Nat.zero_lt_of_lt hn))) + let T := S \ {m} + have hT : T.Finite := hS.sdiff + have hnT : n < T.ncard := by + have he : T.ncard + 1 = S.ncard := by + simpa [T] using Set.ncard_sdiff_singleton_add_one hm hS + omega + obtain ⟨x,hx,hxrank⟩ := ih hT (hv.mono sdiff_subset) hnT + have hxm : x ≠ m := by simpa only [T,mem_sdiff,mem_singleton_iff] using hx.2 + have hvxm : v x < v m := lt_of_le_of_ne (hmax x hx.1) + (fun he => hxm (hv hx.1 hm he)) + have he : {y | y ∈ S ∧ v x < v y} = insert m {y | y ∈ T ∧ v x < v y} := by + ext y + simp only [mem_ofPred_eq,mem_insert_iff,T,mem_sdiff,mem_singleton_iff] + constructor + · intro hy + by_cases hym : y = m + · exact Or.inl hym + · exact Or.inr ⟨⟨hy.1,hym⟩,hy.2⟩ + · rintro (rfl | hy) + · exact ⟨hm,hvxm⟩ + · exact ⟨hy.1.1,hy.2⟩ + refine ⟨x,hx.1,?_⟩ + unfold descendingRank at hxrank ⊢ + rw [he,Set.ncard_insert_of_notMem (by simp [T]) (hT.subset (by intro y hy; exact hy.1)),hxrank] + +lemma closedCut_ncard_eq_rank_succ {X : Type*} {v : X → ℝ} {S : Set X} + (hv : InjOn v S) {x : X} (hx : x ∈ S) + (hf : {y | y ∈ S ∧ v x ≤ v y}.Finite) : + {y | y ∈ S ∧ v x ≤ v y}.ncard = descendingRank v S x + 1 := by + classical + have he : {y | y ∈ S ∧ v x ≤ v y} = insert x {y | y ∈ S ∧ v x < v y} := by + ext y + simp only [mem_ofPred_eq,mem_insert_iff] + constructor + · intro hy + rcases eq_or_lt_of_le hy.2 with h | h + · exact Or.inl (hv hy.1 hx h.symm) + · exact Or.inr ⟨hy.1,h⟩ + · rintro (rfl | hy) + · exact ⟨hx,le_rfl⟩ + · exact ⟨hy.1,hy.2.le⟩ + unfold descendingRank + rw [he,Set.ncard_insert_of_notMem (by simp) (hf.subset (by intro y hy; exact ⟨hy.1,hy.2.le⟩))] + +lemma descendingRank_closedCut {X : Type*} (v : X → ℝ) (S : Set X) + {h : ℝ} {x : X} (hx : h ≤ v x) : + descendingRank v {y | y ∈ S ∧ h ≤ v y} x = descendingRank v S x := by + unfold descendingRank + congr 1 + ext y + constructor + · intro hh + exact ⟨hh.1.1,hh.2⟩ + · intro hh + exact ⟨⟨hh.1,hx.trans hh.2.le⟩,hh.2⟩ + +lemma higher_partner_of_cut_domination {X : Type*} {v : X → ℝ} {A B : Set X} + (hdisj : Disjoint A B) (hv : InjOn v (A ∪ B)) {a : X} (ha : a ∈ A) + (hfA : {y | y ∈ A ∧ v a ≤ v y}.Finite) + (hfB : {y | y ∈ B ∧ v a ≤ v y}.Finite) + (hcount : {y | y ∈ A ∧ v a ≤ v y}.ncard ≤ {y | y ∈ B ∧ v a ≤ v y}.ncard) : + ∃ b ∈ B, v a < v b ∧ descendingRank v B b = descendingRank v A a := by + have hrank : descendingRank v A a < {y | y ∈ B ∧ v a ≤ v y}.ncard := by + rw [closedCut_ncard_eq_rank_succ (hv.mono subset_union_left) ha hfA] at hcount + omega + obtain ⟨b,hb,hr⟩ := exists_descendingRank_eq_of_finite hfB + (hv.mono (by intro x hx; exact Or.inr hx.1)) hrank + refine ⟨b,hb.1,?_,?_⟩ + · apply lt_of_le_of_ne hb.2 + intro he + have hab := hv (Or.inl ha) (Or.inr hb.1) he + exact Set.disjoint_left.mp hdisj (hab ▸ ha) hb.1 + · rwa [descendingRank_closedCut v B hb.2] at hr + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/DiagonalIndex.lean b/lean/OAI/Analysis/StrictMeans/DiagonalIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..665a6cc42e5b5c7636c802cdf7ed96deaccfa441 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/DiagonalIndex.lean @@ -0,0 +1,108 @@ +import OAI.Analysis.StrictMeans.LatticeGeometry + +namespace OAI + +section +open Set Function Filter +open scoped Topology +namespace StrictInverseFirstPower.Grid +noncomputable section + +lemma lineIndex_mul_pos (p : ℤ → ℝ) (a : ℝ) (ha : 0a*p j) i=lineIndex p i := by + simp only [lineIndex,mul_lt_mul_iff_right₀ ha,mul_le_mul_iff_right₀ ha] + +lemma signed_square_index (a t : ℝ) (ha : a≠0) (i : ℤ) : + lineIndex (fun j=>a*((j:ℝ)-t)^2) i = + if i=(if 0a*((j:ℝ)-t)^2) = (fun j : ℤ =>(-a)*(-((j:ℝ)-t)^2)) := by funext j; ring + rw [he,lineIndex_mul_pos _ _ (by linarith),concave_line_index] + simp [not_lt.mpr ha.le] + · rw [lineIndex_mul_pos _ _ ha,convex_line_index] + simp [ha] + +def signedVertex (a c x y : ℝ) : Lattice := + toLex ((if 0a*((i:ℝ)-x)^2) (fun j=>c*((j:ℝ)-y)^2)) ex ey v = + if v=signedVertex a c x y then (if 0a*((i:ℝ)-x)^2) (ofLex v).1 * + lineIndex (fun j=>c*((j:ℝ)-y)^2) (ofLex v).2 = _ + rw [signed_square_index _ _ ha,signed_square_index _ _ hc] + have hv : v=signedVertex a c x y ↔ + (ofLex v).1=(if 0 simp_all + +lemma diagonal_sample {o p : ℂ} {s a c : ℝ} (hs : s≠0) : + (fun v=>quadratic a 0 c (meshPoint o s v-p)) = + latticeHeight (fun i=>(a*s^2/2)*((i:ℝ)-(p.re-o.re)/s)^2) + (fun j=>(c*s^2/2)*((j:ℝ)-(p.im-o.im)/s)^2) := by + funext v + simp only [quadratic,latticeHeight,meshPoint,Complex.sub_re,Complex.sub_im, + Complex.add_re,Complex.add_im,Complex.smul_re,Complex.smul_im,latticeCoord_re,latticeCoord_im, + smul_eq_mul] + field_simp + ring + +lemma nearest_integer_bound (t : ℝ) : + |(⌈t-1/2⌉:ℝ)-t|≤1/2 ∧ |(⌊t+1/2⌋:ℝ)-t|≤1/2 := by + have h₁ := Int.le_ceil (t-1/2) + have h₂ := Int.ceil_lt_add_one (t-1/2) + have h₃ := Int.floor_le (t+1/2) + have h₄ := Int.lt_floor_add_one (t+1/2) + constructor <;> rw [abs_le] <;> constructor <;> linarith + +lemma signedVertex_close {o p : ℂ} {s : ℝ} (hs : 0 [exact (nearest_integer_bound _).1; exact (nearest_integer_bound _).2] + have hy : |((ofLex v).2:ℝ)-(p.im-o.im)/s|≤1/2 := by + dsimp [v,signedVertex] + split_ifs <;> [exact (nearest_integer_bound _).1; exact (nearest_integer_bound _).2] + have hre : (meshPoint o s v-p).re=s*(((ofLex v).1:ℝ)-(p.re-o.re)/s) := by + simp only [meshPoint,Complex.sub_re,Complex.add_re,Complex.smul_re,latticeCoord_re,smul_eq_mul] + field_simp; ring + have him : (meshPoint o s v-p).im=s*(((ofLex v).2:ℝ)-(p.im-o.im)/s) := by + simp only [meshPoint,Complex.sub_im,Complex.add_im,Complex.smul_im,latticeCoord_im,smul_eq_mul] + field_simp; ring + calc + dist (meshPoint o s v) p = ‖meshPoint o s v-p‖ := dist_eq_norm _ _ + _ ≤ |(meshPoint o s v-p).re|+|(meshPoint o s v-p).im| := Complex.norm_le_abs_re_add_abs_im _ + _ ≤ s := by + rw [hre,him,abs_mul,abs_mul,abs_of_pos hs] + nlinarith [mul_le_mul_of_nonneg_left hx hs.le,mul_le_mul_of_nonneg_left hy hs.le] + +lemma diagonal_local_sum {a c : ℝ} (ha : a≠0) (hc : c≠0) + {o p : ℂ} {s r : ℝ} (hs : 0quadratic a 0 c (meshPoint o s w-p)) ex ey v = + (if 0u (z+t•d)) (fderiv ℝ u (z+t•d) d) t := by + have hl : HasDerivAt (fun t : ℝ=>z+t•d) d t := by + simpa using ((hasDerivAt_id t).smul_const d).const_add z + exact hu.hasFDerivAt.comp_hasDerivAt t hl + +lemma line_second_hasDerivAt {u : ℂ → ℝ} {z d : ℂ} {t : ℝ} + (hu : ContDiffAt ℝ 2 u (z+t•d)) : + HasDerivAt (fun t : ℝ=>fderiv ℝ u (z+t•d) d) (second u (z+t•d) d d) t := by + have hl : HasDerivAt (fun t : ℝ=>z+t•d) d t := by + simpa using ((hasDerivAt_id t).smul_const d).const_add z + have hf := (hu.fderiv_right (m:=1) (by norm_num)).differentiableAt one_ne_zero + have hd : HasDerivAt (fun t : ℝ=>fderiv ℝ u (z+t•d)) + (fderiv ℝ (fderiv ℝ u) (z+t•d) d) t := hf.hasFDerivAt.comp_hasDerivAt t hl + simpa only [second,map_zero,add_zero] using hd.clm_apply (hasDerivAt_const t d) + +lemma centered_difference_lower {u : ℂ → ℝ} {z d : ℂ} {s a : ℝ} + (hs : 0 ≤ s) (hu : ∀ t∈Icc (-s) s, ContDiffAt ℝ 2 u (z+t•d)) + (ha : ∀ t∈Icc (-s) s, a ≤ second u (z+t•d) d d) : + a*s^2 ≤ u (z+s•d)+u (z-s•d)-2*u z := by + let f : ℝ → ℝ := fun t=>u (z+t•d)-a*t^2/2 + let f' : ℝ → ℝ := fun t=>fderiv ℝ u (z+t•d) d-a*t + let f'' : ℝ → ℝ := fun t=>second u (z+t•d) d d-a + have hf (t : ℝ) (ht : t∈Icc (-s) s) : HasDerivAt f (f' t) t := by + have hu' := line_hasDerivAt ((hu t ht).differentiableAt (by norm_num)) + convert hu'.sub ((((hasDerivAt_id t).pow 2).const_mul a).div_const 2) using 1 <;> + first | rfl | (dsimp only [f',id_eq]; ring) + have hf' (t : ℝ) (ht : t∈Icc (-s) s) : HasDerivAt f' (f'' t) t := by + convert (line_second_hasDerivAt (hu t ht)).sub ((hasDerivAt_id t).const_mul a) using 1 <;> + first | rfl | (simp only [f'',mul_one]) + have hc : ConvexOn ℝ (Icc (-s) s) f := convexOn_of_hasDerivWithinAt2_nonneg + (convex_Icc _ _) (fun t ht=>(hf t ht).continuousAt.continuousWithinAt) + (fun t ht=>(hf t (interior_subset ht)).hasDerivWithinAt) + (fun t ht=>(hf' t (interior_subset ht)).hasDerivWithinAt) + (fun t ht=>sub_nonneg.mpr (ha t (interior_subset ht))) + have he := hc.2 (show -s∈Icc (-s) s by constructor <;> linarith) + (show s∈Icc (-s) s by constructor <;> linarith) + (show (0:ℝ)≤1/2 by norm_num) (show (0:ℝ)≤1/2 by norm_num) (by norm_num) + change f ((1/2:ℝ)*(-s)+1/2*s) ≤ (1/2:ℝ)*f (-s)+(1/2:ℝ)*f s at he + have hz : (1/2:ℝ)*(-s)+1/2*s=0 := by ring + rw [hz] at he + simp only [f] at he + simp only [zero_smul,add_zero,zero_pow (by norm_num : (2:ℕ)≠0),mul_zero,zero_div,sub_zero, + neg_smul,← sub_eq_add_neg,neg_sq] at he + nlinarith + +lemma second_continuousAt {u : ℂ → ℝ} {p : ℂ} (hu : ContDiffAt ℝ 2 u p) (d : ℂ) : + ContinuousAt (fun z=>second u z d d) p := by + have hf := ((hu.fderiv_right (m:=1) (by norm_num)).fderiv_right (m:=0) (by norm_num)).continuousAt + exact (hf.clm_apply continuousAt_const).clm_apply continuousAt_const + +lemma positive_laplace_ascent {u : ℂ → ℝ} {p : ℂ} + (hu : ContDiffAt ℝ 2 u p) + (htr : 0(hpoint 1 (by simp) t ht).1) + (fun t ht=>(hpoint 1 (by simp) t ht).2.1.le) + have hdy := centered_difference_lower hs.le (fun t ht=>(hpoint Complex.I (by simp) t ht).1) + (fun t ht=>(hpoint Complex.I (by simp) t ht).2.2.le) + by_contra h + push Not at h + have hpos : 0<(A-e+B-e)*q.1^2 := mul_pos (by dsimp [e]; linarith [htr]) (sq_pos_of_pos hs) + nlinarith [h.1,h.2.1,h.2.2.1,h.2.2.2] + +lemma compact_laplace_ascent {u : ℂ → ℝ} {K : Set ℂ} + (hK : IsCompact K) (hu : ∀ p∈K, ContDiffAt ℝ 2 u p) + (htr : ∀ p∈K, 0positive_laplace_ascent (hu p hp) (htr p hp)) + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/DiskAutomorphisms.lean b/lean/OAI/Analysis/StrictMeans/DiskAutomorphisms.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4f55cce795ed1a9fc9141e45bb6f4db920047d5 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/DiskAutomorphisms.lean @@ -0,0 +1,246 @@ +import OAI.Analysis.StrictMeans.RootTransform + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower + +noncomputable section + +lemma not_eventually_constant_of_injOn {s : Set ℂ} {f : ℂ → ℂ} {z : ℂ} + (hs : s ∈ 𝓝 z) (hi : InjOn f s) : + ¬ ∀ᶠ w in 𝓝 z, f w = f z := by + intro h + have hz := mem_of_mem_nhds hs + have hh : ∀ᶠ w in 𝓝[≠] z, False := by + filter_upwards [h.filter_mono nhdsWithin_le_nhds, + Filter.Eventually.filter_mono nhdsWithin_le_nhds hs, + eventually_mem_nhdsWithin] with w hw hws hwz + exact hwz (hi hws hz hw) + exact Filter.Eventually.exists hh |>.elim (fun _ h => h) + +lemma analytic_injOn_map_nhds {s : Set ℂ} {f : ℂ → ℂ} {z : ℂ} + (hs : s ∈ 𝓝 z) (hi : InjOn f s) (hf : AnalyticAt ℂ f z) : + map f (𝓝 z) = 𝓝 (f z) := by + exact le_antisymm hf.continuousAt + (hf.eventually_constant_or_nhds_le_map_nhds.resolve_left + (not_eventually_constant_of_injOn hs hi)) + +lemma invFunOn_continuousAt {s : Set ℂ} {f : ℂ → ℂ} {z : ℂ} + (hs : s ∈ 𝓝 z) (hi : InjOn f s) (hf : AnalyticAt ℂ f z) : + ContinuousAt (invFunOn f s) (f z) := by + have hz := mem_of_mem_nhds hs + rw [ContinuousAt, hi.leftInvOn_invFunOn hz, ← analytic_injOn_map_nhds hs hi hf] + change map (invFunOn f s) (map f (𝓝 z)) ≤ 𝓝 z + rw [Filter.map_map] + have hh : (invFunOn f s ∘ f) =ᶠ[𝓝 z] id := by + filter_upwards [hs] with w hw + exact hi.leftInvOn_invFunOn hw + exact (tendsto_congr' hh).mpr tendsto_id + +lemma deriv_eventually_ne_zero_of_injOn {s : Set ℂ} {f : ℂ → ℂ} {z : ℂ} + (hs : IsOpen s) (hz : z ∈ s) (hi : InjOn f s) (hf : DifferentiableOn ℂ f s) : + ∀ᶠ w in 𝓝[≠] z, deriv f w ≠ 0 := by + have hfa : AnalyticAt ℂ (deriv f) z := (hf.deriv hs).analyticAt (hs.mem_nhds hz) + refine hfa.eventually_eq_zero_or_eventually_ne_zero.resolve_left ?_ + intro hzero + have he : ∀ᶠ w in 𝓝 z, w ∈ s ∧ deriv f w = 0 := + Filter.Eventually.and (hs.mem_nhds hz) hzero + obtain ⟨r, hr, hrsub⟩ := Metric.eventually_nhds_iff.mp he + have hdiff : DifferentiableOn ℂ f (ball z r) := hf.mono (fun w hw => (hrsub hw).1) + have hc : ∀ᶠ w in 𝓝 z, f w = f z := by + filter_upwards [ball_mem_nhds z hr] with w hw + exact isOpen_ball.is_const_of_deriv_eq_zero (convex_ball z r).isPreconnected hdiff + (fun w hw => (hrsub hw).2) hw (mem_ball_self hr) + exact not_eventually_constant_of_injOn (hs.mem_nhds hz) hi hc + +theorem deriv_ne_zero_of_injOn {s : Set ℂ} {f : ℂ → ℂ} {z : ℂ} + (hs : IsOpen s) (hz : z ∈ s) (hi : InjOn f s) (hf : DifferentiableOn ℂ f s) : + deriv f z ≠ 0 := by + let g := invFunOn f s + have hfa : AnalyticAt ℂ f z := hf.analyticAt (hs.mem_nhds hz) + have hg : ContinuousAt g (f z) := invFunOn_continuousAt (hs.mem_nhds hz) hi hfa + have hgz : g (f z) = z := hi.leftInvOn_invFunOn hz + have himage : f '' s ∈ 𝓝 (f z) := by + rw [← analytic_injOn_map_nhds (hs.mem_nhds hz) hi hfa] + exact image_mem_map (hs.mem_nhds hz) + have hder := deriv_eventually_ne_zero_of_injOn hs hz hi hf + have hder' : ∀ᶠ w in 𝓝 (f z), g w ≠ z → deriv f (g w) ≠ 0 := by + have hh := hg.tendsto + rw [hgz] at hh + exact hh.eventually (eventually_nhdsWithin_iff.mp hder) + have hgd : ∀ᶠ w in 𝓝[≠] (f z), DifferentiableAt ℂ g w := by + filter_upwards [hder'.filter_mono nhdsWithin_le_nhds, + Filter.Eventually.filter_mono nhdsWithin_le_nhds himage, eventually_mem_nhdsWithin] + with w hd hw hwz + have hgw : g w ∈ s := invFunOn_mem hw + have hfg : f (g w) = w := invFunOn_eq hw + have hgne : g w ≠ z := by + intro he + apply hwz + change w = f z + rw [← hfg, he] + have hleft : ∀ᶠ x in 𝓝 (g w), g (f x) = x := by + filter_upwards [hs.mem_nhds hgw] with x hx + exact hi.leftInvOn_invFunOn hx + have hh := (hf.analyticAt (hs.mem_nhds hgw)).hasStrictDerivAt.to_local_left_inverse + (hd hgne) hleft + simpa only [hfg] using hh.hasDerivAt.differentiableAt + have hga := Complex.analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt hgd hg + have hcomp := hga.differentiableAt.hasDerivAt.comp z (hf.differentiableAt (hs.mem_nhds hz)).hasDerivAt + have hleft : (g ∘ f) =ᶠ[𝓝 z] id := by + filter_upwards [hs.mem_nhds hz] with x hx + exact hi.leftInvOn_invFunOn hx + have hid : HasDerivAt (g ∘ f) 1 z := (hasDerivAt_id z).congr_of_eventuallyEq hleft + have he := hcomp.unique hid + intro hzero + simp only [hzero, mul_zero] at he + exact zero_ne_one he + +end +end StrictInverseFirstPower + +namespace StrictInverseFirstPower +noncomputable section + +lemma second_deriv_eq_twice_dslope {f : ℂ → ℂ} + (hd : DifferentiableOn ℂ f (ball 0 1)) : + deriv (deriv f) 0 = 2 * deriv (dslope f 0) 0 := by + let u := dslope f 0 + have hu : DifferentiableOn ℂ u (ball 0 1) := + (Complex.differentiableOn_dslope (isOpen_ball.mem_nhds (by simp))).mpr hd + have he (z : ℂ) : f z = z * u z + f 0 := by + have hh := sub_smul_dslope f (0 : ℂ) z + simp only [sub_zero, smul_eq_mul] at hh + exact (eq_sub_iff_add_eq.mp hh).symm + have hder : deriv f =ᶠ[𝓝 (0 : ℂ)] (fun z => u z + z * deriv u z) := by + filter_upwards [isOpen_ball.mem_nhds (by simp : (0 : ℂ) ∈ ball 0 1)] with z hz + have hzU := hu.differentiableAt (isOpen_ball.mem_nhds hz) + have hp := ((hasDerivAt_id z).mul hzU.hasDerivAt).add_const (f 0) + have hpf : HasDerivAt f (u z + z * deriv u z) z := by + convert hp using 1 + all_goals first | rfl | exact funext he | simp + exact hpf.deriv + have hu0 := hu.differentiableAt (isOpen_ball.mem_nhds (by simp : (0 : ℂ) ∈ ball 0 1)) + have hu'0 := (hu.deriv isOpen_ball).differentiableAt (isOpen_ball.mem_nhds (by simp : (0 : ℂ) ∈ ball 0 1)) + have hp := hu0.hasDerivAt.add ((hasDerivAt_id (0 : ℂ)).mul hu'0.hasDerivAt) + have hpf : HasDerivAt (deriv f) (2 * deriv u 0) 0 := by + convert hp.congr_of_eventuallyEq hder using 1 + all_goals first | rfl | simp [two_mul] + exact hpf.deriv + +lemma second_deriv_norm_le_four {f : ℂ → ℂ} + (hd : DifferentiableOn ℂ f (ball 0 1)) (hi : InjOn f (ball 0 1)) + (h0 : f 0 = 0) (h1 : deriv f 0 = 1) : ‖deriv (deriv f) 0‖ ≤ 4 := by + rw [second_deriv_eq_twice_dslope hd, norm_mul] + have hh := second_coefficient_le_two hd hi h0 h1 + norm_num + linarith + +def diskAutomorphism (a z : ℂ) : ℂ := (a + z) / (1 + conj a * z) + +lemma diskAutomorphism_den_ne {a z : ℂ} (ha : ‖a‖ < 1) (hz : ‖z‖ < 1) : + 1 + conj a * z ≠ 0 := by + have hl : ‖conj a * z‖ < 1 := by + rw [norm_mul, norm_conj] + nlinarith [norm_nonneg a, norm_nonneg z] + intro he + have he' : conj a * z = -1 := by linear_combination he + rw [he'] at hl + norm_num at hl + +lemma diskAutomorphism_norm_identity (a z : ℂ) : + ‖1 + conj a * z‖ ^ 2 - ‖a + z‖ ^ 2 = (1 - ‖a‖ ^ 2) * (1 - ‖z‖ ^ 2) := by + simp only [← normSq_eq_norm_sq, normSq_apply, add_re, add_im, mul_re, mul_im, + conj_re, conj_im, one_re, one_im] + ring + +lemma diskAutomorphism_mapsTo {a : ℂ} (ha : ‖a‖ < 1) : + MapsTo (diskAutomorphism a) (ball 0 1) (ball 0 1) := by + intro z hz + simp only [mem_ball, dist_zero_right] at * + have hn := diskAutomorphism_norm_identity a z + have hp : 0 < (1 - ‖a‖ ^ 2) * (1 - ‖z‖ ^ 2) := + mul_pos (by nlinarith [norm_nonneg a]) (by nlinarith [norm_nonneg z]) + have hl : ‖a + z‖ < ‖1 + conj a * z‖ := by + nlinarith [norm_nonneg (a + z), norm_nonneg (1 + conj a * z)] + dsimp only [diskAutomorphism] + rw [norm_div, div_lt_one (norm_pos_iff.mpr (diskAutomorphism_den_ne ha hz))] + exact hl + +lemma diskAutomorphism_injOn {a : ℂ} (ha : ‖a‖ < 1) : + InjOn (diskAutomorphism a) (ball 0 1) := by + intro z hz w hw he + have hz' : ‖z‖ < 1 := by simpa only [mem_ball, dist_zero_right] using hz + have hw' : ‖w‖ < 1 := by simpa only [mem_ball, dist_zero_right] using hw + have haN : 1 - conj a * a ≠ 0 := by + rw [← normSq_eq_conj_mul_self, ← ofReal_one, ← ofReal_sub, ne_eq, ofReal_eq_zero] + rw [normSq_eq_norm_sq] + nlinarith [norm_nonneg a] + have he' := (div_eq_div_iff (diskAutomorphism_den_ne ha hz') (diskAutomorphism_den_ne ha hw')).mp he + have he'' : (1 - conj a * a) * (z - w) = 0 := by linear_combination he' + exact sub_eq_zero.mp ((mul_eq_zero.mp he'').resolve_left haN) + +lemma diskAutomorphism_hasDerivAt {a z : ℂ} (ha : ‖a‖ < 1) (hz : ‖z‖ < 1) : + HasDerivAt (diskAutomorphism a) + ((1 - conj a * a) / (1 + conj a * z) ^ 2) z := by + have hh := ((hasDerivAt_id z).const_add a).div + (((hasDerivAt_id z).const_mul (conj a)).const_add 1) (diskAutomorphism_den_ne ha hz) + convert hh using 1 + all_goals first | rfl | (dsimp only [id_eq, Function.comp_apply]; ring) + +lemma diskAutomorphism_differentiableOn {a : ℂ} (ha : ‖a‖ < 1) : + DifferentiableOn ℂ (diskAutomorphism a) (ball 0 1) := by + intro z hz + exact (diskAutomorphism_hasDerivAt ha (by simpa [mem_ball, dist_zero_right] using hz)).differentiableAt.differentiableWithinAt + +@[simp] lemma diskAutomorphism_zero (a : ℂ) : diskAutomorphism a 0 = a := by simp [diskAutomorphism] + +lemma diskAutomorphism_deriv_zero {a : ℂ} (ha : ‖a‖ < 1) : + deriv (diskAutomorphism a) 0 = 1 - conj a * a := by + simpa using (diskAutomorphism_hasDerivAt (z := 0) ha (by simp)).deriv + +lemma diskAutomorphism_second_deriv_zero {a : ℂ} (ha : ‖a‖ < 1) : + deriv (deriv (diskAutomorphism a)) 0 = -2 * conj a * (1 - conj a * a) := by + have he : deriv (diskAutomorphism a) =ᶠ[𝓝 (0 : ℂ)] + (fun z => (1 - conj a * a) / (1 + conj a * z) ^ 2) := by + filter_upwards [isOpen_ball.mem_nhds (by simp : (0 : ℂ) ∈ ball 0 1)] with z hz + exact (diskAutomorphism_hasDerivAt ha (by simpa [mem_ball, dist_zero_right] using hz)).deriv + have hn : (1 + conj a * (0 : ℂ)) ^ 2 ≠ 0 := by simp + have hp := (hasDerivAt_const (0 : ℂ) (1 - conj a * a)).div + ((((hasDerivAt_id (0 : ℂ)).const_mul (conj a)).const_add 1).pow 2) hn + have hpf : HasDerivAt (deriv (diskAutomorphism a)) (-2 * conj a * (1 - conj a * a)) 0 := by + convert hp.congr_of_eventuallyEq he using 1 + all_goals first | rfl | (simp; ring) + exact hpf.deriv + +lemma second_deriv_comp {f g : ℂ → ℂ} {z : ℂ} + (hf : AnalyticAt ℂ f (g z)) (hg : AnalyticAt ℂ g z) : + deriv (deriv (f ∘ g)) z = deriv (deriv f) (g z) * deriv g z ^ 2 + + deriv f (g z) * deriv (deriv g) z := by + have he : deriv (f ∘ g) =ᶠ[𝓝 z] (fun w => deriv f (g w) * deriv g w) := by + filter_upwards [hg.eventually_analyticAt, + hg.continuousAt.preimage_mem_nhds hf.eventually_analyticAt] with w hgw hfw + exact deriv_comp w hfw.differentiableAt hgw.differentiableAt + have hp := (hf.deriv.differentiableAt.hasDerivAt.comp z hg.differentiableAt.hasDerivAt).mul + hg.deriv.differentiableAt.hasDerivAt + have hpf : HasDerivAt (deriv (f ∘ g)) + (deriv (deriv f) (g z) * deriv g z ^ 2 + deriv f (g z) * deriv (deriv g) z) z := by + convert hp.congr_of_eventuallyEq he using 1 + all_goals first | rfl | (dsimp only [id_eq, Function.comp_apply]; ring) + exact hpf.deriv + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/DyadicBounds.lean b/lean/OAI/Analysis/StrictMeans/DyadicBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..f07c8b6d8efb780bceb565642f6ce208338274b6 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/DyadicBounds.lean @@ -0,0 +1,202 @@ +import OAI.Analysis.StrictMeans.TransferOperator + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +lemma cayleyToDisk_norm_relation (z : UpperHalfPlane) : + (1 - ‖cayleyToDisk z‖ ^ 2) * ‖(z : ℂ) + I‖ ^ 2 = 4 * z.im := by + have hd : ‖(z : ℂ) + I‖ ≠ 0 := norm_ne_zero_iff.mpr (add_I_ne_zero z.im_pos) + rw [cayleyToDisk, norm_div, div_pow] + field_simp + rw [Complex.sq_norm, Complex.sq_norm] + simp only [Complex.normSq_apply, add_re, I_re, add_zero, add_im, I_im, + sub_re, sub_zero, sub_im, UpperHalfPlane.coe_re, UpperHalfPlane.coe_im] + ring + +lemma halfPlaneQ_norm (f : DiskFamily) (z : UpperHalfPlane) : + ‖halfPlaneQ f z‖ = ‖(z : ℂ) + I‖ ^ 2 / + (4 * ‖deriv (diskExtension f.val) (cayleyToDisk z)‖) := by + rw [halfPlaneQ, norm_inv, halfPlaneFunction_deriv f z.im_pos] + simp only [norm_mul, norm_ofNat, norm_I, mul_one, norm_div, norm_pow] + field_simp + ring + +lemma halfPlaneQ_strip_bound (f : DiskFamily) (z : UpperHalfPlane) + (hx : |z.re| ≤ 2) (hy : z.im ≤ 1) : ‖halfPlaneQ f z‖ ≤ 64 / z.im := by + let r := ‖cayleyToDisk z‖ + let d := ‖deriv (diskExtension f.val) (cayleyToDisk z)‖ + let D := ‖(z : ℂ) + I‖ ^ 2 + have hr0 : 0 ≤ r := norm_nonneg _ + have hr : r < 1 := by + simpa only [mem_ball, dist_zero_right] using cayleyToDisk_mem z.im_pos + have hD0 : 0 ≤ D := sq_nonneg _ + have hD : D ≤ 8 := by + dsimp only [D] + rw [Complex.sq_norm] + simp only [Complex.normSq_apply, add_re, add_im, I_re, I_im, add_zero, + UpperHalfPlane.coe_re, UpperHalfPlane.coe_im] + have ha := abs_le.mp hx + nlinarith [z.im_pos] + have hd0 : 0 < d := norm_pos_iff.mpr + (diskFamily_derivative_ne_zero f ⟨_, cayleyToDisk_mem z.im_pos⟩) + have hrel : (1 - r) * (1 + r) * D = 4 * z.im := by + have hh := cayleyToDisk_norm_relation z + dsimp only [r, D] + nlinarith [hh] + have hylo : z.im ≤ 4 * (1 - r) := by + have h := mul_le_mul_of_nonneg_left hD (mul_nonneg (by linarith) (by linarith)) + have h' := mul_le_mul_of_nonneg_left (show 1 + r ≤ 2 by linarith) + (show 0 ≤ 8 * (1 - r) by positivity) + nlinarith + have hd := (derivative_distortion f.property.1 f.property.2.1 f.property.2.2.2 hr).1 + change (1 - r) / (1 + r) ^ 3 ≤ d at hd + have hp : 0 < (1 + r) ^ 3 := pow_pos (by linarith) _ + have hd' := (div_le_iff₀ hp).mp hd + have hc : (1 + r) ^ 3 ≤ 8 := by + simpa only [show (2 : ℝ)^3 = 8 by norm_num] using pow_le_pow_left₀ (show 0 ≤ 1 + r by linarith) + (show 1 + r ≤ 2 by linarith) 3 + have hds : z.im ≤ 32 * d := by + have hh := mul_le_mul_of_nonneg_left hc hd0.le + nlinarith + rw [halfPlaneQ_norm, div_le_div_iff₀ (mul_pos (by norm_num) hd0) z.im_pos] + change D * z.im ≤ 64 * (4 * d) + have hh := mul_le_mul_of_nonneg_right hD z.im_pos.le + nlinarith + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +def xyPoint (x y : ℝ) (hy : 0 < y) : UpperHalfPlane := ⟨x + y * I, by simpa⟩ +@[simp] lemma xyPoint_re (x y : ℝ) (hy : 0 < y) : (xyPoint x y hy).re = x := by simp [xyPoint] +@[simp] lemma xyPoint_im (x y : ℝ) (hy : 0 < y) : (xyPoint x y hy).im = y := by simp [xyPoint] + +lemma affineProduct_xyPoint (x y s t : ℝ) (hy : 0 < y) (ht : 0 < t) : + affineProduct (xyPoint x y hy) (xyPoint s t ht) = + xyPoint (x + y * s) (y * t) (mul_pos hy ht) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, xyPoint] + ring + +def horizontalPoint (x : ℝ) : UpperHalfPlane := xyPoint x 1 zero_lt_one + +def dyadicHeight (n : ℕ) : ℝ := (1 / 2 : ℝ) ^ n +lemma dyadicHeight_pos (n : ℕ) : 0 < dyadicHeight n := pow_pos (by norm_num) _ +lemma dyadicHeight_le_one (n : ℕ) : dyadicHeight n ≤ 1 := + pow_le_one₀ (by norm_num) (by norm_num) +lemma dyadicHeight_succ (n : ℕ) : dyadicHeight (n + 1) = dyadicHeight n / 2 := by + simp [dyadicHeight, pow_succ, div_eq_mul_inv] + +def gridStart (n : ℕ) : UpperHalfPlane := + xyPoint (-1 + dyadicHeight n) (dyadicHeight n) (dyadicHeight_pos n) +def gridEnd (n : ℕ) : UpperHalfPlane := + xyPoint (1 + dyadicHeight n) (dyadicHeight n) (dyadicHeight_pos n) + +lemma dyadicLeft_gridStart (n : ℕ) : affineProduct dyadicLeft (gridStart n) = gridStart (n + 1) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, dyadicLeft, gridStart, xyPoint, dyadicHeight_succ] + ring +lemma dyadicRight_gridEnd (n : ℕ) : affineProduct dyadicRight (gridEnd n) = gridEnd (n + 1) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, dyadicRight, gridEnd, xyPoint, dyadicHeight_succ] + ring +lemma dyadic_gridMiddle (n : ℕ) : + affineProduct dyadicLeft (gridEnd n) = affineProduct dyadicRight (gridStart n) := by + apply UpperHalfPlane.ext + simp [coe_affineProduct, affineAt, dyadicLeft, dyadicRight, gridStart, gridEnd, xyPoint] + ring + +lemma dyadic_shift (n : ℕ) : + dyadicOperator ^ n * affineOperator (horizontalPoint 2) - dyadicOperator ^ n = + dyadicHeight n • (affineOperator (gridEnd n) - affineOperator (gridStart n)) := by + induction n with + | zero => + have hs : gridStart 0 = UpperHalfPlane.I := by apply UpperHalfPlane.ext; simp [gridStart, dyadicHeight, xyPoint] + have he : gridEnd 0 = horizontalPoint 2 := by apply UpperHalfPlane.ext; norm_num [gridEnd, horizontalPoint, dyadicHeight, xyPoint] + simp [hs, he, dyadicHeight] + | succ n ih => + rw [pow_succ', mul_assoc, ← mul_sub, ih, mul_smul_comm, + dyadicOperator, smul_mul_assoc, smul_smul, mul_sub, add_mul, add_mul, + affineOperator_mul, affineOperator_mul, affineOperator_mul, affineOperator_mul, + dyadicLeft_gridStart, dyadicRight_gridEnd, dyadic_gridMiddle] + have hc (a b c : C(DiskFamily, ℝ) →L[ℝ] C(DiskFamily, ℝ)) : + (c + a) - (b + c) = a - b := by abel + rw [hc] + congr 1 + +lemma affineOperator_norm_bound {z : UpperHalfPlane} {C : ℝ} (hC : 0 ≤ C) + (h : ∀ f : DiskFamily, ‖halfPlaneQ f z‖ ≤ C) : ‖affineOperator z‖ ≤ C := by + apply ContinuousLinearMap.opNorm_le_bound _ hC + intro φ + apply (ContinuousMap.norm_le _ (mul_nonneg hC (norm_nonneg _))).mpr + intro f + rw [affineOperator_apply, norm_mul, norm_norm] + exact mul_le_mul (h f) (φ.norm_coe_le_norm _) (norm_nonneg _) hC + +lemma affineOperator_strip_norm (z : UpperHalfPlane) (hx : |z.re| ≤ 2) (hy : z.im ≤ 1) : + ‖affineOperator z‖ ≤ 64 / z.im := + affineOperator_norm_bound (by positivity) (fun f => halfPlaneQ_strip_bound f z hx hy) + +lemma dyadic_shift_norm_le (n : ℕ) : + ‖dyadicOperator ^ n * affineOperator (horizontalPoint 2) - dyadicOperator ^ n‖ ≤ 128 := by + have hv := dyadicHeight_pos n + have hv1 := dyadicHeight_le_one n + have hs := affineOperator_strip_norm (gridStart n) + (by simp only [gridStart, xyPoint_re]; rw [abs_le]; constructor <;> linarith) + (by simpa only [gridStart, xyPoint_im] using hv1) + have he := affineOperator_strip_norm (gridEnd n) + (by simp only [gridEnd, xyPoint_re]; rw [abs_le]; constructor <;> linarith) + (by simpa only [gridEnd, xyPoint_im] using hv1) + simp only [gridEnd, gridStart, xyPoint_im] at hs he + rw [dyadic_shift] + calc + _ ≤ ‖dyadicHeight n‖ * ‖affineOperator (gridEnd n) - affineOperator (gridStart n)‖ := + ContinuousLinearMap.opNorm_smul_le _ _ + _ ≤ dyadicHeight n * (‖affineOperator (gridEnd n)‖ + ‖affineOperator (gridStart n)‖) := by + rw [Real.norm_of_nonneg hv.le] + apply mul_le_mul_of_nonneg_left _ hv.le + exact norm_sub_le (affineOperator (gridEnd n)) (affineOperator (gridStart n)) + _ ≤ dyadicHeight n * (64 / dyadicHeight n + 64 / dyadicHeight n) := + mul_le_mul_of_nonneg_left (add_le_add he hs) hv.le + _ = 128 := by field_simp; ring + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/DyadicGap.lean b/lean/OAI/Analysis/StrictMeans/DyadicGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..547ffa8b0f8722d51daa9041abcebe33c5800dd5 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/DyadicGap.lean @@ -0,0 +1,49 @@ +import OAI.Analysis.StrictMeans.EqualityBarrier + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +theorem dyadicExponent_lt_quarter : dyadicExponent < 1/4 := by + by_contra hn + have hβ : 1/4 ≤ dyadicExponent := le_of_not_gt hn + have hβ0 : 0 ≤ dyadicExponent := dyadicExponent_nonneg + obtain ⟨μ,hμ⟩ := exists_exact_affine_probability_continuous (by linarith : 0 < dyadicExponent) + have hlaw : AffineProbabilityLaw μ dyadicExponent := by + intro z φ hφ + rw [← weightedRebaseMeasure_lintegral _ _ _ hφ, + weightedRebaseMeasure_eq_smul μ dyadicExponent hμ z,lintegral_smul_measure] + rfl + let k := (dyadicExponent+2)/3 + have hk : k ≠ 0 := by dsimp [k]; linarith + have hm := expected_normalizedJacobian_at_source_k μ dyadicExponent hβ + (affine_real_law_mean_law μ dyadicExponent hμ) + change k^2 * (∫ f, normalizedJacobian k (halfPlaneFunction f) I ∂(μ : Measure DiskFamily)) = + ((4 * dyadicExponent - 1) * (dyadicExponent + 2)) / 9 at hm + simp_rw [halfPlaneFunction_normalizedJacobian_I _ hk] at hm + have ht := strict_weighted_transport μ dyadicExponent hβ0 hlaw + have he : dyadicExponent = 1/4 := by + have hle : k^2 * (∫ f, jacobianExpression k (halfPlaneFunction f) I ∂(μ : Measure DiskFamily)) ≤ 0 := + mul_nonpos_of_nonneg_of_nonpos (sq_nonneg _) ht.1 + rw [hm] at hle + nlinarith + have k_eq : (dyadicExponent+2)/3 = (3/4:ℝ) := by rw [he]; norm_num + have hz : (∫ f, jacobianExpression ((dyadicExponent+2)/3) (halfPlaneFunction f) I ∂(μ : Measure DiskFamily)) = 0 := by + dsimp [k] at hm + rw [he] at hm ⊢ + norm_num at hm ⊢ + linarith + have hae := ht.2 hz + rw [k_eq] at hae + exact affine_law_not_ae_zero_jacobian μ dyadicExponent hμ hae + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/Eigenmeasure.lean b/lean/OAI/Analysis/StrictMeans/Eigenmeasure.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1d18268083d41a9c414059f3a98780197ab746f --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/Eigenmeasure.lean @@ -0,0 +1,264 @@ +import OAI.Analysis.StrictMeans.PositiveFunctionals + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section +open Set Filter MeasureTheory +open scoped Topology + +variable {A : Type*} [NormedRing A] [NormedAlgebra ℝ A] [CompleteSpace A] + +omit [CompleteSpace A] in +lemma scaled_power (a : A) (t : ℝ) (n : ℕ) : (t • a) ^ n = t ^ n • a ^ n := + smul_pow t a n + +def growthResolvent (a : A) (τ : ℝ) : A := ∑' n : ℕ, (τ⁻¹ • a) ^ n + +lemma summable_growthResolvent (a : A) (h : ∀ n : ℕ, 1 ≤ ‖a ^ n‖) + {τ : ℝ} (hτ : 0 < τ) (hg : logNormGrowth a h < Real.log τ) : + Summable (fun n : ℕ => (τ⁻¹ • a) ^ n) := by + simpa only [smul_pow] using summable_resolventPower a h hτ hg + +lemma growthResolvent_mul (a : A) (h : ∀ n : ℕ, 1 ≤ ‖a ^ n‖) + {τ : ℝ} (hτ : 0 < τ) (hg : logNormGrowth a h < Real.log τ) : + growthResolvent a τ * a = τ • (growthResolvent a τ - 1) := by + have hh := (summable_growthResolvent a h hτ hg).tsum_pow_mul_one_sub + change growthResolvent a τ * (1 - τ⁻¹ • a) = 1 at hh + rw [mul_sub, mul_one, mul_smul_comm] at hh + have he : τ⁻¹ • (growthResolvent a τ * a) = growthResolvent a τ - 1 := by + exact (sub_eq_iff_eq_add.mp hh).symm |> eq_sub_of_add_eq' + calc + growthResolvent a τ * a = τ • (τ⁻¹ • (growthResolvent a τ * a)) := by + rw [smul_smul, mul_inv_cancel₀ hτ.ne', one_smul] + _ = τ • (growthResolvent a τ - 1) := congrArg (τ • ·) he + +lemma mul_growthResolvent (a : A) (h : ∀ n : ℕ, 1 ≤ ‖a ^ n‖) + {τ : ℝ} (hτ : 0 < τ) (hg : logNormGrowth a h < Real.log τ) : + a * growthResolvent a τ = τ • (growthResolvent a τ - 1) := by + have hh := (summable_growthResolvent a h hτ hg).one_sub_mul_tsum_pow + change (1 - τ⁻¹ • a) * growthResolvent a τ = 1 at hh + rw [sub_mul, one_mul, smul_mul_assoc] at hh + have he : τ⁻¹ • (a * growthResolvent a τ) = growthResolvent a τ - 1 := by + exact (sub_eq_iff_eq_add.mp hh).symm |> eq_sub_of_add_eq' + calc + a * growthResolvent a τ = τ • (τ⁻¹ • (a * growthResolvent a τ)) := by + rw [smul_smul, mul_inv_cancel₀ hτ.ne', one_smul] + _ = τ • (growthResolvent a τ - 1) := congrArg (τ • ·) he + +section Positive +variable {X : Type*} [TopologicalSpace X] [CompactSpace X] + +lemma growthResolvent_apply_series (L : C(X, ℝ) →L[ℝ] C(X, ℝ)) + (h : ∀ n : ℕ, 1 ≤ ‖L ^ n‖) {τ : ℝ} (hτ : 0 < τ) + (hg : logNormGrowth L h < Real.log τ) (f : C(X, ℝ)) (x : X) : + growthResolvent L τ f x = ∑' n : ℕ, τ⁻¹ ^ n * ((L ^ n) f) x := by + let e := (ContinuousMap.evalCLM ℝ x).comp (ContinuousLinearMap.apply ℝ C(X, ℝ) f) + have he := e.map_tsum (summable_growthResolvent L h hτ hg) + change growthResolvent L τ f x = _ at he + rw [he] + apply tsum_congr + intro n + rw [scaled_power] + simp [e] + +lemma growthResolvent_monotone (L : C(X, ℝ) →L[ℝ] C(X, ℝ)) (hL : Monotone L) + (h : ∀ n : ℕ, 1 ≤ ‖L ^ n‖) {τ : ℝ} (hτ : 0 < τ) + (hg : logNormGrowth L h < Real.log τ) : Monotone (growthResolvent L τ : C(X, ℝ) →L[ℝ] C(X, ℝ)) := by + have hp : ∀ f : C(X, ℝ), 0 ≤ f → 0 ≤ growthResolvent L τ f := by + intro f hf x + change (0 : ℝ) ≤ growthResolvent L τ f x + rw [growthResolvent_apply_series L h hτ hg] + apply tsum_nonneg + intro n + apply mul_nonneg (pow_nonneg (inv_nonneg.mpr hτ.le) n) + have hh := positiveOperator_pow_monotone L hL n hf x + change ((L ^ n) 0) x ≤ ((L ^ n) f) x at hh + simpa only [map_zero, ContinuousMap.zero_apply] using hh + intro f g hfg + rw [← sub_nonneg, ← map_sub] + exact hp (g - f) (sub_nonneg.mpr hfg) + +lemma growthResolvent_unit_ge_one (L : C(X, ℝ) →L[ℝ] C(X, ℝ)) (hL : Monotone L) + (h : ∀ n : ℕ, 1 ≤ ‖L ^ n‖) {τ : ℝ} (hτ : 0 < τ) + (hg : logNormGrowth L h < Real.log τ) : (1 : C(X, ℝ)) ≤ growthResolvent L τ 1 := by + intro x + let e := (ContinuousMap.evalCLM ℝ x).comp (ContinuousLinearMap.apply ℝ C(X, ℝ) (1 : C(X, ℝ))) + have hs := e.summable (summable_growthResolvent L h hτ hg) + have hh := hs.le_tsum 0 (fun n _ => show 0 ≤ e ((τ⁻¹ • L) ^ n) from by + rw [scaled_power L τ⁻¹ n] + change 0 ≤ τ⁻¹ ^ n * ((L ^ n) 1) x + exact mul_nonneg (pow_nonneg (inv_nonneg.mpr hτ.le) n) + (positiveOperator_unit_nonneg (L ^ n) (positiveOperator_pow_monotone L hL n) x)) + have he := e.map_tsum (summable_growthResolvent L h hτ hg) + rw [← he] at hh + simpa [e, growthResolvent] using hh + +end Positive + +end +end StrictInverseFirstPower + +namespace StrictInverseFirstPower +noncomputable section +open Set Filter MeasureTheory +open scoped Topology + +variable {X : Type*} [TopologicalSpace X] [CompactSpace X] [Nonempty X] + [T2Space X] [MeasurableSpace X] [BorelSpace X] + +lemma exists_approximate_eigenprobability + (L : C(X, ℝ) →L[ℝ] C(X, ℝ)) (hL : Monotone L) + (h : ∀ n : ℕ, 1 ≤ ‖L ^ n‖) {τ : ℝ} (hτ : 0 < τ) + (hg : logNormGrowth L h < Real.log τ) : + ∃ μ : ProbabilityMeasure X, ∀ f : C(X, ℝ), + |(∫ x, L f x ∂(μ : Measure X)) - τ * ∫ x, f x ∂(μ : Measure X)| ≤ + (τ - Real.exp (logNormGrowth L h)) * ‖f‖ := by + let R := growthResolvent L τ + let g := R (1 : C(X, ℝ)) + have hR : Monotone R := growthResolvent_monotone L hL h hτ hg + have hg1 : (1 : C(X, ℝ)) ≤ g := growthResolvent_unit_ge_one L hL h hτ hg + obtain ⟨x, _, hx⟩ := isCompact_univ.exists_isMaxOn (univ_nonempty : (univ : Set X).Nonempty) + g.continuous.continuousOn + let M := g x + have hM1 : 1 ≤ M := hg1 x + have hMpos : 0 < M := lt_of_lt_of_le zero_lt_one hM1 + have hM : g ≤ M • (1 : C(X, ℝ)) := by + intro y + change g y ≤ M * 1 + rw [mul_one] + exact hx (mem_univ y) + have hMi : M⁻¹ ≤ 1 := by + rw [inv_eq_one_div, div_le_one hMpos] + exact hM1 + let a := τ * (1 - M⁻¹) + have ha : 0 ≤ a := mul_nonneg hτ.le (sub_nonneg.mpr hMi) + have hLg : L g = τ • (g - 1) := by + have hh := congrArg (fun S : C(X, ℝ) →L[ℝ] C(X, ℝ) => S 1) + (mul_growthResolvent L h hτ hg) + exact hh + have hsuper : L g ≤ a • g := by + rw [hLg] + intro y + change τ * (g y - 1) ≤ a * g y + have hi : M⁻¹ * g y ≤ 1 := by + have hh := mul_le_mul_of_nonneg_left (hx (mem_univ y)) (inv_nonneg.mpr hMpos.le) + change M⁻¹ * g y ≤ M⁻¹ * M at hh + simpa only [inv_mul_cancel₀ hMpos.ne'] using hh + dsimp [a] + nlinarith [mul_nonneg hτ.le (sub_nonneg.mpr hi)] + have hiter (n : ℕ) : ‖L ^ n‖ ≤ M * a ^ n := + positiveOperator_iterate_bound L hL g ha hg1 hM hsuper n + have hapos : 0 < a := by + have hh := (h 1).trans (hiter 1) + simp only [pow_one] at hh + by_contra hn + have hz : a = 0 := le_antisymm (le_of_not_gt hn) ha + norm_num [hz] at hh + have hρ : Real.exp (logNormGrowth L h) ≤ a := by + calc + Real.exp (logNormGrowth L h) ≤ Real.exp (Real.log a) := + Real.exp_le_exp.mpr (logNormGrowth_le_of_power_bound L h hMpos hapos hiter) + _ = a := Real.exp_log hapos + have herr : τ / M ≤ τ - Real.exp (logNormGrowth L h) := by + dsimp [a] at hρ + rw [div_eq_mul_inv] + nlinarith + have herr0 : 0 ≤ τ / M := (div_pos hτ hMpos).le + let Λ : C(X, ℝ) →L[ℝ] ℝ := M⁻¹ • ((ContinuousMap.evalCLM ℝ x).comp R) + have hΛ : Monotone Λ := by + intro f₁ f₂ hf + change M⁻¹ * R f₁ x ≤ M⁻¹ * R f₂ x + exact mul_le_mul_of_nonneg_left (hR hf x) (inv_nonneg.mpr hMpos.le) + have hΛ1 : Λ 1 = 1 := by + change M⁻¹ * M = 1 + exact inv_mul_cancel₀ hMpos.ne' + obtain ⟨μ, hμ⟩ := exists_probabilityMeasure_of_positiveFunctional Λ hΛ hΛ1 + refine ⟨μ, fun f => ?_⟩ + rw [hμ (L f), hμ f] + change |M⁻¹ * R (L f) x - τ * (M⁻¹ * R f x)| ≤ _ + have hh := congrArg (fun S : C(X, ℝ) →L[ℝ] C(X, ℝ) => S f x) + (growthResolvent_mul L h hτ hg) + change R (L f) x = τ * (R f x - f x) at hh + rw [hh] + have hid : M⁻¹ * (τ * (R f x - f x)) - τ * (M⁻¹ * R f x) = -(τ / M * f x) := by + rw [div_eq_mul_inv] + ring + rw [hid, abs_neg, abs_mul, abs_of_nonneg herr0] + exact (mul_le_mul_of_nonneg_left (f.norm_coe_le_norm x) herr0).trans + (mul_le_mul_of_nonneg_right herr (norm_nonneg f)) + +theorem exists_exact_eigenprobability [TopologicalSpace.MetrizableSpace X] + (L : C(X, ℝ) →L[ℝ] C(X, ℝ)) (hL : Monotone L) + (h : ∀ n : ℕ, 1 ≤ ‖L ^ n‖) : + ∃ μ : ProbabilityMeasure X, ∀ f : C(X, ℝ), + (∫ x, L f x ∂(μ : Measure X)) = + Real.exp (logNormGrowth L h) * ∫ x, f x ∂(μ : Measure X) := by + classical + let : MetricSpace X := TopologicalSpace.metrizableSpaceMetric X + let ρ := Real.exp (logNormGrowth L h) + have hρ : 0 < ρ := Real.exp_pos _ + let τ (n : ℕ) := ρ + 1 / ((n : ℝ) + 1) + have hτgt (n : ℕ) : ρ < τ n := by + dsimp [τ] + have hn : (0 : ℝ) < n + 1 := by positivity + exact lt_add_of_pos_right _ (one_div_pos.mpr hn) + have hτ (n : ℕ) : 0 < τ n := hρ.trans (hτgt n) + have hg (n : ℕ) : logNormGrowth L h < Real.log (τ n) := by + calc + logNormGrowth L h = Real.log ρ := (Real.log_exp _).symm + _ < Real.log (τ n) := Real.log_lt_log hρ (hτgt n) + choose μ hμ using fun n => exists_approximate_eigenprobability L hL h (hτ n) (hg n) + obtain ⟨ν, φ, hφ, hν⟩ := CompactSpace.tendsto_subseq μ + refine ⟨ν, fun f => ?_⟩ + have hτlim : Tendsto τ atTop (𝓝 ρ) := by + simpa only [add_zero] using + tendsto_one_div_add_atTop_nhds_zero_nat.const_add ρ + have hτφ : Tendsto (τ ∘ φ) atTop (𝓝 ρ) := hτlim.comp hφ.tendsto_atTop + have hf := (ProbabilityMeasure.continuous_integral_continuousMap f).tendsto ν |>.comp hν + have hLf := (ProbabilityMeasure.continuous_integral_continuousMap (L f)).tendsto ν |>.comp hν + have habs := (hLf.sub (hτφ.mul hf)).abs + have hzero : Tendsto (fun n => (τ (φ n) - ρ) * ‖f‖) atTop (𝓝 0) := by + convert! (hτφ.sub_const ρ).mul_const ‖f‖ using 1; simp only [sub_self, zero_mul] + have hh : |(∫ x, L f x ∂(ν : Measure X)) - ρ * ∫ x, f x ∂(ν : Measure X)| ≤ 0 := + le_of_tendsto_of_tendsto habs hzero (Eventually.of_forall fun n => hμ (φ n) f) + exact sub_eq_zero.mp (abs_nonpos_iff.mp hh) + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/Endpoints.lean b/lean/OAI/Analysis/StrictMeans/Endpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa7b91c83f312b7b89c7efda900279557a64eb11 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/Endpoints.lean @@ -0,0 +1,64 @@ +import OAI.Analysis.StrictMeans.Spectrum + +namespace OAI + +section +open Set Filter MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +/-- A single, strictly positive gap works for every normalized univalent map, +and hence for the supremum of the individual bounded-map exponents. -/ +theorem uniform_inverse_first_power_gap : + ∃ ε C : ℝ, 0 < ε ∧ ε < 1 / 4 ∧ 0 < C ∧ + (∀ (f : ℂ → ℂ), NormalizedUnivalent f → + ∀ r : ℝ, 1 / 2 ≤ r → r < 1 → + integralMean (-1) f r ≤ C * (1 - r) ^ (-(1 / 4 : ℝ) + ε)) ∧ + boundedSpectrum (-1) ≤ ((1 / 4 - ε : ℝ) : EReal) := by + let b := (dyadicExponent+1/4)/2 + have hb : dyadicExponent < b := by dsimp [b]; linarith [dyadicExponent_lt_quarter] + have hb0 : 0 < b := lt_of_le_of_lt dyadicExponent_nonneg hb + have hb1 : b < 1/4 := by dsimp [b]; linarith [dyadicExponent_lt_quarter] + obtain ⟨C,hC,hbound⟩ := uniform_integralMean_bound_above_dyadicExponent hb + refine ⟨1/4-b,C,by linarith,by linarith,hC,?_,?_⟩ + · intro f hf r hr0 hr + simpa only [show -(1/4:ℝ)+(1/4-b) = -b by ring] using hbound f hf r hr0 hr + · rw [show (1/4:ℝ) - (1/4-b) = b by ring] + apply iSup_le + intro f + apply iSup_le + intro hf + exact growthExponent_le_of_mean_bound f hf.1 hC (hbound f hf.1) + +theorem uniform_inverse_first_power : + ∃ ε C : ℝ, 0 < ε ∧ ε < 1 / 4 ∧ + ∀ (f : ℂ → ℂ), NormalizedUnivalent f → + ∀ r : ℝ, 1 / 2 ≤ r → r < 1 → + integralMean (-1) f r ≤ C * (1 - r) ^ (-(1 / 4 : ℝ) + ε) := by + obtain ⟨ε,C,hε,hε',_hC,hbound,_hs⟩ := uniform_inverse_first_power_gap + exact ⟨ε,C,hε,hε',hbound⟩ + +theorem bounded_spectrum_strict : boundedSpectrum (-1) < (1 / 4 : EReal) := by + obtain ⟨ε,_C,hε,_hε',_hC,_hbound,hs⟩ := uniform_inverse_first_power_gap + apply hs.trans_lt + change ((1/4-ε : ℝ) : EReal) < ((1/4 : ℝ) : EReal) + exact EReal.coe_lt_coe_iff.mpr (by linarith) + +theorem kraetzer_identity_false : + ¬ ∀ p : ℝ, boundedSpectrum p = kraetzerPrediction p := by + intro h + have hp := bounded_spectrum_strict + rw [h (-1)] at hp + have hpred : kraetzerPrediction (-1) = ((1/4 : ℝ) : EReal) := by + norm_num [kraetzerPrediction] + rw [hpred] at hp + change ((1/4 : ℝ) : EReal) < ((1/4 : ℝ) : EReal) at hp + exact lt_irrefl _ hp + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/EqualityBarrier.lean b/lean/OAI/Analysis/StrictMeans/EqualityBarrier.lean new file mode 100644 index 0000000000000000000000000000000000000000..7919c26e2df01718abb4bb237cd2512fe6011d56 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/EqualityBarrier.lean @@ -0,0 +1,172 @@ +import OAI.Analysis.StrictMeans.StrictTransport + +namespace OAI + +section +open Set Filter Metric Complex +open scoped Topology + +namespace StrictInverseFirstPower + +noncomputable section + +theorem disk_decay_zero_at_zero {g : ℂ → ℂ} {C : ℝ} + (hg : DifferentiableOn ℂ g (ball 0 1)) + (hbound : ∀ w ∈ ball (0 : ℂ) 1, ‖g w‖ ≤ C * (1 - ‖w‖ ^ 2)) : + g 0 = 0 := by + have h_circle (r : ℝ) (hr : 0 < r) (hr1 : r < 1) : + ‖g 0‖ ≤ C * (1 - r ^ 2) := by + apply Complex.norm_le_of_forall_mem_frontier_norm_le isBounded_ball + (hg.diffContOnCl_ball (closedBall_subset_ball hr1)) + · intro w hw + rw [frontier_ball _ hr.ne'] at hw + have hw' : ‖w‖ = r := by simpa using hw + simpa [hw'] using hbound w (by simpa [mem_ball, dist_zero_right, hw'] using hr1) + · exact subset_closure (mem_ball_self hr) + have ht : Tendsto (fun r : ℝ => C * (1 - r ^ 2)) (𝓝[<] (1 : ℝ)) (𝓝 0) := by + have hcont : Continuous (fun r : ℝ => C * (1 - r ^ 2)) := by fun_prop + simpa using (hcont.tendsto (1 : ℝ)).mono_left nhdsWithin_le_nhds + have hn : ‖g 0‖ ≤ 0 := ge_of_tendsto ht (by + filter_upwards [eventually_mem_nhdsWithin, + (eventually_gt_nhds (show (0 : ℝ) < 1 by norm_num)).filter_mono nhdsWithin_le_nhds] + with r hr1 hr + exact h_circle r hr hr1) + exact norm_eq_zero.mp (le_antisymm hn (norm_nonneg _)) + +theorem halfPlane_linear_decay_zero {g : ℂ → ℂ} {C : ℝ} + (hg : DifferentiableOn ℂ g {z : ℂ | 0 < z.im}) + (hbound : ∀ z : ℂ, 0 < z.im → ‖g z‖ ≤ C * z.im) : g I = 0 := by + let h : ℂ → ℂ := fun w => (1 - w) ^ 2 * g (cayleyToHalfPlane w) + have hh : DifferentiableOn ℂ h (ball 0 1) := by + apply DifferentiableOn.mul + · fun_prop + · exact hg.comp cayley_differentiableOn (fun w hw => cayley_mem_halfPlane hw) + have hb : ∀ w ∈ ball (0 : ℂ) 1, ‖h w‖ ≤ C * (1 - ‖w‖ ^ 2) := by + intro w hw + calc + ‖h w‖ = ‖1 - w‖ ^ 2 * ‖g (cayleyToHalfPlane w)‖ := by + simp [h, norm_pow] + _ ≤ ‖1 - w‖ ^ 2 * (C * (cayleyToHalfPlane w).im) := + mul_le_mul_of_nonneg_left (hbound _ (cayley_mem_halfPlane hw)) (sq_nonneg _) + _ = C * (1 - ‖w‖ ^ 2) := by + rw [← cayley_im_mul_norm_sq (one_sub_ne_zero_of_mem_disk hw)] + ring + have hz := disk_decay_zero_at_zero hh hb + simpa [h, cayleyToHalfPlane] using hz +theorem norm_logarithmicDerivative (F : ℂ → ℂ) {z : ℂ} (hz : 0 < z.im) : + ‖logarithmicDerivative F z‖ = z.im * ‖deriv (deriv F) z / deriv F z‖ := by + simp [logarithmicDerivative, abs_of_pos hz] + +theorem jacobian_eq_zero_lower_bound {F : ℂ → ℂ} {z : ℂ} + (h : jacobianExpression (3 / 4) F z = 0) : + 1 / 4 ≤ ‖logarithmicDerivative F z‖ := by + have hq := Complex.re_le_norm (logarithmicDerivative F z) + have hn := norm_nonneg (logarithmicDerivative F z) + unfold jacobianExpression at h + have he := (div_eq_zero_iff.mp h).resolve_right (by norm_num) + norm_num at he + by_contra hlt + have hlt' : ‖logarithmicDerivative F z‖ < 1 / 4 := lt_of_not_ge hlt + have hsq : ‖logarithmicDerivative F z‖ ^ 2 < (1 / 4 : ℝ) ^ 2 := + (sq_lt_sq₀ hn (by norm_num)).mpr hlt' + nlinarith + +theorem no_identically_zero_jacobianExpression {F : ℂ → ℂ} + (hF : DifferentiableOn ℂ F {z : ℂ | 0 < z.im}) : + ¬ ∀ z : ℂ, 0 < z.im → jacobianExpression (3 / 4) F z = 0 := by + intro hJ + have hopen : IsOpen {z : ℂ | 0 < z.im} := isOpen_lt continuous_const Complex.continuous_im + have hF' := hF.deriv hopen + have hF'' := hF'.deriv hopen + let p : ℂ → ℂ := fun z => deriv (deriv F) z / deriv F z + have hlow (z : ℂ) (hz : 0 < z.im) : 1 / 4 ≤ z.im * ‖p z‖ := by + simpa only [norm_logarithmicDerivative F hz] using jacobian_eq_zero_lower_bound (hJ z hz) + have hp (z : ℂ) (hz : 0 < z.im) : p z ≠ 0 := by + intro h + have := hlow z hz + simp only [h, norm_zero, mul_zero] at this + norm_num at this + have hFne (z : ℂ) (hz : 0 < z.im) : deriv F z ≠ 0 := by + intro he + exact hp z hz (by simp [p, he]) + have hpd : DifferentiableOn ℂ p {z : ℂ | 0 < z.im} := + hF''.div hF' (fun z hz => hFne z hz) + have hgd : DifferentiableOn ℂ (fun z => (p z)⁻¹) {z : ℂ | 0 < z.im} := + hpd.inv (fun z hz => hp z hz) + have hgb (z : ℂ) (hz : 0 < z.im) : ‖(p z)⁻¹‖ ≤ 4 * z.im := by + rw [norm_inv, inv_eq_one_div, div_le_iff₀ (norm_pos_iff.mpr (hp z hz))] + nlinarith [hlow z hz] + have hgz := halfPlane_linear_decay_zero hgd hgb + exact inv_ne_zero (hp I (by simp)) hgz + +end + +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +lemma continuous_jacobianExpression_fixed (k : ℝ) (z : UpperHalfPlane) : + Continuous (fun f : DiskFamily => jacobianExpression k (halfPlaneFunction f) z) := by + let w : HalfPlaneSet := ⟨(z : ℂ), z.im_pos⟩ + have hp : Continuous (fun f : DiskFamily => (f, w)) := continuous_id.prodMk continuous_const + have hc := (continuous_jacobianExpression k).comp hp + exact hc + +lemma ae_jacobian_zero_everywhere (μ : ProbabilityMeasure DiskFamily) (β k : ℝ) + (hlaw : ∀ (z : UpperHalfPlane) (φ : C(DiskFamily, ℝ)), + (∫ f, ‖halfPlaneQ f z‖ * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + z.im ^ (-β) * ∫ f, φ f ∂(μ : Measure DiskFamily)) + (hzero : ∀ᵐ f ∂(μ : Measure DiskFamily), jacobianExpression k (halfPlaneFunction f) I = 0) + (z : UpperHalfPlane) : + ∀ᵐ f ∂(μ : Measure DiskFamily), jacobianExpression k (halfPlaneFunction f) z = 0 := by + let φ : C(DiskFamily, ℝ) := ⟨fun f => |jacobianExpression k (halfPlaneFunction f) I|, + (continuous_jacobianExpression_fixed k UpperHalfPlane.I).abs⟩ + have hφ : ∫ f, φ f ∂(μ : Measure DiskFamily) = 0 := by + apply integral_eq_zero_of_ae + filter_upwards [hzero] with f hf + change |jacobianExpression k (halfPlaneFunction f) I| = 0 + rw [hf, abs_zero] + have he := hlaw z φ + simp only [hφ, mul_zero] at he + have hfun (f : DiskFamily) : ‖halfPlaneQ f z‖ * φ (rebase f z) = + ‖halfPlaneQ f z‖ * |jacobianExpression k (halfPlaneFunction f) z| := by + change ‖halfPlaneQ f z‖ * |jacobianExpression k (halfPlaneFunction (rebase f z)) I| = _ + rw [jacobianExpression_rebase_I] + have hc : Continuous (fun f : DiskFamily => + ‖halfPlaneQ f z‖ * |jacobianExpression k (halfPlaneFunction f) z|) := + ((continuous_halfPlaneQ.comp (continuous_id.prodMk continuous_const)).norm).mul + (continuous_jacobianExpression_fixed k z).abs + have ha := (integral_eq_zero_iff_of_nonneg + (fun f => mul_nonneg (norm_nonneg _) (abs_nonneg _)) + (hc.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _))).mp + (by simpa only [hfun] using he) + filter_upwards [ha] with f hf + exact abs_eq_zero.mp ((mul_eq_zero.mp hf).resolve_left + (norm_ne_zero_iff.mpr (halfPlaneQ_ne_zero f z))) + +theorem affine_law_not_ae_zero_jacobian (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hlaw : ∀ (z : UpperHalfPlane) (φ : C(DiskFamily, ℝ)), + (∫ f, ‖halfPlaneQ f z‖ * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + z.im ^ (-β) * ∫ f, φ f ∂(μ : Measure DiskFamily)) : + ¬ ∀ᵐ f ∂(μ : Measure DiskFamily), + jacobianExpression (3 / 4) (halfPlaneFunction f) I = 0 := by + intro hzero + obtain ⟨f, hf⟩ := (μ : Measure DiskFamily).nonempty_support (by + intro h + have hu := measure_univ (μ := (μ : Measure DiskFamily)) + simp [h] at hu) + apply no_identically_zero_jacobianExpression (halfPlaneFunction_differentiableOn f) + intro z hz + exact (μ : Measure DiskFamily).support_subset_of_isClosed + (isClosed_eq (continuous_jacobianExpression_fixed (3 / 4) ⟨z, hz⟩) continuous_const) + (ae_jacobian_zero_everywhere μ β (3 / 4) hlaw hzero ⟨z, hz⟩) hf + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/FamilyDerivatives.lean b/lean/OAI/Analysis/StrictMeans/FamilyDerivatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0cb2ea7722d15de27e4792f56cfe32dda225f0c --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/FamilyDerivatives.lean @@ -0,0 +1,153 @@ +import OAI.Analysis.StrictMeans.AffineAveraging + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate + +namespace StrictInverseFirstPower +noncomputable section + +lemma continuous_holomorphicFamily_deriv {X : Type*} [TopologicalSpace X] {U : Set ℂ} + (hU : IsOpen U) (F : X → ℂ → ℂ) + (hF : Continuous (fun p : X × U => F p.1 p.2)) + (hd : ∀ x, DifferentiableOn ℂ (F x) U) : + Continuous (fun p : X × U => deriv (F p.1) p.2) := by + let : LocallyCompactSpace U := hU.locallyCompactSpace + let g : X → C(U, ℂ) := fun x => ⟨fun z => F x z, + hF.comp (continuous_const.prodMk continuous_id)⟩ + have hg : Continuous g := ContinuousMap.continuous_of_continuous_uncurry g hF + let g' : X → C(U, ℂ) := fun x => ⟨fun z => deriv (F x) z, + ((hd x).deriv hU).continuousOn.comp_continuous continuous_subtype_val (fun z => z.property)⟩ + have hg' : Continuous g' := by + rw [continuous_iff_continuousAt] + intro x + rw [ContinuousAt, ContinuousMap.tendsto_iff_tendstoLocallyUniformly] + have hh : TendstoLocallyUniformlyOn F (F x) (𝓝 x) U := by + rw [tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe] + exact ContinuousMap.tendsto_iff_tendstoLocallyUniformly.mp (hg.tendsto x) + have hh' := hh.deriv (Eventually.of_forall hd) hU + rw [tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe] at hh' + exact hh' + exact hg'.comp continuous_fst |>.eval continuous_snd + +lemma complex_path_norm_hasDerivAt {g : ℝ → ℂ} {b : ℂ} {x : ℝ} + (hg : HasDerivAt g b x) (hne : g x ≠ 0) : + HasDerivAt (fun t => ‖g t‖) ((conj (g x) * b).re / ‖g x‖) x := by + have hn := hg.norm_sq.sqrt (pow_ne_zero 2 (norm_ne_zero_iff.mpr hne)) + simp only [Real.sqrt_sq (norm_nonneg _)] at hn + have hi : inner ℝ (g x) b = (conj (g x) * b).re := by + rw [real_inner_eq_re_inner ℂ, RCLike.inner_apply] + change (b * conj (g x)).re = _ + rw [mul_comm] + rw [hi] at hn + convert hn using 1 + ring + +lemma complex_path_normFirst_hasDerivAt {g g' : ℝ → ℂ} {b c : ℂ} {x : ℝ} + (hg : HasDerivAt g b x) (hg' : HasDerivAt g' c x) (hb : g' x = b) + (hne : g x ≠ 0) : + HasDerivAt (fun t => (conj (g t) * g' t).re / ‖g t‖) + (((conj b * b + conj (g x) * c).re) / ‖g x‖ - + ((conj (g x) * b).re) ^ 2 / ‖g x‖ ^ 3) x := by + have hconj : HasDerivAt (fun t => conj (g t)) (conj b) x := + Complex.conjCLE.hasFDerivAt.comp_hasDerivAt x hg + have htop := Complex.reCLM.hasFDerivAt.comp_hasDerivAt x (hconj.mul hg') + have hnorm := complex_path_norm_hasDerivAt hg hne + have he := htop.div hnorm (norm_ne_zero_iff.mpr hne) + have he' : HasDerivAt (fun t => (conj (g t) * g' t).re / ‖g t‖) + (((conj b * b + conj (g x) * c).re * ‖g x‖ - + (conj (g x) * b).re * ((conj (g x) * b).re / ‖g x‖)) / ‖g x‖ ^ 2) x := by + simpa only [Function.comp_apply, Complex.reCLM_apply, Pi.mul_apply, Pi.div_apply, hb] using! he + convert he' using 1 + field_simp + +lemma complex_normSecond_at_one (b c : ℂ) : + ((conj b * b + conj (1 : ℂ) * c).re) / ‖(1 : ℂ)‖ - + ((conj (1 : ℂ) * b).re) ^ 2 / ‖(1 : ℂ)‖ ^ 3 = c.re + b.im ^ 2 := by + simp only [map_one, one_mul, norm_one, div_one, one_pow, add_re, mul_re, conj_re, conj_im] + ring + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +lemma compactFamily_hasDerivAt_integral {X E : Type*} [TopologicalSpace X] + [CompactSpace X] [SecondCountableTopology X] [MeasurableSpace X] [BorelSpace X] + [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] + (μ : Measure X) [IsFiniteMeasure μ] {F G : ℝ → X → E} + {s : Set ℝ} {t₀ : ℝ} (hs : IsCompact s) (ht : s ∈ 𝓝 t₀) + (hF : Continuous (fun p : X × s => F p.2 p.1)) + (hG : Continuous (fun p : X × s => G p.2 p.1)) + (hd : ∀ x t, t ∈ s → HasDerivAt (fun t => F t x) (G t x) t) : + HasDerivAt (fun t => ∫ x, F t x ∂μ) (∫ x, G t₀ x ∂μ) t₀ := by + have : CompactSpace s := isCompact_iff_compactSpace.mp hs + have ht₀ : t₀ ∈ s := mem_of_mem_nhds ht + have hcF (t : ℝ) (hts : t ∈ s) : Continuous (F t) := + hF.comp (continuous_id.prodMk (continuous_const (y := (⟨t, hts⟩ : s)))) + have hcG (t : ℝ) (hts : t ∈ s) : Continuous (G t) := + hG.comp (continuous_id.prodMk (continuous_const (y := (⟨t, hts⟩ : s)))) + obtain ⟨C, hC⟩ := isCompact_range hG |>.isBounded.exists_norm_le + apply (hasDerivAt_integral_of_dominated_loc_of_deriv_le ht + (F := F) (F' := G) (bound := fun _ => C) ?_ ?_ ?_ ?_ (integrable_const C) ?_).2 + · filter_upwards [ht] with t hts using (hcF t hts).aestronglyMeasurable + · exact (hcF t₀ ht₀).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + · exact (hcG t₀ ht₀).aestronglyMeasurable + · exact Eventually.of_forall fun x t hts => hC _ ⟨(x, ⟨t, hts⟩), rfl⟩ + · exact Eventually.of_forall hd + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/FiberSum.lean b/lean/OAI/Analysis/StrictMeans/FiberSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a3a21f7d81d7b7b8d5cc344daeca75a32b7e069 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/FiberSum.lean @@ -0,0 +1,70 @@ +import OAI.Analysis.StrictMeans.PairingCovariance + +namespace OAI + +section +open Set MeasureTheory +open scoped ENNReal +namespace StrictInverseFirstPower +noncomputable section + +def fiberSum {X Y : Type*} (G : X → Y) (s : Set X) (h : X → ℝ≥0∞) (ξ : Y) : ℝ≥0∞ := + ∑' z : {z | z ∈ s ∧ G z = ξ}, h z + +lemma fiberSum_le_of_injection {X Y : Type*} {G : X → Y} {s t : Set X} + {h q : X → ℝ≥0∞} (R : s → X) (hR : Function.Injective R) + (hRt : ∀ z, R z ∈ t) (hG : ∀ z, G (R z) = G z) + (hw : ∀ z : s, h z ≤ q (R z)) (ξ : Y) : + fiberSum G s h ξ ≤ fiberSum G t q ξ := by + let r : {z | z ∈ s ∧ G z = ξ} → {z | z ∈ t ∧ G z = ξ} := + fun z => ⟨R ⟨z.1,z.2.1⟩,hRt _,(hG _).trans z.2.2⟩ + have hr : Function.Injective r := by + intro z w he + apply Subtype.ext + have e : (⟨z.val,z.property.1⟩ : s) = ⟨w.val,w.property.1⟩ := + hR (congrArg Subtype.val he) + exact congrArg (fun a : s => (a : X)) e + exact Summable.tsum_le_tsum_of_inj r hr (fun _ _ => bot_le) (fun z => hw ⟨z.1,z.2.1⟩) + ENNReal.summable ENNReal.summable + +lemma fiberSum_iUnion {X Y I : Type*} (G : X → Y) (s : I → Set X) (h : X → ℝ≥0∞) + (hd : Pairwise (fun i j => Disjoint (s i) (s j))) (ξ : Y) : + fiberSum G (⋃ i, s i) h ξ = ∑' i, fiberSum G (s i) h ξ := by + unfold fiberSum + have he : {z | z ∈ ⋃ i, s i ∧ G z = ξ} = ⋃ i, {z | z ∈ s i ∧ G z = ξ} := by + ext z + simp only [mem_ofPred_eq,mem_iUnion] + tauto + rw [he] + apply ENNReal.tsum_biUnion + intro i _ j _ hij + exact (hd hij).mono (fun _ hz => hz.1) (fun _ hz => hz.1) + +lemma fiberSum_eq_single {X Y : Type*} {G : X → Y} {s : Set X} {h : X → ℝ≥0∞} + (hi : InjOn G s) {z : X} (hz : z ∈ s) : fiberSum G s h (G z) = h z := by + unfold fiberSum + apply tsum_eq_single (⟨z,hz,rfl⟩ : {w | w ∈ s ∧ G w = G z}) + intro w hw + exact False.elim (hw (Subtype.ext (hi w.2.1 hz w.2.2))) + +lemma fiberSum_eq_zero_of_not_mem_image {X Y : Type*} {G : X → Y} {s : Set X} + {h : X → ℝ≥0∞} {ξ : Y} (hξ : ξ ∉ G '' s) : fiberSum G s h ξ = 0 := by + have : IsEmpty {z | z ∈ s ∧ G z = ξ} := ⟨fun z => hξ ⟨z,z.2.1,z.2.2⟩⟩ + simp [fiberSum] + +lemma fiberSum_eq_indicator_inverse {X Y : Type*} {G : X → Y} {s : Set X} + (hi : InjOn G s) (h : X → ℝ≥0∞) (φ : Y → X) (hφ : ∀ z ∈ s, φ (G z) = z) : + fiberSum G s h = (G '' s).indicator (fun ξ => h (φ ξ)) := by + classical + funext ξ + by_cases hξ : ξ ∈ G '' s + · obtain ⟨z,hz,rfl⟩ := hξ + rw [fiberSum_eq_single hi hz,indicator_of_mem (mem_image_of_mem G hz),hφ z hz] + · rw [fiberSum_eq_zero_of_not_mem_image hξ,indicator_of_notMem hξ] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/FiniteEuler.lean b/lean/OAI/Analysis/StrictMeans/FiniteEuler.lean new file mode 100644 index 0000000000000000000000000000000000000000..c84d7fef1730ef5f8ec1a906cc827ef58bc48876 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/FiniteEuler.lean @@ -0,0 +1,32 @@ +import OAI.Analysis.StrictMeans.GridSupport + +namespace OAI + +section +namespace StrictInverseFirstPower +open LinearMap Module + +lemma finite_euler_inequality {K V₀ V₁ V₂ : Type*} [Field K] + [AddCommGroup V₀] [Module K V₀] [FiniteDimensional K V₀] + [AddCommGroup V₁] [Module K V₁] [FiniteDimensional K V₁] + [AddCommGroup V₂] [Module K V₂] [FiniteDimensional K V₂] + (d₁ : V₁ →ₗ[K] V₀) (d₂ : V₂ →ₗ[K] V₁) (aug : V₀ →ₗ[K] K) + (hinj : Function.Injective d₂) (hexact : d₂.range = d₁.ker) + (haug : aug ∘ₗ d₁ = 0) (hne : aug ≠ 0) : + finrank K V₁ + 1 ≤ finrank K V₀ + finrank K V₂ := by + have hr := d₁.finrank_range_add_finrank_ker + have hd : finrank K d₁.ker = finrank K V₂ := by + rw [← hexact] + exact LinearMap.finrank_range_of_inj hinj + have hle : d₁.range ≤ aug.ker := LinearMap.range_le_ker_iff.mpr haug + have hh : aug.ker < ⊤ := lt_top_iff_ne_top.mpr (by simpa using hne) + have ht := Submodule.finrank_lt_finrank_of_lt hh + have hm := Submodule.finrank_mono hle + simp only [finrank_top] at ht + omega + +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GenericTargets.lean b/lean/OAI/Analysis/StrictMeans/GenericTargets.lean new file mode 100644 index 0000000000000000000000000000000000000000..de2f0888e3e62e4a196ddddcb5491fcec6a0f8d2 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GenericTargets.lean @@ -0,0 +1,384 @@ +import OAI.Analysis.StrictMeans.RegularTargets + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter MeasureTheory Complex +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +namespace StrictInverseFirstPower +noncomputable section + +lemma real_complex_log_norm_fderiv {H : ℂ → ℂ} {ξ : ℂ} + (hH : DifferentiableAt ℝ H ξ) (hne : H ξ ≠ 0) (v : ℂ) : + fderiv ℝ (fun η => Real.log ‖H η‖) ξ v = ((fderiv ℝ H ξ v) / H ξ).re := by + have hh := ((hH.hasFDerivAt.norm_sq).log + (pow_ne_zero 2 (norm_ne_zero_iff.mpr hne))).const_mul (1/2) + have he : (fun η => (1/2:ℝ) * Real.log (‖H η‖^2)) = (fun η => Real.log ‖H η‖) := by + funext η + rw [Real.log_pow] + ring + rw [he] at hh + rw [hh.fderiv] + simp only [smul_apply, ContinuousLinearMap.comp_apply, smul_eq_mul, innerSL_apply_apply] + simp only [Complex.inner, Complex.mul_re, Complex.div_re, Complex.conj_re, Complex.conj_im] + rw [← Complex.normSq_eq_norm_sq] + field_simp + ring + +lemma logPotential_branch_contDiffAt {k : ℝ} {F Z : ℂ → ℂ} {ξ : ℂ} + (hF : AnalyticAt ℂ F (Z ξ)) (hZ : ContDiffAt ℝ 1 Z ξ) + (hy : 0 < (Z ξ).im) (hp : F (Z ξ) ≠ ξ) : + ContDiffAt ℝ 1 (fun η => logPotential k F η (Z η)) ξ := by + have hh := (hF.restrictScalars (𝕜 := ℝ)).contDiffAt (n := 1) + exact (contDiffAt_const.mul ((Complex.imCLM.contDiff.contDiffAt.comp ξ hZ).log hy.ne')).sub + ((((hh.comp ξ hZ).sub contDiffAt_id).norm ℝ (sub_ne_zero.mpr hp)).log + (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hp))) + +lemma critical_branch_derivative {k : ℝ} {F Z : ℂ → ℂ} {ξ : ℂ} + (hk : k ≠ 0) (hy : 0 < (Z ξ).im) (hF : DifferentiableAt ℂ F (Z ξ)) + (hp : F (Z ξ) ≠ ξ) (hZ : DifferentiableAt ℝ Z ξ) + (hG : criticalMap k F (Z ξ) = ξ) (v : ℂ) : + fderiv ℝ (fun η => logPotential k F η (Z η)) ξ v = (v / (F (Z ξ)-ξ)).re := by + have h1 := (((Complex.imCLM.hasFDerivAt (x := Z ξ)).comp ξ hZ.hasFDerivAt).log hy.ne').const_mul k + change HasFDerivAt (fun η => k * Real.log (Z η).im) + (k • (Z ξ).im⁻¹ • (Complex.imCLM.comp (fderiv ℝ Z ξ))) ξ at h1 + have hpr : DifferentiableAt ℝ (fun η => F (Z η)-η) ξ := + ((hF.restrictScalars (𝕜 := ℝ)).comp ξ hZ).sub differentiableAt_id + have h2 := (hpr.norm ℝ (sub_ne_zero.mpr hp)).log + (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hp)) + have hcomp : fderiv ℝ (fun η => F (Z η)-η) ξ v = + deriv F (Z ξ) * fderiv ℝ Z ξ v - v := by + have hd := ((hF.hasDerivAt.complexToReal_fderiv).comp ξ hZ.hasFDerivAt).sub (hasFDerivAt_id ξ) + change (fderiv ℝ (F ∘ Z - id) ξ) v = _ + rw [hd.fderiv] + simp only [sub_apply, ContinuousLinearMap.comp_apply, one_apply_eq_self, + ContinuousLinearMap.id_apply, smul_apply, smul_eq_mul] + change (fderiv ℝ ((fun η => k * Real.log (Z η).im) - + (fun η => Real.log ‖F (Z η)-η‖)) ξ) v = _ + rw [fderiv_sub h1.differentiableAt h2, sub_apply, h1.fderiv, + real_complex_log_norm_fderiv hpr (sub_ne_zero.mpr hp), hcomp] + simp only [smul_apply, smul_eq_mul, ContinuousLinearMap.comp_apply, Complex.imCLM_apply] + have hz := congrArg (fun L : ℂ →L[ℝ] ℝ => L (fderiv ℝ Z ξ v)) + ((logPotential_critical_iff hk hy hF hp).mpr hG) + rw [logPotential_fderiv_apply hy hF hp, zero_apply] at hz + have he : (deriv F (Z ξ) * fderiv ℝ Z ξ v - v) / (F (Z ξ)-ξ) = + (deriv F (Z ξ) / (F (Z ξ)-ξ)) * fderiv ℝ Z ξ v - v/(F (Z ξ)-ξ) := by ring + rw [he, Complex.sub_re] + linear_combination hz + +lemma critical_branch_difference_nz {k : ℝ} {F Z W : ℂ → ℂ} {ξ : ℂ} + (hk : k ≠ 0) (hZy : 0 < (Z ξ).im) (hWy : 0 < (W ξ).im) + (hFZ : DifferentiableAt ℂ F (Z ξ)) (hFW : DifferentiableAt ℂ F (W ξ)) + (hpZ : F (Z ξ) ≠ ξ) (hpW : F (W ξ) ≠ ξ) + (hZ : DifferentiableAt ℝ Z ξ) (hW : DifferentiableAt ℝ W ξ) + (hGZ : criticalMap k F (Z ξ) = ξ) (hGW : criticalMap k F (W ξ) = ξ) + (hne : F (Z ξ) ≠ F (W ξ)) : + fderiv ℝ (fun η => logPotential k F η (Z η) - logPotential k F η (W η)) ξ ≠ 0 := by + have hdZ : DifferentiableAt ℝ (fun η => logPotential k F η (Z η)) ξ := by + exact (((Complex.imCLM.differentiableAt.comp ξ hZ).log hZy.ne').const_mul k).sub + (((((hFZ.restrictScalars (𝕜 := ℝ)).comp ξ hZ).sub differentiableAt_id).norm ℝ + (sub_ne_zero.mpr hpZ)).log (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hpZ))) + have hdW : DifferentiableAt ℝ (fun η => logPotential k F η (W η)) ξ := by + exact (((Complex.imCLM.differentiableAt.comp ξ hW).log hWy.ne').const_mul k).sub + (((((hFW.restrictScalars (𝕜 := ℝ)).comp ξ hW).sub differentiableAt_id).norm ℝ + (sub_ne_zero.mpr hpW)).log (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hpW))) + intro hh + have he (v : ℂ) : (v / (F (Z ξ)-ξ)).re = (v/(F (W ξ)-ξ)).re := by + have h := congrArg (fun L : ℂ →L[ℝ] ℝ => L v) hh + change (fderiv ℝ ((fun η => logPotential k F η (Z η)) - + (fun η => logPotential k F η (W η))) ξ) v = (0 : ℂ →L[ℝ] ℝ) v at h + rw [fderiv_sub hdZ hdW, sub_apply, critical_branch_derivative hk hZy hFZ hpZ hZ hGZ, + critical_branch_derivative hk hWy hFW hpW hW hGW, zero_apply] at h + exact sub_eq_zero.mp h + have hc : (F (Z ξ)-ξ)⁻¹ = (F (W ξ)-ξ)⁻¹ := by + apply Complex.ext + · simpa only [one_div] using he 1 + · have ht := he I + simp only [div_eq_mul_inv, I_mul_re] at ht + linarith + have hc' := inv_injective hc + exact hne (by simpa using congrArg (fun w : ℂ => w + ξ) hc') + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +namespace StrictInverseFirstPower +noncomputable section + +lemma singular_values_null {G : ℂ → ℂ} {U : Set ℂ} + (hG : ∀ z ∈ U, DifferentiableAt ℝ G z) : + volume (G '' {z ∈ U | (fderiv ℝ G z).det = 0}) = 0 := by + apply MeasureTheory.addHaar_image_eq_zero_of_det_fderivWithin_eq_zero volume + (f' := fderiv ℝ G) + · intro z hz + exact (hG z hz.1).hasFDerivAt.hasFDerivWithinAt + · intro z hz + exact hz.2 + +lemma criticalMap_contDiffOn (k : ℝ) (f : DiskFamily) : + ContDiffOn ℝ 1 (criticalMap k (halfPlaneFunction f)) {z : ℂ | 0 < z.im} := by + intro z hz + exact ((criticalMap_contDiffAt k f hz).of_le (by simp)).contDiffWithinAt + +lemma logPotential_eq_log_criticalHeight {k : ℝ} (f : DiskFamily) {ξ z : ℂ} + (hk : 0 < k) (hz : 0 < z.im) (hg : criticalMap k (halfPlaneFunction f) z = ξ) : + logPotential k (halfPlaneFunction f) ξ z = Real.log (criticalHeight k (halfPlaneFunction f) z) := by + have hp : halfPlaneFunction f z ≠ ξ := by + intro he + exact criticalMap_ne_image hk.ne' hz (halfPlaneFunction_deriv_ne_zero f hz) (hg.trans he.symm) + rw [← criticalHeight_value hk hz hg, Real.log_div + (Real.rpow_pos_of_pos hz k).ne' (norm_ne_zero_iff.mpr (sub_ne_zero.mpr hp)), + Real.log_rpow hz] + unfold logPotential + rw [mul_comm k] + +lemma critical_inverse_chart_data {k : ℝ} (hk : k ≠ 0) (f : DiskFamily) + (e : OpenPartialHomeomorph ℂ ℂ) (he : (e : ℂ → ℂ) = criticalMap k (halfPlaneFunction f)) + (hs : e.source ⊆ {z ∈ {z : ℂ | 0 < z.im} | (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det ≠ 0}) + {ξ : ℂ} (hξ : ξ ∈ e.target) : + 0 < (e.symm ξ).im ∧ halfPlaneFunction f (e.symm ξ) ≠ ξ ∧ + criticalMap k (halfPlaneFunction f) (e.symm ξ) = ξ := by + have hy := (hs (e.map_target hξ)).1 + have hg : criticalMap k (halfPlaneFunction f) (e.symm ξ) = ξ := by + rw [← he] + exact e.right_inv hξ + refine ⟨hy,?_,hg⟩ + intro hp + exact criticalMap_ne_image hk hy (halfPlaneFunction_deriv_ne_zero f hy) (hg.trans hp.symm) + +lemma critical_inverse_branch_contDiffOn {k : ℝ} (hk : k ≠ 0) (f : DiskFamily) + (e : OpenPartialHomeomorph ℂ ℂ) (he : (e : ℂ → ℂ) = criticalMap k (halfPlaneFunction f)) + (hs : e.source ⊆ {z ∈ {z : ℂ | 0 < z.im} | (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det ≠ 0}) + (hd : ContDiffOn ℝ 1 e.symm e.target) : + ContDiffOn ℝ 1 (fun ξ => logPotential k (halfPlaneFunction f) ξ (e.symm ξ)) e.target := by + intro ξ hξ + obtain ⟨hy,hp,_⟩ := critical_inverse_chart_data hk f e he hs hξ + exact (logPotential_branch_contDiffAt + ((halfPlaneFunction_differentiableOn f).analyticAt (isOpen_halfPlane.mem_nhds hy)) + (hd.contDiffAt (e.open_target.mem_nhds hξ)) hy hp).contDiffWithinAt + +lemma inverse_chart_pair_ties_null {k : ℝ} (hk : k ≠ 0) (f : DiskFamily) + (e d : OpenPartialHomeomorph ℂ ℂ) + (he : (e : ℂ → ℂ) = criticalMap k (halfPlaneFunction f)) + (hd : (d : ℂ → ℂ) = criticalMap k (halfPlaneFunction f)) + (heS : e.source ⊆ {z ∈ {z : ℂ | 0 < z.im} | (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det ≠ 0}) + (hdS : d.source ⊆ {z ∈ {z : ℂ | 0 < z.im} | (fderiv ℝ (criticalMap k (halfPlaneFunction f)) z).det ≠ 0}) + (heD : ContDiffOn ℝ 1 e.symm e.target) (hdD : ContDiffOn ℝ 1 d.symm d.target) : + volume {ξ | ξ ∈ e.target ∧ ξ ∈ d.target ∧ e.symm ξ ≠ d.symm ξ ∧ + logPotential k (halfPlaneFunction f) ξ (e.symm ξ) = + logPotential k (halfPlaneFunction f) ξ (d.symm ξ)} = 0 := by + let U := e.target ∩ d.target + let V := {ξ ∈ U | e.symm ξ ≠ d.symm ξ} + let φ := fun ξ => logPotential k (halfPlaneFunction f) ξ (e.symm ξ) - + logPotential k (halfPlaneFunction f) ξ (d.symm ξ) + have hU : IsOpen U := e.open_target.inter d.open_target + have hV : IsOpen V := by + have ht := (e.continuousOn_symm.mono inter_subset_left |>.sub + (d.continuousOn_symm.mono inter_subset_right)).isOpen_inter_preimage hU + (isOpen_compl_singleton (x := (0:ℂ))) + convert ht using 1 + ext ξ + simp only [V,U, mem_inter_iff, mem_ofPred_eq, + mem_preimage, mem_compl_iff, mem_singleton_iff, Pi.sub_apply, sub_ne_zero] + have hφ : ContDiffOn ℝ 1 φ V := + ((critical_inverse_branch_contDiffOn hk f e he heS heD).mono + (fun _ hx => hx.1.1)).sub + ((critical_inverse_branch_contDiffOn hk f d hd hdS hdD).mono (fun _ hx => hx.1.2)) + have hn (ξ : ℂ) (hξ : ξ ∈ V) : fderiv ℝ φ ξ ≠ 0 := by + obtain ⟨hy,hp,hg⟩ := critical_inverse_chart_data hk f e he heS hξ.1.1 + obtain ⟨hy',hp',hg'⟩ := critical_inverse_chart_data hk f d hd hdS hξ.1.2 + exact critical_branch_difference_nz hk hy hy' + ((halfPlaneFunction_differentiableOn f).differentiableAt (isOpen_halfPlane.mem_nhds hy)) + ((halfPlaneFunction_differentiableOn f).differentiableAt (isOpen_halfPlane.mem_nhds hy')) hp hp' + ((heD.contDiffAt (e.open_target.mem_nhds hξ.1.1)).differentiableAt one_ne_zero) + ((hdD.contDiffAt (d.open_target.mem_nhds hξ.1.2)).differentiableAt one_ne_zero) hg hg' + (fun hh => hξ.2 (halfPlaneFunction_injOn f hy hy' hh)) + apply measure_mono_null (t := {ξ ∈ V | φ ξ = 0 ∧ fderiv ℝ φ ξ ≠ 0}) _ + (complex_regular_level_null hV hφ) + intro ξ hξ + have hv : ξ ∈ V := ⟨⟨hξ.1,hξ.2.1⟩,hξ.2.2.1⟩ + exact ⟨hv,sub_eq_zero.mpr hξ.2.2.2,hn ξ hv⟩ + +theorem ae_regular_distinct_critical_heights {k : ℝ} (hk : 0 < k) (f : DiskFamily) : + ∀ᵐ ξ : ℂ, + (∀ z : UpperHalfPlane, criticalMap k (halfPlaneFunction f) z = ξ → + jacobianExpression k (halfPlaneFunction f) z ≠ 0) ∧ + (∀ z w : UpperHalfPlane, criticalMap k (halfPlaneFunction f) z = ξ → + criticalMap k (halfPlaneFunction f) w = ξ → + criticalHeight k (halfPlaneFunction f) z = criticalHeight k (halfPlaneFunction f) w → z = w) := by + classical + let G := criticalMap k (halfPlaneFunction f) + let H := {z : ℂ | 0 < z.im} + have hc : ContDiffOn ℝ 1 G H := criticalMap_contDiffOn k f + have hs := singular_values_null (U := H) (G := G) + (fun z hz => (hc.contDiffAt (isOpen_halfPlane.mem_nhds hz)).differentiableAt one_ne_zero) + have ha : ∀ᵐ ξ : ℂ, ξ ∉ G '' {z ∈ H | (fderiv ℝ G z).det = 0} := by + apply ae_iff.mpr + simpa only [not_not, ofPred_mem_eq] using hs + obtain ⟨C,hC,hcharts,hcover⟩ := countable_regular_inverse_charts isOpen_halfPlane hc + have : Countable C := hC.to_subtype + have ht : ∀ᵐ ξ : ℂ, ∀ e d : C, + ¬ (ξ ∈ e.1.target ∧ ξ ∈ d.1.target ∧ e.1.symm ξ ≠ d.1.symm ξ ∧ + logPotential k (halfPlaneFunction f) ξ (e.1.symm ξ) = + logPotential k (halfPlaneFunction f) ξ (d.1.symm ξ)) := by + apply ae_all_iff.mpr + intro e + apply ae_all_iff.mpr + intro d + apply ae_iff.mpr + simpa only [not_not] using inverse_chart_pair_ties_null hk.ne' f e.1 d.1 + (hcharts e.1 e.2).1 (hcharts d.1 d.2).1 + (hcharts e.1 e.2).2.1 (hcharts d.1 d.2).2.1 + (hcharts e.1 e.2).2.2 (hcharts d.1 d.2).2.2 + filter_upwards [ha,ht] with ξ hξ htξ + have hreg (z : ℂ) (hz : z ∈ H) (hg : G z = ξ) : (fderiv ℝ G z).det ≠ 0 := by + intro hh + exact hξ ⟨z,⟨hz,hh⟩,hg⟩ + refine ⟨?_,?_⟩ + · intro z hz + exact fun hJ => hreg z z.im_pos hz ((jacobianExpression_zero_iff k hk.ne' f z.im_pos).mp hJ) + · intro z w hz hw hv + by_contra hne + have hzR : (z:ℂ) ∈ {z ∈ H | (fderiv ℝ G z).det ≠ 0} := ⟨z.im_pos,hreg z z.im_pos hz⟩ + have hwR : (w:ℂ) ∈ {z ∈ H | (fderiv ℝ G z).det ≠ 0} := ⟨w.im_pos,hreg w w.im_pos hw⟩ + obtain ⟨e,he,hze⟩ := mem_iUnion₂.mp (hcover hzR) + obtain ⟨d,hd,hwd⟩ := mem_iUnion₂.mp (hcover hwR) + have heξ : e z = ξ := by rw [(hcharts e he).1]; exact hz + have hdξ : d w = ξ := by rw [(hcharts d hd).1]; exact hw + have hξe : ξ ∈ e.target := heξ ▸ e.map_source hze + have hξd : ξ ∈ d.target := hdξ ▸ d.map_source hwd + have hzeq : e.symm ξ = z := heξ ▸ e.left_inv hze + have hwdeq : d.symm ξ = w := hdξ ▸ d.left_inv hwd + apply htξ ⟨e,he⟩ ⟨d,hd⟩ + refine ⟨hξe,hξd,?_,?_⟩ + · rw [hzeq,hwdeq] + exact fun hh => hne (UpperHalfPlane.ext hh) + · rw [hzeq,hwdeq, logPotential_eq_log_criticalHeight f hk z.im_pos hz, + logPotential_eq_log_criticalHeight f hk w.im_pos hw,hv] + +theorem affine_law_ae_good_pairs (μ : ProbabilityMeasure DiskFamily) (β : ℝ) + (hβ : 0 ≤ β) + (hlaw : ∀ (z : UpperHalfPlane) (φ : DiskFamily → ℝ≥0∞), Measurable φ → + (∫⁻ f, (‖halfPlaneQ f z‖₊ : ℝ≥0∞) * φ (rebase f z) ∂(μ : Measure DiskFamily)) = + ENNReal.ofReal (z.im ^ (-β)) * ∫⁻ f, φ f ∂(μ : Measure DiskFamily)) : + ∀ᵐ f ∂(μ : Measure DiskFamily), ∀ᵐ ξ : ℂ, GoodPair ((β+2)/3) (f,ξ) := by + filter_upwards [weightedAreaTail_ae_finite μ β hlaw] with f hf + filter_upwards [ae_compact_positive_superlevels f β hβ hf,ae_regular_distinct_critical_heights (by linarith : 0 < (β+2)/3) f] + with ξ hc hr + exact ⟨hc,hr⟩ + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GreenIdentity.lean b/lean/OAI/Analysis/StrictMeans/GreenIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..14c132b6a7d601b34a69167cdddbd52cd7a7ad25 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GreenIdentity.lean @@ -0,0 +1,382 @@ +import OAI.Analysis.StrictMeans.InfinityEscape + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function MeasureTheory +open scoped Topology +open Set Filter +open scoped Topology +open Set Filter MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology +open Set Filter Function MeasureTheory +open scoped Topology ENNReal NNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal + +open Set Filter Metric MeasureTheory +open scoped Topology ContDiff +namespace StrictInverseFirstPower +noncomputable section + +lemma compact_integral_deriv_zero {g : ℝ → ℝ} (hg : ContDiff ℝ 1 g) + (hc : HasCompactSupport g) : ∫ x, deriv g x = 0 := by + exact integral_eq_zero_of_hasDerivAt_of_integrable + (fun x => (hg.differentiable one_ne_zero x).hasDerivAt) + ((hg.continuous_deriv le_rfl).integrable_of_hasCompactSupport hc.deriv) + (hg.continuous.integrable_of_hasCompactSupport hc) + +lemma compact_second_deriv_green {g : ℝ → ℝ} (hg : ContDiff ℝ 2 g) + (hc : HasCompactSupport g) (s : ℝ) : + (∫ t in Ioi s, (t - s) * deriv (deriv g) t) = g s := by + let H : ℝ → ℝ := fun t => (t - s) * deriv g t - g t + have h1 : ContDiff ℝ 1 (deriv g) := hg.deriv' + have hH : ContDiff ℝ 1 H := + ((contDiff_id.sub contDiff_const).mul h1).sub (hg.of_le (by norm_num)) + have hcH : HasCompactSupport H := (hc.deriv.mul_left).sub hc + have hder (t : ℝ) : deriv H t = (t - s) * deriv (deriv g) t := by + have h := (((hasDerivAt_id t).sub_const s).mul + ((h1.differentiable one_ne_zero t).hasDerivAt)).sub + ((hg.differentiable (by norm_num) t).hasDerivAt) + have he : ((fun x => id x - s) * deriv g - g) = H := rfl + rw [he] at h + rw [h.deriv] + simp + simpa only [H, hder, sub_self, zero_mul, zero_sub, neg_neg] using + hcH.integral_Ioi_deriv_eq hH s + +def realPlanePartial (v : ℝ × ℝ) (g : ℝ × ℝ → ℝ) (p : ℝ × ℝ) : ℝ := + fderiv ℝ g p v + +lemma contDiff_realPlanePartial {g : ℝ × ℝ → ℝ} (hg : ContDiff ℝ ∞ g) (v : ℝ × ℝ) : + ContDiff ℝ ∞ (realPlanePartial v g) := by + exact (hg.fderiv_right (by simp)).clm_apply contDiff_const + +lemma compact_realPlanePartial {g : ℝ × ℝ → ℝ} (hc : HasCompactSupport g) (v : ℝ × ℝ) : + HasCompactSupport (realPlanePartial v g) := hc.fderiv_apply ℝ v + +lemma deriv_vertical_line {g : ℝ × ℝ → ℝ} {x y : ℝ} (hg : DifferentiableAt ℝ g (x,y)) : + deriv (fun t => g (x,t)) y = realPlanePartial (0,1) g (x,y) := by + exact (hg.hasFDerivAt.comp_hasDerivAt y + ((hasDerivAt_const y x).prodMk (hasDerivAt_id y))).deriv + +lemma deriv_horizontal_line {g : ℝ × ℝ → ℝ} {x y : ℝ} (hg : DifferentiableAt ℝ g (x,y)) : + deriv (fun t => g (t,y)) x = realPlanePartial (1,0) g (x,y) := by + exact (hg.hasFDerivAt.comp_hasDerivAt x + ((hasDerivAt_id x).prodMk (hasDerivAt_const x y))).deriv + +lemma compact_vertical_line {g : ℝ × ℝ → ℝ} (hc : HasCompactSupport g) (x : ℝ) : + HasCompactSupport (fun y => g (x,y)) := by + apply hc.comp_isClosedEmbedding + exact ⟨isEmbedding_prodMkRight x, (isClosedMap_prodMk_left x).isClosed_range⟩ + +lemma compact_horizontal_line {g : ℝ × ℝ → ℝ} (hc : HasCompactSupport g) (y : ℝ) : + HasCompactSupport (fun x => g (x,y)) := by + apply hc.comp_isClosedEmbedding + exact ⟨isEmbedding_prodMkLeft y, (isClosedMap_prodMk_right y).isClosed_range⟩ + +lemma compact_plane_second_horizontal_zero {g : ℝ × ℝ → ℝ} (hg : ContDiff ℝ ∞ g) + (hc : HasCompactSupport g) (y : ℝ) : + (∫ x, realPlanePartial (1,0) (realPlanePartial (1,0) g) (x,y)) = 0 := by + have hdx := contDiff_realPlanePartial hg (1,0) + have hL : ContDiff ℝ 2 (fun x => g (x,y)) := + contDiff_infty.mp (hg.comp (contDiff_id.prodMk contDiff_const)) 2 + have hL' : deriv (fun x => g (x,y)) = fun x => realPlanePartial (1,0) g (x,y) := by + funext x + exact deriv_horizontal_line (hg.differentiable (by simp) (x,y)) + have hL'' : deriv (deriv (fun x => g (x,y))) = fun x => realPlanePartial (1,0) (realPlanePartial (1,0) g) (x,y) := by + rw [hL'] + funext x + exact deriv_horizontal_line (hdx.differentiable (by simp) (x,y)) + simpa only [hL''] using compact_integral_deriv_zero hL.deriv' + (compact_horizontal_line hc y).deriv + +lemma compact_plane_second_vertical_green {g : ℝ × ℝ → ℝ} (hg : ContDiff ℝ ∞ g) + (hc : HasCompactSupport g) (x s : ℝ) : + (∫ y in Ioi s, (y - s) * realPlanePartial (0,1) (realPlanePartial (0,1) g) (x,y)) = g (x,s) := by + have hdy := contDiff_realPlanePartial hg (0,1) + have hL : ContDiff ℝ 2 (fun y => g (x,y)) := + contDiff_infty.mp (hg.comp (contDiff_const.prodMk contDiff_id)) 2 + have hL' : deriv (fun y => g (x,y)) = fun y => realPlanePartial (0,1) g (x,y) := by + funext y + exact deriv_vertical_line (hg.differentiable (by simp) (x,y)) + have hL'' : deriv (deriv (fun y => g (x,y))) = fun y => realPlanePartial (0,1) (realPlanePartial (0,1) g) (x,y) := by + rw [hL'] + funext y + exact deriv_vertical_line (hdy.differentiable (by simp) (x,y)) + simpa only [hL''] using compact_second_deriv_green hL (compact_vertical_line hc x) s + +lemma compact_plane_weight_integrable {D : ℝ × ℝ → ℝ} (hD : Continuous D) + (hc : HasCompactSupport D) (s : ℝ) : + Integrable (fun p : ℝ × ℝ => (p.2 - s) * D p) + (volume.prod (volume.restrict (Ioi s))) := + ((continuous_snd.sub continuous_const).mul hD).integrable_of_hasCompactSupport hc.mul_left + +lemma compact_plane_horizontal_integral_zero {X : ℝ × ℝ → ℝ} {s : ℝ} + (hX : Continuous X) (hcX : HasCompactSupport X) + (hxx : ∀ y : ℝ, (∫ x, X (x,y)) = 0) : + (∫ p : ℝ × ℝ, (p.2-s) * X p ∂(volume.prod (volume.restrict (Ioi s)))) = 0 := by + have hi := compact_plane_weight_integrable hX hcX s + rw [integral_prod _ hi] + have he : (∫ x : ℝ, ∫ y in Ioi s, (y-s)*X (x,y)) = + ∫ y in Ioi s, ∫ x : ℝ, (y-s)*X (x,y) := + integral_integral_swap_of_hasCompactSupport + ((continuous_snd.sub continuous_const).mul hX) hcX.mul_left + rw [he] + simp only [integral_const_mul, hxx, mul_zero, integral_zero] + +lemma compact_plane_green_assemble {X Y : ℝ × ℝ → ℝ} {H : ℝ → ℝ} {s : ℝ} + (hX : Continuous X) (hcX : HasCompactSupport X) + (hY : Continuous Y) (hcY : HasCompactSupport Y) + (hxx : ∀ y : ℝ, (∫ x, X (x,y)) = 0) + (hyy : ∀ x : ℝ, (∫ y in Ioi s, (y - s) * Y (x,y)) = H x) : + (∫ x, H x) = ∫ p : ℝ × ℝ, (p.2 - s) * (X p + Y p) + ∂(volume.prod (volume.restrict (Ioi s))) := by + have hiX := compact_plane_weight_integrable hX hcX s + have hiY := compact_plane_weight_integrable hY hcY s + have he : (fun p : ℝ × ℝ => (p.2-s)*(X p+Y p)) = + (fun p => (p.2-s)*X p + (p.2-s)*Y p) := by + funext p + exact mul_add _ _ _ + rw [he, integral_add hiX hiY, compact_plane_horizontal_integral_zero hX hcX hxx, + zero_add, integral_prod _ hiY] + simp only [hyy] + +lemma compact_plane_horizontal_green {g : ℝ × ℝ → ℝ} (hg : ContDiff ℝ ∞ g) + (hc : HasCompactSupport g) (s : ℝ) : + (∫ x, g (x,s)) = + ∫ p : ℝ × ℝ, (p.2 - s) * + (realPlanePartial (1,0) (realPlanePartial (1,0) g) p + + realPlanePartial (0,1) (realPlanePartial (0,1) g) p) + ∂(volume.prod (volume.restrict (Ioi s))) := by + apply compact_plane_green_assemble + · exact (contDiff_realPlanePartial (contDiff_realPlanePartial hg (1,0)) (1,0)).continuous + · exact (compact_realPlanePartial (compact_realPlanePartial hc (1,0)) (1,0)) + · exact (contDiff_realPlanePartial (contDiff_realPlanePartial hg (0,1)) (0,1)).continuous + · exact (compact_realPlanePartial (compact_realPlanePartial hc (0,1)) (0,1)) + · exact compact_plane_second_horizontal_zero hg hc + · exact fun x => compact_plane_second_vertical_green hg hc x s + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology +namespace StrictInverseFirstPower +noncomputable section + +def planePartial (v : ℂ) (g : ℂ → ℝ) (z : ℂ) : ℝ := fderiv ℝ g z v + +def planeLaplacian (g : ℂ → ℝ) (z : ℂ) : ℝ := + planePartial 1 (planePartial 1 g) z + planePartial I (planePartial I g) z + +lemma planePartial_comp_holomorphic {F : ℂ → ℂ} {ψ : ℂ → ℝ} {z : ℂ} + (hF : DifferentiableAt ℂ F z) (hψ : DifferentiableAt ℝ ψ (F z)) (v : ℂ) : + planePartial v (fun w => ψ (F w)) z = fderiv ℝ ψ (F z) (deriv F z * v) := by + change (fderiv ℝ (ψ ∘ F) z) v = _ + rw [fderiv_comp z hψ (hF.restrictScalars (𝕜 := ℝ))] + simp only [ContinuousLinearMap.comp_apply, hF.hasDerivAt.complexToReal_fderiv.fderiv] + rfl + +lemma second_planePartial_comp_holomorphic {F : ℂ → ℂ} {ψ : ℂ → ℝ} {z : ℂ} + (hF : AnalyticAt ℂ F z) (hψ : ContDiffAt ℝ 2 ψ (F z)) (v : ℂ) : + planePartial v (planePartial v (fun w => ψ (F w))) z = + fderiv ℝ ψ (F z) (deriv (deriv F) z * v * v) + + fderiv ℝ (fderiv ℝ ψ) (F z) (deriv F z * v) (deriv F z * v) := by + have he : planePartial v (fun w => ψ (F w)) =ᶠ[𝓝 z] + fun w => fderiv ℝ ψ (F w) (deriv F w * v) := by + have hp := hψ.eventually (by norm_num) + filter_upwards [hF.eventually_analyticAt, hF.continuousAt.eventually hp] with w hw hpw + exact planePartial_comp_holomorphic hw.differentiableAt + (hpw.differentiableAt (by norm_num)) v + have hDψ : DifferentiableAt ℝ (fderiv ℝ ψ) (F z) := + (hψ.fderiv_right (m := 1) (by norm_num)).differentiableAt one_ne_zero + have hA := hDψ.hasFDerivAt.comp z hF.differentiableAt.hasDerivAt.complexToReal_fderiv + have hB := ((hF.deriv.differentiableAt.hasDerivAt).mul_const v).complexToReal_fderiv + change fderiv ℝ (planePartial v (fun w => ψ (F w))) z v = _ + rw [he.fderiv_eq] + have hh := congrArg (fun L : ℂ →L[ℝ] ℝ => L v) (hA.clm_apply hB).fderiv + simpa only [Function.comp_def, add_apply, ContinuousLinearMap.comp_apply, + ContinuousLinearMap.flip_apply, smul_apply, one_apply_eq_self, + smul_eq_mul] using hh + +lemma real_bilinear_complex_trace (B : ℂ →L[ℝ] ℂ →L[ℝ] ℝ) (a : ℂ) : + B a a + B (a * I) (a * I) = ‖a‖ ^ 2 * (B 1 1 + B I I) := by + have ha : a = a.re • (1 : ℂ) + a.im • I := by apply Complex.ext <;> simp + have hai : a * I = (-a.im) • (1 : ℂ) + a.re • I := by apply Complex.ext <;> simp + calc + B a a + B (a * I) (a * I) = + B (a.re • 1 + a.im • I) (a.re • 1 + a.im • I) + + B ((-a.im) • 1 + a.re • I) ((-a.im) • 1 + a.re • I) := by rw [← ha, ← hai] + _ = _ := by + simp only [map_add, map_smul, add_apply, smul_apply, smul_eq_mul] + rw [Complex.sq_norm, Complex.normSq_apply] + ring + +lemma planeLaplacian_comp_holomorphic {F : ℂ → ℂ} {ψ : ℂ → ℝ} {z : ℂ} + (hF : AnalyticAt ℂ F z) (hψ : ContDiffAt ℝ 2 ψ (F z)) : + planeLaplacian (fun w => ψ (F w)) z = ‖deriv F z‖ ^ 2 * planeLaplacian ψ (F z) := by + have hDψ : DifferentiableAt ℝ (fderiv ℝ ψ) (F z) := + (hψ.fderiv_right (m := 1) (by norm_num)).differentiableAt one_ne_zero + have hp (v : ℂ) : planePartial v (planePartial v ψ) (F z) = + fderiv ℝ (fderiv ℝ ψ) (F z) v v := by + unfold planePartial + rw [fderiv_clm_apply hDψ (differentiableAt_const v)] + simp + rw [planeLaplacian, second_planePartial_comp_holomorphic hF hψ, + second_planePartial_comp_holomorphic hF hψ] + simp only [mul_one, mul_assoc, I_mul_I, mul_neg_one, map_neg] + rw [show fderiv ℝ ψ (F z) (deriv (deriv F) z) + + fderiv ℝ (fderiv ℝ ψ) (F z) (deriv F z) (deriv F z) + + (-fderiv ℝ ψ (F z) (deriv (deriv F) z) + + fderiv ℝ (fderiv ℝ ψ) (F z) (deriv F z * I) (deriv F z * I)) = + fderiv ℝ (fderiv ℝ ψ) (F z) (deriv F z) (deriv F z) + + fderiv ℝ (fderiv ℝ ψ) (F z) (deriv F z * I) (deriv F z * I) by ring] + rw [real_bilinear_complex_trace] + simp only [planeLaplacian, hp] + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex MeasureTheory +open scoped Topology ContDiff +namespace StrictInverseFirstPower +noncomputable section + +lemma planePartial_contDiff {g : ℂ → ℝ} (hg : ContDiff ℝ ∞ g) (v : ℂ) : + ContDiff ℝ ∞ (planePartial v g) := by + exact (hg.fderiv_right (by simp)).clm_apply contDiff_const + +lemma partial_realProd_comp {g : ℂ → ℝ} (hg : Differentiable ℝ g) (v : ℝ × ℝ) : + realPlanePartial v (fun p => g (Complex.equivRealProdCLM.symm p)) = + fun p => planePartial (Complex.equivRealProdCLM.symm v) g (Complex.equivRealProdCLM.symm p) := by + funext p + unfold realPlanePartial planePartial + change fderiv ℝ (g ∘ Complex.equivRealProdCLM.symm) p v = _ + rw [fderiv_comp p (hg _) Complex.equivRealProdCLM.symm.differentiableAt, + Complex.equivRealProdCLM.symm.fderiv] + rfl + +lemma laplacian_realProd_comp {g : ℂ → ℝ} (hg : ContDiff ℝ ∞ g) (p : ℝ × ℝ) : + realPlanePartial (1,0) (realPlanePartial (1,0) + (fun p => g (Complex.equivRealProdCLM.symm p))) p + + realPlanePartial (0,1) (realPlanePartial (0,1) + (fun p => g (Complex.equivRealProdCLM.symm p))) p = + planeLaplacian g (Complex.equivRealProdCLM.symm p) := by + rw [partial_realProd_comp (hg.differentiable (by simp)), + partial_realProd_comp ((planePartial_contDiff hg _).differentiable (by simp)), + partial_realProd_comp (hg.differentiable (by simp)), + partial_realProd_comp ((planePartial_contDiff hg _).differentiable (by simp))] + rfl + +lemma integral_realProd_above (H : ℂ → ℝ) (s : ℝ) : + (∫ p : ℝ × ℝ, H (Complex.equivRealProdCLM.symm p) + ∂(volume.prod (volume.restrict (Ioi s)))) = + ∫ z in {z : ℂ | s < z.im}, H z := by + have hp := Complex.volume_preserving_equiv_real_prod.restrict_preimage + (MeasurableSet.univ.prod measurableSet_Ioi : MeasurableSet ((univ : Set ℝ) ×ˢ Ioi s)) + have he := hp.integral_comp Complex.measurableEquivRealProd.measurableEmbedding + (fun p => H (Complex.equivRealProdCLM.symm p)) + have hm : (volume : Measure (ℝ × ℝ)).restrict ((univ : Set ℝ) ×ˢ Ioi s) = + volume.prod (volume.restrict (Ioi s)) := by + rw [Measure.volume_eq_prod, ← Measure.prod_restrict, Measure.restrict_univ] + rw [hm] at he + have hs : (Complex.measurableEquivRealProd ⁻¹' ((univ : Set ℝ) ×ˢ Ioi s)) = + {z : ℂ | s < z.im} := by ext z; simp + have hx (z : ℂ) : Complex.equivRealProdCLM.symm (Complex.measurableEquivRealProd z) = z := + Complex.equivRealProdCLM.symm_apply_apply z + simpa only [hs, hx] using he.symm + +lemma compact_complex_horizontal_green {g : ℂ → ℝ} (hg : ContDiff ℝ ∞ g) + (hc : HasCompactSupport g) (s : ℝ) : + (∫ x : ℝ, g ((x : ℂ) + (s : ℂ) * I)) = + ∫ z in {z : ℂ | s < z.im}, (z.im-s) * planeLaplacian g z := by + have hgc : ContDiff ℝ ∞ (fun p => g (Complex.equivRealProdCLM.symm p)) := + hg.comp Complex.equivRealProdCLM.symm.contDiff + have hcc : HasCompactSupport (fun p => g (Complex.equivRealProdCLM.symm p)) := + hc.comp_isClosedEmbedding Complex.equivRealProdCLM.symm.toHomeomorph.isClosedEmbedding + have he := compact_plane_horizontal_green hgc hcc s + simp only [laplacian_realProd_comp hg] at he + have hz (x : ℝ) : Complex.equivRealProdCLM.symm (x,s) = (x : ℂ) + (s : ℂ) * I := by + apply Complex.ext <;> simp + simp only [hz] at he + rw [he] + exact integral_realProd_above (fun z => (z.im-s) * planeLaplacian g z) s + +lemma planeLaplacian_congr_nhds {g h : ℂ → ℝ} {z : ℂ} (he : g =ᶠ[𝓝 z] h) : + planeLaplacian g z = planeLaplacian h z := by + have hp (v : ℂ) : planePartial v g =ᶠ[𝓝 z] planePartial v h := by + filter_upwards [he.fderiv (𝕜 := ℝ)] with w hw + exact congrArg (fun L : ℂ →L[ℝ] ℝ => L v) hw + change fderiv ℝ (planePartial 1 g) z 1 + fderiv ℝ (planePartial I g) z I = + fderiv ℝ (planePartial 1 h) z 1 + fderiv ℝ (planePartial I h) z I + rw [(hp 1).fderiv_eq, (hp I).fderiv_eq] + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GridChains.lean b/lean/OAI/Analysis/StrictMeans/GridChains.lean new file mode 100644 index 0000000000000000000000000000000000000000..e80244314449f127b82af5d584090c8179f13105 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GridChains.lean @@ -0,0 +1,100 @@ +import OAI.Analysis.StrictMeans.PlaneRectangle + +namespace OAI + +section +open Polynomial +namespace StrictInverseFirstPower.Grid +noncomputable section + +abbrev Chain := Polynomial (Polynomial ℚ) + +def x : Chain := C X +def y : Chain := X + +lemma x_sub_one_ne_zero : x - 1 ≠ 0 := by + intro h + have he := congrArg (fun p : Chain => (p.coeff 0).coeff 1) h + norm_num [x,coeff_one] at he + +lemma y_sub_one_ne_zero : y - 1 ≠ 0 := by + intro h + have he := congrArg (fun p : Chain => (p.coeff 1).coeff 0) h + norm_num [y,coeff_one] at he + +def boundary₁ (h v d : Chain) : Chain := (x-1)*h + (y-1)*v + (x*y-1)*d + +def faceH (a b : Chain) : Chain := a-y*b +def faceV (a b : Chain) : Chain := x*a-b +def faceD (a b : Chain) : Chain := b-a + +lemma boundary_face (a b : Chain) : boundary₁ (faceH a b) (faceV a b) (faceD a b) = 0 := by + unfold boundary₁ faceH faceV faceD + ring + +lemma square_cycle_fills {h v : Chain} (hc : (x-1)*h+(y-1)*v=0) : + ∃ s : Chain, h=(1-y)*s ∧ v=(x-1)*s := by + have hv : eval (1 : Polynomial ℚ) h = 0 := by + have he := congrArg (eval (1 : Polynomial ℚ)) hc + simp only [eval_add,eval_mul,eval_sub,eval_one,eval_zero,x,y,eval_C,eval_X, + sub_self,zero_mul,add_zero] at he + have hn : (X : Polynomial ℚ)-1 ≠ 0 := by + intro hn + have ha := congrArg (fun p : Polynomial ℚ => p.coeff 1) hn + norm_num [coeff_one] at ha + exact (mul_eq_zero.mp he).resolve_left hn + have hd : (y-1) ∣ h := by + simpa only [y,C_1] using (dvd_iff_isRoot.mpr hv : (X-C (1 : Polynomial ℚ)) ∣ h) + obtain ⟨a,ha⟩ := hd + refine ⟨-a,?_,?_⟩ + · rw [ha] + ring + · have he : (y-1)*((x-1)*a+v)=0 := by + rw [ha] at hc + convert hc using 1 + ring + have he' := (mul_eq_zero.mp he).resolve_left y_sub_one_ne_zero + have hv' : v = -(x-1)*a := by linear_combination he' + rw [hv'] + ring + +lemma cycle_fills {h v d : Chain} (hc : boundary₁ h v d = 0) : + ∃ a b : Chain, faceH a b = h ∧ faceV a b = v ∧ faceD a b = d := by + have hs : (x-1)*(h+d)+(y-1)*(v+x*d)=0 := by + unfold boundary₁ at hc + convert hc using 1 + ring + obtain ⟨s,hh,hv⟩ := square_cycle_fills hs + refine ⟨s-d,s,?_,?_,?_⟩ + · unfold faceH + linear_combination -hh + · unfold faceV + linear_combination -hv + · unfold faceD + ring + +lemma face_eq_aux {R : Type*} [CommRing R] (Y : R) {a b c d : R} + (hH : a-Y*b=c-Y*d) (hD : b-a=d-c) : (Y-1)*(b-d)=0 := by + linear_combination -hH-hD + +lemma face_boundary_injective : Function.Injective + (fun p : Chain × Chain => (faceH p.1 p.2,faceV p.1 p.2,faceD p.1 p.2)) := by + intro p q he + have hH := congrArg (fun a : Chain × Chain × Chain => a.1) he + have hD := congrArg (fun a : Chain × Chain × Chain => a.2.2) he + change p.1-y*p.2 = q.1-y*q.2 at hH + change p.2-p.1 = q.2-q.1 at hD + have hm := face_eq_aux y hH hD + have hp := (mul_eq_zero.mp hm).resolve_left y_sub_one_ne_zero + have hb : p.2=q.2 := sub_eq_zero.mp hp + have ha : p.1=q.1 := by + rw [hb] at hH + exact sub_left_injective hH + exact Prod.ext ha hb + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GridComplex.lean b/lean/OAI/Analysis/StrictMeans/GridComplex.lean new file mode 100644 index 0000000000000000000000000000000000000000..f62779f0ca1dcdcbaea654d9ede7b631dcaf5c99 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GridComplex.lean @@ -0,0 +1,127 @@ +import OAI.Analysis.StrictMeans.GridLinear + +namespace OAI + +section +open Polynomial Set Module +namespace StrictInverseFirstPower.Grid +noncomputable section + +lemma chainSpace_mono {S T : Set (ℕ × ℕ)} (hST : S ⊆ T) : chainSpace S ≤ chainSpace T := by + intro p hp + rw [mem_chainSpace] at hp ⊢ + exact fun i j ht => hp i j (fun hs => ht (hST hs)) + +lemma chainSpace_shift_x {S T : Set (ℕ × ℕ)} (hST : ∀ i j, (i,j) ∈ S → (i+1,j) ∈ T) + {p : Chain} (hp : p ∈ chainSpace S) : x*p ∈ chainSpace T := by + rw [mem_chainSpace] at hp ⊢ + intro i j ht + cases i with + | zero => exact coeff_x_zero p j + | succ i => + rw [coeff_x_succ] + exact hp i j (fun hs => ht (hST i j hs)) + +lemma chainSpace_shift_y {S T : Set (ℕ × ℕ)} (hST : ∀ i j, (i,j) ∈ S → (i,j+1) ∈ T) + {p : Chain} (hp : p ∈ chainSpace S) : y*p ∈ chainSpace T := by + rw [mem_chainSpace] at hp ⊢ + intro i j ht + cases j with + | zero => exact coeff_y_zero p i + | succ j => + rw [coeff_y_succ] + exact hp i j (fun hs => ht (hST i j hs)) + +lemma chainSpace_shift_xy {S T : Set (ℕ × ℕ)} (hST : ∀ i j, (i,j) ∈ S → (i+1,j+1) ∈ T) + {p : Chain} (hp : p ∈ chainSpace S) : x*y*p ∈ chainSpace T := by + rw [mul_assoc] + apply chainSpace_shift_x (S := {v | ∃ j, (v.1,j) ∈ S ∧ v.2=j+1}) + · rintro i r ⟨j,hj,rfl⟩ + exact hST i j hj + · exact chainSpace_shift_y (S := S) (T := {v | ∃ j, (v.1,j) ∈ S ∧ v.2=j+1}) (fun i j h => ⟨j,h,rfl⟩) hp + +lemma boundary₁_mem (S : Set (ℕ × ℕ)) (e : EdgeSpace S) : + boundary₁ e.1.1 e.2.1.1 e.2.2.1 ∈ chainSpace S := by + unfold boundary₁ + simp only [sub_mul,one_mul] + apply (chainSpace S).add_mem + · apply (chainSpace S).add_mem + · exact (chainSpace S).sub_mem (chainSpace_shift_x (fun _ _ h => h.2) e.1.2) + (chainSpace_mono (fun _ h => h.1) e.1.2) + · exact (chainSpace S).sub_mem (chainSpace_shift_y (fun _ _ h => h.2) e.2.1.2) + (chainSpace_mono (fun _ h => h.1) e.2.1.2) + · exact (chainSpace S).sub_mem (chainSpace_shift_xy (fun _ _ h => h.2) e.2.2.2) + (chainSpace_mono (fun _ h => h.1) e.2.2.2) + +lemma faceH_mem (S : Set (ℕ × ℕ)) (f : FaceSpace S) : + faceH f.1.1 f.2.1 ∈ chainSpace (horizontalSet S) := by + exact (chainSpace _).sub_mem (chainSpace_mono (S := lowerSet S) (T := horizontalSet S) (fun _ h => ⟨h.1,h.2.1⟩) f.1.2) + (chainSpace_shift_y (S := upperSet S) (T := horizontalSet S) (fun _ _ h => ⟨h.2.1,h.2.2⟩) f.2.2) +lemma faceV_mem (S : Set (ℕ × ℕ)) (f : FaceSpace S) : + faceV f.1.1 f.2.1 ∈ chainSpace (verticalSet S) := by + exact (chainSpace _).sub_mem (chainSpace_shift_x (S := lowerSet S) (T := verticalSet S) (fun _ _ h => ⟨h.2.1,h.2.2⟩) f.1.2) + (chainSpace_mono (S := upperSet S) (T := verticalSet S) (fun _ h => ⟨h.1,h.2.1⟩) f.2.2) +lemma faceD_mem (S : Set (ℕ × ℕ)) (f : FaceSpace S) : + faceD f.1.1 f.2.1 ∈ chainSpace (diagonalSet S) := by + exact (chainSpace _).sub_mem (chainSpace_mono (S := upperSet S) (T := diagonalSet S) (fun _ h => ⟨h.1,h.2.2⟩) f.2.2) + (chainSpace_mono (S := lowerSet S) (T := diagonalSet S) (fun _ h => ⟨h.1,h.2.2⟩) f.1.2) + +def edgeBoundary (S : Set (ℕ × ℕ)) : EdgeSpace S →ₗ[ℚ] chainSpace S where + toFun e := ⟨_,boundary₁_mem S e⟩ + map_add' e f := by + apply Subtype.ext + exact fullBoundary₁.map_add (e.1.1,e.2.1.1,e.2.2.1) (f.1.1,f.2.1.1,f.2.2.1) + map_smul' r e := by + apply Subtype.ext + exact fullBoundary₁.map_smul r (e.1.1,e.2.1.1,e.2.2.1) + +def faceBoundary (S : Set (ℕ × ℕ)) : FaceSpace S →ₗ[ℚ] EdgeSpace S where + toFun f := (⟨_,faceH_mem S f⟩,⟨_,faceV_mem S f⟩,⟨_,faceD_mem S f⟩) + map_add' f g := by + have he := fullBoundary₂.map_add (f.1.1,f.2.1) (g.1.1,g.2.1) + exact Prod.ext (Subtype.ext (congrArg Prod.fst he)) + (Prod.ext (Subtype.ext (congrArg (fun e => e.2.1) he)) (Subtype.ext (congrArg (fun e => e.2.2) he))) + map_smul' r f := by + have he := fullBoundary₂.map_smul r (f.1.1,f.2.1) + exact Prod.ext (Subtype.ext (congrArg Prod.fst he)) + (Prod.ext (Subtype.ext (congrArg (fun e => e.2.1) he)) (Subtype.ext (congrArg (fun e => e.2.2) he))) + +lemma faceBoundary_injective (S : Set (ℕ × ℕ)) : Function.Injective (faceBoundary S) := by + intro f g he + have hh : (faceH f.1.1 f.2.1,faceV f.1.1 f.2.1,faceD f.1.1 f.2.1) = + (faceH g.1.1 g.2.1,faceV g.1.1 g.2.1,faceD g.1.1 g.2.1) := + congrArg (fun e : EdgeSpace S => (e.1.1,e.2.1.1,e.2.2.1)) he + have hf := @face_boundary_injective (f.1.1,f.2.1) (g.1.1,g.2.1) hh + exact Prod.ext (Subtype.ext (congrArg Prod.fst hf)) (Subtype.ext (congrArg Prod.snd hf)) + +lemma boundary_exact {u : ℕ × ℕ → ℝ} {c : ℝ} + (hascent : ∀ i j, c < u (i,j) → 0 < i → 0 < j → + u (i,j) < u (i+1,j) ∨ u (i,j) < u (i,j+1) ∨ + u (i,j) < u (i-1,j) ∨ u (i,j) < u (i,j-1)) : + (faceBoundary {w | u w ≤ c}).range = (edgeBoundary {w | u w ≤ c}).ker := by + let S := {w | u w ≤ c} + apply le_antisymm + · rintro _ ⟨f,rfl⟩ + apply Subtype.ext + exact boundary_face f.1.1 f.2.1 + · intro e he + have hc : boundary₁ e.1.1 e.2.1.1 e.2.2.1 = 0 := congrArg Subtype.val he + have hH := (mem_chainSpace (horizontalSet S) e.1.1).mp e.1.2 + have hV := (mem_chainSpace (verticalSet S) e.2.1.1).mp e.2.1.2 + have hD := (mem_chainSpace (diagonalSet S) e.2.2.1).mp e.2.2.2 + obtain ⟨a,b,ha,hb,hd,hs⟩ := cycle_fills_sublevel hc + (fun i j h => hH i j (by intro hw; exact h.elim (fun hh => (not_lt_of_ge hw.1) hh) (fun hh => (not_lt_of_ge hw.2) hh))) + (fun i j h => hV i j (by intro hw; exact h.elim (fun hh => (not_lt_of_ge hw.1) hh) (fun hh => (not_lt_of_ge hw.2) hh))) + (fun i j h => hD i j (by intro hw; exact h.elim (fun hh => (not_lt_of_ge hw.1) hh) (fun hh => (not_lt_of_ge hw.2) hh))) hascent + have ha' : a ∈ chainSpace (lowerSet S) := (mem_chainSpace _ _).mpr + (fun i j h => by by_contra hn; exact h (hs.lower i j hn)) + have hb' : b ∈ chainSpace (upperSet S) := (mem_chainSpace _ _).mpr + (fun i j h => by by_contra hn; exact h (hs.upper i j hn)) + exact ⟨(⟨a,ha'⟩,⟨b,hb'⟩),Prod.ext (Subtype.ext ha) (Prod.ext (Subtype.ext hb) (Subtype.ext hd))⟩ + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GridEuler.lean b/lean/OAI/Analysis/StrictMeans/GridEuler.lean new file mode 100644 index 0000000000000000000000000000000000000000..58fd653ac7528ea6941443b0b377b7f8131b1dd5 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GridEuler.lean @@ -0,0 +1,86 @@ +import OAI.Analysis.StrictMeans.GridComplex + +namespace OAI + +section +open Polynomial Set Module +namespace StrictInverseFirstPower.Grid +noncomputable section + +def augmentation : Chain →ₗ[ℚ] ℚ where + toFun p := eval 1 (eval 1 p) + map_add' := by intros; simp + map_smul' := by intros; simp + +lemma augmentation_boundary₁ (h v d : Chain) : augmentation (boundary₁ h v d) = 0 := by + simp [augmentation,boundary₁,x,y] + +def vertexAugmentation (S : Set (ℕ × ℕ)) : chainSpace S →ₗ[ℚ] ℚ := + augmentation.comp (chainSpace S).subtype + +lemma vertexAugmentation_boundary (S : Set (ℕ × ℕ)) : + vertexAugmentation S ∘ₗ edgeBoundary S = 0 := by + apply LinearMap.ext + intro e + exact augmentation_boundary₁ e.1.1 e.2.1.1 e.2.2.1 + +lemma vertexAugmentation_ne_zero {S : Set (ℕ × ℕ)} (hne : S.Nonempty) : + vertexAugmentation S ≠ 0 := by + classical + obtain ⟨⟨i,j⟩,hv⟩ := hne + let p : Chain := monomial j (monomial i 1) + have hp : p ∈ chainSpace S := by + rw [mem_chainSpace] + intro l m hm + by_cases hmi : m=j + · subst m + have hli : l ≠ i := by rintro rfl; exact hm hv + simp [p,coeff,coeff_monomial,Ne.symm hli] + · simp [p,coeff,coeff_monomial,Ne.symm hmi] + intro he + have hh := congrArg (fun f : chainSpace S →ₗ[ℚ] ℚ => f ⟨p,hp⟩) he + simp [vertexAugmentation,augmentation,p,eval_monomial] at hh + +lemma sublevel_euler {u : ℕ × ℕ → ℝ} {c : ℝ} + (hfin : {v | u v ≤ c}.Finite) (hne : {v | u v ≤ c}.Nonempty) + (hascent : ∀ i j, c < u (i,j) → 0 < i → 0 < j → + u (i,j) < u (i+1,j) ∨ u (i,j) < u (i,j+1) ∨ + u (i,j) < u (i-1,j) ∨ u (i,j) < u (i,j-1)) : + (horizontalSet {v | u v ≤ c}).ncard + (verticalSet {v | u v ≤ c}).ncard + + (diagonalSet {v | u v ≤ c}).ncard + 1 ≤ + {v | u v ≤ c}.ncard + (lowerSet {v | u v ≤ c}).ncard + (upperSet {v | u v ≤ c}).ncard := by + let S := {v | u v ≤ c} + have hH : (horizontalSet S).Finite := hfin.subset fun _ h => h.1 + have hV : (verticalSet S).Finite := hfin.subset fun _ h => h.1 + have hD : (diagonalSet S).Finite := hfin.subset fun _ h => h.1 + have hL : (lowerSet S).Finite := hfin.subset fun _ h => h.1 + have hU : (upperSet S).Finite := hfin.subset fun _ h => h.1 + let := hfin.fintype + let := hH.fintype + let := hV.fintype + let := hD.fintype + let := hL.fintype + let := hU.fintype + have he := finite_euler_inequality (K := ℚ) (V₀ := chainSpace S) (V₁ := EdgeSpace S) (V₂ := FaceSpace S) (edgeBoundary S) (faceBoundary S) (vertexAugmentation S) + (faceBoundary_injective S) (boundary_exact hascent) (vertexAugmentation_boundary S) + (vertexAugmentation_ne_zero hne) + let (T : Set (ℕ × ℕ)) : Module.Free ℚ (chainSpace T) := Module.Free.of_equiv (chainSpaceEquiv T).symm + have hdimE : finrank ℚ (EdgeSpace S) = finrank ℚ (chainSpace (horizontalSet S)) + finrank ℚ (chainSpace (verticalSet S)) + finrank ℚ (chainSpace (diagonalSet S)) := by + dsimp only [EdgeSpace] + rw [Module.finrank_prod,Module.finrank_prod] + omega + have hdimF : finrank ℚ (FaceSpace S) = finrank ℚ (chainSpace (lowerSet S)) + finrank ℚ (chainSpace (upperSet S)) := by + exact Module.finrank_prod + rw [hdimE,hdimF] at he + simp only [finrank_chainSpace S hfin, + finrank_chainSpace _ hH,finrank_chainSpace _ hV,finrank_chainSpace _ hD, + finrank_chainSpace _ hL,finrank_chainSpace _ hU] at he + dsimp only [S] at he + omega + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GridLinear.lean b/lean/OAI/Analysis/StrictMeans/GridLinear.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e072606a820ab77b52f414ff6285cc108b86a33 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GridLinear.lean @@ -0,0 +1,76 @@ +import OAI.Analysis.StrictMeans.FiniteEuler + +namespace OAI + +section +open Polynomial Set Module +namespace StrictInverseFirstPower.Grid +noncomputable section + +def polyCoefficients (R : Type*) [Semiring R] : Polynomial R ≃ₗ[R] (ℕ →₀ R) := + (Polynomial.toFinsuppIsoLinear R).trans (AddMonoidAlgebra.coeffLinearEquiv R) + +def coefficients : Chain ≃ₗ[ℚ] (ℕ × ℕ →₀ ℚ) := + (((polyCoefficients (Polynomial ℚ)).restrictScalars ℚ).trans + (Finsupp.mapRange.linearEquiv (polyCoefficients ℚ))).trans + ((Finsupp.curryLinearEquiv ℚ).symm.trans + (Finsupp.domLCongr (Equiv.prodComm ℕ ℕ))) + +@[simp] lemma coefficients_apply (p : Chain) (i j : ℕ) : coefficients p (i,j) = coeff p i j := rfl + +def chainSpace (S : Set (ℕ × ℕ)) : Submodule ℚ Chain := + (Finsupp.supported ℚ ℚ S).comap coefficients.toLinearMap + +lemma mem_chainSpace (S : Set (ℕ × ℕ)) (p : Chain) : + p ∈ chainSpace S ↔ ∀ i j, (i,j) ∉ S → coeff p i j = 0 := by + simp only [chainSpace,Submodule.mem_comap,Finsupp.mem_supported] + simp only [Set.subset_def,Finset.mem_coe,Finsupp.mem_support_iff] + constructor + · intro h i j hi + by_contra hn + exact hi (h (i,j) hn) + · intro h v hv + by_contra he + exact hv (h v.1 v.2 he) + +def chainSpaceEquiv (S : Set (ℕ × ℕ)) : chainSpace S ≃ₗ[ℚ] (S →₀ ℚ) := + (coefficients.ofSubmodule' (Finsupp.supported ℚ ℚ S)).trans + (Finsupp.supportedEquivFinsupp S) + +instance finite_chainSpace (S : Set (ℕ × ℕ)) [Finite S] : FiniteDimensional ℚ (chainSpace S) := + (chainSpaceEquiv S).symm.finiteDimensional + +lemma finrank_chainSpace (S : Set (ℕ × ℕ)) (hS : S.Finite) : + finrank ℚ (chainSpace S) = S.ncard := by + let := hS.fintype + rw [(chainSpaceEquiv S).finrank_eq] + simp + +def horizontalSet (S : Set (ℕ × ℕ)) : Set (ℕ × ℕ) := {v | v ∈ S ∧ (v.1+1,v.2) ∈ S} +def verticalSet (S : Set (ℕ × ℕ)) : Set (ℕ × ℕ) := {v | v ∈ S ∧ (v.1,v.2+1) ∈ S} +def diagonalSet (S : Set (ℕ × ℕ)) : Set (ℕ × ℕ) := {v | v ∈ S ∧ (v.1+1,v.2+1) ∈ S} +def lowerSet (S : Set (ℕ × ℕ)) : Set (ℕ × ℕ) := {v | v ∈ S ∧ (v.1+1,v.2) ∈ S ∧ (v.1+1,v.2+1) ∈ S} +def upperSet (S : Set (ℕ × ℕ)) : Set (ℕ × ℕ) := {v | v ∈ S ∧ (v.1,v.2+1) ∈ S ∧ (v.1+1,v.2+1) ∈ S} + +abbrev EdgeSpace (S : Set (ℕ × ℕ)) := chainSpace (horizontalSet S) × chainSpace (verticalSet S) × chainSpace (diagonalSet S) +abbrev FaceSpace (S : Set (ℕ × ℕ)) := chainSpace (lowerSet S) × chainSpace (upperSet S) + +def fullBoundary₁ : (Chain × Chain × Chain) →ₗ[ℚ] Chain where + toFun p := boundary₁ p.1 p.2.1 p.2.2 + map_add' := by intros; simp only [boundary₁,Prod.fst_add,Prod.snd_add]; ring + map_smul' := by + intro r p + change (x-1)*(r • p.1)+(y-1)*(r • p.2.1)+(x*y-1)*(r • p.2.2) = r • _ + simp only [mul_smul_comm,boundary₁,smul_add] + +def fullBoundary₂ : (Chain × Chain) →ₗ[ℚ] (Chain × Chain × Chain) where + toFun p := (faceH p.1 p.2,faceV p.1 p.2,faceD p.1 p.2) + map_add' := by intros; ext <;> simp [faceH,faceV,faceD,mul_add] <;> ring + map_smul' := by intros; ext <;> simp [faceH,faceV,faceD] <;> ring + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GridLink.lean b/lean/OAI/Analysis/StrictMeans/GridLink.lean new file mode 100644 index 0000000000000000000000000000000000000000..65aaa777263bf97e708c82c1a4047bc5b65b61a0 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GridLink.lean @@ -0,0 +1,75 @@ +import OAI.Analysis.StrictMeans.HessianLocal + +namespace OAI + +section +namespace StrictInverseFirstPower.Grid + +def bit (b : Bool) : ℤ := if b then 1 else 0 + +def linkIndex (b₀ b₁ b₂ b₃ b₄ b₅ : Bool) : ℤ := + 1 - (bit b₀+bit b₁+bit b₂+bit b₃+bit b₄+bit b₅) + + (bit b₀*bit b₁+bit b₁*bit b₂+bit b₂*bit b₃+ + bit b₃*bit b₄+bit b₄*bit b₅+bit b₅*bit b₀) + +def signBound (b : Bool) (t e : ℝ) : Prop := if b then t ≤ e else -e ≤ t + +lemma linkIndex_rotate (a b c d e f : Bool) : linkIndex a b c d e f = linkIndex b c d e f a := by + unfold linkIndex + ring + +lemma regular_link_xpos {gx gy e : ℝ} {b₀ b₁ b₂ b₃ b₄ b₅ : Bool} + (hx : 2*e < gx) (he : 0 ≤ e) + (h₀ : signBound b₀ gx e) (h₁ : signBound b₁ (gx+gy) e) + (h₂ : signBound b₂ gy e) (h₃ : signBound b₃ (-gx) e) + (h₄ : signBound b₄ (-gx-gy) e) (h₅ : signBound b₅ (-gy) e) : + linkIndex b₀ b₁ b₂ b₃ b₄ b₅ = 0 := by + have hb₀ : b₀ = false := by cases b₀ <;> simp_all [signBound]; linarith + have hb₃ : b₃ = true := by cases b₃ <;> simp_all [signBound]; linarith + subst b₀; subst b₃ + cases b₁ <;> cases b₂ <;> cases b₄ <;> cases b₅ <;> + norm_num [linkIndex,bit,signBound] at * <;> linarith + +lemma regular_link_xneg {gx gy e : ℝ} {b₀ b₁ b₂ b₃ b₄ b₅ : Bool} + (hx : gx < -2*e) (he : 0 ≤ e) + (h₀ : signBound b₀ gx e) (h₁ : signBound b₁ (gx+gy) e) + (h₂ : signBound b₂ gy e) (h₃ : signBound b₃ (-gx) e) + (h₄ : signBound b₄ (-gx-gy) e) (h₅ : signBound b₅ (-gy) e) : + linkIndex b₀ b₁ b₂ b₃ b₄ b₅ = 0 := by + rw [linkIndex_rotate,linkIndex_rotate,linkIndex_rotate] + apply regular_link_xpos (gx := -gx) (gy := -gy) (by linarith) he h₃ + · simpa only [sub_eq_add_neg] using h₄ + · exact h₅ + · simpa using h₀ + · simpa using h₁ + · simpa using h₂ + +lemma linkIndex_reverse (a b c d e f : Bool) : linkIndex a b c d e f = linkIndex c b a f e d := by + unfold linkIndex + ring + +lemma regular_link {gx gy e : ℝ} {b₀ b₁ b₂ b₃ b₄ b₅ : Bool} + (hreg : 2*e < |gx| ∨ 2*e < |gy|) (he : 0 ≤ e) + (h₀ : signBound b₀ gx e) (h₁ : signBound b₁ (gx+gy) e) + (h₂ : signBound b₂ gy e) (h₃ : signBound b₃ (-gx) e) + (h₄ : signBound b₄ (-gx-gy) e) (h₅ : signBound b₅ (-gy) e) : + linkIndex b₀ b₁ b₂ b₃ b₄ b₅ = 0 := by + have hbase : ∀ {x y : ℝ} {a b c d e' f : Bool}, 2*e < |x| → + signBound a x e → signBound b (x+y) e → signBound c y e → + signBound d (-x) e → signBound e' (-x-y) e → signBound f (-y) e → + linkIndex a b c d e' f = 0 := by + intro x y a b c d e' f hx ha hb hc hd he' hf + rcases lt_abs.mp hx with hp | hn + · exact regular_link_xpos hp he ha hb hc hd he' hf + · exact regular_link_xneg (by linarith) he ha hb hc hd he' hf + rcases hreg with hx | hy + · exact hbase hx h₀ h₁ h₂ h₃ h₄ h₅ + · rw [linkIndex_reverse] + exact hbase hy h₂ (by simpa [add_comm] using h₁) h₀ h₅ + (by convert h₄ using 1; ring) h₃ + +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/GridSupport.lean b/lean/OAI/Analysis/StrictMeans/GridSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2e357f6b06047cb4672b8a0568f31a6cde3eca0 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/GridSupport.lean @@ -0,0 +1,168 @@ +import OAI.Analysis.StrictMeans.GridChains + +namespace OAI + +section +open Polynomial Set +namespace StrictInverseFirstPower.Grid +noncomputable section + +def coeff (p : Chain) (i j : ℕ) : ℚ := (p.coeff j).coeff i + +@[simp] lemma coeff_sub (p q : Chain) (i j : ℕ) : + coeff (p-q) i j = coeff p i j - coeff q i j := by simp [coeff] + +@[simp] lemma coeff_x_zero (p : Chain) (j : ℕ) : coeff (x*p) 0 j = 0 := by + simp [coeff,x,coeff_C_mul] +@[simp] lemma coeff_x_succ (p : Chain) (i j : ℕ) : coeff (x*p) (i+1) j = coeff p i j := by + simp [coeff,x,coeff_C_mul,coeff_X_mul] +@[simp] lemma coeff_y_zero (p : Chain) (i : ℕ) : coeff (y*p) i 0 = 0 := by + simp [coeff,y] +@[simp] lemma coeff_y_succ (p : Chain) (i j : ℕ) : coeff (y*p) i (j+1) = coeff p i j := by + simp [coeff,y,coeff_X_mul] + +lemma finite_coeff_support (p : Chain) : {v : ℕ × ℕ | coeff p v.1 v.2 ≠ 0}.Finite := by + classical + apply ((p.support.biUnion fun j => ((p.coeff j).support).map ⟨fun i => (i,j),by intro i k h; exact congrArg Prod.fst h⟩).finite_toSet).subset + intro v hv + simp only [Finset.mem_coe,Finset.mem_biUnion,Finset.mem_map] + refine ⟨v.2,mem_support_iff.mpr ?_,v.1,mem_support_iff.mpr hv,rfl⟩ + intro he + exact hv (by simp [coeff,he]) + +structure BoundarySupported (S : Set (ℕ × ℕ)) (a b : Chain) : Prop where + horizontal : ∀ i j, (i,j) ∉ S ∨ (i+1,j) ∉ S → coeff (faceH a b) i j = 0 + vertical : ∀ i j, (i,j) ∉ S ∨ (i,j+1) ∉ S → coeff (faceV a b) i j = 0 + diagonal : ∀ i j, (i,j) ∉ S ∨ (i+1,j+1) ∉ S → coeff (faceD a b) i j = 0 + +lemma BoundarySupported.anchor_eq {S : Set (ℕ × ℕ)} {a b : Chain} (hb : BoundarySupported S a b) + {i j : ℕ} (hv : (i,j) ∉ S) : coeff a i j = coeff b i j := by + have h := hb.diagonal i j (Or.inl hv) + exact (sub_eq_zero.mp (by simpa only [faceD,coeff_sub] using h)).symm + +lemma BoundarySupported.anchor_zero_axis₁ {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) {j : ℕ} (hv : (0,j) ∉ S) : coeff a 0 j = 0 := by + have h := hb.vertical 0 j (Or.inl hv) + rw [hb.anchor_eq hv] + simpa only [faceV,coeff_sub,coeff_x_zero,zero_sub,neg_eq_zero] using h + +lemma BoundarySupported.anchor_zero_axis₂ {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) {i : ℕ} (hv : (i,0) ∉ S) : coeff a i 0 = 0 := by + have h := hb.horizontal i 0 (Or.inl hv) + simpa only [faceH,coeff_sub,coeff_y_zero,sub_zero] using h + +lemma BoundarySupported.anchor_eq_right {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) {i j : ℕ} (hv : (i+1,j) ∉ S) : + coeff a i j = coeff a (i+1) j := by + have h := hb.vertical (i+1) j (Or.inl hv) + simpa only [faceV,coeff_sub,coeff_x_succ,sub_eq_zero,← hb.anchor_eq hv] using h + +lemma BoundarySupported.anchor_eq_up {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) {i j : ℕ} (hv : (i,j) ∉ S) (hw : (i,j+1) ∉ S) : + coeff a i j = coeff a i (j+1) := by + have h := hb.horizontal i (j+1) (Or.inl hw) + exact (sub_eq_zero.mp (by simpa only [faceH,coeff_sub,coeff_y_succ,← hb.anchor_eq hv] using h)).symm + +lemma BoundarySupported.anchor_eq_left {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) {i j : ℕ} (hv : (i,j) ∉ S) (hi : 0 < i) : + coeff a i j = coeff a (i-1) j := by + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_zero_of_lt hi) + simpa only [Nat.succ_eq_add_one,Nat.add_sub_cancel] using (hb.anchor_eq_right hv).symm + +lemma BoundarySupported.anchor_eq_down {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) {i j : ℕ} (hv : (i,j) ∉ S) + (hw : (i,j-1) ∉ S) (hj : 0 < j) : coeff a i j = coeff a i (j-1) := by + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_zero_of_lt hj) + simpa only [Nat.succ_eq_add_one,Nat.add_sub_cancel] using (hb.anchor_eq_up hw hv).symm + +lemma BoundarySupported.anchor_zero_of_ascent {u : ℕ × ℕ → ℝ} {c : ℝ} {a b : Chain} + (hb : BoundarySupported {v | u v ≤ c} a b) + (hascent : ∀ i j, c < u (i,j) → 0 < i → 0 < j → + u (i,j) < u (i+1,j) ∨ u (i,j) < u (i,j+1) ∨ + u (i,j) < u (i-1,j) ∨ u (i,j) < u (i,j-1)) : + ∀ i j, c < u (i,j) → coeff a i j = 0 := by + classical + let T : Set (ℕ × ℕ) := {v : ℕ × ℕ | coeff a v.1 v.2 ≠ 0 ∧ c < u v} + have hT : T.Finite := (finite_coeff_support a).subset (fun _ h => h.1) + by_contra hall + push Not at hall + obtain ⟨i,j,hij,hne⟩ := hall + have hneT : T.Nonempty := ⟨(i,j),hne,hij⟩ + obtain ⟨v,hv,hmax⟩ := Set.exists_max_image T u hT hneT + have hvout : v ∉ {w | u w ≤ c} := not_le.mpr hv.2 + have hi : 0 < v.1 := by + by_contra h + have hz : v.1 = 0 := Nat.eq_zero_of_not_pos h + exact hv.1 (by simpa [hz] using hb.anchor_zero_axis₁ (by simpa only [← hz,Prod.mk.eta] using hvout)) + have hj : 0 < v.2 := by + by_contra h + have hz : v.2 = 0 := Nat.eq_zero_of_not_pos h + exact hv.1 (by simpa [hz] using hb.anchor_zero_axis₂ (by simpa only [← hz,Prod.mk.eta] using hvout)) + have hcontr (w : ℕ × ℕ) (hle : u v < u w) (he : coeff a v.1 v.2 = coeff a w.1 w.2) : False := by + have hw : w ∈ T := ⟨fun h => hv.1 (he.trans h),hv.2.trans hle⟩ + exact (not_lt_of_ge (hmax w hw)) hle + rcases hascent v.1 v.2 hv.2 hi hj with h|h|h|h + · exact hcontr (v.1+1,v.2) h (hb.anchor_eq_right (not_le.mpr (hv.2.trans h))) + · exact hcontr (v.1,v.2+1) h (hb.anchor_eq_up hvout (not_le.mpr (hv.2.trans h))) + · exact hcontr (v.1-1,v.2) h (hb.anchor_eq_left hvout hi) + · exact hcontr (v.1,v.2-1) h (hb.anchor_eq_down hvout (not_le.mpr (hv.2.trans h)) hj) + +structure FaceSupported (S : Set (ℕ × ℕ)) (a b : Chain) : Prop where + lower : ∀ i j, coeff a i j ≠ 0 → (i,j) ∈ S ∧ (i+1,j) ∈ S ∧ (i+1,j+1) ∈ S + upper : ∀ i j, coeff b i j ≠ 0 → (i,j) ∈ S ∧ (i,j+1) ∈ S ∧ (i+1,j+1) ∈ S + +lemma BoundarySupported.faceSupported {S : Set (ℕ × ℕ)} {a b : Chain} + (hb : BoundarySupported S a b) (ha : ∀ i j, (i,j) ∉ S → coeff a i j = 0) : FaceSupported S a b := by + have hbzero (i j : ℕ) (hv : (i,j) ∉ S) : coeff b i j = 0 := + (hb.anchor_eq hv).symm.trans (ha i j hv) + have hdiag (i j : ℕ) (hv : (i+1,j+1) ∉ S) : coeff b i j = 0 := by + have hvv := hb.vertical (i+1) (j+1) (Or.inl hv) + have hhh := hb.horizontal i (j+1) (Or.inr hv) + simp only [faceV,coeff_sub,coeff_x_succ,hbzero _ _ hv,sub_zero] at hvv + simpa only [faceH,coeff_sub,coeff_y_succ,hvv,zero_sub,neg_eq_zero] using hhh + constructor + · intro i j hne + refine ⟨?_,?_,?_⟩ + · by_contra hv + exact hne (ha i j hv) + · by_contra hv + exact hne ((hb.anchor_eq_right hv).trans (ha (i+1) j hv)) + · by_contra hv + have h := hb.diagonal i j (Or.inr hv) + exact hne (by simpa only [faceD,coeff_sub,hdiag i j hv,zero_sub,neg_eq_zero] using h) + · intro i j hne + refine ⟨?_,?_,?_⟩ + · by_contra hv + exact hne (hbzero i j hv) + · by_contra hv + have h := hb.horizontal i (j+1) (Or.inl hv) + exact hne (by simpa only [faceH,coeff_sub,coeff_y_succ,ha _ _ hv,zero_sub,neg_eq_zero] using h) + · by_contra hv + exact hne (hdiag i j hv) + +lemma cycle_fills_sublevel {u : ℕ × ℕ → ℝ} {c : ℝ} {h v d : Chain} + (hc : boundary₁ h v d = 0) + (hH : ∀ i j, c < u (i,j) ∨ c < u (i+1,j) → coeff h i j = 0) + (hV : ∀ i j, c < u (i,j) ∨ c < u (i,j+1) → coeff v i j = 0) + (hD : ∀ i j, c < u (i,j) ∨ c < u (i+1,j+1) → coeff d i j = 0) + (hascent : ∀ i j, c < u (i,j) → 0 < i → 0 < j → + u (i,j) < u (i+1,j) ∨ u (i,j) < u (i,j+1) ∨ + u (i,j) < u (i-1,j) ∨ u (i,j) < u (i,j-1)) : + ∃ a b, faceH a b = h ∧ faceV a b = v ∧ faceD a b = d ∧ + FaceSupported {w | u w ≤ c} a b := by + obtain ⟨a,b,ha,hb,hd⟩ := cycle_fills hc + have hs : BoundarySupported {w | u w ≤ c} a b := by + constructor + · simpa only [ha,mem_ofPred_eq,not_le] using hH + · simpa only [hb,mem_ofPred_eq,not_le] using hV + · simpa only [hd,mem_ofPred_eq,not_le] using hD + refine ⟨a,b,ha,hb,hd,hs.faceSupported ?_⟩ + intro i j hi + exact hs.anchor_zero_of_ascent hascent i j (not_le.mp hi) + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/HalfPlane.lean b/lean/OAI/Analysis/StrictMeans/HalfPlane.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d8bbe2bbb14e3e9e19a6e365debdd78d044d356 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/HalfPlane.lean @@ -0,0 +1,274 @@ +import OAI.Analysis.StrictMeans.CompactFamily + +namespace OAI + +section +open Set Filter Metric Complex MeasureTheory +open scoped Topology ENNReal ComplexConjugate +open Set Filter Metric Complex +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology +open Set Filter Metric Complex Function +open scoped Topology + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +def cayleyToHalfPlane (w : ℂ) : ℂ := I * (1 + w) / (1 - w) + +theorem one_sub_ne_zero_of_mem_disk {w : ℂ} (hw : w ∈ ball (0 : ℂ) 1) : + 1 - w ≠ 0 := by + intro h + have : w = 1 := (sub_eq_zero.mp h).symm + simp [this] at hw + +theorem cayley_im_mul_norm_sq {w : ℂ} (hw : 1 - w ≠ 0) : + (cayleyToHalfPlane w).im * ‖1 - w‖ ^ 2 = 1 - ‖w‖ ^ 2 := by + rw [← Complex.normSq_eq_norm_sq, ← Complex.normSq_eq_norm_sq] + simp only [cayleyToHalfPlane, Complex.div_im] + have hsq : Complex.normSq (1 - w) ≠ 0 := (Complex.normSq_pos.mpr hw).ne' + field_simp + simp [Complex.normSq_apply, Complex.mul_re, Complex.mul_im] + ring + +theorem cayley_mem_halfPlane {w : ℂ} (hw : w ∈ ball (0 : ℂ) 1) : + 0 < (cayleyToHalfPlane w).im := by + have hn : ‖w‖ < 1 := by simpa using hw + have h := cayley_im_mul_norm_sq (one_sub_ne_zero_of_mem_disk hw) + have hpos : 0 < 1 - ‖w‖ ^ 2 := by nlinarith [norm_nonneg w] + have hp := lt_of_lt_of_eq hpos h.symm + exact (mul_pos_iff.mp hp).resolve_right (by + rintro ⟨_, hs⟩ + exact (not_lt_of_ge (sq_nonneg ‖1 - w‖)) hs) |>.1 + +theorem cayley_differentiableOn : + DifferentiableOn ℂ cayleyToHalfPlane (ball 0 1) := by + apply DifferentiableOn.div + · fun_prop + · fun_prop + · exact fun w hw => one_sub_ne_zero_of_mem_disk hw + +def cayleyToDisk (z : ℂ) : ℂ := (z - I) / (z + I) + +lemma add_I_ne_zero {z : ℂ} (hz : 0 < z.im) : z + I ≠ 0 := by + intro h + have := congrArg Complex.im h + simp only [add_im, I_im, zero_im] at this + linarith + +lemma cayleyToDisk_mem {z : ℂ} (hz : 0 < z.im) : + cayleyToDisk z ∈ ball (0 : ℂ) 1 := by + rw [mem_ball, dist_zero_right, cayleyToDisk, norm_div, + div_lt_one (norm_pos_iff.mpr (add_I_ne_zero hz))] + have hsq : ‖z + I‖ ^ 2 - ‖z - I‖ ^ 2 = 4 * z.im := by + rw [Complex.sq_norm, Complex.sq_norm] + simp only [normSq_apply, add_re, I_re, add_zero, add_im, I_im, + sub_re, sub_zero, sub_im] + ring + nlinarith [norm_nonneg (z + I), norm_nonneg (z - I)] + +@[simp] lemma cayleyToDisk_I : cayleyToDisk I = 0 := by simp [cayleyToDisk] +@[simp] lemma cayleyToHalfPlane_zero : cayleyToHalfPlane 0 = I := by simp [cayleyToHalfPlane] + +lemma cayleyToHalfPlane_toDisk {z : ℂ} (hz : 0 < z.im) : + cayleyToHalfPlane (cayleyToDisk z) = z := by + have hd := add_I_ne_zero hz + have hi := one_sub_ne_zero_of_mem_disk (cayleyToDisk_mem hz) + dsimp only [cayleyToHalfPlane, cayleyToDisk] at hi ⊢ + field_simp + ring + +lemma cayleyToDisk_toHalfPlane {w : ℂ} (hw : w ∈ ball (0 : ℂ) 1) : + cayleyToDisk (cayleyToHalfPlane w) = w := by + have hd := one_sub_ne_zero_of_mem_disk hw + have hi := add_I_ne_zero (cayley_mem_halfPlane hw) + dsimp only [cayleyToDisk, cayleyToHalfPlane] at hi ⊢ + field_simp + ring + +lemma cayleyToDisk_hasDerivAt {z : ℂ} (hz : 0 < z.im) : + HasDerivAt cayleyToDisk (2 * I / (z + I) ^ 2) z := by + convert! ((hasDerivAt_id z).sub_const I).div ((hasDerivAt_id z).add_const I) + (add_I_ne_zero hz) using 1; simp + ring + +lemma cayleyToHalfPlane_hasDerivAt {w : ℂ} (hw : w ∈ ball (0 : ℂ) 1) : + HasDerivAt cayleyToHalfPlane (2 * I / (1 - w) ^ 2) w := by + convert! (((hasDerivAt_id w).const_add 1).const_mul I).div + ((hasDerivAt_id w).const_sub 1) (one_sub_ne_zero_of_mem_disk hw) using 1; + simp + ring + +lemma cayleyToDisk_differentiableOn : + DifferentiableOn ℂ cayleyToDisk {z : ℂ | 0 < z.im} := + fun _ hz => (cayleyToDisk_hasDerivAt hz).differentiableAt.differentiableWithinAt + +lemma cayleyToDisk_injOn : InjOn cayleyToDisk {z : ℂ | 0 < z.im} := by + intro z hz w hw h + have := congrArg cayleyToHalfPlane h + simpa only [cayleyToHalfPlane_toDisk hz, cayleyToHalfPlane_toDisk hw] using this + +lemma cayleyToHalfPlane_injOn : InjOn cayleyToHalfPlane (ball 0 1) := by + intro z hz w hw h + have := congrArg cayleyToDisk h + simpa only [cayleyToDisk_toHalfPlane hz, cayleyToDisk_toHalfPlane hw] using this + +def affineAt (z : UpperHalfPlane) (w : ℂ) : ℂ := z.re + (z.im : ℂ) * w + +@[simp] lemma affineAt_im (z : UpperHalfPlane) (w : ℂ) : + (affineAt z w).im = z.im * w.im := by simp [affineAt] + +@[simp] lemma affineAt_re (z : UpperHalfPlane) (w : ℂ) : + (affineAt z w).re = z.re + z.im * w.re := by simp [affineAt] + +lemma affineAt_mapsTo (z : UpperHalfPlane) : + MapsTo (affineAt z) {w : ℂ | 0 < w.im} {w : ℂ | 0 < w.im} := by + intro w hw + simpa only [mem_ofPred_eq, affineAt_im] using mul_pos z.im_pos hw + +lemma affineAt_injective (z : UpperHalfPlane) : Injective (affineAt z) := by + intro a b hab + exact mul_left_cancel₀ (Complex.ofReal_ne_zero.mpr z.im_ne_zero) (add_left_cancel hab) + +lemma affineAt_hasDerivAt (z : UpperHalfPlane) (w : ℂ) : + HasDerivAt (affineAt z) (z.im : ℂ) w := by + convert! ((hasDerivAt_id w).const_mul (z.im : ℂ)).const_add (z.re : ℂ) using 1 + simp + +@[simp] lemma affineAt_I (z : UpperHalfPlane) : affineAt z I = z := z.re_add_im + +@[simp] lemma affineAt_one (w : ℂ) : affineAt UpperHalfPlane.I w = w := by + simp [affineAt] + +def affineProduct (z w : UpperHalfPlane) : UpperHalfPlane := + ⟨affineAt z w, affineAt_mapsTo z w.im_pos⟩ + +@[simp] lemma coe_affineProduct (z w : UpperHalfPlane) : + (affineProduct z w : ℂ) = affineAt z w := rfl + +lemma affineAt_assoc (z w : UpperHalfPlane) (u : ℂ) : + affineAt z (affineAt w u) = affineAt (affineProduct z w) u := by + change (z.re : ℂ) + (z.im : ℂ) * ((w.re : ℂ) + (w.im : ℂ) * u) = + ((affineAt z w).re : ℂ) + ((affineAt z w).im : ℂ) * u + rw [affineAt_re, affineAt_im] + change (z.re : ℂ) + (z.im : ℂ) * ((w.re : ℂ) + (w.im : ℂ) * u) = + ((z.re + z.im * w.re : ℝ) : ℂ) + ((z.im * w.im : ℝ) : ℂ) * u + push_cast + ring + +lemma affineProduct_assoc (z w u : UpperHalfPlane) : + affineProduct (affineProduct z w) u = affineProduct z (affineProduct w u) := by + apply UpperHalfPlane.ext + exact (affineAt_assoc z w u).symm + +def affineInverse (z : UpperHalfPlane) : UpperHalfPlane := + ⟨(-(z.re : ℂ) + I) / (z.im : ℂ), by + simpa [Complex.div_im, pow_two] using + (div_pos z.im_pos (sq_pos_of_pos z.im_pos))⟩ + +lemma affineAt_inverse (z : UpperHalfPlane) : + affineAt z (affineInverse z) = I := by + dsimp [affineAt, affineInverse] + field_simp [Complex.ofReal_ne_zero.mpr z.im_ne_zero] + ring + +end +end StrictInverseFirstPower + +open Set Filter Metric Complex Function +open scoped Topology + +namespace StrictInverseFirstPower +noncomputable section + +def halfPlaneFunction (f : DiskFamily) (z : ℂ) : ℂ := + 2 * I * diskExtension f.val (cayleyToDisk z) + +lemma halfPlaneFunction_differentiableOn (f : DiskFamily) : + DifferentiableOn ℂ (halfPlaneFunction f) {z : ℂ | 0 < z.im} := by + exact (f.property.1.comp cayleyToDisk_differentiableOn + (fun _ hz => cayleyToDisk_mem hz)).const_mul (2 * I) + +lemma halfPlaneFunction_injOn (f : DiskFamily) : + InjOn (halfPlaneFunction f) {z : ℂ | 0 < z.im} := by + intro z hz w hw h + apply cayleyToDisk_injOn hz hw + apply f.property.2.1 (cayleyToDisk_mem hz) (cayleyToDisk_mem hw) + exact mul_left_cancel₀ (by simp : (2 : ℂ) * I ≠ 0) h + +@[simp] lemma halfPlaneFunction_I (f : DiskFamily) : halfPlaneFunction f I = 0 := by + simp [halfPlaneFunction, f.property.2.2.1] + +lemma halfPlaneFunction_hasDerivAt (f : DiskFamily) {z : ℂ} (hz : 0 < z.im) : + HasDerivAt (halfPlaneFunction f) + (2 * I * (deriv (diskExtension f.val) (cayleyToDisk z) * + (2 * I / (z + I) ^ 2))) z := by + exact ((f.property.1.differentiableAt + (isOpen_ball.mem_nhds (cayleyToDisk_mem hz))).hasDerivAt.comp z + (cayleyToDisk_hasDerivAt hz)).const_mul (2 * I) + +lemma halfPlaneFunction_deriv (f : DiskFamily) {z : ℂ} (hz : 0 < z.im) : + deriv (halfPlaneFunction f) z = + 2 * I * (deriv (diskExtension f.val) (cayleyToDisk z) * + (2 * I / (z + I) ^ 2)) := + (halfPlaneFunction_hasDerivAt f hz).deriv + +@[simp] lemma halfPlaneFunction_deriv_I (f : DiskFamily) : + deriv (halfPlaneFunction f) I = 1 := by + rw [halfPlaneFunction_deriv f (by simp), cayleyToDisk_I, f.property.2.2.2] + field_simp + norm_num [Complex.I_sq] + +lemma halfPlaneFunction_deriv_ne_zero (f : DiskFamily) {z : ℂ} (hz : 0 < z.im) : + deriv (halfPlaneFunction f) z ≠ 0 := by + rw [halfPlaneFunction_deriv f hz] + exact mul_ne_zero (by simp) (mul_ne_zero + (diskFamily_derivative_ne_zero f ⟨_, cayleyToDisk_mem hz⟩) + (div_ne_zero (by simp) (pow_ne_zero _ (add_I_ne_zero hz)))) + +def cayleyDiskMap : C(UpperHalfPlane, UnitDisk) := + ⟨fun z => ⟨cayleyToDisk z, cayleyToDisk_mem z.im_pos⟩, + ((cayleyToDisk_differentiableOn.continuousOn.comp_continuous + UpperHalfPlane.continuous_coe (fun z => z.im_pos))).subtype_mk _⟩ + +lemma continuous_halfPlaneFunction : + Continuous (fun p : DiskFamily × UpperHalfPlane => halfPlaneFunction p.1 p.2) := by + have h : Continuous (fun p : DiskFamily × UpperHalfPlane => + 2 * I * p.1.val (cayleyDiskMap p.2)) := + continuous_const.mul ((continuous_subtype_val.comp continuous_fst).eval + (cayleyDiskMap.continuous.comp continuous_snd)) + exact h.congr (fun p => by + simp only [halfPlaneFunction, cayleyDiskMap, ContinuousMap.coe_mk, + diskExtension, dite_eq_left (cayleyToDisk_mem p.2.im_pos)]) + +lemma continuous_halfPlaneFunction_deriv : + Continuous (fun p : DiskFamily × UpperHalfPlane => deriv (halfPlaneFunction p.1) p.2) := by + have hh : (fun p : DiskFamily × UpperHalfPlane => deriv (halfPlaneFunction p.1) p.2) = + fun p => 2 * I * (deriv (diskExtension p.1.val) (cayleyToDisk p.2) * + (2 * I / ((p.2 : ℂ) + I) ^ 2)) := by + funext p + exact halfPlaneFunction_deriv p.1 p.2.im_pos + rw [hh] + apply Continuous.mul continuous_const + apply Continuous.mul + · exact continuous_diskFamily_derivative.comp + (continuous_fst.prodMk (cayleyDiskMap.continuous.comp continuous_snd)) + · apply Continuous.div continuous_const + · exact ((UpperHalfPlane.continuous_coe.comp continuous_snd).add continuous_const).pow 2 + · intro p + exact pow_ne_zero _ (add_I_ne_zero p.2.im_pos) + +end +end StrictInverseFirstPower + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/HeightIndex.lean b/lean/OAI/Analysis/StrictMeans/HeightIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..54c7967d3b34375c1ae60eb99e64550b6863dbb9 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/HeightIndex.lean @@ -0,0 +1,69 @@ +import OAI.Analysis.StrictMeans.IndexConservation + +namespace OAI + +section +open Set Function +namespace StrictInverseFirstPower.Grid +noncomputable section +variable {V : Type*} [LinearOrder V] + +def heightRank (u : V → ℝ) (v : V) : Lex (ℝ × V) := toLex (u v,v) + +omit [LinearOrder V] in +lemma heightRank_injective (u : V → ℝ) : Injective (heightRank u) := by + intro a b h + exact congrArg (fun t : Lex (ℝ × V) => (ofLex t).2) h + +lemma heightRank_lt_imp_le {u : V → ℝ} {a b : V} (h : heightRank u a < heightRank u b) : u a ≤ u b := by + rw [heightRank,heightRank,Prod.Lex.toLex_lt_toLex] at h + rcases h with h | h + · exact h.le + · exact h.1.le + +lemma heightRank_not_lt_imp_le {u : V → ℝ} {a b : V} (h : ¬ heightRank u a < heightRank u b) : u b ≤ u a := by + by_contra hh + apply h + rw [heightRank,heightRank,Prod.Lex.toLex_lt_toLex] + exact Or.inl (lt_of_not_ge hh) + +lemma heightRank_signBound {u : V → ℝ} {a b : V} {g e : ℝ} + (herror : |u a-u b-g| ≤ e) : + signBound (decide (heightRank u a < heightRank u b)) g e := by + by_cases h : heightRank u a < heightRank u b + · have hh := heightRank_lt_imp_le h + have he := (abs_le.mp herror).1 + simpa [signBound,h] using (show g ≤ e by linarith) + · have hh := heightRank_not_lt_imp_le h + have he := (abs_le.mp herror).2 + simpa [signBound,h] using (show -e ≤ g by linarith) + +variable [AddCommGroup V] + +def heightIndex (u : V → ℝ) (x y v : V) : ℤ := meshIndex (heightRank u) x y v + +lemma heightIndex_regular {u : V → ℝ} {x y v : V} {gx gy e : ℝ} + (hreg : 2*e < |gx| ∨ 2*e < |gy|) (he : 0 ≤ e) + (h₀ : |u (v+x)-u v-gx| ≤ e) + (h₁ : |u (v+x+y)-u v-(gx+gy)| ≤ e) + (h₂ : |u (v+y)-u v-gy| ≤ e) + (h₃ : |u (v-x)-u v-(-gx)| ≤ e) + (h₄ : |u (v-(x+y))-u v-(-gx-gy)| ≤ e) + (h₅ : |u (v-y)-u v-(-gy)| ≤ e) : heightIndex u x y v = 0 := by + rw [heightIndex,meshIndex_eq_linkIndex] + exact regular_link hreg he (heightRank_signBound h₀) (heightRank_signBound h₁) + (heightRank_signBound h₂) (heightRank_signBound h₃) (heightRank_signBound h₄) + (heightRank_signBound h₅) + +lemma heightIndex_finite_change {u w : V → ℝ} (hfin : {v | u v ≠ w v}.Finite) + {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) (hd : x+y ≠ 0) : + ∑ᶠ v, (heightIndex u x y v-heightIndex w x y v) = 0 := by + apply meshIndex_change_finsum_zero (heightRank_injective u) (heightRank_injective w) _ hx hy hd + exact hfin.subset fun v hv he => hv (by simp only [heightRank,he]) + +end +end StrictInverseFirstPower.Grid + +end + +end OAI diff --git a/lean/OAI/Analysis/StrictMeans/HessianLocal.lean b/lean/OAI/Analysis/StrictMeans/HessianLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d0b52a103d031aaf8422d76ccbec82ab8bc7401 --- /dev/null +++ b/lean/OAI/Analysis/StrictMeans/HessianLocal.lean @@ -0,0 +1,168 @@ +import OAI.Analysis.StrictMeans.QuadraticHomotopy + +namespace OAI + +section +open Set Function Filter +open scoped Topology +namespace StrictInverseFirstPower.Grid +noncomputable section + +lemma complex_real_decomposition (z : ℂ) : z.re • (1:ℂ)+z.im • Complex.I=z := by + apply Complex.ext <;> simp + +lemma realCLM_apply (L : ℂ →L[ℝ] ℝ) (z : ℂ) : + L z=z.re*L 1+z.im*L Complex.I := by + conv_lhs => rw [← complex_real_decomposition z] + simp only [map_add,map_smul,smul_eq_mul] + +lemma realCLM_eq_zero {L : ℂ →L[ℝ] ℝ} (hx : L 1=0) (hy : L Complex.I=0) : L=0 := by + ext z + simp [realCLM_apply L z,hx,hy] + +def planeCLM (a b : ℝ) : ℂ →L[ℝ] ℝ := a•Complex.reCLM+b•Complex.imCLM + +@[simp] lemma planeCLM_apply (a b : ℝ) (z : ℂ) : planeCLM a b z=a*z.re+b*z.im := by + simp [planeCLM] + +def hessianCLM (a b c : ℝ) : ℂ →L[ℝ] (ℂ →L[ℝ] ℝ) := + Complex.reCLM.smulRight (planeCLM a b)+Complex.imCLM.smulRight (planeCLM b c) + +lemma hessianCLM_apply (a b c : ℝ) (z w : ℂ) : + hessianCLM a b c z w=(a*z.re+b*z.im)*w.re+(b*z.re+c*z.im)*w.im := by + simp [hessianCLM] + ring + +lemma hessianCLM_injective {a b c : ℝ} (hD : a*c-b^2≠0) : Injective (hessianCLM a b c) := by + apply (hessianCLM a b c).toLinearMap.ker_eq_bot.mp + apply LinearMap.ker_eq_bot'.mpr + intro z hz + change hessianCLM a b c z=0 at hz + have hx := congrArg (fun L : ℂ →L[ℝ] ℝ =>L 1) hz + have hy := congrArg (fun L : ℂ →L[ℝ] ℝ =>L Complex.I) hz + simp only [hessianCLM_apply,Complex.one_re,Complex.one_im,Complex.I_re,Complex.I_im, + mul_one,mul_zero,zero_add,add_zero,zero_apply] at hx hy + have hxr : z.re=0 := (mul_eq_zero.mp (show (a*c-b^2)*z.re=0 by linear_combination c*hx-b*hy)).resolve_left hD + have hyr : z.im=0 := (mul_eq_zero.mp (show (a*c-b^2)*z.im=0 by linear_combination a*hy-b*hx)).resolve_left hD + exact Complex.ext (by simpa using hxr) (by simpa using hyr) + +lemma injectiveCLM_lower_bound {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] + {L : E →L[ℝ] F} (hL : Injective L) : ∃ m : ℝ, 0 < m ∧ ∀ z, m*‖z‖≤‖L z‖ := by + obtain ⟨K,hK,hBound⟩ := L.toLinearMap.exists_antilipschitzWith (LinearMap.ker_eq_bot.mpr hL) + have hKr : (0:ℝ)?_⟩ + have h := ZeroHomClass.bound_of_antilipschitz L hBound z + rw [inv_mul_le_iff₀ hKr] + exact h + +lemma hessianCLM_of_second {u : ℂ → ℝ} {p : ℂ} (hu : ContDiffAt ℝ 2 u p) : + fderiv ℝ (fderiv ℝ u) p = + hessianCLM (fderiv ℝ (fderiv ℝ u) p 1 1) + (fderiv ℝ (fderiv ℝ u) p 1 Complex.I) + (fderiv ℝ (fderiv ℝ u) p Complex.I Complex.I) := by + let L := fderiv ℝ (fderiv ℝ u) p + have hsym := (hu.isSymmSndFDerivAt (by norm_num)).eq 1 Complex.I + change L 1 Complex.I=L Complex.I 1 at hsym + ext z w + rw [hessianCLM_apply,realCLM_apply (L z) w] + have he : L z=z.re•L 1+z.im•L Complex.I := by + conv_lhs => rw [← complex_real_decomposition z] + simp only [map_add,map_smul] + rw [he] + simp only [add_apply,smul_apply,smul_eq_mul] + rw [← hsym] + ring + +lemma quadratic_contDiff (a b c : ℝ) : ContDiff ℝ ⊤ (quadratic a b c) := by + have hr := Complex.reCLM.contDiff (n := (⊤ : WithTop ℕ∞)) + have hi := Complex.imCLM.contDiff (n := (⊤ : WithTop ℕ∞)) + exact (((contDiff_const.mul (hr.pow 2)).add (((contDiff_const.mul hr).mul hi))).add + (contDiff_const.mul (hi.pow 2))).div_const 2 + +lemma quadratic_fderiv (a b c : ℝ) (z : ℂ) : + fderiv ℝ (quadratic a b c) z=hessianCLM a b c z := by + have hr := quadraticFamily_dx (A:=fun _=>a) (B:=fun _=>b) (C:=fun _=>c) (p:=0) + (q:=(0,z)) ((quadraticFamily_contDiff contDiff_const contDiff_const contDiff_const 0).differentiable (by norm_num : (1 : WithTop ℕ∞)≠0) (0,z)) + have hi := quadraticFamily_dy (A:=fun _=>a) (B:=fun _=>b) (C:=fun _=>c) (p:=0) + (q:=(0,z)) ((quadraticFamily_contDiff contDiff_const contDiff_const contDiff_const 0).differentiable (by norm_num : (1 : WithTop ℕ∞)≠0) (0,z)) + have he : quadraticFamily (fun _=>a) (fun _=>b) (fun _=>c) 0 = quadratic a b c ∘ Prod.snd := by + funext q; simp [quadraticFamily] + have hf : HasFDerivAt (quadratic a b c ∘ Prod.snd) + ((fderiv ℝ (quadratic a b c) z).comp (ContinuousLinearMap.snd ℝ ℝ ℂ)) ((0:ℝ),z) := + ((quadratic_contDiff a b c).differentiable (by simp) z).hasFDerivAt.comp ((0:ℝ),z) + (hasFDerivAt_snd (𝕜 := ℝ) (p := ((0:ℝ),z))) + rw [he,hf.fderiv] at hr hi + simp only [ContinuousLinearMap.comp_apply,ContinuousLinearMap.coe_snd',sub_zero] at hr hi + ext w + rw [realCLM_apply _ w,hr,hi,hessianCLM_apply] + ring + +def affinePotential (u v : ℂ → ℝ) (q : ℝ × ℂ) : ℝ := (1-q.1)*u q.2+q.1*v q.2 + +lemma affinePotential_contDiffAt {u v : ℂ → ℝ} {q : ℝ × ℂ} + (hu : ContDiffAt ℝ 1 u q.2) (hv : ContDiffAt ℝ 1 v q.2) : + ContDiffAt ℝ 1 (affinePotential u v) q := by + exact (((contDiffAt_const.sub contDiffAt_fst).mul (hu.comp q contDiffAt_snd)).add + (contDiffAt_fst.mul (hv.comp q contDiffAt_snd))) + +lemma affinePotential_spatial {u v : ℂ → ℝ} {q : ℝ × ℂ} + (hu : DifferentiableAt ℝ u q.2) (hv : DifferentiableAt ℝ v q.2) (d : ℂ) : + fderiv ℝ (affinePotential u v) q (0,d)= + (1-q.1)*fderiv ℝ u q.2 d+q.1*fderiv ℝ v q.2 d := by + have hU := hu.hasFDerivAt.comp q hasFDerivAt_snd + have hV := hv.hasFDerivAt.comp q hasFDerivAt_snd + have hT := hasFDerivAt_fst (𝕜 := ℝ) (p := q) + have hd := ((hasFDerivAt_const (1:ℝ) q).sub hT).mul hU |>.add (hT.mul hV) + change fderiv ℝ (((fun _ : ℝ × ℂ => (1:ℝ))-Prod.fst) * (u ∘ Prod.snd) + + (Prod.fst * (v ∘ Prod.snd))) q (0,d) = _ + rw [hd.fderiv] + simp + +lemma local_quadratic_homotopy_regular {u : ℂ → ℝ} {p : ℂ} + (hu : ContDiffAt ℝ 2 u p) (hp : fderiv ℝ u p=0) + (hD : (fderiv ℝ (fderiv ℝ u) p 1 1)* + (fderiv ℝ (fderiv ℝ u) p Complex.I Complex.I)- + (fderiv ℝ (fderiv ℝ u) p 1 Complex.I)^2≠0) : + let a := fderiv ℝ (fderiv ℝ u) p 1 1 + let b := fderiv ℝ (fderiv ℝ u) p 1 Complex.I + let c := fderiv ℝ (fderiv ℝ u) p Complex.I Complex.I + ∀ᶠ z in 𝓝 p, z≠p → ∀ t∈Icc (0:ℝ) 1, + ∃ L : (ℝ × ℂ) →L[ℝ] ℝ, + HasStrictFDerivAt (affinePotential u (fun w=>quadratic a b c (w-p))) L (t,z) ∧ + (L (0,1)≠0 ∨ L (0,Complex.I)≠0) := by + dsimp only + let a := fderiv ℝ (fderiv ℝ u) p 1 1 + let b := fderiv ℝ (fderiv ℝ u) p 1 Complex.I + let c := fderiv ℝ (fderiv ℝ u) p Complex.I Complex.I + obtain ⟨m,hm,hH⟩ := injectiveCLM_lower_bound (hessianCLM_injective hD) + have hg : HasFDerivAt (fderiv ℝ u) (hessianCLM a b c) p := by + rw [← hessianCLM_of_second hu] + exact (hu.fderiv_right (m:=1) (by norm_num)).differentiableAt one_ne_zero |>.hasFDerivAt + have hreg := derivative_homotopy_regular hg hp hm hH + have hQ : ContDiff ℝ 1 (fun w=>quadratic a b c (w-p)) := + (quadratic_contDiff a b c).of_le (by simp) |>.comp (contDiff_id.sub contDiff_const) + have hQd (z : ℂ) : fderiv ℝ (fun w=>quadratic a b c (w-p)) z=hessianCLM a b c (z-p) := by + have he := ((quadratic_contDiff a b c).differentiable (by simp) (z-p)).hasFDerivAt.comp z + ((hasFDerivAt_id z).sub_const p) + change fderiv ℝ (quadratic a b c ∘ fun x => id x-p) z = _ + rw [he.fderiv,quadratic_fderiv] + ext d; simp + filter_upwards [hreg,(hu.of_le (by norm_num : (1 : WithTop ℕ∞)≤2)).eventually (by norm_num)] with z hz hzu + intro hzp t ht + have hd := affinePotential_contDiffAt hzu hQ.contDiffAt (q := (t,z)) + refine ⟨_,hd.hasStrictFDerivAt one_ne_zero,?_⟩ + rw [affinePotential_spatial (hzu.differentiableAt one_ne_zero) (hQ.differentiable one_ne_zero z), + affinePotential_spatial (hzu.differentiableAt one_ne_zero) (hQ.differentiable one_ne_zero z),hQd] + by_contra hn + obtain ⟨hx,hy⟩ := not_or.mp hn + simp only [not_not] at hx hy + apply hz hzp t ht + exact realCLM_eq_zero hx hy + +end +end StrictInverseFirstPower.Grid + +end + +end OAI