diff --git a/research/staged544-neutral-fixed-d2/.gitattributes b/research/staged544-neutral-fixed-d2/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/research/staged544-neutral-fixed-d2/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/research/staged544-neutral-fixed-d2/.gitignore b/research/staged544-neutral-fixed-d2/.gitignore new file mode 100644 index 0000000000..7a60b85e14 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/research/staged544-neutral-fixed-d2/CENSUS.json b/research/staged544-neutral-fixed-d2/CENSUS.json new file mode 100644 index 0000000000..b4a2b75cf4 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/CENSUS.json @@ -0,0 +1,1467 @@ +{ + "providers": { + "base": { + "combined_profiles": [ + { + "caps": [ + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 30164, + "delta": [ + 0, + -2, + 4, + -2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 46679, + "delta": [ + 0, + -1, + 1, + 1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 0, + 1, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 11892452, + "delta": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "caps": [ + 1, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 50534, + "delta": [ + 0, + 0, + 2, + 0, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 3, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "caps": [ + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 13467, + "delta": [ + 0, + 0, + 3, + -2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 2, + 4, + 2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 154323, + "delta": [ + 0, + 0, + 4, + 0, + -2, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 6, + 8, + 8, + 8, + 8, + 8, + 8 + ] + }, + { + "caps": [ + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 61205, + "delta": [ + 0, + 1, + 0, + 1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 2, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 266900, + "delta": [ + 0, + 1, + 1, + -1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 1, + 1, + -1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 17794, + "delta": [ + 0, + 1, + 2, + -3, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "caps": [ + 2, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 58339, + "delta": [ + 0, + 1, + 3, + -1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 5, + 6, + 6, + 6, + 6, + 6, + 6 + ] + }, + { + "caps": [ + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 13890, + "delta": [ + 0, + 2, + -2, + 1, + 1, + -1, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 1, + 2, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 2704, + "delta": [ + 0, + 2, + -2, + 2, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 26830, + "delta": [ + 0, + 2, + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "caps": [ + 2, + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 308646, + "delta": [ + 0, + 2, + 0, + 2, + -2, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 4, + 6, + 6, + 6, + 6, + 6, + 6 + ] + }, + { + "caps": [ + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 58339, + "delta": [ + 0, + 2, + 1, + 0, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 4, + 5, + 5, + 5, + 5, + 5, + 5 + ] + }, + { + "caps": [ + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 306486, + "delta": [ + 0, + 2, + 2, + -2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 4, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "caps": [ + 2, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 517, + "delta": [ + 0, + 3, + -1, + 1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 3, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "caps": [ + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 49730, + "delta": [ + 0, + 3, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 367008, + "delta": [ + 0, + 4, + -2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + } + ], + "combined_signed_types": 19, + "exact_dirty_blocks": 8034, + "first_counts": { + "by_A": 5314, + "by_B": 2499, + "by_restore": 221, + "crossed_AA": 6719, + "crossed_AS": 563, + "crossed_SA": 564, + "crossed_SS": 188, + "frame_rejected": 154, + "legal_first_records": 8034, + "scalar_legal_first_records": 8188 + }, + "price_counts": { + "block_add_prices": 9109630, + "first_words": 8034, + "outside_add_interior_cut_prices": 4616377, + "second_cut_dimensions": 13726007 + }, + "single_move_premise_cases": 1776295, + "whole_word_final_samples": 9, + "whole_word_first_samples": 9 + }, + "extra": { + "combined_profiles": [ + { + "caps": [ + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 30164, + "delta": [ + 0, + -2, + 4, + -2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 46679, + "delta": [ + 0, + -1, + 1, + 1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 0, + 1, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 11892452, + "delta": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + { + "caps": [ + 1, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 50534, + "delta": [ + 0, + 0, + 2, + 0, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 3, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "caps": [ + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 13467, + "delta": [ + 0, + 0, + 3, + -2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 2, + 4, + 2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 154323, + "delta": [ + 0, + 0, + 4, + 0, + -2, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 6, + 8, + 8, + 8, + 8, + 8, + 8 + ] + }, + { + "caps": [ + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 61205, + "delta": [ + 0, + 1, + 0, + 1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 2, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 266900, + "delta": [ + 0, + 1, + 1, + -1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 1, + 1, + -1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 17794, + "delta": [ + 0, + 1, + 2, + -3, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "caps": [ + 2, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 58339, + "delta": [ + 0, + 1, + 3, + -1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 5, + 6, + 6, + 6, + 6, + 6, + 6 + ] + }, + { + "caps": [ + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 13890, + "delta": [ + 0, + 2, + -2, + 1, + 1, + -1, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 1, + 2, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 2704, + "delta": [ + 0, + 2, + -2, + 2, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 2 + ] + }, + { + "caps": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 26830, + "delta": [ + 0, + 2, + -1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "caps": [ + 2, + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 308646, + "delta": [ + 0, + 2, + 0, + 2, + -2, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 4, + 6, + 6, + 6, + 6, + 6, + 6 + ] + }, + { + "caps": [ + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 58339, + "delta": [ + 0, + 2, + 1, + 0, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 4, + 5, + 5, + 5, + 5, + 5, + 5 + ] + }, + { + "caps": [ + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 306486, + "delta": [ + 0, + 2, + 2, + -2, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 4, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "caps": [ + 2, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 517, + "delta": [ + 0, + 3, + -1, + 1, + -1, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 3, + 4, + 4, + 4, + 4, + 4, + 4 + ] + }, + { + "caps": [ + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 49730, + "delta": [ + 0, + 3, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "caps": [ + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "certificate": true, + "count": 367008, + "delta": [ + 0, + 4, + -2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "prefixes": [ + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ] + } + ], + "combined_signed_types": 19, + "exact_dirty_blocks": 8034, + "first_counts": { + "by_A": 5314, + "by_B": 2499, + "by_restore": 221, + "crossed_AA": 6719, + "crossed_AS": 563, + "crossed_SA": 564, + "crossed_SS": 188, + "frame_rejected": 154, + "legal_first_records": 8034, + "scalar_legal_first_records": 8188 + }, + "price_counts": { + "block_add_prices": 9109630, + "first_words": 8034, + "outside_add_interior_cut_prices": 4616377, + "second_cut_dimensions": 13726007 + }, + "single_move_premise_cases": 1776295, + "whole_word_final_samples": 9, + "whole_word_first_samples": 9 + } + }, + "schema_version": 1, + "scope": "Neutral fixed-frame first ADD, displacement exactly two; arbitrary legal second ADD; fixed interfaces.", + "total_second_prices": 27452014 +} diff --git a/research/staged544-neutral-fixed-d2/LEDGER.json b/research/staged544-neutral-fixed-d2/LEDGER.json new file mode 100644 index 0000000000..16ccd09cc0 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/LEDGER.json @@ -0,0 +1,234 @@ +{ + "acceptance": "Scoped raw-moment obstruction; no new supplier, kappa or physical admission.", + "providers": { + "base": { + "added_gates_helpers_buffers": 0, + "all_combined_histograms_recorded": "pair_census.variable_frame.profiles", + "all_first_profiles": "Every first profile equals the baseline exactly; the deterministic full state stream is hashed in the receipt.", + "all_second_price_rank_masses": 5134, + "all_two_edit_scalar_height": { + "all_two_edit_denominator_bits_at_most": 11, + "all_two_edit_numerator_bits_at_most": 11, + "argument": "Each ADD conjugates only through existing corridor scales once; two selections of the same ADD telescope. All other coefficients and all native maps are unchanged.", + "corridors": 39, + "maximum_absolute_scale_exponent": 2, + "maximum_sum_absolute_scale_exponents_per_ADD_corridor": 7, + "status": "constructive finite upper bound, not a measured maximum or uniform all-size precision tariff" + }, + "baseline_local_profile": { + "1": 2440, + "2": 725, + "3": 224, + "4": 102, + "5": 20, + "8": 8 + }, + "dirty_buffers": 91, + "entrance_frames_sha256": "e82d4f3c4e35e6aaf384c90fc7cc3ed89ad939a7760ad5f06aff80a519c7353c", + "exit_frames_sha256": "ebd6650741d3b91cd4c0c7f4c5d5aa680094654768f3c0a0342864ab79c4e5dc", + "first_recursive_children_range": [ + 3519, + 3519 + ], + "first_scalar_coefficient_bound": { + "maximum_denominator_bits": 4, + "maximum_numerator_bits": 4 + }, + "helper_roles": 408, + "helper_width_inventory": { + "4": 26, + "5": 2, + "6": 18, + "7": 53, + "8": 96, + "9": 213 + }, + "inherited_outer_profile": { + "1": 7990332, + "2": 2349000, + "3": 748971, + "32": 1, + "4": 330480, + "48": 137911, + "5": 69479, + "8": 25920 + }, + "inherited_outer_profile_status": "Authenticated predecessor source only; no fresh outer reconstruction or admission.", + "initial_operator_corrections": 36, + "live_inputs": 632, + "local_status": "Proved finite chronological invoice and compositional dirty algebra under fixed word/frame contract.", + "native_warps": 72, + "new_supplier_or_kappa": false, + "physical_status": "Unknown/inherited obligations are explicitly listed; no physically admitted implementation is claimed.", + "primitive_inventory": { + "A": { + "add": 3557, + "scale": 498, + "warp": 24 + }, + "B": { + "add": 1796, + "scale": 73 + }, + "cleanup": { + "add": 4633, + "scale": 519, + "warp": 72 + }, + "compensation": { + "add": 5736 + }, + "cut": { + "add": 176 + }, + "precondition": { + "add": 136, + "scale": 56 + }, + "restore": { + "add": 196, + "scale": 16 + } + }, + "proved": [ + "Local chronological recursive invoices, fixed native maps/cuts and helper widths", + "Exact rational first-block equality for every admitted first move on arbitrary dirty inputs", + "Complete baseline free-operator replay and deterministic first/final replay controls", + "Recomputed inverse cleanup and full first-word resource inventories in sampled whole-word controls" + ], + "rank_mass": 5134, + "recursive_children": 3519, + "second_relaxed_recursive_children_range": [ + 3519, + 3521 + ], + "source_scalar_coefficient_bound": { + "maximum_denominator_bits": 4, + "maximum_numerator_bits": 4 + }, + "unknown": [ + "Fresh native Gaussian/Clifford realization and phase", + "Physical hosting/allocation and complete owner chronology", + "Uniform coefficient/precision/stock/tape costs", + "All-size compiler, outer/supplier admission", + "Analytic transfer and BIT H1-H5" + ], + "unknown_costs_are_zero": false + }, + "extra": { + "added_gates_helpers_buffers": 0, + "all_combined_histograms_recorded": "pair_census.variable_frame.profiles", + "all_first_profiles": "Every first profile equals the baseline exactly; the deterministic full state stream is hashed in the receipt.", + "all_second_price_rank_masses": 5134, + "all_two_edit_scalar_height": { + "all_two_edit_denominator_bits_at_most": 11, + "all_two_edit_numerator_bits_at_most": 11, + "argument": "Each ADD conjugates only through existing corridor scales once; two selections of the same ADD telescope. All other coefficients and all native maps are unchanged.", + "corridors": 39, + "maximum_absolute_scale_exponent": 2, + "maximum_sum_absolute_scale_exponents_per_ADD_corridor": 7, + "status": "constructive finite upper bound, not a measured maximum or uniform all-size precision tariff" + }, + "baseline_local_profile": { + "1": 2440, + "2": 725, + "3": 224, + "4": 102, + "5": 20, + "8": 8 + }, + "dirty_buffers": 91, + "entrance_frames_sha256": "e82d4f3c4e35e6aaf384c90fc7cc3ed89ad939a7760ad5f06aff80a519c7353c", + "exit_frames_sha256": "ebd6650741d3b91cd4c0c7f4c5d5aa680094654768f3c0a0342864ab79c4e5dc", + "first_recursive_children_range": [ + 3519, + 3519 + ], + "first_scalar_coefficient_bound": { + "maximum_denominator_bits": 4, + "maximum_numerator_bits": 4 + }, + "helper_roles": 408, + "helper_width_inventory": { + "4": 26, + "5": 2, + "6": 18, + "7": 53, + "8": 96, + "9": 213 + }, + "inherited_outer_profile": { + "1": 7990332, + "2": 2349000, + "3": 748971, + "32": 1, + "4": 330480, + "48": 137911, + "5": 69479, + "8": 25920 + }, + "inherited_outer_profile_status": "Authenticated predecessor source only; no fresh outer reconstruction or admission.", + "initial_operator_corrections": 36, + "live_inputs": 632, + "local_status": "Proved finite chronological invoice and compositional dirty algebra under fixed word/frame contract.", + "native_warps": 72, + "new_supplier_or_kappa": false, + "physical_status": "Unknown/inherited obligations are explicitly listed; no physically admitted implementation is claimed.", + "primitive_inventory": { + "A": { + "add": 3557, + "scale": 498, + "warp": 24 + }, + "B": { + "add": 1796, + "scale": 73 + }, + "cleanup": { + "add": 4633, + "scale": 519, + "warp": 72 + }, + "compensation": { + "add": 5736 + }, + "cut": { + "add": 176 + }, + "precondition": { + "add": 136, + "scale": 56 + }, + "restore": { + "add": 196, + "scale": 16 + } + }, + "proved": [ + "Local chronological recursive invoices, fixed native maps/cuts and helper widths", + "Exact rational first-block equality for every admitted first move on arbitrary dirty inputs", + "Complete baseline free-operator replay and deterministic first/final replay controls", + "Recomputed inverse cleanup and full first-word resource inventories in sampled whole-word controls" + ], + "rank_mass": 5134, + "recursive_children": 3519, + "second_relaxed_recursive_children_range": [ + 3519, + 3521 + ], + "source_scalar_coefficient_bound": { + "maximum_denominator_bits": 4, + "maximum_numerator_bits": 4 + }, + "unknown": [ + "Fresh native Gaussian/Clifford realization and phase", + "Physical hosting/allocation and complete owner chronology", + "Uniform coefficient/precision/stock/tape costs", + "All-size compiler, outer/supplier admission", + "Analytic transfer and BIT H1-H5" + ], + "unknown_costs_are_zero": false + } + }, + "schema_version": 1 +} diff --git a/research/staged544-neutral-fixed-d2/PROOF.md b/research/staged544-neutral-fixed-d2/PROOF.md new file mode 100644 index 0000000000..e05bee288a --- /dev/null +++ b/research/staged544-neutral-fixed-d2/PROOF.md @@ -0,0 +1,106 @@ +# Neutral fixed-frame displacement-two reduction + +The scope is the two immutable PR3734 words, with PR3886's scalar corridor, +sufficient ADD commutation rule, and exact nonzero SCALE conjugation. The first +ADD moves across **exactly two scalar neighbours**, retaining its binary frame; +the intermediate must satisfy all fixed entrance, cut, native-map and exit +checks. The second ADD can be any existing ADD, at any allowed scalar-corridor +cut and any common binary subspace. All other frames and interfaces are fixed. +No statement covers simultaneous rewrites with an illegal intermediate. + +## First-word admission and neutrality + +Write the affected three-instruction block as `g,h,k -> h,k,g` or its reverse. +For every crossed event sharing a register with g, baseline monotonicity puts +its frame after (or before) g's; reversed order puts it before (or after). +Containment in both directions requires equality of those two frames. Conversely, +these pairwise equalities preserve every register's ordered frame sequence up +to equal consecutive frames, while exclusive-register events only change their +chronological addresses. All source and destination block endpoints are the same. +Thus the equal-frame condition is necessary and sufficient for frame legality; +all first words have exactly the source invoice, including zero-rank omissions. +The exact incremental chronological tracer checks each changed block. An +independent direct event-itinerary oracle enumerates every first admission and +rejection; deterministic phase/direction/operation-pattern controls compare the +entire incremental trace and pricing geometry with fresh full reconstruction. SCALEs have frames and obey the same shared-register condition. + +The scalar move is exact because each crossed ADD satisfies the sufficient +commutation rule, and each crossed SCALE adjusts the moved coefficient by the +appropriate rational conjugation. An independent rational matrix on every +register touched by each three-instruction block verifies the actual before/after +blocks, using independent input symbols for arbitrary dirty state. Composition +with identical surrounding operators proves whole-word equality. The inverse +cleanup is rederived when constructing complete-word controls. + +## Why exactly two new insertion cuts suffice + +Let the block occupy positions `[l,l+3)`. Cover second moves as follows. + +1. If the second ADD is one of the ADDs in this block, explicitly enumerate + **all** its legal corridor cuts and every relaxed legal frame dimension. + This includes the first-moved ADD and both crossed ADDs, when present. +2. For a second ADD outside the block, explicitly enumerate its insertion at + the two cuts `l+1` and `l+2`, with every relaxed legal frame dimension. +3. Every other destination has an equal-price counterpart in the pinned + baseline single-move census. + +For (3), the outside ADD's original location and frame are unchanged. Removing +it has the same frame predecessors and successors, modulo events of identical +frame on a shared register inside the permuted block. Destinations at or outside +the block endpoints similarly see the same before/after register frames. The +insertion interval (join of preceding frames through intersection of following +frames) and every dimension price therefore agree. A move reaching across the +entire block encounters the same set of ADD/SCALE instructions, so sufficient +commutation eligibility is unchanged and scalar conjugation factors multiply to +the same rational value. A move that does not enter the block changes nothing +there. Other phases are untouched. Thus baseline non-improvement applies without +iterating a theorem on an altered baseline. + +For (2), the outside ADD's reach to the original block edge is unchanged. +The implementation checks the actual permuted instructions between that edge +and each interior cut. It then computes the new register frame neighbours and +insertion dimension prices. These are distinct cuts: checking just a single +middle cut, as for an adjacent pair, would omit a domain. + +## Frames, relaxed checks, and exact signs + +For a fixed removal/insertion cut, let `(p,q)` be the preceding and following +frames on each ADD register. The allowed common frame interval is their preceding +join through following intersection. Every dimension between its endpoint ranks +has a binary subspace, and its invoice depends only on that dimension. Pricing +all dimensions therefore covers all legal second frames, with no representative +orientation assumption. Fixed check boundaries are relaxed to virtual climbs as +in credited PR3886; every genuinely legal witness has zero such extra charge. + +The new-minus-old signed histogram has zero rank mass. For ranks 1 through 9, +let `c_k = sum_r delta_r min(r,k)`. The retained exact criterion checks every +prefix sum of `c_1,...,c_8` is nonnegative and `c_9=0`. Discrete summation by parts +against the positive decreasing curvatures of `r^a`, `0976, outside ADD989 target977. Fixed clipping to actual scalar segment. Corrected full generations restarted from zero.", + "status": "Interrupted before completion; no result claimed" + } + ], + "full_generations": [ + { + "command": [ + "python3", + "-B", + "research/staged544-neutral-fixed-d2/verify.py", + "--provider", + "base", + "--emit", + "EXTERNAL_RECEIPT" + ], + "elapsed_seconds": 311.28, + "exit": 0, + "log_sha256": "8311c3350a70c01194cc9c4b00fef9549d0b92a148ebdecf9497fa26a53cbc17", + "provider": "base", + "receipt": { + "first_counts": { + "by_A": 5314, + "by_B": 2499, + "by_restore": 221, + "crossed_AA": 6719, + "crossed_AS": 563, + "crossed_SA": 564, + "crossed_SS": 188, + "frame_rejected": 154, + "legal_first_records": 8034, + "scalar_legal_first_records": 8188 + }, + "new_supplier": false, + "provider": "base", + "result_sha256": "d41439ccbd0beb4c24e6e0d6b809e84f9e3f4b289f61baa7d8cb95f47cf79d68", + "status": "PASS_STAGED544_NEUTRAL_FIXED_D2" + }, + "timing_context": "Both provider generations ran concurrently on separately authenticated immutable inputs; elapsed is wall clock." + }, + { + "command": [ + "python3", + "-B", + "research/staged544-neutral-fixed-d2/verify.py", + "--provider", + "extra", + "--emit", + "EXTERNAL_RECEIPT" + ], + "elapsed_seconds": 308.28, + "exit": 0, + "log_sha256": "c1187b50600848a3c477b2dbf52e1fa75d50d8a5a2d613832bc0977bd6de5e3a", + "provider": "extra", + "receipt": { + "first_counts": { + "by_A": 5314, + "by_B": 2499, + "by_restore": 221, + "crossed_AA": 6719, + "crossed_AS": 563, + "crossed_SA": 564, + "crossed_SS": 188, + "frame_rejected": 154, + "legal_first_records": 8034, + "scalar_legal_first_records": 8188 + }, + "new_supplier": false, + "provider": "extra", + "result_sha256": "ef45d4b23af99e3996233a7d3fe86532039f6da773c393c8d5f14986f7928ea3", + "status": "PASS_STAGED544_NEUTRAL_FIXED_D2" + }, + "timing_context": "Both provider generations ran concurrently on separately authenticated immutable inputs; elapsed is wall clock." + } + ], + "publication_boundary": "This file records pre-publication science. After commit creation the exact public Git object, committed bytes, history gates, full registered replay and Git-free exported controls are checked and reported separately in the PR/handoff. This statement is not a claim those later steps already passed.", + "schema_version": 1, + "science_code_sha256": { + "check_controls.py": "78e2a79e11a47ce0f53ca0b61f0a6a224ed1238092d9f1301d2d752b01ae6d9f", + "dirty_blocks.py": "3e418073be52dc48dbf6a03ee7341040cd0b99555fc4002658a85cecd585c54b", + "reports.py": "4a184316c7a3d2da7bacd668592199e7b69fbb132d30c83f81f6c3d5af79cb34", + "search.py": "dd48b77541e0e7bdea104a33741ee6c65b501f674a5b2a300fadeb29d0368515", + "vendor/audit_core.py": "888679ca8502cdcb100420fe5382a052529a494bf76cb332928b86e62612b951", + "vendor/audit_verify.py": "99971d3cc143cc894600e08c8cfbad3e8f537a544212f21dfbe4271cfa97354d", + "vendor/pr3942_search.py": "94db5a29ed8fed594491b186f4b713213f32526fe67f666412f930cb324f4f51", + "vendor/pr3957_search.py": "826b8ec3ba7d478d5c9d328f15a64f68179ea67553716d98e8e01da762e5b398", + "vendor/pr3957_verify.py": "f2eb48dd6c0382b3adf53969544bb3ab8ab75e6135febfebd96db6b80a09c1ab", + "vendor/retiming.py": "591d7278541ac4de9e9b6fc1e17aba23b205ac4b6c81824a28fc08294658ef0d", + "verify.py": "1e599940f66ab935370c9ae5d4553054429e3ead942d82c62b3851ed229484a0" + }, + "selected_frontier_changed": false, + "status": "Both complete provider generations and independent normal/optimized controls pass. Exact committed-source and registered-replay status is reported on the publication PR after the GitHub-authored commit exists.", + "unrun_obligations": [ + "Independent human scientific review or formal-kernel proof", + "Fresh native Gaussian/Clifford phase reconstruction", + "Physical hosting/allocation and complete owner chronology", + "Uniform coefficient/precision/stock/tape costs", + "All-size compiler and complete outer/supplier admission", + "Analytic transfer and BIT" + ] +} diff --git a/research/staged544-neutral-fixed-d2/VERIFY.json b/research/staged544-neutral-fixed-d2/VERIFY.json new file mode 100644 index 0000000000..fb290f6982 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/VERIFY.json @@ -0,0 +1,41 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--provider", + "base" + ], + "timeout_seconds": 540, + "checks": "Authenticate immutable sources and regenerate complete single-move premise, all fixed-frame displacement-two first words, both interior cuts and all block ADD second prices; exact signs, dirty blocks, sampled complete words and full receipt equality." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--provider", + "extra" + ], + "timeout_seconds": 540, + "checks": "Independently regenerate the complete extra-provider census and dirty-state/ledger receipt with separately authenticated source." + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "{package}/check_controls.py" + ], + "timeout_seconds": 120, + "checks": "Independent all-first event itineraries, full trace/geometry and unoptimized two-cut reach comparisons, baseline counterpart prices, omitted-gap production mutation, source/scalar/frame/cleanup/barrier rejections, credited positive control and source-bound summaries." + } + ] +} diff --git a/research/staged544-neutral-fixed-d2/check_controls.py b/research/staged544-neutral-fixed-d2/check_controls.py new file mode 100644 index 0000000000..2739d3a26f --- /dev/null +++ b/research/staged544-neutral-fixed-d2/check_controls.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Independent event-order oracle, reduction coverage and adversarial controls.""" +from collections import Counter +from copy import deepcopy +from fractions import Fraction +import json,types +from pathlib import Path +P=Path(__file__).resolve().parent +V=types.ModuleType('entry');V.__file__=str(P/'verify.py');exec(compile((P/'verify.py').read_bytes(),V.__file__,'exec'),V.__dict__) +S,C,A=V.setup();R=S.R;D=V.module('blocks',P/'dirty_blocks.py');checks=Counter() +def need(ok,why): + if not ok:raise ValueError(why) +def rejects(fn,label): + try:fn() + except (ValueError,C.AuditFailure):checks[label]+=1;return + raise ValueError('mutation accepted: '+label) +def independent_sign(delta): + caps=[sum(n*min(r,k) for r,n in enumerate(delta)) for k in range(1,10)] + prefixes=[sum(caps[:j]) for j in range(1,9)] + return sum(r*n for r,n in enumerate(delta))==0 and all(x>=0 for x in prefixes),caps,prefixes +row=json.loads((P/'SOURCES.json').read_text())['snapshots'][0] +rejects(lambda:V.authenticate((P/row['local']).read_bytes()+b'x',row),'source_corruption') +for tag in ('base','extra'): + word=V.load(tag);variable,counts,_=S.first_moves(word);original_hash=S.digest(word) + nodes,where,bill=R.tracing(word);expected=set();rejected=0 + # Independent direct monotone event itinerary after literal block permutation. + # No primary first-frame equality filter or first price routine is used. + for sec in S.PHASES: + gates=word[sec] + for a,b in R.segments(word,sec): + for i in range(a,b): + g=gates[i] + if g[0]!='add':continue + for cut in (i-2,i+3): + if not a<=cut<=b:continue + crossed=gates[i+1:cut] if cut>i else gates[cut:i] + if not all((g[1]!=h[2] and h[1]!=g[2]) if h[0]=='add' else (h[0]=='scale' and h[2]!=0) for h in crossed):continue + lo,hi=min(i,cut),max(i+1,cut) + old=gates[lo:hi];new=(old[1:]+old[:1]) if cut>i else (old[-1:]+old[:-1]) + regs=set(r for h in old for r in (h[1:3] if h[0]=='add' else h[1:2])) + valid=True;delta=Counter() + for r in regs: + positions=[j for j in range(lo,hi) if r in (gates[j][1:3] if gates[j][0]=='add' else gates[j][1:2])] + start=nodes[r][where[((sec,positions[0]),r)]][2] + end=nodes[r][where[((sec,positions[-1]),r)]+1][3] + for sign,sequence in ((-1,old),(1,new)): + before=start + for h in sequence: + if r not in (h[1:3] if h[0]=='add' else h[1:2]):continue + frame=R.span(tuple(h[-1])) + if before&~frame:valid=False;break + d=frame.bit_count().bit_length()-before.bit_count().bit_length() + if d:delta[d]+=sign + before=frame + if before&~end:valid=False + if valid: + d=end.bit_count().bit_length()-before.bit_count().bit_length() + if d:delta[d]+=sign + if valid: + need(not any(delta.values()),'independent first not neutral') + expected.add((sec,i,cut,R.span(tuple(g[-1])))) + else:rejected+=1 + actual={(sec,i,cut,frame) for sec,i,cut,frame,delta,_ in variable} + need(actual==expected and rejected==counts['frame_rejected'],'independent first admission differs') + checks['independent_first_records']+=len(expected);checks['independent_rejections']+=rejected + # Select every phase, direction and crossed operation pattern present. + chosen={} + for ordinal,v in enumerate(variable): + sec,i,cut,frame,delta,_=v;lo,hi=min(i,cut),max(i+1,cut) + pattern=''.join(g[0][0] for g in word[sec][lo:hi]) + chosen.setdefault((sec,cut>i,pattern),ordinal) + for ordinal in sorted(set(chosen.values())): + sec,i,cut,frame,delta,_=variable[ordinal];lo,hi=min(i,cut),max(i+1,cut) + middle=S.first_apply(word,sec,i,cut) + retained=R.apply_move(word,sec,i,cut,word[sec][i][-1]) + need(middle==retained and S.digest(word)==original_hash,'persistent-copy source equality') + checks['persistent_copy_full_word_equality']+=1 + trace=R.tracing(middle);need(C.frame_bill(middle)[0]==bill==trace[2],'independent full frame invoice') + inc=S.first_trace(word,middle,(nodes,where,bill),sec,i,cut) + need(inc==trace,'incremental full trace mismatch') + geometry=S.first_geometry(word,middle,list(S.geometry(word,sec,(nodes,where,bill))),inc,sec,i,cut) + need(geometry==list(S.geometry(middle,sec,trace)),'incremental full geometry mismatch') + checks['incremental_trace_and_geometry']+=1 + # Exact reach, frame intervals and prices at both interior gaps, without + # the optimized original-bound/partial-block reach selection. + outside=[j for j,g in enumerate(middle[sec]) if g[0]=='add' and not lo<=j=lo and all(R.crosses(g,h) for h in middle[sec][lo:target])) if jbad['counts']['second_cut_dimensions'],'second-gap omission not detected') + checks['production_second_gap_omission']+=1 + # Exact semantic failure controls; derive fresh cleanup for wrong scalar. + sec,i,cut,frame,_,_=variable[0];middle=R.apply_move(word,sec,i,cut,R.basis(frame));moved=cut-(cut>i) + middle['cleanup']=C.derive_cleanup(middle);middle['report']['local_profile']={str(r):n for r,n in bill.items()} + A.semantics(C,middle);checks['full_dirty_control_words']+=1 + bad=deepcopy(middle);bad[sec][moved][3]*=-1;bad['cleanup']=C.derive_cleanup(bad) + rejects(lambda:A.semantics(C,bad),'wrong_scalar_fresh_cleanup') + bad=deepcopy(middle);bad['cleanup']=[] + rejects(lambda:A.semantics(C,bad),'omitted_cleanup_arbitrary_dirty') + bad=deepcopy(middle);ns,ad,_=R.tracing(bad) + phase,j=next((phase,j) for phase in S.PHASES for j,g in enumerate(bad[phase]) if g[0]=='add' and any(ns[r][ad[((phase,j),r)]][2]!=1 for r in R.touched(g))) + bad[phase][j][-1]=[];rejects(lambda:C.frame_bill(bad),'illegal_frame') + j=next(j for j in range(word['prelude_events'],len(word['A'])-1) if word['A'][j][0]=='add' and not R.crosses(word['A'][j],word['A'][j+1])) + rejects(lambda:R.apply_move(word,'A',j,j+2,word['A'][j][-1]),'noncommuting_barrier') + # Credited retained Jeremy Kothe PR2957 rollback/recovery positive fixture. + oldword=deepcopy(word);g,h=oldword['A'][4043:4045] + oldword['A'][4043:4045]=[h[:-1]+[g[-1]],g];oldword['cleanup']=C.derive_cleanup(oldword) + before,widths,*_=C.frame_bill(oldword);oldword['report']['local_profile']={str(r):n for r,n in before.items()} + recovered=R.apply_move(oldword,'A',4043,4045,h[-1]);recovered['A'][4044][-1]=deepcopy(h[-1]);recovered['cleanup']=C.derive_cleanup(recovered) + after,widths2,*_=C.frame_bill(recovered);recovered['report']['local_profile']={str(r):n for r,n in after.items()} + need(recovered==word and widths==widths2,'credited positive source recovery') + delta=tuple(after.get(r,0)-before.get(r,0) if r else 0 for r in range(10)) + need(delta==(0,1,-1,-1,1,0,0,0,0,0) and not independent_sign(delta)[0],'credited positive sign') + A.semantics(C,oldword);A.semantics(C,recovered);checks['credited_positive_dirty_words']+=2 + receipt=P/('RESULT-'+tag+'.json') + need(receipt.is_file(),'missing committed full provider receipt') + if receipt.exists(): + for row in json.loads(receipt.read_text())['pair_census']['variable_frame']['profiles']: + ok,caps,prefixes=independent_sign(row['delta']) + need(ok and caps==row['caps'] and prefixes==row['prefixes'] and row['certificate'],'independent result sign') + checks['independent_result_signs']+=1 +for c in (Fraction(-3,2),Fraction(1,4)): + for q in (Fraction(-2),Fraction(1,2)): + for r in range(3): + for right in (False,True): + add=['add',0,1,c.numerator,c.denominator,[]];scale=['scale',r,q.numerator,q.denominator,[]];other=['add',2,1,1,1,[]] + gates=[add,scale,other] if right else [other,scale,add] + toy={'A':gates,'B':[],'restore':[],'prelude_events':0,'warps':[]} + changed=R.apply_move(toy,'A',0 if right else 2,3 if right else 0,[]) + D.block_equal(gates,changed['A']);checks['scale_three_gate_matrices']+=1 +H=V.module('summary_reports',P/'reports.py');census,ledger=H.summaries(P,S) +need(census==json.loads((P/'CENSUS.json').read_text()) and V.normal(ledger)==json.loads((P/'LEDGER.json').read_text()),'source-bound summaries mismatch') +checks['source_bound_census_and_ledger']+=1 +print(json.dumps({'status':'PASS_NEUTRAL_FIXED_D2_CONTROLS','checks':dict(sorted(checks.items())),'new_supplier':False},sort_keys=True)) diff --git a/research/staged544-neutral-fixed-d2/dirty_blocks.py b/research/staged544-neutral-fixed-d2/dirty_blocks.py new file mode 100644 index 0000000000..72cc62fa4d --- /dev/null +++ b/research/staged544-neutral-fixed-d2/dirty_blocks.py @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Exact dirty scalar blocks, adapted from PR3941; retained auditors are separate.""" +from fractions import Fraction as Q +import hashlib,json + +def need(ok,why): + if not ok:raise ValueError(why) + +def object_hash(x): + return hashlib.sha256(json.dumps(x,sort_keys=True,separators=(',',':')).encode()).hexdigest() + +def block_matrix(gates,registers=None): + """Own rational scalar-block check, independent of retained interpreters. + + Every input row is an independent symbol, so equality is on all dirty states. + Frames are checked separately; native gates are forbidden in this block. + """ + if registers is None:registers=sorted({r for g in gates for r in (g[1:3] if g[0]=='add' else g[1:2])}) + rows={r:{r:Q(1)} for r in registers} + for g in gates: + if g[0]=='scale': + q=Q(g[2],g[3]);need(q!=0,'zero scalar') + rows[g[1]]={k:v*q for k,v in rows[g[1]].items()} + else: + need(g[0]=='add' and g[1]!=g[2],'non-scalar block or self ADD') + q=Q(g[3],g[4]);need(q!=0,'zero ADD') + for k,v in rows[g[2]].items(): + z=rows[g[1]].get(k,0)+q*v + if z:rows[g[1]][k]=z + else:rows[g[1]].pop(k,None) + return [[str(rows[r].get(c,0)) for c in registers] for r in registers] + +def block_equal(before,after): + regs=sorted({r for g in before+after for r in (g[1:3] if g[0]=='add' else g[1:2])}) + b,a=block_matrix(before,regs),block_matrix(after,regs) + need(a==b,'arbitrary-dirty scalar block differs') + return {'registers':regs,'matrix_sha256':object_hash(a)} + +def first_block(w,new,rec): + lo=min(rec['index'],rec['cut']);hi=max(rec['index']+1,rec['cut']) + return block_equal(w[rec['section']][lo:hi],new[rec['section']][lo:hi]) + diff --git a/research/staged544-neutral-fixed-d2/inputs/BORROW-WORD-43base.json.gz b/research/staged544-neutral-fixed-d2/inputs/BORROW-WORD-43base.json.gz new file mode 100644 index 0000000000..674ea18ade Binary files /dev/null and b/research/staged544-neutral-fixed-d2/inputs/BORROW-WORD-43base.json.gz differ diff --git a/research/staged544-neutral-fixed-d2/inputs/BORROW-WORD-43extra.json.gz b/research/staged544-neutral-fixed-d2/inputs/BORROW-WORD-43extra.json.gz new file mode 100644 index 0000000000..b17e2be67e Binary files /dev/null and b/research/staged544-neutral-fixed-d2/inputs/BORROW-WORD-43extra.json.gz differ diff --git a/research/staged544-neutral-fixed-d2/inputs/PROFILE.json b/research/staged544-neutral-fixed-d2/inputs/PROFILE.json new file mode 100644 index 0000000000..d1000454af --- /dev/null +++ b/research/staged544-neutral-fixed-d2/inputs/PROFILE.json @@ -0,0 +1,10 @@ +{ + "1": 7990332, + "2": 2349000, + "3": 748971, + "4": 330480, + "5": 69479, + "8": 25920, + "32": 1, + "48": 137911 +} diff --git a/research/staged544-neutral-fixed-d2/inputs/SINGLE-CENSUS.json b/research/staged544-neutral-fixed-d2/inputs/SINGLE-CENSUS.json new file mode 100644 index 0000000000..c9db55a477 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/inputs/SINGLE-CENSUS.json @@ -0,0 +1 @@ +{"base":{"candidates":1776295,"deltas":[{"caps":[0,2,0,0,0,0,0,0,0],"certificate":true,"count":5404,"delta":{"1":-2,"2":4,"3":-2}},{"caps":[0,1,1,0,0,0,0,0,0],"certificate":true,"count":8908,"delta":{"1":-1,"2":1,"3":1,"4":-1}},{"caps":[0,0,0,0,0,0,0,0,0],"certificate":true,"count":1536697,"delta":{}},{"caps":[1,2,1,0,0,0,0,0,0],"certificate":true,"count":9311,"delta":{"2":2,"4":-1}},{"caps":[1,2,0,0,0,0,0,0,0],"certificate":true,"count":2498,"delta":{"2":3,"3":-2}},{"caps":[2,4,2,0,0,0,0,0,0],"certificate":true,"count":18680,"delta":{"2":4,"4":-2}},{"caps":[1,1,1,0,0,0,0,0,0],"certificate":true,"count":7458,"delta":{"1":1,"3":1,"4":-1}},{"caps":[1,1,0,0,0,0,0,0,0],"certificate":true,"count":31273,"delta":{"1":1,"2":1,"3":-1}},{"caps":[1,1,-1,0,0,0,0,0,0],"certificate":true,"count":2755,"delta":{"1":1,"2":2,"3":-3,"4":1}},{"caps":[2,3,1,0,0,0,0,0,0],"certificate":true,"count":7120,"delta":{"1":1,"2":3,"3":-1,"4":-1}},{"caps":[1,0,1,1,0,0,0,0,0],"certificate":true,"count":1630,"delta":{"1":2,"2":-2,"3":1,"4":1,"5":-1}},{"caps":[1,0,1,0,0,0,0,0,0],"certificate":true,"count":294,"delta":{"1":2,"2":-2,"3":2,"4":-1}},{"caps":[1,0,0,0,0,0,0,0,0],"certificate":true,"count":3762,"delta":{"1":2,"2":-1}},{"caps":[2,2,2,0,0,0,0,0,0],"certificate":true,"count":37360,"delta":{"1":2,"3":2,"4":-2}},{"caps":[2,2,1,0,0,0,0,0,0],"certificate":true,"count":7120,"delta":{"1":2,"2":1,"4":-1}},{"caps":[2,2,0,0,0,0,0,0,0],"certificate":true,"count":40432,"delta":{"1":2,"2":2,"3":-2}},{"caps":[2,1,1,0,0,0,0,0,0],"certificate":true,"count":84,"delta":{"1":3,"2":-1,"3":1,"4":-1}},{"caps":[2,1,0,0,0,0,0,0,0],"certificate":true,"count":5695,"delta":{"1":3,"3":-1}},{"caps":[2,0,0,0,0,0,0,0,0],"certificate":true,"count":49814,"delta":{"1":4,"2":-2}}],"per_section":{"A":1451231,"B":308890,"restore":16174},"source_profile":{"1":2440,"2":725,"3":224,"4":102,"5":20,"8":8}},"extra":{"candidates":1776295,"deltas":[{"caps":[0,2,0,0,0,0,0,0,0],"certificate":true,"count":5404,"delta":{"1":-2,"2":4,"3":-2}},{"caps":[0,1,1,0,0,0,0,0,0],"certificate":true,"count":8908,"delta":{"1":-1,"2":1,"3":1,"4":-1}},{"caps":[0,0,0,0,0,0,0,0,0],"certificate":true,"count":1536697,"delta":{}},{"caps":[1,2,1,0,0,0,0,0,0],"certificate":true,"count":9311,"delta":{"2":2,"4":-1}},{"caps":[1,2,0,0,0,0,0,0,0],"certificate":true,"count":2498,"delta":{"2":3,"3":-2}},{"caps":[2,4,2,0,0,0,0,0,0],"certificate":true,"count":18680,"delta":{"2":4,"4":-2}},{"caps":[1,1,1,0,0,0,0,0,0],"certificate":true,"count":7458,"delta":{"1":1,"3":1,"4":-1}},{"caps":[1,1,0,0,0,0,0,0,0],"certificate":true,"count":31273,"delta":{"1":1,"2":1,"3":-1}},{"caps":[1,1,-1,0,0,0,0,0,0],"certificate":true,"count":2755,"delta":{"1":1,"2":2,"3":-3,"4":1}},{"caps":[2,3,1,0,0,0,0,0,0],"certificate":true,"count":7120,"delta":{"1":1,"2":3,"3":-1,"4":-1}},{"caps":[1,0,1,1,0,0,0,0,0],"certificate":true,"count":1630,"delta":{"1":2,"2":-2,"3":1,"4":1,"5":-1}},{"caps":[1,0,1,0,0,0,0,0,0],"certificate":true,"count":294,"delta":{"1":2,"2":-2,"3":2,"4":-1}},{"caps":[1,0,0,0,0,0,0,0,0],"certificate":true,"count":3762,"delta":{"1":2,"2":-1}},{"caps":[2,2,2,0,0,0,0,0,0],"certificate":true,"count":37360,"delta":{"1":2,"3":2,"4":-2}},{"caps":[2,2,1,0,0,0,0,0,0],"certificate":true,"count":7120,"delta":{"1":2,"2":1,"4":-1}},{"caps":[2,2,0,0,0,0,0,0,0],"certificate":true,"count":40432,"delta":{"1":2,"2":2,"3":-2}},{"caps":[2,1,1,0,0,0,0,0,0],"certificate":true,"count":84,"delta":{"1":3,"2":-1,"3":1,"4":-1}},{"caps":[2,1,0,0,0,0,0,0,0],"certificate":true,"count":5695,"delta":{"1":3,"3":-1}},{"caps":[2,0,0,0,0,0,0,0,0],"certificate":true,"count":49814,"delta":{"1":4,"2":-2}}],"per_section":{"A":1451231,"B":308890,"restore":16174},"source_profile":{"1":2440,"2":725,"3":224,"4":102,"5":20,"8":8}}} diff --git a/research/staged544-neutral-fixed-d2/reports.py b/research/staged544-neutral-fixed-d2/reports.py new file mode 100644 index 0000000000..6a6f3192b2 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/reports.py @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Construct source-bound census/ledger summaries; ordinary use is read-only.""" +from collections import Counter +from fractions import Fraction +import gzip,json +from pathlib import Path + +def scale_height_bound(S,word): + # Any retimed ADD crosses each SCALE in its unchanged native corridor at + # most once. For two different ADDs this applies separately; selecting the + # same ADD twice telescopes to a single original move (PR3942 reduction). + maximum=0;max_scale=0;corridors=0 + for sec in S.PHASES: + gates=word[sec] + for lo,hi in S.R.segments(word,sec): + corridors+=1;by_register=Counter() + for g in gates[lo:hi]: + if g[0]=='scale': + q=Fraction(g[2],g[3]);num,den=abs(q.numerator),q.denominator + if not num or num&(num-1) or den<=0 or den&(den-1):raise ValueError('non-dyadic power scale') + exponent=(num.bit_length()-1)-(den.bit_length()-1) + by_register[g[1]]+=abs(exponent);max_scale=max(max_scale,abs(exponent)) + for g in gates[lo:hi]: + if g[0]=='add':maximum=max(maximum,by_register[g[1]]+by_register[g[2]]) + adds=[g for sec in S.PHASES for g in word[sec] if g[0]=='add'] + nb=max(abs(g[3]).bit_length() for g in adds);db=max(g[4].bit_length() for g in adds) + return {'status':'constructive finite upper bound, not a measured maximum or uniform all-size precision tariff', + 'corridors':corridors,'maximum_absolute_scale_exponent':max_scale, + 'maximum_sum_absolute_scale_exponents_per_ADD_corridor':maximum, + 'all_two_edit_numerator_bits_at_most':nb+maximum, + 'all_two_edit_denominator_bits_at_most':db+maximum, + 'argument':'Each ADD conjugates only through existing corridor scales once; two selections of the same ADD telescope. All other coefficients and all native maps are unchanged.'} + +def summaries(P,S): + census={'schema_version':1,'scope':'Neutral fixed-frame first ADD, displacement exactly two; arbitrary legal second ADD; fixed interfaces.','providers':{}} + ledger={'schema_version':1,'acceptance':'Scoped raw-moment obstruction; no new supplier, kappa or physical admission.','providers':{}} + for tag in ('base','extra'): + r=json.loads((P/('RESULT-'+tag+'.json')).read_text());c=r['pair_census'];v=c['variable_frame'] + if sum(x['count'] for x in v['profiles'])!=v['counts']['second_cut_dimensions']:raise ValueError('combined price count') + if v['counts']['first_words']!=c['first_counts']['legal_first_records']:raise ValueError('legal first inventory') + if not all(x['certificate'] for x in v['profiles']):raise ValueError('unresolved sign') + census['providers'][tag]={'first_counts':c['first_counts'],'price_counts':v['counts'], + 'combined_signed_types':len(v['profiles']),'exact_dirty_blocks':v['dirty_block_checks'], + 'whole_word_first_samples':len(c['dirty_validation']['whole_word_samples']), + 'whole_word_final_samples':len(c['dirty_validation']['whole_word_samples']), + 'single_move_premise_cases':r['single_move_candidates'],'combined_profiles':v['profiles']} + word=json.loads(gzip.decompress((P/'inputs'/('BORROW-WORD-43'+tag+'.json.gz')).read_bytes())) + ledger['providers'][tag]={**c['ledger'],'all_two_edit_scalar_height':scale_height_bound(S,word), + 'inherited_outer_profile':json.loads((P/'inputs/PROFILE.json').read_text()), + 'inherited_outer_profile_status':'Authenticated predecessor source only; no fresh outer reconstruction or admission.', + 'second_relaxed_recursive_children_range':[min(c['ledger']['recursive_children']+sum(x['delta']) for x in v['profiles']),max(c['ledger']['recursive_children']+sum(x['delta']) for x in v['profiles'])], + 'all_second_price_rank_masses':c['ledger']['rank_mass'], + 'local_status':'Proved finite chronological invoice and compositional dirty algebra under fixed word/frame contract.', + 'physical_status':'Unknown/inherited obligations are explicitly listed; no physically admitted implementation is claimed.'} + census['total_second_prices']=sum(x['price_counts']['second_cut_dimensions'] for x in census['providers'].values()) + return census,ledger diff --git a/research/staged544-neutral-fixed-d2/search.py b/research/staged544-neutral-fixed-d2/search.py new file mode 100644 index 0000000000..8de87e7687 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/search.py @@ -0,0 +1,294 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Neutral fixed-frame first ADD at displacement exactly two, unrestricted second ADD. + +Chris R / Clear1nsight, with substantial OpenAI assistance. The pinned +PR3886 trace, applier and sign criterion are reused, not independently authored. +Adapted from PR3942 with its retained source. The interaction reduction is reused. +""" +from bisect import bisect_left +from collections import Counter +from functools import lru_cache +import hashlib +import json +from pathlib import Path +import types + +P = Path(__file__).resolve().parent + +def module(name, path): + value = types.ModuleType(name) + value.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), value.__dict__) + return value + +# The entry point authenticates these bytes before loading this module. +R = module('pinned_retiming', P / 'vendor/retiming.py') +PHASES = ('A', 'B', 'restore') +ZERO = (0,) * 10 +R.all_power_nonnegative = lru_cache(maxsize=None)(R.all_power_nonnegative) + +def require(ok, message): + if not ok: + raise ValueError(message) + +def digest(value): + return hashlib.sha256(json.dumps(value, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + +def rows(histogram): + result = [] + for delta, count in sorted(histogram.items()): + caps = R.caps(delta) + prefixes = [sum(caps[:j]) for j in range(1, 9)] + require(sum(r*n for r,n in enumerate(delta))==0,'histogram rank mass') + result.append({'delta': list(delta), 'count': count, 'caps': caps, + 'prefixes': prefixes, 'certificate': R.all_power_nonnegative(delta)}) + return result + +def geometry(word, section, trace=None): + nodes, where, bill = R.tracing(word) if trace is None else trace + gates = word[section] + for lo, hi in R.segments(word, section): + occurrences = {} + for i in range(lo, hi): + for r in R.touched(gates[i]): + occurrences.setdefault(r, []).append(i) + entries, exits, removal = {}, {}, {} + for r, indices in occurrences.items(): + entries[r] = nodes[r][where[((section, indices[0]), r)]][2] + exits[r] = nodes[r][where[((section, indices[-1]), r)] + 1][3] + for i in range(lo, hi): + if gates[i][0] != 'add': + continue + delta = [0] * 10 + for r in R.touched(gates[i]): + seq = nodes[r] + pos = where[((section, i), r)] + _, _, before, frame = seq[pos] + require(seq[pos + 1][1] != 'map', 'missing map-entry check') + after = seq[pos + 1][3] + delta[R.rank(frame) - R.rank(before)] -= 1 + delta[R.rank(after) - R.rank(frame)] -= 1 + delta[R.rank(after) - R.rank(before)] += 1 + removal[i] = delta + yield lo, hi, occurrences, entries, exits, removal + +def candidates(word, section, selected, first=False, window=None, trace=None, trusted=False, prepared=None): + """Exact prices in the predecessor's fixed-check relaxation. + + First moves use cuts i-2 and i+3, hence final displacement exactly two. + For second moves all permitted corridor cuts and all frame dimensions occur. + """ + gates = word[section] + for lo, hi, occurrences, entries, exits, removal in (geometry(word, section, trace) if prepared is None else prepared): + for i in selected: + if not lo <= i < hi or gates[i][0] != 'add': + continue + gate = gates[i] + lower, upper = i, i + 1 + if trusted: + require(window is not None, 'trusted reach requires window') + lower, upper = max(lo, window[0]), min(hi, window[1]) + else: + while lower > lo and R.crosses(gate, gates[lower - 1]): + lower -= 1 + while upper < hi and R.crosses(gate, gates[upper]): + upper += 1 + if window is not None: + lower, upper = max(lower, window[0]), min(upper, window[1]) + cuts = [c for c in (i - 2, i + 3) if lower <= c <= upper] if first else range(lower, upper + 1) + reduced = {r: [x for x in occurrences[r] if x != i] for r in R.touched(gate)} + for cut in cuts: + if cut == i + 1: + continue + bounds = [] + for r in R.touched(gate): + indices = reduced[r] + j = bisect_left(indices, cut) + before = R.span(tuple(gates[indices[j - 1]][-1])) if j else entries[r] + after = R.span(tuple(gates[indices[j]][-1])) if j < len(indices) else exits[r] + bounds.append((before, after)) + low = R.join(bounds[0][0], bounds[1][0]) + high = bounds[0][1] & bounds[1][1] + if not R.contained(low, high): + continue + for dimension in range(R.rank(low), R.rank(high) + 1): + delta = removal[i].copy() + for before, after in bounds: + p, q = R.rank(before), R.rank(after) + delta[q - p] -= 1 + delta[dimension - p] += 1 + delta[q - dimension] += 1 + delta[0] = 0 + require(sum(r * n for r, n in enumerate(delta)) == 0, 'rank mass drift') + yield i, cut, dimension, low, high, tuple(delta) + +@lru_cache(maxsize=None) +def frames(low, high, dimension): + """All intermediate subspaces, not one representative per dimension.""" + require(R.contained(low, high), 'empty frame interval') + require(R.rank(low) <= dimension <= R.rank(high), 'invalid frame dimension') + require(R.rank(high) - R.rank(low) <= 4, 'first-frame resource bound exceeded') + current = {low} + for _ in range(dimension - R.rank(low)): + expanded = set() + for frame in current: + for v in range(1, 512): + if high >> v & 1 and not frame >> v & 1: + expanded.add(R.join(frame, R.span((v,)))) + current = expanded + return tuple(sorted(current)) + +def first_moves(word, auditor=None): + records, counts = [], Counter() + for section in PHASES: + gates=word[section] + for lo,hi in R.segments(word,section): + for i in range(lo,hi): + g=gates[i] + if g[0]!='add':continue + for cut in (i-2,i+3): + if not lo<=cut<=hi:continue + crossed=gates[i+1:cut] if cut>i else gates[cut:i] + if not all(R.crosses(g,h) for h in crossed):continue + counts['scalar_legal_first_records']+=1 + frame=R.span(tuple(g[-1])) + # The source and final sequences are monotone. Every event + # sharing a register with the moved gate changes order with + # it, hence their frames must agree in both orders. + if any(set(R.touched(g))&set(R.touched(h)) and frame!=R.span(tuple(h[-1])) for h in crossed): + counts['frame_rejected']+=1;continue + counts['legal_first_records']+=1 + counts['by_'+section]+=1 + counts['crossed_'+''.join(h[0][0].upper() for h in crossed)]+=1 + records.append((section,i,cut,frame,ZERO,'neutral_fixed_displacement_two')) + return records,counts,set() + +def corridor_bounds(word): + result={} + for sec in PHASES: + gates=word[sec] + for lo,hi in R.segments(word,sec): + for i in range(lo,hi): + g=gates[i] + if g[0]!='add':continue + a,b=i,i+1 + while a>lo and R.crosses(g,gates[a-1]):a-=1 + while bi else word[section][cut:i] + for h in crossed: + if h[0]=='scale' and h[1] in R.touched(g): + power=(1 if h[1]==g[1] else -1)*(1 if cut>i else -1) + coeff*=Fraction(h[2],h[3])**power + g[3:5]=[coeff.numerator,coeff.denominator] + g[-1]=list(R.basis(R.span(tuple(g[-1])))) + new=word.copy();new[section]=word[section].copy() + new[section].pop(i);new[section].insert(cut-(cut>i),g) + return new + +def first_trace(word,middle,baseline,section,i,cut): + """Reindex just the three changed events, checking local containment.""" + old_nodes,old_where,bill=baseline + nodes=old_nodes.copy();where=old_where.copy() + lo,hi=min(i,cut),max(i+1,cut) + regs={r for g in word[section][lo:hi] for r in R.touched(g)} + for r in regs: + old_positions=[j for j in range(lo,hi) if r in R.touched(word[section][j])] + positions=[old_where[((section,j),r)] for j in old_positions] + for j in old_positions:del where[((section,j),r)] + sequence=old_nodes[r].copy();before=sequence[positions[0]][2] + new_positions=[j for j in range(lo,hi) if r in R.touched(middle[section][j])] + require(len(positions)==len(new_positions),'event inventory drift') + for pos,j in zip(positions,new_positions): + frame=R.span(tuple(middle[section][j][-1])) + require(R.contained(before,frame),'incremental frame containment') + sequence[pos]=((section,j),'climb',before,frame) + where[((section,j),r)]=pos;before=frame + require(before==old_nodes[r][positions[-1]][3],'block final frame drift') + nodes[r]=sequence + return nodes,where,bill + +def first_geometry(word,middle,baseline_geometry,trace,section,i,cut): + """Transport baseline event positions; recompute removals in the block.""" + lo,hi=min(i,cut),max(i+1,cut);nodes,where,_=trace + out=[] + for a,b,occ,entry,exit,removal in baseline_geometry: + if not a<=i=lo and all(R.crosses(g,h) for h in middle[section][lo:target]) + else: + legal=a<=hi and all(R.crosses(g,h) for h in middle[section][target:hi]) + if legal:outside.append(j) + for j,t,d,L,H,delta in candidates(middle,section,outside,window=(target,target),trace=trace,trusted=True,prepared=prepared): + local[delta]+=1;class_counts['outside_add_interior_cut_prices']+=1 + if not R.all_power_nonnegative(delta):witnesses.setdefault(delta,[section,i,cut,j,t,d,L,H]) + histogram.update(local);counts.update(class_counts);counts['first_words']+=1 + states.append({'first':[section,i,cut,list(R.basis(frame)),list(first_delta)], + 'profile':baseline,'prices':dict(class_counts),'second_cut_dimensions':sum(local.values()), + 'second_histogram_sha256':digest(sorted((list(d),n) for d,n in local.items()))}) + if progress and (number%100==0 or number+1==len(variable)): + print('FIRST_AND_SECOND',number+1,'of',len(variable),'counts',dict(counts),flush=True) + counts['second_cut_dimensions']=sum(histogram.values()) + return {'counts':dict(counts),'profiles':rows(histogram),'states':states, + 'dirty_block_checks':len(blocks),'dirty_block_stream_sha256':digest(blocks), + 'boundary_rejected':[],'uncertified_witnesses':list(witnesses.values())} + +def compute(word,auditor=None,progress=False): + variable,counts,_=first_moves(word,auditor) + if progress:print('FIRST_DOMAIN',dict(counts),flush=True) + return {'first_counts':dict(sorted(counts.items())), + 'first_digest':digest([[s,i,c,list(R.basis(f)),list(d),k] for s,i,c,f,d,k in variable]), + 'variable_frame':variable_census(word,variable,auditor,progress)} diff --git a/research/staged544-neutral-fixed-d2/vendor/SOURCE-CREDITS.md b/research/staged544-neutral-fixed-d2/vendor/SOURCE-CREDITS.md new file mode 100644 index 0000000000..c054fad87e --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/SOURCE-CREDITS.md @@ -0,0 +1,14 @@ +# Source credit and independence + +New work: dataisfire with substantial OpenAI Codex assistance, Apache-2.0. No independent human review, fresh third-party AI review or proof-kernel verification is claimed. + +The construction extends [PR3682](https://github.com/CrocSwap/integer-mult-bounds/pull/3682), head431e6c6023ef352c41696469de7fb614cd4ded8c. Its retimed word, actual T360 source clock and immutable native/parent framework are retained. The complete new source/receipt snapshot is bound by REPLAY-INPUTS.json. The new ordinary source stage is an explicit pinned record applied after the unchanged predecessor reconstruction. + +- [PR3605](https://github.com/CrocSwap/integer-mult-bounds/pull/3605), Ross Richardson, supplies the staged-entrance mechanism, literal cleanup and exact Gaussian residual-check pattern. staged_pair.py is retained; the new544 shear and its proof are separate. +- [PR3638](https://github.com/CrocSwap/integer-mult-bounds/pull/3638), head d62e1acd7518a231440383f0d0dddf54d6edf8c1, supplies the T360 source-window clock, chronological aggregate model and integral-network/literal construction, with its retained PR3605 and earlier credits. The new inventory, integer incumbent and literal fill are recomputed. No predecessor owner receipt is used as proof of the new fill. +- [PR3687](https://github.com/CrocSwap/integer-mult-bounds/pull/3687) and [PR3693](https://github.com/CrocSwap/integer-mult-bounds/pull/3693), Sagar Thakrar and roger-sato with their credited AI assistance, supply audit_core.py and the whole-word semantics adapter audit_verify.py. These bytes are retained and reused. They are independent of the current constructor in the stated interpreter scope, not a newly written independent audit or new reviewer approval. +- The coupled-word source lineage includes PR3133, PR2979, Marius-Paul Dumitrean, dcharb78, Jeremy Kothe and the retained native/owner/block-norm/outer authors. All notices and scientific engines inside the source snapshot remain intact. + +owner_audit.py is a standalone standard-library adaptation of the source-window/family/prefix/invoice predicates in PR3638's independent_literal.py. It imports no producer, optimizer or retained owner checker. Its source template, plan and actual native canonical words are authenticated inputs. Three controls mutate actual literal roles and must fail for the intended reason. It shares the credited contract interpretation; it is not evidence of independent human agreement. + +The rational finite-price enclosure is retained from the PR3682 sources. New script adapters bind it to the actual finite histogram. Native forward/backward scalar replay, wrapper/phase lowering and all-column warp recipes were freshly run for both new words; unchanged native and parent ancestry is explicitly reused. The separate new544 span(414,51) residual check includes global Gaussian phase. diff --git a/research/staged544-neutral-fixed-d2/vendor/audit_core.py b/research/staged544-neutral-fixed-d2/vendor/audit_core.py new file mode 100644 index 0000000000..8b5e1d5f2a --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/audit_core.py @@ -0,0 +1,480 @@ +"""Independent exact semantics and binary-frame bill for the BORROW-WORD format. + +Standard library only. Nothing is imported from the audited authors' code +(PR3133/PR3605 producers, cleanup generator, evaluator or frame solver); the word +format and its semantic contract were read from those pinned sources and are +credited there. The frame-bill and free-word structure (point-set spans, warp +frame and lifted-frame checks, target levels keyed by register, dual symbol +naming) re-implements, without importing, Arham Tahir's +research/coupled-carrier-independent-audit/verify.py (Apache-2.0) and shares its +reading of the contract, so this module is not independent of that audit. + +Sagar Thakrar (thakrarsagar), with substantial AI assistance from Claude +(Anthropic, Claude Opus 5.5). Apache-2.0. +""" +from collections import Counter +from fractions import Fraction as Q + +V, N, H = 112, 704, 9 # sources 0..111, targets 112..223, helpers 224..703 +DUAL = 10 ** 6 # offset naming the independent dual symbols D_k = K_k^(-T) + + +class AuditFailure(Exception): + """Explicit failure; never disabled by python -O.""" + + +def need(ok, *why): + if not ok: + raise AuditFailure(' '.join(map(str, why))) + + +def is_target(r): + return V <= r < 2 * V + + +def touched(g): + return g[1:3] if g[0] == 'add' else g[1:2] + + +# ---------------------------------------------------------------------------- +# Binary frames: a subspace of F_2^9 is stored as a 512-bit point-set mask +# (bit x set iff x lies in the subspace). Containment is mask inclusion. +# ---------------------------------------------------------------------------- +_SPAN = {} + + +def span(vectors): + key = tuple(vectors) + mask = _SPAN.get(key) + if mask is None: + points = {0} + for u in key: + need(type(u) is int and 0 <= u < 512, 'frame vector out of range', u) + if u not in points: + points |= {p ^ u for p in points} + mask = sum(1 << p for p in points) + _SPAN[key] = mask + return mask + + +def points(mask): + return [x for x in range(512) if mask >> x & 1] + + +def dim(mask): + size = bin(mask).count('1') + need(size and size & (size - 1) == 0, 'not a subspace point set') + return size.bit_length() - 1 + + +FULL = (1 << 512) - 1 +ZERO = 1 + + +def hyperplane(port): + return sum(1 << x for x in range(512) if bin(x & port).count('1') % 2 == 0) + + +def warp_images(columns): + """Images of all 512 vectors under the F_2-linear map with columns G e_i.""" + need(len(columns) == H and all(type(c) is int and 0 <= c < 512 for c in columns), 'warp columns') + images = [0] * 512 + for x in range(1, 512): + low = x & -x + images[x] = images[x ^ low] ^ columns[low.bit_length() - 1] + need(len(set(images)) == 512, 'singular warp') + return images + + +def image_mask(images, mask): + return sum(1 << images[x] for x in points(mask)) + + +def lagrangian_action_ok(images, U, E): + """K_G(x,z)=(Gx, Gx+G^{-T}(x+z)) is symplectic and maps L_U to L_E, L_0 and L_FULL to themselves. + + L_U={(x,x+p): x in U, p in U^perp}. This is the binary frame action only; it + is not a Clifford phase or Gaussian-product certificate. For invertible G with + G(U)=E it is implied by the frame-map check ( = ), so it is a + consistency check of the implementation, not extra evidence. + """ + inverse = [0] * 512 + for x, y in enumerate(images): + inverse[y] = x + # G^{-T} z: bit j of the result is . + git = lambda z: sum((bin(inverse[1 << j] & z).count('1') & 1) << j for j in range(H)) + lift = lambda x, z: (images[x], images[x] ^ git(x ^ z)) + pair = lambda a, b: (bin(a[0] & b[1]).count('1') + bin(a[1] & b[0]).count('1')) & 1 + basis = [(1 << i, 0) for i in range(H)] + [(0, 1 << i) for i in range(H)] + lifted = [lift(*b) for b in basis] + if any(pair(lifted[i], lifted[j]) != pair(basis[i], basis[j]) for i in range(18) for j in range(i + 1, 18)): + return False + + def frame(mask): + us = points(mask) + perp = [p for p in range(512) if all(bin(p & u).count('1') % 2 == 0 for u in us)] + return {(u, u ^ p) for u in us for p in perp} + return all({lift(*pt) for pt in frame(a)} == frame(b) for a, b in ((ZERO, ZERO), (FULL, FULL), (U, E))) + + +# ---------------------------------------------------------------------------- +# Chronological binary-frame bill (BORROW-WORD contract) +# ---------------------------------------------------------------------------- +def frame_bill(w, lagrangian=False): + rep = w['report'] + need((rep['v'], 2 * rep['v'] + rep['R'], rep['h']) == (V, N, H), 'word geometry') + removed = set(w['removed']) + need(len(removed) == len(w['removed']) and all(2 * V <= r < N for r in removed), 'removed helpers') + live = [r for r in range(N) if r not in removed] + liveset = set(live) + B, warps = w['B'], w['warps'] + for k, (pos, lender, cols, U, E) in enumerate(warps, 1): + need(0 <= pos <= len(B), 'warp position', k) + need(lender in liveset and not is_target(lender), 'warp lender', k) + images = warp_images(cols) + su, se = span(U), span(E) + need(dim(su) == len(U) == len(E) == dim(se), 'warp frame bases', k) + need(image_mask(images, su) == se, 'warp does not map its frame', k) + if lagrangian: + need(lagrangian_action_ok(images, su, se), 'lifted frame action', k) + for name in ('A', 'B', 'restore'): + for g in w[name]: + if g[0] != 'warp': + need(all(r in liveset for r in touched(g)), 'removed/out-of-range register', name, g) + if g[0] == 'add' and not is_target(g[1]): + need(not is_target(g[2]), 'non-target reads a target', name, g) + need(all(g[-1] is None and is_target(g[1]) and g[0] == 'add' for g in w['cut']), 'cut gates') + need(all(g[-1] == [] and is_target(g[1]) for g in w['precondition'] + w['compensation']), 'zero-frame wrapper writes') + need(all(not is_target(g[1]) for g in w['restore']), 'restore writes a target') + + ports = w['ports'] + start, end = {}, {} + for r in live: + if r < V: + start[r], end[r] = span((ports[r],)), FULL + elif r < 2 * V: + start[r], end[r] = ZERO, hyperplane(ports[r - V]) + else: + start[r], end[r] = ZERO, FULL + for q, U in w['start_extra'].items(): + need(int(q) in liveset and int(q) >= 2 * V, 'entrance names a live helper', q) + start[int(q)] = span(U) + for q, U in w['helper_final'].items(): + need(int(q) in liveset and int(q) >= 2 * V, 'terminal names a live helper', q) + end[int(q)] = span(U) + + current, bill, chain = dict(start), Counter(), {} + + def climb(r, mask, where): + need(current[r] & ~mask == 0, 'frame containment fails', where, r) + d = dim(mask) - dim(current[r]) + if d: + bill[d] += 1 + chain.setdefault(r, []).append((where, d, mask)) + current[r] = mask + + npre = w['prelude_events'] + for i, g in enumerate(w['A']): + if g[0] == 'warp': + need(i < npre and len(g) == 5, 'warp outside the prelude', i) + _, r, op, fr, to = g + need(op != 0 and abs(op) <= len(warps) and warps[abs(op) - 1][1] == r, 'prelude warp lender', i) + images = warp_images(warps[abs(op) - 1][2]) + if op < 0: + inverse = [0] * 512 + for x, y in enumerate(images): + inverse[y] = x + images = inverse + need(image_mask(images, span(fr)) == span(to), 'prelude warp frame action', i) + need(current[r] == span(fr), 'prelude warp entry frame', i, r) + current[r] = span(to) + chain.setdefault(r, []).append((('A', i), 'warp', span(to))) + else: + if i < npre: + need(is_target(g[1]), 'prelude scalar writes a non-target', i) + for r in touched(g): + climb(r, span(g[-1]), ('A', i)) + levels = {V + int(t): span(U) for t, U in w['target_levels'].items()} + need(all(current[t] == levels.get(t, ZERO) for t in range(V, 2 * V)), 'target cut levels') + for q, U in zip(w['centers'], w['center_frames']): + U = span(U) + need(current[q] == U, 'centre entry frame', q) + served = {levels.get(g[1], ZERO) for g in w['cut'] if g[2] == q} + for T in sorted(served, key=lambda m: -dim(m)): + need(T & ~U == 0, 'centre descent not nested', q) + d = dim(U) - dim(T) + if d: + bill[d] += 1 + chain.setdefault(q, []).append((('centre',), d, T)) + U = T + at = {} + for k, rec in enumerate(warps, 1): + at.setdefault(rec[0], []).append(k) + for p in range(len(B) + 1): + for k in at.get(p, ()): + _, lender, _, U, E = warps[k - 1] + need(current[lender] == span(U), 'native warp entry frame', k, lender) + current[lender] = span(E) + chain.setdefault(lender, []).append((('warp', k), 'warp', span(E))) + if p < len(B): + for r in touched(B[p]): + climb(r, span(B[p][-1]), ('B', p)) + for i, g in enumerate(w['restore']): + for r in touched(g): + climb(r, span(g[-1]), ('restore', i)) + for r in live: + climb(r, end[r], ('end',)) + restored = set(map(int, w['helper_final'])) + need(all(end[r] == FULL for r in live if r not in restored and not is_target(r)), 'a FULL-cleanup register ends low') + widths = Counter(dim(end[r]) - dim(start[r]) for r in live if r >= 2 * V) + return dict(sorted(bill.items())), dict(sorted(widths.items())), chain, start, end + + +def hygiene(w): + """Inherited structural contract: dyadic scalars, power-of-two scales, wrapper and correction access.""" + entering = set(map(int, w['start_extra'])) + restored = set(map(int, w['helper_final'])) + live = set(range(N)) - set(w['removed']) + for name in ('precondition', 'compensation', 'A', 'cut', 'B', 'restore', 'cleanup'): + for g in w[name]: + if g[0] == 'warp': + continue + q = Q(g[3], g[4]) if g[0] == 'add' else Q(g[2], g[3]) + need(q != 0 and q.denominator & (q.denominator - 1) == 0, 'non-dyadic scalar', name, g) + if g[0] == 'scale': + need(abs(q.numerator) & (abs(q.numerator) - 1) == 0, 'non power-of-two scale', name, g) + for g in w['precondition'] + w['compensation']: + need(not any(r in entering | restored for r in touched(g)), 'wrapper touches an entering or restored helper', g) + for c in w['initial_corrections']: + word = c['operator_word'] + need(is_target(c['target']) and c['source'] in live and c['source'] >= 2 * V + and c['source'] not in entering, 'correction access', c) + need(word and all(w['warps'][abs(o) - 1][1] == c['source'] for o in word), 'correction operator lender', c) + q = Q(c['coefficient']) + need(q != 0 and q.denominator & (q.denominator - 1) == 0, 'correction coefficient', c) + return True + + +# ---------------------------------------------------------------------------- +# Literal inverse cleanup, derived from the contract +# ---------------------------------------------------------------------------- +def ordinary_forward(w): + """Chronological non-wrapper actions whose inverse forms cleanup.""" + out = [g for g in w['A'][w['prelude_events']:]] + at = {} + for k, rec in enumerate(w['warps'], 1): + at.setdefault(rec[0], []).append(['warp', rec[1], k]) + for p in range(len(w['B']) + 1): + out += at.get(p, []) + if p < len(w['B']): + out.append(w['B'][p]) + return out + list(w['restore']) + + +def derive_cleanup(w): + restored = set(map(int, w['helper_final'])) + buf = lambda r: r + N if r in restored else r + full = [256, 128, 64, 32, 16, 8, 4, 2, 1] + out = [] + for g in reversed(ordinary_forward(w)): + if g[0] == 'warp': + out.append(['warp', buf(g[1]), -g[2], full]) + elif is_target(g[1]): + continue + elif g[0] == 'add': + out.append(['add', buf(g[1]), buf(g[2]), -g[3], g[4], full]) + else: + need(g[0] == 'scale', 'unknown primitive', g) + out.append(['scale', buf(g[1]), g[3], g[2], full]) + return out + + +def same_cleanup(a, b): + norm = lambda c: [(g[:-1], span(g[-1])) for g in c] + return len(a) == len(b) and norm(a) == norm(b) + + +# ---------------------------------------------------------------------------- +# Exact free-operator semantics. A value is a dict {(input, word): Fraction}; +# word is a reduced tuple of signed operator ids (leftmost = applied last). +# ---------------------------------------------------------------------------- +def program(w, cleanup=None): + """Literal executed sequence: corrections, wrapper, A, cut, B+warps, restore | cleanup.""" + items = [('corr', c['target'], c['source'], tuple(c['operator_word']), Q(c['coefficient'])) + for c in w['initial_corrections']] + items += w['precondition'] + w['compensation'] + w['A'] + w['cut'] + at = {} + for k, rec in enumerate(w['warps'], 1): + at.setdefault(rec[0], []).append(['warp', rec[1], k]) + for p in range(len(w['B']) + 1): + items += at.get(p, []) + if p < len(w['B']): + items.append(w['B'][p]) + items += w['restore'] + return items, list(w['cleanup'] if cleanup is None else cleanup) + + +def dual_op(op): + return (1 if op > 0 else -1) * (abs(op) + DUAL) + + +def _left(op, word): + return word[1:] if word and word[0] == -op else (op,) + word + + +def _right(word, op): + return word[:-1] if word and word[-1] == -op else word + (op,) + + +def _axpy(dst, src, q): + for key, x in src.items(): + y = dst.get(key, 0) + q * x + if y: + dst[key] = y + else: + dst.pop(key, None) + + +def forward_rows(w, cleanup=None, dual=False, symbolic_buffers=True, snapshot=None): + """Schrodinger pass: every register's value as a combination of initial inputs. + + Live inputs are independent symbols. Private buffers are independent symbols + when symbolic_buffers is set (dirty), otherwise zero. The optional snapshot + callback sees the rows at the cleanup boundary. + """ + removed = set(w['removed']) + live = [r for r in range(N) if r not in removed] + restored = sorted(map(int, w['helper_final'])) + rows = {r: {(r, ()): Q(1)} for r in live} + for c in restored: + rows[c + N] = {(c + N, ()): Q(1)} if symbolic_buffers else {} + prefix, tail = program(w, cleanup) + + def apply(g): + kind = g[0] + if kind == 'add': + t, s, q = g[1], g[2], Q(g[3], g[4]) + need(t != s and q, 'add gate', g) + if dual: + t, s, q = s, t, -q + _axpy(rows[t], rows[s], q) + elif kind == 'scale': + q = Q(g[2], g[3]) + need(q != 0, 'zero scale', g) + if dual: + q = 1 / q + rows[g[1]] = {k: q * x for k, x in rows[g[1]].items()} + elif kind == 'warp': + op = dual_op(g[2]) if dual else g[2] + rows[g[1]] = {(var, _left(op, word)): x for (var, word), x in rows[g[1]].items()} + elif kind == 'corr': + _, t, s, word, c = g + if dual: + src, ops, dst, c = rows[t], [-dual_op(o) for o in word], s, -c + else: + src, ops, dst = rows[s], list(reversed(word)), t + moved = {} + for (var, wd), x in src.items(): + for o in ops: + wd = _left(o, wd) + moved[var, wd] = x + _axpy(rows[dst], moved, c) + else: + raise AuditFailure('unknown primitive ' + repr(g)) + + for g in prefix: + apply(g) + if snapshot is not None: + snapshot(rows) + for g in tail: + apply(g) + return rows + + +def reverse_columns(w, cleanup=None, upto_cleanup=False): + """Heisenberg pull-back: process the forward program backwards. + + cols[s] = {(output, word): coefficient}: the final output register 'output' + contains coefficient*word*x_s. Words grow on the right. Every live input and + every private buffer is an independent symbol. + """ + removed = set(w['removed']) + live = [r for r in range(N) if r not in removed] + restored = sorted(map(int, w['helper_final'])) + regs = live + [c + N for c in restored] + cols = {r: {(r, ()): Q(1)} for r in regs} + prefix, tail = program(w, cleanup) + seq = prefix if upto_cleanup else prefix + tail + for g in reversed(seq): + kind = g[0] + if kind == 'add': + t, s, q = g[1], g[2], Q(g[3], g[4]) + need(t != s and q, 'add gate', g) + _axpy(cols[s], cols[t], q) + elif kind == 'scale': + q = Q(g[2], g[3]) + need(q != 0, 'zero scale', g) + cols[g[1]] = {k: q * x for k, x in cols[g[1]].items()} + elif kind == 'warp': + op = g[2] + cols[g[1]] = {(out, _right(word, op)): x for (out, word), x in cols[g[1]].items()} + elif kind == 'corr': + _, t, s, word, c = g + moved = {} + for (out, wd), x in cols[t].items(): + for o in word: + wd = _right(wd, o) + moved[out, wd] = x + _axpy(cols[s], moved, c) + else: + raise AuditFailure('unknown primitive ' + repr(g)) + return cols + + +def transpose(cols): + rows = {} + for s, col in cols.items(): + for (r, word), x in col.items(): + rows.setdefault(r, {})[s, word] = x + return rows + + +def endpoint_defects(w, rows, dual=False): + """Compare final rows with the contract on the zero-buffer (live-input) domain. + + Returns (bad live registers, dirty buffers, buffer->live leaks, buffer self-map identity). + """ + removed = set(w['removed']) + live = [r for r in range(N) if r not in removed] + restored = sorted(map(int, w['helper_final'])) + bad = [] + for r in live: + expect = {(r, ()): Q(1)} + if dual and r < V: + expect[r + V, ()] = Q(-1) + if not dual and is_target(r): + expect[r - V, ()] = Q(1) + got = {k: x for k, x in rows.get(r, {}).items() if k[0] < N} + if got != expect: + bad.append(r) + dirty = [c for c in restored if any(k[0] < N for k in rows.get(c + N, {}))] + leaks = sorted({r for r in live for k in rows.get(r, {}) if k[0] >= N}) + buffer_identity = all({k: x for k, x in rows.get(c + N, {}).items() if k[0] >= N} == {(c + N, ()): Q(1)} + for c in restored) + return bad, dirty, leaks, buffer_identity + + +def boundary_defects(w, rows): + """Contract at the cleanup boundary (forward): targets sheared, restored helpers clean and isolated.""" + restored = set(map(int, w['helper_final'])) + out = [] + for t in range(V, 2 * V): + if {k: x for k, x in rows[t].items() if k[0] < N} != {(t, ()): Q(1), (t - V, ()): Q(1)}: + out.append(('target', t)) + for c in restored: + if rows[c] != {(c, ()): Q(1)}: + out.append(('restored', c)) + for r, row in rows.items(): + if r < N and r not in restored and any(k[0] in restored for k in row): + out.append(('restored input read', r)) + return out diff --git a/research/staged544-neutral-fixed-d2/vendor/audit_verify.py b/research/staged544-neutral-fixed-d2/vendor/audit_verify.py new file mode 100644 index 0000000000..7f9fc1df42 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/audit_verify.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 +"""Whole-word cross-check of published RETIMED and DELAYED supplier words. + +Reuses Sagar Thakrar's exact PR3687 audit_core, unchanged and authenticated +before execution. This is not a new interpreter. No construction/native checker +is imported. roger-sato with substantial OpenAI Codex assistance; Apache-2.0. +""" +from collections import Counter +from copy import deepcopy +import gzip +import hashlib +import json +from pathlib import Path +import sys +import types + +HERE = Path(__file__).resolve().parent +STAGED = {1: 2439, 2: 726, 3: 224, 4: 102, 5: 20, 8: 8} +RETIMED = {1: 2437, 2: 724, 3: 226, 4: 102, 5: 20, 8: 8} +WIDTHS = {4: 26, 5: 2, 6: 18, 7: 52, 8: 97, 9: 213} +MOVES = ((591, 1045, 640, 644, 2, [423, 65, 20, 10]), + (641, 1085, 656, 660, -1, [427, 96, 24, 6])) +SOURCE_COMMITS = { + 3605: '3efbb5de06a49ffeea6684482f2d3fe48cdca3fb', + 3642: '044d24f12e74f228dd462c07ae2d7f3ea35e2be9', + 3653: '607a09ff441c79b215a8127a81f4cc70021d0d9b', + 3682: '431e6c6023ef352c41696469de7fb614cd4ded8c', + 3687: 'f798838eb8ede4178e94f240e7b7e54b3f80c82d', +} + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def authenticate(): + rows = json.loads((HERE / 'SOURCES.json').read_text())['snapshots'] + expected = {(3687, 'vendor/audit_core.py')} + for provider in ('base', 'extra'): + expected.update((number, f'inputs/{kind}-{provider}.json.gz') for number, kind in + ((3605, 'STAGED'), (3642, 'RETIMED'), (3653, 'RETIMED'), (3682, 'DELAYED'))) + keys = [(row['source_pr'], row['local']) for row in rows] + need(len(keys) == len(expected) and set(keys) == expected, 'source mapping inventory differs') + for row in rows: + need(row['source_commit'] == SOURCE_COMMITS[row['source_pr']], 'source commit differs') + raw = (HERE / row['local']).read_bytes() + need(len(raw) == row['bytes'], 'source byte length: ' + row['local']) + need(hashlib.sha256(raw).hexdigest() == row['sha256'], 'source SHA256: ' + row['local']) + blob = hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() + need(blob == row['git_blob'], 'source Git blob: ' + row['local']) + core = types.ModuleType('retained_audit_core') + path = HERE / 'vendor/audit_core.py' + # Execute the authenticated source bytes, without accepting a .pyc cache. + exec(compile(path.read_bytes(), str(path), 'exec'), core.__dict__) + return core + + +def load(kind, provider): + return json.loads(gzip.decompress((HERE / 'inputs' / f'{kind}-{provider}.json.gz').read_bytes())) + + +def events(w): + result = [] + for pos in range(len(w['B']) + 1): + result += [('warp', k, deepcopy(rec)) for k, rec in enumerate(w['warps']) if rec[0] == pos] + if pos < len(w['B']): + result.append(('gate', pos, deepcopy(w['B'][pos]))) + return result + + +def replace_events(w, seq): + result = deepcopy(w) + body, warps = [], [None] * len(w['warps']) + for kind, label, gate in seq: + gate = deepcopy(gate) + if kind == 'gate': + body.append(gate) + else: + gate[0] = len(body) + warps[label] = gate + need(all(rec is not None for rec in warps), 'lost warp in reconstruction') + result['B'], result['warps'] = body, warps + return result + + +def reconstruct(C, staged, kind): + """Literal prose recipes: adjacent shear swap, or move before first producer. + + This repeats the credited local structural arguments as an input control; + the new evidence is the full word calculation below. + """ + seq = events(staged) + for start, stop, donor, pivot, coefficient, frame in MOVES: + source = next(x for x in seq if x[:2] == ('gate', start)) + need(source[2] == ['add', donor, pivot, coefficient, 1, [429, 30]], 'source release') + if kind == 'RETIMED': + target = next(x for x in seq if x[:2] == ('gate', start + 1)) + need(target[2][0] == 'add' and target[2][2] == pivot, 'adjacent same-pivot shear') + need(not any(rec[0] == start + 1 for rec in staged['warps']), 'unexpected crossed warp') + where = seq.index(target) + 1 + else: + target = next(x for x in seq if x[:2] == ('gate', stop)) + writes = [i for i, g in enumerate(staged['B']) if i > start and g[1] == pivot] + need(writes[0] == stop, 'first producer cut') + where = seq.index(target) + changed = deepcopy(source[2]) + changed[-1] = frame + seq.insert(where, ('gate', -pivot, changed)) + seq.remove(source) + result = replace_events(staged, seq) + result['cleanup'] = C.derive_cleanup(result) + result['report']['local_profile'] = {str(k): v for k, v in RETIMED.items()} + return result + + +def semantics(C, w): + """All live and buffer inputs are symbols, with no zero-buffer assumption.""" + def endpoint(name, result): + bad_live, dirty_buffers, leaks, buffer_identity = result + need(not bad_live and not dirty_buffers and not leaks and buffer_identity, + name + ' endpoint: ' + repr(result)) + boundary = {} + rows = C.forward_rows(w, symbolic_buffers=True, + snapshot=lambda values: boundary.setdefault('defects', C.boundary_defects(w, values))) + endpoint('forward', C.endpoint_defects(w, rows)) + dual_rows = C.forward_rows(w, dual=True, symbolic_buffers=True) + endpoint('dual', C.endpoint_defects(w, dual_rows, dual=True)) + need(not boundary['defects'], 'cleanup boundary: ' + repr(boundary['defects'])) + pulled = C.transpose(C.reverse_columns(w)) + need(pulled == {r: row for r, row in rows.items() if row}, 'reverse pull-back differs from forward') + pre = C.transpose(C.reverse_columns(w, upto_cleanup=True)) + pre = {r: pre.get(r, {}) for r in set(pre) | set(range(C.N))} + need(not C.boundary_defects(w, pre), 'reverse cleanup-boundary contract') + live = C.N - len(w['removed']) + buffers = len(w['helper_final']) + need((live, buffers, len(rows)) == (632, 91, 723), 'complete symbolic domain') + # Endpoint expectations are derived by the retained checker: live x,y,h + # map to x,y+x,h; all private buffer symbols return unchanged. + return {'live_inputs': live, 'dirty_buffers': buffers, 'matrix_dimension': len(rows), + 'forward': 'PASS', 'dual': 'PASS', 'reverse_pullback_equals_forward': True, + 'cleanup_boundary_forward_and_reverse': 'PASS', + 'buffer_to_live_leaks': 0, 'buffer_self_map': 'identity', + 'nonzero_endpoint_terms': sum(len(row) for row in rows.values())} + + +def inspect(C, w, profile): + C.hygiene(w) + bill, widths, chain, _, _ = C.frame_bill(w) + need(bill == profile, 'computed profile differs') + need(w['report']['local_profile'] == {str(k): v for k, v in bill.items()}, 'declared profile differs') + need(widths == WIDTHS, 'helper widths differ') + need(w['cleanup'] == C.derive_cleanup(w), 'literal cleanup differs') + return {'semantics': semantics(C, w), 'profile': bill, 'widths': widths, + 'rank_mass': sum(r * n for r, n in bill.items())}, chain + + +def expect_rejection(C, fn, phrase): + try: + fn() + except (ValueError, C.AuditFailure) as exc: + need(phrase in str(exc), 'wrong rejection: ' + str(exc)) + return phrase + raise ValueError('mutant unexpectedly passed: ' + phrase) + + +def negative_controls(C, staged, w, kind): + controls = [] + for _, _, donor, pivot, _, _ in MOVES: + seq = events(w) + release = next(x for x in seq if x[0] == 'gate' and x[2][0] == 'add' and x[2][1:3] == [donor, pivot]) + for defect in ('omit', 'flip', 'cross_first_producer'): + changed = deepcopy(seq) + index = seq.index(release) + if defect == 'omit': + changed.pop(index) + elif defect == 'flip': + changed[index][2][3] *= -1 + else: + producer = next(x for x in changed[index + 1:] if x[0] == 'gate' and x[2][1] == pivot) + moved = changed.pop(index) + changed.insert(changed.index(producer) + 1, moved) + bad = replace_events(w, changed) + bad['cleanup'] = C.derive_cleanup(bad) + # Repair the literal inverse so stale cleanup is not the rejection. + reason = expect_rejection(C, lambda: semantics(C, bad), 'forward endpoint') + controls.append({'defect': defect, 'pivot': pivot, 'rejected_by': reason}) + old_cleanup = deepcopy(w) + old_cleanup['cleanup'] = staged['cleanup'] + # The inverse shears commute: this is a format failure, not a wrong operator. + semantic_control = semantics(C, old_cleanup) + need(old_cleanup['cleanup'] != C.derive_cleanup(old_cleanup), 'old cleanup unexpectedly literal') + controls.append({'defect': 'old_cleanup_order', 'semantics': semantic_control, + 'rejected_by': expect_rejection(C, lambda: inspect(C, old_cleanup, RETIMED), 'literal cleanup differs')}) + old_frames = deepcopy(w) + for gate in old_frames['B']: + if gate[0] == 'add' and gate[1:3] in ([640, 644], [656, 660]): + gate[-1] = [429, 30] + need(semantics(C, old_frames) == semantic_control, 'frame-only mutation changed operator') + if kind == 'RETIMED': + need(C.frame_bill(old_frames)[0] == STAGED, 'old frame control does not restore staged bill') + controls.append({'defect': 'old_release_frames', 'semantic_operator': 'PASS', + 'profile': STAGED, 'rejected_by': expect_rejection(C, lambda: inspect(C, old_frames, RETIMED), 'computed profile differs')}) + else: + # The later release encounters a donor that has already climbed, so + # the original rank-2 frame is now illegal, despite the same operator. + controls.append({'defect': 'old_release_frames', 'semantic_operator': 'PASS', + 'rejected_by': expect_rejection(C, lambda: inspect(C, old_frames, RETIMED), 'frame containment fails')}) + fake_report = deepcopy(w) + fake_report['report']['local_profile']['1'] += 1 + controls.append({'defect': 'wrong_declared_profile', 'rejected_by': + expect_rejection(C, lambda: inspect(C, fake_report, RETIMED), 'declared profile differs')}) + return controls + + +def run(C): + results = {} + for provider in ('base', 'extra'): + staged = load('STAGED', provider) + control, old_chain = inspect(C, staged, STAGED) + records = {'STAGED': control} + for kind in ('RETIMED', 'DELAYED'): + w = load(kind, provider) + need(reconstruct(C, staged, kind) == w, 'prose reconstruction differs: ' + kind) + record, chain = inspect(C, w, RETIMED) + deltas = {} + for register in set(chain) | set(old_chain): + before = Counter(d for _, d, _ in old_chain.get(register, []) if type(d) is int and d > 0) + after = Counter(d for _, d, _ in chain.get(register, []) if type(d) is int and d > 0) + delta = {r: after[r] - before[r] for r in set(after) | set(before) if after[r] != before[r]} + if delta: + deltas[register] = delta + need(deltas == {640: {1: -1, 2: -1, 3: 1}, 656: {1: -1, 2: -1, 3: 1}}, 'per-register invoice differs') + record['prose_reconstruction'] = 'exact complete JSON equality' + record['changed_register_bills'] = deltas + record['controls'] = negative_controls(C, staged, w, kind) + records[kind] = record + print('CHECKED', provider, kind, '723-register forward/dual/pull-back and 9 controls', flush=True) + results[provider] = records + return {'status': 'PASS_RETIMED_AND_DELAYED_WHOLE_WORD_AUDIT', + 'scope': 'Reused PR3687 interpreter; finite exact operator/frame audit only. No native Gaussian, owner, root, or complete supplier claim.', + 'providers': results} + + +if __name__ == '__main__': + need(sys.argv[1:] in ([], ['--write']), 'usage: verify.py [--write]') + C = authenticate() + result = run(C) + output = json.dumps(result, sort_keys=True, indent=2) + '\n' + if sys.argv[1:] == ['--write']: + (HERE / 'RESULT.json').write_text(output) + else: + need((HERE / 'RESULT.json').read_text() == output, 'committed result differs') + print(result['status']) diff --git a/research/staged544-neutral-fixed-d2/vendor/pr3942_PROOF.md b/research/staged544-neutral-fixed-d2/vendor/pr3942_PROOF.md new file mode 100644 index 0000000000..9c44765e69 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/pr3942_PROOF.md @@ -0,0 +1,162 @@ +# Local-first two-ADD retiming obstruction + +## Statement and fixed contract + +Fix either literal PR3734 provider retained in `inputs/`. A first existing ADD +may change its common binary frame in place, or move across exactly one adjacent +ADD or nonzero SCALE and change that frame. A second existing ADD may then move +any distance inside its allowed scalar corridor and choose any common binary +frame. Both the intermediate and final words must satisfy the fixed boundaries. +Every other gate, gate frame, entrance, target/centre cut, native warp, and exit +is unchanged. Each move stays within A after its prelude, B between native warp +cuts, or restore. ADD crossings use the sufficient condition +`destination(g) != source(h)` and `destination(h) != source(g)`; SCALE crossings +use exact conjugation. These are the PR3886 move rules, not every possible +semantics-preserving rewrite. The same ADD may be chosen twice. + +**Theorem.** Every word in this class has new-minus-old raw rank moment at least +zero for every real `0 < a < 1`. The raw moment is `sum n_r r^(1-a)`. This is a +finite source-bound theorem conditional on the explicitly stated word/frame +contract, supported by the exact census below. It is not a universal two-gate +barrier or supplier admission. + +The first move need not be neutral. The census also includes every locally +losing first move in this radius-one class. The second move has no radius bound. +A simultaneous edit which needs an illegal intermediate, a longer first move, +a moved SCALE, extra/deleted gates, warp/phase crossings, or another changed +boundary is outside the statement. + +## 1. Reused scalar and single-move facts + +The elementary matrix `I+cE_ds` commutes with `I+bE_uv` under the displayed +sufficient condition. Moving it right across a scale q at d multiplies c by q; +a scale at s divides c by q. Moving left reverses these factors. The source +scales are nonzero powers of two, so coefficients remain dyadic. These are +identities on arbitrary inputs, including dirty helpers. Cleanup is defined as +the literal inverse of the edited forward programme, with the inherited buffer +substitution; it does not require zero dirty state. + +The PR3886 trace, move applier, complete single-move census, and sign criterion +are reused verbatim. The primary replay regenerates all 1,776,295 single-move +cut/dimension cases separately for each provider and compares the entire frozen +receipt, rather than trusting its old PASS flag. That census proves every +single-move delta is nonnegative for all real `0 lo and R.crosses(gate, gates[lower - 1]): + lower -= 1 + while upper < hi and R.crosses(gate, gates[upper]): + upper += 1 + if window is not None: + lower, upper = max(lower, window[0]), min(upper, window[1]) + cuts = [c for c in (i - 1, i, i + 2) if lower <= c <= upper] if first else range(lower, upper + 1) + reduced = {r: [x for x in occurrences[r] if x != i] for r in R.touched(gate)} + for cut in cuts: + if cut == i + 1: + continue + bounds = [] + for r in R.touched(gate): + indices = reduced[r] + j = bisect_left(indices, cut) + before = R.span(tuple(gates[indices[j - 1]][-1])) if j else entries[r] + after = R.span(tuple(gates[indices[j]][-1])) if j < len(indices) else exits[r] + bounds.append((before, after)) + low = R.join(bounds[0][0], bounds[1][0]) + high = bounds[0][1] & bounds[1][1] + if not R.contained(low, high): + continue + for dimension in range(R.rank(low), R.rank(high) + 1): + delta = removal[i].copy() + for before, after in bounds: + p, q = R.rank(before), R.rank(after) + delta[q - p] -= 1 + delta[dimension - p] += 1 + delta[q - dimension] += 1 + delta[0] = 0 + require(sum(r * n for r, n in enumerate(delta)) == 0, 'rank mass drift') + yield i, cut, dimension, low, high, tuple(delta) + +@lru_cache(maxsize=None) +def frames(low, high, dimension): + """All intermediate subspaces, not one representative per dimension.""" + require(R.contained(low, high), 'empty frame interval') + require(R.rank(low) <= dimension <= R.rank(high), 'invalid frame dimension') + require(R.rank(high) - R.rank(low) <= 4, 'first-frame resource bound exceeded') + current = {low} + for _ in range(dimension - R.rank(low)): + expanded = set() + for frame in current: + for v in range(1, 512): + if high >> v & 1 and not frame >> v & 1: + expanded.add(R.join(frame, R.span((v,)))) + current = expanded + return tuple(sorted(current)) + +def first_moves(word): + fixed, variable, seen = {}, [], set() + counts = Counter() + interval_checks = set() + for section in PHASES: + gates = word[section] + for i, cut, dimension, low, high, delta in candidates(word, section, range(len(gates)), first=True): + interval_checks.add((low, high, dimension)) + for frame in frames(low, high, dimension): + if frame == R.span(tuple(gates[i][-1])): + if cut == i: + continue + pair = (section, min(i, cut)) + if pair in seen: + continue + seen.add(pair) + require(delta == ZERO, 'fixed-frame swap was not neutral') + fixed[pair] = (i, cut, frame) + counts['fixed_adjacent'] += 1 + else: + kind = ('frame_only' if cut == i else 'adjacent') + ('_neutral' if delta == ZERO else '_losing') + require(R.all_power_nonnegative(delta), 'first move unexpectedly improves') + variable.append((section, i, cut, frame, delta, kind)) + counts[kind] += 1 + # A separate structural enumeration checks completeness of fixed-frame swaps. + direct = set() + for section in PHASES: + gates = word[section] + for lo, hi in R.segments(word, section): + for p in range(lo, hi - 1): + g, h = gates[p:p + 2] + if g[0] != 'add' and h[0] != 'add': + continue + a, b = (g, h) if g[0] == 'add' else (h, g) + if not R.crosses(a, b): + continue + if set(R.touched(g)) & set(R.touched(h)) and R.span(tuple(g[-1])) != R.span(tuple(h[-1])): + continue + direct.add((section, p)) + require(set(fixed) == direct, 'fixed-swap enumerators disagree') + return fixed, variable, counts, interval_checks + +def bridge_census(word, fixed): + """Only the newly opened gap can have a new price after a fixed-frame swap.""" + histogram, counts = Counter(), Counter() + nonzero = [] + for section in PHASES: + gates = word[section] + touched = [set(R.touched(g)) for g in gates] + for lo, hi, occurrences, entries, exits, removal in geometry(word, section): + for p in range(lo, hi - 1): + if (section, p) not in fixed: + continue + counts['first_pairs'] += 1 + g, h = gates[p:p + 2] + selected = sorted({j for r in touched[p] for j in occurrences[r] + if gates[j][0] == 'add' and j not in (p, p + 1) + and touched[j] & touched[p + 1]}) + for j in selected: + counts['bridge_gates'] += 1 + crossed = gates[j + 1:p] + [h] if j < p else [g] + gates[p + 2:j] + if not all(R.crosses(gates[j], e) for e in crossed): + continue + counts['scalar_legal'] += 1 + bounds = [] + for r in R.touched(gates[j]): + indices = occurrences[r] + left = bisect_left(indices, p) - 1 + if left >= 0 and indices[left] == j: + left -= 1 + before = R.span(tuple(gates[indices[left]][-1])) if left >= 0 else entries[r] + right = bisect_left(indices, p + 2) + if right < len(indices) and indices[right] == j: + right += 1 + after = R.span(tuple(gates[indices[right]][-1])) if right < len(indices) else exits[r] + if r in touched[p + 1]: + before = R.span(tuple(h[-1])) + if r in touched[p]: + after = R.span(tuple(g[-1])) + bounds.append((before, after)) + low = R.join(bounds[0][0], bounds[1][0]) + high = bounds[0][1] & bounds[1][1] + if not R.contained(low, high): + continue + for dimension in range(R.rank(low), R.rank(high) + 1): + delta = removal[j].copy() + for before, after in bounds: + a, b = R.rank(before), R.rank(after) + delta[b - a] -= 1 + delta[dimension - a] += 1 + delta[b - dimension] += 1 + delta[0] = 0 + histogram[tuple(delta)] += 1 + if any(delta): + nonzero.append([section, p, j, dimension, delta]) + counts['candidate_dimensions'] += 1 + return {'counts': dict(counts), 'profiles': rows(histogram), 'nonzero_cases': nonzero} + +def variable_census(word, variable, auditor=None, progress=False): + baseline = R.tracing(word)[2] + histogram, by_kind = Counter(), {} + for number, (section, i, cut, frame, first_delta, kind) in enumerate(variable): + middle = R.apply_move(word, section, i, cut, R.basis(frame)) + intermediate = R.tracing(middle)[2] + require(tuple(intermediate.get(r, 0) - baseline.get(r, 0) if r else 0 for r in range(10)) == first_delta, + 'first actual invoice differs from relaxation') + if auditor is not None: + require(auditor.frame_bill(middle)[0] == intermediate, 'retained first-word invoice disagrees') + moved = cut - (cut > i) + registers = set(R.touched(word[section][i])) + counts = by_kind.setdefault(kind, Counter()) + counts['first_words'] += 1 + for second_section in PHASES: + selected = [j for j, g in enumerate(middle[second_section]) + if g[0] == 'add' and registers.intersection(R.touched(g)) + and (second_section, j) != (section, moved)] + for _, _, _, _, _, second_delta in candidates(middle, second_section, selected): + delta = tuple(a + b for a, b in zip(first_delta, second_delta)) + histogram[delta] += 1 + counts['second_cut_dimensions'] += 1 + if progress and number % 100 == 0: + print('Checked first word', number, 'of', len(variable), flush=True) + return {'by_kind': {k: dict(v) for k, v in sorted(by_kind.items())}, 'profiles': rows(histogram)} + +def compute(word, auditor=None, progress=False): + fixed, variable, counts, intervals = first_moves(word) + serial = [[s, p, i, c, list(R.basis(f))] for (s, p), (i, c, f) in sorted(fixed.items())] + serial += [[s, i, c, list(R.basis(f)), list(d), k] for s, i, c, f, d, k in variable] + return {'first_counts': dict(sorted(counts.items())), 'first_digest': digest(serial), + 'max_first_quotient_dimension': max(R.rank(h) - R.rank(l) for l, h, _ in intervals), + 'fixed_frame': bridge_census(word, fixed), + 'variable_frame': variable_census(word, variable, auditor, progress)} diff --git a/research/staged544-neutral-fixed-d2/vendor/pr3957_search.py b/research/staged544-neutral-fixed-d2/vendor/pr3957_search.py new file mode 100644 index 0000000000..e5509c6a22 --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/pr3957_search.py @@ -0,0 +1,206 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Losing first ADD at displacement exactly two, unrestricted second ADD. + +Chris R / Clear1nsight, with substantial OpenAI assistance. The pinned +PR3886 trace, applier and sign criterion are reused, not independently authored. +Adapted from PR3942 with its retained source. The interaction reduction is reused. +""" +from bisect import bisect_left +from collections import Counter +from functools import lru_cache +import hashlib +import json +from pathlib import Path +import types + +P = Path(__file__).resolve().parent + +def module(name, path): + value = types.ModuleType(name) + value.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), value.__dict__) + return value + +# The entry point authenticates these bytes before loading this module. +R = module('pinned_retiming', P / 'vendor/retiming.py') +PHASES = ('A', 'B', 'restore') +ZERO = (0,) * 10 +R.all_power_nonnegative = lru_cache(maxsize=None)(R.all_power_nonnegative) + +def require(ok, message): + if not ok: + raise ValueError(message) + +def digest(value): + return hashlib.sha256(json.dumps(value, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + +def rows(histogram): + result = [] + for delta, count in sorted(histogram.items()): + caps = R.caps(delta) + prefixes = [sum(caps[:j]) for j in range(1, 9)] + require(sum(r*n for r,n in enumerate(delta))==0,'histogram rank mass') + result.append({'delta': list(delta), 'count': count, 'caps': caps, + 'prefixes': prefixes, 'certificate': R.all_power_nonnegative(delta)}) + return result + +def geometry(word, section): + nodes, where, bill = R.tracing(word) + gates = word[section] + for lo, hi in R.segments(word, section): + occurrences = {} + for i in range(lo, hi): + for r in R.touched(gates[i]): + occurrences.setdefault(r, []).append(i) + entries, exits, removal = {}, {}, {} + for r, indices in occurrences.items(): + entries[r] = nodes[r][where[((section, indices[0]), r)]][2] + exits[r] = nodes[r][where[((section, indices[-1]), r)] + 1][3] + for i in range(lo, hi): + if gates[i][0] != 'add': + continue + delta = [0] * 10 + for r in R.touched(gates[i]): + seq = nodes[r] + pos = where[((section, i), r)] + _, _, before, frame = seq[pos] + require(seq[pos + 1][1] != 'map', 'missing map-entry check') + after = seq[pos + 1][3] + delta[R.rank(frame) - R.rank(before)] -= 1 + delta[R.rank(after) - R.rank(frame)] -= 1 + delta[R.rank(after) - R.rank(before)] += 1 + removal[i] = delta + yield lo, hi, occurrences, entries, exits, removal + +def candidates(word, section, selected, first=False, window=None): + """Exact prices in the predecessor's fixed-check relaxation. + + First moves use cuts i-2 and i+3, hence final displacement exactly two. + For second moves all permitted corridor cuts and all frame dimensions occur. + """ + gates = word[section] + for lo, hi, occurrences, entries, exits, removal in geometry(word, section): + for i in selected: + if not lo <= i < hi or gates[i][0] != 'add': + continue + gate = gates[i] + lower, upper = i, i + 1 + while lower > lo and R.crosses(gate, gates[lower - 1]): + lower -= 1 + while upper < hi and R.crosses(gate, gates[upper]): + upper += 1 + if window is not None: + lower, upper = max(lower, window[0]), min(upper, window[1]) + cuts = [c for c in (i - 2, i + 3) if lower <= c <= upper] if first else range(lower, upper + 1) + reduced = {r: [x for x in occurrences[r] if x != i] for r in R.touched(gate)} + for cut in cuts: + if cut == i + 1: + continue + bounds = [] + for r in R.touched(gate): + indices = reduced[r] + j = bisect_left(indices, cut) + before = R.span(tuple(gates[indices[j - 1]][-1])) if j else entries[r] + after = R.span(tuple(gates[indices[j]][-1])) if j < len(indices) else exits[r] + bounds.append((before, after)) + low = R.join(bounds[0][0], bounds[1][0]) + high = bounds[0][1] & bounds[1][1] + if not R.contained(low, high): + continue + for dimension in range(R.rank(low), R.rank(high) + 1): + delta = removal[i].copy() + for before, after in bounds: + p, q = R.rank(before), R.rank(after) + delta[q - p] -= 1 + delta[dimension - p] += 1 + delta[q - dimension] += 1 + delta[0] = 0 + require(sum(r * n for r, n in enumerate(delta)) == 0, 'rank mass drift') + yield i, cut, dimension, low, high, tuple(delta) + +@lru_cache(maxsize=None) +def frames(low, high, dimension): + """All intermediate subspaces, not one representative per dimension.""" + require(R.contained(low, high), 'empty frame interval') + require(R.rank(low) <= dimension <= R.rank(high), 'invalid frame dimension') + require(R.rank(high) - R.rank(low) <= 4, 'first-frame resource bound exceeded') + current = {low} + for _ in range(dimension - R.rank(low)): + expanded = set() + for frame in current: + for v in range(1, 512): + if high >> v & 1 and not frame >> v & 1: + expanded.add(R.join(frame, R.span((v,)))) + current = expanded + return tuple(sorted(current)) + +def first_moves(word, auditor=None): + variable, counts, intervals = [], Counter(), set() + for section in PHASES: + gates = word[section] + for i, cut, dimension, low, high, delta in candidates(word, section, range(len(gates)), first=True): + require(abs(cut - (cut > i) - i) == 2, 'first displacement is not exactly two') + intervals.add((low, high, dimension)) + counts['first_price_cells'] += 1 + require(R.all_power_nonnegative(delta), 'unclassified first profile') + if delta == ZERO: + counts['neutral_price_cells_excluded'] += 1 + continue + for frame in frames(low, high, dimension): + counts['losing_subspace_records'] += 1 + variable.append((section, i, cut, frame, delta, 'displacement_two_losing')) + return variable, counts, intervals + +def variable_census(word, variable, auditor=None, progress=False): + D = module('dirty_blocks', P/'dirty_blocks.py') + baseline = R.tracing(word)[2] + histogram, first_histogram, counts = Counter(), Counter(), Counter() + states, block_checks, rejected, uncertified_witnesses = [], [], [], {} + for number, (section, i, cut, frame, first_delta, kind) in enumerate(variable): + middle = R.apply_move(word, section, i, cut, R.basis(frame)) + try: + intermediate = R.tracing(middle)[2] + except ValueError as error: + require(str(error) in ('source fixed boundary','source frame containment'), 'unexpected first rejection: '+str(error)) + rejected.append([section,i,cut,list(R.basis(frame)),str(error)]) + continue + require(tuple(intermediate.get(r, 0) - baseline.get(r, 0) if r else 0 for r in range(10)) == first_delta, + 'first actual invoice differs from relaxation') + if auditor is not None: + require(auditor.frame_bill(middle)[0] == intermediate, 'retained first-word invoice disagrees') + require(sum(r*n for r,n in intermediate.items())==sum(r*n for r,n in baseline.items()),'first rank mass differs') + lo,hi=min(i,cut),max(i+1,cut) + block_checks.append(D.block_equal(word[section][lo:hi],middle[section][lo:hi])) + first_histogram[first_delta]+=1 + moved = cut - (cut > i) + registers = set(R.touched(word[section][i])) + local=Counter() + for second_section in PHASES: + selected = [j for j, g in enumerate(middle[second_section]) + if g[0] == 'add' and registers.intersection(R.touched(g)) + and (second_section, j) != (section, moved)] + for j, target, dimension, low, high, second_delta in candidates(middle, second_section, selected): + delta = tuple(a + b for a, b in zip(first_delta, second_delta)) + histogram[delta] += 1 + local[delta] += 1 + if delta not in uncertified_witnesses and not R.all_power_nonnegative(delta): + # An insufficient sign certificate is retained, never treated as a gain. + uncertified_witnesses[delta]={'first':[section,i,cut,list(R.basis(frame)),list(first_delta)], + 'second':[second_section,j,target,dimension,low,high,list(second_delta)]} + n=sum(local.values());counts['first_words']+=1;counts['second_cut_dimensions']+=n + states.append({'first':[section,i,cut,list(R.basis(frame)),list(first_delta)],'profile':intermediate, + 'second_cut_dimensions':n,'second_histogram_sha256':digest(sorted((list(d),n) for d,n in local.items()))}) + if progress and (number%50==0 or number+1==len(variable)): + print('FIRST_AND_SECOND',number+1,'of',len(variable),'prices',counts['second_cut_dimensions'],flush=True) + return {'counts':dict(counts),'first_profiles':rows(first_histogram),'profiles':rows(histogram), + 'states':states,'dirty_block_checks':len(block_checks),'dirty_block_stream_sha256':digest(block_checks), + 'boundary_rejected':rejected,'uncertified_witnesses':list(uncertified_witnesses.values())} + +def compute(word, auditor=None, progress=False): + variable, counts, intervals = first_moves(word, auditor) + if progress:print('FIRST_DOMAIN',dict(counts),'intervals',len(intervals),flush=True) + serial = [[s, i, c, list(R.basis(f)), list(d), k] for s, i, c, f, d, k in variable] + return {'first_counts': dict(sorted(counts.items())), 'first_digest': digest(serial), + 'first_intervals':[[l,h,d] for l,h,d in sorted(intervals)], + 'max_first_quotient_dimension': max(R.rank(h)-R.rank(l) for l,h,_ in intervals), + 'variable_frame': variable_census(word, variable, auditor, progress)} diff --git a/research/staged544-neutral-fixed-d2/vendor/pr3957_verify.py b/research/staged544-neutral-fixed-d2/vendor/pr3957_verify.py new file mode 100644 index 0000000000..09a89c879b --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/pr3957_verify.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Read-only exact replay; --emit explicitly regenerates an external receipt.""" +import argparse +import gzip +import hashlib +import json +from pathlib import Path +import types +from collections import Counter +from copy import deepcopy +import time + +P = Path(__file__).resolve().parent + +def require(ok, message): + if not ok: + raise ValueError(message) + +def module(name, path): + value = types.ModuleType(name) + value.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), value.__dict__) + return value + +def authenticate(raw, row): + require(len(raw) == row['bytes'], 'source length: ' + row['local']) + require(hashlib.sha256(raw).hexdigest() == row['sha256'], 'source SHA256: ' + row['local']) + blob = hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() + require(blob == row['git_blob'], 'source Git blob: ' + row['local']) + +def setup(): + sources = json.loads((P / 'SOURCES.json').read_text()) + for row in sources['snapshots']: + authenticate((P / row['local']).read_bytes(), row) + return (module('owned_search', P / 'search.py'), + module('retained_auditor', P / 'vendor/audit_core.py'), + module('retained_semantics', P / 'vendor/audit_verify.py')) + +def load(tag): + return json.loads(gzip.decompress((P / 'inputs' / f'BORROW-WORD-43{tag}.json.gz').read_bytes())) + +def calculate(tag, progress=False): + S, C, A = setup() + word = load(tag) + C.hygiene(word) + bill, inventory, *_ = C.frame_bill(word) + require(bill == {int(r): n for r, n in word['report']['local_profile'].items()}, 'source declared invoice') + require(S.R.tracing(word)[2] == bill, 'source trace disagreement') + require(C.derive_cleanup(word) == word['cleanup'], 'source inverse cleanup') + baseline = S.R.census(word) + expected = json.loads((P / 'inputs/SINGLE-CENSUS.json').read_text())[tag] + require(json.loads(json.dumps(baseline)) == expected, 'predecessor single-move census differs') + require(all(row['certificate'] for row in baseline['deltas']), 'single-move premise failed') + result = S.compute(word, C, progress) + proof_rows=result['variable_frame']['profiles'] + if not all(row['certificate'] for row in proof_rows): + raise ValueError('unresolved combined signs; no obstruction claimed: '+repr(result['variable_frame']['uncertified_witnesses'])) + result['dirty_validation']=dirty_validation(S,C,A,word,result['variable_frame']['states']) + result['ledger']=ledger(S,C,word,result) + + return {'schema_version': 1, 'provider': tag, 'source_canonical': S.digest(word), + 'source_profile': bill, 'width_inventory': inventory, + 'single_move_candidates': baseline['candidates'], + 'single_census_digest': S.digest(baseline), + 'source_semantics': A.semantics(C, word), 'pair_census': result} + +def normal(value):return json.loads(json.dumps(value,sort_keys=True)) + +def ledger(S,C,word,result): + bill,widths,_,start,end=C.frame_bill(word) + primitives={sec:dict(sorted(Counter(g[0] for g in word[sec]).items())) for sec in + ('precondition','compensation','A','cut','B','restore','cleanup')} + first=result['variable_frame']['states'] + masses={sum(int(r)*n for r,n in x['profile'].items()) for x in first} + require(masses=={sum(r*n for r,n in bill.items())},'first rank masses') + return {'baseline_local_profile':bill,'recursive_children':sum(bill.values()), + 'rank_mass':sum(r*n for r,n in bill.items()),'helper_width_inventory':widths, + 'helper_roles':sum(widths.values()),'dirty_buffers':len(word['helper_final']), + 'live_inputs':C.N-len(word['removed']),'primitive_inventory':primitives, + 'native_warps':len(word['warps']),'initial_operator_corrections':len(word['initial_corrections']), + 'first_recursive_children_range':[min(sum(x['profile'].values()) for x in first),max(sum(x['profile'].values()) for x in first)], + 'all_first_profiles_recorded':'pair_census.variable_frame.states', + 'all_combined_histograms_recorded':'pair_census.variable_frame.profiles', + 'entrance_frames_sha256':S.digest({str(k):str(v) for k,v in start.items()}), + 'exit_frames_sha256':S.digest({str(k):str(v) for k,v in end.items()}), + 'added_gates_helpers_buffers':0,'source_scalar_coefficient_bound':coefficient_bound(word), + 'first_scalar_coefficient_bound':result['dirty_validation']['coefficient_bound'], + 'proved':['Local chronological recursive invoices, fixed native maps/cuts and helper widths', + 'Exact rational first-block equality for every admitted first move on arbitrary dirty inputs', + 'Complete baseline free-operator replay and deterministic first/final replay controls', + 'Recomputed inverse cleanup and full first-word resource inventories in sampled whole-word controls'], + 'unknown':['Fresh native Gaussian/Clifford realization and phase','Physical hosting/allocation and complete owner chronology', + 'Uniform coefficient/precision/stock/tape costs','All-size compiler, outer/supplier admission','Analytic transfer and BIT H1-H5'], + 'unknown_costs_are_zero':False,'new_supplier_or_kappa':False} + +def coefficient_bound(word): + a=[g for sec in ('A','B','restore') for g in word[sec] if g[0]=='add'] + return {'maximum_numerator_bits':max(abs(g[3]).bit_length() for g in a), + 'maximum_denominator_bits':max(g[4].bit_length() for g in a)} + +def dirty_validation(S,C,A,word,states): + # Local block equality was checked for every first word during the census. + # Whole-word samples additionally exercise the retained production interpreter. + samples={0,len(states)-1} + for sec in S.PHASES: + group=[i for i,x in enumerate(states) if x['first'][0]==sec] + if group: + samples.update((group[0],group[len(group)//2],group[-1])) + rows=[];bound=coefficient_bound(word);second_blocks=[] + D=module('dirty_oracle',P/'dirty_blocks.py') + for ordinal in sorted(samples): + sec,i,cut,fr,delta=states[ordinal]['first'] + middle=S.R.apply_move(word,sec,i,cut,fr) + middle['cleanup']=C.derive_cleanup(middle) + bill,widths,*_=C.frame_bill(middle) + middle['report']['local_profile']={str(r):n for r,n in bill.items()} + C.hygiene(middle) + semantic=A.semantics(C,middle) + b=coefficient_bound(middle) + bound={k:max(bound[k],b[k]) for k in bound} + moved=cut-(cut>i) + restored=S.R.apply_move(middle,sec,moved,i+(moved=d:break + if not mask>>v&1:frame.append(v);mask=S.R.span(tuple(frame)) + require(len(frame)==d,'second frame realization') + final=S.R.apply_move(middle,section,j,target,frame) + try:fb,fw,*_=C.frame_bill(final) + except C.AuditFailure:continue + require(fw==widths,'second helper width drift') + actual=tuple(fb.get(r,0)-bill.get(r,0) if r else 0 for r in range(10)) + require(actual==sd,'second real invoice differs') + lo,hi=min(j,target),max(j+1,target) + check=D.block_equal(middle[section][lo:hi],final[section][lo:hi]) + final['cleanup']=C.derive_cleanup(final);final['report']['local_profile']={str(r):n for r,n in fb.items()} + C.hygiene(final) + second={'section':section,'index':j,'cut':target,'frame':frame,'profile':fb, + 'block':check,'semantics':A.semantics(C,final)} + break + if second:break + require(second is not None,'no legal second control') + rows.append({'first_state':ordinal,'semantics':semantic,'literal_undo':'PASS','second':second}) + # Meter all first scalar conjugations without replaying complete words. + for state in states: + sec,i,cut,fr,_=state['first'];g=word[sec][i] + from fractions import Fraction + coefficient=Fraction(g[3],g[4]) + crossed=word[sec][i+1:cut] if cut>i else word[sec][cut:i] + for h in crossed: + if h[0]=='scale' and h[1] in S.R.touched(g): + power=(1 if h[1]==g[1] else -1)*(1 if cut>i else -1) + coefficient*=Fraction(h[2],h[3])**power + bound['maximum_numerator_bits']=max(bound['maximum_numerator_bits'],abs(coefficient.numerator).bit_length()) + bound['maximum_denominator_bits']=max(bound['maximum_denominator_bits'],coefficient.denominator.bit_length()) + return {'all_first_dirty_blocks':len(states),'whole_word_samples':rows,'coefficient_bound':bound, + 'proof':'Every first scalar block equals its source on independent rational symbols; unchanged surrounding free operators compose with that equality. Inverse cleanup is rederived; baseline and sampled complete words additionally replay all 723 symbolic inputs.'} + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--provider', choices=('base', 'extra'), required=True) + parser.add_argument('--emit', type=Path) + parser.add_argument('--progress', action='store_true') + args = parser.parse_args() + result = calculate(args.provider, args.progress) + if args.emit: + require(not args.emit.resolve().is_relative_to(P), 'write regenerated receipt outside the package') + args.emit.write_text(json.dumps(result, sort_keys=True, separators=(',', ':')) + '\n') + else: + expected = json.loads((P / f'RESULT-{args.provider}.json').read_text()) + require(json.loads(json.dumps(result)) == expected, 'complete pair receipt differs') + print(json.dumps({'status': 'PASS_STAGED544_LOSING_FIRST_D2', 'provider': args.provider, + 'first_counts': result['pair_census']['first_counts'], + 'result_sha256': hashlib.sha256(json.dumps(result, sort_keys=True, separators=(',', ':')).encode()).hexdigest(), + 'new_supplier': False}, sort_keys=True)) + +if __name__ == '__main__': + main() diff --git a/research/staged544-neutral-fixed-d2/vendor/retiming.py b/research/staged544-neutral-fixed-d2/vendor/retiming.py new file mode 100644 index 0000000000..c33d7bbcdf --- /dev/null +++ b/research/staged544-neutral-fixed-d2/vendor/retiming.py @@ -0,0 +1,269 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Exact, fixed-neighbour single-ADD retiming relaxation. + +Chris R / Clear1nsight, with substantial OpenAI assistance. The BORROW-WORD +frame contract and scalar-retiming mechanism are credited in README.md. +This module does not import the retained auditor or a numerical optimiser. +""" +from bisect import bisect_left +from collections import Counter +from copy import deepcopy +from fractions import Fraction +from functools import lru_cache + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +@lru_cache(maxsize=None) +def span(vectors): + points = {0} + for v in vectors: + need(type(v) is int and 0 <= v < 512, 'invalid frame vector') + points |= {x ^ v for x in tuple(points)} + return sum(1 << x for x in points) + + +@lru_cache(maxsize=None) +def basis(mask): + answer = [] + have = 1 + for v in range(1, 512): + if (mask >> v) & 1 and not (have >> v) & 1: + answer.append(v) + have = span(tuple(answer)) + need(have == mask, 'not a binary subspace') + return tuple(answer) + + +@lru_cache(maxsize=None) +def join(a, b): + return span(basis(a) + basis(b)) + + +@lru_cache(maxsize=None) +def rank(mask): + n = mask.bit_count() + need(n > 0 and n & (n - 1) == 0, 'invalid subspace cardinality') + return n.bit_length() - 1 + + +def contained(a, b): + return not a & ~b + + +def touched(gate): + return gate[1:3] if gate[0] == 'add' else gate[1:2] + + +def tracing(word): + """Own chronological trace; centre descent is NOT persistent state. + + A check node is a fixed boundary, not a charged instruction. The census + relaxes it to a virtual climb. Every legal witness has zero such charge. + """ + full = (1 << 512) - 1 + live = set(range(704)) - set(word['removed']) + start, end = {}, {} + for r in live: + if r < 112: + start[r], end[r] = span((word['ports'][r],)), full + elif r < 224: + p = word['ports'][r - 112] + start[r] = 1 + end[r] = sum(1 << x for x in range(512) if (x & p).bit_count() % 2 == 0) + else: + start[r], end[r] = 1, full + for r, fr in word['start_extra'].items(): + start[int(r)] = span(tuple(fr)) + for r, fr in word['helper_final'].items(): + end[int(r)] = span(tuple(fr)) + current = dict(start) + nodes = {r: [] for r in live} + where = {} + bill = Counter() + + def event(r, frame, address, kind='climb'): + before = current[r] + if kind != 'map': + need(contained(before, frame), 'source frame containment') + d = rank(frame) - rank(before) + if kind == 'check': + need(d == 0, 'source fixed boundary') + elif d: + bill[d] += 1 + if kind == 'climb': + where[(address, r)] = len(nodes[r]) + nodes[r].append((address, kind, before, frame)) + current[r] = frame + + for i, gate in enumerate(word['A']): + if gate[0] == 'warp': + event(gate[1], span(tuple(gate[3])), ('check-A', i), 'check') + event(gate[1], span(tuple(gate[4])), ('map-A', i), 'map') + else: + for r in touched(gate): + event(r, span(tuple(gate[-1])), ('A', i)) + levels = {112 + int(r): span(tuple(fr)) for r, fr in word['target_levels'].items()} + for r in range(112, 224): + event(r, levels.get(r, 1), ('target-cut', r), 'check') + for r, fr in zip(word['centers'], word['center_frames']): + u = span(tuple(fr)) + event(r, u, ('centre-cut', r), 'check') + served = {levels.get(g[1], 1) for g in word['cut'] if g[2] == r} + for v in sorted(served, key=lambda x: -rank(x)): + need(contained(v, u), 'centre nesting') + if rank(u) > rank(v): + bill[rank(u) - rank(v)] += 1 + u = v + # The main forward register remains at its declared centre entry. + warps = {} + for j, rec in enumerate(word['warps']): + warps.setdefault(rec[0], []).append((j, rec)) + for i in range(len(word['B']) + 1): + for j, rec in warps.get(i, []): + event(rec[1], span(tuple(rec[3])), ('check-B', j), 'check') + event(rec[1], span(tuple(rec[4])), ('map-B', j), 'map') + if i < len(word['B']): + gate = word['B'][i] + for r in touched(gate): + event(r, span(tuple(gate[-1])), ('B', i)) + for i, gate in enumerate(word['restore']): + for r in touched(gate): + event(r, span(tuple(gate[-1])), ('restore', i)) + for r in live: + event(r, end[r], ('end',)) + return nodes, where, dict(sorted(bill.items())) + + +def crosses(g, h): + """Sufficient exact scalar normal form, not all algebraic commutations.""" + if h[0] == 'add': + return g[1] != h[2] and h[1] != g[2] + return h[0] == 'scale' and h[2] != 0 + + +def segments(word, section): + if section == 'A': + cuts = [word['prelude_events'], len(word['A'])] + elif section == 'B': + cuts = sorted({0, len(word['B'])} | {rec[0] for rec in word['warps']}) + else: + cuts = [0, len(word[section])] + return list(zip(cuts, cuts[1:])) + + +def caps(delta): + return [sum(n * min(r, k) for r, n in enumerate(delta)) for k in range(1, 10)] + + +def all_power_nonnegative(delta): + """Sufficient exact certificate using decreasing positive curvatures.""" + values = caps(delta) + prefix = 0 + for value in values[:-1]: + prefix += value + if prefix < 0: + return False + return values[-1] == 0 + + +def census(word): + nodes, where, bill = tracing(word) + deltas = Counter() + counts = {} + for section in ('A', 'B', 'restore'): + gates = word[section] + count = 0 + for lo, hi in segments(word, section): + occurrences = {} + for i in range(lo, hi): + need(gates[i][0] in ('add', 'scale'), 'unexpected scalar segment') + for r in touched(gates[i]): + occurrences.setdefault(r, []).append(i) + for i in range(lo, hi): + g = gates[i] + if g[0] != 'add': + continue + lower = i + while lower > lo and crosses(g, gates[lower - 1]): + lower -= 1 + upper = i + 1 + while upper < hi and crosses(g, gates[upper]): + upper += 1 + removal = [0] * 10 + reduced, entries, exits = {}, {}, {} + for r in touched(g): + seq = nodes[r] + pos = where[((section, i), r)] + _, _, p, u = seq[pos] + need(pos + 1 < len(seq) and seq[pos + 1][1] != 'map', 'missing successor') + q = seq[pos + 1][3] + removal[rank(u) - rank(p)] -= 1 + removal[rank(q) - rank(u)] -= 1 + removal[rank(q) - rank(p)] += 1 + indices = occurrences[r] + reduced[r] = [x for x in indices if x != i] + entries[r] = seq[where[((section, indices[0]), r)]][2] + last = where[((section, indices[-1]), r)] + need(seq[last + 1][1] != 'map', 'missing exit check') + exits[r] = seq[last + 1][3] + for cut in range(lower, upper + 1): + if cut == i + 1: # Same placement as cut i, counted once. + continue + boundaries = [] + for r in touched(g): + indices = reduced[r] + j = bisect_left(indices, cut) + p = span(tuple(gates[indices[j - 1]][-1])) if j else entries[r] + q = span(tuple(gates[indices[j]][-1])) if j < len(indices) else exits[r] + boundaries.append((p, q)) + lower_frame = join(boundaries[0][0], boundaries[1][0]) + upper_frame = boundaries[0][1] & boundaries[1][1] + if not contained(lower_frame, upper_frame): + continue + dims = [(rank(p), rank(q)) for p, q in boundaries] + for d in range(rank(lower_frame), rank(upper_frame) + 1): + delta = removal.copy() + for p, q in dims: + delta[q - p] -= 1 + delta[d - p] += 1 + delta[q - d] += 1 + delta[0] = 0 + need(sum(r * n for r, n in enumerate(delta)) == 0, 'rank mass drift') + deltas[tuple(delta)] += 1 + count += 1 + counts[section] = count + return {'per_section': counts, 'candidates': sum(counts.values()), + 'source_profile': bill, + 'deltas': [{'delta': {r: n for r, n in enumerate(d) if n}, 'count': n, + 'caps': caps(d), 'certificate': all_power_nonnegative(d)} + for d, n in sorted(deltas.items())]} + + +def apply_move(word, section, index, cut, frame): + """Apply one exact scalar retiming. Caller must rederive cleanup and audit.""" + need(section in ('A', 'B', 'restore'), 'unknown section') + gates = word[section] + need(type(index) is int and 0 <= index < len(gates), 'bad source index') + need(type(cut) is int and 0 <= cut <= len(gates), 'bad insertion cut') + need(any(lo <= index < hi and lo <= cut <= hi for lo, hi in segments(word, section)), + 'crosses prelude or native warp boundary') + g = deepcopy(gates[index]) + need(g[0] == 'add', 'only ADD moves are covered') + crossed = gates[index + 1:cut] if cut > index else gates[cut:index] + need(all(crosses(g, h) for h in crossed), 'noncommuting scalar barrier') + coefficient = Fraction(g[3], g[4]) + for h in crossed: + if h[0] == 'scale' and h[1] in touched(g): + power = (1 if h[1] == g[1] else -1) * (1 if cut > index else -1) + coefficient *= Fraction(h[2], h[3]) ** power + g[3:5] = [coefficient.numerator, coefficient.denominator] + g[-1] = list(basis(span(tuple(frame)))) + result = deepcopy(word) + result[section].pop(index) + result[section].insert(cut - (cut > index), g) + # Segment length and all warp cuts are unchanged. No warp is crossed. + return result diff --git a/research/staged544-neutral-fixed-d2/verify.py b/research/staged544-neutral-fixed-d2/verify.py new file mode 100644 index 0000000000..119df8ee1e --- /dev/null +++ b/research/staged544-neutral-fixed-d2/verify.py @@ -0,0 +1,195 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Read-only exact replay; --emit explicitly regenerates an external receipt.""" +import argparse +import gzip +import hashlib +import json +from pathlib import Path +import types +from collections import Counter +from copy import deepcopy +import time + +P = Path(__file__).resolve().parent + +def require(ok, message): + if not ok: + raise ValueError(message) + +def module(name, path): + value = types.ModuleType(name) + value.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), value.__dict__) + return value + +def authenticate(raw, row): + require(len(raw) == row['bytes'], 'source length: ' + row['local']) + require(hashlib.sha256(raw).hexdigest() == row['sha256'], 'source SHA256: ' + row['local']) + blob = hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() + require(blob == row['git_blob'], 'source Git blob: ' + row['local']) + +def setup(): + sources = json.loads((P / 'SOURCES.json').read_text()) + for row in sources['snapshots']: + authenticate((P / row['local']).read_bytes(), row) + return (module('owned_search', P / 'search.py'), + module('retained_auditor', P / 'vendor/audit_core.py'), + module('retained_semantics', P / 'vendor/audit_verify.py')) + +def load(tag): + return json.loads(gzip.decompress((P / 'inputs' / f'BORROW-WORD-43{tag}.json.gz').read_bytes())) + +def calculate(tag, progress=False): + S, C, A = setup() + word = load(tag) + C.hygiene(word) + bill, inventory, *_ = C.frame_bill(word) + require(bill == {int(r): n for r, n in word['report']['local_profile'].items()}, 'source declared invoice') + require(S.R.tracing(word)[2] == bill, 'source trace disagreement') + require(C.derive_cleanup(word) == word['cleanup'], 'source inverse cleanup') + baseline = S.R.census(word) + expected = json.loads((P / 'inputs/SINGLE-CENSUS.json').read_text())[tag] + require(json.loads(json.dumps(baseline)) == expected, 'predecessor single-move census differs') + require(all(row['certificate'] for row in baseline['deltas']), 'single-move premise failed') + result = S.compute(word, C, progress) + proof_rows=result['variable_frame']['profiles'] + if not all(row['certificate'] for row in proof_rows): + raise ValueError('unresolved combined signs; no obstruction claimed: '+repr(result['variable_frame']['uncertified_witnesses'])) + result['dirty_validation']=dirty_validation(S,C,A,word,result['variable_frame']['states']) + result['ledger']=ledger(S,C,word,result) + states=result['variable_frame'].pop('states') + result['variable_frame']['state_stream_sha256']=S.digest(states) + result['variable_frame']['first_state']=states[0] + result['variable_frame']['last_state']=states[-1] + + return {'schema_version': 1, 'provider': tag, 'source_canonical': S.digest(word), + 'source_profile': bill, 'width_inventory': inventory, + 'single_move_candidates': baseline['candidates'], + 'single_census_digest': S.digest(baseline), + 'source_semantics': A.semantics(C, word), 'pair_census': result} + +def normal(value):return json.loads(json.dumps(value,sort_keys=True)) + +def ledger(S,C,word,result): + bill,widths,_,start,end=C.frame_bill(word) + primitives={sec:dict(sorted(Counter(g[0] for g in word[sec]).items())) for sec in + ('precondition','compensation','A','cut','B','restore','cleanup')} + first=result['variable_frame']['states'] + masses={sum(int(r)*n for r,n in x['profile'].items()) for x in first} + require(masses=={sum(r*n for r,n in bill.items())},'first rank masses') + return {'baseline_local_profile':bill,'recursive_children':sum(bill.values()), + 'rank_mass':sum(r*n for r,n in bill.items()),'helper_width_inventory':widths, + 'helper_roles':sum(widths.values()),'dirty_buffers':len(word['helper_final']), + 'live_inputs':C.N-len(word['removed']),'primitive_inventory':primitives, + 'native_warps':len(word['warps']),'initial_operator_corrections':len(word['initial_corrections']), + 'first_recursive_children_range':[min(sum(x['profile'].values()) for x in first),max(sum(x['profile'].values()) for x in first)], + 'all_first_profiles':'Every first profile equals the baseline exactly; the deterministic full state stream is hashed in the receipt.', + 'all_combined_histograms_recorded':'pair_census.variable_frame.profiles', + 'entrance_frames_sha256':S.digest({str(k):str(v) for k,v in start.items()}), + 'exit_frames_sha256':S.digest({str(k):str(v) for k,v in end.items()}), + 'added_gates_helpers_buffers':0,'source_scalar_coefficient_bound':coefficient_bound(word), + 'first_scalar_coefficient_bound':result['dirty_validation']['coefficient_bound'], + 'proved':['Local chronological recursive invoices, fixed native maps/cuts and helper widths', + 'Exact rational first-block equality for every admitted first move on arbitrary dirty inputs', + 'Complete baseline free-operator replay and deterministic first/final replay controls', + 'Recomputed inverse cleanup and full first-word resource inventories in sampled whole-word controls'], + 'unknown':['Fresh native Gaussian/Clifford realization and phase','Physical hosting/allocation and complete owner chronology', + 'Uniform coefficient/precision/stock/tape costs','All-size compiler, outer/supplier admission','Analytic transfer and BIT H1-H5'], + 'unknown_costs_are_zero':False,'new_supplier_or_kappa':False} + +def coefficient_bound(word): + a=[g for sec in ('A','B','restore') for g in word[sec] if g[0]=='add'] + return {'maximum_numerator_bits':max(abs(g[3]).bit_length() for g in a), + 'maximum_denominator_bits':max(g[4].bit_length() for g in a)} + +def dirty_validation(S,C,A,word,states): + # Local block equality was checked for every first word during the census. + # Whole-word samples additionally exercise the retained production interpreter. + samples={0,len(states)-1} + for sec in S.PHASES: + group=[i for i,x in enumerate(states) if x['first'][0]==sec] + if group: + samples.update((group[0],group[len(group)//2],group[-1])) + rows=[];bound=coefficient_bound(word);second_blocks=[] + D=module('dirty_oracle',P/'dirty_blocks.py') + for ordinal in sorted(samples): + sec,i,cut,fr,delta=states[ordinal]['first'] + middle=S.R.apply_move(word,sec,i,cut,fr) + middle['cleanup']=C.derive_cleanup(middle) + bill,widths,*_=C.frame_bill(middle) + middle['report']['local_profile']={str(r):n for r,n in bill.items()} + C.hygiene(middle) + semantic=A.semantics(C,middle) + b=coefficient_bound(middle) + bound={k:max(bound[k],b[k]) for k in bound} + moved=cut-(cut>i) + restored=S.R.apply_move(middle,sec,moved,i+(moved=d:break + if not mask>>v&1:frame.append(v);mask=S.R.span(tuple(frame)) + require(len(frame)==d,'second frame realization') + final=S.R.apply_move(middle,section,j,target,frame) + try:fb,fw,*_=C.frame_bill(final) + except C.AuditFailure:continue + require(fw==widths,'second helper width drift') + actual=tuple(fb.get(r,0)-bill.get(r,0) if r else 0 for r in range(10)) + require(actual==sd,'second real invoice differs') + lo,hi=min(j,target),max(j+1,target) + check=D.block_equal(middle[section][lo:hi],final[section][lo:hi]) + final['cleanup']=C.derive_cleanup(final);final['report']['local_profile']={str(r):n for r,n in fb.items()} + C.hygiene(final) + second={'section':section,'index':j,'cut':target,'frame':frame,'profile':fb, + 'block':check,'semantics':A.semantics(C,final)} + break + if second:break + require(second is not None,'no legal second control') + rows.append({'first_state':ordinal,'semantics':semantic,'literal_undo':'PASS','second':second}) + # Meter all first scalar conjugations without replaying complete words. + for state in states: + sec,i,cut,fr,_=state['first'];g=word[sec][i] + from fractions import Fraction + coefficient=Fraction(g[3],g[4]) + crossed=word[sec][i+1:cut] if cut>i else word[sec][cut:i] + for h in crossed: + if h[0]=='scale' and h[1] in S.R.touched(g): + power=(1 if h[1]==g[1] else -1)*(1 if cut>i else -1) + coefficient*=Fraction(h[2],h[3])**power + bound['maximum_numerator_bits']=max(bound['maximum_numerator_bits'],abs(coefficient.numerator).bit_length()) + bound['maximum_denominator_bits']=max(bound['maximum_denominator_bits'],coefficient.denominator.bit_length()) + return {'all_first_dirty_blocks':len(states),'whole_word_samples':rows,'coefficient_bound':bound, + 'proof':'Every first scalar block equals its source on independent rational symbols; unchanged surrounding free operators compose with that equality. Inverse cleanup is rederived; baseline and sampled complete words additionally replay all 723 symbolic inputs.'} + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--provider', choices=('base', 'extra'), required=True) + parser.add_argument('--emit', type=Path) + parser.add_argument('--progress', action='store_true') + args = parser.parse_args() + result = calculate(args.provider, args.progress) + if args.emit: + require(not args.emit.resolve().is_relative_to(P), 'write regenerated receipt outside the package') + args.emit.write_text(json.dumps(result, sort_keys=True, separators=(',', ':')) + '\n') + else: + expected = json.loads((P / f'RESULT-{args.provider}.json').read_text()) + require(json.loads(json.dumps(result)) == expected, 'complete pair receipt differs') + print(json.dumps({'status': 'PASS_STAGED544_NEUTRAL_FIXED_D2', 'provider': args.provider, + 'first_counts': result['pair_census']['first_counts'], + 'result_sha256': hashlib.sha256(json.dumps(result, sort_keys=True, separators=(',', ':')).encode()).hexdigest(), + 'new_supplier': False}, sort_keys=True)) + +if __name__ == '__main__': + main()