From 61f09e54aca0acd8e7ae00356bf303e500f9caa7 Mon Sep 17 00:00:00 2001 From: AbPh Lean Date: Fri, 27 Nov 2026 10:34:28 -0700 Subject: [PATCH 1/2] Add C196 matching round-area masking rates --- LeanPool/VenNullClockRoundRates.lean | 41 ++ LeanPool/VenNullClockRoundRates/Filter.lean | 123 ++++++ LeanPool/VenNullClockRoundRates/Finite.lean | 100 +++++ LeanPool/VenNullClockRoundRates/Geometry.lean | 99 +++++ LeanPool/VenNullClockRoundRates/Imports.lean | 30 ++ LeanPool/VenNullClockRoundRates/Layer.lean | 82 ++++ LeanPool/VenNullClockRoundRates/Lower.lean | 123 ++++++ LeanPool/VenNullClockRoundRates/Pole.lean | 68 +++ .../RoundAreaBridge.lean | 127 ++++++ .../RoundAreaCutoffInputs.lean | 178 ++++++++ .../RoundAreaPositiveStrips.lean | 224 ++++++++++ .../RoundAreaUpperHemisphere.lean | 393 ++++++++++++++++++ .../VenNullClockRoundRates/SphereModel.lean | 51 +++ .../VenRateUpperAssembly.lean | 206 +++++++++ .../VenRateUpperBudget.lean | 167 ++++++++ .../VenRateUpperBump.lean | 51 +++ .../VenRateUpperClassGap.lean | 248 +++++++++++ .../VenRateUpperHeight.lean | 379 +++++++++++++++++ .../VenRateUpperPhysical.lean | 121 ++++++ .../VenRateUpperPositive.lean | 106 +++++ .../VenRateUpperRoundRates.lean | 71 ++++ .../VenRateUpperStrips.lean | 111 +++++ .../VenRateUpperTaylor.lean | 120 ++++++ .../projects/ven-null-clock-round-rates.yaml | 36 ++ 24 files changed, 3255 insertions(+) create mode 100644 LeanPool/VenNullClockRoundRates.lean create mode 100644 LeanPool/VenNullClockRoundRates/Filter.lean create mode 100644 LeanPool/VenNullClockRoundRates/Finite.lean create mode 100644 LeanPool/VenNullClockRoundRates/Geometry.lean create mode 100644 LeanPool/VenNullClockRoundRates/Imports.lean create mode 100644 LeanPool/VenNullClockRoundRates/Layer.lean create mode 100644 LeanPool/VenNullClockRoundRates/Lower.lean create mode 100644 LeanPool/VenNullClockRoundRates/Pole.lean create mode 100644 LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean create mode 100644 LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean create mode 100644 LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean create mode 100644 LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean create mode 100644 LeanPool/VenNullClockRoundRates/SphereModel.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean create mode 100644 LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean create mode 100644 LeanPool/projects/ven-null-clock-round-rates.yaml diff --git a/LeanPool/VenNullClockRoundRates.lean b/LeanPool/VenNullClockRoundRates.lean new file mode 100644 index 0000000000..61522f85c3 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates.lean @@ -0,0 +1,41 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.Filter +public import LeanPool.VenNullClockRoundRates.Finite +public import LeanPool.VenNullClockRoundRates.Geometry +public import LeanPool.VenNullClockRoundRates.Layer +public import LeanPool.VenNullClockRoundRates.Lower +public import LeanPool.VenNullClockRoundRates.Pole +public import LeanPool.VenNullClockRoundRates.RoundAreaBridge +public import LeanPool.VenNullClockRoundRates.RoundAreaCutoffInputs +public import LeanPool.VenNullClockRoundRates.RoundAreaPositiveStrips +public import LeanPool.VenNullClockRoundRates.RoundAreaUpperHemisphere +public import LeanPool.VenNullClockRoundRates.SphereModel +public import LeanPool.VenNullClockRoundRates.VenRateUpperAssembly +public import LeanPool.VenNullClockRoundRates.VenRateUpperBudget +public import LeanPool.VenNullClockRoundRates.VenRateUpperBump +public import LeanPool.VenNullClockRoundRates.VenRateUpperClassGap +public import LeanPool.VenNullClockRoundRates.VenRateUpperHeight +public import LeanPool.VenNullClockRoundRates.VenRateUpperPhysical +public import LeanPool.VenNullClockRoundRates.VenRateUpperPositive +public import LeanPool.VenNullClockRoundRates.VenRateUpperRoundRates +public import LeanPool.VenNullClockRoundRates.VenRateUpperStrips +public import LeanPool.VenNullClockRoundRates.VenRateUpperTaylor + +/-! +# Matching masking rates for two-layer scans on normalized round area + +Source: url:https://github.com/VanGogh7777/c196-lean/blob/4f45e33dc5376b362e13601adee77a0a76358387/paper/C196_v0.3.pdf +Authors: Mark Gladden +Status: verified +Main declarations: `VenRateUpper.matching_round_class_rates`, + `VenRateUpper.smooth_round_common_profile_error` +Tags: inverse problems, spherical measure, moment cancellation, Laplace transforms +MSC: 28A25, 44A10 +-/ diff --git a/LeanPool/VenNullClockRoundRates/Filter.lean b/LeanPool/VenNullClockRoundRates/Filter.lean new file mode 100644 index 0000000000..d731ccd54e --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Filter.lean @@ -0,0 +1,123 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import LeanPool.VenNullClockRoundRates.Geometry +public import Mathlib.Analysis.Complex.Exponential +public import Mathlib.MeasureTheory.Integral.Bochner.Set +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! The pole filter and its exact realization by finitely many exponential reads. -/ +@[expose] public section +noncomputable section +namespace VenRate +open MeasureTheory VenMask + +/-- Exponential difference filter that retains values near the energy pole. -/ +def poleFilter (h t : ℝ) : ℝ := 1 - (Real.exp (h * t) - 1) / (2 * h) + +theorem filter_bounds {h t : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (ht : t ∈ Set.Icc 0 1) : + 1 - t ≤ poleFilter h t ∧ poleFilter h t ≤ 1 - t / 2 := by + have ht0 := ht.1 + have h0 := mul_nonneg hh.le ht0 + have h1 : h * t ≤ 1 := (mul_le_mul_of_nonneg_left ht.2 hh.le).trans (by simpa using hh1) + have hn := Real.abs_exp_sub_one_le (x := h * t) (by rwa [abs_of_nonneg h0]) + rw [abs_of_nonneg h0] at hn + have hlo := (le_abs_self _).trans hn + have hhi := Real.add_one_le_exp (h * t) + unfold poleFilter + constructor + · apply sub_le_sub_left + apply (div_le_iff₀ (by positivity : 0 < 2 * h)).2 + linarith + · apply sub_le_sub_left + apply (le_div_iff₀ (by positivity : 0 < 2 * h)).2 + linarith + +private theorem filter_mem {h : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (y : UnitSphere) : + poleFilter h (firstEnergy y) ∈ Set.Icc (0 : ℝ) 1 := by + have hf := (en_bounds 0 y).1 + obtain ⟨hl, hu⟩ := filter_bounds hh hh1 hf + exact ⟨by linarith [hf.2], by linarith [hf.1]⟩ + +/-- Integral carrying the k-fold pole filter on the first energy. -/ +def filtered (μ : Measure UnitSphere) (U : UnitSphere → ℝ) (h : ℝ) (k : ℕ) (x : ℝ) : ℝ := + ∫ y, U y * Real.exp (x * firstEnergy y) * (poleFilter h (firstEnergy y)) ^ k ∂μ + +theorem weighted_integrable {μ : Measure UnitSphere} {U : UnitSphere → ℝ} + (hi : Integrable U μ) (x : ℝ) : + Integrable (fun y ↦ U y * Real.exp (x * firstEnergy y)) μ := by + apply hi.mul_bdd (c := Real.exp |x|) + ((Real.continuous_exp.comp (continuous_const.mul first_cont)).aestronglyMeasurable) + exact Filter.Eventually.of_forall fun y ↦ by + change ‖Real.exp (x * firstEnergy y)‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + apply Real.exp_le_exp.mpr + calc + x * firstEnergy y ≤ |x| * firstEnergy y := + mul_le_mul_of_nonneg_right (le_abs_self _) (en_bounds 0 y).1.1 + _ ≤ |x| := by simpa using mul_le_mul_of_nonneg_left (en_bounds 0 y).1.2 (abs_nonneg x) + +theorem filtered_integrable {μ : Measure UnitSphere} {U : UnitSphere → ℝ} + (hi : Integrable U μ) {h : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (k : ℕ) (x : ℝ) : + Integrable (fun y ↦ U y * Real.exp (x * firstEnergy y) * (poleFilter h (firstEnergy y)) ^ + k) μ := by + apply (weighted_integrable hi x).mul_bdd (c := 1) + · have hc : Continuous (fun y ↦ (poleFilter h (firstEnergy y)) ^ k) := by + unfold poleFilter + exact (continuous_const.sub (((Real.continuous_exp.comp (continuous_const.mul first_cont)).sub + continuous_const).div_const _)).pow _ + exact hc.aestronglyMeasurable + · exact Filter.Eventually.of_forall fun y ↦ by + rw [Real.norm_eq_abs, abs_of_nonneg (pow_nonneg (filter_mem hh hh1 y).1 _)] + exact pow_le_one₀ (filter_mem hh hh1 y).1 (filter_mem hh hh1 y).2 + +private theorem recur {μ : Measure UnitSphere} {U : UnitSphere → ℝ} (hi : Integrable U μ) + {h : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (k : ℕ) (x : ℝ) : + filtered μ U h (k + 1) x = + (1 + 1 / (2 * h)) * filtered μ U h k x - (1 / (2 * h)) * filtered μ U h k (x + h) := by + unfold filtered + rw [← integral_const_mul, ← integral_const_mul, + ← integral_sub ((filtered_integrable hi hh hh1 k x).const_mul _) + ((filtered_integrable hi hh hh1 k (x + h)).const_mul _)] + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro y + dsimp only + rw [add_mul x h, Real.exp_add, pow_succ] + unfold poleFilter + ring + +/-- Error amplification for the exact order-k finite difference. The samples are +the actual integrals at x, x + h, ..., x + kh, with the same density U throughout. -/ +theorem filter_error {μ : Measure UnitSphere} {U : UnitSphere → ℝ} (hi : Integrable U μ) + {h : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (k : ℕ) (x e : ℝ) + (H : ∀ j : ℕ, j ≤ k → |filtered μ U h 0 (x + j * h)| ≤ e) : + |filtered μ U h k x| ≤ (1 + 1 / h) ^ k * e := by + induction k generalizing x with + | zero => simpa using H 0 (by omega) + | succ k ih => + have hj (j : ℕ) (hl : j ≤ k) : |filtered μ U h 0 (x + h + j * h)| ≤ e := by + have he : x + h + j * h = x + (↑(j + 1 : ℕ) : ℝ) * h := by push_cast; ring + rw [he]; exact H (j + 1) (by omega) + have ha := ih x (fun j hj ↦ H j (by omega)) + have hb := ih (x + h) hj + set A := (1 + 1 / (2 * h)) + set B := (1 / (2 * h)) + have hA : 0 ≤ A := by dsimp [A]; positivity + have hB : 0 ≤ B := by dsimp [B]; positivity + rw [recur hi hh hh1 k x] + calc + _ ≤ |A * filtered μ U h k x| + |B * filtered μ U h k (x + h)| := abs_sub _ _ + _ ≤ A * ((1 + 1 / h) ^ k * e) + B * ((1 + 1 / h) ^ k * e) := by + rw [abs_mul, abs_mul, abs_of_nonneg hA, abs_of_nonneg hB] + exact add_le_add (mul_le_mul_of_nonneg_left ha hA) (mul_le_mul_of_nonneg_left hb hB) + _ = _ := by dsimp [A, B]; rw [pow_succ]; ring +end VenRate +end diff --git a/LeanPool/VenNullClockRoundRates/Finite.lean b/LeanPool/VenNullClockRoundRates/Finite.lean new file mode 100644 index 0000000000..cb15563ee3 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Finite.lean @@ -0,0 +1,100 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import LeanPool.VenNullClockRoundRates.Layer +public import LeanPool.VenNullClockRoundRates.Pole +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! A finite quantitative separation theorem for the actual two spherical layers. +Constants are independent of the degree, profiles, budget and angle of the +alternative. The uniform read error is an absolute, not relative, error. -/ +@[expose] public section +noncomputable section +open MeasureTheory VenMask +namespace VenRate + +theorem finite_layer_separation (μ : Measure UnitSphere) [IsFiniteMeasure μ] [μ.IsOpenPosMeasure] + {d b : ℝ} (hd : 0 < d) (hd1 : d ≤ 1) (hb : 0 < b) : + ∃ c K T R J : ℝ, 0 < c ∧ 0 < K ∧ 0 < R ∧ R < T ∧ T < 1 ∧ 0 < J ∧ + ∀ {θ a M ε h : ℝ} {w₀ w₁ : UnitSphere → ℝ} (k : ℕ), + d ≤ 1 - Real.cos θ ^ 2 → 0 < h → h ≤ 1 → (k : ℝ) * h ≤ a → + Integrable w₀ μ → Integrable w₁ μ → + (∀ᵐ y ∂μ, 1 ≤ w₀ y) → (∀ᵐ y ∂μ, 1 ≤ w₁ y) → + (∫ y, w₀ y ∂μ) ≤ M → (∫ y, w₁ y ∂μ) ≤ M → + DataClose μ w₀ w₁ θ b a ε → + c * T ^ k ≤ K * M * R ^ k + J * (1 + 1 / h) ^ k * ε := by + let e := d / 8 + let δ := e ^ 4 + have he : 0 < e := by dsimp [e]; positivity + have he1 : e < 1 := by dsimp [e]; linarith + have ee : e ^ 2 < 1 := by nlinarith [mul_pos (sub_pos.mpr he1) (by linarith : 0 < 1 + e)] + have hδ : 0 < δ := pow_pos he _ + have hdlt : δ < e ^ 2 := by + dsimp [δ]; nlinarith only [mul_pos (sq_pos_of_pos he) (sub_pos.mpr ee)] + have hδ1 := hdlt.trans ee + let lo := Real.exp (b * δ) + let hi := Real.exp (b * e ^ 2) + let τ := (hi + lo) / 2 + let g := (hi - lo) / 2 + let B := Real.exp b + τ + have gap : lo < hi := Real.exp_lt_exp.mpr (mul_lt_mul_of_pos_left hdlt hb) + have hh : 0 < hi := Real.exp_pos _ + have hl : 0 < lo := Real.exp_pos _ + have ht : 0 < τ := by dsimp [τ]; positivity + have hg : 0 < g := by dsimp [g]; linarith + have hB : 0 < B := by dsimp [B]; positivity + have hc := cap_pos μ (show 0 < δ / 4 by positivity) + refine ⟨μ.real {y | firstEnergy y < δ / 4}*g, 2 * B, 1 - δ / 4, 1 - δ / 2, 1 + τ, + mul_pos hc hg, by positivity, by linarith, by linarith, by linarith, by positivity,?_⟩ + intro θ a M ε h w₀ w₁ k hangle hhpos hh1 hgrid i₀ i₁ w₀floor w₁floor m₀ m₁ H + let U := density w₀ w₁ θ b τ + let W := fun y ↦ w₀ y + w₁ y + have intU : Integrable U μ := int_density i₀ i₁ hb.le + have intW : Integrable W μ := i₀.add i₁ + have pt (y : UnitSphere) : + U y = w₁ y * (Real.exp (b * secondEnergy θ y) - τ) + + w₀ y * (τ - Real.exp (b * firstEnergy y)) := by + dsimp [U, density, tilt]; ring + have Hbound : ∀ᵐ y ∂μ, 0 ≤ W y ∧ -(B * W y) ≤ U y ∧ (firstEnergy y ≤ δ → g ≤ U y) := by + filter_upwards [w₀floor, w₁floor] with y hy₀ hy₁ + have h₀ : 0 ≤ w₀ y := by linarith + have h₁ : 0 ≤ w₁ y := by linarith + have hE : Real.exp (b * firstEnergy y) ≤ Real.exp b := by + apply Real.exp_le_exp.mpr + simpa using mul_le_mul_of_nonneg_left (en_bounds θ y).1.2 hb.le + have Min₀ : -B ≤ τ - Real.exp (b * firstEnergy y) := by dsimp [B]; linarith + have Min₁ : -B ≤ Real.exp (b * secondEnergy θ y) - τ := by + dsimp [B]; linarith [Real.exp_pos b, Real.exp_pos (b * secondEnergy θ y)] + rw [pt]; dsimp [W] + refine ⟨add_nonneg h₀ h₁,?_,?_⟩ + · linarith only [mul_le_mul_of_nonneg_left Min₀ h₀, mul_le_mul_of_nonneg_left Min₁ h₁] + · intro near + have loy : Real.exp (b * firstEnergy y) ≤ lo := + Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left near hb.le) + have hiy : hi ≤ Real.exp (b * secondEnergy θ y) := + Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (cap_separation hd hd1 hangle y near) hb.le) + have g₀ : g ≤ τ - Real.exp (b * firstEnergy y) := by dsimp [g, τ]; linarith + have g₁ : g ≤ Real.exp (b * secondEnergy θ y) - τ := by dsimp [g, τ]; linarith + linarith only [mul_le_mul_of_nonneg_left g₀ h₀, mul_le_mul_of_nonneg_left g₁ h₁, + mul_le_mul_of_nonneg_right hy₁ hg.le, mul_nonneg h₀ hg.le] + have PM := pole_integral intU intW hhpos hh1 hδ hδ1.le hg.le hB.le Hbound k + have moment := filter_error intU hhpos hh1 k 0 ((1 + τ) * ε) (by + intro j hj + apply density_sample i₀ i₁ hb.le ht.le H + constructor + · positivity + · simp only [zero_add]; exact (mul_le_mul_of_nonneg_right (by exact_mod_cast hj) + hhpos.le).trans hgrid) + have sumW : (∫ y, W y ∂μ) ≤ 2 * M := by + dsimp [W]; rw [integral_add i₀ i₁]; linarith + have err := mul_le_mul_of_nonneg_left sumW + (mul_nonneg hB.le (pow_nonneg (by linarith : 0 ≤ 1 - δ / 2) k)) + linarith only [PM, le_abs_self (filtered μ U h k 0), moment, err] +end VenRate +end diff --git a/LeanPool/VenNullClockRoundRates/Geometry.lean b/LeanPool/VenNullClockRoundRates/Geometry.lean new file mode 100644 index 0000000000..05bf1ee02e --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Geometry.lean @@ -0,0 +1,99 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import LeanPool.VenNullClockRoundRates.SphereModel +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.FunProp +import Mathlib.Tactic.Ring + +/-! Physical cap separation for the two quadrupole clock kernels. -/ +@[expose] public section +noncomputable section +namespace VenRate +open MeasureTheory VenMask + +instance : OpensMeasurableSpace UnitSphere := inferInstanceAs + (OpensMeasurableSpace {q : ℝ × ℝ × ℝ // q.1 ^ 2 + q.2.1 ^ 2 + q.2.2 ^ 2 = 1}) + +theorem first_cont : Continuous firstEnergy := by + change Continuous (fun y : {q : ℝ × ℝ × ℝ // _} ↦ (1 - y.val.1 ^ 2) ^ 2) + fun_prop + +theorem second_cont (θ : ℝ) : Continuous (secondEnergy θ) := by + change Continuous (fun y : {q : ℝ × ℝ × ℝ // _} ↦ + (1 - (Real.cos θ * y.val.1 + Real.sin θ * y.val.2.1) ^ 2) ^ 2) + fun_prop + +private theorem eb {u : ℝ} (hu : u ^ 2 ≤ 1) : energy u ∈ Set.Icc (0 : ℝ) 1 := by + unfold energy + constructor + · positivity + · nlinarith only [sq_nonneg u, mul_nonneg (sq_nonneg u) (sub_nonneg.mpr hu)] + +theorem en_bounds (θ : ℝ) (y : UnitSphere) : + firstEnergy y ∈ Set.Icc (0 : ℝ) 1 ∧ secondEnergy θ y ∈ Set.Icc (0 : ℝ) 1 := by + have len := y.property + have alg : (Real.cos θ * y.val.1 + Real.sin θ * y.val.2.1) ^ 2 + + (Real.sin θ * y.val.1 - Real.cos θ * y.val.2.1) ^ 2 = + (Real.sin θ ^2 + Real.cos θ ^2) * (y.val.1 ^ 2 + y.val.2.1 ^ 2) := by ring + rw [Real.sin_sq_add_cos_sq, one_mul] at alg + exact ⟨eb (by nlinarith only [len, sq_nonneg y.val.2.1, sq_nonneg y.val.2.2]), + eb (by nlinarith only [len, alg, sq_nonneg (Real.sin θ * y.val.1 - Real.cos θ * y.val.2.1), + sq_nonneg y.val.2.2])⟩ + +/-- A uniform pole separation: the first energy is at most e⁴ while the second +is at least e² on the same cap. The aperture is independent of the alternative. -/ +theorem cap_separation {d θ : ℝ} (hd : 0 < d) (hd1 : d ≤ 1) + (hs : d ≤ 1 - Real.cos θ ^ 2) (y : UnitSphere) + (hp : firstEnergy y ≤ (d / 8) ^ 4) : (d / 8) ^ 2 ≤ secondEnergy θ y := by + set e := d / 8 with he + have he0 : 0 < e := by dsimp [e]; positivity + have he1 : e < 1 := by dsimp [e]; linarith + have len := y.property + have hxs : y.val.1 ^ 2 ≤ 1 := by nlinarith only [len, sq_nonneg y.val.2.1, sq_nonneg y.val.2.2] + have hx : |y.val.1| ≤ 1 := by nlinarith only [sq_abs y.val.1, hxs, abs_nonneg y.val.1] + have hy1 : y.val.2.1 ^ 2 ≤ 1 - y.val.1 ^ 2 := by nlinarith only [len, sq_nonneg y.val.2.2] + change (1 - y.val.1 ^ 2) ^ 2 ≤ e ^ 4 at hp + have hf : 1 - y.val.1 ^ 2 ≤ e ^ 2 := by + by_contra! no + nlinarith only [hp, mul_pos (sub_pos.mpr no) (by linarith [sq_nonneg e] : 0 < 1 - y.val.1 ^ 2 + + e ^ 2)] + have hy : |y.val.2.1| ≤ e := by + by_contra! no + nlinarith only [hy1, hf, sq_abs y.val.2.1, + mul_pos (sub_pos.mpr no) (by linarith [abs_nonneg y.val.2.1] : 0 < |y.val.2.1|+e)] + have hc : |Real.cos θ| ≤ 1 - 2 * e := by + by_contra! no + have : 0 < |Real.cos θ|+(1 - 2 * e) := by rw [he]; linarith [abs_nonneg (Real.cos θ)] + have h := mul_pos (sub_pos.mpr no) this + rw [he] at h + nlinarith only [h, sq_abs (Real.cos θ), hs, hd.le, sq_nonneg d] + have hsin : |Real.sin θ| ≤ 1 := abs_le.mpr ⟨Real.neg_one_le_sin _, Real.sin_le_one _⟩ + have hproj : |Real.cos θ * y.val.1 + Real.sin θ * y.val.2.1| ≤ 1 - e := by + calc + _ ≤ |Real.cos θ| * |y.val.1| + |Real.sin θ| * |y.val.2.1| := by + simpa only [abs_mul] using abs_add_le (Real.cos θ * y.val.1) (Real.sin θ * y.val.2.1) + _ ≤ (1 - 2 * e) * 1 + 1 * e := add_le_add + (mul_le_mul hc hx (abs_nonneg _) ((abs_nonneg _).trans hc)) + (mul_le_mul hsin hy (abs_nonneg _) zero_le_one) + _ = _ := by ring + set v := Real.cos θ * y.val.1 + Real.sin θ * y.val.2.1 + have hb := mul_self_le_mul_self (abs_nonneg v) hproj + have hb' : e ≤ 1 - v ^ 2 := by + nlinarith only [hb, sq_abs v, mul_nonneg he0.le (sub_nonneg.mpr he1.le)] + change e ^ 2 ≤ (1 - v ^ 2) ^ 2 + simpa only [sq] using mul_self_le_mul_self he0.le hb' + +theorem cap_pos (μ : Measure UnitSphere) [IsFiniteMeasure μ] [μ.IsOpenPosMeasure] + {r : ℝ} (hr : 0 < r) : 0 < μ.real {y | firstEnergy y < r} := by + have ho := isOpen_lt first_cont (continuous_const (y := r)) + let pole : UnitSphere := ⟨(1, 0, 0), by norm_num⟩ + have hm := ho.measure_pos μ ⟨pole, by change (1 - (1 : ℝ) ^ 2) ^ 2 < r; simpa using hr⟩ + exact ENNReal.toReal_pos hm.ne' (measure_ne_top _ _) +end VenRate +end diff --git a/LeanPool/VenNullClockRoundRates/Imports.lean b/LeanPool/VenNullClockRoundRates/Imports.lean new file mode 100644 index 0000000000..fd89308f77 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Imports.lean @@ -0,0 +1,30 @@ +/- +Copyright (c) 2026 Lean Pool contributors. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Lean Pool contributors +-/ +module -- shake: keep-all --deprecated_module: ignore + +-- Generated project imports; run `lake exe mk_all`. +public import LeanPool.VenNullClockRoundRates +public import LeanPool.VenNullClockRoundRates.Filter +public import LeanPool.VenNullClockRoundRates.Finite +public import LeanPool.VenNullClockRoundRates.Geometry +public import LeanPool.VenNullClockRoundRates.Layer +public import LeanPool.VenNullClockRoundRates.Lower +public import LeanPool.VenNullClockRoundRates.Pole +public import LeanPool.VenNullClockRoundRates.RoundAreaBridge +public import LeanPool.VenNullClockRoundRates.RoundAreaCutoffInputs +public import LeanPool.VenNullClockRoundRates.RoundAreaPositiveStrips +public import LeanPool.VenNullClockRoundRates.RoundAreaUpperHemisphere +public import LeanPool.VenNullClockRoundRates.SphereModel +public import LeanPool.VenNullClockRoundRates.VenRateUpperAssembly +public import LeanPool.VenNullClockRoundRates.VenRateUpperBudget +public import LeanPool.VenNullClockRoundRates.VenRateUpperBump +public import LeanPool.VenNullClockRoundRates.VenRateUpperClassGap +public import LeanPool.VenNullClockRoundRates.VenRateUpperHeight +public import LeanPool.VenNullClockRoundRates.VenRateUpperPhysical +public import LeanPool.VenNullClockRoundRates.VenRateUpperPositive +public import LeanPool.VenNullClockRoundRates.VenRateUpperRoundRates +public import LeanPool.VenNullClockRoundRates.VenRateUpperStrips +public import LeanPool.VenNullClockRoundRates.VenRateUpperTaylor diff --git a/LeanPool/VenNullClockRoundRates/Layer.lean b/LeanPool/VenNullClockRoundRates/Layer.lean new file mode 100644 index 0000000000..80cb9ed909 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Layer.lean @@ -0,0 +1,82 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import LeanPool.VenNullClockRoundRates.Filter +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! Two calibrated layer curves and the signed density they control. -/ +@[expose] public section +noncomputable section +open MeasureTheory VenMask +namespace VenRate + +/-- Profile weighted by the downstream exponential read. -/ +def tilt (w G : UnitSphere → ℝ) (b : ℝ) (y : UnitSphere) := + w y * Real.exp (b * G y) + +/-- The scalar read on a layer with downstream strength `b`. -/ +def layer (μ : Measure UnitSphere) (w G : UnitSphere → ℝ) (b x : ℝ) := + ∫ y, tilt w G b y * Real.exp (x * firstEnergy y) ∂μ + +/-- An absolute error bound on both layer differences over the full read interval. -/ +def DataClose (μ : Measure UnitSphere) (w₀ w₁ : UnitSphere → ℝ) (θ b a ε : ℝ) : Prop := + ∀ x ∈ Set.Icc (0 : ℝ) a, + |layer μ w₁ (secondEnergy θ) 0 x - layer μ w₀ firstEnergy 0 x| ≤ ε ∧ + |layer μ w₁ (secondEnergy θ) b x - layer μ w₀ firstEnergy b x| ≤ ε + +/-- Signed downstream-layer difference after subtracting the scaled zero-layer density. -/ +def density (w₀ w₁ : UnitSphere → ℝ) (θ b τ : ℝ) (y : UnitSphere) := + (tilt w₁ (secondEnergy θ) b y - tilt w₀ firstEnergy b y) - τ * (w₁ y - w₀ y) + +theorem int_tilt {μ : Measure UnitSphere} {w G : UnitSphere → ℝ} {b : ℝ} + (hw : Integrable w μ) (hb : 0 ≤ b) (hc : Continuous G) (hG : ∀ y, G y ≤ 1) : + Integrable (tilt w G b) μ := by + apply hw.mul_bdd (c := Real.exp b) (Real.continuous_exp.comp (continuous_const.mul + hc)).aestronglyMeasurable + exact Filter.Eventually.of_forall fun y ↦ by + change ‖Real.exp (b * G y)‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + exact Real.exp_le_exp.mpr (by simpa using mul_le_mul_of_nonneg_left (hG y) hb) + +theorem int_density {μ : Measure UnitSphere} {w₀ w₁ : UnitSphere → ℝ} + {θ b τ : ℝ} (h₀ : Integrable w₀ μ) (h₁ : Integrable w₁ μ) (hb : 0 ≤ b) : + Integrable (density w₀ w₁ θ b τ) μ := + ((int_tilt h₁ hb (second_cont θ) fun y ↦ (en_bounds θ y).2.2).sub + (int_tilt h₀ hb first_cont fun y ↦ (en_bounds θ y).1.2)).sub ((h₁.sub h₀).const_mul τ) + +theorem density_sample {μ : Measure UnitSphere} {w₀ w₁ : UnitSphere → ℝ} + {θ a b τ ε h : ℝ} (h₀ : Integrable w₀ μ) (h₁ : Integrable w₁ μ) (hb : 0 ≤ b) + (ht : 0 ≤ τ) (hc : DataClose μ w₀ w₁ θ b a ε) {x : ℝ} (hx : x ∈ Set.Icc 0 a) : + |filtered μ (density w₀ w₁ θ b τ) h 0 x| ≤ (1 + τ) * ε := by + let E := fun y ↦ Real.exp (x * firstEnergy y) + have t₀ := weighted_integrable (int_tilt h₀ hb first_cont fun y ↦ (en_bounds θ y).1.2) x + have t₁ := weighted_integrable (int_tilt h₁ hb (second_cont θ) fun y ↦ (en_bounds θ y).2.2) x + have sz (w G : UnitSphere → ℝ) : layer μ w G 0 x = ∫ y, w y * E y ∂μ := by + simp [layer, tilt, E] + have eqn : filtered μ (density w₀ w₁ θ b τ) h 0 x = + (layer μ w₁ (secondEnergy θ) b x - layer μ w₀ firstEnergy b x) - + τ * (layer μ w₁ (secondEnergy θ) 0 x - layer μ w₀ firstEnergy 0 x) := by + rw [sz w₀, sz w₁] + unfold layer filtered + rw [← integral_sub t₁ t₀, ← integral_sub (weighted_integrable h₁ x) (weighted_integrable h₀ x), + ← integral_const_mul] + erw [← integral_sub (t₁.sub t₀) (((weighted_integrable h₁ x).sub + (weighted_integrable h₀ x)).const_mul τ)] + apply integral_congr_ae; apply Filter.Eventually.of_forall; intro y + simp only [density, Pi.sub_apply]; ring + rw [eqn] + obtain ⟨hA, hB⟩ := hc x hx + calc + _ ≤ _ := abs_sub _ _ + _ ≤ ε + τ * ε := by + rw [abs_mul, abs_of_nonneg ht] + exact add_le_add hB (mul_le_mul_of_nonneg_left hA ht) + _ = _ := by ring +end VenRate +end diff --git a/LeanPool/VenNullClockRoundRates/Lower.lean b/LeanPool/VenNullClockRoundRates/Lower.lean new file mode 100644 index 0000000000..deda695aa3 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Lower.lean @@ -0,0 +1,123 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import LeanPool.VenNullClockRoundRates.Finite +public import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! Uniform lower masking rate under an observable mean budget. -/ +@[expose] public section +noncomputable section +namespace VenRate +open MeasureTheory VenMask + +/-- Every uniform error envelope on the actual unnormalized two-layer curves +obeys the eventual lower masking rate. The constants are chosen before the +alternative orientation, budget, and arbitrary separate nuisance profiles. -/ +theorem lower_masking_rate (μ : Measure UnitSphere) [IsFiniteMeasure μ] [μ.IsOpenPosMeasure] + {d a b : ℝ} (hd : 0 < d) (hd1 : d ≤ 1) (ha : 0 < a) (hb : 0 < b) : + ∃ C M₀ : ℝ, 0 < C ∧ 1 < M₀ ∧ + ∀ {M θ ε : ℝ} {w₀ w₁ : UnitSphere → ℝ}, + M₀ ≤ M → d ≤ 1 - Real.cos θ ^ 2 → Integrable w₀ μ → Integrable w₁ μ → + (∀ᵐ y ∂μ, 1 ≤ w₀ y) → (∀ᵐ y ∂μ, 1 ≤ w₁ y) → + (∫ y, w₀ y ∂μ) ≤ M → (∫ y, w₁ y ∂μ) ≤ M → + DataClose μ w₀ w₁ θ b a ε → + Real.exp (-C * Real.log M * Real.log (Real.log M)) ≤ ε := by + obtain ⟨c, K, T, R, J, hc, hK, hR, hRT, _hT1, hJ, F⟩ := finite_layer_separation μ hd hd1 hb + have hT := hR.trans hRT + let D := Real.log T - Real.log R + have hD : 0 < D := sub_pos.mpr (Real.log_lt_log hR hRT) + let N := 2 / D + 1 + let m := min a 1 + let A := 1 + N / m + let B := |Real.log A| + |Real.log T| + 1 + let L₀ := max (Real.exp 1) (max (Real.log K - Real.log (c / 2)) (Real.log J - Real.log (c / 2))) + have hm : 0 < m := lt_min ha zero_lt_one + have hN : 0 < N := by dsimp [N]; positivity + have hA : 0 < A := by dsimp [A]; positivity + have hB : 0 < B := by dsimp [B]; positivity + have hL₀ : 0 < L₀ := (Real.exp_pos _).trans_le (le_max_left _ _) + refine ⟨N * B + 1, Real.exp L₀, by positivity, Real.one_lt_exp_iff.mpr hL₀, ?_⟩ + intro M θ ε w₀ w₁ hM hθ i₀ i₁ f₀ f₁ m₀ m₁ H + let L := Real.log M + let l := Real.log L + have hMp : 0 < M := (Real.exp_pos _).trans_le hM + have hLL : L₀ ≤ L := (Real.le_log_iff_exp_le hMp).mpr hM + have hL : 0 < L := hL₀.trans_le hLL + have hel : Real.exp 1 ≤ L := (le_max_left _ _).trans hLL + have h1 : 1 ≤ L := (Real.one_le_exp zero_le_one).trans hel + have hl : 1 ≤ l := (Real.le_log_iff_exp_le hL).mpr hel + have hKc : Real.log K - Real.log (c / 2) ≤ L := (le_max_left _ _).trans ((le_max_right _ + _).trans hLL) + have hJc : Real.log J - Real.log (c / 2) ≤ L := (le_max_right _ _).trans ((le_max_right _ + _).trans hLL) + let k := ⌈(2 / D) * L⌉₊ + have hlk : (2 / D) * L ≤ (k : ℝ) := Nat.le_ceil _ + have hkk : 0 < (k : ℝ) := (show 0 < (2 / D) * L by positivity).trans_le hlk + have hk' : 1 ≤ k := by exact_mod_cast (show 0 < k by exact_mod_cast hkk) + have hk1 : 1 ≤ (k : ℝ) := by exact_mod_cast hk' + have hku : (k : ℝ) ≤ N * L := by + have hh := Nat.ceil_lt_add_one (show 0 ≤ (2 / D) * L by positivity) + dsimp only [N, k]; linarith + have hkd : 2 * L ≤ (k : ℝ) * D := by + have v := mul_le_mul_of_nonneg_right hlk hD.le + convert v using 1 + field_simp + let h := m / (k : ℝ) + have hhp : 0 < h := div_pos hm hkk + have hh1 : h ≤ 1 := (div_le_iff₀ hkk).mpr (by rw [one_mul]; exact (min_le_right a 1).trans hk1) + have hgrid : (k : ℝ) * h ≤ a := by + dsimp [h] + rw [mul_div_cancel₀ _ hkk.ne'] + exact min_le_left _ _ + have hfin := F k hθ hhp hh1 hgrid i₀ i₁ f₀ f₁ m₀ m₁ H + have c2 : 0 < c / 2 := by positivity + have htail : K * M * R ^ k ≤ (c / 2) * T ^ k := by + apply (Real.log_le_log_iff (by positivity) (by positivity)).mp + rw [Real.log_mul (by positivity : K * M ≠ 0) (pow_ne_zero _ hR.ne'), + Real.log_mul hK.ne' hMp.ne', Real.log_mul c2.ne' (pow_ne_zero _ hT.ne'), Real.log_pow, + Real.log_pow] + dsimp only [D] at hkd + dsimp only [L] at hKc hkd + linarith only [hkd, hKc] + have hcoef : (c / 2) * T ^ k ≤ J * (1 + 1 / h) ^ k * ε := by linarith only [hfin, htail] + have hcpos : 0 < (c / 2) * T ^ k := by positivity + have hZ : 0 < 1 + 1 / h := by positivity + have hε : 0 < ε := pos_of_mul_pos_right (hcpos.trans_le hcoef) (by positivity) + have hlogs := Real.log_le_log hcpos hcoef + rw [Real.log_mul c2.ne' (pow_ne_zero _ hT.ne'), Real.log_pow, + Real.log_mul (by positivity : J * (1 + 1 / h) ^ k ≠ 0) hε.ne', Real.log_mul hJ.ne' + (pow_ne_zero _ hZ.ne'), + Real.log_pow] at hlogs + have hr : 1 / h=(k : ℝ) / m := by dsimp only [h]; field_simp + have hZ' : 1 + 1 / h ≤ A * L := by + rw [hr]; dsimp only [A] + have hv := div_le_div_of_nonneg_right hku hm.le + calc + _ ≤ L + (N * L) / m := add_le_add h1 hv + _ = _ := by ring + have hlogZ := Real.log_le_log hZ hZ' + rw [Real.log_mul hA.ne' hL.ne'] at hlogZ + have hBnd : Real.log (1 + 1 / h) - Real.log T ≤ B * l := by + have la := le_abs_self (Real.log A) + have lt := neg_le_abs (Real.log T) + have ea := mul_le_mul_of_nonneg_left hl (abs_nonneg (Real.log A)) + have et := mul_le_mul_of_nonneg_left hl (abs_nonneg (Real.log T)) + dsimp only [l, B] at * + linarith only [hlogZ, la, lt, ea, et] + have hprod := (mul_le_mul_of_nonneg_left hBnd hkk.le).trans + (mul_le_mul_of_nonneg_right hku (mul_nonneg hB.le (by linarith))) + have hlL := mul_le_mul_of_nonneg_left hl hL.le + apply (Real.le_log_iff_exp_le hε).mp + change -(N * B + 1) * L * l ≤ Real.log ε + linarith only [hlogs, hprod, hJc, hlL] +end VenRate +end diff --git a/LeanPool/VenNullClockRoundRates/Pole.lean b/LeanPool/VenNullClockRoundRates/Pole.lean new file mode 100644 index 0000000000..327c26b4e3 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/Pole.lean @@ -0,0 +1,68 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import LeanPool.VenNullClockRoundRates.Filter +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! Quantitative lower bound on a signed, pole-localized moment. -/ +@[expose] public section +noncomputable section +open MeasureTheory VenMask +namespace VenRate + +theorem pole_integral {μ : Measure UnitSphere} [IsFiniteMeasure μ] + {U W : UnitSphere → ℝ} {h δ g K : ℝ} (hi : Integrable U μ) (hw : Integrable W μ) + (hh : 0 < h) (hh1 : h ≤ 1) (hd : 0 < δ) (hd1 : δ ≤ 1) (hg : 0 ≤ g) (hK : 0 ≤ K) + (hbound : ∀ᵐ y ∂μ, 0 ≤ W y ∧ -(K * W y) ≤ U y ∧ (firstEnergy y ≤ δ → g ≤ U y)) + (k : ℕ) : + μ.real {y | firstEnergy y < δ / 4} * (g * (1 - δ / 4) ^ k) - + (K * (1 - δ / 2) ^ k) * (∫ y, W y ∂μ) ≤ filtered μ U h k 0 := by + classical + let s := {y | firstEnergy y < δ / 4} + have hs : MeasurableSet s := (isOpen_lt first_cont continuous_const).measurableSet + let S := g * (1 - δ / 4) ^ k + let B := K * (1 - δ / 2) ^ k + have B0 : 0 ≤ B := mul_nonneg hK (pow_nonneg (by linarith) _) + have intI : Integrable (s.indicator (fun _ : UnitSphere ↦ S)) μ := + (integrable_const _).indicator hs + have intP : Integrable (fun y ↦ U y * poleFilter h (firstEnergy y) ^ k) μ := by + simpa using filtered_integrable hi hh hh1 k 0 + have L := integral_mono_ae (intI.sub (hw.const_mul B)) intP (by + filter_upwards [hbound] with y hY + simp only [Pi.sub_apply] + change s.indicator (fun _ ↦ S) y - B * W y ≤ U y * poleFilter h (firstEnergy y) ^ k + let p := poleFilter h (firstEnergy y) + obtain ⟨l, u⟩ := filter_bounds hh hh1 (en_bounds 0 y).1 + have hp : 0 ≤ p := by dsimp [p]; linarith [(en_bounds 0 y).1.2] + have hp' : 0 ≤ p ^ k := pow_nonneg hp k + have db := mul_nonneg B0 hY.1 + by_cases hys : y ∈ s + · rw [Set.indicator_of_mem hys] + change firstEnergy y < δ / 4 at hys + have hl : 1 - δ / 4 ≤ p := by dsimp [p]; linarith + have h₁ := pow_le_pow_left₀ (by linarith : 0 ≤ 1 - δ / 4) hl k + have h₂ := mul_le_mul_of_nonneg_right (hY.2.2 (by linarith)) hp' + have h₃ := mul_le_mul_of_nonneg_left h₁ hg + change S - B * W y ≤ U y * p ^ k + dsimp only [S]; linarith + · rw [Set.indicator_of_notMem hys] + by_cases hδ : firstEnergy y ≤ δ + · have hpos := mul_nonneg (hg.trans (hY.2.2 hδ)) hp' + change 0 - B * W y ≤ U y * p ^ k; linarith + · have hpR : p ≤ 1 - δ / 2 := by dsimp [p]; linarith + have h₁ := pow_le_pow_left₀ hp hpR k + have h₂ := mul_le_mul_of_nonneg_left h₁ (mul_nonneg hK hY.1) + have h₃ := mul_le_mul_of_nonneg_right hY.2.1 hp' + change 0 - B * W y ≤ U y * p ^ k + dsimp only [B]; linarith only [h₂, h₃]) + simp only [Pi.sub_apply] at L + rw [integral_sub intI (hw.const_mul B), integral_indicator_const _ hs, integral_const_mul] at L + simpa [s, S, B, filtered] using L +end VenRate +end diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean b/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean new file mode 100644 index 0000000000..275fcf4bfa --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean @@ -0,0 +1,127 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.SphereModel +public import Mathlib.Analysis.InnerProductSpace.PiL2 +public import Mathlib.MeasureTheory.Constructions.HaarToSphere +public import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum + +/-! +# Normalized round area in Cartesian sphere coordinates +-/ + +@[expose] public section +noncomputable section + +open MeasureTheory Set +open scoped ENNReal Pointwise + +namespace VenRateUpper + +/-- The three-dimensional Euclidean ambient space. -/ +abbrev RoundAmbient := EuclideanSpace ℝ (Fin 3) +/-- The unit metric sphere around the origin in the Euclidean ambient space. -/ +abbrev MetricUnitSphere := Metric.sphere (0 : RoundAmbient) 1 + +instance : BorelSpace VenMask.UnitSphere := by + change BorelSpace {q : ℝ × ℝ × ℝ // q.1 ^ 2 + q.2.1 ^ 2 + q.2.2 ^ 2 = 1} + infer_instance + +/-- Map the Euclidean sphere to the Cartesian sphere of the observation model. -/ +def fromMetricSphere (q : MetricUnitSphere) : VenMask.UnitSphere := + ⟨(q.1 0, q.1 1, q.1 2), by + have h := mem_sphere_zero_iff_norm.mp q.2 + have hsq : ‖q.1‖ ^ 2 = 1 := by rw [h]; norm_num + rw [EuclideanSpace.real_norm_sq_eq, Fin.sum_univ_three] at hsq + exact hsq⟩ + +/-- Interpret a Cartesian point on the model sphere as a Euclidean unit vector. -/ +def toMetricSphere (q : VenMask.UnitSphere) : MetricUnitSphere := + ⟨WithLp.toLp 2 ![q.val.1, q.val.2.1, q.val.2.2], by + apply mem_sphere_zero_iff_norm.mpr + have h : ‖(WithLp.toLp 2 ![q.val.1, q.val.2.1, q.val.2.2] : RoundAmbient)‖ ^ 2 = 1 := by + simpa [EuclideanSpace.real_norm_sq_eq, Fin.sum_univ_three, PiLp.toLp_apply] using q.property + have h₀ : 0 ≤ ‖(WithLp.toLp 2 ![q.val.1, q.val.2.1, q.val.2.2] : RoundAmbient)‖ := + norm_nonneg _ + nlinarith⟩ + +/-- Cartesian coordinates identify the Euclidean sphere with the accepted sphere type. -/ +def metricSphereHomeomorph : MetricUnitSphere ≃ₜ VenMask.UnitSphere where + toFun := fromMetricSphere + invFun := toMetricSphere + left_inv q := by + apply Subtype.ext + apply PiLp.ext + intro i + fin_cases i <;> rfl + right_inv q := by + apply Subtype.ext + rcases q with ⟨⟨x, y, z⟩, h⟩ + rfl + continuous_toFun := by + apply continuous_induced_rng.2 + have h (i : Fin 3) : Continuous (fun q : MetricUnitSphere ↦ q.1 i) := + (PiLp.continuous_apply 2 (fun _ : Fin 3 ↦ ℝ) i).comp continuous_subtype_val + exact (h 0).prodMk ((h 1).prodMk (h 2)) + continuous_invFun := by + apply continuous_induced_rng.2 + apply (PiLp.continuous_toLp 2 fun _ : Fin 3 ↦ ℝ).comp + rw [continuous_pi_iff] + intro i + fin_cases i + · exact continuous_fst.comp continuous_subtype_val + · exact continuous_fst.comp (continuous_snd.comp continuous_subtype_val) + · exact continuous_snd.comp (continuous_snd.comp continuous_subtype_val) + +/-- Euclidean area of the unit sphere, transported by the coordinate identification. +The Mathlib cone construction assigns each measurable patch three times the volume of +its unit radial cone. -/ +def roundAreaUnnormalized : Measure VenMask.UnitSphere := + Measure.map metricSphereHomeomorph ((volume : Measure RoundAmbient).toSphere) + +instance : IsFiniteMeasure roundAreaUnnormalized := by + unfold roundAreaUnnormalized + infer_instance + +instance : roundAreaUnnormalized.IsOpenPosMeasure := + metricSphereHomeomorph.continuous.isOpenPosMeasure_map + (μ := (volume : Measure RoundAmbient).toSphere) metricSphereHomeomorph.surjective + +private theorem roundAreaUnnormalized_ne_zero : roundAreaUnnormalized univ ≠ 0 := by + rw [roundAreaUnnormalized, Measure.map_apply metricSphereHomeomorph.measurable + MeasurableSet.univ, preimage_univ] + rw [Measure.toSphere_apply_univ] + exact mul_ne_zero (by simp) + (Metric.isOpen_ball.measure_ne_zero volume (Metric.nonempty_ball.2 zero_lt_one)) + +/-- Normalized Euclidean round area on the accepted sphere. -/ +def roundArea : Measure VenMask.UnitSphere := + (roundAreaUnnormalized univ)⁻¹ • roundAreaUnnormalized + +instance instProbabilityRoundArea : IsProbabilityMeasure roundArea where + measure_univ := ENNReal.inv_mul_cancel roundAreaUnnormalized_ne_zero + (measure_ne_top roundAreaUnnormalized univ) + +instance instOpenPosRoundArea : roundArea.IsOpenPosMeasure where + open_pos U hU hne := by + rw [roundArea, smul_apply, smul_eq_mul] + exact mul_ne_zero (ENNReal.inv_ne_zero.mpr (measure_ne_top roundAreaUnnormalized univ)) + (hU.measure_ne_zero roundAreaUnnormalized hne) + +theorem roundAreaUnnormalized_apply {U : Set VenMask.UnitSphere} (hU : MeasurableSet U) : + roundAreaUnnormalized U = + 3 * (volume : Measure RoundAmbient) + (Ioo (0 : ℝ) 1 • (Subtype.val '' (metricSphereHomeomorph ⁻¹' U))) := by + rw [roundAreaUnnormalized, Measure.map_apply metricSphereHomeomorph.measurable hU, + Measure.toSphere_apply' _ (metricSphereHomeomorph.measurable hU)] + simp + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean b/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean new file mode 100644 index 0000000000..2d4657ef7e --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean @@ -0,0 +1,178 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.RoundAreaUpperHemisphere +public import LeanPool.VenNullClockRoundRates.VenRateUpperStrips +public import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension +public import Mathlib.Analysis.SpecialFunctions.SmoothTransition +import Mathlib.Tactic.FunProp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! +# Local cutoffs for the positive and negative Cartesian strips +-/ + +@[expose] public section +noncomputable section + +open Filter Function MeasureTheory Set +open scoped ContDiff Topology + +namespace VenRateUpper + +theorem continuous_graphHeight : Continuous graphHeight := by + unfold graphHeight + fun_prop + +theorem contDiff_chartEnergy : ContDiff ℝ ∞ chartEnergy := by + unfold chartEnergy + fun_prop + +theorem contDiff_chartGap (θ b : ℝ) : + ContDiff ℝ ∞ (fun p : ℝ × ℝ ↦ chartGap θ b p.1 p.2) := by + unfold chartGap chartEnergy + fun_prop + +/-- Choose one shared horizontal interval and fixed transverse intervals with +strict sign and positive hemisphere height margins. -/ +theorem exists_chartStripRectangles {θ b : ℝ} + (hθ : 0 < 1 - Real.cos θ ^ 2) (hb : 0 < b) : + ∃ l u yp ym rp rm δ z : ℝ, 0 < l ∧ l < u ∧ u < 1 ∧ + 0 < rp ∧ 0 < rm ∧ 0 < δ ∧ 0 < z ∧ + (∀ p ∈ Icc l u ×ˢ Metric.closedBall yp rp, + δ < chartGap θ b p.1 p.2 ∧ z < graphHeight p) ∧ + (∀ p ∈ Icc l u ×ˢ Metric.closedBall ym rm, + δ < -chartGap θ b p.1 p.2 ∧ z < graphHeight p) := by + obtain ⟨x, yp, ym, hx, hdP, hdM, hP, hM⟩ := opposite_chart_points hθ hb + have hDiskP : (x, yp) ∈ graphDisk := by + change 0 < 1 - x ^ 2 - yp ^ 2 + linarith + have hDiskM : (x, ym) ∈ graphDisk := by + change 0 < 1 - x ^ 2 - ym ^ 2 + linarith + let δ := min (chartGap θ b x yp) (-chartGap θ b x ym) / 2 + let z := min (graphHeight (x, yp)) (graphHeight (x, ym)) / 2 + have hδ : 0 < δ := div_pos (lt_min hP (by linarith)) (by norm_num) + have hz : 0 < z := div_pos (lt_min (graphHeight_pos hDiskP) (graphHeight_pos hDiskM)) (by + norm_num) + have hδlt : δ < min (chartGap θ b x yp) (-chartGap θ b x ym) := by dsimp [δ] at *; linarith + have hzlt : z < min (graphHeight (x, yp)) (graphHeight (x, ym)) := by dsimp [z] at *; linarith + let A : Set (ℝ × ℝ) := {p | δ < chartGap θ b p.1 p.2 ∧ z < graphHeight p} + let B : Set (ℝ × ℝ) := {p | δ < -chartGap θ b p.1 p.2 ∧ z < graphHeight p} + have hA : IsOpen A := + (isOpen_lt continuous_const (contDiff_chartGap θ b).continuous).inter + (isOpen_lt continuous_const continuous_graphHeight) + have hB : IsOpen B := + (isOpen_lt continuous_const (contDiff_chartGap θ b).continuous.neg).inter + (isOpen_lt continuous_const continuous_graphHeight) + have hxA : (x, yp) ∈ A := + ⟨hδlt.trans_le (min_le_left _ _), hzlt.trans_le (min_le_left _ _)⟩ + have hxB : (x, ym) ∈ B := + ⟨hδlt.trans_le (min_le_right _ _), hzlt.trans_le (min_le_right _ _)⟩ + obtain ⟨Xp, hXp, Yp, hYp, hXYp⟩ := mem_nhds_prod_iff.mp (hA.mem_nhds hxA) + obtain ⟨Xm, hXm, Ym, hYm, hXYm⟩ := mem_nhds_prod_iff.mp (hB.mem_nhds hxB) + have hX : Xp ∩ Xm ∩ Ioo (0 : ℝ) 1 ∈ 𝓝 x := + inter_mem (inter_mem hXp hXm) (isOpen_Ioo.mem_nhds hx) + obtain ⟨rx, hrx, hRX⟩ := Metric.mem_nhds_iff.mp hX + let l := x - rx / 2 + let u := x + rx / 2 + have hlu : l < u := by dsimp [l, u]; linarith + have hI : Icc l u ⊆ Xp ∩ Xm ∩ Ioo (0 : ℝ) 1 := by + intro v hv + apply hRX + rw [Metric.mem_ball, Real.dist_eq, abs_lt] + exact ⟨by linarith [show x - rx / 2 ≤ v from hv.1], + by linarith [show v ≤ x + rx / 2 from hv.2]⟩ + obtain ⟨rp, hrp, hp⟩ := Metric.mem_nhds_iff.mp hYp + obtain ⟨rm, hrm, hm⟩ := Metric.mem_nhds_iff.mp hYm + refine ⟨l, u, yp, ym, rp / 2, rm / 2, δ, z, + (hI (left_mem_Icc.mpr hlu.le)).2.1, hlu, (hI (right_mem_Icc.mpr hlu.le)).2.2, + by positivity, by positivity, hδ, hz, ?_, ?_⟩ + · intro p hp' + exact hXYp ⟨(hI hp'.1).1.1, hp (Metric.closedBall_subset_ball (by linarith) hp'.2)⟩ + · intro p hp' + exact hXYm ⟨(hI hp'.1).1.2, hm (Metric.closedBall_subset_ball (by linarith) hp'.2)⟩ + +/-- A positive globally smooth denominator equal to its argument above `δ`. -/ +def cutoffDenominator (δ x : ℝ) : ℝ := + δ * (1 - Real.smoothTransition (x / δ)) + x * Real.smoothTransition (x / δ) + +theorem cutoffDenominator_pos {δ : ℝ} (hδ : 0 < δ) (x : ℝ) : + 0 < cutoffDenominator δ x := by + unfold cutoffDenominator + by_cases hx : x ≤ 0 + · rw [Real.smoothTransition.zero_of_nonpos (div_nonpos_of_nonpos_of_nonneg hx hδ.le)] + simpa using hδ + · let t := Real.smoothTransition (x / δ) + have ht0 : 0 ≤ t := Real.smoothTransition.nonneg _ + have ht1 : t ≤ 1 := Real.smoothTransition.le_one _ + rcases lt_or_eq_of_le ht1 with h | h + · exact add_pos_of_pos_of_nonneg (mul_pos hδ (sub_pos.mpr h)) + (mul_nonneg (le_of_lt (lt_of_not_ge hx)) ht0) + · change 0 < δ * (1 - t) + x * t + simpa [h] using (lt_of_not_ge hx) + +theorem cutoffDenominator_eq_self {δ x : ℝ} (hδ : 0 < δ) (hx : δ ≤ x) : + cutoffDenominator δ x = x := by + unfold cutoffDenominator + rw [Real.smoothTransition.one_of_one_le ((one_le_div hδ).2 hx)] + ring + +theorem contDiff_cutoffDenominator (δ : ℝ) : ContDiff ℝ ∞ (cutoffDenominator δ) := by + unfold cutoffDenominator + have ht : ContDiff ℝ ∞ (fun x : ℝ ↦ Real.smoothTransition (x / δ)) := + Real.smoothTransition.contDiff.comp (contDiff_id.div_const δ) + exact (contDiff_const.mul (contDiff_const.sub ht)).add (contDiff_id.mul ht) + +/-- Fixed normalized nonnegative smooth transverse function within the specified interval. -/ +theorem exists_transverse_bump (y r : ℝ) (hr : 0 < r) : + ∃ β : ℝ → ℝ, ContDiff ℝ ∞ β ∧ (∀ x, 0 ≤ β x) ∧ + (∀ x ∉ Metric.closedBall y r, β x = 0) ∧ (∫ x, β x) = 1 := by + let B : ContDiffBump y := ⟨r / 2, r, by positivity, by linarith⟩ + have hB : 0 < ∫ x, B x := + B.continuous.integral_pos_of_hasCompactSupport_nonneg_ne_zero + B.hasCompactSupport B.nonneg' (by rw [B.one_of_mem_closedBall + (Metric.mem_closedBall_self B.rIn_pos.le)]; norm_num) + refine ⟨fun x ↦ (∫ v, B v)⁻¹ * B x, contDiff_const.mul B.contDiff, + fun x ↦ mul_nonneg (inv_nonneg.mpr hB.le) (B.nonneg' x), ?_, ?_⟩ + · intro x hx + change (∫ v, B v)⁻¹ * B x = 0 + rw [B.zero_of_le_dist (le_of_lt (lt_of_not_ge hx)), mul_zero] + · rw [integral_const_mul, inv_mul_cancel₀ hB.ne'] + +/-- The same compact smooth cutoff in the first Cartesian coordinate is used on both signs. -/ +theorem exists_height_cutoff {l u : ℝ} (hl : 0 < l) (hlu : l < u) (hu : u < 1) : + ∃ h₀ h₁ : ℝ, 0 < h₀ ∧ h₀ < h₁ ∧ h₁ < 1 ∧ + ∃ η : ℝ → ℝ, ContDiff ℝ ∞ η ∧ HasCompactSupport η ∧ (∀ t, 0 ≤ η t) ∧ + (∀ t ∉ Icc l u, η t = 0) ∧ (∀ t ∈ Icc h₀ h₁, η t = 1) := by + let c := (l + u) / 2 + let r := (u - l) / 4 + have hr : 0 < r := by dsimp [r]; linarith + let E : ContDiffBump c := ⟨r / 2, r, by positivity, by linarith⟩ + have h₁ : l < c - r := by dsimp [c, r]; linarith + have h₂ : c + r < u := by dsimp [c, r]; linarith + refine ⟨c - r / 2, c + r / 2, by linarith, by linarith, by linarith, + E, E.contDiff, E.hasCompactSupport, E.nonneg', ?_, ?_⟩ + · intro t ht + apply E.zero_of_le_dist + change r ≤ dist t c + rw [Real.dist_eq] + by_contra! hn + apply ht + have H := abs_lt.mp hn + exact ⟨by linarith, by linarith⟩ + · intro t ht + apply E.one_of_mem_closedBall + change dist t c ≤ r / 2 + rw [Real.dist_eq, abs_le] + exact ⟨by linarith [ht.1], by linarith [ht.2]⟩ + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean b/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean new file mode 100644 index 0000000000..ee88cd61b8 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean @@ -0,0 +1,224 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.RoundAreaCutoffInputs +public import Mathlib.MeasureTheory.Integral.Prod +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! +# Positive smooth realization of the strip densities +-/ + +@[expose] public section +noncomputable section + +open Function MeasureTheory Set +open scoped ContDiff Topology + +namespace VenRateUpper + +/-- Downstream exponential difference between the alternative and aligned energies. -/ +def sphereReadGap (θ b : ℝ) (y : VenMask.UnitSphere) : ℝ := + Real.exp (b * VenMask.secondEnergy θ y) - Real.exp (b * VenMask.firstEnergy y) + +/-- The smooth cutoff equals the transverse and longitudinal bump product times +the reciprocal signed discrepancy and reciprocal normalized area density on its support. +The vertical cutoff isolates the positive hemisphere. -/ +def ambientStripCutoff (θ b s δ z : ℝ) (η β : ℝ → ℝ) (p : ℝ × ℝ × ℝ) : ℝ := + (4 * Real.pi) * (p.2.2 * Real.smoothTransition (p.2.2 / z)) * η p.1 * β p.2.1 / + cutoffDenominator δ (s * chartGap θ b p.1 p.2.1) + +theorem contDiff_ambientStripCutoff {θ b s δ z : ℝ} {η β : ℝ → ℝ} + (hδ : 0 < δ) (hη : ContDiff ℝ ∞ η) (hβ : ContDiff ℝ ∞ β) : + ContDiff ℝ ∞ (ambientStripCutoff θ b s δ z η β) := by + have hX : ContDiff ℝ ∞ (fun p : ℝ × ℝ × ℝ ↦ p.1) := contDiff_fst + have hY : ContDiff ℝ ∞ (fun p : ℝ × ℝ × ℝ ↦ p.2.1) := contDiff_fst.comp contDiff_snd + have hZ : ContDiff ℝ ∞ (fun p : ℝ × ℝ × ℝ ↦ p.2.2) := contDiff_snd.comp contDiff_snd + have hC := Real.smoothTransition.contDiff.comp (hZ.div_const z) + have hG := (contDiff_chartGap θ b).comp (hX.prodMk hY) + exact (((contDiff_const.mul (hZ.mul hC)).mul (hη.comp hX)).mul (hβ.comp hY)).div + ((contDiff_cutoffDenominator δ).comp (contDiff_const.mul hG)) + (fun p ↦ (cutoffDenominator_pos hδ (s * chartGap θ b p.1 p.2.1)).ne') + +theorem ambientStripCutoff_nonneg {θ b s δ z : ℝ} {η β : ℝ → ℝ} + (hδ : 0 < δ) (hz : 0 < z) (hη : ∀ x, 0 ≤ η x) (hβ : ∀ y, 0 ≤ β y) + (p : ℝ × ℝ × ℝ) : 0 ≤ ambientStripCutoff θ b s δ z η β p := by + have hc : 0 ≤ p.2.2 * Real.smoothTransition (p.2.2 / z) := by + by_cases h : p.2.2 ≤ 0 + · rw [Real.smoothTransition.zero_of_nonpos (div_nonpos_of_nonpos_of_nonneg h hz.le), mul_zero] + · exact mul_nonneg (le_of_lt (lt_of_not_ge h)) (Real.smoothTransition.nonneg _) + exact div_nonneg (mul_nonneg (mul_nonneg (mul_nonneg (by positivity) hc) (hη _)) (hβ _)) + (cutoffDenominator_pos hδ _).le + +private theorem graphHeight_projection {y : VenMask.UnitSphere} (hy : y ∈ upperHemisphere) : + graphHeight (graphProjection y) = y.val.2.2 := by + have hs : 1 - y.val.1 ^ 2 - y.val.2.1 ^ 2 = y.val.2.2 ^ 2 := by + linarith [y.property] + change Real.sqrt (1 - y.val.1 ^ 2 - y.val.2.1 ^ 2) = y.val.2.2 + rw [hs, Real.sqrt_sq (le_of_lt hy)] + +/-- The two strip identities follow from the round-area law and one product integral. -/ +theorem integral_ambientStripCutoff + {θ b s δ z : ℝ} (hs : s ^ 2 = 1) (hδ : 0 < δ) (hz : 0 < z) + {I J : Set ℝ} (hI : MeasurableSet I) (hJ : MeasurableSet J) + {η β : ℝ → ℝ} (hη : ContDiff ℝ ∞ η) (hβ : ContDiff ℝ ∞ β) + (hη0 : ∀ x ∉ I, η x = 0) (hβ0 : ∀ x ∉ J, β x = 0) + (hβ1 : ∫ x, β x = 1) + (hStrip : ∀ p ∈ I ×ˢ J, δ < s * chartGap θ b p.1 p.2 ∧ z < graphHeight p) + (g : ℝ → ℝ) (hg : Continuous g) : + (∫ q, sphereReadGap θ b q * ambientStripCutoff θ b s δ z η β q.val * + g q.val.1 ∂roundArea) = s * ∫ t, η t * g t := by + let W := ambientStripCutoff θ b s δ z η β + let lift (p : ℝ × ℝ) : ℝ × ℝ × ℝ := (p.1, p.2, graphHeight p) + let f (p : ℝ × ℝ) : ℝ := chartGap θ b p.1 p.2 * W (lift p) * g p.1 + let A (x : ℝ) : ℝ := (4 * Real.pi * s) * (η x * g x) + have hf : Continuous f := by + have hW : Continuous W := (contDiff_ambientStripCutoff hδ hη hβ).continuous + have hlift : Continuous lift := + continuous_fst.prodMk (continuous_snd.prodMk continuous_graphHeight) + exact (((contDiff_chartGap θ b).continuous).mul (hW.comp hlift)).mul + (hg.comp continuous_fst) + have hStripDisk : I ×ˢ J ⊆ graphDisk := by + intro p hp + have h := hz.trans (hStrip p hp).2 + exact Real.sqrt_pos.mp h + have hPatch : ∀ p ∈ graphDisk, + graphAreaDensity p * f p = (I ×ˢ J).indicator (fun p ↦ A p.1 * β p.2) p := by + intro p hp + by_cases hi : p.1 ∈ I + · by_cases hj : p.2 ∈ J + · have hIJ : p ∈ I ×ˢ J := ⟨hi, hj⟩ + have h := hStrip p hIJ + have hzP : 0 < graphHeight p := hz.trans h.2 + have hsG : 0 < s * chartGap θ b p.1 p.2 := hδ.trans h.1 + have hRatio : chartGap θ b p.1 p.2 / (s * chartGap θ b p.1 p.2) = s := by + apply (div_eq_iff hsG.ne').2 + rw [← mul_assoc, ← pow_two, hs, one_mul] + rw [indicator_of_mem hIJ] + dsimp [f, W, lift, A, ambientStripCutoff, graphAreaDensity] + rw [cutoffDenominator_eq_self hδ h.1.le, + Real.smoothTransition.one_of_one_le ((one_le_div hz).2 h.2.le), mul_one] + calc + _ = (chartGap θ b p.1 p.2 / (s * chartGap θ b p.1 p.2)) * + ((4 * Real.pi) * (η p.1 * g p.1) * β p.2) := by + field_simp [hzP.ne'] + _ = _ := by rw [hRatio]; ring + · rw [indicator_of_notMem (show p ∉ I ×ˢ J from fun hp' ↦ hj hp'.2)] + simp [f, W, lift, ambientStripCutoff, hβ0 _ hj] + · rw [indicator_of_notMem (show p ∉ I ×ˢ J from fun hp' ↦ hi hp'.1)] + simp [f, W, lift, ambientStripCutoff, hη0 _ hi] + calc + _ = ∫ q in upperHemisphere, sphereReadGap θ b q * W q.val * g q.val.1 ∂roundArea := by + symm + apply setIntegral_eq_integral_of_forall_compl_eq_zero + intro q hq + have hv : q.val.2.2 ≤ 0 := le_of_not_gt hq + simp [W, ambientStripCutoff, + Real.smoothTransition.zero_of_nonpos (div_nonpos_of_nonpos_of_nonneg hv hz.le)] + _ = ∫ q in upperHemisphere, f (graphProjection q) ∂roundArea := by + apply setIntegral_congr_fun + · have h : Continuous (fun q : VenMask.UnitSphere ↦ q.val) := continuous_subtype_val + exact (isOpen_lt continuous_const h.snd.snd).measurableSet + · intro q hq + have hq' : lift (graphProjection q) = q.val := by + change (q.val.1, q.val.2.1, graphHeight (graphProjection q)) = q.val + rw [graphHeight_projection hq] + change _ = chartGap θ b q.val.1 q.val.2.1 * W (lift (graphProjection q)) * g q.val.1 + rw [hq'] + rfl + _ = (4 * Real.pi)⁻¹ * ∫ p in graphDisk, graphAreaDensity p * f p := + integral_roundArea_upperHemisphere f hf.measurable + _ = (4 * Real.pi)⁻¹ * ∫ p in graphDisk, + (I ×ˢ J).indicator (fun p ↦ A p.1 * β p.2) p := by + rw [setIntegral_congr_fun isOpen_graphDisk.measurableSet hPatch] + _ = (4 * Real.pi)⁻¹ * ∫ p in I ×ˢ J, A p.1 * β p.2 := by + rw [setIntegral_indicator (hI.prod hJ)] + rw [inter_eq_right.mpr hStripDisk] + _ = (4 * Real.pi)⁻¹ * ((∫ x in I, A x) * ∫ y in J, β y) := by + congr 1 + exact setIntegral_prod_mul A β I J + _ = s * ∫ t, η t * g t := by + rw [setIntegral_eq_integral_of_forall_compl_eq_zero hβ0, hβ1, mul_one] + dsimp [A] + rw [integral_const_mul, setIntegral_eq_integral_of_forall_compl_eq_zero + (fun x hx ↦ by rw [hη0 x hx, zero_mul])] + have hp : (4 * Real.pi : ℝ) ≠ 0 := by positivity + rw [← mul_assoc, ← mul_assoc, inv_mul_cancel₀ hp, one_mul] + +instance : CompactSpace VenMask.UnitSphere := metricSphereHomeomorph.compactSpace + +/-- A common Cartesian cutoff and two ordinary-round-area lift functions for its +opposite signed read - gap pushforwards. The height interval lies in the unit range. -/ +theorem exists_smooth_strip_cutoffs {θ b : ℝ} + (hθ : 0 < 1 - Real.cos θ ^ 2) (hb : 0 < b) : + ∃ h₀ h₁ Aplus Aminus : ℝ, 0 < h₀ ∧ h₀ < h₁ ∧ h₁ < 1 ∧ + 0 ≤ Aplus ∧ 0 ≤ Aminus ∧ + ∃ η : ℝ → ℝ, ContDiff ℝ ∞ η ∧ HasCompactSupport η ∧ + (∀ t ∈ Icc h₀ h₁, η t = 1) ∧ + ∃ Cplus Cminus : ℝ × ℝ × ℝ → ℝ, ContDiff ℝ ∞ Cplus ∧ ContDiff ℝ ∞ Cminus ∧ + (∀ y : VenMask.UnitSphere, Cplus y.val ∈ Icc 0 Aplus) ∧ + (∀ y : VenMask.UnitSphere, Cminus y.val ∈ Icc 0 Aminus) ∧ + (∀ p : ℝ × ℝ × ℝ, Cplus p * Cminus p = 0) ∧ + (∀ g : ℝ → ℝ, Continuous g → + (∫ y, sphereReadGap θ b y * Cplus y.val * g y.val.1 ∂roundArea) = + ∫ t, η t * g t) ∧ + (∀ g : ℝ → ℝ, Continuous g → + (∫ y, sphereReadGap θ b y * Cminus y.val * g y.val.1 ∂roundArea) = + -(∫ t, η t * g t)) := by + obtain ⟨l, u, yp, ym, rp, rm, δ, z, hl, hlu, hu, hrp, hrm, hδ, hz, hP, hM⟩ := + exists_chartStripRectangles hθ hb + obtain ⟨h₀, h₁, h₀pos, h₀₁, h₁lt, η, hη, hηc, hηp, hηs, hη1⟩ := + exists_height_cutoff hl hlu hu + obtain ⟨βp, hβp, hβpp, hβps, hβp1⟩ := exists_transverse_bump yp rp hrp + obtain ⟨βm, hβm, hβmp, hβms, hβm1⟩ := exists_transverse_bump ym rm hrm + let Cp := ambientStripCutoff θ b 1 δ z η βp + let Cm := ambientStripCutoff θ b (-1) δ z η βm + have hCp : ContDiff ℝ ∞ Cp := contDiff_ambientStripCutoff hδ hη hβp + have hCm : ContDiff ℝ ∞ Cm := contDiff_ambientStripCutoff hδ hη hβm + have bound {f : ℝ × ℝ × ℝ → ℝ} (hf : Continuous f) (hn : 0 ≤ f) : + ∃ A : ℝ, 0 ≤ A ∧ ∀ y : VenMask.UnitSphere, f y.val ∈ Icc 0 A := by + have hc : Continuous (fun y : VenMask.UnitSphere ↦ f y.val) := + hf.comp continuous_subtype_val + let y₀ : VenMask.UnitSphere := ⟨(1, 0, 0), by norm_num⟩ + obtain ⟨a, _, ha⟩ := isCompact_univ.exists_isMaxOn + (show (univ : Set VenMask.UnitSphere).Nonempty from ⟨y₀, mem_univ _⟩) hc.continuousOn + exact ⟨f a.val, hn _, fun y ↦ ⟨hn _, ha (mem_univ y)⟩⟩ + obtain ⟨Aplus, hAplus, hBoundsP⟩ := bound hCp.continuous + (ambientStripCutoff_nonneg hδ hz hηp hβpp) + obtain ⟨Aminus, hAminus, hBoundsM⟩ := bound hCm.continuous + (ambientStripCutoff_nonneg hδ hz hηp hβmp) + refine ⟨h₀, h₁, Aplus, Aminus, h₀pos, h₀₁, h₁lt, hAplus, hAminus, + η, hη, hηc, hη1, Cp, Cm, hCp, hCm, hBoundsP, hBoundsM, ?_, ?_, ?_⟩ + · intro p + by_cases hE : η p.1 = 0 + · simp [Cp, ambientStripCutoff, hE] + by_cases hVp : βp p.2.1 = 0 + · simp [Cp, ambientStripCutoff, hVp] + by_cases hVm : βm p.2.1 = 0 + · simp [Cm, ambientStripCutoff, hVm] + have hI : p.1 ∈ Icc l u := by by_contra h; exact hE (hηs _ h) + have hJp : p.2.1 ∈ Metric.closedBall yp rp := by by_contra h; exact hVp (hβps _ h) + have hJm : p.2.1 ∈ Metric.closedBall ym rm := by by_contra h; exact hVm (hβms _ h) + have hp := (hP (p.1, p.2.1) ⟨hI, hJp⟩).1 + have hm := (hM (p.1, p.2.1) ⟨hI, hJm⟩).1 + exfalso + linarith only [hδ, hp, hm] + · intro g hg + simpa [Cp] using integral_ambientStripCutoff (by norm_num : (1 : ℝ) ^ 2 = 1) + hδ hz measurableSet_Icc Metric.isClosed_closedBall.measurableSet hη hβp + hηs hβps hβp1 (by simpa using hP) g hg + · intro g hg + simpa [Cm] using integral_ambientStripCutoff (by norm_num : (-1 : ℝ) ^ 2 = 1) + hδ hz measurableSet_Icc Metric.isClosed_closedBall.measurableSet hη hβm + hηs hβms hβm1 (by simpa using hM) g hg + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean b/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean new file mode 100644 index 0000000000..8e95fc73c4 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean @@ -0,0 +1,393 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.RoundAreaBridge +public import Mathlib.Analysis.Calculus.FDeriv.WithLp +public import Mathlib.Analysis.SpecialFunctions.Sqrt +public import Mathlib.MeasureTheory.Function.Jacobian +public import Mathlib.Analysis.SpecialFunctions.Integrals.Basic +public import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.FunProp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! +# Area density for the upper - hemisphere graph +-/ + +@[expose] public section +noncomputable section + +open MeasureTheory Set Filter intervalIntegral +open scoped ENNReal Pointwise + +namespace VenRateUpper + +/-- Domain of the Cartesian graph of the upper open hemisphere. -/ +def graphDisk : Set (ℝ × ℝ) := {p | 0 < 1 - p.1 ^ 2 - p.2 ^ 2} + +theorem isOpen_graphDisk : IsOpen graphDisk := + isOpen_lt continuous_const (by fun_prop) + +/-- The nonnegative sphere height over the unit disk. -/ +def graphHeight (p : ℝ × ℝ) : ℝ := Real.sqrt (1 - p.1 ^ 2 - p.2 ^ 2) + +theorem graphHeight_pos {p : ℝ × ℝ} (hp : p ∈ graphDisk) : 0 < graphHeight p := + Real.sqrt_pos.2 hp + +theorem graphHeight_sq {p : ℝ × ℝ} (hp : p ∈ graphDisk) : + graphHeight p ^ 2 = 1 - p.1 ^ 2 - p.2 ^ 2 := + Real.sq_sqrt (le_of_lt hp) + +theorem contDiffOn_graphHeight : ContDiffOn ℝ ⊤ graphHeight graphDisk := + ((by fun_prop : ContDiff ℝ ⊤ (fun p : ℝ × ℝ ↦ 1 - p.1 ^ 2 - p.2 ^ 2)).contDiffOn).sqrt + fun _ hp ↦ ne_of_gt hp + +/-- Embed the open disk as the sphere's upper hemisphere. -/ +def upperGraph (p : graphDisk) : VenMask.UnitSphere := + ⟨(p.1.1, p.1.2, graphHeight p.1), by rw [graphHeight_sq p.property]; ring⟩ + +/-- Euclidean surface Jacobian of the Cartesian graph. -/ +def graphAreaDensity (p : ℝ × ℝ) : ℝ := (graphHeight p)⁻¹ + +theorem graphAreaDensity_pos {p : ℝ × ℝ} (hp : p ∈ graphDisk) : 0 < graphAreaDensity p := + inv_pos.2 (graphHeight_pos hp) + +theorem contDiffOn_graphAreaDensity : ContDiffOn ℝ ⊤ graphAreaDensity graphDisk := + contDiffOn_graphHeight.inv fun _ hp ↦ (graphHeight_pos hp).ne' + +/-- Scale a lifted disk point by the third coordinate to parametrize its radial cone. -/ +def coneGraph (p : RoundAmbient) : RoundAmbient := + WithLp.toLp 2 ![p 2 * p 0, p 2 * p 1, p 2 * graphHeight (p 0, p 1)] + +private abbrev coorBasis := (EuclideanSpace.basisFun (Fin 3) ℝ).toBasis + +private def coneDerivativeMatrix (p : RoundAmbient) : Matrix (Fin 3) (Fin 3) ℝ := + let z := graphHeight (p 0, p 1) + !![p 2, 0, p 0; 0, p 2, p 1; -(p 2 * p 0) / z, -(p 2 * p 1) / z, z] + +private def coneDerivative (p : RoundAmbient) : RoundAmbient →L[ℝ] RoundAmbient := + (Matrix.toLin coorBasis coorBasis (coneDerivativeMatrix p)).toContinuousLinearMap + +private lemma coneDerivative_apply (p v : RoundAmbient) (i : Fin 3) : + coneDerivative p v i = + (![p 2 * v 0 + p 0 * v 2, p 2 * v 1 + p 1 * v 2, + (-(p 2 * p 0) / graphHeight (p 0, p 1)) * v 0 + + (-(p 2 * p 1) / graphHeight (p 0, p 1)) * v 1 + + graphHeight (p 0, p 1) * v 2] : Fin 3 → ℝ) i := by + change coorBasis.repr ((Matrix.toLin coorBasis coorBasis (coneDerivativeMatrix p)) v) i = _ + rw [Matrix.repr_toLin] + fin_cases i <;> + simp [coneDerivativeMatrix, Matrix.mulVec, dotProduct, Fin.sum_univ_three, + Matrix.cons_val_two, Matrix.head_cons, Matrix.tail_cons] + +private theorem hasFDerivAt_coneGraph {p : RoundAmbient} + (hp : (p 0, p 1) ∈ graphDisk) : HasFDerivAt coneGraph (coneDerivative p) p := by + have hx := PiLp.hasFDerivAt_apply (𝕜 := ℝ) 2 p (0 : Fin 3) + have hy := PiLp.hasFDerivAt_apply (𝕜 := ℝ) 2 p (1 : Fin 3) + have hr := PiLp.hasFDerivAt_apply (𝕜 := ℝ) 2 p (2 : Fin 3) + have hz := (((hasFDerivAt_const (1 : ℝ) p).sub (hx.pow 2)).sub (hy.pow 2)).sqrt + (show 1 - p 0 ^ 2 - p 1 ^ 2 ≠ 0 from ne_of_gt hp) + have hProj (i : Fin 3) (v : RoundAmbient) : + (PiLp.proj (𝕜 := ℝ) 2 (fun _ : Fin 3 ↦ ℝ) i) v = v i := rfl + rw [← hasFDerivWithinAt_univ, hasFDerivWithinAt_piLp 2] + intro i + apply HasFDerivAt.hasFDerivWithinAt + fin_cases i + · convert hr.mul hx using 1 + · rfl + · apply ContinuousLinearMap.ext + intro v + simp [coneDerivative_apply, hProj] + · convert hr.mul hy using 1 + · rfl + · apply ContinuousLinearMap.ext + intro v + simp [coneDerivative_apply, hProj] + · convert hr.mul hz using 1 + · rfl + · apply ContinuousLinearMap.ext + intro v + have hZ : graphHeight (p 0, p 1) ≠ 0 := (graphHeight_pos hp).ne' + simp [coneDerivative_apply, hProj, graphHeight] + unfold graphHeight at hZ + field_simp + ring + +private theorem det_coneDerivative {p : RoundAmbient} + (hp : (p 0, p 1) ∈ graphDisk) : + (coneDerivative p).det = (p 2) ^ 2 * graphAreaDensity (p 0, p 1) := by + unfold coneDerivative coneDerivativeMatrix graphAreaDensity + simp only [LinearMap.det_toContinuousLinearMap, LinearMap.det_toLin, Matrix.det_fin_three, + Matrix.of_apply, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, + Matrix.head_cons, Matrix.tail_cons, mul_zero, zero_mul, add_zero, sub_zero] + have hz := graphHeight_pos hp + have hunit := graphHeight_sq hp + field_simp + linear_combination (p 2) ^ 2 * hunit + + +/-- Sphere points with positive third coordinate. -/ +def upperHemisphere : Set VenMask.UnitSphere := {q | 0 < q.val.2.2} + +/-- Project a sphere point onto its first two coordinates. -/ +def graphProjection (q : VenMask.UnitSphere) : ℝ × ℝ := (q.val.1, q.val.2.1) + +theorem continuous_graphProjection : Continuous graphProjection := by + have hc : Continuous (fun q : VenMask.UnitSphere ↦ q.val) := continuous_subtype_val + exact hc.fst.prodMk hc.snd.fst + +/-- The image of a measurable subpatch is its inverse image under the coordinate projection, +intersected with the upper hemisphere. -/ +theorem upperGraph_image (U : Set (ℝ × ℝ)) : + upperGraph '' (Subtype.val ⁻¹' U) = upperHemisphere ∩ graphProjection ⁻¹' U := by + ext q + constructor + · rintro ⟨p, hp, rfl⟩ + exact ⟨graphHeight_pos p.property, hp⟩ + · rintro ⟨hq, hU⟩ + have hsub : 1 - q.val.1 ^ 2 - q.val.2.1 ^ 2 = q.val.2.2 ^ 2 := by + linarith [q.property] + have hd : graphProjection q ∈ graphDisk := by + change 0 < 1 - q.val.1 ^ 2 - q.val.2.1 ^ 2 + rw [hsub] + exact sq_pos_of_pos hq + refine ⟨⟨graphProjection q, hd⟩, hU, ?_⟩ + apply Subtype.ext + have hz : graphHeight (graphProjection q) = q.val.2.2 := by + unfold graphHeight graphProjection + simp only + rw [hsub, Real.sqrt_sq hq.le] + change (q.val.1, q.val.2.1, graphHeight (graphProjection q)) = q.val + rw [hz] + +theorem measurableSet_upperGraph_image {U : Set (ℝ × ℝ)} (hU : MeasurableSet U) : + MeasurableSet (upperGraph '' (Subtype.val ⁻¹' U)) := by + rw [upperGraph_image] + have hc : Continuous (fun q : VenMask.UnitSphere ↦ q.val) := continuous_subtype_val + exact (isOpen_lt continuous_const hc.snd.snd).measurableSet.inter + (continuous_graphProjection.measurable hU) + +private def radialCoordinates : RoundAmbient ≃ᵐ ℝ × (ℝ × ℝ) := + ((MeasurableEquiv.toLp 2 (Fin 3 → ℝ)).symm.trans + (MeasurableEquiv.piFinSuccAbove (fun _ : Fin 3 ↦ ℝ) (Fin.last 2))).trans + (MeasurableEquiv.prodCongr (MeasurableEquiv.refl ℝ) + (MeasurableEquiv.piFinTwo (fun _ : Fin 2 ↦ ℝ))) + +private lemma radialCoordinates_apply (p : RoundAmbient) : + radialCoordinates p = (p 2, p 0, p 1) := rfl + +private lemma measurePreserving_radialCoordinates : MeasurePreserving radialCoordinates := by + let e := MeasurableEquiv.piFinTwo (fun _ : Fin 2 ↦ ℝ) + have he : MeasurePreserving e := volume_preserving_piFinTwo _ + have h₁ := (volume_preserving_piFinSuccAbove + (fun _ : Fin 3 ↦ ℝ) (Fin.last 2)).comp (PiLp.volume_preserving_ofLp (Fin 3)) + have h₂ : MeasurePreserving (fun p : ℝ × (Fin 2 → ℝ) ↦ (p.1, e p.2)) volume volume := + (MeasurePreserving.id (volume : Measure ℝ)).skew_product + (g := fun (_ : ℝ) x ↦ e x) (e.measurable.comp measurable_snd) (ae_of_all _ fun _ ↦ he.map_eq) + exact h₂.comp h₁ + +private lemma coneGraph_eq_smul {p : RoundAmbient} (hp : (p 0, p 1) ∈ graphDisk) : + coneGraph p = (p 2) • (toMetricSphere (upperGraph ⟨(p 0, p 1), hp⟩)).val := by + apply PiLp.ext + intro i + fin_cases i <;> rfl + +private def graphSector (U : Set (ℝ × ℝ)) : Set RoundAmbient := + radialCoordinates ⁻¹' (Ioo (0 : ℝ) 1 ×ˢ U) + +private lemma coneGraph_injOn {U : Set (ℝ × ℝ)} (hUD : U ⊆ graphDisk) : + InjOn coneGraph (graphSector U) := by + intro p hp q hq h + rw [graphSector, mem_preimage, radialCoordinates_apply, mem_prod] at hp hq + have hp' := hUD hp.2 + have hq' := hUD hq.2 + have hpNorm : ‖coneGraph p‖ = p 2 := by + rw [coneGraph_eq_smul hp', norm_smul, mem_sphere_zero_iff_norm.mp (Subtype.prop _), + mul_one, Real.norm_eq_abs, abs_of_pos hp.1.1] + have hqNorm : ‖coneGraph q‖ = q 2 := by + rw [coneGraph_eq_smul hq', norm_smul, mem_sphere_zero_iff_norm.mp (Subtype.prop _), + mul_one, Real.norm_eq_abs, abs_of_pos hq.1.1] + have hr : p 2 = q 2 := by rw [← hpNorm, h, hqNorm] + have hx : p 0 = q 0 := by + have hh : p 2 * p 0 = q 2 * q 0 := congrArg (fun u : RoundAmbient ↦ u 0) h + rw [← hr] at hh + exact mul_left_cancel₀ hp.1.1.ne' hh + have hy : p 1 = q 1 := by + have hh : p 2 * p 1 = q 2 * q 1 := congrArg (fun u : RoundAmbient ↦ u 1) h + rw [← hr] at hh + exact mul_left_cancel₀ hp.1.1.ne' hh + apply PiLp.ext + intro i + fin_cases i + · exact hx + · exact hy + · exact hr + +private lemma coneGraph_image {U : Set (ℝ × ℝ)} (hUD : U ⊆ graphDisk) : + coneGraph '' graphSector U = + Ioo (0 : ℝ) 1 • + (Subtype.val '' (metricSphereHomeomorph ⁻¹' (upperGraph '' (Subtype.val ⁻¹' U)))) := by + ext w + constructor + · rintro ⟨p, hp, rfl⟩ + rw [graphSector, mem_preimage, radialCoordinates_apply, mem_prod] at hp + let q := upperGraph ⟨(p 0, p 1), hUD hp.2⟩ + have hq : q ∈ upperGraph '' (Subtype.val ⁻¹' U) := + ⟨⟨(p 0, p 1), hUD hp.2⟩, hp.2, rfl⟩ + refine ⟨p 2, hp.1, (toMetricSphere q).val, ⟨toMetricSphere q, ?_, rfl⟩, + (coneGraph_eq_smul (hUD hp.2)).symm⟩ + change metricSphereHomeomorph (metricSphereHomeomorph.symm q) ∈ + (upperGraph '' (Subtype.val ⁻¹' U)) + simpa using hq + · rintro ⟨r, hr, v, ⟨q, hq, rfl⟩, rfl⟩ + rcases hq with ⟨p, hp, heq⟩ + let u : RoundAmbient := WithLp.toLp 2 ![p.val.1, p.val.2, r] + refine ⟨u, ?_, ?_⟩ + · rw [graphSector, mem_preimage, radialCoordinates_apply, mem_prod] + exact ⟨hr, hp⟩ + · rw [coneGraph_eq_smul p.property] + change r • (metricSphereHomeomorph.symm (upperGraph p)).val = _ + rw [heq, metricSphereHomeomorph.symm_apply_apply] + +private lemma lintegral_radial_pow : + (∫⁻ r in Ioo (0 : ℝ) 1, ENNReal.ofReal (r ^ 2)) = ENNReal.ofReal (1 / 3) := by + rw [Measure.restrict_congr_set Ioo_ae_eq_Ioc, + ← ofReal_integral_eq_lintegral_ofReal (intervalIntegrable_pow (a := 0) (b := 1) (μ := + volume) 2).1, + ← intervalIntegral.integral_of_le (by norm_num), integral_pow] + · norm_num + · exact Eventually.of_forall (fun r ↦ sq_nonneg r) + +private lemma lintegral_coneGraph_jacobian {U : Set (ℝ × ℝ)} + (hU : MeasurableSet U) (hUD : U ⊆ graphDisk) : + (volume : Measure RoundAmbient) (coneGraph '' graphSector U) = + ENNReal.ofReal (1 / 3) * ∫⁻ p in U, ENNReal.ofReal (graphAreaDensity p) := by + have hSet : MeasurableSet (graphSector U) := + radialCoordinates.measurable (measurableSet_Ioo.prod hU) + have hD {p} (hp : p ∈ graphSector U) : (p 0, p 1) ∈ graphDisk := by + rw [graphSector, mem_preimage, radialCoordinates_apply, mem_prod] at hp + exact hUD hp.2 + have hJac := lintegral_image_eq_lintegral_abs_det_fderiv_mul + (volume : Measure RoundAmbient) hSet + (fun _ hp ↦ (hasFDerivAt_coneGraph (hD hp)).hasFDerivWithinAt) + (coneGraph_injOn hUD) (fun _ ↦ (1 : ℝ≥0∞)) + rw [lintegral_const, one_mul] at hJac + simp only [Measure.restrict_apply_univ, mul_one] at hJac + rw [hJac] + calc + _ = ∫⁻ p in graphSector U, + ENNReal.ofReal ((p 2) ^ 2) * ENNReal.ofReal (graphAreaDensity (p 0, p 1)) := by + refine setLIntegral_congr_fun hSet (fun p hp ↦ ?_) + rw [det_coneDerivative (hD hp), abs_of_nonneg (mul_nonneg (sq_nonneg _) + (graphAreaDensity_pos (hD hp)).le), ENNReal.ofReal_mul (sq_nonneg _)] + _ = ∫⁻ p in Ioo (0 : ℝ) 1 ×ˢ U, + ENNReal.ofReal (p.1 ^ 2) * ENNReal.ofReal (graphAreaDensity p.2) := by + simpa only [graphSector, radialCoordinates_apply] using + (measurePreserving_radialCoordinates.setLIntegral_comp_preimage_emb + radialCoordinates.measurableEmbedding + (fun p : ℝ × (ℝ × ℝ) ↦ + ENNReal.ofReal (p.1 ^ 2) * ENNReal.ofReal (graphAreaDensity p.2)) + (Ioo (0 : ℝ) 1 ×ˢ U)) + _ = ENNReal.ofReal (1 / 3) * ∫⁻ p in U, ENNReal.ofReal (graphAreaDensity p) := by + change (∫⁻ p : ℝ × (ℝ × ℝ), _ ∂ + (((volume : Measure ℝ).prod (volume : Measure (ℝ × ℝ))).restrict + (Ioo (0 : ℝ) 1 ×ˢ U))) = _ + have hRad : AEMeasurable (fun r : ℝ ↦ ENNReal.ofReal (r ^ 2)) + ((volume : Measure ℝ).restrict (Ioo 0 1)) := + ((measurable_id.pow_const _).ennreal_ofReal).aemeasurable + have hDisk : AEMeasurable (fun p ↦ ENNReal.ofReal (graphAreaDensity p)) + ((volume : Measure (ℝ × ℝ)).restrict U) := + by + have hSqrt : Continuous (fun p : ℝ × ℝ ↦ √(1 - p.1 ^ 2 - p.2 ^ 2)) := by fun_prop + exact hSqrt.measurable.inv.ennreal_ofReal.aemeasurable + rw [← Measure.prod_restrict, lintegral_prod_mul hRad hDisk, lintegral_radial_pow] + +/-- The upper hemisphere has ordinary Euclidean graph area with density +`1 / sqrt (1 - x ^ 2 - y ^ 2)` in Cartesian coordinates. -/ +theorem roundAreaUnnormalized_upperGraph {U : Set (ℝ × ℝ)} + (hU : MeasurableSet U) (hUD : U ⊆ graphDisk) : + roundAreaUnnormalized (upperGraph '' (Subtype.val ⁻¹' U)) = + ∫⁻ p in U, ENNReal.ofReal (graphAreaDensity p) := by + rw [roundAreaUnnormalized_apply (measurableSet_upperGraph_image hU), ← coneGraph_image hUD, + lintegral_coneGraph_jacobian hU hUD, ← mul_assoc] + have h : (3 : ℝ≥0∞) * ENNReal.ofReal (1 / 3) = 1 := by + rw [← ENNReal.ofReal_ofNat, ← ENNReal.ofReal_mul (by norm_num : (0 : ℝ) ≤ 3)] + norm_num + rw [h, one_mul] + +/-- The normalized round law restricted to the chart, expressed on measurable planar patches. -/ +theorem roundArea_upperGraph {U : Set (ℝ × ℝ)} + (hU : MeasurableSet U) (hUD : U ⊆ graphDisk) : + roundArea (upperGraph '' (Subtype.val ⁻¹' U)) = + (roundAreaUnnormalized univ)⁻¹ * ∫⁻ p in U, ENNReal.ofReal (graphAreaDensity p) := by + rw [roundArea, smul_apply, smul_eq_mul, roundAreaUnnormalized_upperGraph hU hUD] + +private theorem graphProjection_mem_graphDisk {q : VenMask.UnitSphere} + (hq : q ∈ upperHemisphere) : graphProjection q ∈ graphDisk := by + change 0 < 1 - q.val.1 ^ 2 - q.val.2.1 ^ 2 + have hs := q.property + have hz : 0 < q.val.2.2 := hq + nlinarith [sq_pos_of_pos hz] + +/-- The chart projection pushes the upper-hemisphere restriction to the weighted planar law. -/ +theorem map_graphProjection_roundArea : + Measure.map graphProjection (roundArea.restrict upperHemisphere) = + (roundAreaUnnormalized univ)⁻¹ • + ((volume : Measure (ℝ × ℝ)).restrict graphDisk).withDensity + (fun p ↦ ENNReal.ofReal (graphAreaDensity p)) := by + ext U hU + rw [Measure.map_apply continuous_graphProjection.measurable hU, + Measure.restrict_apply (continuous_graphProjection.measurable hU), + smul_apply, smul_eq_mul, withDensity_apply _ hU, Measure.restrict_restrict hU] + have hPatch : MeasurableSet (U ∩ graphDisk) := hU.inter isOpen_graphDisk.measurableSet + have hEq : graphProjection ⁻¹' U ∩ upperHemisphere = + upperGraph '' (Subtype.val ⁻¹' (U ∩ graphDisk)) := by + rw [upperGraph_image] + ext q + exact ⟨fun h ↦ ⟨h.2, h.1, graphProjection_mem_graphDisk h.2⟩, + fun h ↦ ⟨h.2.1, h.1⟩⟩ + rw [hEq, roundArea_upperGraph hPatch inter_subset_right] + + +/-- The Euclidean cone-area law has total area `4π`. -/ +theorem roundAreaUnnormalized_univ : + roundAreaUnnormalized univ = ENNReal.ofReal (4 * Real.pi) := by + rw [roundAreaUnnormalized, Measure.map_apply metricSphereHomeomorph.measurable + MeasurableSet.univ, preimage_univ, Measure.toSphere_apply_univ, + EuclideanSpace.volume_ball_fin_three] + have hrank : (Module.finrank ℝ RoundAmbient : ℝ≥0∞) = 3 := by simp + simp only [hrank, ENNReal.ofReal_one, one_pow, one_mul] + rw [← ENNReal.ofReal_ofNat, ← ENNReal.ofReal_mul (by norm_num : (0 : ℝ) ≤ 3)] + congr 1 + ring + +/-- Bochner integral change of variables for the upper hemisphere. -/ +theorem integral_roundArea_upperHemisphere (f : ℝ × ℝ → ℝ) (hf : Measurable f) : + (∫ q in upperHemisphere, f (graphProjection q) ∂roundArea) = + (4 * Real.pi)⁻¹ * ∫ p in graphDisk, graphAreaDensity p * f p := by + rw [← integral_map continuous_graphProjection.measurable.aemeasurable hf.aestronglyMeasurable, + map_graphProjection_roundArea, MeasureTheory.integral_smul_measure, roundAreaUnnormalized_univ, + ENNReal.toReal_inv, ENNReal.toReal_ofReal (by positivity)] + have hMeas : Measurable graphAreaDensity := + ((Real.continuous_sqrt.comp (by fun_prop : + Continuous (fun p : ℝ × ℝ ↦ 1 - p.1 ^ 2 - p.2 ^ 2))).measurable.inv) + have hDensity : (fun p ↦ ENNReal.ofReal (graphAreaDensity p)) = + fun p ↦ (Real.toNNReal (graphAreaDensity p) : ℝ≥0∞) := by + funext p + exact (ENNReal.ofNNReal_toNNReal _).symm + rw [hDensity, integral_withDensity_eq_integral_smul hMeas.real_toNNReal] + congr 1 + refine setIntegral_congr_fun isOpen_graphDisk.measurableSet (fun p hp ↦ ?_) + rw [NNReal.smul_def, Real.coe_toNNReal _ (graphAreaDensity_pos hp).le, smul_eq_mul] + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/SphereModel.lean b/LeanPool/VenNullClockRoundRates/SphereModel.lean new file mode 100644 index 0000000000..2ef86b5519 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/SphereModel.lean @@ -0,0 +1,51 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Measure.OpenPos + +/-! Coordinate-fixed pair of axes in the physical round generator sphere: +first axis (1, 0, 0), second (cos θ, sin θ, 0). The measure may be the normalized +area law. The conclusion concerns scalar exponential reads, not a PDE. -/ +@[expose] public section +noncomputable section +open MeasureTheory +open scoped Topology +namespace VenMask +/-- The Cartesian unit sphere used by the scalar observation model. -/ +def UnitSphere := {q : ℝ × ℝ × ℝ // q.1 ^ 2 + q.2.1 ^ 2 + q.2.2 ^ 2 = 1} +deriving instance TopologicalSpace, MeasurableSpace for UnitSphere + +/-- Quadrupole energy as a function of the coordinate along the axis. -/ +def energy (u : ℝ) : ℝ := (1 - u ^ 2) ^ 2 + +/-- Energy for the first axis, aligned with the first Cartesian coordinate. -/ +def firstEnergy (y : UnitSphere) : ℝ := energy y.val.1 + +/-- Energy for the second axis rotated in the first two coordinates by `θ`. -/ +def secondEnergy (θ : ℝ) (y : UnitSphere) : ℝ := + energy (Real.cos θ * y.val.1 + Real.sin θ * y.val.2.1) + +/-- Unweighted exponential observation kernel for a finite list of controls. -/ +def sphereKernel {n : ℕ} (x s : Fin n → ℝ) (θ : ℝ) (i : Fin n) (y : UnitSphere) : ℝ := + Real.exp (x i * firstEnergy y + s i * secondEnergy θ y) + +/-- At every nonaligned angle, with any fixed list of distinct strength pairs, +one strictly positive hidden log - focusing suffices at each nearby angle to +match *all* of the reference mean reads exactly. The multiplier is an analytic +angular function (constant plus finite combinations of exponential kernels). -/ +def SphereMaskingCertificate : Prop := + ∀ {n : ℕ} (μ : Measure UnitSphere) [IsFiniteMeasure μ] [μ.IsOpenPosMeasure] + (x s : Fin n → ℝ) (θ₀ w₀ : ℝ), + 1 < w₀ → Real.sin θ₀ ≠ 0 → Function.Injective (fun i ↦ (x i, s i)) → + ∀ᶠ θ in 𝓝 θ₀, ∃ c : Fin n → ℝ, + let k := sphereKernel x s + let w := fun y ↦ w₀ + ∑ j, c j * k θ j y + (∀ y, 1 < w y) ∧ + (∀ i, (∫ y, w y * k θ i y ∂μ) = ∫ y, w₀ * k θ₀ i y ∂μ) +end VenMask diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean new file mode 100644 index 0000000000..5f0998f93b --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean @@ -0,0 +1,206 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.VenRateUpperHeight +public import LeanPool.VenNullClockRoundRates.VenRateUpperPositive +public import LeanPool.VenNullClockRoundRates.VenRateUpperTaylor +public import LeanPool.VenNullClockRoundRates.VenRateUpperBudget +public import Mathlib.Topology.Algebra.Polynomial +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! Assembly of the exponential bound from two opposite pushforward cutoffs. +The chart law supplying the two integral identities is used separately. -/ + +@[expose] public section +open MeasureTheory +open scoped ContDiff + +namespace VenRateUpper + +variable {Ω : Type*} [TopologicalSpace Ω] [MeasurableSpace Ω] + +private theorem compact_integrable [OpensMeasurableSpace Ω] [CompactSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] + {g : Ω → ℝ} (hg : Continuous g) : Integrable g μ := + hg.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace g) + +private noncomputable def correctionFunctional [OpensMeasurableSpace Ω] [CompactSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] + {q F : Ω → ℝ} (hq : Continuous q) (hF : Continuous F) : + Polynomial ℝ →ₗ[ℝ] ℝ where + toFun P := -(∫ y, q y * 2 * P.eval (F y) ∂μ) + map_add' P Q := by + simp only [Polynomial.eval_add] + simp_rw [mul_add] + have hp : Integrable (fun y => q y * 2 * P.eval (F y)) μ := + compact_integrable μ ((hq.mul continuous_const).mul (P.continuous.comp hF)) + have hq' : Integrable (fun y => q y * 2 * Q.eval (F y)) μ := + compact_integrable μ ((hq.mul continuous_const).mul (Q.continuous.comp hF)) + rw [integral_add hp hq', neg_add] + map_smul' a P := by + change -(∫ y, q y * 2 * (a • P).eval (F y) ∂μ) = + a * -(∫ y, q y * 2 * P.eval (F y) ∂μ) + simp only [Polynomial.eval_smul, smul_eq_mul] + have eqHere : (fun y => q y * 2 * (a * P.eval (F y))) = + fun y => a * (q y * 2 * P.eval (F y)) := by + funext y + ring + rw [eqHere, integral_const_mul, mul_neg] + +private theorem correctionFunctional_bounded [OpensMeasurableSpace Ω] [CompactSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] + {q F : Ω → ℝ} (hq : Continuous q) (hF : Continuous F) {Q : ℝ} + (qBdd : ∀ y, |q y| ≤ Q) (height : ∀ y, F y ∈ Set.Icc (-1 : ℝ) 1) + (P : Polynomial ℝ) (A : ℝ) + (hP : ∀ u ∈ Set.Icc (-1 : ℝ) 1, |P.eval u| ≤ A) : + |correctionFunctional μ hq hF P| ≤ (2 * Q) * A := by + have hA : 0 ≤ A := (abs_nonneg (P.eval 0)).trans (hP 0 (by norm_num)) + change |-(∫ y, q y * 2 * P.eval (F y) ∂μ)| ≤ _ + rw [abs_neg] + apply abs_integral_le_integral_abs.trans + calc + _ ≤ ∫ _ : Ω, (2 * Q) * A ∂μ := by + refine integral_mono_of_nonneg (Filter.Eventually.of_forall fun _ => abs_nonneg _) + (integrable_const _) (Filter.Eventually.of_forall fun y => ?_) + change |q y * 2 * P.eval (F y)| ≤ _ + rw [abs_mul, abs_mul, abs_of_nonneg (by norm_num : (0 : ℝ) ≤ 2), mul_comm |q y| 2] + exact mul_le_mul (mul_le_mul_of_nonneg_left (qBdd y) (by norm_num)) (hP _ (height y)) + (abs_nonneg _) (by + have hQ := (abs_nonneg (q y)).trans (qBdd y) + positivity) + _ = _ := by simp + +private theorem succ_le_pow_two (n : ℕ) : n + 1 ≤ 2 ^ n := by + induction n with + | zero => decide + | succ n ih => + rw [pow_succ] + have hp : 0 < 2 ^ n := by positivity + omega + +theorem exponential_upper_of_twoStripIdentities [OpensMeasurableSpace Ω] [CompactSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] {F H q chiPlus chiMinus : Ω → ℝ} + {η ψ : ℝ → ℝ} {t₀ t₁ ℓ B Q Aplus Aminus a : ℝ} + (hF : Continuous F) (hH : Continuous H) (hq : Continuous q) (hPlus : Continuous chiPlus) + (hMinus : Continuous chiMinus) (hη : Continuous η) (suppη : HasCompactSupport η) + (hψ : ContDiff ℝ ∞ ψ) (normψ : (∫ t, ψ t) = 1) + (supψ : ∀ t, |ψ t| ≤ B) (suppψ : ∀ t ∉ Set.Icc t₀ t₁, ψ t = 0) + (hℓ : 0 < ℓ) (h₀ : -1 ≤ t₀) (h₁ : t₁ + ℓ ≤ 1) + (hfη : ∀ t ∈ Set.Icc t₀ (t₁ + ℓ), η t = 1) + (height : ∀ y, F y ∈ Set.Icc (0 : ℝ) 1) + (rangeH : ∀ y, H y ∈ Set.Icc (-1 : ℝ) 1) + (heightRelation : ∀ y, F y = (1 - (H y) ^ 2) ^ 2) (qBdd : ∀ y, |q y| ≤ Q) + (plusBdd : ∀ y, chiPlus y ∈ Set.Icc (0 : ℝ) Aplus) + (minusBdd : ∀ y, chiMinus y ∈ Set.Icc (0 : ℝ) Aminus) + (hQ : 0 ≤ Q) + (ha : 0 ≤ a) + (identityPlus : ∀ g : ℝ → ℝ, Continuous g → + (∫ y, q y * chiPlus y * g (H y) ∂μ) = ∫ t, η t * g t) + (identityMinus : ∀ g : ℝ → ℝ, Continuous g → + (∫ y, q y * chiMinus y * g (H y) ∂μ) = -(∫ t, η t * g t)) : + ∃ c M₁ : ℝ, 0 < c ∧ 1 < M₁ ∧ ∀ M ≥ M₁, ∃ (ρ : ℝ → ℝ) (K : ℝ), + ContDiff ℝ ∞ ρ ∧ (∀ y, twoStripProfile H chiPlus chiMinus ρ K y ∈ Set.Icc (2 : ℝ) M) ∧ + ∀ x ∈ Set.Icc (0 : ℝ) a, + |∫ y, (q y * twoStripProfile H chiPlus chiMinus ρ K y) * + Real.exp (x * F y) ∂μ| ≤ Real.exp (-c * Real.log M * Real.log (Real.log M)) := by + let L := correctionFunctional μ hq hH + have hB : 0 ≤ B := (abs_nonneg (ψ 0)).trans (supψ 0) + let Kbase := B * (2 * Q) + let R := max 1 (4 * Real.exp 1 / ℓ) + let D := (2 * R) ^ 4 + let A := max D (2 + (2 * Aplus + Aminus) * Kbase) + have R1 : 1 ≤ R := le_max_left _ _ + have D2 : 2 ≤ D := by + have Hpower := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) + (show (2 : ℝ) ≤ 2 * R by linarith only [R1]) 4 + calc + (2 : ℝ) ≤ 2 ^ 4 := by norm_num + _ ≤ D := Hpower + have Agt : 1 < A := (by norm_num : (1 : ℝ) < 2).trans_le (D2.trans (le_max_left _ _)) + have Kbase0 : 0 ≤ Kbase := mul_nonneg hB (mul_nonneg (by norm_num) hQ) + obtain ⟨c, M₁, hc, hM₁, budget⟩ := exists_factorial_budget_with_kernel + Agt ha (show 0 ≤ Q * Real.exp a from mul_nonneg hQ (Real.exp_pos a).le) + refine ⟨c, M₁, hc, hM₁,?_⟩ + intro M hM + obtain ⟨n, hn, cost, tail⟩ := budget M hM + obtain ⟨ρ, hρ, suppρ, supρ, momρ⟩ := smooth_height_moment_correction + (4 * n) (by omega) ℓ t₀ t₁ B (2 * Q) hℓ h₀ h₁ hB (mul_nonneg (by norm_num) hQ) + L (correctionFunctional_bounded μ hq hH qBdd rangeH) ψ hψ normψ supψ suppψ + let K := Kbase * D ^ n + have hK : 0 ≤ K := mul_nonneg Kbase0 (pow_nonneg (by linarith only [D2]) _) + have supρ' (t : ℝ) : |ρ t| ≤ K := by + have hn2 : ((4 * n + 1 : ℕ) : ℝ) ≤ (2 : ℝ) ^ (4 * n) := by + exact_mod_cast succ_le_pow_two (4 * n) + have hpow : (4 * Real.exp 1 / ℓ) ^ (4 * n) ≤ R ^ (4 * n) := + pow_le_pow_left₀ (by positivity) (le_max_right _ _) _ + calc + _ ≤ ((4 * n + 1 : ℕ) : ℝ) * (B * ((2 * Q) * (4 * Real.exp 1 / ℓ) ^ (4 * n))) := supρ t + _ = Kbase * (((4 * n + 1 : ℕ) : ℝ) * (4 * Real.exp 1 / ℓ) ^ (4 * n)) := by dsimp [Kbase]; ring + _ ≤ Kbase * ((2 : ℝ) ^ (4 * n) * R ^ (4 * n)) := by + apply mul_le_mul_of_nonneg_left _ Kbase0 + exact mul_le_mul hn2 hpow (by positivity) (by positivity) + _ = K := by rw [← mul_pow, pow_mul] + let w := twoStripProfile H chiPlus chiMinus ρ K + have Dn : 1 ≤ D ^ n := one_le_pow₀ ((by norm_num : (1 : ℝ) ≤ 2).trans D2) + have Apow : D ^ n ≤ A ^ n := pow_le_pow_left₀ (by linarith only [D2]) (le_max_left _ _) _ + have cap : 2 + Aplus * (2 * K) + Aminus * K ≤ A ^ (n + 1) := by + rw [pow_succ'] + calc + _ = 2 + ((2 * Aplus + Aminus) * Kbase) * D ^ n := by dsimp [K]; ring + _ ≤ (2 + (2 * Aplus + Aminus) * Kbase) * D ^ n := by nlinarith only [Dn] + _ ≤ A * A ^ n := mul_le_mul (le_max_right _ _) Apow (by positivity) + (zero_lt_one.trans Agt).le + have hw (y : Ω) : w y ∈ Set.Icc (2 : ℝ) (A ^ (n + 1)) := by + obtain ⟨hl, hu⟩ := twoStripProfile_bounds H chiPlus chiMinus ρ hK supρ' plusBdd minusBdd y + exact ⟨hl, hu.trans cap⟩ + have eta_rho (t : ℝ) : η t * ρ t = ρ t := by + by_cases hi : t ∈ Set.Icc t₀ (t₁ + ℓ) + · rw [hfη t hi, one_mul] + · rw [suppρ t hi, mul_zero] + have moments (j : ℕ) (hj : j < n + 1) : (∫ y, (q y * w y) * F y ^ j ∂μ) = 0 := by + let P : Polynomial ℝ := ((1 - Polynomial.X ^ 2) ^ 2) ^ j + have Pval (t : ℝ) : P.eval t = ((1 - t ^ 2) ^ 2) ^ j := by simp [P] + have Ph (y : Ω) : F y ^ j = P.eval (H y) := by rw [heightRelation y, Pval] + have Psub : (1 - (Polynomial.X : Polynomial ℝ) ^ 2).natDegree ≤ 2 := + (Polynomial.natDegree_sub_le _ _).trans (by simp) + have Pnat : P.natDegree ≤ 4 * j := by + dsimp [P] + rw [Polynomial.natDegree_pow, Polynomial.natDegree_pow] + calc + _ ≤ j * (2 * 2) := Nat.mul_le_mul_left _ (Nat.mul_le_mul_left _ Psub) + _ = 4 * j := by omega + have Pdeg : P.degree < ((4 * n + 1 : ℕ) : WithBot ℕ) := by + apply Polynomial.degree_le_natDegree.trans_lt + exact_mod_cast (show P.natDegree < 4 * n + 1 by omega) + have hstrip := integral_twoStripProfile (f := fun t : ℝ => P.eval t) μ K hH hq hPlus hMinus hη + suppη hρ.continuous P.continuous eta_rho identityPlus identityMinus + simp_rw [Ph] + change (∫ y, q y * twoStripProfile H chiPlus chiMinus ρ K y * P.eval (H y) ∂μ) = 0 + rw [hstrip, momρ P Pdeg] + change (∫ y, q y * 2 * P.eval (H y) ∂μ) + -(∫ y, q y * 2 * P.eval (H y) ∂μ) = 0 + exact add_neg_cancel _ + have wCont : Continuous w := + (continuous_const.add (hPlus.mul (continuous_const.add (hρ.continuous.comp hH)))).add + (hMinus.mul continuous_const) + have supQ (y : Ω) : |q y * w y| ≤ Q * A ^ (n + 1) := by + have hw0 : 0 ≤ w y := (by norm_num : (0 : ℝ) ≤ 2).trans (hw y).1 + rw [abs_mul, abs_of_nonneg hw0] + exact mul_le_mul (qBdd y) (hw y).2 hw0 hQ + refine ⟨ρ, K, hρ, fun y => ⟨(hw y).1, (hw y).2.trans cost⟩,?_⟩ + intro x hx + have est := exponential_integral_le_of_zero_moments μ F (fun y => q y * w y) hF.measurable + height (compact_integrable μ (hq.mul wCont)) (by positivity : 0 ≤ Q * A ^ (n + 1)) + supQ (n + 1) moments hx.1 hx.2 + calc + _ ≤ Q * A ^ (n + 1) * (a ^ (n + 1) / ((n + 1).factorial : ℝ) * Real.exp a) := est + _ = Q * Real.exp a * A ^ (n + 1) * a ^ (n + 1) / ((n + 1).factorial : ℝ) := by ring + _ ≤ _ := tail + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean new file mode 100644 index 0000000000..16568ce484 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean @@ -0,0 +1,167 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Algebra.Order.Floor.Semiring +import Mathlib.Analysis.Complex.Exponential +import Mathlib.Order.Filter.AtTopBot.Basic +import Mathlib.Order.Filter.AtTopBot.Tendsto +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! +# Factorial error and the exponential profile budget +-/ + +@[expose] public section + +open Filter + +namespace VenRateUpper + +private theorem factorial_log_lower (n : ℕ) (hn : 1 ≤ n) : + (n : ℝ) * Real.log (n : ℝ) - (n : ℝ) ≤ Real.log (Nat.factorial (n + 1) : ℝ) := by + have hnReal : 0 < (n : ℝ) := by exact_mod_cast (Nat.succ_le_iff.mp hn) + have hnFactorial : 0 < (Nat.factorial n : ℝ) := by exact_mod_cast Nat.factorial_pos n + have hTerm := Real.pow_div_factorial_le_exp (n : ℝ) hnReal.le n + have hLog := (Real.log_le_iff_le_exp (div_pos (pow_pos hnReal n) hnFactorial)).2 hTerm + rw [Real.log_div (pow_pos hnReal n).ne' hnFactorial.ne', Real.log_pow] at hLog + have hFactorial : (Nat.factorial n : ℝ) ≤ (Nat.factorial (n + 1) : ℝ) := by + exact_mod_cast Nat.factorial_le (Nat.le_succ n) + exact (by linarith : (n : ℝ) * Real.log (n : ℝ) - (n : ℝ) ≤ + Real.log (Nat.factorial n : ℝ)).trans (Real.log_le_log hnFactorial hFactorial) + +/-- A single natural degree meets a fixed geometric budget and gives the +factorial error at most `exp (-c * log M * log (log M))` for every large budget. -/ +theorem exists_factorial_budget {C B : ℝ} (hC : 0 < C) (hB : 1 < B) : + ∃ c M₁ : ℝ, 0 < c ∧ 1 < M₁ ∧ ∀ M ≥ M₁, ∃ n : ℕ, 1 ≤ n ∧ + C * B ^ n ≤ M ∧ C * B ^ n / (Nat.factorial (n + 1) : ℝ) ≤ + Real.exp (-c * Real.log M * Real.log (Real.log M)) := by + let L := 2 * (Real.log B + 1) + let D := Real.log B + 1 + max 0 (Real.log C) + have hLogB := Real.log_pos hB + have hBPos : 0 < B := zero_lt_one.trans hB + have hL : 0 < L := by dsimp [L]; linarith + have hD : 0 < D := by + dsimp [D] + linarith [le_max_left (0 : ℝ) (Real.log C)] + let c := ((2 * L)⁻¹) / 4 + have hc : 0 < c := by dsimp [c]; positivity + have hLarge₁ : ∀ᶠ M : ℝ in atTop, max (2 * L) (2 * Real.log C) ≤ Real.log M := + Real.tendsto_log_atTop.eventually_ge_atTop _ + have hLarge₂ : ∀ᶠ M : ℝ in atTop, + max (2 * Real.log (2 * L)) (4 * D) ≤ Real.log (Real.log M) := + (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually_ge_atTop _ + have hResult : ∀ᶠ M : ℝ in atTop, ∃ n : ℕ, 1 ≤ n ∧ C * B ^ n ≤ M ∧ + C * B ^ n / (Nat.factorial (n + 1) : ℝ) ≤ + Real.exp (-c * Real.log M * Real.log (Real.log M)) := by + filter_upwards [hLarge₁, hLarge₂, eventually_ge_atTop (2 : ℝ)] with M h₁ h₂ hM + let x := Real.log M + let y := Real.log x + have hxL : 2 * L ≤ x := (le_max_left _ _).trans h₁ + have hxC : 2 * Real.log C ≤ x := (le_max_right _ _).trans h₁ + have hyL : 2 * Real.log (2 * L) ≤ y := (le_max_left _ _).trans h₂ + have hyD : 4 * D ≤ y := (le_max_right _ _).trans h₂ + have hx : 0 < x := by linarith + have hy : 0 ≤ y := by linarith + let n := ⌊x / L⌋₊ + have hnUpper : (n : ℝ) ≤ x / L := Nat.floor_le (div_nonneg hx.le hL.le) + have hnFloor : x / L < (n : ℝ) + 1 := Nat.lt_floor_add_one _ + have hxDiv : 2 ≤ x / L := (le_div_iff₀ hL).2 hxL + have hnOne : 1 ≤ n := by + have : (1 : ℝ) ≤ (n : ℝ) := by linarith + exact_mod_cast this + have hnPos : 0 < (n : ℝ) := by exact_mod_cast (Nat.succ_le_iff.mp hnOne) + have hnHalf : x / (2 * L) ≤ (n : ℝ) := by + rw [show x / (2 * L) = (x / L) / 2 by rw [div_div, mul_comm L 2]] + linarith + have hTwoL : 0 < 2 * L := mul_pos (by positivity) hL + have hHalfPos : 0 < x / (2 * L) := div_pos hx hTwoL + have hnLog := Real.log_le_log hHalfPos hnHalf + rw [Real.log_div hx.ne' hTwoL.ne'] at hnLog + have hnLogHalf : y / 2 ≤ Real.log (n : ℝ) := by + linarith [show y - Real.log (2 * L) ≤ Real.log (n : ℝ) from hnLog] + have hPowPos : 0 < B ^ n := pow_pos hBPos n + have hLogNumerator : Real.log (C * B ^ n) = Real.log C + (n : ℝ) * Real.log B := by + rw [Real.log_mul hC.ne' hPowPos.ne', Real.log_pow] + refine ⟨n, hnOne, ?_, ?_⟩ + · have hUpperMul : (n : ℝ) * L ≤ x := (le_div_iff₀ hL).1 hnUpper + have hLogBLe : Real.log B ≤ L / 2 := by dsimp [L]; linarith + have hNumLog : Real.log (C * B ^ n) ≤ x := by + rw [hLogNumerator] + linarith [mul_le_mul_of_nonneg_left hLogBLe hnPos.le] + exact (Real.log_le_log_iff (mul_pos hC hPowPos) (by linarith : 0 < M)).1 hNumLog + · have hLogC : Real.log C ≤ (n : ℝ) * max 0 (Real.log C) := by + have hnOneReal : (1 : ℝ) ≤ (n : ℝ) := by exact_mod_cast hnOne + exact (le_max_right _ _).trans (le_mul_of_one_le_left (le_max_left _ _) hnOneReal) + have hFactPos : 0 < (Nat.factorial (n + 1) : ℝ) := by + exact_mod_cast Nat.factorial_pos (n + 1) + apply (Real.log_le_iff_le_exp (div_pos (mul_pos hC hPowPos) hFactPos)).1 + rw [Real.log_div (mul_pos hC hPowPos).ne' hFactPos.ne', hLogNumerator] + change Real.log C + (n : ℝ) * Real.log B - Real.log (Nat.factorial (n + 1) : ℝ) ≤ + -c * x * y + calc + _ ≤ (n : ℝ) * D - (n : ℝ) * Real.log (n : ℝ) := by + dsimp [D] + linarith [factorial_log_lower n hnOne] + _ ≤ -((n : ℝ) * y) / 4 := by + have hDTerm := mul_le_mul_of_nonneg_left (show D ≤ y / 4 by linarith) hnPos.le + have hLogTerm := mul_le_mul_of_nonneg_left hnLogHalf hnPos.le + linarith + _ ≤ -(x / (2 * L) * y) / 4 := by + linarith [mul_le_mul_of_nonneg_right hnHalf hy] + _ = _ := by dsimp [c]; simp only [div_eq_mul_inv]; ring + obtain ⟨M₀, hM₀⟩ := eventually_atTop.1 hResult + refine ⟨c, max M₀ 2, hc, (by linarith : (1 : ℝ) < 2).trans_le (le_max_right _ _), ?_⟩ + intro M hM + exact hM₀ M ((le_max_left _ _).trans hM) + +/-- Budget conversion in the form of C196 v0.3, Eqs. (45) and (48). +The fixed constant `K` can include the sup norm of the signed kernel and `exp a`. -/ +theorem exists_factorial_budget_with_kernel {A a K : ℝ} (hA : 1 < A) (ha : 0 ≤ a) + (hK : 0 ≤ K) : + ∃ c M₁ : ℝ, 0 < c ∧ 1 < M₁ ∧ ∀ M ≥ M₁, ∃ n : ℕ, 1 ≤ n ∧ A ^ (n + 1) ≤ M ∧ + K * A ^ (n + 1) * a ^ (n + 1) / (Nat.factorial (n + 1) : ℝ) ≤ + Real.exp (-c * Real.log M * Real.log (Real.log M)) := by + let B := A * max 1 a + let C := max 1 K * B + have hAPos : 0 < A := zero_lt_one.trans hA + have hAB : A ≤ B := le_mul_of_one_le_right hAPos.le (le_max_left _ _) + have hB : 1 < B := hA.trans_le hAB + have hBPos : 0 < B := zero_lt_one.trans hB + have hMaxK : 0 < max 1 K := zero_lt_one.trans_le (le_max_left _ _) + have hC : 0 < C := mul_pos hMaxK hBPos + obtain ⟨c, M₁, hc, hM₁, hBudget⟩ := exists_factorial_budget hC hB + refine ⟨c, M₁, hc, hM₁, ?_⟩ + intro M hM + obtain ⟨n, hn, hCost, hTail⟩ := hBudget M hM + have hAbsorb : max 1 K * B ^ (n + 1) = C * B ^ n := by + dsimp [C] + rw [pow_succ'] + ring + have hCostBase : A ^ (n + 1) ≤ B ^ (n + 1) := pow_le_pow_left₀ hAPos.le hAB _ + refine ⟨n, hn, ?_, ?_⟩ + · calc + _ ≤ B ^ (n + 1) := hCostBase + _ ≤ max 1 K * B ^ (n + 1) := le_mul_of_one_le_left (by positivity) (le_max_left _ _) + _ = C * B ^ n := hAbsorb + _ ≤ M := hCost + · have hNumerator : K * A ^ (n + 1) * a ^ (n + 1) ≤ C * B ^ n := by + calc + _ ≤ max 1 K * A ^ (n + 1) * (max 1 a) ^ (n + 1) := by + have hK' := mul_le_mul_of_nonneg_right (le_max_right (1 : ℝ) K) + (pow_nonneg hAPos.le (n + 1)) + have ha' := pow_le_pow_left₀ ha (le_max_right (1 : ℝ) a) (n + 1) + exact (mul_le_mul_of_nonneg_left ha' (mul_nonneg hK (pow_nonneg hAPos.le _))).trans + (mul_le_mul_of_nonneg_right hK' (by positivity)) + _ = max 1 K * B ^ (n + 1) := by dsimp [B]; rw [mul_pow, mul_assoc] + _ = C * B ^ n := hAbsorb + exact (div_le_div_of_nonneg_right hNumerator (by positivity)).trans hTail + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean new file mode 100644 index 0000000000..35d90217fd --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean @@ -0,0 +1,51 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import Mathlib.Analysis.Calculus.BumpFunction.Normed +import Mathlib.Analysis.Calculus.BumpFunction.InnerProduct +import Mathlib.Tactic.Linarith + +/-! +# Normalized smooth bump functions with prescribed support +-/ + +@[expose] public section + +open MeasureTheory +open scoped ContDiff + +namespace VenRateUpper + +/-- Every nonempty open interval admits a nonnegative smooth bump of integral +one, with compact support inside the interval and a finite uniform bound. -/ +theorem exists_normalized_interval_bump {l r : ℝ} (hlr : l < r) : + ∃ (ψ : ℝ → ℝ) (B : ℝ), 0 < B ∧ ContDiff ℝ ∞ ψ ∧ (∫ t, ψ t) = 1 ∧ + HasCompactSupport ψ ∧ tsupport ψ ⊆ Set.Ioo l r ∧ + (∀ t, 0 ≤ ψ t) ∧ (∀ t, |ψ t| ≤ B) := by + let center := (l + r) / 2 + let bump : ContDiffBump center := + { rIn := (r - l) / 8 + rOut := (r - l) / 4 + rIn_pos := by linarith + rIn_lt_rOut := by linarith } + have hInt : 0 < ∫ t : ℝ, bump t := bump.integral_pos (μ := volume) + refine ⟨bump.normed volume, 1 / (∫ t : ℝ, bump t), div_pos zero_lt_one hInt, + bump.contDiff_normed (n := ⊤), bump.integral_normed, bump.hasCompactSupport_normed, + ?_, bump.nonneg_normed, ?_⟩ + · rw [bump.tsupport_normed_eq] + intro t ht + rw [Metric.mem_closedBall, Real.dist_eq] at ht + change |t - center| ≤ (r - l) / 4 at ht + have hdist := abs_le.mp ht + dsimp [center] at hdist + exact ⟨by linarith [hdist.1], by linarith [hdist.2]⟩ + · intro t + rw [abs_of_nonneg (bump.nonneg_normed t), bump.normed_def] + exact div_le_div_of_nonneg_right bump.le_one hInt.le + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean new file mode 100644 index 0000000000..21904db78b --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean @@ -0,0 +1,248 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.RoundAreaBridge +public import LeanPool.VenNullClockRoundRates.Lower +public import Mathlib.Analysis.Calculus.ContDiff.Operations +import Mathlib.MeasureTheory.Integral.IntegrableOn +import Mathlib.Order.ConditionallyCompleteLattice.Basic +import Mathlib.Tactic.Linarith + +/-! +# Admissible round-area profile classes and their observation gap +-/ + +@[expose] public section +noncomputable section + +open MeasureTheory Set VenMask VenRate +open scoped ContDiff + +namespace VenRateUpper + +/-- The absolute discrepancy of the layer at downstream control `s`. -/ +def layerDiscrepancy (μ : Measure UnitSphere) (w₀ w₁ : UnitSphere → ℝ) + (θ s x : ℝ) : ℝ := + |layer μ w₁ (secondEnergy θ) s x - layer μ w₀ firstEnergy s x| + +/-- Supremum absolute layer discrepancy over the closed read interval. -/ +def layerSup (μ : Measure UnitSphere) (w₀ w₁ : UnitSphere → ℝ) + (θ s a : ℝ) : ℝ := + sSup (layerDiscrepancy μ w₀ w₁ θ s '' Icc 0 a) + +/-- The two-layer distance of Eq. (4), the maximum of the absolute suprema +of the separate unnormalized layer discrepancies on the full read interval. -/ +def dataDistance (μ : Measure UnitSphere) (w₀ w₁ : UnitSphere → ℝ) (θ b a : ℝ) : ℝ := + max (layerSup μ w₀ w₁ θ 0 a) (layerSup μ w₀ w₁ θ b a) + +private theorem abs_layer_le {μ : Measure UnitSphere} {w G : UnitSphere → ℝ} + {s x a : ℝ} (hw : Integrable w μ) (hc : Continuous G) (hG : ∀ y, G y ≤ 1) + (hs : 0 ≤ s) (hx : x ∈ Icc 0 a) : + |layer μ w G s x| ≤ (∫ y, |w y| ∂μ) * Real.exp (a + s) := by + have hi := weighted_integrable (int_tilt hw hs hc hG) x + unfold layer + calc + _ ≤ ∫ y, |tilt w G s y * Real.exp (x * firstEnergy y)| ∂μ := + abs_integral_le_integral_abs + _ ≤ ∫ y, |w y| * Real.exp (a + s) ∂μ := by + apply integral_mono hi.abs (hw.abs.mul_const _) + intro y + have hSG : s * G y ≤ s := by + simpa using mul_le_mul_of_nonneg_left (hG y) hs + have hXF : x * firstEnergy y ≤ a := by + exact (show x * firstEnergy y ≤ x by + simpa using mul_le_mul_of_nonneg_left (en_bounds 0 y).1.2 hx.1).trans hx.2 + change |tilt w G s y * Real.exp (x * firstEnergy y)| ≤ |w y| * Real.exp (a + s) + simp only [tilt, abs_mul, abs_of_pos (Real.exp_pos _)] + rw [mul_assoc, ← Real.exp_add] + exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) (abs_nonneg _) + _ = _ := integral_mul_const _ _ + +private theorem layerDiscrepancy_bddAbove {μ : Measure UnitSphere} + {w₀ w₁ : UnitSphere → ℝ} {θ s a : ℝ} + (hw₀ : Integrable w₀ μ) (hw₁ : Integrable w₁ μ) (hs : 0 ≤ s) : + BddAbove (layerDiscrepancy μ w₀ w₁ θ s '' Icc 0 a) := by + refine ⟨(∫ y, |w₁ y| ∂μ) * Real.exp (a + s) + + (∫ y, |w₀ y| ∂μ) * Real.exp (a + s), ?_⟩ + rintro _ ⟨x, hx, rfl⟩ + unfold layerDiscrepancy + exact (abs_sub _ _).trans (add_le_add + (abs_layer_le hw₁ (second_cont θ) (fun y => (en_bounds θ y).2.2) hs hx) + (abs_layer_le hw₀ first_cont (fun y => (en_bounds θ y).1.2) hs hx)) + +/-- An envelope holds exactly when it bounds the actual two-layer distance. -/ +theorem dataDistance_le_iff_dataClose {μ : Measure UnitSphere} + {w₀ w₁ : UnitSphere → ℝ} {θ b a ε : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + (hw₀ : Integrable w₀ μ) (hw₁ : Integrable w₁ μ) : + dataDistance μ w₀ w₁ θ b a ≤ ε ↔ DataClose μ w₀ w₁ θ b a ε := by + have hControl : (Icc (0 : ℝ) a).Nonempty := ⟨0, le_rfl, ha⟩ + unfold dataDistance layerSup + constructor + · intro h x hx + refine ⟨?_, ?_⟩ + · exact (le_csSup (layerDiscrepancy_bddAbove hw₀ hw₁ (θ := θ) (a := a) le_rfl) + ⟨x, hx, rfl⟩).trans ((le_max_left _ _).trans h) + · exact (le_csSup (layerDiscrepancy_bddAbove hw₀ hw₁ (θ := θ) (a := a) hb) + ⟨x, hx, rfl⟩).trans ((le_max_right _ _).trans h) + · intro h + apply max_le + · refine csSup_le (hControl.image _) ?_ + rintro _ ⟨x, hx, rfl⟩ + exact (h x hx).1 + · refine csSup_le (hControl.image _) ?_ + rintro _ ⟨x, hx, rfl⟩ + exact (h x hx).2 + +private theorem dataDistance_nonneg {μ : Measure UnitSphere} + {w₀ w₁ : UnitSphere → ℝ} {θ b a : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + (hw₀ : Integrable w₀ μ) (hw₁ : Integrable w₁ μ) : + 0 ≤ dataDistance μ w₀ w₁ θ b a := by + have hc := (dataDistance_le_iff_dataClose ha hb hw₀ hw₁ (θ := θ)).1 le_rfl + exact (abs_nonneg _).trans (hc 0 ⟨le_rfl, ha⟩).1 + +/-- The three profile conditions in Eq. (2) under normalized round area. -/ +def RoundAdmissible (M : ℝ) (w : UnitSphere → ℝ) : Prop := + Integrable w roundArea ∧ (∀ᵐ y ∂roundArea, 1 ≤ w y) ∧ (∫ y, w y ∂roundArea) ≤ M + +/-- A smooth sphere profile represented by the restriction of a smooth +function on the ambient Cartesian space. -/ +def AmbientSmooth (w : UnitSphere → ℝ) : Prop := + ∃ W : ℝ × ℝ × ℝ → ℝ, ContDiff ℝ ∞ W ∧ ∀ y, w y = W y.val + +private theorem ambientSmooth_one : AmbientSmooth (fun _ => 1) := + ⟨fun _ => 1, contDiff_const, fun _ => rfl⟩ + +/-- All data distances achievable by the stated round-area nuisance class. -/ +def roundClassDistances (a b d M : ℝ) (Q : (UnitSphere → ℝ) → Prop) : Set ℝ := + {r | ∃ (θ : ℝ) (w₀ w₁ : UnitSphere → ℝ), d ≤ 1 - Real.cos θ ^ 2 ∧ + RoundAdmissible M w₀ ∧ RoundAdmissible M w₁ ∧ Q w₀ ∧ Q w₁ ∧ + r = dataDistance roundArea w₀ w₁ θ b a} + +/-- The Eq. (33) infimum over separate nuisance profiles, with a common bound +on the two individual integrals, and all admissible alternative angles. +`Q := fun _ => True` gives the broad class. `Q := AmbientSmooth` gives the +smooth subclass in the ambient restriction representation. -/ +def roundClassGap (a b d M : ℝ) (Q : (UnitSphere → ℝ) → Prop) : ℝ := + sInf (roundClassDistances a b d M Q) + +private theorem roundClassDistances_bddBelow {a b d M : ℝ} {Q : (UnitSphere → ℝ) → Prop} + (ha : 0 ≤ a) (hb : 0 ≤ b) : BddBelow (roundClassDistances a b d M Q) := by + refine ⟨0, ?_⟩ + rintro _ ⟨θ, w₀, w₁, _, hw₀, hw₁, _, _, rfl⟩ + exact dataDistance_nonneg ha hb hw₀.1 hw₁.1 + +private theorem roundAdmissible_one {M : ℝ} (hM : 1 ≤ M) : + RoundAdmissible M (fun _ => 1) := by + refine ⟨integrable_const _, ae_of_all _ fun _ => le_rfl, ?_⟩ + simpa using hM + +private theorem roundClassDistances_nonempty {a b d M : ℝ} {Q : (UnitSphere → ℝ) → Prop} + (hM : 1 ≤ M) (hd : d ≤ 1) (hQ : Q (fun _ => 1)) : + (roundClassDistances a b d M Q).Nonempty := by + have hSep : d ≤ 1 - Real.cos (Real.pi / 2) ^ 2 := by + simpa [Real.cos_pi_div_two] using hd + exact ⟨_, Real.pi / 2, (fun _ => 1), (fun _ => 1), hSep, + roundAdmissible_one hM, roundAdmissible_one hM, hQ, hQ, rfl⟩ + +/-- The broad lower bound and ambient-smooth upper bound also apply to each +intermediate subclass, including an intrinsic smooth class that admits every +ambient smooth restriction. -/ +theorem round_class_gap_between_broad_and_ambient {a b d M : ℝ} + {Q : (UnitSphere → ℝ) → Prop} (ha : 0 ≤ a) (hb : 0 ≤ b) + (hd : d ≤ 1) (hM : 1 ≤ M) (hQ : ∀ w, AmbientSmooth w → Q w) : + roundClassGap a b d M (fun _ => True) ≤ roundClassGap a b d M Q ∧ + roundClassGap a b d M Q ≤ roundClassGap a b d M AmbientSmooth := by + unfold roundClassGap + constructor + · refine csInf_le_csInf (roundClassDistances_bddBelow ha hb) + (roundClassDistances_nonempty hM hd (hQ _ ambientSmooth_one)) ?_ + rintro _ ⟨θ, w₀, w₁, hSep, hw₀, hw₁, _, _, rfl⟩ + exact ⟨θ, w₀, w₁, hSep, hw₀, hw₁, trivial, trivial, rfl⟩ + · refine csInf_le_csInf (roundClassDistances_bddBelow ha hb) + (roundClassDistances_nonempty hM hd ambientSmooth_one) ?_ + rintro _ ⟨θ, w₀, w₁, hSep, hw₀, hw₁, h₀, h₁, rfl⟩ + exact ⟨θ, w₀, w₁, hSep, hw₀, hw₁, hQ w₀ h₀, hQ w₁ h₁, rfl⟩ + +/-- The accepted lower masking rate bounds the actual class infimum uniformly. +The extra class predicate may retain only smooth profiles. The constant one +belongs to both printed classes and witnesses nonemptiness at large budgets. -/ +theorem eventual_round_class_gap_lower {a b d : ℝ} + (hd : 0 < d) (hd1 : d ≤ 1) (ha : 0 < a) (hb : 0 < b) : + ∃ C M₀ : ℝ, 0 < C ∧ 1 < M₀ ∧ ∀ M ≥ M₀, + ∀ Q : (UnitSphere → ℝ) → Prop, Q (fun _ => 1) → + Real.exp (-C * Real.log M * Real.log (Real.log M)) ≤ roundClassGap a b d M Q := by + obtain ⟨C, M₀, hC, hM₀, hLower⟩ := lower_masking_rate roundArea hd hd1 ha hb + refine ⟨C, M₀, hC, hM₀, ?_⟩ + intro M hM Q hQ + unfold roundClassGap + apply le_csInf (roundClassDistances_nonempty (hM₀.le.trans hM) hd1 hQ) + rintro _ ⟨θ, w₀, w₁, hSep, hw₀, hw₁, _, _, rfl⟩ + exact hLower hM hSep hw₀.1 hw₁.1 hw₀.2.1 hw₁.2.1 hw₀.2.2 hw₁.2.2 + ((dataDistance_le_iff_dataClose ha.le hb.le hw₀.1 hw₁.1).1 le_rfl) + +/-- One admissible common profile gives an upper bound for any of the printed +class infima whose defining class predicate accepts that profile. -/ +theorem round_class_gap_le_of_common_witness {a b d M θ ε : ℝ} + {Q : (UnitSphere → ℝ) → Prop} {w : UnitSphere → ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + (hSep : d ≤ 1 - Real.cos θ ^ 2) (hw : RoundAdmissible M w) (hQ : Q w) + (hClose : DataClose roundArea w w θ b a ε) : roundClassGap a b d M Q ≤ ε := by + have hMem : dataDistance roundArea w w θ b a ∈ roundClassDistances a b d M Q := + ⟨θ, w, w, hSep, hw, hw, hQ, hQ, rfl⟩ + exact (csInf_le (roundClassDistances_bddBelow ha hb) hMem).trans + ((dataDistance_le_iff_dataClose ha hb hw.1 hw.1).2 hClose) + +private theorem roundAdmissible_of_ambient {M : ℝ} {W : ℝ × ℝ × ℝ → ℝ} + (hW : ContDiff ℝ ∞ W) (hRange : ∀ y : UnitSphere, 2 ≤ W y.val ∧ W y.val ≤ M) : + RoundAdmissible M (fun y => W y.val) := by + have hc : Continuous (fun y : UnitSphere => W y.val) := + hW.continuous.comp continuous_subtype_val + have hi : Integrable (fun y : UnitSphere => W y.val) roundArea := by + apply Integrable.of_bound hc.aestronglyMeasurable M + exact ae_of_all _ fun y => by + rw [Real.norm_eq_abs, abs_of_nonneg (by linarith [(hRange y).1])] + exact (hRange y).2 + refine ⟨hi, ae_of_all _ (fun y => by linarith [(hRange y).1]), ?_⟩ + calc + _ ≤ ∫ _ : UnitSphere, M ∂roundArea := + integral_mono hi (integrable_const _) (fun y => (hRange y).2) + _ = M := by simp + +/-- Eq. (34) follows for both classes from the accepted lower theorem and a +smooth common-profile upper witness at any one fixed admissible angle. This +join takes the full witness family of Proposition 5 as its premise. -/ +theorem matching_round_class_rates_of_smooth_witness {a b d θ : ℝ} + (ha : 0 < a) (hb : 0 < b) (hd : 0 < d) (hd1 : d ≤ 1) + (hSep : d ≤ 1 - Real.cos θ ^ 2) + (hUpper : ∃ c M₁ : ℝ, 0 < c ∧ 1 < M₁ ∧ ∀ M ≥ M₁, + ∃ W : ℝ × ℝ × ℝ → ℝ, ContDiff ℝ ∞ W ∧ + (∀ y : UnitSphere, 2 ≤ W y.val ∧ W y.val ≤ M) ∧ + DataClose roundArea (fun y => W y.val) (fun y => W y.val) θ b a + (Real.exp (-c * Real.log M * Real.log (Real.log M)))) : + ∃ C c M₀ : ℝ, 0 < C ∧ 0 < c ∧ 1 < M₀ ∧ ∀ M ≥ M₀, + let lower := Real.exp (-C * Real.log M * Real.log (Real.log M)) + let upper := Real.exp (-c * Real.log M * Real.log (Real.log M)) + lower ≤ roundClassGap a b d M (fun _ => True) ∧ + roundClassGap a b d M (fun _ => True) ≤ upper ∧ + lower ≤ roundClassGap a b d M AmbientSmooth ∧ + roundClassGap a b d M AmbientSmooth ≤ upper := by + obtain ⟨C, L, hC, hL, hLower⟩ := eventual_round_class_gap_lower hd hd1 ha hb + obtain ⟨c, U, hc, _, hUpper⟩ := hUpper + refine ⟨C, c, max L U, hC, hc, hL.trans_le (le_max_left _ _), ?_⟩ + intro M hM + have hML : L ≤ M := (le_max_left _ _).trans hM + have hMU : U ≤ M := (le_max_right _ _).trans hM + obtain ⟨W, hW, hRange, hClose⟩ := hUpper M hMU + have hw := roundAdmissible_of_ambient hW hRange + have hs : AmbientSmooth (fun y => W y.val) := ⟨W, hW, fun _ => rfl⟩ + exact ⟨hLower M hML (fun _ => True) trivial, + round_class_gap_le_of_common_witness ha.le hb.le hSep hw trivial hClose, + hLower M hML AmbientSmooth ambientSmooth_one, + round_class_gap_le_of_common_witness ha.le hb.le hSep hw hs hClose⟩ + +end VenRateUpper +end diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean new file mode 100644 index 0000000000..cc8dfee77b --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean @@ -0,0 +1,379 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module +public import Mathlib.Analysis.Complex.Exponential +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset +import Mathlib.Data.Nat.Choose.Bounds +import Mathlib.Data.Nat.Factorial.BigOperators +public import Mathlib.LinearAlgebra.Lagrange +public import Mathlib.Analysis.Calculus.ContDiff.Operations +public import Mathlib.MeasureTheory.Measure.Lebesgue.Basic +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +import Mathlib.MeasureTheory.Group.Integral +import Mathlib.MeasureTheory.Function.LocallyIntegrable +import Mathlib.Topology.Algebra.Polynomial +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.GCongr +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! +# Smooth correction of finitely many height moments +-/ + +@[expose] public section +open Finset +open scoped ContDiff Nat + +namespace VenRateUpper + +private theorem grid_below_prod (i : ℕ) : + (∏ j ∈ range i, |(i : ℝ) - (j : ℝ)|) = (i ! : ℝ) := by + calc + _ = ∏ j ∈ range i, ((j : ℝ) + 1) := by + refine Finset.prod_bij' (fun j _ => i - 1 - j) (fun j _ => i - 1 - j) ?_ ?_ ?_ ?_ ?_ + · intro j hj + have hj' := mem_range.mp hj + exact mem_range.mpr (by omega) + · intro j hj + have hj' := mem_range.mp hj + exact mem_range.mpr (by omega) + · intro j hj + have hj' := mem_range.mp hj + omega + · intro j hj + have hj' := mem_range.mp hj + omega + · intro j hj + have hj' := mem_range.mp hj + have hij : (i : ℝ) - (j : ℝ) = ((i - 1 - j : ℕ) : ℝ) + 1 := by + have he : (i - 1 - j : ℕ) + j + 1 = i := by omega + have herm : ((i - 1 - j : ℕ) : ℝ) + (j : ℝ) + 1 = (i : ℝ) := by exact_mod_cast he + linarith + rw [hij, abs_of_nonneg] + positivity + _ = _ := by exact_mod_cast Finset.prod_range_add_one_eq_factorial i + +private theorem grid_above_prod (n i : ℕ) (hi : i ≤ n) : + (∏ j ∈ Ico (i + 1) (n + 1), |(i : ℝ) - (j : ℝ)|) = ((n - i)! : ℝ) := by + calc + _ = ∏ j ∈ range (n - i), ((j : ℝ) + 1) := by + refine Finset.prod_bij' (fun j _ => j - i - 1) (fun j _ => j + i + 1) ?_ ?_ ?_ ?_ ?_ + · intro j hj + have H := mem_Ico.mp hj + exact mem_range.mpr (by omega) + · intro j hj + have H := mem_range.mp hj + exact mem_Ico.mpr ⟨by omega, by omega⟩ + · intro j hj + have H := mem_Ico.mp hj + omega + · intro j hj + have H := mem_range.mp hj + omega + · intro j hj + have H := mem_Ico.mp hj + have hej : (i : ℝ) + ((j - i - 1 : ℕ) : ℝ) + 1 = (j : ℝ) := by + exact_mod_cast (show i + (j - i - 1) + 1 = j by omega) + rw [abs_of_nonpos] <;> linarith [show (0 : ℝ) ≤ ((j - i - 1 : ℕ) : ℝ) by positivity] + _ = _ := by exact_mod_cast Finset.prod_range_add_one_eq_factorial (n - i) + +theorem absolute_grid_denominator (n i : ℕ) (hi : i ≤ n) : + (∏ j ∈ (range (n + 1)).erase i, |(i : ℝ) - (j : ℝ)|) = + (i ! : ℝ) * ((n - i)! : ℝ) := by + classical + have hs : (range (n + 1)).erase i = range i ∪ Ico (i + 1) (n + 1) := by + ext j + simp only [mem_erase, mem_range, mem_union, mem_Ico] + omega + have hd : Disjoint (range i) (Ico (i + 1) (n + 1)) := by + refine Finset.disjoint_left.mpr ?_ + intro j h1 h2 + have h1' := mem_range.mp h1 + have h2' := mem_Ico.mp h2 + omega + rw [hs, Finset.prod_union hd, grid_below_prod, grid_above_prod n i hi] + +private theorem factorial_ratio_bound (n i : ℕ) (hi : i ≤ n) : + (n : ℝ) ^ n / ((i ! : ℝ) * ((n - i)! : ℝ)) ≤ (2 * Real.exp 1) ^ n := by + have hF : 0 < (n ! : ℝ) := by exact_mod_cast Nat.factorial_pos n + have hDi : 0 < (i ! : ℝ) := by exact_mod_cast Nat.factorial_pos i + have hDj : 0 < ((n - i)! : ℝ) := by exact_mod_cast Nat.factorial_pos (n - i) + have hD : 0 < (i ! : ℝ) * ((n - i)! : ℝ) := mul_pos hDi hDj + have hN : (n : ℝ) ^ n / (n ! : ℝ) ≤ Real.exp 1 ^ n := by + calc + _ ≤ ∑ j ∈ range (n + 1), (n : ℝ) ^ j / (j ! : ℝ) := by + apply Finset.single_le_sum (f := fun j : ℕ => (n : ℝ) ^ j / (j ! : ℝ)) + · intro j _ + positivity + · exact mem_range.mpr (by omega) + _ ≤ Real.exp (n : ℝ) := Real.sum_le_exp_of_nonneg (by positivity) _ + _ = _ := by rw [← Real.exp_nat_mul]; simp + have hQ : (n ! : ℝ) / ((i ! : ℝ) * ((n - i)! : ℝ)) = (n.choose i : ℝ) := by + apply (div_eq_iff hD.ne').2 + have hh := Nat.choose_mul_factorial_mul_factorial hi + exact_mod_cast (show n ! = n.choose i * (i ! * (n - i)!) by simpa [Nat.mul_assoc] using hh.symm) + have hB : (n.choose i : ℝ) ≤ (2 : ℝ) ^ n := by exact_mod_cast Nat.choose_le_two_pow n i + calc + _ = ((n : ℝ) ^ n / (n ! : ℝ)) * ((n ! : ℝ) / ((i ! : ℝ) * ((n - i)! : ℝ))) := by + field_simp + _ ≤ (Real.exp 1) ^ n * (2 : ℝ) ^ n := by + rw [hQ] + gcongr + _ = _ := by rw [← mul_pow, mul_comm] + +/-- Exponential, not n^n, growth of Lagrange interpolation after translating an equally +spaced grid of fixed total diameter. The parameter s is a common translation. -/ +theorem translated_grid_lagrange_bound + (n i : ℕ) (hn : n ≠ 0) (hi : i ≤ n) (ℓ s u B : ℝ) (hℓ : 0 < ℓ) (hB : 0 ≤ B) + (hyp : ∀ j ≤ n, |u - (s + ℓ * j / n)| ≤ B) : + |(Lagrange.basis (range (n + 1)) (fun j : ℕ => s + ℓ * j / n) i).eval u| + ≤ (B * (2 * Real.exp 1) / ℓ) ^ n := by + classical + have hn' : 0 < (n : ℝ) := by exact_mod_cast Nat.pos_of_ne_zero hn + let T := (range (n + 1)).erase i + have hcard : #T = n := by + dsimp [T] + rw [card_erase_of_mem (mem_range.mpr (by omega)), card_range, Nat.add_sub_cancel] + have hdiff (j : ℕ) : |(s + ℓ * (i : ℝ) / n) - (s + ℓ * (j : ℝ) / n)| = + (ℓ / n) * |(i : ℝ) - (j : ℝ)| := by + rw [← abs_of_pos (div_pos hℓ hn'), ← abs_mul] + congr 1 + ring + change |(∏ j ∈ T, Lagrange.basisDivisor (s + ℓ * i / n) (s + ℓ * j / n)).eval u| ≤ _ + simp only [Polynomial.eval_prod, Lagrange.basisDivisor, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_sub, Polynomial.eval_X, abs_prod, abs_mul, abs_inv] + rw [show (∏ j ∈ T, |s + ℓ * (i : ℝ) / n - (s + ℓ * (j : ℝ) / n)|⁻¹ * + |u - (s + ℓ * (j : ℝ) / n)|) = + (∏ j ∈ T, |u - (s + ℓ * (j : ℝ) / n)|) / + (∏ j ∈ T, |s + ℓ * (i : ℝ) / n - (s + ℓ * (j : ℝ) / n)|) by + simp_rw [mul_comm (_⁻¹)] + rw [Finset.prod_mul_distrib, Finset.prod_inv_distrib] + exact (div_eq_mul_inv _ _).symm] + have hden : (∏ j ∈ T, |s + ℓ * (i : ℝ) / n - (s + ℓ * (j : ℝ) / n)|) = + (ℓ / n) ^ n * ((i ! : ℝ) * ((n - i)! : ℝ)) := by + simp_rw [hdiff] + rw [Finset.prod_mul_distrib, Finset.prod_const, hcard, absolute_grid_denominator n i hi] + rw [hden] + have hDi : 0 < (i ! : ℝ) := by exact_mod_cast Nat.factorial_pos i + have hDj : 0 < ((n - i)! : ℝ) := by exact_mod_cast Nat.factorial_pos (n - i) + have hgood : 0 < (ℓ / (n : ℝ)) ^ n * ((i ! : ℝ) * ((n - i)! : ℝ)) := by positivity + have hnum : (∏ j ∈ T, |u - (s + ℓ * (j : ℝ) / n)|) ≤ B ^ n := by + calc + _ ≤ ∏ _j ∈ T, B := by + refine Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) (fun j hj => hyp j ?_) + exact Nat.lt_succ_iff.mp (mem_range.mp (mem_erase.mp hj).2) + _ = _ := by rw [Finset.prod_const, hcard] + calc + _ ≤ B ^ n / ((ℓ / (n : ℝ)) ^ n * ((i ! : ℝ) * ((n - i)! : ℝ))) := + div_le_div_of_nonneg_right hnum hgood.le + _ = (B / ℓ) ^ n * ((n : ℝ) ^ n / ((i ! : ℝ) * ((n - i)! : ℝ))) := by + rw [div_pow, div_pow] + field_simp + _ ≤ (B / ℓ) ^ n * (2 * Real.exp 1) ^ n := by + exact mul_le_mul_of_nonneg_left (factorial_ratio_bound n i hi) (by positivity) + _ = _ := by rw [← mul_pow]; congr 1; ring + +/-- Pointwise exact redistribution of a polynomial linear functional onto each +translated grid. Smooth averaging over translations does not alter any of these moments. -/ +theorem translated_grid_moment_identity + (n : ℕ) (hn : n ≠ 0) (ℓ s : ℝ) (hℓ : 0 < ℓ) + (L : Polynomial ℝ →ₗ[ℝ] ℝ) (P : Polynomial ℝ) + (hP : P.degree < ((n + 1 : ℕ) : WithBot ℕ)) : + (∑ j ∈ range (n + 1), P.eval (s + ℓ * j / n) * + L (Lagrange.basis (range (n + 1)) (fun i : ℕ => s + ℓ * i / n) j)) = L P := by + classical + let nodes := fun i : ℕ => s + ℓ * (i : ℝ) / (n : ℝ) + have hdiv : 0 < (ℓ / (n : ℝ)) := div_pos hℓ (by exact_mod_cast Nat.pos_of_ne_zero hn) + have hinj : Function.Injective nodes := by + intro i j h + have heq : (ℓ / (n : ℝ)) * (i : ℝ) = (ℓ / (n : ℝ)) * (j : ℝ) := by + dsimp [nodes] at h + rw [div_mul_eq_mul_div, div_mul_eq_mul_div] + linarith + exact_mod_cast ((mul_right_inj' (ne_of_gt hdiv)).mp heq) + have interp : Lagrange.interpolate (range (n + 1)) nodes (fun j => P.eval (nodes j)) = P := by + apply Polynomial.eq_of_degrees_lt_of_eval_index_eq _ hinj.injOn + · exact Lagrange.degree_interpolate_lt _ hinj.injOn + · simpa only [Finset.card_range] using hP + · intro j hj + exact Lagrange.eval_interpolate_at_node _ hinj.injOn hj + have res := congrArg L interp + dsimp [nodes] at res ⊢ + simpa only [Lagrange.interpolate_apply, ← Polynomial.smul_eq_C_mul, + map_sum, map_smul, smul_eq_mul] using res + +open MeasureTheory + +/-- Integrating a translated family of exact moment identities gives an exact Lebesgue +redistribution density. This statement deals only with height, not the spherical lift. -/ +theorem averaged_grid_moments {ι : Type*} (T : Finset ι) (x : ι → ℝ) + (ψ : ℝ → ℝ) (v : ι → ℝ → ℝ) (P : Polynomial ℝ) (m : ℝ) + (hψ : Continuous ψ) (hc : HasCompactSupport ψ) (hψ₁ : ∫ s, ψ s = (1 : ℝ)) + (hv : ∀ i ∈ T, Continuous (v i)) + (hm : ∀ s, (∑ i ∈ T, P.eval (s + x i) * v i s) = m) : + (∫ t : ℝ, P.eval t * ∑ i ∈ T, (ψ (t - x i) * v i (t - x i))) = m := by + let f (i : ι) (s : ℝ) := P.eval (s + x i) * (ψ s * v i s) + have hf (i) (hi : i ∈ T) : Integrable (f i) volume := by + apply Continuous.integrable_of_hasCompactSupport + · exact (P.continuous.comp (continuous_id.add continuous_const)).mul (hψ.mul (hv i hi)) + · change HasCompactSupport (fun s => P.eval (s + x i) * (ψ s * v i s)) + exact (hc.mul_right (f' := v i)).mul_left + have hs (i) (y : ℝ) : f i (y - x i) = P.eval y * (ψ (y - x i) * v i (y - x i)) := by + simp [f] + simp_rw [Finset.mul_sum, ← hs] + rw [integral_finsetSum _ (fun i hi => (hf i hi).comp_sub_right (x i))] + simp_rw [integral_sub_right_eq_self] + rw [← integral_finsetSum _ hf] + have H (s : ℝ) : (∑ i ∈ T, f i s) = m * ψ s := by + calc + _ = (∑ i ∈ T, P.eval (s + x i) * v i s) * ψ s := by + rw [Finset.sum_mul] + exact Finset.sum_congr rfl fun i _ => by dsimp [f]; ring + _ = _ := by rw [hm] + simp_rw [H, integral_const_mul, hψ₁, mul_one] + +/-- Translating every node has the same effect as translating the evaluation variable backwards. -/ +theorem basis_shift {ι : Type*} [DecidableEq ι] (T : Finset ι) + (x : ι → ℝ) (s : ℝ) (i : ι) : + Lagrange.basis T (fun j => s + x j) i = + (Lagrange.basis T x i).comp (Polynomial.X - Polynomial.C s) := by + simp only [Lagrange.basis, Polynomial.prod_comp] + refine Finset.prod_congr rfl fun j _ => ?_ + simp only [Lagrange.basisDivisor, Polynomial.mul_comp, Polynomial.sub_comp, + Polynomial.C_comp, Polynomial.X_comp, + show s + x i - (s + x j) = x i - x j by ring] + congr 1 + rw [map_add] + ring + +/-- Applying an arbitrary polynomial linear functional after translating the evaluation variable +gives a polynomial in the amount of translation. No topology on the space of polynomials is used. -/ +theorem functional_polynomial_shift (L : Polynomial ℝ →ₗ[ℝ] ℝ) (P : Polynomial ℝ) : + ∃ Q : Polynomial ℝ, ∀ s, Q.eval s = + L (P.comp (Polynomial.X - Polynomial.C s)) := by + classical + induction P using Polynomial.induction_on' with + | add P Q hP hQ => + obtain ⟨U, hU⟩ := hP + obtain ⟨V, hV⟩ := hQ + exact ⟨U + V, fun s => by simp [Polynomial.add_comp, hU s, hV s]⟩ + | monomial n a => + let R : Polynomial ℝ := ∑ j ∈ range (n + 1), + Polynomial.C ((n.choose j : ℝ) * L (Polynomial.C a * Polynomial.X ^ j)) * + (-Polynomial.X) ^ (n - j) + refine ⟨R, fun s => ?_⟩ + rw [← Polynomial.C_mul_X_pow_eq_monomial, Polynomial.mul_comp, Polynomial.C_comp, + Polynomial.pow_comp, Polynomial.X_comp, sub_eq_add_neg, add_pow, + Finset.mul_sum, map_sum] + simp only [R, Polynomial.eval_finsetSum, Polynomial.eval_mul, Polynomial.eval_C, + Polynomial.eval_pow, Polynomial.eval_neg, Polynomial.eval_X] + refine Finset.sum_congr rfl fun j _ => ?_ + -- Pull all scalar factors outside the arbitrary linear functional. + rw [← Polynomial.C_neg, ← Polynomial.C_pow, ← Polynomial.C_eq_natCast] + conv_rhs => + rw [show Polynomial.C a * (Polynomial.X ^ j * Polynomial.C ((-s) ^ (n - j)) * + Polynomial.C (n.choose j : ℝ)) = + Polynomial.C (((-s) ^ (n - j)) * (n.choose j : ℝ)) * + (Polynomial.C a * Polynomial.X ^ j) by rw [Polynomial.C_mul]; ring] + simp_rw [← Polynomial.smul_eq_C_mul, map_smul, smul_eq_mul] + ring + +private theorem smooth_eval {order : ℕ∞ω} (P : Polynomial ℝ) : ContDiff ℝ order (fun x => + P.eval x) := by + induction P using Polynomial.induction_on' with + | add P Q hP hQ => simpa only [Polynomial.eval_add] using hP.add hQ + | monomial n a => simpa only [Polynomial.eval_monomial] using + (contDiff_const.mul (contDiff_id.pow n) : ContDiff ℝ order (fun x : ℝ => a * x ^ n)) + +/-- A signed height correction with exact moments and exponential uniform cost. The bump +may have any differentiability order, including `∞` for smooth functions, and is normalized +and supported in the chosen translation interval. The correction has the same regularity. +The source linear functional is bounded on `[-1, 1]`. -/ +theorem smooth_height_moment_correction {order : ℕ∞ω} + (n : ℕ) (hn : n ≠ 0) (ℓ t₀ t₁ B N : ℝ) (hℓ : 0 < ℓ) + (ht₀ : -1 ≤ t₀) (ht₁ : t₁ + ℓ ≤ 1) (hB : 0 ≤ B) (hN : 0 ≤ N) + (L : Polynomial ℝ →ₗ[ℝ] ℝ) + (hL : ∀ (P : Polynomial ℝ) (A : ℝ), + (∀ u ∈ Set.Icc (-1 : ℝ) 1, |P.eval u| ≤ A) → |L P| ≤ N * A) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ order ψ) (hψ₁ : ∫ s, ψ s = (1 : ℝ)) + (hψsup : ∀ s, |ψ s| ≤ B) (hψsupp : ∀ s ∉ Set.Icc t₀ t₁, ψ s = 0) : + ∃ ρ : ℝ → ℝ, ContDiff ℝ order ρ ∧ + (∀ t ∉ Set.Icc t₀ (t₁ + ℓ), ρ t = 0) ∧ + (∀ t, |ρ t| ≤ (n + 1 : ℕ) * (B * (N * (4 * Real.exp 1 / ℓ) ^ n))) ∧ + (∀ (P : Polynomial ℝ), P.degree < ((n + 1 : ℕ) : WithBot ℕ) → + (∫ t, P.eval t * ρ t) = L P) := by + classical + let T := range (n + 1) + let x : ℕ → ℝ := fun i => ℓ * (i : ℝ) / (n : ℝ) + let k : ℕ → ℝ → ℝ := fun i s => L (Lagrange.basis T (fun j => s + x j) i) + let term : ℕ → ℝ → ℝ := fun i t => ψ (t - x i) * k i (t - x i) + let ρ : ℝ → ℝ := fun t => ∑ i ∈ T, term i t + have hnk : 0 < (n : ℝ) := by exact_mod_cast Nat.pos_of_ne_zero hn + have hxi (i : ℕ) (hi : i ∈ T) : x i ∈ Set.Icc 0 ℓ := by + refine ⟨by dsimp [x]; positivity, ?_⟩ + have Hin : i ≤ n := by simpa [T] using hi + have HR : (i : ℝ) ≤ (n : ℝ) := by exact_mod_cast Hin + dsimp [x] + exact (div_le_iff₀ hnk).2 (mul_le_mul_of_nonneg_left HR hℓ.le) + have hk (i : ℕ) : ContDiff ℝ order (k i) := by + obtain ⟨Q, hQ⟩ := functional_polynomial_shift L (Lagrange.basis T x i) + have hh : k i = fun s => Q.eval s := by + funext s + exact ((hQ s).trans (congrArg L (basis_shift T x s i).symm)).symm + rw [hh] + exact smooth_eval Q + have hcψ : HasCompactSupport ψ := + HasCompactSupport.intro' isCompact_Icc isClosed_Icc hψsupp + refine ⟨ρ, ContDiff.sum fun i _ => ?_, ?_, ?_, ?_⟩ + · have hs : ContDiff ℝ order (fun t : ℝ => t - x i) := contDiff_id.sub contDiff_const + exact (hψ.comp hs).mul ((hk i).comp hs) + · intro t ht + apply Finset.sum_eq_zero + intro i hi + have hx := hxi i hi + have ht' : t - x i ∉ Set.Icc t₀ t₁ := by + intro hm + exact ht ⟨by linarith [hm.1, hx.1], by linarith [hm.2, hx.2]⟩ + dsimp [term] + rw [hψsupp _ ht', zero_mul] + · intro t + calc + _ ≤ ∑ i ∈ T, |term i t| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i ∈ T, B * (N * (4 * Real.exp 1 / ℓ) ^ n) := by + apply Finset.sum_le_sum + intro i hi + by_cases hs : t - x i ∈ Set.Icc t₀ t₁ + · have Hin : i ≤ n := by simpa [T] using hi + have hd : ∀ u ∈ Set.Icc (-1 : ℝ) 1, ∀ j ≤ n, |u - ((t - x i) + x j)| ≤ 2 := by + intro u hu j hj + have hx := hxi j (by simpa [T] using hj) + exact abs_le.mpr ⟨by linarith [hu.1, hs.2, hx.2], + by linarith [hu.2, hs.1, hx.1]⟩ + have hb : |k i (t - x i)| ≤ N * (4 * Real.exp 1 / ℓ) ^ n := by + apply hL + intro u hu + convert translated_grid_lagrange_bound n i hn Hin ℓ (t - x i) u 2 hℓ + (by norm_num) (hd u hu) using 1 + ring + dsimp [term] + rw [abs_mul] + gcongr + exact hψsup _ + · dsimp [term] + rw [hψsupp _ hs, zero_mul, abs_zero] + positivity + _ = _ := by simp [T, mul_left_comm] + · intro P hP + exact averaged_grid_moments T x ψ k P (L P) hψ.continuous hcψ hψ₁ + (fun i _ => (hk i).continuous) (fun s => + translated_grid_moment_identity n hn ℓ s hℓ L P hP) + +end VenRateUpper +end diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean new file mode 100644 index 0000000000..f3aa285d76 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean @@ -0,0 +1,121 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.RoundAreaPositiveStrips +public import LeanPool.VenNullClockRoundRates.VenRateUpperAssembly +public import LeanPool.VenNullClockRoundRates.VenRateUpperBump +public import LeanPool.VenNullClockRoundRates.Layer +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +/-! The common-profile upper rate on the normalized Euclidean round sphere. -/ + +@[expose] public section + +open MeasureTheory VenMask VenRate +open scoped ContDiff + +namespace VenRateUpper + +private theorem first_coordinate_bound (y : UnitSphere) : y.val.1 ∈ Set.Icc (-1 : ℝ) 1 := by + have hs : y.val.1 ^ 2 ≤ 1 := by + nlinarith only [y.property, sq_nonneg y.val.2.1, sq_nonneg y.val.2.2] + apply abs_le.mp + by_contra! H + have hsq : 1 < |y.val.1|^2 := by + nlinarith only [mul_pos (sub_pos.mpr H) (show 0 < |y.val.1| + 1 by linarith only [H])] + rw [sq_abs] at hsq + exact (not_lt_of_ge hs) hsq + +private theorem spherical_read_gap_bound {θ b : ℝ} (hb : 0 ≤ b) (y : UnitSphere) : + |sphereReadGap θ b y| ≤ Real.exp b := by + obtain ⟨h₀, h₁⟩ := en_bounds θ y + have hp : Real.exp (b * secondEnergy θ y) ≤ Real.exp b := + Real.exp_le_exp.mpr (mul_le_of_le_one_right hb h₁.2) + have hm : Real.exp (b * firstEnergy y) ≤ Real.exp b := + Real.exp_le_exp.mpr (mul_le_of_le_one_right hb h₀.2) + change |Real.exp (b * secondEnergy θ y) - Real.exp (b * firstEnergy y)| ≤ _ + exact abs_le.mpr ⟨by linarith only [hm, Real.exp_pos (b * secondEnergy θ y)], + by linarith only [hp, Real.exp_pos (b * firstEnergy y)]⟩ + +/-- Proposition 5. One smooth ambient restriction supplies both profiles and +satisfies the pointwise floor and cap on the unit sphere. -/ +theorem smooth_round_common_profile_upper {a b θ : ℝ} + (ha : 0 < a) (hb : 0 < b) (hθ : 0 < 1 - Real.cos θ ^ 2) : + ∃ c M₁ : ℝ, 0 < c ∧ 1 < M₁ ∧ ∀ M ≥ M₁, + ∃ W : ℝ × ℝ × ℝ → ℝ, ContDiff ℝ ∞ W ∧ + (∀ y : UnitSphere, 2 ≤ W y.val ∧ W y.val ≤ M) ∧ + DataClose roundArea (fun y => W y.val) (fun y => W y.val) θ b a + (Real.exp (-c * Real.log M * Real.log (Real.log M))) := by + obtain ⟨l, r, Aplus, Aminus, hl, hlr, hr, _hAp, _hAm, η, hη, hηc, hη₁, + chiPlus, chiMinus, hchiPlus, hchiMinus, bddPlus, bddMinus, _disjoint, pushPlus, pushMinus⟩ := + exists_smooth_strip_cutoffs hθ hb + let t₁ := (l + r) / 2 + let ℓ := (r - l) / 4 + have hl₁ : l < t₁ := by dsimp [t₁]; linarith only [hlr] + have hℓ : 0 < ℓ := by dsimp [ℓ]; linarith only [hlr] + have hsum : t₁ + ℓ ≤ r := by dsimp [t₁, ℓ]; linarith only [hlr] + obtain ⟨ψ, B, _hB, hψ, normψ, _compactψ, supportψ, _positiveψ, supψ⟩ := + exists_normalized_interval_bump hl₁ + have ψSupport : ∀ t ∉ Set.Icc l t₁, ψ t = 0 := by + intro t ht + by_contra ne + have h := supportψ (subset_tsupport ψ ne) + exact ht ⟨h.1.le, h.2.le⟩ + have ηOne (x : ℝ) (hx : x ∈ Set.Icc l (t₁ + ℓ)) : η x = 1 := + hη₁ x ⟨hx.1, hx.2.trans hsum⟩ + have hy : Continuous (fun y : UnitSphere => y.val) := continuous_subtype_val + have hheight : Continuous (fun y : UnitSphere => y.val.1) := continuous_fst.comp hy + have hq : Continuous (sphereReadGap θ b) := by + change Continuous (fun y : UnitSphere => + Real.exp (b * secondEnergy θ y) - Real.exp (b * firstEnergy y)) + exact (Real.continuous_exp.comp (continuous_const.mul (second_cont θ))).sub + (Real.continuous_exp.comp (continuous_const.mul first_cont)) + obtain ⟨c, M₁, hc, hM₁, proof⟩ := exponential_upper_of_twoStripIdentities + (F := firstEnergy) (H := fun y => y.val.1) (q := sphereReadGap θ b) + (chiPlus := fun y => chiPlus y.val) (chiMinus := fun y => chiMinus y.val) roundArea + first_cont hheight hq (hchiPlus.continuous.comp hy) (hchiMinus.continuous.comp hy) + hη.continuous hηc hψ normψ supψ ψSupport hℓ (by linarith only [hl]) (hsum.trans hr.le) + ηOne (fun y => (en_bounds θ y).1) first_coordinate_bound (fun _ => rfl) + (spherical_read_gap_bound hb.le) bddPlus bddMinus (Real.exp_pos b).le ha.le + pushPlus pushMinus + refine ⟨c, M₁, hc, hM₁,?_⟩ + intro M hM + obtain ⟨ρ, K, hρ, bdd, rate⟩ := proof M hM + let W := twoStripProfile Prod.fst chiPlus chiMinus ρ K + have hW : ContDiff ℝ ∞ W := contDiff_twoStripProfile contDiff_fst hchiPlus hchiMinus hρ + refine ⟨W, hW, fun y => bdd y,?_⟩ + intro x hx + have positiveRate : 0 ≤ Real.exp (-c * Real.log M * Real.log (Real.log M)) := + (Real.exp_pos _).le + constructor + · simpa only [layer, tilt, zero_mul, Real.exp_zero, mul_one, sub_self, abs_zero] using + positiveRate + · let w := fun y : UnitSphere => W y.val + have hcont : Continuous w := hW.continuous.comp hy + have hi (G : UnitSphere → ℝ) (hG : Continuous G) : + Integrable (fun y => tilt w G b y * Real.exp (x * firstEnergy y)) roundArea := by + have continuousTerm : Continuous (fun y => tilt w G b y * Real.exp (x * firstEnergy y)) := + (hcont.mul (Real.continuous_exp.comp (continuous_const.mul hG))).mul + (Real.continuous_exp.comp (continuous_const.mul first_cont)) + exact continuousTerm.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + change |layer roundArea w (secondEnergy θ) b x - layer roundArea w firstEnergy b x| ≤ _ + have diff : layer roundArea w (secondEnergy θ) b x - layer roundArea w firstEnergy b x = + ∫ y, (sphereReadGap θ b y * w y) * Real.exp (x * firstEnergy y) ∂roundArea := by + unfold layer + rw [← integral_sub (hi _ (second_cont θ)) (hi _ first_cont)] + apply integral_congr_ae + filter_upwards with y + change tilt w (secondEnergy θ) b y * Real.exp (x * firstEnergy y) - + tilt w firstEnergy b y * Real.exp (x * firstEnergy y) = _ + unfold tilt sphereReadGap + ring + rw [diff] + exact rate x hx + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean new file mode 100644 index 0000000000..8f3fa2fbf1 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean @@ -0,0 +1,106 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import Mathlib.Analysis.Calculus.ContDiff.Operations +public import Mathlib.MeasureTheory.Function.LocallyIntegrable +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Measure.Lebesgue.Basic +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring + +/-! The common positive offset in a matched two-strip lifting construction. -/ + +@[expose] public section +open MeasureTheory +open scoped ContDiff + +namespace VenRateUpper + +/-- The common profile with positive offset and opposite strip corrections. -/ +noncomputable def twoStripProfile {Ω : Type*} (F chiPlus chiMinus : Ω → ℝ) + (ρ : ℝ → ℝ) (K : ℝ) (y : Ω) : ℝ := + 2 + chiPlus y * (K + ρ (F y)) + chiMinus y * K + +theorem twoStripProfile_bounds {Ω : Type*} (F chiPlus chiMinus : Ω → ℝ) + (ρ : ℝ → ℝ) {K Aplus Aminus : ℝ} (hK : 0 ≤ K) (hρ : ∀ t, |ρ t| ≤ K) + (hPlus : ∀ y, chiPlus y ∈ Set.Icc (0 : ℝ) Aplus) (hMinus : ∀ y, chiMinus y ∈ Set.Icc (0 : + ℝ) Aminus) + (y : Ω) : twoStripProfile F chiPlus chiMinus ρ K y ∈ Set.Icc (2 : ℝ) (2 + Aplus * (2 * K) + + Aminus * K) := by + have H := abs_le.mp (hρ (F y)) + have hsum : 0 ≤ K + ρ (F y) := by linarith [H.1] + have hup : K + ρ (F y) ≤ 2 * K := by linarith [H.2] + constructor + · unfold twoStripProfile + linarith only [mul_nonneg (hPlus y).1 hsum, mul_nonneg (hMinus y).1 hK] + · unfold twoStripProfile + have hp := mul_le_mul (hPlus y).2 hup hsum ((hPlus y).1.trans (hPlus y).2) + have hm := mul_le_mul_of_nonneg_right (hMinus y).2 hK + linarith only [hp, hm] + +theorem contDiff_twoStripProfile {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + {F chiPlus chiMinus : E → ℝ} {ρ : ℝ → ℝ} {K : ℝ} + (hF : ContDiff ℝ ∞ F) (hPlus : ContDiff ℝ ∞ chiPlus) (hMinus : ContDiff ℝ ∞ chiMinus) + (hρ : ContDiff ℝ ∞ ρ) : ContDiff ℝ ∞ (twoStripProfile F chiPlus chiMinus ρ K) := by + exact (contDiff_const.add (hPlus.mul (contDiff_const.add (hρ.comp hF)))).add + (hMinus.mul contDiff_const) + +theorem integral_twoStripProfile {Ω : Type*} [TopologicalSpace Ω] [MeasurableSpace Ω] + [OpensMeasurableSpace Ω] [CompactSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] {F q chiPlus chiMinus : Ω → ℝ} + {η ρ f : ℝ → ℝ} (K : ℝ) + (hF : Continuous F) (hq : Continuous q) (hchiPlus : Continuous chiPlus) (hchiMinus : + Continuous chiMinus) + (hη : Continuous η) (suppη : HasCompactSupport η) + (hρ : Continuous ρ) (hf : Continuous f) (support : ∀ t, η t * ρ t = ρ t) + (identityPlus : ∀ g : ℝ → ℝ, Continuous g → + (∫ y, q y * chiPlus y * g (F y) ∂μ) = ∫ t, η t * g t) + (identityMinus : ∀ g : ℝ → ℝ, Continuous g → + (∫ y, q y * chiMinus y * g (F y) ∂μ) = -(∫ t, η t * g t)) : + (∫ y, q y * twoStripProfile F chiPlus chiMinus ρ K y * f (F y) ∂μ) = + (∫ y, q y * 2 * f (F y) ∂μ) + ∫ t, f t * ρ t := by + let g₁ (t : ℝ) := K * f t + let g₂ (t : ℝ) := ρ t * f t + have hg₁ : Continuous g₁ := continuous_const.mul hf + have hg₂ : Continuous g₂ := hρ.mul hf + have hgg : Continuous (fun t => g₁ t + g₂ t) := hg₁.add hg₂ + let u (y : Ω) := q y * 2 * f (F y) + let v (y : Ω) := q y * chiPlus y * (g₁ (F y) + g₂ (F y)) + let z (y : Ω) := q y * chiMinus y * g₁ (F y) + have integ (g : Ω → ℝ) (h : Continuous g) : Integrable g μ := + h.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace g) + have hu := integ u ((hq.mul continuous_const).mul (hf.comp hF)) + have hv := integ v ((hq.mul hchiPlus).mul (hgg.comp hF)) + have hz := integ z ((hq.mul hchiMinus).mul (hg₁.comp hF)) + have split : (fun y => q y * twoStripProfile F chiPlus chiMinus ρ K y * f (F y)) = + fun y => (u y + v y) + z y := by + funext y + dsimp [u, v, z, g₁, g₂, twoStripProfile] + ring + rw [split] + have hsum := integral_add (hu.add hv) hz + simp only [Pi.add_apply] at hsum + rw [hsum, integral_add hu hv] + have hv' : (∫ y, v y ∂μ) = ∫ t, η t * (g₁ t + g₂ t) := identityPlus _ hgg + have hz' : (∫ y, z y ∂μ) = -(∫ t, η t * g₁ t) := identityMinus _ hg₁ + rw [hv', hz'] + have intmul (g : ℝ → ℝ) (h : Continuous g) : Integrable (fun t => η t * g t) := + (hη.mul h).integrable_of_hasCompactSupport suppη.mul_right + simp_rw [mul_add] + rw [integral_add (intmul g₁ hg₁) (intmul g₂ hg₂)] + have eqn : (∫ t, η t * g₂ t) = ∫ t, f t * ρ t := by + apply integral_congr_ae + filter_upwards with t + dsimp [g₂] + rw [← mul_assoc, support, mul_comm] + rw [eqn] + change (∫ y, u y ∂μ) + ((∫ t, η t * g₁ t) + ∫ t, f t * ρ t) + + -(∫ t, η t * g₁ t) = (∫ y, u y ∂μ) + ∫ t, f t * ρ t + ring + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean new file mode 100644 index 0000000000..23dd05f8e6 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean @@ -0,0 +1,71 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import LeanPool.VenNullClockRoundRates.VenRateUpperPhysical +public import LeanPool.VenNullClockRoundRates.VenRateUpperClassGap + +/-! The printed common-profile witness and matching class rates on round area. -/ + +@[expose] public section +open MeasureTheory VenMask VenRate +open scoped ContDiff + +namespace VenRateUpper + +/-- The smooth common-profile witness with the exact two-supremum error in Eq. (31). -/ +theorem smooth_round_common_profile_error {a b θ : ℝ} + (ha : 0 < a) (hb : 0 < b) (hθ : 0 < 1 - Real.cos θ ^ 2) : + ∃ c M₁ : ℝ, 0 < c ∧ 1 < M₁ ∧ ∀ M ≥ M₁, + ∃ W : ℝ × ℝ × ℝ → ℝ, ContDiff ℝ ∞ W ∧ + (∀ y : UnitSphere, 2 ≤ W y.val ∧ W y.val ≤ M) ∧ + dataDistance roundArea (fun y => W y.val) (fun y => W y.val) θ b a ≤ + Real.exp (-c * Real.log M * Real.log (Real.log M)) := by + obtain ⟨c, M₁, hc, hM₁, existsProfile⟩ := smooth_round_common_profile_upper ha hb hθ + refine ⟨c, M₁, hc, hM₁,?_⟩ + intro M hM + obtain ⟨W, hW, rangeW, hclose⟩ := existsProfile M hM + have hw : Continuous (fun y : UnitSphere => W y.val) := + hW.continuous.comp continuous_subtype_val + have hint : Integrable (fun y : UnitSphere => W y.val) roundArea := + hw.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + exact ⟨W, hW, rangeW, (dataDistance_le_iff_dataClose ha.le hb.le hint hint).mpr hclose⟩ + +/-- Equation (34), jointly for the broad class and the restrictions of +ambient smooth profiles. The upper witness uses one fixed admissible angle. -/ +theorem matching_round_class_rates {a b d : ℝ} + (ha : 0 < a) (hb : 0 < b) (hd : 0 < d) (hd1 : d ≤ 1) : + ∃ C c M₀ : ℝ, 0 < C ∧ 0 < c ∧ 1 < M₀ ∧ ∀ M ≥ M₀, + let lower := Real.exp (-C * Real.log M * Real.log (Real.log M)) + let upper := Real.exp (-c * Real.log M * Real.log (Real.log M)) + lower ≤ roundClassGap a b d M (fun _ => True) ∧ + roundClassGap a b d M (fun _ => True) ≤ upper ∧ + lower ≤ roundClassGap a b d M AmbientSmooth ∧ + roundClassGap a b d M AmbientSmooth ≤ upper := by + have separation : d ≤ 1 - Real.cos (Real.pi / 2) ^ 2 := by + simpa using hd1 + exact matching_round_class_rates_of_smooth_witness ha hb hd hd1 separation + (smooth_round_common_profile_upper ha hb (hd.trans_le separation)) + +/-- Any admissible profile subclass containing the smooth ambient restrictions +has the same two-sided rate. In particular the upper construction remains valid +for the intrinsic smooth class, while the lower applies to the broad class. -/ +theorem matching_round_class_rate_for_subclass {a b d : ℝ} + (ha : 0 < a) (hb : 0 < b) (hd : 0 < d) (hd1 : d ≤ 1) + (Q : (UnitSphere → ℝ) → Prop) (hQ : ∀ w, AmbientSmooth w → Q w) : + ∃ C c M₀ : ℝ, 0 < C ∧ 0 < c ∧ 1 < M₀ ∧ ∀ M ≥ M₀, + Real.exp (-C * Real.log M * Real.log (Real.log M)) ≤ roundClassGap a b d M Q ∧ + roundClassGap a b d M Q ≤ Real.exp (-c * Real.log M * Real.log (Real.log M)) := by + obtain ⟨C, c, M₀, hC, hc, hM₀, rate⟩ := matching_round_class_rates ha hb hd hd1 + refine ⟨C, c, M₀, hC, hc, hM₀,?_⟩ + intro M hM + have compare := round_class_gap_between_broad_and_ambient ha.le hb.le hd1 + (hM₀.le.trans hM) hQ + have h := rate M hM + exact ⟨h.1.trans compare.1, compare.2.trans h.2.2.2⟩ + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean new file mode 100644 index 0000000000..bdd2314eb4 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean @@ -0,0 +1,111 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic +public import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! Positive and negative strips for the two-layer discrepancy in Cartesian coordinates. -/ + +@[expose] public section + +namespace VenRateUpper + +/-- First-axis energy in upper-hemisphere disk coordinates. -/ +noncomputable def chartEnergy (x : ℝ) : ℝ := (1 - x ^ 2) ^ 2 + +/-- Difference of the downstream exponential weights in the disk chart. -/ +noncomputable def chartGap (θ b x y : ℝ) : ℝ := + Real.exp (b * chartEnergy (Real.cos θ * x + Real.sin θ * y)) - + Real.exp (b * chartEnergy x) + +private theorem chartEnergy_antitone {u v : ℝ} (hu : 0 ≤ u) (hv : v ≤ 1) (h : u < v) : + chartEnergy v < chartEnergy u := by + have h₁ : u ^ 2 < v ^ 2 := by + nlinarith [mul_pos (sub_pos.mpr h) (show 0 < v + u by linarith)] + have hu1 : u ≤ 1 := h.le.trans hv + have h₂ : 0 ≤ 1 - v ^ 2 := by + nlinarith [mul_nonneg (sub_nonneg.mpr hv) (show 0 ≤ 1 + v by linarith)] + unfold chartEnergy + apply (sq_lt_sq₀ h₂ (by linarith only [h₁, h₂])).2 + linarith only [h₁] + +theorem opposite_chart_points {θ b : ℝ} (hθ : 0 < 1 - Real.cos θ ^ 2) (hb : 0 < b) : + ∃ x yp ym : ℝ, x ∈ Set.Ioo 0 1 ∧ x ^ 2 + yp ^ 2 < 1 ∧ x ^ 2 + ym ^ 2 < 1 ∧ + 0 < chartGap θ b x yp ∧ chartGap θ b x ym < 0 := by + let s := Real.sin θ + let c := Real.cos θ + have trig : s ^ 2 + c ^ 2 = 1 := Real.sin_sq_add_cos_sq θ + have hs : s ≠ 0 := by + intro heq + rw [heq] at trig + change 0 < 1 - c ^ 2 at hθ + nlinarith + have hs2 : 0 < s ^ 2 := sq_pos_of_ne_zero hs + have hs2' : s ^ 2 ≤ 1 := by nlinarith only [trig, sq_nonneg c] + let k := (1 - c) / s + have hk : s * k = 1 - c := by + dsimp [k] + rw [← mul_div_assoc, mul_comm s (1 - c), mul_div_cancel_right₀ _ hs] + let x := 1 / (8 * (1+|k|)) + have hx : 0 < x := by dsimp [x]; positivity + have hxmul : x * (8 * (1+|k|)) = 1 := by + dsimp [x] + exact div_mul_cancel₀ _ (by positivity) + have hx8 : x ≤ 1 / 8 := by nlinarith only [hxmul, mul_nonneg hx.le (abs_nonneg k)] + have hbase : |x * k| ≤ 1 / 8 := by + rw [abs_mul, abs_of_pos hx] + nlinarith only [hxmul, hx] + let δ := x / 4 + have hδ : 0 < δ := by dsimp [δ]; positivity + have hδb : δ ≤ 1 / 32 := by dsimp [δ]; linarith only [hx8] + have hss : |s| ≤ 1 := Real.abs_sin_le_one θ + have hsd : |s * δ| ≤ 1 / 32 := by + rw [abs_mul, abs_of_pos hδ] + exact (mul_le_of_le_one_left hδ.le hss).trans hδb + let yp := x * k - s * δ + let ym := x * k + s * δ + have hyp : |yp| ≤ 1 / 4 := by + dsimp [yp] + exact (abs_sub _ _).trans (by linarith only [hbase, hsd]) + have hym : |ym| ≤ 1 / 4 := by + dsimp [ym] + exact (abs_add_le _ _).trans (by linarith only [hbase, hsd]) + have disk (y : ℝ) (hy : |y| ≤ 1 / 4) : x ^ 2 + y ^ 2 < 1 := by + have hxx : x ^ 2 ≤ (1 / 8 : ℝ) ^ 2 := pow_le_pow_left₀ hx.le hx8 _ + have hyy : |y|^2 ≤ (1 / 4 : ℝ) ^ 2 := pow_le_pow_left₀ (abs_nonneg _) hy _ + rw [sq_abs] at hyy + linarith only [hxx, hyy] + have hpp : c * x + s * yp = x - s ^ 2 * δ := by + dsimp [yp] + calc + _ = c * x + x * (s * k) - s ^ 2 * δ := by ring + _ = _ := by rw [hk]; ring + have hpm : c * x + s * ym = x + s ^ 2 * δ := by + dsimp [ym] + calc + _ = c * x + x * (s * k) + s ^ 2 * δ := by ring + _ = _ := by rw [hk]; ring + have hvpos : 0 < s ^ 2 * δ := mul_pos hs2 hδ + have hvbound : s ^ 2 * δ ≤ x / 4 := by + exact mul_le_of_le_one_left hδ.le hs2' + have hc₁ : chartEnergy x < chartEnergy (c * x + s * yp) := by + rw [hpp] + exact chartEnergy_antitone (by linarith only [hx, hvbound]) (by linarith only [hx8]) + (by linarith only [hvpos]) + have hc₂ : chartEnergy (c * x + s * ym) < chartEnergy x := by + rw [hpm] + exact chartEnergy_antitone hx.le (by linarith only [hx8, hvbound]) (by linarith only [hvpos]) + refine ⟨x, yp, ym,⟨hx, by linarith only [hx8]⟩, disk _ hyp, disk _ hym,?_⟩ + constructor + · exact sub_pos.mpr (Real.exp_lt_exp.mpr (mul_lt_mul_of_pos_left hc₁ hb)) + · exact sub_neg.mpr (Real.exp_lt_exp.mpr (mul_lt_mul_of_pos_left hc₂ hb)) + +end VenRateUpper diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean new file mode 100644 index 0000000000..1643a29f02 --- /dev/null +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean @@ -0,0 +1,120 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +module + +public import Mathlib.Analysis.SpecialFunctions.Exponential +public import Mathlib.Data.Nat.Choose.Basic +public import Mathlib.MeasureTheory.Integral.Bochner.Basic +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! Uniform factorial remainder for the exponential kernel on a unit height interval. -/ + +@[expose] public section +open Filter Finset MeasureTheory + +namespace VenRateUpper + +theorem abs_exp_sub_sum_le_factorial {t : ℝ} (ht : 0 ≤ t) (n : ℕ) : + |Real.exp t - ∑ j ∈ range n, t ^ j / (j.factorial : ℝ)| ≤ + t ^ n / (n.factorial : ℝ) * Real.exp t := by + classical + let term (j : ℕ) := t ^ j / (j.factorial : ℝ) + have hs : HasSum term (Real.exp t) := by + rw [Real.exp_eq_exp_ℝ] + exact NormedSpace.expSeries_div_hasSum_exp t + have hshift : Summable (fun j : ℕ => term (j + n)) := + (summable_nat_add_iff n).mpr hs.summable + have hsplit : Real.exp t - (∑ j ∈ range n, term j) = ∑' j, term (j + n) := by + linarith [hs.summable.sum_add_tsum_nat_add n, hs.tsum_eq] + change |Real.exp t - (∑ j ∈ range n, term j)| ≤ term n * Real.exp t + rw [hsplit, abs_of_nonneg (tsum_nonneg (fun j => by dsimp [term]; positivity)), ← hs.tsum_eq] + rw [← tsum_mul_left] + refine hshift.tsum_le_tsum (fun j => ?_) (hs.summable.mul_left (term n)) + have hd : (j.factorial * n.factorial : ℕ) ≤ (j + n).factorial := + Nat.le_of_dvd (Nat.factorial_pos _) (Nat.factorial_mul_factorial_dvd_factorial_add j n) + have hdc : (j.factorial : ℝ) * (n.factorial : ℝ) ≤ ((j + n).factorial : ℝ) := by + exact_mod_cast hd + dsimp [term] + rw [pow_add, div_mul_div_comm, mul_comm (t ^ n) (t ^ j), + mul_comm (n.factorial : ℝ) (j.factorial : ℝ)] + exact div_le_div_of_nonneg_left (by positivity) (by positivity) hdc + +theorem exponential_integral_le_of_zero_moments {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F p : Ω → ℝ) + (hF : Measurable F) (rangeF : ∀ y, F y ∈ Set.Icc (0 : ℝ) 1) + (hp : Integrable p μ) {A : ℝ} (hA : 0 ≤ A) (supP : ∀ y, |p y| ≤ A) + (n : ℕ) (moments : ∀ j < n, (∫ y, p y * F y ^ j ∂μ) = 0) + {x a : ℝ} (hx : 0 ≤ x) (hxa : x ≤ a) : + |∫ y, p y * Real.exp (x * F y) ∂μ| ≤ + A * (a ^ n / (n.factorial : ℝ) * Real.exp a) := by + let E (y : Ω) := Real.exp (x * F y) + let T (j : ℕ) (y : Ω) := (x ^ j / (j.factorial : ℝ)) * (F y) ^ j + have hE : Integrable (fun y => p y * E y) μ := by + apply hp.mul_bdd (c := Real.exp a) + (Real.continuous_exp.measurable.comp (measurable_const.mul hF)).aestronglyMeasurable + refine Filter.Eventually.of_forall fun y => ?_ + change ‖Real.exp (x * F y)‖ ≤ Real.exp a + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + apply Real.exp_le_exp.mpr + exact (mul_le_of_le_one_right hx (rangeF y).2).trans hxa + have hTi (j : ℕ) : Integrable (fun y => p y * T j y) μ := by + have hPow : Integrable (fun y => p y * F y ^ j) μ := by + apply hp.mul_bdd (c := 1) (hF.pow_const j).aestronglyMeasurable + refine Filter.Eventually.of_forall fun y => ?_ + rw [Real.norm_eq_abs, abs_of_nonneg (pow_nonneg (rangeF y).1 _)] + simpa only [one_pow] using pow_le_pow_left₀ (rangeF y).1 (rangeF y).2 j + convert hPow.const_mul (x ^ j / (j.factorial : ℝ)) using 1 + ext y + dsimp [T] + ring + have hTerms : + Integrable (fun y => p y * ∑ j ∈ range n, T j y) μ := by + simpa only [Finset.mul_sum] using integrable_finsetSum (range n) (fun j _ => hTi j) + have hsum : (∫ y, p y * (∑ j ∈ range n, T j y) ∂μ) = 0 := by + simp_rw [Finset.mul_sum] + rw [integral_finsetSum _ (fun j _ => hTi j)] + apply Finset.sum_eq_zero + intro j hj + calc + _ = (x ^ j / (j.factorial : ℝ)) * (∫ y, p y * F y ^ j ∂μ) := by + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards with y + dsimp [T] + ring + _ = 0 := by rw [moments j (mem_range.mp hj), mul_zero] + have difference : + (∫ y, p y * (E y - ∑ j ∈ range n, T j y) ∂μ) = ∫ y, p y * E y ∂μ := by + simp_rw [mul_sub] + rw [integral_sub hE hTerms, hsum, sub_zero] + rw [← difference] + refine (abs_integral_le_integral_abs).trans ?_ + calc + _ ≤ ∫ _ : Ω, A * (a ^ n / (n.factorial : ℝ) * Real.exp a) ∂μ := by + refine integral_mono_of_nonneg (Filter.Eventually.of_forall fun _ => abs_nonneg _) + (integrable_const _) (Filter.Eventually.of_forall fun y => ?_) + have hy0 : 0 ≤ x * F y := mul_nonneg hx (rangeF y).1 + have hyA := (mul_le_of_le_one_right hx (rangeF y).2).trans hxa + have htail := abs_exp_sub_sum_le_factorial hy0 n + have sumEq : (∑ j ∈ range n, T j y) = ∑ j ∈ range n, (x * F y) ^ j / (j.factorial : ℝ) := by + apply Finset.sum_congr rfl + intro j _ + simp only [T, mul_pow] + ring + change |p y * (Real.exp (x * F y) - ∑ j ∈ range n, T j y)| ≤ _ + rw [abs_mul, sumEq] + refine mul_le_mul (supP y) (htail.trans ?_) (abs_nonneg _) hA + have ha : 0 ≤ a := hx.trans hxa + exact mul_le_mul + (div_le_div_of_nonneg_right (pow_le_pow_left₀ hy0 hyA n) (by positivity)) + (Real.exp_le_exp.mpr hyA) (Real.exp_pos _).le + (div_nonneg (pow_nonneg ha _) (by positivity)) + _ = _ := by simp + +end VenRateUpper diff --git a/LeanPool/projects/ven-null-clock-round-rates.yaml b/LeanPool/projects/ven-null-clock-round-rates.yaml new file mode 100644 index 0000000000..36f47999e7 --- /dev/null +++ b/LeanPool/projects/ven-null-clock-round-rates.yaml @@ -0,0 +1,36 @@ +slug: ven-null-clock-round-rates +title: Matching masking rates for two-layer scans on normalized round area +entry_module: LeanPool.VenNullClockRoundRates +authors: [Mark Gladden] +provenance: AI +license: Apache-2.0 +source: + url: https://github.com/VanGogh7777/c196-lean/blob/4f45e33dc5376b362e13601adee77a0a76358387/paper/C196_v0.3.pdf + github_repo: VanGogh7777/c196-lean +status: verified +summary: >- + Proves matching logarithmic-order bounds for the two-layer observation gap on normalized + round area, together with a smooth common-profile upper witness. The rate fixes two positive + control strengths and a positive separation scale at most one. The broad class permits + two independently chosen profiles with individual integral budgets. The smooth witness + uses one ambient-smooth profile at a fixed nonaligned angle, with a pointwise floor and cap. +branch: main +main_declarations: + - VenRateUpper.matching_round_class_rates + - VenRateUpper.smooth_round_common_profile_error +main_results: + - declaration: VenRateUpper.matching_round_class_rates + source_ref: "C196 v0.3, §5, p. 5, Eqs. (33)–(34)" + informal: >- + With fixed positive control strengths and separation scale 0 < d ≤ 1, + the broad and ambient-smooth class gaps on normalized round area have the + same two-sided exp(−Θ(log M log log M)) rate for sufficiently large budget M. + The class gap uses the maximum of two absolute layer discrepancies on the full read interval. + - declaration: VenRateUpper.smooth_round_common_profile_error + source_ref: "C196 v0.3, §5, p. 5, Proposition 5, Eq. (31)" + informal: >- + At fixed positive control strengths and any fixed nonaligned angle, every + sufficiently large budget M admits one smooth profile for both hypotheses, + satisfying 2 ≤ w_M ≤ M everywhere and giving error at most exp(−c log M log log M). +msc: ['28A25', '44A10'] +tags: [inverse problems, spherical measure, moment cancellation, Laplace transforms] From 6066f72ad173407fac2f80f112c79f853f58d14f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Fri, 27 Nov 2026 21:07:13 +0000 Subject: [PATCH 2/2] Preserve C196 source notices and narrow the exported scope --- LeanPool/VenNullClockRoundRates.lean | 13 ++++++++++++ LeanPool/VenNullClockRoundRates/Filter.lean | 2 ++ LeanPool/VenNullClockRoundRates/Finite.lean | 2 ++ LeanPool/VenNullClockRoundRates/Geometry.lean | 2 ++ LeanPool/VenNullClockRoundRates/Layer.lean | 2 ++ LeanPool/VenNullClockRoundRates/Lower.lean | 2 ++ LeanPool/VenNullClockRoundRates/Pole.lean | 2 ++ .../RoundAreaBridge.lean | 2 ++ .../RoundAreaCutoffInputs.lean | 2 ++ .../RoundAreaPositiveStrips.lean | 2 ++ .../RoundAreaUpperHemisphere.lean | 2 ++ .../VenNullClockRoundRates/SphereModel.lean | 21 ++----------------- .../VenRateUpperAssembly.lean | 2 ++ .../VenRateUpperBudget.lean | 2 ++ .../VenRateUpperBump.lean | 2 ++ .../VenRateUpperClassGap.lean | 2 ++ .../VenRateUpperHeight.lean | 2 ++ .../VenRateUpperPhysical.lean | 2 ++ .../VenRateUpperPositive.lean | 2 ++ .../VenRateUpperRoundRates.lean | 2 ++ .../VenRateUpperStrips.lean | 2 ++ .../VenRateUpperTaylor.lean | 2 ++ .../projects/ven-null-clock-round-rates.yaml | 1 + 23 files changed, 56 insertions(+), 19 deletions(-) diff --git a/LeanPool/VenNullClockRoundRates.lean b/LeanPool/VenNullClockRoundRates.lean index 61522f85c3..4be66de226 100644 --- a/LeanPool/VenNullClockRoundRates.lean +++ b/LeanPool/VenNullClockRoundRates.lean @@ -4,6 +4,19 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- +Upstream NOTICE for the matching-rates subproject + +C196 v0.3 manuscript and Lean formalization +Copyright 2026 Mark Gladden + +The included manuscript PDF and the Lean code are distributed under the Apache License, Version 2.0. +Mark Gladden is the responsible maintainer. AI produced the Lean proofs under his direction. + +Lean source: VanGogh7777/c196-lean, matching-rates subproject. +Commit: f14c11cca549acba4a3fcf832e7af005d2afd8ee +-/ + module public import LeanPool.VenNullClockRoundRates.Filter diff --git a/LeanPool/VenNullClockRoundRates/Filter.lean b/LeanPool/VenNullClockRoundRates/Filter.lean index d731ccd54e..e1e17ef334 100644 --- a/LeanPool/VenNullClockRoundRates/Filter.lean +++ b/LeanPool/VenNullClockRoundRates/Filter.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.Geometry public import Mathlib.Analysis.Complex.Exponential diff --git a/LeanPool/VenNullClockRoundRates/Finite.lean b/LeanPool/VenNullClockRoundRates/Finite.lean index cb15563ee3..f883654dd3 100644 --- a/LeanPool/VenNullClockRoundRates/Finite.lean +++ b/LeanPool/VenNullClockRoundRates/Finite.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.Layer public import LeanPool.VenNullClockRoundRates.Pole diff --git a/LeanPool/VenNullClockRoundRates/Geometry.lean b/LeanPool/VenNullClockRoundRates/Geometry.lean index 05bf1ee02e..021f01fec3 100644 --- a/LeanPool/VenNullClockRoundRates/Geometry.lean +++ b/LeanPool/VenNullClockRoundRates/Geometry.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.SphereModel import Mathlib.Tactic.Linarith diff --git a/LeanPool/VenNullClockRoundRates/Layer.lean b/LeanPool/VenNullClockRoundRates/Layer.lean index 80cb9ed909..0e547ef031 100644 --- a/LeanPool/VenNullClockRoundRates/Layer.lean +++ b/LeanPool/VenNullClockRoundRates/Layer.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.Filter import Mathlib.Tactic.Linarith diff --git a/LeanPool/VenNullClockRoundRates/Lower.lean b/LeanPool/VenNullClockRoundRates/Lower.lean index deda695aa3..cfaaebff9d 100644 --- a/LeanPool/VenNullClockRoundRates/Lower.lean +++ b/LeanPool/VenNullClockRoundRates/Lower.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt imports and reformat the lower-rate proof. -/ + module public import LeanPool.VenNullClockRoundRates.Finite public import Mathlib.Analysis.SpecialFunctions.Log.Basic diff --git a/LeanPool/VenNullClockRoundRates/Pole.lean b/LeanPool/VenNullClockRoundRates/Pole.lean index 327c26b4e3..39a52befec 100644 --- a/LeanPool/VenNullClockRoundRates/Pole.lean +++ b/LeanPool/VenNullClockRoundRates/Pole.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.Filter import Mathlib.Tactic.Linarith diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean b/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean index 275fcf4bfa..0e8fbc9ece 100644 --- a/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean +++ b/LeanPool/VenNullClockRoundRates/RoundAreaBridge.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.SphereModel diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean b/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean index 2d4657ef7e..e8a9073de2 100644 --- a/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean +++ b/LeanPool/VenNullClockRoundRates/RoundAreaCutoffInputs.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.RoundAreaUpperHemisphere diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean b/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean index ee88cd61b8..8d92f1cef7 100644 --- a/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean +++ b/LeanPool/VenNullClockRoundRates/RoundAreaPositiveStrips.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.RoundAreaCutoffInputs diff --git a/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean b/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean index 8e95fc73c4..61984cb84d 100644 --- a/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean +++ b/LeanPool/VenNullClockRoundRates/RoundAreaUpperHemisphere.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt imports and rework the local continuity proof. -/ + module public import LeanPool.VenNullClockRoundRates.RoundAreaBridge diff --git a/LeanPool/VenNullClockRoundRates/SphereModel.lean b/LeanPool/VenNullClockRoundRates/SphereModel.lean index 2ef86b5519..e2cbe232d3 100644 --- a/LeanPool/VenNullClockRoundRates/SphereModel.lean +++ b/LeanPool/VenNullClockRoundRates/SphereModel.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt imports and omit the separate finite-menu interface. -/ + module public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic public import Mathlib.MeasureTheory.Integral.Bochner.Basic @@ -14,8 +16,6 @@ first axis (1, 0, 0), second (cos θ, sin θ, 0). The measure may be the normali area law. The conclusion concerns scalar exponential reads, not a PDE. -/ @[expose] public section noncomputable section -open MeasureTheory -open scoped Topology namespace VenMask /-- The Cartesian unit sphere used by the scalar observation model. -/ def UnitSphere := {q : ℝ × ℝ × ℝ // q.1 ^ 2 + q.2.1 ^ 2 + q.2.2 ^ 2 = 1} @@ -31,21 +31,4 @@ def firstEnergy (y : UnitSphere) : ℝ := energy y.val.1 def secondEnergy (θ : ℝ) (y : UnitSphere) : ℝ := energy (Real.cos θ * y.val.1 + Real.sin θ * y.val.2.1) -/-- Unweighted exponential observation kernel for a finite list of controls. -/ -def sphereKernel {n : ℕ} (x s : Fin n → ℝ) (θ : ℝ) (i : Fin n) (y : UnitSphere) : ℝ := - Real.exp (x i * firstEnergy y + s i * secondEnergy θ y) - -/-- At every nonaligned angle, with any fixed list of distinct strength pairs, -one strictly positive hidden log - focusing suffices at each nearby angle to -match *all* of the reference mean reads exactly. The multiplier is an analytic -angular function (constant plus finite combinations of exponential kernels). -/ -def SphereMaskingCertificate : Prop := - ∀ {n : ℕ} (μ : Measure UnitSphere) [IsFiniteMeasure μ] [μ.IsOpenPosMeasure] - (x s : Fin n → ℝ) (θ₀ w₀ : ℝ), - 1 < w₀ → Real.sin θ₀ ≠ 0 → Function.Injective (fun i ↦ (x i, s i)) → - ∀ᶠ θ in 𝓝 θ₀, ∃ c : Fin n → ℝ, - let k := sphereKernel x s - let w := fun y ↦ w₀ + ∑ j, c j * k θ j y - (∀ y, 1 < w y) ∧ - (∀ i, (∫ y, w y * k θ i y ∂μ) = ∫ y, w₀ * k θ₀ i y ∂μ) end VenMask diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean index 5f0998f93b..988f173362 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperAssembly.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.VenRateUpperHeight diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean index 16568ce484..649361588f 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperBudget.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import Mathlib.Analysis.SpecialFunctions.Log.Basic diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean index 35d90217fd..f1c0844cd1 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperBump.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import Mathlib.Analysis.Calculus.BumpFunction.Normed diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean index 21904db78b..16924e7708 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperClassGap.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.RoundAreaBridge diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean index cc8dfee77b..a31788a336 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperHeight.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import Mathlib.Analysis.Complex.Exponential import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean index f3aa285d76..c0aa6f2e79 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperPhysical.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.RoundAreaPositiveStrips diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean index 8f3fa2fbf1..d63c202360 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperPositive.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import Mathlib.Analysis.Calculus.ContDiff.Operations diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean index 23dd05f8e6..1e85617683 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperRoundRates.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import LeanPool.VenNullClockRoundRates.VenRateUpperPhysical diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean index bdd2314eb4..483a426e4c 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperStrips.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic diff --git a/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean b/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean index 1643a29f02..e183c9ad90 100644 --- a/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean +++ b/LeanPool/VenNullClockRoundRates/VenRateUpperTaylor.lean @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Gladden -/ +/- Modified for Lean Pool: adapt module imports and source presentation. -/ + module public import Mathlib.Analysis.SpecialFunctions.Exponential diff --git a/LeanPool/projects/ven-null-clock-round-rates.yaml b/LeanPool/projects/ven-null-clock-round-rates.yaml index 36f47999e7..7d587b1420 100644 --- a/LeanPool/projects/ven-null-clock-round-rates.yaml +++ b/LeanPool/projects/ven-null-clock-round-rates.yaml @@ -7,6 +7,7 @@ license: Apache-2.0 source: url: https://github.com/VanGogh7777/c196-lean/blob/4f45e33dc5376b362e13601adee77a0a76358387/paper/C196_v0.3.pdf github_repo: VanGogh7777/c196-lean + commit: f14c11cca549acba4a3fcf832e7af005d2afd8ee status: verified summary: >- Proves matching logarithmic-order bounds for the two-layer observation gap on normalized