diff --git a/research/jp8-grid-bounded-synthesis/CERTIFICATE.json b/research/jp8-grid-bounded-synthesis/CERTIFICATE.json new file mode 100644 index 0000000000..b0482e1999 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/CERTIFICATE.json @@ -0,0 +1,1141 @@ +{ + "schema": "jp8-grid-bounded-synthesis/1", + "seed": 33, + "domain": { + "maximum_numerator": 127, + "maximum_denominator": 16, + "magnitude_bound": "abs(numerator)", + "scratch_grid": "1/denominator", + "unit_handling": "direct accumulation plus private clear, cost 2; outside graph search" + }, + "entries": [ + { + "numerator": 31, + "denominator": 2, + "operations": [ + "double", + "double", + "double", + "double", + "subtract", + "double", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 8, + "graph_vertices": 125, + "reachable_vertices": 125, + "reachable_edges_with_multiplicity": 497, + "horner_macro_costs": { + "binary-forward": 12, + "naf-forward": 10, + "binary-reverse": 14, + "naf-reverse": 13 + }, + "strict_horner_improvement": false + }, + { + "numerator": 16, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 33, + "reachable_vertices": 33, + "reachable_edges_with_multiplicity": 131, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 7, + "binary-reverse": 7, + "naf-reverse": 7 + }, + "strict_horner_improvement": false + }, + { + "numerator": 20, + "denominator": 1, + "operations": [ + "double", + "double", + "add", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 41, + "reachable_vertices": 41, + "reachable_edges_with_multiplicity": 163, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 8, + "binary-reverse": 10, + "naf-reverse": 10 + }, + "strict_horner_improvement": false + }, + { + "numerator": 24, + "denominator": 1, + "operations": [ + "double", + "add", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 49, + "reachable_vertices": 49, + "reachable_edges_with_multiplicity": 195, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 9, + "binary-reverse": 9, + "naf-reverse": 11 + }, + "strict_horner_improvement": false + }, + { + "numerator": 32, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 65, + "reachable_vertices": 65, + "reachable_edges_with_multiplicity": 259, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 8, + "binary-reverse": 8, + "naf-reverse": 8 + }, + "strict_horner_improvement": false + }, + { + "numerator": 79, + "denominator": 2, + "operations": [ + "double", + "double", + "add", + "double", + "double", + "double", + "subtract", + "double", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 10, + "graph_vertices": 317, + "reachable_vertices": 317, + "reachable_edges_with_multiplicity": 1265, + "horner_macro_costs": { + "binary-forward": 14, + "naf-forward": 12, + "binary-reverse": 18, + "naf-reverse": 16 + }, + "strict_horner_improvement": false + }, + { + "numerator": 48, + "denominator": 1, + "operations": [ + "double", + "add", + "double", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 97, + "reachable_vertices": 97, + "reachable_edges_with_multiplicity": 387, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 10, + "binary-reverse": 10, + "naf-reverse": 12 + }, + "strict_horner_improvement": false + }, + { + "numerator": 54, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "subtract", + "double", + "double", + "subtract", + "double" + ], + "end_sign": 1, + "preparation_steps": 8, + "graph_vertices": 109, + "reachable_vertices": 109, + "reachable_edges_with_multiplicity": 435, + "horner_macro_costs": { + "binary-forward": 11, + "naf-forward": 11, + "binary-reverse": 15, + "naf-reverse": 16 + }, + "strict_horner_improvement": false + }, + { + "numerator": 60, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "double", + "subtract", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 7, + "graph_vertices": 121, + "reachable_vertices": 121, + "reachable_edges_with_multiplicity": 483, + "horner_macro_costs": { + "binary-forward": 11, + "naf-forward": 10, + "binary-reverse": 14, + "naf-reverse": 14 + }, + "strict_horner_improvement": false + }, + { + "numerator": 64, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 129, + "reachable_vertices": 129, + "reachable_edges_with_multiplicity": 515, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 9, + "binary-reverse": 9, + "naf-reverse": 9 + }, + "strict_horner_improvement": false + }, + { + "numerator": 72, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "add", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 7, + "graph_vertices": 145, + "reachable_vertices": 145, + "reachable_edges_with_multiplicity": 579, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 10, + "binary-reverse": 13, + "naf-reverse": 13 + }, + "strict_horner_improvement": false + }, + { + "numerator": 79, + "denominator": 1, + "operations": [ + "double", + "double", + "add", + "double", + "double", + "double", + "subtract", + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 9, + "graph_vertices": 159, + "reachable_vertices": 159, + "reachable_edges_with_multiplicity": 633, + "horner_macro_costs": { + "binary-forward": 13, + "naf-forward": 11, + "binary-reverse": 19, + "naf-reverse": 17 + }, + "strict_horner_improvement": false + }, + { + "numerator": 80, + "denominator": 1, + "operations": [ + "double", + "double", + "add", + "double", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 7, + "graph_vertices": 161, + "reachable_vertices": 161, + "reachable_edges_with_multiplicity": 643, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 10, + "binary-reverse": 12, + "naf-reverse": 12 + }, + "strict_horner_improvement": false + }, + { + "numerator": 96, + "denominator": 1, + "operations": [ + "double", + "add", + "double", + "double", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 7, + "graph_vertices": 193, + "reachable_vertices": 193, + "reachable_edges_with_multiplicity": 771, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 11, + "binary-reverse": 11, + "naf-reverse": 13 + }, + "strict_horner_improvement": false + }, + { + "numerator": 108, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "subtract", + "double", + "double", + "subtract", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 9, + "graph_vertices": 217, + "reachable_vertices": 217, + "reachable_edges_with_multiplicity": 867, + "horner_macro_costs": { + "binary-forward": 12, + "naf-forward": 12, + "binary-reverse": 16, + "naf-reverse": 17 + }, + "strict_horner_improvement": false + }, + { + "numerator": 120, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "double", + "subtract", + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 8, + "graph_vertices": 241, + "reachable_vertices": 241, + "reachable_edges_with_multiplicity": 963, + "horner_macro_costs": { + "binary-forward": 12, + "naf-forward": 11, + "binary-reverse": 15, + "naf-reverse": 15 + }, + "strict_horner_improvement": false + }, + { + "numerator": 1, + "denominator": 8, + "operations": [ + "halve", + "halve", + "halve" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 17, + "reachable_vertices": 17, + "reachable_edges_with_multiplicity": 53, + "horner_macro_costs": { + "binary-forward": 6, + "naf-forward": 6, + "binary-reverse": 6, + "naf-reverse": 6 + }, + "strict_horner_improvement": false + }, + { + "numerator": 1, + "denominator": 4, + "operations": [ + "halve", + "halve" + ], + "end_sign": 1, + "preparation_steps": 2, + "graph_vertices": 9, + "reachable_vertices": 9, + "reachable_edges_with_multiplicity": 29, + "horner_macro_costs": { + "binary-forward": 5, + "naf-forward": 5, + "binary-reverse": 5, + "naf-reverse": 5 + }, + "strict_horner_improvement": false + }, + { + "numerator": 3, + "denominator": 8, + "operations": [ + "halve", + "add", + "halve", + "halve" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 49, + "reachable_vertices": 49, + "reachable_edges_with_multiplicity": 181, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 9, + "binary-reverse": 7, + "naf-reverse": 7 + }, + "strict_horner_improvement": false + }, + { + "numerator": 1, + "denominator": 2, + "operations": [ + "halve" + ], + "end_sign": 1, + "preparation_steps": 1, + "graph_vertices": 5, + "reachable_vertices": 5, + "reachable_edges_with_multiplicity": 17, + "horner_macro_costs": { + "binary-forward": 4, + "naf-forward": 4, + "binary-reverse": 4, + "naf-reverse": 4 + }, + "strict_horner_improvement": false + }, + { + "numerator": 3, + "denominator": 4, + "operations": [ + "halve", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 25, + "reachable_vertices": 25, + "reachable_edges_with_multiplicity": 93, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 8, + "binary-reverse": 6, + "naf-reverse": 6 + }, + "strict_horner_improvement": false + }, + { + "numerator": 5, + "denominator": 4, + "operations": [ + "halve", + "halve", + "add" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 41, + "reachable_vertices": 41, + "reachable_edges_with_multiplicity": 157, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 8, + "binary-reverse": 6, + "naf-reverse": 6 + }, + "strict_horner_improvement": false + }, + { + "numerator": 3, + "denominator": 2, + "operations": [ + "halve", + "add" + ], + "end_sign": 1, + "preparation_steps": 2, + "graph_vertices": 13, + "reachable_vertices": 13, + "reachable_edges_with_multiplicity": 49, + "horner_macro_costs": { + "binary-forward": 6, + "naf-forward": 7, + "binary-reverse": 5, + "naf-reverse": 7 + }, + "strict_horner_improvement": false + }, + { + "numerator": 7, + "denominator": 4, + "operations": [ + "halve", + "add", + "halve", + "add" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 57, + "reachable_vertices": 57, + "reachable_edges_with_multiplicity": 221, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 9, + "binary-reverse": 7, + "naf-reverse": 8 + }, + "strict_horner_improvement": false + }, + { + "numerator": 2, + "denominator": 1, + "operations": [ + "double" + ], + "end_sign": 1, + "preparation_steps": 1, + "graph_vertices": 5, + "reachable_vertices": 5, + "reachable_edges_with_multiplicity": 19, + "horner_macro_costs": { + "binary-forward": 4, + "naf-forward": 4, + "binary-reverse": 4, + "naf-reverse": 4 + }, + "strict_horner_improvement": false + }, + { + "numerator": 9, + "denominator": 4, + "operations": [ + "halve", + "halve", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 73, + "reachable_vertices": 73, + "reachable_edges_with_multiplicity": 285, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 9, + "binary-reverse": 8, + "naf-reverse": 8 + }, + "strict_horner_improvement": true + }, + { + "numerator": 5, + "denominator": 2, + "operations": [ + "halve", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 21, + "reachable_vertices": 21, + "reachable_edges_with_multiplicity": 81, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 7, + "binary-reverse": 7, + "naf-reverse": 7 + }, + "strict_horner_improvement": true + }, + { + "numerator": 11, + "denominator": 4, + "operations": [ + "halve", + "add", + "halve", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 89, + "reachable_vertices": 89, + "reachable_edges_with_multiplicity": 349, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 11, + "binary-reverse": 9, + "naf-reverse": 11 + }, + "strict_horner_improvement": true + }, + { + "numerator": 3, + "denominator": 1, + "operations": [ + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 2, + "graph_vertices": 7, + "reachable_vertices": 7, + "reachable_edges_with_multiplicity": 25, + "horner_macro_costs": { + "binary-forward": 5, + "naf-forward": 6, + "binary-reverse": 6, + "naf-reverse": 8 + }, + "strict_horner_improvement": false + }, + { + "numerator": 13, + "denominator": 4, + "operations": [ + "halve", + "halve", + "add", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 105, + "reachable_vertices": 105, + "reachable_edges_with_multiplicity": 413, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 11, + "binary-reverse": 9, + "naf-reverse": 11 + }, + "strict_horner_improvement": true + }, + { + "numerator": 7, + "denominator": 2, + "operations": [ + "halve", + "add", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 29, + "reachable_vertices": 29, + "reachable_edges_with_multiplicity": 113, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 8, + "binary-reverse": 8, + "naf-reverse": 9 + }, + "strict_horner_improvement": true + }, + { + "numerator": 15, + "denominator": 4, + "operations": [ + "halve", + "add", + "halve", + "add", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 121, + "reachable_vertices": 121, + "reachable_edges_with_multiplicity": 477, + "horner_macro_costs": { + "binary-forward": 11, + "naf-forward": 10, + "binary-reverse": 10, + "naf-reverse": 10 + }, + "strict_horner_improvement": true + }, + { + "numerator": 4, + "denominator": 1, + "operations": [ + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 2, + "graph_vertices": 9, + "reachable_vertices": 9, + "reachable_edges_with_multiplicity": 35, + "horner_macro_costs": { + "binary-forward": 5, + "naf-forward": 5, + "binary-reverse": 5, + "naf-reverse": 5 + }, + "strict_horner_improvement": false + }, + { + "numerator": 17, + "denominator": 4, + "operations": [ + "halve", + "halve", + "add", + "add", + "add", + "add" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 137, + "reachable_vertices": 137, + "reachable_edges_with_multiplicity": 541, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 10, + "binary-reverse": 10, + "naf-reverse": 10 + }, + "strict_horner_improvement": true + }, + { + "numerator": 9, + "denominator": 2, + "operations": [ + "double", + "double", + "double", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 37, + "reachable_vertices": 37, + "reachable_edges_with_multiplicity": 145, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 8, + "binary-reverse": 9, + "naf-reverse": 9 + }, + "strict_horner_improvement": false + }, + { + "numerator": 5, + "denominator": 1, + "operations": [ + "double", + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 11, + "reachable_vertices": 11, + "reachable_edges_with_multiplicity": 41, + "horner_macro_costs": { + "binary-forward": 6, + "naf-forward": 6, + "binary-reverse": 8, + "naf-reverse": 8 + }, + "strict_horner_improvement": false + }, + { + "numerator": 11, + "denominator": 2, + "operations": [ + "double", + "double", + "double", + "add", + "halve", + "add" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 45, + "reachable_vertices": 45, + "reachable_edges_with_multiplicity": 177, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 10, + "binary-reverse": 10, + "naf-reverse": 12 + }, + "strict_horner_improvement": false + }, + { + "numerator": 6, + "denominator": 1, + "operations": [ + "double", + "add", + "double" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 13, + "reachable_vertices": 13, + "reachable_edges_with_multiplicity": 51, + "horner_macro_costs": { + "binary-forward": 6, + "naf-forward": 7, + "binary-reverse": 7, + "naf-reverse": 9 + }, + "strict_horner_improvement": false + }, + { + "numerator": 13, + "denominator": 2, + "operations": [ + "double", + "add", + "double", + "double", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 53, + "reachable_vertices": 53, + "reachable_edges_with_multiplicity": 209, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 10, + "binary-reverse": 10, + "naf-reverse": 12 + }, + "strict_horner_improvement": false + }, + { + "numerator": 7, + "denominator": 1, + "operations": [ + "double", + "add", + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 15, + "reachable_vertices": 15, + "reachable_edges_with_multiplicity": 57, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 7, + "binary-reverse": 9, + "naf-reverse": 10 + }, + "strict_horner_improvement": false + }, + { + "numerator": 15, + "denominator": 2, + "operations": [ + "double", + "double", + "double", + "subtract", + "double", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 7, + "graph_vertices": 61, + "reachable_vertices": 61, + "reachable_edges_with_multiplicity": 241, + "horner_macro_costs": { + "binary-forward": 10, + "naf-forward": 9, + "binary-reverse": 11, + "naf-reverse": 11 + }, + "strict_horner_improvement": false + }, + { + "numerator": 31, + "denominator": 4, + "operations": [ + "double", + "double", + "double", + "double", + "subtract", + "double", + "add", + "halve", + "halve" + ], + "end_sign": 1, + "preparation_steps": 9, + "graph_vertices": 249, + "reachable_vertices": 249, + "reachable_edges_with_multiplicity": 989, + "horner_macro_costs": { + "binary-forward": 13, + "naf-forward": 11, + "binary-reverse": 13, + "naf-reverse": 12 + }, + "strict_horner_improvement": false + }, + { + "numerator": 8, + "denominator": 1, + "operations": [ + "double", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 3, + "graph_vertices": 17, + "reachable_vertices": 17, + "reachable_edges_with_multiplicity": 67, + "horner_macro_costs": { + "binary-forward": 6, + "naf-forward": 6, + "binary-reverse": 6, + "naf-reverse": 6 + }, + "strict_horner_improvement": false + }, + { + "numerator": 17, + "denominator": 2, + "operations": [ + "double", + "double", + "double", + "double", + "add", + "halve" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 69, + "reachable_vertices": 69, + "reachable_edges_with_multiplicity": 273, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 9, + "binary-reverse": 11, + "naf-reverse": 11 + }, + "strict_horner_improvement": false + }, + { + "numerator": 9, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 19, + "reachable_vertices": 19, + "reachable_edges_with_multiplicity": 73, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 7, + "binary-reverse": 10, + "naf-reverse": 10 + }, + "strict_horner_improvement": false + }, + { + "numerator": 10, + "denominator": 1, + "operations": [ + "double", + "double", + "add", + "double" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 21, + "reachable_vertices": 21, + "reachable_edges_with_multiplicity": 83, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 7, + "binary-reverse": 9, + "naf-reverse": 9 + }, + "strict_horner_improvement": false + }, + { + "numerator": 11, + "denominator": 1, + "operations": [ + "double", + "double", + "add", + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 5, + "graph_vertices": 23, + "reachable_vertices": 23, + "reachable_edges_with_multiplicity": 89, + "horner_macro_costs": { + "binary-forward": 8, + "naf-forward": 9, + "binary-reverse": 11, + "naf-reverse": 13 + }, + "strict_horner_improvement": false + }, + { + "numerator": 12, + "denominator": 1, + "operations": [ + "double", + "add", + "double", + "double" + ], + "end_sign": 1, + "preparation_steps": 4, + "graph_vertices": 25, + "reachable_vertices": 25, + "reachable_edges_with_multiplicity": 99, + "horner_macro_costs": { + "binary-forward": 7, + "naf-forward": 8, + "binary-reverse": 8, + "naf-reverse": 10 + }, + "strict_horner_improvement": false + }, + { + "numerator": 15, + "denominator": 1, + "operations": [ + "double", + "double", + "double", + "subtract", + "double", + "add" + ], + "end_sign": 1, + "preparation_steps": 6, + "graph_vertices": 31, + "reachable_vertices": 31, + "reachable_edges_with_multiplicity": 121, + "horner_macro_costs": { + "binary-forward": 9, + "naf-forward": 8, + "binary-reverse": 12, + "naf-reverse": 12 + }, + "strict_horner_improvement": false + } + ] +} diff --git a/research/jp8-grid-bounded-synthesis/CLAIM.json b/research/jp8-grid-bounded-synthesis/CLAIM.json new file mode 100644 index 0000000000..1359a83812 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/CLAIM.json @@ -0,0 +1,59 @@ +{ + "track": "Complex supplier", + "seed": 33, + "randomness": "Python secrets.randbelow(100), OS randomness", + "base_commit": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "claimed_at": "2026-10-13T09:18:03.350173+00:00", + "finish_by": "2026-10-13T10:03:54Z", + "coordination": "No pinned issue returned by GitHub GraphQL; local claim per sprint instructions. No issue created.", + "candidates": [ + { + "task": "General signed shift/add synthesis for JP8 dyadic coefficients, constrained by local fractional grid and original numerator envelope", + "decision": "selected; odd seed chooses JP8, seed 33 rotates coefficient ordering" + }, + { + "task": "CK cleanup scale relocation", + "decision": "not selected: completed class search in PR750; no new mechanism identified" + }, + { + "task": "SW4 full pair/triple read exchanges", + "decision": "not selected: overlapping PR876 and fixed-frame exclusions PR864" + } + ], + "scope": "Pinned historical PR626 JP8 scalar additions with reduced denominator <=16 and absolute numerator <=127. Synthesize coefficient work in one scratch register using source copy, signed source additions, doubling, exact halving and negation. Scratch always clears at each macro boundary. Grid denominator is at most the coefficient denominator, magnitude at most its original numerator. Exhaustive shortest-path search over the resulting finite signed integer graph; compare copy/binary and four Horner comparators. No frame, paid-profile, selected frontier or upstream changes.", + "deliverable": "Exact finite circuits or a scoped negative result with complete graph coverage, independently implemented verification, source pins, controls and reproducible command. No kappa claim.", + "related_prs": [ + 696, + 734, + 837, + 866, + 811, + 860, + 750, + 876, + 864 + ], + "overlap_snapshot": "669 open PRs through PR876, downloaded 2026-10-13; no overlapping grid-constrained arbitrary shift/add search identified.", + "result": { + "status": "Submitted finite circuit construction; no new kappa", + "pull_request": "https://github.com/CrocSwap/integer-mult-bounds/pull/882", + "completed_at": "2026-10-13T09:39:28.105031+00:00", + "searched_coefficients": 49, + "new_circuits": 7, + "affected_macros_per_orientation": 44, + "saved_real_primitives_vs_pr696": [ + 104, + 104 + ], + "saved_real_primitives_vs_four_horner_at_replacements": [ + 88, + 88 + ], + "exact_fractional_guards": [ + 4, + 27 + ], + "verification": "All-column primitive replay; independent full-graph Bellman proof; 15 mathematical negative controls; 9 package tests on Python 3.14.7 and 3.11.15; selected-record check.", + "coordination_update": "Local claim updated once with result and PR link; no pinned coordination issue available." + } +} diff --git a/research/jp8-grid-bounded-synthesis/EXPECTED.json b/research/jp8-grid-bounded-synthesis/EXPECTED.json new file mode 100644 index 0000000000..fe1cdf6109 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/EXPECTED.json @@ -0,0 +1,3564 @@ +{ + "full_pr837_composition_claimed": false, + "improved_coefficients": 7, + "improvements": [ + { + "coefficient": "9/4", + "horner_macro_costs": { + "binary-forward": 9, + "binary-reverse": 8, + "naf-forward": 9, + "naf-reverse": 8 + }, + "occurrences": { + "backward": 2, + "forward": 2 + }, + "real_component_macro_cost": 7, + "scratch_operations": [ + "halve", + "halve", + "add", + "add" + ] + }, + { + "coefficient": "5/2", + "horner_macro_costs": { + "binary-forward": 7, + "binary-reverse": 7, + "naf-forward": 7, + "naf-reverse": 7 + }, + "occurrences": { + "backward": 25, + "forward": 25 + }, + "real_component_macro_cost": 6, + "scratch_operations": [ + "halve", + "add", + "add" + ] + }, + { + "coefficient": "11/4", + "horner_macro_costs": { + "binary-forward": 10, + "binary-reverse": 9, + "naf-forward": 11, + "naf-reverse": 11 + }, + "occurrences": { + "backward": 1, + "forward": 1 + }, + "real_component_macro_cost": 8, + "scratch_operations": [ + "halve", + "add", + "halve", + "add", + "add" + ] + }, + { + "coefficient": "13/4", + "horner_macro_costs": { + "binary-forward": 10, + "binary-reverse": 9, + "naf-forward": 11, + "naf-reverse": 11 + }, + "occurrences": { + "backward": 1, + "forward": 1 + }, + "real_component_macro_cost": 8, + "scratch_operations": [ + "halve", + "halve", + "add", + "add", + "add" + ] + }, + { + "coefficient": "7/2", + "horner_macro_costs": { + "binary-forward": 8, + "binary-reverse": 8, + "naf-forward": 8, + "naf-reverse": 9 + }, + "occurrences": { + "backward": 10, + "forward": 10 + }, + "real_component_macro_cost": 7, + "scratch_operations": [ + "halve", + "add", + "add", + "add" + ] + }, + { + "coefficient": "15/4", + "horner_macro_costs": { + "binary-forward": 11, + "binary-reverse": 10, + "naf-forward": 10, + "naf-reverse": 10 + }, + "occurrences": { + "backward": 4, + "forward": 4 + }, + "real_component_macro_cost": 9, + "scratch_operations": [ + "halve", + "add", + "halve", + "add", + "add", + "add" + ] + }, + { + "coefficient": "17/4", + "horner_macro_costs": { + "binary-forward": 10, + "binary-reverse": 10, + "naf-forward": 10, + "naf-reverse": 10 + }, + "occurrences": { + "backward": 1, + "forward": 1 + }, + "real_component_macro_cost": 9, + "scratch_operations": [ + "halve", + "halve", + "add", + "add", + "add", + "add" + ] + } + ], + "independent_graph": { + "checked_coefficients": 49, + "checked_directed_edges": 14311, + "checked_vertices": 3703, + "entries": [ + { + "bound": 62, + "denominator": 2, + "directed_edges": 489, + "independent_states": [ + 2, + 4, + 8, + 16, + 32, + 30, + 60, + 62, + 31 + ], + "macro_cost": 11, + "maximum_distance": 15, + "numerator": 31, + "potential_sha256": "e357d699bea9f53f63a69cb071e0785a5ab75045c1857fe4e7ef4700b37536b6", + "preparation_steps": 8, + "relaxation_rounds": 15, + "submitted_states": [ + 2, + 4, + 8, + 16, + 32, + 30, + 60, + 62, + 31 + ], + "verified": true, + "vertices": 125 + }, + { + "bound": 16, + "denominator": 1, + "directed_edges": 125, + "independent_states": [ + 1, + 2, + 4, + 8, + 16 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 16, + "potential_sha256": "5857031575154803b49cf2051a2a66f7ef4df69560eb7a07c959b3e34c5b6d8b", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 1, + 2, + 4, + 8, + 16 + ], + "verified": true, + "vertices": 33 + }, + { + "bound": 20, + "denominator": 1, + "directed_edges": 157, + "independent_states": [ + 1, + 2, + 4, + 5, + 10, + 20 + ], + "macro_cost": 8, + "maximum_distance": 6, + "numerator": 20, + "potential_sha256": "2f274996c3ce3b27f8c9213f8e224de05f93e04838031a26ff1024274953bd0b", + "preparation_steps": 5, + "relaxation_rounds": 6, + "submitted_states": [ + 1, + 2, + 4, + 5, + 10, + 20 + ], + "verified": true, + "vertices": 41 + }, + { + "bound": 24, + "denominator": 1, + "directed_edges": 189, + "independent_states": [ + 1, + 2, + 3, + 6, + 12, + 24 + ], + "macro_cost": 8, + "maximum_distance": 6, + "numerator": 24, + "potential_sha256": "9ac1b023fdd228a88b05459c1fdff7c47f3d4b6b68664fea7731b218c6d564b8", + "preparation_steps": 5, + "relaxation_rounds": 6, + "submitted_states": [ + 1, + 2, + 3, + 6, + 12, + 24 + ], + "verified": true, + "vertices": 49 + }, + { + "bound": 32, + "denominator": 1, + "directed_edges": 253, + "independent_states": [ + 1, + 2, + 4, + 8, + 16, + 32 + ], + "macro_cost": 8, + "maximum_distance": 7, + "numerator": 32, + "potential_sha256": "e5f12c69f54b05d9db1bfe70b9e4a24facc3b6864ebe95c94d8ed1accfc66e62", + "preparation_steps": 5, + "relaxation_rounds": 7, + "submitted_states": [ + 1, + 2, + 4, + 8, + 16, + 32 + ], + "verified": true, + "vertices": 65 + }, + { + "bound": 158, + "denominator": 2, + "directed_edges": 1257, + "independent_states": [ + 2, + 4, + 8, + 10, + 20, + 40, + 80, + 78, + 156, + 158, + 79 + ], + "macro_cost": 13, + "maximum_distance": 39, + "numerator": 79, + "potential_sha256": "d94de147535347826a9d7c0e201228aa83f02cee6c3a3f564a3f963a51091b28", + "preparation_steps": 10, + "relaxation_rounds": 39, + "submitted_states": [ + 2, + 4, + 8, + 10, + 20, + 40, + 80, + 78, + 156, + 158, + 79 + ], + "verified": true, + "vertices": 317 + }, + { + "bound": 48, + "denominator": 1, + "directed_edges": 381, + "independent_states": [ + 1, + 2, + 3, + 6, + 12, + 24, + 48 + ], + "macro_cost": 9, + "maximum_distance": 8, + "numerator": 48, + "potential_sha256": "1e26362d4468cfb3aeaa66bf35472c40c65982547915ebfd7114b1ab788bac25", + "preparation_steps": 6, + "relaxation_rounds": 8, + "submitted_states": [ + 1, + 2, + 3, + 6, + 12, + 24, + 48 + ], + "verified": true, + "vertices": 97 + }, + { + "bound": 54, + "denominator": 1, + "directed_edges": 429, + "independent_states": [ + 1, + 2, + 3, + 6, + 7, + 14, + 28, + 27, + 54 + ], + "macro_cost": 11, + "maximum_distance": 9, + "numerator": 54, + "potential_sha256": "5f45b69a096d023bda3ea803b06d60c06c079ac23de44491d518a48ae671dc16", + "preparation_steps": 8, + "relaxation_rounds": 9, + "submitted_states": [ + 1, + 2, + 4, + 8, + 7, + 14, + 28, + 27, + 54 + ], + "verified": true, + "vertices": 109 + }, + { + "bound": 60, + "denominator": 1, + "directed_edges": 477, + "independent_states": [ + 1, + 2, + 4, + 8, + 16, + 15, + 30, + 60 + ], + "macro_cost": 10, + "maximum_distance": 9, + "numerator": 60, + "potential_sha256": "e524e867f613a568b1843252fdad1f69adf4f3e9081f0d1da2f0e6bc002ae5e1", + "preparation_steps": 7, + "relaxation_rounds": 9, + "submitted_states": [ + 1, + 2, + 4, + 8, + 16, + 15, + 30, + 60 + ], + "verified": true, + "vertices": 121 + }, + { + "bound": 64, + "denominator": 1, + "directed_edges": 509, + "independent_states": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "macro_cost": 9, + "maximum_distance": 9, + "numerator": 64, + "potential_sha256": "758452af376b8065b59e221f43cc39e8d7781a4c6e14e00b2b655f62511297db", + "preparation_steps": 6, + "relaxation_rounds": 9, + "submitted_states": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "verified": true, + "vertices": 129 + }, + { + "bound": 72, + "denominator": 1, + "directed_edges": 573, + "independent_states": [ + 1, + 2, + 4, + 8, + 9, + 18, + 36, + 72 + ], + "macro_cost": 10, + "maximum_distance": 10, + "numerator": 72, + "potential_sha256": "e92bf51981c590b8c8f205d7c3cd36e912560f5dfdc55a9dc0a2d938a4578739", + "preparation_steps": 7, + "relaxation_rounds": 10, + "submitted_states": [ + 1, + 2, + 4, + 8, + 9, + 18, + 36, + 72 + ], + "verified": true, + "vertices": 145 + }, + { + "bound": 79, + "denominator": 1, + "directed_edges": 627, + "independent_states": [ + 1, + 2, + 4, + 5, + 10, + 20, + 40, + 39, + 78, + 79 + ], + "macro_cost": 12, + "maximum_distance": 12, + "numerator": 79, + "potential_sha256": "bcf18fd9d2e37dfe22066f1ae57f8f356bcca5ccaa353347f0d2b9ff8723be56", + "preparation_steps": 9, + "relaxation_rounds": 12, + "submitted_states": [ + 1, + 2, + 4, + 5, + 10, + 20, + 40, + 39, + 78, + 79 + ], + "verified": true, + "vertices": 159 + }, + { + "bound": 80, + "denominator": 1, + "directed_edges": 637, + "independent_states": [ + 1, + 2, + 4, + 5, + 10, + 20, + 40, + 80 + ], + "macro_cost": 10, + "maximum_distance": 10, + "numerator": 80, + "potential_sha256": "37a5bf13615d1de6fbd63b7d9d050d035716e0efd77a32f23d22110b102147c5", + "preparation_steps": 7, + "relaxation_rounds": 10, + "submitted_states": [ + 1, + 2, + 4, + 5, + 10, + 20, + 40, + 80 + ], + "verified": true, + "vertices": 161 + }, + { + "bound": 96, + "denominator": 1, + "directed_edges": 765, + "independent_states": [ + 1, + 2, + 3, + 6, + 12, + 24, + 48, + 96 + ], + "macro_cost": 10, + "maximum_distance": 11, + "numerator": 96, + "potential_sha256": "7f834bf447609c837d176c2f6022d745ce0fbdc7fceb705d1719782d38a169a2", + "preparation_steps": 7, + "relaxation_rounds": 11, + "submitted_states": [ + 1, + 2, + 3, + 6, + 12, + 24, + 48, + 96 + ], + "verified": true, + "vertices": 193 + }, + { + "bound": 108, + "denominator": 1, + "directed_edges": 861, + "independent_states": [ + 1, + 2, + 3, + 6, + 7, + 14, + 28, + 27, + 54, + 108 + ], + "macro_cost": 12, + "maximum_distance": 12, + "numerator": 108, + "potential_sha256": "e14f3b77888d3e7cad10bedad3a9c6912a44478987966cf4ca8dae75cf2efca4", + "preparation_steps": 9, + "relaxation_rounds": 12, + "submitted_states": [ + 1, + 2, + 4, + 8, + 7, + 14, + 28, + 27, + 54, + 108 + ], + "verified": true, + "vertices": 217 + }, + { + "bound": 120, + "denominator": 1, + "directed_edges": 957, + "independent_states": [ + 1, + 2, + 4, + 8, + 16, + 15, + 30, + 60, + 120 + ], + "macro_cost": 11, + "maximum_distance": 12, + "numerator": 120, + "potential_sha256": "2238c9e7a45cb7fdb1a3ef29500448afd0e0135e7a8436c8a78225cd9ad7c261", + "preparation_steps": 8, + "relaxation_rounds": 12, + "submitted_states": [ + 1, + 2, + 4, + 8, + 16, + 15, + 30, + 60, + 120 + ], + "verified": true, + "vertices": 241 + }, + { + "bound": 8, + "denominator": 8, + "directed_edges": 49, + "independent_states": [ + 8, + 4, + 2, + 1 + ], + "macro_cost": 6, + "maximum_distance": 4, + "numerator": 1, + "potential_sha256": "1390a2a1691e0b58fa528a33e95ebf45efa05cca9e49f4fccb8c7362be856a42", + "preparation_steps": 3, + "relaxation_rounds": 4, + "submitted_states": [ + 8, + 4, + 2, + 1 + ], + "verified": true, + "vertices": 17 + }, + { + "bound": 4, + "denominator": 4, + "directed_edges": 25, + "independent_states": [ + 4, + 2, + 1 + ], + "macro_cost": 5, + "maximum_distance": 3, + "numerator": 1, + "potential_sha256": "3e31e1b4768b4b542d76ed637636f44d46d7a96ed7f7011d3ea2e7efdcbb4b8d", + "preparation_steps": 2, + "relaxation_rounds": 3, + "submitted_states": [ + 4, + 2, + 1 + ], + "verified": true, + "vertices": 9 + }, + { + "bound": 24, + "denominator": 8, + "directed_edges": 173, + "independent_states": [ + 8, + 4, + 2, + -6, + -3 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 3, + "potential_sha256": "bd3fbfc4edbc1fab32c96aee1a55c000e63d8309878b1fa49d9697c500f113d8", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 8, + 4, + 12, + 6, + 3 + ], + "verified": true, + "vertices": 49 + }, + { + "bound": 2, + "denominator": 2, + "directed_edges": 13, + "independent_states": [ + 2, + 1 + ], + "macro_cost": 4, + "maximum_distance": 2, + "numerator": 1, + "potential_sha256": "b2aba92626d524f70ad91fa5c45e8e2847edce72ee82efb403c83bbd1ac2f028", + "preparation_steps": 1, + "relaxation_rounds": 2, + "submitted_states": [ + 2, + 1 + ], + "verified": true, + "vertices": 5 + }, + { + "bound": 12, + "denominator": 4, + "directed_edges": 85, + "independent_states": [ + 4, + 2, + 1, + -3 + ], + "macro_cost": 6, + "maximum_distance": 4, + "numerator": 3, + "potential_sha256": "fdb9f0779f9cf1b66468c49c5d96fb91a50eb8a44c5839d1ecb919e870aa3658", + "preparation_steps": 3, + "relaxation_rounds": 4, + "submitted_states": [ + 4, + 2, + 6, + 3 + ], + "verified": true, + "vertices": 25 + }, + { + "bound": 20, + "denominator": 4, + "directed_edges": 149, + "independent_states": [ + 4, + 2, + 1, + 5 + ], + "macro_cost": 6, + "maximum_distance": 6, + "numerator": 5, + "potential_sha256": "8276af535f7b3849729e86c229e94600a8960c6364fe48ec3c5cc90fc31e056d", + "preparation_steps": 3, + "relaxation_rounds": 6, + "submitted_states": [ + 4, + 2, + 1, + 5 + ], + "verified": true, + "vertices": 41 + }, + { + "bound": 6, + "denominator": 2, + "directed_edges": 41, + "independent_states": [ + 2, + 1, + 3 + ], + "macro_cost": 5, + "maximum_distance": 3, + "numerator": 3, + "potential_sha256": "7b4814a4b67420ae5d09d4425981b13ed9414a4ea848ae6cc1617b061b4a4c07", + "preparation_steps": 2, + "relaxation_rounds": 3, + "submitted_states": [ + 2, + 1, + 3 + ], + "verified": true, + "vertices": 13 + }, + { + "bound": 28, + "denominator": 4, + "directed_edges": 213, + "independent_states": [ + 4, + 2, + 1, + -3, + -7 + ], + "macro_cost": 7, + "maximum_distance": 7, + "numerator": 7, + "potential_sha256": "0b46c0d3927002e5b05e60bac78f47631ec8bdc11ce6182fcca40113ecf884e0", + "preparation_steps": 4, + "relaxation_rounds": 7, + "submitted_states": [ + 4, + 2, + 6, + 3, + 7 + ], + "verified": true, + "vertices": 57 + }, + { + "bound": 2, + "denominator": 1, + "directed_edges": 13, + "independent_states": [ + 1, + 2 + ], + "macro_cost": 4, + "maximum_distance": 2, + "numerator": 2, + "potential_sha256": "51aeda22ae9c1608a69aac5bad4d9590ee9742cfe22ec7c35dd7c4a2fc422ce7", + "preparation_steps": 1, + "relaxation_rounds": 2, + "submitted_states": [ + 1, + 2 + ], + "verified": true, + "vertices": 5 + }, + { + "bound": 36, + "denominator": 4, + "directed_edges": 277, + "independent_states": [ + 4, + 2, + 1, + 5, + 9 + ], + "macro_cost": 7, + "maximum_distance": 9, + "numerator": 9, + "potential_sha256": "26f31a4ded713249971741a3224129b4bef35e2a8621204e071691e6b1483c49", + "preparation_steps": 4, + "relaxation_rounds": 9, + "submitted_states": [ + 4, + 2, + 1, + 5, + 9 + ], + "verified": true, + "vertices": 73 + }, + { + "bound": 10, + "denominator": 2, + "directed_edges": 73, + "independent_states": [ + 2, + 1, + 3, + 5 + ], + "macro_cost": 6, + "maximum_distance": 4, + "numerator": 5, + "potential_sha256": "68c8481929ce671c0a92ac946a27068a5da88d42df0e9369ac5c539588792a06", + "preparation_steps": 3, + "relaxation_rounds": 4, + "submitted_states": [ + 2, + 1, + 3, + 5 + ], + "verified": true, + "vertices": 21 + }, + { + "bound": 44, + "denominator": 4, + "directed_edges": 341, + "independent_states": [ + 4, + 2, + 1, + -3, + -7, + -11 + ], + "macro_cost": 8, + "maximum_distance": 10, + "numerator": 11, + "potential_sha256": "339d8d30605cb7ded79097014daf3b462a79417abfdfe830d0980bebad56e524", + "preparation_steps": 5, + "relaxation_rounds": 10, + "submitted_states": [ + 4, + 2, + 6, + 3, + 7, + 11 + ], + "verified": true, + "vertices": 89 + }, + { + "bound": 3, + "denominator": 1, + "directed_edges": 19, + "independent_states": [ + 1, + 2, + 3 + ], + "macro_cost": 5, + "maximum_distance": 3, + "numerator": 3, + "potential_sha256": "b38059c22eec14a828631979a7ce07e5269dcb6c02fdc78e1cfc27df212856ed", + "preparation_steps": 2, + "relaxation_rounds": 3, + "submitted_states": [ + 1, + 2, + 3 + ], + "verified": true, + "vertices": 7 + }, + { + "bound": 52, + "denominator": 4, + "directed_edges": 405, + "independent_states": [ + 4, + 2, + 1, + 5, + 9, + 13 + ], + "macro_cost": 8, + "maximum_distance": 12, + "numerator": 13, + "potential_sha256": "6ac195106f8894710a47965729b60eb2859e68b3dbe5c45b5fee21494abb46db", + "preparation_steps": 5, + "relaxation_rounds": 12, + "submitted_states": [ + 4, + 2, + 1, + 5, + 9, + 13 + ], + "verified": true, + "vertices": 105 + }, + { + "bound": 14, + "denominator": 2, + "directed_edges": 105, + "independent_states": [ + 2, + 1, + 3, + 5, + 7 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 7, + "potential_sha256": "8cf45124113d68f92c72852641e6c38dbaac9fe1b506dc157e67f9b3d5e885d7", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 2, + 1, + 3, + 5, + 7 + ], + "verified": true, + "vertices": 29 + }, + { + "bound": 60, + "denominator": 4, + "directed_edges": 469, + "independent_states": [ + 4, + 2, + 1, + -3, + -7, + -11, + -15 + ], + "macro_cost": 9, + "maximum_distance": 13, + "numerator": 15, + "potential_sha256": "20f2047b7d8ce548b6060a871a1da8269d42296aa8d3ae567011cc69e07a27c9", + "preparation_steps": 6, + "relaxation_rounds": 13, + "submitted_states": [ + 4, + 2, + 6, + 3, + 7, + 11, + 15 + ], + "verified": true, + "vertices": 121 + }, + { + "bound": 4, + "denominator": 1, + "directed_edges": 29, + "independent_states": [ + 1, + 2, + 4 + ], + "macro_cost": 5, + "maximum_distance": 3, + "numerator": 4, + "potential_sha256": "abc1946a87f3f5c72240aa59da5d0d71b289173dc9f440ed23b093f7b3d4be87", + "preparation_steps": 2, + "relaxation_rounds": 3, + "submitted_states": [ + 1, + 2, + 4 + ], + "verified": true, + "vertices": 9 + }, + { + "bound": 68, + "denominator": 4, + "directed_edges": 533, + "independent_states": [ + 4, + 2, + 1, + 5, + 9, + 13, + 17 + ], + "macro_cost": 9, + "maximum_distance": 15, + "numerator": 17, + "potential_sha256": "1e98c336e8295ed39c5c3e5e8ceefc36e9c534b44cfe9352fb6f32d23a79ef71", + "preparation_steps": 6, + "relaxation_rounds": 15, + "submitted_states": [ + 4, + 2, + 1, + 5, + 9, + 13, + 17 + ], + "verified": true, + "vertices": 137 + }, + { + "bound": 18, + "denominator": 2, + "directed_edges": 137, + "independent_states": [ + 2, + 1, + 3, + 5, + 7, + 9 + ], + "macro_cost": 8, + "maximum_distance": 6, + "numerator": 9, + "potential_sha256": "b3acd2be7ec04088146c1579e2e45de1e13d49553a8d09a62d2e890e1c78e620", + "preparation_steps": 5, + "relaxation_rounds": 6, + "submitted_states": [ + 2, + 4, + 8, + 16, + 18, + 9 + ], + "verified": true, + "vertices": 37 + }, + { + "bound": 5, + "denominator": 1, + "directed_edges": 35, + "independent_states": [ + 1, + 2, + 4, + 5 + ], + "macro_cost": 6, + "maximum_distance": 4, + "numerator": 5, + "potential_sha256": "fb77b9582326b63a3e3295a59afb636169a770fc6c8023056f64bb12dc8a8e49", + "preparation_steps": 3, + "relaxation_rounds": 4, + "submitted_states": [ + 1, + 2, + 4, + 5 + ], + "verified": true, + "vertices": 11 + }, + { + "bound": 22, + "denominator": 2, + "directed_edges": 169, + "independent_states": [ + 2, + 1, + 3, + 5, + 7, + 9, + 11 + ], + "macro_cost": 9, + "maximum_distance": 7, + "numerator": 11, + "potential_sha256": "9e1ff81934d9fd3158f276862d636e59b478c5059defae2b1cc1f2652ad2de1c", + "preparation_steps": 6, + "relaxation_rounds": 7, + "submitted_states": [ + 2, + 4, + 8, + 16, + 18, + 9, + 11 + ], + "verified": true, + "vertices": 45 + }, + { + "bound": 6, + "denominator": 1, + "directed_edges": 45, + "independent_states": [ + 1, + 2, + 3, + 6 + ], + "macro_cost": 6, + "maximum_distance": 4, + "numerator": 6, + "potential_sha256": "c218c0343f4d549ccda3978880d075b94a9c323c3dba54f24535f3a076585e91", + "preparation_steps": 3, + "relaxation_rounds": 4, + "submitted_states": [ + 1, + 2, + 3, + 6 + ], + "verified": true, + "vertices": 13 + }, + { + "bound": 26, + "denominator": 2, + "directed_edges": 201, + "independent_states": [ + 2, + 4, + 6, + 12, + 24, + 26, + 13 + ], + "macro_cost": 9, + "maximum_distance": 7, + "numerator": 13, + "potential_sha256": "486201b3e3deecf1c8fe6d84c17e24b01c73a93babf04055b8ca9bddf7f455a4", + "preparation_steps": 6, + "relaxation_rounds": 7, + "submitted_states": [ + 2, + 4, + 6, + 12, + 24, + 26, + 13 + ], + "verified": true, + "vertices": 53 + }, + { + "bound": 7, + "denominator": 1, + "directed_edges": 51, + "independent_states": [ + 1, + 2, + 3, + 6, + 7 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 7, + "potential_sha256": "3411dba6b11eaca1337d19333b1f4a3cc30704fb1eab0f726d25f6ac77837468", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 1, + 2, + 3, + 6, + 7 + ], + "verified": true, + "vertices": 15 + }, + { + "bound": 30, + "denominator": 2, + "directed_edges": 233, + "independent_states": [ + 2, + 4, + 6, + 12, + 14, + 28, + 30, + 15 + ], + "macro_cost": 10, + "maximum_distance": 8, + "numerator": 15, + "potential_sha256": "95b0c301d253a082634f0c2a2523e9bea45342a6cca21e33fc4ed96b8ebf6e9e", + "preparation_steps": 7, + "relaxation_rounds": 8, + "submitted_states": [ + 2, + 4, + 8, + 16, + 14, + 28, + 30, + 15 + ], + "verified": true, + "vertices": 61 + }, + { + "bound": 124, + "denominator": 4, + "directed_edges": 981, + "independent_states": [ + 4, + 8, + 16, + 32, + 64, + 60, + 120, + 124, + 62, + 31 + ], + "macro_cost": 12, + "maximum_distance": 25, + "numerator": 31, + "potential_sha256": "b867a389802ad3971e03953ff640c3a5d58e7909125cc72c95c9e20641359dc4", + "preparation_steps": 9, + "relaxation_rounds": 25, + "submitted_states": [ + 4, + 8, + 16, + 32, + 64, + 60, + 120, + 124, + 62, + 31 + ], + "verified": true, + "vertices": 249 + }, + { + "bound": 8, + "denominator": 1, + "directed_edges": 61, + "independent_states": [ + 1, + 2, + 4, + 8 + ], + "macro_cost": 6, + "maximum_distance": 4, + "numerator": 8, + "potential_sha256": "7c4d3599083123e397a9dc7123f9f4a4c4e7016145e3972ea734e3964e139801", + "preparation_steps": 3, + "relaxation_rounds": 4, + "submitted_states": [ + 1, + 2, + 4, + 8 + ], + "verified": true, + "vertices": 17 + }, + { + "bound": 34, + "denominator": 2, + "directed_edges": 265, + "independent_states": [ + 2, + 4, + 8, + 16, + 32, + 34, + 17 + ], + "macro_cost": 9, + "maximum_distance": 8, + "numerator": 17, + "potential_sha256": "8efe8579a050dfe8119c974d2b2430eabaf60e09d6b688e34aaac86af9a5c429", + "preparation_steps": 6, + "relaxation_rounds": 8, + "submitted_states": [ + 2, + 4, + 8, + 16, + 32, + 34, + 17 + ], + "verified": true, + "vertices": 69 + }, + { + "bound": 9, + "denominator": 1, + "directed_edges": 67, + "independent_states": [ + 1, + 2, + 4, + 8, + 9 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 9, + "potential_sha256": "40c8f612f07207a79c86e5e398eacf7e51f7b2407da1a1ad57f92388431dc899", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 1, + 2, + 4, + 8, + 9 + ], + "verified": true, + "vertices": 19 + }, + { + "bound": 10, + "denominator": 1, + "directed_edges": 77, + "independent_states": [ + 1, + 2, + 4, + 5, + 10 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 10, + "potential_sha256": "156851b8bd1ef254f920f057c23c042520d19dab151922bf259071ddfff5383a", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 1, + 2, + 4, + 5, + 10 + ], + "verified": true, + "vertices": 21 + }, + { + "bound": 11, + "denominator": 1, + "directed_edges": 83, + "independent_states": [ + 1, + 2, + 4, + 5, + 10, + 11 + ], + "macro_cost": 8, + "maximum_distance": 6, + "numerator": 11, + "potential_sha256": "6eb822f4162ca7ac576df3f064f76ba7f41e36f392fbb7fbf524a8a424d15f02", + "preparation_steps": 5, + "relaxation_rounds": 6, + "submitted_states": [ + 1, + 2, + 4, + 5, + 10, + 11 + ], + "verified": true, + "vertices": 23 + }, + { + "bound": 12, + "denominator": 1, + "directed_edges": 93, + "independent_states": [ + 1, + 2, + 3, + 6, + 12 + ], + "macro_cost": 7, + "maximum_distance": 5, + "numerator": 12, + "potential_sha256": "fbb8371d86056c678cea66ec671d568ce23e528eed3d21cc33ca764462d4611c", + "preparation_steps": 4, + "relaxation_rounds": 5, + "submitted_states": [ + 1, + 2, + 3, + 6, + 12 + ], + "verified": true, + "vertices": 25 + }, + { + "bound": 15, + "denominator": 1, + "directed_edges": 115, + "independent_states": [ + 1, + 2, + 3, + 6, + 7, + 14, + 15 + ], + "macro_cost": 9, + "maximum_distance": 7, + "numerator": 15, + "potential_sha256": "7848efb4525e7436f4a44075d2cad38b630ede92a57db425cf8b0135113426ba", + "preparation_steps": 6, + "relaxation_rounds": 7, + "submitted_states": [ + 1, + 2, + 4, + 8, + 7, + 14, + 15 + ], + "verified": true, + "vertices": 31 + } + ], + "method": "full synchronous reverse Bellman relaxation and all-edge potential proof", + "negative_controls": { + "forged_distance_potential": { + "reason": "edge lower-bound violation at state 0", + "rejected": true + }, + "odd_state_halving": { + "reason": "off-grid halving at operation 1", + "rejected": true + }, + "valid_but_nonoptimal_path": { + "reason": "submitted length 4 is not the exact optimum 2", + "rejected": true + }, + "wrong_signed_endpoint": { + "reason": "witness does not reach its stated goal", + "rejected": true + } + }, + "positive_controls": { + "known_distances": 8, + "primitive_names_covered": 5 + }, + "source_coverage_checked": true, + "status": "PASS" + }, + "independent_integer_replay": { + "arithmetic": "normalized sparse integer rows with a common power-of-two denominator", + "certificate_coefficients_checked": 49, + "finite_graph_optimality_rechecked": false, + "independently_recomputed_comparator_lengths": { + "11/4": { + "binary-forward": 10, + "binary-reverse": 9, + "naf-forward": 11, + "naf-reverse": 11 + }, + "13/4": { + "binary-forward": 10, + "binary-reverse": 9, + "naf-forward": 11, + "naf-reverse": 11 + }, + "15/4": { + "binary-forward": 11, + "binary-reverse": 10, + "naf-forward": 10, + "naf-reverse": 10 + }, + "17/4": { + "binary-forward": 10, + "binary-reverse": 10, + "naf-forward": 10, + "naf-reverse": 10 + }, + "5/2": { + "binary-forward": 7, + "binary-reverse": 7, + "naf-forward": 7, + "naf-reverse": 7 + }, + "7/2": { + "binary-forward": 8, + "binary-reverse": 8, + "naf-forward": 8, + "naf-reverse": 9 + }, + "9/4": { + "binary-forward": 9, + "binary-reverse": 8, + "naf-forward": 9, + "naf-reverse": 8 + } + }, + "input_semantic_sha256": { + "certificate": "b77549cc42ebc4ffbb2ea95e02b20cbcfa200846e67d85ccf00f9f9fffc20a6f", + "checks": "e29bdcebdc2966979a9f5911f56b68c6f4942f6fdbeb6737e9db44e147d0193a", + "inherited": "3ca597b8c9053574c66ba005fc553dbec5291b01dd476e147b18870cb786c0d2", + "programs": "efe45ce7fb025a6f53cc9eb54e951ac2211a5ed927e689a049e4f68ca680654b" + }, + "kappa_claim": null, + "negative_controls": { + "dirty_scratch_missing_clear": "dirty coefficient scratch", + "endpoint_neutral_grid_excursion": "coefficient grid excursion", + "incorrect_halving": "incorrect local macro endpoint", + "incorrect_scale_sign": "incorrect local macro endpoint", + "missing_source_copy": "dirty scratch dependency", + "wrong_accumulation_sign": "incorrect local macro endpoint" + }, + "positive_controls": { + "NAF_carry_cases": 1, + "integer_row_arithmetic_cases": 5 + }, + "programs": { + "backward": { + "addition_macros_with_coefficient_work_clear": 22219, + "arbitrary_helper_columns_restored": 492, + "arbitrary_private_input_columns": 9, + "changed_macros": 44, + "events": 27909, + "extra_real_source_reads_vs_pr696": 92, + "historical_real_primitives": 257280, + "logical_input_columns": 716, + "lowerings": { + "pr696": { + "maximum_fractional_denominator_exponent": 27, + "maximum_scalar_prefix_row_l1": "1469388997/2", + "primitive_tags": { + "add": 29176, + "clear": 44470, + "copy": 31992, + "double": 32576, + "halve": 39438, + "negate": 692, + "subtract": 22052 + }, + "primitive_word_sha256": "8a1f3a16f146088e72c4a3decf0f967ff449b58a3521a86c3ee5c60d8abc5e75", + "real_macro_source_reads": 51228, + "real_primitives": 200396, + "real_total_register_reads": 207154 + }, + "replacement": { + "maximum_fractional_denominator_exponent": 27, + "maximum_scalar_prefix_row_l1": "1469388997/2", + "primitive_tags": { + "add": 29268, + "clear": 44470, + "copy": 31992, + "double": 32380, + "halve": 39438, + "negate": 692, + "subtract": 22052 + }, + "primitive_word_sha256": "28fe0fbc9983efbce296864a9ed18f9faba57fb12afc29c8c4e6e574d57ef5ed", + "real_macro_source_reads": 51320, + "real_primitives": 200292, + "real_total_register_reads": 207142 + } + }, + "macro_boundaries_compared_with_integer_oracle": 22693, + "non_scalar_event_indexed_sha256": "f6d942e0ed78b1df58bc5e9b5f313b96385ab10ec315feff237fcbe11b755622", + "paid_profile": { + "1": 2512, + "2": 400, + "3": 448, + "4": 160, + "5": 70, + "6": 8, + "8": 8 + }, + "private_registers_erased": 9, + "saved_real_primitives_vs_pr696": 104, + "scalar_frame_indexed_sha256": "e3dfdbc2f70a81019ab5d3d8aac7d86c677e9dd3967ecfb0150f8b38b0220c6d", + "scalar_macros": 22693, + "total_exact_input_columns": 725 + }, + "forward": { + "addition_macros_with_coefficient_work_clear": 22211, + "arbitrary_helper_columns_restored": 492, + "arbitrary_private_input_columns": 9, + "changed_macros": 44, + "events": 27909, + "extra_real_source_reads_vs_pr696": 92, + "historical_real_primitives": 257232, + "logical_input_columns": 716, + "lowerings": { + "pr696": { + "maximum_fractional_denominator_exponent": 4, + "maximum_scalar_prefix_row_l1": "503316465", + "primitive_tags": { + "add": 29050, + "clear": 44454, + "copy": 32008, + "double": 32576, + "halve": 39438, + "negate": 692, + "subtract": 22162 + }, + "primitive_word_sha256": "65af87a53b40699f2711182819179af1820be741474b291009c4f5567921bf56", + "real_macro_source_reads": 51228, + "real_primitives": 200380, + "real_total_register_reads": 207138 + }, + "replacement": { + "maximum_fractional_denominator_exponent": 4, + "maximum_scalar_prefix_row_l1": "503316465", + "primitive_tags": { + "add": 29142, + "clear": 44454, + "copy": 32008, + "double": 32380, + "halve": 39438, + "negate": 692, + "subtract": 22162 + }, + "primitive_word_sha256": "3a6a08261e75f4ef4bb5f1286d1c842ade135005691543072aa29f5b9349eae9", + "real_macro_source_reads": 51320, + "real_primitives": 200276, + "real_total_register_reads": 207126 + } + }, + "macro_boundaries_compared_with_integer_oracle": 22693, + "non_scalar_event_indexed_sha256": "bd1e5e7700469f06100d7580e064a6524658931785359e6c9fe6429425b4a47b", + "paid_profile": { + "1": 2512, + "2": 400, + "3": 448, + "4": 160, + "5": 70, + "6": 8, + "8": 8 + }, + "private_registers_erased": 9, + "saved_real_primitives_vs_pr696": 104, + "scalar_frame_indexed_sha256": "7fa49a442a45e031833e44b7f00ce98e3ceda30f36a9fdcd92ce1cdbc9c5855f", + "scalar_macros": 22693, + "total_exact_input_columns": 725 + } + }, + "schema": "jp8-integer-scalar-crosscheck/1", + "scope": "Historical PR626 JP8 scalar projections only; no complex-event or multiplication-bound proof.", + "selected_coefficients": [ + "9/4", + "5/2", + "11/4", + "13/4", + "7/2", + "15/4", + "17/4" + ], + "selected_replacements": 7, + "status": "PASS_JP8_INTEGER_SCALAR_CROSSCHECK" + }, + "kappa_claim": null, + "negative_controls": { + "endpoint_neutral_grid_excursion": "fractional grid", + "endpoint_neutral_magnitude_excursion": "magnitude bound", + "missing_clear": "macro endpoint or private clear", + "missing_copy": "dirty work dependency", + "nondyadic": "addition requires distinct registers and a nonzero dyadic", + "scratch_alias": "addition requires distinct registers and a nonzero dyadic", + "source_modified_then_restored": "source write", + "source_target_alias": "addition requires distinct registers and a nonzero dyadic", + "uncharged_extra_clear": "primitive count", + "wrong_accumulation_sign": "target prefix", + "zero_coefficient": "addition requires distinct registers and a nonzero dyadic" + }, + "programs": { + "backward": { + "addition_macros": 22219, + "addition_macros_with_coefficient_work_clear": 22219, + "arbitrary_helper_columns_restored": 492, + "arbitrary_private_input_columns": 9, + "changed_coefficients": { + "-11/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 20, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 16, + "replacement_real_source_reads_per_macro": 8 + }, + "-13/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 20, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 16, + "replacement_real_source_reads_per_macro": 8 + }, + "-15/4": { + "occurrences": 2, + "pr696_real_primitives_per_macro": 22, + "pr696_real_source_reads_per_macro": 8, + "replacement_real_primitives_per_macro": 18, + "replacement_real_source_reads_per_macro": 10 + }, + "-17/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 20, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 18, + "replacement_real_source_reads_per_macro": 10 + }, + "-5/2": { + "occurrences": 12, + "pr696_real_primitives_per_macro": 14, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 12, + "replacement_real_source_reads_per_macro": 6 + }, + "-7/2": { + "occurrences": 6, + "pr696_real_primitives_per_macro": 16, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 8 + }, + "-9/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 18, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 6 + }, + "15/4": { + "occurrences": 2, + "pr696_real_primitives_per_macro": 22, + "pr696_real_source_reads_per_macro": 8, + "replacement_real_primitives_per_macro": 18, + "replacement_real_source_reads_per_macro": 10 + }, + "5/2": { + "occurrences": 13, + "pr696_real_primitives_per_macro": 14, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 12, + "replacement_real_source_reads_per_macro": 6 + }, + "7/2": { + "occurrences": 4, + "pr696_real_primitives_per_macro": 16, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 8 + }, + "9/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 18, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 6 + } + }, + "changed_macros": 44, + "charged_payload_bits": 192, + "events": 27909, + "extra_real_source_reads_vs_pr696": 92, + "inherited_prefix_bits_upper": 101, + "logical_input_columns": 716, + "lowerings": { + "historical": { + "maximum_fractional_denominator_exponent": 27, + "maximum_scalar_prefix_row_l1": "1469388997/2", + "primitive_tags": { + "add": 73614, + "clear": 88908, + "double": 32576, + "halve": 39438, + "negate": 692, + "subtract": 22052 + }, + "primitive_word_sha256": "9744c810cd6b252f4cfdc59f2e584acc8c25a0bce53ec2659db375f1e5806074", + "real_macro_source_reads": 51228, + "real_primitives": 257280, + "real_total_register_reads": 264038 + }, + "pr696": { + "maximum_fractional_denominator_exponent": 27, + "maximum_scalar_prefix_row_l1": "1469388997/2", + "primitive_tags": { + "add": 29176, + "clear": 44470, + "copy": 31992, + "double": 32576, + "halve": 39438, + "negate": 692, + "subtract": 22052 + }, + "primitive_word_sha256": "8a1f3a16f146088e72c4a3decf0f967ff449b58a3521a86c3ee5c60d8abc5e75", + "real_macro_source_reads": 51228, + "real_primitives": 200396, + "real_total_register_reads": 207154 + }, + "replacement": { + "maximum_fractional_denominator_exponent": 27, + "maximum_scalar_prefix_row_l1": "1469388997/2", + "primitive_tags": { + "add": 29268, + "clear": 44470, + "copy": 31992, + "double": 32380, + "halve": 39438, + "negate": 692, + "subtract": 22052 + }, + "primitive_word_sha256": "28fe0fbc9983efbce296864a9ed18f9faba57fb12afc29c8c4e6e574d57ef5ed", + "real_macro_source_reads": 51320, + "real_primitives": 200292, + "real_total_register_reads": 207142 + } + }, + "macro_boundaries_compared": 22693, + "non_scalar_event_indexed_sha256": "f6d942e0ed78b1df58bc5e9b5f313b96385ab10ec315feff237fcbe11b755622", + "paid_profile": { + "1": 2512, + "2": 400, + "3": 448, + "4": 160, + "5": 70, + "6": 8, + "8": 8 + }, + "preserved_non_scalar_events": 5216, + "private_registers_erased": 9, + "retained_prefix_l1_upper": "16753412757380464429924108070201913461/8388608", + "saved_real_primitives_vs_historical": 56988, + "saved_real_primitives_vs_pr696": 104, + "scalar_frame_indexed_sha256": "e3dfdbc2f70a81019ab5d3d8aac7d86c677e9dd3967ecfb0150f8b38b0220c6d", + "scalar_macros": 22693, + "total_exact_input_columns": 725 + }, + "forward": { + "addition_macros": 22211, + "addition_macros_with_coefficient_work_clear": 22211, + "arbitrary_helper_columns_restored": 492, + "arbitrary_private_input_columns": 9, + "changed_coefficients": { + "-15/4": { + "occurrences": 2, + "pr696_real_primitives_per_macro": 22, + "pr696_real_source_reads_per_macro": 8, + "replacement_real_primitives_per_macro": 18, + "replacement_real_source_reads_per_macro": 10 + }, + "-5/2": { + "occurrences": 13, + "pr696_real_primitives_per_macro": 14, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 12, + "replacement_real_source_reads_per_macro": 6 + }, + "-7/2": { + "occurrences": 4, + "pr696_real_primitives_per_macro": 16, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 8 + }, + "-9/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 18, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 6 + }, + "11/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 20, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 16, + "replacement_real_source_reads_per_macro": 8 + }, + "13/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 20, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 16, + "replacement_real_source_reads_per_macro": 8 + }, + "15/4": { + "occurrences": 2, + "pr696_real_primitives_per_macro": 22, + "pr696_real_source_reads_per_macro": 8, + "replacement_real_primitives_per_macro": 18, + "replacement_real_source_reads_per_macro": 10 + }, + "17/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 20, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 18, + "replacement_real_source_reads_per_macro": 10 + }, + "5/2": { + "occurrences": 12, + "pr696_real_primitives_per_macro": 14, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 12, + "replacement_real_source_reads_per_macro": 6 + }, + "7/2": { + "occurrences": 6, + "pr696_real_primitives_per_macro": 16, + "pr696_real_source_reads_per_macro": 6, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 8 + }, + "9/4": { + "occurrences": 1, + "pr696_real_primitives_per_macro": 18, + "pr696_real_source_reads_per_macro": 4, + "replacement_real_primitives_per_macro": 14, + "replacement_real_source_reads_per_macro": 6 + } + }, + "changed_macros": 44, + "charged_payload_bits": 192, + "events": 27909, + "extra_real_source_reads_vs_pr696": 92, + "inherited_prefix_bits_upper": 64, + "logical_input_columns": 716, + "lowerings": { + "historical": { + "maximum_fractional_denominator_exponent": 4, + "maximum_scalar_prefix_row_l1": "503316465", + "primitive_tags": { + "add": 73472, + "clear": 88876, + "copy": 16, + "double": 32576, + "halve": 39438, + "negate": 692, + "subtract": 22162 + }, + "primitive_word_sha256": "1dfd0a36e3bf9cc694ec8b43583a987158bdd0bfc107f6ce75e08b119491fb3b", + "real_macro_source_reads": 51228, + "real_primitives": 257232, + "real_total_register_reads": 263990 + }, + "pr696": { + "maximum_fractional_denominator_exponent": 4, + "maximum_scalar_prefix_row_l1": "503316465", + "primitive_tags": { + "add": 29050, + "clear": 44454, + "copy": 32008, + "double": 32576, + "halve": 39438, + "negate": 692, + "subtract": 22162 + }, + "primitive_word_sha256": "65af87a53b40699f2711182819179af1820be741474b291009c4f5567921bf56", + "real_macro_source_reads": 51228, + "real_primitives": 200380, + "real_total_register_reads": 207138 + }, + "replacement": { + "maximum_fractional_denominator_exponent": 4, + "maximum_scalar_prefix_row_l1": "503316465", + "primitive_tags": { + "add": 29142, + "clear": 44454, + "copy": 32008, + "double": 32380, + "halve": 39438, + "negate": 692, + "subtract": 22162 + }, + "primitive_word_sha256": "3a6a08261e75f4ef4bb5f1286d1c842ade135005691543072aa29f5b9349eae9", + "real_macro_source_reads": 51320, + "real_primitives": 200276, + "real_total_register_reads": 207126 + } + }, + "macro_boundaries_compared": 22693, + "non_scalar_event_indexed_sha256": "bd1e5e7700469f06100d7580e064a6524658931785359e6c9fe6429425b4a47b", + "paid_profile": { + "1": 2512, + "2": 400, + "3": 448, + "4": 160, + "5": 70, + "6": 8, + "8": 8 + }, + "preserved_non_scalar_events": 5216, + "private_registers_erased": 9, + "retained_prefix_l1_upper": "4536094588619580433782972610869617/281474976710656", + "saved_real_primitives_vs_historical": 56956, + "saved_real_primitives_vs_pr696": 104, + "scalar_frame_indexed_sha256": "7fa49a442a45e031833e44b7f00ce98e3ceda30f36a9fdcd92ce1cdbc9c5855f", + "scalar_macros": 22693, + "total_exact_input_columns": 725 + } + }, + "saved_real_primitives_vs_four_horner_at_replacements": { + "backward": 88, + "forward": 88 + }, + "scope": "Historical PR626 JP8 scalar projections; finite graph class optimum only.", + "searched_nonunit_coefficients": 49, + "source_read_pareto": { + "all_submitted_shortest_witnesses_minimize_reads": true, + "coefficients": 49, + "common_nonunit_macro_overhead": [ + 3, + 1 + ], + "cost_coordinates": [ + "primitive_instructions", + "reads_of_unchanged_macro_source" + ], + "emitted_circuits_changed": false, + "graphs": [ + { + "coefficient": "1/8", + "edge_label_obligations": 53, + "label_certificate_sha256": "1389f622a8e9d68a4be6f8b4bdb68d4e83b7a4bd8d78f1dd012436a809707a2c", + "labels": 17, + "macro_frontier": [ + [ + 6, + 1 + ] + ], + "vertices": 17 + }, + { + "coefficient": "1/4", + "edge_label_obligations": 29, + "label_certificate_sha256": "e60ecc8be8a5837945b16fa982226293902dbe6eb7c5a3746d1857adaa57e9fc", + "labels": 9, + "macro_frontier": [ + [ + 5, + 1 + ] + ], + "vertices": 9 + }, + { + "coefficient": "3/8", + "edge_label_obligations": 207, + "label_certificate_sha256": "c387330dd64dce02783b88213a4793b198f1b673bdeceffc419f6ab9803c7c23", + "labels": 57, + "macro_frontier": [ + [ + 7, + 2 + ] + ], + "vertices": 49 + }, + { + "coefficient": "1/2", + "edge_label_obligations": 17, + "label_certificate_sha256": "2108c1eb57d439d19732a6601248d64e160379221c55c0339d13720e44b715c7", + "labels": 5, + "macro_frontier": [ + [ + 4, + 1 + ] + ], + "vertices": 5 + }, + { + "coefficient": "3/4", + "edge_label_obligations": 99, + "label_certificate_sha256": "aeccfa1f3a4de26e458c1d11425ff439f74edb69a3ae6ef4e00abf23f6937f22", + "labels": 27, + "macro_frontier": [ + [ + 6, + 2 + ] + ], + "vertices": 25 + }, + { + "coefficient": "5/4", + "edge_label_obligations": 171, + "label_certificate_sha256": "ab5a32cc7edde4be5b977b7a83b764542b27f6c7ad5b452e11cba927ecf3eeef", + "labels": 44, + "macro_frontier": [ + [ + 6, + 2 + ] + ], + "vertices": 41 + }, + { + "coefficient": "3/2", + "edge_label_obligations": 49, + "label_certificate_sha256": "5724d9c86c663ba1b59a7a7f37df9b9b2835316f6f496376a2e2f816826d9d52", + "labels": 13, + "macro_frontier": [ + [ + 5, + 2 + ] + ], + "vertices": 13 + }, + { + "coefficient": "7/4", + "edge_label_obligations": 236, + "label_certificate_sha256": "e69e77615a70533defd006a03f30ca549aea9509cfd09b5c7c8a5239bdadcd3c", + "labels": 60, + "macro_frontier": [ + [ + 7, + 3 + ] + ], + "vertices": 57 + }, + { + "coefficient": "2", + "edge_label_obligations": 19, + "label_certificate_sha256": "03928b20f860c2e0f5319daa1ee97dca684a0af6aff39059efe8fb5210d69564", + "labels": 5, + "macro_frontier": [ + [ + 4, + 1 + ] + ], + "vertices": 5 + }, + { + "coefficient": "9/4", + "edge_label_obligations": 429, + "label_certificate_sha256": "01693f3f6d16763e81b0185ee73d39de8341178e387e466ce93bc1eec5d18121", + "labels": 114, + "macro_frontier": [ + [ + 7, + 3 + ], + [ + 9, + 2 + ] + ], + "vertices": 73 + }, + { + "coefficient": "5/2", + "edge_label_obligations": 99, + "label_certificate_sha256": "7acb4dca7cf02343730f5b2e5328dc08b76c8967aeda99d209e92324d1bb5b77", + "labels": 27, + "macro_frontier": [ + [ + 6, + 3 + ], + [ + 7, + 2 + ] + ], + "vertices": 21 + }, + { + "coefficient": "11/4", + "edge_label_obligations": 538, + "label_certificate_sha256": "a0feff93b375d5b7b51d5af9463890e2fcf47b51de826f97c6a760abe398dc19", + "labels": 142, + "macro_frontier": [ + [ + 8, + 4 + ], + [ + 10, + 3 + ] + ], + "vertices": 89 + }, + { + "coefficient": "3", + "edge_label_obligations": 25, + "label_certificate_sha256": "8efe402b90956a464aa0c2576f270585bfdc13efd2f4c7505341b57b23d1de69", + "labels": 7, + "macro_frontier": [ + [ + 5, + 2 + ] + ], + "vertices": 7 + }, + { + "coefficient": "13/4", + "edge_label_obligations": 634, + "label_certificate_sha256": "07cf48fd74b7b54b021ae15423684e5b268103189ccd9a97294943de055cca4c", + "labels": 167, + "macro_frontier": [ + [ + 8, + 4 + ], + [ + 10, + 3 + ] + ], + "vertices": 105 + }, + { + "coefficient": "7/2", + "edge_label_obligations": 145, + "label_certificate_sha256": "691ad76d52d8bc22438babc4fb1a16590d4fe2e3ff8a20be06e733e534035e93", + "labels": 39, + "macro_frontier": [ + [ + 7, + 4 + ], + [ + 8, + 3 + ] + ], + "vertices": 29 + }, + { + "coefficient": "15/4", + "edge_label_obligations": 751, + "label_certificate_sha256": "b3690cda07c0843ff52dfb37923510ca8ffe6101f66ee9ef208e10bbf1336f84", + "labels": 197, + "macro_frontier": [ + [ + 9, + 5 + ], + [ + 11, + 3 + ] + ], + "vertices": 121 + }, + { + "coefficient": "4", + "edge_label_obligations": 35, + "label_certificate_sha256": "73c4622e9d69469f388a76aa5ede9861ad0d7846e9d731dedf38201d42ad9a90", + "labels": 9, + "macro_frontier": [ + [ + 5, + 1 + ] + ], + "vertices": 9 + }, + { + "coefficient": "17/4", + "edge_label_obligations": 834, + "label_certificate_sha256": "ad25921abb9f70123114cedb942db79c3fb26d334e5a4a26ac892b3633f4ddec", + "labels": 219, + "macro_frontier": [ + [ + 9, + 5 + ], + [ + 10, + 2 + ] + ], + "vertices": 137 + }, + { + "coefficient": "9/2", + "edge_label_obligations": 161, + "label_certificate_sha256": "d50f2b6fa34dd3660187078784de49d17cb3c76b82474657b5faf0d19d81620a", + "labels": 41, + "macro_frontier": [ + [ + 8, + 2 + ] + ], + "vertices": 37 + }, + { + "coefficient": "5", + "edge_label_obligations": 41, + "label_certificate_sha256": "b97df5b3b40e7aff08f0ecdcb9938775bde58eadef93172b007979541e9d6c9a", + "labels": 11, + "macro_frontier": [ + [ + 6, + 2 + ] + ], + "vertices": 11 + }, + { + "coefficient": "11/2", + "edge_label_obligations": 193, + "label_certificate_sha256": "f77259279655e52cf537c56e310294849f3e449d6d716f4b0e07c4400c2b4f26", + "labels": 49, + "macro_frontier": [ + [ + 9, + 3 + ] + ], + "vertices": 45 + }, + { + "coefficient": "6", + "edge_label_obligations": 51, + "label_certificate_sha256": "8394d5b6a3178034126f8c7d432ad1bcea5f2cd6ce8727eeda75bc13f4e27792", + "labels": 13, + "macro_frontier": [ + [ + 6, + 2 + ] + ], + "vertices": 13 + }, + { + "coefficient": "13/2", + "edge_label_obligations": 225, + "label_certificate_sha256": "05c7b5304369a7782f359895e42f290b512401b61236f38dcd8616b5b4b71b00", + "labels": 57, + "macro_frontier": [ + [ + 9, + 3 + ] + ], + "vertices": 53 + }, + { + "coefficient": "7", + "edge_label_obligations": 57, + "label_certificate_sha256": "2cb2f1dd90e352306cd60a577cac82d705fa5ac023e7c3bc5ddadebff05fa865", + "labels": 15, + "macro_frontier": [ + [ + 7, + 3 + ] + ], + "vertices": 15 + }, + { + "coefficient": "15/2", + "edge_label_obligations": 257, + "label_certificate_sha256": "4ff00d4c27bb56a89189d3599f6909d845f8c46b08d8f96e4a0a53f43bb6ca15", + "labels": 65, + "macro_frontier": [ + [ + 10, + 3 + ] + ], + "vertices": 61 + }, + { + "coefficient": "31/4", + "edge_label_obligations": 1102, + "label_certificate_sha256": "8a5a636661a52395b548b8eb65ebeb53c0abfd93c7a6b26e21a7a39a95394ce0", + "labels": 276, + "macro_frontier": [ + [ + 12, + 3 + ] + ], + "vertices": 249 + }, + { + "coefficient": "8", + "edge_label_obligations": 67, + "label_certificate_sha256": "81a33a24c9cf15c025cf7e45b1e0577592543c8a4875f1a9fe3309a0926a7cea", + "labels": 17, + "macro_frontier": [ + [ + 6, + 1 + ] + ], + "vertices": 17 + }, + { + "coefficient": "17/2", + "edge_label_obligations": 289, + "label_certificate_sha256": "db4beb2807ae37ec90fd70efa90f36e539ada386b6b25360befb3836be86b03d", + "labels": 73, + "macro_frontier": [ + [ + 9, + 2 + ] + ], + "vertices": 69 + }, + { + "coefficient": "9", + "edge_label_obligations": 73, + "label_certificate_sha256": "afae1a1a648b64b17df8c57cc0b9ace09aabadbebb367347055a9c387565791c", + "labels": 19, + "macro_frontier": [ + [ + 7, + 2 + ] + ], + "vertices": 19 + }, + { + "coefficient": "10", + "edge_label_obligations": 83, + "label_certificate_sha256": "7f7e5f346ab716d9258c41610d69aae3e8aeed6e3f27ecc3806b35aab9d17e12", + "labels": 21, + "macro_frontier": [ + [ + 7, + 2 + ] + ], + "vertices": 21 + }, + { + "coefficient": "11", + "edge_label_obligations": 89, + "label_certificate_sha256": "82426b9c86a70f1c8c93e6fd2672ef3a1551f36f01cdf35df7cb7770295fdea4", + "labels": 23, + "macro_frontier": [ + [ + 8, + 3 + ] + ], + "vertices": 23 + }, + { + "coefficient": "12", + "edge_label_obligations": 99, + "label_certificate_sha256": "e0847dc27bd30b794f77395a94d1d6e8d9086d8e7d2f7ae87a1bab20f4969bda", + "labels": 25, + "macro_frontier": [ + [ + 7, + 2 + ] + ], + "vertices": 25 + }, + { + "coefficient": "15", + "edge_label_obligations": 121, + "label_certificate_sha256": "6bf4f83a28156f3d7102db4fd6627bba6928093ae9efed6fbd599a6c32f34479", + "labels": 31, + "macro_frontier": [ + [ + 9, + 3 + ] + ], + "vertices": 31 + }, + { + "coefficient": "31/2", + "edge_label_obligations": 513, + "label_certificate_sha256": "c2bb594f24ad8cf3539103f711140aace02511b37ca6e7dd5145fe4dcc8da47a", + "labels": 129, + "macro_frontier": [ + [ + 11, + 3 + ] + ], + "vertices": 125 + }, + { + "coefficient": "16", + "edge_label_obligations": 131, + "label_certificate_sha256": "ee397b3ffb1bd94097cd475c951f7ff56569b2042130c0c4f3e518af4370b53a", + "labels": 33, + "macro_frontier": [ + [ + 7, + 1 + ] + ], + "vertices": 33 + }, + { + "coefficient": "20", + "edge_label_obligations": 163, + "label_certificate_sha256": "3682d87bba58e26f814083d40d608345d07de96827936018268d617480670a5b", + "labels": 41, + "macro_frontier": [ + [ + 8, + 2 + ] + ], + "vertices": 41 + }, + { + "coefficient": "24", + "edge_label_obligations": 195, + "label_certificate_sha256": "bfe204ca2951ec261687afcaff3a61ca7995db2dc78be3ef5f782bb499a101f8", + "labels": 49, + "macro_frontier": [ + [ + 8, + 2 + ] + ], + "vertices": 49 + }, + { + "coefficient": "32", + "edge_label_obligations": 259, + "label_certificate_sha256": "717f7225d7328966482a52a7e4cfc7243bb2ecb3dd59812c054646188f77ecc0", + "labels": 65, + "macro_frontier": [ + [ + 8, + 1 + ] + ], + "vertices": 65 + }, + { + "coefficient": "79/2", + "edge_label_obligations": 1281, + "label_certificate_sha256": "71571c23a2fa4bd33c50b8013fa305d078584ea5fb60f2d208c6afad50b1f68e", + "labels": 321, + "macro_frontier": [ + [ + 13, + 4 + ] + ], + "vertices": 317 + }, + { + "coefficient": "48", + "edge_label_obligations": 387, + "label_certificate_sha256": "604893b45ec734e52495e462cb8d06ec9c3c1bde2601a9d5730d69168c2f29b4", + "labels": 97, + "macro_frontier": [ + [ + 9, + 2 + ] + ], + "vertices": 97 + }, + { + "coefficient": "54", + "edge_label_obligations": 435, + "label_certificate_sha256": "ca1c2a410a3293339ff6ddebc70a9b32f5eaa7cf5766e6d692f5df35e32accc8", + "labels": 109, + "macro_frontier": [ + [ + 11, + 3 + ] + ], + "vertices": 109 + }, + { + "coefficient": "60", + "edge_label_obligations": 483, + "label_certificate_sha256": "f41aa9e7fa95d6d1e13cc6665e0d9ddefec7831514b3d1333c19e0feeb431bf8", + "labels": 121, + "macro_frontier": [ + [ + 10, + 2 + ] + ], + "vertices": 121 + }, + { + "coefficient": "64", + "edge_label_obligations": 515, + "label_certificate_sha256": "18a775b1aefa59263ac0b1af7727f434ae170c78c1d2f84f90b59aaf06f5cd2b", + "labels": 129, + "macro_frontier": [ + [ + 9, + 1 + ] + ], + "vertices": 129 + }, + { + "coefficient": "72", + "edge_label_obligations": 579, + "label_certificate_sha256": "34061687ae799ab5170c740913f1c570e75f8d4d04bc48e296df32f8f546cd6b", + "labels": 145, + "macro_frontier": [ + [ + 10, + 2 + ] + ], + "vertices": 145 + }, + { + "coefficient": "79", + "edge_label_obligations": 633, + "label_certificate_sha256": "689d98dc667394df6a3d6f147b38e50350c28a33bc5724351cfac0b6e67cc0ec", + "labels": 159, + "macro_frontier": [ + [ + 12, + 4 + ] + ], + "vertices": 159 + }, + { + "coefficient": "80", + "edge_label_obligations": 643, + "label_certificate_sha256": "a4d7dd2846bb4bddaa2c9b54309d5aac43e0dc792fbb8785ea3f2df1b5e69589", + "labels": 161, + "macro_frontier": [ + [ + 10, + 2 + ] + ], + "vertices": 161 + }, + { + "coefficient": "96", + "edge_label_obligations": 771, + "label_certificate_sha256": "562a6d5adb075497c3357b66735f50be4eebfc8801f7a2658e5bdce8171b483b", + "labels": 193, + "macro_frontier": [ + [ + 10, + 2 + ] + ], + "vertices": 193 + }, + { + "coefficient": "108", + "edge_label_obligations": 867, + "label_certificate_sha256": "e4cba7fe38b8fa7757f50782da80ec99946c523da355c493e4f674363a39a93e", + "labels": 217, + "macro_frontier": [ + [ + 12, + 3 + ] + ], + "vertices": 217 + }, + { + "coefficient": "120", + "edge_label_obligations": 963, + "label_certificate_sha256": "717b4f28cfe94b3ef19e55325262536cd59c05b8c1fe50edfb57979c3b9e7031", + "labels": 241, + "macro_frontier": [ + [ + 11, + 2 + ] + ], + "vertices": 241 + } + ], + "hypothetical_sensitivity": { + "breakpoints": [ + "1/3", + "1", + "2" + ], + "current_schedule_break_even": "26/23", + "current_schedule_gain_vs_696": "104 - 92*p per orientation", + "endpoint_rule": "Intervals describe interiors; adjacent choices tie at a breakpoint; p=0 uses the first.", + "intervals": [ + { + "choices": { + "11/4": [ + 8, + 4 + ], + "13/4": [ + 8, + 4 + ], + "15/4": [ + 9, + 5 + ], + "17/4": [ + 9, + 5 + ], + "5/2": [ + 6, + 3 + ], + "7/2": [ + 7, + 4 + ], + "9/4": [ + 7, + 3 + ] + }, + "delta_instructions_source_reads_vs_696": { + "backward": [ + -104, + 92 + ], + "forward": [ + -104, + 92 + ] + }, + "lower": "0", + "upper": "1/3" + }, + { + "choices": { + "11/4": [ + 8, + 4 + ], + "13/4": [ + 8, + 4 + ], + "15/4": [ + 9, + 5 + ], + "17/4": [ + 10, + 2 + ], + "5/2": [ + 6, + 3 + ], + "7/2": [ + 7, + 4 + ], + "9/4": [ + 7, + 3 + ] + }, + "delta_instructions_source_reads_vs_696": { + "backward": [ + -102, + 86 + ], + "forward": [ + -102, + 86 + ] + }, + "lower": "1/3", + "upper": "1" + }, + { + "choices": { + "11/4": [ + 8, + 4 + ], + "13/4": [ + 8, + 4 + ], + "15/4": [ + 11, + 3 + ], + "17/4": [ + 10, + 2 + ], + "5/2": [ + 7, + 2 + ], + "7/2": [ + 8, + 3 + ], + "9/4": [ + 7, + 3 + ] + }, + "delta_instructions_source_reads_vs_696": { + "backward": [ + -16, + 0 + ], + "forward": [ + -16, + 0 + ] + }, + "lower": "1", + "upper": "2" + }, + { + "choices": { + "11/4": [ + 10, + 3 + ], + "13/4": [ + 10, + 3 + ], + "15/4": [ + 11, + 3 + ], + "17/4": [ + 10, + 2 + ], + "5/2": [ + 7, + 2 + ], + "7/2": [ + 8, + 3 + ], + "9/4": [ + 9, + 2 + ] + }, + "delta_instructions_source_reads_vs_696": { + "backward": [ + 0, + -8 + ], + "forward": [ + 0, + -8 + ] + }, + "lower": "2", + "upper": null + } + ], + "lower_read_15_over_4_prior_art": "Bounded signed-Horner word credited to PR734; no new construction claim.", + "model": "instructions + p * source_reads; p >= 0 is hypothetical additional overhead", + "physical_price_claimed": false + }, + "negative_controls": { + "forged_source_reads": "Pareto witness source-read count", + "missing_lower_read_tradeoff": "Pareto edge closure", + "uncharged_initial_copy": "Pareto macro initial copy", + "wrong_magnitude_bound": "Pareto declared bound" + }, + "selected_frontiers": [ + { + "coefficient": "9/4", + "comparators": { + "binary-forward": { + "instructions": 9, + "source_reads": 2, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 8, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 9, + "source_reads": 2, + "within_grid": true, + "within_magnitude": true + }, + "naf-reverse": { + "instructions": 8, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 7, + "macro_source_reads": 3, + "operations": [ + "halve", + "halve", + "add", + "add" + ], + "preparation_instructions": 4, + "preparation_source_reads": 2 + }, + { + "end_sign": 1, + "macro_instructions": 9, + "macro_source_reads": 2, + "operations": [ + "double", + "double", + "double", + "add", + "halve", + "halve" + ], + "preparation_instructions": 6, + "preparation_source_reads": 1 + } + ], + "occurrences": { + "backward": 2, + "forward": 2 + } + }, + { + "coefficient": "5/2", + "comparators": { + "binary-forward": { + "instructions": 7, + "source_reads": 2, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 7, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 7, + "source_reads": 2, + "within_grid": true, + "within_magnitude": true + }, + "naf-reverse": { + "instructions": 7, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 6, + "macro_source_reads": 3, + "operations": [ + "halve", + "add", + "add" + ], + "preparation_instructions": 3, + "preparation_source_reads": 2 + }, + { + "end_sign": 1, + "macro_instructions": 7, + "macro_source_reads": 2, + "operations": [ + "double", + "double", + "add", + "halve" + ], + "preparation_instructions": 4, + "preparation_source_reads": 1 + } + ], + "occurrences": { + "backward": 25, + "forward": 25 + } + }, + { + "coefficient": "11/4", + "comparators": { + "binary-forward": { + "instructions": 10, + "source_reads": 3, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 9, + "source_reads": 3, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 11, + "source_reads": 3, + "within_grid": true, + "within_magnitude": false + }, + "naf-reverse": { + "instructions": 11, + "source_reads": 3, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 8, + "macro_source_reads": 4, + "operations": [ + "halve", + "add", + "halve", + "add", + "add" + ], + "preparation_instructions": 5, + "preparation_source_reads": 3 + }, + { + "end_sign": 1, + "macro_instructions": 10, + "macro_source_reads": 3, + "operations": [ + "double", + "double", + "double", + "subtract", + "halve", + "halve", + "add" + ], + "preparation_instructions": 7, + "preparation_source_reads": 2 + } + ], + "occurrences": { + "backward": 1, + "forward": 1 + } + }, + { + "coefficient": "13/4", + "comparators": { + "binary-forward": { + "instructions": 10, + "source_reads": 3, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 9, + "source_reads": 3, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 11, + "source_reads": 3, + "within_grid": true, + "within_magnitude": true + }, + "naf-reverse": { + "instructions": 11, + "source_reads": 3, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 8, + "macro_source_reads": 4, + "operations": [ + "halve", + "halve", + "add", + "add", + "add" + ], + "preparation_instructions": 5, + "preparation_source_reads": 3 + }, + { + "end_sign": 1, + "macro_instructions": 10, + "macro_source_reads": 3, + "operations": [ + "double", + "double", + "double", + "add", + "halve", + "halve", + "add" + ], + "preparation_instructions": 7, + "preparation_source_reads": 2 + } + ], + "occurrences": { + "backward": 1, + "forward": 1 + } + }, + { + "coefficient": "7/2", + "comparators": { + "binary-forward": { + "instructions": 8, + "source_reads": 3, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 8, + "source_reads": 3, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 8, + "source_reads": 2, + "within_grid": true, + "within_magnitude": false + }, + "naf-reverse": { + "instructions": 9, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 7, + "macro_source_reads": 4, + "operations": [ + "halve", + "add", + "add", + "add" + ], + "preparation_instructions": 4, + "preparation_source_reads": 3 + }, + { + "end_sign": 1, + "macro_instructions": 8, + "macro_source_reads": 3, + "operations": [ + "double", + "double", + "add", + "halve", + "add" + ], + "preparation_instructions": 5, + "preparation_source_reads": 2 + } + ], + "occurrences": { + "backward": 10, + "forward": 10 + } + }, + { + "coefficient": "15/4", + "comparators": { + "binary-forward": { + "instructions": 11, + "source_reads": 4, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 10, + "source_reads": 4, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 10, + "source_reads": 2, + "within_grid": true, + "within_magnitude": false + }, + "naf-reverse": { + "instructions": 10, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 9, + "macro_source_reads": 5, + "operations": [ + "halve", + "add", + "halve", + "add", + "add", + "add" + ], + "preparation_instructions": 6, + "preparation_source_reads": 4 + }, + { + "end_sign": 1, + "macro_instructions": 11, + "macro_source_reads": 3, + "operations": [ + "double", + "double", + "double", + "subtract", + "double", + "add", + "halve", + "halve" + ], + "preparation_instructions": 8, + "preparation_source_reads": 2 + } + ], + "occurrences": { + "backward": 4, + "forward": 4 + } + }, + { + "coefficient": "17/4", + "comparators": { + "binary-forward": { + "instructions": 10, + "source_reads": 2, + "within_grid": true, + "within_magnitude": true + }, + "binary-reverse": { + "instructions": 10, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + }, + "naf-forward": { + "instructions": 10, + "source_reads": 2, + "within_grid": true, + "within_magnitude": true + }, + "naf-reverse": { + "instructions": 10, + "source_reads": 2, + "within_grid": false, + "within_magnitude": true + } + }, + "frontier": [ + { + "end_sign": 1, + "macro_instructions": 9, + "macro_source_reads": 5, + "operations": [ + "halve", + "halve", + "add", + "add", + "add", + "add" + ], + "preparation_instructions": 6, + "preparation_source_reads": 4 + }, + { + "end_sign": 1, + "macro_instructions": 10, + "macro_source_reads": 2, + "operations": [ + "double", + "double", + "double", + "double", + "add", + "halve", + "halve" + ], + "preparation_instructions": 7, + "preparation_source_reads": 1 + } + ], + "occurrences": { + "backward": 1, + "forward": 1 + } + } + ], + "selected_occurrence_totals_both_real_components": { + "backward": { + "best-four-min-read-cost-tie": [ + 678, + 180 + ], + "best-four-stable": [ + 678, + 200 + ], + "binary-forward": [ + 694, + 216 + ], + "binary-reverse": [ + 678, + 216 + ], + "current": [ + 590, + 308 + ], + "naf-forward": [ + 690, + 180 + ], + "naf-reverse": [ + 706, + 180 + ], + "original-binary": [ + 782, + 216 + ] + }, + "forward": { + "best-four-min-read-cost-tie": [ + 678, + 180 + ], + "best-four-stable": [ + 678, + 200 + ], + "binary-forward": [ + 694, + 216 + ], + "binary-reverse": [ + 678, + 216 + ], + "current": [ + 590, + 308 + ], + "naf-forward": [ + 690, + 180 + ], + "naf-reverse": [ + 706, + 180 + ], + "original-binary": [ + 782, + 216 + ] + } + }, + "state_totals": { + "edge_label_obligations": 16096, + "labels": 4104, + "vertices": 3703 + }, + "status": "PASS_JP8_PARETO_SOURCE_READS" + }, + "status": "PASS_JP8_GRID_BOUNDED_SYNTHESIS" +} diff --git a/research/jp8-grid-bounded-synthesis/NOTICE.md b/research/jp8-grid-bounded-synthesis/NOTICE.md new file mode 100644 index 0000000000..326b5781cf --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/NOTICE.md @@ -0,0 +1,19 @@ +# Attribution and license + +New files: prepared for Philipp (@mightyOil), with substantial OpenAI Codex +assistance. Apache-2.0, under the repository's LICENSE and NOTICE. + +`vendor/pr837/lower.py` is verbatim Gareth Davidson (@bitplane), PR837 at +`0a2977195efc8fb2a918fbfb694ec8d294387f08`, with its original AI disclosure. +Its `vendor/pr696_lower.py` is verbatim Sagar Thakrar (@thakrarsagar), PR696 at +`5a3f983715027c4fd83f50bc9001d4b18463bed1`, as accepted in +`research/complex-dyadic-lowering/lower.py`. These sources are Apache-2.0. + +The source and scalar/primitive lineage remains credited to icekylinx, +Jeremy Kothe / AtomScout (PR622), Chafik Boukhalfa (PR626), DreamingOfClouds, +Rohan Arun, eumemic and all predecessors in their retained repository notices. +Signed-digit comparisons credit PR723, PR734 and PR787. The related PR866 +fractional-grid audit is credited explicitly in the README and proof. + +Both independent algorithm implementations and their review were AI-assisted; +no independent human mathematical review or full formal proof is claimed. diff --git a/research/jp8-grid-bounded-synthesis/OVERLAP.json b/research/jp8-grid-bounded-synthesis/OVERLAP.json new file mode 100644 index 0000000000..9c849ba4dc --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/OVERLAP.json @@ -0,0 +1,234 @@ +{ + "checked_at": "2026-10-13T09:37:56.703666+00:00", + "initial_open_prs": 669, + "final_open_prs": 672, + "base_still_current": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "pinned_sprint_issues": [], + "recent_metadata_refreshed": 60, + "latest_number_observed": 880, + "new_prs_since_initial": [ + { + "number": 880, + "title": "Research/r439 block1 schedule seed8", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/880", + "headRefOid": "554532392ae15ef3c2e90050df3a90a4d0ac573e", + "updatedAt": "2026-10-13T09:31:31Z" + }, + { + "number": 879, + "title": "Independent verification: exact synthetic-transform physical layouts (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/879", + "headRefOid": "12012c9478d121d6d404a0d94e446016e3f51a2e", + "updatedAt": "2026-10-13T09:29:54Z" + }, + { + "number": 878, + "title": "[Lean] Verify selected PR589 B boundaries and XOR interfaces", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/878", + "headRefOid": "7b3241566ddfd50548e6b113ede9333826b86313", + "updatedAt": "2026-10-13T09:25:59Z" + }, + { + "number": 877, + "title": "Research audit: quartic precision for balanced dirty cyclic inverses (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/877", + "headRefOid": "80a60c0da2b916798167deb0ce3a5ef22fda147a", + "updatedAt": "2026-10-13T09:20:29Z" + } + ], + "related": { + "696": { + "title": "Research: lower selected complex scalar primitives by 22\u201325% (no new kappa)", + "head": "5a3f983715027c4fd83f50bc9001d4b18463bed1", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/696", + "relation": "Accepted binary copy/unit lowering; baseline dependency." + }, + "734": { + "title": "Research: prefix-bounded signed-Horner circuits for CK and JP8 (no new kappa)", + "head": "ba76ba3321d000c8996b0b254bcf0d7260e1bbb6", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/734", + "relation": "Bounded integer signed-Horner graph; excludes arbitrary interleaved halves and repeated reads." + }, + "837": { + "title": "Research: bidirectional Horner saves 312 SW4 primitives per orientation (no new kappa)", + "head": "0a2977195efc8fb2a918fbfb694ec8d294387f08", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/837", + "relation": "Four binary/NAF Horner comparator words, pinned and vendored verbatim." + }, + "866": { + "title": "Research audit: CK Horner reversal raises scalar-grid guard from 3 to 5 bits (no new kappa)", + "head": "5ae580bf68516f1cbe3b2dd3cb646be55170288f", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/866", + "relation": "Exact fractional-grid audit; motivates preserving original guard." + }, + "811": { + "title": "Research: JP8 additive coefficient routes save 2,784 beyond rescaling (no new kappa)", + "head": "b5c244c916dd0b30957332edad7ae7ae22b0eb9d", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/811", + "relation": "Shares coefficient work across JP8 macros; no composition asserted." + }, + "860": { + "title": "Research construction: signed CK reuse saves 926 primitives", + "head": "72899c888af7e171f8aba4d5c66f4b31a5719eba", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/860", + "relation": "Signed CK inter-macro routes; different provider and scratch boundary." + }, + "750": { + "title": "Research: save 62 CK primitives per orientation by relocating one scale (no new kappa)", + "head": "b6d6934092c063ab2575ebee00f48bbc7b1c9d82", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/750", + "relation": "Completed CK scale relocation class; rejected candidate track." + }, + "876": { + "title": "Scoped negative result: simultaneous full pair/triple exchanges do not beat SW4 (seed 29)", + "head": "0d8d4be2b8093e809c4c422849c486532f6ee1c1", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/876", + "relation": "SW4 pair/triple exchange search; rejected candidate track." + }, + "864": { + "title": "Scoped negative result: no frame reassignment of the selected X4 complex word admits the next tick (exact duals, no new kappa)", + "head": "9b1a55f6d281ae5bd7d691977d38861fcd9bd015", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/864", + "relation": "Fixed X4 frame reassignment exclusion; separate geometric class." + } + }, + "assessment": "No duplicate of the seven local grid-preserving JP8 circuits found. General shift/add synthesis is not claimed as novel; finite words, exact class optima, all-column substitution and guard evidence are the contribution.", + "continuation_refresh": { + "checked_at": "2026-10-13T10:26:56.873793+00:00", + "base_still_current": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "open_prs": 682, + "recent_metadata_refreshed": 70, + "latest_number_observed": 888, + "pinned_sprint_issues": [], + "existing_submission": { + "number": 882, + "headRefOid": "ec287f261b91b31c694991a1d18ca2f9b052f28d", + "title": "Research construction: seven grid-preserving JP8 circuits save 104 primitives per orientation (no new kappa)", + "state": "OPEN", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/882" + }, + "dependency_heads_rechecked": { + "622": "f69477f4f6d3c7eb1f740b166881bffed4ffa9f6", + "626": "660de893d27bb7abd1d5b01b1640207528a5c851", + "696": "5a3f983715027c4fd83f50bc9001d4b18463bed1", + "734": "ba76ba3321d000c8996b0b254bcf0d7260e1bbb6", + "837": "0a2977195efc8fb2a918fbfb694ec8d294387f08", + "866": "5ae580bf68516f1cbe3b2dd3cb646be55170288f", + "811": "b5c244c916dd0b30957332edad7ae7ae22b0eb9d", + "860": "72899c888af7e171f8aba4d5c66f4b31a5719eba" + }, + "new_prs": [ + { + "number": 888, + "title": "Research: Gaussian nonlinear message copy floor 40b under explicit width pricing", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/888", + "headRefOid": "8c9964b7ab4419409d20762c8d78591701008d04", + "updatedAt": "2026-10-13T10:21:37Z", + "relation": "Gaussian nonlinear block-message copy floor; different decoder model." + }, + { + "number": 887, + "title": "[Lean] Prove reserved-scratch echo bounds and equality family (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/887", + "headRefOid": "5b14b7a0a7443421cfc719ccec1ac909ddf34c3e", + "updatedAt": "2026-10-13T10:15:20Z", + "relation": "Reserved-scratch echo grammar formalization; different recursive interface." + }, + { + "number": 886, + "title": "Scoped negative result: PR589's bit word is exactly frame-optimal (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/886", + "headRefOid": "881f72ec596a5c6d7aba801153792292ecc39737", + "updatedAt": "2026-10-13T10:05:07Z", + "relation": "PR589 bit frame-only optimality; different supplier and graph." + }, + { + "number": 885, + "title": "[Lean] Prove the selected PR799 native Real moment bound", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/885", + "headRefOid": "0181d0f2e00278535f435968f000d7e2ec4b93aa", + "updatedAt": "2026-10-13T10:01:44Z", + "relation": "Selected native-complex moment Lean formalization; different obligation." + }, + { + "number": 884, + "title": "Research construction: R439 frame-521 block, 47 to 31 ADDs (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/884", + "headRefOid": "35992d6721583d642465b1ad6dabd58dfc0cc77a", + "updatedAt": "2026-10-13T09:59:47Z", + "relation": "Bit-side R439 frame-521 block factorization; different supplier." + }, + { + "number": 883, + "title": "Research construction: four-primitive X4 preconditions save 784 per orientation (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/883", + "headRefOid": "b31a870a3842b37f6ab97767c506ce91783632a2", + "updatedAt": "2026-10-13T09:40:02Z", + "relation": "Selected X4 two-register precondition fusion; distinct from historical JP8 single-coefficient macros. No savings composition asserted." + }, + { + "number": 881, + "title": "Independent verification: PR869's U8 word and \u03ba with a code-disjoint checker (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/881", + "headRefOid": "2730da199c4dad53b52b32b6be8ed6328f014648", + "updatedAt": "2026-10-13T09:34:23Z", + "relation": "Independent U8 word verifier; different source and physical obligations." + } + ], + "assessment": "No duplicate of this historical JP8 single-macro construction, independent integer replay or same-graph source-read Pareto audit found. Continue the existing PR882 only; submitted circuits and selected frontier remain unchanged." + }, + "pre_update_refresh": { + "checked_at": "2026-10-13T10:39:21.573041+00:00", + "base_still_current": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "all_eight_dependency_heads_unchanged": true, + "open_prs": 685, + "latest_number_observed": 893, + "recent_metadata_refreshed": 30, + "pinned_sprint_issues": [], + "existing_pr_reviews": [], + "existing_pr_comments": [], + "new_prs": [ + { + "number": 893, + "title": "Independently audit PR236 source commands and recorded axiom evidence", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/893", + "headRefOid": "5d8c2e96e0624efbadb182d9ee0a09ee65b70b48", + "updatedAt": "2026-10-13T10:37:22Z", + "relation": "Recorded Lean source-command/axiom audit; unrelated finite evidence obligation." + }, + { + "number": 892, + "title": "Research: rank-eight coded-helper endpoint and complete mixed-cost obstruction (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/892", + "headRefOid": "9778ba2d891468996b81eb50c389bb4169df0025", + "updatedAt": "2026-10-13T10:35:52Z", + "relation": "Rank-eight coded-helper endpoint and mixed-cost obstruction; different helper lifetime and native program." + }, + { + "number": 891, + "title": "Research construction: R439 phase-B blocks 506/523 to 24/39 ADDs + certified single-write class boundaries (no new kappa)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/891", + "headRefOid": "645fb93fcd21b86aca7e2bf81582be5c62411b27", + "updatedAt": "2026-10-13T10:26:59Z", + "relation": "Bit-side R439 phase-B block shortening and class survey; different supplier." + }, + { + "number": 890, + "title": "Conditional \u03ba = 0.001661957774647029: T21 whole-owner packing and fixed-family bound", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/890", + "headRefOid": "61b71bcf5a34db70220da81fa978d5b0c7bbb008", + "updatedAt": "2026-10-13T10:26:05Z", + "relation": "Conditional U8 whole-owner packing and fixed-family bound; different supplier/owner program. An open bound claim is not the selected accepted frontier." + }, + { + "number": 889, + "title": "Research: batch common-factor product shears with dirty restoration", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/889", + "headRefOid": "e2021d1c9e06948528cbc0a8fd7079b671da981d", + "updatedAt": "2026-10-13T10:25:49Z", + "relation": "Dirty shared-factor output-shear batches; recursive multi-output interface, not single JP8 scalar macros." + } + ], + "assessment": "No duplicate of the same historical JP8 single-macro construction or its independent scalar/Pareto verification found. Update existing PR882 only." + } +} diff --git a/research/jp8-grid-bounded-synthesis/PROOF.md b/research/jp8-grid-bounded-synthesis/PROOF.md new file mode 100644 index 0000000000..e1f319f1d1 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/PROOF.md @@ -0,0 +1,506 @@ +# Proof and scope of the grid-bounded coefficient search + +This note concerns the frozen historical PR626 JP8 scalar event streams. It +does not modify the selected supplier or establish a new multiplication +constant. The claim is a finite circuit result in the explicitly defined +single-work-register class below. The executable certificate and independent +checker supply the finite coverage evidence; this note explains why those +checks establish that claim. + +## 1. Register contract and admissible words + +An addition macro with nonzero dyadic coefficient + +\[ +q=\sigma a/d,\qquad \sigma\in\{-1,1\},\quad a>0,\quad +d=2^k,\quad \gcd(a,d)=1 +\] + +has the complete boundary map + +\[ +(T,S,W)\longmapsto(T+qS,S,0). +\] + +The three registers are distinct. Their incoming values are arbitrary and +may be correlated; in particular, `W` is not assumed initially zero. The +source and target stay untouched while the coefficient is prepared. A word +in the searched class consists of: + +1. One paid copy `W <- S`. +2. Any finite sequence of `W <- W + S`, `W <- W - S`, + `W <- 2 W`, `W <- W/2`, or `W <- -W`. +3. One signed target accumulation, using the final `W`. +4. One paid clear `W <- 0`. + +At every preparation prefix, including immediately after the copy, +`W = c S` for a dyadic `c` satisfying + +\[ +c\in d^{-1}\mathbb Z,\qquad |c|\le a. +\] + +The terminal coefficient is either `a/d` or `-a/d`. If it is +`epsilon * a/d`, the target update uses sign `sigma * epsilon`. This makes +the final map exactly the displayed contract for either sign of `q`. + +Here the bound is on the **magnitude of the coefficient** `|c|`, not on the +reduced numerator of `c` and not on the scaled graph coordinate defined +below. The source range is reduced `a <= 127`, `d <= 16`; the actual corpus +contains 49 nonunit absolute coefficients. The coefficient `|q| = 1` uses +the established direct circuit `T <- T +/- S; W <- 0`, costing two +primitives. Its special two-instruction circuit is outside the mandatory +copy/preparation/accumulation/clear form. + +Every instruction uses the macro's original frame. No source modification, +source restoration, extra register, helper, frame transition, recursive +child, or transfer of work across macro boundaries is allowed in this +search. The optimality claim does not cover circuits allowing any of those +operations, multiple target updates, different initialization, or a larger +grid or magnitude envelope. + +## 2. Exact finite graph + +Write `c = m/d`. The vertex set, initial vertex and terminal set are + +\[ +V_{a,d}=\{-ad,-ad+1,\ldots,ad\},\qquad m_0=d,\qquad +G=\{-a,a\}. +\] + +There is a unit-cost directed edge for each admitted operation: + +| Work instruction | Graph edge | Additional condition | +| --- | --- | --- | +| `W += S` | `m -> m+d` | destination belongs to `V` | +| `W -= S` | `m -> m-d` | destination belongs to `V` | +| double | `m -> 2m` | destination belongs to `V` | +| halve | `m -> m/2` | `m` is even and destination belongs to `V` | +| negate | `m -> -m` | destination belongs to `V` | + +The parity condition is necessary: halving an odd `m` would produce a +coefficient on a strictly finer grid. Halving can be legal when the source +happens to have special divisibility, but such input-dependent shortcuts +are deliberately excluded: the macro must work for arbitrary source input. + +Induction on instructions gives a cost-preserving correspondence between +admissible preparation words and directed walks from `d` to `G`. The +graph therefore contains every preparation word in the stated class, not +merely binary, signed-digit or monotone words. Conversely, each graph edge +is one legal primitive. Removing a repeated-vertex cycle never increases +cost; hence the finite graph suffices even though words of unbounded length +are allowed. There are `2ad+1` vertices, at most 4,065 under the stated +parameter bounds. + +If `L(a,d)` is the shortest distance from `d` to `G`, the optimal nonunit +macro cost in this class is exactly + +\[ +C(a,d)=1+L(a,d)+1+1=L(a,d)+3. +\] + +The three charged instructions outside the graph are initialization, +target accumulation and final clearing. Source additions and subtractions, +doublings, halvings and negations each cost one, even if a particular +implementation could combine them. Complex streams execute the same real +coefficient circuit on their real and imaginary components, so their +charged cost is twice the real-component cost. + +## 3. Independently checkable optimality certificate + +Breadth-first search with unit edge weights finds a shortest witness. The +independent checker does not import that search. It enumerates every vertex +and successor, computes a potential by synchronous Bellman relaxation from +both goals, and checks the following conditions over the entire graph: + +* `h(v)` is a nonnegative integer and is zero exactly on `G`. +* Every directed edge `v -> w` satisfies `h(v) <= 1 + h(w)`. +* Every nongoal has a successor with `h(w) = h(v)-1`. + +For any walk `v_0,...,v_l` ending at a goal, telescoping the edge inequality +gives `h(v_0) <= l`. Following decreasing successors gives a walk of +exactly `h(v_0)` edges to a zero-potential goal. Thus these checks establish +the exact distance at every vertex, including `v_0=d`. Replaying the +submitted instruction sequence separately checks that it attains that +distance with its claimed terminal sign. Duplicate operations leading to +the same successor and self-loops do not change a unit-cost shortest path. + +Coverage requires the coefficient census as well as graph checks. Extract +the reduced absolute coefficients from **both** frozen JP8 orientations, +filter by `a <= 127` and `d <= 16`, and compare that set to the certificate +entries. There are 50 absolute coefficients including the special unit, +100 signed coefficients in their union, and 90 signed coefficients in each +orientation. The filtered occurrence counts are 21,566 forward and 21,574 +backward, out of 22,211 and 22,219 additions respectively. A seed may order +this finite corpus; it cannot replace complete coverage. + +## 4. Endpoint substitution and exact arithmetic cost + +After initialization, the invariant `W=cS` follows directly from the five +instruction rules. The chosen signed accumulation gives the required +target value; the source is unchanged and the final clear erases any work. +The initialization overwrites arbitrary incoming private dirt. This is a +three-register linear identity, so checking independent formal input +columns proves it for all real inputs, including correlated inputs. Applying +the identity to both components proves it for complex inputs as well. + +Replace a scalar macro only by a word with the same complete boundary map. +Induction over the unchanged event stream preserves every later macro's +inputs and the complete scalar endpoint. Reuse of the existing scratch is +valid because every replacement clears it at the boundary. Frames, child +calls, adapters and paid-event inventories are untouched by this local +substitution; their inherited physical interpretation is a separate matter. + +The reference original binary-Horner cost per real component is + +\[ +B(a,d)=3+\lfloor\log_2 a\rfloor+\operatorname{popcount}(a)+k. +\] + +It pays one initial clear, the leading source addition, all binary shifts +and remaining source additions, `k` halvings, the signed target accumulation, +and the final clear. The accepted copy-based nonunit lowering costs +`B(a,d)-1`; the unit lowering costs two. Scale, copy and clear macros that +are not selected for replacement retain their existing costs. + +For a selected replacement set `R` and orientation-specific occurrence +counts `N_o(q)`, the saving against the accepted copy-based baseline is + +\[ +2\sum_{q\in R}N_o(q)\left(C_{\rm copy}(q)-C_{\rm new}(q)\right). +\] + +The factor two charges both real components. A saving against the best of +four Horner comparators is a different quantity; it must be computed with +that comparator's cost in place of `C_copy`. Comparing complete circuit +lengths, including initialization and clearing, avoids assigning a saving +to an uncharged source read. No unchanged child, adapter or wrapper cost +may be removed from a global invoice because a local coefficient is cheaper. + +The seven selected absolute coefficients have the following positive +witnesses. `H` means halve and `A` means add the unchanged source. Each +displayed preparation starts immediately after the paid copy `W=S` and is +followed by the paid signed target update and final clear. + +| `|q|` | Preparation | Complete new cost | Copy-binary cost | Occurrences in each orientation | +| --- | --- | ---: | ---: | ---: | +| `9/4` | `H H A A` | 7 | 9 | 2 | +| `5/2` | `H A A` | 6 | 7 | 25 | +| `11/4` | `H A H A A` | 8 | 10 | 1 | +| `13/4` | `H H A A A` | 8 | 10 | 1 | +| `7/2` | `H A A A` | 7 | 8 | 10 | +| `15/4` | `H A H A A A` | 9 | 11 | 4 | +| `17/4` | `H H A A A A` | 9 | 10 | 1 | + +These are 44 macro occurrences per orientation, saving 52 primitives on +one real component and therefore 104 on both components against the +copy-binary baseline. Each new circuit is also one real-component +primitive shorter than the best of the four pinned PR837 Horner +comparators for that coefficient; the incremental saving against those +comparators at these occurrences is therefore 88 per orientation. That +second figure is a comparator calculation, not an assertion that the +complete PR837 implementation is composed into this package. + +## 5. Exact instruction/source-read Pareto certificate + +[pareto.py](pareto.py) audits a second coordinate on the **same 49 graphs**: +the number of instructions that read the unchanged macro source `S`. +During preparation, `add` and `subtract` contribute the cost pair `(1,1)`; +doubling, halving and negation contribute `(1,0)`. The paid initial copy +contributes one further source read. Target accumulation reads `W`, and +the final clear reads no `S`. Thus a preparation pair `(l,r)` has complete +macro pair `(l+3,r+1)`. All register operations remain charged by the first +coordinate; the second singles out occurrences of `S` as an operand. It +is not a measured memory-access count. + +Operation identities matter for this audit. For example, at `m=d`, both +doubling and adding `S` reach `2d`, but their source-read increments are +zero and one respectively. The search and checker preserve these +differently priced parallel edges. + +A pair dominates another pair when it is no larger in either coordinate +and strictly smaller in at least one. Each vertex stores an antichain of +nondominated preparation pairs and one operation-word witness per pair. +The search discards a candidate only when an existing label is no more +expensive in either coordinate. These state-local costs are additive, so +the same comparison holds after every common continuation. Removing a +cycle strictly decreases the instruction coordinate and cannot increase +source reads. Every nondominated pair therefore has a simple-path witness +of at most `|V|-1` instructions. This proves finiteness without a search +depth cutoff or a heuristic read budget. + +The checker certifies the resulting antichains independently of the +search's integer successor table and pruning decisions. It requires: + +1. Exactly the declared state set `[-ad,ad]`, and the initial label `(0,0)` + at state `d`. +2. A rational-arithmetic replay of every stored witness from coefficient + one, with the exact instruction/read counts, endpoint, magnitude bound + and grid at every prefix. +3. Pairwise nondomination among labels at each state. +4. Local closure for every label and every admissible operation: extending + a label at `v` must produce a pair dominated or equalled by a stored + label at its successor. Successors are reconstructed with `Fraction` + arithmetic, including differently priced operations to one successor. + +To prove completeness, take any finite graph walk. The initial `(0,0)` +label covers its empty prefix. If a stored label covers a prefix cost, +monotonicity of addition and local closure give a stored label covering +the next prefix cost. Induction therefore shows that every attainable +pair is covered by a stored pair. Conversely, every stored pair is +attainable by its checked witness. The two sets have the same upward +closure; the checked antichains are consequently their exact Pareto +frontiers. Taking the union at both signed goals and removing dominated +pairs gives the complete endpoint frontier. + +Across the corpus, this checks **3,703 vertices, 4,104 labels and 16,096 +edge-label closure obligations**. [pareto.py](pareto.py) binds the coefficient +census and occurrence weights to the pinned JP8 payload, replays every +label witness, and returns canonical hashes of the complete label tables. +The receipt also compares each existing [CERTIFICATE.json](CERTIFICATE.json) +word with its frontier: all **submitted** shortest witnesses minimize +source reads among shortest words. This does not mean every shortest word +minimizes reads: for coefficient `2`, `double` and `add` are both one-step +preparations, with zero and one source reads. + +Exactly the seven selected coefficients have two endpoint Pareto points; +the other 42 coefficients have one. Pairs below include all macro +instructions and the initial copy's source read, per real component: + +| `|q|` | Submitted `(instructions, reads)` | Lower-read Pareto alternative | +| --- | --- | --- | +| `9/4` | `(7,3)` | `(9,2)` | +| `5/2` | `(6,3)` | `(7,2)` | +| `11/4` | `(8,4)` | `(10,3)` | +| `13/4` | `(8,4)` | `(10,3)` | +| `7/2` | `(7,4)` | `(8,3)` | +| `15/4` | `(9,5)` | `(11,3)` | +| `17/4` | `(9,5)` | `(10,2)` | + +There is no third intermediate Pareto point. The alternative for `15/4` +prepares the integer coefficient along +`1 -> 2 -> 4 -> 8 -> 7 -> 14 -> 15`, then halves twice. Its complete pair +`(11,3)` dominates PR696's `(11,4)` in source reads at equal instruction +count. This is the bounded signed-Horner construction class credited to +**Chris Pagolu's PR734**, not a newly claimed coefficient construction. +The endpoint frontier and witness words are diagnostic evidence; the +emitted circuits remain the seven submitted shortest words in section 4. + +For the 44 affected macro occurrences in either orientation, the source +audit independently counts actual frozen comparator words. The following +totals include both real components and use the pins in +[SOURCES.json](SOURCES.json): + +| Lowering at the affected occurrences | Instructions | Source reads | +| --- | ---: | ---: | +| Original pre-PR696 binary Horner | 782 | 216 | +| PR696 / binary-forward comparator | 694 | 216 | +| NAF-forward comparator | 690 | 180 | +| Binary-reverse comparator | 678 | 216 | +| NAF-reverse comparator | 706 | 180 | +| Best of four, PR837's stable instruction-count tie order | 678 | 200 | +| Best of four, minimum reads among instruction-count ties | 678 | 180 | +| Submitted replacement words | 590 | 308 | + +The best-of-four rows are coefficient-wise comparator selections, not the +execution of one fixed candidate family. These comparators remain +unrestricted by the search's magnitude/grid constraints, as in the original +instruction-count comparison. For example, NAF-forward for `7/2` has pair +`(8,2)` but reaches coefficient `8`, exceeding the allowed magnitude `7`. +It therefore does not contradict the bounded frontier `(7,4),(8,3)`. + +All primitive operand occurrences are counted separately from reads of the +unchanged macro source. A clear reads zero operands, a copy or unary operation +reads one, and an addition/subtraction reads two. The complete submitted +replacement adds 92 additions and removes 196 doublings per orientation; +other primitive-tag counts stay unchanged. It therefore increases source +reads by 92 while reducing total operand reads by `2*92-196 = -12`: +`207138 -> 207126` forward and `207154 -> 207142` backward. These are syntactic +operand occurrences, not physical memory loads, cache traffic or runtime. + +### Hypothetical source-read sensitivity + +To expose the tradeoff algebraically, define a hypothetical cost + +\[ +\text{instructions}+p\,\text{source reads},\qquad p\ge0. +\] + +Here `p` is an **additional** overhead on a source read that is already +paid as a primitive. No physical or runtime value of `p` is assumed or +inferred. For the fixed submitted schedule, the gain against PR696 is +`104 - 92p` per orientation, with algebraic break-even `p=26/23`. + +Choosing the least hypothetical cost independently from each of the seven +frontiers gives exact switch points `1/3`, `1`, and `2`. The other macro +positions stay at their PR696 baseline. The resulting diagnostic deltas +per orientation, including both real components, are: + +| Hypothetical extra read overhead | Instruction delta versus PR696 | Source-read delta versus PR696 | +| --- | ---: | ---: | +| `0 <= p < 1/3` | `-104` | `+92` | +| `1/3 < p < 1` | `-102` | `+86` | +| `1 < p < 2` | `-16` | `0` | +| `p > 2` | `0` | `-8` | + +Adjacent choices tie at a switch point; intermediate mixtures of tied +choices are also optimal there. The switch points follow from each pair's +instruction difference divided by its read difference: `17/4` switches at +`1/3`; `5/2`, `7/2` and `15/4` at `1`; and `9/4`, `11/4` and `13/4` at `2`. +Because the objective is additive over these fixed occurrences, minimizing +each independently minimizes their summed hypothetical cost. + +The zero aggregate read-delta row keeps the submitted words for `9/4`, +`11/4` and `13/4`, and uses the lower-read alternatives for the other four, +including the credited bounded-Horner `15/4` word. This describes a +certified possible schedule, not an implemented alternative or a physical +read-budget guarantee. Equal aggregate read counts do not establish equal +costs for different frames, source locations or access schedules. The +executable lowering and its 104-primitive saving per orientation remain +unchanged. + +## 6. Magnitude bound inherited from original binary Horner + +The original binary-Horner preparation explicitly reaches `W=aS` before +its terminal halvings. Every candidate preparation value obeys + +\[ +|W|=|cS|\le a|S|. +\] + +The source is unchanged; the target stays at its incoming value until one +final update, after which it equals the original final target. The arbitrary +incoming work and the final zero also occur in the original trace. Therefore +the maximum absolute value over all registers and prefixes in a replacement +macro is no larger than in that macro's original binary-Horner trace, for +each input separately. + +For symbolic source row `s`, the same argument gives +`norm_1(c*s) = |c| norm_1(s) <= a norm_1(s)`. Thus the inherited maximum-row +norm or nonnegative original-Horner envelope remains an upper bound under +successive substitutions. This does **not** assert that each replacement +row literally occurs in the original trace, or that all simultaneous +transfer matrices satisfy an entrywise order. New fractional coefficients +usually prevent literal prefix-trace containment. + +The complete scalar replays additionally measure the exact maximum row-L1 +norm over all 725 formal input columns at every primitive prefix. Initial +basis rows have norm one; after each primitive only the written row can +change the maximum. The Fraction interpreter sums absolute rational entries; +the independent integer interpreter sums absolute integer numerators and +compares dyadic values by cross multiplication. All historical, PR696 and +replacement traces agree at `503316465` forward and `1469388997/2` backward. +These finite values supplement the substitution proof; they do not interpret +physical frame or recursive operators, nor reduce the inherited 192-bit +allocation. Both observed global maxima lie in unchanged macros outside the +bounded coefficient search, so equality of these maxima alone would not prove +every changed macro satisfies its local bound. + +## 7. What the fractional-grid constraint guarantees + +Locally, if macro-entry `T`, `S` and `W` are on `2^-p Z`, every candidate +value is representable on `2^-(p+k) Z`, with an unbounded integer part. +The coefficient grid does not by itself fix `p`, total register width, +overflow behavior, rounding-error amplification, or the precision needed by +the physical compiler. + +There is also a stronger **scalar-projection** comparison with the original +word. Replay scalar primitives as exact dyadic linear maps on the original +formal input columns, leaving physical frame operators outside this model. +Let `s_j` be a coefficient in the current source row. A candidate scratch +coefficient is `m*s_j/2^k`. + +If `k>0`, reduction of `a/2^k` means `a` is odd. For nonzero `s_j`, the +2-adic valuation satisfies + +\[ +\nu_2(m s_j/2^k)\ge\nu_2(s_j)-k + =\nu_2(a s_j/2^k). +\] + +Consequently its reduced binary denominator exponent cannot exceed that +of the original terminal scratch coefficient `q*s_j`. A zero coefficient +has no denominator requirement. If `k=0`, every candidate multiplier is an +integer, so its denominator exponent cannot exceed that of `s_j`; the +original leading-source state `W=S` already attains that bound. These +arguments also cover source rows whose integer coefficients are all even; +it would be incorrect to assume that the clipped denominator depth always +increases by exactly `k`. + +All remaining registers, the arbitrary incoming work and the target before +and after its single update have the same values as before. Hence each +replacement has no larger scalar-prefix denominator depth than its original +macro, and boundary induction extends this to the complete scalar +projection. This comparison is against the original/copy binary lowering; +it does not imply that the chosen word minimizes denominator depth among +all shortest words. + +The conclusion does not evaluate frame/phase operators, normalization, +recursive children, tape interfaces or floating-point arithmetic. It is +not a full compiler precision certificate or a proof of the all-size +integer multiplication theorem. The distinction matters because a +coefficient on a depth-`k` local grid can be applied to a source already +carrying additional fractional depth from previous macros. + +## 8. Adverse checks and review boundaries + +Endpoint checks alone would miss several false claims. The implemented +controls exercise distinct failures with the recorded failure reason: + +* Remove the initial copy while retaining arbitrary incoming work: the + three-register endpoint must fail. +* Remove the final clear: private dirt must be + detected even if the target endpoint is correct. +* Flip the target accumulation sign or the claimed terminal sign: the + target identity must fail. +* Insert enough halving and inverse doubling to cross the allowed grid + and restore the original endpoint: the grid check must fail. +* Insert a doubling excursion beyond `|c|<=a` followed by its inverse: + the magnitude check must fail despite the correct endpoint. +* Insert two negations into a valid optimum: a legal equal-endpoint path + must fail optimality or exact cost, not arithmetic correctness. +* Understate a potential entry: the full-graph optimality check must fail. +* Omit one corpus coefficient or change a pinned source payload: coverage + or provenance must fail. +* Supply zero, a nondyadic coefficient or + aliased source/target/work: domain or register-contract validation must + reject it. + +The Pareto checker adds four controls with specific rejection reasons: +removing a required lower-read label fails edge closure; understating a +label's source-read count fails witness replay; changing the declared +magnitude bound fails domain matching; and omitting the initial source +copy fails macro-boundary/source-read accounting. These checks distinguish +frontier completeness from endpoint correctness and detect an uncharged +source read even when a claimed preparation length looks plausible. + +The reproducible verifier output and validation record identify the controls +actually executed. Independent implementation here +means a separate algorithm and interpreter, not independent human review +or formal verification of the full theorem. + +## 9. Relation to the closest prior work + +PR696 already supplies the copy/unit lowering and dirty-work contract. +PR734 supplies numerator-bounded signed-Horner circuits, a proof within its +restricted recurrence, and a Dijkstra crosscheck. Its crosscheck uses +positive integer states with transitions `c -> 2c+e`, `e` in `{-1,0,1}`, +cost `1+|e|`, and bounded doubled and final states; halving follows after +integer preparation. PR837 chooses among +forward/reverse binary and NAF Horner circuits. PR866 demonstrates why exact +endpoints and small magnitudes do not alone control fractional grids. + +The incremental search class here permits arbitrary interleaving of paid +source additions/subtractions and shifts, while preserving both the +original magnitude envelope and coefficient grid. Its finite optimality +claim must be stated relative to this class and corpus. General shift/add +synthesis, bounded Horner optimization, copy initialization, and grid-guard +analysis are not claimed as new ideas. Savings already available from a +prior candidate family must not be presented as an additional improvement +over that family; the certificate should distinguish them from words that +strictly beat every named comparator. + +No result here automatically transports to another supplier or to the +currently selected frontier. No new kappa, asymptotic complexity bound, +runtime speedup, physical admission certificate or production integration +is claimed. diff --git a/research/jp8-grid-bounded-synthesis/README.md b/research/jp8-grid-bounded-synthesis/README.md new file mode 100644 index 0000000000..24c0757ecd --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/README.md @@ -0,0 +1,213 @@ +# Seven grid-preserving JP8 coefficient circuits + +**Finite complex-supplier circuit construction; no new kappa.** + +Seven coefficients in the historical PR626 JP8 scalar programs admit a shorter +single-scratch circuit than any of PR837's four binary/NAF Horner variants. +The new circuits interleave halvings and repeated source additions. Their +intermediate magnitudes and fractional grids stay within the original binary +lowering's bounds, and private work is cleared after every addition macro. + +For example, prepare `5S/2` with `W=S; W/=2; W+=S; W+=S`, then perform the +signed target update and clear `W`. The complete macro costs six primitives per +real component, versus seven for each of the four Horner comparators. The +initial copy, both source additions, final accumulation and clearing are paid. + +| Complete JP8 scalar projection | Accepted PR696 lowering | Replacement | Saved | +| --- | ---: | ---: | ---: | +| Forward | 200,380 | 200,276 | 104 | +| Backward / inverse-transpose | 200,396 | 200,292 | 104 | + +Each orientation changes 44 macros. At those occurrences the saving versus +the **best of all four PR837 variants** is 88 real-component primitives. +The full PR837 program is not composed here; all other macros retain PR696's +accepted lowering. These are distinct comparisons, not additive savings. +The original pre-PR696 bills are 257,232 / 257,280. This package claims only +the additional 104 / 104 improvement over PR696. + +The additional **92 real source reads per orientation** are explicitly counted +and paid as copy/add/subtract instructions; fewer shifts more than offset them +in this primitive cost model. There is no additional helper, source mutation, +restoration, frame transition or recursive child. This is an operation count, +not a measured runtime result or a refreshed global invoice. +Counting every arithmetic operand occurrence, total register reads decrease by +12 per orientation: 92 added additions replace 196 doublings. Macro-source +reads and all operand reads are distinct syntactic counts, not physical loads. + +## Reproduce + +From the repository root, Python 3.11+ and the standard library: + +```sh +python3 -I -O -B research/jp8-grid-bounded-synthesis/verify.py +``` + +Expected final line: + +```text +PASS_JP8_GRID_BOUNDED_SYNTHESIS coefficients=49 improved=7 extra_vs_four_horner=88,88 columns=716+9 kappa=unchanged +``` + +The command is offline, writes nothing, freshly rebuilds every search result, +checks the independent distance certificates and complete scalar traces, and +compares every receipt field with [EXPECTED.json](EXPECTED.json). Checks remain +active with Python optimization enabled. `--json` prints the checked receipt; +the development option `--write PATH` refuses existing output. + +The verification has three complementary parts: + +- **Finite search:** BFS constructs the coefficient words; a separate complete + Bellman-potential checker proves their shortest lengths in the stated graph. +- **Complete scalar execution:** sparse `Fraction` rows replay the historical, + PR696 and replacement programs. A separately implemented integer replay + reconstructs PR696 and the same submitted replacement circuits, then checks + them against a direct integer macro oracle. The main verifier compares the + full primitive-stream hashes, bills, tags, read counts, denominator maxima, + event/frame hashes and other shared receipt fields between implementations. +- **Fault and arithmetic checks:** deliberate corruptions must fail, while + bounded differential tests check the integer row arithmetic, comparator + formulas and graph-potential obligations. + +The individual checks can also be run directly: + +```sh +python3 -I -O -B research/jp8-grid-bounded-synthesis/crosscheck.py --self-test +python3 -I -O -B research/jp8-grid-bounded-synthesis/integer_replay.py +python3 -I -O -B research/jp8-grid-bounded-synthesis/test_independent.py +python3 -I -O -B research/jp8-grid-bounded-synthesis/test_package.py +python3 -I -O -B research/jp8-grid-bounded-synthesis/pareto.py +``` + +`integer_replay.py --json` prints its deterministic receipt; `pareto.py` prints +the source-read tradeoff diagnostics described below. Neither changes the +submitted circuits. + +## Completed search and evidence + +The OS assignment seed is **33**. The prespecified domain is every nonunit +absolute coefficient `a/d` in both frozen JP8 programs with reduced +`a <= 127`, `d <= 16`. There are **49**; the unit coefficient is handled by +the established direct update and paid clear. Seed 33 rotates traversal order +and selects JP8 by parity; all domain coefficients are covered. + +The work coefficient lies on `d^-1 Z` with magnitude at most `a`. Starting +with the paid copy `W=S`, each search edge is one signed source addition, +doubling, exact halving or negation. Both terminal signs are allowed, followed +by one signed accumulation and one clear. The search stops only after the +finite graph is exhausted, with no timeout or randomized pruning. + +[CERTIFICATE.json](CERTIFICATE.json) contains every shortest word. A separately +implemented checker enumerates **3,703 vertices and 14,311 distinct directed +edges** across the 49 graphs. It uses synchronous Bellman relaxation and checks +an integer potential and descending witness at every vertex. This establishes +optimality in the explicitly bounded single-scratch class, not general circuit +optimality. The other 42 coefficients supply no strict improvement over the +minimum of the four Horner comparators in this class; this says nothing about +larger grids, another initialization, more registers or multiple target updates. + +The seven improvements are `9/4`, `5/2`, `11/4`, `13/4`, `7/2`, `15/4`, `17/4`. +The [proof](PROOF.md) gives the words, full cost recurrence and substitution +argument. Every graph witness is checked on arbitrary target/source/work inputs +for both coefficient signs, even when it is not installed as a replacement. + +Both complete scalar projections are executed as actual primitives on all +**716 logical plus nine arbitrary private input columns**, comparing the +original, PR696 and replacement words at every macro boundary. All 492 helper +columns restore, and all nine private registers erase. The exact maximum +fractional denominator exponents stay **4 forward / 27 backward** in all three +traces. The original positive prefix bounds remain valid within the inherited +192-bit allocation; the proof covers magnitude and denominator nonincrease. +Both arithmetic implementations also measure the exact scalar-prefix maximum +row-L1 norms: **503316465 forward / 1469388997/2 backward**, unchanged from +PR696. These scalar-coordinate measurements do not reduce that allocation. + +The additional [integer replay](integer_replay.py) uses normalized sparse integer +rows with one power-of-two denominator per row. It imports neither `Fraction` +nor the synthesis, replay or vendored lowering modules. It independently +reconstructs the four comparator lengths and checks every submitted path before +selecting the same seven replacements. Both complete programs then agree with +its direct integer macro oracle on all 725 input columns at every macro +boundary. This is a different arithmetic implementation of the same circuits, +not an additional circuit construction or proof of the non-scalar events. + +Non-scalar events and macro frames are retained by construction and recorded +with indexed hashes; paid profiles match the pinned receipts. Those preservation +checks are not an independent physical frame or wrapper replay. Eleven macro +rejection controls, six integer-replay controls, four graph rejection controls +and package corruption tests separate endpoint, grid, magnitude, optimality, +provenance and invoice failures. [test_independent.py](test_independent.py) +checks 7,000 signed row multiplications and 39,200 row sums against `Fraction` +arithmetic, including denominator depths 0 through 27, and compares the +independent Horner length formulas over all 383 supported reduced coefficients. +These bounded helper tests complement the full pinned-program replays. +Six independent tests and 14 package tests pass on both Python versions +recorded in [VALIDATION.md](VALIDATION.md). + +## Source-read tradeoff diagnostics + +[pareto.py](pareto.py) audits primitive count and reads of the unchanged macro +source as separate coordinates in the same 49 bounded graphs. An independent +rational checker verifies every witness, state-label antichain and edge-closure +obligation. The certificate covers **3,703 states, 4,104 nondominated state +labels and 16,096 edge-label obligations**. Four corruption controls check +missing tradeoffs, forged read counts, the bound and the paid initial copy. + +All 49 submitted shortest witnesses also minimize source reads among shortest +words. Each of the seven replacement coefficients has one further nondominated +option with more instructions and fewer source reads. For `5/2`, the two +complete macro costs are `(6 instructions, 3 source reads)` and +`(7 instructions, 2 source reads)`, per real component. The initial source copy +is included in both coordinates where applicable. The lower-read `15/4` word +is credited to PR734. + +The optional sensitivity model is `instructions + p * source_reads`, where +`p >= 0` is a **hypothetical additional read overhead**, not a measured or +adopted physical price. For the unchanged submitted schedule, its advantage +over PR696 would be `104 - 92*p` per orientation, with equality at `p = 26/23`. +Choosing alternative words under that hypothetical model changes at +`p = 1/3`, `1` and `2`; adjacent choices tie at each breakpoint. These are +diagnostic alternatives: the implementation and the 104-primitive / 92-read +tradeoff reported above remain unchanged. +An independently coded weighted Dijkstra test checks 490 graph/price cases, +including interval interiors and both adjacent choices at every breakpoint. + +## Provenance, related work and limits + +Base commit: `f567884aeb8851b6e794af1184119a3bfbe1e631`. The selected record at +that base is PR799 with conditional kappa `0.001661634653669567`; this package +uses the **historical PR626 JP8** provider and makes no transport claim to X4. +[SOURCES.json](SOURCES.json) binds the official PR626 checkpoint, its SPEC, +emitter, accounting code, programs and receipts. Compressed source pins cover +decompressed payloads; the two vendored code files are pinned byte for byte. + +- **Sagar Thakrar, PR696:** accepted copy/unit lowering and arbitrary-dirty + scratch contract, retained verbatim. The coefficient/primitive lineage + credits icekylinx, Jeremy Kothe's PR622, Chafik Boukhalfa's PR626 packaging, + DreamingOfClouds, Rohan Arun, eumemic and their retained predecessors. +- **Gareth Davidson, PR837**, head `0a2977195efc8fb2a918fbfb694ec8d294387f08`: + the four comparator circuits are vendored verbatim. Forward signed digits + credit PR723 and PR787. We do not claim priority for shift/add synthesis. +- **Chris Pagolu, PR734**, head `ba76ba3321d000c8996b0b254bcf0d7260e1bbb6`: + numerator-bounded signed-Horner recurrence and integer digit-graph + crosscheck. Our class also admits halves interleaved with repeated additions. +- **Gareth Davidson, PR866**, head `5ae580bf68516f1cbe3b2dd3cb646be55170288f`: + the fractional-grid audit motivates preserving this distinct precision + quantity. Here it is constrained during synthesis and proved not to increase. +- PR811/PR860 reuse coefficients across macro boundaries; this package retains + every original scratch-clearing boundary. Their savings are not combined. + +Production-emitter integration, typed frame/phase admission, refreshed global +owner/invoice/assembly receipts and full compiler precision remain separate +obligations. The inherited all-size compilation, common-label/mutable-source, +whole-call hosting, precision/tape and analytic hypotheses remain. Finite +scalar replay and finite optimality are not a formal multiplication theorem. +`upstream/`, the selected frontier, and all existing files are unchanged. + +Prepared for **Philipp (@mightyOil)** with substantial **OpenAI Codex assistance** +in research, implementation, proof writing, verification and packaging. +Separate AI workers implemented the graph checker and complete scalar replay +and reviewed the proof. This is not independent human review. New material is +Apache-2.0; predecessor source headers and notices are retained. + +See [CLAIM.json](CLAIM.json), [VALIDATION.md](VALIDATION.md) and +[OVERLAP.json](OVERLAP.json) for the local sprint record and submission checks. diff --git a/research/jp8-grid-bounded-synthesis/SOURCES.json b/research/jp8-grid-bounded-synthesis/SOURCES.json new file mode 100644 index 0000000000..7b7490ac55 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/SOURCES.json @@ -0,0 +1,54 @@ +{ + "base_commit": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "historical_provider": "PR626 JP8; not a PR799 implementation change", + "source_heads": { + "626": "660de893d27bb7abd1d5b01b1640207528a5c851", + "622": "f69477f4f6d3c7eb1f740b166881bffed4ffa9f6", + "696": "5a3f983715027c4fd83f50bc9001d4b18463bed1", + "837": "0a2977195efc8fb2a918fbfb694ec8d294387f08" + }, + "files": { + "certificates/checkpoints/k492626.json": { + "representation": "exact-bytes", + "sha256": "b3bf402f31a69bde0629936a9b569bed48281568d7b16d5fba120b5311ea1f53" + }, + "research/complex-k492-owner-repair/data/SPEC.json": { + "representation": "exact-bytes", + "sha256": "2a2577ac526535826fed9d5f7f83f6e2e0ec058a146c64f7286720b995fa2323" + }, + "research/complex-k492-owner-repair/code/hpe_emit_local.py": { + "representation": "exact-bytes", + "sha256": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805" + }, + "research/complex-k492-owner-repair/code/invoice_allcold.py": { + "representation": "exact-bytes", + "sha256": "141bd2fd58bbfb5b8d0fc8f56f61c45586d5608a5af3487c6b883dd987f998ec" + }, + "research/complex-dyadic-lowering/lower.py": { + "representation": "exact-bytes", + "sha256": "eb37d00063dc09323e9aca041d23da749ce17fbd71dade9aaf1c059cab0b9753" + }, + "research/community-k492-audit/pr626/replay/mixed-global/base/providers/jp8/LOCAL-PROGRAMS.json.gz": { + "representation": "decompressed-payload", + "sha256": "efe45ce7fb025a6f53cc9eb54e951ac2211a5ed927e689a049e4f68ca680654b" + }, + "research/community-k492-audit/pr626/replay/mixed-global/base/providers/jp8/LOCAL-CHECKS.json": { + "representation": "exact-bytes", + "sha256": "0fad744aa863eedb288a9f87b1c23225a36b316b6275cc3b1bcedd42afe28a67" + }, + "research/community-k492-audit/pr626/replay/mixed-global/base/providers/jp8/INDEPENDENT-LOCAL-REPLAY.json": { + "representation": "exact-bytes", + "sha256": "cb2f99ed351925dd35434b73de16f4085884fe81a35a69e1c7ce2d5e96cb975b" + } + }, + "vendored": { + "vendor/pr837/lower.py": { + "representation": "exact-bytes", + "sha256": "6a7ae3f2aff61077ce4b3f179f7ccc2024f5176b5894547250eb14105b14f5e2" + }, + "vendor/pr837/vendor/pr696_lower.py": { + "representation": "exact-bytes", + "sha256": "eb37d00063dc09323e9aca041d23da749ce17fbd71dade9aaf1c059cab0b9753" + } + } +} diff --git a/research/jp8-grid-bounded-synthesis/VALIDATION.md b/research/jp8-grid-bounded-synthesis/VALIDATION.md new file mode 100644 index 0000000000..622d50fbb5 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/VALIDATION.md @@ -0,0 +1,118 @@ +# Validation record + +Date: 2026-10-13. Base `f567884aeb8851b6e794af1184119a3bfbe1e631`. +Local macOS arm64, CPython **3.14.7** and **3.11.15**; standard library only. +No remote Linux, full repository suite or Lean result is claimed. + +## Executed checks + +1. `python3 -I -O -B research/jp8-grid-bounded-synthesis/verify.py` and the + same command under `python3.11`: PASS. All 49 nonunit coefficients are + reconstructed; seven strictly improve all four Horner variants. Complete + source closure, type-preserving certificate comparisons and every field of + [EXPECTED.json](EXPECTED.json) match. The circuit certificate and emitted + words are unchanged from the initial submission. +2. Independent Bellman/potential checker: PASS for 3,703 vertices and 14,311 + distinct directed edges, exact coefficient coverage, four adverse controls, + eight elementary distance checks and all five preparation primitive types. + `crosscheck.py --self-test` also passed standalone. +3. Complete three-way primitive replay: PASS on both orientations, each with + 716 logical and nine arbitrary private input columns, 22,693 scalar macro + boundaries, restored 492 helper columns and erased private registers. + The historical, PR696 and replacement bills are respectively + `257232/200380/200276` forward and `257280/200396/200292` backward. + Exact maximum scalar fractional denominator exponents agree at 4 and 27. + Exact maximum scalar-prefix row-L1 norms agree at `503316465` forward and + `1469388997/2` backward in all three traces. +4. Independent integer replay: PASS for both complete orientations, using + normalized sparse integer rows with a common power-of-two denominator. + It imports neither `Fraction` nor any project module, independently emits + PR696/replacement words, and compares each macro with direct integer + semantics. The main verifier requires its full primitive-stream hashes, + bills, tags, reads, denominator/row-L1 maxima and all shared accounting fields to + match the Fraction implementation. Six adverse controls and six elementary + integer/NAF cases pass. +5. Source-read Pareto certificate: PASS on all 49 graphs, 3,703 vertices, + 4,104 state labels and 16,096 edge-label closure obligations. Every label + has a checked rational witness; all edges preserve antichain coverage. + All submitted shortest witnesses minimize reads among shortest words. + Exactly the seven selected coefficients have two Pareto options; four + adverse controls pass. Occurrence-weighted instruction/read deltas agree + with the complete primitive replay. This diagnostic changes no circuit. +6. `python3 -I -O -B research/jp8-grid-bounded-synthesis/test_package.py`: + **14 tests PASS** on CPython 3.14.7 and 3.11.15. This includes a minimal + checkout without Git metadata in a path with spaces, a different working + directory and recompressed gzip input. Controls reject source/reference + byte changes, missing pins, forged source identity, omitted coefficients, + altered paths, altered JSON types and forged receipts. Existing output is + preserved. Every subprocess also uses isolated optimized Python. +7. `python3 -I -O -B research/jp8-grid-bounded-synthesis/test_independent.py`: + **six tests PASS** on both Python versions. Differential checks cover 7,000 + signed row multiplications, 39,200 row sums, + 1,400 intermediate primitive states and all 383 supported comparator + coefficient pairs. Graph mutations cover 114 single-potential changes, + missing/extra potential vertices and every one-operation deletion from + the `7/4` witness. The bounded corpus spans denominator depths 0 through 27; + it complements, rather than replaces, complete source-program replay. + A separate scaled-integer Dijkstra calculation checks all 49 graphs at ten + exact hypothetical read prices (490 graph/price cases), without importing + the Pareto search, successor function or sensitivity code. It confirms + the four aggregate interval costs, paid copy/accumulation/clear overhead, + and both adjacent choices at all three breakpoints. +8. `make selected-record-check`: PASS, current PR799 exact kappa + `1661634653669567/1000000000000000000` and source/proof inventory. +9. Whitespace and scope checks: PASS. Only this new research directory is + included. `upstream/`, existing source packages and selected certificates + match the exact base commit. + An export of the exact staged Git blobs also passes optimized verification + and the six independent tests without Git metadata, in a path with spaces. + +## Adversarial review and corrections + +The initial nine-test package passed before submission. Further independent +AI-assisted review found that Python value equality accepted JSON `true` in +place of integer `1`, and integral floats in place of integer certificate or +receipt counts. It also found that descriptive source-head/base/provider +metadata could be relabelled without changing the correctly pinned payloads. +These were checker-boundary defects, not counterexamples to the submitted +circuits. The main verifier now compares type-preserving canonical JSON, +checks exact provenance identity, and passes the submitted certificate entries +to the independent graph checker after reconstruction. Five new regression +tests exercise these failure modes. A separate reviewer reran the four input +corruptions and confirmed rejection under `-I -O`. + +An earlier test expected an overly narrow error-message regex (`coverage` +versus `does not cover`). Correcting the regex did not alter the checker, which +rejected the missing coefficient throughout. The Pareto receipt wording was +also narrowed to **submitted** shortest witnesses: other shortest words can +use more source reads, as `double` versus `add` for coefficient two demonstrates. +No mathematical failure was suppressed to obtain a passing result. + +## Interpretation and review status + +The full scalar replays execute primitives; they do not interpret frame changes +or recursive children as physical numerical operators. Event/frame hashes are +preservation evidence by construction, and paid profiles are checked against +the pinned receipt. The nonincrease of magnitude and scalar fractional depth +also follows from the local substitution proof, separately from finite tests. +All source accesses in the primitive model are charged, including 92 more real +macro-source reads per orientation in the submitted replacement. + +The two-coordinate audit makes that tradeoff explicit. Its hypothetical extra +read overhead is not a physical price or runtime benchmark. Alternative Pareto +words and aggregate menus are certified diagnostics, not installed or separately +replayed full programs. In particular, equal aggregate read counts do not prove +equal source-location, frame or physical access costs. + +No full `make verify`, selected cold reconstruction, regenerated global invoice, +owner admission, native phase/wrapper rebuild, production compiler integration, +remote CI or formal multiplication theorem is asserted. None of those artifacts +is modified. Those inherited or integration obligations remain outside this +finite research contribution. The selected kappa is unchanged. + +The [overlap record](OVERLAP.json) preserves the original pre-submission check +and a continuation refresh through PR893. The base and eight dependency heads +remain unchanged. No pinned sprint coordination issue is available; the local +claim already records the result and existing PR882. All subsequent evidence +stays in that same contribution. Independent implementations and reviews here +are AI-assisted; no independent human mathematical review is claimed. diff --git a/research/jp8-grid-bounded-synthesis/crosscheck.py b/research/jp8-grid-bounded-synthesis/crosscheck.py new file mode 100644 index 0000000000..23f7f2a1e4 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/crosscheck.py @@ -0,0 +1,310 @@ +#!/usr/bin/env python3 +"""Independent finite-graph checker for the claim in this directory. + +This module does not import the synthesis code. It constructs the entire graph +and uses synchronous Bellman relaxation from BOTH signed goals. Its potential +is checked at every vertex and edge: zero exactly at the goals, a unit-edge +Lipschitz lower bound, and a descending edge at every other vertex. Thus the +potential gives both a lower bound for every path and a matching witness. + +The CLI accepts CERTIFICATE.json with an ``entries`` list. A record contains +positive reduced ``numerator``, ``denominator`` in {1,2,4,8,16}, an ``operations`` +list, ``end_sign`` in {-1,1}, and ``preparation_steps``. The operations are +double, halve, add, subtract, negate. Optional --potentials writes the full +integer distance arrays, ordered by state -bound through +bound; their hashes +are always included in the report. All arithmetic uses Python integers. +""" + +from __future__ import annotations + +import argparse +import copy +import gzip +import hashlib +import json +from fractions import Fraction +from pathlib import Path + + +class CertificateError(ValueError): + """A witness or potential fails an independently checked obligation.""" + + +def _require(condition: bool, message: str) -> None: + if not condition: + raise CertificateError(message) + + +def _domain(numerator: int, denominator: int) -> tuple[int, int]: + _require(type(numerator) is int and 1 <= numerator <= 127, + "numerator is outside the claimed positive range") + _require(type(denominator) is int and denominator in (1, 2, 4, 8, 16), + "denominator is outside the claimed dyadic grid") + _require(denominator == 1 or numerator % 2 == 1, + "coefficient is not reduced") + return numerator * denominator, denominator + + +def _graph(numerator: int, denominator: int) -> tuple[int, list[tuple[int, ...]]]: + """Construct all successor indices, independently of a path search.""" + bound, source = _domain(numerator, denominator) + successors = [] + for state in range(-bound, bound + 1): + neighbors = {state + source, state - source, 2 * state, -state} + if state % 2 == 0: + neighbors.add(state // 2) + successors.append(tuple(sorted(v + bound for v in neighbors + if -bound <= v <= bound))) + return bound, successors + + +def bellman_potential(numerator: int, denominator: int) -> dict: + """Compute reverse distances by full synchronous relaxation, not BFS.""" + bound, graph = _graph(numerator, denominator) + vertex_count = len(graph) + infinity = vertex_count + 1 + distances = [infinity] * vertex_count + distances[bound - numerator] = distances[bound + numerator] = 0 + rounds = 0 + while True: + updated = [min(old, 1 + min(distances[j] for j in neighbors)) + for old, neighbors in zip(distances, graph)] + if updated == distances: + break + distances = updated + rounds += 1 + _require(rounds <= vertex_count - 1, "relaxation did not converge") + _require(max(distances) < infinity, "an enumerated state is unreachable") + validate_potential(numerator, denominator, distances) + encoded = json.dumps(distances, separators=(",", ":")).encode("ascii") + return { + "numerator": numerator, + "denominator": denominator, + "bound": bound, + "vertices": vertex_count, + "directed_edges": sum(map(len, graph)), + "relaxation_rounds": rounds, + "maximum_distance": max(distances), + "preparation_steps": distances[bound + denominator], + "potential_sha256": hashlib.sha256(encoded).hexdigest(), + "distances": distances, + } + + +def validate_potential(numerator: int, denominator: int, distances: list[int]) -> None: + """Check complete Bellman obligations without recomputing the solution. + + Every step can lower the integer potential by at most one; a goal has + potential zero. Hence no path is shorter than the start potential. Every + non-goal has a successor with potential one smaller, giving attainment and + proving that no vertex/edge omitted by a partial search is being ignored. + """ + bound, graph = _graph(numerator, denominator) + _require(len(distances) == len(graph), "potential does not cover every vertex") + _require(all(type(value) is int and value >= 0 for value in distances), + "potential must have nonnegative integer values") + goals = {bound - numerator, bound + numerator} + for vertex, neighbors in enumerate(graph): + value = distances[vertex] + _require((value == 0) == (vertex in goals), + f"incorrect zero set at state {vertex - bound}") + for successor in neighbors: + _require(value <= distances[successor] + 1, + f"edge lower-bound violation at state {vertex - bound}") + if vertex not in goals: + _require(any(value == distances[j] + 1 for j in neighbors), + f"no descending witness at state {vertex - bound}") + + +def replay_operations(numerator: int, denominator: int, operations: list[str], + end_sign: int) -> list[int]: + """Replay submitted primitive names with a separate explicit interpreter.""" + bound, state = _domain(numerator, denominator) + _require(type(end_sign) is int and end_sign in (-1, 1), "invalid end sign") + _require(isinstance(operations, list), "operations must be a list") + states = [state] + for position, operation in enumerate(operations): + if operation == "double": + state *= 2 + elif operation == "halve": + _require(state % 2 == 0, f"off-grid halving at operation {position}") + state //= 2 + elif operation == "add": + state += denominator + elif operation == "subtract": + state -= denominator + elif operation == "negate": + state = -state + else: + raise CertificateError(f"unknown operation {operation!r}") + _require(-bound <= state <= bound, + f"magnitude bound exceeded at operation {position}") + states.append(state) + _require(state == end_sign * numerator, "witness does not reach its stated goal") + return states + + +def _descending_witness(numerator: int, denominator: int, + distances: list[int]) -> list[int]: + bound, graph = _graph(numerator, denominator) + position = bound + denominator + path = [denominator] + while distances[position]: + position = next(j for j in graph[position] + if distances[j] + 1 == distances[position]) + path.append(position - bound) + _require(abs(path[-1]) == numerator, "independent witness missed both goals") + return path + + +def verify_entry(entry: dict, *, include_distances: bool = False) -> dict: + """Verify one submitted path and its exact shortest preparation length.""" + numerator = entry["numerator"] + denominator = entry["denominator"] + _domain(numerator, denominator) + steps = entry["preparation_steps"] + _require(type(steps) is int and steps >= 0, "invalid preparation step count") + states = replay_operations(numerator, denominator, entry["operations"], + entry["end_sign"]) + _require(len(states) - 1 == steps, "forged preparation step count") + result = bellman_potential(numerator, denominator) + _require(result["preparation_steps"] == steps, + f"submitted length {steps} is not the exact optimum " + f"{result['preparation_steps']}") + if "distance_potential" in entry: + validate_potential(numerator, denominator, entry["distance_potential"]) + _require(entry["distance_potential"] == result["distances"], + "submitted potential differs from independent solution") + result["submitted_states"] = states + result["independent_states"] = _descending_witness( + numerator, denominator, result["distances"]) + # An arbitrary incoming scratch value still has to be cleared for a unit + # addition, even though that branch does not copy or prepare the source. + result["macro_cost"] = 2 if numerator == denominator == 1 else steps + 3 + result["verified"] = True + if not include_distances: + del result["distances"] + return result + + +def negative_controls() -> dict: + """Ensure four distinct false claims are rejected by the checker.""" + valid = {"numerator": 3, "denominator": 2, + "operations": ["halve", "add"], + "end_sign": 1, "preparation_steps": 2} + verify_entry(valid) + controls = {} + + def rejection(name, operation): + try: + operation() + except CertificateError as error: + controls[name] = {"rejected": True, "reason": str(error)} + else: + raise CertificateError(f"negative control accepted: {name}") + + forged_optimum = copy.deepcopy(valid) + forged_optimum["operations"] += ["negate", "negate"] + forged_optimum["preparation_steps"] += 2 + rejection("valid_but_nonoptimal_path", lambda: verify_entry(forged_optimum)) + potential = bellman_potential(3, 2)["distances"] + potential[6 + 2] -= 1 + rejection("forged_distance_potential", lambda: validate_potential(3, 2, potential)) + wrong_path = dict(valid, end_sign=-1) + rejection("wrong_signed_endpoint", lambda: verify_entry(wrong_path)) + off_grid = dict(valid, operations=["halve", "halve"], preparation_steps=2) + rejection("odd_state_halving", lambda: verify_entry(off_grid)) + return controls + + +def positive_controls() -> dict: + """Check elementary exact distances and all primitive interpreter branches.""" + known_distances = [(1, 1, 0), (1, 2, 1), (1, 4, 2), (1, 8, 3), + (1, 16, 4), (3, 1, 2), (3, 2, 2), (7, 4, 4)] + for numerator, denominator, steps in known_distances: + actual = bellman_potential(numerator, denominator)["preparation_steps"] + _require(actual == steps, "known elementary distance changed") + # These two paths deliberately cover all five primitive names, independently + # of whatever shortest witnesses happen to be supplied in a certificate. + _require(replay_operations(3, 1, ["double", "negate", "subtract"], -1) + == [1, 2, -2, -3], "primitive replay control failed") + _require(replay_operations(3, 2, ["halve", "add"], 1) == [2, 1, 3], + "fractional replay control failed") + return {"known_distances": len(known_distances), "primitive_names_covered": 5} + + +def source_coefficients(path: Path) -> set[tuple[int, int]]: + """Independently extract the claimed absolute JP8 scalar-add coefficient set.""" + data = path.read_bytes() + if path.suffix == ".gz": + data = gzip.decompress(data) + programs = json.loads(data) + _require(set(programs) == {"forward", "backward"}, "unexpected program schema") + selected = set() + for program in programs.values(): + for row in program: + if row[0] == "scalar" and row[1][0] == "add": + coefficient = abs(Fraction(row[1][3], row[1][4])) + n, d = coefficient.numerator, coefficient.denominator + if 1 <= n <= 127 and d in (1, 2, 4, 8, 16): + selected.add((n, d)) + return selected + + +def run(entries: list[dict], *, include_distances: bool = False, + source: Path | None = None) -> dict: + _require(isinstance(entries, list) and entries, "certificate entries are empty") + keys = [(e["numerator"], e["denominator"]) for e in entries] + _require(len(keys) == len(set(keys)), "duplicate coefficient entry") + if source is not None: + expected = source_coefficients(source) + # The direct unit addition is allowed to have no scratch-graph record. + _require(set(keys) - {(1, 1)} == expected - {(1, 1)}, + "certificate does not cover the selected source coefficients") + verified = [verify_entry(e, include_distances=include_distances) for e in entries] + return { + "status": "PASS", + "method": "full synchronous reverse Bellman relaxation and all-edge potential proof", + "checked_coefficients": len(verified), + "checked_vertices": sum(e["vertices"] for e in verified), + "checked_directed_edges": sum(e["directed_edges"] for e in verified), + "source_coverage_checked": source is not None, + "negative_controls": negative_controls(), + "positive_controls": positive_controls(), + "entries": verified, + } + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("certificate", nargs="?", type=Path) + parser.add_argument("--source", type=Path, + help="pinned JP8 LOCAL-PROGRAMS.json.gz for independent coverage") + parser.add_argument("--potentials", type=Path, + help="write full potential arrays as a reproducible certificate") + parser.add_argument("--output", type=Path, help="write compact JSON report") + parser.add_argument("--self-test", action="store_true") + args = parser.parse_args() + if args.self_test: + print(json.dumps({"status": "PASS", "negative_controls": negative_controls(), + "positive_controls": positive_controls()}, + indent=2, sort_keys=True)) + return + if args.certificate is None: + parser.error("certificate is required unless --self-test is used") + certificate = json.loads(args.certificate.read_text()) + report = run(certificate["entries"], include_distances=bool(args.potentials), + source=args.source) + if args.potentials: + args.potentials.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n") + for entry in report["entries"]: + del entry["distances"] + encoded = json.dumps(report, indent=2, sort_keys=True) + "\n" + if args.output: + args.output.write_text(encoded) + else: + print(encoded, end="") + + +if __name__ == "__main__": + main() diff --git a/research/jp8-grid-bounded-synthesis/integer_replay.py b/research/jp8-grid-bounded-synthesis/integer_replay.py new file mode 100644 index 0000000000..a9a56bca23 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/integer_replay.py @@ -0,0 +1,539 @@ +#!/usr/bin/env python3 +"""Independent integer-only replay of the historical JP8 scalar projections. + +Prepared for Philipp (@mightyOil) with substantial OpenAI Codex assistance. +Apache-2.0. Python 3.11+, standard library only. No project modules or Fraction +arithmetic are imported. This checks scalar words, not the full complex circuit +or a multiplication bound. All checks remain active under ``python -I -O``. + +A row is (k, sparse_integers), representing sparse_integers / 2**k. Each written +row is normalized by removing every common factor of two allowed by k. Rows are +never mutated after construction, so copying a row can safely share its value. +""" +import argparse +from collections import Counter +import gzip +import hashlib +import json +from math import gcd +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PROVIDER = ROOT / "research/community-k492-audit/pr626/replay/mixed-global/base/providers/jp8" +N, V = 716, 112 +WORK = ("W", 0) +PRIVATE = (WORK,) + tuple(("C", i) for i in range(8)) +ZERO = (0, {}) + + +class VerificationError(ValueError): + """An integer replay obligation failed.""" + + +def require(condition, message): + if not condition: + raise VerificationError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def sha(value): + return hashlib.sha256(canonical(value)).hexdigest() + + +def read(path): + data = path.read_bytes() + return json.loads(gzip.decompress(data) if path.suffix == ".gz" else data) + + +def reduced(numerator, denominator): + require(type(numerator) is int and type(denominator) is int and denominator, + "invalid scalar ratio") + if denominator < 0: + numerator, denominator = -numerator, -denominator + common = gcd(abs(numerator), denominator) + numerator, denominator = numerator // common, denominator // common + require(denominator & (denominator - 1) == 0, "non-dyadic scalar ratio") + return numerator, denominator.bit_length() - 1 + + +def trailing_twos(value): + require(value != 0, "zero has no finite two-adic valuation") + value = abs(value) + return (value & -value).bit_length() - 1 + + +def row(denominator_power, coefficients): + coefficients = {column: value for column, value in coefficients.items() if value} + require(denominator_power >= 0, "negative denominator power") + if not coefficients: + return ZERO + common = min(denominator_power, min(trailing_twos(x) for x in coefficients.values())) + if common: + coefficients = {column: value >> common for column, value in coefficients.items()} + return denominator_power - common, coefficients + + +def row_sum(left, right, sign=1): + power = max(left[0], right[0]) + result = {column: value << (power - left[0]) for column, value in left[1].items()} + for column, value in right[1].items(): + result[column] = result.get(column, 0) + sign * (value << (power - right[0])) + return row(power, result) + + +def row_multiple(value, numerator, denominator_power=0): + return row(value[0] + denominator_power, + {column: coefficient * numerator for column, coefficient in value[1].items()}) + + +def initial_rows(): + result = {("L", i): (0, {i: 1}) for i in range(N)} + result.update({register: (0, {N + i: 1}) for i, register in enumerate(PRIVATE)}) + return result + + +def primitive(rows, instruction): + """Integer row arithmetic; no macro evaluation is used by this interpreter.""" + require(isinstance(instruction, (tuple, list)) and len(instruction) >= 2, + "malformed primitive") + tag, target = instruction[0], tuple(instruction[1]) + require(target in rows, "unknown primitive target") + require(tag in ("clear", "copy", "add", "subtract", "double", "halve", "negate"), + "unknown primitive tag") + require(len(instruction) == (3 if tag in ("copy", "add", "subtract") else 2), + "primitive arity") + if tag in ("copy", "add", "subtract"): + source = tuple(instruction[2]) + require(source in rows and source != target, "invalid primitive source") + if tag == "clear": + rows[target] = ZERO + elif tag == "copy": + rows[target] = rows[source] + elif tag in ("add", "subtract"): + rows[target] = row_sum(rows[target], rows[source], 1 if tag == "add" else -1) + elif tag == "double": + rows[target] = row_multiple(rows[target], 2) + elif tag == "halve": + # Increase the common denominator; never use integer truncating division. + rows[target] = row_multiple(rows[target], 1, 1) + else: + rows[target] = row_multiple(rows[target], -1) + + +def macro_oracle(rows, op): + """Direct integer scalar semantics, independent of either primitive emitter.""" + tag, target = op[0], tuple(op[1]) + require(target in rows and target != WORK, "invalid scalar target") + if tag == "clear": + rows[target] = ZERO + elif tag == "copy": + source = tuple(op[2]) + require(source in rows and source not in (target, WORK), "invalid scalar source") + rows[target] = rows[source] + elif tag == "scale": + numerator, power = reduced(op[2], op[3]) + require(numerator and abs(numerator) & (abs(numerator) - 1) == 0, + "scale is not a signed power of two") + rows[target] = row_multiple(rows[target], numerator, power) + elif tag == "add": + source = tuple(op[2]) + require(source in rows and source not in (target, WORK), "invalid scalar source") + numerator, power = reduced(op[3], op[4]) + require(numerator, "zero addition coefficient") + rows[target] = row_sum(rows[target], row_multiple(rows[source], numerator, power)) + rows[WORK] = ZERO + else: + raise VerificationError("unknown scalar macro") + + +def naf_statistics(numerator): + """Length and nonzero count from the defining non-adjacent-digit recurrence.""" + require(type(numerator) is int and numerator > 0, "invalid NAF numerator") + length = weight = 0 + while numerator: + if numerator & 1: + digit = 1 if numerator == 1 or numerator % 4 == 1 else -1 + numerator -= digit + weight += 1 + numerator >>= 1 + length += 1 + return length, weight + + +def comparator_lengths(numerator, denominator_power): + """Count copy, shifts, non-leading digits, accumulation, and final clear.""" + require(numerator > 0, "invalid comparator numerator") + if numerator == 1 and denominator_power == 0: + return {"binary-forward": 2} + binary_length, binary_weight = numerator.bit_length(), numerator.bit_count() + naf_length, naf_weight = naf_statistics(numerator) + removed = trailing_twos(numerator) + odd = numerator >> removed + reverse_binary_length, reverse_binary_weight = odd.bit_length(), odd.bit_count() + reverse_naf_length, reverse_naf_weight = naf_statistics(odd) + return { + "binary-forward": binary_length + binary_weight + denominator_power + 1, + "naf-forward": naf_length + naf_weight + denominator_power + 1, + "binary-reverse": reverse_binary_length + reverse_binary_weight + 1 + + abs(reverse_binary_length - 1 + removed - denominator_power), + "naf-reverse": reverse_naf_length + reverse_naf_weight + 1 + + abs(reverse_naf_length - 1 + removed - denominator_power), + } + + +def validate_path(entry): + n, d = entry["numerator"], entry["denominator"] + require(type(n) is int and 1 <= n <= 127 and type(d) is int and d in (1, 2, 4, 8, 16), + "certificate coefficient outside domain") + require(gcd(n, d) == 1 and (n, d) != (1, 1), "unreduced or unit graph coefficient") + operations, sign = entry["operations"], entry["end_sign"] + require(isinstance(operations, list) and type(sign) is int and sign in (-1, 1), + "invalid certificate path") + require(type(entry["preparation_steps"]) is int and entry["preparation_steps"] == len(operations), + "certificate preparation invoice") + state, bound = d, n * d + for operation in operations: + if operation == "double": + state *= 2 + elif operation == "halve": + require(state % 2 == 0, "certificate path leaves coefficient grid") + state //= 2 + elif operation == "add": + state += d + elif operation == "subtract": + state -= d + elif operation == "negate": + state = -state + else: + raise VerificationError("unknown certificate operation") + require(abs(state) <= bound, "certificate path exceeds magnitude envelope") + require(state == sign * n, "certificate signed endpoint") + costs = comparator_lengths(n, d.bit_length() - 1) + require(canonical(entry["horner_macro_costs"]) == canonical(costs), "independent comparator lengths differ") + selected = len(operations) + 3 < min(costs.values()) + require(type(entry["strict_horner_improvement"]) is bool + and entry["strict_horner_improvement"] == selected, "certificate selection flag") + return selected + + +def prepare_certificate(certificate, programs): + require(certificate["schema"] == "jp8-grid-bounded-synthesis/1", "certificate schema") + all_entries, selected = {}, {} + for entry in certificate["entries"]: + key = entry["numerator"], entry["denominator"] + require(key not in all_entries, "duplicate certificate coefficient") + all_entries[key] = entry + if validate_path(entry): + selected[key] = entry + source = set() + for events in programs.values(): + for event in events: + if event[0] == "scalar" and event[1][0] == "add": + n, power = reduced(event[1][3], event[1][4]) + key = abs(n), 1 << power + if key != (1, 1) and abs(n) <= 127 and power <= 4: + source.add(key) + require(set(all_entries) == source, "certificate source coefficient coverage") + require(len(all_entries) == 49 and len(selected) == 7, "claimed coefficient census") + return all_entries, selected + + +def emit_baseline(op): + """Reconstruct PR696 binary/copy and unit words without importing a lowerer.""" + tag, target = op[0], tuple(op[1]) + require(target != WORK, "scalar work alias") + if tag == "clear": + return [("clear", target)] + if tag == "copy": + source = tuple(op[2]) + require(source not in (target, WORK), "scalar source alias") + return [("copy", target, source)] + if tag == "scale": + numerator, power = reduced(op[2], op[3]) + require(numerator and abs(numerator) & (abs(numerator) - 1) == 0, + "scale is not a signed power of two") + shift = abs(numerator).bit_length() - 1 - power + return ([("double" if shift > 0 else "halve", target)] * abs(shift) + + ([("negate", target)] if numerator < 0 else [])) + require(tag == "add", "unknown scalar macro") + source = tuple(op[2]) + require(source not in (target, WORK), "scalar source alias") + numerator, power = reduced(op[3], op[4]) + require(numerator, "zero addition coefficient") + accumulate = "add" if numerator > 0 else "subtract" + if abs(numerator) == 1 and power == 0: + return [(accumulate, target, source), ("clear", WORK)] + word = [("copy", WORK, source)] + for position in range(abs(numerator).bit_length() - 2, -1, -1): + word.append(("double", WORK)) + if (abs(numerator) >> position) & 1: + word.append(("add", WORK, source)) + word += [("halve", WORK)] * power + return word + [(accumulate, target, WORK), ("clear", WORK)] + + +def emit_replacement(op, selected): + if op[0] != "add": + return emit_baseline(op) + numerator, power = reduced(op[3], op[4]) + entry = selected.get((abs(numerator), 1 << power)) + if entry is None: + return emit_baseline(op) + target, source = tuple(op[1]), tuple(op[2]) + word = [("copy", WORK, source)] + for operation in entry["operations"]: + word.append((operation, WORK, source) if operation in ("add", "subtract") + else (operation, WORK)) + sign = (1 if numerator > 0 else -1) * entry["end_sign"] + return word + [("add" if sign > 0 else "subtract", target, WORK), ("clear", WORK)] + + +def historical_count(op): + if op[0] in ("clear", "copy"): + return 1 + if op[0] == "scale": + n, power = reduced(op[2], op[3]) + return abs(abs(n).bit_length() - 1 - power) + (n < 0) + n, power = reduced(op[3], op[4]) + return abs(n).bit_length() + abs(n).bit_count() + power + 2 + + +class Trace: + def __init__(self): + self.rows = initial_rows() + self.tags = Counter() + self.maximum_denominator = 0 + self.maximum_l1_numerator, self.maximum_l1_power = 1, 0 + self.source_reads = self.register_reads = 0 + self.digest = hashlib.sha256() + + def run(self, op, word, frame, event_index): + target = tuple(op[1]) + source = tuple(op[2]) if op[0] in ("copy", "add") else None + allowed_writes = {target, WORK} if op[0] == "add" else {target} + allowed_reads = allowed_writes | ({source} if source is not None else set()) + for instruction in word: + tag, written = instruction[0], tuple(instruction[1]) + require(written in allowed_writes, "primitive writes outside its macro") + reads = [] if tag in ("clear", "copy") else [written] + if len(instruction) == 3: + read_register = tuple(instruction[2]) + require(read_register in allowed_reads, "primitive reads outside its macro") + reads.append(read_register) + primitive(self.rows, instruction) + self.source_reads += reads.count(source) if source is not None else 0 + self.register_reads += len(reads) + self.tags[tag] += 2 + self.maximum_denominator = max(self.maximum_denominator, self.rows[written][0]) + # Compare exact dyadic norms by integer cross multiplication. + # All initial basis rows have norm one; only the written row changes. + power, coefficients = self.rows[written] + numerator = sum(abs(value) for value in coefficients.values()) + if (numerator << self.maximum_l1_power) > (self.maximum_l1_numerator << power): + self.maximum_l1_numerator, self.maximum_l1_power = numerator, power + self.digest.update(canonical([event_index, frame, instruction]) + b"\n") + if op[0] == "add": + require(self.rows[WORK] == ZERO, "dirty coefficient scratch") + + def receipt(self): + denominator = 1 << self.maximum_l1_power + common = gcd(self.maximum_l1_numerator, denominator) + numerator, denominator = self.maximum_l1_numerator // common, denominator // common + maximum_l1 = str(numerator) if denominator == 1 else f"{numerator}/{denominator}" + return {"real_primitives": sum(self.tags.values()), + "primitive_tags": dict(sorted(self.tags.items())), + "primitive_word_sha256": self.digest.hexdigest(), + "maximum_fractional_denominator_exponent": self.maximum_denominator, + "maximum_scalar_prefix_row_l1": maximum_l1, + "real_macro_source_reads": 2 * self.source_reads, + "real_total_register_reads": 2 * self.register_reads} + + +def full_endpoint(rows, orientation): + for index in range(N): + expected = {index: 1} + if orientation == "forward" and V <= index < 2 * V: + expected[index - V] = 1 + elif orientation == "backward" and index < V: + expected[index + V] = -1 + require(rows[("L", index)] == (0, expected), "full scalar endpoint") + require(all(rows[register] == ZERO for register in PRIVATE), "private scalar endpoint") + + +def replay_orientation(orientation, events, checks, selected): + require(sha(events) == checks["sha256"], "source orientation semantic hash") + baseline, replacement = Trace(), Trace() + oracle = initial_rows() + paid = Counter() + historical = macros = additions = units = changed = 0 + non_scalar_digest = hashlib.sha256() + frame_digest = hashlib.sha256() + for index, event in enumerate(events): + if event[0] != "scalar": + require(event[0] in ("climb", "center", "phase", "adapter", "residual_adapter"), + "unknown nonscalar event") + if event[0] == "climb": + paid[event[5]] += 1 + elif event[0] == "center": + paid[event[4]] += 1 + non_scalar_digest.update(canonical([index, event]) + b"\n") + continue + require(len(event) == 3, "scalar event arity") + op, frame = event[1:] + old_word, new_word = emit_baseline(op), emit_replacement(op, selected) + require(len(new_word) <= len(old_word), "replacement raised primitive bill") + macros += 1 + historical += 2 * historical_count(op) + changed += old_word != new_word + if op[0] == "add": + additions += 1 + n, power = reduced(op[3], op[4]) + units += abs(n) == 1 and power == 0 + macro_oracle(oracle, op) + baseline.run(op, old_word, frame, index) + replacement.run(op, new_word, frame, index) + # Every primitive is restricted to target and W, so checking the written + # rows propagates equality of all 725 columns/registers by induction. + target = tuple(op[1]) + for trace in (baseline, replacement): + require(trace.rows[target] == oracle[target], "macro target differs from integer oracle") + require(trace.rows[WORK] == oracle[WORK], "macro scratch differs from integer oracle") + frame_digest.update(canonical([index, frame]) + b"\n") + for rows in (oracle, baseline.rows, replacement.rows): + full_endpoint(rows, orientation) + require(baseline.rows == replacement.rows == oracle, "all-register endpoint comparison") + require(len(events) == checks["events"] and macros == checks["scalar_macros"], "source event/macro census") + require(historical == checks["real_component_primitive_bound"], "historical primitive invoice") + require(dict(paid) == {int(key): value for key, value in checks["paid_profile"].items()}, "paid profile") + old, new = baseline.receipt(), replacement.receipt() + require(historical - old["real_primitives"] == 2 * (additions + units), "PR696 primitive invoice") + require(new["maximum_fractional_denominator_exponent"] <= old["maximum_fractional_denominator_exponent"], + "replacement increases full-trace fractional guard") + require((replacement.maximum_l1_numerator << baseline.maximum_l1_power) <= + (baseline.maximum_l1_numerator << replacement.maximum_l1_power), + "replacement increases scalar prefix row-L1 maximum") + return {"total_exact_input_columns": N + len(PRIVATE), "logical_input_columns": N, + "arbitrary_private_input_columns": len(PRIVATE), "arbitrary_helper_columns_restored": N - 2 * V, + "private_registers_erased": len(PRIVATE), "events": len(events), "scalar_macros": macros, + "macro_boundaries_compared_with_integer_oracle": macros, "changed_macros": changed, + "addition_macros_with_coefficient_work_clear": additions, + "historical_real_primitives": historical, "lowerings": {"pr696": old, "replacement": new}, + "saved_real_primitives_vs_pr696": old["real_primitives"] - new["real_primitives"], + "extra_real_source_reads_vs_pr696": new["real_macro_source_reads"] - old["real_macro_source_reads"], + "non_scalar_event_indexed_sha256": non_scalar_digest.hexdigest(), + "scalar_frame_indexed_sha256": frame_digest.hexdigest(), + "paid_profile": {str(key): value for key, value in sorted(paid.items())}} + + +def local_word_check(op, word, *, coefficient_grid=False): + """Three independent integer columns expose dirty scratch and prefix faults.""" + t, s = ("T", 0), ("S", 0) + rows = {t: (0, {0: 1}), s: (0, {1: 1}), WORK: (0, {2: 1})} + oracle = rows.copy() + macro_oracle(oracle, op) + initialized = False + for instruction in word: + require(tuple(instruction[1]) != s, "source register modified") + primitive(rows, instruction) + if tuple(instruction[1]) == WORK: + initialized = True + if coefficient_grid and initialized: + scratch_power, scratch_values = rows[WORK] + require(set(scratch_values) <= {1}, "dirty scratch dependency") + n, power = reduced(op[3], op[4]) + require(scratch_power <= power, "coefficient grid excursion") + require(abs(scratch_values.get(1, 0)) <= abs(n) * (1 << scratch_power), + "coefficient magnitude excursion") + require(rows[WORK] == oracle[WORK], "dirty coefficient scratch") + require(rows == oracle, "incorrect local macro endpoint") + + +def negative_controls(selected): + t, s = ("T", 0), ("S", 0) + op = ["add", list(t), list(s), 5, 2] + word = emit_replacement(op, selected) + local_word_check(op, word, coefficient_grid=True) + half_index = next(i for i, instruction in enumerate(word) if instruction[0] == "halve") + wrong_half = list(word) + wrong_half[half_index] = ("double", WORK) + cases = { + "wrong_accumulation_sign": (op, word[:-2] + [("subtract", t, WORK)] + word[-1:], False, + "incorrect local macro endpoint"), + "dirty_scratch_missing_clear": (op, word[:-1], False, "dirty coefficient scratch"), + "incorrect_halving": (op, wrong_half, False, "incorrect local macro endpoint"), + "endpoint_neutral_grid_excursion": + (op, word[:1] + [("halve", WORK)] * 2 + [("double", WORK)] * 2 + word[1:], + True, "coefficient grid excursion"), + "incorrect_scale_sign": (["scale", list(t), -2, 1], [("double", t)], False, + "incorrect local macro endpoint"), + "missing_source_copy": (op, word[1:], True, "dirty scratch dependency"), + } + result = {} + for name, (macro, bad_word, grid, expected) in cases.items(): + try: + local_word_check(macro, bad_word, coefficient_grid=grid) + except VerificationError as error: + require(str(error) == expected, "negative control failed for an unrelated reason: " + name) + result[name] = str(error) + else: + raise VerificationError("accepted negative control: " + name) + # Demonstrate that the grid control isolates a prefix violation: its endpoint + # is nevertheless correct when the prefix guard is deliberately disabled. + local_word_check(op, cases["endpoint_neutral_grid_excursion"][1], coefficient_grid=False) + return result + + +def positive_controls(): + require(row(3, {0: -12, 1: 4}) == (1, {0: -3, 1: 1}), "row common-denominator normalization") + require(row_sum((2, {0: 1}), (1, {0: -1, 1: 3})) == (2, {0: -1, 1: 6}), + "unaligned denominator addition") + require(row_multiple((0, {0: -1}), 1, 1) == (1, {0: -1}), "negative exact halving") + require(row_sum((3, {0: 3}), (3, {0: 3}), -1) == ZERO, "exact cancellation") + require(reduced(2, -1) == (-2, 0), "negative input denominator") + require(naf_statistics(31) == (6, 2), "NAF carry control") + return {"integer_row_arithmetic_cases": 5, "NAF_carry_cases": 1} + + +def verify(programs, checks, inherited, certificate): + """Return independently reconstructed, deterministic scalar evidence.""" + require(set(programs) == {"forward", "backward"}, "program orientation coverage") + positive = positive_controls() + entries, selected = prepare_certificate(certificate, programs) + programs_result = {orientation: replay_orientation(orientation, programs[orientation], checks[orientation], selected) + for orientation in ("forward", "backward")} + return {"status": "PASS_JP8_INTEGER_SCALAR_CROSSCHECK", "schema": "jp8-integer-scalar-crosscheck/1", + "input_semantic_sha256": {"programs": sha(programs), "checks": sha(checks), + "inherited": sha(inherited), "certificate": sha(certificate)}, + "arithmetic": "normalized sparse integer rows with a common power-of-two denominator", + "certificate_coefficients_checked": len(entries), "selected_replacements": len(selected), + "selected_coefficients": [f"{n}/{d}" for n, d in sorted(selected, key=lambda key: (key[0] * 16 // key[1]))], + "independently_recomputed_comparator_lengths": { + f"{n}/{d}": comparator_lengths(n, d.bit_length() - 1) for n, d in sorted(selected)}, + "programs": programs_result, "positive_controls": positive, + "negative_controls": negative_controls(selected), + "scope": "Historical PR626 JP8 scalar projections only; no complex-event or multiplication-bound proof.", + "finite_graph_optimality_rechecked": False, "kappa_claim": None} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--programs", type=Path, default=PROVIDER / "LOCAL-PROGRAMS.json.gz") + parser.add_argument("--checks", type=Path, default=PROVIDER / "LOCAL-CHECKS.json") + parser.add_argument("--inherited", type=Path, default=PROVIDER / "INDEPENDENT-LOCAL-REPLAY.json") + parser.add_argument("--certificate", type=Path, default=HERE / "CERTIFICATE.json") + parser.add_argument("--json", action="store_true", help="print deterministic receipt") + args = parser.parse_args() + result = verify(read(args.programs), read(args.checks), read(args.inherited), read(args.certificate)) + if args.json: + print(json.dumps(result, indent=2, sort_keys=True)) + else: + print(f"{result['status']} columns=725 orientations=2 independent_integer_macro_oracle=pass " + f"negative_controls={len(result['negative_controls'])}") + + +if __name__ == "__main__": + main() diff --git a/research/jp8-grid-bounded-synthesis/pareto.py b/research/jp8-grid-bounded-synthesis/pareto.py new file mode 100644 index 0000000000..c6d9b2c43f --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/pareto.py @@ -0,0 +1,349 @@ +#!/usr/bin/env python3 +"""Exact instruction/source-read Pareto audit of the same 49 bounded graphs. + +Prepared for Philipp (@mightyOil), with substantial OpenAI Codex assistance. +Apache-2.0. No emitted circuit is changed. The optional weighted-cost +diagnostic is algebraic sensitivity, not a physical source-read price. + +Run with Python 3.11+: python3 -I -B research/jp8-grid-bounded-synthesis/pareto.py +The label search is certified by complete state coverage, rational witness +replay, pairwise nondomination and every-edge local closure. The checker +constructs successors independently with Fraction arithmetic. It does not +trust the search's integer successor table or pruning decisions. +""" +from collections import Counter +from copy import deepcopy +from fractions import Fraction as Q +import gzip +import hashlib +import heapq +import importlib.util +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PROGRAM = "research/community-k492-audit/pr626/replay/mixed-global/base/providers/jp8/LOCAL-PROGRAMS.json.gz" +OPERATIONS = ("double", "halve", "add", "subtract", "negate") +T, S, W = ("T", 0), ("S", 0), ("W", 0) + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def domain(a, d): + need(type(a) is int and 1 <= a <= 127, "Pareto numerator domain") + need(type(d) is int and d in (1, 2, 4, 8, 16), "Pareto denominator domain") + need(Q(a, d).numerator == a and (a, d) != (1, 1), "Pareto reduced nonunit domain") + return a*d + + +def successors(state, d, bound): + """Search edges retain differently priced operations to the same state.""" + edges = [(2*state, "double", 0), (state+d, "add", 1), + (state-d, "subtract", 1), (-state, "negate", 0)] + if state % 2 == 0: + edges.append((state//2, "halve", 0)) + return [(nxt, op, reads) for nxt, op, reads in edges if abs(nxt) <= bound] + + +def covered(pair, pairs): + return any(x <= pair[0] and y <= pair[1] for x, y in pairs) + + +def synthesize(a, d): + """Label-setting search; positive instruction cost makes cycle pruning safe.""" + bound = domain(a, d) + labels = {state: {} for state in range(-bound, bound+1)} + labels[d][(0, 0)] = () + queue = [(0, 0, d, ())] + while queue: + steps, reads, state, word = heapq.heappop(queue) + if labels[state].get((steps, reads)) != word: + continue + for nxt, operation, increment in successors(state, d, bound): + pair = steps+1, reads+increment + if covered(pair, labels[nxt]): + continue + labels[nxt] = {old: path for old, path in labels[nxt].items() + if not (pair[0] <= old[0] and pair[1] <= old[1])} + path = word+(operation,) + labels[nxt][pair] = path + heapq.heappush(queue, (*pair, nxt, path)) + return {"bound": bound, "labels": labels} + + +def rational_step(value, operation): + if operation == "double": return value*2 + if operation == "halve": return value/2 + if operation == "negate": return -value + if operation == "add": return value+1 + if operation == "subtract": return value-1 + raise ValueError("Pareto unknown operation") + + +def witness(a, d, word): + value, reads = Q(1), 0 + for operation in word: + value = rational_step(value, operation) + need(abs(value) <= a, "Pareto witness magnitude") + need(d % value.denominator == 0, "Pareto witness grid") + reads += operation in ("add", "subtract") + return int(value*d), reads + + +def validate(a, d, certificate): + """A witnessed, closed antichain proves all Pareto labels without searching. + + Any finite walk is dominated by a stored label, by induction from (0,0) + using local closure. Every stored label has an actual witness. Thus the + two reachable upward closures agree; pairwise antichains give the exact + Pareto sets. This checks all prefixes of every witness and every edge. + """ + bound = domain(a, d) + need(type(certificate["bound"]) is int and certificate["bound"] == bound, + "Pareto declared bound") + labels = certificate["labels"] + need(set(labels) == set(range(-bound, bound+1)), "Pareto state coverage") + need(labels[d].get((0, 0)) == (), "Pareto initial label") + for state, costs in labels.items(): + need(type(state) is int and costs, "Pareto empty or invalid state") + for pair, word in costs.items(): + need(len(pair) == 2 and all(type(x) is int and x >= 0 for x in pair), + "Pareto label type") + need(pair[0] == len(word), "Pareto witness instruction count") + end, reads = witness(a, d, word) + need(reads == pair[1], "Pareto witness source-read count") + need(end == state, "Pareto witness endpoint") + for pair in costs: + need(not covered(pair, [other for other in costs if other != pair]), + "Pareto dominated state label") + edge_obligations = 0 + for state, costs in labels.items(): + for operation in OPERATIONS: + value = rational_step(Q(state, d), operation) + if abs(value) > a or d % value.denominator: + continue + target = int(value*d) + increment = int(operation in ("add", "subtract")) + for steps, reads in costs: + need(covered((steps+1, reads+increment), labels[target]), + "Pareto edge closure") + edge_obligations += 1 + return edge_obligations + + +def endpoint_frontier(a, labels): + result = {} + for goal in (a, -a): + for pair, word in sorted(labels[goal].items()): + if not covered(pair, result): + result = {old: path for old, path in result.items() + if not (pair[0] <= old[0] and pair[1] <= old[1])} + result[pair] = (goal, word) + return [{"preparation_instructions": steps, "preparation_source_reads": reads, + "macro_instructions": steps+3, "macro_source_reads": reads+1, + "end_sign": 1 if goal > 0 else -1, "operations": list(word)} + for (steps, reads), (goal, word) in sorted(result.items())] + + +def macro_word(word, sign=1): + result = [("copy", W, S)] + result.extend((op, W, S) if op in ("add", "subtract") else (op, W) for op in word) + return result+[("add" if sign > 0 else "subtract", T, W), ("clear", W)] + + +def macro_stats(word, a, d): + need(word[0] == ("copy", W, S), "Pareto macro initial copy") + need(word[-1] == ("clear", W) and word[-2] in (("add", T, W), ("subtract", T, W)), + "Pareto macro paid boundary") + reads = sum(len(op) == 3 and op[0] in ("copy", "add", "subtract") and op[2] == S + for op in word) + value, grid, magnitude = Q(1), True, True + for op in word[1:-2]: + need(op[1] == W, "Pareto comparator writes another register") + need((len(op) == 3 and op[2] == S) if op[0] in ("add", "subtract") else len(op) == 2, + "Pareto comparator source operand") + value = rational_step(value, op[0]) + grid &= d % value.denominator == 0 + magnitude &= abs(value) <= a + need(value*(1 if word[-2][0] == "add" else -1) == Q(a, d), + "Pareto comparator endpoint") + return {"instructions": len(word), "source_reads": reads, + "within_grid": grid, "within_magnitude": magnitude} + + +def pinned_inputs(): + pins = json.loads((HERE / "SOURCES.json").read_text()) + payload = gzip.decompress((ROOT / PROGRAM).read_bytes()) + need(hashlib.sha256(payload).hexdigest() == pins["files"][PROGRAM]["sha256"], + "Pareto program source pin") + for name in ("vendor/pr837/lower.py", "vendor/pr837/vendor/pr696_lower.py"): + need(hashlib.sha256((HERE / name).read_bytes()).hexdigest() == pins["vendored"][name]["sha256"], + "Pareto comparator source pin") + spec = importlib.util.spec_from_file_location("pareto_pinned_horner", HERE / "vendor/pr837/lower.py") + horner = importlib.util.module_from_spec(spec) + spec.loader.exec_module(horner) + programs = json.loads(payload) + counts = {orientation: Counter(abs(Q(e[1][3], e[1][4])) for e in events + if e[0] == "scalar" and e[1][0] == "add") for orientation, events in programs.items()} + need(set(counts) == {"forward", "backward"}, "Pareto orientation coverage") + return counts, horner + + +def negative_controls(): + certificate = synthesize(5, 2) + validate(5, 2, certificate) + mutations = {} + missing = deepcopy(certificate) + del missing["labels"][5][(4, 1)] + mutations["missing_lower_read_tradeoff"] = (missing, "Pareto edge closure") + forged = deepcopy(certificate) + forged["labels"][5][(3, 1)] = forged["labels"][5].pop((3, 2)) + mutations["forged_source_reads"] = (forged, "Pareto witness source-read count") + wrong = deepcopy(certificate) + wrong["bound"] += 1 + mutations["wrong_magnitude_bound"] = (wrong, "Pareto declared bound") + rejected = {} + for name, (bad, reason) in mutations.items(): + try: + validate(5, 2, bad) + except ValueError as error: + need(str(error) == reason, "Pareto control wrong rejection: "+name) + rejected[name] = reason + else: + raise ValueError("Pareto accepted control: "+name) + try: + macro_stats(macro_word(("halve", "add", "add"))[1:], 5, 2) + except ValueError as error: + need(str(error) == "Pareto macro initial copy", "Pareto copy control wrong rejection") + rejected["uncharged_initial_copy"] = str(error) + else: + raise ValueError("Pareto accepted uncharged copy") + return rejected + + +def sensitivity(selected, counts): + """Exact lower envelope for an explicitly hypothetical nonnegative price.""" + breaks = set() + for row in selected: + left, right = row["frontier"] + breaks.add(Q(right["macro_instructions"]-left["macro_instructions"], + left["macro_source_reads"]-right["macro_source_reads"])) + breaks = sorted(breaks) + intervals = [] + for lower, upper in zip([Q(0)]+breaks, breaks+[None]): + price = (lower+upper)/2 if upper is not None else lower+1 + deltas = {o: [0, 0] for o in sorted(counts)} + chosen = {} + for row in selected: + point = min(row["frontier"], key=lambda x: + x["macro_instructions"]+price*x["macro_source_reads"]) + chosen[row["coefficient"]] = [point["macro_instructions"], point["macro_source_reads"]] + base = row["comparators"]["binary-forward"] + for orientation, counter in counts.items(): + n = 2*counter[Q(row["coefficient"])] + deltas[orientation][0] += n*(point["macro_instructions"]-base["instructions"]) + deltas[orientation][1] += n*(point["macro_source_reads"]-base["source_reads"]) + intervals.append({"lower": str(lower), "upper": str(upper) if upper is not None else None, + "delta_instructions_source_reads_vs_696": deltas, "choices": chosen}) + current_deltas = intervals[0]["delta_instructions_source_reads_vs_696"] + need(current_deltas["forward"] == current_deltas["backward"], "Pareto current orientation sensitivity") + primitive_delta, read_delta = current_deltas["forward"] + need(primitive_delta < 0 < read_delta, "Pareto current tradeoff sign") + return {"model": "instructions + p * source_reads; p >= 0 is hypothetical additional overhead", + "physical_price_claimed": False, "breakpoints": list(map(str, breaks)), + "endpoint_rule": "Intervals describe interiors; adjacent choices tie at a breakpoint; p=0 uses the first.", + "intervals": intervals, + "current_schedule_gain_vs_696": f"{-primitive_delta} - {read_delta}*p per orientation", + "current_schedule_break_even": str(Q(-primitive_delta, read_delta)), + "lower_read_15_over_4_prior_art": "Bounded signed-Horner word credited to PR734; no new construction claim."} + + +def verify(entries): + """Return a deterministic receipt; accepts the existing entry list or map.""" + values = list(entries.values()) if isinstance(entries, dict) else list(entries) + counts, horner = pinned_inputs() + expected = {q for counter in counts.values() for q in counter + if q != 1 and q.numerator <= 127 and q.denominator <= 16} + supplied = [Q(e["numerator"], e["denominator"]) for e in values] + need(len(supplied) == len(set(supplied)) == 49 and set(supplied) == expected, + "Pareto coefficient coverage") + summaries, selected = [], [] + totals = Counter() + for entry in sorted(values, key=lambda x: Q(x["numerator"], x["denominator"])): + a, d = entry["numerator"], entry["denominator"] + certificate = synthesize(a, d) + obligations = validate(a, d, certificate) + labels = certificate["labels"] + frontier = endpoint_frontier(a, labels) + end, reads = witness(a, d, entry["operations"]) + need(type(entry["end_sign"]) is int and entry["end_sign"] in (-1, 1) and + end == entry["end_sign"]*a, "Pareto current witness endpoint") + need(type(entry["preparation_steps"]) is int and entry["preparation_steps"] == len(entry["operations"]), + "Pareto current instruction count") + need((len(entry["operations"]), reads) == + (frontier[0]["preparation_instructions"], frontier[0]["preparation_source_reads"]), + "Pareto current shortest witness does not minimize reads") + for point in frontier: + stats = macro_stats(macro_word(point["operations"], point["end_sign"]), a, d) + need((stats["instructions"], stats["source_reads"]) == + (point["macro_instructions"], point["macro_source_reads"]), "Pareto macro accounting") + serialized = [[state, [[*pair, list(word)] for pair, word in sorted(costs.items())]] + for state, costs in sorted(labels.items())] + summary = {"coefficient": str(Q(a, d)), "vertices": len(labels), + "labels": sum(map(len, labels.values())), "edge_label_obligations": obligations, + "label_certificate_sha256": hashlib.sha256(canonical(serialized)).hexdigest(), + "macro_frontier": [[p["macro_instructions"], p["macro_source_reads"]] for p in frontier]} + summaries.append(summary) + for key in ("vertices", "labels", "edge_label_obligations"): + totals[key] += summary[key] + op = ["add", list(T), list(S), a, d] + comparators = {name: macro_stats(word, a, d) for name, word in horner.candidates(op).items()} + baseline = comparators["binary-forward"] + need(baseline["source_reads"] == a.bit_count() and baseline["instructions"] == + 2+(a.bit_length()-1)+a.bit_count()+(d.bit_length()-1), "Pareto binary accounting") + is_selected = frontier[0]["macro_instructions"] < min(x["instructions"] for x in comparators.values()) + need(entry["strict_horner_improvement"] is is_selected, "Pareto selected coefficient flag") + if is_selected: + selected.append({"coefficient": str(Q(a, d)), "frontier": frontier, "comparators": comparators, + "occurrences": {o: c[Q(a, d)] for o, c in sorted(counts.items())}}) + need(len(selected) == 7 and all(len(row["frontier"]) == 2 for row in selected) and + all(len(row["macro_frontier"]) == (2 if row["coefficient"] in + {s["coefficient"] for s in selected} else 1) for row in summaries), "Pareto frontier inventory") + aggregate = {} + for orientation, counter in sorted(counts.items()): + costs = {name: [0, 0] for name in ("original-binary", "binary-forward", "naf-forward", + "binary-reverse", "naf-reverse", "best-four-stable", "best-four-min-read-cost-tie", "current")} + for row in selected: + n = 2*counter[Q(row["coefficient"])] + pairs = {k: [v["instructions"], v["source_reads"]] for k, v in row["comparators"].items()} + pairs["original-binary"] = [pairs["binary-forward"][0]+1, pairs["binary-forward"][1]] + best = min(row["comparators"], key=lambda k: row["comparators"][k]["instructions"]) + pairs["best-four-stable"] = pairs[best] + minimum = min(v["instructions"] for v in row["comparators"].values()) + pairs["best-four-min-read-cost-tie"] = [minimum, min(v["source_reads"] for v in + row["comparators"].values() if v["instructions"] == minimum)] + pairs["current"] = [row["frontier"][0]["macro_instructions"], row["frontier"][0]["macro_source_reads"]] + for name, pair in pairs.items(): + costs[name][0] += n*pair[0] + costs[name][1] += n*pair[1] + aggregate[orientation] = costs + return {"status": "PASS_JP8_PARETO_SOURCE_READS", "coefficients": len(summaries), + "cost_coordinates": ["primitive_instructions", "reads_of_unchanged_macro_source"], + "common_nonunit_macro_overhead": [3, 1], "state_totals": dict(totals), + "all_submitted_shortest_witnesses_minimize_reads": True, "graphs": summaries, + "selected_frontiers": selected, "selected_occurrence_totals_both_real_components": aggregate, + "hypothetical_sensitivity": sensitivity(selected, counts), "negative_controls": negative_controls(), + "emitted_circuits_changed": False} + + +if __name__ == "__main__": + certificate = json.loads((HERE / "CERTIFICATE.json").read_text()) + print(json.dumps(verify(certificate["entries"]), indent=2, sort_keys=True)) diff --git a/research/jp8-grid-bounded-synthesis/replay.py b/research/jp8-grid-bounded-synthesis/replay.py new file mode 100644 index 0000000000..f25c0950be --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/replay.py @@ -0,0 +1,318 @@ +"""Exact, all-column primitive replay of the two pinned JP8 scalar words. + +The interpreter uses sparse Fraction rows and does not evaluate scalar macros as +an implementation shortcut. Logical helpers enter arbitrarily and are restored; +eight centre registers and coefficient work enter arbitrarily and are erased. +Standard library only; checks stay active under ``python -I -O``. +""" +from collections import Counter +from fractions import Fraction as Q +import hashlib +import json + +from synth import lower, reference_lower + +WORK = ("W", 0) +N = 716 +V = 112 +CENTRES = tuple(("C", i) for i in range(8)) +PRIMITIVES = {"clear", "copy", "double", "halve", "negate", "add", "subtract"} + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def historical_lower(op): + """Literal original clear/binary/Horner emitter, before PR696 copy removal.""" + tag, target = op[0], tuple(op[1]) + if tag == "clear": + return [("clear", target)] + if tag == "copy": + return [("copy", target, tuple(op[2]))] + if tag == "scale": + q = Q(op[2], op[3]) + a, b = abs(q.numerator), q.denominator + require(a and a & (a - 1) == 0 and b & (b - 1) == 0, + "historical scale must be signed power of two") + shift = a.bit_length() - b.bit_length() + return ([("double" if shift > 0 else "halve", target)] * abs(shift) + + ([("negate", target)] if q < 0 else [])) + require(tag == "add", "unknown scalar macro") + source, q = tuple(op[2]), Q(op[3], op[4]) + require(q and q.denominator & (q.denominator - 1) == 0, + "historical addition must be nonzero dyadic") + require(source != target and WORK not in (target, source), "scalar alias") + word = [("clear", WORK)] + for index, bit in enumerate(bin(abs(q.numerator))[2:]): + if index: + word.append(("double", WORK)) + if bit == "1": + word.append(("add", WORK, source)) + word.extend([("halve", WORK)] * (q.denominator.bit_length() - 1)) + word.extend([("add" if q > 0 else "subtract", target, WORK), + ("clear", WORK)]) + return word + + +def baseline_count(op): + tag = op[0] + if tag in ("clear", "copy"): + return 1 + q = Q(op[3], op[4]) if tag == "add" else Q(op[2], op[3]) + a, b = abs(q.numerator), q.denominator + if tag == "scale": + return abs(a.bit_length() - b.bit_length()) + int(q < 0) + return 3 + a.bit_length() - 1 + a.bit_count() + b.bit_length() - 1 + + +def initial_rows(): + rows = {("L", r): {r: Q(1)} for r in range(N)} + rows.update({register: {N + i: Q(1)} + for i, register in enumerate((WORK,) + CENTRES)}) + return rows + + +class Interpreter: + def __init__(self): + self.rows = initial_rows() + self.tags = Counter() + self.denominator_exponent = 0 + self.maximum_row_l1 = Q(1) + self.word_hash = hashlib.sha256() + self.source_reads = 0 + self.all_register_reads = 0 + self.instructions = 0 + + def step(self, primitive, frame, event_index, macro_source=None): + tag, target = primitive[:2] + target = tuple(target) + require(tag in PRIMITIVES, "unknown primitive: " + str(tag)) + require(target in self.rows, "unknown target register") + require(len(primitive) == (3 if tag in ("copy", "add", "subtract") else 2), + "primitive arity") + reads = [] + if tag != "clear": + if tag != "copy": + reads.append(target) + if tag in ("copy", "add", "subtract"): + source = tuple(primitive[2]) + require(source in self.rows, "unknown source register") + require(source != target, "primitive source alias") + reads.append(source) + self.all_register_reads += len(reads) + self.source_reads += reads.count(macro_source) if macro_source is not None else 0 + if tag == "clear": + self.rows[target] = {} + elif tag == "copy": + self.rows[target] = self.rows[source].copy() + elif tag in ("double", "halve", "negate"): + q = {"double": Q(2), "halve": Q(1, 2), "negate": Q(-1)}[tag] + self.rows[target] = {j: q * x for j, x in self.rows[target].items()} + else: + target_row = self.rows[target] + for j, x in self.rows[source].items(): + value = target_row.get(j, Q(0)) + (x if tag == "add" else -x) + if value: + target_row[j] = value + else: + target_row.pop(j, None) + # Only the written row can introduce a denominator not already seen. + for x in self.rows[target].values(): + denominator = x.denominator + require(denominator & (denominator - 1) == 0, "nondyadic trace row") + self.denominator_exponent = max(self.denominator_exponent, + denominator.bit_length() - 1) + # Initial basis rows have norm one. Only this written row can change + # the maximum; this measures scalar coordinates, not physical frames. + self.maximum_row_l1 = max(self.maximum_row_l1, + sum((abs(x) for x in self.rows[target].values()), Q(0))) + self.tags[tag] += 2 # same circuit separately on real and imaginary parts + self.instructions += 1 + self.word_hash.update(canonical([event_index, frame, primitive]) + b"\n") + + def run_macro(self, op, word, frame, index): + tag, target = op[0], tuple(op[1]) + source = tuple(op[2]) if tag in ("add", "copy") else None + require(target in self.rows and (source is None or source in self.rows), + "unknown scalar register") + require(WORK not in (target, source), "coefficient work used by scalar macro") + allowed_writes = {target, WORK} if tag == "add" else {target} + allowed_reads = allowed_writes | ({source} if source is not None else set()) + for primitive in word: + require(tuple(primitive[1]) in allowed_writes, "write outside scalar macro") + if len(primitive) == 3: + require(tuple(primitive[2]) in allowed_reads, "read outside scalar macro") + self.step(primitive, frame, index, source) + if tag == "add": + require(not self.rows[WORK], "coefficient work survived addition macro") + + def endpoint(self, orientation): + for r in range(N): + expected = {r: Q(1)} + if orientation == "forward" and V <= r < 2 * V: + expected[r - V] = Q(1) + elif orientation == "backward" and r < V: + expected[r + V] = Q(-1) + require(self.rows[("L", r)] == expected, + f"{orientation}: full exact input-column map at L{r}") + require(all(not self.rows[r] for r in (WORK,) + CENTRES), + "arbitrary private input columns survived endpoint") + + def receipt(self): + return { + "real_primitives": 2 * self.instructions, + "primitive_tags": dict(sorted(self.tags.items())), + "primitive_word_sha256": self.word_hash.hexdigest(), + "maximum_fractional_denominator_exponent": self.denominator_exponent, + "maximum_scalar_prefix_row_l1": str(self.maximum_row_l1), + "real_macro_source_reads": 2 * self.source_reads, + "real_total_register_reads": 2 * self.all_register_reads, + } + + +def source_reads(word, op): + if op[0] not in ("add", "copy"): + return 0 + source = tuple(op[2]) + return sum(1 for primitive in word if len(primitive) == 3 + and tuple(primitive[2]) == source) + + +def replay_orientation(orientation, events, checks, inherited, entries): + interpreters = {name: Interpreter() for name in ("historical", "pr696", "replacement")} + paid = Counter() + baseline = macros = additions = units = changed = 0 + non_scalar_hash = hashlib.sha256() + replacement_non_scalar_hash = hashlib.sha256() + frame_hash = hashlib.sha256() + replacement_frame_hash = hashlib.sha256() + non_scalar_count = 0 + env = {register: Q(1) for register in initial_rows()} + peak = Q(1) + changed_coefficients = {} + boundary_comparisons = 0 + for index, event in enumerate(events): + if event[0] != "scalar": + require(event[0] in ("climb", "center", "phase", "adapter", "residual_adapter"), + "unknown event") + if event[0] == "climb": + paid[event[5]] += 1 + elif event[0] == "center": + paid[event[4]] += 1 + payload = canonical([index, event]) + b"\n" + non_scalar_hash.update(payload) + # The transformed stream emits exactly the original event at this slot. + replacement_event = event + replacement_non_scalar_hash.update(canonical([index, replacement_event]) + b"\n") + non_scalar_count += 1 + continue + require(len(event) == 3, "scalar event arity") + op, frame = event[1:] + tag, target = op[0], tuple(op[1]) + words = {"historical": historical_lower(op), "pr696": reference_lower(op), + "replacement": lower(op, entries)} + require(len(words["historical"]) == baseline_count(op), "historical emitter invoice") + require(len(words["replacement"]) <= len(words["pr696"]), "replacement increased bill") + baseline += 2 * baseline_count(op) + macros += 1 + frame_hash.update(canonical([index, frame]) + b"\n") + replacement_frame = frame + replacement_frame_hash.update(canonical([index, replacement_frame]) + b"\n") + if tag == "add": + source, q = tuple(op[2]), Q(op[3], op[4]) + additions += 1 + units += abs(q) == 1 + peak = max(peak, abs(q.numerator) * env[source]) + env[target] += abs(q) * env[source] + elif tag == "scale": + env[target] *= abs(Q(op[2], op[3])) + elif tag == "clear": + env[target] = Q(0) + elif tag == "copy": + env[target] = env[tuple(op[2])] + else: + raise ValueError("unknown macro") + peak = max(peak, env[target]) + if words["replacement"] != words["pr696"]: + require(tag == "add", "changed non-addition macro") + require(len(words["replacement"]) < len(words["pr696"]), + "changed word without strict saving") + changed += 1 + coefficient = str(q) + item = changed_coefficients.setdefault(coefficient, { + "occurrences": 0, + "pr696_real_primitives_per_macro": 2 * len(words["pr696"]), + "replacement_real_primitives_per_macro": 2 * len(words["replacement"]), + "pr696_real_source_reads_per_macro": 2 * source_reads(words["pr696"], op), + "replacement_real_source_reads_per_macro": 2 * source_reads(words["replacement"], op), + }) + item["occurrences"] += 1 + for name, interpreter in interpreters.items(): + interpreter.run_macro(op, words[name], frame, index) + expected_row = interpreters["historical"].rows[target] + for name in ("pr696", "replacement"): + require(interpreters[name].rows[target] == expected_row, + f"{orientation} macro {index}: target differs from historical emitter") + require(interpreters[name].rows[WORK] == interpreters["historical"].rows[WORK], + f"{orientation} macro {index}: coefficient work boundary differs") + boundary_comparisons += 1 + for interpreter in interpreters.values(): + interpreter.endpoint(orientation) + require(macros == checks["scalar_macros"], "source macro count") + require(len(events) == checks["events"], "source event count") + require(baseline == checks["real_component_primitive_bound"], "historical primitive receipt") + require(dict(paid) == {int(k): value for k, value in checks["paid_profile"].items()}, + "paid profile changed") + require(peak == Q(inherited["prefix_l1_upper"]), "inherited positive prefix envelope") + require(non_scalar_hash.digest() == replacement_non_scalar_hash.digest(), "non-scalar event change") + require(frame_hash.digest() == replacement_frame_hash.digest(), "scalar frame change") + receipts = {name: interpreter.receipt() for name, interpreter in interpreters.items()} + require(receipts["replacement"]["maximum_fractional_denominator_exponent"] <= + receipts["pr696"]["maximum_fractional_denominator_exponent"] <= + receipts["historical"]["maximum_fractional_denominator_exponent"], + "scalar fractional guard increased") + require(interpreters["replacement"].maximum_row_l1 <= interpreters["pr696"].maximum_row_l1 + <= interpreters["historical"].maximum_row_l1, "scalar prefix row-L1 maximum increased") + require(peak < 2 ** inherited["charged_payload_bits"], "inherited payload bound exceeded") + require(receipts["historical"]["real_primitives"] - receipts["pr696"]["real_primitives"] + == 2 * (additions + units), "PR696 closed-form saving") + return { + "logical_input_columns": N, + "arbitrary_private_input_columns": 9, + "total_exact_input_columns": N + 9, + "arbitrary_helper_columns_restored": N - 2 * V, + "private_registers_erased": 9, + "events": len(events), + "scalar_macros": macros, + "addition_macros": additions, + "macro_boundaries_compared": boundary_comparisons, + "addition_macros_with_coefficient_work_clear": additions, + "changed_macros": changed, + "changed_coefficients": dict(sorted(changed_coefficients.items(), key=lambda x: Q(x[0]))), + "saved_real_primitives_vs_pr696": receipts["pr696"]["real_primitives"] - receipts["replacement"]["real_primitives"], + "saved_real_primitives_vs_historical": baseline - receipts["replacement"]["real_primitives"], + "extra_real_source_reads_vs_pr696": receipts["replacement"]["real_macro_source_reads"] - receipts["pr696"]["real_macro_source_reads"], + "lowerings": receipts, + "preserved_non_scalar_events": non_scalar_count, + "non_scalar_event_indexed_sha256": non_scalar_hash.hexdigest(), + "scalar_frame_indexed_sha256": frame_hash.hexdigest(), + "paid_profile": {str(k): value for k, value in sorted(paid.items())}, + "retained_prefix_l1_upper": str(peak), + "inherited_prefix_bits_upper": inherited["prefix_bits_upper"], + "charged_payload_bits": inherited["charged_payload_bits"], + } + + +def replay(programs, checks, inherited, entries): + """Replay full forward/backward words; return deterministic evidence only.""" + require(set(programs) == {"forward", "backward"}, "source program orientations") + local_inherited = inherited.get("local", inherited) + return {orientation: replay_orientation(orientation, programs[orientation], checks[orientation], + local_inherited[orientation], entries) + for orientation in ("forward", "backward")} diff --git a/research/jp8-grid-bounded-synthesis/synth.py b/research/jp8-grid-bounded-synthesis/synth.py new file mode 100644 index 0000000000..fd1ff94859 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/synth.py @@ -0,0 +1,94 @@ +"""Finite grid-bounded coefficient synthesis. Apache-2.0. + +Prepared for Philipp (@mightyOil) with substantial OpenAI Codex assistance. +The comparison is Gareth Davidson's pinned PR837 code and Sagar Thakrar's +PR696 copy/unit lowering, retained verbatim under vendor/ with attribution. +""" +from collections import deque +from fractions import Fraction as Q +import importlib.util +from pathlib import Path + +HERE = Path(__file__).resolve().parent +spec = importlib.util.spec_from_file_location("grid_pr837", HERE / "vendor/pr837/lower.py") +horner = importlib.util.module_from_spec(spec) +spec.loader.exec_module(horner) +reference_lower = horner.reference.lower +WORK = ("W", 0) + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def solve(n, denominator): + """BFS over the *entire* bounded directed graph, not only to the goal.""" + need(type(n) is int and type(denominator) is int and 1 <= n <= 127, + "numerator outside search domain") + need(denominator in (1, 2, 4, 8, 16) and Q(n, denominator).numerator == n, + "denominator outside reduced search domain") + bound = n * denominator + previous = {denominator: None} + distance = {denominator: 0} + queue = deque([denominator]) + edges = 0 + while queue: + m = queue.popleft() + outgoing = [(2*m, "double"), (m+denominator, "add"), + (m-denominator, "subtract"), (-m, "negate")] + if m % 2 == 0: + outgoing.append((m//2, "halve")) + for nxt, operation in outgoing: + if abs(nxt) > bound: + continue + edges += 1 + if nxt not in previous: + previous[nxt] = (m, operation) + distance[nxt] = distance[m] + 1 + queue.append(nxt) + goal = min((n, -n), key=lambda state: (distance.get(state, float("inf")), state < 0)) + need(goal in previous, "coefficient unreachable") + operations = [] + cursor = goal + while previous[cursor] is not None: + cursor, operation = previous[cursor] + operations.append(operation) + return {"numerator": n, "denominator": denominator, + "operations": list(reversed(operations)), + "end_sign": 1 if goal > 0 else -1, + "preparation_steps": distance[goal], + "graph_vertices": 2*bound+1, "reachable_vertices": len(previous), + "reachable_edges_with_multiplicity": edges} + + +def comparisons(entry): + """Actual frozen PR837 four-candidate comparator; no feasibility filtering.""" + n, d = entry["numerator"], entry["denominator"] + op = ["add", ["T", 0], ["S", 0], n, d] + return {name: len(word) for name, word in horner.candidates(op).items()} + + +def improved(entry): + return entry["preparation_steps"] + 3 < min(comparisons(entry).values()) + + +def lower(op, entries): + """Replace only strict improvements over *all four* unbounded Horner words.""" + baseline = reference_lower(op) # Validate macro type, dyadic and aliases first. + if op[0] != "add": + return baseline + q = Q(op[3], op[4]) + entry = entries.get(abs(q)) + if entry is None or not improved(entry): + return baseline + source, target = tuple(op[2]), tuple(op[1]) + word = [("copy", WORK, source)] + for operation in entry["operations"]: + need(operation in ("double", "halve", "negate", "add", "subtract"), + "unknown synthesized operation") + word.append((operation, WORK, source) if operation in ("add", "subtract") + else (operation, WORK)) + sign = (1 if q > 0 else -1) * entry["end_sign"] + word.extend([("add" if sign > 0 else "subtract", target, WORK), ("clear", WORK)]) + return word diff --git a/research/jp8-grid-bounded-synthesis/test_independent.py b/research/jp8-grid-bounded-synthesis/test_independent.py new file mode 100644 index 0000000000..2769fd4405 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/test_independent.py @@ -0,0 +1,241 @@ +"""Bounded differential arithmetic and graph-certificate mutation tests. + +Prepared for Philipp (@mightyOil) with substantial OpenAI Codex assistance. +Apache-2.0. Python 3.11+, standard library only; no files are written. + +The replay implementation intentionally does not import Fraction. Here that +different representation checks its common-denominator arithmetic, including +all denominator depths 0..27 observed in the complete scalar projections. +These are helper tests; the main verifier supplies full source/trace coverage. +""" +from copy import deepcopy +from collections import Counter +from fractions import Fraction +import gzip +import heapq +import json +from pathlib import Path +import sys +import unittest + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import crosscheck +import integer_replay +import synth + + +def fractions(power, coefficients): + return {column: Fraction(value, 1 << power) + for column, value in coefficients.items() if value} + + +def add_fractions(left, right, sign): + result = {column: left.get(column, Fraction(0)) + sign * right.get(column, Fraction(0)) + for column in left.keys() | right.keys()} + return {column: value for column, value in result.items() if value} + + +def corpus(): + """Negative, odd, even, mixed, cancelled-zero and depth-dependent numerators.""" + for power in range(28): + for coefficients in ({0: -12, 1: 4, 2: 0}, {0: 1, 1: -1}, {2: 0}, + {0: -(1 << power), 2: 7}, {0: 8, 1: -24, 3: 16}): + yield power, coefficients + + +class IndependentTests(unittest.TestCase): + def assert_row(self, actual, expected): + power, coefficients = actual + self.assertIs(type(power), int) + self.assertTrue(all(type(value) is int and value != 0 for value in coefficients.values())) + self.assertEqual(fractions(power, coefficients), expected) + canonical_power = max((value.denominator.bit_length() - 1 for value in expected.values()), + default=0) + self.assertEqual(power, canonical_power) + if not expected: + self.assertEqual(actual, (0, {})) + + def test_row_normalization_and_signed_multipliers(self): + checked = 0 + for power, coefficients in corpus(): + original = deepcopy(coefficients) + value = integer_replay.row(power, coefficients) + expected = fractions(power, coefficients) + self.assert_row(value, expected) + self.assertEqual(coefficients, original) + saved = deepcopy(value) + for numerator in (-127, -16, -3, -1, 0, 1, 2, 3, 16, 127): + for divisor_power in range(5): + scaled = integer_replay.row_multiple(value, numerator, divisor_power) + factor = Fraction(numerator, 1 << divisor_power) + answer = {column: coefficient * factor for column, coefficient in expected.items() + if coefficient * factor} + self.assert_row(scaled, answer) + checked += 1 + self.assertEqual(value, saved, "row multiplication mutated its input") + self.assertEqual(checked, 7000) + + def test_all_corpus_row_sums_and_cancellation(self): + values = [(integer_replay.row(power, coefficients), fractions(power, coefficients)) + for power, coefficients in corpus()] + checked = 0 + for left, left_expected in values: + for right, right_expected in values: + saved_left, saved_right = deepcopy(left), deepcopy(right) + for sign in (-1, 1): + self.assert_row(integer_replay.row_sum(left, right, sign), + add_fractions(left_expected, right_expected, sign)) + checked += 1 + self.assertEqual(left, saved_left, "row addition mutated its left input") + self.assertEqual(right, saved_right, "row addition mutated its right input") + self.assertEqual(checked, 39200) + + def test_primitive_intermediate_states_and_copy_independence(self): + t, s, w = ("T", 0), ("S", 0), ("W", 0) + word = [("copy", w, s), ("double", s), ("halve", w), ("add", t, w), + ("subtract", t, s), ("negate", w), ("halve", t), + ("clear", s), ("add", s, w), ("clear", w)] + for power, coefficients in corpus(): + initial = {t: integer_replay.row(power, coefficients), + s: integer_replay.row((power + 3) % 28, {0: -3, 2: 5}), + w: integer_replay.row(1, {3: -7})} + rows = deepcopy(initial) + expected = {register: fractions(*value) for register, value in initial.items()} + for instruction in word: + tag, target = instruction[:2] + if tag == "copy": + expected[target] = expected[instruction[2]].copy() + elif tag == "clear": + expected[target] = {} + elif tag in ("add", "subtract"): + expected[target] = add_fractions(expected[target], expected[instruction[2]], + 1 if tag == "add" else -1) + else: + factor = {"double": Fraction(2), "halve": Fraction(1, 2), + "negate": Fraction(-1)}[tag] + expected[target] = {column: value * factor + for column, value in expected[target].items()} + integer_replay.primitive(rows, instruction) + for register in rows: + self.assert_row(rows[register], expected[register]) + self.assertEqual(integer_replay.ZERO, (0, {}), "shared zero row was mutated") + + def test_comparator_formulas_over_entire_supported_coefficient_domain(self): + checked = 0 + for denominator in (1, 2, 4, 8, 16): + for numerator in range(1, 128): + if denominator > 1 and numerator % 2 == 0: + continue + entry = {"numerator": numerator, "denominator": denominator} + self.assertEqual(integer_replay.comparator_lengths( + numerator, denominator.bit_length() - 1), synth.comparisons(entry), entry) + checked += 1 + self.assertEqual(checked, 383) + + def test_complete_potential_obligations_reject_local_mutations(self): + numerator, denominator = 7, 4 + potential = crosscheck.bellman_potential(numerator, denominator)["distances"] + self.assertEqual(len(potential), 57) + for position, value in enumerate(potential): + for delta in (-1, 1): + corrupted = potential.copy() + corrupted[position] = value + delta + with self.assertRaises(crosscheck.CertificateError): + crosscheck.validate_potential(numerator, denominator, corrupted) + for corrupted in (potential[:-1], potential + [0]): + with self.assertRaisesRegex(crosscheck.CertificateError, "every vertex"): + crosscheck.validate_potential(numerator, denominator, corrupted) + entry = synth.solve(numerator, denominator) + for position in range(len(entry["operations"])): + corrupted = deepcopy(entry) + corrupted["operations"].pop(position) + corrupted["preparation_steps"] -= 1 + with self.assertRaises(crosscheck.CertificateError): + crosscheck.verify_entry(corrupted) + + def test_weighted_dijkstra_against_pareto_receipt(self): + """490 independent scalar-weight searches, plus aggregate and tie checks.""" + root = HERE.parents[1] + source = root / ('research/community-k492-audit/pr626/replay/mixed-global/' + 'base/providers/jp8/LOCAL-PROGRAMS.json.gz') + programs = json.loads(gzip.decompress(source.read_bytes())) + counts = {name: Counter(abs(Fraction(e[1][3], e[1][4])) for e in events + if e[0] == 'scalar' and e[1][0] == 'add') + for name, events in programs.items()} + self.assertEqual(set(counts), {'forward', 'backward'}) + coefficients = {q for counter in counts.values() for q in counter + if q != 1 and q.numerator <= 127 + and q.denominator in (1, 2, 4, 8, 16)} + receipt = json.loads((HERE / 'EXPECTED.json').read_text())['source_read_pareto'] + claimed = {Fraction(r['coefficient']): [tuple(p) for p in r['macro_frontier']] + for r in receipt['graphs']} + selected = {Fraction(r['coefficient']) for r in receipt['selected_frontiers']} + self.assertEqual(coefficients, set(claimed)) + self.assertEqual((len(coefficients), len(selected)), (49, 7)) + + def shortest(q, price): + # Each positive scalar edge weight is instructions + price*reads. + # Keep differently priced parallel edges, notably double vs add. + n, d = q.numerator, q.denominator + bound = n*d + numerator, denominator = price.numerator, price.denominator + distances, queue = {d: (0, 0, 0)}, [(0, 0, 0, d)] + while queue: + cost, reads, steps, state = heapq.heappop(queue) + if distances.get(state) != (cost, reads, steps): + continue + edges = [(state+d, 1), (state-d, 1), (-state, 0), (2*state, 0)] + if state % 2 == 0: + edges.append((state//2, 0)) + for target, increment in edges: + if abs(target) > bound: + continue + candidate = (cost+denominator+numerator*increment, + reads+increment, steps+1) + if target not in distances or candidate < distances[target]: + distances[target] = candidate + heapq.heappush(queue, (*candidate, target)) + cost, reads, steps = min(distances[n], distances[-n]) + self.assertEqual(cost, denominator*steps+numerator*reads) + return steps+3, reads+1 # Paid copy, accumulation, clear; copy reads S. + + prices = list(map(Fraction, ('0', '1/6', '1/3', '2/3', '1', + '26/23', '3/2', '2', '3', '10'))) + intervals = receipt['hypothetical_sensitivity']['intervals'] + self.assertEqual(receipt['hypothetical_sensitivity']['breakpoints'], ['1/3', '1', '2']) + checked = 0 + for price in prices: + choices = {} + for q in coefficients: + choices[q] = shortest(q, price) + expected = min(claimed[q], key=lambda p: (p[0]+price*p[1], p[1], p[0])) + self.assertEqual(choices[q], expected, (q, price)) + checked += 1 + deltas = {name: [0, 0] for name in counts} + for q in selected: + tail = bin(q.numerator)[3:] + old = (3+len(tail)+tail.count('1')+q.denominator.bit_length()-1, + 1+tail.count('1')) + for name, counter in counts.items(): + for coordinate in (0, 1): + deltas[name][coordinate] += 2*counter[q]*(choices[q][coordinate]-old[coordinate]) + applicable = [r for r in intervals if Fraction(r['lower']) <= price + and (r['upper'] is None or price <= Fraction(r['upper']))] + self.assertTrue(applicable) + for interval in applicable: # Both adjacent costs must agree at ties. + for name, delta in deltas.items(): + declared = interval['delta_instructions_source_reads_vs_696'][name] + self.assertEqual(delta[0]+price*delta[1], declared[0]+price*declared[1]) + if price > Fraction(interval['lower']) and (interval['upper'] is None + or price < Fraction(interval['upper'])): + self.assertEqual(delta, declared) + if price == 0: + for delta in deltas.values(): + self.assertEqual(delta, [-104, 92]) + self.assertEqual(Fraction(-delta[0], delta[1]), Fraction(26, 23)) + self.assertEqual(checked, 490) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/jp8-grid-bounded-synthesis/test_package.py b/research/jp8-grid-bounded-synthesis/test_package.py new file mode 100644 index 0000000000..fc73a98f45 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/test_package.py @@ -0,0 +1,138 @@ +"""Boundary, corruption and portable reproduction tests; standard library only. + +Prepared for Philipp (@mightyOil) with substantial OpenAI Codex assistance. +Apache-2.0. Run with Python 3.11+ from any working directory. +""" +import gzip +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +import crosscheck +import verify + + +class PackageTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory(prefix="jp8 grid test ") + self.root = Path(self.temp.name) / "minimal checkout with spaces" + self.package = self.root / "research/jp8-grid-bounded-synthesis" + shutil.copytree(HERE, self.package, ignore=shutil.ignore_patterns("__pycache__")) + for name in verify.read(HERE / "SOURCES.json")["files"]: + dest = self.root / name + dest.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / name, dest) + + def tearDown(self): + self.temp.cleanup() + + def invoke(self, *args): + return subprocess.run([sys.executable, "-I", "-O", "-B", str(self.package / "verify.py"), *args], + cwd=self.temp.name, text=True, capture_output=True, timeout=90) + + def rejection(self, reason, *args): + result = self.invoke(*args) + self.assertNotEqual(result.returncode, 0, result.stdout) + self.assertIn(reason, result.stderr) + + def edit_certificate(self, edit): + path = self.package / "CERTIFICATE.json" + data = json.loads(path.read_text()) + edit(data) + path.write_text(json.dumps(data)) + + def test_optimized_relocated_recompressed_replay(self): + path = self.root / verify.PROVIDER.relative_to(ROOT) / "LOCAL-PROGRAMS.json.gz" + before = path.read_bytes() + path.write_bytes(gzip.compress(gzip.decompress(before), compresslevel=1, mtime=33)) + self.assertNotEqual(path.read_bytes(), before) + result = self.invoke() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("PASS_JP8_GRID_BOUNDED_SYNTHESIS", result.stdout) + + def test_source_corruption(self): + path = self.root / "research/complex-k492-owner-repair/data/SPEC.json" + path.write_bytes(path.read_bytes() + b" ") + self.rejection("source pin mismatch") + + def test_reference_corruption(self): + path = self.package / "vendor/pr837/lower.py" + path.write_bytes(path.read_bytes() + b"\n# changed\n") + self.rejection("source pin mismatch") + + def test_missing_source_pin(self): + path = self.package / "SOURCES.json" + data = json.loads(path.read_text()) + del data["vendored"]["vendor/pr837/lower.py"] + path.write_text(json.dumps(data)) + self.rejection("source manifest coverage") + + def test_forged_source_provenance(self): + path = self.package / "SOURCES.json" + data = json.loads(path.read_text()) + data["source_heads"]["837"] = "0"*40 + data["base_commit"] = "1"*40 + data["historical_provider"] = "a different provider" + path.write_text(json.dumps(data)) + self.rejection("source provenance identity") + + def test_boolean_coefficient_denominator(self): + def change(certificate): + next(e for e in certificate["entries"] if e["denominator"] == 1)["denominator"] = True + self.edit_certificate(change) + self.rejection("certificate reconstruction mismatch") + + def test_float_preparation_count(self): + def change(certificate): + entry = certificate["entries"][0] + entry["preparation_steps"] = float(entry["preparation_steps"]) + self.edit_certificate(change) + self.rejection("certificate reconstruction mismatch") + + def test_altered_search_domain_type(self): + self.edit_certificate(lambda c: c["domain"].update(maximum_numerator=127.0)) + self.rejection("certificate search domain") + + def test_float_receipt_count(self): + path = self.package / "EXPECTED.json" + data = json.loads(path.read_text()) + data["improved_coefficients"] = float(data["improved_coefficients"]) + path.write_text(json.dumps(data)) + self.rejection("expected receipt mismatch") + + def test_missing_coefficient(self): + self.edit_certificate(lambda c: c["entries"].pop()) + self.rejection("certificate reconstruction mismatch") + + def test_forged_shorter_path(self): + self.edit_certificate(lambda c: c["entries"][0]["operations"].pop()) + self.rejection("certificate reconstruction mismatch") + + def test_forged_receipt(self): + path = self.package / "EXPECTED.json" + data = json.loads(path.read_text()) + data["programs"]["forward"]["lowerings"]["replacement"]["real_primitives"] -= 1 + path.write_text(json.dumps(data)) + self.rejection("expected receipt mismatch") + + def test_output_preserved(self): + path = self.root / "existing.json" + path.write_text("do not replace") + self.rejection("output already exists", "--write", str(path)) + self.assertEqual(path.read_text(), "do not replace") + + def test_independent_coverage_rejects_omission(self): + entries = verify.read(HERE / "CERTIFICATE.json")["entries"][:-1] + with self.assertRaisesRegex(crosscheck.CertificateError, "does not cover"): + crosscheck.run(entries, source=verify.PROVIDER / "LOCAL-PROGRAMS.json.gz") + + +if __name__ == "__main__": + unittest.main() diff --git a/research/jp8-grid-bounded-synthesis/vendor/pr837/lower.py b/research/jp8-grid-bounded-synthesis/vendor/pr837/lower.py new file mode 100644 index 0000000000..a7855d2a87 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/vendor/pr837/lower.py @@ -0,0 +1,92 @@ +"""Both Horner directions for a single nonzero dyadic scalar macro. + +Gareth Davidson (@bitplane), with substantial OpenAI Codex assistance. +Apache-2.0. Binary copy/unit lowering is Sagar Thakrar's verbatim PR696 +module. Forward NAF follows PR723 and our PR787; see README.md for pins. +""" + +import importlib.util +from fractions import Fraction as Q +from pathlib import Path + + +def load_reference(): + spec = importlib.util.spec_from_file_location( + "pr696", Path(__file__).resolve().parent / "vendor/pr696_lower.py") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +reference = load_reference() + + +def digits(n, signed): + """Least-significant-first binary or non-adjacent digits.""" + if type(n) is not int or n <= 0: + raise ValueError("positive integer required") + result = [] + while n: + d = (2 - n % 4 if signed else 1) if n % 2 else 0 + result.append(d) + n = (n - d) // 2 + return result + + +def candidates(op, work=("W", 0)): + """Emit four circuits in stable tie order; each clears work on exit. + + Non-addition macros are inherited unchanged. No circuit writes source, + borrows a logical register, or crosses the original macro boundary. + """ + binary = reference.lower(op, work) # Also validates dyadics and aliases. + result = {"binary-forward": binary} + if op[0] != "add" or abs(Q(op[3], op[4])) == 1: + return result + target, source = tuple(op[1]), tuple(op[2]) + q = Q(op[3], op[4]) + a, k = abs(q.numerator), q.denominator.bit_length() - 1 + sign = 1 if q > 0 else -1 + + forward = [("copy", work, source)] + for d in reversed(digits(a, True)[:-1]): + forward.append(("double", work)) + if d: + forward.append(("add" if d > 0 else "subtract", work, source)) + forward.extend([("halve", work)] * k) + forward.extend([("add" if sign > 0 else "subtract", target, work), ("clear", work)]) + result["naf-forward"] = forward + + # Remove numerator trailing zeros so the initial reverse digit is +/-1. + odd, exponent = a, -k + while odd % 2 == 0: + odd //= 2 + exponent += 1 + for signed in (False, True): + ds = digits(odd, signed) + initial_sign = ds[0] + reverse = [("copy", work, source)] + for d in ds[1:]: + reverse.append(("halve", work)) + if d: + reverse.append(("add" if d * initial_sign > 0 else "subtract", work, source)) + shift = len(ds) - 1 + exponent + reverse.extend([("double" if shift > 0 else "halve", work)] * abs(shift)) + reverse.extend([ + ("add" if sign * initial_sign > 0 else "subtract", target, work), + ("clear", work), + ]) + result["naf-reverse" if signed else "binary-reverse"] = reverse + return result + + +def choose(op, work=("W", 0), reverse=True): + words = candidates(op, work) + if not reverse: + words = {k: v for k, v in words.items() if k.endswith("forward")} + name = min(words, key=lambda key: len(words[key])) + return name, words[name] + + +def lower(op, work=("W", 0)): + return choose(op, work)[1] diff --git a/research/jp8-grid-bounded-synthesis/vendor/pr837/vendor/pr696_lower.py b/research/jp8-grid-bounded-synthesis/vendor/pr837/vendor/pr696_lower.py new file mode 100644 index 0000000000..a2c2889e5b --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/vendor/pr837/vendor/pr696_lower.py @@ -0,0 +1,56 @@ +"""Smaller exact dyadic circuits for the fixed PR626 complex scalar words. + +Sagar Thakrar, with substantial OpenAI Codex assistance. Apache-2.0. +Primitive vocabulary and the original Horner circuit follow icekylinx's +PR425/433/531 lineage, retained by Jeremy Kothe's PR622 supplier. +""" +from fractions import Fraction + + +def power_of_two(n): + return n > 0 and n & (n - 1) == 0 + + +def lower(op, work=("W", 0)): + """Return real-component primitives; work may be dirty on entry. + + Every addition leaves work zero. All operations use the macro's frame. + The complex circuit applies this word separately to real and imaginary parts. + """ + tag, target = op[0], tuple(op[1]) + if target == work: + raise ValueError("coefficient work aliases a scalar register") + if tag == "clear": + return [("clear", target)] + if tag == "copy": + source = tuple(op[2]) + if source == work: + raise ValueError("coefficient work used as a scalar source") + return [("copy", target, source)] + if tag == "scale": + q = Fraction(op[2], op[3]) + if not power_of_two(abs(q.numerator)) or not power_of_two(q.denominator): + raise ValueError("scale is not a signed power of two") + shift = abs(q.numerator).bit_length() - q.denominator.bit_length() + result = [("double" if shift > 0 else "halve", target)] * abs(shift) + if q < 0: + result.append(("negate", target)) + return result + if tag != "add": + raise ValueError("unknown scalar macro") + source = tuple(op[2]) + q = Fraction(op[3], op[4]) + if source in (target, work) or not q or not power_of_two(q.denominator): + raise ValueError("addition requires distinct registers and a nonzero dyadic") + accumulate = "add" if q > 0 else "subtract" + if abs(q) == 1: + return [(accumulate, target, source), ("clear", work)] + # Copy replaces clear + addition of the leading binary digit. + result = [("copy", work, source)] + for bit in bin(abs(q.numerator))[3:]: + result.append(("double", work)) + if bit == "1": + result.append(("add", work, source)) + result.extend([("halve", work)] * (q.denominator.bit_length() - 1)) + result.extend([(accumulate, target, work), ("clear", work)]) + return result diff --git a/research/jp8-grid-bounded-synthesis/verify.py b/research/jp8-grid-bounded-synthesis/verify.py new file mode 100644 index 0000000000..6ab5897ae8 --- /dev/null +++ b/research/jp8-grid-bounded-synthesis/verify.py @@ -0,0 +1,282 @@ +#!/usr/bin/env python3 +"""Offline finite JP8 circuit certificate. Python 3.11+, standard library. + +Philipp (@mightyOil), with substantial OpenAI Codex assistance. Apache-2.0. +This is a scalar circuit result, not a formal multiplication theorem. +""" +import argparse +from collections import Counter +from fractions import Fraction as Q +import gzip +import hashlib +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +PROVIDER = ROOT / "research/community-k492-audit/pr626/replay/mixed-global/base/providers/jp8" +SOURCE_NAMES = { + "certificates/checkpoints/k492626.json", + "research/complex-k492-owner-repair/data/SPEC.json", + "research/complex-k492-owner-repair/code/hpe_emit_local.py", + "research/complex-k492-owner-repair/code/invoice_allcold.py", + "research/complex-dyadic-lowering/lower.py", + *{str(PROVIDER.relative_to(ROOT) / name) for name in + ("LOCAL-PROGRAMS.json.gz", "LOCAL-CHECKS.json", "INDEPENDENT-LOCAL-REPLAY.json")}, +} +VENDOR_NAMES = {"vendor/pr837/lower.py", "vendor/pr837/vendor/pr696_lower.py"} +DOMAIN = {"maximum_numerator":127, "maximum_denominator":16, + "magnitude_bound":"abs(numerator)", "scratch_grid":"1/denominator", + "unit_handling":"direct accumulation plus private clear, cost 2; outside graph search"} +PROVENANCE = { + "base_commit":"f567884aeb8851b6e794af1184119a3bfbe1e631", + "historical_provider":"PR626 JP8; not a PR799 implementation change", + "source_heads":{ + "626":"660de893d27bb7abd1d5b01b1640207528a5c851", + "622":"f69477f4f6d3c7eb1f740b166881bffed4ffa9f6", + "696":"5a3f983715027c4fd83f50bc9001d4b18463bed1", + "837":"0a2977195efc8fb2a918fbfb694ec8d294387f08", + }, +} + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def sha(data): + return hashlib.sha256(data).hexdigest() + + +def read(path): + data = path.read_bytes() + return json.loads(gzip.decompress(data) if path.suffix == ".gz" else data) + + +def check_pins(): + pins = read(HERE / "SOURCES.json") + need(canonical({key:pins.get(key) for key in PROVENANCE}) == canonical(PROVENANCE), + "source provenance identity") + need(set(pins["files"]) == SOURCE_NAMES and set(pins["vendored"]) == VENDOR_NAMES, + "source manifest coverage") + for section, root in (("files", ROOT), ("vendored", HERE)): + for name, pin in pins[section].items(): + payload = (root / name).read_bytes() + if pin["representation"] == "decompressed-payload": + payload = gzip.decompress(payload) + else: + need(pin["representation"] == "exact-bytes", "unknown pin representation") + need(sha(payload) == pin["sha256"], "source pin mismatch: " + name) + checkpoint = read(ROOT / "certificates/checkpoints/k492626.json") + spec = read(ROOT / "research/complex-k492-owner-repair/data/SPEC.json") + need(checkpoint["audited_source_head"] == pins["source_heads"]["626"], "historical source head") + need(Q(checkpoint["kappa"]) == Q(spec["expected"]["kappa"]), "historical SPEC binding") + return spec + + +def macro_check(q, word, budget): + """Dense exact T,S,W map, local magnitude and grid, and paid word length.""" + t, s, w = ("T", 0), ("S", 0), ("W", 0) + rows = {t: [Q(1), Q(0), Q(0)], s: [Q(0), Q(1), Q(0)], + w: [Q(0), Q(0), Q(1)]} + target_start, target_end = rows[t].copy(), [Q(1), q, Q(0)] + initialized = False + for primitive in word: + op, dst = primitive[:2] + need(dst in rows, "unknown register") + need(dst != s, "source write") + if op == "copy": + rows[dst] = rows[primitive[2]].copy() + elif op == "clear": + rows[dst] = [Q(0)]*3 + elif op in ("double", "halve", "negate"): + factor = {"double": Q(2), "halve": Q(1, 2), "negate": Q(-1)}[op] + rows[dst] = [factor*x for x in rows[dst]] + elif op in ("add", "subtract"): + sign = 1 if op == "add" else -1 + rows[dst] = [x+sign*y for x, y in zip(rows[dst], rows[primitive[2]])] + else: + raise ValueError("unknown primitive") + need(rows[t] in (target_start, target_end), "target prefix") + if dst == w: + initialized = True + if initialized: + need(rows[w][0] == rows[w][2] == 0, "dirty work dependency") + coefficient = rows[w][1] + need(abs(coefficient) <= abs(q.numerator), "magnitude bound") + need(coefficient.denominator <= q.denominator, "fractional grid") + need(rows == {t: target_end, s: [Q(0), Q(1), Q(0)], w: [Q(0)]*3}, + "macro endpoint or private clear") + need(len(word) == budget, "primitive count") + + +def negative_controls(entries): + import synth + t, s, w = ("T", 0), ("S", 0), ("W", 0) + q = Q(5, 2) + good = synth.lower(["add", list(t), list(s), 5, 2], entries) + grid = good[:1] + [("halve", w)]*2 + [("double", w)]*2 + good[1:] + growth = good[:1] + [("double", w)]*3 + [("halve", w)]*3 + good[1:] + cases = { + "missing_clear": (good[:-1], len(good)-1, "macro endpoint or private clear"), + "missing_copy": (good[1:], len(good)-1, "dirty work dependency"), + "wrong_accumulation_sign": (good[:-2]+[("subtract",t,w)]+good[-1:], len(good), "target prefix"), + "endpoint_neutral_grid_excursion": (grid, len(grid), "fractional grid"), + "endpoint_neutral_magnitude_excursion": (growth, len(growth), "magnitude bound"), + "source_modified_then_restored": ([("double",s),("halve",s)]+good, len(good)+2, "source write"), + "uncharged_extra_clear": (good+[("clear",w)], len(good), "primitive count"), + } + rejected = {} + for name, (word, cost, reason) in cases.items(): + try: + macro_check(q, word, cost) + except ValueError as error: + need(str(error) == reason, "wrong rejection reason for " + name) + rejected[name] = str(error) + else: + raise ValueError("accepted negative control: " + name) + for name, op in { + "source_target_alias": ["add", list(t), list(t), 5, 2], + "scratch_alias": ["add", list(t), list(w), 5, 2], + "nondyadic": ["add", list(t), list(s), 5, 3], + "zero_coefficient": ["add", list(t), list(s), 0, 1], + }.items(): + try: + synth.lower(op, entries) + except ValueError as error: + rejected[name] = str(error) + else: + raise ValueError("accepted invalid macro: " + name) + return rejected + + +def collect(): + spec = check_pins() + import synth + import crosscheck + import integer_replay + import pareto + from replay import replay + + programs = read(PROVIDER / "LOCAL-PROGRAMS.json.gz") + checks = read(PROVIDER / "LOCAL-CHECKS.json") + inherited = read(PROVIDER / "INDEPENDENT-LOCAL-REPLAY.json") + provider_spec = spec["providers"]["jp8"] + need(set(programs) == {"forward", "backward"}, "orientation coverage") + need(sha(canonical(programs)) == provider_spec["artifact_semantic_sha256"]["LOCAL-PROGRAMS.json.gz"], + "SPEC program payload") + counts = {} + for orientation, events in programs.items(): + need(sha(canonical(events)) == checks[orientation]["sha256"] == + provider_spec["program_hashes"][orientation], "orientation source binding") + counts[orientation] = Counter(abs(Q(e[1][3],e[1][4])) for e in events + if e[0] == "scalar" and e[1][0] == "add") + coefficients = sorted({q for counter in counts.values() for q in counter + if q != 1 and q.numerator <= 127 and q.denominator <= 16}) + coefficients = coefficients[33:] + coefficients[:33] + certificate = read(HERE / "CERTIFICATE.json") + need(certificate["schema"] == "jp8-grid-bounded-synthesis/1" and + type(certificate["seed"]) is int and certificate["seed"] == 33, + "certificate identity") + need(canonical(certificate["domain"]) == canonical(DOMAIN), "certificate search domain") + rebuilt = [] + for q in coefficients: + entry = synth.solve(q.numerator, q.denominator) + entry["horner_macro_costs"] = synth.comparisons(entry) + entry["strict_horner_improvement"] = synth.improved(entry) + rebuilt.append(entry) + # JSON true, 1 and 1.0 have different certificate types although Python + # equality conflates them. Verify the submitted witness itself after a + # type-preserving reconstruction comparison, not only the regenerated one. + need(canonical(certificate["entries"]) == canonical(rebuilt), "certificate reconstruction mismatch") + independent = crosscheck.run(certificate["entries"], source=PROVIDER / "LOCAL-PROGRAMS.json.gz") + entries = {Q(x["numerator"],x["denominator"]): x for x in rebuilt} + census = [] + for q, entry in entries.items(): + # Check every graph witness directly, even when it is not used. + for sign in (-1, 1): + t, s, w = ("T",0), ("S",0), ("W",0) + word = [("copy",w,s)] + word += [(op,w,s) if op in ("add","subtract") else (op,w) + for op in entry["operations"]] + word += [("add" if sign*entry["end_sign"]>0 else "subtract",t,w),("clear",w)] + macro_check(sign*q, word, entry["preparation_steps"]+3) + if synth.improved(entry): + census.append({"coefficient": str(q), "real_component_macro_cost": entry["preparation_steps"]+3, + "horner_macro_costs": entry["horner_macro_costs"], + "occurrences": {k: c[q] for k,c in counts.items()}, + "scratch_operations": entry["operations"]}) + controls = negative_controls(entries) + complete = replay(programs, checks, inherited, entries) + integer_result = integer_replay.verify(programs, checks, inherited, certificate) + for orientation in ("forward", "backward"): + other = integer_result["programs"][orientation] + for lowering in ("pr696", "replacement"): + need(canonical(other["lowerings"][lowering]) == + canonical(complete[orientation]["lowerings"][lowering]), + "independent integer primitive trace disagreement") + for field in ("total_exact_input_columns", "logical_input_columns", + "arbitrary_private_input_columns", "arbitrary_helper_columns_restored", + "private_registers_erased", "events", "scalar_macros", "changed_macros", + "addition_macros_with_coefficient_work_clear", "saved_real_primitives_vs_pr696", + "extra_real_source_reads_vs_pr696", "non_scalar_event_indexed_sha256", + "scalar_frame_indexed_sha256", "paid_profile"): + need(canonical(other[field]) == canonical(complete[orientation][field]), + "independent integer accounting disagreement: " + field) + source_read_pareto = pareto.verify(certificate["entries"]) + for orientation in ("forward", "backward"): + costs = source_read_pareto["selected_occurrence_totals_both_real_components"][orientation] + need(costs["binary-forward"][0] - costs["current"][0] == + complete[orientation]["saved_real_primitives_vs_pr696"], + "Pareto instruction accounting disagrees with full replay") + need(costs["current"][1] - costs["binary-forward"][1] == + complete[orientation]["extra_real_source_reads_vs_pr696"], + "Pareto source-read accounting disagrees with full replay") + comparator_saving = {orientation: 2*sum( + c[q]*(min(entry["horner_macro_costs"].values()) - entry["preparation_steps"]-3) + for q,entry in entries.items() if synth.improved(entry)) + for orientation,c in counts.items()} + return {"status":"PASS_JP8_GRID_BOUNDED_SYNTHESIS", "searched_nonunit_coefficients":len(rebuilt), + "improved_coefficients":len(census), "improvements":census, + "saved_real_primitives_vs_four_horner_at_replacements":comparator_saving, + "full_pr837_composition_claimed":False, + "independent_graph":independent, "programs":complete, + "independent_integer_replay":integer_result, + "source_read_pareto":source_read_pareto, + "negative_controls":controls, "kappa_claim":None, + "scope":"Historical PR626 JP8 scalar projections; finite graph class optimum only."} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--json", action="store_true") + parser.add_argument("--write", type=Path, help="development only: create a new receipt; never overwrite") + args = parser.parse_args() + if args.write: + need(not args.write.exists(), "output already exists") + result = collect() + if args.write: + with args.write.open("x") as stream: + json.dump(result, stream, indent=2, sort_keys=True) + stream.write("\n") + else: + need(canonical(result) == canonical(read(HERE / "EXPECTED.json")), "expected receipt mismatch") + if args.json: + print(json.dumps(result,indent=2,sort_keys=True)) + else: + savings = ",".join(str(result["saved_real_primitives_vs_four_horner_at_replacements"][o]) + for o in ("forward","backward")) + print(f"{result['status']} coefficients={result['searched_nonunit_coefficients']} " + f"improved={result['improved_coefficients']} extra_vs_four_horner={savings} " + "columns=716+9 kappa=unchanged") + + +if __name__ == "__main__": + main()