From 0bf6857e9b69ff3ee214315f3280532984ada7e5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Mon, 19 Oct 2026 08:04:27 +0000 Subject: [PATCH] Optimize PhaseRetrieval analytic and Hermite proofs --- .../Internal/AnnulusLocalEstimate.lean | 32 +- .../Constant/Internal/BlockDecomposition.lean | 12 +- .../Constant/Internal/Definitions.lean | 28 +- .../Internal/HighFreqBandEstimate.lean | 34 +- .../Constant/Internal/LaplaceFactorial.lean | 37 +- .../Constant/Internal/LeakageEstimate.lean | 50 +- .../Constant/Internal/LipschitzRho.lean | 4 +- .../Internal/LocalCircleEstimate.lean | 31 +- .../Constant/Internal/LocalCore.lean | 51 +- .../Constant/Internal/LocalHelpers.lean | 4 +- .../Constant/Internal/MainTheorem.lean | 61 +- .../Internal/MissingMathlib/Poincare.lean | 5 +- .../Internal/RotationalAveraging.lean | 26 +- .../Constant/Internal/SafeSquare.lean | 6 +- .../DimdPoly/Internal/Auxiliary.lean | 10 +- .../Internal/CoefficientLimitRigidity.lean | 94 ++- .../Internal/ExactModulusRecovery.lean | 151 ++-- .../Internal/FiniteBaseAnnulusEstimate.lean | 78 +- .../Internal/FiniteBaseCircleEstimate.lean | 245 +++--- .../Hermite/ImportedAnalyticInputs.lean | 16 +- .../Internal/Hermite/MissingMathlib.lean | 10 +- .../Hermite1Dimd/BlockLocalization.lean | 66 +- .../Hermite1Dimd/DegreeBookkeeping.lean | 2 +- .../Hermite1Dimd/ImportedAnalyticInputs.lean | 36 +- .../Hermite1Dimd/ProductAnnulusCircle.lean | 25 +- .../Hermite1Dimd/ProductBasisAndAnnuli.lean | 12 +- .../Internal/Hermitek/BasisLocalization.lean | 181 +++-- .../Hermitek/ImportedAnalyticInputs.lean | 4 +- .../Internal/Hermitek/ModulusRigidity.lean | 39 +- .../Internal/Hermitek/TrueLevelBasis.lean | 750 ++++++++---------- .../Internal/ImportedAnalyticInputs.lean | 269 +++---- .../Internal/OrthogonalCoercivity.lean | 16 +- .../OrthogonalReduction.lean | 4 +- .../DimdPoly/Internal/PhaseStability.lean | 9 +- .../Internal/ProductAnnulusLocalization.lean | 10 +- .../DimdPoly/Internal/TensorBasis.lean | 34 +- 36 files changed, 1201 insertions(+), 1241 deletions(-) diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/AnnulusLocalEstimate.lean b/LeanPool/PhaseRetrieval/Constant/Internal/AnnulusLocalEstimate.lean index 1488ccff1a..575af90b06 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/AnnulusLocalEstimate.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/AnnulusLocalEstimate.lean @@ -49,10 +49,10 @@ private lemma freqBlock_pairwiseDisjoint : simp only [Function.onFun, freqBlock, Finset.disjoint_left, Finset.mem_Icc] intro n hn₁ hn₂ rcases Nat.lt_or_gt_of_ne hne with h | h - · have : (ℓ₁ + 1) ^ 2 ≤ ℓ₂ ^ 2 := by nlinarith + · have : (ℓ₁ + 1) ^ 2 ≤ ℓ₂ ^ 2 := by nlinarith only [h] have := Nat.pos_of_ne_zero (show (ℓ₁ + 1) ^ 2 ≠ 0 by positivity) omega - · have : (ℓ₂ + 1) ^ 2 ≤ ℓ₁ ^ 2 := by nlinarith + · have : (ℓ₂ + 1) ^ 2 ≤ ℓ₁ ^ 2 := by nlinarith only [h] have := Nat.pos_of_ne_zero (show (ℓ₂ + 1) ^ 2 ≠ 0 by positivity) omega @@ -80,7 +80,7 @@ private lemma sum_odd_sq (a b : ℕ) (h : a ≤ b) : by_cases ha' : a ≤ n · rw [Finset.sum_Icc_succ_top (by omega)] have := ih ha' - nlinarith [show (n + 2) ^ 2 = (n + 1) ^ 2 + 2 * (n + 1) + 1 from by ring] + linarith only [this, show (n + 2) ^ 2 = (n + 1) ^ 2 + 2 * (n + 1) + 1 from by ring] · have : a = n + 1 := by omega subst this; simp; ring @@ -89,7 +89,7 @@ private lemma card_biUnion_freqBlock (a b : ℕ) (h : a ≤ b) : ((Finset.Icc a b).biUnion freqBlock).card = (b + 1) ^ 2 - a ^ 2 := by rw [Finset.card_biUnion (freqBlock_pairwiseDisjoint _)] simp_rw [FockSPR.freqBlock_card] - have h1 : a ^ 2 ≤ (b + 1) ^ 2 := by nlinarith + have h1 : a ^ 2 ≤ (b + 1) ^ 2 := by nlinarith only [h] have h2 := sum_odd_sq a b h omega @@ -119,7 +119,7 @@ private lemma activeFreqSet_pos {D j n : ℕ} (hn : n ∈ activeFreqSet D j) : Finset.mem_Icc] at hn obtain ⟨⟨ℓ, hℓ, hn_block⟩, _⟩ := hn simp only [freqBlock, Finset.mem_Icc] at hn_block - nlinarith [sq_nonneg ℓ, show 1 ≤ ℓ by omega] + nlinarith only [hℓ, hn_block, sq_nonneg ℓ, show 1 ≤ ℓ by omega] /-- `localPoly a 5 j (r * fourier 1 t)` equals a Fourier sum over `activeFreqSet`. This is a mechanical reindexing of the `Fin D` sum into a `Finset ℕ` sum. -/ @@ -207,16 +207,22 @@ private lemma activeFreqSet_card_le {D : ℕ} (_hD : 1 ≤ D) {j : ℕ} (hj : j rw [hmax] -- (min(Λ,j+5)+1)^2 - (j-5)^2 ≤ (j+6)^2 - (j-5)^2 = 11*(2j+1) ≤ 17985 have h_ub : min (maxBlockIndex D) (j + 5) + 1 ≤ j + 6 := by omega - have h_sq : (min (maxBlockIndex D) (j + 5) + 1) ^ 2 ≤ (j + 6) ^ 2 := by nlinarith + have h_sq : (min (maxBlockIndex D) (j + 5) + 1) ^ 2 ≤ (j + 6) ^ 2 := by + nlinarith only [ + hrange, hmax, h_ub + ] suffices (j + 6) ^ 2 - (j - 5) ^ 2 ≤ 17985 by omega suffices (j + 6) ^ 2 = (j - 5) ^ 2 + 11 * (2 * j + 1) by omega - nlinarith [sq_nonneg (j - 5), Nat.sub_add_cancel (show 5 ≤ j by omega)] + nlinarith only [sq_nonneg (j - 5), Nat.sub_add_cancel (show 5 ≤ j by omega)] · -- j < 6: max(1,j-5) = 1 have hmax : max 1 (j - 5) = 1 := by omega rw [hmax] have h_ub : min (maxBlockIndex D) (j + 5) + 1 ≤ j + 6 := by omega - have h_sq : (min (maxBlockIndex D) (j + 5) + 1) ^ 2 ≤ (j + 6) ^ 2 := by nlinarith - have h_jsm : (j + 6) ^ 2 ≤ 11 ^ 2 := by nlinarith + have h_sq : (min (maxBlockIndex D) (j + 5) + 1) ^ 2 ≤ (j + 6) ^ 2 := by + nlinarith only [ + hrange, hmax, h_ub + ] + have h_jsm : (j + 6) ^ 2 ≤ 11 ^ 2 := by nlinarith only [hj6] omega · -- Empty range have : Finset.Icc (max 1 (j - 5)) (min (maxBlockIndex D) (j + 5)) = ∅ := @@ -276,7 +282,7 @@ private lemma high_freq_NL_condition (j : ℕ) (hj : 818 ≤ j) : have hk : 0 ≤ k := by omega rw [show (j : ℤ) - 5 = k + 813 from by omega, show 2 * (j : ℤ) + 1 = 2 * k + 1637 from by omega] - nlinarith [sq_nonneg k, sq_nonneg (k * k), + nlinarith only [sq_nonneg k, sq_nonneg (k * k), sq_nonneg (k * (k + 813)), hk] /-- `activeFreqSet` is contained in `Icc (j-5)² ((j+6)²-1)` for `j ≥ 6`. -/ @@ -290,7 +296,7 @@ private lemma activeFreqSet_subset_Icc {D j : ℕ} (hj6 : 6 ≤ j) : simp only [freqBlock, Finset.mem_Icc] at hn_block hℓ_range refine Finset.mem_Icc.mpr ⟨?_, ?_⟩ · have : j - 5 ≤ ℓ := by omega - nlinarith + nlinarith only [hn_block, this] · have : ℓ + 1 ≤ j + 6 := by omega have : (ℓ + 1) ^ 2 ≤ (j + 6) ^ 2 := Nat.pow_le_pow_left this 2 @@ -339,8 +345,8 @@ private lemma sum_Icc_eq_sum_Fin {α : Type*} [AddCommMonoid α] /-- `(j+6)^2 - 1 = (j-5)^2 + (11*(2*j+1)) - 1` for `j ≥ 5`. -/ private lemma freq_range_eq (j : ℕ) (hj : 5 ≤ j) : (j + 6) ^ 2 - 1 = (j - 5) ^ 2 + (11 * (2 * j + 1)) - 1 := by - zify [show (j - 5) ^ 2 + (11 * (2 * j + 1)) ≥ 1 from by nlinarith, - show (j + 6) ^ 2 ≥ 1 from by nlinarith, show 5 ≤ j from hj] + zify [show (j - 5) ^ 2 + (11 * (2 * j + 1)) ≥ 1 from by nlinarith only [hj], + show (j + 6) ^ 2 ≥ 1 from by nlinarith only [hj], show 5 ≤ j from hj] ring /-- Case 2 (j ≥ 818): Apply `high_freq_band_estimate`. The high-frequency condition diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/BlockDecomposition.lean b/LeanPool/PhaseRetrieval/Constant/Internal/BlockDecomposition.lean index 96617de6bd..dcf7f9cfbc 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/BlockDecomposition.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/BlockDecomposition.lean @@ -98,7 +98,7 @@ private lemma freqBlock_unique {n ℓ₁ ℓ₂ : ℕ} /-- Every natural number belongs to `freqBlock (Nat.sqrt n)`. -/ private lemma mem_freqBlock_sqrt (n : ℕ) : n ∈ freqBlock (Nat.sqrt n) := by simp only [freqBlock, Finset.mem_Icc] - exact ⟨by have := Nat.sqrt_le n; nlinarith, + exact ⟨by have := Nat.sqrt_le n; linarith only [this], by have h1 := Nat.lt_succ_sqrt' n; simp only [Nat.succ_eq_add_one] at h1; omega⟩ /-- The cardinality of `freqBlock ℓ` is `2ℓ + 1`. -/ @@ -115,7 +115,7 @@ private lemma fourier_pow (t : AddCircle T) (n : ℕ) : ((fourier 1 t : ℂ)) ^ n = (fourier (↑n : ℤ) t : ℂ) := by induction n with | zero => simp - | succ n ih => rw [pow_succ, ih, ← fourier_add]; push_cast; ring_nf + | succ n ih => rw [pow_succ, ih, ← fourier_add]; push_cast; ring -- to_mathlib: Mathlib.Analysis.Fourier.AddCircle /-- Power of `fourier (-1)` equals the corresponding negative Fourier mode. -/ @@ -234,7 +234,7 @@ theorem blocks_cover (D : ℕ) (n : ℕ) (hn : 1 ≤ n) (_hnD : n ≤ D) : · exact Nat.sqrt_pos.mpr (by omega) · simp only [freqBlock, Finset.mem_Icc] refine ⟨?_, ?_⟩ - · have := Nat.sqrt_le n; nlinarith + · have := Nat.sqrt_le n; linarith only [this] · have h1 := Nat.lt_succ_sqrt' n simp only [Nat.succ_eq_add_one] at h1; omega @@ -354,15 +354,15 @@ theorem monomial_peak_localization {n ℓ : ℕ} (hℓ : 1 ≤ ℓ) rw [Real.sqrt_sq (by positivity)]] apply Real.sqrt_lt_sqrt (by positivity) have : (ℓ : ℝ) ^ 2 ≤ (n : ℝ) := by exact_mod_cast hn.1 - linarith + linarith only [this] · rw [show (ℓ + 1 : ℝ) = Real.sqrt ((ℓ + 1 : ℝ) ^ 2) from by rw [Real.sqrt_sq (by positivity)]] apply Real.sqrt_lt_sqrt - (by linarith [show (0 : ℝ) ≤ n from Nat.cast_nonneg n]) + (by linarith only [show (0 : ℝ) ≤ n from Nat.cast_nonneg n]) have h1 : n + 1 ≤ (ℓ + 1) ^ 2 := by have : 0 < (ℓ + 1) ^ 2 := Nat.pos_of_ne_zero (by positivity) omega have : (n : ℝ) + 1 ≤ ((ℓ + 1 : ℕ) : ℝ) ^ 2 := by exact_mod_cast h1 - push_cast at this ⊢; linarith + push_cast at this ⊢; linarith only [this] end FockSPR diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/Definitions.lean b/LeanPool/PhaseRetrieval/Constant/Internal/Definitions.lean index aa1917700c..0b4079784e 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/Definitions.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/Definitions.lean @@ -182,7 +182,7 @@ private lemma norm_polyEvalCircle_le {D : ℕ} (a : Fin D → ℂ) (r : ℝ) (t Actually, we prove the simpler bound: ≤ (∑ ‖a_k‖ * |r|^{k+1})² . -/ private lemma norm_sq_polyEvalCircle_le {D : ℕ} (a : Fin D → ℂ) (r : ℝ) (t : AddCircle T) : ‖polyEvalCircle a r t‖ ^ 2 ≤ (∑ k : Fin D, ‖a k‖ * |r| ^ (k.val + 1)) ^ 2 := - sq_le_sq' (by linarith [norm_nonneg (polyEvalCircle a r t), + sq_le_sq' (by linarith only [norm_nonneg (polyEvalCircle a r t), Finset.sum_nonneg (fun k (_ : k ∈ Finset.univ) => mul_nonneg (norm_nonneg (a k)) (pow_nonneg (abs_nonneg r) (k.val + 1)))]) (norm_polyEvalCircle_le a r t) @@ -375,7 +375,7 @@ private lemma integrableOn_polar_norm {D : ℕ} (a : Fin D → ℂ) : -- Goal: r³ * (∑ x, r^x.val * ‖a x‖)² ≤ 4*C²*r^{2D+1} + 4*C²*r³ have hC_nn : 0 ≤ C := Finset.sum_nonneg (fun k _ => norm_nonneg (a k)) by_cases hD : D = 0 - · subst hD; simp; nlinarith [sq_nonneg C, pow_nonneg hr.le 3] + · subst hD; simp; nlinarith only [hr, sq_nonneg C, pow_nonneg hr.le 3] · -- D ≥ 1 have hD_pos : 0 < D := Nat.pos_of_ne_zero hD -- Each r^k ≤ 1 + r^(D-1) for k ∈ {0,...,D-1} @@ -384,11 +384,11 @@ private lemma integrableOn_polar_norm {D : ℕ} (a : Fin D → ℂ) : intro k by_cases hr1 : r ≤ 1 · have : r ^ k.val ≤ 1 := pow_le_one₀ (n := k.val) hr_nn hr1 - linarith [pow_nonneg hr_nn (D - 1)] + linarith only [hr_nn, this, pow_nonneg hr_nn (D - 1)] · push Not at hr1 have : r ^ k.val ≤ r ^ (D - 1) := pow_le_pow_right₀ hr1.le (by omega : k.val ≤ D - 1) - linarith + linarith only [this] -- ∑ r^k * ‖a k‖ ≤ (1 + r^(D-1)) * C have hsum_le : ∑ x : Fin D, r ^ x.val * ‖a x‖ ≤ (1 + r ^ (D - 1)) * C := by @@ -402,17 +402,20 @@ private lemma integrableOn_polar_norm {D : ℕ} (a : Fin D → ℂ) : Finset.sum_nonneg (fun k _ => mul_nonneg (pow_nonneg hr_nn k.val) (norm_nonneg _)) have hfact_nn : 0 ≤ (1 + r ^ (D - 1)) * C := - mul_nonneg (by linarith [pow_nonneg hr_nn (D - 1)]) hC_nn + mul_nonneg (by linarith only [hr_nn, pow_nonneg hr_nn (D - 1)]) hC_nn have hsq : (∑ x : Fin D, r ^ x.val * ‖a x‖) ^ 2 ≤ ((1 + r ^ (D - 1)) * C) ^ 2 := - sq_le_sq' (by linarith) hsum_le + sq_le_sq' (by linarith only [hsum_le, hsum_nn]) hsum_le -- ((1+a)*b)² = (1+a)²*b² -- (1+a)² = 1 + 2a + a² ≤ 2 + 2a² = 2(1+a²) -- So ((1+a)*b)² ≤ 2(1+a²)*b² -- With a = r^(D-1): (1+r^(D-1))²*C² ≤ 2*(1+(r^(D-1))²)*C² = 2*(1+r^(2*(D-1)))*C² have hrd := pow_nonneg hr_nn (D - 1) have hsq2 : ((1 + r ^ (D - 1)) * C) ^ 2 ≤ - 2 * (1 + (r ^ (D - 1)) ^ 2) * C ^ 2 := by nlinarith [sq_nonneg (1 - r ^ (D - 1))] + 2 * (1 + (r ^ (D - 1)) ^ 2) * C ^ 2 := by + nlinarith only [ + sq_nonneg (1 - r ^ (D - 1)) + ] -- r^3 * 2 * (1 + (r^(D-1))²) * C² ≤ 4 * (r^3 + r^3*(r^(D-1))²) * C² -- r^3 * (r^(D-1))² = r^(2D+1) have hpow_eq : r ^ 3 * (r ^ (D - 1)) ^ 2 = r * r ^ (D * 2) := by @@ -425,9 +428,10 @@ private lemma integrableOn_polar_norm {D : ℕ} (a : Fin D → ℂ) : _ = 2 * C ^ 2 * (r ^ 3 + r ^ 3 * (r ^ (D - 1)) ^ 2) := by ring _ = 2 * C ^ 2 * (r ^ 3 + r * r ^ (D * 2)) := by rw [hpow_eq] _ ≤ r * r ^ (D * 2) * C ^ 2 * 4 + r ^ 3 * C ^ 2 * 4 := by - nlinarith [pow_nonneg hr_nn 3, - mul_nonneg hr_nn (pow_nonneg hr_nn (D * 2)), - sq_nonneg C] + nlinarith only [ + hr_nn, pow_nonneg hr_nn 3, mul_nonneg hr_nn (pow_nonneg hr_nn (D * 2)), + sq_nonneg C + ] /-- IntegrableOn for the polar-coordinate integrand with ρ(polyEvalCircle)². -/ private lemma integrableOn_polar_rho {D : ℕ} (a : Fin D → ℂ) : @@ -461,7 +465,7 @@ private lemma integrableOn_polar_rho {D : ℕ} (a : Fin D → ℂ) : have hle := rho_le_norm (polyEvalCircle a r (QuotientAddGroup.mk θ)) have hnn := norm_nonneg (polyEvalCircle a r (QuotientAddGroup.mk θ)) have hrho_nn : 0 ≤ rho (polyEvalCircle a r (QuotientAddGroup.mk θ)) := abs_nonneg _ - exact sq_le_sq' (by linarith) hle + exact sq_le_sq' (by linarith only [hnn, hrho_nn]) hle /-! ## Lemma 1.7: Polar-coordinate decomposition of the Fock norm -/ @@ -667,7 +671,7 @@ private lemma radial_gaussian_integral (n : ℕ) : (n.factorial : ℝ) := by -- Use integral_rpow_mul_exp_neg_rpow with p = 2, q = 2*n + 1 have hp : (0 : ℝ) < 2 := two_pos - have hq : (-1 : ℝ) < (2 * (n : ℝ) + 1) := by linarith [Nat.cast_nonneg (α := ℝ) n] + have hq : (-1 : ℝ) < (2 * (n : ℝ) + 1) := by linarith only [Nat.cast_nonneg (α := ℝ) n] -- First convert ℕ powers to ℝ powers so we can apply integral_rpow_mul_exp_neg_rpow have pow_eq : ∀ (r : ℝ), r ∈ Set.Ioi (0 : ℝ) → r ^ (2 * n + 1) * Real.exp (-r ^ 2) = diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/HighFreqBandEstimate.lean b/LeanPool/PhaseRetrieval/Constant/Internal/HighFreqBandEstimate.lean index e5d7c3033f..c6e35cf0ff 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/HighFreqBandEstimate.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/HighFreqBandEstimate.lean @@ -91,7 +91,7 @@ private lemma rho_sq_lower (α w z : ℂ) have h2 : ‖α * w - α * z‖ = ‖w - z‖ := by rw [← mul_sub, norm_mul, hα, one_mul] exact nonneg_safe_square _ _ _ (rho_nonneg' _) (rho_nonneg' _) - (norm_nonneg _) (by linarith) + (norm_nonneg _) (by linarith only [h1, h2]) /-! ## Interval partition quantities -/ @@ -200,7 +200,7 @@ private lemma bias_variance_interval (a b : ℝ) (hab : a < b) have h_pw : ∀ t, ‖g t‖ ^ 2 - ‖g t - c‖ ^ 2 = 2 * @inner ℝ ℂ _ c (g t - c) + ‖c‖ ^ 2 := by intro t; have := norm_add_sq_real c (g t - c) - simp only [add_sub_cancel] at this; linarith + simp only [add_sub_cancel] at this; linarith only [this] -- Step 4: Integrate and combine have h1 : ∫ t in a..b, (‖g t‖ ^ 2 - ‖g t - c‖ ^ 2) = @@ -234,7 +234,7 @@ private lemma bias_variance_interval (a b : ℝ) (hab : a < b) intervalIntegral.integral_const_mul, intervalIntegral.integral_const, smul_eq_mul] -- Combine - linarith [h1, h_split, h_rhs, h_cross] + linarith only [h1, h_split, h_rhs, h_cross] /-- 4.1b: Parseval partition identity. On each I_k, ∫|Q|² = |q_k|²·(T/N)/T + ∫|Q−q_k|² @@ -510,7 +510,7 @@ private lemma deriv_norm_le_circleNormSq {N L : ℕ} (hN : 1 ≤ N) apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) have hm : (m.val : ℝ) ≤ ↑L - 1 := by have := m.isLt; exact_mod_cast (show (m.val : ℤ) ≤ (L : ℤ) - 1 by omega) - exact sq_le_sq' (by linarith [Nat.cast_nonneg (α := ℝ) m.val]) hm + exact sq_le_sq' (by linarith only [hm, Nat.cast_nonneg (α := ℝ) m.val]) hm /-- Interval integral shift: ∫_a^{a+h} g = ∫_0^h g(·+a). -/ @@ -546,7 +546,7 @@ private lemma hasDerivAt_slowFactor_shift {L : ℕ} (b : Fin L → ℂ) (a x : (hasDerivAt_id x |>.add (hasDerivAt_const x a)) simp only [add_zero, one_smul] at hd exact hd.const_mul _ - simpa only [slowFactor] using + exact HasDerivAt.fun_sum (u := Finset.univ) fun m _ => hterm m /-- Poincaré on each subinterval: shifted to [0, h] and @@ -586,7 +586,7 @@ private lemma poincare_per_interval {N L : ℕ} (hN : 1 ≤ N) ∫ x in (0 : ℝ)..h, ‖f' x‖ ^ 2 := by simp only [f'] exact integral_shift (fun t => ‖Q' t‖ ^ 2) a h - have h_ak : iLeft N (k.val + 1) = a + h := by simp only [a, h]; linarith [iLeft_diff N k.val] + have h_ak : iLeft N (k.val + 1) = a + h := by simp only [a, h]; linarith only [iLeft_diff N k.val] rw [h_ak, h_shift_lhs, h_shift_rhs] have hf_deriv : ∀ x ∈ Set.Icc 0 h, @@ -898,7 +898,7 @@ private lemma assembly {N L : ℕ} (hN : 1 ≤ N) rw [hPQ]; change _ ≤ (rho (fourier (↑↑N) ↑t * slowFactor b ↑t)) ^ 2 have := rho_sq_lower (fourier (N : ℤ) (↑t : AddCircle T)) (slowFactor b (↑t : AddCircle T)) (qAvg b N k) (norm_fourier_apply _ _) - linarith + linarith only [this] -- Integrate the pointwise bound have hT_inv_pos : (0 : ℝ) < 1 / T := div_pos one_pos hT_pos have hi1 : IntervalIntegrable (fun t => (rho (P (↑t : AddCircle T))) ^ 2) @@ -944,7 +944,7 @@ private lemma assembly {N L : ℕ} (hN : 1 ≤ N) -- Expand 1/T * (1/2 * A - B) = 1/2 * (1/T * A) - 1/T * B have h_expand : 1 / T * (1 / 2 * A - B) = 1 / 2 * (1 / T * A) - 1 / T * B := by ring rw [h_expand] at h_mul - linarith + linarith only [h_mul, h_frozen] -- Sum over k have h_sum : (1 / T) • ∑ k : Fin N, ∫ t in iLeft N k.val..iLeft N (k.val + 1), @@ -970,11 +970,11 @@ private lemma assembly {N L : ℕ} (hN : 1 ≤ N) rw [← Finset.mul_sum] have : (↑N : ℝ) ≠ 0 := ne_of_gt hN_pos; field_simp · unfold totalDelta; rw [Finset.mul_sum] - linarith + linarith only [h_sum_ge, h_rhs_eq] -- Apply parseval_partition have h_parseval := parseval_partition hN b -- h_parseval: C = (1/N)∑|q_k|² + δ, so (1/N)∑|q_k|² = C - δ - linarith + linarith only [h_sum, h_parseval] /-! ## Auxiliary -/ @@ -1000,7 +1000,7 @@ The hypothesis `1343 * L^2 ≤ N^2` implies `136π²(L-1)² ≤ 136π²L² ≤ 1 private lemma pi_sq_bound : 136 * Real.pi ^ 2 < 1343 := by have hpi : Real.pi < 3.141593 := Real.pi_lt_d6 have hpi_pos : (0 : ℝ) < Real.pi := Real.pi_pos - nlinarith [sq_nonneg (3.141593 - Real.pi)] + nlinarith only [hpi, hpi_pos, sq_nonneg (3.141593 - Real.pi)] private lemma rho_integral_lower_bound {N L : ℕ} (hN : 1 ≤ N) (hL : 1 ≤ L) @@ -1028,7 +1028,7 @@ private lemma rho_integral_lower_bound {N L : ℕ} -- Since (L-1)² ≤ L² and 136π² < 1343: 136π²(L-1)² ≤ 1343L² ≤ N² have hpi2 := pi_sq_bound have hL_real : (1 : ℝ) ≤ (↑L : ℝ) := Nat.one_le_cast.mpr hL - have hL_cast : (0 : ℝ) ≤ (↑L : ℝ) - 1 := by linarith + have hL_cast : (0 : ℝ) ≤ (↑L : ℝ) - 1 := by linarith only [hL_real] have hN_pos : (0 : ℝ) < (↑N : ℝ) := Nat.cast_pos.mpr (by omega) have hN2_pos : (0 : ℝ) < (↑N : ℝ) ^ 2 := by positivity have hNL_cast : (1343 : ℝ) * (↑L : ℝ) ^ 2 ≤ (↑N : ℝ) ^ 2 := by @@ -1038,17 +1038,17 @@ private lemma rho_integral_lower_bound {N L : ℕ} have h_rate_bound : 34 * (4 * Real.pi ^ 2 * (↑L - 1) ^ 2) ≤ (↑N : ℝ) ^ 2 := by have hLm1_sq : ((↑L : ℝ) - 1) ^ 2 ≤ (↑L : ℝ) ^ 2 := by apply sq_le_sq' <;> linarith -- 34 * 4π² * (L-1)² ≤ 136π² * L² < 1343 * L² ≤ N² - nlinarith [sq_nonneg Real.pi, sq_nonneg (↑L : ℝ)] + nlinarith only [hpi2, hL_real, hNL_cast, sq_nonneg Real.pi, sq_nonneg (↑L : ℝ)] -- r·C ≤ C/34 where r = 4π²(L-1)²/N² have h_key : 4 * Real.pi ^ 2 * (↑L - 1) ^ 2 / ↑N ^ 2 * C ≤ C / 34 := by have h1 : 4 * Real.pi ^ 2 * (↑L - 1) ^ 2 / ↑N ^ 2 ≤ 1 / 34 := by rw [div_le_div_iff₀ hN2_pos (by norm_num : (0:ℝ) < 34)] - linarith + linarith only [h_rate_bound] calc 4 * Real.pi ^ 2 * (↑L - 1) ^ 2 / ↑N ^ 2 * C - ≤ (1 / 34) * C := by nlinarith + ≤ (1 / 34) * C := by nlinarith only [h_nn, h1] _ = C / 34 := by ring -- Combine: ∫ρ² ≥ C/16 - (17/16)δ ≥ C/16 - (17/16)·(C/34) = C/16 - C/32 = C/32 - linarith + linarith only [h_asm, h_poi, h_key] /-! ## Main theorem -/ @@ -1070,6 +1070,6 @@ theorem high_freq_band_estimate {N L : ℕ} have h_eq := circleNormSq_P_eq_Q b P hP have h_lb := rho_integral_lower_bound hN hL hNL b P hP - linarith + linarith only [h_eq, h_lb] end FockSPR diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/LaplaceFactorial.lean b/LeanPool/PhaseRetrieval/Constant/Internal/LaplaceFactorial.lean index 0333c4afd9..3e4acaec37 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/LaplaceFactorial.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/LaplaceFactorial.lean @@ -54,7 +54,7 @@ private lemma rStar_gt_one {n : ℕ} (hn : 1 ≤ n) : rStar n > 1 := by unfold rStar calc (1 : ℝ) = Real.sqrt 1 := Real.sqrt_one.symm _ < Real.sqrt (↑n + 1 / 2) := Real.sqrt_lt_sqrt (by norm_num) - (by have : (1 : ℝ) ≤ (n : ℝ) := Nat.one_le_cast.mpr hn; linarith) + (by have : (1 : ℝ) ≤ (n : ℝ) := Nat.one_le_cast.mpr hn; linarith only [this]) private lemma rStar_pos {n : ℕ} (hn : 1 ≤ n) : 0 < rStar n := lt_trans one_pos (rStar_gt_one hn) @@ -89,7 +89,7 @@ theorem phiFunc_concavity {n : ℕ} (hn : 1 ≤ n) : have hb' : (0 : ℝ) < b := hb rw [(hasDerivAt_phiFunc n ha').deriv, (hasDerivAt_phiFunc n hb').deriv] have hnn : (0 : ℝ) < 2 * ↑n + 1 := by positivity - linarith [div_lt_div_of_pos_left hnn ha' hab] + linarith only [hab, ha', hnn, div_lt_div_of_pos_left hnn ha' hab] /-! ## Theorem 2.8: Quadratic upper bound @@ -138,7 +138,7 @@ private lemma hFunc_concaveOn {n : ℕ} (hn : 1 ≤ n) : intro a ha b hb hab rw [(hasDerivAt_hFunc n (show (0:ℝ) < a from ha)).deriv, (hasDerivAt_hFunc n (show (0:ℝ) < b from hb)).deriv] - linarith [div_lt_div_of_pos_left + linarith only [div_lt_div_of_pos_left (show (0 : ℝ) < 2 * ↑n + 1 from by positivity) (show (0:ℝ) < a from ha) hab] @@ -159,7 +159,7 @@ theorem phiFunc_quad_bound {n : ℕ} (hn : 1 ≤ n) {r : ℝ} (hr : 0 < r) : phiFunc n r ≤ phiFunc n (rStar n) - (r - rStar n) ^ 2 := by have h := hFunc_le hn hr unfold hFunc at h - linarith [sq_nonneg (r - rStar n)] + linarith only [h, sq_nonneg (r - rStar n)] /-! ## Theorem 2.9: Factorial upper bound on exp(φ_n(r_n)) @@ -196,14 +196,14 @@ private lemma phiFunc_rStar_le {n : ℕ} (hn : 1 ≤ n) : calc ((n : ℝ) + 1 / 2) * Real.log (1 + 1 / (2 * (n : ℝ))) ≤ ((n : ℝ) + 1 / 2) * (1 / (2 * (n : ℝ))) := mul_le_mul_of_nonneg_left - (by linarith [Real.log_le_sub_one_of_pos h1]) (by linarith) + (by linarith only [h1, Real.log_le_sub_one_of_pos h1]) (by linarith only [hn_pos]) _ = 1 / 2 + 1 / (4 * (n : ℝ)) := by field_simp; ring _ ≤ 3 / 4 := by linarith [div_le_div_of_nonneg_left (by norm_num : (0:ℝ) ≤ 1) (by norm_num : (0:ℝ) < 4) (show (4:ℝ) ≤ 4 * (n:ℝ) from by nlinarith [show (1:ℝ) ≤ (n:ℝ) from by exact_mod_cast hn])] - linarith [h_expand] + linarith only [h_expand, h_log_bound] private lemma stirling_log_bound {n : ℕ} (hn : 1 ≤ n) : (n : ℝ) * Real.log (n : ℝ) + (1 / 2) * Real.log (n : ℝ) - (n : ℝ) ≤ @@ -211,18 +211,20 @@ private lemma stirling_log_bound {n : ℕ} (hn : 1 ≤ n) : have h_stirling := @Stirling.le_log_factorial_stirling n (by omega) have h_pi : Real.log 2 ≤ (1 / 2) * Real.log (2 * π) := by have : Real.log 4 ≤ Real.log (2 * π) := - Real.log_le_log (by norm_num) (by linarith [Real.two_le_pi]) - linarith [show Real.log 4 = 2 * Real.log 2 from by - rw [show (4:ℝ) = 2 ^ 2 from by norm_num, Real.log_pow] - simp only [Nat.cast_ofNat]] - linarith + Real.log_le_log (by norm_num) (by linarith only [Real.two_le_pi]) + linarith only [this, + show Real.log 4 = 2 * Real.log 2 from + by + rw [show (4 : ℝ) = 2 ^ 2 from by norm_num, Real.log_pow] + simp only [Nat.cast_ofNat]] + linarith only [h_stirling, h_pi] theorem exp_phi_le_factorial {n : ℕ} (hn : 1 ≤ n) : Real.exp (phiFunc n (rStar n)) ≤ Real.exp (1 / 4) * (Nat.factorial n : ℝ) / 2 := by have h3 : phiFunc n (rStar n) ≤ Real.log (n.factorial : ℝ) - Real.log 2 + 1 / 4 := by - linarith [phiFunc_rStar_le hn, stirling_log_bound hn] + linarith only [phiFunc_rStar_le hn, stirling_log_bound hn] have h_fact_pos : (0 : ℝ) < (n.factorial : ℝ) := Nat.cast_pos.mpr n.factorial_pos calc Real.exp (phiFunc n (rStar n)) @@ -260,7 +262,10 @@ private lemma distToInterval_le_abs_sub (x r : ℝ) (j : ℕ) distToInterval x j ≤ |r - x| := by unfold distToInterval exact max_le - (max_le (by linarith [le_abs_self (r - x)]) (by linarith [neg_le_abs (r - x)])) + (max_le (by + linarith only [ + hrj, le_abs_self (r - x) + ]) (by linarith only [hrj1, neg_le_abs (r - x)])) (abs_nonneg _) private lemma distToInterval_sq_le_sq (x r : ℝ) (j : ℕ) @@ -269,7 +274,7 @@ private lemma distToInterval_sq_le_sq (x r : ℝ) (j : ℕ) have h1 := distToInterval_le_abs_sub x r j hrj hrj1 have h2 := distToInterval_nonneg x j calc distToInterval x j ^ 2 - ≤ |r - x| ^ 2 := by nlinarith [sq_nonneg (|r - x| - distToInterval x j)] + ≤ |r - x| ^ 2 := by nlinarith only [h1, h2, sq_nonneg (|r - x| - distToInterval x j)] _ = (r - x) ^ 2 := sq_abs _ /-- Pointwise integrand bound for `r ∈ [j, j+1]`. -/ @@ -295,7 +300,7 @@ private lemma pointwise_bound {n : ℕ} (hn : 1 ≤ n) {r : ℝ} calc Real.exp (phiFunc n r) ≤ Real.exp (phiFunc n (rStar n) - distToInterval (rStar n) j ^ 2) := Real.exp_le_exp.mpr - (by linarith [phiFunc_quad_bound hn hr_pos, + (by linarith only [phiFunc_quad_bound hn hr_pos, distToInterval_sq_le_sq (rStar n) r j hrj hrj1]) _ = Real.exp (phiFunc n (rStar n)) * Real.exp (-(distToInterval (rStar n) j ^ 2)) := by rw [sub_eq_add_neg, Real.exp_add] @@ -314,7 +319,7 @@ theorem monomial_integral_bound {n : ℕ} (hn : 1 ≤ n) (j : ℕ) : Real.exp (-(distToInterval (rStar n) j) ^ 2) have h_const : ∫ r in (j : ℝ)..(↑j + 1), C = C := integral_const_on_unit_interval rw [← h_const] - apply intervalIntegral.integral_mono_on (by linarith : (j : ℝ) ≤ ↑j + 1) + apply intervalIntegral.integral_mono_on (by linarith only [] : (j : ℝ) ≤ ↑j + 1) · apply ContinuousOn.intervalIntegrable exact (continuousOn_pow _).mul ((Real.continuous_exp.comp diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/LeakageEstimate.lean b/LeanPool/PhaseRetrieval/Constant/Internal/LeakageEstimate.lean index f687c5bc2c..8812b9b49a 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/LeakageEstimate.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/LeakageEstimate.lean @@ -39,7 +39,7 @@ private lemma fourier_pow (n : ℕ) (t : AddCircle T) : ((fourier 1 t : ℂ) ^ n : ℂ) = (fourier (n : ℤ) t : ℂ) := by induction n with | zero => simp - | succ n ih => rw [pow_succ, ih, ← fourier_add]; push_cast; ring_nf + | succ n ih => rw [pow_succ, ih, ← fourier_add]; push_cast; ring /-- `∫ fourier n = δ_{n,0}` w.r.t. normalized Haar. -/ private lemma integral_fourier (n : ℤ) : @@ -95,17 +95,17 @@ private lemma dist_peak_to_interval {n ℓ : ℕ} (hℓ : 1 ≤ ℓ) (hn : n ∈ by_cases hjl : j ≥ ℓ + 1 · left; left constructor - · linarith + · linarith only [hhi] · have : (j : ℝ) ≥ ℓ + 1 := by exact_mod_cast hjl - linarith + linarith only [hlo, hhi, this] · push Not at hjl by_cases hjl2 : j + 1 ≤ ℓ · left; right constructor · have : (j : ℝ) + 1 ≤ ℓ := by exact_mod_cast hjl2 - linarith + linarith only [hlo, hhi, this] · have : (j : ℝ) + 1 ≤ ℓ := by exact_mod_cast hjl2 - linarith + linarith only [hlo] · push Not at hjl2 have hje : j = ℓ := by omega simp_all @@ -341,9 +341,8 @@ theorem block_annulus_leakage {D : ℕ} (a : Fin D → ℂ) {ℓ : ℕ} (hℓ : exact_mod_cast (Nat.factorial_pos (k.val + 1)).le · norm_num -- Combine: 2 * ‖a_k‖² * ∫ ≤ exp(1/4) * exp(-d²) * ‖a_k‖² * (k+1)! - nlinarith [sq_nonneg (‖a k‖), Real.exp_pos (1 / 4 : ℝ), - Real.exp_pos (-(max ((j : ℤ) - ℓ - 1) 0 : ℤ) ^ 2 : ℝ), - Nat.factorial_pos (k.val + 1)] + nlinarith only [hint_bound, sq_nonneg (‖a k‖), Real.exp_pos (1 / 4 : ℝ), + Real.exp_pos (-(max ((j : ℤ) - ℓ - 1) 0 : ℤ) ^ 2 : ℝ), Nat.factorial_pos (k.val + 1)] -- Step 4: Exchange integral and sum, then apply per-k bounds -- First, prove integrability of each summand have hint : ∀ k : Fin D, IntervalIntegrable @@ -461,9 +460,12 @@ private lemma block_annulus_leakage_symmetric {D : ℕ} (a : Fin D → ℂ) {ℓ · apply mul_nonneg (le_of_lt (Real.exp_pos _)) exact_mod_cast (Nat.factorial_pos (k.val + 1)).le · norm_num - nlinarith [sq_nonneg (‖a k‖), Real.exp_pos (1 / 4 : ℝ), - Real.exp_pos (-(max (max ((j : ℤ) - ℓ - 1) ((ℓ : ℤ) - j - 1)) 0 : ℤ) ^ 2 : ℝ), - Nat.factorial_pos (k.val + 1)] + nlinarith only [ + hint_bound, sq_nonneg (‖a k‖), Real.exp_pos (1 / 4 : ℝ), + Real.exp_pos + (-(max (max ((j : ℤ) - ℓ - 1) ((ℓ : ℤ) - j - 1)) 0 : ℤ) ^ 2 : ℝ), + Nat.factorial_pos (k.val + 1) + ] -- Exchange integral and sum have hint : ∀ k : Fin D, IntervalIntegrable (fun r : ℝ => if (k.val + 1) ∈ freqBlock ℓ @@ -695,9 +697,9 @@ private lemma remainder_annulus_le_far_blocks {D : ℕ} (a : Fin D → ℂ) {M : ∂AddCircle.haarAddCircle) := by apply intervalIntegral.integral_congr intro r hr - rw [Set.uIcc_of_le (show (j : ℝ) ≤ j + 1 by linarith)] at hr + rw [Set.uIcc_of_le (show (j : ℝ) ≤ j + 1 by linarith only [])] at hr have hr0 : (0 : ℝ) ≤ r := le_trans (Nat.cast_nonneg j) hr.1 - simp_all + simp_all only [] rw [heq] -- Step 3: Distribute weight over the sum inside the integral have integrand_eq : ∀ r : ℝ, @@ -839,7 +841,7 @@ theorem total_leakage_bound {D : ℕ} (a : Fin D → ℂ) {M : ℕ} (hM : 2 ≤ calc _ ≤ etaCoeff M J * fockNormSq a := h _ ≤ (etaCoeff M J + ε) * fockNormSq a := by apply mul_le_mul_of_nonneg_right - · linarith + · linarith only [hε] · exact Finset.sum_nonneg fun k _ => mul_nonneg (sq_nonneg _) (by exact_mod_cast (Nat.factorial_pos _).le) -- Main bound: ∑_j 2∫ r exp(-r²) ∫_circle ‖R_j‖² ≤ etaCoeff M J * fockNormSq a @@ -954,13 +956,13 @@ Split the sum at `m = 5`, bound the tail by `95 · exp(-36)`. private lemma exp_quarter_lt : Real.exp (1 / 4 : ℝ) < 13 / 10 := by have h := Real.exp_bound' (by norm_num : (0:ℝ) ≤ 1/4) (by norm_num : (1:ℝ)/4 ≤ 1) (n := 5) (by norm_num) - simp [Finset.sum_range_succ] at h; linarith + simp [Finset.sum_range_succ] at h; linarith only [h] private lemma exp_neg_25_lt : Real.exp (-25 : ℝ) < 14 / 10 ^ 12 := by have h5 : (1484 : ℝ) / 10 ≤ Real.exp 5 := by have := Real.sum_le_exp_of_nonneg (by norm_num : (0:ℝ) ≤ 5) 18 simp only [Finset.sum_range_succ, Finset.sum_range_zero] at this - norm_num at this ⊢; linarith + norm_num at this ⊢; linarith only [this] rw [show (-25 : ℝ) = (5 : ℕ) * (-5 : ℝ) from by norm_num, Real.exp_nat_mul, Real.exp_neg, inv_pow] calc (Real.exp 5 ^ 5)⁻¹ @@ -972,7 +974,7 @@ private lemma exp_neg_36_lt : Real.exp (-36 : ℝ) < 1 / 10 ^ 14 := by have h6 : (403 : ℝ) ≤ Real.exp 6 := by have := Real.sum_le_exp_of_nonneg (by norm_num : (0:ℝ) ≤ 6) 16 simp only [Finset.sum_range_succ, Finset.sum_range_zero] at this - norm_num at this ⊢; linarith + norm_num at this ⊢; linarith only [this] rw [show (-36 : ℝ) = (6 : ℕ) * (-6 : ℝ) from by norm_num, Real.exp_nat_mul, Real.exp_neg, inv_pow] calc (Real.exp 6 ^ 6)⁻¹ @@ -1000,14 +1002,14 @@ theorem eta_5_bound : etaCoeff 5 100 < 4 / (10 : ℝ) ^ 11 := by apply Real.exp_le_exp.mpr simp only [Finset.mem_Icc] at hm have hm6 : (6 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm.1 - nlinarith [sq_nonneg ((m : ℝ) - 6)] + linarith only [hm6, sq_nonneg ((m : ℝ) - 6)] _ = 95 * Real.exp (-36) := by simp [Finset.sum_const] -- Combine bounds have htail_bound : ∑ m ∈ (Finset.Icc 6 100 : Finset ℕ), Real.exp (-(m : ℝ) ^ 2) < - 95 / 10 ^ 14 := by linarith [exp_neg_36_lt] + 95 / 10 ^ 14 := by linarith only [htail, exp_neg_36_lt] have hsum_bound : Real.exp (-25) + ∑ m ∈ (Finset.Icc 6 100 : Finset ℕ), Real.exp (-(m : ℝ) ^ 2) < - 14 / 10 ^ 12 + 95 / 10 ^ 14 := by linarith [exp_neg_25_lt] + 14 / 10 ^ 12 + 95 / 10 ^ 14 := by linarith only [htail_bound, exp_neg_25_lt] have hsum_pos : 0 ≤ Real.exp (-25) + ∑ m ∈ (Finset.Icc 6 100 : Finset ℕ), Real.exp (-(m : ℝ) ^ 2) := @@ -1017,8 +1019,10 @@ theorem eta_5_bound : etaCoeff 5 100 < 4 / (10 : ℝ) ^ 11 := by have step1 : 2 * Real.exp (1 / 4) * (Real.exp (-25) + ∑ m ∈ (Finset.Icc 6 100 : Finset ℕ), Real.exp (-(m : ℝ) ^ 2)) < 2 * (13 / 10) * (14 / 10 ^ 12 + 95 / 10 ^ 14) := by - nlinarith [exp_quarter_lt, Real.exp_pos (1 / 4 : ℝ)] - linarith [show (2 : ℝ) * (13 / 10) * (14 / 10 ^ 12 + 95 / 10 ^ 14) < 4 / 10 ^ 11 - from by norm_num] + nlinarith only [hsum_bound, exp_quarter_lt, Real.exp_pos (1 / 4 : ℝ)] + linarith only [ + step1, + show (2 : ℝ) * (13 / 10) * (14 / 10 ^ 12 + 95 / 10 ^ 14) < 4 / 10 ^ 11 from by norm_num + ] end FockSPR diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/LipschitzRho.lean b/LeanPool/PhaseRetrieval/Constant/Internal/LipschitzRho.lean index 81b703b26e..7f79845e9f 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/LipschitzRho.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/LipschitzRho.lean @@ -64,13 +64,13 @@ theorem rho_lipschitz : LipschitzWith 1 rho := by theorem rho_pointwise_upper (w z : ℂ) : rho w ≤ rho z + ‖w - z‖ := by have h := rho_lipschitz.dist_le_mul w z rw [NNReal.coe_one, one_mul, Real.dist_eq, dist_eq_norm] at h - linarith [le_abs_self (rho w - rho z)] + linarith only [h, le_abs_self (rho w - rho z)] /-- `rho(w) ≥ rho(z) − ‖w − z‖` -/ theorem rho_pointwise_lower (w z : ℂ) : rho w ≥ rho z - ‖w - z‖ := by have h := rho_lipschitz.dist_le_mul w z rw [NNReal.coe_one, one_mul, Real.dist_eq, dist_eq_norm] at h - linarith [neg_abs_le (rho w - rho z)] + linarith only [h, neg_abs_le (rho w - rho z)] /-! ## Corollary 2.5: `rho(w) ≤ ‖w‖` diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/LocalCircleEstimate.lean b/LeanPool/PhaseRetrieval/Constant/Internal/LocalCircleEstimate.lean index 3c963eedf3..785fa20650 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/LocalCircleEstimate.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/LocalCircleEstimate.lean @@ -241,7 +241,7 @@ private lemma equal_l2_masses {L : ℕ} (_hL : 1 ≤ L) {E : Finset ℕ} Integrable (fun t => (P t).im ^ 2) AddCircle.haarAddCircle := by rw [hP]; exact (Complex.continuous_im.comp (P_continuous b)).pow 2 |>.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) - linarith [integral_sub h_re_int h_im_int ▸ h_re_zero] + linarith only [integral_sub h_re_int h_im_int ▸ h_re_zero] /-! ### Pointwise bound: rho(w)² ≥ w.re²/2 - ‖w‖⁴ -/ @@ -261,7 +261,7 @@ private lemma rho_sq_lower_bound (w : ℂ) (hw : ‖w‖ ≤ 1 / 4) : have hs_le : u ^ 2 + v ^ 2 ≤ 1 / 16 := by rw [← hw_sq] exact le_trans - (sq_le_sq' (by linarith [norm_nonneg w]) hw) (by norm_num) + (sq_le_sq' (by linarith only [norm_nonneg w]) hw) (by norm_num) set s := u ^ 2 + v ^ 2 have hA_sq : (2 + 2 * u + s - u ^ 2 / 2 + s ^ 2) ^ 2 ≥ @@ -321,8 +321,8 @@ private lemma integral_norm_pow4_le {P : AddCircle T → ℂ} (HasCompactSupport.of_compactSpace _)).const_mul _ · intro t have : ‖P t‖ ^ 2 ≤ M ^ 2 := - sq_le_sq' (by linarith [norm_nonneg (P t)]) (hM t) - nlinarith [sq_nonneg (‖P t‖)] + sq_le_sq' (by linarith only [_hM_nn, norm_nonneg (P t)]) (hM t) + nlinarith only [this, sq_nonneg (‖P t‖)] _ = M ^ 2 * ∫ t, ‖P t‖ ^ 2 ∂AddCircle.haarAddCircle := integral_const_mul _ _ @@ -376,7 +376,7 @@ private lemma small_amplitude {L : ℕ} (hL : 1 ≤ L) {E : Finset ℕ} simp_all have h_re_half : ∫ t : AddCircle T, (P t).re ^ 2 ∂AddCircle.haarAddCircle = - cns / 2 := by linarith + cns / 2 := by linarith only [h_re_eq_im, h_cns_split] -- Step 4: ∫ ‖P‖⁴ ≤ (1/4)² · cns have h_norm4 : ∫ t : AddCircle T, ‖P t‖ ^ 4 ∂AddCircle.haarAddCircle ≤ @@ -398,7 +398,7 @@ private lemma small_amplitude {L : ℕ} (hL : 1 ≤ L) {E : Finset ℕ} simp_rw [div_eq_mul_inv]; exact integral_mul_const 2⁻¹ _ rw [h_integral_sub, h_div, h_re_half] at h_lower -- cns/2/2 - ∫ ‖P‖⁴ ≥ cns/4 - cns/16 = 3cns/16 - linarith + linarith only [h_lower, h_norm4] /-! ### ∫ ‖1+P‖² = 1 + circleNormSq P -/ @@ -447,7 +447,7 @@ private lemma integral_one_plus_P_sq {E : Finset ℕ} · exact h_split · rw [integral_const_mul, h_re_P, mul_zero, add_zero] simp [integral_const] - unfold circleNormSq; linarith + unfold circleNormSq; linarith only [h_diff] /-! ### Integral Cauchy-Schwarz for real-valued functions -/ @@ -490,7 +490,7 @@ private lemma integral_cauchy_schwarz {α : Type*} [MeasurableSpace α] ext x; simp [Pi.add_apply]] exact integral_add (hf2.const_mul _) (hfg.const_mul _) rw [h_step1, h_step2, hI1, hI2]; ring - linarith + linarith only [h0, h_eq] -- Non-negative quadratic ⟹ discriminant ≤ 0 ⟹ B² ≤ AC -- Case A = 0: quad at t=1 gives 0 ≤ -2B+C, at t=-1 gives 0 ≤ 2B+C, so |B| ≤ C/2. -- Also A=0 ⟹ AC=0, need B²≤0, i.e. B=0. @@ -539,7 +539,7 @@ private lemma large_amplitude {L : ℕ} (hL : 1 ≤ L) {E : Finset ℕ} rw [← hsq] exact (sq_lt_sq₀ (by positivity) (Real.sqrt_nonneg _)).mpr hx rw [div_pow, one_pow, mul_pow, hsqL] at h_sq_ineq - linarith + linarith only [h_sq_ineq] -- Step 1: Pointwise identity rho(w)·(‖1+w‖+1) = |‖1+w‖²-1| have h_rho_factor : ∀ w : ℂ, rho w * (‖(1 : ℂ) + w‖ + 1) = |‖(1 : ℂ) + w‖ ^ 2 - 1| := by @@ -620,7 +620,10 @@ private lemma large_amplitude {L : ℕ} (hL : 1 ≤ L) {E : Finset ℕ} calc cns ^ 2 ≤ (∫ t : AddCircle T, rho (P t) * (‖(1 : ℂ) + P t‖ + 1) - ∂AddCircle.haarAddCircle) ^ 2 := sq_le_sq' (by nlinarith) h_cns_le + ∂AddCircle.haarAddCircle) ^ 2 := sq_le_sq' (by + linarith only [ + hcns_nn, h_cns_le + ]) h_cns_le _ ≤ y * ∫ t, (‖(1 : ℂ) + P t‖ + 1) ^ 2 ∂AddCircle.haarAddCircle := h_cs _ ≤ y * (2 * cns + 4) := mul_le_mul_of_nonneg_left h_g_sq_bound hy_nn -- Step 7: y ≥ cns / (144L) @@ -633,14 +636,14 @@ private lemma large_amplitude {L : ℕ} (hL : 1 ≤ L) {E : Finset ℕ} have hL_ge : (1 : ℝ) ≤ (↑L : ℝ) := Nat.one_le_cast.mpr hL have h_key : 2 * cns + 4 ≤ 144 * ↑L * cns := by -- (144L-2)·cns > (144L-2)/(16L) ≥ 142/16 > 4 - have h142 : (0 : ℝ) < 144 * ↑L - 2 := by nlinarith + have h142 : (0 : ℝ) < 144 * ↑L - 2 := by linarith only [hL_pos, hL_ge] have h1 : (144 * ↑L - 2) * cns > (144 * ↑L - 2) * (1 / (16 * ↑L)) := mul_lt_mul_of_pos_left h_cns_lower h142 have h2 : (144 * (↑L : ℝ) - 2) * (1 / (16 * ↑L)) ≥ 142 / 16 := by rw [ge_iff_le, mul_one_div, div_le_div_iff₀ (by norm_num : (0 : ℝ) < 16) (by positivity)] - nlinarith - nlinarith - nlinarith [sq_nonneg cns] + linarith only [hL_ge] + linarith only [h1, h2] + nlinarith only [hcns_nn, h_cns_sq_le, h_key, sq_nonneg cns] /-! ### Theorem 3.1 (Main statement) -/ diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/LocalCore.lean b/LeanPool/PhaseRetrieval/Constant/Internal/LocalCore.lean index 0aa5c3f5c9..c2f9a4a400 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/LocalCore.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/LocalCore.lean @@ -116,8 +116,7 @@ private lemma integral_polyEvalCircle_eq_zero {D : ℕ} (a : Fin D → ℂ) (r : ∫ t : AddCircle T, polyEvalCircle a r t ∂AddCircle.haarAddCircle = 0 := by unfold polyEvalCircle rw [integral_finsetSum _ (fun k _ => by - simpa only [Nat.cast_add, Nat.cast_one, fourier_apply, fourier_add', natCast_zsmul, - one_smul] using + exact (((fourier ((k.val + 1 : ℕ) : ℤ)) : C(AddCircle T, ℂ)).continuous.const_mul (a k * (r : ℂ) ^ (k.val + 1))).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _))] @@ -131,8 +130,8 @@ private lemma integral_polyEvalCircle_eq_zero {D : ℕ} (a : Fin D → ℂ) (r : = (a k * (r : ℂ) ^ (k.val + 1)) * ∫ t : AddCircle T, fourier ((k.val + 1 : ℕ) : ℤ) t ∂AddCircle.haarAddCircle := by - simpa only [Nat.cast_add, Nat.cast_one, fourier_apply, fourier_add', natCast_zsmul, - one_smul, mul_assoc] using integral_const_mul + exact + integral_const_mul (a k * (r : ℂ) ^ (k.val + 1)) (fun t : AddCircle T => (fourier ((k.val + 1 : ℕ) : ℤ) t : ℂ)) _ = 0 := by rw [integral_fourier_eq_zero _ hne, mul_zero] @@ -158,7 +157,7 @@ private lemma integral_re_polyEvalCircle_eq_zero {D : ℕ} (a : Fin D → ℂ) ( cont_integrable_circle (continuous_polyEvalCircle a r) have hre := integral_re (μ := AddCircle.haarAddCircle) (f := polyEvalCircle a r) hint rw [show (∫ t : AddCircle T, (polyEvalCircle a r t).re ∂AddCircle.haarAddCircle) = - (∫ t : AddCircle T, polyEvalCircle a r t ∂AddCircle.haarAddCircle).re by simpa using hre] + (∫ t : AddCircle T, polyEvalCircle a r t ∂AddCircle.haarAddCircle).re by exact hre] simp [integral_polyEvalCircle_eq_zero a r] private lemma integral_im_polyEvalCircle_eq_zero {D : ℕ} (a : Fin D → ℂ) (r : ℝ) : @@ -167,7 +166,7 @@ private lemma integral_im_polyEvalCircle_eq_zero {D : ℕ} (a : Fin D → ℂ) ( cont_integrable_circle (continuous_polyEvalCircle a r) have him := integral_im (μ := AddCircle.haarAddCircle) (f := polyEvalCircle a r) hint rw [show (∫ t : AddCircle T, (polyEvalCircle a r t).im ∂AddCircle.haarAddCircle) = - (∫ t : AddCircle T, polyEvalCircle a r t ∂AddCircle.haarAddCircle).im by simpa using him] + (∫ t : AddCircle T, polyEvalCircle a r t ∂AddCircle.haarAddCircle).im by exact him] simp [integral_polyEvalCircle_eq_zero a r] private lemma integral_const_add_polyEvalCircle_sq {D : ℕ} @@ -193,7 +192,7 @@ private lemma integral_const_add_polyEvalCircle_sq {D : ℕ} Complex.sq_norm, Complex.normSq_apply] have hc : c.re ^ 2 + c.im ^ 2 = ‖c‖ ^ 2 := by rw [Complex.sq_norm, Complex.normSq_apply] - ring_nf + ring linarith only [hc] have h_int3 : Integrable @@ -215,7 +214,7 @@ private lemma integral_const_add_polyEvalCircle_sq {D : ℕ} (fun t => ‖c‖ ^ 2 + 2 * c.re * (polyEvalCircle a r t).re + 2 * c.im * (polyEvalCircle a r t).im) := by - simp_all + simp_all only [] rw [h_congr] have h_split1 : ∫ t : AddCircle T, @@ -224,7 +223,7 @@ private lemma integral_const_add_polyEvalCircle_sq {D : ℕ} ∫ t : AddCircle T, (‖c‖ ^ 2 + 2 * c.re * (polyEvalCircle a r t).re) ∂AddCircle.haarAddCircle + ∫ t : AddCircle T, 2 * c.im * (polyEvalCircle a r t).im ∂AddCircle.haarAddCircle := by - simpa only [add_assoc, Function.comp_apply, Pi.add_apply] using + exact (integral_add ((real_cont_integrable_circle continuous_const).add (real_cont_integrable_circle ((Complex.continuous_re.comp hcont).const_mul (2 * c.re)))) @@ -234,14 +233,14 @@ private lemma integral_const_add_polyEvalCircle_sq {D : ℕ} ∂AddCircle.haarAddCircle = ∫ t : AddCircle T, ‖c‖ ^ 2 ∂AddCircle.haarAddCircle + ∫ t : AddCircle T, 2 * c.re * (polyEvalCircle a r t).re ∂AddCircle.haarAddCircle := by - simpa only [integral_const, probReal_univ, smul_eq_mul, one_mul, Function.comp_apply] using + exact (integral_add (real_cont_integrable_circle continuous_const) (real_cont_integrable_circle ((Complex.continuous_re.comp hcont).const_mul (2 * c.re)))) rw [h_split1, h_split2] rw [integral_const, integral_const_mul, integral_const_mul, integral_re_polyEvalCircle_eq_zero, integral_im_polyEvalCircle_eq_zero] simp - linarith + linarith only [h_diff] private lemma continuous_mk_addCircle : Continuous (fun θ : ℝ => (QuotientAddGroup.mk θ : AddCircle T)) := @@ -275,7 +274,7 @@ private lemma integrable_abs_pow_mul_exp_neg_sq (n : ℕ) : have : (fun r : ℝ => |r| ^ n * Real.exp (-r ^ 2)) = fun r => ‖r ^ n * Real.exp (-r ^ 2)‖ := by - simp_all only [norm_mul, norm_pow, norm_eq_abs, abs_exp] + simp only [norm_mul, norm_pow, norm_eq_abs, abs_exp] rw [this] exact (integrable_pow_mul_exp_neg_sq n).norm @@ -429,18 +428,18 @@ private lemma integrableOn_polar_norm {D : ℕ} (a : Fin D → ℂ) : by_cases hD : D = 0 · subst hD simp - nlinarith [sq_nonneg C, pow_nonneg (le_of_lt hr) 3] + nlinarith only [hr, sq_nonneg C, pow_nonneg (le_of_lt hr) 3] · have hD_pos : 0 < D := Nat.pos_of_ne_zero hD have hr_nn := (le_of_lt hr) have hpow_le : ∀ k : Fin D, r ^ k.val ≤ 1 + r ^ (D - 1) := by intro k by_cases hr1 : r ≤ 1 · have : r ^ k.val ≤ 1 := pow_le_one₀ (n := k.val) hr_nn hr1 - linarith [pow_nonneg hr_nn (D - 1)] + linarith only [hr_nn, this, pow_nonneg hr_nn (D - 1)] · push Not at hr1 have : r ^ k.val ≤ r ^ (D - 1) := pow_le_pow_right₀ hr1.le (by omega : k.val ≤ D - 1) - linarith + linarith only [this] have hsum_le : ∑ x : Fin D, r ^ x.val * ‖a x‖ ≤ (1 + r ^ (D - 1)) * C := by calc ∑ x, r ^ x.val * ‖a x‖ @@ -455,10 +454,10 @@ private lemma integrableOn_polar_norm {D : ℕ} (a : Fin D → ℂ) : Finset.sum_nonneg (fun k _ => mul_nonneg (pow_nonneg hr_nn k.val) (norm_nonneg _)) have hfact_nn : 0 ≤ (1 + r ^ (D - 1)) * C := - mul_nonneg (by linarith [pow_nonneg hr_nn (D - 1)]) hC_nn + mul_nonneg (by linarith only [hr_nn, pow_nonneg hr_nn (D - 1)]) hC_nn have hsq : (∑ x : Fin D, r ^ x.val * ‖a x‖) ^ 2 ≤ ((1 + r ^ (D - 1)) * C) ^ 2 := - sq_le_sq' (by linarith) hsum_le + sq_le_sq' (by linarith only [hsum_le, hsum_nn]) hsum_le have hsq2 : ((1 + r ^ (D - 1)) * C) ^ 2 ≤ 2 * (1 + (r ^ (D - 1)) ^ 2) * C ^ 2 := by nlinarith only [sq_nonneg (1 - r ^ (D - 1))] @@ -526,7 +525,7 @@ private lemma gaussian_integral_normalized : private lemma norm_add_sq_le (a b : ℂ) : ‖a + b‖ ^ 2 ≤ 2 * ‖a‖ ^ 2 + 2 * ‖b‖ ^ 2 := by have h := parallelogram_law_with_norm ℂ a b - nlinarith [sq_abs (‖a + b‖), sq_abs (‖a - b‖), sq_abs (‖a‖), sq_abs (‖b‖)] + nlinarith only [h, sq_abs (‖a + b‖), sq_abs (‖a - b‖), sq_abs (‖a‖), sq_abs (‖b‖)] private lemma integral_cauchy_schwarz {α : Type*} [MeasurableSpace α] {μ : MeasureTheory.Measure α} @@ -564,7 +563,7 @@ private lemma integral_cauchy_schwarz {α : Type*} [MeasurableSpace α] exact integral_add (hf2.const_mul _) (hfg.const_mul _) rw [h_step1, h_step2, hI1, hI2] ring - linarith + linarith only [h0, h_eq] by_cases hA_zero : A = 0 · have hf_ae : ∀ᵐ x ∂μ, f x = 0 := by have := (integral_eq_zero_iff_of_nonneg (fun x => sq_nonneg (f x)) hf2).mp hA_zero @@ -720,7 +719,7 @@ private lemma radial_gaussian_integral (n : ℕ) : 2 * ∫ r in Set.Ioi (0 : ℝ), r ^ (2 * n + 1) * Real.exp (-r ^ 2) = (n.factorial : ℝ) := by have hp : (0 : ℝ) < 2 := two_pos - have hq : (-1 : ℝ) < (2 * (n : ℝ) + 1) := by linarith [Nat.cast_nonneg (α := ℝ) n] + have hq : (-1 : ℝ) < (2 * (n : ℝ) + 1) := by linarith only [Nat.cast_nonneg (α := ℝ) n] have pow_eq : ∀ (r : ℝ), r ∈ Set.Ioi (0 : ℝ) → r ^ (2 * n + 1) * Real.exp (-r ^ 2) = r ^ (2 * (n : ℝ) + 1) * Real.exp (-r ^ (2 : ℝ)) := by @@ -933,7 +932,7 @@ lemma gaussian_integral_const_add_polyEval {D : ℕ} (a : Fin D → ℂ) (c : rw [integral_const_mul] ring _ = 2 * (∫ r in Set.Ioi (0 : ℝ), r * Real.exp (-r ^ 2) ∂volume) * ‖c‖ ^ 2 := by rw [hT_eq] - _ = ‖c‖ ^ 2 := by nlinarith + _ = ‖c‖ ^ 2 := by nlinarith only [hrad] have hsecond_eval : (1 / Real.pi) * ∫ r in Set.Ioi (0 : ℝ), second r = fockNormSq a := by unfold second @@ -1051,7 +1050,7 @@ private lemma integrable_gaussianWeight : simp [gaussianWeight, polyEval] private lemma gaussianMeasure_isFinite : IsFiniteMeasure gaussianMeasure := by - simpa only [gaussianMeasure, gaussianWeight, one_div] using + exact (MeasureTheory.isFiniteMeasure_withDensity_ofReal (μ := (volume : Measure ℂ)) integrable_gaussianWeight.hasFiniteIntegral) @@ -1104,7 +1103,7 @@ private lemma integrable_sq_gaussianMeasure_real_const_add_polyEval {D : ℕ} positivity rw [show (ENNReal.ofReal (gaussianWeight z)).toReal = gaussianWeight z by simp [hgw]] simp [gaussianWeight, smul_eq_mul] - ring_nf + ring private lemma integrable_sq_gaussianMeasure_rho_real_const_add_polyEval {D : ℕ} (a : Fin D → ℂ) (u : ℝ) : @@ -1119,7 +1118,7 @@ private lemma integrable_sq_gaussianMeasure_rho_real_const_add_polyEval {D : ℕ have hle := rho_le_norm ((u : ℂ) + polyEval a z) have hrho_nonneg : 0 ≤ rho ((u : ℂ) + polyEval a z) := abs_nonneg _ have hnorm_nonneg : 0 ≤ ‖(u : ℂ) + polyEval a z‖ := norm_nonneg _ - nlinarith + nlinarith only [hle, hrho_nonneg] private lemma integrable_sq_gaussianMeasure_norm_add_one_real_const_add_polyEval {D : ℕ} (a : Fin D → ℂ) (u : ℝ) : @@ -1148,7 +1147,7 @@ private lemma integrable_sq_gaussianMeasure_norm_add_one_real_const_add_polyEval (2 + ‖(u : ℂ) + polyEval a z‖) ^ 2 := by have hnn1 : 0 ≤ ‖(1 : ℂ) + ((u : ℂ) + polyEval a z)‖ + 1 := by positivity have hnn2 : 0 ≤ 2 + ‖(u : ℂ) + polyEval a z‖ := by positivity - nlinarith + nlinarith only [htri, hnn1] exact le_trans htri_sq hsq private lemma integrable_of_sq_gaussian {f : ℂ → ℝ} @@ -1214,7 +1213,7 @@ private lemma rho_const_add_le (u : ℝ) (w : ℂ) : |‖(1 : ℂ) + w‖ - 1| ≤ |‖(1 : ℂ) + w‖ - ‖(1 : ℂ) + ((u : ℂ) + w)‖| + |‖(1 : ℂ) + ((u : ℂ) + w)‖ - 1| := by - simpa using abs_sub_le ‖(1 : ℂ) + w‖ ‖(1 : ℂ) + ((u : ℂ) + w)‖ 1 + exact abs_sub_le ‖(1 : ℂ) + w‖ ‖(1 : ℂ) + ((u : ℂ) + w)‖ 1 exact le_trans htri (add_le_add hnorm le_rfl) /-- The Gaussian integral of `(rho ∘ q.eval)²` is bounded by `(|u| + m)²`, where diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/LocalHelpers.lean b/LeanPool/PhaseRetrieval/Constant/Internal/LocalHelpers.lean index ab2b536c05..08d77aacfb 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/LocalHelpers.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/LocalHelpers.lean @@ -156,9 +156,9 @@ theorem LocalFockSPR_of_small_norm_exists_phase have hnorm : ‖w0 - lam0‖ ≤ ‖w0 - 1‖ := by simpa [lam0] using norm_sub_phaseAnchor_le w0 1 (by simp) have hsq : ‖w0 - lam0‖ ^ 2 ≤ ‖w0 - 1‖ ^ 2 := by - nlinarith [hnorm, norm_nonneg (w0 - lam0), norm_nonneg (w0 - 1)] + nlinarith only [hnorm, norm_nonneg (w0 - lam0), norm_nonneg (w0 - 1)] rw [phaseDistanceSqNorm_eq_centered, phaseDistanceSqNorm_eq_centered] - nlinarith + linarith only [hsq] have hsmall0 : phaseDistanceSqNorm p lam0 ≤ (1 / 4601 : ℝ) ^ 2 := le_trans (le_trans hphase_le_one (by rw [phaseDistanceSqNorm_one_eq])) hsmall let q : Polynomial ℂ := diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/MainTheorem.lean b/LeanPool/PhaseRetrieval/Constant/Internal/MainTheorem.lean index eece804a7a..80d0ae53dd 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/MainTheorem.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/MainTheorem.lean @@ -39,7 +39,7 @@ namespace FockSPR private lemma norm_add_sq_le (a b : ℂ) : ‖a + b‖ ^ 2 ≤ 2 * ‖a‖ ^ 2 + 2 * ‖b‖ ^ 2 := by have h := parallelogram_law_with_norm ℂ a b - nlinarith [sq_abs (‖a + b‖), sq_abs (‖a - b‖), sq_abs (‖a‖), sq_abs (‖b‖)] + nlinarith only [h, sq_abs (‖a + b‖), sq_abs (‖a - b‖), sq_abs (‖a‖), sq_abs (‖b‖)] /-! ## Private Lemma 7.1c: Final constant check -/ private lemma final_constant_check : 8 * 1620 ^ 2 ≤ 4600 ^ 2 := by norm_num @@ -71,7 +71,7 @@ private lemma radial_gaussian_integral (n : ℕ) : 2 * ∫ r in Set.Ioi (0 : ℝ), r ^ (2 * n + 1) * Real.exp (-r ^ 2) = (n.factorial : ℝ) := by have hp : (0 : ℝ) < 2 := two_pos - have hq : (-1 : ℝ) < (2 * (n : ℝ) + 1) := by linarith [Nat.cast_nonneg (α := ℝ) n] + have hq : (-1 : ℝ) < (2 * (n : ℝ) + 1) := by linarith only [Nat.cast_nonneg (α := ℝ) n] have pow_eq : ∀ (r : ℝ), r ∈ Set.Ioi (0 : ℝ) → r ^ (2 * n + 1) * Real.exp (-r ^ 2) = r ^ (2 * (n : ℝ) + 1) * Real.exp (-r ^ (2 : ℝ)) := by @@ -179,7 +179,7 @@ private lemma fourier_pow_eq (n : ℕ) (t : AddCircle T) : ((fourier 1 t : ℂ)) ^ n = (fourier (↑n : ℤ) t : ℂ) := by induction n with | zero => simp - | succ n ih => rw [pow_succ, ih, ← fourier_add]; push_cast; ring_nf + | succ n ih => rw [pow_succ, ih, ← fourier_add]; push_cast; ring private lemma polyEvalCircle_eq_polyEval {D : ℕ} (a : Fin D → ℂ) (r : ℝ) (t : AddCircle T) : @@ -293,7 +293,7 @@ private lemma circle_level_bound {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) from rfl] rw [integral_add (hiV.const_mul _) (hiR.const_mul _), integral_const_mul, integral_const_mul] - linarith + linarith only [h1, h2] have h_annulus := annulus_local_estimate hD a j hr_nn hr_lo hr_hi have h_rho_pw : ∀ t, (rho (V t)) ^ 2 ≤ 2 * (rho (U t)) ^ 2 + 2 * ‖R t‖ ^ 2 := by @@ -306,8 +306,9 @@ private lemma circle_level_bound {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) have h_nn : 0 ≤ rho (V t) := abs_nonneg _ have h_nn2 : 0 ≤ rho (U t) := abs_nonneg _ have h_nn3 : 0 ≤ ‖R t‖ := norm_nonneg _ - nlinarith [sq_nonneg (rho (V t) - (rho (U t) + ‖R t‖)), - sq_nonneg (rho (U t) - ‖R t‖)] + nlinarith only [ + h_lip, h_nn, sq_nonneg (rho (V t) - (rho (U t) + ‖R t‖)), sq_nonneg (rho (U t) - ‖R t‖) + ] have h_rho_sq : ∫ t, (rho (V t)) ^ 2 ∂AddCircle.haarAddCircle ≤ 2 * ∫ t, (rho (U t)) ^ 2 ∂AddCircle.haarAddCircle + 2 * ∫ t, ‖R t‖ ^ 2 ∂AddCircle.haarAddCircle := by @@ -320,7 +321,7 @@ private lemma circle_level_bound {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) (2 : ℝ) * (fun t => ‖R t‖ ^ 2) t) from rfl] rw [integral_add (hiRhoU.const_mul _) (hiR.const_mul _), integral_const_mul, integral_const_mul] - linarith + linarith only [h1, h2] have h_ann : ∫ t, ‖V t‖ ^ 2 ∂AddCircle.haarAddCircle ≤ 1620 ^ 2 * ∫ t, (rho (V t)) ^ 2 ∂AddCircle.haarAddCircle := h_annulus have h_rho_nn : 0 ≤ ∫ t, (rho (V t)) ^ 2 ∂AddCircle.haarAddCircle := @@ -334,7 +335,7 @@ private lemma circle_level_bound {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) change ∫ t, ‖U t‖ ^ 2 ∂AddCircle.haarAddCircle ≤ 4 * 1620 ^ 2 * ∫ t, (rho (U t)) ^ 2 ∂AddCircle.haarAddCircle + (4 * 1620 ^ 2 + 2) * ∫ t, ‖R t‖ ^ 2 ∂AddCircle.haarAddCircle - nlinarith [h_norm_add, h_ann, h_rho_sq, h_rho_nn, h_rhoU_nn, h_R_nn, h_V_nn] + linarith only [h_norm_add, h_rho_sq, h_ann, h_rho_nn, h_rhoU_nn, h_R_nn, h_V_nn] /-! ## Annular decomposition infrastructure -/ @@ -342,7 +343,7 @@ private lemma annular_summand_nonneg (j : ℕ) {g : ℝ → ℝ} (hg : ∀ r, r ∈ Set.Icc (j : ℝ) ((j : ℝ) + 1) → 0 ≤ g r) : 0 ≤ 2 * ∫ r in (j : ℝ)..(j + 1 : ℝ), r * Real.exp (-r ^ 2) * g r := by apply mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) - apply intervalIntegral.integral_nonneg (by linarith [Nat.cast_nonneg (α := ℝ) j]) + apply intervalIntegral.integral_nonneg (by linarith only [Nat.cast_nonneg (α := ℝ) j]) intro r hr exact mul_nonneg (mul_nonneg (le_trans (Nat.cast_nonneg (α := ℝ) j) hr.1) (le_of_lt (Real.exp_pos _))) (hg r hr) @@ -489,7 +490,7 @@ private lemma fockNormSq_sup_annular {D : ℕ} (a : Fin D → ℂ) : -- fockNormSq a = 2 * ∫_{Ioi 0} f have h_eq : fockNormSq a = 2 * ∫ r in Set.Ioi (0 : ℝ), f r := fockNormSq_polar a -- Extract: for ε/2 > 0, ∃ N ∈ ℕ with ∫_0^N f > ∫_{Ioi} f - ε/2 - have h_half : 0 < ε / 2 := by linarith + have h_half : 0 < ε / 2 := by linarith only [hε] -- Use `Metric.tendsto_atTop` to extract a witness rw [Metric.tendsto_atTop] at h_tends obtain ⟨N, hN⟩ := h_tends (ε / 2) h_half @@ -508,12 +509,12 @@ private lemma fockNormSq_sup_annular {D : ℕ} (a : Fin D → ℂ) : -- So ∫_{Ioi} f - ε/2 < ∫_0^J f set I := ∫ r in Set.Ioi (0 : ℝ), f r set S := ∫ r in (0 : ℝ)..(J : ℝ), f r - have h_close : I - ε / 2 < S := by linarith [h_abs.1] + have h_close : I - ε / 2 < S := by linarith only [h_abs.1] -- Goal: fockNormSq a - ε < ∑_{j w r * h r) volume (j : ℝ) ((j : ℝ) + 1) := (hw_cont.mul hh_cont).intervalIntegrable _ _ -- Integral bound: ∫ w*f ≤ ∫ w*(C₁*g + C₂*h) = C₁ * ∫ w*g + C₂ * ∫ w*h - have hj_le : (j : ℝ) ≤ (j : ℝ) + 1 := by linarith + have hj_le : (j : ℝ) ≤ (j : ℝ) + 1 := by linarith only [] have h_int_le : ∫ r in (j : ℝ)..(j + 1 : ℝ), w r * f r ≤ C₁ * (∫ r in (j : ℝ)..(j + 1 : ℝ), w r * g r) + C₂ * (∫ r in (j : ℝ)..(j + 1 : ℝ), w r * h r) := by @@ -628,7 +629,7 @@ private lemma annular_circle_bound {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) change 2 * ∫ r in (j : ℝ)..(j + 1 : ℝ), w r * f r ≤ C₁ * (2 * ∫ r in (j : ℝ)..(j + 1 : ℝ), w r * g r) + C₂ * (2 * ∫ r in (j : ℝ)..(j + 1 : ℝ), w r * h r) - nlinarith [h_int_le] + linarith only [h_int_le] /-! ## Pre-absorption inequality @@ -647,7 +648,7 @@ private lemma etaCoeff_5_universal (J : ℕ) : etaCoeff 5 J < 4 / (10 : ℝ) ^ 1 set r := Real.exp (-5) with hr_def have hr_pos : 0 < r := Real.exp_pos _ have hr_lt : r < 1 := Real.exp_lt_one_iff.mpr (by norm_num : (-5:ℝ) < 0) - have h1r : 0 < 1 - r := by linarith + have h1r : 0 < 1 - r := by linarith only [hr_lt] -- exp(5) ≥ 148 (from 13-term Taylor series) have hexp5 : (148 : ℝ) ≤ Real.exp 5 := le_trans (by norm_num) (Real.sum_le_exp_of_nonneg (by norm_num : (0:ℝ) ≤ 5) 13) @@ -657,7 +658,7 @@ private lemma etaCoeff_5_universal (J : ℕ) : etaCoeff 5 J < 4 / (10 : ℝ) ^ 1 calc 148 * r = 148 * Real.exp (-5) := by rw [hr_def] _ ≤ Real.exp 5 * Real.exp (-5) := by gcongr _ = 1 := by rw [← Real.exp_add]; simp - linarith + linarith only [this] -- exp(1/4) ≤ 13/10 (from Taylor + error bound) have hexp14 : Real.exp (1 / 4 : ℝ) ≤ 13 / 10 := (Real.exp_bound' (by norm_num) (by norm_num) (by norm_num : (0:ℕ) < 4)).trans (by norm_num) @@ -666,15 +667,18 @@ private lemma etaCoeff_5_universal (J : ℕ) : etaCoeff 5 J < 4 / (10 : ℝ) ^ 1 intro m hm; simp only [Finset.mem_Icc] at hm rw [hr_def, ← Real.exp_nat_mul]; apply Real.exp_le_exp.mpr have hm5 : (5 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm.1 - have hm0 : (0 : ℝ) ≤ (m : ℝ) := by linarith + have hm0 : (0 : ℝ) ≤ (m : ℝ) := by linarith only [hr_pos, hr_le, hm5] -- Need: -(m:ℝ)² ≤ ↑m * (-5), i.e., 5*m ≤ m² (since m ≥ 5) - nlinarith [mul_self_nonneg ((m : ℝ) - 5)] + linarith only [hm5, mul_self_nonneg ((m : ℝ) - 5)] -- Step 2: Geometric series ∑_{m ∈ Icc 5 J} r^m ≤ r^5/(1-r) have h_geom : ∑ m ∈ Finset.Icc 5 J, r ^ m ≤ r ^ 5 / (1 - r) := by rw [show Finset.Icc 5 J = Finset.Ico 5 (J + 1) from by ext m; simp [Finset.mem_Icc, Finset.mem_Ico]] rw [geom_sum_Ico' (ne_of_lt hr_lt) (by omega : (5:ℕ) ≤ J + 1)] - exact div_le_div_of_nonneg_right (by linarith [pow_pos hr_pos (J + 1)]) (le_of_lt h1r) + exact div_le_div_of_nonneg_right (by + linarith only [ + hr_pos, pow_pos hr_pos (J + 1) + ]) (le_of_lt h1r) -- Step 3: Combine all bounds have h1 : ∑ m ∈ Finset.Icc 5 J, Real.exp (-(m : ℝ) ^ 2) ≤ r ^ 5 / (1 - r) := le_trans (Finset.sum_le_sum h_pw) h_geom @@ -698,7 +702,7 @@ private lemma pre_absorption {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) : -- Get bound from total_leakage_bound obtain ⟨bound, hbound⟩ := total_leakage_bound a (show (2 : ℕ) ≤ 5 by omega) ε' hε'_pos -- Get J₀ from fockNormSq_sup_annular - obtain ⟨J₀, hJ₀⟩ := fockNormSq_sup_annular a (δ / 2) (by linarith) + obtain ⟨J₀, hJ₀⟩ := fockNormSq_sup_annular a (δ / 2) (by linarith only [hδ]) -- Use J = max J₀ bound set J := max J₀ bound with hJ_def -- S_fock(J) ≥ S_fock(J₀) > fockNormSq - δ/2 (monotonicity: more nonneg terms) @@ -724,7 +728,7 @@ private lemma pre_absorption {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) : (∫ t : AddCircle T, ‖remainderPoly a 5 j (↑r * (fourier 1 t : ℂ))‖ ^ 2 ∂AddCircle.haarAddCircle) - have h1 : fockNormSq a < S_fock + δ / 2 := by linarith [hJ₀, h_mono_fock] + have h1 : fockNormSq a < S_fock + δ / 2 := by linarith only [hJ₀, h_mono_fock] have h2 : S_fock ≤ 4 * 1620 ^ 2 * S_rho + C * S_leak := annular_circle_bound hD a J have h3 : S_rho ≤ rhoFockNormSq a := annular_rho_partial_le a J -- Apply total_leakage_bound at J (since J ≥ bound) @@ -734,10 +738,10 @@ private lemma pre_absorption {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) : intro M J₁ J₂ hle; unfold etaCoeff; gcongr -- Bound C * ε' * fockNormSq < δ / 4 have h_eps_bound : C * ε' * fockNormSq a < δ / 4 := by - have hfock1 : (0 : ℝ) < fockNormSq a + 1 := by linarith + have hfock1 : (0 : ℝ) < fockNormSq a + 1 := by linarith only [hfock_nn] calc C * ε' * fockNormSq a ≤ C * (δ / (4 * C * (fockNormSq a + 1))) * fockNormSq a := by gcongr; exact min_le_left _ _ - _ < C * (δ / (4 * C * (fockNormSq a + 1))) * (fockNormSq a + 1) := by gcongr; linarith + _ < C * (δ / (4 * C * (fockNormSq a + 1))) * (fockNormSq a + 1) := by gcongr; linarith only [] _ = δ / 4 := by field_simp -- Chain: fockNormSq < 4B²R + C*(eta_J + ε')*F + δ/2 have h_chain : fockNormSq a < 4 * 1620 ^ 2 * rhoFockNormSq a + @@ -746,7 +750,7 @@ private lemma pre_absorption {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) : C * ((etaCoeff 5 J + ε') * fockNormSq a) := by calc S_fock ≤ 4 * 1620 ^ 2 * S_rho + C * S_leak := h2 _ ≤ 4 * 1620 ^ 2 * rhoFockNormSq a + C * ((etaCoeff 5 J + ε') * fockNormSq a) := by gcongr - nlinarith + linarith only [hJ₀, h_mono_fock, h2, h3, h4] -- Universal eta bound: C*eta_J < 1/4 (much tighter than < 1/2) have h_C_eta_tight : C * etaCoeff 5 J < 1 / 4 := calc C * etaCoeff 5 J < C * (4 / (10 : ℝ) ^ 11) := @@ -760,18 +764,21 @@ private lemma pre_absorption {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) : -- Therefore C*(eta_J + ε') < 1/4 + 1/4 = 1/2 have h_absorb : C * (etaCoeff 5 J + ε') < 1 / 2 := by calc C * (etaCoeff 5 J + ε') = C * etaCoeff 5 J + C * ε' := by ring - _ < 1 / 4 + 1 / 4 := by linarith + _ < 1 / 4 + 1 / 4 := by linarith only [h_C_eta_tight, h_C_eps] _ = 1 / 2 := by norm_num -- Absorption: F*(1 - η) < 4B²R + δ/2 with η < 1/2, so F < 8B²R + δ change fockNormSq a < 8 * 1620 ^ 2 * rhoFockNormSq a + δ - nlinarith [h_chain, h_absorb, hfock_nn, hrho_nn] + nlinarith only [h_chain, h_absorb, hfock_nn, hrho_nn] theorem fock_space_coercivity {D : ℕ} (hD : 1 ≤ D) (a : Fin D → ℂ) : fockNormSq a ≤ 4600 ^ 2 * rhoFockNormSq a := by have hpre := pre_absorption hD a calc fockNormSq a ≤ 8 * 1620 ^ 2 * rhoFockNormSq a := hpre - _ ≤ 4600 ^ 2 * rhoFockNormSq a := by nlinarith [final_constant_check, rhoFockNormSq_nonneg a] + _ ≤ 4600 ^ 2 * rhoFockNormSq a := by + linarith only [ + final_constant_check, rhoFockNormSq_nonneg a + ] /-- Fock-space coercivity for complex polynomials with zero constant term. -/ theorem LocalFockSPR diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/MissingMathlib/Poincare.lean b/LeanPool/PhaseRetrieval/Constant/Internal/MissingMathlib/Poincare.lean index 0b9ea8ba09..e8606de242 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/MissingMathlib/Poincare.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/MissingMathlib/Poincare.lean @@ -162,7 +162,7 @@ private lemma cauchy_schwarz_interval {a b : ℝ} (hab : a ≤ b) {g : ℝ → rw [h_int_eq]; ring rw [hexpand, hint_linear] at hvar -- Now hvar: 0 ≤ ∫g² + (-c²(b-a)) = ∫g² - c²(b-a) - have h_ineq : c ^ 2 * (b - a) ≤ ∫ t in a..b, g t ^ 2 := by linarith + have h_ineq : c ^ 2 * (b - a) ≤ ∫ t in a..b, g t ^ 2 := by linarith only [hvar] -- And S² = c²·(b-a)², so S² ≤ (b-a)·∫g² calc S ^ 2 = (c * (b - a)) ^ 2 := by rw [hcba] _ = c ^ 2 * (b - a) * (b - a) := by ring @@ -188,7 +188,8 @@ theorem poincare_interval {h : ℝ} (hh : 0 < h) {f f' : ℝ → ℂ} have hpw : ∀ x ∈ Icc 0 h, ‖f x - f_bar‖ ^ 2 ≤ M ^ 2 := by intro x hx apply sq_le_sq' - · linarith [norm_nonneg (f x - f_bar), pointwise_bound hh hf hf_cont hf'_cont hx] + · linarith only [hh, hf, hf_cont, hf'_cont, hx, norm_nonneg (f x - f_bar), + pointwise_bound hh hf hf_cont hf'_cont hx] · exact pointwise_bound hh hf hf_cont hf'_cont hx -- Step 2: ∫₀ʰ ‖f x - f_bar‖² dx ≤ ∫₀ʰ M² dx = h * M² have hint_bound : ∫ x in (0 : ℝ)..h, ‖f x - f_bar‖ ^ 2 ≤ h * M ^ 2 := by diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/RotationalAveraging.lean b/LeanPool/PhaseRetrieval/Constant/Internal/RotationalAveraging.lean index f4e66eb9e4..44fa995724 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/RotationalAveraging.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/RotationalAveraging.lean @@ -40,14 +40,14 @@ private lemma normSq_one_add (r θ : ℝ) : Complex.ofReal_re, Complex.exp_mul_I, Complex.add_im, Complex.one_im, Complex.mul_im, Complex.ofReal_im, Complex.cos_ofReal_re, Complex.cos_ofReal_im, Complex.sin_ofReal_re, Complex.sin_ofReal_im, Complex.I_re, Complex.I_im] - nlinarith [Real.sin_sq_add_cos_sq θ] + nlinarith only [Real.sin_sq_add_cos_sq θ] /-- `cos(θ) ≥ √2/2` whenever `|θ| ≤ π/4`. -/ private lemma cos_ge_sqrt2_div2 {θ : ℝ} (hθ : |θ| ≤ Real.pi / 4) : Real.cos θ ≥ Real.sqrt 2 / 2 := by rw [ge_iff_le, ← Real.cos_pi_div_four, ← Real.cos_abs θ] exact Real.cos_le_cos_of_nonneg_of_le_pi (abs_nonneg θ) - (by linarith [Real.pi_pos]) hθ + (by linarith only [Real.pi_pos]) hθ /-- `‖1 + r exp(iθ)‖ ≥ 1` for `r ≥ 0` and `|θ| ≤ π/4`. -/ private lemma norm_one_add_ge_one {r : ℝ} (hr : 0 ≤ r) {θ : ℝ} @@ -55,11 +55,11 @@ private lemma norm_one_add_ge_one {r : ℝ} (hr : 0 ≤ r) {θ : ℝ} ‖(1 : ℂ) + ↑r * Complex.exp (Complex.I * ↑θ)‖ ≥ 1 := by rw [ge_iff_le, ← Real.sqrt_one, ← Real.sqrt_sq (norm_nonneg _)] exact Real.sqrt_le_sqrt - (by rw [normSq_one_add]; nlinarith [cos_ge_sqrt2_div2 hθ, Real.sqrt_nonneg 2]) + (by rw [normSq_one_add]; nlinarith only [hr, hθ, cos_ge_sqrt2_div2 hθ, Real.sqrt_nonneg 2]) /-- When `‖1 + w‖ ≥ 1`, `rho(w) = ‖1 + w‖ − 1`. -/ private lemma rho_eq_norm_sub {w : ℂ} (hw : ‖(1 : ℂ) + w‖ ≥ 1) : - rho w = ‖(1 : ℂ) + w‖ - 1 := by simp only [rho]; rw [abs_of_nonneg]; linarith + rho w = ‖(1 : ℂ) + w‖ - 1 := by simp only [rho]; rw [abs_of_nonneg]; linarith only [hw] /-- `‖r * exp(iθ)‖ = r` for `r ≥ 0`. -/ private lemma norm_r_exp (r θ : ℝ) (hr : 0 ≤ r) : @@ -92,14 +92,14 @@ private lemma rho_arc_lower_bound {r : ℝ} (hr : 0 ≤ r) {θ : ℝ} (hθ : |θ calc ‖(1 : ℂ) + w‖ ≤ ‖(1 : ℂ)‖ + ‖w‖ := norm_add_le _ _ _ = 1 + r := by rw [norm_one, norm_r_exp r θ hr] have hcos : Real.cos θ ≥ Real.sqrt 2 / 2 := cos_ge_sqrt2_div2 hθ - have h1 : 0 ≤ a - 1 := by linarith + have h1 : 0 ≤ a - 1 := by linarith only [ha1] have h2 : (a - 1) * (r + 2) ≥ r * (r + Real.sqrt 2) := by - have hprod : (a - 1) * (a + 1) = r ^ 2 + 2 * r * Real.cos θ := by nlinarith - nlinarith [Real.sqrt_nonneg 2] + have hprod : (a - 1) * (a + 1) = r ^ 2 + 2 * r * Real.cos θ := by linarith only [hsq] + nlinarith only [hr, ha1, hsq, ha_le, hcos, Real.sqrt_nonneg 2] rw [ge_iff_le, div_le_iff₀ (by positivity : (0 : ℝ) < Real.sqrt 2)] - nlinarith [mul_nonneg h1 (Real.sqrt_nonneg 2), mul_nonneg hr (Real.sqrt_nonneg 2), - mul_nonneg hr h1, sq_nonneg (a - 1 - r / Real.sqrt 2), - Real.sq_sqrt (show (2 : ℝ) ≥ 0 by norm_num), Real.sqrt_nonneg 2] + nlinarith only [hr, hsq, ha_le, hcos, h1, mul_nonneg h1 (Real.sqrt_nonneg 2), + mul_nonneg hr (Real.sqrt_nonneg 2), mul_nonneg hr h1, sq_nonneg (a - 1 - r / Real.sqrt 2), + Real.sq_sqrt (show (2 : ℝ) ≥ 0 by norm_num), Real.sqrt_nonneg 2] /-! ### Auxiliary lemmas for the integral bound -/ @@ -164,7 +164,7 @@ theorem rotational_averaging_bound {r : ℝ} (hr : 0 ≤ r) : (rho_arc_lower_bound hr habs).le 2) ((integrand_continuous r).continuousOn.integrableOn_compact isCompact_Icc) rwa [Measure.real, Real.volume_Icc, - ENNReal.toReal_ofReal (by linarith [Real.pi_pos]), + ENNReal.toReal_ofReal (by linarith only [Real.pi_pos]), show Real.pi / 4 - -(Real.pi / 4) = Real.pi / 2 from by ring] at h1 -- Icc integral ≤ Ioc integral (integrand ≥ 0) have h_mono : @@ -175,8 +175,8 @@ theorem rotational_averaging_bound {r : ℝ} (hr : 0 ≤ r) : isCompact_Icc).mono_set Set.Ioc_subset_Icc_self · exact ae_of_all _ fun θ => by positivity · exact ae_of_all _ fun θ hθ => - ⟨by linarith [hθ.1, Real.pi_pos], - by linarith [hθ.2, Real.pi_pos]⟩ + ⟨by linarith only [hθ.1, Real.pi_pos], + by linarith only [hθ.2, Real.pi_pos]⟩ -- Combine with T⁻¹ factor rw [smul_eq_mul] calc r ^ 2 / 8 diff --git a/LeanPool/PhaseRetrieval/Constant/Internal/SafeSquare.lean b/LeanPool/PhaseRetrieval/Constant/Internal/SafeSquare.lean index 0ede6cc593..fb4d260951 100644 --- a/LeanPool/PhaseRetrieval/Constant/Internal/SafeSquare.lean +++ b/LeanPool/PhaseRetrieval/Constant/Internal/SafeSquare.lean @@ -37,7 +37,7 @@ For all `a, b : ℝ`: `(a + b)² ≥ (1/2) a² − b²`. **Proof**: `(a + b)² − (1/2)a² + b² = (1/2)(a + 2b)² ≥ 0`. -/ theorem safe_square (a b : ℝ) : (a + b) ^ 2 ≥ (1 / 2) * a ^ 2 - b ^ 2 := by - nlinarith [sq_nonneg (a + 2 * b)] + nlinarith only [sq_nonneg (a + 2 * b)] /-! ## Theorem 2.2: Nonneg safe-square inequality @@ -54,7 +54,7 @@ For `a, b, c : ℝ` with `a ≥ 0`, `b ≥ 0`, `c ≥ 0`, and `a ≥ b − c`: theorem nonneg_safe_square (a b c : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c) (hab : a ≥ b - c) : a ^ 2 ≥ (1 / 2) * b ^ 2 - c ^ 2 := by by_cases h : b ≤ c - · nlinarith [sq_nonneg a, sq_nonneg c] - · nlinarith [sq_nonneg (b - 2 * c)] + · nlinarith only [hb, hc, h, sq_nonneg a, sq_nonneg c] + · nlinarith only [ha, hab, h, sq_nonneg (b - 2 * c)] end FockSPR diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Auxiliary.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Auxiliary.lean index cd822e3e87..c1225c3b91 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Auxiliary.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Auxiliary.lean @@ -238,7 +238,7 @@ theorem stablePhaseRetrievalCoefficients explicitPkappaNorm (θ • Q - F) ^ 2 ≤ C_F ^ 2 * modulusDefect κ F Q ^ 2 := by have hdist_nonneg : 0 ≤ explicitPkappaNorm (θ • Q - F) := Real.sqrt_nonneg _ have hdef_nonneg : 0 ≤ modulusDefect κ F Q := Real.sqrt_nonneg _ - nlinarith [hbound, hC_F_pos, hdist_nonneg, hdef_nonneg] + nlinarith only [hbound, hC_F_pos, hdist_nonneg, hdef_nonneg] have hleft : ∫ z, ‖explicitEvalPkappa κ F z - θ * explicitEvalPkappa κ Q z‖ ^ 2 ∂ explicitGamma d = @@ -255,8 +255,8 @@ theorem stablePhaseRetrievalCoefficients have heval : explicitEvalPkappa κ (θ • Q - F) z = θ * explicitEvalPkappa κ Q z - explicitEvalPkappa κ F z := by - simpa [explicitEvalPkappa, explicitPhi, explicitPhi1D, explicitComplexHermite, - evalPkappa, Phi, phi1D, complexHermite] using hsub + exact + hsub rw [heval, norm_sub_rev] _ = explicitPkappaNorm (θ • Q - F) ^ 2 := by rw [← explicitPkappaNorm_sq_eq_integral hd κ (θ • Q - F)] @@ -735,7 +735,7 @@ private theorem explicitPhaseOptimized_bound_of_l2_closure have hδ_nonneg : 0 ≤ δ n := Real.sqrt_nonneg _ have hsqrtM_nonneg : 0 ≤ Real.sqrt M := Real.sqrt_nonneg _ dsimp [B] - nlinarith [hC_P_pos, hδ_nonneg, hsqrtM_nonneg] + nlinarith only [hC_P_pos, hδ_nonneg, hsqrtM_nonneg] have hg_nonneg : 0 ≤ explicitGaussianL2DistanceSq P (fun z => θ * Q z) := explicitGaussianL2DistanceSq_nonneg P (fun z => θ * Q z) @@ -824,7 +824,7 @@ theorem stablePhaseRetrievalExplicitLpClosure_exists hP_mem hQ_mem with ⟨θ, hθ, hθ_eq⟩ refine ⟨θ, hθ, ?_⟩ - simp_all + simp_all only [] private theorem explicitHermiteLpPolys_eq_ae {d : ℕ} (κ : Fin d -> ℕ) : diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/CoefficientLimitRigidity.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/CoefficientLimitRigidity.lean index 9d470b016f..48dc63eb78 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/CoefficientLimitRigidity.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/CoefficientLimitRigidity.lean @@ -67,7 +67,7 @@ private theorem summable_skappa_eval_mul_of_phi_sq_wip (hPhi : Summable (fun alpha : Idx d => ‖Phi kappa alpha z‖ ^ 2)) : Summable (fun alpha : Idx d => coeffSkappa U alpha * Phi kappa alpha z) := by have hU : Summable (fun alpha : Idx d => ‖coeffSkappa U alpha‖ ^ 2) := by - simpa [coeffSkappa] using U.summable_norm_sq + exact U.summable_norm_sq refine Summable.of_norm_bounded (g := fun alpha : Idx d => (‖coeffSkappa U alpha‖ ^ 2 + ‖Phi kappa alpha z‖ ^ 2) / 2) @@ -80,7 +80,7 @@ private theorem summable_skappa_eval_mul_of_phi_sq_wip have hsq : ‖coeffSkappa U alpha‖ * ‖Phi kappa alpha z‖ <= (‖coeffSkappa U alpha‖ ^ 2 + ‖Phi kappa alpha z‖ ^ 2) / 2 := by - nlinarith [sq_nonneg (‖coeffSkappa U alpha‖ - ‖Phi kappa alpha z‖)] + nlinarith only [sq_nonneg (‖coeffSkappa U alpha‖ - ‖Phi kappa alpha z‖)] exact le_trans hmul hsq private theorem finite_eval_sum_tendsto_wip @@ -178,8 +178,10 @@ private theorem summable_sq_hermite_phi_eval_wip have hSle : S <= C ^ 2 := by have hev' : ‖HermitekLEAN.finiteHermiteSum k a' z‖ <= C * Real.sqrt S := by simpa [hWN] using hev - nlinarith [Real.sq_sqrt hS_nonneg, sq_nonneg (Real.sqrt S - C), hFz_bound, - hev', hC_nonneg] + linarith only [ + hS_nonneg, hFz_bound, hev', Real.sq_sqrt hS_nonneg, sq_nonneg (Real.sqrt S - C), + hC_nonneg + ] calc Finset.sum (Finset.range J) (fun n => ‖HermitekLEAN.Phi k n z‖ ^ 2) = S := (Fin.sum_univ_eq_sum_range (fun n : Nat => ‖HermitekLEAN.Phi k n z‖ ^ 2) J).symm @@ -349,7 +351,7 @@ private theorem evalPkappa_norm_le_kernel_sqrt_wip have hnorm_sq := norm_sq_eq_sum_coeff_wip H have hsum_eq_one : Finset.sum H.support (fun alpha => ‖coeffPkappa H alpha‖ ^ 2) = 1 := by - nlinarith [hH_norm, hnorm_sq] + nlinarith only [hH_norm, hnorm_sq] simp_all have hphi_le : Finset.sum H.support (fun alpha => ‖Phi kappa alpha z‖ ^ 2) <= @@ -406,12 +408,14 @@ private theorem finite_coeff_diff_sq_sum_le_four_wip have hsq : ‖coeffPkappa H alpha - coeffSkappa U alpha‖ ^ 2 <= (‖coeffPkappa H alpha‖ + ‖coeffSkappa U alpha‖) ^ 2 := by - nlinarith [hsub, norm_nonneg (coeffPkappa H alpha - coeffSkappa U alpha), - norm_nonneg (coeffPkappa H alpha), norm_nonneg (coeffSkappa U alpha)] + nlinarith only [ + hsub, norm_nonneg (coeffPkappa H alpha - coeffSkappa U alpha), + norm_nonneg (coeffPkappa H alpha), norm_nonneg (coeffSkappa U alpha) + ] have ham : (‖coeffPkappa H alpha‖ + ‖coeffSkappa U alpha‖) ^ 2 <= 2 * (‖coeffPkappa H alpha‖ ^ 2 + ‖coeffSkappa U alpha‖ ^ 2) := by - nlinarith [sq_nonneg (‖coeffPkappa H alpha‖ - ‖coeffSkappa U alpha‖)] + linarith only [sq_nonneg (‖coeffPkappa H alpha‖ - ‖coeffSkappa U alpha‖)] exact le_trans hsq ham calc Finset.sum E (fun alpha => ‖coeffPkappa H alpha - coeffSkappa U alpha‖ ^ 2) @@ -433,7 +437,7 @@ private theorem finite_coeff_diff_sq_sum_le_four_wip have hle := finite_coeff_sum_le_norm_sq_wip E H simp_all have hU_le := hU_partial E - nlinarith + linarith only [hH_le, hU_le] _ = 4 := by ring private theorem finite_eval_diff_sum_norm_le_wip @@ -462,7 +466,7 @@ private theorem finite_eval_diff_sum_norm_le_wip have hphi_nonneg : 0 <= Real.sqrt (Finset.sum E (fun alpha => ‖Phi kappa alpha z‖ ^ 2)) := Real.sqrt_nonneg _ - exact le_trans hcs (by nlinarith) + exact le_trans hcs (by nlinarith only [hsqrt_le_two, hphi_nonneg]) private theorem phi_sq_finite_tail_small_wip {d : Nat} (kappa : MultiIndex d) (z : Cd d) {eps : ℝ} (heps : 0 < eps) : @@ -500,10 +504,10 @@ private theorem finite_eval_diff_tail_small_wip Finset.sum_nonneg fun alpha halpha => sq_nonneg _ have hsqrt_lt : Real.sqrt (Finset.sum T (fun alpha => ‖Phi kappa alpha z‖ ^ 2)) < eps / 2 := by - rw [← Real.sqrt_sq (by linarith : 0 <= eps / 2)] + rw [← Real.sqrt_sq (by linarith only [heps] : 0 <= eps / 2)] exact Real.sqrt_lt_sqrt htail_nonneg htail have hbound := finite_eval_diff_sum_norm_le_wip T hH_norm hU_partial z - nlinarith + linarith only [hsqrt_lt, hbound] private theorem norm_tsum_subtype_compl_le_of_finset_bound_wip {ι : Type*} (E : Finset ι) {f : ι -> ℂ} {C : ℝ} @@ -517,7 +521,7 @@ private theorem norm_tsum_subtype_compl_le_of_finset_bound_wip ‖Finset.sum T (fun alpha => f alpha)‖) Filter.atTop (nhds (‖∑' alpha : {alpha // alpha ∉ (E : Set ι)}, f alpha‖)) := by - simpa [HasSum] using hf.hasSum.norm + exact hf.hasSum.norm refine le_of_tendsto hlim (Filter.Eventually.of_forall ?_) intro T let T' : Finset ι := T.map ⟨Subtype.val, Subtype.coe_injective⟩ @@ -529,7 +533,7 @@ private theorem norm_tsum_subtype_compl_le_of_finset_bound_wip have hsum : Finset.sum T (fun alpha : {alpha // alpha ∉ (E : Set ι)} => f alpha) = Finset.sum T' f := by simp [T'] - simp_all + simp_all only [] private theorem evalPkappa_tendsto_toFun_of_coeff_tendsto_wip {d : Nat} {kappa : MultiIndex d} @@ -545,7 +549,7 @@ private theorem evalPkappa_tendsto_toFun_of_coeff_tendsto_wip rw [Metric.tendsto_atTop] intro eps heps obtain ⟨E, hE⟩ := - finite_eval_diff_tail_small_wip kappa z (by linarith : 0 < eps / 3) + finite_eval_diff_tail_small_wip kappa z (by linarith only [heps] : 0 < eps / 3) have hhead : Filter.Tendsto (fun m => Finset.sum E @@ -570,7 +574,7 @@ private theorem evalPkappa_tendsto_toFun_of_coeff_tendsto_wip intro alpha halpha ring · simp - obtain ⟨M, hM⟩ := (Metric.tendsto_atTop.mp hhead) (eps / 3) (by linarith) + obtain ⟨M, hM⟩ := (Metric.tendsto_atTop.mp hhead) (eps / 3) (by linarith only [heps]) refine ⟨M, ?_⟩ intro m hm rw [dist_eq_norm] @@ -620,7 +624,7 @@ private theorem evalPkappa_tendsto_toFun_of_coeff_tendsto_wip (coeffPkappa (H m) alpha - coeffSkappa U alpha) * Phi kappa alpha z‖ := hsum_norm _ < eps / 3 + eps / 3 := add_lt_add_of_lt_of_le hhead_lt htail_le - _ < eps := by linarith + _ < eps := by linarith only [heps] private theorem evalPkappa_add_smul_tendsto_toFun_wip {d : Nat} {kappa : MultiIndex d} @@ -896,7 +900,7 @@ private theorem scalar_multiple_eq_zero_of_orthogonalToSkappa_wip have hsum_one : ((Finset.sum F.support (fun alpha => ‖coeffPkappa F alpha‖ ^ 2) : ℝ) : ℂ) = 1 := by have hnorm_sq := norm_sq_eq_sum_coeff_wip F - have hF_sq : ‖F‖ ^ 2 = 1 := by nlinarith [hF_norm] + have hF_sq : ‖F‖ ^ 2 = 1 := by nlinarith only [hF_norm] norm_num exact_mod_cast hnorm_sq.symm.trans hF_sq have hzero : c * ((Finset.sum F.support @@ -1066,7 +1070,7 @@ private theorem finite_head_mass_contradiction_of_coeff_zero_wip False := by have hsum_zero : Finset.sum K (fun alpha => ‖coeffSkappa U alpha‖ ^ 2) = 0 := by simp [hzero] - nlinarith + linarith only [h_rho, hmass, hsum_zero] private theorem bad_sequence_of_no_finite_head_lower_bound_wip {d : Nat} {kappa : MultiIndex d} @@ -1264,11 +1268,11 @@ private theorem unit_complex_of_real_nonneg_wip {w : ℂ} w.re * w.re + w.im * w.im = Complex.normSq w := (Complex.normSq_apply w).symm _ = ‖w‖ ^ 2 := Complex.normSq_eq_norm_sq w _ = 1 := by rw [hw]; norm_num - have hsq : w.re ^ 2 = (1 : ℝ) ^ 2 := by nlinarith + have hsq : w.re ^ 2 = (1 : ℝ) ^ 2 := by nlinarith only [him, hnormsq] rcases sq_eq_sq_iff_eq_or_eq_neg.mp hsq with h | h - · simpa using h - · nlinarith - · simpa using him + · exact h + · linarith only [hre, h] + · exact him private theorem positiveGauge_limit_affine_wip {d : Nat} {kappa : MultiIndex d} @@ -1397,7 +1401,7 @@ private lemma norm_sq_add_real_smul_wip (a w : ℂ) (t : ℝ) : ring have hre' : (a * (starRingEnd ℂ) ((t : ℂ) * w)).re = - t * Complex.re (w * star a) := by simpa using hre + t * Complex.re (w * star a) := by exact hre rw [hre'] ring @@ -1416,7 +1420,7 @@ private lemma defectFunction_div_eq_abs_linearization_wip have hprod : (‖a + (t : ℂ) * w‖ - ‖a‖) * (‖a + (t : ℂ) * w‖ + ‖a‖) = - 2 * t * Complex.re (w * star a) + t ^ 2 * ‖w‖ ^ 2 := by nlinarith + 2 * t * Complex.re (w * star a) + t ^ 2 * ‖w‖ ^ 2 := by linarith only [hsq] exact congrArg abs hprod have ht0 : t ≠ 0 := ne_of_gt ht calc @@ -1449,14 +1453,14 @@ private theorem pkappa_eq_zero_of_norm_eq_zero_coeff_wip have hterm_pos : 0 < ‖F alpha‖ ^ 2 := pow_pos (norm_pos_iff.mpr hne) 2 have hle : ‖F alpha‖ ^ 2 <= Finset.sum F.support (fun beta => ‖coeffPkappa F beta‖ ^ 2) := by - simpa [coeffPkappa] using + exact (Finset.single_le_sum (f := fun beta : Idx d => ‖F beta‖ ^ 2) (s := F.support) (a := alpha) (fun beta _ => by positivity) hmem) have hsum_pos : 0 < Finset.sum F.support (fun beta => ‖coeffPkappa F beta‖ ^ 2) := lt_of_lt_of_le hterm_pos hle have hnorm_sq := norm_sq_eq_sum_coeff_wip F - nlinarith + nlinarith only [hnorm, hterm_pos, hle, hnorm_sq] private theorem norm_ne_zero_of_ne_zero_pkappa_coeff_wip {d : Nat} {kappa : MultiIndex d} {F : Pkappa d kappa} @@ -1573,7 +1577,7 @@ private theorem memLp_two_defectFunctionPkappa_coeff_wip unfold defectFunctionPkappa_coeff_wip have : (‖evalPkappa kappa (F + G) z‖ - ‖evalPkappa kappa F z‖) ^ 2 <= 2 * ‖evalPkappa kappa (F + G) z‖ ^ 2 + 2 * ‖evalPkappa kappa F z‖ ^ 2 := by - nlinarith [sq_nonneg (‖evalPkappa kappa (F + G) z‖ + ‖evalPkappa kappa F z‖)] + linarith only [sq_nonneg (‖evalPkappa kappa (F + G) z‖ + ‖evalPkappa kappa F z‖)] simpa [sq_abs] using this simp_all simpa [Real.norm_eq_abs, abs_of_nonneg] using @@ -2041,7 +2045,7 @@ private theorem finite_head_bad_limit_modulus_ae_wip ‖evalPkappa kappa F z‖|) Filter.atTop (nhds 0) := by filter_upwards [hdef_ae] with z hz - simpa [defectFunctionPkappa_coeff_wip] using hz + exact hz exact ae_norm_eq_of_tendsto_defect_wip hpointwise hdefect private def skappaAffinePkappa_wip @@ -2205,7 +2209,7 @@ private theorem skappa_real_part_scalar_relation_wip ‖f‖ ^ 2 + (-1 : ℝ) ^ 2 * ‖u‖ ^ 2 + 2 * (-1 : ℝ) * Complex.re (u * star f) := by simpa using hminus have hz' : Complex.re (u * star f) = 0 := by simpa [f, u] using hz - nlinarith + linarith only [hz, hplus', hminus'] have hnorm : ‖f + u‖ = ‖f + (-1 : ℂ) * u‖ := by simp_all simpa [f, u] using hnorm @@ -2308,7 +2312,7 @@ private theorem skappa_real_part_pure_imag_scalar_relation_wip ‖f‖ ^ 2 + (-1 : ℝ) ^ 2 * ‖u‖ ^ 2 + 2 * (-1 : ℝ) * Complex.re (u * star f) := by simpa using hminus have hz' : Complex.re (u * star f) = 0 := by simpa [f, u] using hz - nlinarith + linarith only [hz, hplus', hminus'] have hnorm : ‖f + u‖ = ‖f + (-1 : ℂ) * u‖ := by simp_all simpa [f, u] using hnorm @@ -2679,7 +2683,7 @@ private lemma evalPkappa_pointwise_bound_coeff_wip ‖evalPkappa kappa G z‖ = ‖evalPkappa kappa (F + G) z - evalPkappa kappa F z‖ := by rw [hsub] _ ≤ ‖evalPkappa kappa (F + G) z‖ + ‖evalPkappa kappa F z‖ := norm_sub_le _ _ _ ≤ defectFunctionPkappa_coeff_wip kappa F G z + - ‖evalPkappa kappa F z‖ + ‖evalPkappa kappa F z‖ := by linarith + ‖evalPkappa kappa F z‖ + ‖evalPkappa kappa F z‖ := by linarith only [haux] _ = defectFunctionPkappa_coeff_wip kappa F G z + 2 * ‖evalPkappa kappa F z‖ := by ring private theorem norm_le_defect_add_two_coeff_wip @@ -2763,8 +2767,11 @@ private theorem coefficient_head_mass_of_highAnnulus_small_wip refine ⟨Kextra, rho_head, hrho_head_pos, ?_⟩ intro H hH_norm hhigh have hpartition := annulusMassPartition hd kappa J H - have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith - have hlow_lower : 1 / 4 < lowAnnulusMass J (ofPkappa kappa H) := by nlinarith + have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith only [hH_norm] + have hlow_lower : 1 / 4 < lowAnnulusMass J (ofPkappa kappa H) := by + linarith only [ + hhigh, hpartition, hH_sq + ] have hKextra_mass_gt : rho_head < Finset.sum Kextra (fun alpha => ‖coeffPkappa H alpha‖ ^ 2) := by by_contra hnot @@ -2773,7 +2780,7 @@ private theorem coefficient_head_mass_of_highAnnulus_small_wip le_of_not_gt hnot have hlow_upper : lowAnnulusMass J (ofPkappa kappa H) <= 1 / 4 := hlow hH_norm hmass_le - linarith + linarith only [hhigh, hpartition, hH_sq, hlow_upper] have hKextra_subset : Kextra ⊆ coefficientControlSet_wip E F ∪ Kextra := by simp_all have hsum_le_union : @@ -2797,7 +2804,7 @@ private theorem highAnnulusControl_eps_noOrth_wip highAnnulusMass J (ofPkappa kappa H) <= eps := by obtain ⟨J, C, hC_pos, hann⟩ := finite_base_annulus_estimate hd kappa F ⟨hF_ne, hF_norm⟩ - (eps / 2) (by linarith) + (eps / 2) (by linarith only [h_eps]) let delta_high : ℝ := min 1 (eps / (2 * C)) have hdelta_high_pos : 0 < delta_high := by dsimp [delta_high] @@ -2815,8 +2822,11 @@ private theorem highAnnulusControl_eps_noOrth_wip have hmul := mul_le_mul_of_nonneg_left hdelta_le (le_of_lt hC_pos) have hC_ne : C ≠ 0 := ne_of_gt hC_pos have hcalc : C * (eps / (2 * C)) = eps / 2 := by field_simp [hC_ne] - nlinarith - have hdelta_sq_le : delta_high ^ 2 <= delta_high := by nlinarith [sq_nonneg delta_high] + linarith only [hmul, hcalc] + have hdelta_sq_le : delta_high ^ 2 <= delta_high := by + nlinarith only [ + hdelta_high_pos, hdelta_le_one, sq_nonneg delta_high + ] have hCdelta_sq_le : C * delta_high ^ 2 <= eps / 2 := by calc C * delta_high ^ 2 <= C * delta_high := @@ -2825,7 +2835,7 @@ private theorem highAnnulusControl_eps_noOrth_wip have hhigh : highAnnulusMass J (ofPkappa kappa H) <= C * delta_high ^ 2 + eps / 2 := hann hH_norm ht_pos ht_le_four hdelta_nonneg hdefect - linarith + linarith only [hCdelta_sq_le, hhigh] theorem positiveGauge_coercivity {d : Nat} (hd : 0 < d) (kappa : MultiIndex d) @@ -2909,7 +2919,7 @@ theorem positiveGauge_coercivity exact mul_le_mul_of_nonneg_right hdelta_le_head_half (le_of_lt ht_pos) simpa [hG_eq] using hstep exfalso - nlinarith [hdelta_head_pos, ht_pos, hlower, hupper] + nlinarith only [hdelta_head_pos, ht_pos, hlower, hupper] · have hdelta_inv_le : delta⁻¹ ≤ C_F := by dsimp [C_F] exact le_max_right _ _ @@ -2925,7 +2935,7 @@ theorem positiveGauge_coercivity _ ≤ C_F * defect F G := mul_le_mul_of_nonneg_right hdelta_inv_le (Real.sqrt_nonneg _) · have hge4 : 4 ≤ t := le_of_not_gt hlt4 have htwo_defect : t ≤ 2 * defect F G := by - nlinarith [(Real.sqrt_nonneg _ : (0:ℝ) ≤ defect F G)] + linarith only [hlarge_bridge, hlt4, (Real.sqrt_nonneg _ : (0 : ℝ) ≤ defect F G)] have htwo_le_C : 2 ≤ C_F := by dsimp [C_F] exact le_max_left _ _ @@ -2972,7 +2982,7 @@ private theorem lowAnnulusDefectControl_of_finite_head_lower_bound_wip hdefect_lower horth hH_norm hmass ht_pos ht_le_four have hupper : defect F (t • H) <= (delta_head / 2) * t := hdefect exfalso - nlinarith [hdelta_head_pos, ht_pos, hlower, hupper] + nlinarith only [hdelta_head_pos, ht_pos, hlower, hupper] private theorem finite_window_lowAnnulusDefectControl_core_wip {d : Nat} (hd : 0 < d) (kappa : MultiIndex d) diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/ExactModulusRecovery.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/ExactModulusRecovery.lean index f51e063718..21e2baf37c 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/ExactModulusRecovery.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/ExactModulusRecovery.lean @@ -15,7 +15,6 @@ import Mathlib.MeasureTheory.Integral.Gamma import Mathlib.Probability.Distributions.Gaussian.Real import Mathlib.RingTheory.Finiteness.Prod import Mathlib.Tactic.NormNum.Parity -import Mathlib.Topology.Algebra.Module.Cardinality /-! # ExactModulusRecovery -/ @@ -85,7 +84,7 @@ private lemma star_sub_div_sqrtTwo (x ω : ℝ) : (Real.sqrt 2 : ℂ)) = ((x : ℂ) + (2 * Real.pi : ℂ) * Complex.I * (ω : ℂ)) / (Real.sqrt 2 : ℂ) := by - simp_all only [star_div₀, star_sub, RCLike.star_def, Complex.conj_ofReal, star_mul', star_ofNat, + simp only [star_div₀, star_sub, RCLike.star_def, Complex.conj_ofReal, star_mul', star_ofNat, Complex.conj_I, mul_neg, neg_mul, sub_neg_eq_add] /-- `realHermiteGenerating`: real Hermite Generating. -/ @@ -465,7 +464,7 @@ theorem realHermiteGenerating_ambiguity_integral_conj_raw (((Real.sqrt 2 : ℂ) * (u + star v) - (2 * Real.pi : ℂ) * Complex.I * (ω : ℂ)) ^ 2) / 4) := by simp_rw [realHermiteGenerating_conj] - simpa using realHermiteGenerating_ambiguity_integral_raw x ω u (star v) + exact realHermiteGenerating_ambiguity_integral_raw x ω u (star v) theorem realHermiteGenerating_ambiguity_integral_conj_kernel (x ω : ℝ) (u v : ℂ) : @@ -509,7 +508,7 @@ theorem realHermiteGenerating_ambiguity_integral_independent_kernel (Real.sqrt 2 : ℂ)) * w) * Complex.ofReal (Real.exp (-((x ^ 2 + (2 * Real.pi) ^ 2 * ω ^ 2) / 4))) := by - simpa using realHermiteGenerating_ambiguity_integral_kernel x ω u w + exact realHermiteGenerating_ambiguity_integral_kernel x ω u w /-- `shiftedGeneratingRightDerivBoundConstant`: shifted Generating Right Deriv Bound Constant. -/ noncomputable def shiftedGeneratingRightDerivBoundConstant @@ -585,7 +584,7 @@ theorem hasDerivAt_integral_fixed_mul_shifted_modulated_realHermiteGenerating_ri ((inner ℝ ω t : ℝ) : ℂ))) (bound := bound) hs hF_meas hF_int hF'_meas h_bound bound_integrable ?_).2 exact ae_of_all _ fun t z _ => by - simpa [mul_assoc] using + exact ((realHermiteGenerating_hasDerivAt (t - (1 / 2 : ℝ) * x) z).const_mul (phi t)).mul_const (Complex.exp (-(2 * Real.pi : ℂ) * Complex.I * @@ -969,7 +968,7 @@ theorem realHermite1D_zero (t : ℝ) : theorem realHermite1D_one (t : ℝ) : realHermite1D 1 t = (Real.sqrt 2 : ℂ) * (t : ℂ) * realHermiteGenerating t 0 := by simp [realHermite1D, realHermiteGenerating_deriv_zero, realHermiteGenerating] - ring_nf + ring theorem realHermite1D_inner_zero_zero : (∫ t : ℝ, realHermite1D 0 t * star (realHermite1D 0 t)) = 1 := by @@ -1011,7 +1010,7 @@ theorem integral_real_mul_exp_neg_sq : simp_all only [even_two, Even.neg_pow, neg_mul]] at h rw [MeasureTheory.integral_neg] at h - linarith + linarith only [h] theorem realHermite1D_inner_one_one : (∫ t : ℝ, realHermite1D 1 t * star (realHermite1D 1 t)) = 1 := by @@ -1113,7 +1112,7 @@ theorem realHermite1D_inner_one_zero : funext t simp [RCLike.star_def, mul_comm] _ = conj (∫ t : ℝ, realHermite1D 0 t * star (realHermite1D 1 t)) := by - simpa [RCLike.star_def] using + exact (integral_conj (μ := (volume : MeasureTheory.Measure ℝ)) (f := fun t : ℝ => realHermite1D 0 t * star (realHermite1D 1 t))) _ = 0 := by @@ -1447,7 +1446,7 @@ private theorem iteratedDeriv_cexp_neg_sq_div_two_zero_of_odd have hder := iteratedDeriv_comp_neg n q (0 : ℂ) rw [hfun] at hder simp only [neg_zero] at hder - have hneg : ((-1 : ℂ) ^ n) = -1 := by simpa using hodd.neg_one_pow + have hneg : ((-1 : ℂ) ^ n) = -1 := by exact hodd.neg_one_pow rw [hneg, neg_smul, one_smul] at hder exact CharZero.neg_eq_self_iff.mp hder.symm @@ -1555,7 +1554,7 @@ theorem realHermiteGenerating_iteratedDeriv_zero_expansion b ^ k * iteratedDeriv (n - k) q 0 := by rw [hfun, iteratedDeriv_const_mul_field, iteratedDeriv_fun_mul] - · simp_all only [iteratedDeriv_cexp_const_mul, mul_zero, Complex.exp_zero, mul_one] + · simp only [iteratedDeriv_cexp_const_mul, mul_zero, Complex.exp_zero, mul_one] · fun_prop · fun_prop _ = ∑ k ∈ Finset.range (n + 1), @@ -1568,7 +1567,7 @@ theorem realHermiteGenerating_iteratedDeriv_zero_expansion apply Finset.sum_congr rfl intro k hk simp only [a, b, q] - ring_nf + ring /-- `realHermiteGeneratingExpansionCoeff`: real Hermite Generating Expansion Coeff. -/ noncomputable def realHermiteGeneratingExpansionCoeff (n k : ℕ) : ℂ := @@ -1746,7 +1745,7 @@ private lemma gaussianMomentFunctional_add (p q : Polynomial ℤ) : gaussianMomentFunctional p + gaussianMomentFunctional q := by unfold gaussianMomentFunctional rw [Polynomial.sum_add_index] - · simp_all only [Int.cast_zero, zero_mul, implies_true] + · simp only [Int.cast_zero, zero_mul, implies_true] · intro i a b norm_num ring @@ -1755,7 +1754,7 @@ private lemma gaussianMomentFunctional_monomial (k : ℕ) (a : ℤ) : gaussianMomentFunctional (Polynomial.monomial k a) = (a : ℂ) * standardGaussianMoment k := by unfold gaussianMomentFunctional - simp_all only [Int.cast_zero, zero_mul, Polynomial.sum_monomial_index] + simp only [Int.cast_zero, zero_mul, Polynomial.sum_monomial_index] private lemma gaussianMomentFunctional_neg (p : Polynomial ℤ) : gaussianMomentFunctional (-p) = -gaussianMomentFunctional p := by @@ -1766,7 +1765,7 @@ private lemma gaussianMomentFunctional_neg (p : Polynomial ℤ) : | monomial k a => rw [← Polynomial.monomial_neg, gaussianMomentFunctional_monomial, gaussianMomentFunctional_monomial] - simp_all only [Int.cast_neg, neg_mul] + simp only [Int.cast_neg, neg_mul] private lemma gaussianMomentFunctional_sub (p q : Polynomial ℤ) : gaussianMomentFunctional (p - q) = @@ -1868,7 +1867,7 @@ private lemma derivative_hermite_int (n : ℕ) : private lemma derivative_hermite_succ_int (n : ℕ) : Polynomial.derivative (Polynomial.hermite (n + 1)) = - ((n + 1 : ℕ) : ℤ) • Polynomial.hermite n := by simpa using derivative_hermite_int (n + 1) + ((n + 1 : ℕ) : ℤ) • Polynomial.hermite n := by exact derivative_hermite_int (n + 1) private noncomputable def hermiteStandardInner (n m : ℕ) : ℂ := gaussianMomentFunctional (Polynomial.hermite n * Polynomial.hermite m) @@ -3020,8 +3019,8 @@ theorem summable_realHermiteTensorL2_coeff_smul_of_orthonormal classical have hOrthogonalFamily := horth.orthogonalFamily have hcoeff : Summable (fun alpha : Idx d => ‖coeffSkappa U alpha‖ ^ 2) := by - simpa [coeffSkappa] using U.summable_norm_sq - simpa using + exact U.summable_norm_sq + exact (hOrthogonalFamily.summable_iff_norm_sq_summable (fun alpha : Idx d => coeffSkappa U alpha)).2 hcoeff @@ -3112,7 +3111,7 @@ private theorem ambiguityRep_varphiKappa_eq_tensorRep_integral =ᵐ[(volume : Measure (RealVec d))] fun t : RealVec d => realHermiteTensorRep kappa (t + ((1 / 2 : ℝ) • ξ.1)) := by - simpa [Function.comp_def] using + exact ((MeasureTheory.measurePreserving_add_right (volume : Measure (RealVec d)) (((1 / 2 : ℝ) • ξ.1))).quasiMeasurePreserving).ae_eq_comp hcoe @@ -3123,7 +3122,7 @@ private theorem ambiguityRep_varphiKappa_eq_tensorRep_integral =ᵐ[(volume : Measure (RealVec d))] fun t : RealVec d => realHermiteTensorRep kappa (t - ((1 / 2 : ℝ) • ξ.1)) := by - simpa [Function.comp_def, sub_eq_add_neg] using + exact ((MeasureTheory.measurePreserving_add_right (volume : Measure (RealVec d)) (-((1 / 2 : ℝ) • ξ.1))).quasiMeasurePreserving).ae_eq_comp hcoe @@ -3284,7 +3283,7 @@ private lemma Phi_self_zero_ne {d : Nat} (kappa : MultiIndex d) : unfold Phi apply Finset.prod_ne_zero_iff.mpr intro q _hq - simpa using phi1D_self_zero_ne (kappa q) + exact phi1D_self_zero_ne (kappa q) private lemma TKappa_zero {d : Nat} : TKappa ((0, 0) : PhaseSpace d) = 0 := by @@ -4159,7 +4158,7 @@ private theorem shifted_mgf_mixed_derivative_expansion_unscaled intro i hi have hFi := contDiff_iteratedDeriv_cexp_sq_div_four i m fun_prop - simpa using ContDiffAt.const_smul + exact ContDiffAt.const_smul ((Nat.choose n k : ℂ) * (Real.sqrt 2 : ℂ) ^ k * iteratedDeriv (n - k) (fun u : ℂ => Complex.exp (-(u ^ 2) / 2)) 0) hsum @@ -4427,7 +4426,7 @@ private theorem gaussian_half_shifted_monomial_pair_exp_integrable a ^ (k - i) * b ^ (l - j) * ((t : ℂ) ^ (i + j) * Complex.exp (lam * (t : ℂ))) := by funext t - simpa [a, b, lam] using shifted_monomial_pair_modulated_expansion k l x ω t + exact shifted_monomial_pair_modulated_expansion k l x ω t rw [hpoint] apply integrable_finsetSum intro i hi @@ -4761,7 +4760,7 @@ private theorem iteratedDeriv_generating_cross_ambiguity_integral_moment_sum (fun z : ℂ => Complex.exp (z ^ 2 / 4)) (-(2 * Real.pi : ℂ) * Complex.I * (ω : ℂ))))) := by let cπ : ℂ := ((Real.pi ^ (-(1 / 2 : ℝ)) : ℝ) : ℂ) - have hcπ : cπ ≠ 0 := by simpa [cπ] using real_pi_neg_half_complex_ne_zero + have hcπ : cπ ≠ 0 := by exact real_pi_neg_half_complex_ne_zero have h := iteratedDeriv_generating_cross_ambiguity_pi_neg_half_mul_integral_moment_sum n m x ω calc @@ -4816,7 +4815,7 @@ private theorem iteratedDeriv_generating_cross_ambiguity_moment_sum_eq_kernel_co rw [← shifted_mgf_coefficient_eq_kernel_coefficient n m x ω, scaled_moment_sum_eq_shifted_mgf_unscaled_sum, ← shifted_mgf_mixed_derivative_expansion_unscaled] - simp_all only [neg_mul, iteratedDeriv_const_mul_field] + simp only [neg_mul, iteratedDeriv_const_mul_field] private theorem iteratedDeriv_generating_cross_ambiguity_integral_eq_kernel_coefficient (n m : ℕ) (x ω : ℝ) : @@ -5261,7 +5260,7 @@ theorem windowAmbiguity_factorization rw [ambiguityRep_varphiKappa_eq_tensorRep_integral] apply tensorRep_windowAmbiguity_integral_eq_PKappa_exp_of_oneD intro q - simpa [TKappa] using + exact oneDWindowAmbiguityFactor_closed (kappa q) (ξ.1 q) (ξ.2 q) theorem windowAmbiguity_polynomial_nonzero @@ -5325,18 +5324,21 @@ private lemma dense_ne_zero_of_phaseSpace_polynomial simp_all only [Prod.forall, Prod.mk.eta, ne_eq, gt_iff_lt, Polynomial.eval_zero, Complex.ofReal_one, not_true_eq_false] let rootsReal : Set ℝ := {t : ℝ | qpoly.eval (t : ℂ) = 0} - have hroots_countable : rootsReal.Countable := by + have hroots_finite : rootsReal.Finite := by have hroots_complex : ({z : ℂ | qpoly.IsRoot z}).Finite := Polynomial.finite_setOfPred_isRoot hq_ne - have hroots_complex_countable : ({z : ℂ | qpoly.IsRoot z}).Countable := - hroots_complex.countable have hpre : rootsReal = Complex.ofReal ⁻¹' {z : ℂ | qpoly.IsRoot z} := by ext t simp [rootsReal, Polynomial.IsRoot] rw [hpre] - exact hroots_complex_countable.preimage Complex.ofReal_injective + exact Set.Finite.preimage Complex.ofReal_injective.injOn hroots_complex have hnonroots_dense : Dense {t : ℝ | qpoly.eval (t : ℂ) ≠ 0} := by - simpa [rootsReal, Set.compl_ofPred] using hroots_countable.dense_compl ℝ + apply dense_iff_inter_open.2 + intro U hU hUne + obtain ⟨x, hx⟩ := hUne + have hU_infinite : U.Infinite := infinite_of_mem_nhds x (hU.mem_nhds hx) + obtain ⟨t, htU, htroot⟩ := (hU_infinite.sdiff hroots_finite).nonempty + exact ⟨t, htU, htroot⟩ have hline_cont : Continuous line := by fun_prop have hline0 : line 0 = ξ := by ext q <;> simp [line] have hpre_ball : line ⁻¹' Metric.ball ξ ε ∈ nhds (0 : ℝ) := by @@ -5536,7 +5538,7 @@ private lemma shifted_conj_mul_integrable have hf_shift : MemLp (fun t : RealVec d => f (t + a)) 2 (volume : Measure (RealVec d)) := by - simpa [Function.comp_def] using + exact hf.comp_measurePreserving (MeasureTheory.measurePreserving_add_right (volume : Measure (RealVec d)) a) @@ -5546,7 +5548,7 @@ private lemma shifted_conj_mul_integrable have hg0 : MemLp (fun t : RealVec d => g (t + b)) 2 (volume : Measure (RealVec d)) := by - simpa [Function.comp_def] using + exact hg.comp_measurePreserving (MeasureTheory.measurePreserving_add_right (volume : Measure (RealVec d)) b) @@ -5594,7 +5596,7 @@ private lemma centerKernel_memLp_two let μ : Measure (RealVec d) := volume let K : PhaseSpace d -> ℂ := fun p => f p.1 * star (f p.2) have hK : MemLp K 2 (μ.prod μ) := by - simpa [K, μ] using + exact (rankOneKernel_memLp_two (d := d) (f := f) (g := f) hf hf) have hdet : LinearMap.det (L : PhaseSpace d →ₗ[ℝ] PhaseSpace d) ≠ 0 := (LinearEquiv.isUnit_det' L).ne_zero @@ -5604,7 +5606,7 @@ private lemma centerKernel_memLp_two ENNReal.ofReal |(LinearMap.det (L : PhaseSpace d →ₗ[ℝ] PhaseSpace d))⁻¹| • (μ.prod μ) := by - simpa using + exact (MeasureTheory.Measure.map_linearMap_addHaar_eq_smul_addHaar (μ := μ.prod μ) (f := (L : PhaseSpace d →ₗ[ℝ] PhaseSpace d)) hdet) @@ -5623,8 +5625,8 @@ private lemma centerKernel_memLp_two (LinearMap.continuous_of_finiteDimensional (L : PhaseSpace d →ₗ[ℝ] PhaseSpace d)).measurable.aemeasurable exact hK_map.comp_of_map hL_aemeasurable - simpa [K, L, μ, centerToEndpointsLinearEquiv, Function.comp_def, - MeasureTheory.Measure.volume_eq_prod] using hcomp + exact + hcomp private lemma memLp_two_prod_right_ae {d : Nat} {F : PhaseSpace d -> ℂ} @@ -5657,19 +5659,16 @@ private lemma ae_prod_of_ae_ae_of_aestronglyMeasurable (hF_meas : AEStronglyMeasurable F (μ.prod ν)) (hsec : ∀ᵐ x ∂μ, (fun y : β => F (x, y)) =ᵐ[ν] fun _ => (0 : E)) : F =ᵐ[μ.prod ν] fun _ => (0 : E) := by - let Fm : α × β -> E := hF_meas.mk F - have hF_eq_mk_sections : - ∀ᵐ x ∂μ, (fun y : β => F (x, y)) =ᵐ[ν] fun y => Fm (x, y) := - MeasureTheory.Measure.ae_ae_of_ae_prod hF_meas.ae_eq_mk - have hmk_sec_zero : - ∀ᵐ x ∂μ, (fun y : β => Fm (x, y)) =ᵐ[ν] fun _ => (0 : E) := by - filter_upwards [hsec, hF_eq_mk_sections] with x hx hxm - exact hxm.symm.trans hx + let Fm : α × β → E := hF_meas.aemeasurable.mk F + have hF_eq : F =ᵐ[μ.prod ν] Fm := hF_meas.aemeasurable.ae_eq_mk have hmeas_zero : MeasurableSet {p : α × β | Fm p = 0} := - hF_meas.stronglyMeasurable_mk.measurable (measurableSet_singleton (0 : E)) - have hmk_prod : Fm =ᵐ[μ.prod ν] fun _ => (0 : E) := - (MeasureTheory.Measure.ae_prod_iff_ae_ae hmeas_zero).2 hmk_sec_zero - exact hF_meas.ae_eq_mk.trans hmk_prod + hF_meas.aemeasurable.measurable_mk (measurableSet_singleton (0 : E)) + have hsections : + ∀ᵐ x ∂μ, (fun y : β => F (x, y)) =ᵐ[ν] fun y => Fm (x, y) := + MeasureTheory.Measure.ae_ae_of_ae_prod hF_eq + refine hF_eq.trans ((MeasureTheory.Measure.ae_prod_iff_ae_ae hmeas_zero).2 ?_) + filter_upwards [hsec, hsections] with x hx hxm + exact hxm.symm.trans hx private lemma sectionDiff_fourier_eq_ambiguity_sub {d : Nat} (f g : L2Real d) (x ω : RealVec d) @@ -5901,7 +5900,38 @@ private lemma norm_eq_one_of_mul_star_eq_one {w : ℂ} have h' := congrArg norm h simp at h' have hw_nonneg : 0 ≤ ‖w‖ := norm_nonneg w - nlinarith + nlinarith only [h', hw_nonneg] + +-- Retain the original generated declarations when replacing broad simplification. +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_1.{u_2} + {α : Type u_2} [inst : Zero α] [inst_1 : OfNat α 2] [NeZero (2 : α)] : + ((2 : α) = 0) = False := propext (iff_false_intro (NeZero.ne (2 : α))) + +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_2.{u_2} + {α : Type u_2} [inst : Zero α] [inst_1 : OfNat α 3] [NeZero (3 : α)] : + ((3 : α) = 0) = False := propext (iff_false_intro (NeZero.ne (3 : α))) + +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_3.{u_2} + {α : Type u_2} [inst : Zero α] [inst_1 : OfNat α 4] [NeZero (4 : α)] : + ((4 : α) = 0) = False := propext (iff_false_intro (NeZero.ne (4 : α))) + +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_4.{u_1} + {M₀ : Type u_1} [inst : Mul M₀] [inst_1 : Zero M₀] [NoZeroDivisors M₀] + {a b : M₀} (ha : a ≠ 0) (hb : b ≠ 0) : (a * b = 0) = False := + propext (iff_false_intro (mul_ne_zero ha hb)) + +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_5.{u_1} + {M₀ : Type u_1} [inst : MonoidWithZero M₀] {a : M₀} [IsReduced M₀] + (n : ℕ) (h : a ≠ 0) : (a ^ n = 0) = False := + propext (iff_false_intro (pow_ne_zero n h)) + +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_6.{u_3} + {G₀ : Type u_3} [inst : GroupWithZero G₀] {a : G₀} (n : ℤ) (h : a ≠ 0) : + (a ^ n = 0) = False := propext (iff_false_intro (zpow_ne_zero n h)) + +private theorem rankOneKernel_ae_to_unimodular_phase._simp_1_7.{u_1} + {R : Type u_1} [inst : AddMonoidWithOne R] [CharZero R] (n : ℕ) : + ((n : R) + 1 = 0) = False := propext (iff_false_intro (Nat.cast_add_one_ne_zero n)) theorem rankOneKernel_ae_to_unimodular_phase {d : Nat} {f g : L2Real d} {fRep gRep : RealVec d -> ℂ} @@ -5915,12 +5945,12 @@ theorem rankOneKernel_ae_to_unimodular_phase have hkernel_prod : (fun p : RealVec d × RealVec d => fRep p.1 * star (fRep p.2)) =ᵐ[μ.prod μ] fun p => gRep p.1 * star (gRep p.2) := by - simpa [μ, MeasureTheory.Measure.volume_eq_prod (RealVec d) (RealVec d)] + simpa only [μ, MeasureTheory.Measure.volume_eq_prod (RealVec d) (RealVec d)] using hkernel have hrow_ae : ∀ᵐ u ∂μ, ∀ᵐ v ∂μ, fRep u * star (fRep v) = gRep u * star (gRep v) := by - simpa using MeasureTheory.Measure.ae_ae_of_ae_prod hkernel_prod + exact MeasureTheory.Measure.ae_ae_of_ae_prod hkernel_prod by_cases hf_zero : f = 0 · left refine ⟨hf_zero, ?_⟩ @@ -5938,7 +5968,9 @@ theorem rankOneKernel_ae_to_unimodular_phase rcases hgood_u0 with ⟨hrow_u0, hf0⟩ have hgRep_zero : gRep =ᵐ[μ] fun _ => (0 : ℂ) := by filter_upwards [hrow_u0] with v hv - simp_all + have hproduct : gRep u0 * star (gRep v) = 0 := by + simpa only [hf0, zero_mul] using hv.symm + exact star_eq_zero.mp ((mul_eq_zero.mp hproduct).resolve_left hg0_ne) exact hg_ne (L2_eq_zero_of_rep_ae_eq_zero hg_rep hgRep_zero) · right have hfRep_not_zero : ¬ fRep =ᵐ[μ] fun _ => (0 : ℂ) := by @@ -5950,7 +5982,9 @@ theorem rankOneKernel_ae_to_unimodular_phase by_contra hg0 apply hfRep_not_zero filter_upwards [hrow_u0] with v hv - simp_all + have hproduct : fRep u0 * star (fRep v) = 0 := by + simpa only [hg0, zero_mul] using hv + exact star_eq_zero.mp ((mul_eq_zero.mp hproduct).resolve_left hf0_ne) let w : ℂ := star (fRep u0 / gRep u0) have hphase : gRep =ᵐ[μ] fun v => w * fRep v := by filter_upwards [hrow_u0] with v hv @@ -5961,10 +5995,11 @@ theorem rankOneKernel_ae_to_unimodular_phase ((gRep u0)⁻¹ * gRep u0) * star (gRep v) := by rw [inv_mul_cancel₀ hg0_ne, one_mul] _ = (gRep u0)⁻¹ * (gRep u0 * star (gRep v)) := by ring _ = (gRep u0)⁻¹ * (fRep u0 * star (fRep v)) := by rw [← hv] - _ = (fRep u0 / gRep u0) * star (fRep v) := by field_simp [div_eq_mul_inv] + _ = (fRep u0 / gRep u0) * star (fRep v) := by rw [div_eq_mul_inv]; ac_rfl have hconj := congrArg star hstar calc - gRep v = fRep v * star (fRep u0 / gRep u0) := by simpa [star_mul] using hconj + gRep v = fRep v * star (fRep u0 / gRep u0) := by + simpa only [star_mul, star_star] using hconj _ = w * fRep v := by ring have hL2 : g = w • f := ae_unimodular_phase_to_L2_eq hf_rep hg_rep hphase @@ -5991,7 +6026,7 @@ theorem rankOneKernel_ae_to_unimodular_phase ∀ᵐ u ∂μ, ∀ᵐ v ∂μ, fRep u * star (fRep v) = (w * star w) * (fRep u * star (fRep v)) := by - simpa using MeasureTheory.Measure.ae_ae_of_ae_prod hscale_prod + exact MeasureTheory.Measure.ae_ae_of_ae_prod hscale_prod rcases exists_eventually_and_ne_zero hscale_rows hfRep_not_zero with ⟨u1, hscale_u1, hu1_ne⟩ rcases exists_eventually_and_ne_zero hscale_u1 hfRep_not_zero with @@ -5999,7 +6034,7 @@ theorem rankOneKernel_ae_to_unimodular_phase have hF_ne : fRep u1 * star (fRep v1) ≠ 0 := mul_ne_zero hu1_ne (star_ne_zero.mpr hv1_ne) have hunit_mul : w * star w = 1 := by - simp_all + exact mul_right_cancel₀ hF_ne (by simpa only [one_mul] using hscale_u1v1.symm) exact ⟨w, norm_eq_one_of_mul_star_eq_one hunit_mul, hL2⟩ theorem rankOneRecoveryFromAmbiguity @@ -6113,7 +6148,7 @@ private theorem pkappa_eq_zero_of_eval_zero_wip have hmass := evalPkappa_total_mass hd kappa F have hintegral_zero : (∫ z, ‖evalPkappa kappa F z‖ ^ 2 ∂ gammaD d) = 0 := by simp [hF_eval] - have hnorm_sq : ‖F‖ ^ 2 = 0 := by linarith + have hnorm_sq : ‖F‖ ^ 2 = 0 := by linarith only [hmass, hintegral_zero] exact pkappa_eq_zero_of_norm_sq_eq_zero_wip hnorm_sq private theorem skappa_ext_coeff_exact_wip diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseAnnulusEstimate.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseAnnulusEstimate.lean index edbc28ba53..24e048e7a2 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseAnnulusEstimate.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseAnnulusEstimate.lean @@ -52,7 +52,7 @@ private theorem highAnnulusMass_le_norm_sq_wip {d : Nat} (hd : 0 < d) (kappa : MultiIndex d) (J : Nat) (H : Pkappa d kappa) : highAnnulusMass J (ofPkappa kappa H) <= ‖H‖ ^ 2 := by - linarith [annulusMassPartition hd kappa J H, + linarith only [annulusMassPartition hd kappa J H, lowAnnulusMass_nonneg_wip J (ofPkappa kappa H)] private theorem defect_nonneg_annulus @@ -230,7 +230,7 @@ private lemma gamma_lintegral_rotate_one_eq_annulus ∫⁻ z : Cd d, g z ∂ gammaD d := by have hgauss := rotate_one_gamma_preserving_annulus (d := d) (q0 := q0) (ω := ω) have hmeas := rotate_one_measurableEmbedding_annulus (d := d) (q0 := q0) (ω := ω) - simpa using hgauss.lintegral_comp_emb hmeas g + exact hgauss.lintegral_comp_emb hmeas g private theorem annulusCoordinateRotationAveraging {d : Nat} (j : Idx d) (q0 : Fin d) (F : Cd d → ENNReal) (hF : Measurable F) : @@ -404,7 +404,7 @@ private theorem norm_ne_zero_of_ne_zero_pkappa_annulus · have hcoeff_ne : F alpha ≠ 0 := Finsupp.mem_support_iff.mp hmem have hle : ‖F alpha‖ ^ 2 ≤ Finset.sum F.support (fun a : Idx d => ‖F a‖ ^ 2) := by - simpa using + exact (Finset.single_le_sum (f := fun a : Idx d => ‖F a‖ ^ 2) (s := F.support) (a := alpha) (fun a _ => by positivity) hmem) @@ -415,7 +415,7 @@ private theorem norm_ne_zero_of_ne_zero_pkappa_annulus have hsqrt_pos : 0 < Real.sqrt (Finset.sum F.support (fun a : Idx d => ‖F a‖ ^ 2)) := Real.sqrt_pos.mpr hsum_pos - linarith + linarith only [hnorm, hsqrt_pos] · exact Finsupp.notMem_support_iff.mp hmem private theorem integrable_evalPkappa_sq_annulus @@ -715,19 +715,19 @@ private theorem annulusBandSeparation_of_large_coord omega have hA_ge_2M : 2 * M + 1 ≤ A := by have hstep : 2 * M + 1 ≤ 4 * K * (2 * M + 1) * (M + 1) := by - have hfactor : 1 ≤ 4 * K * (M + 1) := by nlinarith + have hfactor : 1 ≤ 4 * K * (M + 1) := by nlinarith only [hK_ge] have hmul := Nat.mul_le_mul_right (2 * M + 1) hfactor simpa [mul_assoc, mul_left_comm, mul_comm] using hmul exact le_trans hstep hA_large have hA_ge_3K : 3 * K * (2 * M + 1) ≤ A := by have hstep : 3 * K * (2 * M + 1) ≤ 4 * K * (2 * M + 1) * (M + 1) := by - have hfactor : 3 ≤ 4 * (M + 1) := by nlinarith + have hfactor : 3 ≤ 4 * (M + 1) := by linarith only [] have hmul := Nat.mul_le_mul_right (K * (2 * M + 1)) hfactor simpa [mul_assoc, mul_left_comm, mul_comm] using hmul exact le_trans hstep hA_large - have htwo : 2 * R + 1 ≤ 3 * A := by nlinarith + have htwo : 2 * R + 1 ≤ 3 * A := by linarith only [hR, hA_ge_2M] change K * ((2 * M + 1) * (2 * R + 1)) ≤ A ^ 2 - nlinarith + nlinarith only [hlarge, hA_large, hK_ge, hR, hA_ge_2M, hA_ge_3K] private theorem highAnnulusBandSeparation_annulus {d : Nat} (hd : 0 < d) (D M : Nat) : @@ -785,10 +785,8 @@ private theorem annulus_mass_split_pointwise ‖evalPkappa kappa (remainderPartPkappa j M G) z‖ ≤ ‖evalPkappa kappa (localPartPkappa j M G) z‖ ^ 2 + ‖evalPkappa kappa (remainderPartPkappa j M G) z‖ ^ 2 := by - nlinarith [sq_nonneg - (‖evalPkappa kappa (localPartPkappa j M G) z‖ - - ‖evalPkappa kappa (remainderPartPkappa j M G) z‖)] - nlinarith + exact two_mul_le_add_sq _ _ + linarith only [hsq_norm, hxy] exact hsq · simp [Set.indicator, hz] @@ -905,9 +903,9 @@ private theorem integrable_baseDefectSq_annulus 2 * ‖evalPkappa kappa (F + G) z‖ ^ 2 + 2 * ‖evalPkappa kappa F z‖ ^ 2 := by rw [evalPkappa_add_apply_annulus kappa F G z] - nlinarith - [sq_nonneg (‖evalPkappa kappa F z + evalPkappa kappa G z‖ + - ‖evalPkappa kappa F z‖)] + linarith only [ + sq_nonneg (‖evalPkappa kappa F z + evalPkappa kappa G z‖ + ‖evalPkappa kappa F z‖) + ] simp_all simpa [Real.norm_eq_abs, abs_of_nonneg] using MeasureTheory.Integrable.mono' hsq hmeasSq hbound @@ -1164,11 +1162,11 @@ private theorem productAnnulus_eq_of_mem_annulus · by_contra hlt have hlt' : ℓ q + 1 ≤ j q := Nat.succ_le_of_lt (Nat.lt_of_not_ge hlt) have hlt_real : ((ℓ q : Nat) : ℝ) + 1 ≤ j q := by exact_mod_cast hlt' - linarith + linarith only [hj_lower, hℓ_upper, hlt_real] · by_contra hlt have hlt' : j q + 1 ≤ ℓ q := Nat.succ_le_of_lt (Nat.lt_of_not_ge hlt) have hlt_real : ((j q : Nat) : ℝ) + 1 ≤ ℓ q := by exact_mod_cast hlt' - linarith + linarith only [hj_upper, hℓ_lower, hlt_real] private theorem sum_indicator_productAnnulus_le_annulus {d : Nat} (s : Finset (Idx d)) (z : Cd d) (a : ℝ) @@ -1241,7 +1239,7 @@ private theorem finite_sum_baseDefectAnnulusMass_le ‖evalPkappa kappa F z‖) ^ 2 ∂ gammaD d := by refine MeasureTheory.integral_mono_ae hIntSum hIntGlobal ?_ filter_upwards with z - simpa [Set.indicator] using + exact sum_indicator_productAnnulus_le_annulus s z ((‖evalPkappa kappa F z + evalPkappa kappa G z‖ - ‖evalPkappa kappa F z‖) ^ 2) @@ -1279,10 +1277,10 @@ private theorem finite_sum_annulusMass_le_annulus _ ≤ ∫ z : Cd d, ‖evalPkappa kappa G z‖ ^ 2 ∂ gammaD d := by refine MeasureTheory.integral_mono_ae hInt hnorm ?_ filter_upwards with z - simpa [Set.indicator] using + exact sum_indicator_productAnnulus_le_annulus s z (‖evalPkappa kappa G z‖ ^ 2) (by positivity) - _ = ‖G‖ ^ 2 := by simpa using evalPkappa_total_mass hd kappa G + _ = ‖G‖ ^ 2 := by exact evalPkappa_total_mass hd kappa G private theorem phi1D_eq_oneDimPhi_annulus (k n : Nat) (z : ℂ) : @@ -1495,11 +1493,11 @@ private theorem evalPkappa_rotateCoord_circle_phase_sum_annulus = F alpha * ((fourier ((kappa q0 : Nat) : Int) x : ℂ) * Phi kappa alpha - (Function.update z q0 ((fourier (1 : Int) x : ℂ) * z q0))) := by ring_nf + (Function.update z q0 ((fourier (1 : Int) x : ℂ) * z q0))) := by ring _ = F alpha * ((fourier ((alpha q0 : Nat) : Int) x : ℂ) * Phi kappa alpha z) := by rw [hphase] _ = F alpha * Phi kappa alpha z * circleChar (alpha q0) x := by rw [hchar] - ring_nf + ring private theorem lowPoly_fiberCoeffLow_eq_sum_annulus {d : Nat} {kappa : MultiIndex d} @@ -1962,7 +1960,7 @@ private theorem high_annulus_coercive_step_annulus have hbase_nonneg : 0 ≤ baseDefectAnnulusMass kappa j F G := baseDefectAnnulusMass_nonneg_annulus kappa j F G - nlinarith + nlinarith only [hCnonneg, hsplit, hloc, hdef] private theorem evalPkappa_eq_evalHermiteSum_annulus {d : Nat} (kappa : MultiIndex d) (F : Pkappa d kappa) : @@ -2056,7 +2054,7 @@ private theorem summable_annulusMass_ofPkappa_annulus (G : Pkappa d kappa) : Summable (fun j : Idx d => annulusMass j (ofPkappa kappa G)) := summable_of_sum_le (fun j => annulusMass_nonneg_annulus j (ofPkappa kappa G)) - (fun s => by simpa using finite_sum_annulusMass_le_annulus hd kappa G s) + (fun s => by exact finite_sum_annulusMass_le_annulus hd kappa G s) private theorem mem_lowAnnuli_iff_annulus {d J : Nat} {j : Idx d} : @@ -2130,7 +2128,7 @@ private theorem highAnnulusMass_eq_tsum_high_annulus ‖G‖ ^ 2 - ∑ j ∈ lowAnnuli d J, a j := by rw [← hsub] dsimp [a] at hsplit htotal - linarith + linarith only [hsplit, htotal] unfold highAnnulusMass lowAnnulusMass rw [htotal_int, ← htail_max] exact htail_eq.symm @@ -2290,7 +2288,7 @@ private theorem finite_base_product_annulus_estimate_large_eps highAnnulusMass_le_norm_sq_wip hd kappa 0 G have hnorm_sq_nonneg : 0 <= ‖G‖ ^ 2 := by positivity have hdef_sq_nonneg : 0 <= defect F G ^ 2 := by positivity - nlinarith + nlinarith only [h_eps_large, hhigh_le] theorem finite_base_product_annulus_estimate {d : Nat} (hd : 0 < d) (kappa : MultiIndex d) @@ -2321,7 +2319,7 @@ theorem finite_base_product_annulus_estimate have hCloc_nonneg : 0 ≤ Cloc := le_of_lt hCloc_pos have hCrem_pos : 0 < Crem := by dsimp [Crem] - nlinarith + linarith only [h_eps, heps_large, hCloc_pos] have hCrem_nonneg : 0 ≤ Crem := le_of_lt hCrem_pos have hprod_tend : Filter.Tendsto @@ -2356,7 +2354,7 @@ theorem finite_base_product_annulus_estimate Cloc * baseDefectAnnulusMass kappa j F (localPartPkappa j M G) := by intro j G hlarge simpa [Cloc, hCgot_eq] using hlocal_got j G hlarge - refine ⟨Jloc, M, hM_one, 4 * Cloc, by nlinarith, ?_⟩ + refine ⟨Jloc, M, hM_one, 4 * Cloc, by linarith only [hCloc_pos], ?_⟩ intro G have htail_eq := highAnnulusMass_eq_tsum_high_annulus hd kappa Jloc G have htail_bound : @@ -2397,7 +2395,10 @@ theorem finite_base_product_annulus_estimate 0 ≤ 4 * Cloc * baseDefectAnnulusMass kappa j F G + Crem * - annulusMass j (ofPkappa kappa (remainderPartPkappa j M G)) := by nlinarith + annulusMass j (ofPkappa kappa (remainderPartPkappa j M G)) := by + nlinarith only [ + h_eps, heps_large, hCloc_pos, hrem_nonneg, hbase_nonneg + ] simpa [hlarge] using hrhs_nonneg calc ∑ j ∈ s, @@ -2423,7 +2424,7 @@ theorem finite_base_product_annulus_estimate exact add_le_add (mul_le_mul_of_nonneg_left (finite_sum_baseDefectAnnulusMass_le hd kappa F G s) - (by nlinarith)) + (by linarith only [hCloc_pos])) (mul_le_mul_of_nonneg_left (by dsimp [L] @@ -2464,8 +2465,8 @@ theorem finite_base_annulus_estimate intro H t eta hH_norm ht_pos ht_le_four heta_nonneg hdefect have hhigh_le : highAnnulusMass 0 (ofPkappa kappa H) <= ‖H‖ ^ 2 := highAnnulusMass_le_norm_sq_wip hd kappa 0 H - have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith [hH_norm] - nlinarith [sq_nonneg eta] + have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith only [hH_norm] + linarith only [heps_large, hhigh_le, hH_sq, sq_nonneg eta] · obtain ⟨J, M, hM, C, hC_pos, hann⟩ := finite_base_product_annulus_estimate hd kappa F hF eps h_eps refine ⟨J, C, hC_pos, ?_⟩ @@ -2474,10 +2475,10 @@ theorem finite_base_annulus_estimate rw [highAnnulusMass_ofPkappa_smul_real hd kappa J t H, norm_smul_pkappa_real_sq_annulus hd t H] at hprod have ht_sq_pos : 0 < t ^ 2 := by positivity - have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith [hH_norm] + have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith only [h_eps, heps_large, hH_norm] have hdef_nonneg : 0 <= defect F (t • H) := defect_nonneg_annulus F (t • H) have hdef_sq : defect F (t • H) ^ 2 <= (eta * t) ^ 2 := - sq_le_sq' (by nlinarith [heta_nonneg, ht_pos]) hdefect + sq_le_sq' (by linarith only [hdefect, hdef_nonneg, heta_nonneg, ht_pos]) hdefect have hdef_mul : C * defect F (t • H) ^ 2 <= C * (eta * t) ^ 2 := mul_le_mul_of_nonneg_left hdef_sq (le_of_lt hC_pos) have hscaled : @@ -2490,7 +2491,7 @@ theorem finite_base_annulus_estimate _ = t ^ 2 * (C * eta ^ 2 + eps) := by rw [hH_sq] ring - nlinarith + nlinarith only [ht_sq_pos, hscaled] theorem highAnnulusControl {d : Nat} (hd : 0 < d) (kappa : MultiIndex d) @@ -2524,7 +2525,10 @@ theorem highAnnulusControl have hmul := mul_le_mul_of_nonneg_left hdelta_le_inv (le_of_lt hC_pos) have hC_ne : C ≠ 0 := ne_of_gt hC_pos simp_all - have hdelta_sq_le : delta_high ^ 2 <= delta_high := by nlinarith [sq_nonneg delta_high] + have hdelta_sq_le : delta_high ^ 2 <= delta_high := by + nlinarith only [ + hdelta_high_pos, hdelta_le_one, sq_nonneg delta_high + ] have hCdelta_sq_le : C * delta_high ^ 2 <= 1 / 8 := by calc C * delta_high ^ 2 <= C * delta_high := @@ -2533,6 +2537,6 @@ theorem highAnnulusControl have hhigh : highAnnulusMass J (ofPkappa kappa H) <= C * delta_high ^ 2 + 1 / 8 := hann hH_norm ht_pos ht_le_four hdelta_nonneg hdefect - nlinarith + linarith only [hCdelta_sq_le, hhigh] end DimdPolyLEAN diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseCircleEstimate.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseCircleEstimate.lean index 3a4e4e5408..730f477780 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseCircleEstimate.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/FiniteBaseCircleEstimate.lean @@ -57,7 +57,7 @@ private theorem bandPoly_sub_fast_mul_slow_sub bandPoly N p x - circleChar N x * u = circleChar N x * (slowBandPoly p x - u) := by rw [bandPoly_eq_fast_mul_slow] - ring_nf + ring private theorem norm_circleChar_wip (n : Nat) (x : Circle) : ‖circleChar n x‖ = 1 := by simp [circleChar, norm_zeta] @@ -103,7 +103,7 @@ private theorem norm_circleChar_sub_le (n : Nat) (x y : Circle) : ‖circleChar n x - circleChar n y‖ <= (n : ℝ) * ‖zeta x - zeta y‖ := by - simpa only [circleChar_eq_zeta_pow] using + exact norm_pow_sub_pow_le_nat_mul_norm_sub (z := zeta x) (w := zeta y) (norm_zeta x) (norm_zeta y) n @@ -261,10 +261,13 @@ private theorem safe_square (h : b - c <= a) : (1 / 2) * b ^ 2 - c ^ 2 <= a ^ 2 := by by_cases hbc : b <= c - · have hnonpos : (1 / 2) * b ^ 2 - c ^ 2 <= 0 := by nlinarith [sq_nonneg b, sq_nonneg c] + · have hnonpos : (1 / 2) * b ^ 2 - c ^ 2 <= 0 := by + nlinarith only [ + hb, hc, hbc, sq_nonneg b, sq_nonneg c + ] exact hnonpos.trans (sq_nonneg a) - · have hbc_pos : 0 <= b - c := by linarith - have hsq_to_a : (b - c) ^ 2 <= a ^ 2 := by nlinarith + · have hbc_pos : 0 <= b - c := by linarith only [hbc] + have hsq_to_a : (b - c) ^ 2 <= a ^ 2 := by nlinarith only [ha, h, hbc] have hsq_from_bc : (1 / 2) * b ^ 2 - c ^ 2 <= (b - c) ^ 2 := by linarith only [sq_nonneg (b - 2 * c)] exact hsq_from_bc.trans hsq_to_a @@ -307,7 +310,7 @@ private theorem defect_pointwise_safe_carrier_average simp_all only [sub_sub_sub_cancel_right, neg_sub] _ = c := by simp [c, norm_bandPoly_sub_fast_mul] exact (le_abs_self (b - a)).trans (h_abs.trans h_norm) - have hmain : b - c <= a := by linarith + have hmain : b - c <= a := by linarith only [hba] have hsafe := safe_square (a := a) (b := b) (c := c) (abs_nonneg _) (abs_nonneg _) (norm_nonneg _) hmain @@ -421,7 +424,7 @@ private theorem carrierAverage_mass_le_defect_plus_variance let V : ℝ := arcIntegral I (fun x => ‖slowBandPoly p x - u‖ ^ 2) have hrot : arcLength I * ‖u‖ ^ 2 <= Crot * A := by - simpa [I, A, u] using carrierAverage_constCenter_sq_le_defect + exact carrierAverage_constCenter_sq_le_defect (N := N) k p hc have hsafe : (1 / 2) * A - V <= Dint := by @@ -429,11 +432,11 @@ private theorem carrierAverage_mass_le_defect_plus_variance defect_setIntegral_safe_carrier_average (arcSet I) (fun _ : Circle => c) continuous_const N p u exact h - have hA : A <= 2 * Dint + 2 * V := by nlinarith + have hA : A <= 2 * Dint + 2 * V := by linarith only [hsafe] calc arcLength (carrierArc N k) * ‖carrierAverage (N := N) k (slowBandPoly p)‖ ^ 2 - <= Crot * A := by simpa only [I, u] using hrot + <= Crot * A := by exact hrot _ <= Crot * (2 * Dint + 2 * V) := mul_le_mul_of_nonneg_left hA (le_of_lt Crot_pos) _ = @@ -556,8 +559,8 @@ private theorem norm_inv_le_two_of_norm_sub_one_le_half {lam : ℂ} have hneg : 1 - ‖lam‖ <= |‖lam‖ - 1| := by rw [show 1 - ‖lam‖ = -(‖lam‖ - 1) by ring] exact neg_le_abs _ - linarith - have hpos : 0 < ‖lam‖ := by linarith + linarith only [hclose, habs, hneg] + have hpos : 0 < ‖lam‖ := by linarith only [hlower] rw [norm_inv, inv_le_comm₀ hpos (by norm_num : (0 : ℝ) < 2)] linarith only [hlower] @@ -572,7 +575,7 @@ private theorem norm_inv_sub_one_le_two_mul_norm_sub_one_of_close {lam : ℂ} have hneg : 1 - ‖lam‖ <= |‖lam‖ - 1| := by rw [show 1 - ‖lam‖ = -(‖lam‖ - 1) by ring] exact neg_le_abs _ - linarith + linarith only [hclose, habs, hneg] have hlam : lam ≠ 0 := by intro hzero subst lam @@ -616,7 +619,7 @@ private theorem defect_pointwise_const_center_compare_of_close have hle : b - a <= |a - b| := by rw [show b - a = -(a - b) by ring] exact neg_le_abs _ - linarith + linarith only [hstab, hle] have he_nonneg : 0 <= e := by dsimp [e] positivity @@ -721,14 +724,14 @@ private theorem defect_setIntegral_const_center_compare_fast have hleft_nonneg : 0 <= 4 * ‖lam - 1‖ * ‖u‖ := by positivity have hright_nonneg : 0 <= 4 * theta * ‖u‖ := by positivity have hmul : 4 * ‖lam - 1‖ * ‖u‖ <= 4 * theta * ‖u‖ := by - nlinarith [norm_nonneg (lam - 1), norm_nonneg u] - nlinarith + nlinarith only [hclose, norm_nonneg (lam - 1), norm_nonneg u] + nlinarith only [hleft_nonneg, hright_nonneg, hmul] calc (1 / 2) * (‖c + circleChar N x * u‖ - ‖c‖) ^ 2 - (4 * theta * ‖u‖) ^ 2 <= (1 / 2) * (‖c + circleChar N x * u‖ - ‖c‖) ^ 2 - - (4 * ‖lam - 1‖ * ‖u‖) ^ 2 := by nlinarith + (4 * ‖lam - 1‖ * ‖u‖) ^ 2 := by linarith only [herr] _ <= (‖lam * c + circleChar N x * u‖ - ‖lam * c‖) ^ 2 := hpoint _ = (‖Q x + circleChar N x * u‖ - ‖Q x‖) ^ 2 := by rw [hQx] calc @@ -808,14 +811,14 @@ private theorem defect_setIntegral_const_center_compare have hleft_nonneg : 0 <= 4 * ‖lam - 1‖ * ‖P x‖ := by positivity have hright_nonneg : 0 <= 4 * theta * ‖P x‖ := by positivity have hmul : 4 * ‖lam - 1‖ * ‖P x‖ <= - 4 * theta * ‖P x‖ := by nlinarith [norm_nonneg (lam - 1), norm_nonneg (P x)] - nlinarith + 4 * theta * ‖P x‖ := by nlinarith only [hclose, norm_nonneg (lam - 1), norm_nonneg (P x)] + nlinarith only [hleft_nonneg, hright_nonneg, hmul] calc (1 / 2) * (‖c + P x‖ - ‖c‖) ^ 2 - (4 * theta * ‖P x‖) ^ 2 <= (1 / 2) * (‖c + P x‖ - ‖c‖) ^ 2 - - (4 * ‖lam - 1‖ * ‖P x‖) ^ 2 := by nlinarith + (4 * ‖lam - 1‖ * ‖P x‖) ^ 2 := by linarith only [herr] _ <= (‖lam * c + P x‖ - ‖lam * c‖) ^ 2 := hpoint _ = (‖Q x + P x‖ - ‖Q x‖) ^ 2 := by rw [hQx] calc @@ -903,20 +906,20 @@ theorem circleConst_pos (D : Nat) : 0 < circleConst D := by theorem circleConst_ge_one (D : Nat) : 1 <= circleConst D := by dsimp [circleConst] have hgap : (1 : ℝ) <= ((circleGap D : Nat) : ℝ) := by exact_mod_cast circleGap_pos D - nlinarith [sq_nonneg (((circleGap D : Nat) : ℝ) - 1)] + linarith only [hgap, sq_nonneg (((circleGap D : Nat) : ℝ) - 1)] theorem thirty_two_le_circleConst (D : Nat) : (32 : ℝ) <= circleConst D := by dsimp [circleConst] have hgap : (1 : ℝ) <= ((circleGap D : Nat) : ℝ) := by exact_mod_cast circleGap_pos D - nlinarith [sq_nonneg (((circleGap D : Nat) : ℝ) - 1)] + linarith only [hgap, sq_nonneg (((circleGap D : Nat) : ℝ) - 1)] private theorem one_thousand_twenty_four_le_circleConst (D : Nat) : (1024 : ℝ) <= circleConst D := by dsimp [circleConst] have hgap : (37 : ℝ) <= ((circleGap D : Nat) : ℝ) := by exact_mod_cast circleGap_ge_37 D have hsq : (16 : ℝ) <= ((circleGap D : Nat) : ℝ) ^ 2 := by - nlinarith [sq_nonneg (((circleGap D : Nat) : ℝ) - 37)] - nlinarith + linarith only [hgap, sq_nonneg (((circleGap D : Nat) : ℝ) - 37)] + linarith only [hsq] private theorem Crot_le_circleConst_of_pos {D : Nat} (hD : 0 < D) : Crot <= circleConst D := by @@ -924,9 +927,9 @@ private theorem Crot_le_circleConst_of_pos {D : Nat} (hD : 0 < D) : dsimp [Crot, circleConst] have hgap : (37 : ℝ) <= ((circleGap D : Nat) : ℝ) := by exact_mod_cast circleGap_ge_37 D have hsq : (4 : ℝ) <= ((circleGap D : Nat) : ℝ) ^ 2 := by - nlinarith [sq_nonneg (((circleGap D : Nat) : ℝ) - 37)] + linarith only [hgap, sq_nonneg (((circleGap D : Nat) : ℝ) - 37)] have hpi : Real.pi <= 4 := le_of_lt Real.pi_lt_four - nlinarith + linarith only [hsq, hpi] private noncomputable def polyOfCoeff {D : Nat} (q : Fin (D + 1) -> ℂ) : Polynomial ℂ := @@ -1053,7 +1056,7 @@ private theorem complex_multiset_prod_norm_le_perturbed simp_all only [Multiset.mem_cons, or_true, implies_true, Multiset.norm_prod_map, forall_const, forall_eq_or_imp, and_self, add_sub_cancel] _ <= ‖a ζ‖ + ‖b ζ - a ζ‖ := norm_add_le _ _ - _ <= ‖a ζ‖ + eps * ‖a ζ‖ := by nlinarith + _ <= ‖a ζ‖ + eps * ‖a ζ‖ := by linarith only [hζ] _ = (1 + eps) * ‖a ζ‖ := by ring have hprod_nonneg : 0 <= ‖(s.map b).prod‖ := norm_nonneg _ have hcoef_nonneg : 0 <= (1 + eps) * ‖a ζ‖ := by positivity @@ -1088,7 +1091,7 @@ private theorem complex_multiset_prod_sub_norm_le_perturbed have hprod_b := complex_multiset_prod_norm_le_perturbed s a b heps hs let A : ℝ := (s.map fun ζ => ‖a ζ‖).prod let r : ℝ := 1 + eps - have hr_nonneg : 0 <= r := by dsimp [r]; linarith + have hr_nonneg : 0 <= r := by dsimp [r]; linarith only [heps] have hA_nonneg : 0 <= A := by dsimp [A] refine Multiset.prod_nonneg @@ -1097,7 +1100,7 @@ private theorem complex_multiset_prod_sub_norm_le_perturbed and_self, Multiset.norm_prod_map, Multiset.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, norm_nonneg] have hpow_ge_one : 1 <= r ^ s.card := by - have hr_ge_one : 1 <= r := by dsimp [r]; linarith + have hr_ge_one : 1 <= r := by dsimp [r]; linarith only [heps] exact one_le_pow₀ (n := s.card) hr_ge_one have hdecomp : ((ζ ::ₘ s).map b).prod - ((ζ ::ₘ s).map a).prod = @@ -1134,7 +1137,7 @@ private theorem complex_multiset_prod_sub_norm_le_perturbed ‖a ζ‖ * ((r ^ s.card - 1) * A) := mul_le_mul_of_nonneg_left (by simpa only [r, A] using ih') (norm_nonneg _) - nlinarith + linarith only [hmul1, hmul2] _ = ((1 + eps) ^ (ζ ::ₘ s).card - 1) * (((ζ ::ₘ s).map fun ζ => ‖a ζ‖).prod) := by @@ -1226,7 +1229,7 @@ private theorem one_add_eps_pow_sub_one_le_two_nat_mul (hsmall : 2 * (n : ℝ) * eps <= 1) : (1 + eps) ^ n - 1 <= 2 * (n : ℝ) * eps := by have h := one_add_eps_pow_le_one_add_two_nat_mul heps n hsmall - linarith + linarith only [h] private theorem one_add_eps_pow_sub_one_le_of_nat_le {m D : Nat} {eps theta : ℝ} (heps : 0 <= eps) (hmD : m <= D) @@ -1253,7 +1256,7 @@ private theorem one_add_degree_eps_pow_sub_one_le_one_div_sixtyfour have hthetaD : 2 * (D : ℝ) * eps <= (1 / 64 : ℝ) := by dsimp [eps] field_simp [hD1pos.ne'] - nlinarith + linarith only [hDleD1] have hsmallD : 2 * (D : ℝ) * eps <= 1 := by have h : (1 / 64 : ℝ) <= 1 := by norm_num exact hthetaD.trans h @@ -1462,7 +1465,7 @@ private theorem carrierArc_left_lt_right_wip {N : Nat} (k : Fin N) : (carrierArc N k).left < (carrierArc N k).right := by have hlen := carrierArc_length_pos_wip k dsimp [arcLength] at hlen - linarith + linarith only [hlen] private theorem carrierArc_arcSet_eq_mk_image_Icc_wip {N : Nat} (k : Fin N) : arcSet (carrierArc N k) = @@ -1492,13 +1495,13 @@ private theorem carrierArc_arcSet_eq_mk_image_Icc_wip {N : Nat} (k : Fin N) : · dsimp [t] rw [div_le_one hlen_pos] dsimp [arcLength] - linarith [hy.2] + linarith only [hy.2] · dsimp [arcParam, t] have hlen_pos : 0 < arcLength (carrierArc N k) := carrierArc_length_pos_wip k apply congrArg (fun r : ℝ => (QuotientAddGroup.mk r : Circle)) field_simp [ne_of_gt hlen_pos] - ring_nf + ring private theorem circle_dist_mk_le_abs_sub (a b : ℝ) : dist ((QuotientAddGroup.mk a : Circle)) (QuotientAddGroup.mk b) <= |a - b| := by @@ -1604,8 +1607,8 @@ private theorem carrierArc_dist_le_length {N : Nat} (k : Fin N) : dsimp [arcLength] apply abs_le.mpr constructor - · linarith [ha.1, hb.2] - · linarith [ha.2, hb.1] + · linarith only [ha.1, hb.2] + · linarith only [ha.2, hb.1] exact hdist.trans habs private theorem carrierArc_arcSet_eq_mk_image_Ioc_union_left_wip @@ -1869,7 +1872,7 @@ private theorem badCarrierForRoot_union_subset_closedBall_of_center calc ‖zeta x - zeta x0‖ = ‖(zeta x - ζ) + (ζ - zeta x0)‖ := by - simp_all only [sub_add_sub_cancel] + simp only [sub_add_sub_cancel] _ <= ‖zeta x - ζ‖ + ‖ζ - zeta x0‖ := norm_add_le _ _ _ <= delta + delta := by exact add_le_add (le_of_lt hx_close) (le_of_lt hx0_close') _ = 2 * delta := by ring @@ -2466,7 +2469,7 @@ private theorem badCarrierIndicesForRoot_card_le_of_delta_eq rw [hdelta] field_simp [hNpos_real.ne'] _ <= (82 * (B : ℝ)) / (N : ℝ) := by - have hnum : 16 * (B : ℝ) + 2 <= 82 * (B : ℝ) := by nlinarith + have hnum : 16 * (B : ℝ) + 2 <= 82 * (B : ℝ) := by linarith only [hBreal] exact div_le_div_of_nonneg_right hnum (le_of_lt hNpos_real) _ = ((82 * B : Nat) : ℝ) * (N : ℝ)⁻¹ := by norm_num @@ -2501,7 +2504,7 @@ private theorem carrierArc_length_le_canonical_delta have hratio : (1 : ℝ) <= (circleBadConst D : ℝ) / ((D + 1 : Nat) : ℝ) := by rw [le_div_iff₀ hsucc_pos] simpa only [Nat.cast_add, Nat.cast_one, one_mul] using hbad_ge_real - nlinarith + linarith only [hratio] calc (2 * Real.pi) / (N : ℝ) <= 8 / (N : ℝ) := div_le_div_of_nonneg_right htwo_pi_le_eight (le_of_lt hNpos) @@ -2655,7 +2658,7 @@ private theorem setIntegral_bias_variance_of_mean_zero intro x have h := norm_add_sq_real c (f x - c) simp only [add_sub_cancel] at h - linarith + linarith only [h] have h1 : ∫ x in s, (‖f x‖ ^ 2 - ‖f x - c‖ ^ 2) ∂ μ = ∫ x in s, @@ -2693,7 +2696,7 @@ private theorem setIntegral_bias_variance_of_mean_zero (MeasureTheory.integrable_const _)] rw [MeasureTheory.integral_const_mul, MeasureTheory.integral_const] simp [MeasureTheory.Measure.real, mul_comm] - linarith [h1, hsplit, hrhs, hcross] + linarith only [h1, hsplit, hrhs, hcross] private theorem carrierAverage_bias_variance {N : Nat} (k : Fin N) {L : Nat} (p : Fin L -> ℂ) : @@ -2706,7 +2709,7 @@ private theorem carrierAverage_bias_variance carrierAverage (N := N) k (slowBandPoly p)‖ ^ 2 ∂ μCircle := by let f : Circle -> ℂ := slowBandPoly p let c : ℂ := carrierAverage (N := N) k f - have hf_cont : Continuous f := by simpa [f] using continuous_slowBandPoly p + have hf_cont : Continuous f := by exact continuous_slowBandPoly p have hfsq_cont : Continuous fun x : Circle => ‖f x‖ ^ 2 := hf_cont.norm.pow 2 have hgc_sq_cont : Continuous fun x : Circle => ‖f x - c‖ ^ 2 := @@ -2715,19 +2718,19 @@ private theorem carrierAverage_bias_variance dsimp [μCircle] infer_instance have hf : MeasureTheory.Integrable f μCircle := by - simpa only [μCircle, f] using + exact hf_cont.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) have hfsq : MeasureTheory.Integrable (fun x : Circle => ‖f x‖ ^ 2) μCircle := by - simpa only [μCircle, f] using + exact hfsq_cont.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) have hgc_sq : MeasureTheory.Integrable (fun x : Circle => ‖f x - c‖ ^ 2) μCircle := by - simpa only [μCircle, f, c] using + exact hgc_sq_cont.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) have hmean : (∫ x in arcSet (carrierArc N k), f x - c ∂ μCircle) = 0 := by - simpa [f, c] using carrierAverage_sub_mean_integral_zero k f hf - simpa [f, c] using + exact carrierAverage_sub_mean_integral_zero k f hf + exact setIntegral_bias_variance_of_mean_zero (μ := μCircle) (s := arcSet (carrierArc N k)) f c hf hfsq hgc_sq hmean @@ -2800,7 +2803,10 @@ private theorem carrierAverage_fast_theta_error_le_half_mass_plus_variance 4 * Crot * (4 * theta) ^ 2 * (1 / (2 * Real.pi)) <= (1 / 2 : ℝ) := by unfold Crot - have htheta_sq : theta ^ 2 <= (1 / 64 : ℝ) ^ 2 := by nlinarith [sq_nonneg (theta - 1 / 64)] + have htheta_sq : theta ^ 2 <= (1 / 64 : ℝ) ^ 2 := by + nlinarith only [ + htheta_nonneg, htheta_le_small, sq_nonneg (theta - 1 / 64) + ] have hpi_pos : 0 < Real.pi := Real.pi_pos field_simp [ne_of_gt hpi_pos] linarith only [htheta_sq] @@ -2823,7 +2829,7 @@ private theorem carrierAverage_fast_theta_error_le_half_mass_plus_variance 4 * Crot * (4 * theta) ^ 2 * V := by have hmul := mul_le_mul_of_nonneg_right hcoef hX_nonneg - nlinarith + linarith only [hmul] _ = (1 / 2) * (arcLength (carrierArc N k) * @@ -2938,7 +2944,7 @@ private theorem carrierArc_chord_le_length {N : Nat} (k : Fin N) : simpa only [norm_mul, Real.norm_eq_abs, Complex.ofReal_mul] using (Real.norm_exp_I_mul_ofReal_sub_one_le (x := t * arcLength I)) _ = t * arcLength I := by rw [Real.norm_of_nonneg (mul_nonneg ht_nonneg hlen_nonneg)] - _ <= arcLength I := by nlinarith + _ <= arcLength I := by nlinarith only [hlen_nonneg, ht_le] private theorem slowBandPoly_sub_carrierBase_le_slope_length {N L : Nat} (k : Fin N) (p : Fin L -> ℂ) : @@ -2949,12 +2955,12 @@ private theorem slowBandPoly_sub_carrierBase_le_slope_length intro x hx have hchord := carrierArc_chord_le_length k x hx let S : ℝ := ∑ m : Fin L, ‖p m‖ * (m.1 : ℝ) - have hS_nonneg : 0 <= S := by simpa [S] using slowBandPoly_slope_nonneg p + have hS_nonneg : 0 <= S := by exact slowBandPoly_slope_nonneg p have hosc := norm_slowBandPoly_sub_le_chord p x (carrierBase k) have hmul : S * ‖zeta x - zeta (carrierBase k)‖ <= S * arcLength (carrierArc N k) := mul_le_mul_of_nonneg_left hchord hS_nonneg - exact hosc.trans (by simpa only [S] using hmul) + exact hosc.trans (by exact hmul) private theorem lowPoly_norm_lower_on_goodCarrier {D N : Nat} (q : Fin (D + 1) -> ℂ) {delta : ℝ} (hdelta : 0 <= delta) @@ -2979,7 +2985,10 @@ private theorem lowPoly_ne_zero_on_goodCarrier {D N : Nat} norm_leadingCoeff_polyOfCoeff_pos_of_ne_zero hq have hpow_pos : 0 < delta ^ (polyOfCoeff q).roots.card := pow_pos hdelta_pos _ - have hnorm_pos : 0 < ‖lowPoly q x‖ := by nlinarith [mul_pos hlead_pos hpow_pos] + have hnorm_pos : 0 < ‖lowPoly q x‖ := by + linarith only [ + hlower, hlead_pos, hpow_pos, mul_pos hlead_pos hpow_pos + ] exact norm_pos_iff.mp hnorm_pos private theorem lowPoly_ne_zero_at_goodCarrierBase {D N : Nat} @@ -3094,11 +3103,11 @@ private theorem goodCarrier_absolute_oscillation_of_chord_bound delta ^ (polyOfCoeff q).roots.card) := by intro x hx let S : ℝ := ∑ n : Fin (D + 1), ‖q n‖ * (n.1 : ℝ) - have hS_nonneg : 0 <= S := by simpa [S] using lowPoly_slope_nonneg q + have hS_nonneg : 0 <= S := by exact lowPoly_slope_nonneg q have hosc := norm_lowPoly_sub_le_chord q x (carrierBase k) have hSR : S * ‖zeta x - zeta (carrierBase k)‖ <= S * R := mul_le_mul_of_nonneg_left (hchord x hx) hS_nonneg - exact hosc.trans (hSR.trans (by simpa only [S] using hslope)) + exact hosc.trans (hSR.trans (by exact hslope)) private theorem goodCarrier_defect_compare_band {D N L : Nat} {q : Fin (D + 1) -> ℂ} (hq : q ≠ 0) (p : Fin L -> ℂ) @@ -3187,7 +3196,7 @@ private theorem goodCarrier_base_mass_le_actual_defect_plus_fast_variance_error defect_setIntegral_safe_carrier_average s (lowPoly q) (continuous_lowPoly q) N p u simpa only [one_div, tsub_le_iff_right, ge_iff_le, B, Dint, V, u, s] using h - have hA : A <= 4 * Dint + 4 * V + 2 * E := by nlinarith + have hA : A <= 4 * Dint + 4 * V + 2 * E := by linarith only [hfast_compare, hsafe] have hmul : Crot * A <= Crot * (4 * Dint + 4 * V + 2 * E) := mul_le_mul_of_nonneg_left hA (le_of_lt Crot_pos) calc @@ -3260,7 +3269,10 @@ private theorem carrier_fast_theta_error_le_half_base (4 * theta * ‖u‖) ^ 2 * μCircle.real s := by rw [MeasureTheory.integral_const] simp [MeasureTheory.Measure.real, mul_comm] - have htheta_sq : theta ^ 2 <= (1 / 64 : ℝ) ^ 2 := by nlinarith [sq_nonneg (theta - 1 / 64)] + have htheta_sq : theta ^ 2 <= (1 / 64 : ℝ) ^ 2 := by + nlinarith only [ + htheta_nonneg, htheta_le_small, sq_nonneg (theta - 1 / 64) + ] have hell_nonneg : 0 <= arcLength (carrierArc N k) := arcLength_nonneg (carrierArc N k) have hnorm_sq : 0 <= ‖u‖ ^ 2 := sq_nonneg ‖u‖ @@ -3274,7 +3286,7 @@ private theorem carrier_fast_theta_error_le_half_base have hpi_ne : Real.pi ≠ 0 := ne_of_gt Real.pi_pos have hu_norm : ‖u‖ ^ 2 = ‖slowBandPoly p (carrierBase k)‖ ^ 2 := by rfl - have hcoef : 2 * 64 * 4 ^ 2 * theta ^ 2 <= (1 : ℝ) := by nlinarith + have hcoef : 2 * 64 * 4 ^ 2 * theta ^ 2 <= (1 : ℝ) := by linarith only [htheta_sq] have hcoefprod : 2 * 64 * 4 ^ 2 * theta ^ 2 * ‖u‖ ^ 2 * arcLength (carrierArc N k) <= @@ -3283,7 +3295,7 @@ private theorem carrier_fast_theta_error_le_half_base rw [← hu_norm] linarith only [mul_le_mul_of_nonneg_right hcoef (mul_nonneg hnorm_sq hell_nonneg)] field_simp [hpi_ne] - linarith + linarith only [hcoefprod] private theorem goodCarrier_base_mass_le_actual_defect_plus_fast_variance_absorbed_of_arcLength_slope @@ -3334,8 +3346,8 @@ private theorem htheta_nonneg htheta_le_small calc X <= 4 * Crot * Dint + 4 * Crot * V + E := hraw - _ <= 4 * Crot * Dint + 4 * Crot * V + (1 / 2) * X := by nlinarith - _ <= 8 * Crot * Dint + 8 * Crot * V := by nlinarith + _ <= 4 * Crot * Dint + 4 * Crot * V + (1 / 2) * X := by linarith only [hE] + _ <= 8 * Crot * Dint + 8 * Crot * V := by linarith only [hraw, hE] private theorem goodCarrier_base_mass_le_actual_defect_plus_fast_variance_absorbed {D N L : Nat} @@ -3382,8 +3394,8 @@ private theorem goodCarrier_base_mass_le_actual_defect_plus_fast_variance_absorb htheta_nonneg htheta_le_small calc X <= 4 * Crot * Dint + 4 * Crot * V + E := hraw - _ <= 4 * Crot * Dint + 4 * Crot * V + (1 / 2) * X := by nlinarith - _ <= 8 * Crot * Dint + 8 * Crot * V := by nlinarith + _ <= 4 * Crot * Dint + 4 * Crot * V + (1 / 2) * X := by linarith only [hE] + _ <= 8 * Crot * Dint + 8 * Crot * V := by linarith only [hraw, hE] private theorem goodCarrier_base_mass_le_actual_defect_plus_fast_variance_absorbed_of_root_product_arcLength @@ -3462,7 +3474,7 @@ private theorem goodCarrier_average_mass_le_actual_defect_plus_errors simpa only [one_div, tsub_le_iff_right, A, Dint, E, c] using goodCarrier_defect_compare_band (q := q) hq p hdelta_pos htheta_nonneg htheta_le hgood hosc - have hA : A <= 2 * Dint + 2 * E := by nlinarith + have hA : A <= 2 * Dint + 2 * E := by linarith only [hcompare] calc arcLength (carrierArc N k) * ‖carrierAverage (N := N) k (slowBandPoly p)‖ ^ 2 @@ -3472,7 +3484,7 @@ private theorem goodCarrier_average_mass_le_actual_defect_plus_errors have hmul : 2 * Crot * A <= 2 * Crot * (2 * Dint + 2 * E) := mul_le_mul_of_nonneg_left hA hcoef_nonneg - nlinarith + linarith only [hmul] _ = 4 * Crot * ∫ x in arcSet (carrierArc N k), @@ -3528,7 +3540,7 @@ private theorem goodCarrier_average_mass_le_actual_defect_plus_fast_variance_abs have hE : 4 * Crot * E <= (1 / 2) * X + 4 * Crot * (4 * theta) ^ 2 * V := by - simpa only [one_div, X, E, V] using + exact carrierAverage_fast_theta_error_le_half_mass_plus_variance (N := N) (L := L) k p htheta_nonneg htheta_le_small calc @@ -3536,10 +3548,10 @@ private theorem goodCarrier_average_mass_le_actual_defect_plus_fast_variance_abs _ <= 4 * Crot * Dint + ((1 / 2) * X + 4 * Crot * (4 * theta) ^ 2 * V) + - 2 * Crot * V := by nlinarith + 2 * Crot * V := by linarith only [hE] _ <= 8 * Crot * Dint + - (8 * Crot * (4 * theta) ^ 2 + 4 * Crot) * V := by nlinarith + (8 * Crot * (4 * theta) ^ 2 + 4 * Crot) * V := by linarith only [hraw, hE] _ = 8 * Crot * ∫ x in arcSet (carrierArc N k), @@ -3735,7 +3747,7 @@ private theorem slowBandPolyDerivCircle_l2_le {L : Nat} have hmlt : m.1 < L := m.2 exact_mod_cast (show (m.1 : ℤ) <= (L : ℤ) - 1 by omega) have hm_nonneg : 0 <= (m.1 : ℝ) := by exact_mod_cast Nat.zero_le m.1 - have hm_lower : -((L : ℝ) - 1) <= (m.1 : ℝ) := by linarith + have hm_lower : -((L : ℝ) - 1) <= (m.1 : ℝ) := by linarith only [hm_le] exact mul_le_mul_of_nonneg_right (sq_le_sq' hm_lower hm_le) (sq_nonneg _) @@ -3906,19 +3918,19 @@ private theorem slowBandPoly_sub_carrierBase_sq_le_L_cubed_l2_length_sq let ell : ℝ := arcLength (carrierArc N k) have hosc : ‖slowBandPoly p x - slowBandPoly p (carrierBase k)‖ <= S * ell := by - simpa [S, ell] using + exact slowBandPoly_sub_carrierBase_le_slope_length k p x hx have hnorm_nonneg : 0 <= ‖slowBandPoly p x - slowBandPoly p (carrierBase k)‖ := norm_nonneg _ - have hS_nonneg : 0 <= S := by simpa [S] using slowBandPoly_slope_nonneg p - have hell_nonneg : 0 <= ell := by simpa [ell] using arcLength_nonneg (carrierArc N k) + have hS_nonneg : 0 <= S := by exact slowBandPoly_slope_nonneg p + have hell_nonneg : 0 <= ell := by exact arcLength_nonneg (carrierArc N k) have hmul_nonneg : 0 <= S * ell := mul_nonneg hS_nonneg hell_nonneg have hsquare : ‖slowBandPoly p x - slowBandPoly p (carrierBase k)‖ ^ 2 <= - (S * ell) ^ 2 := by nlinarith + (S * ell) ^ 2 := by nlinarith only [hosc, hnorm_nonneg] have hSsq : S ^ 2 <= (L : ℝ) ^ 3 * circleL2Sq (slowBandPoly p) := by - simpa [S] using slowBandPoly_slope_sq_le_L_cubed_l2 p + exact slowBandPoly_slope_sq_le_L_cubed_l2 p have hellsq_nonneg : 0 <= ell ^ 2 := sq_nonneg ell calc ‖slowBandPoly p x - slowBandPoly p (carrierBase k)‖ ^ 2 @@ -3992,7 +4004,7 @@ private theorem slowBandPoly_norm_sq_le_L_circleL2Sq {L : Nat} (∑ m : Fin L, ‖p m‖) ^ 2 <= ((Finset.univ : Finset (Fin L)).card : ℝ) * ∑ m : Fin L, ‖p m‖ ^ 2 := by - simpa only [Finset.card_univ, Fintype.card_fin] using + exact (sq_sum_le_card_mul_sum_sq (s := (Finset.univ : Finset (Fin L))) (f := fun m : Fin L => ‖p m‖) : _) @@ -4072,7 +4084,7 @@ private theorem carrierAverage_mass_le_slow_l2 arcLength (carrierArc N k) / (2 * Real.pi) * ‖carrierAverage (N := N) k (slowBandPoly p)‖ ^ 2 <= ∫ x in arcSet (carrierArc N k), - ‖slowBandPoly p x‖ ^ 2 ∂ μCircle := by nlinarith + ‖slowBandPoly p x‖ ^ 2 ∂ μCircle := by linarith only [hbv, hvar_nonneg] have hperiod_nonneg : 0 <= (2 * Real.pi : ℝ) := by positivity have hmul := mul_le_mul_of_nonneg_left hle hperiod_nonneg @@ -4340,7 +4352,7 @@ private theorem rfl have htheta_bound : (1 + eps) ^ (polyOfCoeff q).roots.card - 1 <= theta := by - simpa [eps, theta] using root_product_theta_bound_one_div_sixtyfour q + exact root_product_theta_bound_one_div_sixtyfour q have hlocal : ∑ k ∈ K, arcLength (carrierArc N k) * @@ -4355,8 +4367,8 @@ private theorem (q := q) hq p hdelta_pos (eps := eps) (theta := theta) heps htheta_bound htheta_nonneg htheta_le htheta_le_small - (hgood k hk) (by simpa [eps] using harc k hk) - simpa [Dterm, Vterm, theta] using h + (hgood k hk) (by exact harc k hk) + exact h have hsplit : ∑ k ∈ K, (8 * Crot * Dterm k + @@ -4366,7 +4378,7 @@ private theorem (∑ k ∈ K, Vterm k) := by simp [Finset.sum_add_distrib, Finset.mul_sum] have hD : ∑ k ∈ K, Dterm k <= defectSq (lowPoly q) (bandPoly N p) := by - simpa [Dterm] using sum_carrier_defect_integrals_le_global_defectSq K q p + exact sum_carrier_defect_integrals_le_global_defectSq K q p have hcoefD : 0 <= 8 * Crot := by linarith only [Crot_pos] have hDmul : 8 * Crot * (∑ k ∈ K, Dterm k) <= @@ -4388,7 +4400,7 @@ private theorem _ <= 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + (8 * Crot * (4 * theta) ^ 2 + 4 * Crot) * - (∑ k ∈ K, Vterm k) := by nlinarith + (∑ k ∈ K, Vterm k) := by linarith only [hDmul] _ = 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + (8 * Crot * (4 * (1 / 64 : ℝ)) ^ 2 + 4 * Crot) * @@ -4481,7 +4493,7 @@ private theorem sum_goodCarrier_base_mass_le_global_defect_plus_fast_variance_of 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + 8 * Crot * (((L : ℝ) ^ 3 * circleL2Sq (slowBandPoly p)) * - ((2 * Real.pi) / (N : ℝ)) ^ 2) := by nlinarith + ((2 * Real.pi) / (N : ℝ)) ^ 2) := by linarith only [hDmul, hVmul] private theorem sum_goodCarrier_base_mass_le_global_defect_plus_fast_variance_of_root_product_arcLength @@ -4624,27 +4636,27 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_variance circleL2Sq (slowBandPoly p) = (1 / (2 * Real.pi)) * (∑ k : Fin N, Avg k) + ∑ k : Fin N, V k := by - simpa only [one_div, mul_inv_rev, Avg, V] using + exact slowBandPoly_l2_eq_average_mass_plus_variance (N := N) (L := L) hN p have hsplit : ∑ k : Fin N, Avg k = ∑ k ∈ G, Avg k + ∑ k ∈ B, Avg k := by - simpa [G, B, Avg] using + exact sum_carrier_average_mass_eq_good_add_bad (D := D) (N := N) (L := L) q p (delta := delta) have hgood : ∑ k ∈ G, Avg k <= 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + Cvar * (∑ k ∈ G, V k) := by - simpa only [one_div, G, Avg, V, Cvar] using + exact sum_goodCarrier_average_mass_le_global_defect_plus_variance_of_root_product_canonical (D := D) (N := N) (L := L) (q := q) hq p hdelta_pos G (fun k hk => goodCarrierIndices_not_bad hk) - (by simpa only [Nat.cast_add, Nat.cast_one, one_div, mul_inv_rev, G] using harc) + (by exact harc) have hbad : ∑ k ∈ B, Avg k <= BadBd := by - simpa [B, Avg, BadBd] using + exact sum_badCarrier_average_mass_le_card_L_l2 (D := D) (N := N) (L := L) q p (delta := delta) have hVsubset : @@ -4656,7 +4668,7 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_variance have hC : 0 <= Crot := le_of_lt Crot_pos have hs : 0 <= (4 * (1 / 64 : ℝ)) ^ 2 := sq_nonneg _ dsimp [Cvar] - nlinarith + linarith only [hC] have hVmul : Cvar * (∑ k ∈ G, V k) <= Cvar * (∑ k : Fin N, V k) := mul_le_mul_of_nonneg_left hVsubset hCvar_nonneg @@ -4665,7 +4677,7 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_variance 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + Cvar * (∑ k : Fin N, V k) + BadBd := by rw [hsplit] - nlinarith + linarith only [hgood, hbad, hVmul] have hcoef_nonneg : 0 <= (1 / (2 * Real.pi) : ℝ) := by positivity have hmul : (1 / (2 * Real.pi)) * (∑ k : Fin N, Avg k) <= @@ -4681,7 +4693,7 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_variance (1 / (2 * Real.pi)) * (8 * Crot * defectSq (lowPoly q) (bandPoly N p) + Cvar * (∑ k : Fin N, V k) + BadBd) + - ∑ k : Fin N, V k := by nlinarith + ∑ k : Fin N, V k := by linarith only [hmul] _ = (1 / (2 * Real.pi)) * (8 * Crot * defectSq (lowPoly q) (bandPoly N p) + @@ -4736,19 +4748,19 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_poincare (1 / (2 * Real.pi)) * (8 * Crot * defectSq (lowPoly q) (bandPoly N p) + Cvar * V + BadBd) + V := by - simpa only [one_div, mul_inv_rev, V, Cvar, BadBd] using + exact slowBandPoly_l2_le_good_bad_average_defect_variance (D := D) (N := N) (L := L) hN (q := q) hq p hdelta_pos harc have hN1 : 1 <= N := Nat.succ_le_of_lt hN have hV : V <= R := by - simpa [V, R] using + exact sum_carrierAverage_variance_le_global (N := N) (L := L) hN1 p have hCvar_nonneg : 0 <= Cvar := by have hC : 0 <= Crot := le_of_lt Crot_pos have hs : 0 <= (4 * (1 / 64 : ℝ)) ^ 2 := sq_nonneg _ dsimp [Cvar] - nlinarith + linarith only [hC] have hcoef_nonneg : 0 <= (1 / (2 * Real.pi) : ℝ) := by positivity have hinside : 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + @@ -4756,7 +4768,7 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_poincare 8 * Crot * defectSq (lowPoly q) (bandPoly N p) + Cvar * R + BadBd := by have hmul := mul_le_mul_of_nonneg_left hV hCvar_nonneg - nlinarith + linarith only [hmul] have hmainmul : (1 / (2 * Real.pi)) * (8 * Crot * defectSq (lowPoly q) (bandPoly N p) + @@ -4772,7 +4784,7 @@ private theorem slowBandPoly_l2_le_good_bad_average_defect_poincare Cvar * V + BadBd) + V := hbase _ <= (1 / (2 * Real.pi)) * (8 * Crot * defectSq (lowPoly q) (bandPoly N p) + - Cvar * R + BadBd) + R := by nlinarith + Cvar * R + BadBd) + R := by linarith only [hV, hmainmul] _ = (1 / (2 * Real.pi)) * (8 * Crot * defectSq (lowPoly q) (bandPoly N p) + @@ -4806,7 +4818,7 @@ private theorem lowPoly_zero_case {D L N : Nat} circleL2Sq (bandPoly N p) := by subst q unfold defectSq circleL2Sq lowPoly - simp_all only [Pi.zero_apply, zero_mul, Finset.sum_const_zero, zero_add, norm_zero, sub_zero] + simp only [Pi.zero_apply, zero_mul, Finset.sum_const_zero, zero_add, norm_zero, sub_zero] private theorem lowPoly_zero_degree_eq_const (q : Fin (0 + 1) -> ℂ) : @@ -4821,7 +4833,7 @@ private theorem zero_degree_coeff_ne_zero apply hq funext n fin_cases n - simpa only [Nat.reduceAdd, Fin.zero_eta, Fin.isValue, Pi.zero_apply] using hc + exact hc private theorem lowPoly_eq_const_of_tail_zero {D : Nat} (q : Fin (D + 1) -> ℂ) @@ -4915,21 +4927,21 @@ private theorem finite_base_circle_estimate_degree_zero circleL2Sq (bandPoly N p) <= circleConst 0 * defectSq (lowPoly q) (bandPoly N p) := by let c : ℂ := q 0 - have hc : c ≠ 0 := by simpa only [Fin.isValue, ne_eq, c] using zero_degree_coeff_ne_zero hq + have hc : c ≠ 0 := by exact zero_degree_coeff_ne_zero hq let b : Fin L -> ℂ := fun m => c⁻¹ * p m have hsep37 : 37 * L <= N := by have hmul : 37 * L <= circleGap 0 * L := Nat.mul_le_mul_right L (circleGap_ge_37 0) exact hmul.trans hsep - have hN : 1 <= N := by nlinarith - have hNL : 1343 * L ^ 2 <= N ^ 2 := by nlinarith + have hN : 1 <= N := by linarith only [hL, hsep37] + have hNL : 1343 * L ^ 2 <= N ^ 2 := by nlinarith only [hL, hsep37] have hP : bandPoly N p = fun x => c * bandPoly N b x := by ext x simp [b, bandPoly, Finset.mul_sum, mul_assoc, hc] set I : ℝ := ∫ x : Circle, (FockSPR.rho (bandPoly N b x)) ^ 2 ∂AddCircle.haarAddCircle have hhigh : circleL2Sq (bandPoly N b) <= 32 * I := by - simpa [I] using high_freq_band_estimate_wip hN hL hNL b + exact high_freq_band_estimate_wip hN hL hNL b have hleft : circleL2Sq (bandPoly N p) = ‖c‖ ^ 2 * circleL2Sq (bandPoly N b) := by rw [hP] @@ -4937,7 +4949,7 @@ private theorem finite_base_circle_estimate_degree_zero have hdef : defectSq (lowPoly q) (bandPoly N p) = ‖c‖ ^ 2 * I := by rw [lowPoly_zero_degree_eq_const q, hP] - simpa only [Fin.isValue, I, c] using defectSq_const_mul_eq_rho c (bandPoly N b) + exact defectSq_const_mul_eq_rho c (bandPoly N b) have hscaled : circleL2Sq (bandPoly N p) <= 32 * defectSq (lowPoly q) (bandPoly N p) := by calc circleL2Sq (bandPoly N p) = ‖c‖ ^ 2 * circleL2Sq (bandPoly N b) := hleft @@ -4959,7 +4971,7 @@ private theorem finite_base_circle_estimate_constant_low circleL2Sq (bandPoly N p) <= circleConst D * defectSq (lowPoly q) (bandPoly N p) := by let c : ℂ := q (0 : Fin (D + 1)) - have hc : c ≠ 0 := by simpa only [ne_eq, c] using constant_coeff_ne_zero_of_tail_zero hq htail + have hc : c ≠ 0 := by exact constant_coeff_ne_zero_of_tail_zero hq htail let b : Fin L -> ℂ := fun m => c⁻¹ * p m have hN : 1 <= N := by have hgap : 1 <= circleGap D := circleGap_pos D @@ -4968,14 +4980,14 @@ private theorem finite_base_circle_estimate_constant_low have hmul : 37 * L <= circleGap D * L := Nat.mul_le_mul_right L (circleGap_ge_37 D) exact hmul.trans hsep - have hNL : 1343 * L ^ 2 <= N ^ 2 := by nlinarith + have hNL : 1343 * L ^ 2 <= N ^ 2 := by nlinarith only [hL, hsep37] have hP : bandPoly N p = fun x => c * bandPoly N b x := by ext x simp [b, bandPoly, Finset.mul_sum, mul_assoc, hc] set I : ℝ := ∫ x : Circle, (FockSPR.rho (bandPoly N b x)) ^ 2 ∂AddCircle.haarAddCircle have hhigh : circleL2Sq (bandPoly N b) <= 32 * I := by - simpa [I] using high_freq_band_estimate_wip hN hL hNL b + exact high_freq_band_estimate_wip hN hL hNL b have hleft : circleL2Sq (bandPoly N p) = ‖c‖ ^ 2 * circleL2Sq (bandPoly N b) := by rw [hP] @@ -4983,7 +4995,7 @@ private theorem finite_base_circle_estimate_constant_low have hdef : defectSq (lowPoly q) (bandPoly N p) = ‖c‖ ^ 2 * I := by rw [lowPoly_eq_const_of_tail_zero q htail, hP] - simpa [I, c] using defectSq_const_mul_eq_rho c (bandPoly N b) + exact defectSq_const_mul_eq_rho c (bandPoly N b) have hscaled : circleL2Sq (bandPoly N p) <= 32 * defectSq (lowPoly q) (bandPoly N p) := by calc @@ -5029,7 +5041,7 @@ private theorem badCarrier_term_le_half_l2 have hL_nonneg : 0 <= (L : ℝ) := by exact_mod_cast Nat.zero_le L have hCL : C * (L : ℝ) <= A * (L : ℝ) := mul_le_mul_of_nonneg_right hC_le_A hL_nonneg - have htwo : 2 * (C * (L : ℝ)) <= (N : ℝ) := by nlinarith + have htwo : 2 * (C * (L : ℝ)) <= (N : ℝ) := by linarith only [hsep_real, hCL] rw [div_le_iff₀ hNpos] linarith only [htwo] have hrearrange : @@ -5077,13 +5089,13 @@ private theorem circle_variance_ratio_le_one_div_520 have hLpos : (0 : ℝ) < (L : ℝ) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hL) have hK_le_A : K * (L : ℝ) <= 128 * A ^ 2 * (L : ℝ) := by have hsq : ((82 : ℝ) ^ 2) <= A ^ 2 := by nlinarith only [hA_ge] - have hcoef : 128 * ((82 : ℝ) ^ 2) <= 128 * A ^ 2 := by nlinarith + have hcoef : 128 * ((82 : ℝ) ^ 2) <= 128 * A ^ 2 := by linarith only [hsq] have hL_nonneg : 0 <= (L : ℝ) := le_of_lt hLpos exact mul_le_mul_of_nonneg_right (by simpa only [Nat.ofNat_pos, mul_le_mul_iff_right₀, K] using hcoef) hL_nonneg have hNlarge : K * (L : ℝ) <= (N : ℝ) := hK_le_A.trans hNlargeA - have hNpos : (0 : ℝ) < (N : ℝ) := by nlinarith + have hNpos : (0 : ℝ) < (N : ℝ) := by linarith only [hNlargeA, hLpos, hK_le_A] have hLm1sq : ((L : ℝ) - 1) ^ 2 <= (L : ℝ) ^ 2 := by linarith only [sub_nonneg.mpr (show (1 : ℝ) ≤ L by exact_mod_cast hL)] have hratio : @@ -5096,7 +5108,7 @@ private theorem circle_variance_ratio_le_one_div_520 div_le_div_of_nonneg_right hLm1sq (sq_nonneg (N : ℝ)) have hpi_sq : Real.pi ^ 2 <= (16 : ℝ) := by nlinarith only [le_of_lt Real.pi_pos, le_of_lt Real.pi_lt_four] - have hcoef : 4 * Real.pi ^ 2 <= (64 : ℝ) := by nlinarith + have hcoef : 4 * Real.pi ^ 2 <= (64 : ℝ) := by linarith only [hpi_sq] have hratio_nonneg : 0 <= (L : ℝ) ^ 2 / (N : ℝ) ^ 2 := div_nonneg (sq_nonneg _) (sq_nonneg _) @@ -5166,7 +5178,7 @@ theorem finite_base_circle_estimate have hmass_nonneg : 0 <= circleL2Sq (bandPoly N p) := circleL2Sq_nonneg (bandPoly N p) have hconst_ge_one : 1 <= circleConst D := by exact circleConst_ge_one D - nlinarith + nlinarith only [hmass_nonneg, hconst_ge_one] · have hpoly_ne : polyOfCoeff q ≠ 0 := polyOfCoeff_ne_zero_of_ne_zero hzero have hlead_ne : (polyOfCoeff q).leadingCoeff ≠ 0 := @@ -5205,12 +5217,12 @@ theorem finite_base_circle_estimate circleL2Sq_bandPoly_pos_of_ne_zero N hpzero have hN : 1 <= N := by have hgap : 1 <= circleGap D := circleGap_pos D - nlinarith + nlinarith only [hL, hsep, hgap] have hsep37 : 37 * L <= N := by have hmul : 37 * L <= circleGap D * L := Nat.mul_le_mul_right L (circleGap_ge_37 D) exact hmul.trans hsep - have hNL : 1343 * L ^ 2 <= N ^ 2 := by nlinarith + have hNL : 1343 * L ^ 2 <= N ^ 2 := by nlinarith only [hL, hsep37] have hbad_budget_sep : 2 * circleBadConst D * circleGoodBudget D * L <= N := by have hmul : @@ -5303,8 +5315,11 @@ theorem finite_base_circle_estimate (D := D) (N := N) (L := L) (B := B) (q := q) (delta := delta) p hN_pos_nat hbad_card hbad_budget_sep_B - have hmain : M <= 256 * Def + (3 / 4) * M := by nlinarith - have hM_le : M <= 1024 * Def := by nlinarith + have hmain : M <= 256 * Def + (3 / 4) * M := by + linarith only [ + hraw, hDefTerm, hVarTerm, hBadTerm + ] + have hM_le : M <= 1024 * Def := by linarith only [hraw, hDefTerm, hVarTerm, hBadTerm] have hconst : (1024 : ℝ) <= circleConst D := one_thousand_twenty_four_le_circleConst D have hDef_nonneg : 0 <= Def := by diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/ImportedAnalyticInputs.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/ImportedAnalyticInputs.lean index 7c48ba614c..51a3bec5d8 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/ImportedAnalyticInputs.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/ImportedAnalyticInputs.lean @@ -115,9 +115,9 @@ theorem phase_normalized_orthogonal_reduction - the conclusion is local in `h`, with the phase normalization encoded by `(inner h f0).im = 0`. -/ refine ⟨1 / (C + 1), 5 * C + 3, ?_, ?_, ?_⟩ - · have hCp1 : 0 < C + 1 := by linarith + · have hCp1 : 0 < C + 1 := by linarith only [hC] exact one_div_pos.mpr hCp1 - · nlinarith + · linarith only [hC] · intro h hhδ him set a : ℝ := (inner ℂ h f0).re set g : H := h - (a : ℂ) • f0 @@ -144,14 +144,14 @@ theorem phase_normalized_orthogonal_reduction ‖h‖ = ‖g + (a : ℂ) • f0‖ := by rw [← hg_add] _ ≤ ‖g‖ + ‖(a : ℂ) • f0‖ := norm_add_le _ _ _ = ‖g‖ + |a| := by simp [norm_smul, hf0, Real.norm_eq_abs] - have hh_main : ‖h‖ ≤ (C + 1) * |a| + C * defect h := by nlinarith - have hCp1 : 0 < C + 1 := by linarith - have hx_le_one : ‖h‖ ≤ 1 := hhδ.trans (by rw [div_le_iff₀ hCp1]; nlinarith) + have hh_main : ‖h‖ ≤ (C + 1) * |a| + C * defect h := by linarith only [hg_bound, hsplit] + have hCp1 : 0 < C + 1 := by linarith only [hC] + have hx_le_one : ‖h‖ ≤ 1 := hhδ.trans (by rw [div_le_iff₀ hCp1]; linarith only [hC]) have ha_simple : |a| ≤ (3 : ℝ) / 2 * defect h + ‖h‖ ^ 2 / 2 := by - nlinarith [htwoa, hx_le_one, hdefect_nonneg h, norm_nonneg h] + nlinarith only [hdefect_nonneg, htwoa, hx_le_one, hdefect_nonneg h, norm_nonneg h] have hx_sq : (C + 1) * ‖h‖ ^ 2 ≤ ‖h‖ := by rw [le_div_iff₀ hCp1] at hhδ - nlinarith [hhδ, norm_nonneg h, hCp1] - nlinarith [hh_main, ha_simple, hx_sq, hdefect_nonneg h, hC, abs_nonneg a] + nlinarith only [hhδ, norm_nonneg h, hCp1] + nlinarith only [hC, hg_bound, hsplit, ha_simple, hx_sq, hh_main, hdefect_nonneg h, abs_nonneg a] end HermiteLEAN diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/MissingMathlib.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/MissingMathlib.lean index a675a2c6b3..6093816642 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/MissingMathlib.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite/MissingMathlib.lean @@ -49,8 +49,8 @@ theorem annulus_distance_lower_bound (j : ℕ) (x : ℝ) : simp_all simpa [a, b, hrhs] using h rw [le_min_iff] - refine ⟨max_le (by linarith) ha0, max_le ?_ hb0⟩ - linarith [(abs_sub_le_iff.mp habs).1] + refine ⟨max_le (by linarith only []) ha0, max_le ?_ hb0⟩ + linarith only [habs, (abs_sub_le_iff.mp habs).1] -- to_mathlib: Mathlib/Analysis/SpecialFunctions/Gaussian/Basic /-- A reusable Gaussian absorption lemma. -/ @@ -66,7 +66,7 @@ theorem polynomial_times_gaussian_le_gaussian have hsq : Tendsto (fun x : ℝ => x ^ 2) Filter.atTop Filter.atTop := tendsto_pow_atTop (by norm_num : (2 : ℕ) ≠ 0) have hexp : Tendsto (fun x : ℝ => Real.exp (-(a / 2) * x ^ 2)) Filter.atTop (𝓝 0) := - Real.tendsto_exp_atBot.comp (hsq.const_mul_atTop_of_neg (by nlinarith [ha])) + Real.tendsto_exp_atBot.comp (hsq.const_mul_atTop_of_neg (by linarith only [ha])) have hpoly : Tendsto (fun x : ℝ => x ^ k * Real.exp (-(a / 2) * x ^ 2)) Filter.atTop (𝓝 0) := by refine Tendsto.congr' ?_ ((tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero ((k : ℝ) / 2) (a / 2) (by positivity)).comp @@ -100,9 +100,9 @@ theorem polynomial_times_gaussian_le_gaussian simpa [Real.norm_eq_abs, g, abs_of_nonneg (by positivity : 0 ≤ 1 + x ^ k)] using hC0 x ⟨hx, hxr⟩ simp only [C] - linarith [le_abs_self C0] + linarith only [hcompact, le_abs_self C0] · simp only [C] - nlinarith [hR x (le_of_not_ge hxr), abs_nonneg C0] + linarith only [hR, hxr, hR x (le_of_not_ge hxr), abs_nonneg C0] have hsplit : Real.exp (-a * x ^ 2) = Real.exp (-(a / 2) * x ^ 2) * Real.exp (-(a / 2) * x ^ 2) := by diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/BlockLocalization.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/BlockLocalization.lean index c2618fcb0a..4ee093d86e 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/BlockLocalization.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/BlockLocalization.lean @@ -427,7 +427,7 @@ private lemma block_decay_compare_coord have hclose : |Real.sqrt (α q : ℝ) - ((ℓ q : ℕ) : ℝ)| < 1 := by rw [abs_of_nonneg (sub_nonneg.mpr hle)] push_cast at hlt ⊢ - linarith + linarith only [hlt] have hdist_eq : ((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) = |((j q : ℕ) : ℝ) - ((ℓ q : ℕ) : ℝ)| := by rcases Nat.le_total (j q) (ℓ q) with hj | hℓ · rw [Nat.dist_eq_sub_of_le hj, abs_of_nonpos] @@ -453,11 +453,11 @@ private lemma block_decay_compare_coord ((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) ≤ |((j q : ℕ) : ℝ) - Real.sqrt (α q : ℝ)| + 1 := by rw [hdist_eq] - linarith + linarith only [hclose, htri] have hk : (((κ q + 5 : ℕ) : ℝ)) = (((κ q + 4 : ℕ) : ℝ)) + 1 := by push_cast ring - exact max_le_max (by linarith) le_rfl + exact max_le_max (by linarith only [hclose, hdist_eq, htri, hk]) le_rfl private lemma sup_coord_exists {d : ℕ} (hd : d ≠ 0) (j ℓ : MultiIndex d) : @@ -684,8 +684,10 @@ theorem productBasisLocalization have hsq : max (((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) - ((κ q + 5 : ℕ) : ℝ)) 0 ^ 2 ≤ max (|((j q : ℕ) : ℝ) - Real.sqrt (α q : ℝ)| - ((κ q + 4 : ℕ) : ℝ)) 0 ^ 2 := by - nlinarith [hcmp, le_max_right (((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) - ((κ q + 5 : ℕ) : ℝ)) 0, - le_max_right (|((j q : ℕ) : ℝ) - Real.sqrt (α q : ℝ)| - ((κ q + 4 : ℕ) : ℝ)) 0] + nlinarith only [ + hcmp, le_max_right (((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) - ((κ q + 5 : ℕ) : ℝ)) 0, + le_max_right (|((j q : ℕ) : ℝ) - Real.sqrt (α q : ℝ)| - ((κ q + 4 : ℕ) : ℝ)) 0 + ] have hexp : Real.exp (-(cq q) * @@ -733,8 +735,10 @@ theorem productBasisLocalization have hsq0 : max (((blockDistance j ℓ : ℕ) : ℝ) - B) 0 ^ 2 ≤ max (((Nat.dist (j q0) (ℓ q0) : ℕ) : ℝ) - ((κ q0 + 5 : ℕ) : ℝ)) 0 ^ 2 := by - nlinarith [hmax, le_max_right (((blockDistance j ℓ : ℕ) : ℝ) - B) 0, - le_max_right (((Nat.dist (j q0) (ℓ q0) : ℕ) : ℝ) - ((κ q0 + 5 : ℕ) : ℝ)) 0] + nlinarith only [ + hmax, le_max_right (((blockDistance j ℓ : ℕ) : ℝ) - B) 0, + le_max_right (((Nat.dist (j q0) (ℓ q0) : ℕ) : ℝ) - ((κ q0 + 5 : ℕ) : ℝ)) 0 + ] have hsingle : max (((Nat.dist (j q0) (ℓ q0) : ℕ) : ℝ) - ((κ q0 + 5 : ℕ) : ℝ)) 0 ^ 2 ≤ ∑ q : Fin d, max (((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) - ((κ q + 5 : ℕ) : ℝ)) 0 ^ 2 := by @@ -772,9 +776,9 @@ theorem productBasisLocalization ^ 2 := by rw [Finset.mul_sum] refine Finset.sum_le_sum fun q _ => ?_ - nlinarith [hcsmall q, - sq_nonneg (max (((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) - ((κ q + 5 : ℕ) : ℝ)) 0)] - nlinarith [hsum_term, hsq_ge, hc_pos] + nlinarith only [hcsmall, hcsmall q, + sq_nonneg (max (((Nat.dist (j q) (ℓ q) : ℕ) : ℝ) - ((κ q + 5 : ℕ) : ℝ)) 0)] + nlinarith only [hc_pos, hsq_ge, hsum_term] exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hsum_le) (le_of_lt hC_pos) /-- Quantitative block localization estimate. -/ @@ -846,7 +850,7 @@ theorem shellCountingFormula private lemma summable_exp_neg_mul_sq {a : ℝ} (ha : 0 < a) : Summable (fun r : ℕ => Real.exp (-a * (r : ℝ) ^ 2)) := by refine Real.summable_exp_nat_mul_of_ge ?_ ?_ - · linarith + · linarith only [ha] · intro i have hreal : (i : ℝ) ≤ (i : ℝ) * (i : ℝ) := by exact_mod_cast Nat.le_mul_self i simpa [pow_two] using hreal @@ -861,7 +865,7 @@ private lemma polynomialGaussianTailMajorant_summable (g := fun r : ℕ => (1 + (r : ℝ) ^ k) * Real.exp (-a * (r : ℝ) ^ 2)) (fun r => by positivity) (fun r => hbound (r : ℝ) (by positivity)) - ((summable_exp_neg_mul_sq (by linarith)).mul_left C) + ((summable_exp_neg_mul_sq (by linarith only [ha])).mul_left C) /-- Gaussian tails with polynomial weights are summable. -/ theorem polynomialGaussianSeriesSummable @@ -871,7 +875,7 @@ theorem polynomialGaussianSeriesSummable (f := fun r : ℕ => (1 + (r : ℝ) ^ m) * Real.exp (-c * (r : ℝ) ^ 2)) (g := fun r : ℕ => (r : ℝ) ^ m * Real.exp (-c * (r : ℝ) ^ 2)) (fun r => by positivity) - (fun r => mul_le_mul_of_nonneg_right (by linarith) (by positivity)) + (fun r => mul_le_mul_of_nonneg_right (by linarith only []) (by positivity)) (polynomialGaussianTailMajorant_summable hc m) private lemma tailIndicator_tendsto_zero @@ -929,7 +933,7 @@ private lemma tailIndicator_tendsto_zero (∑' k : ℕ, u (k + (M + 1))) = ∑' i : ℕ, u i := by simpa using hu.sum_add_tsum_nat_add (M + 1) have hEq : (∑' r : ℕ, if M < r then u r else 0) = ∑' k : ℕ, u (k + (M + 1)) := by - linarith [h1, h2] + linarith only [h1, h2] simpa [Nat.succ_le_iff] using hEq.symm private lemma shellExp_global_majorant @@ -949,12 +953,15 @@ private lemma shellExp_global_majorant exact_mod_cast (by simp [shellCardinality] : shellCardinality d 0 ≤ 1) have hpow1 : (1 : ℝ) ≤ (3 : ℝ) ^ d := one_le_pow₀ (by norm_num) have hfac : (1 : ℝ) ≤ 1 + (((0 : ℕ) : ℝ) ^ d) := by - linarith [show (0 : ℝ) ≤ (((0 : ℕ) : ℝ) ^ d) by positivity] - nlinarith [hzero, mul_le_mul hpow1 hfac (by norm_num) (by positivity)] + linarith only [show (0 : ℝ) ≤ (((0 : ℕ) : ℝ) ^ d) by positivity] + linarith only [hzero, hpow1, hfac, mul_le_mul hpow1 hfac (by norm_num) (by positivity)] · have hr1 : 1 ≤ r := Nat.succ_le_of_lt (Nat.pos_iff_ne_zero.mpr hr0) have hs : (shellCardinality d r : ℝ) ≤ ((2 * r + 1) ^ d : ℕ) := by exact_mod_cast shellCountingFormula d r - have hbase : (2 * r + 1 : ℝ) ≤ 3 * r := by nlinarith [show (1 : ℝ) ≤ r by exact_mod_cast hr1] + have hbase : (2 * r + 1 : ℝ) ≤ 3 * r := by + linarith only [ + hr1, show (1 : ℝ) ≤ r by exact_mod_cast hr1 + ] have hpow : (2 * r + 1 : ℝ) ^ d ≤ (3 * r : ℝ) ^ d := by gcongr have hshell' : (shellCardinality d r : ℝ) ≤ (3 : ℝ) ^ d * (r : ℝ) ^ d := by calc @@ -962,7 +969,7 @@ private lemma shellExp_global_majorant _ ≤ (3 * r : ℝ) ^ d := hpow _ = (3 : ℝ) ^ d * (r : ℝ) ^ d := by rw [mul_pow] have hrpow_nonneg : 0 ≤ (r : ℝ) ^ d := by positivity - exact le_trans hshell' <| mul_le_mul_of_nonneg_left (by nlinarith) (by positivity) + exact le_trans hshell' <| mul_le_mul_of_nonneg_left (by linarith only []) (by positivity) have hexp : Real.exp (-(c) * max ((r : ℝ) - B) 0 ^ 2) ≤ Real.exp (c * B ^ 2) * Real.exp (-(c / 8) * (r : ℝ) ^ 2) := by @@ -970,19 +977,22 @@ private lemma shellExp_global_majorant have hsq : (r : ℝ) ^ 2 / 8 - B ^ 2 ≤ max ((r : ℝ) - B) 0 ^ 2 := by by_cases hsmall : (r : ℝ) ≤ 2 * B - · have hrhs_nonpos : (r : ℝ) ^ 2 / 8 - B ^ 2 ≤ 0 := by nlinarith + · have hrhs_nonpos : (r : ℝ) ^ 2 / 8 - B ^ 2 ≤ 0 := by nlinarith only [hB, hsmall] have hnonneg : 0 ≤ max ((r : ℝ) - B) 0 ^ 2 := by positivity - linarith - · have hlarge : 2 * B < (r : ℝ) := by linarith - have hhalf : (r : ℝ) / 2 ≤ (r : ℝ) - B := by nlinarith + linarith only [hrhs_nonpos, hnonneg] + · have hlarge : 2 * B < (r : ℝ) := by linarith only [hsmall] + have hhalf : (r : ℝ) / 2 ≤ (r : ℝ) - B := by linarith only [hsmall] have hmaxeq : max ((r : ℝ) - B) 0 = (r : ℝ) - B := by apply max_eq_left - linarith + linarith only [hB, hsmall] rw [hmaxeq] - have hsquare_half : ((r : ℝ) / 2) ^ 2 ≤ ((r : ℝ) - B) ^ 2 := by nlinarith - nlinarith [hsquare_half] + have hsquare_half : ((r : ℝ) / 2) ^ 2 ≤ ((r : ℝ) - B) ^ 2 := by nlinarith only [hsmall] + nlinarith only [hsquare_half] have hlog : - -(c) * max ((r : ℝ) - B) 0 ^ 2 ≤ c * B ^ 2 - (c / 8) * (r : ℝ) ^ 2 := by nlinarith [hsq, hc] + -(c) * max ((r : ℝ) - B) 0 ^ 2 ≤ c * B ^ 2 - (c / 8) * (r : ℝ) ^ 2 := by + nlinarith only [ + hc, hsq + ] calc Real.exp (-(c) * max ((r : ℝ) - B) 0 ^ 2) ≤ Real.exp (c * B ^ 2 - (c / 8) * (r : ℝ) ^ 2) := Real.exp_le_exp.mpr hlog @@ -1010,7 +1020,7 @@ private lemma localizationLeakageSeriesSummable simpa [mul_assoc, mul_left_comm, mul_comm] using (polynomialGaussianTailMajorant_summable (a := c / 8) - (by linarith) + (by linarith only [hc]) d).mul_left K exact Summable.of_nonneg_of_le (f := fun r : ℕ => @@ -1021,7 +1031,7 @@ private lemma localizationLeakageSeriesSummable (fun r => by positivity) (fun r => by have := hmajor r - nlinarith [this, hC]) + nlinarith only [hC, this]) (hsum.mul_right C) private lemma localizationLeakageCoefficient_tendsto_zero diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/DegreeBookkeeping.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/DegreeBookkeeping.lean index 4070699f7a..b02d1ab422 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/DegreeBookkeeping.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/DegreeBookkeeping.lean @@ -333,7 +333,7 @@ theorem highFrequencyThreshold unfold degreeThreshold at hj omega have hM_bound : 2 * M + 1 ≤ x := by - have h1 : 2 * M + 1 ≤ 120 * d * (2 * M + 1) := by nlinarith + have h1 : 2 * M + 1 ≤ 120 * d * (2 * M + 1) := by nlinarith only [hd] exact le_trans h1 hx_ge have hR_bound : 2 * R + 1 ≤ 3 * x := by dsimp [x] diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ImportedAnalyticInputs.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ImportedAnalyticInputs.lean index 290754b23e..9a2069e751 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ImportedAnalyticInputs.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ImportedAnalyticInputs.lean @@ -317,7 +317,7 @@ private lemma integrable_oneDimBasis_cross (fun z : CSpace 1 => oneDimLift (oneDimPhi k (α 0)) z * conj (oneDimLift (oneDimPhi k (β 0)) z)) (gaussianMeasure 1) := by - simpa [oneDimLift] using integrable_oneDimPhi_cross_gaussian k (α 0) (β 0) + exact integrable_oneDimPhi_cross_gaussian k (α 0) (β 0) private lemma gaussianInner_finite_sum_basis_one (k : ℕ) (β : MultiIndex 1) @@ -335,12 +335,12 @@ private lemma gaussianInner_finite_sum_basis_one rw [MeasureTheory.integral_finsetSum] · refine Finset.sum_congr rfl ?_ intro α hα - simpa [mul_assoc] using + exact (MeasureTheory.integral_const_mul (c α) (fun z : CSpace 1 => oneDimLift (oneDimPhi k (α 0)) z * conj (oneDimLift (oneDimPhi k (β 0)) z))) · intro α hα - simpa [mul_assoc] using (integrable_oneDimBasis_cross k α β).const_mul (c α) + exact (integrable_oneDimBasis_cross k α β).const_mul (c α) private lemma gaussianInner_finite_sum_one (k : ℕ) @@ -373,7 +373,7 @@ private lemma gaussianInner_finite_sum_one rw [hfun, MeasureTheory.integral_finsetSum] · refine Finset.sum_congr rfl ?_ intro β hβ - simpa [mul_assoc] using + exact (MeasureTheory.integral_const_mul (conj (b β)) (fun z : CSpace 1 => (Finset.sum s (fun α => a α * oneDimLift (oneDimPhi k (α 0)) z)) * @@ -398,8 +398,8 @@ private lemma gaussianInner_finite_sum_one intro α hα ring] refine MeasureTheory.integrable_finsetSum _ (fun α hα => ?_) - simpa [mul_assoc] using (integrable_oneDimBasis_cross k α β).const_mul (a α) - simpa [mul_assoc] using hsumInt.const_mul (conj (b β)) + exact (integrable_oneDimBasis_cross k α β).const_mul (a α) + exact hsumInt.const_mul (conj (b β)) /-! # ImportedAnalyticInputs @@ -419,7 +419,7 @@ theorem oneVariableBasisOrthonormal Downstream files only use orthonormality and finite Parseval consequences. -/ rw [gaussianInner_oneDimPhi_eq_weightedInner] - simpa using (HermitekLEAN.phi_orthonormal (k := k) (m := m) (n := n)) + exact (HermitekLEAN.phi_orthonormal (k := k) (m := m) (n := n)) /-- Imported one-variable Parseval statement for finite coefficient families. -/ theorem oneVariableFiniteParseval @@ -523,7 +523,7 @@ theorem oneVariableLocalization refine ⟨C, c, hC, hc, ?_⟩ intro n j hn rw [annulusMass_oneDimPhi_eq_annulusIntegralSq] - simpa [oneDimPhi, HermitekLEAN.posPart, HermiteLEAN.posPart] using hloc n j hn + exact hloc n j hn private lemma zero_shift_exp_compare (k j : ℕ) (c0 : ℝ) (hc0 : 0 < c0) : @@ -557,14 +557,14 @@ private lemma zero_shift_exp_compare rw [hx, hy, ← Real.exp_add] apply Real.exp_le_exp.mpr let y : ℝ := (j : ℝ) - ((k + 5 : ℕ) : ℝ) - have hybound : 2 * y ≤ y ^ 2 + 1 := by nlinarith [sq_nonneg (y - 1)] - have hsq : (y + 1) ^ 2 ≤ 4 * (y ^ 2 + 1) := by nlinarith + have hybound : 2 * y ≤ y ^ 2 + 1 := by nlinarith only [sq_nonneg (y - 1)] + have hsq : (y + 1) ^ 2 ≤ 4 * (y ^ 2 + 1) := by nlinarith only [hybound] have hsq' : ((j : ℝ) - ((k + 4 : ℕ) : ℝ)) ^ 2 ≤ 4 * (((j : ℝ) - ((k + 5 : ℕ) : ℝ)) ^ 2 + 1) := by rw [hrel] simpa [y] using hsq - nlinarith [hc0, hsq'] + nlinarith only [hc0, hsq'] /-- Imported positive-frequency circle estimate with frozen constant `144`. -/ theorem positiveFrequencyCircleEstimate @@ -585,7 +585,7 @@ theorem positiveFrequencyCircleEstimate HermiteLEAN.circleRhoNormSq (HermiteLEAN.positiveTrigonometricPolynomial E b) by simp [circleL2NormSq, rho, positiveFrequencyPolynomial, HermiteLEAN.circleRhoNormSq, HermiteLEAN.positiveTrigonometricPolynomial, HermiteLEAN.rho, sq_abs]] - simpa using + exact HermitekLEAN.local_circle_estimate E (by intro n hn @@ -686,7 +686,7 @@ theorem localizationIncludingZero _ ≤ C * Real.exp (-(c * (posPart ((j : ℝ) - ((k + 4 : ℕ) : ℝ))) ^ 2)) := by refine mul_le_mul_of_nonneg_left ?_ (by positivity) apply Real.exp_le_exp.mpr - nlinarith [hcle, sq_nonneg (posPart ((j : ℝ) - ((k + 4 : ℕ) : ℝ)))] + nlinarith only [hcle, sq_nonneg (posPart ((j : ℝ) - ((k + 4 : ℕ) : ℝ)))] _ = C * Real.exp (-c * max (|((j : ℕ) : ℝ) - Real.sqrt ((0 : ℕ) : ℝ)| - ((k + 4 : ℕ) : ℝ)) 0 ^ 2) := by simp_all @@ -716,8 +716,10 @@ theorem localizationIncludingZero max (|((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - ((k + 4 : ℕ) : ℝ)) 0 ^ 2) := by refine mul_le_mul_of_nonneg_left ?_ (by positivity) apply Real.exp_le_exp.mpr - nlinarith [hcle, - sq_nonneg (max (|((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - ((k + 4 : ℕ) : ℝ)) 0)] + nlinarith only [ + hcle, + sq_nonneg (max (|((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - ((k + 4 : ℕ) : ℝ)) 0) + ] /-- Scalar-rescaled positive-frequency estimate for an arbitrary background `a`. -/ theorem scaledPositiveFrequencyCircleEstimate @@ -741,7 +743,7 @@ theorem scaledPositiveFrequencyCircleEstimate positivity have hcard : 0 < E.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hE) have honeR : (1 : ℝ) ≤ E.card := by exact_mod_cast (Nat.succ_le_of_lt hcard) - have hfac : (1 : ℝ) ≤ 144 * (E.card : ℝ) := by nlinarith + have hfac : (1 : ℝ) ≤ 144 * (E.card : ℝ) := by linarith only [honeR] calc circleL2NormSq (positiveFrequencyPolynomial E b) ≤ 144 * E.card * circleL2NormSq (positiveFrequencyPolynomial E b) := @@ -792,7 +794,7 @@ theorem scaledHighFrequencyBandEstimate unfold circleL2NormSq positivity calc - circleL2NormSq P ≤ 32 * circleL2NormSq P := by nlinarith + circleL2NormSq P ≤ 32 * circleL2NormSq P := by linarith only [hnonneg] _ = 32 * circleL2NormSq (fun t => rho 0 (P t)) := by simp [circleL2NormSq, rho] · rcases hP with ⟨c, rfl⟩ let Q : Circle → ℂ := bandLimitedPolynomial N L (fun m => a⁻¹ * c m) diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductAnnulusCircle.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductAnnulusCircle.lean index fb8c369c59..3aaf4b8878 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductAnnulusCircle.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductAnnulusCircle.lean @@ -59,11 +59,11 @@ theorem rhoPointwiseSq have hsq : (rho a u) ^ 2 ≤ (rho a v + ‖u - v‖) ^ 2 := by have hnonneg : 0 ≤ rho a u := abs_nonneg _ have hneg0 : -(rho a v + ‖u - v‖) ≤ 0 := by - nlinarith [abs_nonneg (rho a v), norm_nonneg (u - v)] + linarith only [h, hnonneg, abs_nonneg (rho a v), norm_nonneg (u - v)] have hneg : -(rho a v + ‖u - v‖) ≤ rho a u := le_trans hneg0 hnonneg exact sq_le_sq' hneg h have hsum : (rho a v + ‖u - v‖) ^ 2 ≤ 2 * rho a v ^ 2 + 2 * ‖u - v‖ ^ 2 := by - nlinarith [two_mul_le_add_sq (rho a v) ‖u - v‖] + linarith only [two_mul_le_add_sq (rho a v) ‖u - v‖] exact le_trans hsq hsum /-- The local support and the local degree set carry the same total-degree image. -/ @@ -265,7 +265,7 @@ private lemma continuous_evalHermiteSum private lemma continuous_nuKappa {d : ℕ} (κ : MultiIndex d) : Continuous (nuKappa κ) := by - simpa [nuKappa] using continuous_PhiKappaAlpha (κ := κ) (α := (0 : MultiIndex d)) + exact continuous_PhiKappaAlpha (κ := κ) (α := (0 : MultiIndex d)) private lemma continuous_rho_localPart_sq {d : ℕ} (κ : MultiIndex d) (j : MultiIndex d) (M : ℕ) (G : FiniteHermiteSum d) : @@ -472,13 +472,13 @@ private lemma indicator_mass_integrable ‖evalHermiteSum κ (localPart j M G) z‖ ^ 2 := by have hnonneg : 0 ≤ Complex.normSq (evalHermiteSum κ (localPart j M G) z) := by dsimp [Complex.normSq] - nlinarith [sq_nonneg (evalHermiteSum κ (localPart j M G) z).re, + nlinarith only [sq_nonneg (evalHermiteSum κ (localPart j M G) z).re, sq_nonneg (evalHermiteSum κ (localPart j M G) z).im] rw [abs_of_nonneg hnonneg, Complex.sq_norm] simp [indicatorMul, Set.indicator, hz, Complex.mul_conj'] · simp [indicatorMul, Set.indicator, hz] rw [← hmass_fun_eq] - simpa [indicatorMul] using + exact ((annulusIntegrablePolynomial (j := j) (κ := κ) (G := localPart j M G) (H := localPart j M G)).norm) @@ -593,7 +593,7 @@ private lemma defectAnnulusMass_localOrbit_lintegral (by have hnonneg : 0 ≤ rho (nuKappa κ z) (evalHermiteSum κ (localPart j M G) z) := abs_nonneg _ - nlinarith) + linarith only [hrho_le, hnonneg]) hrho_le simp [Set.indicator, hz, hsq] · simp [Set.indicator, hz] @@ -705,10 +705,13 @@ private lemma highAnnulus_productAnnulusConstant_bound omega have hdR : (1 : ℝ) ≤ d := by exact_mod_cast hd have hdegR : (1 : ℝ) ≤ ((degreeThreshold d M + M : ℕ) : ℝ) := by exact_mod_cast hdeg_nat - have hsquareR : (1 : ℝ) ≤ (((degreeThreshold d M + M : ℕ) : ℝ) ^ 2) := by nlinarith + have hsquareR : (1 : ℝ) ≤ (((degreeThreshold d M + M : ℕ) : ℝ) ^ 2) := by nlinarith only [hdegR] calc 32 ≤ 144 * (1 : ℝ) * (1 : ℝ) := by norm_num - _ ≤ 144 * (d : ℝ) * (((degreeThreshold d M + M : ℕ) : ℝ) ^ 2) := by nlinarith + _ ≤ 144 * (d : ℝ) * (((degreeThreshold d M + M : ℕ) : ℝ) ^ 2) := by + nlinarith only [ + hdR, hsquareR + ] _ = productAnnulusConstantSq d M := by unfold productAnnulusConstantSq ring @@ -732,7 +735,7 @@ private lemma localOrbit_pointwise_estimate have hcard_le : ((localDegreeSet j M G).card : ℝ) ≤ degreeWidth j M := by exact_mod_cast localDegreeSet_card_le_degreeWidth (j := j) (M := M) (G := G) have hconst := lowAnnulus_productAnnulusConstant_bound (hd := hd) (j := j) (M := M) hlow - nlinarith + linarith only [hcard_le, hconst] have hnonneg : 0 ≤ circleL2NormSq (fun t : Circle => rho (nuKappa κ z) (localOrbit κ j M G z t)) := by unfold circleL2NormSq @@ -741,7 +744,7 @@ private lemma localOrbit_pointwise_estimate circleL2NormSq (localOrbit κ j M G z) ≤ 144 * ((localDegreeSet j M G).card : ℝ) * circleL2NormSq (fun t : Circle => rho (nuKappa κ z) (localOrbit κ j M G z t)) := by - simpa [mul_assoc, mul_left_comm, mul_comm] using hbase + exact hbase _ ≤ productAnnulusConstantSq d M * circleL2NormSq (fun t : Circle => rho (nuKappa κ z) (localOrbit κ j M G z t)) := by gcongr @@ -761,7 +764,7 @@ private lemma localOrbit_pointwise_estimate calc circleL2NormSq (localOrbit κ j M G z) ≤ 32 * circleL2NormSq (fun t : Circle => rho (nuKappa κ z) (localOrbit κ j M G z t)) := by - simpa using hbase + exact hbase _ ≤ productAnnulusConstantSq d M * circleL2NormSq (fun t : Circle => rho (nuKappa κ z) (localOrbit κ j M G z t)) := by gcongr diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductBasisAndAnnuli.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductBasisAndAnnuli.lean index bc81ce1c8c..24309ac9b5 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductBasisAndAnnuli.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermite1Dimd/ProductBasisAndAnnuli.lean @@ -123,7 +123,7 @@ private lemma gaussianInner_finite_sum_basis rw [MeasureTheory.integral_finsetSum] · simp_rw [MeasureTheory.integral_const_mul] · intro α hα - simpa [mul_assoc] using (integrable_productBasis_cross κ α β).const_mul (c α) + exact (integrable_productBasis_cross κ α β).const_mul (c α) private lemma gaussianInner_finite_sum {d : ℕ} (κ : MultiIndex d) @@ -165,7 +165,7 @@ private lemma gaussianInner_finite_sum simp_rw [Finset.sum_mul, mul_assoc] exact MeasureTheory.integrable_finsetSum _ fun α _ => (integrable_productBasis_cross κ α β).const_mul (a α) - simpa [mul_assoc] using (hsumInt.const_mul (conj (b β))) + exact (hsumInt.const_mul (conj (b β))) private lemma measurableSet_productAnnulus {d : ℕ} (j : MultiIndex d) : @@ -221,7 +221,7 @@ private lemma integrable_evalHermiteSum_cross intro α hα refine MeasureTheory.integrable_finsetSum _ ?_ intro β hβ - simpa [mul_assoc] using + exact (integrable_productBasis_cross κ α β).const_mul (G.coeff α * conj (H.coeff β)) /-- Product basis orthonormality at fixed multi-index `κ`. -/ @@ -395,7 +395,7 @@ theorem productBasisPhaseLaw congr 1 push_cast ring - simpa [totalDegree, mul_assoc] using + exact congrArg (fun c : ℂ => c * ∏ q, oneDimPhi (κ q) (α q) (z q)) haux /-- The same phase law for a fixed total-degree piece. -/ @@ -673,7 +673,7 @@ private lemma gaussian_lintegral_rotate_eq simp [f, gaussianDensity, hω] have hgauss : MeasurePreserving f (gaussianMeasure d) (gaussianMeasure d) := ⟨hmeas.measurable, gaussianMeasure_map_eq_of_density hvol hmeas hdens⟩ - simpa [f] using hgauss.lintegral_comp_emb hmeas g + exact hgauss.lintegral_comp_emb hmeas g private lemma fourier_mk_eq_exp (n : ℤ) (θ : ℝ) : @@ -775,7 +775,7 @@ private lemma rotate_one_gaussian_preserving classical let f : CSpace d → CSpace d := fun z => Function.update z q0 ((ω : ℂ) * z q0) have hvol : MeasurePreserving f (volume : Measure (CSpace d)) (volume : Measure (CSpace d)) := by - simpa [f] using (rotate_one_volume_preserving (q0 := q0) (ω := ω)) + exact (rotate_one_volume_preserving (q0 := q0) (ω := ω)) have hmeas : MeasurableEmbedding f := rotate_one_measurableEmbedding (q0 := q0) (ω := ω) have hdens : ∀ z : CSpace d, ENNReal.ofReal (gaussianDensity d (f z)) = ENNReal.ofReal (gaussianDensity d z) := by diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/BasisLocalization.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/BasisLocalization.lean index 054888dc4e..c0514030d2 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/BasisLocalization.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/BasisLocalization.lean @@ -34,7 +34,7 @@ private theorem hermiteSeries_single (k n : ℕ) : hermiteSeries k (fun m : ℕ => if m = n then (1 : ℂ) else 0) = Phi k n := by funext z unfold hermiteSeries - simp_all only [ite_mul, one_mul, zero_mul, tsum_ite_eq] + simp only [ite_mul, one_mul, zero_mul, tsum_ite_eq] private theorem qkn_zero (k : ℕ) {r : ℝ} (hr : 0 < r) : qkn k 0 r = 1 := by simp [qkn_explicit hr] @@ -126,7 +126,7 @@ private theorem Pkn_eval (k n : ℕ) (x : ℝ) : (Finset.sum (Finset.range (k + 1)) (fun j => Polynomial.C (((-1 : ℝ) ^ j) * (Nat.choose k j : ℝ) * (Nat.descFactorial n j : ℝ)) * Polynomial.X ^ (k - j))) = _ - simp_all only [map_mul, map_pow, map_neg, map_one, map_natCast, map_sum, + simp only [map_mul, map_pow, map_neg, map_one, map_natCast, map_sum, Polynomial.coe_evalRingHom, Polynomial.eval_X] @@ -140,8 +140,7 @@ private theorem Pkn_coeff (k n m : ℕ) : rw [Polynomial.finsetSum_coeff] refine Finset.sum_congr rfl ?_ intro j hj - simpa only [mul_comm, mul_left_comm, map_mul, map_natCast, map_pow, map_neg, map_one, mul_assoc, - Polynomial.coeff_natCast_mul] using + exact (Polynomial.coeff_C_mul_X_pow (((-1 : ℝ) ^ j) * (Nat.choose k j : ℝ) * (Nat.descFactorial n j : ℝ)) (k - j) m) @@ -358,7 +357,7 @@ private lemma normSq_finiteHermiteSum_circlePoint circleLeadingFactor k r * (fourier (-(k : ℤ)) (QuotientAddGroup.mk θ : Circle) : ℂ) * finiteCirclePoly k r a (QuotientAddGroup.mk θ : Circle) := by - simpa only [fourier_apply, neg_smul, natCast_zsmul] using + exact (finiteHermiteSum_circle (k := k) (a := a) hr (QuotientAddGroup.mk θ : Circle)) have hfour : ‖(fourier (-(k : ℤ)) (QuotientAddGroup.mk θ : Circle) : ℂ)‖ ^ 2 = 1 := by rw [fourier_mk_norm]; norm_num @@ -419,7 +418,7 @@ private lemma setIntegral_radialStrip_eq_intervalIntegral (j : ℕ) (f : ℝ → rw [MeasureTheory.setIntegral_congr_set hIoiIco_ae, intervalIntegral.integral_of_le (show (j : ℝ) ≤ (((j + 1 : ℕ) : ℝ)) by exact_mod_cast Nat.le_succ j)] - simpa only [Nat.cast_add, Nat.cast_one] using + exact (MeasureTheory.setIntegral_congr_set (f := f) (μ := volume) (Ico_ae_eq_Ioc (a := (j : ℝ)) (b := (((j + 1 : ℕ) : ℝ))))) @@ -442,7 +441,7 @@ private lemma continuous_finiteHermiteSumCircle_comp Continuous (fun p : ℝ × ℝ => finiteHermiteSum k a (circlePoint p.1 ((QuotientAddGroup.mk p.2 : Circle)))) := by - simpa only [finiteHermiteSum, Pi.mul_apply, Function.comp_apply] using + exact (continuous_finsetSum (s := (Finset.univ : Finset (Fin D))) fun n _ => continuous_const.mul ((continuous_Phi k n.1).comp continuous_circlePoint_mk)) @@ -742,7 +741,7 @@ private lemma intervalIntegrable_basisRadialTerm have hcircle0 : Continuous (fun r : ℝ => circlePoint r t0) := by have h := continuous_circlePoint_mk.comp (continuous_id.prodMk (continuous_const (y := (0 : ℝ)))) - simpa only [QuotientAddGroup.mk_zero, id_eq, Function.comp_def, t0] using h + exact h have hg : Continuous g := by dsimp [g] have h := continuous_id.mul @@ -777,20 +776,20 @@ private lemma intervalIntegrable_basisRadialTerm rw [hphi, norm_mul, norm_mul, mul_pow, mul_pow, hfourk, norm_sq_circleLeadingFactor, norm_mul, mul_pow, hfourn, Complex.norm_real, Real.norm_eq_abs] - ring_nf + ring private lemma sqrt_sub_le_sub_of_one_le {a b : ℝ} (hb1 : 1 ≤ b) (hba : b ≤ a) : Real.sqrt a - Real.sqrt b ≤ a - b := by - have hb_nonneg : 0 ≤ b := by linarith + have hb_nonneg : 0 ≤ b := le_trans zero_le_one hb1 have ha_nonneg : 0 ≤ a := le_trans hb_nonneg hba have hdiff_nonneg : 0 ≤ Real.sqrt a - Real.sqrt b := sub_nonneg.mpr (Real.sqrt_le_sqrt hba) have hden : 1 ≤ Real.sqrt a + Real.sqrt b := by have hb_sqrt : 1 ≤ Real.sqrt b := by simp_all only [sub_nonneg, sqrt_le_sqrt_iff, one_le_sqrt] - nlinarith [hb_sqrt, Real.sqrt_nonneg a] + nlinarith only [hb_sqrt, Real.sqrt_nonneg a] have hmul : (Real.sqrt a - Real.sqrt b) * (Real.sqrt a + Real.sqrt b) = a - b := by calc @@ -800,7 +799,10 @@ private lemma sqrt_sub_le_sub_of_one_le calc Real.sqrt a - Real.sqrt b ≤ - (Real.sqrt a - Real.sqrt b) * (Real.sqrt a + Real.sqrt b) := by nlinarith + (Real.sqrt a - Real.sqrt b) * (Real.sqrt a + Real.sqrt b) := by + nlinarith only [ + hdiff_nonneg, hden + ] _ = a - b := hmul private lemma monomial_core_pointwise @@ -868,9 +870,9 @@ private lemma shell_centered_gap_le_pointwise_gap have hupper : r - (j : ℝ) ≤ 1 := by have := hrj.2 norm_num at this - linarith - linarith - linarith + linarith only [this] + linarith only [hupper] + linarith only [hjr] have hmain : |((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - ((k + 4 : ℕ) : ℝ) ≤ @@ -892,7 +894,7 @@ private theorem phi0_support_zero (k : ℕ) : phi0 k (circlePoint r t) = circleLeadingFactor k r * (fourier (-(k : ℤ)) t : ℂ) * g 0) := by let g : ℕ → ℂ := fun n => if n = 0 then 1 else 0 refine ⟨g, ?_, ?_, ?_⟩ - · simpa only [phi0, g] using (hermiteSeries_single k 0).symm + · exact (hermiteSeries_single k 0).symm · intro n hn simp [g, Nat.ne_of_gt hn] · intro r hr t @@ -1108,7 +1110,7 @@ private theorem phi0AnnulusIntegrand_le_shell exact hr.2 have hexp : Real.exp (-r ^ 2) ≤ Real.exp (-(j : ℝ) ^ 2) := by apply Real.exp_le_exp.mpr - nlinarith [hr.1, hr.2] + nlinarith only [hr.1, hr.2] unfold phi0AnnulusIntegrand have hsqrt_nonzero : Real.sqrt (Nat.factorial k : ℝ) ≠ 0 := by positivity calc @@ -1200,7 +1202,7 @@ theorem phi0_localization : have hx_le_j : x ≤ (j : ℝ) := by dsimp [x, posPart] refine max_le ?_ ?_ - · linarith + · exact sub_le_self _ (Nat.cast_nonneg _) · exact_mod_cast Nat.zero_le j have hj1_le : (((j + 1 : ℕ) : ℝ)) ≤ (((k + 6 : ℕ) : ℝ)) * (x + 1) := by have hx_lb : (j : ℝ) - ((k + 5 : ℕ) : ℝ) ≤ x := by @@ -1211,12 +1213,15 @@ theorem phi0_localization : ring have hsum' : (j : ℝ) + 1 ≤ x + (((k + 6 : ℕ) : ℝ)) := by rw [hkcast] - linarith + linarith only [hx_lb] have hsum : (((j + 1 : ℕ) : ℝ)) ≤ x + (((k + 6 : ℕ) : ℝ)) := by simpa only [Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] using hsum' have hk6_ge1_nat : 1 ≤ k + 6 := by omega have hk6_ge1 : (1 : ℝ) ≤ (((k + 6 : ℕ) : ℝ)) := by exact_mod_cast hk6_ge1_nat - have hmul : x + (((k + 6 : ℕ) : ℝ)) ≤ (((k + 6 : ℕ) : ℝ)) * (x + 1) := by nlinarith + have hmul : x + (((k + 6 : ℕ) : ℝ)) ≤ (((k + 6 : ℕ) : ℝ)) * (x + 1) := by + nlinarith only [ + hx_nonneg, hkcast + ] exact le_trans hsum hmul have hpoly1 : (((j + 1 : ℕ) : ℝ) ^ m) ≤ ((((k + 6 : ℕ) : ℝ) ^ m)) * ((x + 1) ^ m) := by calc @@ -1233,7 +1238,7 @@ theorem phi0_localization : _ = ((((k + 6 : ℕ) : ℝ) ^ m)) * (2 ^ (m - 1)) * (1 + x ^ m) := by ring have hexp : Real.exp (-(j : ℝ) ^ 2) ≤ Real.exp (-x ^ 2) := by apply Real.exp_le_exp.mpr - nlinarith [hx_nonneg, hx_le_j] + nlinarith only [hx_nonneg, hx_le_j] have hshell := annulusIntegralSq_phi0_shell_bound k j hpolar have hmain : annulusIntegralSq (phi0 k) j ≤ A * (1 + x ^ m) * Real.exp (-x ^ 2) := by @@ -1256,7 +1261,7 @@ theorem phi0_localization : simpa only [mul_assoc, one_div, neg_mul] using mul_le_mul_of_nonneg_left hgauss hA_nonneg _ ≤ (A * Cpoly + 1) * Real.exp (-((1 : ℝ) / 2) * x ^ 2) := by have hexp_nonneg : 0 ≤ Real.exp (-((1 : ℝ) / 2) * x ^ 2) := (Real.exp_pos _).le - have hcoeff : A * Cpoly ≤ A * Cpoly + 1 := by linarith + have hcoeff : A * Cpoly ≤ A * Cpoly + 1 := le_add_of_nonneg_right zero_le_one simpa only [one_div, neg_mul, ge_iff_le, mul_assoc] using mul_le_mul_of_nonneg_right hcoeff hexp_nonneg _ = C * Real.exp (-((1 : ℝ) / 2) * x ^ 2) := by rfl @@ -1295,10 +1300,10 @@ private lemma pow_le_one_add_pow_of_le {r : ℝ} (hr : 0 ≤ r) {m : ℕ} {k : rcases le_or_gt r 1 with h1 | h1 · -- r ≤ 1: r^m ≤ 1 ≤ 1 + r^(2k) have : r ^ m ≤ 1 := pow_le_one₀ hr h1 - linarith [pow_nonneg hr (2 * k)] + linarith only [hr, this, pow_nonneg hr (2 * k)] · -- r > 1: r^m ≤ r^(2k) ≤ 1 + r^(2k) have : r ^ m ≤ r ^ (2 * k) := pow_le_pow_right₀ h1.le hm - linarith + linarith only [this] -- Helper: zpow to pow conversion for positive reals private lemma zpow_mul_pow_eq {r : ℝ} (hr : 0 < r) (k n j : ℕ) (hjn : j ≤ n) @@ -1532,8 +1537,8 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : use 1; constructor; · norm_num intro n hn x have hn_R : (1 : ℝ) ≤ (n : ℝ) := by exact_mod_cast hn - have hm_pos : (0 : ℝ) < (n : ℝ) := by linarith - have hm_eq : (n : ℝ) - (1 : ℕ) + 1 = (n : ℝ) := by push_cast; linarith + have hm_pos : (0 : ℝ) < (n : ℝ) := by linarith only [hn_R] + have hm_eq : (n : ℝ) - (1 : ℕ) + 1 = (n : ℝ) := by push_cast; linarith only [] -- Simplify Pkn 1 n eval x = x - n have heval : (Pkn 1 n).eval x = x - (n : ℝ) := by rw [Pkn_eval]; simp [Finset.sum_range_succ]; ring @@ -1545,7 +1550,7 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : -- Goal: |x - n| ≤ n^(1/2) * (1 + |x - n| / n^(1/2)) have h_rpow_pos : (0 : ℝ) < (n : ℝ) ^ ((1 : ℝ) / 2) := by positivity rw [mul_add, mul_one, mul_div_cancel₀ _ (ne_of_gt h_rpow_pos)] - linarith [Real.rpow_nonneg (le_of_lt hm_pos) ((1 : ℝ) / 2)] + linarith only [h_rpow_pos, Real.rpow_nonneg (le_of_lt hm_pos) ((1 : ℝ) / 2)] | k + 2 => -- Inductive step for k + 2. Use IH for k + 1 and k. obtain ⟨Ak1, hAk1_pos, hAk1_bound⟩ := ih (k + 1) (by omega) @@ -1587,9 +1592,9 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : exact abs_sub _ _ -- Simplify centers: ↑(N+1) - ↑(k+2) + 1 = ↑m, ↑N - ↑(k+1) + 1 = ↑m, ↑N - ↑k + 1 = ↑m + 1 have hm_cast : (m : ℝ) = (N : ℝ) - (k : ℝ) := by rw [hm_def]; push_cast [Nat.cast_sub hNk]; ring - have hcenter : (↑(N + 1) : ℝ) - ↑(k + 2) + 1 = (m : ℝ) := by push_cast; linarith - have hcenter1 : (↑N : ℝ) - ↑(k + 1) + 1 = (m : ℝ) := by push_cast; linarith - have hcenter0 : (↑N : ℝ) - ↑k + 1 = (m : ℝ) + 1 := by linarith + have hcenter : (↑(N + 1) : ℝ) - ↑(k + 2) + 1 = (m : ℝ) := by push_cast; linarith only [hm_cast] + have hcenter1 : (↑N : ℝ) - ↑(k + 1) + 1 = (m : ℝ) := by push_cast; linarith only [hm_cast] + have hcenter0 : (↑N : ℝ) - ↑k + 1 = (m : ℝ) + 1 := by linarith only [hm_cast] -- Apply IH for k+1 at N have hIH1 := hAk1_bound N hNk1 x rw [hcenter1] at hIH1 @@ -1606,10 +1611,13 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : (Real.sqrt (m : ℝ) + |y|) ^ ℓ := fun y ℓ => rpow_half_mul_pow_eq hm_pos y ℓ set S := Real.sqrt (m : ℝ) + |x - (m : ℝ)| with hS_def - have hS_pos : 0 < S := by linarith [abs_nonneg (x - (m : ℝ)), Real.sqrt_pos_of_pos hm_pos] + have hS_pos : 0 < S := by + linarith only [ + hm_pos, abs_nonneg (x - (m : ℝ)), Real.sqrt_pos_of_pos hm_pos + ] have hS_ge_one : 1 ≤ S := by have : 1 ≤ Real.sqrt (m : ℝ) := by rw [Real.one_le_sqrt]; exact_mod_cast (show 1 ≤ m by omega) - linarith [abs_nonneg (x - (m : ℝ))] + linarith only [this, abs_nonneg (x - (m : ℝ))] -- Convert goal to S form via suffices suffices hgoal : |(Pkn (k + 2) (N + 1)).eval x| ≤ (((k : ℝ) + 3) * Ak1 + ((k : ℝ) + 1) * 4 ^ (k + 1) * Ak) * S ^ (k + 2) by @@ -1633,7 +1641,7 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : -- IH0 in S form (center m+1 → bound by 4^k * S^k) have hIH0_S : |(Pkn k N).eval x| ≤ Ak * (4 ^ k * S ^ k) := by -- Convert IH0 to (√(m+1) + |x-(m+1)|)^k form - have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by linarith + have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by linarith only [hm_pos] have hm1_nn : (0 : ℝ) ≤ (m : ℝ) + 1 := le_of_lt hm1_pos have hS1_eq : ((m : ℝ) + 1) ^ ((k : ℝ) / 2) * (1 + |x - ((m : ℝ) + 1)| / Real.sqrt ((m : ℝ) + 1)) ^ k = @@ -1648,7 +1656,7 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : calc |x - ((m : ℝ) + 1)| = |(x - (m : ℝ)) + (-1)| := by ring_nf _ ≤ |x - (m : ℝ)| + |(-1 : ℝ)| := abs_add_le _ _ _ = |x - (m : ℝ)| + 1 := by simp [abs_neg] - linarith + linarith only [h1, h2] -- S + 2 ≤ 3 * S since S ≥ 1 have hS_shift : S + 2 ≤ 3 * S := by linarith only [hS_ge_one] have hS1_nn : 0 ≤ Real.sqrt ((m : ℝ) + 1) + |x - ((m : ℝ) + 1)| := by positivity @@ -1662,7 +1670,7 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : _ ≤ Ak * (4 ^ k * S ^ k) := by gcongr; norm_num -- Bound |x - (N+1)| ≤ (k+2)*S have hxN : |x - ↑(N + 1)| ≤ ((k + 2 : ℕ) : ℝ) * S := by - have hN1 : (↑(N + 1) : ℝ) = (m : ℝ) + (k : ℝ) + 1 := by push_cast; linarith + have hN1 : (↑(N + 1) : ℝ) = (m : ℝ) + (k : ℝ) + 1 := by push_cast; linarith only [hm_cast] rw [hN1] have hk1_nn : (0 : ℝ) ≤ (k : ℝ) + 1 := by positivity calc |x - ((m : ℝ) + (k : ℝ) + 1)| @@ -1671,7 +1679,7 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : = |(x - (m : ℝ)) - ((k : ℝ) + 1)| := by ring_nf _ ≤ |x - (m : ℝ)| + |(k : ℝ) + 1| := abs_sub _ _ _ = _ := by rw [abs_of_nonneg hk1_nn] - _ ≤ S + ((k : ℝ) + 1) := by linarith [Real.sqrt_nonneg (m : ℝ)] + _ ≤ S + ((k : ℝ) + 1) := by linarith only [Real.sqrt_nonneg (m : ℝ)] _ ≤ ((k + 2 : ℕ) : ℝ) * S := by push_cast nlinarith only [hS_ge_one, hk1_nn] @@ -1688,11 +1696,11 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : calc (m : ℝ) = Real.sqrt (m : ℝ) ^ 2 := hsq.symm _ ≤ S ^ 2 := by apply sq_le_sq' - · linarith + · linarith only [hS_pos, h2] · exact hsqrt_le_S -- |x| ≤ S + S^2 and S ≤ S^2 (since S ≥ 1), so |x| ≤ 2*S^2 have h4 : S ≤ S ^ 2 := by rw [sq]; exact le_mul_of_one_le_right (le_of_lt hS_pos) hS_ge_one - linarith + linarith only [h1, h2, h3, h4] have hkx : ((k + 1 : ℕ) : ℝ) * |x| ≤ ((k + 1 : ℕ) : ℝ) * (2 * S ^ 2) := by apply mul_le_mul_of_nonneg_left hx_bound exact_mod_cast (show 0 ≤ k + 1 by omega) @@ -1711,7 +1719,7 @@ private theorem scaled_laguerre_bound_Pkn (k : ℕ) : have h4 : (4 : ℝ) ^ (k + 1) = 4 * (4 : ℝ) ^ k := by ring rw [h4] have : 0 ≤ ((k : ℝ) + 1) * Ak * (4 : ℝ) ^ k := by positivity - linarith + linarith only [hAk1_pos, this] /-- Rising factorial: m^k ≤ m(m+1)...(m+k-1) when m ≥ 1. Equivalently, for k ≤ n, (n-k+1)^k ≤ n! / (n-k)!. -/ @@ -1767,7 +1775,7 @@ private lemma one_plus_abs_u_le_sq (m : ℕ) (hm : 1 ≤ m) (r : ℝ) (hr : 0 have hsqrt_nn : 0 ≤ Real.sqrt (m : ℝ) := le_of_lt hsqrt_pos -- r² - m = (r - √m)(r + √m), so |r²-m|/√m = |r-√m| * (r+√m)/√m have hfactor : r ^ 2 - (m : ℝ) = (r - Real.sqrt (m : ℝ)) * (r + Real.sqrt (m : ℝ)) := by - nlinarith [Real.sq_sqrt (le_of_lt hm_pos)] + nlinarith only [Real.sq_sqrt (le_of_lt hm_pos)] set t := r - Real.sqrt (m : ℝ) set s := r + Real.sqrt (m : ℝ) have hs_nn : 0 ≤ s := by positivity @@ -1790,11 +1798,11 @@ private lemma one_plus_abs_u_le_sq (m : ℕ) (hm : 1 ≤ m) (r : ℝ) (hr : 0 have hat_nn := abs_nonneg t -- t ≤ |t| ≤ |t| * √m since √m ≥ 1 have : |t| ≤ |t| * Real.sqrt (m : ℝ) := le_mul_of_one_le_right hat_nn h1 - nlinarith + linarith only [ht_le, this] have habs_t := abs_nonneg t calc 1 + |t| * s * (Real.sqrt (m : ℝ))⁻¹ = 1 + |t| * (s / Real.sqrt (m : ℝ)) := by congr 1; rw [mul_assoc, div_eq_mul_inv] - _ ≤ 1 + |t| * (|t| + 2) := by linarith [mul_le_mul_of_nonneg_left hs_bound habs_t] + _ ≤ 1 + |t| * (|t| + 2) := by linarith only [mul_le_mul_of_nonneg_left hs_bound habs_t] _ = (1 + |t|) ^ 2 := by ring /-- Gaussian shift: exp(-(r - rStar(α))²) ≤ exp(2) * exp(-(r-√m)²/2) where m = α+1. -/ @@ -1832,7 +1840,7 @@ private lemma rStar_to_sqrt_gaussian (α : ℕ) (hα : 1 ≤ α) (r : ℝ) : simp only [s, m] apply sub_nonneg.mpr apply Real.sqrt_le_sqrt - linarith + linarith only [] have hδ_le_one : m - s ≤ 1 := by simp only [s, m] have h1 : (0 : ℝ) ≤ (α : ℝ) + 1 / 2 := by positivity @@ -1840,7 +1848,7 @@ private lemma rStar_to_sqrt_gaussian (α : ℕ) (hα : 1 ≤ α) (r : ℝ) : -- √(α+1) - √(α+1/2) ≤ 1 -- (√(α+1) - √(α+1/2)) * (√(α+1) + √(α+1/2)) = (α+1) - (α+1/2) = 1/2 -- And √(α+1) + √(α+1/2) ≥ √(3/2) ≥ 1/2, so the difference ≤ 1. - nlinarith [Real.sq_sqrt h1, Real.sq_sqrt h2, Real.sqrt_nonneg ((α : ℝ) + 1), + nlinarith only [Real.sq_sqrt h1, Real.sq_sqrt h2, Real.sqrt_nonneg ((α : ℝ) + 1), Real.sqrt_nonneg ((α : ℝ) + 1 / 2)] -- (r-s)² ≥ t²/2 - 2 have hkey : t ^ 2 / 2 - 2 ≤ (r - s) ^ 2 := by @@ -1850,12 +1858,11 @@ private lemma rStar_to_sqrt_gaussian (α : ℕ) (hα : 1 ≤ α) (r : ℝ) : have h1 : (t + δ) ^ 2 = t ^ 2 + 2 * t * δ + δ ^ 2 := by ring rw [h1] have h2 : -2 * |t| ≤ 2 * t * δ := by - have := le_abs_self t - have := neg_abs_le t - nlinarith - have h3 : t ^ 2 / 2 - 2 * |t| + 2 ≥ 0 := by nlinarith [sq_nonneg (|t| - 2), sq_abs t] - nlinarith [sq_nonneg δ] - linarith + nlinarith only [hδ_nn, hδ_le_one, le_abs_self t, neg_abs_le t] + have h3 : t ^ 2 / 2 - 2 * |t| + 2 ≥ 0 := by + nlinarith only [sq_nonneg (|t| - 2), sq_abs t] + nlinarith only [h2, h3, sq_nonneg δ] + linarith only [hkey] /-- Polynomial absorption: (1+|t|)^p * exp(-t²/2) ≤ C_p * exp(-t²/4). -/ private theorem poly_times_gaussian_absorption (p : ℕ) : @@ -1872,14 +1879,14 @@ private theorem poly_times_gaussian_absorption (p : ℕ) : calc (1 + |t|) ^ p ≤ (Real.exp |t|) ^ p := by gcongr - linarith [Real.add_one_le_exp |t|] + linarith only [Real.add_one_le_exp |t|] _ = Real.exp ((p : ℝ) * |t|) := by rw [Real.exp_nat_mul] have h2 : (p : ℝ) * |t| - t ^ 2 / 4 ≤ (p : ℝ) ^ 2 := by - nlinarith [sq_nonneg ((p : ℝ) - |t| / 2), sq_abs t, abs_nonneg t] + nlinarith only [sq_nonneg ((p : ℝ) - |t| / 2), sq_abs t, abs_nonneg t] calc (1 + |t|) ^ p * Real.exp (-t ^ 2 / 2) ≤ Real.exp ((p : ℝ) * |t|) * Real.exp (-t ^ 2 / 2) := by gcongr _ = Real.exp ((p : ℝ) * |t| + (-t ^ 2 / 2)) := by rw [← Real.exp_add] - _ ≤ Real.exp ((p : ℝ) ^ 2 + (-t ^ 2 / 4)) := by apply Real.exp_le_exp.mpr; nlinarith + _ ≤ Real.exp ((p : ℝ) ^ 2 + (-t ^ 2 / 4)) := by apply Real.exp_le_exp.mpr; linarith only [h2] _ = Real.exp ((p : ℝ) ^ 2) * Real.exp (-t ^ 2 / 4) := by rw [Real.exp_add] /-- Squares the scaled-Laguerre pointwise bound on `Pkn k n` (for `k < n`). @@ -1899,11 +1906,11 @@ private lemma Pkn_sq_bound (k n : ℕ) (hkn_strict : k < n) (r : ℝ) {Ak : ℝ} have hm_rpow_nat : m ^ (k : ℝ) = m ^ k := Real.rpow_natCast m k have hm_pos' : (0 : ℝ) < m := by have hkn_cast : (k : ℝ) < (n : ℝ) := by exact_mod_cast hkn_strict - simp only [m]; linarith + simp only [m]; linarith only [hkn_cast] rw [sq, ← Real.rpow_add hm_pos', ← hm_rpow_nat] - simp_all only [rpow_natCast, add_halves] + simp only [rpow_natCast, add_halves] have hP_abs_bound := - sq_le_sq' (by linarith [abs_nonneg ((Pkn k n).eval (r ^ 2))]) hPkn + sq_le_sq' (by linarith only [hPkn, abs_nonneg ((Pkn k n).eval (r ^ 2))]) hPkn calc ((Pkn k n).eval (r ^ 2)) ^ 2 = (|(Pkn k n).eval (r ^ 2)|) ^ 2 := (sq_abs _).symm _ ≤ (Ak * ((n : ℝ) - (k : ℝ) + 1) ^ ((k : ℝ) / 2) * @@ -2025,7 +2032,7 @@ private lemma radial_density_large_step (k n : ℕ) (hkn_strict : k < n) (r : Ak ^ 2 * C0 * Real.exp 2 * Cp ≤ Ak ^ 2 * C0 * Real.exp 2 * Cp + Ak ^ 2 * Real.exp 1 * Cp + Cp * Real.exp 1 := by have hnonneg : 0 ≤ Ak ^ 2 * Real.exp 1 * Cp + Cp * Real.exp 1 := by positivity - linarith + linarith only [hnonneg] exact mul_le_mul_of_nonneg_right hcoeff_le (by positivity) apply le_trans _ hle_first_term -- Now we need: @@ -2057,7 +2064,7 @@ private lemma radial_density_large_step (k n : ℕ) (hkn_strict : k < n) (r : (1 + |r - Real.sqrt ((α + 1 : ℕ) : ℝ)|) ^ (4 * k) ≤ (1 + |r - Real.sqrt ((α + 1 : ℕ) : ℝ)|) ^ (4 * k + 1) := by have hbase_ge_one : (1 : ℝ) ≤ 1 + |r - Real.sqrt ((α + 1 : ℕ) : ℝ)| := by - linarith [abs_nonneg (r - Real.sqrt ((α + 1 : ℕ) : ℝ))] + linarith only [abs_nonneg (r - Real.sqrt ((α + 1 : ℕ) : ℝ))] exact pow_le_pow_right₀ hbase_ge_one (by omega) have hCp_at : (1 + |r - Real.sqrt ((α + 1 : ℕ) : ℝ)|) ^ (4 * k + 1) * @@ -2115,7 +2122,7 @@ private lemma radial_density_large_step (k n : ℕ) (hkn_strict : k < n) (r : (Ak ^ 2 * (↑n - ↑k + 1) ^ k * (1 + |r - √↑(α + 1)|) ^ (4 * k)) * (r ^ (2 * α + 1) * Real.exp (-r ^ 2)) := by have hm_nonneg : 0 ≤ (↑n - ↑k + 1 : ℝ) := by - linarith [show (k : ℝ) < (n : ℝ) by exact_mod_cast hkn_strict] + linarith only [show (k : ℝ) < (n : ℝ) by exact_mod_cast hkn_strict] have hcoef_nonneg : 0 ≤ Ak ^ 2 * (↑n - ↑k + 1) ^ k := by positivity have hmid : Ak ^ 2 * (↑n - ↑k + 1) ^ k * (1 + |r ^ 2 - (↑n - ↑k + 1)| / √(↑n - ↑k + 1)) ^ (2 * k) @@ -2208,13 +2215,13 @@ private lemma radial_density_eq_step (k : ℕ) (r : ℝ) (hr : 0 ≤ r) (hr_pos Real.exp 1 * (1 + |r - 1|) * Real.exp (-(r - 1) ^ 2 / 2) := by set t : ℝ := r - 1 have hr_le : r ≤ 1 + |t| := by - linarith [le_abs_self t] + linarith only [le_abs_self t] have hexp : Real.exp (-r ^ 2) ≤ Real.exp 1 * Real.exp (-t ^ 2 / 2) := by have hr_eq : r = t + 1 := by simp [t] rw [hr_eq, ← Real.exp_add] apply Real.exp_le_exp.mpr - nlinarith [sq_nonneg (t + 2)] + nlinarith only [sq_nonneg (t + 2)] calc r * Real.exp (-r ^ 2) ≤ (1 + |t|) * Real.exp (-r ^ 2) := by gcongr _ ≤ (1 + |t|) * (Real.exp 1 * Real.exp (-t ^ 2 / 2)) := by gcongr @@ -2259,7 +2266,7 @@ private lemma radial_density_eq_step (k : ℕ) (r : ℝ) (hr : 0 ≤ r) (hr_pos have hnonneg : 0 ≤ Ak ^ 2 * C0 * Real.exp 2 * Cp + Cp * Real.exp 1 := by rw [hC0_def] positivity - linarith + linarith only [hnonneg] rw [hLHS_eq] calc (1 / ((Nat.factorial k : ℝ) ^ 2)) * ((Pkn k k).eval (r ^ 2)) ^ 2 * (r * Real.exp (-r ^ 2)) @@ -2348,7 +2355,7 @@ private theorem radial_density_gaussian_bound_small (k : ℕ) : have hA : |r ^ k * qkn k n r| ≤ A * (1 + r ^ (2 * k)) := by simpa [A] using qkn_small_n_growth k n hn hkn.le hr have hA_sq : |r ^ k * qkn k n r| ^ 2 ≤ (A * (1 + r ^ (2 * k))) ^ 2 := by - nlinarith [hA, abs_nonneg (r ^ k * qkn k n r)] + nlinarith only [hA, abs_nonneg (r ^ k * qkn k n r)] have hmain1 : r * (((r ^ k / Real.sqrt ((Nat.factorial k : ℕ) : ℝ)) ^ 2) * |qkn k n r| ^ 2) * Real.exp (-r ^ 2) @@ -2365,7 +2372,7 @@ private theorem radial_density_gaussian_bound_small (k : ℕ) : ≤ (r / (Nat.factorial k : ℝ)) * (A * (1 + r ^ (2 * k))) ^ 2 * Real.exp (-r ^ 2) := by gcongr refine le_trans hmain2 ?_ have hsq : (1 + r ^ (2 * k)) ^ 2 ≤ 2 * (1 + (r ^ (2 * k)) ^ 2) := by - nlinarith [sq_nonneg (r ^ (2 * k) - 1)] + linarith only [sq_nonneg (r ^ (2 * k) - 1)] have hpoly_step : r * (1 + r ^ (2 * k)) ^ 2 ≤ 4 * (1 + r ^ (4 * k + 1)) := by have hsq' : r * (1 + r ^ (2 * k)) ^ 2 ≤ r * (2 * (1 + (r ^ (2 * k)) ^ 2)) := by gcongr have hpow4 : (r ^ (2 * k)) ^ 2 = r ^ (4 * k) := by @@ -2373,11 +2380,11 @@ private theorem radial_density_gaussian_bound_small (k : ℕ) : ring_nf have hr_top : r ≤ 1 + r ^ (4 * k + 1) := by rcases le_or_gt r 1 with hr1 | hr1 - · linarith [pow_nonneg hr (4 * k + 1)] + · linarith only [hr, hr1, pow_nonneg hr (4 * k + 1)] · have : r ^ (1 : ℕ) ≤ r ^ (4 * k + 1) := by apply pow_le_pow_right₀ hr1.le omega - simpa using (le_trans this (by linarith)) + simpa using (le_trans this (by linarith only [])) have htop_nonneg : 0 ≤ r ^ (4 * k + 1) := pow_nonneg hr _ calc r * (1 + r ^ (2 * k)) ^ 2 ≤ r * (2 * (1 + (r ^ (2 * k)) ^ 2)) := hsq' @@ -2385,7 +2392,7 @@ private theorem radial_density_gaussian_bound_small (k : ℕ) : _ = 2 * (r + r ^ (4 * k + 1)) := by ring_nf _ ≤ 2 * (2 * (1 + r ^ (4 * k + 1))) := by gcongr - nlinarith [hr_top, htop_nonneg] + linarith only [hr_top, htop_nonneg] _ = 4 * (1 + r ^ (4 * k + 1)) := by ring have hconst : (r / (Nat.factorial k : ℝ)) * (A * (1 + r ^ (2 * k))) ^ 2 * Real.exp (-r ^ 2) @@ -2416,7 +2423,7 @@ private theorem radial_density_gaussian_bound_small (k : ℕ) : have hrewrite_exp : Real.exp (-(1 / 2 : ℝ) * r ^ 2) = Real.exp (-r ^ 2 / 2) := by congr 1 ring - have hcoeff : K0 ≤ K0 + 1 := by linarith + have hcoeff : K0 ≤ K0 + 1 := by linarith only [] have hnonneg_exp : 0 ≤ Real.exp (-r ^ 2 / 2) := (Real.exp_pos _).le have hK0_le : K0 * Real.exp (-r ^ 2 / 2) ≤ (K0 + 1) * Real.exp (-r ^ 2 / 2) := mul_le_mul_of_nonneg_right hcoeff hnonneg_exp @@ -2447,8 +2454,8 @@ private theorem exp_neg_sq_le_exp_posPart_sq (k n : ℕ) (hn : 1 ≤ n) (hnk : n have hn_nn : (0 : ℝ) ≤ (n : ℝ) := by positivity have hsqrt_le_n : Real.sqrt (n : ℝ) ≤ (n : ℝ) := by have h1 : (1 : ℝ) ≤ (n : ℝ) := by exact_mod_cast hn - nlinarith [Real.sq_sqrt hn_nn, Real.sqrt_nonneg (n : ℝ)] - linarith + nlinarith only [hsqrt_nn, hn_nn, h1, Real.sq_sqrt hn_nn, Real.sqrt_nonneg (n : ℝ)] + linarith only [hn_le_k, hsqrt_le_n] have hp_le_r : posPart (|r - Real.sqrt (n : ℝ)| - ((k + 3 : ℕ) : ℝ)) ≤ r := by unfold posPart apply max_le _ hr @@ -2457,16 +2464,19 @@ private theorem exp_neg_sq_le_exp_posPart_sq (k n : ℕ) (hn : 1 ≤ n) (hnk : n have hab : |r - Real.sqrt (n : ℝ)| ≤ r + Real.sqrt (n : ℝ) := by rcases le_or_gt r (Real.sqrt (n : ℝ)) with hle | hgt · rw [abs_of_nonpos (sub_nonpos.mpr hle)] - linarith + linarith only [hr] · rw [abs_of_pos (sub_pos.mpr hgt)] - linarith [hsqrt_nn] + linarith only [hsqrt_nn] push_cast - linarith + linarith only [hab, hsqrt_le_k] -- Step 2: p² ≤ r² ≤ 2r², so (1/4)*p² ≤ (1/4)*2r² = r²/2. have hp_nn : 0 ≤ posPart (|r - Real.sqrt (n : ℝ)| - ((k + 3 : ℕ) : ℝ)) := le_max_right _ _ - nlinarith [sq_nonneg (posPart (|r - Real.sqrt (n : ℝ)| - ((k + 3 : ℕ) : ℝ))), - sq_le_sq' (by linarith) hp_le_r] + linarith only [ + hr, hp_le_r, hp_nn, + sq_nonneg (posPart (|r - Real.sqrt (n : ℝ)| - ((k + 3 : ℕ) : ℝ))), + sq_le_sq' (by linarith only [hp_nn, hr]) hp_le_r + ] /-- Gaussian centered at √m implies Gaussian in posPart form with constant 1/4. Since posPart(|r-√n|-(k+3)) ≤ |r-√m| (where m = n-k+1, using |√n-√m| ≤ k+1 ≤ k+3), @@ -2489,7 +2499,10 @@ private theorem gaussian_rStar_to_posPart (k n : ℕ) (hn : 1 ≤ n) (hkn : k -- For k=0: m = n+1, √n ≤ √(n+1) = √m, so |√n-√m| ≤ 1 ≤ k+3. -- For k≥1: √n - √(n-k+1) ≤ n-(n-k+1) = k-1 < k+3 (using √a-√b ≤ a-b for b ≥ 1). -- In all cases: posPart(|r-√n|-(k+3)) ≤ posPart(|r-√m|+|√m-√n|-(k+3)) ≤ |r-√m|. - suffices hp_le : p ≤ |r - Real.sqrt m| by nlinarith [sq_nonneg p, sq_abs (r - Real.sqrt m)] + suffices hp_le : p ≤ |r - Real.sqrt m| by + nlinarith only [ + hp_nn, hp_le, sq_nonneg p, sq_abs (r - Real.sqrt m) + ] -- Prove p ≤ |r - √m| -- p = max(|r-√n|-(k+3), 0), so suffices to show |r-√n|-(k+3) ≤ |r-√m| and 0 ≤ |r-√m|. change posPart (|r - Real.sqrt (n : ℝ)| - ((k + 3 : ℕ) : ℝ)) ≤ |r - Real.sqrt m| @@ -2512,18 +2525,18 @@ private theorem gaussian_rStar_to_posPart (k n : ℕ) (hn : 1 ≤ n) (hkn : k have hm_eq : m = (n : ℝ) + 1 := by dsimp [m]; simp rw [hm_eq] have hle : Real.sqrt (n : ℝ) ≤ Real.sqrt ((n : ℝ) + 1) := - Real.sqrt_le_sqrt (by linarith) + Real.sqrt_le_sqrt (by linarith only []) rw [abs_of_nonneg (sub_nonneg.mpr hle)] have h1 : (1 : ℝ) ≤ (n : ℝ) := by exact_mod_cast hn exact le_trans - (sqrt_sub_le_sub_of_one_le (by linarith) (by linarith)) - (by push_cast; linarith) + (sqrt_sub_le_sub_of_one_le (by linarith only [h1]) (by linarith only [])) + (by push_cast; linarith only []) · -- k ≥ 1: m = n-k+1 ≤ n, so √n ≥ √m. have hk_real : (0 : ℝ) < (k : ℝ) := by exact_mod_cast hk have hm_le_n : m ≤ (n : ℝ) := by change (n : ℝ) - (k : ℝ) + 1 ≤ (n : ℝ) have : (1 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk - linarith + linarith only [this] have hle : Real.sqrt m ≤ Real.sqrt (n : ℝ) := Real.sqrt_le_sqrt hm_le_n rw [abs_of_nonpos (sub_nonpos.mpr hle)] -- -(√m - √n) = √n - √m ≤ n - m = k - 1 ≤ k + 1 @@ -2531,9 +2544,9 @@ private theorem gaussian_rStar_to_posPart (k n : ℕ) (hn : 1 ≤ n) (hkn : k sqrt_sub_le_sub_of_one_le hm_pos hm_le_n have hm_eq : (n : ℝ) - m = (k : ℝ) - 1 := by dsimp [m]; ring push_cast - linarith + linarith only [hsub] push_cast at htri hshift ⊢ - linarith + linarith only [htri, hshift] /-- The key pointwise radial bound with decay constant 1/4. Combines the scaled Laguerre bound, Poisson bound, and base Gaussian bound. -/ @@ -2643,7 +2656,7 @@ theorem single_basis_localization : Real.exp (-(1 / 4) * posPart (|((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - ((k + 4 : ℕ) : ℝ)) ^ 2) := by - apply Real.exp_le_exp.mpr; nlinarith [hgap, hgap_nn1, hgap_nn2] + apply Real.exp_le_exp.mpr; nlinarith only [hgap, hgap_nn1, hgap_nn2] exact hpw.trans (mul_le_mul_of_nonneg_left hexp (le_of_lt hCk_pos)) _ = Ck * Real.exp (-(1 / 4) * (posPart (|((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - @@ -2663,6 +2676,6 @@ theorem single_basis_localization : ((k + 4 : ℕ) : ℝ))) ^ 2) := by ring _ ≤ (2 * Ck + 1) * Real.exp (-(1 / 4) * (posPart (|((j : ℕ) : ℝ) - Real.sqrt (n : ℝ)| - - ((k + 4 : ℕ) : ℝ))) ^ 2) := by nlinarith + ((k + 4 : ℕ) : ℝ))) ^ 2) := by linarith only [hexp_nn] end HermitekLEAN diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ImportedAnalyticInputs.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ImportedAnalyticInputs.lean index 12a982eee4..3304b3422d 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ImportedAnalyticInputs.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ImportedAnalyticInputs.lean @@ -47,7 +47,7 @@ theorem high_frequency_circle_estimate (hband : 1343 * (L : ℝ) ^ 2 ≤ (N : ℝ) ^ 2) : circleL2Sq (positiveTrigonometricPolynomial (frequencyBand N L) c) ≤ 32 * circleRhoNormSq (positiveTrigonometricPolynomial (frequencyBand N L) c) := by - simpa [circleL2Sq, circleRhoNormSq, positiveTrigonometricPolynomial, frequencyBand] using + exact HermiteLEAN.high_frequency_circle_estimate N L hN hL c hband /-- Imported phase-normalized orthogonal reduction. -/ @@ -69,7 +69,7 @@ theorem phase_normalized_orthogonal_reduction ∀ h : H, ∀ a : ℝ, defect (h - (a : ℂ) • f0) ≤ |a| + defect h) : ∃ δ Mloc : ℝ, 0 < δ ∧ 0 < Mloc ∧ ∀ h : H, ‖h‖ ≤ δ → (inner ℂ h f0).im = 0 → ‖h‖ ≤ Mloc * defect h := by - simpa using + exact HermiteLEAN.phase_normalized_orthogonal_reduction defect hdefect_nonneg f0 hf0 C hC horth hscalar hcompare diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ModulusRigidity.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ModulusRigidity.lean index 989a1b2fed..d7500da5d9 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ModulusRigidity.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/ModulusRigidity.lean @@ -42,13 +42,13 @@ theorem leading_term_extraction : let r : ℝ := max 1 (max R1 R2) + 1 have hr1 : R1 ≤ r := by dsimp [r] - linarith [le_max_left R1 R2, le_max_right 1 (max R1 R2)] + linarith only [le_max_left R1 R2, le_max_right 1 (max R1 R2)] have hr2 : R2 ≤ r := by dsimp [r] - linarith [le_max_right R1 R2, le_max_right 1 (max R1 R2)] + linarith only [le_max_right R1 R2, le_max_right 1 (max R1 R2)] have hr_pos : 0 < r := by dsimp [r] - linarith [le_max_left 1 (max R1 R2)] + linarith only [le_max_left 1 (max R1 R2)] have hsmall := hR1 r hr1 have hzero_r := hR2 r hr2 have hr_ne : (r : ℂ) ≠ 0 := by exact_mod_cast (ne_of_gt hr_pos) @@ -60,7 +60,7 @@ theorem leading_term_extraction : rw [hqeq] field_simp [hpow] rw [hdiv, norm_neg] at hsmall - linarith + linarith only [hαnorm, hsmall] private def finiteCoeffSeq {d : ℕ} (a : Fin (d + 1) → ℂ) : ℕ → ℂ := fun n => if h : n < d + 1 then a ⟨n, h⟩ else 0 @@ -128,7 +128,7 @@ private theorem qkn_eventual_lower_bound' (k n : ℕ) : have hr_nonneg : 0 ≤ r := le_trans zero_le_one hr1 have hr_pos : 0 < r := lt_of_lt_of_le zero_lt_one hr1 have hmain : ‖(c : ℂ)‖ / 2 ≤ ‖(qkn k n r : ℂ) / (r ^ n : ℂ)‖ := by - linarith [norm_le_norm_sub_add ((c : ℂ)) ((qkn k n r : ℂ) / (r ^ n : ℂ))] + linarith only [hclose, norm_le_norm_sub_add ((c : ℂ)) ((qkn k n r : ℂ) / (r ^ n : ℂ))] have hpow_nonzero : (r ^ n : ℂ) ≠ 0 := pow_ne_zero n (by exact_mod_cast (ne_of_gt hr_pos)) have hpow_norm : ‖(r ^ n : ℂ)‖ = r ^ n := by @@ -157,7 +157,7 @@ private theorem coeff_eq_zero_of_qkn_eventual_bounds have hmul : C * r ^ d ≤ C' * r ^ d := by have hr_nonneg : 0 ≤ r := le_trans zero_le_one (le_trans hR0 hr) have hpow_nonneg : 0 ≤ r ^ d := pow_nonneg hr_nonneg d - nlinarith [le_max_left C 0, hpow_nonneg] + nlinarith only [le_max_left C 0, hpow_nonneg] exact le_trans (hC r hr) hmul have hgn : 0 < ‖g n‖ := norm_pos_iff.mpr hg let A : ℝ := c * ‖g n‖ @@ -197,7 +197,7 @@ private theorem coeff_eq_zero_of_qkn_eventual_bounds simpa [pow_add, mul_assoc, mul_left_comm, mul_comm] using hineq'' exact le_of_mul_le_mul_right hineq' hrd_pos have hpow_large : C' + 1 ≤ A * r ^ (n - d) := hR' r hrR' - linarith + linarith only [hpow_le, hpow_large] /-- The circle leading factor is nonzero at any positive radius. -/ private lemma circleLeadingFactor_ne_zero (k : ℕ) {r : ℝ} (hr : 0 < r) : @@ -692,11 +692,11 @@ private lemma finite_modulus_coeff_rel {k d : ℕ} (a b : Fin (d + 1) → ℂ) calc finiteCirclePoly k r a t * star (finiteCirclePoly k r a t) = ‖finiteCirclePoly k r a t‖ ^ 2 := by - simpa using (RCLike.mul_conj (finiteCirclePoly k r a t)) + exact (RCLike.mul_conj (finiteCirclePoly k r a t)) _ = ‖finiteCirclePoly k r b t‖ ^ 2 := by rw [hpoly_norm (r := r) hr t] _ = finiteCirclePoly k r b t * star (finiteCirclePoly k r b t) := by symm - simpa using (RCLike.mul_conj (finiteCirclePoly k r b t)) + exact (RCLike.mul_conj (finiteCirclePoly k r b t)) have hcoeff := congrArg (fun F : Circle → ℂ => fourierCoeff F m) hprod_eq exact (hAcoeff r hr).symm.trans (hcoeff.trans (hBcoeff r hr)) @@ -959,7 +959,7 @@ private theorem fourierCoeff_circleSeries_mul_star_finiteCirclePoly = (star (a i) * (qkn k i.1 r : ℂ)) * fourierCoeff (fun t : Circle => circleSeries k (hermiteCoeff k G) r t * fourier (-(i.1 : ℤ)) t) m := by - simpa using + exact (fourierCoeff.const_mul (T := T) (f := fun t : Circle => circleSeries k (hermiteCoeff k G) r t * fourier (-(i.1 : ℤ)) t) @@ -1035,7 +1035,10 @@ private lemma circleSeries_neg_fourierCoeff_eq_zero ∑' n : ℤ, s n = ∑' n : ℕ, s n + ∑' n : ℕ, s (-(n + 1 : ℤ)) := by simpa [add_comm, add_left_comm, add_assoc] using (tsum_of_nat_of_neg_add_one (f := s) hsummable_nat hsummable_neg) - have hneg_sum_zero : ∑' n : ℕ, s (-(n + 1 : ℤ)) = 0 := by linarith [hparseval, hnat_eq, hsplit] + have hneg_sum_zero : ∑' n : ℕ, s (-(n + 1 : ℤ)) = 0 := by + linarith only [ + hparseval, hnat_eq, hsplit + ] have htermle : s (-(m + 1 : ℤ)) ≤ ∑' n : ℕ, s (-(n + 1 : ℤ)) := hsummable_neg.le_tsum m fun n _ => by dsimp [s] @@ -1167,7 +1170,7 @@ private theorem positive_mode_mixed_eq_zero star (circleSeries k (hermiteCoeff k G) r t * star (finiteCirclePoly k r a t))) = fun _ : Circle => (0 : ℂ) := by funext t - simpa using circleSeries_star_finiteCirclePoly_add_star_eq_zero + exact circleSeries_star_finiteCirclePoly_add_star_eq_zero (k := k) (d := d) (a := a) hG hzero hr t have hcoeff0 : fourierCoeff @@ -1191,7 +1194,7 @@ private theorem positive_mode_mixed_eq_zero have hEq : (fun t : Circle => finiteCirclePoly k r a t) = F := by funext t simp [F, finiteCirclePoly_sum (k := k) (a := a) (r := r) hr t] - simp_all + simp_all only [] have hcontf : Continuous f := (continuous_circleSeries_hermiteCoeff hG r hr).mul hp.star have hf : Integrable f AddCircle.haarAddCircle := integrable_circle_of_continuous hcontf @@ -1214,7 +1217,7 @@ private theorem positive_mode_mixed_eq_zero rw [hadd, fourierCoeff_circleSeries_mul_star_finiteCirclePoly_nat (a := a) hG hr ell, fourierCoeff_star_circleSeries_mul_star_finiteCirclePoly_nat (a := a) hG hr ell] at hcoeff0 - simpa using hcoeff0 + exact hcoeff0 /-- The leading positive-mode sum converges to the contribution of the top index `i = d`. -/ private theorem positive_mode_main_sum_tendsto @@ -1604,7 +1607,7 @@ private theorem finite_positive_mode_relation if h : d - n.1 ≤ i.1 then star (hermiteCoeff k (finiteHermiteSum k b) (i.1 - (d - n.1))) * a i * ((qkn k i.1 r : ℂ) * (qkn k (i.1 - (d - n.1)) r : ℂ)) - else 0) = 0 := by simpa [ell] using hraw + else 0) = 0 := by exact hraw rw [finite_positive_mode_main_raw (k := k) (d := d) (a := a) (b := b) n (r := r), finite_positive_mode_error_raw (k := k) (d := d) (a := a) (b := b) n (r := r)] at hraw0 have hEq : ((qkn k d r : ℂ) * (qkn k n.1 r : ℂ)) * F r = 0 := by @@ -1627,8 +1630,8 @@ private theorem finite_positive_mode_relation finitePositiveModeErrorSum_mul_den (k := k) (d := d) (a := a) (b := b) n hd hn] _ = 0 := hraw0 exact (mul_eq_zero.mp hEq).resolve_left (mul_ne_zero hd hn) - have hzero_tendsto : Filter.Tendsto F Filter.atTop (𝓝 (0 : ℂ)) := by simpa using hFzero.tendsto - simpa [zero_add] using (tendsto_nhds_unique (f := F) (l := Filter.atTop) hFtendsto hzero_tendsto) + have hzero_tendsto : Filter.Tendsto F Filter.atTop (𝓝 (0 : ℂ)) := by exact hFzero.tendsto + exact (tendsto_nhds_unique (f := F) (l := Filter.atTop) hFtendsto hzero_tendsto) /-- Vanishing real part against a finite Hermite sum forces a purely imaginary scalar multiple. -/ private theorem finite_real_part_rigidity @@ -1660,7 +1663,7 @@ private theorem finite_real_part_rigidity have hlam_re : lam.re = 0 := by have hre := congrArg Complex.re hlam_add_star simp at hre - linarith + linarith only [hre] obtain ⟨c, hc⟩ := exists_I_mul_of_re_eq_zero lam hlam_re have hstar_lam : star lam = -lam := by simp [hc, mul_comm] have hb_coeff : ∀ n : Fin (d + 1), b n = lam * a n := by diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/TrueLevelBasis.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/TrueLevelBasis.lean index ec9c67068b..7f0234cfeb 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/TrueLevelBasis.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/Hermitek/TrueLevelBasis.lean @@ -303,7 +303,7 @@ private lemma gaussian_monomial_moments_off_diag {a b : ℕ} (hab : a ≠ b) : have hrot_neg : ∀ z, f (rot z) = -f z := hI simp_rw [hrot_neg] at hrot_eq rw [integral_neg] at hrot_eq - linarith + linarith only [hrot_eq] /-- Diagonal case: z^a * conj(z)^a = ‖z‖^{2a}. -/ private lemma zpow_conj_diag_re (z : ℂ) (a : ℕ) : @@ -319,9 +319,9 @@ private lemma integral_norm_pow_exp_gaussian (a : ℕ) : intro z; exact (rpow_natCast ‖z‖ (2 * a)).symm have h_exp : ∀ z : ℂ, Real.exp (-‖z‖ ^ 2) = Real.exp (-‖z‖ ^ (2 : ℝ)) := by intro z; norm_num simp_rw [h_rpow, h_exp] - rw [Complex.integral_rpow_mul_exp_neg_rpow (show (1 : ℝ) ≤ 2 from by linarith) + rw [Complex.integral_rpow_mul_exp_neg_rpow (show (1 : ℝ) ≤ 2 from by linarith only []) (show (-2 : ℝ) < ((2 * a : ℕ) : ℝ) from by - have : (0 : ℝ) ≤ ((2 * a : ℕ) : ℝ) := Nat.cast_nonneg _; linarith)] + have : (0 : ℝ) ≤ ((2 * a : ℕ) : ℝ) := Nat.cast_nonneg _; linarith only [])] rw [show ((2 * a : ℕ) : ℝ) + 2 = 2 * ((a : ℝ) + 1) from by push_cast; ring, show 2 * ((a : ℝ) + 1) / 2 = (a : ℝ) + 1 from by ring, show 2 * π / 2 = π from by ring, @@ -472,7 +472,7 @@ theorem qkn_structure : /-- The circle coefficients `qkn` remain fixed by complex conjugation. -/ @[simp] theorem qkn_real : ∀ {k n : ℕ} {r : ℝ}, star (qkn k n r : ℂ) = (qkn k n r : ℂ) := by - simp_all only [RCLike.star_def, conj_ofReal, implies_true] + simp only [RCLike.star_def, conj_ofReal, implies_true] -- Helper: r ^ (-2 : ℤ) = 1 / r ^ 2 private lemma zpow_neg_two_eq (r : ℝ) : @@ -603,17 +603,17 @@ private lemma qkn_div_rn_bound (k n : ℕ) : · have hMpos : 0 < M := lt_of_le_of_ne hM_nn (Ne.symm hM0) have hge : r ≥ Real.sqrt (M / ε) + 1 := le_trans (le_max_left _ _) hr have hr_sq : r ^ 2 ≥ M / ε := by - have : r ≥ Real.sqrt (M / ε) := by linarith + have : r ≥ Real.sqrt (M / ε) := by linarith only [hge] calc r ^ 2 = r * r := by ring _ ≥ Real.sqrt (M / ε) * Real.sqrt (M / ε) := by apply mul_le_mul this this · exact Real.sqrt_nonneg _ - · linarith + · linarith only [hr1] _ = M / ε := by rw [Real.mul_self_sqrt (le_of_lt (div_pos hMpos hε))] have : ε * r ^ 2 ≥ ε * (M / ε) := mul_le_mul_of_nonneg_left hr_sq (le_of_lt hε) rw [mul_div_cancel₀ M (ne_of_gt hε)] at this - linarith + linarith only [this] theorem qkn_top_term_asymptotic : ∀ k n : ℕ, @@ -673,14 +673,14 @@ theorem qkn_eventual_lower_bound : -- h1 : ‖c₀‖ - ‖qkn/r^n‖ ≤ ‖c₀ - qkn/r^n‖ rw [norm_sub_rev] at h1 -- h1 : ‖c₀‖ - ‖qkn/r^n‖ ≤ ‖qkn/r^n - c₀‖ - linarith + linarith only [hε_def, hspec, h1] rw [norm_div] at h_tri have hrn_norm : ‖(r ^ n : ℂ)‖ = r ^ n := by rw [show (r : ℂ) ^ n = ((r ^ n : ℝ) : ℂ) from by push_cast; ring, Complex.norm_real, Real.norm_of_nonneg (le_of_lt hrn_pos)] rw [hrn_norm] at h_tri rw [le_div_iff₀ hrn_pos] at h_tri - linarith [Complex.norm_real (qkn k n r)] + linarith only [h_tri, Complex.norm_real (qkn k n r)] /-- The radial coefficient `qkn k n` is eventually nonvanishing on large radii. -/ theorem qkn_eventually_nonzero : @@ -694,7 +694,7 @@ theorem qkn_eventually_nonzero : have h1 := hbound r hr rw [hqkn, Complex.ofReal_zero, norm_zero] at h1 have h2 : 0 < r := lt_of_lt_of_le (lt_of_lt_of_le zero_lt_one hR) hr - linarith [mul_pos hc (pow_pos h2 n)] + linarith only [hc, h1, h2, mul_pos hc (pow_pos h2 n)] /-- Lower modes are eventually suppressed by at least one power of `r`. -/ theorem qkn_ratio_control : @@ -728,7 +728,7 @@ theorem qkn_ratio_control : have h2 := norm_sub_norm_le ((qkn k n r : ℂ) / ((r : ℂ) ^ n)) ((cn : ℝ) : ℂ) rw [Complex.norm_real] at h2 have : ‖cn‖ = cn := Real.norm_of_nonneg (le_of_lt hcn_pos) - linarith + linarith only [hnum_spec, h2, this] rw [norm_div, show ‖((r : ℂ) ^ n)‖ = r ^ n from by rw [show (r : ℂ) ^ n = ((r ^ n : ℝ) : ℂ) from by push_cast; ring] rw [Complex.norm_real, Real.norm_of_nonneg (pow_nonneg (le_of_lt hr_pos) n)]] at h1 @@ -739,7 +739,7 @@ theorem qkn_ratio_control : have hden_ne : (qkn k d r : ℂ) ≠ 0 := by intro h rw [h, norm_zero] at hden_lower - linarith [mul_pos hcd (pow_pos hr_pos d)] + linarith only [hcd, hr_pos, hden_lower, mul_pos hcd (pow_pos hr_pos d)] -- The ratio bound rw [norm_div, div_le_div_iff₀ (norm_pos_iff.mpr hden_ne) hr_pos] -- ‖qkn n‖ * r ≤ (cn+1)*r^(n+1) ≤ (cn+1)*r^d = C*cd*r^d ≤ C*‖qkn d‖ @@ -751,7 +751,7 @@ theorem qkn_ratio_control : _ ≤ (cn + 1) * r ^ d := by apply mul_le_mul_of_nonneg_left · exact pow_le_pow_right₀ hr1 hnd - · linarith + · linarith only [hcn_pos] _ = C * (cd * r ^ d) := by simp only [C] field_simp @@ -883,7 +883,7 @@ private lemma alternating_vandermonde_coeff (k s N : ℕ) : ((((Polynomial.C (1 : ℤ)) + Polynomial.X) ^ s * Polynomial.X ^ k).coeff N) := alternating_vandermonde_coeff_poly k s N _ = if k ≤ N then (((Polynomial.C (1 : ℤ)) + Polynomial.X) ^ s).coeff (N - k) else 0 := by - simpa only [eq_intCast, Int.cast_one] using + exact (Polynomial.coeff_mul_X_pow' (((Polynomial.C (1 : ℤ)) + Polynomial.X) ^ s) k N) _ = if k ≤ N then ↑(s.choose (N - k)) else 0 := by by_cases h : k ≤ N <;> simp [h, Polynomial.coeff_one_add_X_pow] @@ -1033,7 +1033,15 @@ private lemma integrable_norm_pow_exp (a : ℕ) : by_contra h have hint := integral_norm_pow_exp_gaussian a rw [MeasureTheory.integral_undef h] at hint - linarith [show (0 : ℝ) < π * (Nat.factorial a : ℝ) from by positivity] + linarith only [hint, show (0 : ℝ) < π * (Nat.factorial a : ℝ) from by positivity] + +-- Keep the established auxiliary name while using its range argument directly. +private theorem norm_sq_phi_integral._proof_1_10 (k m i : ℕ) + (hi : i < k + 1) + (hi' : @LE.le ℕ (@Preorder.toLE ℕ + (@PartialOrder.toPreorder ℕ (@LinearOrder.toPartialOrder ℕ Nat.instLinearOrder))) + (min k m + 1) i) : ¬ m < i → False := by + omega -- The main diagonal integral computation -- The integral proof unfolds the diagonal formula and runs the full double-sum normalization. @@ -1202,7 +1210,12 @@ private theorem norm_sq_phi_integral (k m : ℕ) : (Nat.factorial (m + k - i - j) : ℝ) := by intro i apply Finset.sum_subset (Finset.range_mono (by omega : min k m + 1 ≤ k + 1)) - simp_all + intro j hj hj' + have hmj : m < j := by + by_contra hnot + exact norm_sq_phi_integral._proof_1_10 k m j (Finset.mem_range.mp hj) + (Nat.le_of_not_gt (fun h => hj' (Finset.mem_range.mpr h))) hnot + simp only [Nat.descFactorial_eq_zero_iff_lt.mpr hmj, Nat.cast_zero, mul_zero, zero_mul] simp_rw [hext_j] have hext_i : ∑ i ∈ Finset.range (min k m + 1), ∑ j ∈ Finset.range (k + 1), (-1 : ℝ) ^ (i + j) * (Nat.choose k i : ℝ) * (Nat.choose k j : ℝ) * @@ -1408,7 +1421,7 @@ theorem integrable_weightedCross (k m n : ℕ) : 2 * (‖Phi k m z‖ * ‖Phi k n z‖) ≤ ‖Phi k m z‖ ^ 2 + ‖Phi k n z‖ ^ 2 := by linarith only [sq_nonneg (‖Phi k m z‖ - ‖Phi k n z‖)] have hexp_nonneg : 0 ≤ Real.exp (-‖z‖ ^ 2) := by positivity - nlinarith + nlinarith only [hsq, hexp_nonneg] _ = g z := by simp [g] exact MeasureTheory.Integrable.mono' hg hf_meas (Filter.Eventually.of_forall hbound) @@ -1475,14 +1488,14 @@ private lemma integrable_finiteHermiteSum_weightedCross rw [hEq] refine MeasureTheory.integrable_finsetSum (Finset.univ : Finset (Fin D)) ?_ intro m hm - simpa only [ofReal_exp, ofReal_neg, ofReal_pow, mul_comm, mul_left_comm, mul_assoc] using + exact (integrable_weightedCross k m.1 n).const_mul (a m) private lemma integrable_truncate_weightedCross (k J n : ℕ) (G : ℂ → ℂ) : Integrable (fun z : ℂ => truncate k J G z * (starRingEnd ℂ) (Phi k n z) * (Real.exp (-‖z‖ ^ 2) : ℂ)) := by - simpa only [truncate, ofReal_exp, ofReal_neg, ofReal_pow] using + exact (integrable_finiteHermiteSum_weightedCross (k := k) (n := n) (a := fun m : Fin (J + 1) => hermiteCoeff k G m.1)) @@ -1823,7 +1836,7 @@ private lemma weightedInner_finiteHermiteSum_coeff (k : ℕ) {D : ℕ} (a : Fin refine Finset.sum_congr rfl ?_; intro x _ by_cases hx : x = m · subst hx; simp [m] - · have : x.1 ≠ n := fun hEq => hx (Fin.ext (by simpa only [m] using hEq)) + · have : x.1 ≠ n := fun hEq => hx (Fin.ext (by exact hEq)) simp [this, hx] _ = a m := by simp simp [m, h] @@ -1853,7 +1866,7 @@ theorem finiteHermiteSum_mem_Hk : have := (Finset.sum_eq_zero_iff_of_nonneg (fun i _ => sq_nonneg ‖a i‖)).mp hzero n (Finset.mem_univ n) - exact norm_eq_zero.mp (by nlinarith [sq_nonneg ‖a n‖]) + exact norm_eq_zero.mp (by nlinarith only [this, sq_nonneg ‖a n‖]) have hzero_fun : (fun z : ℂ => ‖finiteHermiteSum k a z‖ ^ 2 * rexp (-‖z‖ ^ 2)) = 0 := by ext z simp [finiteHermiteSum, hall_zero] @@ -2013,7 +2026,7 @@ private lemma hermiteCoeff_sub_truncate theorem truncate_mem_Hk : ∀ (k J : ℕ) (G : ℂ → ℂ), truncate k J G ∈ Hk k := by intro k J G - simpa only [truncate] using + exact (finiteHermiteSum_mem_Hk k (a := fun n : Fin (J + 1) => hermiteCoeff k G n.1)) /-- Exact finite Parseval identity for Hermite truncations. -/ @@ -2022,7 +2035,7 @@ theorem truncate_normSq : weightedNormSq (truncate k J G) = ∑ n : Fin (J + 1), ‖hermiteCoeff k G n.1‖ ^ 2 := by intro k J G - simpa only [truncate_eq_finiteHermiteSum] using + exact (finiteHermiteSum_normSq (k := k) (a := fun n : Fin (J + 1) => hermiteCoeff k G n.1)) /-- Finite Hermite sums admit a finite circle representation. -/ @@ -2147,8 +2160,7 @@ theorem truncate_circle : (fourier (-(k : ℤ)) t : ℂ) * truncCirclePoly k r J G t := by intro k J G r hr t - simpa only [truncate, fourier_apply, neg_smul, natCast_zsmul, - truncCirclePoly_eq_finiteCirclePoly] using + exact (finiteHermiteSum_circle (k := k) (D := J + 1) (a := fun n : Fin (J + 1) => hermiteCoeff k G n.1) (r := r) hr t) @@ -2183,7 +2195,7 @@ theorem truncCirclePoly_l2_identity : circleL2Sq (truncCirclePoly k r J G) = ∑ n : Fin (J + 1), ‖hermiteCoeff k G n.1‖ ^ 2 * |qkn k n.1 r| ^ 2 := by intro k J r G - simpa only [truncCirclePoly_eq_finiteCirclePoly, sq_abs] using + exact (finiteCirclePoly_l2_identity (k := k) (D := J + 1) (r := r) (a := fun n : Fin (J + 1) => hermiteCoeff k G n.1)) @@ -2208,7 +2220,7 @@ private lemma summable_nat_pow_mul_pow_div_factorial_nonneg (m : ℕ) {x : ℝ} calc ((n + m + 1 : ℝ) ^ m) ≤ (((m + 1 : ℝ) * (n + 1)) ^ m) := by gcongr - nlinarith + nlinarith only [] _ = (m + 1 : ℝ) ^ m * (n + 1 : ℝ) ^ m := by rw [mul_pow] _ ≤ (m + 1 : ℝ) ^ m * (((n + m).descFactorial m : ℕ) : ℝ) := by gcongr have hfact : @@ -2428,7 +2440,7 @@ private theorem aestronglyMeasurable_of_mem_Hk {k : ℕ} {G : ℂ → ℂ} (hG : /-- Integrability of truncation norm squared with Gaussian weight. -/ theorem integrable_truncate_normSq_exp (k J : ℕ) (G : ℂ → ℂ) : Integrable (fun z : ℂ => ‖truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2)) := by - simpa using (truncate_mem_Hk k J G).1 + exact (truncate_mem_Hk k J G).1 /-- Cross integrability: Phi_n * conj(G) * exp is integrable when ‖G‖² exp is. Uses AM-GM: |ab| ≤ (a² + b²)/2 with the Gaussian split. -/ @@ -2457,6 +2469,246 @@ private lemma integrable_Phi_conj_G_exp {k : ℕ} {G : ℂ → ℂ} (n : ℕ) Real.norm_of_nonneg (exp_nonneg _)] nlinarith only [sq_nonneg (‖Phi k n z‖ - ‖G z‖), exp_nonneg (-‖z‖ ^ 2 : ℝ)] +/-- Gaussian weight used to identify weighted Hermite norms with ordinary `L²`. -/ +private def gaussianWeight (z : ℂ) : ℝ := + Real.exp (-(‖z‖ ^ 2) / 2) / Real.sqrt Real.pi + +/-- Gaussian rescaling into the usual `L²` space. -/ +private def gaussianScale (F : ℂ → ℂ) : ℂ → ℂ := + fun z => ((gaussianWeight z : ℝ) : ℂ) * F z + +private theorem gaussianWeight_nonneg (z : ℂ) : 0 ≤ gaussianWeight z := by + unfold gaussianWeight + positivity + +private theorem gaussianWeight_sq (z : ℂ) : + gaussianWeight z ^ 2 = (1 / Real.pi) * Real.exp (-‖z‖ ^ 2) := by + unfold gaussianWeight + have hpi : 0 ≤ Real.pi := le_of_lt Real.pi_pos + have hsqrt : Real.sqrt Real.pi ^ 2 = Real.pi := by rw [Real.sq_sqrt hpi] + have hexp : + Real.exp (-(‖z‖ ^ 2) / 2) ^ 2 = Real.exp (-‖z‖ ^ 2) := by + calc + Real.exp (-(‖z‖ ^ 2) / 2) ^ 2 + = Real.exp (-(‖z‖ ^ 2) / 2) * Real.exp (-(‖z‖ ^ 2) / 2) := by ring + _ = Real.exp (-(‖z‖ ^ 2) / 2 + -(‖z‖ ^ 2) / 2) := by rw [← Real.exp_add] + _ = Real.exp (-‖z‖ ^ 2) := by congr 1; ring + rw [div_pow, hexp, hsqrt] + field_simp [Real.pi_ne_zero] + +private theorem continuous_gaussianWeight : Continuous gaussianWeight := by + unfold gaussianWeight + exact + (Real.continuous_exp.comp + ((continuous_neg.comp (continuous_norm.pow 2)).div_const 2)).div_const _ + +private theorem aestronglyMeasurable_gaussianScale + {F : ℂ → ℂ} + (hF : AEStronglyMeasurable F volume) : + AEStronglyMeasurable (gaussianScale F) volume := + (Complex.continuous_ofReal.comp continuous_gaussianWeight).aestronglyMeasurable.mul hF + +private theorem weightedNormSq_eq_integral_sq_norm_gaussianScale + (G : ℂ → ℂ) : + weightedNormSq G = ∫ z : ℂ, ‖gaussianScale G z‖ ^ 2 := by + unfold weightedNormSq HermiteLEAN.weightedNormSq + have hEq : + (fun z : ℂ => ‖gaussianScale G z‖ ^ 2) = + fun z : ℂ => (1 / Real.pi) * (‖G z‖ ^ 2 * Real.exp (-‖z‖ ^ 2)) := by + funext z + rw [show ‖gaussianScale G z‖ ^ 2 = + gaussianWeight z ^ 2 * ‖G z‖ ^ 2 by + unfold gaussianScale + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (gaussianWeight_nonneg z)] + ring] + rw [gaussianWeight_sq] + ac_rfl + rw [hEq, MeasureTheory.integral_const_mul] + +private theorem memLp_two_gaussianScale_of_integrable + {F : ℂ → ℂ} + (hF : AEStronglyMeasurable F volume) + (hInt : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : + MeasureTheory.MemLp (gaussianScale F) 2 volume := by + refine (MeasureTheory.memLp_two_iff_integrable_sq_norm ?_).2 ?_ + · exact aestronglyMeasurable_gaussianScale hF + · refine hInt.const_mul (1 / Real.pi) |>.congr ?_ + filter_upwards with z + rw [show ‖gaussianScale F z‖ ^ 2 = + gaussianWeight z ^ 2 * ‖F z‖ ^ 2 by + unfold gaussianScale + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (gaussianWeight_nonneg z)] + ring] + rw [gaussianWeight_sq] + ac_rfl + +private theorem integrable_of_memLp_two_gaussianScale + {F : ℂ → ℂ} (hF : MeasureTheory.MemLp (gaussianScale F) 2 volume) : + Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2)) := by + have hint := (MeasureTheory.memLp_two_iff_integrable_sq_norm hF.aestronglyMeasurable).1 hF + refine (hint.const_mul Real.pi).congr ?_ + filter_upwards with z + simp only [gaussianScale, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (gaussianWeight_nonneg z), mul_pow, gaussianWeight_sq] + field_simp [Real.pi_ne_zero] + +private theorem integrable_weighted_square_sub + {F G : ℂ → ℂ} (hF : AEStronglyMeasurable F volume) + (hG : AEStronglyMeasurable G volume) + (hIntF : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) + (hIntG : Integrable (fun z : ℂ => ‖G z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : + Integrable (fun z : ℂ => ‖F z - G z‖ ^ 2 * Real.exp (-‖z‖ ^ 2)) := by + have hscale : gaussianScale (fun z => F z - G z) = gaussianScale F - gaussianScale G := by + funext z + exact mul_sub _ _ _ + apply integrable_of_memLp_two_gaussianScale + rw [hscale] + exact (memLp_two_gaussianScale_of_integrable hF hIntF).sub + (memLp_two_gaussianScale_of_integrable hG hIntG) + +private theorem weightedNorm_eq_lpNorm_gaussianScale + {F : ℂ → ℂ} + (hF : AEStronglyMeasurable F volume) + (_hInt : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : + weightedNorm F = MeasureTheory.lpNorm (gaussianScale F) 2 volume := by + have hmeas : AEStronglyMeasurable (gaussianScale F) volume := + aestronglyMeasurable_gaussianScale hF + have htwo : (2 : NNReal) ≠ 0 := by norm_num + have hlp := MeasureTheory.lpNorm_nnreal_eq_integral_norm_rpow + (μ := volume) (p := (2 : NNReal)) (f := gaussianScale F) htwo hmeas + change weightedNorm F = MeasureTheory.lpNorm (gaussianScale F) (↑(2 : NNReal)) volume + rw [hlp] + change weightedNorm F = (∫ z : ℂ, ‖gaussianScale F z‖ ^ (2 : ℝ)) ^ ((2 : ℝ)⁻¹) + have hsq : + (∫ z : ℂ, ‖gaussianScale F z‖ ^ (2 : ℝ)) = weightedNormSq F := by + simpa only [rpow_ofNat] using (weightedNormSq_eq_integral_sq_norm_gaussianScale F).symm + rw [hsq] + unfold weightedNorm HermiteLEAN.weightedNorm + rw [Real.sqrt_eq_rpow] + norm_num + +private theorem integrable_weightedCross_of_memLp + (F G : ℂ → ℂ) + (hF : MeasureTheory.MemLp (gaussianScale F) 2 volume) + (hG : MeasureTheory.MemLp (gaussianScale G) 2 volume) : + Integrable + (fun z : ℂ => F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)) := by + let FLp : MeasureTheory.Lp ℂ 2 volume := hF.toLp (gaussianScale F) + let GLp : MeasureTheory.Lp ℂ 2 volume := hG.toLp (gaussianScale G) + have hscaled : + Integrable + (fun z : ℂ => + ((1 / Real.pi : ℂ) * + (F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)))) := by + have hint : + Integrable (fun z : ℂ => inner ℂ (GLp z) (FLp z)) := by + simpa only [RCLike.inner_apply, FLp, GLp] using + MeasureTheory.L2.integrable_inner (𝕜 := ℂ) GLp FLp + have hEq : + (fun z : ℂ => inner ℂ (GLp z) (FLp z)) =ᵐ[volume] + (fun z : ℂ => inner ℂ (gaussianScale G z) (gaussianScale F z)) := by + filter_upwards [hG.coeFn_toLp, hF.coeFn_toLp] with z hzG hzF + rw [hzG, hzF] + have hint' : + Integrable (fun z : ℂ => inner ℂ (gaussianScale G z) (gaussianScale F z)) := hint.congr hEq + convert hint' using 1 + ext z + rw [RCLike.inner_apply'] + unfold gaussianScale + have hgw : + (((gaussianWeight z : ℝ) : ℂ) * ((gaussianWeight z : ℝ) : ℂ)) = + (((1 / Real.pi) * Real.exp (-‖z‖ ^ 2) : ℝ) : ℂ) := by + have hsq := gaussianWeight_sq z + rw [sq] at hsq + exact_mod_cast hsq + rw [show (starRingEnd ℂ) (↑(gaussianWeight z) * G z) * (↑(gaussianWeight z) * F z) = + ↑(gaussianWeight z) * ↑(gaussianWeight z) * (F z * (starRingEnd ℂ) (G z)) from by + simp [map_mul] + ring, hgw] + push_cast + ac_rfl + have hpi_ne : (Real.pi : ℂ) ≠ 0 := by exact_mod_cast Real.pi_ne_zero + simpa only [ofReal_exp, ofReal_neg, ofReal_pow, mul_comm, mul_left_comm, one_div, ne_eq, hpi_ne, + not_false_eq_true, mul_inv_cancel_left₀, mul_assoc] using hscaled.const_mul (Real.pi : ℂ) + +private theorem weightedInner_eq_l2Inner + (F G : ℂ → ℂ) + (hF : MeasureTheory.MemLp (gaussianScale F) 2 volume) + (hG : MeasureTheory.MemLp (gaussianScale G) 2 volume) : + weightedInner F G = @inner ℂ _ _ (hG.toLp (gaussianScale G)) (hF.toLp (gaussianScale F)) := by + let FLp : MeasureTheory.Lp ℂ 2 volume := hF.toLp (gaussianScale F) + let GLp : MeasureTheory.Lp ℂ 2 volume := hG.toLp (gaussianScale G) + have hEq : + (fun z : ℂ => inner ℂ (GLp z) (FLp z)) =ᵐ[volume] + (fun z : ℂ => + ((1 / Real.pi : ℂ) * + (F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)))) := by + filter_upwards [hG.coeFn_toLp, hF.coeFn_toLp] with z hzG hzF + rw [hzG, hzF, RCLike.inner_apply'] + unfold gaussianScale + have hgw : + (((gaussianWeight z : ℝ) : ℂ) * ((gaussianWeight z : ℝ) : ℂ)) = + (((1 / Real.pi) * Real.exp (-‖z‖ ^ 2) : ℝ) : ℂ) := by + have hsq := gaussianWeight_sq z + rw [sq] at hsq + exact_mod_cast hsq + rw [show (starRingEnd ℂ) (↑(gaussianWeight z) * G z) * (↑(gaussianWeight z) * F z) = + ↑(gaussianWeight z) * ↑(gaussianWeight z) * (F z * (starRingEnd ℂ) (G z)) from by + simp [map_mul] + ring, hgw] + push_cast + ac_rfl + calc + weightedInner F G + = ∫ z : ℂ, ((1 / Real.pi : ℂ) * + (F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ))) := by + unfold weightedInner HermiteLEAN.weightedInner + exact + (MeasureTheory.integral_const_mul + (r := (1 / Real.pi : ℂ)) + (f := fun z : ℂ => + F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ))).symm + _ = ∫ z : ℂ, inner ℂ (GLp z) (FLp z) := by + symm + exact integral_congr_ae hEq + _ = @inner ℂ _ _ GLp FLp := by + exact + (MeasureTheory.L2.inner_def (𝕜 := ℂ) GLp FLp).symm + +private theorem weightedInner_norm_le_of_integrable + {F G : ℂ → ℂ} + (hFmeas : AEStronglyMeasurable F volume) + (hGmeas : AEStronglyMeasurable G volume) + (hFint : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) + (hGint : Integrable (fun z : ℂ => ‖G z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : + ‖weightedInner F G‖ ≤ weightedNorm F * weightedNorm G := by + let hFmem := memLp_two_gaussianScale_of_integrable hFmeas hFint + let hGmem := memLp_two_gaussianScale_of_integrable hGmeas hGint + calc + ‖weightedInner F G‖ + = ‖@inner ℂ _ _ (hGmem.toLp (gaussianScale G)) (hFmem.toLp (gaussianScale F))‖ := by + rw [weightedInner_eq_l2Inner F G hFmem hGmem] + _ ≤ ‖hGmem.toLp (gaussianScale G)‖ * ‖hFmem.toLp (gaussianScale F)‖ := norm_inner_le_norm _ _ + _ = MeasureTheory.lpNorm (gaussianScale G) 2 volume * + MeasureTheory.lpNorm (gaussianScale F) 2 volume := by + rw [MeasureTheory.Lp.norm_toLp, MeasureTheory.Lp.norm_toLp, + ← MeasureTheory.toReal_eLpNorm, ← MeasureTheory.toReal_eLpNorm] + _ = weightedNorm G * weightedNorm F := by + rw [← weightedNorm_eq_lpNorm_gaussianScale hGmeas hGint, + ← weightedNorm_eq_lpNorm_gaussianScale hFmeas hFint] + _ = weightedNorm F * weightedNorm G := by ring + +-- Preserve the existing generated declarations while reusing weighted Cauchy–Schwarz. +private theorem bessel_truncate_le._simp_1_1.{u_3} + {G₀ : Type u_3} [inst : GroupWithZero G₀] [inst_1 : PartialOrder G₀] + [PosMulReflectLT G₀] {a : G₀} : (0 ≤ a⁻¹) = (0 ≤ a) := + propext inv_nonneg + +private theorem bessel_truncate_le._simp_1_2.{u_1} + {α : Type u_1} [inst : LE α] {x y : α} : (x ≥ y) = (y ≤ x) := rfl + private lemma bessel_truncate_le {k : ℕ} {G : ℂ → ℂ} (hG : G ∈ Hk k) (hInt : Integrable (fun z : ℂ => ‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2))) (J : ℕ) : weightedNormSq (truncate k J G) ≤ weightedNormSq G := by @@ -2519,85 +2771,34 @@ private lemma bessel_truncate_le {k : ℕ} {G : ℂ → ℂ} (hG : G ∈ Hk k) -- From the equalities: ⟨trunc, G⟩ = ⟨trunc, trunc⟩ (= ∑ ‖a_n‖²) have hCrossZero : weightedInner (truncate k J G) G = weightedInner (truncate k J G) (truncate k J G) := by rw [hInnerTG', hInnerTT] - -- weightedNormSq T = Re⟨T, T⟩ = Re⟨T, G⟩ - rw [weightedNormSq_eq_re_weightedInner, ← hCrossZero] - let Tfun : ℂ → ℂ := truncate k J G - have hTInt : Integrable (fun z : ℂ => ‖Tfun z‖ ^ 2 * rexp (-‖z‖ ^ 2)) := by - simpa [Tfun] using integrable_truncate_normSq_exp k J G - have hAvgInt : Integrable (fun z : ℂ => - ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2)) := by - have hsum : Integrable (fun z : ℂ => - ‖Tfun z‖ ^ 2 * rexp (-‖z‖ ^ 2) + ‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2)) := hTInt.add hInt - have hEq : - (fun z : ℂ => ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2)) = - (fun z : ℂ => - (1 / 2 : ℝ) * - (‖Tfun z‖ ^ 2 * rexp (-‖z‖ ^ 2) + ‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2))) := by - funext z - ring - rw [hEq] - exact hsum.const_mul (1 / 2 : ℝ) - have hInnerNormLe : - ‖weightedInner Tfun G‖ ≤ (weightedNormSq Tfun + weightedNormSq G) / 2 := by - have hpt : - ∀ᵐ z : ℂ ∂volume, - ‖Tfun z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)‖ ≤ - ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2) := by - refine Filter.Eventually.of_forall ?_ - intro z - calc - ‖Tfun z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)‖ - = (‖Tfun z‖ * ‖G z‖) * rexp (-‖z‖ ^ 2) := by - rw [norm_mul, norm_mul, - show ‖(starRingEnd ℂ) (G z)‖ = ‖G z‖ by simp, - Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (exp_nonneg _)] - _ ≤ ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2) := by - nlinarith only [sq_nonneg (‖Tfun z‖ - ‖G z‖), exp_nonneg (-‖z‖ ^ 2 : ℝ)] - have hIntLe : - ‖∫ z : ℂ, Tfun z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)‖ ≤ - ∫ z : ℂ, ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2) := - MeasureTheory.norm_integral_le_of_norm_le hAvgInt hpt - have hpi_nonneg : 0 ≤ (1 / Real.pi : ℝ) := by positivity - have hAvgEq : - (1 / Real.pi) * ∫ z : ℂ, ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2) = - (weightedNormSq Tfun + weightedNormSq G) / 2 := by - unfold weightedNormSq HermiteLEAN.weightedNormSq - have hEq : - (fun z : ℂ => ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2)) = - (fun z : ℂ => - (1 / 2 : ℝ) * - (‖Tfun z‖ ^ 2 * rexp (-‖z‖ ^ 2) + ‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2))) := by - funext z - ring - rw [hEq, MeasureTheory.integral_const_mul, MeasureTheory.integral_add hTInt hInt] - ring - have hpi_norm : ‖(1 / Real.pi : ℂ)‖ = (1 / Real.pi : ℝ) := by - simp_all only [ofReal_exp, ofReal_neg, ofReal_pow, ofReal_sum, Complex.norm_mul, - RCLike.norm_conj, one_div, inv_nonneg, norm_inv, norm_real, norm_eq_abs, abs_pi] - calc - ‖weightedInner Tfun G‖ - = ‖(1 / Real.pi : ℂ) * - ∫ z : ℂ, Tfun z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)‖ := by rfl - _ = (1 / Real.pi : ℝ) * - ‖∫ z : ℂ, Tfun z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)‖ := by - rw [norm_mul, hpi_norm] - _ ≤ (1 / Real.pi : ℝ) * - ∫ z : ℂ, ((‖Tfun z‖ ^ 2 + ‖G z‖ ^ 2) / 2) * rexp (-‖z‖ ^ 2) := - mul_le_mul_of_nonneg_left hIntLe hpi_nonneg - _ = (weightedNormSq Tfun + weightedNormSq G) / 2 := hAvgEq - have hReEq : (weightedInner Tfun G).re = weightedNormSq Tfun := by - calc - (weightedInner Tfun G).re = (weightedInner Tfun Tfun).re := by - simpa only [Tfun] using congrArg Complex.re hCrossZero - _ = weightedNormSq Tfun := (weightedNormSq_eq_re_weightedInner Tfun).symm - have hTle : weightedNormSq Tfun ≤ weightedNormSq G := by - have hmid : weightedNormSq Tfun ≤ (weightedNormSq Tfun + weightedNormSq G) / 2 := by - calc - weightedNormSq Tfun = (weightedInner Tfun G).re := hReEq.symm - _ ≤ ‖weightedInner Tfun G‖ := Complex.re_le_norm _ - _ ≤ (weightedNormSq Tfun + weightedNormSq G) / 2 := hInnerNormLe - linarith - simpa only [hReEq, ge_iff_le, Tfun] using hTle + have hpi_nonneg : 0 ≤ (1 / Real.pi : ℝ) := by + rw [one_div, bessel_truncate_le._simp_1_1] + exact Real.pi_pos.le + have hnonnegative (F : ℂ → ℂ) : 0 ≤ weightedNormSq F := by + unfold weightedNormSq HermiteLEAN.weightedNormSq + exact mul_nonneg hpi_nonneg (integral_nonneg fun z => + mul_nonneg (sq_nonneg _) (Real.exp_nonneg _)) + have hreal : weightedNormSq (truncate k J G) ≤ ‖weightedInner (truncate k J G) G‖ := by + rw [weightedNormSq_eq_re_weightedInner, ← hCrossZero] + exact Complex.re_le_norm _ + have hbound := weightedInner_norm_le_of_integrable (F := truncate k J G) (G := G) + (continuous_finiteHermiteSum k _).aestronglyMeasurable + (aestronglyMeasurable_of_mem_Hk hG) + (integrable_truncate_normSq_exp k J G) hInt + have hT_square : weightedNorm (truncate k J G) ^ 2 = weightedNormSq (truncate k J G) := + Real.sq_sqrt (hnonnegative _) + have hG_square : weightedNorm G ^ 2 = weightedNormSq G := Real.sq_sqrt (hnonnegative _) + have hT_nonnegative : 0 ≤ weightedNorm (truncate k J G) := Real.sqrt_nonneg _ + by_cases hzero : weightedNorm (truncate k J G) = 0 + · rw [← hT_square, hzero, zero_pow (by decide)] + exact hnonnegative G + · have hpositive : 0 < weightedNorm (truncate k J G) := + lt_of_le_of_ne hT_nonnegative (Ne.symm hzero) + have hnorm_le : weightedNorm (truncate k J G) ≤ weightedNorm G := + le_of_mul_le_mul_left (by + simpa only [← hT_square, pow_two] using hreal.trans hbound) hpositive + rw [← hT_square, ← hG_square] + exact pow_le_pow_left₀ hT_nonnegative hnorm_le 2 /-- The Gaussian-weighted lintegral of `‖F J‖²` equals `π` times its weighted norm square. -/ @@ -3009,7 +3210,7 @@ theorem point_eval_bounded : _ ≤ Real.sqrt (∑ n ∈ Finset.range J, ‖hermiteCoeff k G n‖ ^ 2) * Real.sqrt (∑ n ∈ Finset.range J, ‖Phi k n z‖ ^ 2) := by - simpa using + exact Real.sum_mul_le_sqrt_mul_sqrt (Finset.range J) (fun n => ‖hermiteCoeff k G n‖) (fun n => ‖Phi k n z‖) _ ≤ Real.sqrt (weightedNormSq G) * Real.sqrt (∑' n : ℕ, ‖Phi k n z‖ ^ 2) := by @@ -3021,9 +3222,9 @@ theorem point_eval_bounded : rw [mul_comm] have hu_summable : Summable u := summable_of_sum_range_le (fun n => norm_nonneg _) hu_range have hnorm_series : Summable (fun n : ℕ => ‖hermiteCoeff k G n * Phi k n z‖) := by - simpa only [Complex.norm_mul, u] using hu_summable + exact hu_summable have htsum : (∑' n : ℕ, hermiteCoeff k G n * Phi k n z) = G z := by - simpa only [hermiteCoeff] using (hG.2 z).tsum_eq + exact (hG.2 z).tsum_eq calc ‖G z‖ = ‖∑' n : ℕ, hermiteCoeff k G n * Phi k n z‖ := by rw [← htsum] _ ≤ ∑' n : ℕ, u n := by @@ -3176,7 +3377,7 @@ private theorem circleSeries_l2_identity_canonical : ‖hermiteCoeff k G n.1 * (qkn k n.1 r : ℂ) * fourier (n.1 : ℤ) t‖ = ‖c n.1‖ * ‖fourier (n.1 : ℤ) t‖ := by simp [c, mul_assoc] _ = ‖c n.1‖ := by - simp_all [fourier_apply, Circle.norm_coe] + simp only [fourier_apply, Circle.norm_coe, mul_one] _ = ∑ n ∈ Finset.range (J + 1), ‖c n‖ := by rw [Finset.sum_range] _ ≤ M := by exact hc_norm.sum_le_tsum _ (fun n hn => norm_nonneg _) have hnonneg : 0 ≤ ‖truncCirclePoly k r J G t‖ ^ 2 := sq_nonneg _ @@ -3336,7 +3537,7 @@ theorem circleSeries_l2_identity : ‖g n.1 * (qkn k n.1 r : ℂ) * fourier (n.1 : ℤ) t‖ = ‖c n.1‖ * ‖fourier (n.1 : ℤ) t‖ := by simp [c, mul_assoc] _ = ‖c n.1‖ := by - simp_all [fourier_apply, Circle.norm_coe] + simp only [fourier_apply, Circle.norm_coe, mul_one] _ = ∑ n ∈ Finset.range (J + 1), ‖c n‖ := by rw [Finset.sum_range] _ ≤ M := by exact hc_norm.sum_le_tsum _ (fun n hn => norm_nonneg _) have hnonneg : 0 ≤ ‖finiteCirclePoly k r (fun n : Fin (J + 1) => g n.1) t‖ ^ 2 := sq_nonneg _ @@ -3365,7 +3566,7 @@ theorem circleSeries_l2_identity : calc ‖a n‖ = ‖c n‖ * ‖fourier (n : ℤ) t‖ := by simp [a, c, mul_assoc] _ = ‖c n‖ := by - simp_all [fourier_apply, Circle.norm_coe] + simp only [fourier_apply, Circle.norm_coe, mul_one] exact haeq.le have hconv : Filter.Tendsto (fun J => ∑ n ∈ Finset.range J, a n) Filter.atTop (nhds (circleSeries k g r @@ -3535,56 +3736,15 @@ theorem h_k_expansion_perp_phi0 : g 0 = 0 := by intro k G hG hperp refine ⟨hermiteCoeff k G, hermiteCoeff_expansion (k := k) (G := G) hG, ?_⟩ - simpa only [hermiteCoeff_phi0, phi0] using + exact (orthogonal_phi0_iff_hermiteCoeff_zero (k := k) (G := G)).mp hperp private lemma sub_truncate_mem_Hk {k : ℕ} {G : ℂ → ℂ} (hG : G ∈ Hk k) (J : ℕ) : (fun z => G z - truncate k J G z) ∈ Hk k := by refine ⟨?_, ?_⟩ - · have hG_aesm : AEStronglyMeasurable G volume := aestronglyMeasurable_of_mem_Hk hG - have hT_aesm : AEStronglyMeasurable (truncate k J G) volume := - (continuous_finiteHermiteSum k _).aestronglyMeasurable - have hbound : - Integrable - (fun z : ℂ => - (2 : ℝ) * - (‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2) + - ‖truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2))) := by - simpa only [mul_add, mul_left_comm, two_mul, add_assoc, Pi.add_apply, add_comm, add_left_comm, - mul_comm, mul_assoc] using - (hG.1.add (integrable_truncate_normSq_exp k J G)).const_mul (2 : ℝ) - have hExp_aesm : AEStronglyMeasurable (fun z : ℂ => rexp (-‖z‖ ^ 2)) volume := - (continuous_neg.comp ((continuous_pow 2).comp continuous_norm)).rexp.aestronglyMeasurable - have hmeas : - AEStronglyMeasurable - (fun z : ℂ => ‖G z - truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2)) volume := - ((hG_aesm.sub hT_aesm).norm.pow 2).mul hExp_aesm - refine MeasureTheory.Integrable.mono' hbound hmeas ?_ - filter_upwards with z - have hsub : ‖G z - truncate k J G z‖ ≤ ‖G z‖ + ‖truncate k J G z‖ := norm_sub_le _ _ - have hexp : 0 ≤ rexp (-‖z‖ ^ 2) := exp_nonneg _ - have hsq : - ‖G z - truncate k J G z‖ ^ 2 ≤ 2 * (‖G z‖ ^ 2 + ‖truncate k J G z‖ ^ 2) := by - have hsubsq : - ‖G z - truncate k J G z‖ ^ 2 ≤ (‖G z‖ + ‖truncate k J G z‖) ^ 2 := - pow_le_pow_left₀ (norm_nonneg _) hsub 2 - have hab : - (‖G z‖ + ‖truncate k J G z‖) ^ 2 ≤ 2 * (‖G z‖ ^ 2 + ‖truncate k J G z‖ ^ 2) := by - linarith only [sq_nonneg (‖G z‖ - ‖truncate k J G z‖)] - exact le_trans hsubsq hab - have hmul : - ‖G z - truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2) ≤ - (2 * (‖G z‖ ^ 2 + ‖truncate k J G z‖ ^ 2)) * rexp (-‖z‖ ^ 2) := - mul_le_mul_of_nonneg_right hsq hexp - have hnonneg : - 0 ≤ ‖G z - truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2) := by positivity - rw [Real.norm_of_nonneg hnonneg] - calc - ‖G z - truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2) - ≤ (2 * (‖G z‖ ^ 2 + ‖truncate k J G z‖ ^ 2)) * rexp (-‖z‖ ^ 2) := hmul - _ = (2 : ℝ) * - (‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2) + - ‖truncate k J G z‖ ^ 2 * rexp (-‖z‖ ^ 2)) := by ring + · exact integrable_weighted_square_sub (aestronglyMeasurable_of_mem_Hk hG) + (continuous_finiteHermiteSum k _).aestronglyMeasurable hG.1 + (integrable_truncate_normSq_exp k J G) · intro z have hGz := hG.2 z have hTzH := (truncate_mem_Hk k J G).2 z @@ -3693,7 +3853,7 @@ theorem truncate_tendsto : rw [hDiffNormSq, hShift] have hJN := hN (J + 1) (by omega) rw [dist_zero_right] at hJN - linarith [abs_nonneg (∑' n, ‖hermiteCoeff k G (n + (J + 1))‖ ^ 2), + linarith only [abs_nonneg (∑' n, ‖hermiteCoeff k G (n + (J + 1))‖ ^ 2), (abs_lt.mp hJN).2] /-- Truncations converge locally uniformly on bounded sets. -/ @@ -3982,7 +4142,7 @@ theorem hermite_series_locally_uniform : -- Use locally uniform convergence: for R = ‖z₀‖ + 1, ε/3, get J0 set R := ‖z₀‖ + 1 with hR_def have hRpos : 0 < R := by positivity - have hε3 : (0 : ℝ) < ε / 3 := by linarith + have hε3 : (0 : ℝ) < ε / 3 := by linarith only [hε] obtain ⟨J0, hJ0⟩ := truncate_locally_uniform hG R (ε / 3) hRpos hε3 -- truncate k J0 G is continuous have hcont_trunc : Continuous (truncate k J0 G) := continuous_finiteHermiteSum k _ @@ -3997,8 +4157,8 @@ theorem hermite_series_locally_uniform : have hz_R : ‖z‖ ≤ R := by have h1 : ‖z‖ ≤ ‖z₀‖ + ‖z - z₀‖ := norm_le_insert' z z₀ have h2 : ‖z - z₀‖ = dist z z₀ := by rw [dist_eq_norm] - linarith [hz, min_le_right δ₁ 1] - have hz₀_R : ‖z₀‖ ≤ R := by linarith + linarith only [hz, h1, h2, min_le_right δ₁ 1] + have hz₀_R : ‖z₀‖ ≤ R := by linarith only [] have hclose_z : ‖truncate k J0 G z - G z‖ ≤ ε / 3 := hJ0 J0 (le_refl _) z hz_R have hclose_z₀ : ‖truncate k J0 G z₀ - G z₀‖ ≤ ε / 3 := hJ0 J0 (le_refl _) z₀ hz₀_R have hclose_trunc : dist (truncate k J0 G z) (truncate k J0 G z₀) < ε / 3 := @@ -4010,14 +4170,12 @@ theorem hermite_series_locally_uniform : (truncate k J0 G z₀ - G z₀)‖ := by ring_nf _ ≤ ‖G z - truncate k J0 G z‖ + ‖truncate k J0 G z - truncate k J0 G z₀‖ + ‖truncate k J0 G z₀ - G z₀‖ := by - linarith [norm_add_le (G z - truncate k J0 G z + (truncate k J0 G z - truncate k J0 G z₀)) - (truncate k J0 G z₀ - G z₀), - norm_add_le (G z - truncate k J0 G z) (truncate k J0 G z - truncate k J0 G z₀)] + exact norm_add₃_le _ < ε / 3 + ε / 3 + ε / 3 := by have h1 : ‖G z - truncate k J0 G z‖ ≤ ε / 3 := by rw [show G z - truncate k J0 G z = -(truncate k J0 G z - G z) by ring, norm_neg] exact hclose_z - linarith + linarith only [hclose_z₀, hclose_trunc, h1] _ = ε := by ring /-- Every element of `H_k` is continuous. -/ @@ -4230,7 +4388,7 @@ private lemma summable_hermite_eval_mul (k : ℕ) (h : ℕ → ℂ) (_hbdd : ∀ n, ‖h n‖ ≤ 1) (hl2 : Summable (fun n => ‖h n‖ ^ 2)) (z : ℂ) : Summable (fun n => h n * Phi k n z) := by - obtain ⟨Cz, _, hCz⟩ := point_eval_bounded (k := k) z + obtain ⟨Cz, hCz_nonnegative, hCz⟩ := point_eval_bounded (k := k) z have hRK_partial : ∀ J : ℕ, ∑ n : Fin (J + 1), ‖Phi k n z‖ ^ 2 ≤ Cz ^ 2 := by intro J let a : Fin (J + 1) → ℂ := fun n => starRingEnd ℂ (Phi k n z) @@ -4271,7 +4429,7 @@ private lemma summable_hermite_eval_mul have hsqS : Real.sqrt S * Real.sqrt S = S := by linarith only [Real.sq_sqrt hS_nn] nlinarith only [hSqLe, hsqS, hsqrt_pos] have hCz_nn : 0 ≤ Cz := le_trans (by simp [hS_def]) hsqrt_le - nlinarith [hsqrt_le, hCz_nn] + nlinarith only [hCz_nonnegative, hSqLe, hsqrt_le, hCz_nn] have hRK_range : ∀ J : ℕ, ∑ n ∈ Finset.range J, ‖Phi k n z‖ ^ 2 ≤ Cz ^ 2 := by intro J by_cases hJ : J = 0 @@ -4307,10 +4465,10 @@ private lemma finiteHermiteSum_tendsto_hermiteSeries have hsumm := summable_hermite_eval_mul k h hbdd hl2 z have hconv : Filter.Tendsto (fun J : ℕ => ∑ n ∈ Finset.range J, h n * Phi k n z) Filter.atTop - (𝓝 (hermiteSeries k h z)) := by simpa only [hermiteSeries] using + (𝓝 (hermiteSeries k h z)) := by exact hsumm.hasSum.tendsto_sum_nat have hshift : Filter.Tendsto (fun J : ℕ => J + 1) Filter.atTop Filter.atTop := by - simpa using (Filter.tendsto_add_atTop_nat 1) + exact (Filter.tendsto_add_atTop_nat 1) have hconv' := hconv.comp hshift have hconv'' : Filter.Tendsto (fun J : ℕ => ∑ n ∈ Finset.range (J + 1), h n * Phi k n z) Filter.atTop @@ -4324,11 +4482,11 @@ private lemma finiteHermiteSum_tendsto_hermiteSeries ext J change ∑ n : Fin (J + 1), h n.1 * Phi k n.1 z = ∑ n ∈ Finset.range (J + 1), h n * Phi k n z - simpa using + exact (Fin.sum_univ_eq_sum_range (f := fun n : ℕ => h n * Phi k n z) (J + 1)) - simpa using hmain + exact hmain /-- The explicit Hermite series is a.e. strongly measurable. -/ private theorem hermiteSeries_aestronglyMeasurable @@ -4341,213 +4499,6 @@ private theorem hermiteSeries_aestronglyMeasurable · exact Filter.Eventually.of_forall (finiteHermiteSum_tendsto_hermiteSeries k h hbdd hl2) -/-- Gaussian weight used to identify weighted Hermite norms with ordinary `L²`. -/ -private def gaussianWeight (z : ℂ) : ℝ := - Real.exp (-(‖z‖ ^ 2) / 2) / Real.sqrt Real.pi - -/-- Gaussian rescaling into the usual `L²` space. -/ -private def gaussianScale (F : ℂ → ℂ) : ℂ → ℂ := - fun z => ((gaussianWeight z : ℝ) : ℂ) * F z - -private theorem gaussianWeight_nonneg (z : ℂ) : 0 ≤ gaussianWeight z := by - unfold gaussianWeight - positivity - -private theorem gaussianWeight_sq (z : ℂ) : - gaussianWeight z ^ 2 = (1 / Real.pi) * Real.exp (-‖z‖ ^ 2) := by - unfold gaussianWeight - have hpi : 0 ≤ Real.pi := le_of_lt Real.pi_pos - have hsqrt : Real.sqrt Real.pi ^ 2 = Real.pi := by rw [Real.sq_sqrt hpi] - have hexp : - Real.exp (-(‖z‖ ^ 2) / 2) ^ 2 = Real.exp (-‖z‖ ^ 2) := by - calc - Real.exp (-(‖z‖ ^ 2) / 2) ^ 2 - = Real.exp (-(‖z‖ ^ 2) / 2) * Real.exp (-(‖z‖ ^ 2) / 2) := by ring - _ = Real.exp (-(‖z‖ ^ 2) / 2 + -(‖z‖ ^ 2) / 2) := by rw [← Real.exp_add] - _ = Real.exp (-‖z‖ ^ 2) := by congr 1; ring - rw [div_pow, hexp, hsqrt] - field_simp [Real.pi_ne_zero] - -private theorem continuous_gaussianWeight : Continuous gaussianWeight := by - unfold gaussianWeight - exact - (Real.continuous_exp.comp - ((continuous_neg.comp (continuous_norm.pow 2)).div_const 2)).div_const _ - -private theorem aestronglyMeasurable_gaussianScale - {F : ℂ → ℂ} - (hF : AEStronglyMeasurable F volume) : - AEStronglyMeasurable (gaussianScale F) volume := - (Complex.continuous_ofReal.comp continuous_gaussianWeight).aestronglyMeasurable.mul hF - -private theorem weightedNormSq_eq_integral_sq_norm_gaussianScale - (G : ℂ → ℂ) : - weightedNormSq G = ∫ z : ℂ, ‖gaussianScale G z‖ ^ 2 := by - unfold weightedNormSq HermiteLEAN.weightedNormSq - have hEq : - (fun z : ℂ => ‖gaussianScale G z‖ ^ 2) = - fun z : ℂ => (1 / Real.pi) * (‖G z‖ ^ 2 * Real.exp (-‖z‖ ^ 2)) := by - funext z - rw [show ‖gaussianScale G z‖ ^ 2 = - gaussianWeight z ^ 2 * ‖G z‖ ^ 2 by - unfold gaussianScale - rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, - abs_of_nonneg (gaussianWeight_nonneg z)] - ring] - rw [gaussianWeight_sq] - ac_rfl - rw [hEq, MeasureTheory.integral_const_mul] - -private theorem memLp_two_gaussianScale_of_integrable - {F : ℂ → ℂ} - (hF : AEStronglyMeasurable F volume) - (hInt : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : - MeasureTheory.MemLp (gaussianScale F) 2 volume := by - refine (MeasureTheory.memLp_two_iff_integrable_sq_norm ?_).2 ?_ - · exact aestronglyMeasurable_gaussianScale hF - · refine hInt.const_mul (1 / Real.pi) |>.congr ?_ - filter_upwards with z - rw [show ‖gaussianScale F z‖ ^ 2 = - gaussianWeight z ^ 2 * ‖F z‖ ^ 2 by - unfold gaussianScale - rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, - abs_of_nonneg (gaussianWeight_nonneg z)] - ring] - rw [gaussianWeight_sq] - ac_rfl - -private theorem weightedNorm_eq_lpNorm_gaussianScale - {F : ℂ → ℂ} - (hF : AEStronglyMeasurable F volume) - (_hInt : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : - weightedNorm F = MeasureTheory.lpNorm (gaussianScale F) 2 volume := by - have hmeas : AEStronglyMeasurable (gaussianScale F) volume := - aestronglyMeasurable_gaussianScale hF - have htwo : (2 : NNReal) ≠ 0 := by norm_num - have hlp := MeasureTheory.lpNorm_nnreal_eq_integral_norm_rpow - (μ := volume) (p := (2 : NNReal)) (f := gaussianScale F) htwo hmeas - change weightedNorm F = MeasureTheory.lpNorm (gaussianScale F) (↑(2 : NNReal)) volume - rw [hlp] - change weightedNorm F = (∫ z : ℂ, ‖gaussianScale F z‖ ^ (2 : ℝ)) ^ ((2 : ℝ)⁻¹) - have hsq : - (∫ z : ℂ, ‖gaussianScale F z‖ ^ (2 : ℝ)) = weightedNormSq F := by - simpa only [rpow_ofNat] using (weightedNormSq_eq_integral_sq_norm_gaussianScale F).symm - rw [hsq] - unfold weightedNorm HermiteLEAN.weightedNorm - rw [Real.sqrt_eq_rpow] - norm_num - -private theorem integrable_weightedCross_of_memLp - (F G : ℂ → ℂ) - (hF : MeasureTheory.MemLp (gaussianScale F) 2 volume) - (hG : MeasureTheory.MemLp (gaussianScale G) 2 volume) : - Integrable - (fun z : ℂ => F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)) := by - let FLp : MeasureTheory.Lp ℂ 2 volume := hF.toLp (gaussianScale F) - let GLp : MeasureTheory.Lp ℂ 2 volume := hG.toLp (gaussianScale G) - have hscaled : - Integrable - (fun z : ℂ => - ((1 / Real.pi : ℂ) * - (F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)))) := by - have hint : - Integrable (fun z : ℂ => inner ℂ (GLp z) (FLp z)) := by - simpa only [RCLike.inner_apply, FLp, GLp] using - MeasureTheory.L2.integrable_inner (𝕜 := ℂ) GLp FLp - have hEq : - (fun z : ℂ => inner ℂ (GLp z) (FLp z)) =ᵐ[volume] - (fun z : ℂ => inner ℂ (gaussianScale G z) (gaussianScale F z)) := by - filter_upwards [hG.coeFn_toLp, hF.coeFn_toLp] with z hzG hzF - rw [hzG, hzF] - have hint' : - Integrable (fun z : ℂ => inner ℂ (gaussianScale G z) (gaussianScale F z)) := hint.congr hEq - convert hint' using 1 - ext z - rw [RCLike.inner_apply'] - unfold gaussianScale - have hgw : - (((gaussianWeight z : ℝ) : ℂ) * ((gaussianWeight z : ℝ) : ℂ)) = - (((1 / Real.pi) * Real.exp (-‖z‖ ^ 2) : ℝ) : ℂ) := by - have hsq := gaussianWeight_sq z - rw [sq] at hsq - exact_mod_cast hsq - rw [show (starRingEnd ℂ) (↑(gaussianWeight z) * G z) * (↑(gaussianWeight z) * F z) = - ↑(gaussianWeight z) * ↑(gaussianWeight z) * (F z * (starRingEnd ℂ) (G z)) from by - simp [map_mul] - ring, hgw] - push_cast - ac_rfl - have hpi_ne : (Real.pi : ℂ) ≠ 0 := by exact_mod_cast Real.pi_ne_zero - simpa only [ofReal_exp, ofReal_neg, ofReal_pow, mul_comm, mul_left_comm, one_div, ne_eq, hpi_ne, - not_false_eq_true, mul_inv_cancel_left₀, mul_assoc] using hscaled.const_mul (Real.pi : ℂ) - -private theorem weightedInner_eq_l2Inner - (F G : ℂ → ℂ) - (hF : MeasureTheory.MemLp (gaussianScale F) 2 volume) - (hG : MeasureTheory.MemLp (gaussianScale G) 2 volume) : - weightedInner F G = @inner ℂ _ _ (hG.toLp (gaussianScale G)) (hF.toLp (gaussianScale F)) := by - let FLp : MeasureTheory.Lp ℂ 2 volume := hF.toLp (gaussianScale F) - let GLp : MeasureTheory.Lp ℂ 2 volume := hG.toLp (gaussianScale G) - have hEq : - (fun z : ℂ => inner ℂ (GLp z) (FLp z)) =ᵐ[volume] - (fun z : ℂ => - ((1 / Real.pi : ℂ) * - (F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ)))) := by - filter_upwards [hG.coeFn_toLp, hF.coeFn_toLp] with z hzG hzF - rw [hzG, hzF, RCLike.inner_apply'] - unfold gaussianScale - have hgw : - (((gaussianWeight z : ℝ) : ℂ) * ((gaussianWeight z : ℝ) : ℂ)) = - (((1 / Real.pi) * Real.exp (-‖z‖ ^ 2) : ℝ) : ℂ) := by - have hsq := gaussianWeight_sq z - rw [sq] at hsq - exact_mod_cast hsq - rw [show (starRingEnd ℂ) (↑(gaussianWeight z) * G z) * (↑(gaussianWeight z) * F z) = - ↑(gaussianWeight z) * ↑(gaussianWeight z) * (F z * (starRingEnd ℂ) (G z)) from by - simp [map_mul] - ring, hgw] - push_cast - ac_rfl - calc - weightedInner F G - = ∫ z : ℂ, ((1 / Real.pi : ℂ) * - (F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ))) := by - unfold weightedInner HermiteLEAN.weightedInner - exact - (MeasureTheory.integral_const_mul - (r := (1 / Real.pi : ℂ)) - (f := fun z : ℂ => - F z * (starRingEnd ℂ) (G z) * (Real.exp (-‖z‖ ^ 2) : ℂ))).symm - _ = ∫ z : ℂ, inner ℂ (GLp z) (FLp z) := by - symm - exact integral_congr_ae hEq - _ = @inner ℂ _ _ GLp FLp := by - simpa only [RCLike.inner_apply, GLp, FLp] using - (MeasureTheory.L2.inner_def (𝕜 := ℂ) GLp FLp).symm - -private theorem weightedInner_norm_le_of_integrable - {F G : ℂ → ℂ} - (hFmeas : AEStronglyMeasurable F volume) - (hGmeas : AEStronglyMeasurable G volume) - (hFint : Integrable (fun z : ℂ => ‖F z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) - (hGint : Integrable (fun z : ℂ => ‖G z‖ ^ 2 * Real.exp (-‖z‖ ^ 2))) : - ‖weightedInner F G‖ ≤ weightedNorm F * weightedNorm G := by - let hFmem := memLp_two_gaussianScale_of_integrable hFmeas hFint - let hGmem := memLp_two_gaussianScale_of_integrable hGmeas hGint - calc - ‖weightedInner F G‖ - = ‖@inner ℂ _ _ (hGmem.toLp (gaussianScale G)) (hFmem.toLp (gaussianScale F))‖ := by - rw [weightedInner_eq_l2Inner F G hFmem hGmem] - _ ≤ ‖hGmem.toLp (gaussianScale G)‖ * ‖hFmem.toLp (gaussianScale F)‖ := norm_inner_le_norm _ _ - _ = MeasureTheory.lpNorm (gaussianScale G) 2 volume * - MeasureTheory.lpNorm (gaussianScale F) 2 volume := by - rw [MeasureTheory.Lp.norm_toLp, MeasureTheory.Lp.norm_toLp, - ← MeasureTheory.toReal_eLpNorm, ← MeasureTheory.toReal_eLpNorm] - _ = weightedNorm G * weightedNorm F := by - rw [← weightedNorm_eq_lpNorm_gaussianScale hGmeas hGint, - ← weightedNorm_eq_lpNorm_gaussianScale hFmeas hFint] - _ = weightedNorm F * weightedNorm G := by ring - /-- The Hermite series `G = hermiteSeries k h` of a square-summable bounded sequence has integrable squared Gaussian density. Extracted from `hermiteSeries_mem_Hk` to respect the proof size limit. -/ @@ -4854,44 +4805,7 @@ private lemma hermiteSeries_weightedInner_eq {k : ℕ} (h : ℕ → ℂ) (continuous_finiteHermiteSum k _).aestronglyMeasurable have hDiff_int : Integrable (fun z : ℂ => ‖G z - SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2)) := by - have hbound : - Integrable - (fun z : ℂ => - (2 : ℝ) * - (‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2) + - ‖SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2))) := by - simpa only [mul_comm, mul_add, mul_left_comm, two_mul, add_assoc, Pi.add_apply, add_comm, - add_left_comm, mul_assoc] using (hIntG.add hSJ_int).const_mul (2 : ℝ) - have hExp_aesm : AEStronglyMeasurable (fun z : ℂ => rexp (-‖z‖ ^ 2)) volume := - (continuous_neg.comp ((continuous_pow 2).comp continuous_norm)).rexp.aestronglyMeasurable - have hmeas : - AEStronglyMeasurable - (fun z : ℂ => ‖G z - SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2)) volume := - ((hG_aesm.sub hSJ_aesm).norm.pow 2).mul hExp_aesm - refine MeasureTheory.Integrable.mono' hbound hmeas ?_ - filter_upwards with z - have hsub : ‖G z - SJ z‖ ≤ ‖G z‖ + ‖SJ z‖ := norm_sub_le _ _ - have hexp : 0 ≤ rexp (-‖z‖ ^ 2) := exp_nonneg _ - have hsq : - ‖G z - SJ z‖ ^ 2 ≤ 2 * (‖G z‖ ^ 2 + ‖SJ z‖ ^ 2) := by - have hsubsq : - ‖G z - SJ z‖ ^ 2 ≤ (‖G z‖ + ‖SJ z‖) ^ 2 := pow_le_pow_left₀ (norm_nonneg _) hsub 2 - have hab : - (‖G z‖ + ‖SJ z‖) ^ 2 ≤ 2 * (‖G z‖ ^ 2 + ‖SJ z‖ ^ 2) := by - linarith only [sq_nonneg (‖G z‖ - ‖SJ z‖)] - exact le_trans hsubsq hab - have hmul : - ‖G z - SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2) ≤ - (2 * (‖G z‖ ^ 2 + ‖SJ z‖ ^ 2)) * rexp (-‖z‖ ^ 2) := mul_le_mul_of_nonneg_right hsq hexp - have hnonneg : - 0 ≤ ‖G z - SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2) := by positivity - rw [Real.norm_of_nonneg hnonneg] - calc - ‖G z - SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2) - ≤ (2 * (‖G z‖ ^ 2 + ‖SJ z‖ ^ 2)) * rexp (-‖z‖ ^ 2) := hmul - _ = (2 : ℝ) * - (‖G z‖ ^ 2 * rexp (-‖z‖ ^ 2) + - ‖SJ z‖ ^ 2 * rexp (-‖z‖ ^ 2)) := by ring + exact integrable_weighted_square_sub hG_aesm hSJ_aesm hIntG hSJ_int have hDiff_sq_le : weightedNormSq (fun z : ℂ => G z - SJ z) ≤ ∑' m : ℕ, ‖h (m + (J + 1))‖ ^ 2 := @@ -4967,7 +4881,7 @@ private lemma hermiteSeries_weightedInner_eq {k : ℕ} (h : ℕ → ℂ) weightedNorm (fun z : ℂ => G z - SJ z) := by simpa only [hPhi_norm, mul_one] using hnorm_le exact lt_of_le_of_lt hnorm_le' hDiff_small - linarith + linarith only [hdist_pos, this] simp_all only [gt_iff_lt, ge_iff_le, dist_zero_right, norm_eq_abs, ne_eq, norm_pos_iff, Order.lt_add_one_iff, ofReal_exp, ofReal_neg, ofReal_pow, add_sub_cancel_left, lt_self_iff_false] diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/ImportedAnalyticInputs.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/ImportedAnalyticInputs.lean index 5b8e25d164..69528a6cf6 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/ImportedAnalyticInputs.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/ImportedAnalyticInputs.lean @@ -57,7 +57,7 @@ def Crot : ℝ := 64 * Real.pi theorem Crot_pos : 0 < Crot := by unfold Crot - nlinarith [Real.pi_pos] + nlinarith only [Real.pi_pos] /-- `zeta`: zeta. -/ noncomputable def zeta (x : Circle) : ℂ := @@ -150,7 +150,7 @@ theorem carrierArc_left_lt_right {N : Nat} (k : Fin N) : (carrierArc N k).left < (carrierArc N k).right := by have hlen := carrierArc_length_pos k dsimp [arcLength] at hlen - linarith + linarith only [hlen] theorem carrierArc_arcSet_eq_mk_image_Icc {N : Nat} (k : Fin N) : arcSet (carrierArc N k) = @@ -165,9 +165,9 @@ theorem carrierArc_arcSet_eq_mk_image_Icc {N : Nat} (k : Fin N) : le_of_lt (carrierArc_length_pos k) constructor · dsimp [arcLength] at hlen_nonneg ⊢ - nlinarith [ht.1, hlen_nonneg] + nlinarith only [ht.1, hlen_nonneg] · dsimp [arcLength] at hlen_nonneg ⊢ - nlinarith [ht.2, hlen_nonneg] + nlinarith only [ht.2, hlen_nonneg] · intro hx rcases hx with ⟨y, hy, rfl⟩ let t : ℝ := (y - (carrierArc N k).left) / arcLength (carrierArc N k) @@ -180,7 +180,7 @@ theorem carrierArc_arcSet_eq_mk_image_Icc {N : Nat} (k : Fin N) : · dsimp [t] rw [div_le_one hlen_pos] dsimp [arcLength] - linarith [hy.2] + linarith only [hy.2] · dsimp [arcParam, t] have hlen_pos : 0 < arcLength (carrierArc N k) := carrierArc_length_pos k @@ -807,13 +807,13 @@ theorem constantCenter_fastRotate_carrierArc_sq_le_defectSq have hlen_nonneg : 0 <= arcLength (carrierArc N k) := arcLength_nonneg (carrierArc N k) have hnorm_nonneg : 0 <= ‖u‖ ^ 2 := sq_nonneg ‖u‖ - nlinarith + nlinarith only [hlen_nonneg] have hJ_nonneg : 0 <= J := le_trans hleft_nonneg hJ_lower calc arcLength (carrierArc N k) * ‖u‖ ^ 2 = 8 * (arcLength (carrierArc N k) * ‖u‖ ^ 2 / 8) := by ring _ <= 8 * J := by exact mul_le_mul_of_nonneg_left hJ_lower (by norm_num) - _ <= 32 * J := by nlinarith + _ <= 32 * J := by linarith only [hJ_lower, hleft_nonneg] _ = Crot * ((2 * Real.pi)⁻¹ * J) := by unfold Crot have hpi_ne : Real.pi ≠ 0 := ne_of_gt Real.pi_pos @@ -2257,24 +2257,20 @@ theorem norm_star_L2 {d : Nat} (f : L2Real d) : private theorem lpPairing_mul_norm_le {d : Nat} (f g : L2Real d) : ‖((ContinuousLinearMap.mul ℂ ℂ).lpPairing (MeasureTheory.volume : MeasureTheory.Measure (RealVec d)) 2 2) f g‖ ≤ ‖f‖ * ‖g‖ := by - let μ : MeasureTheory.Measure (RealVec d) := MeasureTheory.volume - let B := (ContinuousLinearMap.mul ℂ ℂ) - have hB : ‖B‖ ≤ (1 : ℝ) := by simp [B] - rw [ContinuousLinearMap.lpPairing_eq_integral] - let H : MeasureTheory.Lp ℂ 1 μ := B.holder (1 : ENNReal) f g - have hHae : H =ᵐ[μ] fun x => B (f x) (g x) := by exact ContinuousLinearMap.coeFn_holder B f g - have hnorm_int : ‖∫ x, B (f x) (g x) ∂μ‖ ≤ ‖H‖ := by - calc - ‖∫ x, B (f x) (g x) ∂μ‖ = ‖∫ x, H x ∂μ‖ := congrArg norm (integral_congr_ae hHae.symm) - _ ≤ ∫ x, ‖H x‖ ∂μ := norm_integral_le_integral_norm _ - _ = ‖H‖ := by rw [MeasureTheory.L1.norm_eq_integral_norm] - have hholder : ‖H‖ ≤ ‖B‖ * ‖f‖ * ‖g‖ := by - simpa [H] using ContinuousLinearMap.norm_holder_apply_apply_le B f g - have hmul : ‖B‖ * ‖f‖ * ‖g‖ ≤ ‖f‖ * ‖g‖ := by - calc - ‖B‖ * ‖f‖ * ‖g‖ ≤ 1 * ‖f‖ * ‖g‖ := by gcongr - _ = ‖f‖ * ‖g‖ := by ring - exact hnorm_int.trans (hholder.trans hmul) + let B := ContinuousLinearMap.mul ℂ ℂ + have hleft : B.lpPairing (volume : Measure (RealVec d)) 2 2 f g = + MeasureTheory.L1.integral (B.holder 1 f g) := by + rw [MeasureTheory.L1.integral_eq' ℂ] + rfl + rw [hleft] + calc + _ ≤ ‖B.holder 1 f g‖ := MeasureTheory.L1.norm_integral_le _ + _ ≤ ‖B‖ * ‖f‖ * ‖g‖ := ContinuousLinearMap.norm_holder_apply_apply_le B f g + _ ≤ 1 * ‖f‖ * ‖g‖ := + mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (ContinuousLinearMap.opNorm_mul_le ℂ ℂ) (norm_nonneg f)) + (norm_nonneg g) + _ = ‖f‖ * ‖g‖ := by rw [one_mul] theorem norm_ambiguityRep_le {d : Nat} (f g : L2Real d) (ξ : PhaseSpace d) : ‖ambiguityRep f g ξ‖ ≤ ‖f‖ * ‖g‖ := by @@ -2324,6 +2320,23 @@ theorem norm_stftRep_le {d : Nat} (h f : L2Real d) (ξ : PhaseSpace d) : ≤ ‖f‖ * ‖modulateL2 ξ.2 (star (translateL2 (-ξ.1) h))‖ := hpair _ = ‖f‖ * ‖h‖ := by rw [norm_modulateL2, norm_star_L2, norm_translateL2] +private theorem bilinear_sub + {E F G : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] + [NormedSpace ℂ E] [NormedSpace ℂ F] [NormedSpace ℂ G] + (B : E →L[ℂ] F →L[ℂ] G) (f₁ f₂ : E) (g₁ g₂ : F) : + B f₁ g₁ - B f₂ g₂ = B (f₁ - f₂) g₁ + B f₂ (g₁ - g₂) := by + simp only [map_sub, sub_apply] + abel + +private theorem norm_bilinear_sub_le + {E F G : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] + [NormedSpace ℂ E] [NormedSpace ℂ F] [NormedSpace ℂ G] + (B : E →L[ℂ] F →L[ℂ] G) (hB : ∀ f g, ‖B f g‖ ≤ ‖f‖ * ‖g‖) + (f₁ f₂ : E) (g₁ g₂ : F) : + ‖B f₁ g₁ - B f₂ g₂‖ ≤ ‖f₁ - f₂‖ * ‖g₁‖ + ‖f₂‖ * ‖g₁ - g₂‖ := by + rw [bilinear_sub] + exact (norm_add_le _ _).trans (add_le_add (hB _ _) (hB _ _)) + private theorem norm_stftRep_sub_le {d : Nat} (h₁ h₂ f₁ f₂ : L2Real d) (ξ : PhaseSpace d) : ‖stftRep h₁ f₁ ξ - stftRep h₂ f₂ ξ‖ ≤ @@ -2344,17 +2357,8 @@ private theorem norm_stftRep_sub_le {d : Nat} rw [stftRep_eq_lpPairing h₁ f₁ ξ, stftRep_eq_lpPairing h₂ f₂ ξ] change ‖P f₁ (T h₁) - P f₂ (T h₂)‖ ≤ ‖f₁ - f₂‖ * ‖h₁‖ + ‖f₂‖ * ‖h₁ - h₂‖ - have hsplit : - P f₁ (T h₁) - P f₂ (T h₂) = - P (f₁ - f₂) (T h₁) + P f₂ (T h₁ - T h₂) := by simp [P] - calc - ‖P f₁ (T h₁) - P f₂ (T h₂)‖ - = ‖P (f₁ - f₂) (T h₁) + P f₂ (T h₁ - T h₂)‖ := by rw [hsplit] - _ ≤ ‖P (f₁ - f₂) (T h₁)‖ + ‖P f₂ (T h₁ - T h₂)‖ := norm_add_le _ _ - _ ≤ ‖f₁ - f₂‖ * ‖T h₁‖ + ‖f₂‖ * ‖T h₁ - T h₂‖ := by - exact add_le_add (lpPairing_mul_norm_le (f₁ - f₂) (T h₁)) - (lpPairing_mul_norm_le f₂ (T h₁ - T h₂)) - _ = ‖f₁ - f₂‖ * ‖h₁‖ + ‖f₂‖ * ‖h₁ - h₂‖ := by rw [hT_norm, hT_sub_norm] + simpa only [hT_norm, hT_sub_norm] using + norm_bilinear_sub_le P (fun f g => lpPairing_mul_norm_le f g) f₁ f₂ (T h₁) (T h₂) theorem continuous_stftRep {d : Nat} (h f : L2Real d) : @@ -2401,10 +2405,10 @@ private theorem stftRep_sq_integrable_schwartz_realVec {d : Nat} constructor · refine Filter.Eventually.of_forall ?_ intro x - simpa [F, hLp, fLp, μ] using integrable_stftRep_sq_slice_schwartz_realVec h f x + exact integrable_stftRep_sq_slice_schwartz_realVec h f x · have hkernel : Integrable (fun p : RealVec d × RealVec d => ‖f p.1‖ ^ 2 * ‖h (p.1 - p.2)‖ ^ 2) - (μ.prod μ) := by simpa [μ] using integrable_stft_kernel_schwartz_realVec h f + (μ.prod μ) := integrable_stft_kernel_schwartz_realVec h f have h_outer : (fun x : RealVec d => ∫ ω : RealVec d, ‖F (x, ω)‖ ∂μ) = fun x : RealVec d => ∫ t : RealVec d, ‖f t‖ ^ 2 * ‖h (t - x)‖ ^ 2 ∂μ := by @@ -2414,12 +2418,12 @@ private theorem stftRep_sq_integrable_schwartz_realVec {d : Nat} = ∫ ω : RealVec d, ‖stftRep hLp fLp (x, ω)‖ ^ 2 ∂μ := by refine integral_congr_ae ?_ filter_upwards with ω - simp [F] + exact Real.norm_of_nonneg (sq_nonneg _) _ = ∫ t : RealVec d, ‖f t‖ ^ 2 * ‖h (t - x)‖ ^ 2 ∂μ := by rw [integral_norm_sq_stft_slice_schwartz_realVec h f x] refine integral_congr_ae ?_ filter_upwards with t - simp [stftSliceSchwartz_apply, pow_two, mul_assoc, mul_left_comm, mul_comm] + rw [stftSliceSchwartz_apply, norm_mul, norm_star, mul_pow] rw [h_outer] simpa only [norm_mul, norm_pow, norm_norm] using hkernel.integral_norm_prod_right @@ -2474,10 +2478,8 @@ private theorem integral_stftRep_sq_schwartz_realVec {d : Nat} let hLp : L2Real d := h.toLp 2 μ let fLp : L2Real d := f.toLp 2 μ let K : RealVec d → RealVec d → ℝ := fun x t => ‖f t‖ ^ 2 * ‖h (t - x)‖ ^ 2 - have hK : Integrable (Function.uncurry K) (μ.prod μ) := by - refine ((integrable_stft_kernel_schwartz_realVec h f).swap).congr ?_ - filter_upwards with p - simp [K, Function.uncurry, Function.comp_apply, Prod.fst_swap, Prod.snd_swap, mul_comm] + have hK : Integrable (Function.uncurry K) (μ.prod μ) := + (integrable_stft_kernel_schwartz_realVec h f).swap calc ∫ p : PhaseSpace d, ‖stftRep (h.toLp 2 μ) (f.toLp 2 μ) p‖ ^ 2 = ∫ x : RealVec d, ∫ ω : RealVec d, ‖stftRep hLp fLp (x, ω)‖ ^ 2 := by @@ -2498,7 +2500,7 @@ private theorem integral_stftRep_sq_schwartz_realVec {d : Nat} ‖stftSliceSchwartz h f x t‖ ^ 2 = ‖f t * star (h (t - x))‖ ^ 2 := by rw [stftSliceSchwartz_apply] _ = (‖f t‖ * ‖h (t - x)‖) ^ 2 := by rw [norm_mul, norm_star] - _ = K x t := by simp [K, pow_two, mul_assoc, mul_left_comm, mul_comm] + _ = K x t := mul_pow _ _ _ _ = ∫ t : RealVec d, ∫ x : RealVec d, K x t := by exact MeasureTheory.integral_integral_swap hK _ = ∫ t : RealVec d, ‖f t‖ ^ 2 * ∫ x : RealVec d, ‖h x‖ ^ 2 := by refine integral_congr_ae ?_ @@ -2804,6 +2806,8 @@ private theorem stftRep_sub_eq_add {d : Nat} stftRep h₁ (f₁ - f₂) ξ + stftRep (h₁ - h₂) f₂ ξ := by let P := ((ContinuousLinearMap.mul ℂ ℂ).lpPairing (MeasureTheory.volume : MeasureTheory.Measure (RealVec d)) 2 2) + -- Generate the existing congruence theorem on a small application for import compatibility. + have hpairing_zero : P 0 0 = 0 := by simp [P] let T : L2Real d → L2Real d := fun h => modulateL2 ξ.2 (star (translateL2 (-ξ.1) h)) have hT_sub : T (h₁ - h₂) = T h₁ - T h₂ := by @@ -2814,7 +2818,7 @@ private theorem stftRep_sub_eq_add {d : Nat} change P f₁ (T h₁) - P f₂ (T h₂) = P (f₁ - f₂) (T h₁) + P f₂ (T (h₁ - h₂)) rw [hT_sub] - simp [P] + exact bilinear_sub P f₁ f₂ (T h₁) (T h₂) private theorem lpNorm_stftRep_sub_le {d : Nat} (h₁ h₂ f₁ f₂ : L2Real d) : @@ -2878,53 +2882,43 @@ private theorem lpNorm_mul_le_real (hf : MeasureTheory.MemLp f 2 μ) (hg : MeasureTheory.MemLp g 2 μ) : MeasureTheory.lpNorm (fun x => f x * g x) 1 μ ≤ MeasureTheory.lpNorm f 2 μ * MeasureTheory.lpNorm g 2 μ := by - have hmem : MeasureTheory.MemLp (fun x => f x * g x) 1 μ := by - refine MeasureTheory.MemLp.ae_eq ?_ (hg.mul hf) - filter_upwards with x - simp [Pi.mul_apply, mul_comm] - rw [MeasureTheory.lpNorm_one_eq_integral_norm hmem.aestronglyMeasurable] - have hpq : Real.HolderConjugate 2 2 := by constructor <;> norm_num - have hf_abs : MeasureTheory.MemLp (fun x => |f x|) (ENNReal.ofReal (2 : ℝ)) μ := by - simpa only [ENNReal.ofReal_ofNat, Real.norm_eq_abs] using hf.norm - have hg_abs : MeasureTheory.MemLp (fun x => |g x|) (ENNReal.ofReal (2 : ℝ)) μ := by - simpa only [ENNReal.ofReal_ofNat, Real.norm_eq_abs] using hg.norm - have hf_nonneg : 0 ≤ᵐ[μ] fun x => |f x| := - Filter.Eventually.of_forall fun _ => abs_nonneg _ - have hg_nonneg : 0 ≤ᵐ[μ] fun x => |g x| := - Filter.Eventually.of_forall fun _ => abs_nonneg _ - have hholder := @MeasureTheory.integral_mul_le_Lp_mul_Lq_of_nonneg α _ μ 2 2 hpq - (fun x => |f x|) (fun x => |g x|) hf_nonneg hg_nonneg hf_abs hg_abs - have hf_lp : - (∫ x, |f x| ^ (2 : ℝ) ∂μ) ^ (1 / (2 : ℝ)) = - MeasureTheory.lpNorm f 2 μ := by - have h := hf.eLpNorm_eq_integral_rpow_norm (μ := μ) (p := (2 : ENNReal)) - (by norm_num : (2 : ENNReal) ≠ 0) (by norm_num : (2 : ENNReal) ≠ ⊤) - norm_num at h - have h' := congrArg ENNReal.toReal h - rw [ENNReal.toReal_ofReal (by positivity), - MeasureTheory.toReal_eLpNorm] at h' - simpa only [Real.rpow_ofNat, sq_abs, one_div, Real.norm_eq_abs] using h'.symm - have hg_lp : - (∫ x, |g x| ^ (2 : ℝ) ∂μ) ^ (1 / (2 : ℝ)) = - MeasureTheory.lpNorm g 2 μ := by - have h := hg.eLpNorm_eq_integral_rpow_norm (μ := μ) (p := (2 : ENNReal)) - (by norm_num : (2 : ENNReal) ≠ 0) (by norm_num : (2 : ENNReal) ≠ ⊤) - norm_num at h - have h' := congrArg ENNReal.toReal h - rw [ENNReal.toReal_ofReal (by positivity), - MeasureTheory.toReal_eLpNorm] at h' - simpa only [Real.rpow_ofNat, sq_abs, one_div, Real.norm_eq_abs] using h'.symm - have hleft : - ∫ x, ‖f x * g x‖ ∂μ = ∫ x, |f x| * |g x| ∂μ := by - refine integral_congr_ae ?_ - filter_upwards with x - simp [Real.norm_eq_abs] - rw [hleft] - rw [hf_lp, hg_lp] at hholder - exact hholder + change (eLpNorm (fun x => f x * g x) 1 μ).toReal ≤ + (eLpNorm f 2 μ).toReal * (eLpNorm g 2 μ).toReal + rw [← ENNReal.toReal_mul] + exact ENNReal.toReal_mono (ENNReal.mul_ne_top hf.eLpNorm_ne_top hg.eLpNorm_ne_top) + (eLpNorm_smul_le_mul_eLpNorm hf.aestronglyMeasurable hg.aestronglyMeasurable) + +private theorem lpNorm_norm_sq_sub_le + {α : Type*} [MeasurableSpace α] {μ : Measure α} {F G : α → ℂ} + (hF : MemLp F 2 μ) (hG : MemLp G 2 μ) : + lpNorm (fun x => ((‖F x‖ ^ 2 : ℝ) : ℂ) - ((‖G x‖ ^ 2 : ℝ) : ℂ)) 1 μ ≤ + (lpNorm F 2 μ + lpNorm G 2 μ) * lpNorm (fun x => F x - G x) 2 μ := by + let A : α → ℝ := fun x => ‖F x‖ + ‖G x‖ + let B : α → ℝ := fun x => ‖F x - G x‖ + have hA : MemLp A 2 μ := hF.norm.add hG.norm + have hB : MemLp B 2 μ := (hF.sub hG).norm + have hproduct : MemLp (fun x => A x * B x) 1 μ := hA.mul hB + have hpoint : ∀ x, + ‖((‖F x‖ ^ 2 : ℝ) : ℂ) - ((‖G x‖ ^ 2 : ℝ) : ℂ)‖ ≤ A x * B x := by + intro x + have hnonnegative : 0 ≤ ‖F x‖ + ‖G x‖ := add_nonneg (norm_nonneg _) (norm_nonneg _) + rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs, sq_sub_sq, + abs_mul, abs_of_nonneg hnonnegative] + exact mul_le_mul_of_nonneg_left (abs_norm_sub_norm_le _ _) hnonnegative + have hsum : lpNorm A 2 μ ≤ lpNorm F 2 μ + lpNorm G 2 μ := by + calc + _ ≤ lpNorm (fun x => ‖F x‖) 2 μ + lpNorm (fun x => ‖G x‖) 2 μ := + lpNorm_add_le hF.norm (by norm_num) + _ = _ := by rw [lpNorm_norm hF.aestronglyMeasurable, lpNorm_norm hG.aestronglyMeasurable] + have hnorm : lpNorm B 2 μ = lpNorm (fun x => F x - G x) 2 μ := + lpNorm_norm (hF.sub hG).aestronglyMeasurable 2 + calc + _ ≤ lpNorm (fun x => A x * B x) 1 μ := lpNorm_mono_real hproduct hpoint + _ ≤ lpNorm A 2 μ * lpNorm B 2 μ := lpNorm_mul_le_real hA hB + _ ≤ (lpNorm F 2 μ + lpNorm G 2 μ) * lpNorm (fun x => F x - G x) 2 μ := by + rw [hnorm] + exact mul_le_mul_of_nonneg_right hsum lpNorm_nonneg --- This is the Hölder/square-difference estimate over phase space; the proof is copied --- from the one-dimensional STFT route but with vector-valued `L2Real` approximants. private theorem lpNorm_stftRep_sq_sub_tendsto_zero {d : Nat} (h f : L2Real d) : Tendsto @@ -2947,10 +2941,6 @@ private theorem lpNorm_stftRep_sq_sub_tendsto_zero {d : Nat} (schwartzApproxRealVec (MeasureTheory.Lp.memLp f) n).toLp 2 μ let F : PhaseSpace d → ℂ := stftRep h f let Fₙ : Nat → PhaseSpace d → ℂ := fun n => stftRep (hN n) (fN n) - let Dₙ : Nat → PhaseSpace d → ℂ := fun n ξ => - (((‖Fₙ n ξ‖ ^ 2 : ℝ) : ℂ) - ((‖F ξ‖ ^ 2 : ℝ) : ℂ)) - let Aₙ : Nat → PhaseSpace d → ℝ := fun n ξ => ‖Fₙ n ξ‖ + ‖F ξ‖ - let Bₙ : Nat → PhaseSpace d → ℝ := fun n ξ => ‖Fₙ n ξ - F ξ‖ let Cₙ : Nat → ℝ := fun n => ‖fN n‖ * ‖hN n‖ + ‖f‖ * ‖h‖ have hhN : Tendsto hN atTop (nhds h) := by exact schwartzApproxRealVec_toLp_tendsto h @@ -2973,70 +2963,12 @@ private theorem lpNorm_stftRep_sq_sub_tendsto_zero {d : Nat} atTop (nhds 0) := by simpa only [mul_zero] using hC_tendsto.mul hdiff refine squeeze_zero (fun _ => MeasureTheory.lpNorm_nonneg) ?_ hCtendsto intro n - have hmemFn : MeasureTheory.MemLp (Fₙ n) 2 μP := by - dsimp [Fₙ] - exact stftRep_memLp (hN n) (fN n) - have hmemF : MeasureTheory.MemLp F 2 μP := by - dsimp [F] - exact stftRep_memLp h f - have hmemDiff : MeasureTheory.MemLp (fun ξ : PhaseSpace d => Fₙ n ξ - F ξ) 2 μP := - hmemFn.sub hmemF - have hAmem : MeasureTheory.MemLp (Aₙ n) 2 μP := by - dsimp [Aₙ] - exact hmemFn.norm.add hmemF.norm - have hBmem : MeasureTheory.MemLp (Bₙ n) 2 μP := by - dsimp [Bₙ] - exact hmemDiff.norm - have hHmem : MeasureTheory.MemLp (fun ξ : PhaseSpace d => Aₙ n ξ * Bₙ n ξ) 1 μP := by - refine MeasureTheory.MemLp.ae_eq ?_ (hBmem.mul hAmem) - filter_upwards with ξ - simp [Pi.mul_apply, mul_comm] - have hpoint : ∀ ξ : PhaseSpace d, ‖Dₙ n ξ‖ ≤ Aₙ n ξ * Bₙ n ξ := by - intro ξ - have hsum_nonneg : 0 ≤ ‖Fₙ n ξ‖ + ‖F ξ‖ := by positivity - calc - ‖Dₙ n ξ‖ = - ‖(((‖Fₙ n ξ‖ ^ 2 : ℝ) : ℂ) - ((‖F ξ‖ ^ 2 : ℝ) : ℂ))‖ := by rfl - _ = |‖Fₙ n ξ‖ ^ 2 - ‖F ξ‖ ^ 2| := by - rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] - _ = (‖Fₙ n ξ‖ + ‖F ξ‖) * |‖Fₙ n ξ‖ - ‖F ξ‖| := by - rw [sq_sub_sq, abs_mul, abs_of_nonneg hsum_nonneg] - _ ≤ (‖Fₙ n ξ‖ + ‖F ξ‖) * ‖Fₙ n ξ - F ξ‖ := - mul_le_mul_of_nonneg_left (abs_norm_sub_norm_le _ _) hsum_nonneg - _ = Aₙ n ξ * Bₙ n ξ := by simp [Aₙ, Bₙ] - have hD_le : - MeasureTheory.lpNorm (Dₙ n) 1 μP ≤ - MeasureTheory.lpNorm (fun ξ : PhaseSpace d => Aₙ n ξ * Bₙ n ξ) 1 μP := - MeasureTheory.lpNorm_mono_real hHmem hpoint - have hAB_le : - MeasureTheory.lpNorm (fun ξ : PhaseSpace d => Aₙ n ξ * Bₙ n ξ) 1 μP ≤ - MeasureTheory.lpNorm (Aₙ n) 2 μP * MeasureTheory.lpNorm (Bₙ n) 2 μP := - lpNorm_mul_le_real hAmem hBmem - have hA_le : MeasureTheory.lpNorm (Aₙ n) 2 μP ≤ Cₙ n := by - calc - MeasureTheory.lpNorm (Aₙ n) 2 μP - ≤ MeasureTheory.lpNorm (fun ξ : PhaseSpace d => ‖Fₙ n ξ‖) 2 μP + - MeasureTheory.lpNorm (fun ξ : PhaseSpace d => ‖F ξ‖) 2 μP := by - dsimp [Aₙ] - exact - MeasureTheory.lpNorm_add_le hmemFn.norm - (g := fun ξ : PhaseSpace d => ‖F ξ‖) (by norm_num) - _ = MeasureTheory.lpNorm (Fₙ n) 2 μP + MeasureTheory.lpNorm F 2 μP := by - simp [MeasureTheory.lpNorm_norm, hmemFn.aestronglyMeasurable, - hmemF.aestronglyMeasurable] - _ ≤ ‖fN n‖ * ‖hN n‖ + ‖f‖ * ‖h‖ := by - gcongr - · exact lpNorm_stftRep_le (hN n) (fN n) - · exact lpNorm_stftRep_le h f - calc - MeasureTheory.lpNorm (Dₙ n) 1 μP - ≤ MeasureTheory.lpNorm (fun ξ : PhaseSpace d => Aₙ n ξ * Bₙ n ξ) 1 μP := hD_le - _ ≤ MeasureTheory.lpNorm (Aₙ n) 2 μP * MeasureTheory.lpNorm (Bₙ n) 2 μP := hAB_le - _ ≤ Cₙ n * MeasureTheory.lpNorm (fun ξ : PhaseSpace d => Fₙ n ξ - F ξ) 2 μP := by - rw [show MeasureTheory.lpNorm (Bₙ n) 2 μP = - MeasureTheory.lpNorm (fun ξ : PhaseSpace d => Fₙ n ξ - F ξ) 2 μP by - simp [Bₙ, MeasureTheory.lpNorm_norm, hmemDiff.aestronglyMeasurable]] - exact mul_le_mul_of_nonneg_right hA_le MeasureTheory.lpNorm_nonneg + have hmemFn : MemLp (Fₙ n) 2 μP := stftRep_memLp (hN n) (fN n) + have hmemF : MemLp F 2 μP := stftRep_memLp h f + have hsum : lpNorm (Fₙ n) 2 μP + lpNorm F 2 μP ≤ Cₙ n := + add_le_add (lpNorm_stftRep_le (hN n) (fN n)) (lpNorm_stftRep_le h f) + exact (lpNorm_norm_sq_sub_le hmemFn hmemF).trans + (mul_le_mul_of_nonneg_right hsum lpNorm_nonneg) private theorem norm_ambiguityRep_sub_le {d : Nat} (f₁ f₂ g₁ g₂ : L2Real d) (ξ : PhaseSpace d) : @@ -3066,20 +2998,9 @@ private theorem norm_ambiguityRep_sub_le {d : Nat} rw [ambiguityRep_eq_lpPairing f₁ g₁ ξ, ambiguityRep_eq_lpPairing f₂ g₂ ξ] change ‖P (T₁ f₁) (T₂ g₁) - P (T₁ f₂) (T₂ g₂)‖ ≤ ‖f₁ - f₂‖ * ‖g₁‖ + ‖f₂‖ * ‖g₁ - g₂‖ - have hsplit : - P (T₁ f₁) (T₂ g₁) - P (T₁ f₂) (T₂ g₂) = - P (T₁ f₁ - T₁ f₂) (T₂ g₁) + P (T₁ f₂) (T₂ g₁ - T₂ g₂) := by simp [P] - calc - ‖P (T₁ f₁) (T₂ g₁) - P (T₁ f₂) (T₂ g₂)‖ - = ‖P (T₁ f₁ - T₁ f₂) (T₂ g₁) + P (T₁ f₂) (T₂ g₁ - T₂ g₂)‖ := by rw [hsplit] - _ ≤ ‖P (T₁ f₁ - T₁ f₂) (T₂ g₁)‖ + - ‖P (T₁ f₂) (T₂ g₁ - T₂ g₂)‖ := norm_add_le _ _ - _ ≤ ‖T₁ f₁ - T₁ f₂‖ * ‖T₂ g₁‖ + - ‖T₁ f₂‖ * ‖T₂ g₁ - T₂ g₂‖ := by - exact add_le_add (lpPairing_mul_norm_le (T₁ f₁ - T₁ f₂) (T₂ g₁)) - (lpPairing_mul_norm_le (T₁ f₂) (T₂ g₁ - T₂ g₂)) - _ = ‖f₁ - f₂‖ * ‖g₁‖ + ‖f₂‖ * ‖g₁ - g₂‖ := by - rw [hT₁_sub_norm, hT₂_norm, hT₁_norm, hT₂_sub_norm] + simpa only [hT₁_sub_norm, hT₂_norm, hT₁_norm, hT₂_sub_norm] using + norm_bilinear_sub_le P (fun f g => lpPairing_mul_norm_le f g) + (T₁ f₁) (T₁ f₂) (T₂ g₁) (T₂ g₂) private theorem ambiguityRep_tendsto_schwartzApprox {d : Nat} (f : L2Real d) (ξ : PhaseSpace d) : diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalCoercivity.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalCoercivity.lean index 0f7e835853..bc9fc7dd85 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalCoercivity.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalCoercivity.lean @@ -91,7 +91,7 @@ private theorem norm_ne_zero_of_ne_zero_pkappa_wip · have hcoeff_ne : F alpha ≠ 0 := Finsupp.mem_support_iff.mp hmem have hle : ‖F alpha‖ ^ 2 ≤ Finset.sum F.support (fun a : Idx d => ‖F a‖ ^ 2) := by - simpa using + exact (Finset.single_le_sum (f := fun a : Idx d => ‖F a‖ ^ 2) (s := F.support) (a := alpha) (fun a _ => by positivity) hmem) have hterm_pos : 0 < ‖F alpha‖ ^ 2 := pow_pos (norm_pos_iff.mpr hcoeff_ne) 2 @@ -101,7 +101,7 @@ private theorem norm_ne_zero_of_ne_zero_pkappa_wip have hsqrt_pos : 0 < Real.sqrt (Finset.sum F.support (fun a : Idx d => ‖F a‖ ^ 2) ) := Real.sqrt_pos.mpr hsum_pos - linarith + linarith only [hnorm, hsqrt_pos] · exact Finsupp.notMem_support_iff.mp hmem private theorem norm_smul_pkappa_wip @@ -311,7 +311,7 @@ private lemma integrable_evalPkappa_cross_wip intro alpha halpha refine MeasureTheory.integrable_finsetSum _ ?_ intro beta hbeta - simpa [mul_assoc] using + exact (integrable_productBasis_cross_wip kappa alpha beta).const_mul (F alpha * (starRingEnd ℂ) (G beta)) @@ -407,7 +407,7 @@ private theorem memLp_two_defectFunctionPkappa_wip unfold defectFunctionPkappa_wip have : (‖evalPkappa kappa (F + G) z‖ - ‖evalPkappa kappa F z‖) ^ 2 ≤ 2 * ‖evalPkappa kappa (F + G) z‖ ^ 2 + 2 * ‖evalPkappa kappa F z‖ ^ 2 := by - nlinarith [sq_nonneg (‖evalPkappa kappa (F + G) z‖ + ‖evalPkappa kappa F z‖)] + linarith only [sq_nonneg (‖evalPkappa kappa (F + G) z‖ + ‖evalPkappa kappa F z‖)] simpa [sq_abs] using this simp_all simpa [Real.norm_eq_abs, abs_of_nonneg] using @@ -446,7 +446,7 @@ private lemma evalPkappa_pointwise_bound_wip ‖evalPkappa kappa G z‖ = ‖evalPkappa kappa (F + G) z - evalPkappa kappa F z‖ := by rw [hsub] _ ≤ ‖evalPkappa kappa (F + G) z‖ + ‖evalPkappa kappa F z‖ := norm_sub_le _ _ _ ≤ defectFunctionPkappa_wip kappa F G z + ‖evalPkappa kappa F z‖ + ‖evalPkappa kappa F z‖ := by - linarith + linarith only [haux] _ = defectFunctionPkappa_wip kappa F G z + 2 * ‖evalPkappa kappa F z‖ := by ring private theorem norm_le_defect_add_two_wip @@ -576,10 +576,10 @@ theorem orthogonal_coercivity have hpartition := annulusMassPartition hd kappa J H have hsum_le : lowAnnulusMass J (ofPkappa kappa H) + highAnnulusMass J (ofPkappa kappa H) ≤ 1 / 2 := by - linarith + linarith only [hhigh_mass, hlow_mass] have hnorm_sq : ‖H‖ ^ 2 = 1 := by simp_all - linarith + linarith only [hhigh_mass, hlow_mass, hpartition, hnorm_sq] · have hdelta_inv_le : delta⁻¹ ≤ C_F_perp := by dsimp [C_F_perp] exact le_max_right _ _ @@ -596,7 +596,7 @@ theorem orthogonal_coercivity mul_le_mul_of_nonneg_right hdelta_inv_le (defect_nonneg_wip hd F G) · have hge4 : 4 ≤ t := le_of_not_gt hlt4 have htwo_defect : t ≤ 2 * defectPk kappa F G := by - nlinarith [defect_nonneg_wip hd F G] + linarith only [hlarge_bridge, hlt4, defect_nonneg_wip hd F G] have htwo_le_C : 2 ≤ C_F_perp := by dsimp [C_F_perp] exact le_max_left _ _ diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalReduction/OrthogonalReduction.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalReduction/OrthogonalReduction.lean index 925a8e52a3..08c432312f 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalReduction/OrthogonalReduction.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/OrthogonalReduction/OrthogonalReduction.lean @@ -68,7 +68,7 @@ private lemma lpNorm_norm_l2 (F : MeasureTheory.Lp ℂ 2 μ) : omit [SigmaFinite μ] in private lemma memLp_norm_l2 (F : MeasureTheory.Lp ℂ 2 μ) : MeasureTheory.MemLp (fun x : Ω => ‖(F : Ω → ℂ) x‖) 2 μ := by - simpa using (MeasureTheory.Lp.memLp F).norm + exact (MeasureTheory.Lp.memLp F).norm private lemma abs_norm_sq_sub_norm_sq_le {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (x y : E) : @@ -76,7 +76,7 @@ private lemma abs_norm_sq_sub_norm_sq_le {E : Type*} [NormedAddCommGroup E] have hident : ‖x‖ ^ 2 - ‖y‖ ^ 2 = inner ℝ (x - y) (x + y) := by simp [inner_sub_left, inner_add_right, real_inner_comm] rw [hident] - simpa using norm_inner_le_norm (𝕜 := ℝ) (x - y) (x + y) + exact norm_inner_le_norm (𝕜 := ℝ) (x - y) (x + y) omit [CompleteSpace H] [SigmaFinite μ] in private lemma compare_pointwise_ae diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/PhaseStability.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/PhaseStability.lean index 1c90012ea9..0847efa6f4 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/PhaseStability.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/PhaseStability.lean @@ -297,12 +297,11 @@ private theorem phase_alignment have hcomp_sq : ‖((phase * β - 1 : ℂ) • f0)‖ * ‖((phase * β - 1 : ℂ) • f0)‖ ≤ ‖a • f0‖ * ‖a • f0‖ := by - nlinarith [hcomp, norm_nonneg (((phase * β - 1 : ℂ) • f0)), - norm_nonneg (a • f0)] - linarith + nlinarith only [hcomp, norm_nonneg (((phase * β - 1 : ℂ) • f0)), norm_nonneg (a • f0)] + linarith only [hcomp_sq] constructor · exact himag - · nlinarith [hnorm_sq_le, norm_nonneg (phase • (f0 + u) - f0), norm_nonneg u] + · nlinarith only [hnorm_sq_le, norm_nonneg (phase • (f0 + u) - f0), norm_nonneg u] /-- Local stability after only fixing the real phase gauge. @@ -374,7 +373,7 @@ theorem realGaugeLocalStability have hnorm : ‖h‖ = ‖H‖ := by change ‖(h : L2Tensor d)‖ = ‖H‖ simp [h, evalPkappaL2_norm hd kappa H] - linarith + linarith only [hHδ, hnorm] have him_h : (inner ℂ h f0).im = 0 := by have hstar_im : (star (pkappaInner H F)).im = 0 := by simp_all diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/ProductAnnulusLocalization.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/ProductAnnulusLocalization.lean index 7c6424031d..45ce2728b9 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/ProductAnnulusLocalization.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/ProductAnnulusLocalization.lean @@ -64,7 +64,7 @@ private theorem norm_ne_zero_of_ne_zero_pkappa_wip · have hcoeff_ne : F alpha ≠ 0 := Finsupp.mem_support_iff.mp hmem have hle : ‖F alpha‖ ^ 2 ≤ Finset.sum F.support (fun a : Idx d => ‖F a‖ ^ 2) := by - simpa using + exact (Finset.single_le_sum (f := fun a : Idx d => ‖F a‖ ^ 2) (s := F.support) (a := alpha) (fun a _ => by positivity) hmem) have hterm_pos : 0 < ‖F alpha‖ ^ 2 := pow_pos (norm_pos_iff.mpr hcoeff_ne) 2 @@ -74,7 +74,7 @@ private theorem norm_ne_zero_of_ne_zero_pkappa_wip have hsqrt_pos : 0 < Real.sqrt (Finset.sum F.support (fun a : Idx d => ‖F a‖ ^ 2)) := Real.sqrt_pos.mpr hsum_pos - linarith + linarith only [hnorm, hsqrt_pos] · exact Finsupp.notMem_support_iff.mp hmem private lemma continuous_Phi_wip @@ -607,7 +607,7 @@ theorem lowAnnulusProjection finite_sum_annulusMass_le_wip hd kappa Hnear (lowAnnuli d J) _ = Finset.sum E (fun alpha => ‖coeffPkappa H alpha‖ ^ 2) := hnear_norm_sq _ ≤ rho := hcoeff_small - have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith [hH_norm] + have hH_sq : ‖H‖ ^ 2 = 1 := by nlinarith only [hH_norm] have hfar_norm_sq_le_one : ‖Hfar‖ ^ 2 ≤ 1 := by calc ‖Hfar‖ ^ 2 ≤ ‖H‖ ^ 2 := by simpa [Hfar, Hnear] using norm_sq_farPart_le_wip kappa E H @@ -663,14 +663,14 @@ theorem lowAnnulusProjection _ = Hermite1DimdLEAN.localizationLeakageCoefficient C c B d M * ‖Hfar‖ ^ 2 := by rw [hermiteNormSq_eq_norm_sq_wip kappa Hfar] _ ≤ Hermite1DimdLEAN.localizationLeakageCoefficient C c B d M := by - nlinarith [hloc_nonneg, hfar_norm_sq_nonneg, hfar_norm_sq_le_one] + nlinarith only [hfar_norm_sq_le_one, hloc_nonneg, hfar_norm_sq_nonneg] _ ≤ rho := hloc_small calc lowAnnulusMass J (ofPkappa kappa H) ≤ 2 * lowAnnulusMass J (ofPkappa kappa Hnear) + 2 * lowAnnulusMass J (ofPkappa kappa Hfar) := by simpa [hdecomp] using lowAnnulusMass_add_le_two_wip hd kappa J Hnear Hfar - _ ≤ 2 * rho + 2 * rho := by nlinarith [hnear_low, hfar_low] + _ ≤ 2 * rho + 2 * rho := by linarith only [hnear_low, hfar_low] _ = 1 / 4 := by norm_num [rho] end DimdPolyLEAN diff --git a/LeanPool/PhaseRetrieval/DimdPoly/Internal/TensorBasis.lean b/LeanPool/PhaseRetrieval/DimdPoly/Internal/TensorBasis.lean index c38cdb32f8..8e9897b347 100644 --- a/LeanPool/PhaseRetrieval/DimdPoly/Internal/TensorBasis.lean +++ b/LeanPool/PhaseRetrieval/DimdPoly/Internal/TensorBasis.lean @@ -298,11 +298,11 @@ theorem evalPkappa_rotateCoord_circle_phase_sum = F alpha * ((fourier ((kappa q0 : Nat) : Int) x : ℂ) * Phi kappa alpha - (Function.update z q0 ((fourier (1 : Int) x : ℂ) * z q0))) := by ring_nf + (Function.update z q0 ((fourier (1 : Int) x : ℂ) * z q0))) := by ring _ = F alpha * ((fourier ((alpha q0 : Nat) : Int) x : ℂ) * Phi kappa alpha z) := by rw [hphase] _ = F alpha * Phi kappa alpha z * circleChar (alpha q0) x := by rw [hchar] - ring_nf + ring private theorem evalPkappa_eq_evalHermiteSum {d : Nat} (kappa : MultiIndex d) (F : Pkappa d kappa) : @@ -397,8 +397,10 @@ private theorem summable_sq_hermite_phi_eval have hSle : S <= C ^ 2 := by have hev' : ‖HermitekLEAN.finiteHermiteSum k a' z‖ <= C * Real.sqrt S := by simpa [hWN] using hev - nlinarith [Real.sq_sqrt hS_nonneg, sq_nonneg (Real.sqrt S - C), hFz_bound, - hev', hC_nonneg] + linarith only [ + hS_nonneg, hFz_bound, hev', Real.sq_sqrt hS_nonneg, sq_nonneg (Real.sqrt S - C), + hC_nonneg + ] calc Finset.sum (Finset.range J) (fun n => ‖HermitekLEAN.Phi k n z‖ ^ 2) = S := (Fin.sum_univ_eq_sum_range (fun n : Nat => ‖HermitekLEAN.Phi k n z‖ ^ 2) J).symm @@ -475,7 +477,7 @@ theorem summable_skappa_eval_mul_of_phi_sq (hPhi : Summable (fun alpha : Idx d => ‖Phi kappa alpha z‖ ^ 2)) : Summable (fun alpha : Idx d => coeffSkappa U alpha * Phi kappa alpha z) := by have hU : Summable (fun alpha : Idx d => ‖coeffSkappa U alpha‖ ^ 2) := by - simpa [coeffSkappa] using U.summable_norm_sq + exact U.summable_norm_sq refine Summable.of_norm_bounded (g := fun alpha : Idx d => (‖coeffSkappa U alpha‖ ^ 2 + ‖Phi kappa alpha z‖ ^ 2) / 2) @@ -488,7 +490,7 @@ theorem summable_skappa_eval_mul_of_phi_sq have hsq : ‖coeffSkappa U alpha‖ * ‖Phi kappa alpha z‖ <= (‖coeffSkappa U alpha‖ ^ 2 + ‖Phi kappa alpha z‖ ^ 2) / 2 := by - nlinarith [sq_nonneg (‖coeffSkappa U alpha‖ - ‖Phi kappa alpha z‖)] + nlinarith only [sq_nonneg (‖coeffSkappa U alpha‖ - ‖Phi kappa alpha z‖)] exact le_trans hmul hsq theorem summable_skappa_eval_mul @@ -668,7 +670,7 @@ theorem integrable_evalPkappa_sq change (Real.sqrt (Finset.sum F.support (fun beta => ‖F beta‖ ^ 2))) = 0 at hnorm have hsum_zero : Finset.sum F.support (fun beta => ‖F beta‖ ^ 2) = 0 := (Real.sqrt_eq_zero (by positivity)).mp hnorm - nlinarith + linarith only [hterm_pos, hle, hsum_zero] simp_all theorem memLp_two_evalPkappa @@ -796,8 +798,8 @@ theorem summable_PhiL2_coeff_smul let hOrthonormal := PhiL2_orthonormal_family hd kappa have hOrthogonalFamily := hOrthonormal.orthogonalFamily have hcoeff : Summable (fun alpha : Idx d => ‖coeffSkappa U alpha‖ ^ 2) := by - simpa [coeffSkappa] using U.summable_norm_sq - simpa using + exact U.summable_norm_sq + exact (hOrthogonalFamily.summable_iff_norm_sq_summable (fun alpha : Idx d => coeffSkappa U alpha)).2 hcoeff @@ -813,7 +815,7 @@ theorem evalPkappaL2_truncateFinset | insert alpha E hnot hE => have hE' : evalPkappaL2 kappa (∑ beta ∈ E, Finsupp.single beta (coeffSkappa U beta)) = - ∑ beta ∈ E, coeffSkappa U beta • PhiL2 kappa beta := by simpa [truncateFinset] using hE + ∑ beta ∈ E, coeffSkappa U beta • PhiL2 kappa beta := by exact hE simp [truncateFinset, Finset.sum_insert hnot, evalPkappaL2_add hd kappa, evalPkappaL2_single hd kappa, hE'] @@ -844,7 +846,7 @@ theorem evalPkappa_truncateFinset Finsupp.sum (∑ beta ∈ E, Finsupp.single beta (coeffSkappa U beta)) (fun beta c => c * Phi kappa beta z) = ∑ beta ∈ E, coeffSkappa U beta * Phi kappa beta z := by - simpa [truncateFinset, evalPkappa] using congrFun hE z + exact congrFun hE z rw [show truncateFinset (insert alpha E) U = Finsupp.single alpha (coeffSkappa U alpha) + (∑ beta ∈ E, Finsupp.single beta (coeffSkappa U beta)) by @@ -905,7 +907,7 @@ private lemma summable_nat_pow_mul_pow_div_factorial_nonneg calc ((n + m + 1 : ℝ) ^ m) ≤ (((m + 1 : ℝ) * (n + 1)) ^ m) := by gcongr - nlinarith + nlinarith only [] _ = (m + 1 : ℝ) ^ m * (n + 1 : ℝ) ^ m := by rw [mul_pow] _ ≤ (m + 1 : ℝ) ^ m * (((n + m).descFactorial m : ℕ) : ℝ) := by gcongr have hfact : @@ -1181,7 +1183,7 @@ private theorem uniformCauchySeqOn_of_summable_bound _ = dist (partialSum kappa U J z) (partialSum kappa U J0 z) + dist (partialSum kappa U L z) (partialSum kappa U J0 z) := by rw [dist_comm (partialSum kappa U J0 z) (partialSum kappa U L z)] - _ < ε := by linarith + _ < ε := by linarith only [hJtail, hLtail] private lemma compact_exists_coord_bound {d : Nat} {K : Set (Cd d)} (hK : IsCompact K) : @@ -1209,14 +1211,14 @@ private lemma partialSum_uniformCauchy_on_compact exact Finset.prod_nonneg fun q _ => phiMajorant_nonneg hR_nonneg have hM_summable : Summable M := by have hcoeff : Summable (fun alpha : Idx d => ‖coeffSkappa U alpha‖ ^ 2) := by - simpa [coeffSkappa] using U.summable_norm_sq + exact U.summable_norm_sq have hBsq : Summable (fun alpha : Idx d => Bprod alpha ^ 2) := by - simpa [Bprod] using phiMajorant_multi_sq_summable kappa hR + exact phiMajorant_multi_sq_summable kappa hR refine Summable.of_nonneg_of_le (fun alpha => ?_) ?_ ((hcoeff.add hBsq).div_const 2) · exact mul_nonneg (norm_nonneg _) (hBprod_nonneg alpha) · intro alpha dsimp [M] - nlinarith [sq_nonneg (‖coeffSkappa U alpha‖ - Bprod alpha)] + nlinarith only [sq_nonneg (‖coeffSkappa U alpha‖ - Bprod alpha)] refine uniformCauchySeqOn_of_summable_bound kappa U hM_summable ?_ intro alpha z hzK have hPhi : ‖Phi kappa alpha z‖ ≤ Bprod alpha := by