Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions LeanPool/VenNullClockRoundRates.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/-
Copyright (c) 2026 Mark Gladden. All rights reserved.
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
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
-/
125 changes: 125 additions & 0 deletions LeanPool/VenNullClockRoundRates/Filter.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/-
Copyright (c) 2026 Mark Gladden. All rights reserved.
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
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
102 changes: 102 additions & 0 deletions LeanPool/VenNullClockRoundRates/Finite.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/-
Copyright (c) 2026 Mark Gladden. All rights reserved.
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
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
101 changes: 101 additions & 0 deletions LeanPool/VenNullClockRoundRates/Geometry.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/-
Copyright (c) 2026 Mark Gladden. All rights reserved.
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
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
Loading
Loading