diff --git a/research/p104-delayed-precision/NOTICE.md b/research/p104-delayed-precision/NOTICE.md new file mode 100644 index 0000000000..53bf10600c --- /dev/null +++ b/research/p104-delayed-precision/NOTICE.md @@ -0,0 +1,33 @@ +# Source notice + +New precision replay, stream exporter, tests and proof are Apache-2.0 under the +repository LICENSE. + +`producer.py` is retained byte-for-byte from Jose Manuel / jmbarrancoml's +PR2139, commit `1df674ca8e9d9e0fb98ba4df402b648e9b3be0a4`, at +`research/p104-delayed-query-side/verify.py`. The original README and source +manifest are preserved under `predecessor/`, including their original notices +and disclosures. The exporter and literal stream are not a newly claimed +P104 construction. + +The producer consumes Ali Romman's `research/native-source-codes/source_data.py` +and its immutable selected archive. Its original source-word, Hamming packet, +mutable-source/target, native compiler and hosting credits remain authoritative. +The native fixture and compiler/interpreter are inherited through Rohan Arun / +PR1972 and Chafik Boukhalfa / PR1991. Adam Gall / PR1940 and Josie Elliston / +PR1071 supply the preceding delivery geometry. Compiler credit remains with +icekylinx and the retained native lineage; the independent Gaussian interpreter +is Ali Romman's PR1862/PR1931 lineage. + +Relevant unchanged notice files remain at: + +- `research/native-source-codes/README.md` and its source manifest. +- `research/p104-native-channel/notices/`. +- `research/gauge44-slots-t16/NOTICE.md` and `UPSTREAM-NOTICE.md`. +- The selected archive's pinned source credits, listed by + `research/native-source-codes/source_data.py` in `CREDIT_PINS`. + +Adam Gall / PR2096, exact head `f22626f334a06f6e842766e4a6647419e6821d2d`, +supplies the Hilbert-norm independent-defect and state-relative feedback method +on the different G/2 channel. No code or numerical constant from that package +is copied here. Its combined-word precision handoff motivated this check. diff --git a/research/p104-delayed-precision/README.md b/research/p104-delayed-precision/README.md new file mode 100644 index 0000000000..159d0aa525 --- /dev/null +++ b/research/p104-delayed-precision/README.md @@ -0,0 +1,246 @@ +# Precision of the completed delayed-query P104 word + +This supplies a finite local precision implication for Jose Manuel's +[PR2139](https://github.com/CrocSwap/integer-mult-bounds/pull/2139), exact head +`1df674ca8e9d9e0fb98ba4df402b648e9b3be0a4`. It does not supply a rounded +recursive implementation, an admitted supplier or a new exponent. The +predecessor's unfavorable fixed-profile cost screen remains unchanged. + +Adam Gall's [PR2096](https://github.com/CrocSwap/integer-mult-bounds/pull/2096) +checks precision for the different `G/2` channel. Its next question 2 asks for +combined prefix/error maps once a corrected chronological word is available. +This result checks that implication on PR2139's completed forward identity +word, rather than transferring the old channel's constants. + +## Exact result + +The norm is the maximum of individual register Hilbert norms. It is not the +addresswise maximum norm. Let every independent initial register have norm +at most `B`. + +| All-cut quantity | Exact coefficient | +| --- | ---: | +| Ideal input-to-register row norm `P` | 131072 | +| Accumulation of independent unit absolute defects `A` | 1394705 | +| Accumulation of independent weighted defects `K` | 2134050 | + +All three first attain their maxima after combined event **33373**, in source +register **93**. Events are zero-based: 7686 initial compensation additions, +then the predecessor's 26647 actions. The attaining instruction is +`source93 -= 8*source103`. Its ideal row is + +``` +-65536 * input86 - 65536 * input93. +``` + +Input86 is one of the omitted source ports and is an arbitrary dirty helper. +The final source row is just input93. The final target rows are `Y_t + X_t`, +and all 628 dirty helpers restore their own inputs. Thus the ideal endpoint +maximum of two cannot replace the all-cut coefficient 131072. + +[RESULT.json](RESULT.json) contains the complete 2-input and 29-defect +attaining rows, all-cut norm-stream hash and endpoint error maxima. The +checker visits every changed register after every instruction; untouched +registers retain their preceding norm. Exact adapters preserve Hilbert norm, +and exact resets cannot increase it. This covers the initial boundary and +all 34333 subsequent instruction boundaries, not sampled cuts. + +There are 32722 defect sites: 28108 additions, 707 scales and 3907 positive +native transports. There are also 32 exact private resets and 1579 exact +phase/adapter annotations. The eight private copies are additions following +owned initialization, not eight uncharged extra operations. Their later +reset does not erase defects already propagated to another register. + +The full paid profile stays +`2564 H1 + 547 H2 + 432 H3 + 142 H4 + 83 H5 + 128 H6 + 11 H7`, +with rank mass 6782. No precision or recursive charge is removed. + +## Error contract and proof + +### Literal scalar reduction + +Use the predecessor's actual common unitary charts. A physical register at a +cut is `Gamma_W z`. Each exact native transport is +`Gamma_new Gamma_old^-1`; additions and scales have their literal rational +coefficients in logical coordinates. Boundary monomial factors are exact. +The inherited normalized Clifford factors are unitary in Hilbert norm; this +is not a claim of addresswise contraction. + +An additive physical output defect at site `j` becomes +`eta_j = Gamma_after_j^-1 e_j`, with the same Hilbert norm. Therefore every +cut row has the exact form + +``` +z_r = sum_s a[r,s] * input_s + sum_j c[r,j] * eta_j. +``` + +The implementation retains signed dyadic coefficients until it takes the +row's absolute sum. At every updated row it checks cached input, absolute and +weighted norms against direct reductions of the complete coefficient maps. +It does not multiply positive majorants throughout the word. A separate +reverse-adjoint recurrence uses `Fraction` arithmetic and +agrees on the attaining rows. Sign-aligned forward executions attain `P`, +`A` and `K`. For arbitrary independent vectors, choose one unit vector and +align each input or logical defect with the sign of its row coefficient. +Unitary charts convert those logical defects to physical defects with the +same norm. This proves sharpness for **independent additive vector defects**, +not for correlated rounding errors. + +Exact private reset replaces only its current row by zero. Existing error +symbols in other registers survive. Each later instruction has a fresh +error symbol, so reusing the private field cannot alias different lifetimes. +The replay independently checks all 844 initial columns, including the eight +private columns, against the completed endpoint and full frame contract. + +### Absolute defects + +If every defect has norm at most `delta`, every cut has error at most +`1394705 * delta`. This finite independent-defect coefficient is sharp. +For example, `delta <= B * 2^(-b-21)` suffices for all-role error at most +`B * 2^-b` for any integer `b >= 0`. + +### State-relative feedback + +Assume exact dyadic coefficients and a common `u >= 0` satisfying these +completed-instruction output-defect bounds on the actual perturbed operands: + +- Native transport: `u * ||input||`. +- Addition `dst += a*src`: `u * (||dst_before|| + |a|*||src_before||)`. +- Scale `dst *= a`: `u * |a| * ||dst_before||`. + +Resets and monomial factors are exact. A recursively implemented transport +must first meet this completed-output contract; its internal errors are not +analyzed here. For a copy expressed as an addition after exact reset, the +addition hypothesis is sufficient, but may overestimate its actual error. + +Put `w_j=1`, `1+|a|`, or `|a|` respectively at those sites. The sharp weighted +independent-defect coefficient is `K=2134050`. If `M` is the maximum actual +register norm over the finite execution, then + +``` +M <= 131072*B + 2134050*u*M. +``` + +When `2134050*u < 1`, rearranging gives + +``` +M <= 131072*B / (1 - 2134050*u), +max_boundary_error <= 131072*2134050*u*B / (1 - 2134050*u). +``` + +For every integer `b >= 0`, **`u <= 2^(-b-39)` suffices** for all-cut error at +most `B*2^-b`. Indeed, + +``` +K*(P+1) = 279716335650 < 2^39, +P*K = 279714201600 > 2^38. +``` + +For `b >= 0`, `K*(P*2^b+1) <= K*(P+1)*2^b < 2^(b+39)`, which proves the +claim for all `b`, not only the tested examples. The second inequality means +38 uniform guard bits fail this particular sufficient feedback estimate. +It does not prove a minimal numerical precision requirement. This estimate also does not justify subtracting 39 +bits from, or replacing, the selected production precision bill. + +## Source binding and replay + +[producer.py](producer.py) is byte-for-byte PR2139's original `verify.py`. +Its original README and source manifest are under [predecessor/](predecessor/). +`export_word.py` authenticates inputs before importing that producer, observes +only the return of its `main` function, and exports its actual initial frames, +final frames, every compensation coefficient, every action and frame basis. +It does not alter the producer's operations or checks. The registered replay +reconstructs and compares **every** exported field, not just a profile or hash +from a submitted receipt. Native mode also runs the predecessor's 241 new +recipe checks, all 421 bindings and its global-phase rejection control. +Original selected native recipes retain their inherited proof and pins; this +is not a fresh audit of every retained Clifford recipe. + +The default precision replay reads only `WORD.json.gz` and `RESULT.json`, +needs neither Git nor network and writes nothing. It verifies the complete +uncompressed word SHA256 before parsing. Full producer rebinding requires +Git history for the original selected archive. Compressed bytes are not the +mathematical regeneration comparison. + +From the repository root, standard-library CPython 3.12: + +```sh +python3.12 -I -O -W error -B research/p104-delayed-precision/verify.py +python3.12 -I -O -W error -B research/p104-delayed-precision/test_verify.py +python3.12 scripts/research_package.py --package research/p104-delayed-precision --check-only +python3.12 scripts/research_package.py --package research/p104-delayed-precision +``` + +`verify.py --write NEW_PATH` and `export_word.py --write NEW_PATH` create new +files exclusively. The behavior suite checks seven separate endpoint adjoints, +dyadic coefficient extremes, private-defect survival after discard, missing +clear and baseline compensation, illegal charts, receipt/word corruption, +changed-producer rejection before import, no overwrite, capacity limits and +relocated read-only normal/optimized execution. + +Observed locally on Linux x86_64 with CPython 3.12.15: the complete registered +replay passes, including new native phase checks and all nine behavior tests +in normal and optimized modes. The 65 repository research-workflow tests and +`python3 -B scripts/research_baseline.py` also pass. The latter checks selected +source bindings only, not the selected cold replay. No hosted CI pass, +proof-assistant run or independent human review is claimed. + +### Implementation bounds + +New replay loops have fixed stream bounds: 844 roles, 1008 frames of at most +nine generators, 34333 events and at most one defect symbol per event. Input +files are capped at 4 MiB compressed and decompressed. Receipt generation +observed at most 671250 live error coefficients and a maximum row denominator +of 54 bits. The optimized direct replay took 3.27 seconds with 114768 KiB peak +RSS on the stated Linux/Python environment. These are local measurements, +not portable resource guarantees. The registered commands have explicit +120/240-second limits. + +Python requires dynamic allocation and dictionary dispatch. These are +managed-runtime deviations from Power of Ten rules 3 and 9, bounded by the +fixed domain above; there is no ambient registry or unbounded queue. Rule 8 +also has a narrow replay-only deviation for importing the authenticated +producer and a return-profile callback with one known target, restored in +`finally`. The independent precision verifier does neither. All new functions +fit within 60 lines; Python warnings are errors in the registered checks. +No separate type checker or linter was available locally; strict compilation +and execution are the available diagnostics, not a substitute for type analysis. +The preserved producer and loader contain long functions and historical +library/control-flow patterns. They remain immutable predecessor inputs, +not refactored code. Their compensating controls are source authentication, +fixed input geometry, exact regeneration and bounded replay. A future +predecessor API change would require a separately source-bound successor. + +## Open next questions + +1. Bind an actual rounded rank-1 through rank-7 child to the completed-output + Hilbert defect hypothesis. First test the exact rounding convention at + `u <= 2^(-b-39)`. The missing implementation/interface, not native unitarity, + blocks recursive precision admission. +2. Reduce the source93 transient while retaining the full dirty boundary and + bill. First inspect the gauge/scalar cleanup interval around event33373, + propose one exact resynthesis, and replay all columns and paid operations. + Common-chart legality and arbitrary dirty restoration are required. + +Global owners, the dual word, tape/all-size lifting and supplier admission +remain open. PR2139's fixed-profile cost obstruction still applies. Neither +finite precision implication nor automated verification is a complete +multiplication theorem or independent human review. + +## Credit and freshness + +Jose Manuel / PR2139 supplies the entire corrected construction. Adam Gall / +PR2096 supplies the Hilbert-defect and feedback method on the older channel; +no constants or code from that package are imported. Rohan Arun / PR1972, +Chafik Boukhalfa / PR1991, Ali Romman's source reconstruction and Gaussian +interpreter, Adam Gall / PR1940, Josie Elliston / PR1071, icekylinx's Clifford +lineage and the selected Hamming/dirty-helper contributors retain their +original attribution. See [NOTICE.md](NOTICE.md) and the retained source +manifest. New material is Apache-2.0. + +The scientific base is canonical main +`0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2`, priority revision 4. The sole chooser +nonce is `159427fb87da401855d7b74679378fb5`. [TASK.json](TASK.json) records the +changed scope and overlap limits. The canonical coordination claim is in +[Discussion2121](https://github.com/CrocSwap/integer-mult-bounds/discussions/2121#discussioncomment-18934115). +No selected record, frozen predecessor or review disposition is changed. diff --git a/research/p104-delayed-precision/RESULT.json b/research/p104-delayed-precision/RESULT.json new file mode 100644 index 0000000000..15b2b4d761 --- /dev/null +++ b/research/p104-delayed-precision/RESULT.json @@ -0,0 +1,310 @@ +{ + "all_cut_norms_sha256": "ef479ccafbbbfe94b37447cdef3def907f870c7f6fdf6a68759cf2473fc72651", + "all_cut_peaks": { + "absolute": { + "event": 33373, + "register": 93, + "value": "1394705", + "witness": [ + [ + 7691, + "-65536" + ], + [ + 19242, + "-65536" + ], + [ + 19243, + "65536" + ], + [ + 19245, + "-65536" + ], + [ + 19254, + "-65536" + ], + [ + 19255, + "65536" + ], + [ + 19257, + "-65536" + ], + [ + 19298, + "-65536" + ], + [ + 19299, + "-65536" + ], + [ + 19300, + "-65536" + ], + [ + 20913, + "-65536" + ], + [ + 22867, + "-65536" + ], + [ + 25350, + "-65536" + ], + [ + 25353, + "65536" + ], + [ + 25355, + "65536" + ], + [ + 25679, + "-65536" + ], + [ + 26768, + "-65536" + ], + [ + 27760, + "-65536" + ], + [ + 27768, + "32768" + ], + [ + 31855, + "32768" + ], + [ + 31898, + "65536" + ], + [ + 31952, + "65536" + ], + [ + 31954, + "8192" + ], + [ + 33167, + "8192" + ], + [ + 33175, + "-1024" + ], + [ + 33195, + "-1024" + ], + [ + 33196, + "-8" + ], + [ + 33370, + "-8" + ], + [ + 33373, + "1" + ] + ] + }, + "input": { + "event": 33373, + "register": 93, + "value": "131072", + "witness": [ + [ + 86, + "-65536" + ], + [ + 93, + "-65536" + ] + ] + }, + "relative": { + "event": 33373, + "register": 93, + "value": "2134050", + "witness": [ + [ + 7691, + "-65536" + ], + [ + 19242, + "-65536" + ], + [ + 19243, + "65536" + ], + [ + 19245, + "-65536" + ], + [ + 19254, + "-65536" + ], + [ + 19255, + "65536" + ], + [ + 19257, + "-65536" + ], + [ + 19298, + "-65536" + ], + [ + 19299, + "-65536" + ], + [ + 19300, + "-65536" + ], + [ + 20913, + "-65536" + ], + [ + 22867, + "-65536" + ], + [ + 25350, + "-65536" + ], + [ + 25353, + "65536" + ], + [ + 25355, + "65536" + ], + [ + 25679, + "-65536" + ], + [ + 26768, + "-65536" + ], + [ + 27760, + "-65536" + ], + [ + 27768, + "32768" + ], + [ + 31855, + "32768" + ], + [ + 31898, + "65536" + ], + [ + 31952, + "65536" + ], + [ + 31954, + "8192" + ], + [ + 33167, + "8192" + ], + [ + 33175, + "-1024" + ], + [ + 33195, + "-1024" + ], + [ + 33196, + "-8" + ], + [ + 33370, + "-8" + ], + [ + 33373, + "1" + ] + ] + } + }, + "defect_sites": 32722, + "endpoint_error_maxima": { + "dirty_helper": { + "absolute": "131727/4", + "relative": "11940483/256", + "roles": 628 + }, + "private": { + "absolute": "0", + "relative": "0", + "roles": 8 + }, + "source": { + "absolute": "3226355727/131072", + "relative": "3231272975/131072", + "roles": 104 + }, + "target": { + "absolute": "13259/4", + "relative": "20699/4", + "roles": 104 + } + }, + "events": 34333, + "evidence": [ + "full arbitrary-input endpoint and paid profile", + "three reverse cut identities", + "three sign-aligned attaining executions" + ], + "maximum_live_error_coefficients": 671250, + "maximum_row_denominator_bits": 54, + "op_counts": { + "add": 28108, + "exact": 1579, + "reset": 32, + "scale": 707, + "transport": 3907 + }, + "paid_mass": 6782, + "roles": 844, + "scope": "Finite completed forward word, conditional unitary-chart/completed-child defect contract. No rounded-child, global hosting, all-size, supplier or kappa claim.", + "status": "PASS_P104_DELAYED_PRECISION", + "uniform_relative_guard_bits": 39, + "word_sha256": "8be1f3c659d887030fa70afdbdeca38fbfbaea1b2a57b1783d3669e92816545c" +} diff --git a/research/p104-delayed-precision/SOURCES.json b/research/p104-delayed-precision/SOURCES.json new file mode 100644 index 0000000000..3aa9bf2c27 --- /dev/null +++ b/research/p104-delayed-precision/SOURCES.json @@ -0,0 +1,66 @@ +{ + "schema_version": 1, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "predecessors": [ + { + "author": "Jose Manuel / jmbarrancoml", + "pr": 2139, + "head": "1df674ca8e9d9e0fb98ba4df402b648e9b3be0a4", + "path": "research/p104-delayed-query-side/verify.py", + "retained_as": "research/p104-delayed-precision/producer.py", + "sha256": "c948f0d726399b1a4503af3b6468566be270f86229e5d0d29a2b62bf4d4e553a", + "scope": "Entire completed forward construction and inherited native checks, retained byte-for-byte. Original README and source manifest are under predecessor/." + }, + { + "author": "Adam Gall", + "pr": 2096, + "head": "f22626f334a06f6e842766e4a6647419e6821d2d", + "scope": "Hilbert-norm, independent-defect and state-relative feedback method on the different G/2 word. No code or constants are imported." + } + ], + "word_payload_sha256": "8be1f3c659d887030fa70afdbdeca38fbfbaea1b2a57b1783d3669e92816545c", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "e8870e5917057d59b730eb14721a778639eca050", + "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7" + }, + { + "path": "research/native-source-codes/source_data.py", + "usage": "input", + "git_blob": "c9d465ed47500304bef65fcb588befe356c5cf09", + "sha256": "d23924511e3aed41e5e64511ca70126a636d91c8aa02e656cb61d6ceca1fe0a0" + }, + { + "path": "research/p104-native-channel/inputs/P104-FIXTURE.json", + "usage": "input", + "git_blob": "2e16f99b295bb386fd13bd8fbd57b42ef54143a9", + "sha256": "516c06f6ec3cb84be588c546108de897650288576dd5fbf5fe44b9c5546ad8a4" + }, + { + "path": "research/community-frontier1042-audit/selected-replay.tar.gz", + "usage": "input", + "git_blob": "6f4dc6fe7631d8aacf8081fcaecf32197181685b", + "sha256": "22c3f4dce4b897a1d423d1388801933e288b6a6b1906cb15e1b16a5eb68db754" + }, + { + "path": "research/p104-native-channel/vendor/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "path": "research/p104-native-channel/vendor/native_verify.py", + "usage": "input", + "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + } + ] +} diff --git a/research/p104-delayed-precision/TASK.json b/research/p104-delayed-precision/TASK.json new file mode 100644 index 0000000000..c34d855f3c --- /dev/null +++ b/research/p104-delayed-precision/TASK.json @@ -0,0 +1,107 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "priority_revision": 4, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "original_card": { + "id": "p104-side-correction", + "question": "Can the native P104 low-rank channel be completed with a legal, fully charged I-G/2 side correction?", + "starting_points": [ + "research/p104-native-channel/README.md", + "research/p104-native-channel/PROOF.md", + "docs/research/community-efficient1000-review.md" + ], + "methods": [ + "Construct one side-correction word at an explicit chronological cut with the needed frames still available.", + "Derive a lower bound on the side correction and hosting costs that decides whether this channel can beat the selected budget." + ], + "acceptance_gate": "An exact arbitrary-input identity, source/target frame availability and restoration at the chosen cut, plus the complete channel+correction+idle/hosting bill or an explicit favorable bound. The native channel alone is not a supplier.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the P104 open next questions and its fixed local histogram; inspect why appending I-G/2 after source completion is not justified. #1991 supplies the checked native channel, not the missing correction.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "first_experiment": "Choose one exact side-correction cut and bound its allowed cost from a favorable completed moment at a declared target. Stop or hand off if the necessary source/target access cannot be justified or even the optimistic total misses the target.", + "bottleneck_link": "Completing an already realized changed channel tests a concrete construction opportunity, instead of refining the incumbent packing. A positive local result still needs global and all-size admission.", + "allowed_variations": [ + "One correction factorization, one chronological cut, or one explicit hosting obstruction.", + "A changed correction schedule with an updated full bill and native frame contract." + ], + "scope_change_triggers": [ + "Recompiling the already certified low-rank channel without closing a new obligation.", + "Treating a pending ancestor, local histogram or unpriced side correction as an admitted global supplier." + ], + "overlap_terms": [ + "P104", + "I-G/2", + "side correction", + "native channel", + "1972", + "1991" + ] + }, + "scope_status": "changed", + "actual_scope": "Source-bound all-instruction-cut input and defect coefficients for PR2139's completed forward P104 identity word, including its initial compensation, 628 arbitrary dirty helpers and eight owned private-copy lifetimes.", + "scope_change_reason": "The live overlap supplied a completed chronological identity word in PR2139 and a precision handoff in PR2096 question 2. This closes that finite local implication rather than duplicating a correction construction. The older G/2 word's constants cannot be transferred to this changed producer. PR2139's unfavorable fixed-profile cost screen is retained, not reopened.", + "bottleneck_link": "A completed P104 mechanism still needs a local precision interface before any recursive admission. This result measures that obligation on the exact combined word and supplies a reusable benchmark for changed carrier paths; it does not pass the original supplier-construction gate.", + "budget_minutes": 60, + "stop_rule": "Stop after the literal word binding, exact finite all-cut bound, independent reverse/Fraction checks and failure controls. Do not redesign the word, improve its owner packing or claim a rounded-child or all-size implementation.", + "outcome": "completed", + "evidence": "WORD.json.gz rebinds every stream field to the unchanged PR2139 producer. RESULT.json records P=131072, A=1394705, K=2134050 and 39 sufficient relative guard bits. The independent verifier checks all 844 input columns, every instruction cut and the complete profile; reverse adjoints and sign-aligned executions check the peak witnesses.", + "author": "Nick Petalas", + "ai_assistance": "Acceptance evidence consists of automated checks, not independent human review or proof-assistant verification.", + "chooser_nonce": "159427fb87da401855d7b74679378fb5", + "scientific_predecessor_head": "1df674ca8e9d9e0fb98ba4df402b648e9b3be0a4", + "discussion": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2121#discussioncomment-18934115", + "entry_overlap": { + "open_prs": 403, + "discussions": 826, + "complete_pagination": true, + "warnings": [], + "checked_at_utc": "2026-10-14T21:03:22Z", + "limits": "Titles, bodies, comments/replies and local package metadata, not all code diffs, closed history or unpublished work. No-match does not prove novelty." + }, + "submission_checkpoint": { + "canonical_main": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "priority_revision": 4, + "checked_at_utc": "2026-10-14T21:31:14Z", + "relevant_changes": "None. Canonical main, selected record and both pending predecessor heads are unchanged.", + "open_prs": 415, + "discussions": 837, + "complete_pagination": true, + "warnings": [], + "overlap_delta": "The targeted precision search matched this claim and an unrelated cyclic Fourier local note. The final all-P104 refresh adds PR2163's max-flow audit of the frozen cut family, not this changed producer's precision obligation. Entry and submission coverage do not include all diffs or unpublished work." + }, + "verification": { + "environment": "CPython 3.12.15, Linux x86_64, standard library only", + "commands": [ + "python3.12 scripts/research_package.py --package research/p104-delayed-precision --check-only", + "python3.12 scripts/research_package.py --package research/p104-delayed-precision", + "python3.12 -I -O -W error -B research/p104-delayed-precision/verify.py", + "python3.12 -W error -B -m unittest discover -s tests -p 'test_research_*.py'", + "python3 -B scripts/research_baseline.py" + ], + "behavior_groups": 9, + "repository_research_tests": 65, + "unrun": "No full selected cold replay, fresh native audit of every retained recipe, rounded recursive child, global owner/dual/tape/all-size admission, proof assistant or independent human review." + }, + "open_questions": [ + { + "question": "Does an actual rounded rank-1 through rank-7 child meet this completed-output Hilbert defect contract?", + "why_it_matters": "A symbolic local feedback implication does not establish recursive numerical stability or permit removal of the production precision charge.", + "first_step": "Bind one actual child implementation's rounding convention to u <= 2^(-b-39), then test its complete output defect, not just a native factor's norm.", + "blocked_by": "No rounded-child implementation or all-size error contract is supplied here." + }, + { + "question": "Can the source93 transient be reduced while preserving the completed word's dirty boundary and full bill?", + "why_it_matters": "All three peaks occur after source93 -= 8*source103; its ideal row is -65536*(input86+input93), despite a final unit source row. This creates substantial interior amplification.", + "first_step": "Inspect the gauge/scalar cleanup interval around combined event33373, propose one exact resynthesis, and replay all 844 columns plus the full transport and coefficient invoice.", + "blocked_by": "A changed scalar order or scale must retain legal common charts and arbitrary dirty restoration; a local norm reduction is not a supplier or exponent improvement." + } + ] +} diff --git a/research/p104-delayed-precision/VERIFY.json b/research/p104-delayed-precision/VERIFY.json new file mode 100644 index 0000000000..4a4fc3997b --- /dev/null +++ b/research/p104-delayed-precision/VERIFY.json @@ -0,0 +1,35 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/native-source-codes/source_data.py", + "research/community-frontier1042-audit/selected-replay.tar.gz", + "research/p104-native-channel/inputs/P104-FIXTURE.json", + "research/p104-native-channel/vendor/clifford_exact.py", + "research/p104-native-channel/vendor/native_verify.py" + ], + "commands": [ + { + "argv": ["{python}", "-I", "-W", "error", "-B", "{package}/verify.py"], + "timeout_seconds": 120, + "checks": "All 844 input columns, every instruction cut, complete profile, signed sensitivity peaks, independent reverse cut identities and constructive attainment." + }, + { + "argv": ["{python}", "-I", "-W", "error", "-B", "{package}/export_word.py", "--check", "--native"], + "timeout_seconds": 240, + "checks": "Authenticate and run the unchanged PR2139 producer, compare every literal-stream field and run its 241 new native recipes / 421 occurrence bindings and phase control. Full Git history is required." + }, + { + "argv": ["{python}", "-I", "-W", "error", "-B", "{package}/test_verify.py"], + "timeout_seconds": 120, + "checks": "Fraction arithmetic, seven endpoint adjoints, private-defect survival, malformed chart/clear/compensation controls, guard boundaries, relocated read-only normal/optimized replay, corrupted source/receipt and no overwrite." + }, + { + "argv": ["{python}", "-I", "-O", "-W", "error", "-B", "{package}/test_verify.py"], + "timeout_seconds": 120, + "checks": "Repeat the behavior suite with Python assertions disabled." + } + ] +} diff --git a/research/p104-delayed-precision/WORD.json.gz b/research/p104-delayed-precision/WORD.json.gz new file mode 100644 index 0000000000..44bc431a2d Binary files /dev/null and b/research/p104-delayed-precision/WORD.json.gz differ diff --git a/research/p104-delayed-precision/export_word.py b/research/p104-delayed-precision/export_word.py new file mode 100644 index 0000000000..217706f4dc --- /dev/null +++ b/research/p104-delayed-precision/export_word.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +"""Rebind a literal stream to the unchanged, hash-pinned PR2139 producer.""" +import argparse +import contextlib +import gzip +import hashlib +import importlib.util +import io +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PRODUCER_SHA256 = "c948f0d726399b1a4503af3b6468566be270f86229e5d0d29a2b62bf4d4e553a" + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def authenticate(): + raw = (HERE / "producer.py").read_bytes() + need(hashlib.sha256(raw).hexdigest() == PRODUCER_SHA256, + "unchanged PR2139 producer authentication") + pins = json.loads((HERE / "SOURCES.json").read_text()) + for item in pins["files"]: + if item["usage"] == "input": + raw = (ROOT / item["path"]).read_bytes() + need(hashlib.sha256(raw).hexdigest() == item["sha256"], + "source authentication: " + item["path"]) + + +def capture(native): + """Observe only main's return; never replace an algorithm or its checks.""" + path = HERE / "producer.py" + spec = importlib.util.spec_from_file_location("p104_precision_producer", path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + result = {} + + def returned(frame, event, unused): + if event == "return" and frame.f_code is module.main.__code__: + result.update(frame.f_locals) + + old_argv, old_profile = sys.argv, sys.getprofile() + sys.argv = [str(path)] + (["--native"] if native else []) + output = io.StringIO() + try: + with contextlib.redirect_stdout(output): + sys.setprofile(returned) + module.main() + finally: + sys.setprofile(old_profile) + sys.argv = old_argv + report = json.loads(output.getvalue()) + need(report["status"] == "PASS_CANONICAL_P104_DELAYED_SIDE_PROTOTYPE", + "predecessor endpoint checks") + need(report["actions"] == 26647 and report["baseline_compensation_adds"] == 7686, + "complete producer instruction inventory") + need(all(report["controls"].values()), "predecessor semantic controls") + if native: + checked = report["native_new_recipe_check"] + need(checked == {"status": "PASS_NEW_NATIVE_RECIPES", "distinct_recipes": 241, + "paid_occurrences": 421, "global_phase_control": "REJECT"}, + "predecessor new native checks") + return result + + +def exported(result): + compensation = [[t, s, str(q)] for t, s, q in result["compensation"]] + value = {"schema_version": 1, "total_roles": result["total"], + "live_ports": result["live"], "frame_bases": result["frame_bases"], + "initial_frames": result["initial"], "final_frames": result["cur"], + "compensation": compensation, "actions": result["actions"]} + need(value["total_roles"] == 844 and len(value["actions"]) == 26647, + "bounded stream geometry") + raw = canonical(value) + need(len(raw) <= 4 * 1024 * 1024, "literal stream size bound") + return raw + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument("--write", type=Path, help="create a new compressed literal stream") + group.add_argument("--check", action="store_true", help="compare every exported field") + parser.add_argument("--native", action="store_true", help="also run the predecessor native checks") + args = parser.parse_args() + authenticate() + raw = exported(capture(args.native)) + if args.write: + with args.write.open("xb") as stream: + stream.write(gzip.compress(raw, mtime=0)) + else: + with gzip.open(HERE / "WORD.json.gz", "rb") as stream: + frozen = stream.read(4 * 1024 * 1024 + 1) + need(len(frozen) <= 4 * 1024 * 1024, "frozen stream size bound") + need(raw == frozen, "complete regenerated literal stream") + print("PASS_P104_DELAYED_WORD_REBIND sha256=" + hashlib.sha256(raw).hexdigest() + + " new_native=" + str(args.native)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-delayed-precision/predecessor/README.md b/research/p104-delayed-precision/predecessor/README.md new file mode 100644 index 0000000000..b317b752c6 --- /dev/null +++ b/research/p104-delayed-precision/predecessor/README.md @@ -0,0 +1,267 @@ +# A P104 side word with delayed query inputs + +I construct a finite forward P104 identity word by inserting four delayed +queries into the selected side producer and obtaining four more queries from +its omitted target rows. This replaces the separate gather/delivery architecture +of PR1972/1991. I retain eight rank-seven private descents, hence COPY56. + +The exact local profile is + +``` +2564 H1 + 547 H2 + 432 H3 + 142 H4 + 83 H5 + 128 H6 + 11 H7. +``` + +Its rank mass is 6782: persistent frame progress 6726 plus COPY56. I replay +all 836 persistent inputs and eight arbitrary private inputs. I check 241 new +native recipes covering 421 paid occurrences, including their global phases. +The 628 dirty helpers regain their logical inputs at their declared output +frames. This is a finite forward construction, not a globally admitted supplier. + +I also prove a limit for this fixed profile. Under the paired-chain coverage +law and halving guard, no stage count, owner packing or fully paid auxiliary +bank choice reaches the saving selected at this package's base. The best +among the fifteen small-stage screens has a favorable moment above +1.000554 at that saving. A separate entropy inequality covers all larger +stage counts. I do not claim an exponent improvement. + +## Contract and sources + +Use the 104 root ports in the pinned PR1972/1991 fixture, expressed in the +selected Hamming gauge. Source X_t enters with intrinsic frame C_qt and exits +at F9. Target Y_t enters at I and exits at F9 C_qt^-1, with logical value +Y_t+X_t. The source logical values remain unchanged. + +The helper inventory is: + +| Group | Count | Boundary | +| --- | ---: | --- | +| Retained selected-side helpers | 480 | Retained native entry/exit frames | +| Omitted C-source ports | 8 | I to FULL | +| Omitted C-target ports | 8 | I to FULL | +| Early query carriers | 20 | I to FULL | +| Late query carriers | 112 | I to FULL | + +All 628 helper inputs are independent and arbitrary. Logical restoration +does not mean that their charged frame transforms disappear. The eight owned +private fields may start dirty; the word clears them before use and finishes +with zero private outputs. It reuses one private field for eight copy/drop +lifetimes under the inherited private-copy convention. I do not claim a +reversible uncomputation of each discarded copy. + +The producer is the exact center-free selected word reconstructed by Ali +Romman's `native-source-codes/source_data.py`, with its frozen archive and +original credits. I do not substitute the newer P104 low-rank word for it. +The fixture still comes from Rohan Arun's PR1972 through Chafik Boukhalfa's +PR1991. SOURCES.json pins these inputs and the native compiler/interpreter. + +## Algebra of the combined word + +Write G for the P104 Gram matrix and + +``` +D[t,k] = , +T[s,k] = 2 / , +D T^transpose = 2 G. +``` + +If a side producer on P104 union {a_k} receives ordinary inputs x and +pseudo-inputs z_k=-(q_k+T_k^transpose x)/2 at a_k, its 104 requested rows give + +``` +(I-G/2)x + D(q+T^transpose x)/4. +``` + +Initial compensation -Dq/4 makes this x. The mixed deleted basis {b_k} is +not the coordinate frame, so label substitution into the selected P112 word +does not establish that producer. I implement the identity through two +different query cuts in the selected word instead. + +Four a_k lie in the second deleted orthogonal frame C. In selected indices +they are X81, X86, X54 and X25. The corresponding coordinate-center rows at +axes 3,4,5,6 have diagonal coefficients g=(-1,-1,1,-1) on these four inputs, +and zero off-diagonal coefficients. Run A with arbitrary inputs h at those +ports. At the A cut, query Q_i contains g_i h_i plus the ordinary source +query and helper dirt. Add delta_i=-Q_i/g_i along the A-state response to +input i. The effective source value h_i+delta_i has no h_i contribution. +The other initial-dirt terms have known linear coefficients and receive +frame-zero compensation. + +The other four b_k lie in C. Their completed code-only target rows satisfy + +``` +Y_b = eta_b - (1/2) sum_s x_s. +``` + +All C-source columns vanish in those rows because the roots of C are +orthogonal. Thus they do not depend on the early delayed inputs. Put +g=. Copy -Y_b/g from b_k-perp, descend seven ranks to , and +deliver with coefficient D[t,k]. The dirty eta_b term receives initial +compensation; the remaining term is the required Gram contribution. + +## Early injection and arbitrary dirt + +At original event 12550, each early source column has six relevant rows in +five non-FULL frames. `verify.py` lists their exact registers, coefficients +and frame IDs. The five frames form an antichain: one has rank two and four +have rank three. A private query copy descends to and feeds five new +dirty carriers there. Each carrier then climbs to its injection frame. + +The program treats the twenty carrier inputs as independent, rather than +assuming a shared dirty value. One carrier needs a later repair: after +original event 16592 it climbs from frame230 to frame240 and subtracts its +whole content from L341. L341 has no later scalar consumer at that frame. +The other nineteen carriers need no non-FULL repair. + +Immediately before original event17846, all remaining non-Y responses of +the twenty carriers lie at FULL. The four original query registers L224, +L11, L240 and L9 still hold their A-cut values and have zero response to the +injections. The program makes 135 FULL-frame additions to cancel the +non-Y responses, then twenty additions c_i+=Q_i/g_i to restore the carriers. +It runs the original full-frame cleanup afterward, unchanged. Skipping the +query registers' original cleanup would be incorrect because later cleanup +operations read them. + +The twenty carrier paths cost + +``` +24 H1 + 17 H2 + H5 + 16 H6 + 3 H7, +``` + +with rank mass 180. Their progress belongs to new dirty helper paths; it is +not an uncharged private ascent or an extra copied-information descent. + +## Late-query chronology + +The verifier constructs a dependency DAG that preserves strict access order +on each original register, including reads. It removes only the original +center phase. It first executes A and the dependency ideal needed to finish +the four b_C target rows, then resumes the remaining events. + +This query-ready cut contains 13,412 original events. The four final query +writes are events16453,16309,16173,15955 on Y110,Y106,Y8,Y50. None of the 208 +required live-target upper climbs belongs to that dependency ideal. Each +target therefore still has its requested rank-seven read interval available. +The verifier checks each actual common frame in the reordered word. + +For each of the four late queries, 28 carriers serve its 52 targets. The +112 carriers each follow ranks 0 to1 to7 to9, giving + +``` +112 H1 + 112 H6 + 112 H2. +``` + +The chosen read occurs after the target's last target-basis mixing or scale, +so the remaining word does not alter its coefficient. At the full-frame +cleanup cut, the omitted query targets climb to FULL. Their still-live values +restore the carriers. After the original cleanup, the program removes each +omitted target's side increment using restored FULL source values. + +## Verification and native frames + +The checker derives the new initial compensation from an exact formal-row +replay and checks that every required input is available at frame zero. It +then replays the resulting program from scratch on all 844 formal columns. +This proves the linear boundary identity for arbitrary address functions: +each scalar operation acts in one common chart, and each checked native +transport preserves its logical row. + +With `--native`, the retained Gaussian-dyadic compiler lowers each new +transport. The separate interpreter compares signed Pauli actions and an +exact nonzero state column, fixing the global phase. Source padding needs +intrinsic C_q before the retained entry adapter; target padding needs C_q +after the retained exit adapter. The checker uses those operators rather +than treating either boundary as an internal canonical-chart edge. + +The original native events retain their pinned recipes and their order on +each register. This package inherits their source proof; its native check +covers the new recipes. Semantic controls reject an omitted L341 repair, +an omitted carrier restoration and missing initial compensation. A native +control changes a recipe's global phase and must fail. + +```sh +python3 -I -B research/p104-delayed-query-side/verify.py --native +python3 -I -O -B research/p104-delayed-query-side/budget.py +python3.12 scripts/research_package.py --package research/p104-delayed-query-side +``` + +The replay reads pinned Git evidence and writes no files. The package needs +full Git history for the retained selected archive. I checked the local +prototype with Python3.14.6 and the registered replay with Python3.12. + +## Completed optimistic cost obstruction + +Grant a dual orientation with the same profile and favorable hosting. All +invocations use this fixed profile; a cheaper second orientation changes the +screened premise. For +paired-chain parameter p>=1, use s=2p+1, m=16p+9, W=208p and one unpaid +coordinate per data family. Let B be the number of additional fully paid +families. The remaining idle rank mass is + +``` +I = (m-1)W + mB - s*6726. +``` + +We require I>=0 and put all idle mass at the largest rank R with +m^2>2R^2. This gives a lower bound on any completed moment for the fixed +profile. The budget checker takes the smallest feasible B for each +p=1,...,15 and proves its moment exceeds one at + +``` +a = 836330098538459 / 499163669901461541. +``` + +This is the balanced primitive target associated with the selected kappa +at the pinned base. Adding another fully paid family adds favorable cost +(m/R)^a>1 per family, so it cannot repair an already failing moment. + +For p>=16, m>=265. The deficit per call is less than48, while exact rational +intervals give + +``` +a * sum_r n_r*r*log(265/r) > 54.7514 > 48. +``` + +Using exp(x)>=1+x and discarding the positive idle entropy proves failure +for those p as well. The construction therefore cannot beat the pinned +selected saving within this coverage/guard model. This argument does not +cover a redesigned producer, a changed profile or a changed coverage law. + +## Open next questions + +- Can a joint target trajectory reduce the 112 late carriers? Start with a + new legal path for one coordinate query and propagate its coefficient + through the remaining target mixing. The fixed safe-read paths are already + priced here; an owner rearrangement alone cannot fix this profile. +- Can the early response carriers share an existing paid path? A candidate + must restore each independent dirty input and preserve the query until + the repair cut. Reuse the twenty-column response test before claiming a + reduced inventory. + +Global chronological ownership, the dual word, precision/tape bounds and +all-size admission remain open. I stop this fixed construction at its +unfavorable complete price rather than claiming a new supplier. + +## Attribution + +Ali Romman's PR1862 supplies the clean-J reconstruction and source pins. +The selected Hamming packet, mutable-source/target, native compiler and +hosting lineage belongs to the contributors retained in that package's +notices, including icekylinx, jacklightChen and DreamingOfClouds. Rohan Arun's +PR1972 and Chafik Boukhalfa's PR1991 supply the P104 query convention and +fixture; Adam Gall's PR1940 and Josie Elliston's PR1071 supply the preceding +delivery geometry. The compiler/interpreter retain their original attribution. +Douglas Colkitt's PR1240 supplies the exact interval arithmetic; the coverage +premise follows the PR1012 and paired-chain lineage. + +David Arias's PR2082 and Adam Gall's PR2090 study frozen temporal cuts. +Jeremy Diviney's PR2113 and Ross Richardson's PR2127 extend the retained-path +storage analysis; PR2127 distinguishes productive helper progress from excess +rank. Adam Gall's PR2083 gives the terminal correction floor and its coverage +obstruction; PR2089 gives the direct terminal word. This contribution changes +the query inputs and chronology. It does not claim those terminal or +frozen-cut results. Hope7Happiness's Discussion2131 tests a separate bounded +room-rectangle construction with changed paths. + +Jose Manuel (@jmbarrancoml), with substantial OpenAI Codex assistance in +construction, proof, implementation and prose. No independent human review +or proof-assistant verification. Apache-2.0. diff --git a/research/p104-delayed-precision/predecessor/SOURCES.json b/research/p104-delayed-precision/predecessor/SOURCES.json new file mode 100644 index 0000000000..cebdf4679d --- /dev/null +++ b/research/p104-delayed-precision/predecessor/SOURCES.json @@ -0,0 +1,28 @@ +{ + "schema_version": 1, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "files": [ + {"path": "docs/research/agent-task-catalog.json", "usage": "provenance", "git_blob": "e8870e5917057d59b730eb14721a778639eca050", "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7"}, + {"path": "certificates/selected-result.json", "usage": "provenance", "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32"}, + {"path": "research/native-source-codes/source_data.py", "usage": "input", "git_blob": "c9d465ed47500304bef65fcb588befe356c5cf09", "sha256": "d23924511e3aed41e5e64511ca70126a636d91c8aa02e656cb61d6ceca1fe0a0"}, + {"path": "research/community-frontier1042-audit/selected-replay.tar.gz", "usage": "input", "git_blob": "6f4dc6fe7631d8aacf8081fcaecf32197181685b", "sha256": "22c3f4dce4b897a1d423d1388801933e288b6a6b1906cb15e1b16a5eb68db754"}, + {"path": "research/p104-native-channel/inputs/P104-FIXTURE.json", "usage": "input", "git_blob": "2e16f99b295bb386fd13bd8fbd57b42ef54143a9", "sha256": "516c06f6ec3cb84be588c546108de897650288576dd5fbf5fe44b9c5546ad8a4"}, + {"path": "research/p104-native-channel/vendor/clifford_exact.py", "usage": "input", "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962"}, + {"path": "research/p104-native-channel/vendor/native_verify.py", "usage": "input", "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38"}, + {"path": "research/complex-local-word-ceiling/ceiling.py", "usage": "input", "git_blob": "6c0f54527d879396f689523bfde19928a9b6157c", "sha256": "86a1432870b3b21d8454106ec9162fddc0471472d9214c590a1420f2426cedfc"} + ], + "predecessors": [ + {"author": "Ali Romman", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1862", "head": "bb29ea73ad9be9a0c3d53cdcb1d22b2ee9ffe42f", "scope": "Clean-J source reconstruction, selected archive binding and independent Gaussian interpreter."}, + {"author": "Rohan Arun", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1972", "head": "fd82d172f46933fd253c2c6de4bd5eaff5429cfd", "scope": "P104 D/T fixture and dirty query convention."}, + {"author": "Chafik Boukhalfa", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1991", "head": "6e222517e182e98499239bc9a4009f540e1c5520", "scope": "Native P104 realization and retained compiler/interpreter distribution."}, + {"author": "Adam Gall", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1940", "head": "a9b7dfe2809092a9a4c90784d12bb60061e995e8", "scope": "Preceding target-order delivery geometry; the present word uses a different selected-side chronology."}, + {"author": "Josie Elliston", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1071", "scope": "P104 frame-pair fixture and delivery geometry, through the pinned native fixture."}, + {"author": "Douglas Colkitt", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/1240", "scope": "Exact rational interval arithmetic and favorable idle-rank pricing."}, + {"author": "David Arias", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2082", "head": "60f4e337ffba470e09727dd435b1f1be3b67d03d", "scope": "Frozen temporal access obstruction; different retained-word premise."}, + {"author": "Adam Gall", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2083", "head": "7231ab9715308e87f8254d4bf10337e8ebde0b0f", "scope": "Terminal correction floor and coverage accounting, including a relaxed104-rank word."}, + {"author": "Adam Gall", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2090", "head": "dff116efc2c4ddd7236020ad8316db5c98aa693e", "scope": "Frozen temporal query cut."}, + {"author": "Ross Richardson", "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2127", "head": "befebf0f4ae7a3f69fe9c5e136262559dcac125f", "scope": "Retained-path storage cut and distinction between productive progress and excess rank."} + ], + "source_policy": "The selected loader authenticates its frozen Git archive and member hashes. This package imports retained modules unchanged and adds only its own construction/checks. Full Git history is required. Original compiler, scalar-word and hosting notices remain authoritative.", + "attribution": "The delayed-input response carriers, query-ready retiming, combined local forward word and fixed-profile all-stage screen are this contribution. The source word, geometry, compiler and interval methods retain predecessor credit." +} diff --git a/research/p104-delayed-precision/producer.py b/research/p104-delayed-precision/producer.py new file mode 100644 index 0000000000..f95f44bd22 --- /dev/null +++ b/research/p104-delayed-precision/producer.py @@ -0,0 +1,385 @@ +"""Prototype joint P104 word with delayed inputs and arbitrary dirty carriers. + +Jose Manuel, with substantial OpenAI Codex assistance. This reads the pinned +selected side word through Ali Romman's source loader. No supplier admission. +""" + +from collections import Counter, defaultdict +from fractions import Fraction as Q +from hashlib import sha256 +from pathlib import Path +import argparse +import copy +import importlib.util +import json +import sys + +ROOT = Path(__file__).resolve().parents[2] +need_source = ROOT / "research/native-source-codes/source_data.py" +if sha256(need_source.read_bytes()).hexdigest() != "d23924511e3aed41e5e64511ca70126a636d91c8aa02e656cb61d6ceca1fe0a0": + raise ValueError("selected source-loader pin") +spec = importlib.util.spec_from_file_location("p104_selected_source",ROOT / "research/native-source-codes/source_data.py") +S = importlib.util.module_from_spec(spec) +spec.loader.exec_module(S) + + +def need(ok,message): + if not ok: + raise ValueError(message) + + +def span(vs): + out = {0} + for v in vs: + out |= {x^v for x in tuple(out)} + return frozenset(out) + + +def add(row,other,q): + S.add(row,other,q) + + +def touched(event): + if event[0]=="scalar": + op = event[1] + return [reg(r) for r in (op[1:3] if op[0] in ("add","copy") else op[1:2])] + if event[0] in ("climb","adapter","residual_adapter"): + return [event[2]] + return [] + + +def reg(pair): + return pair[1] + (704 if pair[0]=="C" else 0) + + +def scalar(event,state): + if event[0]!="scalar": + return + op = event[1] + t = reg(op[1]) + if op[0]=="clear": + state[t] = {} + elif op[0]=="scale": + state[t] = {j:x*Q(op[2],op[3]) for j,x in state[t].items()} + elif op[0]=="copy": + state[t] = dict(state[reg(op[2])]) + else: + need(op[0]=="add","scalar kind") + add(state[t],state[reg(op[2])],Q(op[3],op[4])) + + +def sc(t,s,q,f): + ref = lambda x:["C",x-704] if 704<=x<712 else ["L",x] + return ["scalar",["add",ref(t),ref(s),Q(q).numerator,Q(q).denominator],f] + + +def main(): + parser=argparse.ArgumentParser() + parser.add_argument("--native",action="store_true") + args=parser.parse_args() + data = S.reconstruct(ROOT) + w,p,R = data["word"],data["programs"]["forward"],data["R"] + frames = list(map(span,w["frames"])) + frame_bases = list(w["frames"]) + full,zero = 1,0 + need(len(frames[full])==512 and frames[zero]=={0},"frame anchors") + n = len(w["start"]) + need(n==704,"selected width") + a_cut = p.index(["phase","centers"]) + b_start = p.index(["phase","B"]) + cleanup = p.index(["phase","full_frame_cleanup"]) + need((a_cut,b_start,cleanup)==(12550,12759,17845),"pinned source cuts") + old = [i for i in range(len(p)) if not a_cut<=ithreshold[112+t] and normals[axis] in frames[f] + and f!=w["final"][112+t]] + need(candidates,"safe nonterminal query read") + start,end,f = min(candidates,key=lambda z:max(z[0],threshold[112+t])) + need(len(frames[f])==128 and end not in ideal,"safe rank-seven read after queries") + key = (axis,f) + if key not in group_ids: + group_ids[key] = 732+len(group_ids) + deliveries[end].append((group_ids[key],112+t,coefficient,f)) + need(len(group_ids)==112 and sum(map(len,deliveries.values()))==208,"late delivery invoice") + total = 844 + # Derive the twenty independent injection responses at the FULL repair cut. + response = [{} for _ in range(total)] + for j,(_,f,items) in enumerate(injection): + for r,q in items.items(): + response[r][j] = q + response_frames = w["start"].copy() + for i in order: + if ilen(frames[e[4]])] + need(len(drops)==8 and all(e[2]==704 and e[5]==7 for e in drops),"eight owned private descents and COPY56") + native={"status":"NOT_RUN"} + if args.native: + def load(name,path,pin): + need(sha256(path.read_bytes()).hexdigest()==pin,"native source pin") + sp=importlib.util.spec_from_file_location(name,path) + module=importlib.util.module_from_spec(sp);sys.modules[name]=module;sp.loader.exec_module(module) + return module + CE=load("p104_delayed_compiler",ROOT/"research/p104-native-channel/vendor/clifford_exact.py", + "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962") + N=load("p104_delayed_independent",ROOT/"research/p104-native-channel/vendor/native_verify.py", + "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38") + charts={} + def chart(f): + if f not in charts:charts[f]=CE.canonical_frame(9,frame_bases[f]) + return charts[f] + checked={};uses=0;phase_control=False + for e in actions: + if e[0]!="climb" or e[1] not in ("joint","source_pad_entry","target_pad_exit"):continue + _,kind,r,a,b,rank=e;uses+=1 + normal=w["ports"][r if kind=="source_pad_entry" else r-112] if kind!="joint" else None + key=(kind,a,b,normal) + if key in checked:continue + if kind=="joint": + op=chart(a).adjoint().then(chart(b)) + expected=N.adjoint(N.frame(tuple(frame_bases[a]),9))+N.frame(tuple(frame_bases[b]),9) + else: + # Padding enters BEFORE the retained source adapter and exits + # AFTER the retained target adapter; both need intrinsic C_q. + op=CE.cgate(9,normal,1);expected=(("C",normal,1),) + recipe,_=CE.lower_child(op) + need(recipe["rank"]==rank,"new positive child rank") + N.equal(N.recipe(recipe),expected,"new joint-side native transport") + if not phase_control: + bad=copy.deepcopy(recipe);bad["left"]["phase"]=(bad["left"]["phase"]+1)%4 + try:N.equal(N.recipe(bad),expected,"mutated global phase") + except ValueError:phase_control=True + else:raise ValueError("accepted wrong native phase") + checked[key]=rank + need(phase_control,"native phase control ran") + native={"status":"PASS_NEW_NATIVE_RECIPES","distinct_recipes":len(checked),"paid_occurrences":uses,"global_phase_control":"REJECT"} + print(json.dumps({"status":"PASS_CANONICAL_P104_DELAYED_SIDE_PROTOTYPE", + "persistent_columns":total-8,"private_columns":8,"actions":len(actions), + "baseline_compensation_adds":len(compensation),"paid_profile":dict(sorted(paid.items())), + "paid_mass":sum(r*c for r,c in paid.items()),"early_dirty_carriers":20, + "late_dirty_carriers":112,"query_cut":len(ideal),"native_new_recipe_check":native, + "controls":controls, + "scope":"Exact finite forward endpoint and canonical common frames. Native recipes are checked only with --native. Global hosting, dual orientation, precision and supplier admission remain separate."},indent=2)) + + +if __name__=="__main__":main() diff --git a/research/p104-delayed-precision/test_verify.py b/research/p104-delayed-precision/test_verify.py new file mode 100644 index 0000000000..38d47c225c --- /dev/null +++ b/research/p104-delayed-precision/test_verify.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python3 +"""Behavior controls and separate Fraction checks for the completed-word bound.""" +from fractions import Fraction as Q +import gzip +import importlib.util +import json +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +spec = importlib.util.spec_from_file_location("p104_delayed_precision", HERE / "verify.py") +V = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = V +spec.loader.exec_module(V) +I = V.Instruction + + +class PrecisionTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.word = V.load_word() + cls.program = V.normalize(cls.word) + cls.result = V.analyze(cls.program) + + def test_signed_cancellation_and_all_cut_coverage(self): + program = [I("add", 0, 1, Q(1)), I("add", 0, 1, Q(-1))] + result = V.analyze(program, roles=2) + self.assertEqual([p[0] for p in result["peaks"]], [Q(2), Q(2), Q(4)]) + self.assertEqual(result["inputs"][0].coefficients(), {0: Q(1)}) + self.assertEqual(result["errors"][0].coefficients(), {0: Q(1), 1: Q(1)}) + V.check_peaks(program, result) + + def test_fraction_oracle_for_dyadic_row_updates(self): + weights = (2, 3, 5) + rows = [V.DyadicRow(weights, i) for i in range(3)] + dense = [{i: Q(1)} for i in range(3)] + operations = [(0, 1, Q(-1, 65536)), (0, 2, Q(3, 2)), + (2, 0, Q(65536)), (1, 2, Q(-8)), (0, 1, Q(1, 2)), + (0, 1, Q(-1, 2)), (2, 1, Q(1, 8))] + # Initial input weights are intentionally nonzero in this arithmetic test. + for i, row in enumerate(rows): + row.weighted = weights[i] + for dst, src, q in operations: + rows[dst].add_scaled(rows[src], q) + for j, value in tuple(dense[src].items()): + dense[dst][j] = dense[dst].get(j, Q(0)) + q * value + if not dense[dst][j]: + del dense[dst][j] + self.assertEqual(rows[dst].coefficients(), dense[dst]) + self.assertEqual(Q(rows[dst].absolute, 1 << rows[dst].exponent), + sum(map(abs, dense[dst].values()))) + self.assertEqual(Q(rows[dst].weighted, 1 << rows[dst].exponent), + sum(abs(q) * weights[j] for j, q in dense[dst].items())) + rows[0].scale(Q(-1, 65536)) + self.assertEqual(rows[0].coefficients(), {j: -q / 65536 for j, q in dense[0].items()}) + + def test_reset_does_not_erase_propagated_private_error(self): + program = [I("reset", 1), I("add", 1, 0, Q(1)), + I("add", 0, 1, Q(1)), I("reset", 1)] + result = V.analyze(program, roles=2) + self.assertEqual(result["errors"][1].coefficients(), {}) + self.assertEqual(result["errors"][0].coefficients(), {1: Q(1), 2: Q(1)}) + self.assertEqual(V.injected(program, 3, 0, defects={1: Q(1)}, roles=2), Q(1)) + + def test_completed_word_sharp_peaks_and_endpoint_sensitivities(self): + self.assertEqual([p[:3] for p in self.result["peaks"]], + [(Q(131072), 33373, 93), (Q(1394705), 33373, 93), + (Q(2134050), 33373, 93)]) + V.endpoint_check(self.result, self.word["live_ports"]) + V.check_peaks(self.program, self.result) + for target in (93, 112, 86, 224, 712, 732, 704): + inputs, errors = V.adjoint(self.program, len(self.program) - 1, target) + self.assertEqual(inputs, self.result["inputs"][target].coefficients()) + self.assertEqual(errors, self.result["errors"][target].coefficients()) + self.assertEqual(V.injected(self.program, 33373, 93, defects={7691: Q(1)}), Q(-65536)) + self.assertEqual(V.injected(self.program, len(self.program)-1, 112, + defects={22003: Q(1)}), Q(1)) + self.assertEqual(V.injected(self.program, len(self.program)-1, 704, + defects={22003: Q(1)}), Q(0)) + + def test_state_relative_guard_is_sufficient_not_a_precision_minimum(self): + P, K = Q(131072), Q(2134050) + self.assertEqual(V.guard_bits(P, K), 39) + for bits in (0, 1, 32, 128, 1024): + u = Q(1, 1 << (bits + 39)) + self.assertLess(K * u, 1) + self.assertLessEqual(P * K * u / (1 - K * u), Q(1, 1 << bits)) + u = Q(1, 1 << (bits + 38)) + self.assertGreater(P * K * u / (1 - K * u), Q(1, 1 << bits)) + with self.assertRaisesRegex(ValueError, "positive feedback"): + V.guard_bits(P, Q(0)) + with self.assertRaisesRegex(ValueError, "capacity exceeded"): + V.guard_bits(Q(1 << 1024), Q(2)) + + def test_semantic_faults_fail(self): + bad = dict(self.word) + bad["actions"] = [list(e) for e in self.word["actions"]] + first = next(i for i, e in enumerate(bad["actions"]) if e[0] == "climb") + bad["actions"][first][3] = 1 + with self.assertRaisesRegex(ValueError, "transport entry chart"): + V.normalize(bad) + # Suppress a real private clear without changing any instruction index. + bad = list(self.program) + index = next(i for i, e in enumerate(bad) if e.op == "reset") + bad[index] = I("exact") + with self.assertRaisesRegex(ValueError, "arbitrary-input endpoint"): + V.endpoint_check(V.analyze(bad), self.word["live_ports"]) + # Initial compensation is part of the completed word, not free metadata. + with self.assertRaisesRegex(ValueError, "arbitrary-input endpoint"): + V.endpoint_check(V.analyze(self.program[7686:]), self.word["live_ports"]) + + def test_read_only_export_and_fail_closed_receipts(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + for name in ("verify.py", "WORD.json.gz", "RESULT.json"): + (root / name).write_bytes((HERE / name).read_bytes()) + before = {p.name: p.read_bytes() for p in root.iterdir()} + for flags in ([], ["-O"]): + done = subprocess.run([sys.executable, "-I", "-B", *flags, str(root / "verify.py")], + capture_output=True, text=True, timeout=60) + self.assertEqual(done.returncode, 0, done.stderr) + self.assertIn("input=131072 absolute=1394705 relative=2134050", done.stdout) + self.assertEqual(before, {p.name: p.read_bytes() for p in root.iterdir()}) + receipt = json.loads((root / "RESULT.json").read_text()) + receipt["uniform_relative_guard_bits"] = 38 + (root / "RESULT.json").write_text(json.dumps(receipt)) + failed = subprocess.run([sys.executable, "-I", "-B", str(root / "verify.py")], + capture_output=True, text=True, timeout=60) + self.assertNotEqual(failed.returncode, 0) + self.assertIn("complete canonical precision receipt", failed.stderr) + raw = gzip.decompress((root / "WORD.json.gz").read_bytes()) + (root / "WORD.json.gz").write_bytes(gzip.compress(raw + b" ", mtime=0)) + failed = subprocess.run([sys.executable, "-I", "-B", str(root / "verify.py")], + capture_output=True, text=True, timeout=60) + self.assertNotEqual(failed.returncode, 0) + self.assertIn("literal stream authentication", failed.stderr) + + def test_changed_producer_is_rejected_before_import(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + (root / "export_word.py").write_bytes((HERE / "export_word.py").read_bytes()) + (root / "producer.py").write_text("raise RuntimeError('untrusted producer executed')\n") + failed = subprocess.run([sys.executable, "-I", "-B", str(root / "export_word.py"), + "--check"], capture_output=True, text=True, timeout=10) + self.assertNotEqual(failed.returncode, 0) + self.assertIn("unchanged PR2139 producer authentication", failed.stderr) + self.assertNotIn("untrusted producer executed", failed.stderr) + + def test_no_overwrite_and_coefficient_boundaries(self): + with tempfile.TemporaryDirectory() as directory: + target = Path(directory) / "receipt.json" + target.write_text("keep\n") + failed = subprocess.run([sys.executable, "-I", "-B", str(HERE / "verify.py"), + "--write", str(target)], + capture_output=True, text=True, timeout=60) + self.assertNotEqual(failed.returncode, 0) + self.assertIn("FileExistsError", failed.stderr) + self.assertEqual(target.read_text(), "keep\n") + with self.assertRaisesRegex(ValueError, "replay domain capacity"): + V.analyze([I("exact")], roles=845) + with self.assertRaisesRegex(ValueError, "replay domain capacity"): + V.analyze([I("exact")] * 34334, roles=1) + self.assertEqual(V.coefficient("-1/65536"), Q(-1, 65536)) + for value in ("0", "1/3", "65537", "1/131072"): + with self.assertRaises(ValueError): + V.coefficient(value) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/p104-delayed-precision/verify.py b/research/p104-delayed-precision/verify.py new file mode 100644 index 0000000000..99cb11d76a --- /dev/null +++ b/research/p104-delayed-precision/verify.py @@ -0,0 +1,383 @@ +#!/usr/bin/env python3 +"""Exact all-cut input and defect maps of the completed PR2139 P104 word.""" +import argparse +from collections import Counter +from fractions import Fraction as Q +import gzip +import hashlib +import json +from pathlib import Path +from typing import NamedTuple + +HERE = Path(__file__).resolve().parent +WORD_SHA256 = "8be1f3c659d887030fa70afdbdeca38fbfbaea1b2a57b1783d3669e92816545c" +MAX_BYTES = 4 * 1024 * 1024 + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def load_word(path=HERE / "WORD.json.gz"): + need(path.stat().st_size <= MAX_BYTES, "compressed stream capacity") + with gzip.open(path, "rb") as stream: + raw = stream.read(MAX_BYTES + 1) + need(len(raw) <= MAX_BYTES, "decompressed stream capacity") + need(hashlib.sha256(raw).hexdigest() == WORD_SHA256, "literal stream authentication") + return json.loads(raw) + + +class Instruction(NamedTuple): + op: str + dst: int = -1 + src: int = -1 + coefficient: Q = Q(0) + rank: int = 0 + + +def coefficient(value): + q = Q(value) + need(q != 0 and abs(q) <= 65536, "nonzero bounded coefficient") + need(q.denominator <= 65536 and q.denominator & (q.denominator - 1) == 0, + "bounded dyadic coefficient") + return q + + +def register(reference): + need(isinstance(reference, list) and len(reference) == 2, "register reference") + kind, index = reference + need(kind in ("C", "L") and type(index) is int, "register kind/index") + limit = 8 if kind == "C" else 844 + need(0 <= index < limit, "register index capacity") + return index + (704 if kind == "C" else 0) + + +def span(basis): + need(isinstance(basis, list) and len(basis) <= 9, "binary basis capacity") + values = {0} + for value in basis: + need(type(value) is int and 0 <= value < 512, "nine-bit frame label") + values.update(x ^ value for x in tuple(values)) + return frozenset(values) + + +def scalar_instruction(event, current): + need(len(event) == 3 and isinstance(event[1], list), "scalar event shape") + op, frame = event[1:] + dst = register(op[1]) + need(current[dst] == frame, "scalar destination chart") + code = op[0] + if code == "clear": + need(len(op) == 2 and 704 <= dst < 712 and frame == 0, "owned exact clear") + return Instruction("reset", dst) + if code == "scale": + need(len(op) == 4, "scale shape") + return Instruction(code, dst, coefficient=coefficient(Q(op[2], op[3]))) + need(code == "add" and len(op) == 5, "scalar opcode/shape") + src = register(op[2]) + need(src != dst and current[src] == frame, "distinct common-chart operands") + return Instruction(code, dst, src, coefficient(Q(op[3], op[4]))) + + +def action_instruction(event, current, frames): + need(isinstance(event, list) and 2 <= len(event) <= 6, "action shape") + if event[0] == "scalar": + return scalar_instruction(event, current) + if event[0] == "owned_init": + need(len(event) == 3 and 704 <= event[1] < 712, "owned private reset") + dst, new = event[1:] + need(0 <= new < len(frames), "private reset frame") + current[dst] = new + return Instruction("reset", dst) + if event[0] == "climb": + need(len(event) == 6, "transport shape") + dst, old, new, rank = event[2:] + need(type(dst) is int and 0 <= dst < 844, "transport register") + need(0 <= old < len(frames) and 0 <= new < len(frames), "transport frame indices") + need(current[dst] == old, "transport entry chart") + a, b = frames[old], frames[new] + need(a <= b or b <= a, "nested native transport") + need(rank == abs(len(a).bit_length() - len(b).bit_length()) and rank > 0, + "positive transport rank") + current[dst] = new + return Instruction("transport", dst, rank=rank) + need(event[0] in ("phase", "adapter", "residual_adapter"), "action opcode") + return Instruction("exact") + + +def normalize(word): + need(word["schema_version"] == 1 and word["total_roles"] == 844, "word geometry") + need(len(word["initial_frames"]) == len(word["final_frames"]) == 844, + "boundary role inventory") + need(len(word["frame_bases"]) == 1008, "frame inventory") + frames = [span(basis) for basis in word["frame_bases"]] + current = list(word["initial_frames"]) + need(all(type(f) is int and 0 <= f < len(frames) for f in current), "initial frames") + live = word["live_ports"] + need(len(live) == 104 and live == sorted(set(live)) and all(0 <= p < 112 for p in live), + "live P104 ports") + need(len(word["compensation"]) == 7686 and len(word["actions"]) == 26647, + "complete instruction inventory") + program = [] + for dst, src, raw in word["compensation"]: + need(type(dst) is int and type(src) is int and 0 <= dst < 844 and 0 <= src < 844, + "compensation indices") + need(dst != src and current[dst] == current[src] == 0, "baseline common zero chart") + program.append(Instruction("add", dst, src, coefficient(raw))) + for event in word["actions"]: + program.append(action_instruction(event, current, frames)) + need(current == word["final_frames"], "complete output charts") + paid = Counter(e.rank for e in program if e.op == "transport") + need(dict(paid) == {1: 2564, 2: 547, 3: 432, 4: 142, 5: 83, 6: 128, 7: 11}, + "complete predecessor paid profile") + return program + + +class DyadicRow: + """Integer coefficients at one row-local power-of-two denominator.""" + def __init__(self, weights, initial=None): + self.weights = weights + self.exponent = 0 + self.values = {} if initial is None else {initial: 1} + self.absolute = 0 if initial is None else 1 + self.weighted = 0 + + def add_scaled(self, other, q): + denominator_bits = q.denominator.bit_length() - 1 + exponent = max(self.exponent, other.exponent + denominator_bits) + if exponent != self.exponent: + factor = 1 << (exponent - self.exponent) + self.values = {j: v * factor for j, v in self.values.items()} + self.absolute *= factor + self.weighted *= factor + self.exponent = exponent + factor = q.numerator << (exponent - other.exponent - denominator_bits) + for j, value in other.values.items(): + old = self.values.get(j, 0) + new = old + value * factor + change = abs(new) - abs(old) + self.absolute += change + self.weighted += change * self.weights[j] + if new: + self.values[j] = new + else: + self.values.pop(j, None) + + def scale(self, q): + self.exponent += q.denominator.bit_length() - 1 + self.values = {j: v * q.numerator for j, v in self.values.items()} + self.absolute *= abs(q.numerator) + self.weighted *= abs(q.numerator) + + def inject(self, index): + value = 1 << self.exponent + self.values[index] = value + self.absolute += value + self.weighted += value * self.weights[index] + + def coefficients(self): + return {j: Q(v, 1 << self.exponent) for j, v in self.values.items()} + + +def weights_for(program): + result = [] + for event in program: + if event.op == "add": + result.append(1 + abs(event.coefficient)) + elif event.op == "scale": + result.append(abs(event.coefficient)) + else: + result.append(Q(int(event.op == "transport"))) + bits = max((q.denominator.bit_length() - 1 for q in result), default=0) + return result, bits, tuple(int(q * (1 << bits)) for q in result) + + +def update(rows, event, weights): + dst = event.dst + if event.op == "reset": + rows[dst] = DyadicRow(weights) + elif event.op == "add": + rows[dst].add_scaled(rows[event.src], event.coefficient) + elif event.op == "scale": + rows[dst].scale(event.coefficient) + + +def analyze(program, roles=844): + need(1 <= roles <= 844 and 1 <= len(program) <= 34333, "replay domain capacity") + weights, bits, integers = weights_for(program) + zero_weights = (0,) * roles + inputs = [DyadicRow(zero_weights, i) for i in range(roles)] + errors = [DyadicRow(integers) for _ in range(roles)] + peaks = [(Q(1), -1, 0, {0: Q(1)}), (Q(0), -1, 0, {}), (Q(0), -1, 0, {})] + stream = hashlib.sha256() + max_slots = slots = 0 + max_exponent = 0 + for index, event in enumerate(program): + if event.op == "exact": + continue + dst = event.dst + before = len(errors[dst].values) + update(inputs, event, zero_weights) + update(errors, event, integers) + if weights[index]: + errors[dst].inject(index) + slots += len(errors[dst].values) - before + max_slots = max(max_slots, slots) + ir, er = inputs[dst], errors[dst] + need(ir.absolute == sum(map(abs, ir.values.values())), "input row norm cache") + need(er.absolute == sum(map(abs, er.values.values())), "defect row norm cache") + need(er.weighted == sum(abs(v) * integers[j] for j, v in er.values.items()), + "weighted defect row norm cache") + values = (Q(ir.absolute, 1 << ir.exponent), Q(er.absolute, 1 << er.exponent), + Q(er.weighted, 1 << (er.exponent + bits))) + for which, value in enumerate(values): + if value > peaks[which][0]: + row = ir if which == 0 else er + peaks[which] = value, index, dst, row.coefficients() + stream.update(canonical([index, dst, *map(str, values)]) + b"\n") + max_exponent = max(max_exponent, ir.exponent, er.exponent) + return {"inputs": inputs, "errors": errors, "weights": weights, "peaks": peaks, + "norm_stream_sha256": stream.hexdigest(), "max_error_slots": max_slots, + "max_row_denominator_bits": max_exponent} + + +def endpoint_check(result, live): + for reg, row in enumerate(result["inputs"]): + expected = {} if 704 <= reg < 712 else {reg: Q(1)} + if 112 <= reg < 224 and reg - 112 in live: + expected[reg - 112] = Q(1) + need(row.coefficients() == expected, "arbitrary-input endpoint: " + str(reg)) + + +def adjoint(program, stop, target, roles=844): + """Separate Fraction recurrence for one cut, with no integer-row machinery.""" + need(1 <= roles <= 844 and 0 <= target < roles and -1 <= stop < len(program) <= 34333, + "reverse cut capacity") + row = [Q(int(i == target)) for i in range(roles)] + defects = {} + for index in range(stop, -1, -1): + event = program[index] + if event.op == "exact": + continue + dst = event.dst + if event.op in ("add", "scale", "transport") and row[dst]: + defects[index] = row[dst] + if event.op == "reset": + row[dst] = Q(0) + elif event.op == "add": + row[event.src] += event.coefficient * row[dst] + elif event.op == "scale": + row[dst] *= event.coefficient + return {i: q for i, q in enumerate(row) if q}, defects + + +def injected(program, stop, target, inputs=None, defects=None, roles=844): + need(1 <= roles <= 844 and 0 <= target < roles and -1 <= stop < len(program) <= 34333, + "injected cut capacity") + state = [Q(0)] * roles + for i, q in (inputs or {}).items(): + state[i] = q + for index in range(stop + 1): + event = program[index] + if event.op == "exact": + continue + dst = event.dst + if event.op == "reset": + state[dst] = Q(0) + elif event.op == "add": + state[dst] += event.coefficient * state[event.src] + elif event.op == "scale": + state[dst] *= event.coefficient + if defects and index in defects: + state[dst] += defects[index] + return state[target] + + +def check_peaks(program, result): + for which, (value, index, target, witness) in enumerate(result["peaks"]): + inputs, defects = adjoint(program, index, target) + need(witness == (inputs if which == 0 else defects), "reverse cut coefficient identity") + signs = {j: Q(1 if q > 0 else -1) for j, q in witness.items()} + if which == 0: + actual = injected(program, index, target, inputs=signs) + else: + if which == 2: + signs = {j: q * result["weights"][j] for j, q in signs.items()} + actual = injected(program, index, target, defects=signs) + need(actual == value, "constructive peak attainment") + + +def guard_bits(P, K): + need(P >= 0 and K > 0, "nonnegative input and positive feedback coefficients") + bits = 0 + for candidate in range(1025): + if Q(1 << candidate) >= K * (P + 1): + bits = candidate + break + else: + raise ValueError("guard-bit capacity exceeded") + need(K < 1 << bits, "strict feedback guard") + return bits + + +def summarize(program, word, result): + P, A, K = (peak[0] for peak in result["peaks"]) + guards = guard_bits(P, K) + groups = {"source": word["live_ports"], "target": [112 + t for t in word["live_ports"]], + "dirty_helper": [r for r in range(844) if r not in word["live_ports"] + and r not in [112 + t for t in word["live_ports"]] + and not 704 <= r < 712], "private": list(range(704, 712))} + endpoint = {} + for name, regs in groups.items(): + rows = [result["errors"][r].coefficients() for r in regs] + endpoint[name] = {"roles": len(regs), + "absolute": str(max(sum(map(abs, row.values()), Q(0)) for row in rows)), + "relative": str(max(sum((abs(v) * result["weights"][j] + for j, v in row.items()), Q(0)) for row in rows))} + need(P == 131072 and A == 1394705 and K == 2134050 and guards == 39, + "complete all-cut constants") + peaks = {name: {"value": str(value), "event": index, "register": reg, + "witness": [[j, str(q)] for j, q in sorted(row.items())]} + for name, (value, index, reg, row) in zip(("input", "absolute", "relative"), result["peaks"])} + return {"status": "PASS_P104_DELAYED_PRECISION", "word_sha256": WORD_SHA256, + "events": len(program), "roles": 844, + "defect_sites": sum(bool(w) for w in result["weights"]), + "op_counts": dict(sorted(Counter(e.op for e in program).items())), + "paid_mass": sum(e.rank for e in program), "all_cut_peaks": peaks, + "endpoint_error_maxima": endpoint, "uniform_relative_guard_bits": guards, + "all_cut_norms_sha256": result["norm_stream_sha256"], + "maximum_live_error_coefficients": result["max_error_slots"], + "maximum_row_denominator_bits": result["max_row_denominator_bits"], + "evidence": ["full arbitrary-input endpoint and paid profile", "three reverse cut identities", + "three sign-aligned attaining executions"], + "scope": "Finite completed forward word, conditional unitary-chart/completed-child defect contract. No rounded-child, global hosting, all-size, supplier or kappa claim."} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--write", type=Path, help="create a new canonical receipt exclusively") + args = parser.parse_args() + word = load_word() + program = normalize(word) + result = analyze(program) + endpoint_check(result, word["live_ports"]) + check_peaks(program, result) + receipt = summarize(program, word, result) + if args.write: + with args.write.open("x") as stream: + json.dump(receipt, stream, indent=2, sort_keys=True) + stream.write("\n") + else: + need(canonical(receipt) == canonical(json.loads((HERE / "RESULT.json").read_text())), + "complete canonical precision receipt") + print("PASS_P104_DELAYED_PRECISION input=131072 absolute=1394705 relative=2134050 " + "guard_bits=39 endpoint_columns=844 reverse_cuts=3 no_new_kappa") + + +if __name__ == "__main__": + main()