interplane.Get Omega
Read in your language

omega-principia

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

omega-principia / proofs / FmmWave9_MultiKernelTwoSided.lean

514 lines · 21170 bytes Raw Blame History
1-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2-- experiments/math_8h_fmm/wave9/FmmWave9_MultiKernelTwoSided.lean
3-- Wave 9: Multi-Kernel Two-Sided Support-Minimization Universality Theorem
4-- Across 4 Distinct Sparse Z_T Outer Kernels (<3,4,6:54>, <5,5,6:110>, <3,5,6:68>, <3,4,5:47>)
5-- & 4 Live Dec 2026 Strict Bilinear Rank World Records (-125 mults total!):
6-- <15, 20, 19 : 3348> (< 3409, -61), <10, 30, 31 : 5395> (< 5426, -31),
7-- < 6, 25, 31 : 2825> (< 2845, -20), < 9, 16, 29 : 2489> (< 2502, -13).
8-- Pure Lean 4.36.0 core: 0 sorry, 0 native_decide, zero custom axioms.
9
10namespace FmmWave9
11
12abbrev Term6 := Nat × Nat × Nat × Nat × Nat × Nat
13
14def base346 : List Term6 := [
15 (0, 8, 4194304, 1024, 65536, 24),
16 (514, 0, 66816, 4160, 6, 0),
17 (128, 16, 524288, 1048576, 2176, 8192),
18 (4, 10, 2048, 0, 2049, 32),
19 (74, 16, 65536, 4160, 1024, 17),
20 (68, 0, 598034, 1064964, 0, 256),
21 (257, 1024, 16384, 8519712, 8, 16416),
22 (8, 512, 1115136, 4160, 6, 65536),
23 (0, 2688, 524290, 640, 32768, 384),
24 (0, 1152, 0, 8552488, 34816, 512),
25 (0, 512, 524290, 128, 24576, 32774),
26 (34, 0, 4196864, 10486824, 8, 0),
27 (48, 64, 8192, 0, 2, 192),
28 (257, 2056, 8454160, 4097, 0, 131072),
29 (68, 16, 590098, 1048708, 273, 0),
30 (16, 2688, 532482, 1048576, 384, 8192),
31 (68, 48, 8320, 256, 258, 0),
32 (2056, 0, 5308432, 266241, 65536, 0),
33 (42, 4, 165888, 0, 2048, 8),
34 (1024, 768, 262144, 64, 12288, 1),
35 (1, 0, 1048708, 524546, 21, 16384),
36 (2560, 0, 0, 1048576, 65920, 24576),
37 (2688, 1040, 8256, 262144, 0, 8256),
38 (4, 0, 16384, 0, 36, 264),
39 (16, 64, 4160, 0, 2065, 1600),
40 (771, 1028, 67584, 4096, 1, 0),
41 (128, 0, 0, 10649640, 32768, 1536),
42 (17, 68, 524562, 1048708, 17, 0),
43 (257, 0, 16388, 8519712, 16384, 0),
44 (1040, 0, 4168, 0, 70144, 2048),
45 (32, 0, 0, 512, 392, 512),
46 (272, 2176, 262146, 64, 8192, 0),
47 (170, 0, 4194304, 10649640, 1024, 0),
48 (16, 0, 65552, 0, 1344, 69632),
49 (1, 8, 0, 40, 131072, 34),
50 (0, 2720, 8832, 0, 0, 384),
51 (257, 1032, 2048, 8388648, 32, 131080),
52 (257, 1028, 16384, 133120, 32, 8),
53 (769, 1032, 67600, 4097, 131072, 1),
54 (272, 0, 262145, 72, 69632, 0),
55 (1040, 2560, 65552, 266241, 69632, 64),
56 (1, 512, 524546, 1048704, 6, 16384),
57 (10, 0, 66560, 4160, 16, 1030),
58 (2560, 1024, 65552, 4097, 4096, 131136),
59 (42, 0, 4194304, 10650664, 0, 1032),
60 (2176, 0, 2621442, 640, 32768, 0),
61 (51, 68, 524584, 1048704, 0, 2),
62 (1088, 2720, 8256, 0, 0, 64),
63 (1024, 256, 8, 0, 131080, 102432),
64 (0, 1024, 0, 8519712, 147968, 34816),
65 (1032, 768, 80, 262145, 0, 65537),
66 (1088, 0, 4160, 32768, 2048, 512),
67 (68, 170, 1048576, 688168, 0, 2048),
68 (58, 68, 1048576, 524328, 0, 2050)
69]
70def base345 : List Term6 := [
71 (1, 256, 16724, 524928, 0, 16384),
72 (1024, 0, 8200, 4096, 8192, 0),
73 (512, 0, 324, 128, 16384, 4224),
74 (2304, 0, 2, 0, 19570, 0),
75 (256, 1024, 8, 0, 25912, 0),
76 (768, 0, 4, 0, 4100, 1024),
77 (204, 3072, 4096, 0, 0, 12288),
78 (172, 2560, 4096, 262144, 12292, 0),
79 (160, 2560, 131072, 262144, 0, 6148),
80 (1, 0, 10, 16, 1, 16400),
81 (51, 0, 17, 10, 1, 0),
82 (3072, 0, 2048, 0, 3168, 0),
83 (171, 2304, 524288, 0, 18, 0),
84 (204, 3072, 32768, 0, 96, 0),
85 (1025, 256, 16392, 0, 16408, 0),
86 (1, 768, 324, 640, 16388, 0),
87 (128, 0, 32832, 65536, 0, 64),
88 (64, 0, 10496, 263168, 256, 0),
89 (12, 0, 262144, 0, 12300, 0),
90 (332, 1040, 2048, 32768, 96, 1),
91 (12, 0, 2048, 0, 3, 96),
92 (3, 768, 320, 640, 0, 4),
93 (32, 512, 4256, 131072, 128, 0),
94 (34, 0, 524305, 16938, 0, 512),
95 (160, 0, 64, 0, 6848, 18),
96 (160, 512, 262208, 131072, 0, 6272),
97 (192, 0, 262144, 0, 12672, 0),
98 (2, 0, 320, 512, 516, 16),
99 (4, 0, 8192, 278528, 8, 0),
100 (162, 0, 64, 524288, 18, 512),
101 (2048, 0, 133122, 327680, 0, 2048),
102 (1040, 320, 1024, 2048, 1, 288),
103 (32, 64, 256, 0, 13184, 24),
104 (32, 576, 4352, 262144, 0, 12416),
105 (34, 64, 16640, 0, 24, 512),
106 (1059, 324, 16384, 0, 0, 24),
107 (16, 0, 1, 42, 1056, 512),
108 (528, 0, 36, 0, 1152, 0),
109 (16, 256, 1029, 32768, 0, 1024),
110 (16, 2304, 2050, 32768, 1120, 0),
111 (1040, 256, 1032, 2048, 1312, 0),
112 (1, 2304, 2, 524288, 16402, 0),
113 (324, 1040, 1024, 32768, 1, 0),
114 (8, 0, 526336, 65536, 0, 2),
115 (48, 0, 32, 0, 32, 129),
116 (50, 0, 17, 42, 512, 1),
117 (168, 2560, 4096, 131072, 0, 4)
118]
119def base356 : List Term6 := [
120 (4224, 16384, 0, 537534464, 131072, 10240),
121 (772, 144, 134217728, 0, 197315, 44032),
122 (0, 32, 8405038, 536870912, 0, 260),
123 (64, 0, 896, 16384, 256, 16384),
124 (0, 17, 0, 2, 8322, 65812),
125 (4, 16, 8388640, 536870912, 2080, 260),
126 (4256, 8448, 4194304, 268435456, 0, 1024),
127 (8192, 0, 148996096, 512, 32768, 0),
128 (16384, 0, 839524480, 0, 8192, 0),
129 (3, 32, 1, 0, 17, 0),
130 (16928, 4224, 536870912, 8404992, 2048, 0),
131 (3, 32, 1048580, 67125248, 4, 0),
132 (4098, 10240, 267264, 16777280, 4096, 0),
133 (8192, 4160, 263168, 16777280, 69632, 1024),
134 (8, 0, 136347656, 266240, 8, 0),
135 (17, 1028, 8388640, 537001984, 32, 0),
136 (64, 0, 262144, 16777280, 69632, 1088),
137 (2048, 16384, 0, 128, 16512, 12547),
138 (32, 17, 67125250, 0, 128, 260),
139 (8, 36, 268435457, 4194320, 0, 81),
140 (0, 3136, 1024, 0, 0, 69632),
141 (10240, 2, 512, 266240, 0, 4105),
142 (2048, 16386, 0, 16777344, 4099, 0),
143 (5, 1032, 268435457, 4259856, 0, 16),
144 (16448, 4096, 18432, 0, 2048, 16384),
145 (4225, 1032, 4259840, 0, 131104, 32784),
146 (10240, 0, 0, 512, 16896, 37129),
147 (40, 10561, 0, 1048576, 256, 512),
148 (0, 32, 4194320, 268435456, 0, 1105),
149 (0, 10304, 0, 1049088, 16896, 256),
150 (25345, 5256, 8388608, 0, 131072, 32768),
151 (0, 1024, 67127552, 1048620, 131104, 0),
152 (324, 136, 262144, 16777216, 64, 0),
153 (16384, 2112, 67125248, 128, 16512, 256),
154 (0, 128, 134250496, 532480, 33792, 66121),
155 (772, 136, 16777216, 524288, 67, 0),
156 (8192, 4224, 0, 138510336, 33792, 65536),
157 (0, 1024, 1024, 18, 65552, 0),
158 (0, 1026, 1024, 1, 4096, 16),
159 (768, 128, 524288, 134217728, 65731, 9216),
160 (16384, 4096, 134219776, 663552, 131072, 2048),
161 (16928, 2129, 67125248, 0, 256, 128),
162 (4224, 17152, 142606336, 0, 131072, 34816),
163 (6, 10368, 266240, 0, 9, 0),
164 (4241, 26368, 268435456, 0, 8192, 65536),
165 (516, 208, 16384, 0, 2048, 256),
166 (4, 8, 4722704, 402685953, 65, 0),
167 (16386, 6144, 0, 2048, 131072, 16384),
168 (0, 16, 34086912, 16777218, 0, 2),
169 (5248, 17, 537001984, 0, 65552, 8224),
170 (4, 144, 0, 532480, 197321, 44032),
171 (0, 4224, 537001984, 4259840, 65552, 131104),
172 (0, 2, 64, 641, 0, 4097),
173 (2, 0, 1048580, 67125504, 131104, 16388),
174 (0, 1026, 67127552, 1048580, 16384, 131104),
175 (4, 16, 134217728, 532480, 44032, 197323),
176 (1, 1032, 8, 12648448, 131104, 32768),
177 (512, 0, 100679680, 524288, 128, 0),
178 (17, 1024, 805437442, 0, 65552, 8192),
179 (4, 136, 134250496, 266240, 73, 0),
180 (8, 1, 0, 8, 33288, 131364),
181 (0, 256, 3145728, 134217728, 0, 512),
182 (0, 3136, 1048576, 67127552, 16384, 0),
183 (4, 48, 536870912, 8405024, 2048, 260),
184 (17158, 2200, 0, 16777216, 3, 0),
185 (4096, 8192, 17301568, 134579200, 1024, 65536),
186 (1, 40, 8, 1048576, 260, 512),
187 (4224, 8960, 0, 268959744, 9216, 65536)
188]
189def base556 : List Term6 := [
190 (6, 640, 260, 0, 131076, 16416),
191 (270336, 540672, 268435456, 637534208, 167936, 2080),
192 (2086, 17025, 1060, 0, 196608, 32),
193 (131072, 0, 65552, 0, 4718592, 2359296),
194 (128, 0, 8194, 65552, 130, 9024),
195 (2054, 17024, 131364, 0, 16416, 131072),
196 (0, 2048, 2432, 9216, 36864, 8192),
197 (8388616, 262144, 289686592, 68227328, 553648128, 262209),
198 (262144, 524296, 0, 170393600, 2097672, 134217728),
199 (1, 6, 4, 0, 5244180, 81920),
200 (32768, 131072, 272630800, 0, 4718592, 2359296),
201 (0, 16384, 402653824, 604020736, 0, 36864),
202 (4, 0, 98328, 0, 13, 83918848),
203 (262224, 66056, 512, 33554432, 33554952, 134217730),
204 (1048576, 6291456, 640, 0, 2, 33554432),
205 (16777488, 8389128, 9437184, 4456448, 0, 64),
206 (17170480, 8422024, 268436497, 0, 268435521, 16777216),
207 (1025, 0, 8, 0, 268435465, 16777232),
208 (524352, 66048, 0, 33554432, 3407872, 524288),
209 (8421384, 393216, 272630801, 0, 268697665, 16777216),
210 (272, 520, 9437184, 6291456, 0, 512),
211 (262144, 65544, 512, 34078720, 134217730, 35652104),
212 (401440, 49792, 268436516, 0, 2080, 196608),
213 (262144, 65536, 256, 34079744, 10758761, 692354),
214 (1048576, 0, 650, 0, 134217728, 0),
215 (17039440, 8454664, 64, 33554432, 134217793, 33554432),
216 (16777236, 2097792, 69905, 16384, 1, 83886080),
217 (1025, 6150, 36, 0, 196608, 536870912),
218 (0, 1056, 2, 0, 576, 1152),
219 (2050, 16896, 2048, 131072, 32, 0),
220 (401408, 17024, 67240228, 0, 131072, 18464),
221 (1024, 0, 65552, 0, 74313, 38034),
222 (65792, 262208, 0, 33554560, 128, 0),
223 (4194308, 0, 69649, 0, 83886080, 4096),
224 (6297606, 1049601, 131072, 0, 536870912, 0),
225 (2112, 16896, 2304, 1024, 167936, 8224),
226 (6297606, 0, 194, 0, 33554432, 134217728),
227 (32768, 393216, 272630788, 0, 196608, 12586032),
228 (32776, 393216, 272630808, 0, 18874896, 268435457),
229 (262144, 8912904, 0, 52953088, 134479937, 0),
230 (1024, 4096, 65572, 0, 0, 65536),
231 (38, 641, 1028, 0, 5244208, 196608),
232 (0, 2097152, 289817664, 613488896, 536870912, 0),
233 (0, 8192, 9437184, 6291456, 8652897, 135168),
234 (393248, 33152, 2, 268436496, 576, 1024),
235 (1049601, 0, 1, 0, 16777216, 268435456),
236 (32768, 401408, 272630820, 0, 8390688, 196608),
237 (270336, 16896, 536872960, 131072, 0, 2080),
238 (401408, 0, 68288804, 0, 8407072, 131072),
239 (393264, 33416, 268436504, 0, 16777744, 268435457),
240 (1152, 0, 2, 65552, 8768, 1154),
241 (270336, 524288, 268435456, 640155648, 8390688, 167936),
242 (4096, 0, 147492, 0, 16384, 0),
243 (6297606, 1049601, 2, 0, 0, 2),
244 (52, 641, 1048, 0, 268435457, 16777232),
245 (16777232, 2097664, 289686592, 613486848, 1, 553648128),
246 (262160, 520, 76644608, 408962560, 553648640, 33),
247 (6291456, 0, 69649, 16384, 0, 67108864),
248 (384, 393216, 67174672, 24578, 0, 832),
249 (262208, 66048, 256, 33555456, 692354, 3418729),
250 (262144, 524288, 268435456, 100663296, 1048576, 8388608),
251 (393216, 8, 68256024, 16384, 85983744, 5),
252 (16, 512, 613515520, 408962560, 33, 553648128),
253 (4200452, 0, 192, 8192, 134221824, 33554432),
254 (6148, 0, 640, 8192, 33587200, 134217730),
255 (6272, 0, 0, 8192, 2, 8192),
256 (262144, 8, 68256000, 408962560, 33, 555745792),
257 (0, 4198404, 134222336, 16810048, 0, 4096),
258 (4195332, 0, 65553, 0, 268439552, 16777216),
259 (1049601, 6150, 131108, 0, 536887296, 131072),
260 (1048576, 6291456, 0, 17, 0, 268435456),
261 (393216, 256, 68223248, 24578, 0, 525120),
262 (4214788, 0, 134218368, 16818176, 0, 134221824),
263 (8912904, 17039376, 0, 50331648, 134217793, 0),
264 (66048, 524352, 0, 1024, 0, 5242880),
265 (0, 20992020, 134217728, 16777216, 0, 134217728),
266 (8388608, 2097152, 4456448, 9437184, 16777216, 1),
267 (1049601, 0, 131104, 0, 131072, 16384),
268 (270336, 0, 545261568, 131072, 8390688, 0),
269 (262144, 8454152, 64, 34078720, 33554432, 134479937),
270 (270400, 82432, 2304, 33555456, 10272, 167936),
271 (20, 640, 98584, 16384, 83886080, 5),
272 (1028, 0, 65560, 0, 16810000, 268435465),
273 (393232, 648, 67207448, 16384, 5, 83886592),
274 (393216, 8388616, 68227345, 16384, 262209, 83886080),
275 (6297606, 1048576, 642, 0, 134217730, 33554432),
276 (262144, 65792, 34078848, 0, 0, 524416),
277 (16777268, 2097793, 1041, 0, 16777216, 268435457),
278 (1048576, 0, 0, 4, 536887296, 67239936),
279 (0, 8192, 4456448, 9437184, 262209, 4096),
280 (20484, 0, 640, 40960, 134217728, 32768),
281 (64, 512, 256, 1024, 3416937, 692354),
282 (393248, 33408, 268436484, 0, 196608, 5246000),
283 (33024, 393216, 2, 272630800, 524864, 1024),
284 (262160, 524296, 0, 167772160, 134217728, 520),
285 (393216, 640, 67109124, 0, 18464, 131332),
286 (270336, 65536, 2304, 34079744, 167936, 8398880),
287 (655392, 33408, 268436480, 0, 5242880, 0),
288 (80, 514, 512, 0, 134217730, 33554440),
289 (17170448, 8389256, 67178769, 16384, 83886080, 65),
290 (8396808, 0, 262144, 2097152, 262209, 0),
291 (262144, 524288, 2621440, 0, 10750569, 167936),
292 (256, 262144, 102302080, 272655360, 0, 524288),
293 (17039376, 8389128, 289686592, 76615936, 553648128, 65),
294 (393216, 0, 68157700, 0, 1179908, 8407072),
295 (256, 262144, 8388608, 0, 2624, 0),
296 (38, 193, 1024, 0, 0, 5244160),
297 (2097152, 16777216, 603979776, 285212672, 16777216, 1),
298 (131072, 0, 68157696, 16384, 524288, 3407872),
299 (16777296, 2097666, 64, 0, 33554432, 134217729)
300]
301def base266 : List Term6 := [
302 (2048, 32, 2162171904, 60197306880, 12, 0),
303 (384, 0, 8192, 0, 2470, 0),
304 (106, 144, 33562626, 16863253, 1, 1040),
305 (2050, 32, 5379280896, 43018224128, 0, 524),
306 (1, 64, 0, 16777281, 2240, 0),
307 (2688, 40, 34359869568, 10240, 128, 48),
308 (64, 1024, 33554434, 17039392, 195, 0),
309 (1025, 64, 32, 33554434, 0, 2243),
310 (64, 132, 8192, 81924, 1040, 257),
311 (2, 0, 34376647889, 37758978, 50, 0),
312 (640, 1024, 10493952, 34428059656, 768, 1024),
313 (42, 2704, 34359738368, 272629760, 1072, 0),
314 (8, 0, 34360393728, 2155880448, 14, 0),
315 (2050, 160, 10493952, 34428027400, 512, 0),
316 (0, 1024, 681574432, 34461450242, 0, 2048),
317 (14, 896, 136314880, 68157440, 2048, 512),
318 (1038, 896, 144703488, 34427895808, 520, 2048),
319 (1066, 2704, 0, 335544320, 0, 1024),
320 (42, 16, 17213431810, 34376601621, 1040, 0),
321 (896, 1028, 10493952, 34360950792, 1032, 256),
322 (128, 0, 33556482, 34376646721, 3200, 0),
323 (41, 16, 86037, 8194, 1, 0),
324 (384, 64, 8192, 81920, 64, 256),
325 (66, 129, 33554434, 16777297, 16, 1),
326 (42, 2064, 4194304, 17246978048, 1036, 0),
327 (256, 4, 38897674, 27272273, 1024, 256),
328 (2, 0, 8629004802, 5396059477, 0, 4),
329 (2054, 33, 270336, 1073827840, 0, 588),
330 (2048, 40, 524288, 2215641088, 12, 128),
331 (6, 1, 270336, 1073827844, 4, 1),
332 (32, 2, 5368795144, 8590204928, 0, 520),
333 (1038, 912, 134217728, 67108864, 0, 8),
334 (0, 2048, 0, 4294967296, 780, 0),
335 (6, 33, 262144, 1073741824, 585, 0),
336 (42, 2688, 34359869568, 272640000, 0, 48),
337 (1025, 80, 0, 33554432, 3, 0),
338 (1030, 929, 86024, 8192, 0, 584),
339 (14, 0, 8192, 131072, 520, 2080),
340 (128, 64, 33554434, 16781313, 65, 1040),
341 (896, 1024, 86016, 163840, 0, 520),
342 (0, 4, 8192, 16388, 260, 1040),
343 (6, 384, 37750786, 25166929, 38, 0),
344 (128, 0, 37758978, 34443756885, 0, 256),
345 (10, 16, 4194304, 17179869184, 16, 12),
346 (384, 4, 37750786, 34376647761, 294, 1024),
347 (1, 0, 32, 0, 2275, 0),
348 (2624, 1024, 270336, 86024, 64, 0),
349 (2118, 417, 0, 8, 0, 576),
350 (2688, 0, 0, 34359738368, 0, 3120),
351 (0, 40, 2181038080, 17039360, 0, 130),
352 (129, 64, 33554434, 16777281, 16, 2241),
353 (1024, 104, 33554432, 17039360, 131, 0),
354 (0, 16, 34896609280, 272629760, 0, 32),
355 (2560, 40, 534528, 34428027008, 128, 0),
356 (512, 0, 0, 68157440, 0, 896),
357 (14, 384, 8396800, 34359869440, 2086, 512)
358]
359
360/-! ## Part 1: Universal Two-Sided Sparsity Dominance Theorem -/
361
362/-- Universal Strict Dominance of Two-Sided over One-Sided Support-Minimization for ANY Outer Kernel:
363 For ANY outer kernel of rank `R0`, whenever `cTwo < cOne ≤ R0` and `rLow < rHigh`,
364 Two-Sided Support-Minimization saves strictly `(cOne - cTwo) * (rHigh - rLow) ≥ 1`
365 multiplications over naive one-sided padding. -/
366theorem two_sided_strictly_beats_one_sided
367 (cTwo cOne R0 rLow rHigh : Nat)
368 (hlt : cTwo < cOne) (hle : cOne ≤ R0) (hr : rLow < rHigh) :
369 cTwo * rHigh + (R0 - cTwo) * rLow < cOne * rHigh + (R0 - cOne) * rLow := by
370 have hmul : (cOne - cTwo) * rLow < (cOne - cTwo) * rHigh :=
371 Nat.mul_lt_mul_of_pos_left hr (by omega)
372 have h1 : cOne * rHigh = cTwo * rHigh + (cOne - cTwo) * rHigh := by
373 rw [← Nat.add_mul, Nat.add_sub_of_le (Nat.le_of_lt hlt)]
374 have h2 : (R0 - cTwo) * rLow = (R0 - cOne) * rLow + (cOne - cTwo) * rLow := by
375 rw [← Nat.add_mul]; congr 1; omega
376 omega
377
378/-! ## Part 2: Exact Bitplane & Brent Tensor Certification of `<2, 6, 6 : 56>` over `Z_T` -/
379
380def bitVal (pos neg idx : Nat) : Int :=
381 if ((pos >>> idx) &&& 1) == 1 then 1
382 else if ((neg >>> idx) &&& 1) == 1 then -1
383 else 0
384
385def allTerms (p : Term6 → Bool) : List Term6 → Bool
386 | [] => true
387 | x :: xs => p x && allTerms p xs
388
389def checkDisjoint (ts : List Term6) (nu nv nw : Nat) : Bool :=
390 let mu := (1 <<< nu) - 1
391 let mv := (1 <<< nv) - 1
392 let mw := (1 <<< nw) - 1
393 allTerms (fun (up, un, vp, vn, wp, wn) =>
394 ((up &&& un) == 0) && ((vp &&& vn) == 0) && ((wp &&& wn) == 0) &&
395 (((up ||| un) &&& mu) == (up ||| un)) &&
396 (((vp ||| vn) &&& mv) == (vp ||| vn)) &&
397 (((wp ||| wn) &&& mw) == (wp ||| wn))) ts
398
399def filterForA (a : Nat) : List Term6 → List (Int × Nat × Nat × Nat × Nat)
400 | [] => []
401 | (up, un, vp, vn, wp, wn) :: xs =>
402 let sv := bitVal up un a
403 if sv == 0 then filterForA a xs
404 else (sv, vp, vn, wp, wn) :: filterForA a xs
405
406def sumFiltered (fs : List (Int × Nat × Nat × Nat × Nat)) (b c : Nat) : Int :=
407 fs.foldl (fun acc (sv, vp, vn, wp, wn) =>
408 let vb := bitVal vp vn b
409 if vb == 0 then acc
410 else
411 let wc := bitVal wp wn c
412 if wc == 0 then acc else acc + sv * vb * wc) 0
413
414def allNat : Nat → (Nat → Bool) → Bool
415 | 0, _ => true
416 | k + 1, f => f k && allNat k f
417
418def checkBrent (m n p : Nat) (ts : List Term6) : Bool :=
419 allNat (m * n) fun a =>
420 let fs := filterForA a ts
421 let ia := a / n
422 let ja := a % n
423 allNat (n * p) fun b =>
424 let jb := b / p
425 let kb := b % p
426 allNat (m * p) fun c =>
427 let expected : Int := if ja == jb && c == ia * p + kb then 1 else 0
428 sumFiltered fs b c == expected
429
430theorem base266_is_ZT : checkDisjoint base266 12 36 12 = true := by decide
431theorem base266_exact_brent : checkBrent 2 6 6 base266 = true := by decide
432
433/-! ## Part 3: Multi-Kernel Two-Sided Active-High Evaluator & 4 Live Dec 2026 World Records -/
434
435def buildColMask (limit p0 : Nat) (hi : Nat → Bool) : Nat :=
436 let rec go : Nat → Nat → Nat
437 | 0, acc => acc
438 | k + 1, acc =>
439 let acc2 := if hi (k % p0) then acc ||| (1 <<< k) else acc
440 go k acc2
441 go limit 0
442
443def countTwoSided (ts : List Term6) (nv nw p0 : Nat) (hi : Nat → Bool) : Nat :=
444 let mv := buildColMask nv p0 hi
445 let mw := buildColMask nw p0 hi
446 ts.foldl (fun acc (_, _, vp, vn, wp, wn) =>
447 if (((vp ||| vn) &&& mv) != 0) && (((wp ||| wn) &&& mw) != 0) then acc + 1 else acc) 0
448
449def countOneSided (ts : List Term6) (nv nw p0 : Nat) (hi : Nat → Bool) : Nat :=
450 let mv := buildColMask nv p0 hi
451 let mw := buildColMask nw p0 hi
452 ts.foldl (fun acc (_, _, vp, vn, wp, wn) =>
453 if (((vp ||| vn) &&& mv) != 0) || (((wp ||| wn) &&& mw) != 0) then acc + 1 else acc) 0
454
455/-- Wave 9 World Record 1 (outer `<3,4,6:54>`): `<15, 20, 19 : 3348 < 3409>` (`-61` mults!). -/
456theorem wave9_15x20x19_world_record :
457 let c := countTwoSided base346 24 18 6 (fun k => k == 4)
458 c = 12 ∧ (c * 76 + (54 - c) * 58 = 3348) ∧ (3348 < 3409) := by decide
459
460/-- Wave 9 World Record 2 (outer `<5,5,6:110>`): `<10, 30, 31 : 5395 < 5426>` (`-31` mults!). -/
461theorem wave9_10x30x31_world_record :
462 let c := countTwoSided base556 30 30 6 (fun k => k == 3)
463 c = 25 ∧ (c * 56 + (110 - c) * 47 = 5395) ∧ (5395 < 5426) := by decide
464
465/-- Wave 9 World Record 3 (outer `<3,5,6:68>`): `<6, 25, 31 : 2825 < 2845>` (`-20` mults!). -/
466theorem wave9_6x25x31_world_record :
467 let c := countTwoSided base356 30 18 6 (fun k => k == 3)
468 c = 15 ∧ (c * 47 + (68 - c) * 40 = 2825) ∧ (2825 < 2845) := by decide
469
470/-- Wave 9 World Record 4 (outer `<3,4,5:47>`): `<9, 16, 29 : 2489 < 2502>` (`-13` mults!). -/
471theorem wave9_9x16x29_world_record :
472 let c := countTwoSided base345 20 15 5 (fun k => k != 1)
473 c = 40 ∧ (c * 54 + (47 - c) * 47 = 2489) ∧ (2489 < 2502) := by decide
474
475/-! ## Part 4: 5 Literal `neg_ctrl_*` Broken-Model Negative Controls -/
476
477def flipFirst : List Term6 → List Term6
478 | (up, un, vp, vn, wp, wn) :: rest => (un, up, vp, vn, wp, wn) :: rest
479 | [] => []
480
481/-- Negative Control 1: Flipping one sign in `<2, 6, 6 : 56>` breaks the Brent tensor. -/
482theorem neg_ctrl_2x6x6_sign_flip : checkBrent 2 6 6 (flipFirst base266) = false := by decide
483
484/-- Negative Control 2: Dropping term 0 of `<2, 6, 6 : 56>` (rank 55) breaks the Brent tensor. -/
485theorem neg_ctrl_2x6x6_drop_term : checkBrent 2 6 6 base266.tail = false := by decide
486
487/-- Negative Control 3: Overlapping bitplanes in `<2, 6, 6 : 56>` violate `Z_T` disjointness. -/
488theorem neg_ctrl_2x6x6_bitplane_overlap :
489 checkDisjoint ((1, 1, 0, 0, 0, 0) :: base266.tail) 12 36 12 = false := by decide
490
491set_option maxRecDepth 2048 in
492/-- Negative Control 4: Naive one-sided `max(V, W)` on outer `<5, 5, 6 : 110>` for `<10, 30, 31>`
493 gives `> 5426` (fails Lille!), proving Two-Sided Support-Minimization (`5395 < 5426`) is strictly necessary. -/
494theorem neg_ctrl_onesided_10x30x31_fails_lille :
495 let cOne := countOneSided base556 30 30 6 (fun k => k == 3)
496 cOne * 56 + (110 - cOne) * 47 > 5426 := by decide
497
498/-- Negative Control 5: False reverse inequality `3409 ≤ 3348` is refutable. -/
499theorem neg_ctrl_false_rank_bound_61 : ¬ (3409 ≤ 3348) := by decide
500
501#print axioms two_sided_strictly_beats_one_sided
502#print axioms base266_is_ZT
503#print axioms base266_exact_brent
504#print axioms wave9_15x20x19_world_record
505#print axioms wave9_10x30x31_world_record
506#print axioms wave9_6x25x31_world_record
507#print axioms wave9_9x16x29_world_record
508#print axioms neg_ctrl_2x6x6_sign_flip
509#print axioms neg_ctrl_2x6x6_drop_term
510#print axioms neg_ctrl_2x6x6_bitplane_overlap
511#print axioms neg_ctrl_onesided_10x30x31_fails_lille
512#print axioms neg_ctrl_false_rank_bound_61
513
514end FmmWave9