Current task: —

← Session 17 — Lean tier (i): elementary proofs (after crash)

#672 assistant 2026-08-20 06:24:03.640 UTC · 907→1713 tok open ⤢
thinking (4075 chars)
Line 1130 is the doc-comment/theorem statement of iimaj_bracket_bound — the whnf timeout at 1130:0 is at the theorem HEADER — meaning elaborating the statement/proof as a whole hits whnf timeout (probably the `set` chain + huge context during final proof-term checking or the `calc` type unifications). The cascading timeouts make incremental debugging painful. Root cause hypothesis: `set L := Real.log 2` etc. create let-bound fvars; when later unifications (calc, exact) compare expressions with/without the lets unfolded, whnf repeatedly expands the whole chain (L → log 2, a → 2L−1/2, eA → exp(−a·s)...) — combined with the giant context this can blow up. Better plan: avoid `set` entirely in this proof. Work with plain `have` abbreviations via local notation... Actually simplest robust fix: replace `set X := v with hXdef` by nothing — keep iimA/iimB folded in the statement (they already are), and use `show` to unfold once into a goal with a,b,eA,eB as FREE variables? Can't introduce free vars. Alternative: prove iimaj_bracket_bound in terms of freshly abstracted variables via a general lemma: lemma iimaj_bracket_generic (a b eA eB s : ℝ) (hab : a ≤ b) (ha : 0.8862943606 ≤ a) ... : 4.56*(2*(−a eA − b eB) + (s+1)*(a²eA+b²eB)) − (4.56*((eA+eB) + (s+1)*(−a eA − b eB)))/s < 2 with hypotheses: hab, ha bounds, hb bounds, hs : √20 ≤ s, heA : eA = exp(−a s), heB : eB = exp(−b s), hb2 : b = a + 1/2... This isolates the algebra+numerics with a SMALL context (no set-vars) — then iimaj_bracket_bound := iimaj_bracket_generic ... (plugging). The generic lemma's proof has exactly the hypotheses it needs in context — linarith/whnf stay fast. But that's a big refactor of an almost-working proof. The timeouts appeared only near the hu2val hexp region... Honestly, maybe the real problem is simpler: `Real.exp_neg` rewrite at 1255 ("pattern not found") — goal `Real.exp (-a * √20) ≤ ...` — the pattern Real.exp_neg : exp (−x) = (exp x)⁻¹ — the exponent is `-a * √20` — is that of the form `-(x)`? `-a * √20` parses as `(-a) * √20` — NEG application on a, then mul — NOT `-(a * √20)`! So exp_neg doesn't match. That's error 1255. Fix: use `Real.exp_neg` with a show: rw [show -a * Real.sqrt 20 = -(a * Real.sqrt 20) by ring, Real.exp_neg]. That fixes 1255. The whnf timeouts might cascade from that failure (unsolved goals causing downstream unification explosions). And 1244:55 "unsolved goals" was the calc's rfl step — the calc's FIRST step — hmm it printed context up to hu1 and hAid/hBid/hanti/hu2le/hb2up — the unsolved goal was probably `Real.exp (-a * √20) ≤ 212721e-7`?? no that was 1244?? The second grep showed ⊢ Real.exp (-a*√20) ≤ 212721e-7 as a leftover goal — from hexp after rw [Real.exp_neg] failed → the calc there broke. So the whnf timeouts are downstream elaboration of broken proofs — fix the exp_neg issue and most may vanish. Also fix: `-a * Real.sqrt 20` vs `-(a * Real.sqrt n)` in hu2val's hexp — and in hu3's hexp: `Real.exp (-s / 2)` — `-s/2` parses as `(-s)/2` — same issue! rw [show -s/2 = -(s/2) by ring, Real.exp_neg]. And in hstep3's heB': `Real.exp (-s / 2)`... heB' : eB = eA * Real.exp (-s/2) — that proof: rw [heBdef, heAdef, ← Real.exp_add]; congr 1; rw [hadef, hbdef]; ring — the exp_add direction: ← Real.exp_add : exp(x)*exp(y) → exp(x+y): goal after rw [heBdef, heAdef]: exp(−b*s) = exp(−a*s)*exp(−s/2) → rw [← Real.exp_add] turns RHS into exp(−a*s + −(s/2)): congr 1: −b*s = −a*s + −(s/2): with a = 2L−1/2, b = 2L: rw [hadef, hbdef]; ring ✓ — but WAIT: hadef : a = b − 1/2?? Earlier context shows `hadef : a = b - 1 / 2` — interesting: `set a := 2*L − 1/2 with hadef` — hadef : a = 2*L−1/2... the print showed `hadef : a = b - 1 / 2` — because b was ALSO set to 2*L and set replaced 2*L with b INSIDE hadef!! So hadef : a = b − 1/2 ✓ that's actually convenient: b − a = 1/2 directly. So in heB': rw [hadef] rewrites a → (b−1/2): goal −b*s = −(b−1/2)*s + −(s/2): ring ✓. And hbdef : b = 2*L ✓. OK apply the exp_neg fixes (two spots). Also the `show -a * Real.sqrt 20 = -(a * Real.sqrt 20) by ring` — neg_mul ✓ ring.
Found it: `-a * √20` parses as `(-a) * √20`, so `Real.exp_neg` (pattern `exp (-x)`) can't match. Fixing both spots.
tool: Edit
input
{
  "file_path": "D:\\Python\\Quantum\\research\\lean\\NguyenRH1\\NguyenRH1\\LiSkeleton.lean",
  "old_string": "        rw [Real.exp_neg]\n        calc (Real.exp (a * Real.sqrt 20))\u207b\u00b9 \u2264 1 / 47.01 :=\n              one_div_le_one_div_of_le (by norm_num : (0 : \u211d) < 47.01) hsum\n          _ \u2264 0.0212721 := by\n              rw [div_le_iff\u2080 (by norm_num : (0 : \u211d) < 47.01)]; norm_num",
  "new_string": "        rw [show -a * Real.sqrt 20 = -(a * Real.sqrt 20) by ring, Real.exp_neg]\n        calc (Real.exp (a * Real.sqrt 20))\u207b\u00b9 \u2264 1 / 47.01 :=\n              one_div_le_one_div_of_le (by norm_num : (0 : \u211d) < 47.01) hsum\n          _ \u2264 0.0212721 := by\n              rw [div_le_iff\u2080 (by norm_num : (0 : \u211d) < 47.01)]; norm_num"
}
raw content_json (database row)
[{"type":"thinking","thinking":"Line 1130 is the doc-comment/theorem statement of iimaj_bracket_bound — the whnf timeout at 1130:0 is at the theorem HEADER — meaning elaborating the statement/proof as a whole hits whnf timeout (probably the `set` chain + huge context during final proof-term checking or the `calc` type unifications). The cascading timeouts make incremental debugging painful.\n\nRoot cause hypothesis: `set L := Real.log 2` etc. create let-bound fvars; when later unifications (calc, exact) compare expressions with/without the lets unfolded, whnf repeatedly expands the whole chain (L → log 2, a → 2L−1/2, eA → exp(−a·s)...) — combined with the giant context this can blow up.\n\nBetter plan: avoid `set` entirely in this proof. Work with plain `have` abbreviations via local notation... Actually simplest robust fix: replace `set X := v with hXdef` by nothing — keep iimA/iimB folded in the statement (they already are), and use `show` to unfold once into a goal with a,b,eA,eB as FREE variables? Can't introduce free vars.\n\nAlternative: prove iimaj_bracket_bound in terms of freshly abstracted variables via a general lemma: \n\nlemma iimaj_bracket_generic (a b eA eB s : ℝ) (hab : a ≤ b) (ha : 0.8862943606 ≤ a) ... : 4.56*(2*(−a eA − b eB) + (s+1)*(a²eA+b²eB)) − (4.56*((eA+eB) + (s+1)*(−a eA − b eB)))/s < 2\n\nwith hypotheses: hab, ha bounds, hb bounds, hs : √20 ≤ s, heA : eA = exp(−a s), heB : eB = exp(−b s), hb2 : b = a + 1/2... This isolates the algebra+numerics with a SMALL context (no set-vars) — then iimaj_bracket_bound := iimaj_bracket_generic ... (plugging). The generic lemma's proof has exactly the hypotheses it needs in context — linarith/whnf stay fast.\n\nBut that's a big refactor of an almost-working proof. The timeouts appeared only near the hu2val hexp region... Honestly, maybe the real problem is simpler: `Real.exp_neg` rewrite at 1255 (\"pattern not found\") — goal `Real.exp (-a * √20) ≤ ...` — the pattern Real.exp_neg : exp (−x) = (exp x)⁻¹ — the exponent is `-a * √20` — is that of the form `-(x)`? `-a * √20` parses as `(-a) * √20` — NEG application on a, then mul — NOT `-(a * √20)`! So exp_neg doesn't match. That's error 1255. Fix: use `Real.exp_neg` with a show: rw [show -a * Real.sqrt 20 = -(a * Real.sqrt 20) by ring, Real.exp_neg]. That fixes 1255.\n\nThe whnf timeouts might cascade from that failure (unsolved goals causing downstream unification explosions). And 1244:55 \"unsolved goals\" was the calc's rfl step — the calc's FIRST step — hmm it printed context up to hu1 and hAid/hBid/hanti/hu2le/hb2up — the unsolved goal was probably `Real.exp (-a * √20) ≤ 212721e-7`?? no that was 1244?? The second grep showed ⊢ Real.exp (-a*√20) ≤ 212721e-7 as a leftover goal — from hexp after rw [Real.exp_neg] failed → the calc there broke. So the whnf timeouts are downstream elaboration of broken proofs — fix the exp_neg issue and most may vanish.\n\nAlso fix: `-a * Real.sqrt 20` vs `-(a * Real.sqrt n)` in hu2val's hexp — and in hu3's hexp: `Real.exp (-s / 2)` — `-s/2` parses as `(-s)/2` — same issue! rw [show -s/2 = -(s/2) by ring, Real.exp_neg].\n\nAnd in hstep3's heB': `Real.exp (-s / 2)`... heB' : eB = eA * Real.exp (-s/2) — that proof: rw [heBdef, heAdef, ← Real.exp_add]; congr 1; rw [hadef, hbdef]; ring — the exp_add direction: ← Real.exp_add : exp(x)*exp(y) → exp(x+y): goal after rw [heBdef, heAdef]: exp(−b*s) = exp(−a*s)*exp(−s/2) → rw [← Real.exp_add] turns RHS into exp(−a*s + −(s/2)): congr 1: −b*s = −a*s + −(s/2): with a = 2L−1/2, b = 2L: rw [hadef, hbdef]; ring ✓ — but WAIT: hadef : a = b − 1/2?? Earlier context shows `hadef : a = b - 1 / 2` — interesting: `set a := 2*L − 1/2 with hadef` — hadef : a = 2*L−1/2... the print showed `hadef : a = b - 1 / 2` — because b was ALSO set to 2*L and set replaced 2*L with b INSIDE hadef!! So hadef : a = b − 1/2 ✓ that's actually convenient: b − a = 1/2 directly. So in heB': rw [hadef] rewrites a → (b−1/2): goal −b*s = −(b−1/2)*s + −(s/2): ring ✓.\n\nAnd hbdef : b = 2*L ✓.\n\nOK apply the exp_neg fixes (two spots). Also the `show -a * Real.sqrt 20 = -(a * Real.sqrt 20) by ring` — neg_mul ✓ ring.","signature":""},{"type":"text","text":"Found it: `-a * √20` parses as `(-a) * √20`, so `Real.exp_neg` (pattern `exp (-x)`) can't match. Fixing both spots."},{"type":"tool_use","id":"Edit_225","name":"Edit","input":{"file_path":"D:\\Python\\Quantum\\research\\lean\\NguyenRH1\\NguyenRH1\\LiSkeleton.lean","old_string":"        rw [Real.exp_neg]\n        calc (Real.exp (a * Real.sqrt 20))⁻¹ ≤ 1 / 47.01 :=\n              one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 47.01) hsum\n          _ ≤ 0.0212721 := by\n              rw [div_le_iff₀ (by norm_num : (0 : ℝ) < 47.01)]; norm_num","new_string":"        rw [show -a * Real.sqrt 20 = -(a * Real.sqrt 20) by ring, Real.exp_neg]\n        calc (Real.exp (a * Real.sqrt 20))⁻¹ ≤ 1 / 47.01 :=\n              one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 47.01) hsum\n          _ ≤ 0.0212721 := by\n              rw [div_le_iff₀ (by norm_num : (0 : ℝ) < 47.01)]; norm_num"},"extra_content":null}]