diff --git a/research/bit-zero-frame-feedback/CERTIFICATE.json b/research/bit-zero-frame-feedback/CERTIFICATE.json new file mode 100644 index 0000000000..889acec6cf --- /dev/null +++ b/research/bit-zero-frame-feedback/CERTIFICATE.json @@ -0,0 +1,1913 @@ +{ + "all_inputs_arbitrary": true, + "ancillas": 0, + "controls": { + "negative_controls": [ + "feedback_rejected_in_restricted_alphabet", + "omitted_helper_restoration", + "wrong_helper_column", + "residual_target_basis", + "wrong_target_map", + "self_xor_noninvertible", + "boolean_gate_index", + "insufficient_radius" + ], + "positive_feedback_cost": 5, + "positive_star_cost": 3 + }, + "dimensions": [ + { + "helpers": 1, + "maps": 2, + "minimum_histogram": { + "0": 1, + "1": 1 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 1, + "restricted_witness": [ + [ + 1, + 0 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 1, + 0, + 0, + 0 + ], + "targets": 1, + "unrestricted_spheres": [ + 1, + 2, + 2, + 1, + 0 + ] + }, + { + "helpers": 1, + "maps": 4, + "minimum_histogram": { + "0": 1, + "1": 2, + "2": 1 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 2, + "restricted_witness": [ + [ + 1, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 1, + "restricted_witness": [ + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 4, + 9, + 7, + 3 + ], + "targets": 2, + "unrestricted_spheres": [ + 1, + 6, + 24, + 51, + 60 + ] + }, + { + "helpers": 1, + "maps": 8, + "minimum_histogram": { + "0": 1, + "1": 3, + "2": 3, + "3": 1 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 3, + "restricted_witness": [ + [ + 1, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 3, + "restricted_witness": [ + [ + 1, + 0 + ], + [ + 2, + 0 + ] + ] + }, + { + "k": 7, + "minimum": 3, + "orbit_size": 1, + "restricted_witness": [ + [ + 1, + 0 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 9, + 51, + 187, + 393 + ], + "targets": 3, + "unrestricted_spheres": [ + 1, + 12, + 96, + 542, + 2058 + ] + }, + { + "helpers": 2, + "maps": 4, + "minimum_histogram": { + "0": 1, + "1": 2, + "2": 1 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 2, + "restricted_witness": [ + [ + 2, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 1, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 4, + 9, + 7, + 3 + ], + "targets": 1, + "unrestricted_spheres": [ + 1, + 6, + 24, + 51, + 60 + ] + }, + { + "helpers": 2, + "maps": 16, + "minimum_histogram": { + "0": 1, + "1": 4, + "2": 6, + "3": 4, + "4": 1 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 4, + "restricted_witness": [ + [ + 2, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 2, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ] + ] + }, + { + "k": 5, + "minimum": 2, + "orbit_size": 2, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 6, + "minimum": 2, + "orbit_size": 2, + "restricted_witness": [ + [ + 2, + 1 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 7, + "minimum": 3, + "orbit_size": 4, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 15, + "minimum": 4, + "orbit_size": 1, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 1 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 8, + 38, + 110, + 153 + ], + "targets": 2, + "unrestricted_spheres": [ + 1, + 12, + 96, + 542, + 2058 + ] + }, + { + "helpers": 2, + "maps": 64, + "minimum_histogram": { + "0": 1, + "1": 6, + "2": 15, + "3": 20, + "4": 15, + "5": 7 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 6, + "restricted_witness": [ + [ + 2, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 3, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ] + ] + }, + { + "k": 5, + "minimum": 2, + "orbit_size": 6, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 6, + "minimum": 2, + "orbit_size": 6, + "restricted_witness": [ + [ + 2, + 1 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 7, + "minimum": 3, + "orbit_size": 12, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 15, + "minimum": 4, + "orbit_size": 3, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 21, + "minimum": 3, + "orbit_size": 2, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 22, + "minimum": 3, + "orbit_size": 6, + "restricted_witness": [ + [ + 2, + 1 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 23, + "minimum": 4, + "orbit_size": 6, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 27, + "minimum": 4, + "orbit_size": 6, + "restricted_witness": [ + [ + 2, + 0 + ], + [ + 2, + 1 + ], + [ + 3, + 1 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 31, + "minimum": 5, + "orbit_size": 6, + "restricted_witness": [ + [ + 4, + 0 + ], + [ + 0, + 1 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 63, + "minimum": 5, + "orbit_size": 1, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ], + [ + 0, + 1 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 14, + 119, + 714, + 2973 + ], + "targets": 3, + "unrestricted_spheres": [ + 1, + 20, + 260, + 2570, + 19680 + ] + }, + { + "helpers": 3, + "maps": 8, + "minimum_histogram": { + "0": 1, + "1": 3, + "2": 3, + "3": 1 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 3, + "restricted_witness": [ + [ + 3, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 3, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ] + ] + }, + { + "k": 7, + "minimum": 3, + "orbit_size": 1, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 3, + 2 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 9, + 51, + 187, + 393 + ], + "targets": 1, + "unrestricted_spheres": [ + 1, + 12, + 96, + 542, + 2058 + ] + }, + { + "helpers": 3, + "maps": 64, + "minimum_histogram": { + "0": 1, + "1": 6, + "2": 15, + "3": 20, + "4": 15, + "5": 7 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ] + ] + }, + { + "k": 7, + "minimum": 3, + "orbit_size": 2, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 3, + 2 + ] + ] + }, + { + "k": 9, + "minimum": 2, + "orbit_size": 3, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 10, + "minimum": 2, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 11, + "minimum": 3, + "orbit_size": 12, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 14, + "minimum": 3, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 15, + "minimum": 4, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 27, + "minimum": 4, + "orbit_size": 3, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 29, + "minimum": 4, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 4, + 1 + ] + ] + }, + { + "k": 31, + "minimum": 5, + "orbit_size": 6, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 3, + 0 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 63, + "minimum": 5, + "orbit_size": 1, + "restricted_witness": [ + [ + 3, + 4 + ], + [ + 4, + 0 + ], + [ + 4, + 1 + ], + [ + 4, + 2 + ], + [ + 3, + 4 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 14, + 119, + 714, + 2973 + ], + "targets": 2, + "unrestricted_spheres": [ + 1, + 20, + 260, + 2570, + 19680 + ] + }, + { + "helpers": 3, + "maps": 512, + "minimum_histogram": { + "0": 1, + "1": 9, + "2": 36, + "3": 84, + "4": 126, + "5": 132, + "6": 96, + "7": 28 + }, + "orbits": [ + { + "k": 0, + "minimum": 0, + "orbit_size": 1, + "restricted_witness": [] + }, + { + "k": 1, + "minimum": 1, + "orbit_size": 9, + "restricted_witness": [ + [ + 3, + 0 + ] + ] + }, + { + "k": 3, + "minimum": 2, + "orbit_size": 9, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ] + ] + }, + { + "k": 7, + "minimum": 3, + "orbit_size": 3, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 3, + 2 + ] + ] + }, + { + "k": 9, + "minimum": 2, + "orbit_size": 9, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 10, + "minimum": 2, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 11, + "minimum": 3, + "orbit_size": 36, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 14, + "minimum": 3, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 15, + "minimum": 4, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ] + ] + }, + { + "k": 27, + "minimum": 4, + "orbit_size": 9, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 29, + "minimum": 4, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 4, + 1 + ] + ] + }, + { + "k": 31, + "minimum": 5, + "orbit_size": 18, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 3, + 0 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 63, + "minimum": 5, + "orbit_size": 3, + "restricted_witness": [ + [ + 3, + 4 + ], + [ + 4, + 0 + ], + [ + 4, + 1 + ], + [ + 4, + 2 + ], + [ + 3, + 4 + ] + ] + }, + { + "k": 73, + "minimum": 3, + "orbit_size": 3, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 74, + "minimum": 3, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 75, + "minimum": 4, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 78, + "minimum": 4, + "orbit_size": 9, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 79, + "minimum": 5, + "orbit_size": 9, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 83, + "minimum": 4, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 1 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 84, + "minimum": 3, + "orbit_size": 6, + "restricted_witness": [ + [ + 3, + 2 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 85, + "minimum": 4, + "orbit_size": 36, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 3, + 2 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ] + ] + }, + { + "k": 87, + "minimum": 5, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 91, + "minimum": 5, + "orbit_size": 18, + "restricted_witness": [ + [ + 5, + 0 + ], + [ + 0, + 1 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 93, + "minimum": 5, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ], + [ + 3, + 0 + ] + ] + }, + { + "k": 94, + "minimum": 5, + "orbit_size": 36, + "restricted_witness": [ + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ], + [ + 3, + 1 + ] + ] + }, + { + "k": 95, + "minimum": 6, + "orbit_size": 36, + "restricted_witness": [ + [ + 3, + 2 + ], + [ + 5, + 0 + ], + [ + 0, + 1 + ], + [ + 4, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 118, + "minimum": 5, + "orbit_size": 9, + "restricted_witness": [ + [ + 1, + 2 + ], + [ + 3, + 1 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ], + [ + 1, + 2 + ] + ] + }, + { + "k": 119, + "minimum": 6, + "orbit_size": 18, + "restricted_witness": [ + [ + 1, + 2 + ], + [ + 3, + 1 + ], + [ + 4, + 1 + ], + [ + 5, + 0 + ], + [ + 3, + 0 + ], + [ + 1, + 2 + ] + ] + }, + { + "k": 127, + "minimum": 6, + "orbit_size": 9, + "restricted_witness": [ + [ + 3, + 4 + ], + [ + 4, + 1 + ], + [ + 4, + 2 + ], + [ + 5, + 0 + ], + [ + 4, + 0 + ], + [ + 3, + 4 + ] + ] + }, + { + "k": 219, + "minimum": 5, + "orbit_size": 3, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 3, + 0 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 221, + "minimum": 6, + "orbit_size": 18, + "restricted_witness": [ + [ + 3, + 0 + ], + [ + 0, + 1 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ], + [ + 3, + 2 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 223, + "minimum": 6, + "orbit_size": 9, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 238, + "minimum": 6, + "orbit_size": 6, + "restricted_witness": [ + [ + 4, + 0 + ], + [ + 4, + 2 + ], + [ + 5, + 0 + ], + [ + 5, + 1 + ], + [ + 3, + 2 + ], + [ + 3, + 1 + ] + ] + }, + { + "k": 239, + "minimum": 7, + "orbit_size": 18, + "restricted_witness": [ + [ + 4, + 0 + ], + [ + 0, + 1 + ], + [ + 4, + 2 + ], + [ + 5, + 0 + ], + [ + 3, + 2 + ], + [ + 3, + 0 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 255, + "minimum": 7, + "orbit_size": 9, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 5, + 0 + ], + [ + 0, + 2 + ], + [ + 4, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 2 + ], + [ + 0, + 1 + ] + ] + }, + { + "k": 511, + "minimum": 7, + "orbit_size": 1, + "restricted_witness": [ + [ + 0, + 1 + ], + [ + 0, + 2 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ], + [ + 3, + 0 + ], + [ + 0, + 2 + ], + [ + 0, + 1 + ] + ] + } + ], + "restricted_spheres": [ + 1, + 21, + 264, + 2436, + 17142 + ], + "targets": 3, + "unrestricted_spheres": [ + 1, + 30, + 570, + 8415, + 101610 + ] + } + ], + "gate_cost": 1, + "kind": "finite-exact-shortest-circuit-certificate", + "schema_version": 1 +} diff --git a/research/bit-zero-frame-feedback/README.md b/research/bit-zero-frame-feedback/README.md new file mode 100644 index 0000000000..60ef66f366 --- /dev/null +++ b/research/bit-zero-frame-feedback/README.md @@ -0,0 +1,221 @@ +# Zero-frame target feedback: exact three-helper/three-target census + +**Finite exact negative result and a scoped prefix-substitution lemma; no new +supplier or kappa.** For every binary 3-by-3 matrix K, allowing targets to feed +helpers does **not** shorten the minimum fully restored circuit + + (h, y) -> (h, y + K h). + +Here all six registers are arbitrary dirty inputs, every gate is a unit-cost +single-source XOR, and there are no additional registers. The result covers +all word lengths: attained minima are at most seven, and the exhaustive search +rules out every shorter word. The same equality holds for all nine shapes with +1 <= helpers, targets <= 3: 682 labeled maps in total. + +This is a refined `bit-helper-contract` investigation. Pending PR1194 already +addresses its original H2/K question for a fixed word but retains H1 even inside +D. We isolate that retained restriction inside the zero-frame prefix, prove +the boundary condition needed to remove it there, and test its local price. +[TASK.json](TASK.json) records the original card and the refinement. + +## Alphabets, complete boundary, and cost + +Order registers as h0,...,h(H-1),y0,...,y(T-1). A gate `[d,s]` means +`register[d] ^= register[s]`, with distinct indices. Compare: + +* **Restricted:** every ordered pair except helper destination / target source. + Helper-to-helper and target-to-target gates are allowed. +* **Unrestricted:** every ordered pair of distinct registers, including target + feedback into helpers. + +Every gate costs one, including preparation and restoration. All registers stay +at the same zero frame. The model contains no source reads, COPY/ERASE, recursive +calls, frame changes, allocation, clean ancillas, or unpriced basis changes. +Its required matrix, in column-vector convention, is + + T_K = [ I_H 0 ] + [ K I_T ]. + +Both helper identity and target identity blocks are checked. A circuit that +works only when targets or helpers start at zero does not meet this contract. +Separate helper/target permutations below only transport proofs and witnesses; +they are not free operations inserted in the executed circuit. + +The complete local bill of a length-L prefix is L scalar ADDs and zero of the +other event types above. A substitution in an already legal continuation leaves +its literal events unchanged, conditional on the same common-frame realization. +This is not a physical precision or hosted-supplier invoice. In particular, +equal binary endpoints do not imply equal intermediate integer envelopes. + +## Scoped prefix-substitution lemma + +Let M be any F2 module, for example bit streams with pointwise XOR. Let D0 and D +be finite prefixes on M^(H+T), both operating wholly at a common zero frame, +touching only these helpers and targets, and with no other state changes or +interior observers. Suppose their complete coefficient matrices are both T_K. +Then any fixed deterministic continuation receives identical register values +and frames after either prefix, and has the same final semantic result. + +**Proof.** Each XOR is an elementary matrix over F2. The product's coefficients +act on M by the same additions, so equality of the complete binary matrices +implies equality for every input in M^(H+T). Untouched sources and other state +are also equal. Composition with the identical continuation preserves equality. +No reordering or frame-free interpretation of the continuation is required. + +Choose D0 to be the direct target-only shear, with one gate for each nonzero +entry of K. If a virtual word with D0 satisfies the inherited interface and +chronological assumptions, the lemma allows replacing just that prefix by D. +H1 is then needed for the unchanged continuation, not for D's intermediate +states. This is the same boundary-substitution mechanism used in PR1194; the +explicit difference here is dropping its D-local target-feedback prohibition. +The actual word D, not the virtual direct shear, must be priced and subjected +to any physical precision checks. + +The enlargement is nonempty. With one helper h and target y, + + h ^= y; y ^= h; h ^= y; y ^= h; h ^= y + +has exactly the boundary `(h,y) -> (h,y+h)`, yet uses target feedback. It costs +five gates; the restricted implementation costs one. The positive control +checks this example on the complete boundary. The census below establishes +that no more economical feedback example exists in the stated finite domain. + +This lemma does not remove H1/H3 from A/scatter/B or alter the projected cleanup +rule. In particular it does not contradict PR1105's raw-feedback cleanup +counterexample: that example lacks the complete restored prefix boundary used +here. Physical all-size realization, tape/rounding and precision bounds remain +separate obligations. + +## Exact certificate and lower-bound argument + +For either alphabet, let B_r be all complete matrices reachable in at most r +gates, with exact breadth-first distances, and S_r its distance-r sphere. +Every generator is its own inverse. For any A in S_i, i <= 3, look up +`B = A T_K` in B_4. A hit gives `T_K = A^-1 B`, realized by the word for B +followed by the reversed word for A. Conversely, every word of length at most +seven splits into such pieces, because its factors have lengths at most four +and three. Thus the minimum hit is the exact minimum whenever a hit exists. +All 682 targets have hits; no unsearched length can be shorter. + +`verify.py` uses packed binary matrix rows. It builds both radius-four balls, +checks every orbit under the independent helper and target permutation groups, +and records shortest restricted witnesses. These permutations conjugate both +gate alphabets and preserve unit cost, so their orbit distances are equal. +For 3-by-3 K there are 36 orbits covering all 512 labeled matrices. + +`independent.py` imports no primary checker code. It represents a complete map +by its truth table on all 2^(H+T) dirty bit inputs, composes byte tables, and +checks all 682 labeled K without using orbit reduction for lower bounds. It +transports and replays the restricted witnesses on each labeled endpoint. +Unrestricted lower bounds and restricted upper bounds meet for every K. +Both implementations use the same proved meet-in-the-middle principle, so +this is independent representation and code, not an independent mathematical +lower-bound method. Full-group ordinary BFS for H,T <= 2 supplies a further +control; the largest case reaches all 20,160 elements of GL(4,2) and all 576 +restricted elements. + +For H=T=3 the exact sphere sizes at radii 0 through 4 are: + +| Alphabet | 0 | 1 | 2 | 3 | 4 | +| --- | ---: | ---: | ---: | ---: | ---: | +| Restricted | 1 | 21 | 264 | 2,436 | 17,142 | +| Unrestricted | 1 | 30 | 570 | 8,415 | 101,610 | + +Both alphabets give the same labeled minimum-cost distribution: + +| Minimum XORs | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | +| Number of K | 1 | 9 | 36 | 84 | 126 | 132 | 96 | 28 | + +[CERTIFICATE.json](CERTIFICATE.json) includes all dimensions, sphere counts, +orbit representatives, multiplicities, minimum costs and attaining witnesses. +The primary replay recomputes and compares every field. The all-ones 3-by-3 K, +for example, has cost seven in both alphabets, versus nine direct helper reads. +The gain over that direct implementation already exists in the restricted +alphabet; target feedback adds no saving. + +## Reproduce + +Python 3.12, standard library only; from the repository root: + +```sh +timeout 60s python3 -I -B scripts/research_package.py --package research/bit-zero-frame-feedback --check-only +timeout 300s python3 -I -B scripts/research_package.py --package research/bit-zero-frame-feedback +``` + +The registered replay runs these two read-only checks in sequence: + +```sh +timeout 120s python3 -I -B research/bit-zero-frame-feedback/verify.py +timeout 120s python3 -I -B research/bit-zero-frame-feedback/independent.py +``` + +Expected lines: + +```text +PASS_ZERO_FRAME_FEEDBACK maps=682 six_wire_maps=512 orbits=36 max_minimum=7 feedback_gains=0 controls=8 no_new_kappa +PASS_INDEPENDENT_ZERO_FRAME_FEEDBACK labeled_maps=682 dirty_inputs_per_six_wire_map=64 full_GL4=20160 +PASS_REGISTERED_RESEARCH_PACKAGE research/bit-zero-frame-feedback outcome=negative-result +``` + +Replay takes a few seconds on the donation host. `verify.py --write` explicitly +regenerates the certificate. Both scripts retain their checks under `-O`. + +Two positive controls check a restored helper star and the five-gate feedback +word. Eight negative controls reject feedback under the restricted alphabet, +omitted helper restoration, a missing helper-input contribution, residual +target-basis mixing, the wrong target map, self-XOR, Boolean register indices, +and an insufficient search radius. Residual target mixing is invisible on +zero-target inputs; that control specifically enforces arbitrary target dirt. + +[SOURCES.json](SOURCES.json) pins the base, original task and selected record, +plus the inherited checker/PR1062 documentation used to identify the contract. +The inherited checker is hash-checked as context and is not executed by this +package. Pending PR1194/1105 heads are contextual attribution, not imported +code or assumed accepted results. No predecessor or selected artifact changes. + +## Limits and unchecked obligations + +The equality of optimum costs is only for 1 <= H,T <= 3, F2, the stated two +single-source unit-cost alphabets, and no extra registers. It is not a theorem +for larger dimensions, multi-source gates with another billing rule, unequal +weights, nonzero frames, or other fields. No fixed R439/R420 circuit was edited, +and no new full physical supplier or recursive moment was constructed. The +all-size compiler, native replay, hosting, precision/tape bounds, source/frame +realization and outer analytic transfer were not checked here. The selected +frontier's cold replay was not rerun for this isolated finite result. + +## Open next questions + +1. **Does equality persist beyond three helpers and three targets?** A strict + advantage would make the D-local feedback relaxation economically relevant. + A feasible first step is one pinned 3-by-4 K, with a restricted upper bound + and an unrestricted shorter candidate followed by exact shorter-word + exclusion. Larger ball sizes and the lack of a candidate are the blockers; + this result supplies no general no-feedback theorem. +2. **Can a useful legal supplier instance realize such a prefix with its full + physical costs?** If a larger strict gain is found, compare its complete + prefix matrix against the original D and then recount actual intermediate + precision envelopes, paths and hosting. No shorter candidate or physical + bridge has been supplied here, so supplier adoption remains blocked. + +Structured versions are in [TASK.json](TASK.json). There is no reason to extend +the same 3-by-3 search: its exact no-gain result is complete. + +## Credit + +Prepared for commdata2338 (@commdata2338), with substantial OpenAI Codex assistance. +New work is Apache-2.0. This contribution claims the specified finite census +and explicit D-local scope clarification, not novelty for elementary matrix +substitution, CNOT synthesis or meet-in-the-middle search. + +Credit @woklerx for [PR1194](https://github.com/CrocSwap/integer-mult-bounds/pull/1194) +(`2e39c98238f543d988f9efc1b076590a4b780dca`) and +[PR1105](https://github.com/CrocSwap/integer-mult-bounds/pull/1105) +(`20a960b545f4b0ade4f26922ef686bd5eaf275f4`), Zhihao Chen's PR425 scalar-interface +lineage, eumemic's interleaved checker and PR555, DreamingOfClouds's PR589, +Gareth Davidson's PR926 pairs, @theon199's PR967 stars, and Sagar Thakrar's +PR1062 with Aaron Wang's PR1015 and Ross Richardson's PR923 block work. PR1188's +exact GL5 window synthesis is related algorithmic work on different endpoints; +PR1122/1208 optimize fixed R439 words. This account's PR794 target-basis result is +separate and was not redone. Existing source licenses and notices are retained. diff --git a/research/bit-zero-frame-feedback/SOURCES.json b/research/bit-zero-frame-feedback/SOURCES.json new file mode 100644 index 0000000000..ab1faecb26 --- /dev/null +++ b/research/bit-zero-frame-feedback/SOURCES.json @@ -0,0 +1,53 @@ +{ + "schema_version": 1, + "base_commit": "dadfea6e8a78ff6ba901705f87532a71c6f5bbb8", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "c05fafaa25ba95b2d5af86b1800427198e3d20eb", + "sha256": "89b5928bc92c81e2647b6d702a7ad85a6795b8f44e2eb267b2ff3145d8f2b2ce" + }, + { + "path": "research/e8-bit-p111-tuned/code/xcheck_p.py", + "usage": "input", + "git_blob": "184f5dcf94a486cc7db91ca4db5865916bf26009", + "sha256": "af3decc877e27c00001cf56f50c6c09566e8e101297ab34c7860aed96a06d80e" + }, + { + "path": "research/r439-bsection-stars-seed01/README.md", + "usage": "input", + "git_blob": "188175a52bb2a3ad65c701b3bd218ae3fc0bdfde", + "sha256": "3a32ecbf886d6605eb7441c63ca934c6aab0942d0e7e570c3dd0795d1cf00336" + } + ], + "context_prs": [ + { + "number": 1194, + "head": "2e39c98238f543d988f9efc1b076590a4b780dca", + "author": "woklerx", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1194", + "path": "research/r439-semantic-d-contract-seed10/PROOF.md", + "git_blob": "2707fdb0d2f34c1c6c4ea41c2a68e44904a3e4fd", + "sha256": "dfbca8c61a92fdf0db8af450dc4466849da37fc296e28b67f357e196e87327db", + "usage": "context-only; not a replay dependency or adopted result" + }, + { + "number": 1105, + "head": "20a960b545f4b0ade4f26922ef686bd5eaf275f4", + "author": "woklerx", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1105", + "path": "research/feedback-cleanup-audit-seed72/PROOF.md", + "git_blob": "446ed7a43aac6ea9afc86a9b70fe7a1ffaf91ee6", + "sha256": "2c93d0f2d04e421ab33d2f76c9964f5a2bd31460b8bffc9814bbf863cfab8cec", + "usage": "context-only; not a replay dependency or adopted result" + } + ], + "input_role": "The two live inputs identify the inherited H1/H2 contract and PR1062 context. Their bytes are hash-checked; neither is executed or imported by this finite checker. Context PR heads are documentary pins and are not required to be present during replay." +} diff --git a/research/bit-zero-frame-feedback/TASK.json b/research/bit-zero-frame-feedback/TASK.json new file mode 100644 index 0000000000..196f7fb9b8 --- /dev/null +++ b/research/bit-zero-frame-feedback/TASK.json @@ -0,0 +1,68 @@ +{ + "schema_version": 1, + "task_id": "bit-helper-contract", + "priority_revision": 2, + "base_commit": "dadfea6e8a78ff6ba901705f87532a71c6f5bbb8", + "original_card": { + "id": "bit-helper-contract", + "question": "Can one precisely specified helper-mixing word satisfy a replacement for the inherited H2/K interface?", + "starting_points": [ + "research/r439-bsection-stars-seed01/README.md", + "research/r439-copy-path-sharing-barrier/README.md" + ], + "methods": [ + "Derive a replacement interface lemma and price its implementation.", + "Seek an exact dirty-input or chronological-cut counterexample to the proposed replacement." + ], + "acceptance_gate": "A full boundary contract and paid profile; unchanged scalar counts alone are insufficient.", + "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." + }, + "first_experiment": "Write one replacement H2/K implication for a single helper-star operation, then try to falsify it on dirty inputs.", + "bottleneck_link": "A legitimate replacement could admit a cheaper bit circuit; scalar savings alone do not alter the selected moment.", + "allowed_variations": [ + "Choose one helper-star or quartet instance; narrow to one boundary implication." + ], + "scope_change_triggers": [ + "Changing only source count or scalar addition count without an interface argument." + ], + "overlap_terms": [ + "H2_D_frame0_targets_from_helpers", + "K_equals_D", + "helper-star" + ] + }, + "scope_status": "refined", + "actual_scope": "D-local H1 relaxation: complete zero-frame target-feedback prefix substitution, and exact restricted/unrestricted unit-cost single-source XOR minima for all binary K with 1 <= helpers, targets <= 3, no extra registers and arbitrary dirty inputs.", + "scope_change_reason": "Pending PR1194 already treats the original H2/K contract on a fixed word while retaining H1 inside D. This tests the necessity and local price of that retained restriction only inside a fully restored, source-free, common-zero-frame prefix; continuation H1/H3 and projected cleanup remain unchanged.", + "bottleneck_link": "A legal shorter D could reduce scalar ADDs, but physical precision, hosting and the complete paid recursive profile would still need verification. The exact 3-by-3 census finds no gate-count gain from feedback, so this domain cannot supply that improvement. No new kappa or physical supplier is claimed.", + "budget_minutes": 60, + "stop_rule": "Stop this domain once every labeled K has an attained optimum and exact shorter-word exclusion; if radius seven is insufficient, report exact achieved coverage without a minimum claim. Resume target 2026-10-13T22:55:00Z, hard stop 2026-10-13T23:25:00Z; reserve the final quarter for verification and handoff.", + "outcome": "negative-result", + "evidence": "CERTIFICATE.json: 682 maps, including all 512 three-by-three K in 36 permutation orbits; minimum histogram [1,9,36,84,126,132,96,28], maximum 7, zero feedback gains. Packed-row exhaustive MITM and a code-disjoint labeled truth-table replay agree; ordinary full-group BFS controls cover H,T <= 2. README supplies the conditional prefix-substitution proof. Two positive and eight negative semantic/search controls.", + "author": "commdata2338", + "ai_assistance": "Prepared for commdata2338 (@commdata2338), with substantial OpenAI Codex assistance in research, proof, code, checking and documentation.", + "open_questions": [ + { + "question": "Does the equality of restricted and unrestricted minima persist beyond three helpers and three targets?", + "why_it_matters": "A strict feedback advantage is needed before this D-local relaxation reduces the local ADD bill.", + "first_step": "Pin one 3-by-4 binary K, obtain a restricted upper bound and an unrestricted shorter candidate, then prove the restricted lower bound by exact shorter-word exclusion.", + "blocked_by": "No larger shorter candidate is known from this package; exact balls grow rapidly and the current result is not dimension-independent." + }, + { + "question": "Can a useful legal supplier instance realize a feedback prefix at a lower complete physical cost?", + "why_it_matters": "A scalar saving alone cannot establish a better paid recursive profile or exponent.", + "first_step": "After finding a larger strict gain, compare its full D boundary with the original word and recount intermediate precision, frame paths, copying and hosting.", + "blocked_by": "No shorter candidate, physical bridge, full supplier replay or promotion evidence is supplied here." + } + ], + "scope_key": "3475f46c8358c6a9211b", + "chooser_nonce": "e1ba96fa16219472c5ab32da75a99c6f" +} diff --git a/research/bit-zero-frame-feedback/VERIFY.json b/research/bit-zero-frame-feedback/VERIFY.json new file mode 100644 index 0000000000..e58e073280 --- /dev/null +++ b/research/bit-zero-frame-feedback/VERIFY.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/e8-bit-p111-tuned/code/xcheck_p.py", + "research/r439-bsection-stars-seed01/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact packed-row restricted/unrestricted shortest-circuit census, complete certificate regeneration, source pins, two positive and eight negative controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 120, + "checks": "Code-disjoint truth-table lower bounds for every labeled K, restricted witness replay on all dirty inputs, and ordinary full-group BFS for H,T <= 2." + } + ] +} diff --git a/research/bit-zero-frame-feedback/independent.py b/research/bit-zero-frame-feedback/independent.py new file mode 100644 index 0000000000..360993334d --- /dev/null +++ b/research/bit-zero-frame-feedback/independent.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python3 +"""Code-disjoint truth-table check of every labeled six-wire endpoint. + +No imports from verify.py. Enumerate complete maps on all 64 dirty bit inputs, +using byte translation to compose functions. Apache-2.0; substantial OpenAI +Codex assistance, prepared for commdata2338. +""" +from collections import Counter, deque +import json +from pathlib import Path + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def gate_table(n, destination, source): + return bytes(x ^ (((x >> source) & 1) << destination) for x in range(256)) + + +def ball(n, helpers, restricted, radius): + gates = [gate_table(n, d, s) for s in range(n) for d in range(n) + if d != s and not (restricted and d < helpers <= s)] + identity = bytes(range(1 << n)) + distances = {identity: 0} + layers = [[identity]] + for depth in range(1, radius + 1): + layer = [] + for mapping in layers[-1]: + for gate in gates: + reached = mapping.translate(gate) + if reached not in distances: + distances[reached] = depth + layer.append(reached) + layers.append(layer) + return distances, layers + + +def endpoint(k, h, t): + result = [] + for initial in range(1 << (h + t)): + final = initial + for row in range(t): + parity = 0 + for col in range(h): + parity ^= ((initial >> col) & 1) & ((k >> (row * h + col)) & 1) + final ^= parity << (h + row) + result.append(final) + return bytes(result) + + +def complete_small_check(h, t): + """Ordinary full-group BFS, without meet-in-the-middle or orbit reduction.""" + n = h + t + wanted = {endpoint(k, h, t): k for k in range(1 << (h * t))} + answers = [] + for restricted in (False, True): + tables = [gate_table(n, d, s) for d in range(n) for s in range(n) + if d != s and not (restricted and d < h <= s)] + start = bytes(range(1 << n)) + distance = {start: 0} + queue = deque([start]) + while queue: + state = queue.popleft() + for table in tables: + after = state.translate(table) + if after not in distance: + distance[after] = distance[state] + 1 + queue.append(after) + answers.append({k: distance[state] for state, k in wanted.items()}) + if h == t == 2: + require(len(distance) == (576 if restricted else 20160), "full GL4/parabolic cardinality") + require(answers[0] == answers[1], "small feedback gain") + return answers[0] + + +def replay_witness(word, wanted, h, t): + state = bytes(range(1 << (h + t))) + for d, s in word: + require(type(d) is int and type(s) is int and 0 <= d < h+t and 0 <= s < h+t and d != s, + "bad witness gate") + require(not (d < h <= s), "witness uses target feedback") + state = state.translate(gate_table(h+t, d, s)) + require(state == wanted, "witness fails on dirty input") + + +def main(): + package = Path(__file__).resolve().parent + certificate = json.loads((package / "CERTIFICATE.json").read_text()) + all_checked = 0 + for entry in certificate["dimensions"]: + h, t = entry["helpers"], entry["targets"] + # The primary certificate proves upper bounds via restricted words. + for row in entry["orbits"]: + replay_witness(row["restricted_witness"], endpoint(row["k"], h, t), h, t) + require(len(row["restricted_witness"]) == row["minimum"], "upper-bound cost") + distances, layers = ball(h+t, h, False, 4) + require([len(x) for x in layers] == entry["unrestricted_spheres"], "independent sphere counts") + left = [(mapping + bytes(256-len(mapping)), depth) + for depth, layer in enumerate(layers[:4]) for mapping in layer] + histogram = Counter() + minima = {} + # No use of the primary permutation quotient: every labeled K is checked. + for k in range(1 << (h*t)): + goal = endpoint(k, h, t) + best = 8 + for translation, depth in left: + other = distances.get(goal.translate(translation)) + if other is not None: + best = min(best, depth + other) + require(best < 8, "insufficient independent search radius") + minima[k] = best + histogram[str(best)] += 1 + all_checked += 1 + require(dict(histogram) == entry["minimum_histogram"], "independent minimum distribution") + # Check orbit coverage separately, by relabeling actual gate witnesses + # using explicit output-to-input register bijections. + from itertools import permutations + covered = {} + for row in entry["orbits"]: + local = set() + for hp in permutations(range(h)): + for tp in permutations(range(t)): + mapping = hp + tuple(h+x for x in tp) + word = [[mapping[d], mapping[s]] for d, s in row["restricted_witness"]] + endpoint_k = 0 + for r in range(t): + for c in range(h): + if row["k"] & (1 << (r*h+c)): + endpoint_k |= 1 << (tp[r]*h+hp[c]) + replay_witness(word, endpoint(endpoint_k, h, t), h, t) + require(minima[endpoint_k] == len(word), "labeled upper/lower bounds disagree") + local.add(endpoint_k) + covered[endpoint_k] = len(word) + require(len(local) == row["orbit_size"], "orbit cardinality") + require(covered == minima, "labeled endpoint coverage") + if h <= 2 and t <= 2: + require(complete_small_check(h, t) == minima, "full-BFS control") + require(all_checked == 682, "missing dimensions") + print("PASS_INDEPENDENT_ZERO_FRAME_FEEDBACK labeled_maps=682 dirty_inputs_per_six_wire_map=64 full_GL4=20160") + + +if __name__ == "__main__": + main() diff --git a/research/bit-zero-frame-feedback/verify.py b/research/bit-zero-frame-feedback/verify.py new file mode 100644 index 0000000000..bf0bc54dfd --- /dev/null +++ b/research/bit-zero-frame-feedback/verify.py @@ -0,0 +1,239 @@ +#!/usr/bin/env python3 +"""Exact shortest zero-frame XOR compensation circuits; standard library only. + +Prepared for commdata2338 with substantial OpenAI Codex assistance. Apache-2.0. +Matrices use packed binary rows. independent.py uses complete truth tables and +does not import this implementation. Neither checker executes supplier code. +""" +import argparse +from collections import Counter +import hashlib +from itertools import permutations +import json +from pathlib import Path + +PACKAGE = Path(__file__).resolve().parent + + +class Reject(ValueError): + pass + + +def need(condition, message): + if not condition: + raise Reject(message) + + +def load(path): + def unique(pairs): + result = {} + for key, value in pairs: + need(key not in result, "duplicate JSON key") + result[key] = value + return result + def invalid(value): + raise Reject("nonfinite JSON: " + value) + return json.loads(Path(path).read_text(), object_pairs_hook=unique, + parse_constant=invalid) + + +def canonical(value): + # Comparing encoded JSON also distinguishes true from 1. + return json.dumps(value, sort_keys=True, separators=(",", ":"), allow_nan=False) + + +def identity(n): + return sum(1 << (i * n + i) for i in range(n)) + + +def generators(h, t, feedback): + return [(d, s) for d in range(h + t) for s in range(h + t) + if d != s and (feedback or not (d < h <= s))] + + +def step(matrix, gate, n): + d, s = gate + return matrix ^ (((matrix >> (s * n)) & ((1 << n) - 1)) << (d * n)) + + +def target(k, h, t): + n = h + t + return identity(n) ^ sum(((k >> (r * h)) & ((1 << h) - 1)) << ((h + r) * n) + for r in range(t)) + + +def sphere_ball(h, t, feedback, radius=4): + """Every word through radius, deduplicated by its complete linear map.""" + n = h + t + gates = generators(h, t, feedback) + first = identity(n) + distances = {first: 0} + last_gate = {} + layers = [[first]] + for depth in range(1, radius + 1): + layer = [] + for matrix in layers[-1]: + for index, gate in enumerate(gates): + reached = step(matrix, gate, n) + if reached not in distances: + distances[reached] = depth + last_gate[reached] = index + layer.append(reached) + layers.append(layer) + return distances, layers, last_gate, gates + + +def word_for(matrix, h, t, ball): + distances, _, last_gate, gates = ball + reverse_word = [] + while distances[matrix]: + gate = gates[last_gate[matrix]] + reverse_word.append(list(gate)) + matrix = step(matrix, gate, h + t) + return list(reversed(reverse_word)) + + +def right_shear(matrix, k, h, t): + """Return matrix * T_K (not T_K * matrix).""" + n = h + t + out = matrix + column_mask = sum(1 << (r * n) for r in range(n)) + for r in range(t): + column = matrix & (column_mask << (h + r)) + for c in range(h): + if k & (1 << (r * h + c)): + out ^= column >> (h + r - c) + return out + + +def shortest(k, h, t, ball): + """Complete meet-in-the-middle coverage of lengths 0..7. + + If B=A*T_K, then T_K=A^-1*B, so run B followed by reverse(A). + Every word of length <=7 splits into pieces of length <=4 and <=3. + Finding an attained minimum <=7 thus certifies a global minimum. + """ + distances, layers, _, _ = ball + best = None + for depth, layer in enumerate(layers[:4]): + for left in layer: + right = right_shear(left, k, h, t) + other = distances.get(right) + if other is not None and (best is None or depth + other < best[0]): + best = (depth + other, left, right) + need(best is not None and best[0] <= 7, "search radius insufficient; no minimum claim") + length, left, right = best + word = word_for(right, h, t, ball) + list(reversed(word_for(left, h, t, ball))) + need(len(word) == length, "witness length") + check_word(word, k, h, t, True) + return length, word + + +def check_word(word, k, h, t, feedback): + n = h + t + allowed = set(generators(h, t, feedback)) + matrix = identity(n) + for gate in word: + need(isinstance(gate, list) and len(gate) == 2 and + all(type(x) is int for x in gate), "typed gate") + need(tuple(gate) in allowed, "forbidden gate") + matrix = step(matrix, gate, n) + need(matrix == target(k, h, t), "complete dirty boundary") + return len(word) + + +def orbit(k, h, t): + return {sum(((k >> (r * h + c)) & 1) << (rr * h + cc) + for rr, r in enumerate(rp) for cc, c in enumerate(cp)) + for rp in permutations(range(t)) for cp in permutations(range(h))} + + +def census(h, t): + restricted = sphere_ball(h, t, False) + unrestricted = sphere_ball(h, t, True) + remaining = set(range(1 << (h * t))) + rows = [] + distribution = Counter() + while remaining: + k = min(remaining) + members = orbit(k, h, t) + need(members <= remaining, "orbit partition") + remaining -= members + old, witness = shortest(k, h, t, restricted) + new, _ = shortest(k, h, t, unrestricted) + need(old == new, "feedback advantage found; update the stated result") + check_word(witness, k, h, t, False) + distribution[str(old)] += len(members) + rows.append({"k": k, "orbit_size": len(members), "minimum": old, + "restricted_witness": witness}) + return {"helpers": h, "targets": t, "maps": 1 << (h * t), + "restricted_spheres": [len(x) for x in restricted[1]], + "unrestricted_spheres": [len(x) for x in unrestricted[1]], + "minimum_histogram": dict(sorted(distribution.items())), "orbits": rows} + + +def controls(): + rejected = [] + def reject(name, action): + try: + action() + except Reject: + rejected.append(name) + else: + raise Reject("control accepted: " + name) + # A legal source-free helper-star computes y += h0+h1 and restores dirt. + star = [[0, 1], [2, 0], [0, 1]] + need(check_word(star, 3, 2, 1, False) == 3, "star positive control") + # Complete target feedback is allowed by the new prefix contract. The + # five-gate word is the one-gate shear, but every one of its gates is paid. + feedback = [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1]] + need(check_word(feedback, 1, 1, 1, True) == 5, "feedback positive control") + reject("feedback_rejected_in_restricted_alphabet", + lambda: check_word(feedback, 1, 1, 1, False)) + reject("omitted_helper_restoration", lambda: check_word(star[:-1], 3, 2, 1, True)) + reject("wrong_helper_column", lambda: check_word([[2, 0]], 3, 2, 1, True)) + # This passes on y=0 and has the correct helper->target block, but mixes + # the arbitrary initial targets. A zero-target test would miss the fault. + reject("residual_target_basis", lambda: check_word([[1, 0], [2, 1]], 3, 1, 2, True)) + reject("wrong_target_map", lambda: check_word([[1, 0]], 0, 1, 1, True)) + reject("self_xor_noninvertible", lambda: check_word([[0, 0]], 0, 1, 1, True)) + reject("boolean_gate_index", lambda: check_word([[True, 0]], 1, 1, 1, True)) + reject("insufficient_radius", lambda: shortest(511, 3, 3, sphere_ball(3, 3, True, 2))) + return {"positive_star_cost": 3, "positive_feedback_cost": 5, + "negative_controls": rejected} + + +def check_source_pins(): + root = PACKAGE.parents[1] + sources = load(PACKAGE / "SOURCES.json") + for row in sources["files"]: + if row["usage"] == "input": + data = (root / row["path"]).read_bytes() + need(hashlib.sha256(data).hexdigest() == row["sha256"], "input source pin: " + row["path"]) + + +def build(): + return {"schema_version": 1, "kind": "finite-exact-shortest-circuit-certificate", + "gate_cost": 1, "ancillas": 0, "all_inputs_arbitrary": True, + "dimensions": [census(h, t) for h in range(1, 4) for t in range(1, 4)], + "controls": controls()} + + +def main(): + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument("--write", action="store_true", help="regenerate the package certificate") + args = ap.parse_args() + check_source_pins() + result = build() + destination = PACKAGE / "CERTIFICATE.json" + if args.write: + destination.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n") + else: + need(canonical(load(destination)) == canonical(result), "certificate differs from exact regeneration") + rows = result["dimensions"][-1] + print("PASS_ZERO_FRAME_FEEDBACK maps=682 six_wire_maps=512 orbits=" + str(len(rows["orbits"])) + + " max_minimum=7 feedback_gains=0 controls=8 no_new_kappa") + + +if __name__ == "__main__": + main()