diff --git a/research/polar-law-t7-overcomplete-screen/CERTIFICATE.json b/research/polar-law-t7-overcomplete-screen/CERTIFICATE.json new file mode 100644 index 0000000000..87938909e7 --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/CERTIFICATE.json @@ -0,0 +1,1012 @@ +{ + "control_failures": [], + "controls": { + "A4_firstBasis": { + "T": 4, + "block_ranks": [ + 4, + 4, + 4, + 4 + ], + "cost": 16, + "v": 10 + }, + "A5_firstBasis": { + "T": 5, + "block_ranks": [ + 5, + 5, + 5, + 5, + 5 + ], + "cost": 25, + "v": 15 + }, + "A6_firstBasis": { + "T": 6, + "block_ranks": [ + 6, + 6, + 6, + 6, + 6, + 6 + ], + "cost": 36, + "v": 21 + }, + "D4": { + "T": 4, + "block_ranks": [ + 3, + 3, + 3, + 3 + ], + "cost": 12, + "v": 12 + }, + "D5": { + "T": 5, + "block_ranks": [ + 4, + 4, + 4, + 4, + 4 + ], + "cost": 20, + "v": 20 + }, + "D6": { + "T": 6, + "block_ranks": [ + 5, + 5, + 5, + 5, + 5, + 5 + ], + "cost": 30, + "v": 30 + }, + "E6": { + "T": 6, + "block_ranks": [ + 6, + 6, + 6, + 6, + 6, + 6 + ], + "cost": 36, + "v": 36 + }, + "E6_firstB0": { + "T": 6, + "block_ranks": [ + 6, + 7, + 6, + 6, + 6, + 6 + ], + "cost": 37, + "v": 36 + }, + "E6_storedB0": { + "T": 6, + "block_ranks": [ + 6, + 6, + 6, + 6, + 6, + 6 + ], + "cost": 36, + "v": 36 + }, + "E7": { + "T": 7, + "block_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "cost": 49, + "v": 63 + }, + "E8": { + "T": 8, + "block_ranks": [ + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9 + ], + "cost": 72, + "v": 120 + } + }, + "model": "full-orthogonal-pattern pairing B0, exact coordinate Gram decoder(s), cost = sum_j rank_F2 B[R_j, A_j]", + "overcomplete_full": { + "A3": { + "T": 3, + "cells": 102, + "directions": 13, + "hist": { + "11": 21, + "12": 77, + "9": 4 + }, + "identity_checks": 39, + "label": "A3", + "min_cost": 9, + "min_cost_minus_v": 3, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "1", + "1" + ], + "lambda": "4" + }, + "v": 6 + }, + "A4": { + "T": 4, + "cells": 340, + "directions": 40, + "hist": { + "16": 1, + "17": 4, + "19": 8, + "20": 85, + "21": 242 + }, + "identity_checks": 120, + "label": "A4", + "min_cost": 16, + "min_cost_minus_v": 6, + "min_witness": { + "cell": "at", + "dir": [ + "1", + "1", + "1", + "1" + ], + "lambda": "8" + }, + "v": 10 + }, + "A5": { + "T": 5, + "cells": 1086, + "directions": 121, + "hist": { + "25": 6, + "27": 10, + "29": 85, + "30": 985 + }, + "identity_checks": 363, + "label": "A5", + "min_cost": 25, + "min_cost_minus_v": 10, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "1", + "1", + "1", + "1" + ], + "lambda": "4" + }, + "v": 15 + }, + "B3": { + "T": 3, + "cells": 120, + "directions": 22, + "hist": { + "12": 18, + "14": 96, + "9": 6 + }, + "identity_checks": 66, + "label": "B3", + "min_cost": 9, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 9 + }, + "B4": { + "T": 4, + "cells": 320, + "directions": 56, + "hist": { + "16": 8, + "20": 24, + "21": 144, + "23": 144 + }, + "identity_checks": 168, + "label": "B4", + "min_cost": 16, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 16 + }, + "B5": { + "T": 5, + "cells": 856, + "directions": 146, + "hist": { + "25": 10, + "30": 30, + "32": 480, + "34": 336 + }, + "identity_checks": 438, + "label": "B5", + "min_cost": 25, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 25 + }, + "C4": { + "T": 4, + "cells": 320, + "directions": 56, + "hist": { + "16": 8, + "20": 24, + "21": 144, + "23": 144 + }, + "identity_checks": 168, + "label": "C4", + "min_cost": 16, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 16 + }, + "C5": { + "T": 5, + "cells": 856, + "directions": 146, + "hist": { + "25": 10, + "30": 30, + "32": 480, + "34": 336 + }, + "identity_checks": 438, + "label": "C5", + "min_cost": 25, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 25 + }, + "D4": { + "T": 4, + "cells": 288, + "directions": 52, + "hist": { + "12": 4, + "15": 284 + }, + "identity_checks": 156, + "label": "D4", + "min_cost": 12, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 12 + }, + "D5": { + "T": 5, + "cells": 804, + "directions": 141, + "hist": { + "20": 5, + "23": 40, + "24": 15, + "25": 744 + }, + "identity_checks": 423, + "label": "D5", + "min_cost": 20, + "min_cost_minus_v": 0, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 20 + }, + "F4": { + "T": 4, + "cells": 416, + "directions": 56, + "hist": { + "36": 8, + "45": 408 + }, + "identity_checks": 168, + "label": "F4", + "min_cost": 36, + "min_cost_minus_v": 12, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 24 + }, + "pm1_T3": { + "T": 3, + "cells": 88, + "directions": 13, + "hist": { + "18": 3, + "24": 9, + "27": 36, + "30": 40 + }, + "identity_checks": 39, + "label": "pm1_T3", + "min_cost": 18, + "min_cost_minus_v": 5, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 13 + }, + "pm1_T4": { + "T": 4, + "cells": 360, + "directions": 40, + "hist": { + "101": 20, + "103": 48, + "104": 16, + "105": 12, + "107": 144, + "109": 104, + "84": 4, + "99": 12 + }, + "identity_checks": 120, + "label": "pm1_T4", + "min_cost": 84, + "min_cost_minus_v": 44, + "min_witness": { + "cell": "at", + "dir": [ + "0", + "0", + "0", + "1" + ], + "lambda": "1" + }, + "v": 40 + } + }, + "overcomplete_punctures": { + "A3": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 32, + 62, + 63 + ], + "brute_mismatches": [], + "directions": 13, + "family_members_per_subset": 102, + "gain_count": 0, + "gains": [], + "label": "A3", + "lines": 6, + "min_cost_minus_v": 0, + "subsets_checked": 63, + "tie_count": 13 + }, + "A4": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 512, + 1022, + 1023 + ], + "brute_mismatches": [], + "directions": 40, + "family_members_per_subset": 340, + "gain_count": 0, + "gains": [], + "label": "A4", + "lines": 10, + "min_cost_minus_v": 0, + "subsets_checked": 1023, + "tie_count": 37 + }, + "B3": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 256, + 510, + 511 + ], + "brute_mismatches": [], + "directions": 22, + "family_members_per_subset": 120, + "gain_count": 0, + "gains": [], + "label": "B3", + "lines": 9, + "min_cost_minus_v": 0, + "subsets_checked": 511, + "tie_count": 91 + }, + "B4": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 32768, + 65534, + 65535 + ], + "brute_mismatches": [], + "directions": 56, + "family_members_per_subset": 320, + "gain_count": 0, + "gains": [], + "label": "B4", + "lines": 16, + "min_cost_minus_v": 0, + "subsets_checked": 65535, + "tie_count": 1279 + }, + "C4": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 32768, + 65534, + 65535 + ], + "brute_mismatches": [], + "directions": 56, + "family_members_per_subset": 320, + "gain_count": 0, + "gains": [], + "label": "C4", + "lines": 16, + "min_cost_minus_v": 0, + "subsets_checked": 65535, + "tie_count": 1279 + }, + "D4": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 2048, + 4094, + 4095 + ], + "brute_mismatches": [], + "directions": 52, + "family_members_per_subset": 288, + "gain_count": 0, + "gains": [], + "label": "D4", + "lines": 12, + "min_cost_minus_v": 0, + "subsets_checked": 4095, + "tie_count": 183 + }, + "pm1_T3": { + "best_cost": 1, + "best_mask": 1, + "best_v": 1, + "brute_masks_checked": [ + 1, + 2, + 4096, + 8190, + 8191 + ], + "brute_mismatches": [], + "directions": 13, + "family_members_per_subset": 88, + "gain_count": 0, + "gains": [], + "label": "pm1_T3", + "lines": 13, + "min_cost_minus_v": 0, + "subsets_checked": 8191, + "tie_count": 95 + } + }, + "python": "3.12.14", + "screen": "polar-law T >= 7 threshold screens and small-T overcomplete census", + "t7t8_full": { + "A7": { + "T_width": 7, + "ambient": 8, + "block_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "cost": 49, + "cost_minus_v": 21, + "gain": false, + "v": 28, + "v_over_Tsq": false + }, + "A8": { + "T_width": 8, + "ambient": 9, + "block_ranks": [ + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + "cost": 64, + "cost_minus_v": 28, + "gain": false, + "v": 36, + "v_over_Tsq": false + }, + "B7": { + "T_width": 7, + "ambient": 7, + "block_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "cost": 49, + "cost_minus_v": 0, + "gain": false, + "v": 49, + "v_over_Tsq": false + }, + "B8": { + "T_width": 8, + "ambient": 8, + "block_ranks": [ + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + "cost": 64, + "cost_minus_v": 0, + "gain": false, + "v": 64, + "v_over_Tsq": false + }, + "C7": { + "T_width": 7, + "ambient": 7, + "block_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "cost": 49, + "cost_minus_v": 0, + "gain": false, + "v": 49, + "v_over_Tsq": false + }, + "C8": { + "T_width": 8, + "ambient": 8, + "block_ranks": [ + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + "cost": 64, + "cost_minus_v": 0, + "gain": false, + "v": 64, + "v_over_Tsq": false + }, + "D7": { + "T_width": 7, + "ambient": 7, + "block_ranks": [ + 6, + 6, + 6, + 6, + 6, + 6, + 6 + ], + "cost": 42, + "cost_minus_v": 0, + "gain": false, + "v": 42, + "v_over_Tsq": false + }, + "D8": { + "T_width": 8, + "ambient": 8, + "block_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "cost": 56, + "cost_minus_v": 0, + "gain": false, + "v": 56, + "v_over_Tsq": false + }, + "E7": { + "T_width": 7, + "ambient": 8, + "block_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "cost": 49, + "cost_minus_v": -14, + "gain": true, + "v": 63, + "v_over_Tsq": true + }, + "E8": { + "T_width": 8, + "ambient": 8, + "block_ranks": [ + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9 + ], + "cost": 72, + "cost_minus_v": -48, + "gain": true, + "v": 120, + "v_over_Tsq": true + }, + "pm1_T7": { + "T_width": 7, + "ambient": 7, + "block_ranks": [ + 643, + 643, + 643, + 643, + 643, + 643, + 643 + ], + "cost": 4501, + "cost_minus_v": 3408, + "gain": false, + "v": 1093, + "v_over_Tsq": true + }, + "pm1_T8": { + "T_width": 8, + "ambient": 8, + "block_ranks": [ + 1970, + 1970, + 1970, + 1970, + 1970, + 1970, + 1970, + 1970 + ], + "cost": 15760, + "cost_minus_v": 12480, + "gain": false, + "v": 3280, + "v_over_Tsq": true + } + }, + "t7t8_searches": { + "A7_basis_pivot": { + "basis": [ + 4, + 8, + 22, + 20, + 5, + 21, + 7 + ], + "min_cost": 46, + "min_cost_minus_v": 18, + "std_cost": null, + "trials": 300, + "v": 28 + }, + "A7_puncture_search": { + "cost": 2, + "greedy_restarts": 12, + "greedy_steps": 250, + "mask": 36, + "min_cost_minus_v": 0, + "random_trials": 200, + "v": 2 + }, + "A8_basis_pivot": { + "basis": [ + 34, + 15, + 20, + 14, + 3, + 32, + 7, + 33 + ], + "min_cost": 64, + "min_cost_minus_v": 28, + "std_cost": null, + "trials": 300, + "v": 36 + }, + "B7_basis_pivot": { + "basis": [ + 40, + 33, + 6, + 24, + 48, + 19, + 46 + ], + "min_cost": 49, + "min_cost_minus_v": 0, + "std_cost": 49, + "trials": 300, + "v": 49 + }, + "B7_puncture_search": { + "cost": 10, + "greedy_restarts": 12, + "greedy_steps": 250, + "mask": 42606092408832, + "min_cost_minus_v": 0, + "random_trials": 200, + "v": 10 + }, + "B8_basis_pivot": { + "basis": [ + 50, + 63, + 14, + 58, + 34, + 39, + 60, + 18 + ], + "min_cost": 66, + "min_cost_minus_v": 2, + "std_cost": 64, + "trials": 300, + "v": 64 + }, + "D7_basis_pivot": { + "basis": [ + 16, + 32, + 37, + 36, + 39, + 24, + 6 + ], + "min_cost": 44, + "min_cost_minus_v": 2, + "std_cost": 42, + "trials": 300, + "v": 42 + }, + "D7_puncture_search": { + "cost": 22, + "greedy_restarts": 12, + "greedy_steps": 250, + "mask": 3517830120255, + "min_cost_minus_v": 0, + "random_trials": 200, + "v": 22 + }, + "D8_basis_pivot": { + "basis": [ + 31, + 29, + 32, + 22, + 54, + 52, + 3, + 26 + ], + "min_cost": 56, + "min_cost_minus_v": 0, + "std_cost": 56, + "trials": 300, + "v": 56 + }, + "E7_basis_pivot": { + "basis": [ + 12, + 28, + 60, + 1, + 42, + 33, + 48 + ], + "min_cost": 49, + "min_cost_minus_v": -14, + "std_cost": null, + "trials": 300, + "v": 63 + } + } +} \ No newline at end of file diff --git a/research/polar-law-t7-overcomplete-screen/README.md b/research/polar-law-t7-overcomplete-screen/README.md new file mode 100644 index 0000000000..3d7a428553 --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/README.md @@ -0,0 +1,227 @@ +# Polar-law screens at T >= 7 and a small-T overcomplete census + +**Scoped negative results; no new kappa.** The dense-polar small-T screen of +[PR 2272](https://github.com/CrocSwap/integer-mult-bounds/pull/2272) left three obligations open: the T^2 +threshold law at T >= 7, overcomplete (m = T + 1) decoders, and pairing minima on its 1,023 cost = v ties. +This package attacks the first two. No configuration at T = 7 or T = 8 outside the already-checked E7/E8 +gains has dense-polar cost below v under the checked decoders, and no overcomplete decoder in the one-extra +rank-one family of [PR 2240](https://github.com/CrocSwap/integer-mult-bounds/pull/2240) beats v on any of +144,953 exhaustively censused punctures at T <= 4 or on any of 13 full sets at T <= 5. + +Model, as in [PR 2125](https://github.com/CrocSwap/integer-mult-bounds/pull/2125) / PR 2272: a configuration +is a list of root lines `t = 1..v` with vectors `p(t) = q(t)` in `Q^T`. The full-orthogonal-pattern pairing +`B0` has unit diagonal and `B_ts = 1` exactly where `dot(p(t), p(s)) = 0`. An exact coordinate Gram decoder +`M = sum_j p_j q_j^T = Gram` is priced `cost = sum_j rank_F2 B[R_j, A_j]` (Theorem C without the floor), +where `R_j = supp p_j` and `A_j = supp q_j`. A gain is `cost < v`. All arithmetic is exact (integers, +rationals, F2 bitsets), standard library only. + +## 1. Positive control: the checked table reproduces exactly + +The engine re-derives the root systems, the exact coordinate decoders and the F2 block ranks independently; +PR 2125's `data/e6_best.json` is pinned read-only (SHA-256 in `SOURCES.json`) and supplies only the E6 +stored basis and stored pairing. Before any new number was computed, the controls reproduced PR 2272's +checked table (PR 2125 values) exactly: + +| unit | v | T | cost | expected | status | +|---|---:|---:|---:|---:|---| +| D4 (standard coords, B0) | 12 | 4 | 12 | 12 | CHECKED | +| D5 (standard coords, B0) | 20 | 5 | 20 | 20 | CHECKED | +| D6 (standard coords, B0) | 30 | 6 | 30 | 30 | CHECKED | +| E6 (stored basis, stored B) | 36 | 6 | 36 | 36 | CHECKED | +| E6 (first-independent basis, B0) | 36 | 6 | 37 | 37 | CHECKED | +| E7 (first-independent basis, B0) | 63 | 7 | 49 | 49 | CHECKED | +| E8 (first-independent basis, B0) | 120 | 8 | 72 | 72 | CHECKED | + +The A4/A5/A6 first-independent-basis values 16/25/36 reproduce as well, and the mutation controls +(replace B by the identity) change the cost on D5 and E7, so the pricing is sensitive to the pairing. + +## 2. Exact full-system screens at T = 7 and T = 8 + +Twelve systems, same rigor as PR 2272's full-system table (exact coordinate Gram decoder, B0). The +B/C/D families use standard coordinates, A7/A8 and E7/E8 the first-independent span basis, matching +PR 2272's conventions. Width is the decoder width (= span dimension); T^2 in the last column is width^2. + +| unit | v | width | cost | cost - v | gain | v > T^2 | +|---|---:|---:|---:|---:|---|---| +| A7 | 28 | 7 | 49 | +21 | no | no | +| B7 | 49 | 7 | 49 | 0 | no | no (v = T^2 exactly) | +| C7 | 49 | 7 | 49 | 0 | no | no (v = T^2 exactly) | +| D7 | 42 | 7 | 42 | 0 | no | no | +| E7 | 63 | 7 | 49 | -14 | yes | yes | +| {0,+/-1}^7 | 1093 | 7 | 4501 | +3408 | no | yes | +| A8 | 36 | 8 | 64 | +28 | no | no | +| B8 | 64 | 8 | 64 | 0 | no | no (v = T^2 exactly) | +| C8 | 64 | 8 | 64 | 0 | no | no (v = T^2 exactly) | +| D8 | 56 | 8 | 56 | 0 | no | no | +| E8 | 120 | 8 | 72 | -48 | yes | yes | +| {0,+/-1}^8 | 3280 | 8 | 15760 | +12480 | no | yes | + +Findings: + +1. **No new T >= 7 gain.** The only systems with cost below v are E7 and E8, both already inside + PR 2272's checked table. Every other T = 7/8 system ties or exceeds v under the checked decoder. +2. **The law's necessary condition survives T = 7 and T = 8.** Both gains have v above T^2 + (63 > 49 and 120 > 64); every system with v at or below T^2 has no gain. The B family sits exactly + on the boundary: v = T^2 = cost at both T = 7 and T = 8. The {0,+/-1}^T sets again show that + v above T^2 is not sufficient for a gain (cost - v = 3408 and 12480 under the checked decoder), + extending PR 2272's T = 4/5/6 observation (40/121/364 lines). +3. The A family costs T^2 strictly above v at both T = 7 and T = 8 (49 and 64), continuing the + A4-A6 pattern 16/25/36. + +## 3. Bounded falsification searches at T = 7 and T = 8 (seeded 20261015) + +Basis pivots (300 seeded random span bases each, exact recomputation of supports) and seeded +greedy/random puncture searches (12 restarts x 250 steps plus 200 random subsets, minimum size 2). +These are bounded searches, not exhaustive: no claim outside the recorded domains. + +| unit | search | best cost | v of best | min(cost - v) | +|---|---|---:|---:|---:| +| A7 | basis pivots | 46 | 28 | +18 | +| B7 | basis pivots | 49 | 49 | 0 | +| D7 | basis pivots | 44 | 42 | +2 | +| E7 | basis pivots | 49 | 63 | -14 | +| A8 | basis pivots | 64 | 36 | +28 | +| B8 | basis pivots | 66 | 64 | +2 | +| D8 | basis pivots | 56 | 56 | 0 | +| A7 | punctures | 2 | 2 | 0 | +| B7 | punctures | 10 | 10 | 0 | +| D7 | punctures | 22 | 22 | 0 | + +No puncture or basis pivot produced cost below v at T = 7 or T = 8 (E7's -14 is the already-known +in-table gain). The std coordinate decoder remains the best known for D7 (42) and B7 (49); the +random pivot search did not find it (minima 44 and 49). + +## 4. Overcomplete (m = T + 1) decoders: one-extra rank-one census + +The identity of PR 2240 with T + 1 terms (exact for every nonzero direction `a` and rational +`lambda != 0`, verified exactly in the replay): + +```text +p_i = X e_i q_i = X(H e_i - lambda a_i a), i = 1..T +p_{T+1} = X a q_{T+1} = lambda X a +``` + +Here `X` is the exact coordinate matrix of the lines in the declared basis and `H` the basis Gram, so +`sum_j p_j q_j^T = G = X H X^T`. The census enumerates every projective `{-1,0,1}^T` direction plus +every configuration line as direction, and for each direction every rational lambda support cell +(each open interval between consecutive breakpoints of the linear forms `p(t) . q_i` and each +breakpoint itself). Supports and F2 block ranks are constant between breakpoints, so the census is +exact on the declared family and alphabet, with B = B0 fixed. + +Full sets (13 configurations, T = 3..5): + +| unit | v | T | directions | cells | min cost | min - v | +|---|---:|---:|---:|---:|---:|---:| +| A3 | 6 | 3 | 13 | 102 | 9 | +3 | +| B3 | 9 | 3 | 22 | 120 | 9 | 0 | +| {0,+/-1}^3 | 13 | 3 | 13 | 88 | 18 | +5 | +| A4 | 10 | 4 | 40 | 340 | 16 | +6 | +| B4 | 16 | 4 | 56 | 320 | 16 | 0 | +| C4 | 16 | 4 | 56 | 320 | 16 | 0 | +| D4 | 12 | 4 | 52 | 288 | 12 | 0 | +| F4 | 24 | 4 | 56 | 416 | 36 | +12 | +| {0,+/-1}^4 | 40 | 4 | 40 | 360 | 84 | +44 | +| A5 | 15 | 5 | 121 | 1086 | 25 | +10 | +| B5 | 25 | 5 | 146 | 856 | 25 | 0 | +| C5 | 25 | 5 | 146 | 856 | 25 | 0 | +| D5 | 20 | 5 | 141 | 804 | 20 | 0 | + +Exhaustive puncture censuses at T <= 4 (every nonempty subset of lines, family restricted to the +subset; the per-subset live-count prefilter is validated against unfiltered exact minima on five +deterministic subsets per configuration): + +| unit | subsets | directions | members per subset | min(cost - v) | gains | ties | +|---|---:|---:|---:|---:|---:|---:| +| A3 | 63 | 13 | 102 | 0 | 0 | 13 | +| B3 | 511 | 22 | 120 | 0 | 0 | 91 | +| {0,+/-1}^3 | 8191 | 13 | 88 | 0 | 0 | 95 | +| A4 | 1023 | 40 | 340 | 0 | 0 | 37 | +| B4 | 65535 | 56 | 320 | 0 | 0 | 1279 | +| C4 | 65535 | 56 | 320 | 0 | 0 | 1279 | +| D4 | 4095 | 52 | 288 | 0 | 0 | 183 | + +Finding: **no overcomplete decoder in this family beats v anywhere in the declared domain.** The +minimum over the family equals v exactly on every B/C/D-family full set and on 2,977 punctures +(counted ties), and exceeds v elsewhere. In particular, within this family no D5 decoder with +m = 6 terms reaches the requested cost 18 (minimum 20 = v), and no D4 or {0,+/-1}^3 puncture +admits an m = T + 1 factorization with cost below its v. Total: 144,953 subsets censused with +zero gains. + +## Scope and limitations + +- Cost is that of the declared factorizations priced with B = B0 (or the stored E6 pairing in the + control). A gain found here would be a true gain, but the negative excludes only these + decoder/pairing pairs: a sparser admissible B could price below the B0 values, so pairing + minimization (PR 2272's open question 2, its 1,023 D5 ties) remains open. +- The overcomplete census covers exactly one factorization family: the one-extra rank-one identity + above with the p_i = X e_i frame fixed, over the declared direction alphabet (all projective + ternary directions in the declared basis plus all configuration lines). Unrestricted (m = T + 1) + factorizations with moving frames are not covered; the finite support-cell reduction over Q for + arbitrary factorizations is the recorded blocker. +- E6 is not in the overcomplete family census (PR 2240 and the transvection extension of + [comment 18938558](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18938558) + cover it in the pinned basis, with family minima 40 and 37 against the 35 target; the + unrestricted seven-term E6 question stays open). +- D5 punctures (2^20 - 1 subsets) and all T >= 7 punctures are not enumerated (compute); the D5 + full set and the T = 7/8 full systems are covered exactly. +- Basis pivots are seeded (300 per unit) and bounded; no claim over all GL_T(Q) bases. The + E7 basis question (is 49 the minimum over bases?) is open, mirroring PR 2272's E6 36-vs-37 question. +- The greedy/random puncture searches at T = 7/8 are seeded and bounded as recorded in + CERTIFICATE.json. No kappa, supplier, paid-profile or selected-frontier change is claimed. + +## Open next questions + +1. **Pairing minima on ties.** On the tied D7/B7/A7 punctures (cost = v at B0), is the minimum over + admissible pairings B exactly v, or can a sparser B price below v? That is PR 2272's open + question 2 now at T = 7. First step: exact branch-and-bound over B on the largest tied punctures. + Blocker: rank_F2 B[R, A] is not monotone in B, so no monotone relaxation is known. +2. **Unrestricted overcomplete factorizations at T = 3.** Does any (m = 4)-term exact factorization + of the {0,+/-1}^3 Gram matrix with a moving frame beat v = 13? First step: a two-direction + correction family (two independent extra frames) with its own exact support-cell reduction. + Blocker: no finite support-cell reduction over Q is known for arbitrary (p_j, q_j) tuples. +3. **E7 basis minimum.** Is the B0 cost of E7 at least 49 over all GL_7(Q) bases (the T = 7 analogue + of PR 2272's 36-vs-37 E6 question)? First step: deterministic basis descent with exact + recomputation of supports. Blocker: support patterns are not continuous in the basis. + +## Reproduce + +From the repository root, with Python 3.12 or newer and only the standard library: + +```sh +python3 -B research/polar-law-t7-overcomplete-screen/verify.py +``` + +Expected final line `PASS_POLAR_T7_OVERCOMPLETE_SCREEN` (about 316 s on this host). The registered +replay was run locally under Python 3.12; `make` is not installed on this host, so +`scripts/research_package.py` was used directly: + +```sh +python3 scripts/research_package.py --package research/polar-law-t7-overcomplete-screen --check-only +``` + +prints `PASS_PACKAGE_METADATA_AND_PINS (not a mathematical acceptance check)`. To regenerate the +certificate after changing the search, run each stage with `--emit`, e.g. +`python3 -B research/polar-law-t7-overcomplete-screen/search.py --stage t7t8 --emit`. +Obligations not checked: host CI replay (queued), human review, and everything listed under +Scope and limitations. + +## Credit and links + +Model, cost formula and the threshold question: DreamingOfClouds, +[PR 2125](https://github.com/CrocSwap/integer-mult-bounds/pull/2125), +[PR 2228](https://github.com/CrocSwap/integer-mult-bounds/pull/2228), +[PR 2111](https://github.com/CrocSwap/integer-mult-bounds/pull/2111), requests +[comment 18934590](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18934590) +item 3 and +[comment 18936173](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18936173) +Q1. Small-T screen, checked table and the three open obligations: Aaron Wang with help from opencode, +[PR 2272](https://github.com/CrocSwap/integer-mult-bounds/pull/2272). One-extra rank-one identity, +support-cell method and E6 family minima: 1337isnot1337, +[PR 2240](https://github.com/CrocSwap/integer-mult-bounds/pull/2240) and +[comment 18938558](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18938558). +Prior lattice work +[PR 446](https://github.com/CrocSwap/integer-mult-bounds/pull/446), +[PR 595](https://github.com/CrocSwap/integer-mult-bounds/pull/595), +[PR 1590](https://github.com/CrocSwap/integer-mult-bounds/pull/1590). The E6 stored basis and pairing +are PR 2125's `data/e6_best.json`, pinned by SHA-256 in `SOURCES.json`. Prepared by Aaron Wang with +help from opencode (substantial AI assistance; no independent human review claimed). Apache-2.0. diff --git a/research/polar-law-t7-overcomplete-screen/SOURCES.json b/research/polar-law-t7-overcomplete-screen/SOURCES.json new file mode 100644 index 0000000000..66585f20ed --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/SOURCES.json @@ -0,0 +1,25 @@ +{ + "schema_version": 1, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "e8870e5917057d59b730eb14721a778639eca050", + "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + } + ], + "package_data": [ + { + "path": "research/polar-law-t7-overcomplete-screen/sources/e6_best.json", + "sha256": "80bb03e235b297ebf961cdc921268e7b1d40701128b1cb0c0c30449263270bcf", + "origin": "PR 2125 research/char2-threshold/data/e6_best.json at head d9eb80ac183bb4df185ca044fd65432b817333bb (DreamingOfClouds), byte-exact copy of the pin in PR 2272 research/polar-law-small-t-screen/sources/e6_best.json at head 50e12c263fa443ba587fd6b205f2fc2825d10de1; read-only input to search.py (E6 stored basis and stored pairing)" + } + ] +} diff --git a/research/polar-law-t7-overcomplete-screen/TASK.json b/research/polar-law-t7-overcomplete-screen/TASK.json new file mode 100644 index 0000000000..054c55552c --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/TASK.json @@ -0,0 +1,71 @@ +{ + "actual_scope": "Dense-polar threshold law screens at T = 7 and T = 8 plus an exhaustive overcomplete one-extra rank-one census at small T. Model as in PR 2272/PR 2125: root lines p(t) = q(t) in Q^T, full-orthogonal-pattern pairing B0 (unit diagonal, ones exactly on orthogonal pairs), exact coordinate Gram decoder M = sum_j p_j q_j^T = Gram, cost = sum_j rank_F2 B[R_j, A_j], gain means cost < v. Part 1 (mandatory positive control): the engine reproduces PR 2272's checked table D4/D5/D6 = 12/20/30, E6 = 36 (stored basis + stored B) and 37 (first-independent basis, B0), E7 = 49, E8 = 72 before any new number is trusted. Part 2: exact full-system costs at T = 7 (A7, B7, C7, D7, E7, {0,+/-1}^7) and T = 8 (A8, B8, C8, D8, {0,+/-1}^8) under the checked decoder and B0, with seeded bounded basis pivots and puncture searches declared as bounded. Part 3: the overcomplete m = T + 1 one-extra rank-one frame identity of PR 2240 (p_i = X e_i, q_i = X(H e_i - lambda a_i a), p_{T+1} = X a, q_{T+1} = lambda X a) censused exactly over every subset (puncture) of the T = 3 {0,+/-1}^3 set (13 lines) and of D4 (12 lines), all projective {-1,0,1}^T directions, and every rational lambda support cell.", + "ai_assistance": "with help from opencode (substantial AI assistance; no independent human review claimed)", + "author": "Aaron Wang", + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "bottleneck_link": "The dense-polar T^2 law and the ideal-decoder formula price the local root-decoder words that feed the complex and bit suppliers; PR 2272 closed T <= 6 for the checked decoders/pairings and left T >= 7, overcomplete (m = T + 1) decoders and pairing minima on its 1,023 cost = v ties open. A T >= 7 gain changes what larger-T decoder interfaces can cost; a scoped negative extends the closed regime to T = 7/8 and to overcomplete punctures at small T, narrowing the three remaining gaps of the rank-3/decoder theory.", + "evidence": "CERTIFICATE.json (all counts, block ranks, seeds, direction/cell counts). Controls reproduce PR 2272 checked table 12/20/30 (D4/D5/D6), 36/37 (E6), 49 (E7), 72 (E8) and A4-A6 16/25/36 exactly, with B=I mutation controls. T = 7/8 screens: no new gain (only in-table E7 49 < 63 and E8 72 < 120); B7/B8 tie at v = T^2 exactly; {0,+/-1}^7 cost 4501 vs v 1093, {0,+/-1}^8 cost 15760 vs v 3280. Seeded basis pivots (300 per unit) and puncture searches find min(cost - v) >= 0 outside E7. Overcomplete one-extra rank-one census: 13 full sets at T = 3..5 and 144,953 exhaustively censused punctures at T <= 4, zero gains, min(cost - v) = 0 with 2,977 ties; exact identity checks and brute-force prefilter cross-checks pass.", + "open_questions": [ + { + "blocked_by": "No finite support-cell reduction over Q is known for arbitrary (p_j, q_j) factorizations; the family identities fix the frame and keep the cell problem one-dimensional in lambda.", + "first_step": "Enumerate the support cells of a two-direction correction family (two independent extra frames) at T = 3 and price every cell exactly.", + "question": "Do unrestricted (m = T + 1) factorizations outside the one-extra rank-one frame family beat v at T <= 4?", + "why_it_matters": "The coupling-lemma square floors fix m = T; the one-extra rank-one family is only one curve through the factorization variety, so a below-v overcomplete decoder could still exist outside it." + }, + { + "blocked_by": "No monotone relaxation is known; pairings must be enumerated or bounded by a rank-aware argument.", + "first_step": "Exact branch-and-bound over pairings B on the largest tied D7/A7 punctures found by the exhaustive census.", + "question": "Pairing minima on cost = v ties: can a sparser admissible B price below v on tied T = 7 punctures?", + "why_it_matters": "rank_F2 B[R, A] is not monotone in B; ties at B0 do not settle min over B, and a below-v pairing would be a genuine T >= 7 gain." + }, + { + "blocked_by": "The support pattern is not continuous in the basis; local moves can escape any greedy descent.", + "first_step": "Deterministic descent over basis changes on the E7 line set with exact recomputation of supports.", + "question": "Is the E7 basis minimum of the B0 cost exactly 49 over all GL_7(Q) bases (E6 analogue: 36 vs 37)?", + "why_it_matters": "Cost depends on the basis; a basis below 49 would improve the first recorded gain and probe the T^2 side of the law at T = 7." + } + ], + "original_card": { + "acceptance_gate": "A full boundary contract and paid profile; unchanged scalar counts alone are insufficient.", + "allowed_variations": [ + "Choose one helper-star or quartet instance; narrow to one boundary implication." + ], + "bottleneck_link": "A legitimate replacement could admit a cheaper bit circuit; scalar savings alone do not alter the selected moment.", + "first_experiment": "Write one replacement H2/K implication for a single helper-star operation, then try to falsify it on dirty inputs.", + "first_step": { + "command": [ + "python3", + "-B", + "research/r439-bsection-stars-seed01/verify.py" + ], + "expected": "PASS_R439_BSECTION_STARS", + "inspect": "Compare the two false H2/K flags with the unchanged paid profile in its README.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "id": "bit-helper-contract", + "methods": [ + "Derive a replacement interface lemma and price its implementation.", + "Seek an exact dirty-input or chronological-cut counterexample to the proposed replacement." + ], + "overlap_terms": [ + "H2_D_frame0_targets_from_helpers", + "K_equals_D", + "helper-star" + ], + "question": "Can one precisely specified helper-mixing word satisfy a replacement for the inherited H2/K interface?", + "scope_change_triggers": [ + "Changing only source count or scalar addition count without an interface argument." + ], + "starting_points": [ + "research/r439-bsection-stars-seed01/README.md", + "research/r439-copy-path-sharing-barrier/README.md" + ] + }, + "outcome": "negative-result", + "predecessor_credit": "Model, cost formula and threshold question: DreamingOfClouds (PRs https://github.com/CrocSwap/integer-mult-bounds/pull/2125, https://github.com/CrocSwap/integer-mult-bounds/pull/2228, https://github.com/CrocSwap/integer-mult-bounds/pull/2111; requests https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18934590 item 3 and https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-18936173 Q1). Small-T screen and checked table: Aaron Wang with help from opencode, https://github.com/CrocSwap/integer-mult-bounds/pull/2272. One-extra rank-one frame identity and lambda support-cell method: 1337isnot1337, https://github.com/CrocSwap/integer-mult-bounds/pull/2240. Prior lattice work #446/#595/#1590. The E6 stored basis and pairing are PR 2125's data/e6_best.json, pinned by SHA-256 in SOURCES.json.", + "schema_version": 1, + "scope_change_reason": "Chooser draw (OS nonce 426840f830ccf60b3745089bc0e4e045, 2026-10-15) landed on track bit-mechanisms with cards bit-helper-contract and bit-new-register-model. Both are saturated at entry: bit-helper-contract has live claims and fresh results (discussion 1317 comment 18944326 two-writer helper-star absorption -> PR 2428; discussion 1166 comment 18939625 two-center defect relay -> PR 2280), and bit-new-register-model's drawn scope is being worked (discussion 1317 comments 18940762/18940800 Q8 pair census and five-SWAP thirteen-call claims). The donation prompt makes an explicit open request from the handoffs thread a legitimate scope change, so this session takes the kappa blocker KB4 request: the recorded open obligations of PR 2272 (https://github.com/CrocSwap/integer-mult-bounds/pull/2272), i.e. the T^2 threshold law at T >= 7 and the overcomplete (m = T + 1) decoder question of discussion 1166 comments 18934590 item 3 and 18936173 Q1 (DreamingOfClouds).", + "scope_status": "changed", + "stop_rule": "Stop after the declared domains: the checked-table control, the T = 7/8 full-system exact screens, the seeded bounded searches recorded in CERTIFICATE.json, and the exhaustive overcomplete puncture censuses at T = 3 and T = 4. One bounded pivot maximum (pivot: expand the overcomplete direction alphabet from root-only to all projective ternary directions, exactly as PR 2240's recorded pivot). No claim outside the declared domains; no repeated search with a different seed alone.", + "task_id": "bit-helper-contract" +} diff --git a/research/polar-law-t7-overcomplete-screen/VERIFY.json b/research/polar-law-t7-overcomplete-screen/VERIFY.json new file mode 100644 index 0000000000..bf559b4f10 --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/VERIFY.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/polar-law-t7-overcomplete-screen/search.py", + "research/polar-law-t7-overcomplete-screen/verify.py", + "research/polar-law-t7-overcomplete-screen/sources/e6_best.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Reruns the whole screen and asserts CERTIFICATE.json matches: PR 2272/PR 2125 checked-table controls (D4/D5/D6 = 12/20/30, E6 = 36/37, E7 = 49, E8 = 72, A4-A6 = 16/25/36) with B = I mutation controls; exact T = 7/8 full-system screens (A7, B7, C7, D7, E7, {0,+/-1}^7, A8, B8, C8, D8, E8, {0,+/-1}^8); 300 seeded basis pivots each on A7/B7/D7/E7/A8/B8/D8 and seeded greedy/random puncture searches on A7/B7/D7; the overcomplete one-extra rank-one census with exact identity checks on 13 full sets (T = 3..5) and every subset of A3, B3, {0,+/-1}^3, A4, B4, C4, D4 (144,953 subsets), with brute-force prefilter cross-checks; prints PASS_POLAR_T7_OVERCOMPLETE_SCREEN. Measured about 316 s locally on CPython 3.12." + } + ] +} diff --git a/research/polar-law-t7-overcomplete-screen/search.py b/research/polar-law-t7-overcomplete-screen/search.py new file mode 100644 index 0000000000..019540d5a7 --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/search.py @@ -0,0 +1,785 @@ +"""Dense-polar threshold screens at T >= 7 and an overcomplete (m = T + 1) census. + +Model (DreamingOfClouds, PR 2125 / PR 2228 / PR 2111; screen convention of +PR 2272): a configuration is a list of root lines t = 1..v with vectors +p(t) = q(t) in Q^T. The full-orthogonal-pattern pairing B0 has unit diagonal +and B_ts = 1 exactly where dot(p(t), p(s)) = 0. An exact coordinate Gram +decoder M = sum_j p_j q_j^T = Gram is priced +cost = sum_j rank_F2 B[R_j, A_j] (Theorem C without the floor w), where +R_j = supp p_j and A_j = supp q_j. A gain is cost < v. + +Stages: + controls - positive control: reproduce PR 2272's checked table + D4/D5/D6 = 12/20/30, E6 = 36/37, E7 = 49, E8 = 72. + t7t8 - exact full-system screens at T = 7 and T = 8. + searches - seeded bounded basis pivots and puncture searches at T = 7/8. + overfull - overcomplete one-extra rank-one family on full sets (small T). + overpunc - overcomplete one-extra rank-one family on every puncture of the + declared small-T configurations (shardable). + +Everything is exact integer / rational / F2 arithmetic, standard library only. +Independent reimplementation; predecessor heads are recorded in SOURCES.json. +""" +import itertools +import json +import os +import random +import sys +from fractions import Fraction as F + +HERE = os.path.dirname(os.path.abspath(__file__)) +E6_BEST_PATH = os.path.join(HERE, "sources", "e6_best.json") + +# ---------------------------------------------------------------- root lines + +def canon(r): + f = next(x for x in r if x) + return tuple(r) if f > 0 else tuple(-x for x in r) + + +def lines(R): + seen, out = set(), [] + for r in R: + c = canon(r) + if c not in seen: + seen.add(c) + out.append(c) + return out + + +def A(n): + R = [] + for i in range(n + 1): + for j in range(i + 1, n + 1): + v = [0] * (n + 1) + v[i], v[j] = 2, -2 + R.append(v) + return lines(R) + + +def D(n): + R = [] + for i in range(n): + for j in range(i + 1, n): + for s in (2, -2): + v = [0] * n + v[i], v[j] = 2, s + R.append(v) + return lines(R) + + +def Bn(n): + R = [] + for i in range(n): + v = [0] * n + v[i] = 2 + R.append(v) + for j in range(i + 1, n): + for s in (2, -2): + w = [0] * n + w[i], w[j] = 2, s + R.append(w) + return lines(R) + + +def Cn(n): + R = [] + for i in range(n): + v = [0] * n + v[i] = 4 + R.append(v) + for j in range(i + 1, n): + for s in (2, -2): + w = [0] * n + w[i], w[j] = 2, s + R.append(w) + return lines(R) + + +def F4(): + R = [] + for i in range(4): + v = [0] * 4 + v[i] = 2 + R.append(v) + for j in range(i + 1, 4): + for s in (2, -2): + w = [0] * 4 + w[i], w[j] = 2, s + R.append(w) + for sg in itertools.product((1, -1), repeat=4): + R.append(list(sg)) + return lines(R) + + +def E8(): + R = [list(r) for r in D(8)] + for sg in itertools.product((1, -1), repeat=8): + if sg.count(-1) % 2 == 0: + R.append(list(sg)) + return lines(R) + + +def dot(a, b): + return sum(x * y for x, y in zip(a, b)) + + +def E7(): + return [r for r in E8() if sum(r) == 0] + + +def E6(): + r1 = [2, -2, 0, 0, 0, 0, 0, 0] + r2 = [0, 2, -2, 0, 0, 0, 0, 0] + return [r for r in E8() if dot(r, r1) == 0 and dot(r, r2) == 0] + + +def pm1_lines(T): + """All lines with coordinates in {0, +1, -1}, canonical sign.""" + R = [] + for r in itertools.product((1, 0, -1), repeat=T): + if any(r): + R.append(list(r)) + return lines(R) + + +# ------------------------------------------------------------ F2 machinery + +def rank2(rows): + piv = [] + for x in rows: + for p in piv: + x = min(x, x ^ p) + if x: + piv.append(x) + piv.sort(reverse=True) + return len(piv) + + +def b0_rows(L): + """Full orthogonal pattern as bitset rows: unit diagonal + orth pairs.""" + v = len(L) + out = [] + for t in range(v): + bits = 1 << t + for s in range(v): + if s != t and dot(L[t], L[s]) == 0: + bits |= 1 << s + out.append(bits) + return out + + +def supports(P): + """Column supports of the coefficient matrix P (nonzero test over Q).""" + v = len(P) + T = len(P[0]) if P else 0 + return [frozenset(t for t in range(v) if P[t][j] != 0) for j in range(T)] + + +def cost_from_supports(Brows, RS, AS): + out = [] + for R, A in zip(RS, AS): + if not R or not A: + out.append(0) + continue + amask = 0 + for s in A: + amask |= 1 << s + rows = [Brows[t] & amask for t in R] + out.append(rank2(rows)) + return out + + +def cost_from_masks(Brows, RS, AS): + """Same cost with supports given as bitmasks.""" + out = [] + n = len(Brows) + for R, A in zip(RS, AS): + if not R or not A: + out.append(0) + continue + rows = [Brows[t] & A for t in range(n) if (R >> t) & 1] + out.append(rank2(rows)) + return out + + +def sup_mask(S): + m = 0 + for s in S: + m |= 1 << s + return m + + +# ------------------------------------------------- exact coordinate decoder + +def solve_coords(basis, r): + n = len(basis) + m = len(r) + M = [[F(basis[i][k]) for i in range(n)] + [F(r[k])] for k in range(m)] + piv, row = [], 0 + for c in range(n): + p = next((i for i in range(row, m) if M[i][c] != 0), None) + if p is None: + raise ValueError("dependent basis") + M[row], M[p] = M[p], M[row] + inv = M[row][c] + M[row] = [x / inv for x in M[row]] + for i in range(m): + if i != row and M[i][c] != 0: + f = M[i][c] + M[i] = [a - f * b for a, b in zip(M[i], M[row])] + row += 1 + return [M[i][n] for i in range(n)] + + +def frac_rank(rows): + M = [[F(x) for x in r] for r in rows] + rk = 0 + if not M: + return 0 + for c in range(len(M[0])): + p = next((i for i in range(rk, len(M)) if M[i][c] != 0), None) + if p is None: + continue + M[rk], M[p] = M[p], M[rk] + for i in range(rk + 1, len(M)): + if M[i][c] != 0: + f = M[i][c] / M[rk][c] + M[i] = [a - f * b for a, b in zip(M[i], M[rk])] + rk += 1 + return rk + + +def first_basis(L): + idx, cur = [], [] + for i, r in enumerate(L): + if frac_rank(cur + [r]) > len(cur): + idx.append(i) + cur.append(r) + return idx + + +def decoder_std(L): + return [[F(x) for x in r] for r in L], [[F(x) for x in r] for r in L] + + +def decoder_basis(L, bidx): + basis = [L[i] for i in bidx] + n = len(basis) + C = [[dot(basis[i], basis[k]) for k in range(n)] for i in range(n)] + P = [solve_coords(basis, r) for r in L] + Q = [[sum(P[t][i] * C[i][k] for i in range(n)) for k in range(n)] for t in range(len(L))] + return P, Q + + +def config_cost(L, P, Q, Brows=None): + if Brows is None: + Brows = b0_rows(L) + RS, AS = supports(P), supports(Q) + br = cost_from_supports(Brows, RS, AS) + return sum(br), br + + +# ------------------------------------------------------ one-extra rank-one + +def ternary_dirs(T): + """All projective directions a in Q^T with entries in {0, +1, -1}.""" + out = set() + for r in itertools.product((1, 0, -1), repeat=T): + if any(r): + out.add(tuple(F(x) for x in canon(list(r)))) + return sorted(out) + + +def one_extra_cells(X, H, a): + """All exact lambda support cells of PR 2240's identity for direction a. + + p_i = X e_i, q_i = X(H e_i - lambda a_i a), i = 1..T + p_{T+1} = X a, q_{T+1} = lambda X a. + Returns a list of tuples (cell_id, [term supports (R_j, A_j) masks]). + Supports are constant on each cell; cells are the open intervals between + consecutive breakpoints plus the breakpoints themselves (lambda != 0). + """ + T = len(X[0]) + n = len(X) + alpha = [dot(X[t], a) for t in range(n)] # p(t) . a + beta = [[dot(X[t], [H[i][k] for k in range(T)]) for i in range(T)] for t in range(n)] + # p(t) . q_i = beta[t][i] - lambda * a[i] * alpha[t] + brk = set() + for t in range(n): + for i in range(T): + ai = a[i] + if ai != 0 and alpha[t] != 0: + brk.add(F(beta[t][i], 1) / (F(ai) * F(alpha[t]))) + brk = sorted(b for b in brk if b != 0) + samples = [("at", b) for b in brk] + cuts = sorted(set([F(0)] + brk)) + # Open cells between consecutive cut points, plus the two unbounded cells. + edges = [None] + cuts + [None] + for lo, hi in zip(edges, edges[1:]): + if lo is None and hi is None: + continue + if lo is None: + samples.append(("in", hi - 1)) + elif hi is None: + samples.append(("in", lo + 1)) + else: + samples.append(("in", (lo + hi) / 2)) + S = [sup_mask(t for t in range(n) if X[t][i] != 0) for i in range(T)] + Ta = sup_mask(t for t in range(n) if alpha[t] != 0) + out = [] + for cid, lam in samples: + AS = [] + for i in range(T): + if a[i] == 0: + c = [H[i][k] for k in range(T)] + else: + c = [F(H[i][k]) - F(lam) * F(a[i]) * F(a[k]) for k in range(T)] + AS.append(sup_mask(t for t in range(n) if dot(X[t], c) != 0)) + terms = [(S[i], AS[i]) for i in range(T)] + [(Ta, Ta)] + out.append((cid, lam, terms)) + return out + + +def verify_identity(X, H, a, lam): + """Exact check that the one-extra identity sums to G = X H X^T at (a, lam), + and that the recorded supports match the constructed p_j, q_j.""" + T = len(X[0]) + n = len(X) + G = [[sum(X[t][i] * H[i][k] * X[s][k] for i in range(T) for k in range(T)) + for s in range(n)] for t in range(n)] + P, Q = [], [] + for i in range(T): + pi = [X[t][i] for t in range(n)] + qi = [sum(X[t][k] * (F(H[i][k]) - F(lam) * F(a[i]) * F(a[k])) for k in range(T)) + for t in range(n)] + P.append(pi) + Q.append(qi) + P.append([sum(X[t][k] * F(a[k]) for k in range(T)) for t in range(n)]) + Q.append([F(lam) * sum(X[t][k] * F(a[k]) for k in range(T)) for t in range(n)]) + for t in range(n): + for s in range(n): + lhs = sum(P[j][t] * Q[j][s] for j in range(T + 1)) + if lhs != G[t][s]: + return False, "identity mismatch at (%d,%d)" % (t, s) + for t in range(n): + if G[t][t] == 0: + return False, "zero diagonal at %d" % t + return True, "ok" + + +def one_extra_census_full(L, X, H, dirs, label): + """Exact census of the one-extra rank-one family on one full configuration.""" + n = len(L) + T = len(X[0]) + Brows = b0_rows(L) + best = None + hist = {} + cells_total = 0 + ident_ok = 0 + for a in dirs: + cells = one_extra_cells(X, H, a) + for k, (cid, lam, terms) in enumerate(cells): + cells_total += 1 + if k in (0, len(cells) // 2, len(cells) - 1): + ok, why = verify_identity(X, H, a, lam) + if not ok: + raise AssertionError("identity failed for %s dir=%s cell=%s: %s" % (label, a, cid, why)) + ident_ok += 1 + br = cost_from_masks(Brows, [R for R, _ in terms], [A for _, A in terms]) + c = sum(br) + hist[c] = hist.get(c, 0) + 1 + if best is None or c < best[0]: + best = (c, list(a), cid, str(lam)) + return { + "label": label, + "v": n, + "T": T, + "directions": len(dirs), + "cells": cells_total, + "identity_checks": ident_ok, + "min_cost": best[0], + "min_cost_minus_v": best[0] - n, + "min_witness": {"dir": [str(x) for x in best[1]], "cell": best[2], "lambda": str(best[3])}, + "hist": {str(k): hist[k] for k in sorted(hist)}, + } + + +def one_extra_punctures(L, X, H, dirs, label, mask_range=None): + """Exhaustive puncture census: every nonempty subset U of lines, with the + family restricted to U (supports and B0 intersected with U). + + The per-subset live-count prefilter is validated against unfiltered exact + minima on a deterministic sample of subsets (brute_masks).""" + n = len(L) + T = len(X[0]) + Brows = b0_rows(L) + # Precompute the global family term-support tuples once. + fam = [] + for a in dirs: + for cid, lam, terms in one_extra_cells(X, H, a): + fam.append([(R, A) for R, A in terms]) + lo, hi = (1, (1 << n) - 1) if mask_range is None else mask_range + brute_masks = {lo, hi, lo + 1, hi - 1, (lo + hi) // 2} + brute_mismatches = [] + gains = [] + best = None + ties = 0 + checked = 0 + for mask in range(lo, hi + 1): + vs = mask.bit_count() + checked += 1 + cache = {} + + def block_rank(R, A): + key = (R & mask, A & mask) + v = cache.get(key) + if v is None: + k, l = key + if not k or not l: + v = 0 + else: + rows = [Brows[t] & l for t in range(n) if (k >> t) & 1] + v = rank2(rows) + cache[key] = v + return v + + best_u = None + for terms in fam: + live = 0 + for R, A in terms: + k, l = R & mask, A & mask + if not k or not l: + continue + for t in range(n): + if (k >> t) & 1 and Brows[t] & l: + live += 1 + break + if best_u is not None and live >= best_u: + continue + c = sum(block_rank(R, A) for R, A in terms) + if best_u is None or c < best_u: + best_u = c + if best_u == 0: + break + d = best_u - vs + if mask in brute_masks: + brute = min(sum(block_rank(R, A) for R, A in terms) for terms in fam) + if brute != best_u: + brute_mismatches.append((mask, best_u, brute)) + if best is None or d < best[0]: + best = (d, mask, vs, best_u) + if best_u < vs: + gains.append((mask, vs, best_u)) + elif best_u == vs: + ties += 1 + return { + "label": label, + "lines": n, + "subsets_checked": checked, + "directions": len(dirs), + "family_members_per_subset": len(fam), + "min_cost_minus_v": best[0], + "best_mask": best[1], + "best_v": best[2], + "best_cost": best[3], + "gain_count": len(gains), + "gains": gains[:10], + "tie_count": ties, + "brute_masks_checked": sorted(m for m in brute_masks if lo <= m <= hi), + "brute_mismatches": brute_mismatches, + } + + +# ------------------------------------------------------------------ controls + +def expect(name, got, want, fails): + ok = got == want + print("CTRL %-42s got=%s want=%s %s" % (name, got, want, "OK" if ok else "MISMATCH")) + if not ok: + fails.append((name, got, want)) + return ok + + +def stage_controls(fails, cert): + """Positive control: PR 2272's checked table (PR 2125 values).""" + tab = {} + for nm in ("D4", "D5", "D6"): + L = {"D4": D(4), "D5": D(5), "D6": D(6)}[nm] + P, Q = decoder_std(L) + c, br = config_cost(L, P, Q) + tab[nm] = {"v": len(L), "T": len(L[0]), "cost": c, "block_ranks": br} + expect("%s std B0 cost" % nm, c, {"D4": 12, "D5": 20, "D6": 30}[nm], fails) + L6 = E6() + with open(E6_BEST_PATH, encoding="utf-8") as f: + e6 = json.load(f) + P6, Q6 = decoder_basis(L6, e6["basis"]) + Bstored = [e6["rows"][t] for t in range(len(L6))] + cs, brs = config_cost(L6, P6, Q6, Bstored) + expect("E6 stored basis + stored B cost", cs, 36, fails) + expect("E6 stored cost matches e6_best.json", cs, e6["cost"], fails) + cb, brb = config_cost(L6, P6, Q6) + P6f, Q6f = decoder_basis(L6, first_basis(L6)) + cf, brf = config_cost(L6, P6f, Q6f) + expect("E6 first-basis B0 cost", cf, 37, fails) + tab["E6"] = {"v": 36, "T": 6, "cost": cs, "block_ranks": brs} + tab["E6_firstB0"] = {"v": 36, "T": 6, "cost": cf, "block_ranks": brf} + tab["E6_storedB0"] = {"v": 36, "T": 6, "cost": cb, "block_ranks": brb} + L7, L8 = E7(), E8() + P7, Q7 = decoder_basis(L7, first_basis(L7)) + c7, br7 = config_cost(L7, P7, Q7) + expect("E7 first-basis B0 cost", c7, 49, fails) + tab["E7"] = {"v": len(L7), "T": 7, "cost": c7, "block_ranks": br7} + P8, Q8 = decoder_basis(L8, first_basis(L8)) + c8, br8 = config_cost(L8, P8, Q8) + expect("E8 first-basis B0 cost", c8, 72, fails) + tab["E8"] = {"v": len(L8), "T": 8, "cost": c8, "block_ranks": br8} + for nm, want in (("A4", 16), ("A5", 25), ("A6", 36)): + L = {"A4": A(4), "A5": A(5), "A6": A(6)}[nm] + P, Q = decoder_basis(L, first_basis(L)) + c, br = config_cost(L, P, Q) + tab[nm + "_firstBasis"] = {"v": len(L), "T": len(P[0]), "cost": c, "block_ranks": br} + expect("%s first-basis B0 cost" % nm, c, want, fails) + # mutation control: B = identity must change the cost on D5 and E7 + L5 = D(5) + P5, Q5 = decoder_std(L5) + ci, _ = config_cost(L5, P5, Q5, [1 << t for t in range(len(L5))]) + expect("D5 mutated B=I cost differs from 20", ci != 20, True, fails) + ci7, _ = config_cost(L7, P7, Q7, [1 << t for t in range(len(L7))]) + expect("E7 mutated B=I cost differs from 49", ci7 != 49, True, fails) + cert["controls"] = tab + return tab + + +# ------------------------------------------------------------- T = 7, 8 + +def stage_t7t8(cert): + full = {} + jobs = (("A7", A(7), "first"), ("B7", Bn(7), "std"), ("C7", Cn(7), "std"), + ("D7", D(7), "std"), ("E7", E7(), "first"), + ("pm1_T7", pm1_lines(7), "std"), + ("A8", A(8), "first"), ("B8", Bn(8), "std"), ("C8", Cn(8), "std"), + ("D8", D(8), "std"), ("E8", E8(), "first"), + ("pm1_T8", pm1_lines(8), "std")) + for nm, L, kind in jobs: + if kind == "std": + P, Q = decoder_std(L) + else: + P, Q = decoder_basis(L, first_basis(L)) + c, br = config_cost(L, P, Q) + v = len(L) + width = len(P[0]) + full[nm] = {"v": v, "T_width": width, "ambient": len(L[0]), "cost": c, + "cost_minus_v": c - v, "gain": c < v, + "v_over_Tsq": v > width * width, "block_ranks": br} + print("T78 %-8s v=%4d width=%d ambient=%d cost=%5d cost-v=%+d gain=%s v>T^2=%s" + % (nm, v, width, len(L[0]), c, c - v, c < v, v > width * width)) + cert["t7t8_full"] = full + + +def stage_searches(cert): + rng = random.Random(20261015) + out = {} + jobs = (("A7", A(7)), ("B7", Bn(7)), ("D7", D(7)), ("E7", E7()), + ("A8", A(8)), ("B8", Bn(8)), ("D8", D(8))) + for nm, L in jobs: + T = frac_rank(L) + best = None + idxs = list(range(len(L))) + for _ in range(300): + rng.shuffle(idxs) + pick, cur = [], [] + for i in idxs: + if len(pick) >= T: + break + if frac_rank(cur + [L[i]]) > len(cur): + pick.append(i) + cur.append(L[i]) + if len(pick) != T: + continue + try: + P, Q = decoder_basis(L, pick) + except ValueError: + continue + c, _ = config_cost(L, P, Q) + if best is None or c < best[0]: + best = (c, list(pick)) + stdc, _ = config_cost(L, *decoder_std(L)) if frac_rank(L) == len(L[0]) else (None, None) + out[nm + "_basis_pivot"] = {"trials": 300, "min_cost": best[0], "v": len(L), + "min_cost_minus_v": best[0] - len(L), + "std_cost": stdc, "basis": best[1]} + print("PIV %-8s bases=300 min=%d v=%d min-v=%+d" % (nm, best[0], len(L), best[0] - len(L))) + # seeded greedy/random puncture searches at T = 7/8 (small systems only) + for nm, L in (("A7", A(7)), ("B7", Bn(7)), ("D7", D(7))): + P, Q = decoder_std(L) if frac_rank(L) == len(L[0]) else decoder_basis(L, first_basis(L)) + n = len(L) + Brows = b0_rows(L) + T = len(P[0]) + Pnz = [frozenset(j for j in range(T) if P[t][j] != 0) for t in range(n)] + Qnz = [frozenset(j for j in range(T) if Q[t][j] != 0) for t in range(n)] + + def cost_of(mask): + br = 0 + for j in range(T): + rows = [Brows[t] & mask for t in range(n) if (mask >> t) & 1 and j in Pnz[t]] + cols = sup_mask(s for s in range(n) if (mask >> s) & 1 and j in Qnz[s]) + br += rank2([rw & cols for rw in rows]) if rows else 0 + return br + + best = None + for _ in range(12): + vs = rng.randint(2, n) + mask = 0 + for t in rng.sample(range(n), vs): + mask |= 1 << t + cur = cost_of(mask) - mask.bit_count() + if best is None or cur < best[0]: + best = (cur, mask) + for _ in range(250): + t = rng.randrange(n) + cand = mask ^ (1 << t) + if cand.bit_count() < 2: + continue + d = cost_of(cand) - cand.bit_count() + if d <= cur: + mask, cur = cand, d + if d < best[0]: + best = (d, mask) + for _ in range(200): + vs = rng.randint(2, n) + mask = 0 + for t in rng.sample(range(n), vs): + mask |= 1 << t + d = cost_of(mask) - mask.bit_count() + if d < best[0]: + best = (d, mask) + out[nm + "_puncture_search"] = {"greedy_restarts": 12, "greedy_steps": 250, + "random_trials": 200, "min_cost_minus_v": best[0], + "mask": best[1], "v": best[1].bit_count(), + "cost": best[0] + best[1].bit_count()} + print("SRCH %-8s min(cost-v)=%+d (v=%d)" % (nm, best[0], best[1].bit_count())) + cert["t7t8_searches"] = out + + +# ------------------------------------------------------------ overcomplete + +def configs_smallT(): + """(label, L, X, H) for the overcomplete census. + + Uses standard coordinates (H = I) where the line span is the full ambient + space (D/B/C/F4/{0,+/-1} families, the PR 2125 D-series convention) and the + first-independent span basis otherwise (A family).""" + out = [] + for nm, L in (("A3", A(3)), ("B3", Bn(3)), ("pm1_T3", pm1_lines(3)), + ("A4", A(4)), ("B4", Bn(4)), ("C4", Cn(4)), ("D4", D(4)), ("F4", F4()), + ("pm1_T4", pm1_lines(4)), + ("A5", A(5)), ("B5", Bn(5)), ("C5", Cn(5)), ("D5", D(5))): + if frac_rank(L) == len(L[0]): + P, Q = decoder_std(L) + H = [[1 if i == k else 0 for k in range(len(L[0]))] for i in range(len(L[0]))] + else: + bidx = first_basis(L) + P, Q = decoder_basis(L, bidx) + basis = [L[i] for i in bidx] + T = len(basis) + H = [[dot(basis[i], basis[k]) for k in range(T)] for i in range(T)] + out.append((nm, L, P, H)) + return out + + +def stage_overfull(cert): + res = {} + for nm, L, X, H in configs_smallT(): + T = len(X[0]) + dirs = sorted(set(ternary_dirs(T)) | set(canon([x for x in r]) for r in X)) + dirs = [tuple(F(x) for x in a) for a in dirs] + r = one_extra_census_full(L, X, H, dirs, nm) + res[nm] = r + print("OVF %-8s v=%3d T=%d dirs=%d cells=%d min=%d min-v=%+d" + % (nm, r["v"], r["T"], r["directions"], r["cells"], r["min_cost"], r["min_cost_minus_v"])) + cert["overcomplete_full"] = res + + +def stage_overpunc(cert, only=None, mask_range=None): + res = {} + for nm, L, X, H in configs_smallT(): + if only is not None and nm not in only: + continue + if nm not in ("A3", "B3", "pm1_T3", "A4", "B4", "C4", "D4"): + continue + T = len(X[0]) + dirs = sorted(set(ternary_dirs(T)) | set(canon([x for x in r]) for r in X)) + dirs = [tuple(F(x) for x in a) for a in dirs] + r = one_extra_punctures(L, X, H, dirs, nm, mask_range=mask_range) + if r["brute_mismatches"]: + raise AssertionError("prefilter mismatch on %s: %s" % (nm, r["brute_mismatches"])) + res[nm] = r + print("OVP %-8s subsets=%d dirs=%d members=%d min(cost-v)=%+d gains=%d ties=%d" + % (nm, r["subsets_checked"], r["directions"], r["family_members_per_subset"], + r["min_cost_minus_v"], r["gain_count"], r["tie_count"])) + cert.setdefault("overcomplete_punctures", {}).update(res) + + +# ----------------------------------------------------------------- driver + +def compute(stage, fails, cert, only=None, mask_range=None): + if stage == "controls": + stage_controls(fails, cert) + elif stage == "t7t8": + stage_t7t8(cert) + elif stage == "searches": + stage_searches(cert) + elif stage == "overfull": + stage_overfull(cert) + elif stage == "overpunc": + stage_overpunc(cert, only=only, mask_range=mask_range) + else: + raise SystemExit("unknown stage: " + stage) + + +def main(argv): + sys.stdout.reconfigure(encoding="utf-8") + args = argv[1:] + emit = "--emit" in args + args = [a for a in args if a != "--emit"] + stage = "all" + only = None + mask_range = None + if "--stage" in args: + stage = args[args.index("--stage") + 1] + if "--only" in args: + only = set(args[args.index("--only") + 1].split(",")) + if "--mask-range" in args: + lo, hi = args[args.index("--mask-range") + 1].split(":") + mask_range = (int(lo), int(hi)) + fails = [] + cert_path = os.path.join(HERE, "CERTIFICATE.json") + cert = {"screen": "polar-law T >= 7 threshold screens and small-T overcomplete census", + "model": "full-orthogonal-pattern pairing B0, exact coordinate Gram decoder(s), cost = sum_j rank_F2 B[R_j, A_j]", + "python": sys.version.split()[0]} + stages = ["controls", "t7t8", "searches", "overfull", "overpunc"] if stage == "all" else [stage] + for st in stages: + print("== stage %s ==" % st) + compute(st, fails, cert, only=only, mask_range=mask_range) + cert["control_failures"] = fails + if emit: + # Merge with any existing certificate so shard runs accumulate. + if os.path.exists(cert_path): + old = json.load(open(cert_path, encoding="utf-8")) + for k, v in cert.items(): + if k in ("overcomplete_punctures", "overcomplete_full", "t7t8_full", "t7t8_searches") and isinstance(v, dict): + merged = dict(old.get(k, {})) + merged.update(v) + old[k] = merged + else: + old[k] = v + cert = old + with open(cert_path, "w", encoding="utf-8") as f: + json.dump(cert, f, indent=1, sort_keys=True) + print("CERTIFICATE:", cert_path) + print("CONTROL_FAILURES:", len(fails)) + return 1 if fails else 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/research/polar-law-t7-overcomplete-screen/sources/e6_best.json b/research/polar-law-t7-overcomplete-screen/sources/e6_best.json new file mode 100644 index 0000000000..ee5760953b --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/sources/e6_best.json @@ -0,0 +1 @@ +{"basis": [16, 7, 19, 20, 29, 25], "rows": [4279222275, 64441270275, 13904919564, 54815112204, 22995481392, 45723366192, 40422657984, 28295876544, 16169829360, 52550173680, 24253762764, 44465065164, 41177641020, 27540910140, 27487432899, 41231118531, 44386421811, 24332405811, 52408615695, 16311386895, 62412991146, 56978134618, 47819676006, 30358742422, 38143370601, 20707695001, 11612542629, 6309980757, 34871810709, 17939457637, 9850939737, 6561633705, 6592042326, 9745033638, 17762248346, 34652658282], "cost": 36} \ No newline at end of file diff --git a/research/polar-law-t7-overcomplete-screen/verify.py b/research/polar-law-t7-overcomplete-screen/verify.py new file mode 100644 index 0000000000..e90f13e1a9 --- /dev/null +++ b/research/polar-law-t7-overcomplete-screen/verify.py @@ -0,0 +1,43 @@ +"""Replay for research/polar-law-t7-overcomplete-screen. + +Reruns every stage of search.py and asserts the results match CERTIFICATE.json, +then prints PASS_POLAR_T7_OVERCOMPLETE_SCREEN. Stdlib only; exact arithmetic. +""" +import json +import os +import sys + +HERE = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, HERE) +import search # noqa: E402 + + +def main(): + sys.stdout.reconfigure(encoding="utf-8") + cert_path = os.path.join(HERE, "CERTIFICATE.json") + want = json.load(open(cert_path, encoding="utf-8")) + fails = [] + got = {"python": sys.version.split()[0]} + stages = ["controls", "t7t8", "searches", "overfull", "overpunc"] + for st in stages: + print("== replay stage %s ==" % st) + search.compute(st, fails, got) + if fails: + print("CONTROL FAILURES:", fails) + return 1 + for key in ("controls", "t7t8_full", "t7t8_searches", "overcomplete_full", "overcomplete_punctures"): + if got.get(key) != want.get(key): + print("MISMATCH in certificate key:", key) + for sub in sorted(set(got.get(key, {})) | set(want.get(key, {}))): + if got.get(key, {}).get(sub) != want.get(key, {}).get(sub): + print(" first differing entry:", sub) + print(" got :", json.dumps(got.get(key, {}).get(sub), sort_keys=True)[:400]) + print(" want:", json.dumps(want.get(key, {}).get(sub), sort_keys=True)[:400]) + return 1 + print("MATCH %s (%d entries)" % (key, len(got.get(key, {})))) + print("PASS_POLAR_T7_OVERCOMPLETE_SCREEN") + return 0 + + +if __name__ == "__main__": + sys.exit(main())