From 53288ac7526dd67423cf226a70532fddef24d140 Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Mon, 2 Nov 2026 19:43:15 +0000 Subject: [PATCH] feat(research): certify fixed-prefix P104 tail optimality --- .../p104-prefix-tail-optimum/CERTIFICATE.json | 2256 +++++++++++++++++ research/p104-prefix-tail-optimum/PROOF.md | 166 ++ research/p104-prefix-tail-optimum/README.md | 115 + research/p104-prefix-tail-optimum/RESULT.json | 58 + .../p104-prefix-tail-optimum/SOURCES.json | 30 + research/p104-prefix-tail-optimum/TASK.json | 104 + research/p104-prefix-tail-optimum/VERIFY.json | 37 + research/p104-prefix-tail-optimum/verify.py | 280 ++ 8 files changed, 3046 insertions(+) create mode 100644 research/p104-prefix-tail-optimum/CERTIFICATE.json create mode 100644 research/p104-prefix-tail-optimum/PROOF.md create mode 100644 research/p104-prefix-tail-optimum/README.md create mode 100644 research/p104-prefix-tail-optimum/RESULT.json create mode 100644 research/p104-prefix-tail-optimum/SOURCES.json create mode 100644 research/p104-prefix-tail-optimum/TASK.json create mode 100644 research/p104-prefix-tail-optimum/VERIFY.json create mode 100644 research/p104-prefix-tail-optimum/verify.py diff --git a/research/p104-prefix-tail-optimum/CERTIFICATE.json b/research/p104-prefix-tail-optimum/CERTIFICATE.json new file mode 100644 index 0000000000..1f617d8acf --- /dev/null +++ b/research/p104-prefix-tail-optimum/CERTIFICATE.json @@ -0,0 +1,2256 @@ +{ + "centres": [ + { + "centre": 0, + "chain_count": 5, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + 0, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + 0, + -3 + ] + }, + { + "hinge": 3, + "potentials": [ + -1, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + 0, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + 0, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -1, + -5 + ] + }, + { + "hinge": 4, + "potentials": [ + -1, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + 0, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + 0, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -1, + -6 + ] + }, + { + "hinge": 5, + "potentials": [ + -1, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + 0, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + 0, + -7, + -7, + -7, + -7, + -7, + -7, + -8, + -1, + -7 + ] + }, + { + "hinge": 6, + "potentials": [ + -1, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -1, + -8 + ] + }, + { + "hinge": 7, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + 0, + -8 + ] + } + ], + "nodes": [ + 9, + 17, + 19, + 23, + 41, + 43, + 45, + 55, + 59, + 65, + 147, + 155, + 173, + 193, + 197, + 199, + 219 + ], + "rank_four_witness": [ + 23, + 43, + 45, + 147, + 197 + ] + }, + { + "centre": 1, + "chain_count": 3, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + 0, + -2 + ] + }, + { + "hinge": 3, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -3, + -3, + -3, + -3, + -4, + -4, + -4, + -3, + -4, + -3, + -4, + 0, + -3 + ] + }, + { + "hinge": 4, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -4, + -4, + -4, + -4, + -5, + -5, + -6, + -4, + -6, + -4, + -6, + 0, + -4 + ] + }, + { + "hinge": 5, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5, + -5, + -5, + -5, + -6, + -6, + -7, + -5, + -7, + -5, + -7, + 0, + -5 + ] + }, + { + "hinge": 6, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -6, + -6, + -6, + -6, + -7, + -7, + -8, + -6, + -8, + -6, + -8, + 0, + -6 + ] + }, + { + "hinge": 7, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -7, + -7, + -7, + -7, + -8, + -8, + -8, + -7, + -8, + -7, + -8, + 0, + -7 + ] + } + ], + "nodes": [ + 2, + 6, + 10, + 11, + 38, + 75, + 102, + 103, + 146, + 203, + 210, + 242 + ], + "rank_four_witness": [ + 75, + 102, + 210 + ] + }, + { + "centre": 2, + "chain_count": 4, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + -3, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + 0, + -2 + ] + }, + { + "hinge": 3, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -3, + -3, + -3, + -5, + -3, + -4, + -4, + -3, + -4, + -4, + -3, + -3, + -4, + -4, + 0, + -3 + ] + }, + { + "hinge": 4, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -4, + -4, + -4, + -6, + -4, + -6, + -6, + -4, + -5, + -6, + -4, + -4, + -6, + -6, + 0, + -4 + ] + }, + { + "hinge": 5, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5, + -5, + -5, + -7, + -5, + -8, + -7, + -5, + -6, + -7, + -5, + -5, + -7, + -8, + 0, + -5 + ] + }, + { + "hinge": 6, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -6, + -6, + -6, + -8, + -6, + -8, + -8, + -6, + -7, + -8, + -6, + -6, + -8, + -8, + 0, + -6 + ] + }, + { + "hinge": 7, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -7, + -7, + -7, + -8, + -7, + -8, + -8, + -7, + -8, + -8, + -7, + -7, + -8, + -8, + 0, + -7 + ] + } + ], + "nodes": [ + 4, + 14, + 15, + 22, + 30, + 36, + 63, + 79, + 100, + 101, + 117, + 148, + 149, + 157, + 159 + ], + "rank_four_witness": [ + 15, + 30, + 101, + 149 + ] + }, + { + "centre": 3, + "chain_count": 4, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -1, + -3 + ] + }, + { + "hinge": 3, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + -4, + -4, + -4, + -4, + -4, + -5, + -4, + -4, + -4, + -4, + -4, + -4, + -4, + -4, + -4, + -4, + -1, + -4 + ] + }, + { + "hinge": 4, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + -5, + -5, + -5, + -5, + -5, + -6, + -6, + -6, + -5, + -5, + -6, + -6, + -5, + -6, + -6, + -6, + -1, + -5 + ] + }, + { + "hinge": 5, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + -6, + -6, + -6, + -6, + -6, + -7, + -7, + -8, + -6, + -6, + -7, + -8, + -6, + -7, + -7, + -8, + -1, + -6 + ] + }, + { + "hinge": 6, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + -7, + -7, + -7, + -7, + -7, + -8, + -8, + -8, + -7, + -7, + -8, + -8, + -7, + -8, + -8, + -8, + -1, + -7 + ] + }, + { + "hinge": 7, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + -1, + -1, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -1, + -8 + ] + } + ], + "nodes": [ + 8, + 26, + 40, + 44, + 73, + 104, + 108, + 110, + 111, + 154, + 172, + 188, + 190, + 201, + 205, + 218, + 237 + ], + "rank_four_witness": [ + 108, + 154, + 172, + 201 + ] + }, + { + "centre": 4, + "chain_count": 4, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + -1, + -1, + 0, + 0, + 0, + -1, + -1, + 0, + -1, + -1, + 0, + -1, + 0, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -1, + -3 + ] + }, + { + "hinge": 3, + "potentials": [ + -2, + -1, + 0, + 0, + 0, + -2, + -2, + 0, + -1, + -2, + 0, + -2, + 0, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -2, + -5 + ] + }, + { + "hinge": 4, + "potentials": [ + -2, + -1, + 0, + 0, + 0, + -2, + -2, + 0, + 0, + -2, + 0, + -2, + 0, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -2, + -6 + ] + }, + { + "hinge": 5, + "potentials": [ + -2, + -1, + 0, + 0, + 0, + -2, + -2, + 0, + 0, + -2, + 0, + -2, + 0, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -2, + -7 + ] + }, + { + "hinge": 6, + "potentials": [ + -2, + -1, + 0, + 0, + 0, + -2, + -2, + 0, + 0, + -2, + 0, + -2, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -2, + -8 + ] + }, + { + "hinge": 7, + "potentials": [ + -1, + 0, + 0, + 0, + 0, + -1, + -1, + 0, + 0, + -1, + 0, + -1, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -1, + -8 + ] + } + ], + "nodes": [ + 16, + 18, + 25, + 54, + 57, + 61, + 118, + 208, + 212, + 215, + 240, + 248 + ], + "rank_four_witness": [ + 54, + 57, + 212, + 240 + ] + }, + { + "centre": 5, + "chain_count": 3, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + -2, + 0, + -2 + ] + }, + { + "hinge": 3, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -3, + -3, + -3, + -3, + -4, + -4, + -3, + -3, + -4, + 0, + -3 + ] + }, + { + "hinge": 4, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -4, + -4, + -4, + -4, + -5, + -6, + -4, + -4, + -6, + 0, + -4 + ] + }, + { + "hinge": 5, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -5, + -5, + -5, + -5, + -6, + -7, + -5, + -5, + -7, + 0, + -5 + ] + }, + { + "hinge": 6, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -6, + -6, + -6, + -6, + -7, + -8, + -6, + -6, + -8, + 0, + -6 + ] + }, + { + "hinge": 7, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -7, + -7, + -7, + -7, + -8, + -8, + -7, + -7, + -8, + 0, + -7 + ] + } + ], + "nodes": [ + 32, + 42, + 58, + 96, + 97, + 113, + 115, + 180, + 181, + 186 + ], + "rank_four_witness": [ + 58, + 113, + 180 + ] + }, + { + "centre": 6, + "chain_count": 4, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + -1, + 0, + 0, + -1, + -1, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + -1, + 0, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -1, + -3 + ] + }, + { + "hinge": 3, + "potentials": [ + -2, + 0, + 0, + -2, + -1, + 0, + 0, + -2, + -1, + 0, + 0, + -2, + -2, + 0, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -2, + -5 + ] + }, + { + "hinge": 4, + "potentials": [ + -2, + 0, + 0, + -2, + 0, + 0, + 0, + -2, + -1, + 0, + 0, + -2, + -2, + 0, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -2, + -6 + ] + }, + { + "hinge": 5, + "potentials": [ + -2, + 0, + 0, + -2, + 0, + 0, + 0, + -2, + -1, + 0, + 0, + -2, + -2, + 0, + -7, + -7, + -7, + -7, + -7, + -7, + -8, + -7, + -7, + -7, + -7, + -7, + -2, + -7 + ] + }, + { + "hinge": 6, + "potentials": [ + -2, + 0, + 0, + -2, + 0, + 0, + 0, + -2, + -1, + 0, + 0, + -2, + -2, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -2, + -8 + ] + }, + { + "hinge": 7, + "potentials": [ + -1, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + -1, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -1, + -8 + ] + } + ], + "nodes": [ + 64, + 81, + 83, + 87, + 89, + 106, + 122, + 123, + 192, + 196, + 198, + 206, + 249 + ], + "rank_four_witness": [ + 83, + 89, + 106, + 198 + ] + }, + { + "centre": 7, + "chain_count": 5, + "hinges": [ + { + "hinge": 1, + "potentials": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 0, + -1 + ] + }, + { + "hinge": 2, + "potentials": [ + -1, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + 0, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -3, + -1, + -3 + ] + }, + { + "hinge": 3, + "potentials": [ + -2, + -1, + 0, + 0, + -2, + -1, + 0, + 0, + 0, + 0, + 0, + -2, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + 0, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -5, + -2, + -5 + ] + }, + { + "hinge": 4, + "potentials": [ + -2, + -1, + 0, + 0, + -2, + -1, + 0, + 0, + 0, + 0, + 0, + -2, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + 0, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -6, + -2, + -6 + ] + }, + { + "hinge": 5, + "potentials": [ + -2, + -1, + 0, + 0, + -2, + -1, + 0, + 0, + 0, + 0, + 0, + -2, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + 0, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -7, + -8, + -8, + -8, + -2, + -7 + ] + }, + { + "hinge": 6, + "potentials": [ + -2, + -1, + 0, + 0, + -2, + -1, + 0, + 0, + 0, + 0, + 0, + -2, + 0, + 0, + 0, + 0, + 0, + -2, + -2, + -2, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -2, + -8 + ] + }, + { + "hinge": 7, + "potentials": [ + -1, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + -1, + -1, + -1, + 0, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -8, + -1, + -8 + ] + } + ], + "nodes": [ + 128, + 132, + 134, + 142, + 143, + 144, + 145, + 153, + 164, + 166, + 182, + 185, + 224, + 225, + 229, + 232, + 234, + 238, + 245, + 246 + ], + "rank_four_witness": [ + 142, + 153, + 166, + 225, + 232 + ] + } + ], + "optimal_histogram": { + "1": 85, + "2": 17, + "3": 19, + "4": 20 + }, + "schema": "p104-prefix-tail-duals/v1", + "source_sha256": "ddc8fe8271392bd5b7c795550a7c52b850fc3bb3efbbf43896c55e0ecc080f48" +} diff --git a/research/p104-prefix-tail-optimum/PROOF.md b/research/p104-prefix-tail-optimum/PROOF.md new file mode 100644 index 0000000000..cd1fbb2987 --- /dev/null +++ b/research/p104-prefix-tail-optimum/PROOF.md @@ -0,0 +1,166 @@ +# Exact optimum with the prefix paths fixed + +## 1. Contract and theorem + +Use Adam Gall's PR1940 supplied-copy boundary and its exact +`SCHEDULE.json`. A parent edge `[S,k]` requires a centre-k read at the +frame spanned by survivor labels in the eight-bit mask S. All survivor +labels are independent, so inclusion of these frames is inclusion of +masks and their dimensions are popcounts. These geometric and decoder +facts are inherited premises, not newly audited here. + +Let D_k be the distinct masks assigned to centre k by the parent edges. +A cover partitions each D_k into nonempty chains under strict inclusion. +It has 32 chains in total. Each chain carries that one centre's exact +value, enters at the singleton `{k}`, visits its chain masks, and exits at +the full frame V of dimension 9. A frame increment of rank r costs f(r), +and f(0)=0. No centre mixing, redrop, changed target order or changed +entry/exit contract is allowed. All direct strict inclusion links are +permitted, not just consecutive links in the published cover. + +**Theorem.** For every concave f on integer ranks 0,...,8, the minimum +delivery-tail cost over these covers is + +```text +85 f(1) + 17 f(2) + 19 f(3) + 20 f(4). +``` + +The minimum is attained by PR1940's published cover. Concavity here means +that f(r)-f(r-1) is nonincreasing. Nondecreasing tariffs are included, but +that additional restriction is unnecessary for the proof. + +The attaining construction and its 32-path count are credited to PR1940 +and Ali Romman's PR1125 respectively. The new assertion is optimality +over the complete fixed-path chain-assignment class. + +## 2. Chain cardinalities and chronology + +The per-centre numbers of rank-four masks are + +```text +centre 0 1 2 3 4 5 6 7 +rank-four masks 5 3 4 4 4 3 4 5 +``` + +The checker enumerates these masks and stores them as antichain witnesses. +A chain can contain at most one of them. Their counts sum to 32 and the +published cover attains every count. Therefore every cover with 32 chains +must have exactly the displayed number c_k at each centre. This is the +fixed-prefix specialization of the credited rank-four antichain argument. + +Each target's successive prefix masks strictly increase in dimension. +Every strict link in a carrier chain does too. Process equal-frame reads +together and otherwise order by increasing dimension, breaking ties by +mask. That respects both target and carrier dependencies. Thus changing +the chain assignment within this class introduces no chronological cycle. +The target moves and scalar reads are unchanged by the assignment. + +Every chain starts in dimension 1 and ends in dimension 9, hence its +increment ranks sum to 8. Every cover therefore has rank mass +32*8=256. This equality is essential for the linear term in section 5. + +## 3. A matching formulation with every legal link + +Fix a centre, put n=|D_k| and make a left and right vertex for every mask +u in D_k. Include an edge u_L to v_R exactly when u is a proper subset of +v. A matching of cardinality n-c_k is precisely a partition into c_k +chains: a matched edge declares an immediate successor. Each mask has +at most one predecessor and successor. Strict inclusion forbids cycles. +Conversely, consecutive pairs in any cover give such a matching. + +Write a=|u| and b=|v|. Starting with each node on a separate chain gives +the constant cost + +```text +B_f = sum_(u in D_k) [f(|u|-1) + f(9-|u|)]. +``` + +Joining u to v replaces u's exit and v's entry by one direct increment. +Give the matching edge cost + +```text +w_f(u,v) = f(b-a) - f(9-a) - f(b-1). +``` + +Then a cover's price equals B_f plus the sum of its matching-edge costs. +This includes every entry and exit increment, including zero increments +at singleton read frames. There is no charge omission at chain endpoints. + +Add a source with unit-capacity zero-cost arcs to all left vertices and +unit-capacity zero-cost arcs from all right vertices to a sink. A matching +is an integral source/sink flow of the prescribed value n-c_k. + +## 4. Exact optimality potentials + +For j=1,...,7 use the hinge tariff h_j(r)=min(r,j). Form the residual +network at the published matching. An unused arc remains forward with +its original cost; a used arc is reversed and its cost negated. This +applies to the source/left and right/sink arcs too, not only links. + +For every centre and hinge the certificate gives one integer potential +pi on all 2n+2 vertices. The checker enumerates every residual arc a to b +and verifies + +```text +cost(a,b) + pi(a) - pi(b) >= 0. +``` + +Every residual circulation then has nonnegative cost, since potentials +telescope. The difference from the published flow to any other feasible +flow of the same value is a sum of residual circulations. Thus no other +matching, and hence no other c_k-chain cover, has a lower hinge price. +This argument requires no trust in an optimization status or numerical +tolerance. The optional certificate generator only finds the integer +potentials; acceptance is the direct inequality check. + +There are 56 witnesses and 3,752 inequalities. The published cover's +total hinge minima, including all centres, are + +```text +j 1 2 3 4 5 6 7 8 +minimum 141 197 236 256 256 256 256 256 +``` + +The j=8 column is the common linear rank mass. The source cover's +histogram gives those values exactly. No global enumeration of chain +covers is asserted; the dual inequalities cover every matching through +the circulation argument. + +## 5. All concave tariffs + +Put Delta_r=f(r)-f(r-1) and d_j=Delta_j-Delta_(j+1). Discrete concavity +is exactly d_j>=0 for j=1,...,7. Directly comparing first differences +gives the identity, for r=0,...,8, + +```text +f(r) = Delta_8*r + sum_(j=1)^7 d_j*min(r,j). +``` + +The linear rank sum is the same for every cover. The published cover +minimizes every hinge separately by section 4. Taking their nonnegative +linear combination proves the theorem. In particular, the restriction +of r^s to these integer ranks is concave for every 0 None: + if not condition: + raise ValueError(message) + + +def read_bytes(path: Path) -> bytes: + require(path.is_file() and not path.is_symlink(), f"not a regular file: {path}") + with path.open("rb") as stream: + data = stream.read(LIMIT + 1) + require(len(data) <= LIMIT, f"file exceeds {LIMIT} bytes: {path}") + return data + + +def read_json(path: Path): + return json.loads(read_bytes(path)) + + +def input_pins() -> dict[str, str]: + manifest = read_json(HERE / "SOURCES.json") + require(len(manifest["files"]) <= 8, "source manifest capacity") + result = {} + for row in manifest["files"]: + if row["usage"] == "input": + path = row["path"] + require(path in {SOURCE, "research/p104-target-order-delivery/README.md"}, + "unexpected live input") + digest = sha256(read_bytes(ROOT / path)).hexdigest() + require(digest == row["sha256"], f"source hash: {path}") + result[path] = digest + require(len(result) == 2, "missing live input") + return result + + +def validate_cover(nodes, chains, centre: int) -> None: + require(isinstance(chains, list) and 1 <= len(chains) <= 20, "chain capacity") + flattened = [] + for chain in chains: + require(isinstance(chain, list) and 1 <= len(chain) <= 20, "path capacity") + require(all(type(mask) is int and 1 <= mask <= 255 for mask in chain), + "chain mask") + require(all(mask & (1 << centre) for mask in chain), "lost survivor") + require(all(u != v and u & v == u for u, v in pairwise(chain)), + "nonnested chain") + flattened.extend(chain) + require(sorted(flattened) == list(nodes), "missing or duplicate read frame") + + +def problem(schedule): + edges = schedule["parent_edges"] + require(isinstance(edges, list) and len(edges) == 116, "prefix edge count") + nodes = [[] for _ in range(8)] + masks = set() + for edge in edges: + require(isinstance(edge, list) and len(edge) == 2, "prefix edge shape") + mask, centre = edge + require(type(mask) is int and 1 <= mask <= 255, "prefix mask") + require(type(centre) is int and 0 <= centre < 8, "prefix centre") + require(mask & (1 << centre) and mask not in masks, "prefix survivor/duplicate") + nodes[centre].append(mask) + masks.add(mask) + chains = schedule["chains"] + require(isinstance(chains, list) and len(chains) == 8, "centre count") + for centre in range(8): + nodes[centre].sort() + require(1 <= len(nodes[centre]) <= 20, "node capacity") + validate_cover(nodes[centre], chains[centre], centre) + antichain = [mask for mask in nodes[centre] if mask.bit_count() == 4] + require(len(antichain) == len(chains[centre]), "rank-four saturation") + require(sum(map(len, chains)) == 32, "total chain count") + return nodes, chains + + +def histogram(chains) -> dict[str, int]: + counts = Counter() + for centre_chains in chains: + for chain in centre_chains: + ranks = [1, *[mask.bit_count() for mask in chain], 9] + counts.update(v - u for u, v in pairwise(ranks) if v > u) + return {str(rank): counts[rank] for rank in sorted(counts)} + + +def residual_arcs(nodes, chains, hinge: int): + """Unit-capacity matching residual graph; source=2n, sink=2n+1.""" + n = len(nodes) + index = {mask: i for i, mask in enumerate(nodes)} + matching = {(index[u], index[v]) for chain in chains for u, v in pairwise(chain)} + left_used = {i for i, _ in matching} + right_used = {j for _, j in matching} + source, sink = 2 * n, 2 * n + 1 + arcs = [] + for i in range(n): + arcs.append((i, source, 0) if i in left_used else (source, i, 0)) + arcs.append((sink, n + i, 0) if i in right_used else (n + i, sink, 0)) + for i, lower in enumerate(nodes): + for j, upper in enumerate(nodes): + if lower != upper and lower & upper == lower: + a, b = lower.bit_count(), upper.bit_count() + cost = min(b - a, hinge) - min(9 - a, hinge) - min(b - 1, hinge) + arcs.append((n + j, i, -cost) if (i, j) in matching + else (i, n + j, cost)) + return arcs + + +def check_dual(nodes, chains, record) -> int: + require(type(record["hinge"]) is int and 1 <= record["hinge"] <= 7, + "hinge domain") + potentials = record["potentials"] + require(isinstance(potentials, list) and len(potentials) == 2 * len(nodes) + 2, + "potential dimension") + require(all(type(value) is int and -256 <= value <= 256 for value in potentials), + "potential integer/capacity") + arcs = residual_arcs(nodes, chains, record["hinge"]) + for u, v, cost in arcs: + require(cost + potentials[u] - potentials[v] >= 0, "negative reduced cost") + return len(arcs) + + +def check_certificate(schedule, certificate, source_digest: str): + nodes, chains = problem(schedule) + require(certificate["schema"] == "p104-prefix-tail-duals/v1", "certificate schema") + require(certificate["source_sha256"] == source_digest, "certificate source binding") + actual_histogram = histogram(chains) + require(certificate["optimal_histogram"] == actual_histogram, "false optimum value") + require(actual_histogram == {"1": 85, "2": 17, "3": 19, "4": 20}, "stated histogram") + records = certificate["centres"] + require(isinstance(records, list) and len(records) == 8, "dual centre count") + inequalities = 0 + for centre in range(8): + record = records[centre] + require(record["centre"] == centre and type(record["centre"]) is int, + "dual centre identity") + require(record["nodes"] == nodes[centre], "dual node identity") + require(record["chain_count"] == len(chains[centre]), "dual chain count") + require(record["rank_four_witness"] == + [mask for mask in nodes[centre] if mask.bit_count() == 4], "antichain identity") + duals = record["hinges"] + require(isinstance(duals, list) and len(duals) == 7, "dual hinge count") + for hinge, dual in enumerate(duals, 1): + require(dual["hinge"] == hinge, "missing/duplicate hinge") + inequalities += check_dual(nodes[centre], chains[centre], dual) + return nodes, chains, inequalities + + +def shortest_potentials(arcs, vertices: int) -> list[int]: + """Generate a witness, never use a solver status as acceptance.""" + distances = [0] * vertices + for _ in range(vertices): + changed = False + for u, v, cost in arcs: + if distances[v] > distances[u] + cost: + distances[v] = distances[u] + cost + changed = True + if not changed: + break + require(all(cost + distances[u] - distances[v] >= 0 for u, v, cost in arcs), + "no optimality potential for the supplied cover") + return distances + + +def make_certificate(schedule, source_digest: str): + nodes, chains = problem(schedule) + records = [] + for centre in range(8): + duals = [] + for hinge in range(1, 8): + arcs = residual_arcs(nodes[centre], chains[centre], hinge) + duals.append({"hinge": hinge, "potentials": + shortest_potentials(arcs, 2 * len(nodes[centre]) + 2)}) + records.append({"centre": centre, "nodes": nodes[centre], + "chain_count": len(chains[centre]), "rank_four_witness": + [mask for mask in nodes[centre] if mask.bit_count() == 4], + "hinges": duals}) + return {"schema": "p104-prefix-tail-duals/v1", "source_sha256": source_digest, + "optimal_histogram": histogram(chains), "centres": records} + + +def rejected(schedule, certificate, source_digest: str) -> None: + try: + check_certificate(schedule, certificate, source_digest) + except ValueError: + return + raise ValueError("semantic rejection control was accepted") + + +def controls(schedule, certificate, source_digest: str) -> list[str]: + tested = [] + for mode in range(8): + changed_schedule, changed_certificate = deepcopy(schedule), deepcopy(certificate) + if mode == 0: + changed_schedule["chains"][0][0].append(changed_schedule["chains"][0][0][-1]) + elif mode == 1: + changed_schedule["chains"][0][0].pop() + elif mode == 2: + changed_schedule["chains"][0][0].reverse() + elif mode == 3: + changed_schedule["parent_edges"][0][1] = 0 + elif mode == 4: + changed_certificate["optimal_histogram"]["1"] += 1 + elif mode == 5: + changed_certificate["centres"][0]["hinges"][0]["potentials"].pop() + elif mode == 6: + dual = changed_certificate["centres"][0]["hinges"][1] + nodes = changed_certificate["centres"][0]["nodes"] + u, v, cost = residual_arcs(nodes, schedule["chains"][0], 2)[0] + dual["potentials"][v] = dual["potentials"][u] + cost + 1 + else: + changed_certificate["centres"][0]["hinges"][1]["hinge"] = 1 + rejected(changed_schedule, changed_certificate, source_digest) + tested.append(["duplicate-frame", "omitted-frame", "reversed-chain", + "wrong-survivor", "false-optimum", "short-potential", + "negative-reduced-cost", "duplicate-hinge"][mode]) + return tested + + +def make_receipt(pins, nodes, chains, inequalities: int, tested): + names = ("README.md", "PROOF.md", "TASK.json", "SOURCES.json", "VERIFY.json", + "CERTIFICATE.json", "verify.py") + files = {name: sha256(read_bytes(HERE / name)).hexdigest() for name in names} + return {"schema": "p104-prefix-tail-result/v1", "claim_type": "scoped proof", + "files_sha256": files, "inputs_sha256": pins, + "read_frames": sum(map(len, nodes)), "chains": sum(map(len, chains)), + "chain_counts": list(map(len, chains)), "hinge_duals": 56, + "checked_residual_inequalities": inequalities, + "optimal_histogram": histogram(chains), "rank_mass": 256, + "hinge_optima": {str(j): sum(count * min(int(rank), j) + for rank, count in histogram(chains).items()) + for j in range(1, 9)}, "controls_rejected": tested} + + +def write_json(path: Path, value) -> None: + text = json.dumps(value, indent=2, sort_keys=True) + "\n" + require(path.write_text(text) == len(text), "short artifact write") + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + outputs = parser.add_mutually_exclusive_group() + outputs.add_argument("--emit-certificate", type=Path) + outputs.add_argument("--emit-receipt", type=Path) + args = parser.parse_args() + pins = input_pins() + schedule = read_json(ROOT / SOURCE) + if args.emit_certificate: + certificate = make_certificate(schedule, pins[SOURCE]) + check_certificate(schedule, certificate, pins[SOURCE]) + write_json(args.emit_certificate, certificate) + print("PASS_GENERATED_P104_PREFIX_TAIL_DUALS") + return + certificate = read_json(HERE / "CERTIFICATE.json") + nodes, chains, inequalities = check_certificate(schedule, certificate, pins[SOURCE]) + tested = controls(schedule, certificate, pins[SOURCE]) + receipt = make_receipt(pins, nodes, chains, inequalities, tested) + if args.emit_receipt: + write_json(args.emit_receipt, receipt) + else: + require(read_json(HERE / "RESULT.json") == receipt, "receipt mismatch") + print(f"PASS_P104_PREFIX_TAIL_OPTIMUM chains=32 frames=116 duals=56 " + f"inequalities={inequalities} controls={len(tested)} all_concave no_new_kappa") + + +if __name__ == "__main__": + main()