← Session 33 — ii′-3b/3c crux + F-D finding; Lagarias letter package
thinking (7513 chars)
`mem_reProdIm {z : ℂ} {s t : Set ℝ} : z ∈ s ×ℂ t ↔ z.re ∈ s ∧ z.im ∈ t` — it's `Complex.mem_reProdIm`. Use it in the rw chain: rw [RectangleBorder, Set.mem_union ×3, mem_reProdIm ×4, Set.mem_singleton_iff ×4] at hs — then the pieces become (s.re ∈ uIcc ∧ s.im = z.im) ∨ (s.re = z.re ∧ s.im ∈ uIcc) ∨ ... and rcases on the Or/And keeps the Eqs as hypotheses WITHOUT cases (since rw already converted the memberships to Eqs — wait, rcases will STILL cases the Eqs s.im = z.im etc.!).
Hmm — but wait: after the rw, hs is `(s.re ∈ uIcc ∧ s.im = z.im) ∨ ...` — rcases destructures the And's and the Eq's — cases on `s.im = z.im` — sides s.im vs z.im = (↑(-5/2) − ↑T·I).im — a projection vs compound — NOT defeq → SAME failure!
The pattern that WORKED: `rcases hs with ⟨h1, h2⟩` on a single ×ℂ piece — there, h1 : s.re ∈ {w.re} remained as a MEMBERSHIP hypothesis (not cases'd). So the safe rule: rcases may destructure And/Or but the destructuring of the Eq... hmm — in the passing test, h1 : s.re ∈ {w.re} — did rcases keep it as membership or convert to Eq? It PASSED, so whatever it did was fine. And in the union case, `rcases hs with hb | hb | hb | hb` failed — maybe because it destructures the And in each piece AND the Eq — the recursion depth. With flat patterns `hb`, does rcases recurse into the And? The error suggests yes (or the Eq cases came from something else).
Let me test the exact thing: after rw [..., mem_reProdIm ×4, Set.mem_singleton_iff ×4], do `rcases hs with ⟨hre1, him1⟩ | ⟨hre2, him2⟩ | ⟨hre3, him3⟩ | ⟨hre4, him4⟩` — the Eq him : s.im = z.im gets... hmm — rcases on an Eq hypothesis: from my earlier test, `rcases h with h1` on `s.re = 5` PASSED — so rcases does NOT cases Eqs (keeps them). Then why did the border union rcases fail?!
Look VERY carefully at the failing equation once more: `Real.add✝ (↑(2 * √↑n)).re (↑T * I).re = s.1`. Now — `s.1` — in ALL my tests s : ℂ — s.1 = s.re. And `Real.add✝ (↑(2√n)).re (↑T·I).re` — hmm — actually maybe this is `(↑(2√n) + (↑T * I)).re`?? with `.re` applied to the SUM: precedence of `.re` (field notation) vs `Real.add✝`... The display `Real.add✝ (↑(2 * √↑n)).re (↑T * I).re` — if it were re(sum), it'd display as `(↑(2√n) + ↑T*I).re`. The actual display has Real.add✝ FIRST — so it's Real.add applied to (↑(2√n)).re and (↑T*I).re: `re(↑(2√n)) + re(↑T*I)`. But wait — (↑(2√n)).re is re of the CAST — displays as `(↑(2 * √↑n)).re` ✓. So the equation is `re(↑(2√n)) + re(↑T·I) = s.1`.
Where does `re(↑(2√n)) + re(↑T·I)` come from? w.re = (↑(2√n) + ↑T·I).re — Complex.add_re is defeq-rfl so it DISPLAYS however the elaborator left it — hmm — actually (a + b).re is NOT defeq to a.re + b.re as TERMS unless the elaborator unfolds Complex.add's definition (instAdd → Complex.add → structure constructor). During rcases' whnf, yes it can unfold to `(↑(2√n)).re + (↑T·I).re`? no — whnf of (a + b).re gives a.re + b.re only after unfolding add — then re(↑(2√n)) = ↑(2√n) (ofReal_re defeq? ↑(2√n) = ⟨2√n, 0⟩? the cast ↑r : ℝ → ℂ is ofReal r = ⟨r, 0⟩ — re(⟨r,0⟩) = r defeq ✓) and re(↑T·I) = re(⟨T,0⟩·⟨0,1⟩) = re(⟨T·0−0·1, T·1+0·0⟩) = T·0−0·1 = 0 defeq ✓. So the Eq `s.re = (↑(2√n) + ↑T·I).re` whnf's to `s.re = 2√n + 0`?? and then `s.re = 2√n`... and cases on it: sides s.re vs 2√n — both stuck terms, not defeq → dependent elimination fails. The displayed equation is mid-whnf: `re(↑(2√n)) + re(↑T·I) = s.1` ✓ consistent.
So the Eq-cases fails because sides are non-defeq. But in my `s.re = 5` test rcases PASSED. WHY? Maybe because in that test rcases had NOTHING else to do (the goal was `trivial`) — rcases h with h1: it cases h... and it PASSED?! Eq cases with non-defeq sides should fail...
OHHH — I think I finally understand: `rcases h with h1` on an Eq h : a = b: rcases tries `subst h` — subst works if a or b is a FREE VARIABLE (local hyp). s.re is not a variable; 5 is not a variable — subst FAILS — and rcases then just keeps h as a hypothesis named h1 (fallback). BUT `cases` (the tactic) on the SAME Eq FAILS (dependent elimination). So: does `rcases` use `cases` or `subst`? It uses subst when possible, else keeps. But `cases h` (the cases TACTIC) always fails on non-defeq Eq. So where did `cases` fire in the border test?!
The border test error: "Tactic `cases` failed with a nested error" — `cases` — not `subst`. So SOMETHING called `cases`. In rcases on the union `rcases hs with hb | hb | hb | hb`: destructuring the Or uses `cases` (Or.elim via cases — fine). Destructuring the And in each piece: fine. Destructuring the Eq... — WAIT: maybe it's not the Eq — maybe it's `Set.uIcc`?? uIcc membership: s.re ∈ uIcc z.re w.re — uIcc a b = Icc (min a b) (max a b) — membership: s.re ∈ Icc (min ..) (max ..) — an And (≤ ∧ ≤) — fine.
Hmm, or the ×ℂ: `s ∈ {w.re} ×ℂ [[z.im, w.im]]` — reProdIm membership — if reProdIm is defined via `equivRealProd` image/preimage: `s ∈ reProdIm A B ↔ (s.re, s.im) ∈ A ×ˢ B`?? — Set.prod membership: (a, b) ∈ A ×ˢ B ↔ a ∈ A ∧ b ∈ B ✓ And. But if rcases destructures s into a PAIR (s.1, s.2) — for Set.prod membership, rcases might destructure the ELEMENT as a pair: s becomes ⟨s.1, s.2⟩ — and then the singleton membership `s.1 ∈ {w.re}` — `Set.singleton` membership — and rcases destructures singleton membership via... `Set.eq_of_mem_singleton` — an Eq — `cases` on `s.1 = w.re` — s.1 a variable?? — if s.1 IS a variable, subst works... but the error shows the Eq `(↑(2√n)+↑T·I).re = s.1` with s.1 — and "failed to solve" — if s.1 were a variable, subst would work. So s.1 is NOT a variable — it's s.re displayed as s.1.
I'm going in circles. NEW STRATEGY: avoid the border decomposition entirely by proving a helper lemma `border_piecewise` ONCE via a fully manual Or-elimination that never lets a tactic cases the Eq: use `Or.elim`/`And.intro` in term/tactic mode with `.mp` projections only:
```lean
have key : s.im = z.im ∨ s.re = z.re ∨ s.im = w.im ∨ s.re = w.re := by
rw [RectangleBorder] at hs
-- eliminate the union manually
have hs' := hs
simp only [Set.mem_union, mem_reProdIm, Set.mem_singleton_iff] at hs'
-- hs' : (s.re ∈ uIcc z.re w.re ∧ s.im = z.im) ∨ (s.re = z.re ∧ s.im ∈ uIcc z.im w.im) ∨
-- (s.re ∈ uIcc z.re w.re ∧ s.im = w.im) ∨ (s.re = w.re ∧ s.im ∈ uIcc z.im w.im)
tauto
```
The simp only with mem_reProdIm + Set.mem_singleton_iff converts to the And/Eq Prop-form WITHOUT cases (rw never cases). Then `tauto` proves the stripped disjunction propositionally — no cases on the Eqs (tauto treats them as atoms). THEN downstream, the four cases come from `key`'s disjunction — rcases on key: it contains Eqs (s.im = z.im) — rcases on the Or — and KEEPS each Eq as hypothesis (rcases on Eqs keeps them, per my passing `s.re = 5` test!). The border test's failure came from cases-ing `s ∈ {w.re} ×ℂ ...` — with key, the pieces are already Eqs — rcases on key's Or/And: keeps Eqs ✓ (per the passing test).
But WAIT — the passing test `rcases h with h1` on `s.re = 5`: if rcases kept the Eq, fine. But in the border test, the failing `cases` — maybe it wasn't the Eq at all but the `Set.singleton` MEMBERSHIP: `s.1 ∈ {w.re}` — cases on SET SINGLETON MEMBERSHIP uses `Set.eq_of_mem_singleton` and then Eq.cases?? — the "at case Eq.refl" — with the equation `... = s.1`...
Hmm — whatever — the simp-only + tauto route avoids it. Also mem_reProdIm needs the `Complex.` prefix? It's in Mathlib Data/Complex/Basic: `theorem mem_reProdIm` — namespace Complex? The file has `namespace Complex` presumably ✓ so `Complex.mem_reProdIm`.
Test it.
`Complex.mem_reProdIm` exists. Testing the simp-only + tauto route that avoids cases entirely.
tool: Bash
input
{
"command": "cd D:/Python/Quantum/research/lean/NguyenRH1 && cat > Scratch.lean << 'EOF'\nimport Mathlib\nimport NguyenRH1.LiSides\nopen Zeta23 Complex Filter Topology\nnoncomputable section\nnamespace NguyenRH1\nexample {n : \u2115} {T : \u211d} (s : \u2102)\n (hs : s \u2208 RectangleBorder (((-5/2 : \u211d) : \u2102) - (T : \u211d) * Complex.I)\n (((2 * Real.sqrt n : \u211d) : \u2102) + (T : \u211d) * Complex.I)) : True := by\n have key : s.im = (((-5/2 : \u211d) : \u2102) - (T : \u211d) * Complex.I).im \u2228\n s.re = (((-5/2 : \u211d) : \u2102) - (T : \u211d) * Complex.I).re \u2228\n s.im = (((2 * Real.sqrt n : \u211d) : \u2102) + (T : \u211d) * Complex.I).im \u2228\n s.re = (((2 * Real.sqrt n : \u211d) : \u2102) + (T : \u211d) * Complex.I).re := by\n rw [RectangleBorder] at hs\n simp only [Set.mem_union, Complex.mem_reProdIm, Set.mem_singleton_iff] at hs\n tauto\n rcases key with him | hre | him2 | hre2\n \u00b7 trivial\n \u00b7 trivial\n \u00b7 trivial\n \u00b7 trivial\nend NguyenRH1\nEOF\nexport PATH=\"$HOME/.elan/bin:$PATH\" && lake env lean Scratch.lean 2>&1 | head -12",
"description": "Test the key-disjunction + tauto route",
"timeout": 300000
}
raw content_json (database row)
[{"type":"thinking","thinking":"`mem_reProdIm {z : ℂ} {s t : Set ℝ} : z ∈ s ×ℂ t ↔ z.re ∈ s ∧ z.im ∈ t` — it's `Complex.mem_reProdIm`. Use it in the rw chain: rw [RectangleBorder, Set.mem_union ×3, mem_reProdIm ×4, Set.mem_singleton_iff ×4] at hs — then the pieces become (s.re ∈ uIcc ∧ s.im = z.im) ∨ (s.re = z.re ∧ s.im ∈ uIcc) ∨ ... and rcases on the Or/And keeps the Eqs as hypotheses WITHOUT cases (since rw already converted the memberships to Eqs — wait, rcases will STILL cases the Eqs s.im = z.im etc.!).\n\nHmm — but wait: after the rw, hs is `(s.re ∈ uIcc ∧ s.im = z.im) ∨ ...` — rcases destructures the And's and the Eq's — cases on `s.im = z.im` — sides s.im vs z.im = (↑(-5/2) − ↑T·I).im — a projection vs compound — NOT defeq → SAME failure!\n\nThe pattern that WORKED: `rcases hs with ⟨h1, h2⟩` on a single ×ℂ piece — there, h1 : s.re ∈ {w.re} remained as a MEMBERSHIP hypothesis (not cases'd). So the safe rule: rcases may destructure And/Or but the destructuring of the Eq... hmm — in the passing test, h1 : s.re ∈ {w.re} — did rcases keep it as membership or convert to Eq? It PASSED, so whatever it did was fine. And in the union case, `rcases hs with hb | hb | hb | hb` failed — maybe because it destructures the And in each piece AND the Eq — the recursion depth. With flat patterns `hb`, does rcases recurse into the And? The error suggests yes (or the Eq cases came from something else).\n\nLet me test the exact thing: after rw [..., mem_reProdIm ×4, Set.mem_singleton_iff ×4], do `rcases hs with ⟨hre1, him1⟩ | ⟨hre2, him2⟩ | ⟨hre3, him3⟩ | ⟨hre4, him4⟩` — the Eq him : s.im = z.im gets... hmm — rcases on an Eq hypothesis: from my earlier test, `rcases h with h1` on `s.re = 5` PASSED — so rcases does NOT cases Eqs (keeps them). Then why did the border union rcases fail?! \n\nLook VERY carefully at the failing equation once more: `Real.add✝ (↑(2 * √↑n)).re (↑T * I).re = s.1`. Now — `s.1` — in ALL my tests s : ℂ — s.1 = s.re. And `Real.add✝ (↑(2√n)).re (↑T·I).re` — hmm — actually maybe this is `(↑(2√n) + (↑T * I)).re`?? with `.re` applied to the SUM: precedence of `.re` (field notation) vs `Real.add✝`... The display `Real.add✝ (↑(2 * √↑n)).re (↑T * I).re` — if it were re(sum), it'd display as `(↑(2√n) + ↑T*I).re`. The actual display has Real.add✝ FIRST — so it's Real.add applied to (↑(2√n)).re and (↑T*I).re: `re(↑(2√n)) + re(↑T*I)`. But wait — (↑(2√n)).re is re of the CAST — displays as `(↑(2 * √↑n)).re` ✓. So the equation is `re(↑(2√n)) + re(↑T·I) = s.1`.\n\nWhere does `re(↑(2√n)) + re(↑T·I)` come from? w.re = (↑(2√n) + ↑T·I).re — Complex.add_re is defeq-rfl so it DISPLAYS however the elaborator left it — hmm — actually (a + b).re is NOT defeq to a.re + b.re as TERMS unless the elaborator unfolds Complex.add's definition (instAdd → Complex.add → structure constructor). During rcases' whnf, yes it can unfold to `(↑(2√n)).re + (↑T·I).re`? no — whnf of (a + b).re gives a.re + b.re only after unfolding add — then re(↑(2√n)) = ↑(2√n) (ofReal_re defeq? ↑(2√n) = ⟨2√n, 0⟩? the cast ↑r : ℝ → ℂ is ofReal r = ⟨r, 0⟩ — re(⟨r,0⟩) = r defeq ✓) and re(↑T·I) = re(⟨T,0⟩·⟨0,1⟩) = re(⟨T·0−0·1, T·1+0·0⟩) = T·0−0·1 = 0 defeq ✓. So the Eq `s.re = (↑(2√n) + ↑T·I).re` whnf's to `s.re = 2√n + 0`?? and then `s.re = 2√n`... and cases on it: sides s.re vs 2√n — both stuck terms, not defeq → dependent elimination fails. The displayed equation is mid-whnf: `re(↑(2√n)) + re(↑T·I) = s.1` ✓ consistent.\n\nSo the Eq-cases fails because sides are non-defeq. But in my `s.re = 5` test rcases PASSED. WHY? Maybe because in that test rcases had NOTHING else to do (the goal was `trivial`) — rcases h with h1: it cases h... and it PASSED?! Eq cases with non-defeq sides should fail...\n\nOHHH — I think I finally understand: `rcases h with h1` on an Eq h : a = b: rcases tries `subst h` — subst works if a or b is a FREE VARIABLE (local hyp). s.re is not a variable; 5 is not a variable — subst FAILS — and rcases then just keeps h as a hypothesis named h1 (fallback). BUT `cases` (the tactic) on the SAME Eq FAILS (dependent elimination). So: does `rcases` use `cases` or `subst`? It uses subst when possible, else keeps. But `cases h` (the cases TACTIC) always fails on non-defeq Eq. So where did `cases` fire in the border test?!\n\nThe border test error: \"Tactic `cases` failed with a nested error\" — `cases` — not `subst`. So SOMETHING called `cases`. In rcases on the union `rcases hs with hb | hb | hb | hb`: destructuring the Or uses `cases` (Or.elim via cases — fine). Destructuring the And in each piece: fine. Destructuring the Eq... — WAIT: maybe it's not the Eq — maybe it's `Set.uIcc`?? uIcc membership: s.re ∈ uIcc z.re w.re — uIcc a b = Icc (min a b) (max a b) — membership: s.re ∈ Icc (min ..) (max ..) — an And (≤ ∧ ≤) — fine.\n\nHmm, or the ×ℂ: `s ∈ {w.re} ×ℂ [[z.im, w.im]]` — reProdIm membership — if reProdIm is defined via `equivRealProd` image/preimage: `s ∈ reProdIm A B ↔ (s.re, s.im) ∈ A ×ˢ B`?? — Set.prod membership: (a, b) ∈ A ×ˢ B ↔ a ∈ A ∧ b ∈ B ✓ And. But if rcases destructures s into a PAIR (s.1, s.2) — for Set.prod membership, rcases might destructure the ELEMENT as a pair: s becomes ⟨s.1, s.2⟩ — and then the singleton membership `s.1 ∈ {w.re}` — `Set.singleton` membership — and rcases destructures singleton membership via... `Set.eq_of_mem_singleton` — an Eq — `cases` on `s.1 = w.re` — s.1 a variable?? — if s.1 IS a variable, subst works... but the error shows the Eq `(↑(2√n)+↑T·I).re = s.1` with s.1 — and \"failed to solve\" — if s.1 were a variable, subst would work. So s.1 is NOT a variable — it's s.re displayed as s.1.\n\nI'm going in circles. NEW STRATEGY: avoid the border decomposition entirely by proving a helper lemma `border_piecewise` ONCE via a fully manual Or-elimination that never lets a tactic cases the Eq: use `Or.elim`/`And.intro` in term/tactic mode with `.mp` projections only:\n\n```lean\n have key : s.im = z.im ∨ s.re = z.re ∨ s.im = w.im ∨ s.re = w.re := by\n rw [RectangleBorder] at hs\n -- eliminate the union manually\n have hs' := hs\n simp only [Set.mem_union, mem_reProdIm, Set.mem_singleton_iff] at hs'\n -- hs' : (s.re ∈ uIcc z.re w.re ∧ s.im = z.im) ∨ (s.re = z.re ∧ s.im ∈ uIcc z.im w.im) ∨\n -- (s.re ∈ uIcc z.re w.re ∧ s.im = w.im) ∨ (s.re = w.re ∧ s.im ∈ uIcc z.im w.im)\n tauto\n```\nThe simp only with mem_reProdIm + Set.mem_singleton_iff converts to the And/Eq Prop-form WITHOUT cases (rw never cases). Then `tauto` proves the stripped disjunction propositionally — no cases on the Eqs (tauto treats them as atoms). THEN downstream, the four cases come from `key`'s disjunction — rcases on key: it contains Eqs (s.im = z.im) — rcases on the Or — and KEEPS each Eq as hypothesis (rcases on Eqs keeps them, per my passing `s.re = 5` test!). The border test's failure came from cases-ing `s ∈ {w.re} ×ℂ ...` — with key, the pieces are already Eqs — rcases on key's Or/And: keeps Eqs ✓ (per the passing test).\n\nBut WAIT — the passing test `rcases h with h1` on `s.re = 5`: if rcases kept the Eq, fine. But in the border test, the failing `cases` — maybe it wasn't the Eq at all but the `Set.singleton` MEMBERSHIP: `s.1 ∈ {w.re}` — cases on SET SINGLETON MEMBERSHIP uses `Set.eq_of_mem_singleton` and then Eq.cases?? — the \"at case Eq.refl\" — with the equation `... = s.1`... \n\nHmm — whatever — the simp-only + tauto route avoids it. Also mem_reProdIm needs the `Complex.` prefix? It's in Mathlib Data/Complex/Basic: `theorem mem_reProdIm` — namespace Complex? The file has `namespace Complex` presumably ✓ so `Complex.mem_reProdIm`.\n\nTest it.","signature":""},{"type":"text","text":"`Complex.mem_reProdIm` exists. Testing the simp-only + tauto route that avoids cases entirely."},{"type":"tool_use","id":"Bash_280","name":"Bash","input":{"command":"cd D:/Python/Quantum/research/lean/NguyenRH1 && cat > Scratch.lean << 'EOF'\nimport Mathlib\nimport NguyenRH1.LiSides\nopen Zeta23 Complex Filter Topology\nnoncomputable section\nnamespace NguyenRH1\nexample {n : ℕ} {T : ℝ} (s : ℂ)\n (hs : s ∈ RectangleBorder (((-5/2 : ℝ) : ℂ) - (T : ℝ) * Complex.I)\n (((2 * Real.sqrt n : ℝ) : ℂ) + (T : ℝ) * Complex.I)) : True := by\n have key : s.im = (((-5/2 : ℝ) : ℂ) - (T : ℝ) * Complex.I).im ∨\n s.re = (((-5/2 : ℝ) : ℂ) - (T : ℝ) * Complex.I).re ∨\n s.im = (((2 * Real.sqrt n : ℝ) : ℂ) + (T : ℝ) * Complex.I).im ∨\n s.re = (((2 * Real.sqrt n : ℝ) : ℂ) + (T : ℝ) * Complex.I).re := by\n rw [RectangleBorder] at hs\n simp only [Set.mem_union, Complex.mem_reProdIm, Set.mem_singleton_iff] at hs\n tauto\n rcases key with him | hre | him2 | hre2\n · trivial\n · trivial\n · trivial\n · trivial\nend NguyenRH1\nEOF\nexport PATH=\"$HOME/.elan/bin:$PATH\" && lake env lean Scratch.lean 2>&1 | head -12","description":"Test the key-disjunction + tauto route","timeout":300000},"extra_content":null}]