← Session 18 — Lean tier (ii): finite-height proof + certified base points
thinking (11610 chars)
All confirmed: `Real.exp_one_gt_d9 : 2.7182818283 < exp 1`, `Real.exp_one_lt_d9 : exp 1 < 2.7182818286`, `Real.sum_le_exp_of_nonneg` ✓.
First add the two public IIMaj lemmas to LiSkeleton.lean (IIMaj bounds), then write LiBasePoints.lean.
For IIMaj bounds in LiSkeleton — insert after IIMaj_eq_psiTilde_sqrt:
```
/-- [PROVED session 012] Crude global upper bound on the I_I majorant:
IIMaj n ≤ 4.56·(√n+1)·2 for n ≥ 0 (both exponentials ≤ 1). Used by the
base-point numerics; the slack is absorbed by the margin. -/
theorem IIMaj_le_two_mul (n : ℝ) (hn : 0 ≤ n) :
IIMaj n ≤ 4.56 * (Real.sqrt n + 1) * 2 := by
rw [IIMaj_eq_psiTilde_sqrt]
unfold psiTilde
have hlog2 := Real.log_two_gt_d9
have ha : (0 : ℝ) < iimA := by unfold iimA; linarith
have hb : (0 : ℝ) < iimB := by unfold iimB; linarith
have hs : (0 : ℝ) ≤ Real.sqrt n := Real.sqrt_nonneg n
have heA : Real.exp (-iimA * Real.sqrt n) ≤ 1 := by
rw [Real.exp_le_one_iff]
exact mul_nonpos_of_nonpos_of_nonneg (by linarith) hs
...
```
wait: −iimA·s ≤ 0: −iimA ≤ 0 and s ≥ 0: mul_nonpos_of_nonpos_of_nonneg (show -iimA ≤ 0 by linarith) hs — (−iimA)·s where the term is −iimA * s = (−iimA)·s ✓. Then:
```
have heB : Real.exp (-iimB * Real.sqrt n) ≤ 1 := ...
have hpos : (0:ℝ) ≤ Real.sqrt n + 1 := by positivity — positivity needs 0 ≤ sqrt: hs; linarith
calc 4.56 * ((Real.sqrt n + 1) * (Real.exp (-iimA * Real.sqrt n) + Real.exp (-iimB * Real.sqrt n)))
≤ 4.56 * ((Real.sqrt n + 1) * (1 + 1)) := by
apply mul_le_mul_of_nonneg_left _ (by norm_num : (0:ℝ) ≤ 4.56)
apply mul_le_mul_of_nonneg_left _ hpos1 -- 0 ≤ s+1
linarith [heA, heB] -- e^{-as}+e^{-bs} ≤ 1+1: add_le_add
_ = 4.56 * (Real.sqrt n + 1) * 2 := by ring
```
add_le_add heA heB : e^{-as} + e^{-bs} ≤ 1 + 1 ✓.
```
/-- [PROVED session 012] IIMaj is nonnegative. -/
theorem IIMaj_nonneg (n : ℝ) : 0 ≤ IIMaj n := by
unfold IIMaj
have h1 : (0:ℝ) ≤ (2:ℝ) ^ (-(2 * Real.sqrt n - 2)) := Real.rpow_nonneg (by norm_num) _
positivity? — with h1: 2*(√n+1)*(exp(√n/2)+1)*0.57*2^(...): all nonneg: mul_nonneg chains. positivity might handle rpow via Real.rpow_nonneg? positivity extensions cover rpow for positive base? There's rpow_nonneg extension... not sure. Manual:
apply mul_nonneg; apply mul_nonneg; apply mul_nonneg; apply mul_nonneg
· norm_num
· linarith [Real.sqrt_nonneg n]
· linarith [Real.exp_pos (Real.sqrt n / 2)] -- exp(..)+1 ≥ 0: exp > 0
· norm_num
· exact h1
```
Wait order: 2 * (√n+1) * (exp(√n/2)+1) * 0.57 * 2^(-(2√n−2)) — left-nested: ((((2 * (√n+1)) * (exp(√n/2)+1)) * 0.57) * 2^(...)). mul_nonneg四次 with pieces in order: 2 ≥ 0; √n+1 ≥ 0; exp(..)+1 ≥ 0; 0.57 ≥ 0; 2^(..) ≥ 0. ✓
`Real.exp_le_one_iff : Real.exp x ≤ 1 ↔ x ≤ 0` — verify name: I believe it's Real.exp_le_one_iff. Yes (Mathlib: Real.exp_le_one_iff : exp x ≤ 1 ↔ x ≤ 0).
Now write LiBasePoints.lean. Also — one subtlety: `sInftyLower_eq`'s ring with γ: lagariasC1 = (γ − 1 − log(2π))/2: sInftyLower n = (1/2)n log n + ((γ − 1 − (log 2 + log π))/2 − γ/2)n − 4 = (1/2)n log n + ((−1 − log 2 − log π)/2)n − 4: coefficient (γ−1−log2−logπ)/2 − γ/2 = γ/2 − (1+log2+logπ)/2 − γ/2 = −(1+log2+logπ)/2 ✓ ring (γ is an opaque real constant — ring treats it as a variable ✓).
Real.log_mul for log(2π): Real.log 2 + Real.log π: Real.log_mul (2 ≠ 0) (π ≠ 0: Real.pi_ne_zero) ✓ (used in file: Real.log_mul (by norm_num) Real.pi_ne_zero ✓).
Now the BIG file. Let me carefully draft it. I'll write helper lemmas for the repeated patterns:
```
/-- exp x ≤ (1 − x/16)⁻¹¹⁶ for 0 ≤ x < 16 (from 1 − y ≤ e^{−y}). -/
theorem exp_le_inv_sub_sixteen {x : ℝ} (hx0 : 0 ≤ x) (hx1 : x < 16) :
Real.exp x ≤ (1 - x / 16)⁻¹ ^ 16 := by
have h16 : ((16 : ℕ) : ℝ) ≠ 0 := by norm_num
have hpos : (0 : ℝ) < 1 - x / 16 := by linarith
have h1 : 1 - x / 16 ≤ (Real.exp (x / 16))⁻¹ := by
have h := Real.add_one_le_exp (-(x / 16))
rw [Real.exp_neg] at h
linarith
have h2 : Real.exp (x / 16) ≤ (1 - x / 16)⁻¹ := by
have h3 := one_div_le_one_div_of_le hpos h1
rwa [one_div, one_div, inv_inv] at h3
have h4 : Real.exp x = (Real.exp (x / 16)) ^ 16 := by
rw [← Real.exp_nat_mul (x / 16) 16]
congr 1
field_simp
rw [h4]
exact pow_le_pow_left (Real.exp_nonneg _) h2 16
```
hmm: add_one_le_exp (−(x/16)) : −(x/16) + 1 ≤ exp(−(x/16)); rw exp_neg: = (exp (x/16))⁻¹. linarith to 1 − x/16 ≤ ... : −(x/16)+1 = 1 − x/16 by linarith-normalization ✓ linarith handles the rearrangement.
one_div_le_one_div_of_le (hpos : 0 < 1−x/16) (h1 : 1−x/16 ≤ (exp(x/16))⁻¹) : 1/((exp(x/16))⁻¹) ≤ 1/(1−x/16). Then 1/((exp(x/16))⁻¹) = (exp(x/16)) via one_div + inv_inv: `one_div ((exp (x/16))⁻¹) = ((exp (x/16))⁻¹)⁻¹`... one_div a = a⁻¹; so 1/(a⁻¹) = (a⁻¹)⁻¹ = a (inv_inv). rwa [one_div, one_div, inv_inv] at h3 — first one_div: turns 1/((exp..)⁻¹) into ((exp..)⁻¹)⁻¹; second one_div: 1/(1−x/16) into (1−x/16)⁻¹; inv_inv: ((exp..)⁻¹)⁻¹ → exp... — but rw rewrites EVERYWHERE incl. possibly other spots; h3's form: 1/(exp(x/16))⁻¹ ≤ 1/(1−x/16): after [one_div, one_div, inv_inv]: exp(x/16) ≤ (1−x/16)⁻¹ ✓.
Careful: one_div_le_one_div_of_le signature: (ha : 0 < a) (h : a ≤ b) : 1 / b ≤ 1 / a ✓ used in file.
field_simp for ↑16 * (x/16) = x: goal after congr 1: x = ↑16 * (x / 16)? or reversed. field_simp [h16] should close: multiply both sides... it's an equality of reals with a division — field_simp normalizes: x = ↑16 * (x/16) → both sides become x = x? field_simp then ring might be needed. Use `field_simp [h16]` then if unsolved `ring`. I'll write `field_simp [h16]` alone first; adjust at compile. Hmm — actually safer: `rw [mul_div_assoc, div_mul_cancel₀ x h16]`? div_mul_cancel₀ : b ≠ 0 → a / b * b = a — form is (x/16)*16 not 16*(x/16). `div_mul_cancel_comm`? Let me instead: have : (↑(16:ℕ) : ℝ) * (x / 16) = x := by field_simp [h16] — field_simp should manage; if not: mul_div_assoc': 16*(x/16) = 16*x/16 = x: rw [mul_div_assoc]; exact div_mul_cancel... div_mul_cancel₀ h16? : a / b * b = a. We have 16*x/16 — that's (16*x)/16 * ... no. (16*x)/16 = 16*x*(1/16)... I'll just do field_simp [h16] and fix at compile.
Then the certified bounds. Writing the whole file now — I'll aim for completeness and fix compile errors iteratively. For the big Bn proofs, structure with explicit named haves for each factor, then mul_le_mul chains.
Let me also double-check one numeric: is 1/(2π) ≤ 0.1592 with margin? 1/(2·3.1415926535) = 1/6.283185307 = 0.15915494... ≤ 0.1592 ✓ (0.028%). In Lean: h2pi : 2*Real.pi ≥ 6.2831853070 (from pi_gt_d20 : 3.14159265358979323846 < π — linarith gives 2π > 6.28318530717958647692 ≥ 6.2831853070). one_div_le_one_div_of_le (h : 0 < 6.2831853070) (2π ≥ that): 1/(2π) ≤ 1/6.2831853070. Then 1/6.2831853070 ≤ 0.1592: div_le_iff₀ (0 < 6.2831853070): 1 ≤ 0.1592·6.2831853070 = 1.00024...: norm_num: 0.1592*6.2831853070 = 1.00028...? compute: 6.2831853070*0.1592 = 6.2831853070*0.16 = 1.0053096 − 6.2831853070*0.0008 = 0.0050265 → 1.0053096−0.0050265 = 1.0002831 ≥ 1 ✓ norm_num.
Actually — simpler: 1/(2π) ≤ 1/6 = 0.1667?? 2π ≥ 6.28 ≥ 6 ⟹ 1/(2π) ≤ 1/6 = 0.16667. Then FAlt's (1/(2π))·T·log T ≤ (1/6)·284·5.7 = 269.8 vs 257.7 — costs 12 to Bn — we have ~970 slack in Bn ≤ 328000... 12 extra fine! SIMPLER (no tight 0.1592 needed). Use 1/(2π) ≤ 1/6: one_div_le_one_div_of_le (by norm_num : (0:ℝ) < 6) (2π ≥ 6 from pi > 3). Recompute Bn(80000) upper: 2F ≤ 2·[269.8+0.7809+0.77525+2.463] = 2·273.82 = 547.6 (was 523.5, +24). Total ≤ 327028.8 + 24 = 327052.8 ≤ 328000 ✓ still fine. And Bn(100000): 2F ≤ 2·[(1/6)·318·5.8 + 0.7946+0.7841+2.463] = 2·[307.4+4.04] = 622.9 (+28). Total ≤ 346893.1+28 = 346921 ≤ 347000 ✓. GOOD — use 1/6 (one less tight link).
Similarly relax other tight links where cheap: log π ≤ 1.1448 (0.007% tight) — could relax to 1.15? π ≤ e^1.15: e^1.15 = e·e^0.15: e^0.15 ≥ Σ_{i<7}: 1+.15+.01125+.0005625+.00002109+.00000063 = 1.161834; ×2.7182818283 = 3.15826 ≥ 3.1415927 ✓ margin 0.53%! log π ≤ 1.15 comfortable. Cost: coefficient (1+0.6931472+1.15)/2 = 1.4215736 vs 1.4189736: +0.0026·40000 = +104 loss on slower(80000) lower: 336998 − 104·... hmm: slower ≥ 40000·11.263 − 40000·2.8431472 − 4 = 450520 − 113725.9 − 4 = 336790.1 ≥ 336000 ✓ fine. slower(100000): 50000·(11.5 − 2.8431472) − 4 = 50000·8.6568528 − 4 = 432842.6 ≥ 433000? ✗ 432842.6 < 433000! Adjust target: ≥ 432800: margin(100000) ≥ 432800 − 347000 + 1 = 85801 > 65001 ✓ fine. And log π ≥ 1.14 stays.
Actually — let me simply retune all targets with slack:
- sInftyLower_80000 ≥ 336000 (true certified 336790 with logπ ≤ 1.15 — slack 790)
- sInftyLower_80000 ≤ 339000 (certified: 40000·11.3 − 40000·(1+0.6931471+1.14) − 4 = 452000 − 113325.88 − 4 = 338670.1 ≤ 339000 ✓ slack 330)
- sInftyLower_100000 ≥ 432800 (certified 432842.6 — slack 42! too tight. log 100000 ≥ 11.5 is 0.35%-margined; the truth is 11.5129 — I could use log 100000 ≥ 11.51: 100000 ≥ e^11.51: e^11.51 = e^11·e^0.51: e^0.51 ≤ (1/(1−0.51/16))^16 = (1/0.968125)^16: ln = 16·0.032388 = 0.518208; e^0.518208 = 1.67914. 59874.30·1.67914 = 100544.7 > 100000 ✗ FAILS. Keep 11.5 (certified 99506.6 ≤ 100000 ✓ 0.49%). Then slower(100000) ≥ 432842.6; set target 432500 (slack 342). margin(100000) ≥ 432500 − 347000 + 1 = 85501 > 65001 ✓ slack 20500 ✓.)
Targets settled:
- sInftyLower_80000_lo : 336000 ≤ sInftyLower 80000
- sInftyLower_80000_up : sInftyLower 80000 ≤ 339000
- sInftyLower_100000_lo : 432500 ≤ sInftyLower 100000
- Bn_FAlt_80000_le : Bn FAlt 80000 ≤ 328000
- Bn_FAlt_80000_ge : 274000 ≤ Bn FAlt 80000
- Bn_FAlt_100000_le : Bn FAlt 100000 ≤ 347000
- margin80000 ≥ 336000 − 328000 + 1 = 8001 > 0 ✓
- margin80000 ≤ 339000 − 274000 + 1 = 65001
- margin100000 ≥ 432500 − 347000 + 1 = 85501
- 65001 < 85501 ✓ slack 20500
All comfortable. Now log bounds needed (final):
- log 80000 ≥ 11.263 (e^11.263 ≤ 78058 ≤ 80000, margin 2.4%): exp 11.263 = exp 11·exp 0.263: e^11 ≤ 2.7182818286^11 = 59874.30; e^0.263 ≤ (1/(1−0.263/16))^16: 0.263/16 = 0.0164375; 1−that = 0.9835625; (1/0.9835625)^16: ln(1/0.9835625) = 0.0165737; ×16 = 0.265179; e^0.265179 = 1.303641. Product: 59874.30·1.303641 = 78060.0. ≤ 80000 ✓. Lean comparison: 59874.30·1.303641 — norm_num with the pow forms: (2.7182818286^11)·((1−0.263/16)⁻¹^16) ≤ 80000: norm_num handles (1−0.263/16)⁻¹^16? (1−0.0164375) = 0.9835625; ⁻¹; ^16 — norm_num can evaluate rational power ⁻¹^16? (0.9835625)⁻¹ = 1/0.9835625 — rational; ^16 — big rational; norm_num should evaluate and compare to 80000. It might be slow but OK. Alternative: pre-simplify in the lemma chain to keep norm_num inputs moderate. I'll write it directly and see.
Hmm — actually, for norm_num to evaluate ((1 - 0.263/16)⁻¹)^16 * 2.7182818286^11 ≤ 80000 — these are exact rational computations with 10-digit decimals raised to 16 — numerator/denominator astronomically large integers. norm_num might choke (time). Safer: step the bounds through simpler intermediates with `calc` and one norm_num per comparison of a decimal power ≤ decimal: e.g. have h1 : (2.7182818286 : ℝ)^11 ≤ 59874.31 := by norm_num; have h2 : ((1 - 0.263/16 : ℝ))⁻¹ ^ 16 ≤ 1.3037 := by norm_num... (0.9835625)^16 = 0.76712; 1/0.76712 = 1.30358 ≤ 1.3037 ✓ (0.01%). norm_num on ((0.9835625:ℝ)⁻¹)^16 ≤ 1.3037: evaluates — big rationals but should work (norm_num handles rational pow; prior sessions did 2.7182818286^5 etc.). Then product ≤ 59874.31·1.3037 = 78063.4 ≤ 80000 ✓ (mul_le_mul of positives).
To keep each norm_num tractable I'll insert intermediate decimal estimates at every step (standard practice in this file already).
Let me now also pre-verify ALL the exact intermediate decimals with python so every norm_num call is pre-checked. Quick script with Fraction to be exact.
All names verified. Before writing 500 lines of Lean, let me pre-verify every intermediate decimal with exact rational arithmetic (so each `norm_num` call is pre-checked).
tool: Bash
input
{
"command": "cd D:/Python/Quantum && .venv/Scripts/python.exe -c \"\nfrom fractions import Fraction as F\n\ndef exp_hi(x, k=16): # upper bound on e^x for 0<=x<k\n return (1/(1-F(x)/k))**k\ndef exp_lo(x, n=7): # lower bound via partial sums\n return sum(F(x)**i / F(1).__class__(1) * 0 + F(x)**i / __import__('math').factorial(i) for i in range(n))\n# use exact factorials\nimport math\ndef exp_lo(x, n=7):\n return sum(F(x)**i / math.factorial(i) for i in range(n))\n\ne1lo, e1hi = F('2.7182818283'), F('2.7182818286')\n# intermediates to norm_num\nsteps = [\n ('e1hi^11 <= 59874.31', e1hi**11, F('59874.31'), '<='),\n ('e1lo^11 >= 59874.13', e1lo**11, F('59874.13'), '>='),\n ('e1hi^5 <= 148.414', e1hi**5, F('148.414'), '<='),\n ('e1lo^5 >= 148.328', e1lo**5, F('148.328'), '>='),\n ('e1hi^4 <= 54.6015', e1hi**4, F('54.6015'), '<='),\n ('e1lo^4 >= 54.5978', e1lo**4, F('54.5978'), '>='),\n ('exp_hi(0.263) <= 1.3037', exp_hi(F('0.263')), F('1.3037'), '<='),\n ('exp_lo(0.3) >= 1.34985', exp_lo(F('0.3')), F('1.34985'), '>='),\n ('exp_hi(0.14) <= 1.151', exp_hi(F('0.14')), F('1.151'), '<='),\n ('exp_lo(0.15) >= 1.1618', exp_lo(F('0.15')), F('1.1618'), '>='),\n ('exp_hi(0.6) <= 1.8432', exp_hi(F('0.6')), F('1.8432'), '<='),\n ('exp_lo(0.7) >= 2.0136', exp_lo(F('0.7')), F('2.0136'), '>='),\n ('exp_lo(0.75) >= 2.1169', exp_lo(F('0.75')), F('2.1169'), '>='),\n ('exp_lo(0.77) >= 2.1597', exp_lo(F('0.77')), F('2.1597'), '>='),\n ('exp_lo(0.8) >= 2.2255', exp_lo(F('0.8')), F('2.2255'), '>='),\n ('exp_hi(0.5) <= 1.6644', exp_hi(F('0.5')), F('1.6644'), '<='),\n]\nfor name, val, bound, d in steps:\n ok = (val <= bound) if d=='<=' else (val >= bound)\n print(('OK ' if ok else 'FAIL'), name, ' val=', float(val))\n# composite checks\nprint()\nprint('e^11.263 <= ', float(e1hi**11 * exp_hi(F('0.263'))), '<= 80000:', e1hi**11*exp_hi(F('0.263')) <= 80000)\nprint('e^11.3 >= ', float(e1lo**11 * exp_lo(F('0.3'))), '>= 80000:', e1lo**11*exp_lo(F('0.3')) >= 80000)\nprint('e^11.5 <= ', float(e1hi**11 * exp_hi(F('0.5'))), '<= 100000:', e1hi**11*exp_hi(F('0.5')) <= 100000)\nprint('e^5.7 >= ', float(e1lo**5 * exp_lo(F('0.7'))), '>= 286:', e1lo**5*exp_lo(F('0.7')) >= 286)\nprint('e^1.75 >= ', float(e1lo * exp_lo(F('0.75'))), '>= 5.7:', e1lo*exp_lo(F('0.75')) >= F('5.7'))\nprint('e^5.6 <= ', float(e1hi**5 * exp_hi(F('0.6'))), '<= 285:', e1hi**5*exp_hi(F('0.6')) <= 285)\nprint('e^5.8 >= ', float(e1lo**5 * exp_lo(F('0.8'))), '>= 320:', e1lo**5*exp_lo(F('0.8')) >= 320)\nprint('e^1.77 >= ', float(e1lo * exp_lo(F('0.77'))), '>= 5.8:', e1lo*exp_lo(F('0.77')) >= F('5.8'))\nprint('e^1.14 <= ', float(e1hi * exp_hi(F('0.14'))), '<= pi_lo:', e1hi*exp_hi(F('0.14')) <= F('3.1415926535'))\nprint('e^1.15 >= ', float(e1lo * exp_lo(F('0.15'))), '>= pi_hi:', e1lo*exp_lo(F('0.15')) >= F('3.1415926536'))\n\"\n",
"description": "Exact rational pre-verification of all norm_num steps"
}
raw content_json (database row)
[{"type":"thinking","thinking":"All confirmed: `Real.exp_one_gt_d9 : 2.7182818283 < exp 1`, `Real.exp_one_lt_d9 : exp 1 < 2.7182818286`, `Real.sum_le_exp_of_nonneg` ✓.\n\nFirst add the two public IIMaj lemmas to LiSkeleton.lean (IIMaj bounds), then write LiBasePoints.lean.\n\nFor IIMaj bounds in LiSkeleton — insert after IIMaj_eq_psiTilde_sqrt:\n\n```\n/-- [PROVED session 012] Crude global upper bound on the I_I majorant:\nIIMaj n ≤ 4.56·(√n+1)·2 for n ≥ 0 (both exponentials ≤ 1). Used by the\nbase-point numerics; the slack is absorbed by the margin. -/\ntheorem IIMaj_le_two_mul (n : ℝ) (hn : 0 ≤ n) :\n IIMaj n ≤ 4.56 * (Real.sqrt n + 1) * 2 := by\n rw [IIMaj_eq_psiTilde_sqrt]\n unfold psiTilde\n have hlog2 := Real.log_two_gt_d9\n have ha : (0 : ℝ) < iimA := by unfold iimA; linarith\n have hb : (0 : ℝ) < iimB := by unfold iimB; linarith\n have hs : (0 : ℝ) ≤ Real.sqrt n := Real.sqrt_nonneg n\n have heA : Real.exp (-iimA * Real.sqrt n) ≤ 1 := by\n rw [Real.exp_le_one_iff]\n exact mul_nonpos_of_nonpos_of_nonneg (by linarith) hs\n ...\n```\nwait: −iimA·s ≤ 0: −iimA ≤ 0 and s ≥ 0: mul_nonpos_of_nonpos_of_nonneg (show -iimA ≤ 0 by linarith) hs — (−iimA)·s where the term is −iimA * s = (−iimA)·s ✓. Then:\n```\n have heB : Real.exp (-iimB * Real.sqrt n) ≤ 1 := ...\n have hpos : (0:ℝ) ≤ Real.sqrt n + 1 := by positivity — positivity needs 0 ≤ sqrt: hs; linarith\n calc 4.56 * ((Real.sqrt n + 1) * (Real.exp (-iimA * Real.sqrt n) + Real.exp (-iimB * Real.sqrt n)))\n ≤ 4.56 * ((Real.sqrt n + 1) * (1 + 1)) := by\n apply mul_le_mul_of_nonneg_left _ (by norm_num : (0:ℝ) ≤ 4.56)\n apply mul_le_mul_of_nonneg_left _ hpos1 -- 0 ≤ s+1\n linarith [heA, heB] -- e^{-as}+e^{-bs} ≤ 1+1: add_le_add\n _ = 4.56 * (Real.sqrt n + 1) * 2 := by ring\n```\nadd_le_add heA heB : e^{-as} + e^{-bs} ≤ 1 + 1 ✓.\n\n```\n/-- [PROVED session 012] IIMaj is nonnegative. -/\ntheorem IIMaj_nonneg (n : ℝ) : 0 ≤ IIMaj n := by\n unfold IIMaj\n have h1 : (0:ℝ) ≤ (2:ℝ) ^ (-(2 * Real.sqrt n - 2)) := Real.rpow_nonneg (by norm_num) _\n positivity? — with h1: 2*(√n+1)*(exp(√n/2)+1)*0.57*2^(...): all nonneg: mul_nonneg chains. positivity might handle rpow via Real.rpow_nonneg? positivity extensions cover rpow for positive base? There's rpow_nonneg extension... not sure. Manual:\n apply mul_nonneg; apply mul_nonneg; apply mul_nonneg; apply mul_nonneg\n · norm_num\n · linarith [Real.sqrt_nonneg n]\n · linarith [Real.exp_pos (Real.sqrt n / 2)] -- exp(..)+1 ≥ 0: exp > 0\n · norm_num\n · exact h1\n```\nWait order: 2 * (√n+1) * (exp(√n/2)+1) * 0.57 * 2^(-(2√n−2)) — left-nested: ((((2 * (√n+1)) * (exp(√n/2)+1)) * 0.57) * 2^(...)). mul_nonneg四次 with pieces in order: 2 ≥ 0; √n+1 ≥ 0; exp(..)+1 ≥ 0; 0.57 ≥ 0; 2^(..) ≥ 0. ✓\n\n`Real.exp_le_one_iff : Real.exp x ≤ 1 ↔ x ≤ 0` — verify name: I believe it's Real.exp_le_one_iff. Yes (Mathlib: Real.exp_le_one_iff : exp x ≤ 1 ↔ x ≤ 0).\n\nNow write LiBasePoints.lean. Also — one subtlety: `sInftyLower_eq`'s ring with γ: lagariasC1 = (γ − 1 − log(2π))/2: sInftyLower n = (1/2)n log n + ((γ − 1 − (log 2 + log π))/2 − γ/2)n − 4 = (1/2)n log n + ((−1 − log 2 − log π)/2)n − 4: coefficient (γ−1−log2−logπ)/2 − γ/2 = γ/2 − (1+log2+logπ)/2 − γ/2 = −(1+log2+logπ)/2 ✓ ring (γ is an opaque real constant — ring treats it as a variable ✓).\n\nReal.log_mul for log(2π): Real.log 2 + Real.log π: Real.log_mul (2 ≠ 0) (π ≠ 0: Real.pi_ne_zero) ✓ (used in file: Real.log_mul (by norm_num) Real.pi_ne_zero ✓).\n\nNow the BIG file. Let me carefully draft it. I'll write helper lemmas for the repeated patterns:\n\n```\n/-- exp x ≤ (1 − x/16)⁻¹¹⁶ for 0 ≤ x < 16 (from 1 − y ≤ e^{−y}). -/\ntheorem exp_le_inv_sub_sixteen {x : ℝ} (hx0 : 0 ≤ x) (hx1 : x < 16) :\n Real.exp x ≤ (1 - x / 16)⁻¹ ^ 16 := by\n have h16 : ((16 : ℕ) : ℝ) ≠ 0 := by norm_num\n have hpos : (0 : ℝ) < 1 - x / 16 := by linarith\n have h1 : 1 - x / 16 ≤ (Real.exp (x / 16))⁻¹ := by\n have h := Real.add_one_le_exp (-(x / 16))\n rw [Real.exp_neg] at h\n linarith\n have h2 : Real.exp (x / 16) ≤ (1 - x / 16)⁻¹ := by\n have h3 := one_div_le_one_div_of_le hpos h1\n rwa [one_div, one_div, inv_inv] at h3\n have h4 : Real.exp x = (Real.exp (x / 16)) ^ 16 := by\n rw [← Real.exp_nat_mul (x / 16) 16]\n congr 1\n field_simp\n rw [h4]\n exact pow_le_pow_left (Real.exp_nonneg _) h2 16\n```\nhmm: add_one_le_exp (−(x/16)) : −(x/16) + 1 ≤ exp(−(x/16)); rw exp_neg: = (exp (x/16))⁻¹. linarith to 1 − x/16 ≤ ... : −(x/16)+1 = 1 − x/16 by linarith-normalization ✓ linarith handles the rearrangement.\none_div_le_one_div_of_le (hpos : 0 < 1−x/16) (h1 : 1−x/16 ≤ (exp(x/16))⁻¹) : 1/((exp(x/16))⁻¹) ≤ 1/(1−x/16). Then 1/((exp(x/16))⁻¹) = (exp(x/16)) via one_div + inv_inv: `one_div ((exp (x/16))⁻¹) = ((exp (x/16))⁻¹)⁻¹`... one_div a = a⁻¹; so 1/(a⁻¹) = (a⁻¹)⁻¹ = a (inv_inv). rwa [one_div, one_div, inv_inv] at h3 — first one_div: turns 1/((exp..)⁻¹) into ((exp..)⁻¹)⁻¹; second one_div: 1/(1−x/16) into (1−x/16)⁻¹; inv_inv: ((exp..)⁻¹)⁻¹ → exp... — but rw rewrites EVERYWHERE incl. possibly other spots; h3's form: 1/(exp(x/16))⁻¹ ≤ 1/(1−x/16): after [one_div, one_div, inv_inv]: exp(x/16) ≤ (1−x/16)⁻¹ ✓.\n\nCareful: one_div_le_one_div_of_le signature: (ha : 0 < a) (h : a ≤ b) : 1 / b ≤ 1 / a ✓ used in file.\n\nfield_simp for ↑16 * (x/16) = x: goal after congr 1: x = ↑16 * (x / 16)? or reversed. field_simp [h16] should close: multiply both sides... it's an equality of reals with a division — field_simp normalizes: x = ↑16 * (x/16) → both sides become x = x? field_simp then ring might be needed. Use `field_simp [h16]` then if unsolved `ring`. I'll write `field_simp [h16]` alone first; adjust at compile. Hmm — actually safer: `rw [mul_div_assoc, div_mul_cancel₀ x h16]`? div_mul_cancel₀ : b ≠ 0 → a / b * b = a — form is (x/16)*16 not 16*(x/16). `div_mul_cancel_comm`? Let me instead: have : (↑(16:ℕ) : ℝ) * (x / 16) = x := by field_simp [h16] — field_simp should manage; if not: mul_div_assoc': 16*(x/16) = 16*x/16 = x: rw [mul_div_assoc]; exact div_mul_cancel... div_mul_cancel₀ h16? : a / b * b = a. We have 16*x/16 — that's (16*x)/16 * ... no. (16*x)/16 = 16*x*(1/16)... I'll just do field_simp [h16] and fix at compile.\n\nThen the certified bounds. Writing the whole file now — I'll aim for completeness and fix compile errors iteratively. For the big Bn proofs, structure with explicit named haves for each factor, then mul_le_mul chains.\n\nLet me also double-check one numeric: is 1/(2π) ≤ 0.1592 with margin? 1/(2·3.1415926535) = 1/6.283185307 = 0.15915494... ≤ 0.1592 ✓ (0.028%). In Lean: h2pi : 2*Real.pi ≥ 6.2831853070 (from pi_gt_d20 : 3.14159265358979323846 < π — linarith gives 2π > 6.28318530717958647692 ≥ 6.2831853070). one_div_le_one_div_of_le (h : 0 < 6.2831853070) (2π ≥ that): 1/(2π) ≤ 1/6.2831853070. Then 1/6.2831853070 ≤ 0.1592: div_le_iff₀ (0 < 6.2831853070): 1 ≤ 0.1592·6.2831853070 = 1.00024...: norm_num: 0.1592*6.2831853070 = 1.00028...? compute: 6.2831853070*0.1592 = 6.2831853070*0.16 = 1.0053096 − 6.2831853070*0.0008 = 0.0050265 → 1.0053096−0.0050265 = 1.0002831 ≥ 1 ✓ norm_num.\n\nActually — simpler: 1/(2π) ≤ 1/6 = 0.1667?? 2π ≥ 6.28 ≥ 6 ⟹ 1/(2π) ≤ 1/6 = 0.16667. Then FAlt's (1/(2π))·T·log T ≤ (1/6)·284·5.7 = 269.8 vs 257.7 — costs 12 to Bn — we have ~970 slack in Bn ≤ 328000... 12 extra fine! SIMPLER (no tight 0.1592 needed). Use 1/(2π) ≤ 1/6: one_div_le_one_div_of_le (by norm_num : (0:ℝ) < 6) (2π ≥ 6 from pi > 3). Recompute Bn(80000) upper: 2F ≤ 2·[269.8+0.7809+0.77525+2.463] = 2·273.82 = 547.6 (was 523.5, +24). Total ≤ 327028.8 + 24 = 327052.8 ≤ 328000 ✓ still fine. And Bn(100000): 2F ≤ 2·[(1/6)·318·5.8 + 0.7946+0.7841+2.463] = 2·[307.4+4.04] = 622.9 (+28). Total ≤ 346893.1+28 = 346921 ≤ 347000 ✓. GOOD — use 1/6 (one less tight link).\n\nSimilarly relax other tight links where cheap: log π ≤ 1.1448 (0.007% tight) — could relax to 1.15? π ≤ e^1.15: e^1.15 = e·e^0.15: e^0.15 ≥ Σ_{i<7}: 1+.15+.01125+.0005625+.00002109+.00000063 = 1.161834; ×2.7182818283 = 3.15826 ≥ 3.1415927 ✓ margin 0.53%! log π ≤ 1.15 comfortable. Cost: coefficient (1+0.6931472+1.15)/2 = 1.4215736 vs 1.4189736: +0.0026·40000 = +104 loss on slower(80000) lower: 336998 − 104·... hmm: slower ≥ 40000·11.263 − 40000·2.8431472 − 4 = 450520 − 113725.9 − 4 = 336790.1 ≥ 336000 ✓ fine. slower(100000): 50000·(11.5 − 2.8431472) − 4 = 50000·8.6568528 − 4 = 432842.6 ≥ 433000? ✗ 432842.6 < 433000! Adjust target: ≥ 432800: margin(100000) ≥ 432800 − 347000 + 1 = 85801 > 65001 ✓ fine. And log π ≥ 1.14 stays.\n\nActually — let me simply retune all targets with slack:\n- sInftyLower_80000 ≥ 336000 (true certified 336790 with logπ ≤ 1.15 — slack 790)\n- sInftyLower_80000 ≤ 339000 (certified: 40000·11.3 − 40000·(1+0.6931471+1.14) − 4 = 452000 − 113325.88 − 4 = 338670.1 ≤ 339000 ✓ slack 330)\n- sInftyLower_100000 ≥ 432800 (certified 432842.6 — slack 42! too tight. log 100000 ≥ 11.5 is 0.35%-margined; the truth is 11.5129 — I could use log 100000 ≥ 11.51: 100000 ≥ e^11.51: e^11.51 = e^11·e^0.51: e^0.51 ≤ (1/(1−0.51/16))^16 = (1/0.968125)^16: ln = 16·0.032388 = 0.518208; e^0.518208 = 1.67914. 59874.30·1.67914 = 100544.7 > 100000 ✗ FAILS. Keep 11.5 (certified 99506.6 ≤ 100000 ✓ 0.49%). Then slower(100000) ≥ 432842.6; set target 432500 (slack 342). margin(100000) ≥ 432500 − 347000 + 1 = 85501 > 65001 ✓ slack 20500 ✓.)\n\nTargets settled:\n- sInftyLower_80000_lo : 336000 ≤ sInftyLower 80000\n- sInftyLower_80000_up : sInftyLower 80000 ≤ 339000\n- sInftyLower_100000_lo : 432500 ≤ sInftyLower 100000\n- Bn_FAlt_80000_le : Bn FAlt 80000 ≤ 328000\n- Bn_FAlt_80000_ge : 274000 ≤ Bn FAlt 80000\n- Bn_FAlt_100000_le : Bn FAlt 100000 ≤ 347000\n- margin80000 ≥ 336000 − 328000 + 1 = 8001 > 0 ✓\n- margin80000 ≤ 339000 − 274000 + 1 = 65001\n- margin100000 ≥ 432500 − 347000 + 1 = 85501\n- 65001 < 85501 ✓ slack 20500\n\nAll comfortable. Now log bounds needed (final):\n- log 80000 ≥ 11.263 (e^11.263 ≤ 78058 ≤ 80000, margin 2.4%): exp 11.263 = exp 11·exp 0.263: e^11 ≤ 2.7182818286^11 = 59874.30; e^0.263 ≤ (1/(1−0.263/16))^16: 0.263/16 = 0.0164375; 1−that = 0.9835625; (1/0.9835625)^16: ln(1/0.9835625) = 0.0165737; ×16 = 0.265179; e^0.265179 = 1.303641. Product: 59874.30·1.303641 = 78060.0. ≤ 80000 ✓. Lean comparison: 59874.30·1.303641 — norm_num with the pow forms: (2.7182818286^11)·((1−0.263/16)⁻¹^16) ≤ 80000: norm_num handles (1−0.263/16)⁻¹^16? (1−0.0164375) = 0.9835625; ⁻¹; ^16 — norm_num can evaluate rational power ⁻¹^16? (0.9835625)⁻¹ = 1/0.9835625 — rational; ^16 — big rational; norm_num should evaluate and compare to 80000. It might be slow but OK. Alternative: pre-simplify in the lemma chain to keep norm_num inputs moderate. I'll write it directly and see.\n\nHmm — actually, for norm_num to evaluate ((1 - 0.263/16)⁻¹)^16 * 2.7182818286^11 ≤ 80000 — these are exact rational computations with 10-digit decimals raised to 16 — numerator/denominator astronomically large integers. norm_num might choke (time). Safer: step the bounds through simpler intermediates with `calc` and one norm_num per comparison of a decimal power ≤ decimal: e.g. have h1 : (2.7182818286 : ℝ)^11 ≤ 59874.31 := by norm_num; have h2 : ((1 - 0.263/16 : ℝ))⁻¹ ^ 16 ≤ 1.3037 := by norm_num... (0.9835625)^16 = 0.76712; 1/0.76712 = 1.30358 ≤ 1.3037 ✓ (0.01%). norm_num on ((0.9835625:ℝ)⁻¹)^16 ≤ 1.3037: evaluates — big rationals but should work (norm_num handles rational pow; prior sessions did 2.7182818286^5 etc.). Then product ≤ 59874.31·1.3037 = 78063.4 ≤ 80000 ✓ (mul_le_mul of positives).\n\nTo keep each norm_num tractable I'll insert intermediate decimal estimates at every step (standard practice in this file already).\n\nLet me now also pre-verify ALL the exact intermediate decimals with python so every norm_num call is pre-checked. Quick script with Fraction to be exact.","signature":""},{"type":"text","text":"All names verified. Before writing 500 lines of Lean, let me pre-verify every intermediate decimal with exact rational arithmetic (so each `norm_num` call is pre-checked)."},{"type":"tool_use","id":"Bash_137","name":"Bash","input":{"command":"cd D:/Python/Quantum && .venv/Scripts/python.exe -c \"\nfrom fractions import Fraction as F\n\ndef exp_hi(x, k=16): # upper bound on e^x for 0<=x<k\n return (1/(1-F(x)/k))**k\ndef exp_lo(x, n=7): # lower bound via partial sums\n return sum(F(x)**i / F(1).__class__(1) * 0 + F(x)**i / __import__('math').factorial(i) for i in range(n))\n# use exact factorials\nimport math\ndef exp_lo(x, n=7):\n return sum(F(x)**i / math.factorial(i) for i in range(n))\n\ne1lo, e1hi = F('2.7182818283'), F('2.7182818286')\n# intermediates to norm_num\nsteps = [\n ('e1hi^11 <= 59874.31', e1hi**11, F('59874.31'), '<='),\n ('e1lo^11 >= 59874.13', e1lo**11, F('59874.13'), '>='),\n ('e1hi^5 <= 148.414', e1hi**5, F('148.414'), '<='),\n ('e1lo^5 >= 148.328', e1lo**5, F('148.328'), '>='),\n ('e1hi^4 <= 54.6015', e1hi**4, F('54.6015'), '<='),\n ('e1lo^4 >= 54.5978', e1lo**4, F('54.5978'), '>='),\n ('exp_hi(0.263) <= 1.3037', exp_hi(F('0.263')), F('1.3037'), '<='),\n ('exp_lo(0.3) >= 1.34985', exp_lo(F('0.3')), F('1.34985'), '>='),\n ('exp_hi(0.14) <= 1.151', exp_hi(F('0.14')), F('1.151'), '<='),\n ('exp_lo(0.15) >= 1.1618', exp_lo(F('0.15')), F('1.1618'), '>='),\n ('exp_hi(0.6) <= 1.8432', exp_hi(F('0.6')), F('1.8432'), '<='),\n ('exp_lo(0.7) >= 2.0136', exp_lo(F('0.7')), F('2.0136'), '>='),\n ('exp_lo(0.75) >= 2.1169', exp_lo(F('0.75')), F('2.1169'), '>='),\n ('exp_lo(0.77) >= 2.1597', exp_lo(F('0.77')), F('2.1597'), '>='),\n ('exp_lo(0.8) >= 2.2255', exp_lo(F('0.8')), F('2.2255'), '>='),\n ('exp_hi(0.5) <= 1.6644', exp_hi(F('0.5')), F('1.6644'), '<='),\n]\nfor name, val, bound, d in steps:\n ok = (val <= bound) if d=='<=' else (val >= bound)\n print(('OK ' if ok else 'FAIL'), name, ' val=', float(val))\n# composite checks\nprint()\nprint('e^11.263 <= ', float(e1hi**11 * exp_hi(F('0.263'))), '<= 80000:', e1hi**11*exp_hi(F('0.263')) <= 80000)\nprint('e^11.3 >= ', float(e1lo**11 * exp_lo(F('0.3'))), '>= 80000:', e1lo**11*exp_lo(F('0.3')) >= 80000)\nprint('e^11.5 <= ', float(e1hi**11 * exp_hi(F('0.5'))), '<= 100000:', e1hi**11*exp_hi(F('0.5')) <= 100000)\nprint('e^5.7 >= ', float(e1lo**5 * exp_lo(F('0.7'))), '>= 286:', e1lo**5*exp_lo(F('0.7')) >= 286)\nprint('e^1.75 >= ', float(e1lo * exp_lo(F('0.75'))), '>= 5.7:', e1lo*exp_lo(F('0.75')) >= F('5.7'))\nprint('e^5.6 <= ', float(e1hi**5 * exp_hi(F('0.6'))), '<= 285:', e1hi**5*exp_hi(F('0.6')) <= 285)\nprint('e^5.8 >= ', float(e1lo**5 * exp_lo(F('0.8'))), '>= 320:', e1lo**5*exp_lo(F('0.8')) >= 320)\nprint('e^1.77 >= ', float(e1lo * exp_lo(F('0.77'))), '>= 5.8:', e1lo*exp_lo(F('0.77')) >= F('5.8'))\nprint('e^1.14 <= ', float(e1hi * exp_hi(F('0.14'))), '<= pi_lo:', e1hi*exp_hi(F('0.14')) <= F('3.1415926535'))\nprint('e^1.15 >= ', float(e1lo * exp_lo(F('0.15'))), '>= pi_hi:', e1lo*exp_lo(F('0.15')) >= F('3.1415926536'))\n\"\n","description":"Exact rational pre-verification of all norm_num steps"},"extra_content":null}]