Skip to main content
AlexKontorovich/PrimeNumberTheoremAnd
Source indexedtheorem · leanprover/lean4:v4.32.0

FKS2.Table4Ext.checkXpowCell_sound

PrimeNumberTheoremAnd.IEANTN.FKS2Cor24Row11 · PrimeNumberTheoremAnd/IEANTN/FKS2Cor24Row11.lean:122 to 167

Source documentation

Soundness: a checked cell obeys eps ≤ exp(-b'/n).

Exact Lean statement

theorem checkXpowCell_sound (n : ℕ) (hn : 0 < n) (c : Cell)
    (hc : checkXpowCell n c = true) :
    (c.eps : ℝ) ≤ Real.exp (-(c.b' : ℝ) / n)

Complete declaration

Lean source

Canonical source
Full Lean sourceLean 4
theorem checkXpowCell_sound (n : ) (hn : 0 < n) (c : Cell)    (hc : checkXpowCell n c = true) :    (c.eps : )  Real.exp (-(c.b' : ) / n) := by  have hnpos : (0 : ) < (n : ) := by exact_mod_cast hn  unfold checkXpowCell at hc  split at hc  case isFalse => simp at hc  case isTrue hle =>    simp only [Bool.and_eq_true, decide_eq_true_eq] at hc    obtain ⟨⟨⟨⟨heps, _hslo0, _hslo, hshi, hcheck := hc    -- semantic slab inequality: exp(s²/n) ≤ 1/eps on [slo, shi]    have hslab := verify_expr_le_on_interval_dyadic (expSplitXpow n)      (Expr.const (1 / c.eps)) c.slo, c.shi, hle (-50) 8      (expSplitXpow_supported _ _) (by norm_num) hcheck    -- instantiate at s = shi (the right endpoint, where exp(s²/n) is largest)    have hshi_mem : (c.shi : )  Set.Icc ((c.slo : )) ((c.shi : )) :=      by exact_mod_cast hle, le_refl _    have hineq := hslab (c.shi : ) hshi_mem    rw [eval_expSplitXpow, Expr.eval_const] at hineq    -- (exp ((1/64n)·shi²))^64 = exp(shi²/n)    have hn' : (n : )  0 := ne_of_gt hnpos    have harg : ((64 : ) : ) * ((xpowCoef n : ) * ((c.shi : ) * (c.shi : )))        = ((c.shi : ) * (c.shi : )) / n := by      simp only [xpowCoef]; push_cast; field_simp    have hexp64 :        exp ((xpowCoef n : ) * ((c.shi : ) * (c.shi : ))) ^ (64 : )          = exp (((c.shi : ) * (c.shi : )) / n) := by      rw [ Real.exp_nat_mul, harg]    rw [hexp64] at hineq    -- 1/eps on the RHS as a real reciprocal    have hrhs : ((1 / c.eps : ) : ) = 1 / (c.eps : ) := by push_cast; ring    rw [hrhs] at hineq    -- positivity facts and the b' ≤ shi² side condition    have hepsR : (0 : ) < (c.eps : ) := by exact_mod_cast heps    have hbshi : (c.b' : )  (c.shi : ) * (c.shi : ) := by exact_mod_cast hshi    have hexppos : (0 : ) < exp ((c.b' : ) / n) := Real.exp_pos _    -- exp(b'/n) ≤ exp(shi²/n) ≤ 1/eps    have hmono2 : exp ((c.b' : ) / n)  exp (((c.shi : ) * (c.shi : )) / n) := by      apply Real.exp_le_exp.mpr      gcongr    have hchain : exp ((c.b' : ) / n)  1 / (c.eps : ) := le_trans hmono2 hineq    -- eps ≤ exp(-b'/n)    rw [neg_div, Real.exp_neg,  one_div, le_div_iff₀ hexppos]    have hmul : exp ((c.b' : ) / n) * (c.eps : )  1 :=      (le_div_iff₀ hepsR).mp hchain    linarith [hmul]