diff --git a/research/p104-contact-rewrite/NOTICE b/research/p104-contact-rewrite/NOTICE new file mode 100644 index 0000000000..2ba2ea3c0a --- /dev/null +++ b/research/p104-contact-rewrite/NOTICE @@ -0,0 +1,36 @@ +New helper-subspace construction, proof and replay: +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The same assistant performed the construction and author-side checks. + +Retained contributions: +flyingviper: PR5605 shared relay, PR5612 delayed relay, and the PR5608/PR5613 +relay/split compositions. +Scratch-net: PR5606 prepared-helper identities and target debit. +Pierre-Loic Doulcet (hexapode): PR5565 commuting-contact construction, used as the exact source. +Ali Romman: PR5602 fixed boundary relations, PR5601 three-contact frame +change, PR5580 contact step, +and PR5544/5545 complete P104 caller. +Joel Pulikkan (GamingPuzzled): PR5569 priced helper handoff. +DreamingOfClouds: PR5561 free helper endpoints and PR5568 search tools. +thu-nmrc: PR5551 contact improvements. +Gareth Davidson (bitplane): PR2305 source composition. +David Arias: PR2152 coalesced P104 word. +Cinna Davis: PR2219 private reuse and the controller lineage. +Jacob Alan Sussman: productive mixed-target recursion. +zxv and Cao Yifan: exact intervals, compiler and native/pricing lineage. +GamingPuzzled: PR5472 successor handoff, a predecessor to the split concept. +The retained source notices preserve earlier geometry, BIT and analytic credit. + +The elementary rank-one basis identity is not claimed as a new general +linear-algebra theorem. The contribution is its explicit independent-target +use on this P104 word and the complete conditional kappa improvement. + +New contribution: Ali Romman, with substantial OpenAI Codex assistance. +The four-gate source-version rewrite composes zxv PR5643 and Ali Romman PR5644. +The A2 method retains Chris R/Clear1nsight PR3998 and ToikY PR4019 credit. +The compensated triangle method retains Cinna Davis PR4692 credit. +No subagents were used for this contribution. Apache-2.0. + +Concurrent PR5650 by zxv publishes the PR5643/PR5644 composition. PR5651 by +Ali Romman corroborates it. This package credits that released composition +and contributes the further four-gate placement. diff --git a/research/p104-contact-rewrite/PRICING-EDITS.json b/research/p104-contact-rewrite/PRICING-EDITS.json new file mode 100644 index 0000000000..0aef36c5b8 --- /dev/null +++ b/research/p104-contact-rewrite/PRICING-EDITS.json @@ -0,0 +1,26 @@ +[ + [ + "Q('.00310440546'), Q('.003104405465')", + "Q('.00310676333'), Q('.003106763335')" + ], + [ + "PREVIOUS = Q('.00308595')", + "PREVIOUS = Q('.00310644469')" + ], + [ + "== 66546", + "== 66474" + ], + [ + "'kappa_decimal':'.00310440546'", + "'kappa_decimal':'.00310676333'" + ], + [ + "previous_open_pr5601", + "previous_open_pr5651" + ], + [ + "Apache-2.0.", + "The paid A2 change is from zxv PR5643. The three helper relations are from\nAli Romman PR5644. The four-gate change is by Ali Romman with Codex assistance.\nApache-2.0." + ] +] diff --git a/research/p104-contact-rewrite/PROOF.md b/research/p104-contact-rewrite/PROOF.md new file mode 100644 index 0000000000..5eab6148f7 --- /dev/null +++ b/research/p104-contact-rewrite/PROOF.md @@ -0,0 +1,176 @@ +# A complete conditional contact rewrite + +The claimed value is **kappa = 0.00310676333**. The comparison is the open +PR5651 value 0.00310644469. The increase is 0.00000031864. This construction +keeps the five selected framework assumptions and the helper endpoint +contract. It does not change the selected record. + +## 1. Exact sources and composition + +The retained export is PR5627 at +`ed4dc88a09a7d201971f6603b8c2074e95dd9c32`. It contains 36 source files and +one export manifest. Authenticate the archive, its complete inventory and +each file before import. Also authenticate the retained PR5644 constructor, +witness, word and the PR5643 word. + +First apply the three fixed PR5644 helper relations. Compare the result with +the complete published word. Each relation changes the local paid profile +by `-H1-H5+H6`. All public inputs, targets and owned instructions stay fixed. + +Then apply zxv's PR5643 A2 change. Check its entire scalar-program difference +against the published PR5643 word. Locate the same two gates in the PR5644 +word. Replace them by the three published gates and rebuild the nested public +paths. The complete local paid change is `H2+H6-H3-H5`. Full replay checks the +composition; numerical headline gains are not added. PR5650 already publishes +this composition, and PR5651 checks it again. Compare with the retained +PR5650 word after rebuilding the same public MOVE order. Each changed order +only swaps consecutive MOVEs on different public fields. The scalar and +owned chronology stays fixed. No new composition result is claimed here. + +## 2. The new four-gate identity + +Let `c=165`, `h=586`, `s=733` and `x=21`. The old gates are + +```text +h <- h - 4s at frame 597 +c <- c + 2s at frame 597 +c <- c - x/2 at frame 652 +x <- x + h at frame 652 +``` + +The first two sites are separated by other operations. The witness checks +that none of the intervening operations reads or writes c, h or s. The two +late gates are consecutive in the scalar skeleton. Operations on x before +the late pair retain their order. + +Use these gates instead: + +```text +c <- c + h/2 at frame 3 +h <- h - 4s at frame 597 +x <- x + h at frame 652 +c <- c - x/2 at frame 652 +``` + +Here frame 3 is `{0}`, frame 597 has basis `[82]`, and frame 652 has basis +`[82,268]`. The new early read uses the old value of h. The new gates are +placed at the old late pair after the two early updates are removed. + +Write the values before these updates as c, h, s and x. Both programs give + +```text +c_out = c + 2s - x/2 +h_out = h - 4s +s_out = s +x_out = x + h - 4s +``` + +The verifier also compares both full 4 by 4 rational matrices. More generally, +this identity holds for coefficients alpha, beta, gamma and delta when +`beta = alpha*gamma*delta`; the early coefficient is `-gamma*delta`. +The A2 identity and compensated triangle method are prior work. The new +result is this source-bound four-gate schedule and its paid native path. + +The new schedule lets c remain in dimension zero until its dimension-two +contact. Its old two rank-one requests become one rank-two request. Every +other paid count has the same value. Thus + +```text +new local paid delta = -2 H1 + H2 +new local target delta = 0 +``` + +For every `00`. The complete caller uses the local word 18 times, +so this new component improves the signed moment by `18*(2-2^t)`. + +For this fixed dimension-zero to dimension-two path of c, the new transport +also has the minimum cost among strictly nested subdivisions. Such a path +has either one rank-two step or two rank-one steps. For `0 2^26*N^5 avoiding all fixed denominators and rank witnesses" + }, + "outer": { + "functional_checks": { + "actual_new_BIT_stock_sublinear": "348599999999253/350000000000000", + "fixed_halo_explicit_metadata_branch": "26950000000001/350000000000", + "new_BIT_row_stock_sublinear_in_active_group": "1395799999997009/1400000000000000", + "new_semantic_group_guard": "3/1400000000000" + }, + "margins": { + "boundary_algebraic_matrix": "1217851226479130106267/392000000000000000000000", + "fused_gaussian": "1217851226477390318801/392000000000000000000000", + "global_coordinate_router": "2174734333/700000000000", + "group_bit_router": "3044628066893475797001/980000000000000000000000", + "group_scans": "699999999999/700000000000", + "main_transform": "1217851226199130106267/392000000000000000000000", + "microbox_face_corrections": "26950000000001/350000000000", + "polynomial_products": "1399999999999/1400000000000", + "sparse_union_movement": "160467851226479130106267/392000000000000000000000" + }, + "parameters": { + "a": "2174734333/700000000000", + "b": "4349468667/1400000000000", + "beta": "1399999999997/1400000000000", + "bit_saving": "17/5000", + "cap_xi": "356467851226199130106267/392000000000000000000000", + "complex_uniform_saving": "1087367167/350000000000", + "d": "1/1400000000000", + "epsilon": "1399999999999/1400000000000", + "kappa": "310676333/100000000000", + "lambda_": "398757294667/400000000000", + "lambda_prime": "279130106267/280000000000", + "layout": "1/1400000000000", + "q": "869893733/280000000000", + "r0": "1/14000000000000", + "stop": "1/1400000000000", + "tested_saving": "621352667/200000000000" + }, + "strict_checks": { + "actual_bit_above_effective": "205265667/700000000000", + "actual_logarithmic_gamma_guard": "1/1400000000000", + "actual_logarithmic_group_guard": "35532148774220869893733/196000000000000000000000", + "alpha_logarithm_absorption": "1/14000000000000", + "boundary_algebraic_matrix_above_kappa": "1119130106267/392000000000000000000000", + "cap_above_band": "160467851226199130106267/392000000000000000000000", + "cap_below_cell": "35532148773520869893733/392000000000000000000000", + "cap_below_phase_cell_power": "427532148773800869893733/392000000000000000000000", + "complex_above_effective": "1/1400000000000", + "complex_below_one_over_32": "39400531333/1400000000000", + "complex_endpoint": "1/700000000000", + "epsilon_below_one": "1/1400000000000", + "epsilon_positive": "1399999999999/1400000000000", + "fine_prime_halo_umbrella": "7/2", + "fused_gaussian_above_kappa": "1117390318801/392000000000000000000000", + "gaussian_above_main": "139130106267/196000000000000000000000", + "global_coordinate_router_above_kappa": "1/350000000000", + "global_gamma_power_slack": "9/14000000000000", + "group_below_dimension": "1/700000000000", + "group_bit_router_above_kappa": "3493475797001/980000000000000000000000", + "group_gauge_power_slack": "35532148774206869893733/196000000000000000000000", + "group_key_fits_record": "1/700000000000", + "group_positive": "1399999999997/1400000000000", + "group_scans_above_kappa": "174456316417/175000000000", + "halo_covers_generic_inverse_radius": "5", + "improvement_over_user_baseline": "687896455400418148631/500000000000000000000000", + "lambda_above_internal": "1/2800000000000", + "lambda_above_sigma": "3/2800000000000", + "lambda_above_tau": "1/2800000000000", + "lambda_prime_above_lambda": "1/2800000000000", + "lambda_prime_above_leaf": "2795650531333/1960000000000000000000000", + "leaf_saving_above_effective": "1395650531333/1960000000000000000000000", + "main_transform_above_kappa": "839130106267/392000000000000000000000", + "membership_arithmetic_fits_record": "1/1400000000000", + "microbox_face_corrections_above_kappa": "53897825265671/700000000000", + "microbox_halo_volume": "110600000000003/1400000000000", + "new_complex_uniform_saving_above_b": "1/1400000000000", + "new_semantic_guard_with_C1_one": "1/1400000000000", + "polynomial_products_above_kappa": "1395650531337/1400000000000", + "positive_layout_slack": "1/1400000000000", + "q_below_effective": "1/1400000000000", + "q_below_internal": "1/1400000000000", + "q_below_leaf": "2795650531333/1960000000000000000000000", + "q_positive": "869893733/280000000000", + "short_record_fallback": "1395650531333/1400000000000", + "source_axis_superpolynomial": "1/1400000000000", + "sparse_union_movement_above_kappa": "159250000001119130106267/392000000000000000000000", + "stop_below_one": "1399999999999/1400000000000", + "stop_positive": "1/1400000000000", + "strassen_integer_power_gap": "1951441519231", + "support_router_span": "3/1400000000000", + "theta_positive_polynomial_power": "2", + "union_header_fits_record": "3/1400000000000", + "union_tag_work_per_visit_fits_record": "3/1400000000000" + } + }, + "paid": { + "1": 41070, + "16": 416, + "2": 8244, + "24": 416, + "3": 8874, + "32": 416, + "4": 1638, + "40": 416, + "48": 416, + "5": 2862, + "56": 416, + "6": 396, + "64": 416, + "7": 270, + "72": 208 + }, + "paid_calls": 66474, + "previous_open_pr5651": "310644469/100000000000", + "productive_fields": 12958, + "query_shears": 15, + "rank_mass_surplus": 760, + "raw_ceiling": { + "derivative_upper": "-185029011078999527555927185035801066152378146458179911814194949/784637716923335095479473677900958302012794430558004314112", + "interval": [ + "0", + "17/5000" + ] + }, + "raw_headroom": [ + "1487/100000000000000", + "93/6250000000000" + ], + "raw_root_interval": [ + "310676334487/100000000000000", + "38834541811/12500000000000" + ], + "relative_gain_percent": "3186400/310644469", + "strictification": { + "alpha": { + "lower": "0.999999999989956163350011203614", + "upper": "0.999999999989956163350011203615" + }, + "cutoff": 17, + "delta": { + "lower": "0.967531205382707654632396498681", + "upper": "0.967531205382707654632396498682" + }, + "floor": 18, + "gamma": { + "lower": "0.968163912338747597412952587420", + "upper": "0.968163912338747597412952587421" + }, + "normalized_paid_upper": "1048576000976562501/1048576001073741824", + "power": 1024, + "reserve": "1/1000000000000", + "tail_block": 128, + "tail_decay": "39/40", + "tail_offset": "1/5", + "tested": "621352667/200000000000" + }, + "targets": { + "1": 36, + "145": 208, + "17": 416, + "2": 72, + "25": 416, + "33": 416, + "4": 1638, + "41": 416, + "49": 416, + "5": 108, + "57": 416, + "65": 416, + "7": 90, + "73": 208, + "8": 288, + "9": 7398 + }, + "whole_idle_jobs": 3120 + }, + "composed_local": { + "endpoint_coefficients": 565504, + "helpers": { + "1": 2, + "2": 4, + "4": 91, + "5": 6, + "7": 5, + "8": 16, + "9": 411 + }, + "owned_fields": 9, + "owned_lifetimes": 11, + "paid": { + "1": 2197, + "2": 457, + "3": 493, + "4": 91, + "5": 159, + "6": 22, + "7": 15 + }, + "paid_rank_mass": 5986, + "peak_owned_fields": 2, + "public_inputs": 743, + "real_scalar_allowance": 220220 + }, + "limits": [ + "The five selected framework assumptions and helper endpoint contract remain.", + "The enormous uniform word and complete rounded multiplier are not materialized.", + "These author checks are not independent scientific acceptance or a proof-kernel theorem.", + "This is a small improvement. No global optimum or large breakthrough is established." + ], + "local": { + "endpoint_coefficients": 565504, + "helpers": { + "1": 2, + "2": 4, + "4": 91, + "5": 6, + "7": 5, + "8": 16, + "9": 411 + }, + "owned_fields": 9, + "owned_lifetimes": 11, + "paid": { + "1": 2195, + "2": 458, + "3": 493, + "4": 91, + "5": 159, + "6": 22, + "7": 15 + }, + "paid_rank_mass": 5986, + "peak_owned_fields": 2, + "public_inputs": 743, + "real_scalar_allowance": 220220 + }, + "local_helper_delta": {}, + "local_paid_delta": { + "1": -5, + "2": 2, + "3": -1, + "5": -4, + "6": 4 + }, + "native": { + "distinct_maps": 2917, + "helper_normalizers": 1070, + "helpers": { + "1": 2, + "2": 4, + "4": 91, + "5": 6, + "7": 5, + "8": 16, + "9": 411 + }, + "main_adapters": 208, + "proof": "Every signed Pauli image and exact global phase; frame induction at every positive tensor width", + "recipe_payload_sha256": "02fb0e822a0fbdf0a6dd03a7cc6a255b074f97ecd923a52acc1793c31d0133a1", + "wrong_phase_rejected": true + }, + "negative_controls": { + "extra_target_credit": "Every productive helper has a native target", + "missing_central_translation": "Rejected by the complete Laurent endpoint", + "missing_early_read": "All public and owned rows", + "missing_owned_erasure": "All public and owned exits", + "unpaid_query": "Complete field and call counts", + "wrong_compensation_sign": "Declared complete replacement", + "wrong_early_frame": "Scalar destination and coefficient", + "wrong_source_version": "Exact four-gate source anchors" + }, + "new_four_gate_paid_delta": { + "1": -2, + "2": 1 + }, + "physical_caller": { + "central_square_columns": 53248, + "full_calls": 18, + "main_targets": { + "145": 208, + "17": 416, + "25": 416, + "33": 416, + "41": 416, + "49": 416, + "57": 416, + "65": 416, + "73": 208 + }, + "new_paid_jobs": 0, + "physical_contacts": 7488, + "ports": 104, + "route_payload_sha256": "7f4f0ca768ffbc4f93dcff575592c4c67411f46b4289e45b73f715a2ad47b142", + "tensor_rule": "Factorwise native maps; scalar signs stay outside the tensor power.", + "whole_idle_jobs": { + "16": 416, + "24": 416, + "32": 416, + "40": 416, + "48": 416, + "56": 416, + "64": 416, + "72": 208 + }, + "wrapper_sites": [ + 1, + 3, + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19, + 21, + 23, + 25, + 27, + 29, + 31 + ] + }, + "pr5644_local": { + "endpoint_coefficients": 565504, + "helpers": { + "1": 2, + "2": 4, + "4": 91, + "5": 6, + "7": 5, + "8": 16, + "9": 411 + }, + "owned_fields": 9, + "owned_lifetimes": 11, + "paid": { + "1": 2197, + "2": 456, + "3": 494, + "4": 91, + "5": 160, + "6": 21, + "7": 15 + }, + "paid_rank_mass": 5986, + "peak_owned_fields": 2, + "public_inputs": 743, + "real_scalar_allowance": 220208 + }, + "released_a2_paid_delta": { + "2": 1, + "3": -1, + "5": -1, + "6": 1 + }, + "released_helper_changes": [ + { + "cancellation": [ + [ + "ADD", + 291, + 293, + "1", + 234 + ], + [ + "SCALE", + 291, + "-1/2", + 234 + ] + ], + "cut": 10627, + "events": 25446, + "frame": 234, + "helper": 291, + "paid": { + "1": 2199, + "2": 456, + "3": 494, + "4": 91, + "5": 162, + "6": 19, + "7": 15 + }, + "preparation": [ + [ + "ADD", + 291, + 39, + "1", + 3 + ], + [ + "ADD", + 291, + 293, + "-1/2", + 3 + ], + [ + "ADD", + 291, + 303, + "1", + 3 + ] + ], + "removed_scalar_events": [ + [ + "SCALE", + 291, + "-1/2", + 234 + ], + [ + "ADD", + 291, + 289, + "1/2", + 234 + ], + [ + "ADD", + 291, + 39, + "1/2", + 234 + ], + [ + "ADD", + 291, + 40, + "1/2", + 234 + ], + [ + "ADD", + 291, + 18, + "-1/2", + 234 + ], + [ + "ADD", + 291, + 55, + "-1", + 234 + ] + ], + "scalar": 220140 + }, + { + "cancellation": [ + [ + "ADD", + 321, + 22, + "-2", + 237 + ], + [ + "ADD", + 321, + 320, + "3/2", + 237 + ], + [ + "ADD", + 321, + 330, + "-2", + 237 + ] + ], + "cut": 11072, + "events": 25446, + "frame": 237, + "helper": 321, + "paid": { + "1": 2198, + "2": 456, + "3": 494, + "4": 91, + "5": 161, + "6": 20, + "7": 15 + }, + "preparation": [ + [ + "ADD", + 321, + 34, + "2", + 3 + ], + [ + "ADD", + 321, + 320, + "2", + 3 + ], + [ + "ADD", + 321, + 330, + "-2", + 3 + ] + ], + "removed_scalar_events": [ + [ + "ADD", + 321, + 320, + "1", + 237 + ], + [ + "ADD", + 321, + 23, + "-1", + 237 + ], + [ + "ADD", + 321, + 22, + "-1", + 237 + ], + [ + "ADD", + 321, + 108, + "1", + 237 + ], + [ + "ADD", + 321, + 49, + "-1", + 237 + ] + ], + "scalar": 220164 + }, + { + "cancellation": [ + [ + "ADD", + 369, + 26, + "-2", + 243 + ], + [ + "ADD", + 369, + 368, + "3/2", + 243 + ], + [ + "ADD", + 369, + 378, + "2", + 243 + ] + ], + "cut": 11718, + "events": 25448, + "frame": 243, + "helper": 369, + "paid": { + "1": 2197, + "2": 456, + "3": 494, + "4": 91, + "5": 160, + "6": 21, + "7": 15 + }, + "preparation": [ + [ + "ADD", + 369, + 3, + "2", + 3 + ], + [ + "ADD", + 369, + 372, + "2", + 3 + ], + [ + "ADD", + 369, + 378, + "2", + 3 + ], + [ + "ADD", + 369, + 382, + "2", + 3 + ], + [ + "ADD", + 369, + 383, + "-2", + 3 + ] + ], + "removed_scalar_events": [ + [ + "ADD", + 369, + 368, + "1", + 243 + ], + [ + "ADD", + 369, + 26, + "-1", + 243 + ], + [ + "ADD", + 369, + 95, + "-1", + 243 + ], + [ + "ADD", + 369, + 8, + "1", + 243 + ], + [ + "ADD", + 369, + 80, + "-1", + 243 + ] + ], + "scalar": 220208 + } + ], + "scalar_pattern_census": { + "after": [], + "before": [ + { + "first": 12754, + "previous": [ + 12513, + 12753 + ], + "roles": [ + 165, + 586, + 733 + ], + "second": 12755 + } + ] + }, + "separate_columns": { + "arithmetic": "Dense integer rows with binary denominators; reverse chronology", + "coefficients": 565504, + "columns": 752 + }, + "source_commit": "ed4dc88a09a7d201971f6603b8c2074e95dd9c32", + "source_local": { + "endpoint_coefficients": 565504, + "helpers": { + "1": 2, + "2": 4, + "4": 91, + "5": 6, + "7": 5, + "8": 16, + "9": 411 + }, + "owned_fields": 9, + "owned_lifetimes": 11, + "paid": { + "1": 2200, + "2": 456, + "3": 494, + "4": 91, + "5": 163, + "6": 18, + "7": 15 + }, + "paid_rank_mass": 5986, + "peak_owned_fields": 2, + "public_inputs": 743, + "real_scalar_allowance": 220154 + }, + "status": "PASS_P104_CONTACT_REWRITE_KAPPA_00310676333" +} diff --git a/research/p104-contact-rewrite/SOURCE-CONTROLS.json b/research/p104-contact-rewrite/SOURCE-CONTROLS.json new file mode 100644 index 0000000000..8f53350972 --- /dev/null +++ b/research/p104-contact-rewrite/SOURCE-CONTROLS.json @@ -0,0 +1,39 @@ +{ + "status": "PASS_SIX_ACTUAL_SOURCE_CORRUPTIONS", + "commit": "1f5a93245540e79be6ff4e7d573bbaf823a9dc23", + "cases": [ + { + "path": "research/p104-contact-rewrite/inputs/pr5627-source.tar", + "exit": 1, + "rejection": "Exact retained input SHA256: research/p104-contact-rewrite/inputs/pr5627-source.tar" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5644-construct.py", + "exit": 1, + "rejection": "Exact retained input SHA256: research/p104-contact-rewrite/inputs/pr5644-construct.py" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5644-witness.json", + "exit": 1, + "rejection": "Exact retained input SHA256: research/p104-contact-rewrite/inputs/pr5644-witness.json" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5644-word.json.gz", + "exit": 1, + "rejection": "Exact retained input SHA256: research/p104-contact-rewrite/inputs/pr5644-word.json.gz" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5643-word.json.gz", + "exit": 1, + "rejection": "Exact retained input SHA256: research/p104-contact-rewrite/inputs/pr5643-word.json.gz" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5650-word.json.gz", + "exit": 1, + "rejection": "Exact retained input SHA256: research/p104-contact-rewrite/inputs/pr5650-word.json.gz" + } + ], + "restored": true, + "path": "/nonexistent", + "python": "3.12.14" +} diff --git a/research/p104-contact-rewrite/SOURCES.json b/research/p104-contact-rewrite/SOURCES.json new file mode 100644 index 0000000000..2a5c2b8015 --- /dev/null +++ b/research/p104-contact-rewrite/SOURCES.json @@ -0,0 +1,121 @@ +{ + "schema_version": 1, + "base_commit": "df0137efd35e11b4445734bf612bdd4c7ebc330c", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "581f8d87008354eb5b869f7ed9de1317ad837ce8", + "sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5627-source.tar", + "usage": "input", + "pin": "head:04a5ad4ddfa871206d435ec3c68d8301b9ceca43:research/p104-contact-rewrite/inputs/pr5627-source.tar", + "git_blob": "bc900f0a1561b17b35492a80d10ae94f790d8378", + "sha256": "86c6bb839e14d79175ff8f3ed80b51a02d5c51a04deb0eff7ccea1afbe72923b" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5644-construct.py", + "usage": "input", + "pin": "head:04a5ad4ddfa871206d435ec3c68d8301b9ceca43:research/p104-contact-rewrite/inputs/pr5644-construct.py", + "git_blob": "1d9ff07f573bdbcf0e68d26eaa11862f958b2412", + "sha256": "99ff4814b7c106973b149d1d4342c7e4608a027445bf07b19b5364658970099e" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5644-witness.json", + "usage": "input", + "pin": "head:04a5ad4ddfa871206d435ec3c68d8301b9ceca43:research/p104-contact-rewrite/inputs/pr5644-witness.json", + "git_blob": "8d4f38c5c9ac9ccbcdf47ee1c95a76e2441b7c8e", + "sha256": "0cf78fcbdb62bd4965536dd7d2f74f96761fcd95b11d750bc68ac81ceb1ec58c" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5644-word.json.gz", + "usage": "input", + "pin": "head:04a5ad4ddfa871206d435ec3c68d8301b9ceca43:research/p104-contact-rewrite/inputs/pr5644-word.json.gz", + "git_blob": "0bd3cff77581895917206a410b685ce4959e3e3e", + "sha256": "3f2563d3c98f9d1170a583ba78bf171d5eb24e21976ddb026216bc637fc8a2ad" + }, + { + "path": "research/p104-contact-rewrite/inputs/pr5643-word.json.gz", + "usage": "input", + "pin": "head:04a5ad4ddfa871206d435ec3c68d8301b9ceca43:research/p104-contact-rewrite/inputs/pr5643-word.json.gz", + "git_blob": "7cf851189d95a471f7e50a7c9b0a60b8958734c9", + "sha256": "b2ab778bdd5d68c62df0b51c12dc33fde93ad89213639a8e7da23e4b9cf6c3dc" + }, + { + "sha256": "e94809cecf9e9cba56dd7a8a11ff1edeedc4c34013ff6caebdaf3b021351cf8c", + "git_blob": "92e858d5dbf43fabee80a2812f92aa55ff7db3cd", + "path": "research/p104-contact-rewrite/inputs/pr5650-word.json.gz", + "usage": "input", + "pin": "head:04a5ad4ddfa871206d435ec3c68d8301b9ceca43:research/p104-contact-rewrite/inputs/pr5650-word.json.gz" + } + ], + "source_export": { + "commit": "ed4dc88a09a7d201971f6603b8c2074e95dd9c32", + "files": 36, + "git_blob": "bc900f0a1561b17b35492a80d10ae94f790d8378", + "local_path": "inputs/pr5627-source.tar", + "package": "research/p104-helper-subspace-splits", + "sha256": "86c6bb839e14d79175ff8f3ed80b51a02d5c51a04deb0eff7ccea1afbe72923b", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/5627" + }, + "predecessors": { + "PR5627": "ed4dc88a09a7d201971f6603b8c2074e95dd9c32", + "PR5643": "a3ff5c628bfc8825553d62d913f3e91f75d6825f", + "PR5644": "c5871955d89bf73506fd68b0a5bf1cf2b3153c02", + "PR5650": "7916490124ac946704339a6a332bb76f06e5db5c", + "PR5651": "853192167b27d44aea0d4bc2b0d52d695fadc7c6" + }, + "input_commit": "04a5ad4ddfa871206d435ec3c68d8301b9ceca43", + "external_inputs": [ + { + "commit": "c5871955d89bf73506fd68b0a5bf1cf2b3153c02", + "path": "research/p104-neutral-helper-cleanup/inputs/pr5627-source.tar", + "copy": "research/p104-contact-rewrite/inputs/pr5627-source.tar", + "git_blob": "bc900f0a1561b17b35492a80d10ae94f790d8378", + "sha256": "86c6bb839e14d79175ff8f3ed80b51a02d5c51a04deb0eff7ccea1afbe72923b" + }, + { + "commit": "c5871955d89bf73506fd68b0a5bf1cf2b3153c02", + "path": "research/p104-neutral-helper-cleanup/construct.py", + "copy": "research/p104-contact-rewrite/inputs/pr5644-construct.py", + "git_blob": "1d9ff07f573bdbcf0e68d26eaa11862f958b2412", + "sha256": "99ff4814b7c106973b149d1d4342c7e4608a027445bf07b19b5364658970099e" + }, + { + "commit": "c5871955d89bf73506fd68b0a5bf1cf2b3153c02", + "path": "research/p104-neutral-helper-cleanup/WITNESS.json", + "copy": "research/p104-contact-rewrite/inputs/pr5644-witness.json", + "git_blob": "8d4f38c5c9ac9ccbcdf47ee1c95a76e2441b7c8e", + "sha256": "0cf78fcbdb62bd4965536dd7d2f74f96761fcd95b11d750bc68ac81ceb1ec58c" + }, + { + "commit": "c5871955d89bf73506fd68b0a5bf1cf2b3153c02", + "path": "research/p104-neutral-helper-cleanup/WORD.json.gz", + "copy": "research/p104-contact-rewrite/inputs/pr5644-word.json.gz", + "git_blob": "0bd3cff77581895917206a410b685ce4959e3e3e", + "sha256": "3f2563d3c98f9d1170a583ba78bf171d5eb24e21976ddb026216bc637fc8a2ad" + }, + { + "commit": "a3ff5c628bfc8825553d62d913f3e91f75d6825f", + "path": "research/p104-a2-paid-rank-exchange/WORD.json.gz", + "copy": "research/p104-contact-rewrite/inputs/pr5643-word.json.gz", + "git_blob": "7cf851189d95a471f7e50a7c9b0a60b8958734c9", + "sha256": "b2ab778bdd5d68c62df0b51c12dc33fde93ad89213639a8e7da23e4b9cf6c3dc" + }, + { + "commit": "7916490124ac946704339a6a332bb76f06e5db5c", + "path": "research/p104-a2-neutral-cleanup/WORD.json.gz", + "copy": "research/p104-contact-rewrite/inputs/pr5650-word.json.gz", + "sha256": "e94809cecf9e9cba56dd7a8a11ff1edeedc4c34013ff6caebdaf3b021351cf8c", + "git_blob": "92e858d5dbf43fabee80a2812f92aa55ff7db3cd" + } + ] +} diff --git a/research/p104-contact-rewrite/TASK.json b/research/p104-contact-rewrite/TASK.json new file mode 100644 index 0000000000..49a7a78aa6 --- /dev/null +++ b/research/p104-contact-rewrite/TASK.json @@ -0,0 +1,78 @@ +{ + "schema_version": 1, + "task_id": "complex-new-helper-inventory", + "priority_revision": 7, + "base_commit": "df0137efd35e11b4445734bf612bdd4c7ebc330c", + "original_card": { + "id": "complex-new-helper-inventory", + "question": "Can a new local cost interface change the deficit-to-recursive-cost ratio beyond current packing?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/heterogeneous-owner-assembly/README.md", + "certificates/selected-result.json", + "research/selected-k8-unrestricted-ends/README.md" + ], + "methods": [ + "Propose a changed helper inventory and derive an optimistic exact moment.", + "Design a small completed instance and independently verify its endpoint and rank bill." + ], + "acceptance_gate": "A new physically realizable contract outside the frozen catalogue whose per-call profile, screened with ceiling.ceiling(), beats the selected word's packing ceiling; a lower cap does not establish identical circuitry or order attainable optima, and is insufficient to pass the stronger-budget target under this model. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/complex-local-word-ceiling/verify.py" + ], + "expected": "PASS_COMPLEX_LOCAL_WORD_CEILING", + "inspect": "Read the selected word's per-call local profile, its packing ceiling and the lever table; run levers.py for the ideal budget of the lever you target.", + "scope": "Positive control and planning budget only; this is not a new construction or full cold replay." + }, + "first_experiment": "Before any synthesis, write the candidate per-call local profile (and centre charge / unpaid coordinates if changed) and screen it with ceiling.ceiling(); reject it if even the ideal ceiling does not beat the selected word's by your stated margin.", + "bottleneck_link": "Packing of the selected word is capped at +0.87% (ceiling model); only a lower local excess spend or a changed coverage law raises the cap.", + "allowed_variations": [ + "Narrow to one changed boundary or helper type with explicit counts.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Mixing only providers already inside the pinned catalogue.", + "Only changing helper terminal subspaces and monotone frames within the fixed scalar word, entrances and cleanup contract already covered by #1995/#2013.", + "Continuing a partial cost improvement while leaving the same unpriced consumer, restoration or central-readout obligation unresolved; refresh the family expansion decision first. Local product-retiming evidence has a narrow scope and is not a ban on changed graphs or contracts." + ], + "overlap_terms": [ + "helper inventory", + "heterogeneous-owner", + "mutable leaver" + ] + }, + "scope_status": "changed", + "actual_scope": "Rebuild the published PR5650 composition and add one new four-gate schedule. Check a complete conditional kappa improvement with every public target retained.", + "scope_change_reason": "The donor asked for a changed construction. Fixed-word carrier, history and scalar screens gave no paid gain. A two-step A2 change removes an internal contact and changes the complete paid profile.", + "bottleneck_link": "The changed internal scalar graph changes the invoice. The inherited packing ceiling does not price this complete productive caller; its replacement bound is the exact complete signed moment.", + "budget_minutes": 180, + "stop_rule": "Freeze one improved complete word after the stated finite search reaches a fixed point. Run the complete verification and publication checks. Do not infer global optimality.", + "outcome": "completed", + "evidence": "PROOF.md, WITNESS.json, RESULT.json and VALIDATION.md", + "author": "Ali Romman with substantial OpenAI Codex assistance", + "ai_assistance": "Substantial OpenAI Codex assistance for algebra, exact scripts, source checks and writing. No subagents.", + "open_questions": [ + { + "question": "Can an independent reviewer confirm this complete source-bound claim?", + "why_it_matters": "Author checks do not supply independent scientific acceptance.", + "first_step": "Check the four literal gates and replay the exact publication commit.", + "blocked_by": "No known technical blocker; independent work remains." + }, + { + "question": "Can a different dependency pattern or caller give a larger paid gain?", + "why_it_matters": "The gain here is small and the tested four-gate pattern is exhausted.", + "first_step": "Check live claims, state a changed pattern, and construct its full paid word.", + "blocked_by": "No known technical blocker; independent work remains." + }, + { + "question": "Can the retained framework assumptions be resolved?", + "why_it_matters": "The present kappa claim remains conditional.", + "first_step": "Select one explicit assumption from certificates/selected-result.json and its pinned proof review.", + "blocked_by": "The complete rounded multiplier and enormous uniform word are not materialized." + } + ] +} diff --git a/research/p104-contact-rewrite/VALIDATION.md b/research/p104-contact-rewrite/VALIDATION.md new file mode 100644 index 0000000000..6cfe42a300 --- /dev/null +++ b/research/p104-contact-rewrite/VALIDATION.md @@ -0,0 +1,107 @@ +# Validation and scope + +The base is canonical main `df0137efd35e11b4445734bf612bdd4c7ebc330c`, +priority revision 7. The selected record at this base is 0.00310045. This +package does not edit that record. The host is macOS on arm64 with CPython +3.12.14. The verifier needs only the standard library. + +## Completed author checks + +The direct full check passes `PASS_P104_CONTACT_REWRITE_KAPPA_00310676333`. +It checks all 565,504 scalar endpoint coefficients with a forward rational +engine and a separate dense integer transpose engine. It checks 2,917 native +maps and their exact phases, 1,070 helper normalizers, 208 main adapters, +7,488 physical contacts and 53,248 central-square columns. The complete +invoice has 66,474 paid requests, 12,958 productive fields and rank surplus 760. + +Both interval engines, the compiler budget, 54 strict outer conditions and +four functional outer conditions pass. The direct raw crossing is +`(0.00310676334487,0.00310676334488)`. The tested saving is 0.003106763335; +the final claim is 0.00310676333. The compiler reserve stays 10^-12, with +power 1024, cutoff 17, floor 18 and both tail blocks at decay 39/40. + +The source, sign, missing early read, wrong frame, missing erasure, extra +target, unpaid query, missing central translation, wrong native phase, +old cutoff and insufficient BIT controls reject. The finite pattern census +finds one candidate before the change and none after it. + +All six retained inputs match their exact external Git objects byte for byte. +The source archive authenticates its 36 payload files before import. The +registered metadata and source-pin check passes. Live source pins refer only +to the base and this branch's retained-input commit; runtime replay does not +need any unmerged predecessor Git object. `external_inputs` retains those +original commits, paths, SHA256 digests and Git blob identifiers for credit +and a separate publication comparison. + +The latest overlap check read 344 open PRs and 25 recent Discussions. PR5650 +publishes the preliminary composition and PR5651 corroborates it. This +package claims only the new four-gate placement, with gain 0.00000031864 over +PR5651's stronger rounded value. PR5440's larger reported endpoint remains +a separate conditional claim: its body explicitly leaves the physical +attachment false and the native chain-to-event compiler unresolved. The +new G20 BIT results do not bind this package's complex crossing. The active +P104 boundary-resynthesis, G20 and caller-construction lanes remain separate. + +## Publication checks + +At scientific commit `1f5a93245540e79be6ff4e7d573bbaf823a9dc23`, the +registered command runs both normal and explicit `-I -O -B` checks. Both +pass and reproduce the saved word and receipt. It then prints +`PASS_REGISTERED_RESEARCH_PACKAGE research/p104-contact-rewrite outcome=completed`. + +```sh +python3.12 -B scripts/research_package.py --package research/p104-contact-rewrite +python3 -B scripts/check_research_commit.py --package research/p104-contact-rewrite +python3 -B scripts/export_research_package.py export --package research/p104-contact-rewrite --ref 1f5a93245540e79be6ff4e7d573bbaf823a9dc23 --output /tmp/contact-source.tar +python3 -B scripts/export_research_package.py check /tmp/contact-source.tar +``` + +The committed-byte check and official exporter each cover 22 package files. +The base and retained-input commit are both ancestors of the scientific +commit. The optional full-history audit remains unavailable in this shallow +checkout. The public-source comparison separately reads all six exact Git +objects named in `external_inputs` and compares every byte with its copy. + +Six actual one-byte input corruptions are tested in a separate exported +copy, with `PATH=/nonexistent`. Each direct optimized verifier fails at its +SHA256 check before it prints any scientific result or imports retained +source code. Every original byte is then restored and its hash checked. +`SOURCE-CONTROLS.json` records the six rejections. + +GitHub's Markdown renderer preserves the README comparison table and the +proof's seven code blocks, including the four-gate endpoint and complete +paid delta. Local relative file links resolve within this package. This is +an HTML structure and text check, not a visual browser audit. + +The same official export passes the full direct optimized replay from a +fresh directory with no `.git` and `PATH=/nonexistent`: + +```sh +/absolute/path/to/python3.12 -I -O -B research/p104-contact-rewrite/verify.py +``` + +All source files are mode 0444 and all directories are mode 0555 during that +run. The 23-file inventory, SHA256 digests and file/directory modes are +unchanged afterwards. The source archive SHA256 is +`04aa750d6e69e9b985e940c40edb5934d8a19926a1a076f8c04d70a42bcfed9f`. +The replay reproduces the saved word and receipt, including gain 3983/12500000000. + +Later publication changes add only this validation record, the corruption +receipt and a proof paragraph about the minimum cost of the fixed c path. +The constructor, verifier, pricing, emitted word, complete receipt and all +retained inputs remain byte-identical to the fully replayed scientific +commit. Metadata, committed-byte, export and rendered-body checks are repeated +for the publication head. + +## Limits + +The five selected framework assumptions and the helper endpoint contract +remain. The huge uniform word and complete rounded multiplier are not +materialized. These are author checks with separate implementations, not +independent human scientific acceptance or a proof-kernel theorem. No +large breakthrough, universal obstruction or global optimum is claimed. + +The checkout is shallow. Full-history ancestry, full historical regression +suites, Lean and Docker were not run. Hosted CI is a separate gate; other +current PRs report a main-branch navigation failure in the shared planner. +This package does not claim a hosted pass from its local checks. diff --git a/research/p104-contact-rewrite/VERIFY.json b/research/p104-contact-rewrite/VERIFY.json new file mode 100644 index 0000000000..5f0316de10 --- /dev/null +++ b/research/p104-contact-rewrite/VERIFY.json @@ -0,0 +1,37 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p104-contact-rewrite/inputs/pr5627-source.tar", + "research/p104-contact-rewrite/inputs/pr5644-construct.py", + "research/p104-contact-rewrite/inputs/pr5644-witness.json", + "research/p104-contact-rewrite/inputs/pr5644-word.json.gz", + "research/p104-contact-rewrite/inputs/pr5643-word.json.gz", + "research/p104-contact-rewrite/inputs/pr5650-word.json.gz" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Every source byte, the four-gate identity, all scalar rows and columns, native phases, the complete caller, cost and failure controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Repeat the complete checks with Python assertions disabled." + } + ] +} diff --git a/research/p104-contact-rewrite/WITNESS.json b/research/p104-contact-rewrite/WITNESS.json new file mode 100644 index 0000000000..4671283b4f --- /dev/null +++ b/research/p104-contact-rewrite/WITNESS.json @@ -0,0 +1,16 @@ +{ + "indices": [12513, 12753, 12754, 12755], + "roles": [165, 586, 733, 21], + "old": [ + ["ADD", 586, 733, "-4", 597], + ["ADD", 165, 733, "2", 597], + ["ADD", 165, 21, "-1/2", 652], + ["ADD", 21, 586, "1", 652] + ], + "replacement": [ + ["ADD", 165, 586, "1/2", 3], + ["ADD", 586, 733, "-4", 597], + ["ADD", 21, 586, "1", 652], + ["ADD", 165, 21, "-1/2", 652] + ] +} diff --git a/research/p104-contact-rewrite/WORD.json.gz b/research/p104-contact-rewrite/WORD.json.gz new file mode 100644 index 0000000000..9e68b7de6b Binary files /dev/null and b/research/p104-contact-rewrite/WORD.json.gz differ diff --git a/research/p104-contact-rewrite/construct.py b/research/p104-contact-rewrite/construct.py new file mode 100644 index 0000000000..1207c37044 --- /dev/null +++ b/research/p104-contact-rewrite/construct.py @@ -0,0 +1,130 @@ +"""Compose the released changes and apply one four-gate identity. + +The A2 identity is from PR3998/4019 and zxv's PR5643 paid construction. +PR5644 supplies the three helper relations. Ali Romman prepared the new +four-gate construction with substantial OpenAI Codex assistance. Apache-2.0. +""" +from collections import Counter +from copy import deepcopy +from fractions import Fraction as Q + + +def roles(event): + return set(event[1:3]) if event[0] in ('ADD', 'COPY') else {event[1]} + + +def scalar_word(word): + return [e for e in word['program'] if e[0] != 'MOVE'] + + +def skeleton(word): + return [e for e in word['program'] if e[0] != 'MOVE' or e[1] >= word['public']] + + +def rebuild(word, program, L): + """Keep the owned paths and rebuild each nested public path.""" + out = deepcopy(word) + n = word['public'] + current = word['initial'] + [None]*word['owned_fields'] + spaces = [L.span(b) for b in word['frames']] + events = [] + + def move(role, frame): + old = current[role] + if old == frame: + return + L.need(role < n and spaces[old] < spaces[frame], 'Strict nested public path') + events.append(['MOVE', role, old, frame, False]) + current[role] = frame + + for event in program: + op, role = event[:2] + if op == 'MOVE': + L.need(role >= n and current[role] == event[2], 'Unchanged owned transport') + current[role] = event[3] + elif op == 'INIT': + L.need(current[role] is None, 'Fresh owned lifetime') + current[role] = event[2] + elif op == 'CLEAR': + L.need(current[role] == event[2], 'Owned erasure frame') + current[role] = None + else: + for operand in sorted(roles(event)): + move(operand, event[-1]) + events.append(event[:]) + for role, frame in enumerate(word['final']): + move(role, frame) + out['program'] = events + return out + + +def replace_a2(program, L): + old = [['ADD', 388, 715, '-4', 825], ['ADD', 340, 388, '1', 825]] + sites = [i for i in range(len(program)-1) if program[i:i+2] == old] + L.need(len(sites) == 1, 'Unique published A2 pair') + i = sites[0] + return program[:i] + [['ADD', 340, 715, '-4', 396], old[1], + ['ADD', 388, 715, '-4', 127]] + program[i+2:] + + +def check_a2_source(source, published, L): + for key in source: + if key not in ('program', 'schema'): + L.need(source[key] == published[key], 'Published A2 boundary: '+key) + L.need(replace_a2(scalar_word(source), L) == scalar_word(published), + 'Exact released PR5643 scalar change') + before, after = L.replay(source), L.replay(published) + delta = Counter(after['paid']) + delta.subtract(before['paid']) + L.need({r:v for r,v in delta.items() if v} == {2:1,3:-1,5:-1,6:1}, + 'Exact released PR5643 paid change') + + +def matrix(gates, labels): + at = {r:i for i,r in enumerate(labels)} + rows = [[Q(i == j) for j in range(len(labels))] for i in range(len(labels))] + for event in gates: + a, b, q = at[event[1]], at[event[2]], Q(event[3]) + rows[a] = [x+q*y for x,y in zip(rows[a], rows[b])] + return rows + + +def rewrite(word, witness, L): + """Use the old helper value before its source update.""" + p = skeleton(word) + indices = witness['indices'] + old, new = witness['old'], witness['replacement'] + L.need(indices == sorted(set(indices)) and len(indices) == 4, 'Four ordered source sites') + L.need([p[i] for i in indices] == old, 'Exact four-gate source anchors') + c, h, s, x = witness['roles'] + L.need(len({c,h,s,x}) == 4 and max(c,h,s,x) < word['public'], 'Four public roles') + L.need([e[1:3] for e in old] == [[h,s],[c,s],[c,x],[x,h]], 'Declared source pattern') + alpha, beta, gamma, delta = (Q(e[3]) for e in old) + L.need(beta == alpha*gamma*delta, 'Exact compensation coefficient') + expected = [['ADD', c, h, str(-gamma*delta), 3], + ['ADD', h, s, str(alpha), 597], + ['ADD', x, h, str(delta), 652], + ['ADD', c, x, str(gamma), 652]] + L.need(new == expected, 'Declared complete replacement') + L.need([word['frames'][f] for f in (3,597,652)] == [[],[82],[82,268]], + 'Exact zero, one and two dimensional charts') + omitted = set(indices) + L.need(not any(roles(e) & {c,h,s} for i,e in enumerate(p) + if indices[0] < i < indices[-1] and i not in omitted), + 'No intervening read or write of the three moved roles') + L.need(indices[-1] == indices[-2]+1, 'The two late gates are consecutive') + L.need(matrix(old, [c,h,s,x]) == matrix(new, [c,h,s,x]), 'Independent four-column identity') + changed = [] + for i,event in enumerate(p): + if i == indices[-1]: + changed.extend(new) + elif i not in omitted: + changed.append(event) + result = rebuild(word, changed, L) + result['schema'] = 'p104-contact-rewrite/1' + before, after = L.replay(word), L.replay(result) + delta_paid = Counter(after['paid']) + delta_paid.subtract(before['paid']) + L.need({r:v for r,v in delta_paid.items() if v} == {1:-2,2:1}, 'Two H1 calls become one H2') + L.need(before['helpers'] == after['helpers'], 'Every independent target is retained') + return result, after diff --git a/research/p104-contact-rewrite/inputs/pr5627-source.tar b/research/p104-contact-rewrite/inputs/pr5627-source.tar new file mode 100644 index 0000000000..bc900f0a15 Binary files /dev/null and b/research/p104-contact-rewrite/inputs/pr5627-source.tar differ diff --git a/research/p104-contact-rewrite/inputs/pr5643-word.json.gz b/research/p104-contact-rewrite/inputs/pr5643-word.json.gz new file mode 100644 index 0000000000..7cf851189d Binary files /dev/null and b/research/p104-contact-rewrite/inputs/pr5643-word.json.gz differ diff --git a/research/p104-contact-rewrite/inputs/pr5644-construct.py b/research/p104-contact-rewrite/inputs/pr5644-construct.py new file mode 100644 index 0000000000..1d9ff07f57 --- /dev/null +++ b/research/p104-contact-rewrite/inputs/pr5644-construct.py @@ -0,0 +1,117 @@ +"""Apply three exact neutral helper relations and join unused transports. + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The helper boundary identity extends the retained PR5602 construction. +""" +from collections import Counter +from copy import deepcopy +from fractions import Fraction as Q + + +def coalesce(word, L): + out = deepcopy(word) + actual = word['initial'] + [None]*word['owned_fields'] + desired, program = actual[:], [] + + def flush(role): + if actual[role] != desired[role]: + program.append(['MOVE', role, actual[role], desired[role], role >= word['public']]) + actual[role] = desired[role] + + for event in word['program']: + op, role = event[:2] + if op == 'MOVE': + L.need(desired[role] == event[2], 'Chronological transport source') + desired[role] = event[3] + elif op == 'INIT': + L.need(actual[role] is None, 'Fresh owned lifetime') + actual[role] = desired[role] = event[2] + program.append(event[:]) + else: + flush(role) + if op in ('ADD', 'COPY'): + flush(event[2]) + program.append(event[:]) + if op == 'CLEAR': + actual[role] = desired[role] = None + for role in range(word['public']): + flush(role) + out['program'] = program + return out + + +def relation(word, witness, L): + h, cut, frame = (witness[k] for k in ('helper', 'cut', 'frame')) + n, owned = word['public'], word['owned_fields'] + main = set(word['live']) | {r+112 for r in word['live']} + L.need(h < n and h not in main and witness['reverse'] is False, 'Forward public helper') + L.need(word['program'][cut] == witness['anchor'], 'Exact chronological anchor') + L.need(word['final'][h] == frame, 'The target boundary stays fixed') + rows = [{r:Q(1)} if r < n else {} for r in range(n+owned)] + current = word['initial'] + [None]*owned + for event in word['program'][:cut+1]: + op, role = event[:2] + if op == 'MOVE': + current[role] = event[3] + elif op in ('INIT', 'CLEAR'): + rows[role] = {} + current[role] = event[2] if op == 'INIT' else None + elif op == 'SCALE': + rows[role] = {j:Q(event[-2])*a for j,a in rows[role].items()} + elif op == 'COPY': + rows[role] = {j:Q(event[-2])*a for j,a in rows[event[2]].items()} + else: + L.add(rows[role], rows[event[2]], Q(event[-2])) + output = {int(j):Q(a) for j,a in witness['output'].items()} + cancel = {int(j):Q(a) for j,a in witness['cancel'].items()} + initial = word['initial'][h] + L.need(h in output and h not in cancel and all(j < n and word['initial'][j] == initial + for j in output), 'One independent input chart') + L.need(current[h] == frame and all(current[j] == frame for j in cancel), + 'One cancellation chart') + row = rows[h].copy() + for role, coefficient in cancel.items(): + L.add(row, rows[role], -coefficient) + L.need(row == output, 'Exact prefix relation on every input') + scale = output[h] + L.need(scale and abs(scale.numerator) & (abs(scale.numerator)-1) == 0 + and scale.denominator & (scale.denominator-1) == 0, 'Invertible dyadic coefficient') + tail = word['program'][cut+1:] + L.need(not any(e[0] in ('ADD', 'COPY') and e[2] == h for e in tail), 'No later helper read') + removed = [e for e in tail if e[1] == h] + L.need(len(removed) == witness['removed'] and all(e[0] in ('ADD', 'SCALE') for e in removed), + 'Only declared scalar cleanup is removed') + preparation = [['ADD', h, j, str(-a/scale), initial] for j,a in sorted(output.items()) if j != h] + cancellation = [['ADD', h, j, str(-a), frame] for j,a in sorted(cancel.items())] + if scale != 1: + cancellation.append(['SCALE', h, str(1/scale), frame]) + out = deepcopy(word) + out['program'] = preparation + word['program'][:cut+1] + cancellation + [e for e in tail if e[1] != h] + out = coalesce(out, L) + return out, {'helper':h, 'cut':cut, 'frame':frame, 'removed_scalar_events':removed, + 'preparation':preparation, 'cancellation':cancellation} + + +def owned_events(word): + n = word['public'] + return [e for e in word['program'] if e[1] >= n or (e[0] in ('ADD', 'COPY') and e[2] >= n)] + + +def construct(source, witnesses, L): + L.need([c['helper'] for c in witnesses] == [291,321,369], 'Three declared helper relations') + word, receipts = deepcopy(source), [] + before = L.replay(word) + for witness in witnesses: + old = word + word, receipt = relation(word, witness, L) + after = L.replay(word) + delta = Counter(after['paid']) + delta.subtract(before['paid']) + L.need({r:v for r,v in delta.items() if v} == {1:-1,5:-1,6:1}, 'One H1+H5 path becomes H6') + L.need(after['helpers'] == before['helpers'] and word['initial'] == old['initial'] + and word['final'] == old['final'], 'Every target and independent input stays fixed') + L.need(owned_events(word) == owned_events(old), 'Every owned operation is retained in order') + receipt.update(paid=after['paid'], events=len(word['program']), scalar=after['real_scalar_allowance']) + receipts.append(receipt) + before = after + return word, receipts, before diff --git a/research/p104-contact-rewrite/inputs/pr5644-witness.json b/research/p104-contact-rewrite/inputs/pr5644-witness.json new file mode 100644 index 0000000000..8d4f38c5c9 --- /dev/null +++ b/research/p104-contact-rewrite/inputs/pr5644-witness.json @@ -0,0 +1,80 @@ +[ + { + "anchor": [ + "ADD", + 18, + 291, + "-1/2", + 234 + ], + "cancel": { + "293": "-1" + }, + "cut": 10627, + "frame": 234, + "gain": 0.0, + "helper": 291, + "output": { + "291": "-2", + "293": "-1", + "303": "2", + "39": "2" + }, + "removed": 6, + "reverse": false + }, + { + "anchor": [ + "ADD", + 320, + 321, + "-1", + 237 + ], + "cancel": { + "22": "2", + "320": "-3/2", + "330": "2" + }, + "cut": 11072, + "frame": 237, + "gain": 0.0, + "helper": 321, + "output": { + "320": "-2", + "321": "1", + "330": "2", + "34": "-2" + }, + "removed": 5, + "reverse": false + }, + { + "anchor": [ + "ADD", + 368, + 369, + "-1", + 243 + ], + "cancel": { + "26": "2", + "368": "-3/2", + "378": "-2" + }, + "cut": 11718, + "frame": 243, + "gain": 0.0, + "helper": 369, + "output": { + "3": "-2", + "369": "1", + "372": "-2", + "378": "-2", + "382": "-2", + "383": "2" + }, + "removed": 5, + "reverse": false + } +] diff --git a/research/p104-contact-rewrite/inputs/pr5644-word.json.gz b/research/p104-contact-rewrite/inputs/pr5644-word.json.gz new file mode 100644 index 0000000000..0bd3cff775 Binary files /dev/null and b/research/p104-contact-rewrite/inputs/pr5644-word.json.gz differ diff --git a/research/p104-contact-rewrite/inputs/pr5650-word.json.gz b/research/p104-contact-rewrite/inputs/pr5650-word.json.gz new file mode 100644 index 0000000000..92e858d5db Binary files /dev/null and b/research/p104-contact-rewrite/inputs/pr5650-word.json.gz differ diff --git a/research/p104-contact-rewrite/patterns.py b/research/p104-contact-rewrite/patterns.py new file mode 100644 index 0000000000..75ca00f9e1 --- /dev/null +++ b/research/p104-contact-rewrite/patterns.py @@ -0,0 +1,74 @@ +"""Count the tested four-gate scalar pattern before frame selection. + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +This is a finite pattern census, not a test of all possible rewrites. +""" +from bisect import bisect_left, bisect_right +from collections import defaultdict +from fractions import Fraction as Q + + +def find(word): + public = word['public'] + program = [e for e in word['program'] if e[0] != 'MOVE' or e[1] >= public] + touches, reads, writes = (defaultdict(list) for _ in range(3)) + for i, event in enumerate(program): + if event[0] not in ('ADD', 'COPY', 'SCALE'): + continue + roles = {event[1],event[2]} if event[0] != 'SCALE' else {event[1]} + for role in roles: + touches[role].append(i) + writes[event[1]].append(i) + reads[event[2] if event[0] != 'SCALE' else event[1]].append(i) + + def next_site(sites, i): + k = bisect_right(sites, i) + return sites[k] if k < len(sites) else len(program) + + def previous(roles, j, skip): + candidates = [] + for role in roles: + sites = touches[role] + k = bisect_left(sites, j)-1 + while k >= 0 and sites[k] in skip: + k -= 1 + if k >= 0: + candidates.append(sites[k]) + return max(candidates, default=-1) + + matches = [] + for i, first in enumerate(program): + if first[0] != 'ADD' or max(first[1:3]) >= public: + continue + a, b = first[1:3] + j = min(next_site(writes[b], i), next_site(reads[a], i)) + if j >= len(program): + continue + second = program[j] + if second[0] != 'ADD' or max(second[1:3]) >= public: + continue + x, y = second[1:3] + if len({a,b,x,y}) != 3: + continue + if y == a: + c, h, eta = x, b, Q(first[-2])*Q(second[-2]) + elif x == b: + c, h, eta = a, y, -Q(first[-2])*Q(second[-2]) + else: + continue + t = previous({c,h}, j, {i}) + if (t < 0 or program[t][0] != 'ADD' or program[t][1] not in (c,h) + or program[t][2] in (c,h)): + continue + s = program[t][2] + if s >= public or previous({c,h,s}, j, {i}) != t: + continue + u = previous({c,h,s}, t, {i}) + if (u < 0 or program[u][0] != 'ADD' or program[u][2] != s + or {program[u][1],program[t][1]} != {c,h}): + continue + alpha = Q(program[u][-2] if program[u][1] == h else program[t][-2]) + beta = Q(program[u][-2] if program[u][1] == c else program[t][-2]) + if beta + eta*alpha == 0: + matches.append(dict(first=i, second=j, previous=[u,t], roles=[c,h,s])) + return matches diff --git a/research/p104-contact-rewrite/pricing.py b/research/p104-contact-rewrite/pricing.py new file mode 100644 index 0000000000..be7b1bce3c --- /dev/null +++ b/research/p104-contact-rewrite/pricing.py @@ -0,0 +1,176 @@ +"""Complete mixed-target price, compiler and outer transfer. + +The interval and compiler bounds follow zxv and Cao Yifan. The productive +recursion is by Jacob Alan Sussman. The controller is by Cinna Davis. +Adapted from Ali Romman's PR5544/5545 for the two coupled contact changes. +Successor choices were prepared for thu-nmrc with OpenAI Codex assistance. +Helper-subspace targets were added by Ali Romman with OpenAI Codex assistance. +The source commuting-contact construction is by Pierre-Loic Doulcet (hexapode) in PR5565. +The source coupled-frame change is by Ali Romman with OpenAI Codex in PR5601. +Five fixed boundary relations are from Ali Romman's PR5602. +The shared and delayed relays are from flyingviper's PR5605 and PR5612. The preparation is from +Scratch-net's PR5606. Their costs and target debit are included. +Ali Romman's complete caller/price proof and all predecessor credit are retained. +The paid A2 change is from zxv PR5643. The three helper relations are from +Ali Romman PR5644. The four-gate change is by Ali Romman with Codex assistance. +Apache-2.0. +""" +from collections import Counter +from fractions import Fraction as Q +import local as L + +KAPPA, TESTED = Q('.00310676333'), Q('.003106763335') +PREVIOUS = Q('.00310644469') + + +def encode(x): + if isinstance(x,Q): + return str(x) + if isinstance(x,dict): + return {str(k):encode(v) for k,v in x.items()} + if isinstance(x,(list,tuple)): + return [encode(v) for v in x] + return x + + +def assemble(local, native, word, physical): + paid, targets = Counter(), Counter() + counts = Counter() + L.need(local['helpers'] == native['helpers'], 'Every productive helper has a native target') + for e in word['physical_events']: + counts[e[0]] += 1 + if e[0] == 'LOCAL': + L.need(e[3] is False, 'Every source invocation is forward') + paid.update(local['paid']) + targets.update(local['helpers']) + elif e[0] == 'QUERY_SHEAR': + paid[1] += 104 + elif e[0] == 'IDLE': + paid[8*len(e[2])] += 208 + main = Counter() + idle = Counter({8*len(e[2]):0 for e in word['physical_events'] if e[0] == 'IDLE'}) + for e in word['physical_events']: + if e[0] == 'IDLE': + idle[8*len(e[2])] += 208 + L.need(idle == physical['whole_idle_jobs'], 'Every whole idle has a native Gaussian and full rank') + for term in word['diagonal']: + main[1+8*sum(term[1:])] += 104 + L.need(main == physical['main_targets'], 'Every main target has its full native phase') + targets.update(main) + L.need(counts['LOCAL'] == 18 and counts['QUERY_SHEAR'] == counts['IDLE'] == 15, 'Complete call census') + # Recount by the two path lengths, without using emitted main diagonals. + second_t = Counter({r:18*n for r,n in local['helpers'].items()}) + second_p = Counter({r:18*n for r,n in local['paid'].items()}) + second_t[145] += 208 + second_p[1] += 15*104 + for length in (7,8): + for j in range(1,length+1): + second_t[1+8*(j+1)] += 208 + second_p[8*(j+1)] += 208 + L.need((targets,paid) == (second_t,second_p), 'Independent full invoice') + L.need(max(targets) == 145 and max(paid) == 72, 'Maximum recursive ranks') + L.need(sum(targets.values()) == 12958 and sum(paid.values()) == 66474, 'Complete field and call counts') + L.need(sum(r*n for r,n in targets.items())-sum(r*n for r,n in paid.items()) == 760, 'Complete rank surplus') + return targets,paid,counts + + +def run(local,native,word,physical): + T,P,counts = assemble(local,native,word,physical) + E = L.load(L.ROOT/'research/higher-moment-strictification/verify.py','p104_productive_intervals') + other = L.load(L.ROOT/'research/kappa-rebuild/architecture/mixed_target_probe.py','p104_productive_second_intervals') + def margin(k): + a,b = E.moment(T,1-k), E.moment(P,1-k) + return a[0]-b[1],a[1]-b[0] + lo,hi,grid = 0,10**12,10**14 + while hi-lo > 1: + m=(lo+hi)//2 + if margin(Q(m,grid))[0] > 0: + lo=m + else: + hi=m + lower,upper = Q(lo,grid),Q(hi,grid) + signed = Counter(T) + signed.subtract(P) + cap = Q('.0034') + derivative_upper = Q(0) + for rank, count in signed.items(): + logarithm = E.log_bounds(rank) + low = E.mul(E.power(rank, 1-cap), logarithm)[0] + high = rank*logarithm[1] + derivative_upper -= count*(low if count >= 0 else high) + L.need(derivative_upper < 0, 'Unique raw crossing below the retained BIT cap') + L.need(margin(lower)[0] > 0 and margin(upper)[1] < 0, 'Strict rational crossing enclosure') + L.need(PREVIOUS < KAPPA < TESTED < lower and margin(PREVIOUS)[0] > 0, 'Changed complete bill improves the source claim') + t,u,v,c,b = 1-TESTED,Q(1,5),1024,17,18 + target,paid = E.moment(T,t),E.moment(P,t) + tl,th = other.moment(T,TESTED) + pl,ph = other.moment(P,TESTED) + L.need(tl > ph and max(tl,target[0]) <= min(th,target[1]) and max(pl,paid[0]) <= min(ph,paid[1]), 'Two exact moment engines') + alpha = E.divide(paid,target) + gamma = E.divide(E.moment(P,t+u),E.mul(E.power(c,u),target)) + delta = E.divide((Q(sum(T.values())*b),)*2,E.mul(E.power(c,TESTED),target)) + reserve,decay = Q(1,10**12),Q(39,40) + L.need(alpha[1] < 1-reserve and gamma[1] < decay and delta[1] < decay, 'All three charged tail ratios') + L.need(decay**128 < Q(1,16), 'Both tail decay blocks') + normalized = 1/(1+v*reserve)+Q(4,2**32) + L.need(normalized < 1 and c**64 < b**63, 'Full completion, splitting and rounding charges') + theta,power = Q(63,64),1024 + eta = E.scale(E.power(145,-v*TESTED),t) + L.need(2*(c**v)**64 <= (145**v)**63 and eta[0] > theta**power, 'Shifted exits and complement capacity') + L.need(E.power(145,v*TESTED)[1] < 2**power, 'Compiler initial range') + gap = (TESTED-KAPPA)/7 + L.need(gap.numerator == 1, 'Exact compiler integer grid') + step = gap.denominator + def wins(j): + return (step*j+1)**power < 2**j + left,right=1,2 + while not wins(right): + left,right=right,2*right + while right-left > 1: + m=(left+right)//2 + if wins(m): + right=m + else: + left=m + H=step*right + L.need(H > 8*v and wins(right) and not wins(right-1), 'Finite uniform threshold with predecessor rejection') + local_routes = (sum(local['paid'].values())+native['helper_normalizers']+native['main_adapters']+4*104+4*local['owned_lifetimes'])*1000 + L.need(local['real_scalar_allowance']+local_routes < 10**7, 'Every local scalar, route and owned operation is funded') + boundary = sum(len(word['boundaries'][side+'_program']) for side in ('left','right')) + raw = 18*10**7 + 15*1664 + 32*104*(len(word['physical_events'])+boundary) + raw += 32*104*(26+1000) + L.need(raw < 10**9, 'Complete nonrecursive raw bound') + bit = L.read(L.ROOT/'research/query-thinned-controllers/RESULT.json')['ordinary_BIT'] + atom = Q(bit['atom']) + ordinary=(1-atom)*Q(bit['after_cover'])+atom*Q('.0000384599') + admitted=Q(bit['admitted']) + L.need(atom > ordinary > admitted > TESTED and atom < 1-ordinary, 'Retained BIT admission and stock') + outer_module=L.load(L.ROOT/'research/pr4359-p7-padding/dependencies/compiler-refill/endpoint.py','p104_productive_outer') + params={'kappa':KAPPA,'tested_saving':TESTED,'complex_uniform_saving':KAPPA+6*gap, + 'b':KAPPA+5*gap,'a':KAPPA+4*gap,'q':KAPPA+3*gap,'bit_saving':admitted, + 'epsilon':1-gap,'beta':1-3*gap,'r0':gap/10,'stop':gap,'layout':gap,'d':gap} + outer=outer_module.ledger(params) + outer['functional_checks']['actual_new_BIT_stock_sublinear']=params['beta']*(1-atom) + L.need(len(outer['strict_checks']) == 54 and len(outer['functional_checks']) == 4, 'Complete outer predicate inventory') + L.need(all(x > 0 for key in ('strict_checks','functional_checks') for x in outer[key].values()), 'All outer inequalities strict') + wrong_cutoff = E.divide((Q(sum(T.values())*21),)*2,E.mul(E.power(20,TESTED),target)) + L.need(wrong_cutoff[0] > 1, 'Old cutoff fails with this helper inventory') + bad=outer_module.ledger(dict(params,bit_saving=Q('.0027'))) + L.need(any(x <= 0 for x in bad['strict_checks'].values()), 'Insufficient BIT contract rejected') + return encode({'kappa':KAPPA,'kappa_decimal':'.00310676333','previous_open_pr5651':PREVIOUS,'gain':KAPPA-PREVIOUS, + 'relative_gain_percent':100*(KAPPA/PREVIOUS-1),'raw_root_interval':[lower,upper], + 'raw_headroom':[lower-KAPPA,upper-KAPPA], + 'raw_ceiling':{'interval':[Q(0),cap],'derivative_upper':derivative_upper},'margin_at_previous':E.display(margin(PREVIOUS)), + 'targets':T,'paid':P,'productive_fields':sum(T.values()),'paid_calls':sum(P.values()), + 'rank_mass_surplus':760,'full_forward_calls':18,'query_shears':15,'whole_idle_jobs':3120, + 'strictification':{'tested':TESTED,'power':v,'cutoff':c,'floor':b,'tail_offset':u,'reserve':reserve,'tail_decay':decay,'tail_block':128, + 'alpha':E.display(alpha),'gamma':E.display(gamma),'delta':E.display(delta),'normalized_paid_upper':normalized}, + 'compiler':{'theta':theta,'logarithm_power':power,'eta':E.display(eta),'gap':gap,'H':H,'N':'2^'+str(H), + 'integer_test_exponent':right,'uniform_saving':params['complex_uniform_saving'],'word_materialized':False}, + 'nonrecursive':{'local_scalar':local['real_scalar_allowance'],'local_routes':local_routes, + 'raw_scalar_upper':raw,'raw_budget':10**9,'peak_owned_fields':local['peak_owned_fields'], + 'fixed_scalar_growth_bound':'At most 2^(16*26000) before native factors; a declared constant, not an attained norm.', + 'local_paid_rank_mass':local['paid_rank_mass'], + 'tensor_native_growth_bound':'Each rank-r Gaussian has row l1 norm at most 2^(rf); use local_paid_rank_mass for the whole word.'}, + 'ordinary_BIT':bit,'outer':outer, + 'negative_controls':{'old_cutoff':'Rejected by completion-tail ratio greater than one','old_BIT':'Rejected by outer inequalities'}}) diff --git a/research/p104-contact-rewrite/sources.py b/research/p104-contact-rewrite/sources.py new file mode 100644 index 0000000000..7cccea00a6 --- /dev/null +++ b/research/p104-contact-rewrite/sources.py @@ -0,0 +1,88 @@ +"""Authenticate the retained PR5627 export before any source import. + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The archive checks follow the repository exporter and flyingviper's PR5613. +""" +from contextlib import contextmanager +from hashlib import sha1, sha256 +from pathlib import Path, PurePosixPath +import importlib.util +import io +import json +import sys +import tarfile +import tempfile + +HERE = Path(__file__).resolve().parent + + +def need(ok, why): + if not ok: + raise ValueError(why) + + +def load(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +@contextmanager +def sources(): + manifest = json.loads((HERE/'SOURCES.json').read_bytes()) + root_prefix = 'research/p104-contact-rewrite/' + retained = {root_prefix+'inputs/'+name for name in ( + 'pr5627-source.tar', 'pr5644-construct.py', 'pr5644-witness.json', + 'pr5644-word.json.gz', 'pr5643-word.json.gz', 'pr5650-word.json.gz')} + rows = {row['path']:row for row in manifest['files']} + need(len(rows) == len(manifest['files']), 'Unique source paths') + need({row['path'] for row in rows.values() if row['usage'] == 'input'} == retained, + 'Complete retained input inventory') + need({row['copy'] for row in manifest['external_inputs']} == retained + and len(manifest['external_inputs']) == len(retained), 'Complete external input map') + for origin in manifest['external_inputs']: + copied = rows[origin['copy']] + need(origin['commit'] in manifest['predecessors'].values(), 'Named published predecessor') + need(copied['pin'] == 'head:'+manifest['input_commit']+':'+copied['path'], + 'Exact retained input commit') + for digest in ('sha256', 'git_blob'): + need(copied[digest] == origin[digest], + 'Published and retained source bytes agree') + for row in manifest['files']: + if row['usage'] != 'input': + continue + need(row['path'].startswith(root_prefix), 'Package-local retained input') + data = (HERE/row['path'][len(root_prefix):]).read_bytes() + need(sha256(data).hexdigest() == row['sha256'], 'Exact retained input SHA256: '+row['path']) + need(sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest() == row['git_blob'], + 'Exact retained input Git blob: '+row['path']) + pin = manifest['source_export'] + raw = (HERE/pin['local_path']).read_bytes() + need(sha256(raw).hexdigest() == pin['sha256'], 'Exact predecessor archive SHA256') + need(sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest() == pin['git_blob'], + 'Exact retained archive Git blob') + with tempfile.TemporaryDirectory(prefix='p104-contact-source-') as directory: + root, names = Path(directory), set() + with tarfile.open(fileobj=io.BytesIO(raw), mode='r:') as bundle: + for member in bundle.getmembers(): + path = PurePosixPath(member.name) + need(member.isfile() and not path.is_absolute() and '..' not in path.parts + and '\\' not in member.name and ':' not in member.name, + 'Regular relative source path') + need(member.name not in names, 'Unique source path') + names.add(member.name) + target = root.joinpath(*path.parts) + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(bundle.extractfile(member).read()) + manifest = json.loads((root/'.research-export.json').read_bytes()) + need(manifest['commit'] == pin['commit'] and manifest['package'] == pin['package'] + and len(manifest['files']) == pin['files'], 'Exact source commit and inventory') + need(names == {'.research-export.json'} | {r['path'] for r in manifest['files']}, + 'No missing or additional source payload') + for row in manifest['files']: + payload = (root/row['path']).read_bytes() + need(len(payload) == row['size'] and sha256(payload).hexdigest() == row['sha256'], + 'Authenticated payload: '+row['path']) + yield root/pin['package'], root diff --git a/research/p104-contact-rewrite/verify.py b/research/p104-contact-rewrite/verify.py new file mode 100644 index 0000000000..93ba8c1769 --- /dev/null +++ b/research/p104-contact-rewrite/verify.py @@ -0,0 +1,143 @@ +"""Check the complete conditional P104 contact rewrite and its price. + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +""" +import argparse +from collections import Counter +from copy import deepcopy +import gzip +import json +from pathlib import Path +import sys +import tempfile + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from sources import sources, load, need +import construct +import patterns + + +def rejected(action): + try: + action() + except ValueError as error: + return str(error) + raise ValueError('An invalid certificate was accepted') + + +def difference(after, before): + delta = Counter(after) + delta.subtract(before) + return {r:v for r,v in delta.items() if v} + + +def run(): + witness = json.loads((HERE/'WITNESS.json').read_bytes()) + with sources() as (parent, root): + L = load(parent/'local.py', 'local') + source = L.read(parent/'WORD.json.gz') + old = L.replay(source) + cleanup = load(HERE/'inputs/pr5644-construct.py', 'released_helper_cleanup') + clean, clean_changes, clean_local = cleanup.construct( + source, L.read(HERE/'inputs/pr5644-witness.json'), L) + need(clean == L.read(HERE/'inputs/pr5644-word.json.gz'), 'Exact released PR5644 word') + construct.check_a2_source(source, L.read(HERE/'inputs/pr5643-word.json.gz'), L) + composed = construct.rebuild(clean, construct.replace_a2(construct.skeleton(clean), L), L) + published = L.read(HERE/'inputs/pr5650-word.json.gz') + normalized = construct.rebuild(published, construct.skeleton(published), L) + normalized['schema'] = composed['schema'] + need(normalized == composed, 'Exact released PR5650 composition after public MOVE ordering') + composed_local = L.replay(composed) + need(L.replay(published) == composed_local, 'Same complete published composition receipt') + need(difference(composed_local['paid'], clean_local['paid']) == {2:1,3:-1,5:-1,6:1}, + 'The released A2 change composes with all three helper relations') + word, local = construct.rewrite(composed, witness, L) + pattern_before, pattern_after = patterns.find(composed), patterns.find(word) + need(pattern_before == [dict(first=12754,second=12755,previous=[12513,12753],roles=[165,586,733])] + and pattern_after == [], 'One tested scalar pattern before the change and none after') + columns = L.reverse_columns(word) + need(cleanup.owned_events(word) == cleanup.owned_events(source), 'All owned instructions stay fixed') + need((local['public_inputs'],local['owned_fields'],local['owned_lifetimes'],local['peak_owned_fields']) == + (743,9,11,2), 'Complete public and owned inventories') + need(difference(local['paid'],old['paid']) == {1:-5,2:2,3:-1,5:-4,6:4}, 'Combined exact paid delta') + need(local['helpers'] == old['helpers'] == composed_local['helpers'], 'No target debit or added credit') + print('PASS released composition, four-gate identity and all 565504 endpoint coefficients', flush=True) + native = L.native(word) + C = load(root/'research/p104-productive-controller/caller.py', 'contact_caller') + caller = C.construct() + need(caller == L.read(root/'research/p104-productive-controller/CONTROLLER.json'), 'Same complete controller') + physical = C.physical(caller, word) + print('PASS all native phases, target maps and physical caller contacts', flush=True) + price = (parent/'pricing.py').read_text() + for before, after in json.loads((HERE/'PRICING-EDITS.json').read_bytes()): + need(price.count(before) == 1, 'One declared price change') + price = price.replace(before, after) + need((HERE/'pricing.py').read_text() == price, 'Only declared price and attribution changes') + P = load(HERE/'pricing.py', 'contact_price') + costs = P.run(local, native, caller, physical) + controls = C.controls(caller) + bad = deepcopy(witness) + bad['replacement'][0][3] = '-1/2' + controls['wrong_compensation_sign'] = rejected(lambda: construct.rewrite(composed,bad,L)) + bad = deepcopy(witness) + bad['indices'][0] += 1 + controls['wrong_source_version'] = rejected(lambda: construct.rewrite(composed,bad,L)) + bad = deepcopy(word) + bad['program'].remove(next(e for e in bad['program'] if e == witness['replacement'][0])) + controls['missing_early_read'] = rejected(lambda: L.replay(bad)) + bad = deepcopy(word) + site = next(i for i,e in enumerate(bad['program']) if e == witness['replacement'][0]) + bad['program'][site][-1] = 597 + controls['wrong_early_frame'] = rejected(lambda: L.replay(bad)) + bad = deepcopy(word) + bad['program'].pop(max(i for i,e in enumerate(bad['program']) if e[0] == 'CLEAR')) + controls['missing_owned_erasure'] = rejected(lambda: L.replay(bad)) + bad = deepcopy(local) + bad['helpers'][1] += 1 + controls['extra_target_credit'] = rejected(lambda: P.assemble(bad,native,caller,physical)) + bad = deepcopy(local) + bad['paid'][1] -= 1 + controls['unpaid_query'] = rejected(lambda: P.assemble(bad,native,caller,physical)) + result = dict(status='PASS_P104_CONTACT_REWRITE_KAPPA_00310676333', + authenticated_package_inputs=6, authenticated_source_files=36, + source_commit='ed4dc88a09a7d201971f6603b8c2074e95dd9c32', + released_helper_changes=clean_changes, + released_a2_paid_delta={2:1,3:-1,5:-1,6:1}, + scalar_pattern_census=dict(before=pattern_before,after=pattern_after), + new_four_gate_paid_delta={1:-2,2:1}, + local_paid_delta={1:-5,2:2,3:-1,5:-4,6:4},local_helper_delta={}, + source_local=old,pr5644_local=clean_local,composed_local=composed_local, + local=local,separate_columns=columns,native=native,physical_caller=physical, + complete_cost=costs,negative_controls=controls, + limits=['The five selected framework assumptions and helper endpoint contract remain.', + 'The enormous uniform word and complete rounded multiplier are not materialized.', + 'These author checks are not independent scientific acceptance or a proof-kernel theorem.', + 'This is a small improvement. No global optimum or large breakthrough is established.']) + return P.encode(result), word + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--write', action='store_true') + args = parser.parse_args() + with tempfile.TemporaryDirectory(prefix='p104-contact-bytecode-') as cache: + sys.pycache_prefix = cache + result, word = run() + for name, value in (('RESULT.json',result),('WORD.json.gz',word)): + path = HERE/name + if args.write: + raw = (json.dumps(value,sort_keys=True,indent=None if name.endswith('.gz') else 2)+'\n').encode() + path.write_bytes(gzip.compress(raw,mtime=0) if name.endswith('.gz') else raw) + else: + raw = path.read_bytes() + need(json.loads(gzip.decompress(raw) if name.endswith('.gz') else raw) == value, + 'Exact saved artifact: '+name) + print(result['status']) + print(json.dumps({k:result['complete_cost'][k] for k in + ('kappa_decimal','gain','raw_root_interval','productive_fields','paid_calls')},sort_keys=True)) + + +if __name__ == '__main__': + main()