diff --git a/research/dyadic-center-basis-shear/CERTIFICATE.json b/research/dyadic-center-basis-shear/CERTIFICATE.json new file mode 100644 index 0000000000..6a43b82fba --- /dev/null +++ b/research/dyadic-center-basis-shear/CERTIFICATE.json @@ -0,0 +1,896 @@ +{ + "independent": { + "changed_cost": { + "gather": 12352, + "scatter": 31557, + "total": 43909 + }, + "changed_scatter_numerator_alphabet": [ + -2, + -1, + 0, + 1, + 2 + ], + "closed_formula_controls": [ + { + "changed_gather": 10, + "changed_scatter": 20, + "complete_three_stage_scalar_bound_saving": -192, + "gather_change": 1, + "h": 4, + "original_gather": 9, + "original_scatter": 19, + "saving_gather_plus_scatter": -2, + "scatter_change": 1 + }, + { + "changed_gather": 72, + "changed_scatter": 147, + "complete_three_stage_scalar_bound_saving": -19200, + "gather_change": 2, + "h": 6, + "original_gather": 70, + "original_scatter": 141, + "saving_gather_plus_scatter": -8, + "scatter_change": 6 + }, + { + "changed_gather": 226, + "changed_scatter": 486, + "complete_three_stage_scalar_bound_saving": -188160, + "gather_change": -5, + "h": 8, + "original_gather": 231, + "original_scatter": 471, + "saving_gather_plus_scatter": -10, + "scatter_change": 15 + }, + { + "changed_gather": 512, + "changed_scatter": 1149, + "complete_three_stage_scalar_bound_saving": 0, + "gather_change": -28, + "h": 10, + "original_gather": 540, + "original_scatter": 1121, + "saving_gather_plus_scatter": 0, + "scatter_change": 28 + }, + { + "changed_gather": 970, + "changed_scatter": 2248, + "complete_three_stage_scalar_bound_saving": 8712000, + "gather_change": -75, + "h": 12, + "original_gather": 1045, + "original_scatter": 2203, + "saving_gather_plus_scatter": 30, + "scatter_change": 45 + }, + { + "changed_gather": 1640, + "changed_scatter": 3895, + "complete_three_stage_scalar_bound_saving": 69957888, + "gather_change": -154, + "h": 14, + "original_gather": 1794, + "original_scatter": 3829, + "saving_gather_plus_scatter": 88, + "scatter_change": 66 + }, + { + "changed_gather": 5322, + "changed_scatter": 13244, + "complete_three_stage_scalar_bound_saving": 3976776000, + "gather_change": -663, + "h": 20, + "original_gather": 5985, + "original_scatter": 13091, + "saving_gather_plus_scatter": 510, + "scatter_change": 153 + }, + { + "changed_gather": 12352, + "changed_scatter": 31557, + "complete_three_stage_scalar_bound_saving": 59704320000, + "gather_change": -1748, + "h": 26, + "original_gather": 14100, + "original_scatter": 31281, + "saving_gather_plus_scatter": 1472, + "scatter_change": 276 + }, + { + "changed_gather": 19432, + "changed_scatter": 50239, + "complete_three_stage_scalar_bound_saving": 249232032000, + "gather_change": -2898, + "h": 30, + "original_gather": 22330, + "original_scatter": 49861, + "saving_gather_plus_scatter": 2520, + "scatter_change": 378 + } + ], + "closed_saving_at_26": { + "changed_gather": 12352, + "changed_scatter": 31557, + "complete_three_stage_scalar_bound_saving": 59704320000, + "gather_change": -1748, + "h": 26, + "original_gather": 14100, + "original_scatter": 31281, + "saving_gather_plus_scatter": 1472, + "scatter_change": 276 + }, + "coefficients": { + "coefficient_histogram": { + "-1": 4604600, + "0": 1973400, + "1": 179400, + "2": 2600 + }, + "coefficient_sha256": "2f6824bdd4d0a4669e974e7a6087fc7ed329c80c4e9b3afa891d46fee40e8eff", + "coefficients_checked": 6760000, + "digest_encoding": "Row-major lexicographic triples; one byte per coefficient plus one", + "h": 26, + "method": "Two closed-form head contractions and exact tail-intersection cardinality", + "triples": 2600 + }, + "dirty_central_controls": [ + { + "all_dirty_center_inputs_restored": true, + "arbitrary_y_preserved": true, + "basis_inputs": 12, + "coordinates": "Exact integer representation (x,2y,c); linearity extends to rational inputs", + "h": 4, + "invocations_checked": 24, + "orientations": 2, + "triples": 4, + "x_unchanged": true + }, + { + "all_dirty_center_inputs_restored": true, + "arbitrary_y_preserved": true, + "basis_inputs": 46, + "coordinates": "Exact integer representation (x,2y,c); linearity extends to rational inputs", + "h": 6, + "invocations_checked": 92, + "orientations": 2, + "triples": 20, + "x_unchanged": true + }, + { + "all_dirty_center_inputs_restored": true, + "arbitrary_y_preserved": true, + "basis_inputs": 120, + "coordinates": "Exact integer representation (x,2y,c); linearity extends to rational inputs", + "h": 8, + "invocations_checked": 240, + "orientations": 2, + "triples": 56, + "x_unchanged": true + } + ], + "negative_controls": { + "gather_changed_without_inverse_scatter_change": { + "S": [ + 0, + 2, + 3 + ], + "T": [ + 0, + 1, + 3 + ], + "actual_numerator": 0, + "expected_numerator": 1 + }, + "negative_two_numerator_flipped_positive": { + "S": [ + 0, + 3, + 4 + ], + "T": [ + 0, + 1, + 3 + ], + "actual_numerator": -3, + "expected_numerator": 1 + }, + "omitted_initial_dirty_scatter_rejected": true, + "omitted_inverse_gather_rejected": true + }, + "orbit_census": { + "admissible_moves": 650, + "candidate_moves": 1300, + "delta_histogram": { + "-1057": 2, + "-1472": 2, + "-252": 46, + "1220": 2, + "1748": 46, + "2000": 23, + "2277": 23, + "528": 506 + }, + "h": 26, + "method": "Dense closed factor entries; 16 coordinate-type/sign representatives with exact orbit multiplicities", + "minimizing_move_categories": [ + { + "delta": -1472, + "delta_G": -1748, + "delta_H": 276, + "gather_admissible": true, + "i_type": "B", + "j_type": "B", + "multiplicity": 2, + "representative": [ + 1, + 2, + -1 + ], + "scatter_admissible": true, + "sign": -1 + } + ], + "minimum_delta": -1472, + "orbit_records": [ + { + "gather_admissible": false, + "i_type": "A", + "j_type": "B", + "multiplicity": 2, + "representative": [ + 0, + 1, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "delta": 1220, + "delta_G": -2300, + "delta_H": 3520, + "gather_admissible": true, + "i_type": "A", + "j_type": "B", + "multiplicity": 2, + "representative": [ + 0, + 1, + 1 + ], + "scatter_admissible": true, + "sign": 1 + }, + { + "delta": 2277, + "delta_G": -300, + "delta_H": 2577, + "gather_admissible": true, + "i_type": "A", + "j_type": "C", + "multiplicity": 23, + "representative": [ + 0, + 3, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "gather_admissible": false, + "i_type": "A", + "j_type": "C", + "multiplicity": 23, + "representative": [ + 0, + 3, + 1 + ], + "scatter_admissible": false, + "sign": 1 + }, + { + "gather_admissible": false, + "i_type": "B", + "j_type": "A", + "multiplicity": 2, + "representative": [ + 1, + 0, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "delta": -1057, + "delta_G": -2000, + "delta_H": 943, + "gather_admissible": true, + "i_type": "B", + "j_type": "A", + "multiplicity": 2, + "representative": [ + 1, + 0, + 1 + ], + "scatter_admissible": true, + "sign": 1 + }, + { + "delta": -1472, + "delta_G": -1748, + "delta_H": 276, + "gather_admissible": true, + "i_type": "B", + "j_type": "B", + "multiplicity": 2, + "representative": [ + 1, + 2, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "gather_admissible": false, + "i_type": "B", + "j_type": "B", + "multiplicity": 2, + "representative": [ + 1, + 2, + 1 + ], + "scatter_admissible": true, + "sign": 1 + }, + { + "gather_admissible": false, + "i_type": "B", + "j_type": "C", + "multiplicity": 46, + "representative": [ + 1, + 3, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "delta": -252, + "delta_G": -252, + "delta_H": 0, + "gather_admissible": true, + "i_type": "B", + "j_type": "C", + "multiplicity": 46, + "representative": [ + 1, + 3, + 1 + ], + "scatter_admissible": true, + "sign": 1 + }, + { + "delta": 2000, + "delta_G": 2000, + "delta_H": 0, + "gather_admissible": true, + "i_type": "C", + "j_type": "A", + "multiplicity": 23, + "representative": [ + 3, + 0, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "gather_admissible": false, + "i_type": "C", + "j_type": "A", + "multiplicity": 23, + "representative": [ + 3, + 0, + 1 + ], + "scatter_admissible": false, + "sign": 1 + }, + { + "gather_admissible": false, + "i_type": "C", + "j_type": "B", + "multiplicity": 46, + "representative": [ + 3, + 1, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "delta": 1748, + "delta_G": 1748, + "delta_H": 0, + "gather_admissible": true, + "i_type": "C", + "j_type": "B", + "multiplicity": 46, + "representative": [ + 3, + 1, + 1 + ], + "scatter_admissible": true, + "sign": 1 + }, + { + "delta": 528, + "delta_G": 252, + "delta_H": 276, + "gather_admissible": true, + "i_type": "C", + "j_type": "C", + "multiplicity": 506, + "representative": [ + 3, + 4, + -1 + ], + "scatter_admissible": true, + "sign": -1 + }, + { + "gather_admissible": false, + "i_type": "C", + "j_type": "C", + "multiplicity": 506, + "representative": [ + 3, + 4, + 1 + ], + "scatter_admissible": true, + "sign": 1 + } + ], + "orbits": 16, + "rejected_moves": 650, + "stopping_rule": "All eight ordered coordinate-type pairs times both signs; AA excluded", + "symmetry": "Fix coordinate0; permute {1,2} and {3,...,h-1}, simultaneously permuting triple labels" + }, + "original_cost": { + "gather": 14100, + "scatter": 31281, + "total": 45381 + }, + "scope": "One fixed shear; full coefficient coverage at h=26; central commutator only; h<8 controls assert algebra only; no new multiplication exponent", + "shear": { + "changed_gather": "V_1 = t_1 - t_2", + "changed_scatter": "U_2 = s_1 + s_2 - 2*s_0", + "i": 1, + "j": 2, + "sign": -1 + }, + "status": "PASS_INDEPENDENT_DYADIC_CENTER_SHEAR" + }, + "pins": { + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "pinned_inputs": 25 + }, + "scope": "Historical complex scalar circuit improvement; unchanged rank profile; no new kappa; one-shear optimum only in the declared finite alphabet, not global circuit optimality", + "source_replay": { + "after": { + "G": 12352, + "G_plus_H": 43909, + "H": 31557 + }, + "before": { + "G": 14100, + "G_plus_H": 45381, + "H": 31281 + }, + "central_coefficient_sha256": "2f6824bdd4d0a4669e974e7a6087fc7ed329c80c4e9b3afa891d46fee40e8eff", + "central_coefficients_checked": 6760000, + "chosen_shear_parameter_controls": [ + { + "h": 8, + "new": { + "G": 226, + "G_plus_H": 712, + "H": 486 + }, + "old": { + "G": 231, + "G_plus_H": 702, + "H": 471 + }, + "saving": -10 + }, + { + "h": 10, + "new": { + "G": 512, + "G_plus_H": 1661, + "H": 1149 + }, + "old": { + "G": 540, + "G_plus_H": 1661, + "H": 1121 + }, + "saving": 0 + }, + { + "h": 12, + "new": { + "G": 970, + "G_plus_H": 3218, + "H": 2248 + }, + "old": { + "G": 1045, + "G_plus_H": 3248, + "H": 2203 + }, + "saving": 30 + }, + { + "h": 14, + "new": { + "G": 1640, + "G_plus_H": 5535, + "H": 3895 + }, + "old": { + "G": 1794, + "G_plus_H": 5623, + "H": 3829 + }, + "saving": 88 + }, + { + "h": 16, + "new": { + "G": 2562, + "G_plus_H": 8764, + "H": 6202 + }, + "old": { + "G": 2835, + "G_plus_H": 8946, + "H": 6111 + }, + "saving": 182 + }, + { + "h": 18, + "new": { + "G": 3776, + "G_plus_H": 13057, + "H": 9281 + }, + "old": { + "G": 4216, + "G_plus_H": 13377, + "H": 9161 + }, + "saving": 320 + }, + { + "h": 20, + "new": { + "G": 5322, + "G_plus_H": 18566, + "H": 13244 + }, + "old": { + "G": 5985, + "G_plus_H": 19076, + "H": 13091 + }, + "saving": 510 + }, + { + "h": 22, + "new": { + "G": 7240, + "G_plus_H": 25443, + "H": 18203 + }, + "old": { + "G": 8190, + "G_plus_H": 26203, + "H": 18013 + }, + "saving": 760 + }, + { + "h": 24, + "new": { + "G": 9570, + "G_plus_H": 33840, + "H": 24270 + }, + "old": { + "G": 10879, + "G_plus_H": 34918, + "H": 24039 + }, + "saving": 1078 + }, + { + "h": 26, + "new": { + "G": 12352, + "G_plus_H": 43909, + "H": 31557 + }, + "old": { + "G": 14100, + "G_plus_H": 45381, + "H": 31281 + }, + "saving": 1472 + }, + { + "h": 28, + "new": { + "G": 15626, + "G_plus_H": 55802, + "H": 40176 + }, + "old": { + "G": 17901, + "G_plus_H": 57752, + "H": 39851 + }, + "saving": 1950 + }, + { + "h": 30, + "new": { + "G": 19432, + "G_plus_H": 69671, + "H": 50239 + }, + "old": { + "G": 22330, + "G_plus_H": 72191, + "H": 49861 + }, + "saving": 2520 + }, + { + "h": 32, + "new": { + "G": 23810, + "G_plus_H": 85668, + "H": 61858 + }, + "old": { + "G": 27435, + "G_plus_H": 88858, + "H": 61423 + }, + "saving": 3190 + }, + { + "h": 34, + "new": { + "G": 28800, + "G_plus_H": 103945, + "H": 75145 + }, + "old": { + "G": 33264, + "G_plus_H": 107913, + "H": 74649 + }, + "saving": 3968 + }, + { + "h": 36, + "new": { + "G": 34442, + "G_plus_H": 124654, + "H": 90212 + }, + "old": { + "G": 39865, + "G_plus_H": 129516, + "H": 89651 + }, + "saving": 4862 + }, + { + "h": 38, + "new": { + "G": 40776, + "G_plus_H": 147947, + "H": 107171 + }, + "old": { + "G": 47286, + "G_plus_H": 153827, + "H": 106541 + }, + "saving": 5880 + }, + { + "h": 40, + "new": { + "G": 47842, + "G_plus_H": 173976, + "H": 126134 + }, + "old": { + "G": 55575, + "G_plus_H": 181006, + "H": 125431 + }, + "saving": 7030 + } + ], + "complete_dirty_invocations": [ + { + "arbitrary_side_and_center_inputs_restored": true, + "center_roles": 8, + "directions": 2, + "h": 8, + "independent_columns_per_direction": 998, + "side_roles": 878, + "source_roles": 56, + "sources_unchanged": true, + "target_roles": 56 + }, + { + "arbitrary_side_and_center_inputs_restored": true, + "center_roles": 10, + "directions": 2, + "h": 10, + "independent_columns_per_direction": 2767, + "side_roles": 2517, + "source_roles": 120, + "sources_unchanged": true, + "target_roles": 120 + } + ], + "counts": { + "L": 13709280000, + "N": 17576000000, + "W": 1247192960000, + "central_roles": 26, + "deficit": 7733440000, + "disjoint_roles": 60372, + "eta": "11/31179824", + "h": 26, + "intersection_two_roles": 29250, + "m": 17576, + "s": 21920655731520000, + "side_roles": 89622, + "v": 2600 + }, + "full_scalar_charge": { + "C": 10400, + "E": 124159782907546727457983300019839938112, + "J": 10400, + "M": 158444, + "additional_helper_roles": 0, + "center_basis_adapter_operations": 0, + "child_profile_changes": 0, + "fixed_side_steps_per_invocation": 696176, + "frame_changes": 0, + "guard": { + "B": 124159782907546727458005220675571458112, + "C0": 4881895913278036402129936106457482525749765266192734292477228464885704741276994568192, + "C1": "4961/1000", + "E": 124159782907546727457983300019839938112, + "alpha": "5", + "beta": "1/100", + "finite_network_and_node_charge_verified": false, + "m": 17576, + "recurrence_assumption": "A(e)<=s A(e/m)+E internally; A(e)<=8e at leaves e43909 full_scalar_saved=59704320000 no_new_kappa +``` + +The command recomputes every field of [CERTIFICATE.json](CERTIFICATE.json). +`--out /fresh/path.json` emits the recomputed certificate and refuses an +existing output. It verifies [SOURCES.json](SOURCES.json) before inherited +imports. An assertion-enabled isolated subprocess runs the original +constructors even when the outer verifier is invoked with `-O`. + +The actual adapter is `circuit.shear(original_factor, 1, 2, -1)`, consumed +by `source_worker.py` through the unchanged original `invoke` executor. +No source patch or selected-record change is required to replay it. + +## Base, selection and dependency boundary + +Base: `66849e1475c930fd7732b1a0067ffee7e1e95f60`. The OS-random assignment +seed was **20**, complex-supplier track. [SELECTION.json](SELECTION.json) +records the three candidates, scope, initial optimistic budget and bounded +search. Current CK/JP8 coefficient reuse overlaps #769/#787/#793; fixed-order +A/B frame freedom is covered by #776. Seed `20 % 3 = 2` selected the historical +center factor. Seed 20 also chooses the first of its two tied one-shear +minimizers. No pinned sprint issue existed, so the claim is local. + +The selected certificate was followed to the actual +[#626 construction](../complex-k492-owner-repair/README.md), +[review](../../docs/research/community-k492-review.md) and +[assembly](../community-k492-audit/pr626/replay/ASSEMBLY.json). +The current accepted conditional value at this base remains +`51110230636731/31250000000000000 = 0.001635527380375392`. +Its source head is `660de893d27bb7abd1d5b01b1640207528a5c851`, with reviewed +#622 `f69477f4f6d3c7eb1f740b166881bffed4ffa9f6` and retained #543 +`2065fe4f72a914d907f1046603f5a36f17018535`. This package changes none of them. + +The object improved here is Douglas R. Colkitt's +[historical dyadic center](../../docs/research/dyadic-central-factor.md), +[written factor/phase argument](../../notes/dyadic-central-factor.tex), and +[implementation](../../scripts/experiments/complex_centers.py), retained in +commit `d55bcd62ceb8f322bcf311a5a66e94c3ac7724f0`. The old note's h=26 saving +and `2^-31` language describe its historical checkpoint. They are not the +current frontier. There is no pending-PR code dependency, and no claim to +supersede contemporary E8 suppliers or their coefficient optimizations. + +## Exact construction + +Let `v=binom(h,3)` and `T0={0,1,2}`. For triple indicators `s,t`, the source +has scatter numerators U and gather coefficients V: + + U[S,0] = s0+s1+s2−1, U[S,i] = si−s0 (i≥1), + V[0,T] = 1, V[i,T] = ti−1(i∈T0) (i≥1). + +Its central map is `UV/2`, with `(UV)[S,T]=|S∩T|−1`. +Use center-coordinate matrix `A=I−E12`, whose inverse is `I+E12`: + + V' = A V, U' = U A^−1. + +Only one gather row and one scatter column change: + + V'[1,T] = t1−t2, + U'[S,2] = s1+s2−2s0. + +All other entries are unchanged. Since `E12²=0`, the product `U'V'=UV` +is exact in every dimension. The new gather still uses only 0,±1, while +scatter numerators lie in 0,±1,±2. Numerator −2 means a single subtraction +with scalar coefficient −1. This extends the old `verify_factor` alphabet +check (which excluded −2) but introduces no primitive operation: the old +negative scatter phase already applies −1 when an original numerator is +2. +The optional checker explicitly admits and prices both signs of 2; the +original checker remains untouched and is tested to reject the extended +alphabet for its original reason. + +## Dirty restoration and why no adapter is paid + +Let c be the arbitrary initial contents of the existing h center roles. +The central subsequence acts as + + y ← y − U'c/2, + c ← c + V'x, + y ← y + U'c/2, + c ← c − V'x. + +It leaves x and c unchanged and adds `U'V'x/2 = UVx/2` to y. The inverse +sequence subtracts this map and also restores c. No actual register is +converted from c to Ac: the new scatter cancels the same arbitrary dirty c +on its two visits. Consequently there is no initial/final center-basis +conversion and no additional helper or restoration work. + +The unchanged side subsequence supplies the complementary side map, so the +complete twelve-operation invocation is still `y ← y+x`, or `y ← y−x` +in reverse. Full exact formal-variable replay checks all 998 independent +source/target/side/center columns at h=8 and all 2,767 at h=10, in both +directions. Separately, the independent central implementation checks 356 +basis executions at h=4,6,8 in coordinates `(x,2y,c)`; h<8 is algebra-only +coverage, not a claim of a complete historical supplier at those sizes. + +## Complete cost and frame accounting + +Each nonzero gather entry costs one signed addition. A scatter numerator +±2 costs one signed addition; ±1 costs one halving and one signed addition. +Every source access represented by those updates is counted. The side +mixer M, copy C and weighted-injection J terms are freshly recounted from the +unchanged h=26 side topology: + + M=158444, C=10400, J=10400, + fixed side bill = 4M + 2C + 4J = 696176. + +The factors 4,2,4 include the inverse mixers, both copies and both weighted +injections. The full invocation costs `4M+2C+4J+2G+2H`, including both +central scatters and inverse gather. There are `3v²=20,280,000` invocations. +Thus the full scalar-bound decrease is `6v²·1472 = 59,704,320,000`. + +For the chosen shear, the old gather row has `binom(h−1,3)` nonzeros; the new +one has `2 binom(h−2,2)`. The old affected scatter column costs +`4 binom(h−2,2)`. Counting whether s0 is present and how many of s1,s2 are +present gives new cost `5 binom(h−2,2)`. Therefore + + saving in G+H = binom(h−1,3) − 3 binom(h−2,2) + = (h−10)(h−2)(h−3)/6. + +This improves the scalar bill exactly when h>10, is neutral at h=10, and +loses 10 operations at h=8. The replay checks the chosen formula against +actual factors for every even h from 8 through 40. This is a proof for the +chosen shear, not an unrestricted optimality theorem. + +Crucially, retain **all** original data and center incidences in each common +gather/scatter frame group, including incidences with zero scalar coefficient. +The inherited phase argument explicitly permits scalar factor changes under +this rule. No gate is split into new frames and no incidence is silently +removed. Every center retains its downward residual of dimension h; the +first/third-stage reuse still preserves center indices. Thus all helpers, +source corrections, endpoint repairs and recursive children keep their old +accounting: + +| Ledger item | Unchanged value at h=26 | +|---|---:| +| Center roles per invocation | 26 | +| Side roles per invocation | 89,622 | +| m | 17,576 | +| W | 1,247,192,960,000 | +| L | 13,709,280,000 | +| s | 21,920,655,731,520,000 | +| Wm−s | 7,733,440,000 | + +The source's scalar node allowance `E=64(W+m+1)³` is unchanged. The replay +checks `E > 4 steps_new + 8s + 8W + 8m`, and reproduces its conditional +stopped recurrence guard `A(e)≤s A(e/m)+E` with the same leaf rule. All +coefficients are still realized using the inherited signed-addition/halving +alphabet; its operation-count-based guard remains applicable. This does +not supply a new tight numerical-growth, tape or all-size realization proof. +The paid rank profile and its saving are unchanged. Another historical +supplier/assembly constraint cannot be improved by this scalar reduction +alone, and no assembly rerun or new exponent is claimed. + +## Bounded search and independent evidence + +The primary census exhausts exactly `2h(h−1)=1300` single elementary shears +`V_i←V_i+εV_j`, `U_j←U_j−εU_i`, with `i≠j`, `ε∈{−1,+1}`, at h=26. +It accepts only gather magnitudes ≤1 and scatter numerator magnitudes ≤2. +Exactly 650 moves meet both restrictions. The minimum change in G+H is +−1472, attained by `(i,j,ε)=(1,2,−1)` and `(2,1,−1)`. The source-bound +census records all coverage counts, the complete cost histogram and a +canonical transcript hash. The stopping rule is exhaustive completion of +this one-shear neighborhood; no multi-step search is being claimed. + +The independent implementation imports no producer or repository code. +It also checks the one-shear census by 16 coordinate-type/sign orbits. The +source factors are invariant, up to triple relabeling, under exchanging +coordinates 1 and 2 and permuting coordinates 3 through h−1. Thus the +classes {0}, {1,2}, {3,...,h−1} give eight ordered distinct-coordinate types +and two signs, with exact orbit multiplicities. Their admissibility, full +cost histogram and minimum must match the 1,300-move implementation. +This is a different finite counting method, not a larger search. + +The independent implementation contracts the three distinguished coordinates and the remaining intersection +cardinality separately, checks all 6,760,000 coefficients, and hashes the +same complete row-major coefficient stream as the sparse-multiplication +checker. Both costs and coefficient hashes must agree. Its separately +executed integer central circuits preserve all dirty inputs and detect +omitted restoration, omitted dirty cancellation, a gather-only rewrite and +the wrong sign on a −2 numerator. + +Additional checks, exact failure controls, overlap refresh and environment +are recorded in [VALIDATION.md](VALIDATION.md). No failed search is promoted +to an impossibility theorem. Optimality is limited to the declared finite +one-shear alphabet; general unimodular bases, multiple shears, new helpers, +new frame schedules and current supplier constructions remain open here. + +## Attribution and remaining obligations + +Prepared by **Curtis Dransfield with substantial OpenAI Codex assistance** in +construction, proof, code, verification and writing, including a separate +Codex worker's independent implementation and review. This is methodological +independence, not independent human peer review. New files use the repository's +Apache-2.0 license. + +Credit Douglas R. Colkitt for the historical dyadic factor, disjoint-tensor +side circuit, dirty transparent schedule, frame proof and recurrence ledger, +with their existing AI disclosures. The selected construction's Jeremy Kothe, +Chafik Boukhalfa, eumemic, DreamingOfClouds, Rohan Arun and retained predecessor +credits remain in its unchanged sources. Contemporary coefficient-circuit +work is credited as related scope, not imported or combined savings. + +This package freshly rebuilds h=26 scalar topology/counts and central +coefficients. Its unchanged h=26 side coefficient/phase proofs are inherited; +full dirty-input invocation replay is finite at h=8,10. The full tensorized +network, upstream analytic transfer, fixed-tape/precision and all-size +compiler assumptions are not newly proved. Neither the historical certificate +nor the selected frontier is edited, and no Lean or full multiplication-theorem +verification is asserted. diff --git a/research/dyadic-center-basis-shear/SELECTION.json b/research/dyadic-center-basis-shear/SELECTION.json new file mode 100644 index 0000000000..336d1b90c3 --- /dev/null +++ b/research/dyadic-center-basis-shear/SELECTION.json @@ -0,0 +1,59 @@ +{ + "assignment_seed": 20, + "seed_source": "OS randomness via secrets.randbelow(100)", + "started_utc": "2026-10-13T05:41:00.896452+00:00", + "expected_finish_utc": "2026-10-13T06:21:00.896452+00:00", + "verification_reserve_starts_utc": "2026-10-13T06:11:00.896452+00:00", + "track": "complex supplier", + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "claimed_utc": "2026-10-13T05:44:36.681013+00:00", + "coordination": "Pinned issue query returned no nodes; local claim", + "candidates": [ + { + "object": "selected CK/JP8 coefficient reuse", + "decision": "declined: crowded by PR769/787/793 and predecessors" + }, + { + "object": "selected fixed-order A/B frame reassignment", + "decision": "declined: closed by PR776 exact duals; no new mechanism" + }, + { + "object": "historical rank-h dyadic center basis", + "decision": "chosen by seed20%3=2; no matching central-basis audit in612 open PR descriptions" + } + ], + "object": "One elementary center-basis shear in scripts/experiments/complex_centers.py factor(26), retaining all center/data incidences and common frames", + "method": "Enumerate all h(h-1)*2 single shears with coefficients +/-1 and retained unit gather/dyadic scatter alphabet; choose minimum complete gather+scatter bill, seed tie-break; prove product identity, price full transparent invocation and verify dirty restoration", + "hypothesis": "A unimodular center reparameterization can reduce gather+scatter operations without adding helpers or changing the paid frame profile", + "expected_deliverable": "One executable finite circuit improvement and exact scoped one-shear census, with proof, certificate, controls and no new kappa", + "domain": { + "main_h": 26, + "moves": 1300, + "signs": [ + -1, + 1 + ], + "admissible_gather_abs_max": 1, + "admissible_scatter_numerator_abs_max": 2, + "stopping_rule": "Exhaust one-shear neighborhood; no multi-step or unbounded search" + }, + "initial_budget_probe": { + "old_G": 14100, + "old_H": 31281, + "best_delta_G_plus_H": -1472, + "valid_moves": 650, + "note": "Small optimistic screen during selection; must verify complete cost and dirty/frame contracts" + }, + "overlap": { + "open_pr_count": 612, + "latest": 793, + "related": [ + 769, + 776, + 787, + 793 + ], + "pending_code_dependencies": [] + }, + "record_type": "Immutable selection snapshot; final local claim will carry PR result" +} diff --git a/research/dyadic-center-basis-shear/SOURCES.json b/research/dyadic-center-basis-shear/SOURCES.json new file mode 100644 index 0000000000..2d976b2a8a --- /dev/null +++ b/research/dyadic-center-basis-shear/SOURCES.json @@ -0,0 +1,31 @@ +{ + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "sha256": { + "certificates/dyadic-central-factor.json": "ffae0f0a22863718e3134a924592dcf4b05e919223323ba536c587c592bfe6a1", + "certificates/selected-result.json": "b3bf402f31a69bde0629936a9b569bed48281568d7b16d5fba120b5311ea1f53", + "docs/research/community-k492-review.md": "3b731d30e80010b15408a289b0b32192700885474c8b36d48ee3320a7a8c5c47", + "docs/research/current-status.md": "197319a6edf04340ec3623d09d03714fcd6a981359f22bdcefdd06e7e2f4174d", + "docs/research/dyadic-central-factor.md": "e97b1dfe11b5eaebacf3f910131e13bcad586ea5fc1af05db23c00ae0eea5c11", + "notes/complex-compression.tex": "10312815290c7bb8ef4db153e30fba13c032bf17ccaf991a34f1aa6340405a0d", + "notes/disjoint-tensor-compression.tex": "528cba56872313b8cd63ff11f523a399dfb3c85cae1a764110ae9d26ac9151ac", + "notes/dyadic-central-factor.tex": "24c0543fb2fd815f114021f929c3efefa1ae79f29c2f7968585bcd4595a96158", + "research/community-k492-audit/pr626/replay/ASSEMBLY.json": "6127732e2fcdd470dab349c1c51d03cd9f0787ad0309b1b4a7c811a908028f4e", + "research/complex-k492-owner-repair/README.md": "ee5a1ace4828f7a073be97e95c2d931988774dd3a29a877e65abdf429aeec902", + "scripts/audit_complex_centers.py": "166b18f560cd0d520d23fa29ee8147e0ea056358c4268a466ec458195a97a960", + "scripts/binary_phase_frames.py": "4148cfa313cf050ed25296e8db36d35871520b8318fd086c7d1facf0c6af67d7", + "scripts/certify.py": "2348d95008276c5d5764f7e028c3918e484582cd589bd4d9b82919161745e53e", + "scripts/complex_compression.py": "9b6f758a5985ba5d9fdd726fe6556b3d3b4bd9d98aaf8ba06a7bb58093c4c504", + "scripts/exclusion_circuit.py": "b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0", + "scripts/experiments/complex_centers.py": "3744396587d729253d80980f6310b56e7bf0ea21b165bd178d0d6d4c49faf2e2", + "scripts/experiments/disjoint_tensor.py": "102dd59bf96033f96ba0dab4c2aba77b3a7a73b67b0f96929ff8b20a98b91cd8", + "scripts/general_network_guard.py": "790a2064449afdbffd6dbd4adbcf4a28eaf41931ce7134e4a4e8766f3764270c", + "scripts/incidence_rectangles.py": "5240fd33dcc3096f5685d10ca360186cad36b355a00d55686a4ea4449417d00e", + "scripts/paired_exclusion_circuit.py": "8f05f04cf06217befd6d0ee0f2d7d0c5c5eb32cfab8c9a8ca7917fd6d620b7d2", + "scripts/paired_network.py": "991223dc3c1374284c361ed017e42bf732dd971fa0bea2be2282cfb18257b3f7", + "scripts/prepare_layers.py": "a6e2adc612f264b1c0e51d18ce6315de9ae5e2ae2420aa22e99a22d8bf304947", + "scripts/search_network.py": "3a4faa5037d9b8e7ca5828afac193a96b6966a8b114f14937921795b24ec4f6a", + "scripts/shared_point_circuit.py": "c9bb7a5df92d260a4e3ad532b53e26936730d7c93f7facfb0784957c1e81c8ba", + "scripts/shared_point_network.py": "a85e7f0d8c42d6a27e3846308571ca324a1824ac5c2d59e4daa5c7673c33c697" + }, + "upstream_frozen_commit": "adc7f1241b42e322a6451854ab7e4b4c146bf78a" +} diff --git a/research/dyadic-center-basis-shear/VALIDATION.md b/research/dyadic-center-basis-shear/VALIDATION.md new file mode 100644 index 0000000000..c8ab44cf6b --- /dev/null +++ b/research/dyadic-center-basis-shear/VALIDATION.md @@ -0,0 +1,113 @@ +# Verification and handoff + +Base `66849e1475c930fd7732b1a0067ffee7e1e95f60`; CPython 3.14.2, +macOS 26.3 arm64, standard library only. The runtime uses Python 3.11+. +Sprint began 2026-10-13 at 05:41 UTC, with a 40-minute budget; the claim was +recorded during the initial selection window. Construction/proof work ended +around 05:55 UTC, with the remaining work dedicated to verification and +handoff, ahead of the reserved final-quarter deadline of 06:11 UTC. + +## Final commands + +From the repository root: + +```sh +python3 -I -B research/dyadic-center-basis-shear/verify.py +python3 -I -O -B research/dyadic-center-basis-shear/verify.py +python3 -I -B research/dyadic-center-basis-shear/test_circuit.py +python3 -I -O -B research/dyadic-center-basis-shear/test_circuit.py +python3 -I -B -m unittest discover -s tests -p test_complex_centers.py -v +make selected-record-check +``` + +Both full replays match every committed certificate field. All **8 new tests** +pass in both modes. All **4 original center tests** pass. The selected-record +check returns its unchanged conditional kappa +`51110230636731/31250000000000000`. + +The primary sparse contraction and independent head/tail implementation +check all **6,760,000** h=26 coefficients and produce identical SHA256 +`2f6824bdd4d0a4669e974e7a6087fc7ed329c80c4e9b3afa891d46fee40e8eff`. +The direct **1,300-move** census and independent **16-orbit** census agree on +all admissibility counts, cost histograms and minima. Unit tests cross-check +these two search methods at h=8,10,12,26. + +The unchanged full invocation executor checks all 998 formal input columns +at h=8 and all 2,767 at h=10 in each direction: **7,530 column/direction +obligations** including every arbitrary dirty side/center input. The +independent central checker performs **356** exact integer basis executions. +The source worker rebuilds the full h=26 side topology and recounts M,C,J; +it inherits the unchanged full-size side-coefficient and phase proofs. + +## Failures detected and final portability + +A minimal temporary checkout containing only the **25 pinned inherited +inputs** and this package passes under `-I -O`, with spaces in its path, +an unrelated working directory, a hostile `PYTHONPATH/sitecustomize.py`, +and ambient `PYTHONOPTIMIZE=2`. Its inherited subprocess still runs with +assertions enabled. The observed isolated replay took approximately 5.63s; +this is descriptive, not a performance result or pass threshold. + +A fresh `--out` certificate agrees field-for-field. Separate subprocess +controls reject: + +- an existing output path, preserving its original bytes; +- altered bytes in the lazily imported `scripts/complex_compression.py`; +- a certificate with scatter charge H reduced by one; +- directly invoking the inherited source worker with assertions disabled. + +The mathematical controls detect a gather-only shear, an incorrect sign on +a −2 scatter numerator, omitted inverse gather, and omitted initial dirty +scatter. Invalid alphabet/shape/move inputs and missing/mutated source pins +are rejected. The −2 numerator appears exactly `binom(23,2)=253` times at +h=26 and is charged as a signed unit update. The original factor checker +continues to reject its unsupported alphabet; no original guard is weakened. + +Two packaging defects were corrected during verification before submission: +the initial import-time manifest missed lazy imports, so the final manifest +is built from complete runtime coverage and checked against the worker's +reported import inventory; tuple/list representation differences in the +independent counterexamples caused certificate comparison failure, so the +complete result is normalized to exact JSON representations before comparing. +No mathematical field was excluded. Final normal, optimized and relocated +replays pass after both fixes. + +All 25 inherited pin hashes were compared against exact Git blobs at the +base. All numeric JSON values are exact integers or rational strings. +A separate Codex worker reviewed the proof, full costs, source-coverage +changes and certificate normalization; no material issue was found. That +is AI-assisted methodological review, not independent human review. + +## Overlap refresh and scope + +At approximately 05:58 UTC, a fresh query found **621 open PRs through #802**, +compared with 612 through #793 at selection. Main still equaled the base; +the pinned-issues query again returned no nodes. New/changed titles and +full bodies matching the center-basis/dyadic-factor scope were inspected. +No matching historical one-shear contribution was found. + +| Related PR | Inspected head | Distinct scope | +|---|---|---| +| #769 | `e891b2b19e3185ec91bcf001e255af87f42389ce` | Selected CK coefficient ladders. | +| #776 | `8bd985fe2842c948a5a4a1554b8e090f2e371afa` | Selected fixed-order A/B frame ceiling. | +| #786 | `c6ae38d9f5a13c53dab623fd6947f08d92173287` | Selected CK/JP8 center quarter scaling and its added-macro cost. | +| #787 | `93ceb65cfbf339d7ca743614d4756a3af1440cd4` | Selected coefficient-lowering/cleanup composition. | +| #793 | `f9383f324ee86793c5ae7b73f8e39d5827a8aa52` | Selected JP8 compensation reordering and batching. | + +These contributions are credited as related circuit research; none is a +code dependency or an additive saving here. The source architecture, +operation bill and common-frame grouping in this package are the historical +h-triple construction. The new mechanism changes its scalar factorization, +not a previously closed fixed-factor frame search. + +Only `research/dyadic-center-basis-shear/` is added. `upstream/`, original +source files, certificates, selected frontier and unrelated artifacts remain +unchanged. The full repository suite and selected supplier cold replay were +not repeated because this optional historical experiment edits no generator +or selected construction. No remote CI, full-size phase replay, full-tensor +scalar replay, new global admission or Lean proof is claimed. Remaining +conditions are stated in README.md. + +Attribution: Curtis Dransfield with substantial OpenAI Codex assistance; +Douglas R. Colkitt's source construction and retained predecessors credited +in README.md. New contribution: Apache-2.0. diff --git a/research/dyadic-center-basis-shear/circuit.py b/research/dyadic-center-basis-shear/circuit.py new file mode 100644 index 0000000000..701de36554 --- /dev/null +++ b/research/dyadic-center-basis-shear/circuit.py @@ -0,0 +1,121 @@ +"""Exact single-shear center reparameterization and finite cost census. + +Copyright 2026 Curtis Dransfield. Apache-2.0; substantial OpenAI Codex assistance. +""" +from collections import Counter +from fractions import Fraction +import hashlib +from itertools import combinations +import json +from math import comb + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def validate(f): + h = f['h'] + require(type(h) is int and h >= 8 and h % 2 == 0, 'Use even h >= 8') + require(f['triples'] == list(combinations(range(h), 3)), 'Wrong ordered triples') + n = comb(h, 3) + require(len(f['gather']) == len(f['scatter']) == n, 'Wrong factor shape') + for v in f['gather']: + require(len({i for i, x in v}) == len(v), 'Repeated gather coordinate') + require(all(type(i) is int and 0 <= i < h and type(x) is int and x in (-1, 1) + for i, x in v), 'Gather requires unit integer coefficients') + require(all(len(u) == h and all(type(x) is int and abs(x) <= 2 for x in u) + for u in f['scatter']), 'Scatter requires integer numerators of magnitude at most two') + + +def shear(f, i, j, sign): + validate(f) + require(type(i) is int and type(j) is int and 0 <= i < f['h'] and 0 <= j < f['h'] + and i != j and type(sign) is int and sign in (-1, 1), 'Invalid elementary shear') + gather = [] + for sparse in f['gather']: + row = dict(sparse) + row[i] = row.get(i, 0) + sign*row.get(j, 0) + gather.append(tuple((a, x) for a, x in sorted(row.items()) if x)) + scatter = [] + for row in f['scatter']: + updated = list(row) + updated[j] -= sign*row[i] + scatter.append(tuple(updated)) + result = dict(h=f['h'], triples=list(f['triples']), gather=gather, scatter=scatter) + validate(result) + return result + + +def charge(f): + validate(f) + G = sum(len(v) for v in f['gather']) + H = sum(1 if abs(x) == 2 else 2 for u in f['scatter'] for x in u if x) + return dict(G=G, H=H, G_plus_H=G+H) + + +def verify_product(f): + validate(f) + masks = [sum(1 << x for x in T) for T in f['triples']] + digest = hashlib.sha256() + for S, u in zip(masks, f['scatter']): + row = bytearray() + for T, v in zip(masks, f['gather']): + value = sum(u[i]*x for i, x in v) + require(value == (S & T).bit_count()-1, 'Central product coefficient mismatch') + row.append(value+1) + digest.update(row) + return dict(coefficients_checked=len(masks)**2, coefficient_sha256=digest.hexdigest()) + + +def census(f, seed=20): + """Exhaust exactly one unit elementary shear, preserving the declared alphabet.""" + validate(f) + h = f['h'] + V = [[dict(v).get(i, 0) for v in f['gather']] for i in range(h)] + U = list(zip(*f['scatter'])) + def gc(row): return sum(x != 0 for x in row) + def hc(row): return sum(0 if x == 0 else 1 if abs(x) == 2 else 2 for x in row) + records, admissible = [], [] + for i in range(h): + for j in range(h): + if i == j: + continue + for sign in (-1, 1): + v = [a + sign*b for a, b in zip(V[i], V[j])] + u = [a - sign*b for a, b in zip(U[j], U[i])] + gather_ok, scatter_ok = max(map(abs, v)) <= 1, max(map(abs, u)) <= 2 + row = dict(i=i, j=j, sign=sign, gather_admissible=gather_ok, + scatter_admissible=scatter_ok) + if gather_ok and scatter_ok: + row.update(delta_G=gc(v)-gc(V[i]), delta_H=hc(u)-hc(U[j])) + row['delta'] = row['delta_G'] + row['delta_H'] + admissible.append(row) + records.append(row) + minimum = min(r['delta'] for r in admissible) + winners = [r for r in admissible if r['delta'] == minimum] + chosen = winners[seed % len(winners)] + transcript = json.dumps(records, sort_keys=True, separators=(',', ':')).encode() + return dict(h=h, assignment_seed=seed, candidate_moves=len(records), + admissible_moves=len(admissible), rejected_moves=len(records)-len(admissible), + delta_histogram=dict(sorted(Counter(str(r['delta']) for r in admissible).items())), + minimum_delta=minimum, minimizers=winners, selected=chosen, + tie_rule='Lexicographic (i,j,sign) enumeration; seed modulo number of minimizers', + transcript_sha256=hashlib.sha256(transcript).hexdigest(), + stopping_rule='All 2*h*(h-1) one-shear moves; no compositions or adaptive search') + + +def closed_saving(h): + require(type(h) is int and h >= 8 and h % 2 == 0, 'Use even h >= 8') + return (h-10)*(h-2)*(h-3)//6 + + +def serializable(value): + if isinstance(value, Fraction): + return str(value) + if isinstance(value, dict): + return {str(k): serializable(v) for k, v in value.items()} + if isinstance(value, (tuple, list)): + return [serializable(v) for v in value] + return value diff --git a/research/dyadic-center-basis-shear/independent.py b/research/dyadic-center-basis-shear/independent.py new file mode 100644 index 0000000000..946c7effad --- /dev/null +++ b/research/dyadic-center-basis-shear/independent.py @@ -0,0 +1,283 @@ +#!/usr/bin/env python3 +"""Independent closed-form and dirty-register checks for one center shear. + +Copyright 2026 Curtis Dransfield. Apache-2.0. +Prepared with substantial OpenAI Codex assistance. Original dyadic central +factor and transparent schedule: Douglas R. Colkitt, with retained Codex +assistance disclosure. This module imports no repository implementation. + +Only the central commutator is checked here; this is not a full scalar +network, frame, recursive-interface, or multiplication-exponent certificate. +""" +from collections import Counter +from hashlib import sha256 +from itertools import combinations +import json +from math import comb + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def factor_entries(h, changed=False): + """Own dense formulas; h<8 is used only for small algebra controls. + + U_rows[S] is a scatter numerator row. V_columns[T] is a gather column. + The changed entries are V[1,T]=t1-t2 and U[S,2]=s1+s2-2s0. + """ + require(type(h) is int and h >= 3, 'Use integer h >= 3') + triples = tuple(combinations(range(h), 3)) + gather, scatter = [], [] + for triple in triples: + indicator = tuple(int(i in triple) for i in range(h)) + s0, s1, s2 = indicator[:3] + v = [1, s1-s2 if changed else s1-1, s2-1] + list(indicator[3:]) + u = [s0+s1+s2-1, s1-s0, + s1+s2-2*s0 if changed else s2-s0] + u += [x-s0 for x in indicator[3:]] + gather.append(tuple(v)) + scatter.append(tuple(u)) + return dict(h=h, triples=triples, U_rows=tuple(scatter), V_columns=tuple(gather)) + + +def weighted_cost(factor): + gather = sum(x != 0 for column in factor['V_columns'] for x in column) + scatter = sum(1 if abs(x) == 2 else 2 for row in factor['U_rows'] for x in row if x) + return dict(gather=gather, scatter=scatter, total=gather+scatter) + + +def closed_cost_formula(h): + def choose(n, k): + return comb(n, k) if n >= k >= 0 else 0 + n = comb(h, 3) + old_gather = n + 2*choose(h-1, 3) + (h-3)*choose(h-1, 2) + old_scatter = 2*choose(h-3, 3) + 6*(h-3) + 1 + 4*(h-1)*choose(h-2, 2) + gather_change = 2*choose(h-2, 2) - choose(h-1, 3) + scatter_change = choose(h-2, 2) + numerator = (h-10)*(h-2)*(h-3) + require(numerator % 6 == 0, 'Nonintegral closed saving') + saving = numerator // 6 + require(saving == -(gather_change + scatter_change), 'Saving formulas disagree') + return dict(h=h, original_gather=old_gather, original_scatter=old_scatter, + changed_gather=old_gather+gather_change, + changed_scatter=old_scatter+scatter_change, + gather_change=gather_change, scatter_change=scatter_change, + saving_gather_plus_scatter=saving, + complete_three_stage_scalar_bound_saving=6*n*n*saving) + + +def orbit_census(h=26): + """Check 16 coordinate-type/sign orbits instead of individual moves. + + The stabilizer of coordinate zero and the base triple permutes B={1,2} + and C={3,...,h-1}. Simultaneously permuting triples and these coordinates + preserves every factor entry and charge. Distinct ordered indices have + eight type pairs (AA is impossible), each with two signs. + """ + require(type(h) is int and h >= 8 and h % 2 == 0, 'Use even h >= 8') + factor = factor_entries(h) + classes = {'A': (0,), 'B': (1, 2), 'C': tuple(range(3, h))} + records = [] + histogram = Counter() + admissible = total = 0 + for i_type, i_members in classes.items(): + for j_type, j_members in classes.items(): + if i_type == j_type and len(i_members) == 1: + continue + i = i_members[0] + j = j_members[1] if i_type == j_type else j_members[0] + multiplicity = len(i_members)*(len(j_members)-int(i_type == j_type)) + original_v = tuple(column[i] for column in factor['V_columns']) + other_v = tuple(column[j] for column in factor['V_columns']) + original_u = tuple(row[j] for row in factor['U_rows']) + other_u = tuple(row[i] for row in factor['U_rows']) + for sign in (-1, 1): + changed_v = tuple(a + sign*b for a, b in zip(original_v, other_v)) + changed_u = tuple(a - sign*b for a, b in zip(original_u, other_u)) + gather_ok = all(x in (-1, 0, 1) for x in changed_v) + scatter_ok = all(x in (-2, -1, 0, 1, 2) for x in changed_u) + result = dict(i_type=i_type, j_type=j_type, sign=sign, + representative=[i, j, sign], multiplicity=multiplicity, + gather_admissible=gather_ok, scatter_admissible=scatter_ok) + total += multiplicity + if gather_ok and scatter_ok: + # Independent literal prices; only the affected row and + # column enter the difference because every other entry + # is identical under an elementary shear. + prices = {0: 0, -1: 2, 1: 2, -2: 1, 2: 1} + delta_g = sum(x != 0 for x in changed_v) - sum(x != 0 for x in original_v) + delta_h = sum(prices[x] for x in changed_u) - sum(prices[x] for x in original_u) + result.update(delta_G=delta_g, delta_H=delta_h, delta=delta_g+delta_h) + histogram[delta_g+delta_h] += multiplicity + admissible += multiplicity + records.append(result) + require(len(records) == 16 and total == 2*h*(h-1), 'Incomplete coordinate-type orbit cover') + minimum = min(histogram) + return dict(h=h, orbits=len(records), candidate_moves=total, + admissible_moves=admissible, rejected_moves=total-admissible, + delta_histogram={str(delta): count for delta, count in sorted(histogram.items())}, + minimum_delta=minimum, + minimizing_move_categories=[row for row in records if row.get('delta') == minimum], + orbit_records=records, + method='Dense closed factor entries; 16 coordinate-type/sign representatives with exact orbit multiplicities', + symmetry='Fix coordinate0; permute {1,2} and {3,...,h-1}, simultaneously permuting triple labels', + stopping_rule='All eight ordered coordinate-type pairs times both signs; AA excluded') + + +def coefficient_check(h=26): + """Check every coefficient by contracting the unchanged tail in closed form. + + The tail dot product is |S_tail intersect T_tail|-s0*|T_tail|. + This avoids both sparse-factor multiplication and imported producer code. + """ + triples = tuple(combinations(range(h), 3)) + masks = [sum(1 << i for i in triple) for triple in triples] + source_features = [] + target_features = [] + for mask in masks: + a, b, c = (mask >> i & 1 for i in range(3)) + source_features.append((mask, mask & ~7, a, a+b+c-1, b-a, c-a, b+c-2*a)) + target_features.append((mask, mask & ~7, b-1, c-1, b-c, 3-a-b-c)) + histogram = [0, 0, 0, 0] + digest = sha256() + checked = 0 + for source_mask, source_tail, s0, u0, u1, old_u2, new_u2 in source_features: + row = bytearray() + for target_mask, target_tail, old_v1, v2, new_v1, tail_size in target_features: + common_tail = (source_tail & target_tail).bit_count() - s0*tail_size + old_value = u0 + u1*old_v1 + old_u2*v2 + common_tail + new_value = u0 + u1*new_v1 + new_u2*v2 + common_tail + expected = (source_mask & target_mask).bit_count() - 1 + if old_value != expected or new_value != expected: + raise ValueError('Closed coefficient mismatch for masks ' + + str((source_mask, target_mask))) + histogram[expected+1] += 1 + row.append(new_value+1) + checked += 1 + digest.update(row) + require(checked == len(triples)**2, 'Incomplete coefficient coverage') + return dict(h=h, triples=len(triples), coefficients_checked=checked, + coefficient_histogram={str(i-1): count for i, count in enumerate(histogram)}, + coefficient_sha256=digest.hexdigest(), + digest_encoding='Row-major lexicographic triples; one byte per coefficient plus one', + method='Two closed-form head contractions and exact tail-intersection cardinality') + + +def _central_run(factor, x, doubled_y, center, inverse=False, omit_step=None): + """Simulate integer coordinates (x,2y,c), so scatter uses U, not U/2.""" + x, doubled_y, center = list(x), list(doubled_y), list(center) + operations = (('scatter', -1), ('gather', 1), ('scatter', 1), ('gather', -1)) + if inverse: + operations = tuple((name, -sign) for name, sign in reversed(operations)) + for step, (name, sign) in enumerate(operations): + if step == omit_step: + continue + if name == 'gather': + for coefficient, column in zip(x, factor['V_columns']): + if coefficient: + for i, value in enumerate(column): + center[i] += sign*coefficient*value + else: + for i, row in enumerate(factor['U_rows']): + doubled_y[i] += sign*sum(a*b for a, b in zip(row, center)) + return x, doubled_y, center + + +def dirty_basis_check(h): + factor = factor_entries(h, changed=True) + n = len(factor['triples']) + masks = [sum(1 << i for i in triple) for triple in factor['triples']] + checked = 0 + for inverse in (False, True): + for basis in range(2*n+h): + x, y2, center = [0]*n, [0]*n, [0]*h + if basis < n: + x[basis] = 1 + elif basis < 2*n: + y2[basis-n] = 2 + else: + center[basis-2*n] = 1 + expected_y2 = list(y2) + if basis < n: + for i, mask in enumerate(masks): + expected_y2[i] += (-1 if inverse else 1)*((mask & masks[basis]).bit_count()-1) + actual = _central_run(factor, x, y2, center, inverse) + require(actual == (x, expected_y2, center), 'Dirty central basis state failed') + checked += 1 + return dict(h=h, triples=n, basis_inputs=2*n+h, orientations=2, + invocations_checked=checked, all_dirty_center_inputs_restored=True, + x_unchanged=True, arbitrary_y_preserved=True, + coordinates='Exact integer representation (x,2y,c); linearity extends to rational inputs') + + +def mutation_controls(): + old, changed = factor_entries(6), factor_entries(6, changed=True) + n = len(changed['triples']) + x, y2, center = [0]*n, [0]*n, [0]*6 + x[0] = 1 + omitted_restore = _central_run(changed, x, y2, center, omit_step=3) + require(omitted_restore[2] != center, 'Missing restore mutation went undetected') + x = [0]*n + center[0] = 1 + omitted_dirty_cancel = _central_run(changed, x, y2, center, omit_step=0) + require(omitted_dirty_cancel[1] != y2, 'Missing dirty cancellation went undetected') + + def first_mismatch(rows, columns): + for i, row in enumerate(rows): + for j, column in enumerate(columns): + actual = sum(a*b for a, b in zip(row, column)) + expected = len(set(changed['triples'][i]) & set(changed['triples'][j]))-1 + if actual != expected: + return dict(S=changed['triples'][i], T=changed['triples'][j], + actual_numerator=actual, expected_numerator=expected) + raise ValueError('Factor mutation went undetected') + + gather_only = first_mismatch(old['U_rows'], changed['V_columns']) + wrong_rows = [list(row) for row in changed['U_rows']] + mutated_row = next(i for i, row in enumerate(wrong_rows) if row[2] == -2) + wrong_rows[mutated_row][2] = 2 + wrong_sign = first_mismatch(wrong_rows, changed['V_columns']) + return dict(omitted_inverse_gather_rejected=True, + omitted_initial_dirty_scatter_rejected=True, + gather_changed_without_inverse_scatter_change=gather_only, + negative_two_numerator_flipped_positive=wrong_sign) + + +def independent_check(): + old, changed = factor_entries(26), factor_entries(26, changed=True) + before, after = weighted_cost(old), weighted_cost(changed) + closed = closed_cost_formula(26) + require(before == dict(gather=14100, scatter=31281, total=45381), 'Original cost changed') + require(after == dict(gather=12352, scatter=31557, total=43909), 'Changed cost changed') + require(before['total'] - after['total'] == 1472, 'Wrong exact scalar saving') + require(all(x in (-1, 0, 1) for col in changed['V_columns'] for x in col), + 'Changed gather alphabet failed') + scatter_alphabet = sorted({x for row in changed['U_rows'] for x in row}) + require(scatter_alphabet == [-2, -1, 0, 1, 2], 'Changed scatter alphabet failed') + formula_cases = [] + for h in (4, 6, 8, 10, 12, 14, 20, 26, 30): + original, altered = weighted_cost(factor_entries(h)), weighted_cost(factor_entries(h, True)) + formula = closed_cost_formula(h) + require(original['gather'] == formula['original_gather'] and + original['scatter'] == formula['original_scatter'] and + altered['gather'] == formula['changed_gather'] and + altered['scatter'] == formula['changed_scatter'], 'Closed cost formula mismatch') + formula_cases.append(formula) + return dict( + status='PASS_INDEPENDENT_DYADIC_CENTER_SHEAR', + shear=dict(i=1, j=2, sign=-1, changed_gather='V_1 = t_1 - t_2', + changed_scatter='U_2 = s_1 + s_2 - 2*s_0'), + coefficients=coefficient_check(26), orbit_census=orbit_census(26), + original_cost=before, changed_cost=after, + closed_saving_at_26=closed, closed_formula_controls=formula_cases, + changed_scatter_numerator_alphabet=scatter_alphabet, + dirty_central_controls=[dirty_basis_check(h) for h in (4, 6, 8)], + negative_controls=mutation_controls(), + scope='One fixed shear; full coefficient coverage at h=26; central commutator only; ' + 'h<8 controls assert algebra only; no new multiplication exponent') + + +if __name__ == '__main__': + print(json.dumps(independent_check(), indent=2, sort_keys=True)) diff --git a/research/dyadic-center-basis-shear/source_worker.py b/research/dyadic-center-basis-shear/source_worker.py new file mode 100644 index 0000000000..5b38cda158 --- /dev/null +++ b/research/dyadic-center-basis-shear/source_worker.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python3 +"""Assertion-enabled source replay for the historical center-basis experiment. + +Copyright 2026 Curtis Dransfield. Apache-2.0; substantial OpenAI Codex assistance. +""" +from fractions import Fraction as F +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +from circuit import census, charge, closed_saving, require, serializable, shear, verify_product +require(__debug__, 'Inherited constructors must run with assertions enabled') +sys.path.insert(0, str(ROOT / 'scripts')) +from experiments.complex_centers import factor, invoke, counts, verify_factor +from experiments.disjoint_tensor import DisjointTensor, scalar_program +from general_network_guard import guard + + +class Form: + """Sparse rational row for simultaneous, independent dirty input columns.""" + def __init__(self, row): + self.row = {i: F(c) for i, c in row.items() if c} + def __add__(self, other): + row = dict(self.row) + for i, c in other.row.items(): + row[i] = row.get(i, F(0)) + c + return Form(row) + def __mul__(self, c): + return Form({i: c*x for i, x in self.row.items()}) + __rmul__ = __mul__ + def __sub__(self, other): + return self + (-1)*other + def __eq__(self, other): + return isinstance(other, Form) and self.row == other.row + + +def invocation_control(h): + f = shear(factor(h), 1, 2, -1) + code = scalar_program(DisjointTensor(h)) + n, R = len(f['triples']), code['roles'] + total = 2*n + R + h + for inverse in (False, True): + values = [Form({i: 1}) for i in range(total)] + x, y = values[:n], values[n:2*n] + side, center = values[2*n:2*n+R], values[2*n+R:] + before = [list(bank) for bank in (x, y, side, center)] + invoke(x, y, side, center, code, f, inverse=inverse) + sign = -1 if inverse else 1 + require(x == before[0] and side == before[2] and center == before[3], + 'Dirty inputs not restored') + require(y == [b + sign*a for a, b in zip(before[0], before[1])], + 'Full signed invocation is not target += sign*source') + return dict(h=h, source_roles=n, target_roles=n, side_roles=R, center_roles=h, + independent_columns_per_direction=total, directions=2, + sources_unchanged=True, arbitrary_side_and_center_inputs_restored=True) + + +def replay(): + h = 26 + old = factor(h) + new = shear(old, 1, 2, -1) + search = census(old, seed=20) + require((search['selected']['i'], search['selected']['j'], search['selected']['sign']) == (1, 2, -1), + 'Selected one-shear minimum changed') + product_checks = verify_product(new) + region = [] + for ground_size in range(8, 41, 2): + b = factor(ground_size) + a = shear(b, 1, 2, -1) + saving = charge(b)['G_plus_H'] - charge(a)['G_plus_H'] + require(saving == closed_saving(ground_size), 'Closed saving formula failed') + region.append(dict(h=ground_size, old=charge(b), new=charge(a), saving=saving)) + baseline = json.loads((ROOT / 'certificates/dyadic-central-factor.json').read_text()) + before, after = charge(old), charge(new) + require(before == dict(G=14100, H=31281, G_plus_H=45381), 'Baseline scalar bill changed') + side = DisjointTensor(h) + code = scalar_program(side) + disjoint_roles = side.compile()['roles'] + n = counts(h, disjoint_roles) + require(serializable(n) == baseline['counts'], 'Historical rank ledger changed') + M = sum(len(ins)+len(outs)-2 for ins, outs in code['gates']) + C, J = len(code['sources']), len(code['outputs']) + require((M, C, J) == tuple(baseline['scalar_charge'][k] for k in ('M', 'C', 'J')), + 'Fresh complete side scalar counts changed') + fixed = 4*M + 2*C + 4*J + old_steps = 3*n['v']**2*(fixed + 2*before['G_plus_H']) + new_steps = 3*n['v']**2*(fixed + 2*after['G_plus_H']) + require(old_steps == baseline['scalar_charge']['steps'] and new_steps < old_steps, + 'Full scalar bill does not improve') + E = 64*(n['W']+n['m']+1)**3 + slack = E-(4*new_steps + 8*n['s'] + 8*n['W'] + 8*n['m']) + require(slack > 0 and E == baseline['scalar_charge']['E'], 'Node-charge guard failed') + g = guard(n['m'], n['s'], E, F(1,100), F(1,1000), F(5)) + require(serializable(g) == baseline['scalar_charge']['guard'], 'Retained conditional recurrence changed') + # The original checker rejects the broadened numerator alphabet; the + # optional adapter explicitly prices -2 as a signed unit update instead. + try: + verify_factor(shear(factor(8), 1, 2, -1)) + except ValueError as exc: + require('dyadic weights' in str(exc), 'Wrong historical-alphabet rejection') + original_rejection = str(exc) + else: + raise ValueError('Historical alphabet guard unexpectedly accepted -2') + result = dict(primary_h=h, central_coefficients_checked=product_checks['coefficients_checked'], + central_coefficient_sha256=product_checks['coefficient_sha256'], one_shear_census=search, + chosen_shear_parameter_controls=region, + before=before, after=after, counts=n, + full_scalar_charge=dict(M=M, C=C, J=J, old_steps=old_steps, new_steps=new_steps, + saved_steps=old_steps-new_steps, per_invocation_saved=2*(before['G_plus_H']-after['G_plus_H']), + fixed_side_steps_per_invocation=fixed, E=E, new_slack=slack, + additional_helper_roles=0, center_basis_adapter_operations=0, + frame_changes=0, child_profile_changes=0, guard=g), + source_reuse='Fresh side topology/counts; unchanged h26 side coefficient and phase proofs inherited, not replayed', + historical_alphabet_rejection=original_rejection, + complete_dirty_invocations=[invocation_control(h) for h in (8, 10)]) + result['inherited_python_imports'] = sorted({ + Path(module.__file__).resolve().relative_to(ROOT).as_posix() + for module in tuple(sys.modules.values()) + if getattr(module, '__file__', None) and Path(module.__file__).is_file() + and Path(module.__file__).resolve().is_relative_to(ROOT) + and not Path(module.__file__).resolve().is_relative_to(HERE)}) + return result + + +if __name__ == '__main__': + print(json.dumps(serializable(replay()), sort_keys=True)) diff --git a/research/dyadic-center-basis-shear/test_circuit.py b/research/dyadic-center-basis-shear/test_circuit.py new file mode 100644 index 0000000000..5a3ddb7eca --- /dev/null +++ b/research/dyadic-center-basis-shear/test_circuit.py @@ -0,0 +1,154 @@ +"""Independent exact controls for the one-shear center circuit. + +Copyright 2026 Curtis Dransfield. Apache-2.0. +Prepared with substantial OpenAI Codex assistance; predecessor attribution +is retained in the package proof note and original source files. +""" +from copy import deepcopy +from hashlib import sha256 +from pathlib import Path +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) + +import circuit +from independent import (closed_cost_formula, coefficient_check, dirty_basis_check, + factor_entries, mutation_controls, orbit_census) + + +def dense_source(h, changed=False): + """Adapt the independent closed entries to the primary sparse interface.""" + dense = factor_entries(h, changed) + return dict(h=h, triples=list(dense['triples']), + gather=[tuple((i, x) for i, x in enumerate(column) if x) + for column in dense['V_columns']], scatter=list(dense['U_rows'])) + + +class CenterCircuit(unittest.TestCase): + def test_shear_matches_independent_entries_and_inverse_restores_input(self): + for h in (8, 10, 12, 26): + original = dense_source(h) + snapshot = deepcopy(original) + changed = circuit.shear(original, 1, 2, -1) + with self.subTest(h=h): + self.assertEqual(changed, dense_source(h, changed=True)) + self.assertEqual(circuit.shear(changed, 1, 2, 1), original) + self.assertEqual(original, snapshot) + self.assertEqual(len(changed['gather']), len(original['gather'])) + self.assertEqual(changed['h'], original['h']) + + def test_small_complete_products_and_digests_use_independent_contraction(self): + for h in (8, 10): + actual = circuit.verify_product(circuit.shear(dense_source(h), 1, 2, -1)) + independent = coefficient_check(h) + with self.subTest(h=h): + self.assertEqual(actual['coefficients_checked'], independent['coefficients_checked']) + self.assertEqual(actual['coefficient_sha256'], independent['coefficient_sha256']) + + def test_product_mutations_pass_alphabet_but_fail_exact_identity(self): + original = dense_source(8) + changed = circuit.shear(original, 1, 2, -1) + gather_only = deepcopy(changed) + gather_only['scatter'] = original['scatter'] + wrong_sign = deepcopy(changed) + position = next(i for i, row in enumerate(wrong_sign['scatter']) if row[2] == -2) + row = list(wrong_sign['scatter'][position]) + row[2] = 2 + wrong_sign['scatter'][position] = tuple(row) + for mutation in (gather_only, wrong_sign): + circuit.validate(mutation) + with self.assertRaisesRegex(ValueError, 'Central product coefficient mismatch'): + circuit.verify_product(mutation) + + def test_invalid_moves_shapes_and_alphabets_are_rejected(self): + original = dense_source(8) + for move in ((1, 1, -1), (-1, 2, -1), (1, 8, -1), (1, 2, 0), + (True, 2, -1), (1, 2, True), (0, 1, -1)): + with self.subTest(move=move), self.assertRaises(ValueError): + circuit.shear(original, *move) + mutations = [] + wrong = deepcopy(original) + wrong['gather'][0] += ((0, 1),) + mutations.append(wrong) + wrong = deepcopy(original) + wrong['gather'][0] = ((0, 2),) + mutations.append(wrong) + wrong = deepcopy(original) + wrong['scatter'][0] = (3,) + wrong['scatter'][0][1:] + mutations.append(wrong) + wrong = deepcopy(original) + wrong['scatter'][0] = (1.0,) + wrong['scatter'][0][1:] + mutations.append(wrong) + wrong = deepcopy(original) + wrong['triples'] = wrong['triples'][::-1] + mutations.append(wrong) + for mutation in mutations: + with self.assertRaises(ValueError): + circuit.validate(mutation) + + def test_independent_orbit_census_matches_individual_moves(self): + for h in (8, 10, 12, 26): + individual = circuit.census(dense_source(h), seed=20) + orbits = orbit_census(h) + with self.subTest(h=h): + self.assertEqual(orbits['orbits'], 16) + self.assertEqual(sum(row['multiplicity'] for row in orbits['orbit_records']), 2*h*(h-1)) + for key in ('candidate_moves', 'admissible_moves', 'rejected_moves', + 'delta_histogram', 'minimum_delta'): + self.assertEqual(orbits[key], individual[key]) + self.assertEqual(sum(row['multiplicity'] for row in orbits['minimizing_move_categories']), + len(individual['minimizers'])) + self.assertEqual(orbits['admissible_moves'], 650) + self.assertEqual(orbits['minimum_delta'], -1472) + + def test_negative_two_is_one_signed_update_and_saving_changes_sign(self): + expected_saving = {8: -10, 10: 0, 26: 1472} + for h, expected in expected_saving.items(): + before = circuit.charge(dense_source(h)) + after = circuit.charge(dense_source(h, changed=True)) + formula = closed_cost_formula(h) + with self.subTest(h=h): + self.assertEqual(before['G_plus_H'] - after['G_plus_H'], expected) + self.assertEqual(circuit.closed_saving(h), expected) + self.assertEqual(formula['saving_gather_plus_scatter'], expected) + self.assertEqual(after['H'], formula['changed_scatter']) + changed = dense_source(26, changed=True) + # The new -2 entries are exactly triples containing 0 and two of the + # 23 outside coordinates, so this tests the signed-unit price on 253 + # actual occurrences through the independently derived total below. + self.assertEqual(sum(row.count(-2) for row in changed['scatter']), 23*22//2) + self.assertEqual(circuit.charge(changed), dict(G=12352, H=31557, G_plus_H=43909)) + + def test_dirty_center_basis_controls_and_missing_operations(self): + controls = [dirty_basis_check(h) for h in (4, 6, 8)] + self.assertEqual(sum(row['invocations_checked'] for row in controls), 356) + self.assertTrue(all(row['all_dirty_center_inputs_restored'] for row in controls)) + mutations = mutation_controls() + self.assertTrue(mutations['omitted_inverse_gather_rejected']) + self.assertTrue(mutations['omitted_initial_dirty_scatter_rejected']) + for key in ('gather_changed_without_inverse_scatter_change', + 'negative_two_numerator_flipped_positive'): + self.assertNotEqual(mutations[key]['actual_numerator'], mutations[key]['expected_numerator']) + + def test_source_pin_mutation_and_missing_input_fail(self): + from verify import verify_pins + with tempfile.TemporaryDirectory(prefix='center-shear-pin-control-') as directory: + root = Path(directory) + path = root / 'fixture.py' + content = b'# exact input\n' + path.write_bytes(content) + manifest = dict(base_commit='test-only', sha256={'fixture.py': sha256(content).hexdigest()}) + self.assertEqual(verify_pins(root, manifest)['pinned_inputs'], 1) + path.write_bytes(content + b'# altered\n') + with self.assertRaisesRegex(ValueError, 'Source pin mismatch: fixture.py'): + verify_pins(root, manifest) + path.unlink() + with self.assertRaises(FileNotFoundError): + verify_pins(root, manifest) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/research/dyadic-center-basis-shear/verify.py b/research/dyadic-center-basis-shear/verify.py new file mode 100644 index 0000000000..2499170b72 --- /dev/null +++ b/research/dyadic-center-basis-shear/verify.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +"""Recompute the exact historical complex-center circuit improvement. + +Copyright 2026 Curtis Dransfield. Apache-2.0; substantial OpenAI Codex assistance. +""" +import argparse +import hashlib +import json +from pathlib import Path +import subprocess +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +from circuit import require, serializable + + +def verify_pins(root=ROOT, manifest=None): + if manifest is None: + manifest = json.loads((HERE / 'SOURCES.json').read_text()) + for path, expected in manifest['sha256'].items(): + require(hashlib.sha256((root / path).read_bytes()).hexdigest() == expected, + 'Source pin mismatch: '+path) + return dict(base_commit=manifest['base_commit'], pinned_inputs=len(manifest['sha256'])) + + +def certificate(): + pins = verify_pins() + # -I discards ambient PYTHONOPTIMIZE, and no -O is passed to inherited code. + completed = subprocess.run([sys.executable, '-I', '-B', str(HERE / 'source_worker.py')], + cwd=HERE, text=True, capture_output=True, check=True) + source = json.loads(completed.stdout) + manifest = json.loads((HERE / 'SOURCES.json').read_text()) + require(set(source['inherited_python_imports']) <= set(manifest['sha256']), + 'Inherited runtime import is missing a source pin') + from independent import independent_check + independent = independent_check() + require(source['central_coefficient_sha256'] == independent['coefficients']['coefficient_sha256'], + 'Independent coefficient transcripts differ') + for side, key in (('before', 'original_cost'), ('after', 'changed_cost')): + require([source[side][k] for k in ('G', 'H', 'G_plus_H')] == + [independent[key][k] for k in ('gather', 'scatter', 'total')], + 'Independent scalar charges differ') + require(source['full_scalar_charge']['saved_steps'] == + independent['closed_saving_at_26']['complete_three_stage_scalar_bound_saving'], + 'Independent full scalar saving differs') + for key in ('candidate_moves', 'admissible_moves', 'rejected_moves', 'delta_histogram', 'minimum_delta'): + require(source['one_shear_census'][key] == independent['orbit_census'][key], + 'Independent symmetry-orbit census differs: '+key) + return serializable(dict(status='PASS_DYADIC_CENTER_BASIS_SHEAR', pins=pins, source_replay=source, + independent=independent, + scope='Historical complex scalar circuit improvement; unchanged rank profile; no new kappa; ' + 'one-shear optimum only in the declared finite alphabet, not global circuit optimality')) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--out', type=Path, help='Fresh certificate path; existing output is rejected') + args = parser.parse_args() + if args.out: + require(not args.out.exists(), 'Refusing to overwrite output') + result = certificate() + if args.out: + with args.out.open('x') as stream: + json.dump(result, stream, indent=2, sort_keys=True) + stream.write('\n') + else: + require(result == json.loads((HERE / 'CERTIFICATE.json').read_text()), + 'Recomputed certificate differs from committed evidence') + print('PASS_DYADIC_CENTER_BASIS_SHEAR h=26 moves=1300 admissible=650 ' + 'G+H=45381->43909 full_scalar_saved=59704320000 no_new_kappa') + + +if __name__ == '__main__': + main()