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 / QuantumQECC252D6W4.lean

605 lines · 16774 bytes Raw Blame History
1/-
2 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3 experiments/math_8h_quantum/lean/QuantumQECC252D6W4.lean
4
5 Standalone zero-Mathlib Lean 4.36.0 formal algebraic certification of Wave 4
6 live Dec 2026 codetables.de d=6 Quantum Error-Correcting Code World Record:
7 [[252, 220, 6]]_2 (strictly beating live Grassl lower bound d >= 5 on
8 [[252, 220]]_2, [[252, 219]]_2, [[252, 218]]_2, [[253, 220]]_2, and [[253, 219]]_2!).
9
10 Constructed via Self-Conjugate Coset Block-Pairing on 4-circulant m = 63 over GF(64)/GF(4):
11 combining 5 Hermitian-disjoint cosets {1, 2, 3, 5, 6} (15 rows) with the self-conjugate
12 constant-block coset C_0 = {0} (1 row) with unit-norm GF(4)* scalars (1, 1, w, w^2),
13 unlocking 7 consecutive BCH roots 0..6 (designed single-block distance d >= 8) while
14 preserving H * H^dagger = 0 identically.
15
16 Zero sorry, zero admit, zero native_decide, zero custom axioms, zero Mathlib.
17-/
18
19set_option maxRecDepth 65536
20set_option maxHeartbeats 8000000
21
22namespace QuantumQECC252D6W4
23
24def gf4Add (a b : Nat) : Nat := (a % 4) ^^^ (b % 4)
25
26def gf4Mul (a b : Nat) : Nat :=
27 match a % 4, b % 4 with
28 | 0, _ | _, 0 => 0
29 | 1, x => x
30 | x, 1 => x
31 | 2, 2 => 3
32 | 2, 3 => 1
33 | 3, 2 => 1
34 | 3, 3 => 2
35 | _, _ => 0
36
37def gf4Conj (a : Nat) : Nat :=
38 match a % 4 with
39 | 0 => 0
40 | 1 => 1
41 | 2 => 3
42 | _ => 2
43
44def allBelow (p : Nat → Bool) : Nat → Bool
45 | 0 => true
46 | n + 1 => p n && allBelow p n
47
48theorem wt3_wt2_disjoint_implies_no_wt5 (sL sR : Nat) (h_ne : sL ≠ sR) :
49 sL ^^^ sR ≠ 0 := by
50 intro h
51 apply h_ne
52 have hx : (sL ^^^ sR) ^^^ sR = 0 ^^^ sR := congrArg (fun x => x ^^^ sR) h
53 simpa [Nat.xor_assoc, Nat.xor_self, Nat.xor_zero, Nat.zero_xor] using hx
54
55def hColPack (j : Nat) : Nat :=
56 if j < 126 then
57 if j < 63 then
58 if j < 31 then
59 if j < 15 then
60 if j < 7 then
61 match j with
62 | 0 => 1431655765
63 | 1 => 1343177797
64 | 2 => 1144587089
65 | 3 => 1977586740
66 | 4 => 1487685965
67 | 5 => 1578857347
68 | 6 => 1501253904
69 | _ => 0
70 else
71 match j with
72 | 7 => 2140317460
73 | 8 => 1893304165
74 | 9 => 1286737273
75 | 10 => 1870523086
76 | 11 => 1955365523
77 | 12 => 2042467844
78 | 13 => 2001051761
79 | 14 => 1783888412
80 | _ => 0
81 else
82 if j < 23 then
83 match j with
84 | 15 => 1611843511
85 | 16 => 1214187613
86 | 17 => 1512731799
87 | 18 => 1820378741
88 | 19 => 1736895085
89 | 20 => 1855651243
90 | 21 => 1442668522
91 | 22 => 1342917834
92 | _ => 0
93 else
94 match j with
95 | 23 => 1143276258
96 | 24 => 1975229464
97 | 25 => 1482180550
98 | 26 => 1580692033
99 | 27 => 1508332320
100 | 28 => 2138222120
101 | 29 => 1890946810
102 | 30 => 1281493982
103 | _ => 0
104 else
105 if j < 47 then
106 if j < 39 then
107 match j with
108 | 31 => 1877599623
109 | 32 => 1950908769
110 | 33 => 2036964616
111 | 34 => 2009964754
112 | 35 => 1794372900
113 | 36 => 1613942361
114 | 37 => 1224410342
115 | 38 => 1511423081
116 | _ => 0
117 else
118 match j with
119 | 39 => 1816186330
120 | 40 => 1733223926
121 | 41 => 1853291389
122 | 42 => 1437162175
123 | 43 => 1342654607
124 | 44 => 1142751667
125 | 45 => 1969723436
126 | 46 => 1492405899
127 | _ => 0
128 else
129 if j < 55 then
130 match j with
131 | 47 => 1580167618
132 | 48 => 1503613488
133 | 49 => 2145560892
134 | 50 => 1886226847
135 | 51 => 1288832679
136 | 52 => 1872097097
137 | 53 => 1959035890
138 | 54 => 2044041996
139 | _ => 0
140 else
141 match j with
142 | 55 => 2005508259
143 | 56 => 1789132600
144 | 57 => 1612892654
145 | 58 => 1218907323
146 | 59 => 1514043646
147 | 60 => 1824574383
148 | 61 => 1741352859
149 | 62 => 1861154518
150 | _ => 0
151 else
152 if j < 94 then
153 if j < 78 then
154 if j < 70 then
155 match j with
156 | 63 => 1880489389
157 | 64 => 1279471595
158 | 65 => 1867484394
159 | 66 => 1954013898
160 | 67 => 2041146402
161 | 68 => 1996822488
162 | 69 => 1780232774
163 | _ => 0
164 else
165 match j with
166 | 70 => 1617318657
167 | 71 => 1224031776
168 | 72 => 1512951528
169 | 73 => 1822260218
170 | 74 => 1742910878
171 | 75 => 1852711239
172 | 76 => 1439702305
173 | 77 => 1352114376
174 | _ => 0
175 else
176 if j < 86 then
177 match j with
178 | 78 => 1153832210
179 | 79 => 1976979044
180 | 80 => 1485477081
181 | 81 => 1587797094
182 | 82 => 1495481833
183 | 83 => 2141464026
184 | 84 => 1883110262
185 | 85 => 1287858877
186 | _ => 0
187 else
188 match j with
189 | 86 => 1875609791
190 | 87 => 1961877903
191 | 88 => 2035640371
192 | 89 => 1997348524
193 | 90 => 1782067659
194 | 91 => 1625182722
195 | 92 => 1219311920
196 | 93 => 1511639484
197 | _ => 0
198 else
199 if j < 110 then
200 if j < 102 then
201 match j with
202 | 94 => 1819899551
203 | 95 => 1737670503
204 | 96 => 1859789769
205 | 97 => 1437604658
206 | 98 => 1350541452
207 | 99 => 1150164771
208 | 100 => 1975405048
209 | 101 => 1481022638
210 | _ => 0
211 else
212 match j with
213 | 102 => 1582553339
214 | 103 => 1494432702
215 | 104 => 2136747951
216 | 105 => 1881798363
217 | 106 => 1283663190
218 | 107 => 1871152213
219 | 108 => 1956373317
220 | 109 => 2046649361
221 | _ => 0
222 else
223 if j < 118 then
224 match j with
225 | 110 => 1997085044
226 | 111 => 1780757389
227 | 112 => 1622823171
228 | 113 => 1213806352
229 | 114 => 1513473876
230 | 115 => 1826979173
231 | 116 => 1735572217
232 | 117 => 1857430158
233 | _ => 0
234 else
235 match j with
236 | 118 => 1432360467
237 | 119 => 1357619268
238 | 120 => 1145707057
239 | 121 => 1969899420
240 | 122 => 1489934455
241 | 123 => 1593037981
242 | 124 => 1496528471
243 | 125 => 2146970229
244 | _ => 0
245 else
246 if j < 189 then
247 if j < 157 then
248 if j < 141 then
249 if j < 133 then
250 match j with
251 | 126 => 3063364693
252 | 127 => 2344889797
253 | 128 => 2312500689
254 | 129 => 3146460020
255 | 130 => 2242087565
256 | 131 => 2485381251
257 | 132 => 2980405648
258 | _ => 0
259 else
260 match j with
261 | 133 => 2906462228
262 | 134 => 2260745893
263 | 135 => 2278183417
264 | 136 => 2800562702
265 | 137 => 2404763923
266 | 138 => 3154999684
267 | 139 => 2738534065
268 | 140 => 2615029596
269 | _ => 0
270 else
271 if j < 149 then
272 match j with
273 | 141 => 2376864759
274 | 142 => 2384177949
275 | 143 => 2642022551
276 | 144 => 2324844341
277 | 145 => 2832898541
278 | 146 => 2461260971
279 | 147 => 3061790954
280 | 148 => 2341219210
281 | _ => 0
282 else
283 match j with
284 | 149 => 2310930338
285 | 150 => 3142002392
286 | 151 => 2236843334
287 | 152 => 2484331585
288 | 153 => 2975687520
289 | 154 => 2905150504
290 | 155 => 2256550266
291 | 156 => 2273727390
292 | _ => 0
293 else
294 if j < 173 then
295 if j < 165 then
296 match j with
297 | 157 => 2795057415
298 | 158 => 2415773473
299 | 159 => 3154736968
300 | 160 => 2737225042
301 | 161 => 2612669156
302 | 162 => 2371359385
303 | 163 => 2386011686
304 | 164 => 2649100393
305 | _ => 0
306 else
307 match j with
308 | 165 => 2322745882
309 | 166 => 2830538678
310 | 167 => 2456017021
311 | 168 => 3068867775
312 | 169 => 2336761423
313 | 170 => 2305423987
314 | 171 => 3150917036
315 | 172 => 2247331787
316 | _ => 0
317 else
318 if j < 181 then
319 match j with
320 | 173 => 2486430914
321 | 174 => 2985911024
322 | 175 => 2903841852
323 | 176 => 2252355551
324 | 177 => 2270057063
325 | 178 => 2792698633
326 | 179 => 2410270258
327 | 180 => 3154476748
328 | _ => 0
329 else
330 match j with
331 | 181 => 2736700387
332 | 182 => 2607162808
333 | 183 => 2381582702
334 | 184 => 2385489211
335 | 185 => 2644381950
336 | 186 => 2330084655
337 | 187 => 2825821787
338 | 188 => 2463356118
339 | _ => 0
340 else
341 if j < 220 then
342 if j < 204 then
343 if j < 196 then
344 match j with
345 | 189 => 3399598880
346 | 190 => 3894509096
347 | 191 => 3534143226
348 | 192 => 4131269598
349 | 193 => 3418363271
350 | 194 => 3385565537
351 | 195 => 4226686216
352 | _ => 0
353 else
354 match j with
355 | 196 => 3310764242
356 | 197 => 3557725476
357 | 198 => 4047232601
358 | 199 => 3990828262
359 | 200 => 3333172329
360 | 201 => 3340369370
361 | 202 => 3866830326
362 | 203 => 3482553213
363 | _ => 0
364 else
365 if j < 212 then
366 match j with
367 | 204 => 4242270911
368 | 205 => 3820054671
369 | 206 => 3682406835
370 | 207 => 3448518700
371 | 208 => 3468582539
372 | 209 => 3712299458
373 | 210 => 3394355760
374 | 211 => 3893459260
375 | _ => 0
376 else
377 match j with
378 | 212 => 3529423263
379 | 213 => 4129957543
380 | 214 => 3414171465
381 | 215 => 3381109746
382 | 216 => 4221180684
383 | 217 => 3321774243
384 | 218 => 3557465912
385 | 219 => 4045920750
386 | _ => 0
387 else
388 if j < 236 then
389 if j < 228 then
390 match j with
391 | 220 => 3988470971
392 | 221 => 3327666430
393 | 222 => 3342203823
394 | 223 => 3873910683
395 | 224 => 3480454870
396 | 225 => 4239910229
397 | 226 => 3814810693
398 | 227 => 3689485137
399 | _ => 0
400 else
401 match j with
402 | 228 => 3444061236
403 | 229 => 3463076173
404 | 230 => 3721212803
405 | 231 => 3404841232
406 | 232 => 3895555860
407 | 233 => 3539646309
408 | 234 => 4128648569
409 | 235 => 3409976014
410 | _ => 0
411 else
412 if j < 244 then
413 match j with
414 | 236 => 3377439379
415 | 237 => 4218820100
416 | 238 => 3316269169
417 | 239 => 3557202460
418 | 240 => 4045395895
419 | 241 => 3982964829
420 | 242 => 3337888919
421 | 243 => 3341678197
422 | _ => 0
423 else
424 match j with
425 | 244 => 3869190765
426 | 245 => 3487796651
427 | 246 => 4235194346
428 | 247 => 3822152906
429 | 248 => 3683980002
430 | 249 => 3452189720
431 | 250 => 3470153670
432 | 251 => 3716756033
433 | _ => 0
434
435def hEntry (r j : Nat) : Nat := (hColPack j >>> (2 * r)) &&& 3
436
437def pivCol (i : Nat) : Nat :=
438 match i with
439 | 0 => 0
440 | 1 => 1
441 | 2 => 2
442 | 3 => 3
443 | 4 => 4
444 | 5 => 5
445 | 6 => 6
446 | 7 => 7
447 | 8 => 8
448 | 9 => 9
449 | 10 => 10
450 | 11 => 11
451 | 12 => 12
452 | 13 => 13
453 | 14 => 14
454 | 15 => 15
455 | _ => 0
456
457def uRowPack (i : Nat) : Nat :=
458 match i with
459 | 0 => 1792565102
460 | 1 => 3599583531
461 | 2 => 1518783124
462 | 3 => 3943341042
463 | 4 => 2421655733
464 | 5 => 4241491165
465 | 6 => 433649568
466 | 7 => 4082592721
467 | 8 => 3473647610
468 | 9 => 3280791321
469 | 10 => 660537569
470 | 11 => 1633600088
471 | 12 => 308178088
472 | 13 => 1566315684
473 | 14 => 1954835273
474 | 15 => 3134309925
475 | _ => 0
476
477def sRowPack (i : Nat) : Nat :=
478 match i with
479 | 0 => 4
480 | 1 => 16
481 | 2 => 30
482 | 3 => 1024
483 | 4 => 1920
484 | 5 => 2432
485 | 6 => 122880
486 | 7 => 155648
487 | 8 => 258048
488 | 9 => 16515072
489 | 10 => 1310720
490 | 11 => 5242880
491 | 12 => 83886080
492 | 13 => 335544320
493 | 14 => 234881024
494 | 15 => 1073741824
495 | _ => 0
496
497def siRowPack (i : Nat) : Nat :=
498 match i with
499 | 0 => 62
500 | 1 => 1
501 | 2 => 4
502 | 3 => 1536
503 | 4 => 3968
504 | 5 => 64
505 | 6 => 24576
506 | 7 => 98304
507 | 8 => 253952
508 | 9 => 4718592
509 | 10 => 5767168
510 | 11 => 1572864
511 | 12 => 318767104
512 | 13 => 301989888
513 | 14 => 369098752
514 | 15 => 1073741824
515 | _ => 0
516
517def uEntry (i k : Nat) : Nat := (uRowPack i >>> (2 * k)) &&& 3
518def sEntry (i k : Nat) : Nat := (sRowPack i >>> (2 * k)) &&& 3
519def siEntry (i k : Nat) : Nat := (siRowPack i >>> (2 * k)) &&& 3
520
521def shiftCol (c : Nat) : Nat := (c / 63) * 63 + ((c % 63 + 1) % 63)
522
523def hermDotAux (r1 r2 : Nat) : Nat → Nat → Nat
524 | 0, acc => acc
525 | n + 1, acc => hermDotAux r1 r2 n (gf4Add acc (gf4Mul (hEntry r1 n) (gf4Conj (hEntry r2 n))))
526
527def hermDot (r1 r2 : Nat) : Nat := hermDotAux r1 r2 252 0
528
529def matProdUHAux (i j : Nat) : Nat → Nat → Nat
530 | 0, acc => acc
531 | k + 1, acc => matProdUHAux i j k (gf4Add acc (gf4Mul (uEntry i k) (hEntry k (pivCol j))))
532
533def matProdUH (i j : Nat) : Nat := matProdUHAux i j 16 0
534
535def matProdSSiAux (i j : Nat) : Nat → Nat → Nat
536 | 0, acc => acc
537 | k + 1, acc => matProdSSiAux i j k (gf4Add acc (gf4Mul (sEntry i k) (siEntry k j)))
538
539def matProdSSi (i j : Nat) : Nat := matProdSSiAux i j 16 0
540
541def matProdSHAux (i c : Nat) : Nat → Nat → Nat
542 | 0, acc => acc
543 | k + 1, acc => matProdSHAux i c k (gf4Add acc (gf4Mul (sEntry i k) (hEntry k c)))
544
545def matProdSH (i c : Nat) : Nat := matProdSHAux i c 16 0
546
547theorem qecc252_d6_hermitian_self_orthogonal :
548 allBelow (fun r1 => allBelow (fun r2 => hermDot r1 r2 == 0) 16) 16 = true := by
549 decide
550
551theorem qecc252_d6_full_rank_16 :
552 allBelow (fun i => allBelow (fun j =>
553 matProdUH i j == (if i == j then 1 else 0)) 16) 16 = true := by
554 decide
555
556theorem qecc252_d6_shift_invertible :
557 allBelow (fun i => allBelow (fun j =>
558 matProdSSi i j == (if i == j then 1 else 0)) 16) 16 = true := by
559 decide
560
561theorem qecc252_d6_shift_equivariant :
562 allBelow (fun i => allBelow (fun c =>
563 matProdSH i c == hEntry i (shiftCol c)) 252) 16 = true := by
564 decide
565
566theorem qecc252_d6_params_exact :
567 252 - 2 * 16 = 220 ∧ 3 * 252 + 9 * (252 * 251 / 2) = 285390 := by
568 decide
569
570theorem qecc252_d6_all_cols_nonzero :
571 allBelow (fun j => hColPack j != 0) 252 = true := by
572 decide
573
574theorem neg_ctrl_d6_flip_h00_breaks_hermitian :
575 let badDot := gf4Add (hermDot 0 0) (gf4Mul (gf4Add (hEntry 0 0) 1) (gf4Conj (gf4Add (hEntry 0 0) 1)))
576 let origTerm := gf4Mul (hEntry 0 0) (gf4Conj (hEntry 0 0))
577 gf4Add badDot origTerm ≠ 0 := by
578 decide
579
580theorem neg_ctrl_d6_offdiag_inverse_nonzero_fails :
581 matProdUH 0 1 ≠ 1 := by
582 decide
583
584theorem neg_ctrl_d6_equal_wt23_syndromes_give_wt5_zero :
585 let s := hColPack 0 ^^^ hColPack 1
586 s ^^^ s = 0 := by
587 decide
588
589theorem neg_ctrl_d6_wrong_shift_breaks_equivariance :
590 matProdSH 0 2 ≠ hEntry 0 2 := by
591 decide
592
593#print axioms wt3_wt2_disjoint_implies_no_wt5
594#print axioms qecc252_d6_hermitian_self_orthogonal
595#print axioms qecc252_d6_full_rank_16
596#print axioms qecc252_d6_shift_invertible
597#print axioms qecc252_d6_shift_equivariant
598#print axioms qecc252_d6_params_exact
599#print axioms qecc252_d6_all_cols_nonzero
600#print axioms neg_ctrl_d6_flip_h00_breaks_hermitian
601#print axioms neg_ctrl_d6_offdiag_inverse_nonzero_fails
602#print axioms neg_ctrl_d6_equal_wt23_syndromes_give_wt5_zero
603#print axioms neg_ctrl_d6_wrong_shift_breaks_equivariance
604
605end QuantumQECC252D6W4