From 993e2d4ba993d9818c6d7c5ae1e35980d1ab3ebb Mon Sep 17 00:00:00 2001 From: commdata2338 <199849969+commdata2338@users.noreply.github.com> Date: Sat, 17 Oct 2026 14:10:11 -0500 Subject: [PATCH] Research: independently audit PR #3131's first paired P104 collector at tensor multiplicity two Checks the first paired P104 collector of PR #3131 at actual tensor multiplicity two (n = 18, N = 262144, rank 14, events 2025-2039, native events 2031 and 2033), beyond the predecessor's complete N = 512 tests. Two separately written exact evaluators agree on the entire outgoing value, promoted query and working grid of four deterministic signed fixtures; the five dirty sources are preserved and the private collector returns to literal zero. Both actual wrappers are checked on every address (524,288 forward columns) and inverted. Two fixtures have nonzero rounding error, 5379503/8 and 2615337/4 in working-grid numerator units (grids 3 and 5), inside the exact forward and paired-inverse relative bounds; the cancellation and zero fixtures (grids 25 and 3) have none. The original return recipe passes an ideal round-trip fixture, and layout, phase, lift-order, promotion, restoration, source and receipt controls reject. PR #3131's own nested evaluator did not finish on this fixture in two 600-second attempts; the optional script is kept outside the registered replay and is not claimed as evidence. PR #3134's implementation, lambda > 2, the fast physical trace, clean-stock hosting, all-size refinement and the consumer bill remain open, and the inherited 599/584 screen is unchanged. No new kappa or selected-frontier change. Adds research/p104-tensor-collector-audit/ only. Submitted by @commdata2338 with substantial AI assistance (OpenAI Codex research and implementation; packaged with Claude Code). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01X86sCSXdoDd61SDFfC1PKG --- .../p104-tensor-collector-audit/README.md | 232 ++++++++++++ .../p104-tensor-collector-audit/RESULT.json | 276 +++++++++++++++ .../p104-tensor-collector-audit/SOURCES.json | 114 ++++++ .../p104-tensor-collector-audit/TASK.json | 155 ++++++++ .../p104-tensor-collector-audit/VERIFY.json | 48 +++ .../attempt_retained.py | 93 +++++ .../p104-tensor-collector-audit/oracle.py | 110 ++++++ .../test_verify.py | 119 +++++++ .../p104-tensor-collector-audit/verify.py | 333 ++++++++++++++++++ 9 files changed, 1480 insertions(+) create mode 100644 research/p104-tensor-collector-audit/README.md create mode 100644 research/p104-tensor-collector-audit/RESULT.json create mode 100644 research/p104-tensor-collector-audit/SOURCES.json create mode 100644 research/p104-tensor-collector-audit/TASK.json create mode 100644 research/p104-tensor-collector-audit/VERIFY.json create mode 100644 research/p104-tensor-collector-audit/attempt_retained.py create mode 100644 research/p104-tensor-collector-audit/oracle.py create mode 100644 research/p104-tensor-collector-audit/test_verify.py create mode 100644 research/p104-tensor-collector-audit/verify.py diff --git a/research/p104-tensor-collector-audit/README.md b/research/p104-tensor-collector-audit/README.md new file mode 100644 index 0000000000..f63d4634e3 --- /dev/null +++ b/research/p104-tensor-collector-audit/README.md @@ -0,0 +1,232 @@ +# Independent actual tensor-collector audit for P104 + +Two independent direct interpretations of the first paired P104 collector +of Jose Manuel's **PR3131** agree at **multiplicity two**: `n=18`, `N=262144`, +rank `14`, with the actual nine-field native recipe. Four complete signed fixtures +agree on every query component and working grid, preserve all five source +arrays, and return the private collector to literal zero. Two fixtures have +nonzero rounding error. This supplies actual `lambda>1` semantic evidence at +the boundary left in PR3131's PROOF section 7. The full retained nested +implementation comparison remains **unchecked** after two bounded timeouts. + +This is a **finite interface audit**, not verification of the fast physical +implementation, its time/space theorem, or a complete P104 supplier. The +selected frontier is unchanged. The original-order map, paired inverse and +error policy are predecessor constructions, not new results here. + +## Exact scope and evidence + +The frozen word interval is events **2025–2039**, with native occurrences +**2031 and 2033**. The audit reconstructs the prefix frames, checks the actual +source names `D31,D30,D29,D28,D27`, the `Q7` query, gathering/ungathering signs, +private lifetime and unique native records. It uses PR3131's layout + +``` +address = sum_i v_i * 2^(i*lambda), +v_i = sum_j x_(i,j) * 2^j. +``` + +The original lift acts on consecutive axes `0,...,7*lambda-1`. The numerical +return inverts the outbound wrappers and the literal lift in reverse order. +It does **not** independently round the distinct return recipe from event +2033. That recipe remains bound to the source and is checked as an ideal +round-trip fixture on the full multiplicity-two rounding input. + +`verify.py` expands the binary affine and strict-upper quadratic phase +polynomials directly on 18 bits. `oracle.py` instead applies one 512-entry +factor at a time on each strided nine-bit column. Every address of both +outbound wrappers and their inverses is checked: **524288 forward monomial +columns**, plus both inverse checks. Unique positive address markers make +this an exact permutation-and-phase check, not a sampled linear-operator +comparison. The two implementations share raw recipes and fixture inputs, +not wrapper or lift code. + +Tekalign's later [PR3134](../guarded-wrapper-refinement/README.md) reduces +wrapper-level lifting calls from 416 to 104 while retaining this collector +interface. Its complete collector checks are also at `N=512`. This audit +keeps PR3131's exact comparison source explicit; it does not replay PR3134's +changed implementation or claim its call reduction as new. + +The primary lift uses the signed difference/floor sequence. The other uses +a separately derived parity formula for each output. An additional ideal +oracle uses `H diag(i^popcount) H / 2^14`, independently of either rounded +pair implementation. Both full query arrays are compared before recording +SHA256 digests. Digests summarize the outputs; they do not replace those +component comparisons. + +| Multiplicity-two fixture | Input grid `f` | Working grid `F` | Squared error in working-grid numerator units | +|---|---:|---:|---:| +| signed, unpromoted, nonzero rounding | 3 | 3 | `5379503/8` | +| signed, promoted, nonzero rounding | 3 | 5 | `2615337/4` | +| 70-bit dirty cancellation to two unit components | 3 | 25 | `0` | +| exact zero gathered sum | 3 | 3 | `0` | + +Physical squared error is the last column times `2^(-2F)`. The first two +cases use `beta=0`; the latter two use `beta=8`. The cancellation cases +retain independently supplied large positive and negative source arrays. +Their small or zero sum does not permit omitting source preservation or +literal ungathering. A complete `lambda=1` fixture is also included, and +four small cases are compared with Tekalign's authenticated PR3025 source. + +## Why these are the intended semantics + +For Gaussian integers `a,b`, put `d=a-b`, +`s=b+floor(d/2)` componentwise, rotate `d` by `i`, then return +`(s-floor(d/2)+d, s-floor(d/2))`. Replacing the rotation by `-i` +inverts the pair: the output difference determines the original `d`, and +adding back its floor recovers `s`. Reversing the stage order therefore +restores every integer input. This is Tekalign's credited bijection; the +checker also exhausts all **2401** pairs with four real coordinates in +`[-3,3]` against the separate parity expression. + +If `p_R,p_I` are the parities of the entering difference, both outputs +have error `(p_I-p_R)(1-i)/2` relative to the ideal pair. Thus each stage's +squared error is at most `N/2`. Ideal suffixes and exact monomial wrappers +are unitary, so the whole outbound error has norm at most +`r sqrt(N/2)` in working-grid numerator units. The ideal Walsh oracle +checks the actual error and its unitary norm identity with integers only. + +For nonzero gathered numerator `S`, let `M=max |component(S)|` and +`h=floor(log2 M)-f`. The source policy is + +``` +gamma = ceil(log2 r) + ceil((n-1)/2), +F = max(f, beta+1+gamma-h). +``` + +For zero `S`, use `F=f`. Since `||S 2^-f|| >= 2^h` and +`r sqrt(N/2) <= 2^gamma`, the outbound relative defect is at most +`epsilon=2^(-beta-1)`. The paired return is exactly the embedded input. +Its difference from the *ideal* inverse has the same norm as the outbound +defect, by unitarity, so its relative defect on this paired execution is at +most `epsilon/(1-epsilon) <= 2^-beta`. The checker evaluates both squared +relative inequalities without floating point. This is not a relative-error +theorem for arbitrary inputs to the inverse routine. + +The query is promoted to grid `F` **before** adding the outbound value. +Private return permits exact downshift to `f`, then five reversed +ungathers. Exact private cleanup does not remove the query's numerical +error and is not by itself evidence of the correct forward map. + +## Discriminating controls + +The retained recipe's right wrapper sends address zero to **212799** with +phase **2** at multiplicity two. Using copy-major layout without conversion +instead sends it to **192375**. Forgetting the second copy's constant phase +changes phase 2 to 1. The left wrapper has a separate layout witness at +address 8. The full address checks distinguish these errors. + +The four-component real impulse `(1,0,0,0)` becomes `(0,0,1,0)` under +lift order `[0,1]`, but `(0,1,0,0)` under `[1,0]`. Both paired inverses +restore the impulse. This small control explains why checking cleanup or +an ideal tensor endpoint alone cannot justify reordering nonlinear stages. +It is a calibration of the inherited order requirement, not a new +obstruction to arbitrary collectors. + +Eight behavioral test groups also cover the actual optimized CLI, +source corruption before arithmetic, altered event signs/targets/lifetimes, +missing native occurrence, wrong query-grid promotion, corrupted return, +signed-floor truncation, wrapper phase changes, duplicate JSON keys and +changed receipt values/types. Assertions are not used for acceptance. + +## Incomplete retained evaluator comparison + +`attempt_retained.py` attempts the actual PR3131 nested evaluator on the full promoted +multiplicity-two fixture and compares its complete entrance, query, sent, +returned and private arrays with the independent oracle. Its one disclosed +adapter changes the finite `Executor` extent check from `n<=10` to `n<=18`. +All arithmetic, block-planning code, protected XOR interfaces, dense wrapper +calls and inverse routines are unchanged. The finite parameters are +`width=160, d=157, spacing=1, suffix=2, outer=14`, obtained from the inherited +exponents and checked using integer inequalities. The adapter authenticates +the original bytes and requires exactly that one reversible text substitution. + +Both the small-test defaults `d=2, spacing=2, suffix=1, outer=3` and the +explicit derived plan above failed to finish within **600 seconds each** +(exit 124). Neither produced a completed receipt. These timeouts establish +no mathematical failure and no successful retained implementation comparison. +The script is preserved as an optional follow-up, outside the registered +successful replay. For example, from the repository root: + +```sh +timeout 600s python3 -I -B research/p104-tensor-collector-audit/attempt_retained.py --plan derived +``` + +Use `--plan defaults` for the other attempt. The command compares full arrays +if it completes; no successful output is claimed for either recorded attempt. + +The evaluator retains PR3109's frozen **direct semantic oracle**. This does +not execute, benchmark or verify a fast physical C-layer trace. Sources and +the archive remain unchanged; the adapter compiles its copy in memory. +`TASK.json` records the two attempted parameter sets and incomplete outcomes. + +## Reproduce + +Python **3.12**, standard library, from the repository root: + +```sh +python3 -I -B scripts/research_package.py --package research/p104-tensor-collector-audit --check-only +python3 -I -B scripts/research_package.py --package research/p104-tensor-collector-audit +``` + +The registered replay runs the independent full-array check and eight controls +under `-O`. Expected markers are +`PASS_P104_TENSOR_COLLECTOR_AUDIT cases=5 no_new_kappa` and +`PASS_REGISTERED_RESEARCH_PACKAGE`. Individual commands are in `VERIFY.json`. +`--emit` prints regenerated JSON; default replay reads and compares the +complete committed receipt without modifying it. Exact immutable source +hashes and Git blobs are in `SOURCES.json`. + +The independent full-array run takes about **32 seconds** and **690 MiB** +on the recorded CPython 3.12.3 environment. This measures this direct checker, +not the proposed fast collector. The finite direct paired word has +`3670016` pair sites, `1048576` wrapper value visits and 11 full-array +scalar additions per multiplicity-two execution. Those are direct-reference +counts, not project-native child charges or a hosted physical bill. + +## Limitations + +No completed retained nested `lambda=2` implementation comparison, actual +`lambda>2` collector, fast C-layer trace, all-size machine +refinement, clean-history hosting, tape movement, complete correction word +or selected cold replay is checked. No human or formal-kernel review is +claimed. The source archive's scientific admission remains separate. + +## Open next questions + +1. Complete the retained nested evaluator comparison on this same actual + fixture, with a measured replay budget, or establish its separate component + equivalences. Agreement of the two direct semantic models does not verify + the nested implementation. Both 600-second attempts remain unresolved. +2. Bind an actual fast reversible backend trace to this checked boundary, + pricing snapshots, source access, cleanup and clean stock. The blocker is + the physical backend and enclosing caller, not this direct finite oracle. +3. Name a changed complete P104 profile or consumer and price every term + before further construction. PR3131 retains the unchanged five-forward / + four-dual rejection `599/584 > 1`; this audit does not reprove it or remove + any of its paid ranks. Clean history is not extra productive coverage. + +The decision is to stop at this bounded audit. Detailed scope and next +questions are in `TASK.json`; the claim is in discussion **#2750**. + +## Credit + +Prepared for commdata2338 (@commdata2338), with substantial OpenAI Codex assistance. + +Credit Jose Manuel / jmbarrancoml, **PR3131** +`0c9e344d5a5295a218558fa4a51d867f39ff5311`, for the actual field-major dense +collector, original-order construction and explicit validation gap; +Tekalign, **PR3025** `a544ef068a46f4de3bc47d1d02149cbdc3ba547f` and **PR3033** +`b12bbaeb5ca2e83f15433fc2dd0ba3b766595281`, for the signed lifting pair, +paired collector, grid policy and period split; and Ross Richardson, +**PR3072** `cd1bbd05251f9d8e15cbb0192f1bfe83dc138f5e`, for the conditional +blocked construction. Retain Jose Manuel's PR3109 and PR2250/2287/2899 +affine/compiler/physical lineage, Douglas Colkitt, ywz65 / PR2586, +Arham Tahir, Vasek/flyingviper's consumer audit and the retained Rohan Arun, +Chafik Boukhalfa, Adam Gall, Josie Elliston and Ali Romman P104 lineage. + +Both new numerical evaluators were separately written in this contribution +with shared raw inputs. The small calibration intentionally executes credited +PR3025 code; the incomplete retained attempts intentionally execute credited +PR3131 and its source archive. These are not separate human reviews. Apache-2.0; +predecessor licenses, frozen inputs and the selected record are unchanged. diff --git a/research/p104-tensor-collector-audit/RESULT.json b/research/p104-tensor-collector-audit/RESULT.json new file mode 100644 index 0000000000..a443a2c1c4 --- /dev/null +++ b/research/p104-tensor-collector-audit/RESULT.json @@ -0,0 +1,276 @@ +{ + "actual_events": [ + 2025, + 2039 + ], + "cases": [ + { + "beta": 0, + "components": 512, + "entrance_query_sha256": "5349eb1fde593330d8b139acaf3674e923db69a609b3e1f8edd22aaa35e7979d", + "exact_return": true, + "input_grid": 3, + "input_norm2_at_working_grid": 6692002474278400, + "literal_pair_sites_both_directions": 3584, + "mode": "rounding", + "multiplicity": 1, + "original_return_recipe_ideal_fixture_checked": false, + "output_grid": 3, + "private_zero": true, + "promotion": 0, + "query_sha256": "eec84779b1c46dfedcc5a16ebba4003344331f73a39a4d8769748e628ba97853", + "rank": 7, + "scalar_field_adds": 11, + "sent_norm2_at_working_grid": 6692002474278400, + "sent_sha256": "fa6a78b1116e93096e7160d99ed641bc90a98b43b345c809f9b2d544a116d666", + "source_sha256": [ + "1c8aebd2047166d387555d64e3f073fb7aa74455dc70ad8f4c210e9217b0f6e3", + "d742e5eab01a9ba8fc36a61412e36c28d3858e576d52ff7bc49c4f10b1044e49", + "a798a5db384208c40b86e8acba7ac7e4fc20c377b1637f85767db5c9bf845ed8", + "de5d687a10b39e67d3383b0aa5078e4e6d42cfca71554f70af2af62e3c2344f0", + "a493f920a9b524240521ef4812b1e6614990a1f68660499a3a3a343c1468ae04" + ], + "squared_error_denominator": 16384, + "squared_error_numerator": 0, + "wrapper_values_both_directions": 2048 + }, + { + "beta": 0, + "components": 262144, + "entrance_query_sha256": "1166a8789b6c203b44ccc9ebd1b03f83ab08e48f4a6f024ac622e2a69fe66db2", + "exact_return": true, + "input_grid": 3, + "input_norm2_at_working_grid": 252277053466569662, + "literal_pair_sites_both_directions": 3670016, + "mode": "rounding", + "multiplicity": 2, + "original_return_recipe_ideal_fixture_checked": true, + "output_grid": 3, + "private_zero": true, + "promotion": 0, + "query_sha256": "6bdc2f00efe382ee5b08414b343a99e2e224df5acd4c6fcfa508aa18a2e9e06b", + "rank": 14, + "scalar_field_adds": 11, + "sent_norm2_at_working_grid": 252277058455729000, + "sent_sha256": "b5ee12c6746dad334039eaf0455fe4ecce5c8721a6a68dfa423308dc50524b23", + "source_sha256": [ + "5b1877eee1500bb4937ce3fd0f3836d6485f0b6b4d272d4b41454ee3f42727ce", + "3c84ef88ea2e0fa5ab1207ea7dfb4ed714a1a9c56042f40fcbf41df9e9b2be87", + "f85154c470e70b58eb8a2a3e45b975f27ea3f52059c57c9a4faf04f2f7f90c9a", + "6301d63c2de44bd35e6a6c0dc996776046b13a02f29924b1c81208e1c6c5161c", + "17b6481b5b34755f4d547a1dc67866211340dde6762919fc644900960a08b6d1" + ], + "squared_error_denominator": 268435456, + "squared_error_numerator": 180506167607296, + "wrapper_values_both_directions": 1048576 + }, + { + "beta": 0, + "components": 262144, + "entrance_query_sha256": "1166a8789b6c203b44ccc9ebd1b03f83ab08e48f4a6f024ac622e2a69fe66db2", + "exact_return": true, + "input_grid": 3, + "input_norm2_at_working_grid": 14926865734896, + "literal_pair_sites_both_directions": 3670016, + "mode": "promoted", + "multiplicity": 2, + "original_return_recipe_ideal_fixture_checked": false, + "output_grid": 5, + "private_zero": true, + "promotion": 2, + "query_sha256": "e9953a1f3325babed42b07981a1c067780226609cf51c5c15f0a50ffc7ddf642", + "rank": 14, + "scalar_field_adds": 11, + "sent_norm2_at_working_grid": 14926878207316, + "sent_sha256": "32044047544d63fbf8769f110debbaf147727447227b0ac1bd84de2e7e732ed1", + "source_sha256": [ + "9427e583db4067d999f77c1bc650ccd3172722a4fcfa0629e39495db701852de", + "79aac716dd3bb0f26f56125d37de8fb9fc22c378967157dc34cb53fb3851befe", + "81fd08c52cb700a03a375f126b2642f2430997a50a81e9c7823dcaddb32dabd6", + "e3f82069fcdc9348e2bef6fcf3a01748a34d616406cf485597b2508f584d661c", + "35ab1354fae1ff9e0a467c961e4d638867828cd6acbabe2d40568eef854751be" + ], + "squared_error_denominator": 268435456, + "squared_error_numerator": 175512295047168, + "wrapper_values_both_directions": 1048576 + }, + { + "beta": 8, + "components": 262144, + "entrance_query_sha256": "1166a8789b6c203b44ccc9ebd1b03f83ab08e48f4a6f024ac622e2a69fe66db2", + "exact_return": true, + "input_grid": 3, + "input_norm2_at_working_grid": 35184372088832, + "literal_pair_sites_both_directions": 3670016, + "mode": "cancellation", + "multiplicity": 2, + "original_return_recipe_ideal_fixture_checked": false, + "output_grid": 25, + "private_zero": true, + "promotion": 22, + "query_sha256": "00d0f20e059d554c59944e141faab683fe4c8875e4bf01600d1abc21e3b9e863", + "rank": 14, + "scalar_field_adds": 11, + "sent_norm2_at_working_grid": 35184372088832, + "sent_sha256": "340f4994e542bf623094ca5152230059dee928259377f57a5eda82db4e6d190b", + "source_sha256": [ + "fb6826722ec08b9651d83840a29c5730d7722dc4f0a52ecaae88fdf056bd6a7c", + "659cf0271b88f7cc345ebba271a3b63f162a3a59fe5694c58bfe70534a7bf352", + "5ef461366079e7818a8832facb3d761bcd464a0b9a1fc38fc96a87df91d24e51", + "476b3e7f7f2cc7c7302fcdf13bcffc3d2e95795d27f9c23cc1d1a182d8df0297", + "6c136db9fbaa2c5d9875a48273948263215a53f7ef90f34c6ab26d25e03ec7a9" + ], + "squared_error_denominator": 268435456, + "squared_error_numerator": 0, + "wrapper_values_both_directions": 1048576 + }, + { + "beta": 8, + "components": 262144, + "entrance_query_sha256": "1166a8789b6c203b44ccc9ebd1b03f83ab08e48f4a6f024ac622e2a69fe66db2", + "exact_return": true, + "input_grid": 3, + "input_norm2_at_working_grid": 0, + "literal_pair_sites_both_directions": 3670016, + "mode": "zero", + "multiplicity": 2, + "original_return_recipe_ideal_fixture_checked": false, + "output_grid": 3, + "private_zero": true, + "promotion": 0, + "query_sha256": "1166a8789b6c203b44ccc9ebd1b03f83ab08e48f4a6f024ac622e2a69fe66db2", + "rank": 14, + "scalar_field_adds": 11, + "sent_norm2_at_working_grid": 0, + "sent_sha256": "61b1fec8cfbee1ed941bc7bb0c1076f0def60163dc10f6093b9b546600f83aaf", + "source_sha256": [ + "fb6826722ec08b9651d83840a29c5730d7722dc4f0a52ecaae88fdf056bd6a7c", + "659cf0271b88f7cc345ebba271a3b63f162a3a59fe5694c58bfe70534a7bf352", + "61b1fec8cfbee1ed941bc7bb0c1076f0def60163dc10f6093b9b546600f83aaf", + "476b3e7f7f2cc7c7302fcdf13bcffc3d2e95795d27f9c23cc1d1a182d8df0297", + "6c136db9fbaa2c5d9875a48273948263215a53f7ef90f34c6ab26d25e03ec7a9" + ], + "squared_error_denominator": 268435456, + "squared_error_numerator": 0, + "wrapper_values_both_directions": 1048576 + } + ], + "controls": { + "exhaustive_signed_pairs": 2401, + "order_witness": { + "both_paired_inverses_restore": true, + "input": [ + [ + 1, + 0 + ], + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0, + 0 + ] + ], + "natural": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 0, + 0 + ] + ], + "reversed": [ + [ + 0, + 0 + ], + [ + 1, + 0 + ], + [ + 0, + 0 + ], + [ + 0, + 0 + ] + ] + }, + "tensor": { + "omitted_tensor_constant": { + "address": 0, + "correct": [ + 212799, + 2 + ], + "wrong": [ + 212799, + 1 + ] + }, + "wrappers": [ + { + "addresses": 262144, + "output_sha256": "155ed6dc9f92df67cf7c52e1b302f13641f947eb2c6ee73d4a6bf0f37b833a7b", + "side": "left", + "wrong_layout_witness": { + "address": 8, + "copy_major": [ + 160, + 3 + ], + "correct": [ + 8, + 2 + ] + } + }, + { + "addresses": 262144, + "output_sha256": "3477b5a5044a5db4855e0f7a93670e1ac1b70ec8b4ba35813f71277ec3a046f8", + "side": "right", + "wrong_layout_witness": { + "address": 0, + "copy_major": [ + 192375, + 2 + ], + "correct": [ + 212799, + 2 + ] + } + } + ] + }, + "wrong_inverse_order_rejected": true + }, + "native_events": [ + 2031, + 2033 + ], + "recipe_sha256": [ + "79b5ff9278a589c388a7dfaaf0691792f2f5dafab297515392f86d2908bb14a4", + "df96a8c45a37182854f6f163efd995e4c8bf0dc058db342103bbd928a1b14de7" + ], + "schema_version": 1, + "scope": "finite exact scalar tensor boundary; no fast physical trace, all-size proof or new kappa" +} diff --git a/research/p104-tensor-collector-audit/SOURCES.json b/research/p104-tensor-collector-audit/SOURCES.json new file mode 100644 index 0000000000..7d961517b8 --- /dev/null +++ b/research/p104-tensor-collector-audit/SOURCES.json @@ -0,0 +1,114 @@ +{ + "schema_version": 1, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/dense-paired-collector/PROOF.md", + "usage": "input", + "git_blob": "11c1c4ae2dd9a3f4cb72a5e00603d0450a26a90e", + "sha256": "5d38442baf3cd5cb332d0fd0e78054a4f4689162ddb47486574c7dba5e3113e1" + }, + { + "path": "research/dense-paired-collector/RESULT.json", + "usage": "input", + "git_blob": "6c7d79aae090942fc72e1dce57d72aa679e1e032", + "sha256": "ceaad736ef486f93fc4895b7e43fccdb6a2edd53989a16f003e1b07638b68922" + }, + { + "path": "research/dense-paired-collector/model.py", + "usage": "input", + "git_blob": "c314be172423f9a171705056944a50e5390336f5", + "sha256": "0b7b64b72a95b0ba38f4ea5917a4faabcb430e3888400e0d510a8cc6e4d4a909" + }, + { + "path": "research/p104-reversible-lifting/lifting.py", + "usage": "input", + "git_blob": "524ed59c1e498f78134681bea49fac55e9541068", + "sha256": "9424ee08f22b717f6d58f7cc46f189c5549fa86778afcd0c0762ab2daf591160" + }, + { + "path": "research/p104-rounded-collector/inputs/NATIVE.json.gz", + "usage": "input", + "git_blob": "04f2877aa5444948b7ae37efd267745af82cb34d", + "sha256": "ab91c78835c3e10cf3b2cb8a5d4e0b7cfc3df1ae5a811298d27842f2193e1e3d" + }, + { + "path": "research/p104-rounded-collector/inputs/WORD.json", + "usage": "input", + "git_blob": "93acaabc0a523789ef2f1b06f6eeeefed5551397", + "sha256": "cec1fb3fbd0067b500ad5119a62ba60685be718e769374d7ec8abdd2beaa7e50" + }, + { + "path": "research/dense-paired-collector/inputs/pr3109.tar", + "usage": "input", + "git_blob": "3c422fa63672460d4e3583b8a3f24a518f50b148", + "sha256": "9c171aabb02e59e53b2e4f0ed2845409fa2987fcd90a349a8c492abca1059f4b" + }, + { + "path": "research/dense-paired-collector/sources.py", + "usage": "input", + "git_blob": "56b60cf14a58a9b56e926c8a3c5f663d0cb3cb35", + "sha256": "0f93778c4e1f92a718d9376984b002a2cd87ff4286160194ac03a89b379590b0" + }, + { + "path": "research/p104-blockwise-lifting/PROOF.md", + "usage": "input", + "git_blob": "75142a63021fc0087f048feb86b1022717da8628", + "sha256": "d84477000e580fa73eec8225d9acf43aabdcc50780b679bf239205a359b538e2" + }, + { + "path": "research/p104-blockwise-lifting/README.md", + "usage": "input", + "git_blob": "20df0afb308eeb826f101be6e6b861db00728d66", + "sha256": "63af9f9a3519cedcd4d121b750dba5dcacf7b17f0a679a819b41f8b892097c9e" + }, + { + "path": "research/p104-consumer-budget-audit/README.md", + "usage": "input", + "git_blob": "7317fa775e5942e66237b9053aa5e0ed8dc6b1a3", + "sha256": "13694215d0c1a245b392f7155e8395b9c4bad9c5db3558833c784d9449616417" + }, + { + "path": "research/p104-lifting-residue-reduction/split.py", + "usage": "input", + "git_blob": "3d31c6df14c84220cb22fd3fe5de624c7a6d8fe3", + "sha256": "5722ab53b2f46fcc5a761b9d4567df36887fd9fff10eb04380535266be6df99d" + }, + { + "path": "research/p104-lifting-residue-reduction/vendor/lifting.py", + "usage": "input", + "git_blob": "524ed59c1e498f78134681bea49fac55e9541068", + "sha256": "9424ee08f22b717f6d58f7cc46f189c5549fa86778afcd0c0762ab2daf591160" + }, + { + "path": "research/physical-ordinary-interchange/PROOF.md", + "usage": "input", + "git_blob": "12be1f06062090fcc68e598bae250f185e3d8524", + "sha256": "8a1c2145cd8f080026488a571d95813c09679aa323f19aeaef0ea98030136e1c" + }, + { + "path": "research/selected-complex-compact-adapters/monomial.py", + "usage": "input", + "git_blob": "5fa4494167c4ba668993a2b1c902969518728a4c", + "sha256": "394f9a465ac9148af0c20844d375e4befbef17d92b2fcc840d83419480dd4740" + }, + { + "path": "research/selected-complex-layer-closure/PROOF.md", + "usage": "input", + "git_blob": "d7ec0d101405a5f099f55f6a73e9791731737fd0", + "sha256": "43feda0342c07a9429699c3a44e8936a3f3fb57ce9b32f38ff3dc06ac887b265" + } + ] +} diff --git a/research/p104-tensor-collector-audit/TASK.json b/research/p104-tensor-collector-audit/TASK.json new file mode 100644 index 0000000000..549b178e3f --- /dev/null +++ b/research/p104-tensor-collector-audit/TASK.json @@ -0,0 +1,155 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "priority_revision": 6, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "original_card": { + "id": "p104-side-correction", + "question": "Can the proposed P104 joint endpoint flags be realized by a chronological correction program with coefficients, dirty restoration and an affordable complete bill?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/p104-native-channel/README.md", + "research/p104-native-channel/PROOF.md", + "docs/research/community-efficient1000-review.md", + "research/p104-joint-unit-flags/README.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. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the revision-6 family record and #2981 static joint flags, alongside the reviewed #1991 channel. #2981 is an author-checked source archive, not an independently validated executable correction or a refutation of program-level lifetime floors.", + "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": "After checking live handoffs, pin one named collection from #2981 and attach acquisition/delivery times, source dependencies and coefficient requirements. Test legal access and arbitrary dirty restoration; price any completion against the full channel/endpoint/hosting allowance. Stop with the exact missing implication or a scoped counterexample rather than expanding the static cover census.", + "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.", + "Repeating a correction or physical conversion already supplied by a pending follow-up without adding independent coverage or a different unresolved obligation.", + "Repeating the 208-flag static matching or calling a static nested cover a chronological correction program. Independent audit of that certificate is distinct and remains useful." + ], + "overlap_terms": [ + "P104", + "I-G/2", + "side correction", + "native channel", + "1972", + "1991", + "2586", + "endpoint transport", + "physical dual", + "relay composition", + "2981", + "joint unit flags", + "acquisition delivery", + "static nesting" + ], + "existing_checks": [ + { + "scope": "PR #2981 reports static joint endpoint flags and a matching of 208 departure and arrival flags; archival intake is not independent verification.", + "evidence": "research/p104-joint-unit-flags/README.md", + "remaining": "Independent flag check and a chronological coefficient program with dirty restoration and a complete cost.", + "status": "author-checked", + "source_commit": "3d24b92d8ba057b57cb2d480170ec407520e6882", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Independent actual multiplicity-two finite boundary audit of PR3131 first paired P104 collector: all tensor wrapper addresses, original-order rounded output, adaptive grid, five preserved dirty sources and literal private zero return.", + "scope_change_reason": "The revision-6 static-matching realization question has newer active checks. This supplies independent semantic evidence for PR3131 PROOF section7's explicitly unrun actual lambda>1 collector boundary, a concrete chronological restoration/precision component on the same P104 track. It does not reconstruct a static collection or certify the fast implementation.", + "bottleneck_link": "A collector used inside a future chronological correction must preserve its actual field-major recipe, nonlinear order, query grid and private cleanup. This independently checks the first larger actual tensor instance before relying on that interface; it does not repair the rejected unchanged consumer bill.", + "budget_minutes": 60, + "stop_rule": "Stop after four deterministic full multiplicity-two fixtures, all-address wrapper checks, a small calibration, exact error inequalities and rejecting controls; no further size search or supplier expansion.", + "outcome": "completed", + "evidence": "Two separately written exact evaluators agree on complete actual multiplicity-two semantic outputs. Two cases have nonzero rounding error; cancellation and zero cases restore exactly. Complete receipt and controls accompany the scoped derivation. Two optional retained nested-evaluator plans each timed out at600 seconds; neither establishes an implementation comparison. The fast physical backend is not run.", + "author": "commdata2338", + "ai_assistance": "Prepared for commdata2338 (@commdata2338), with substantial OpenAI Codex assistance in derivation, implementation, checking and writing. No independent human review is claimed.", + "open_questions": [ + { + "question": "Does the retained nested PR3131 evaluator agree on the complete actual multiplicity-two promoted fixture?", + "why_it_matters": "Two direct semantic models agree, but their agreement does not validate the nested implementation; both retained attempts timed out at600 seconds.", + "first_step": "Run the preserved single-fixture attempt with a measured longer budget, or separately bind its actual wrapper and original-order core components before claiming composition.", + "blocked_by": "No complete retained nested receipt atN262144; no arithmetic counterexample established." + }, + { + "question": "Does an actual fast reversible implementation realize this tensor boundary with the claimed complete time and clean-space tariff?", + "why_it_matters": "This audit executes direct integer semantics and monomial permutations, not the fast C-layer implementation or a tape trace.", + "first_step": "Bind one named complete backend trace at a small actual tensor instance to the independently checked query/grid/private boundary, counting its retained history, access and cleanup.", + "blocked_by": "Source-preserving fast backend, all-size machine refinement and actual enclosing clean-stock/physical hosting remain inherited premises." + }, + { + "question": "Can a changed complete P104 consumer afford the correction and its physical storage?", + "why_it_matters": "Correct local collector execution does not reduce the unchanged five-forward/four-dual paid profile, whose cited zero-saving screen is 599/584 > 1.", + "first_step": "Name a changed profile or coverage law and price every rank, idle, restoration, movement and clean-stock term before construction expansion.", + "blocked_by": "No changed complete consumer is supplied; this audit does not reprove or alter the inherited budget screen." + } + ], + "scope_key": "72dfbf0708467ad34793 / PR3131-first-paired-collector-lambda2", + "coordination": { + "thread": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2750", + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2750#discussioncomment-19001927", + "status": "Claim public; artifact awaiting publication." + }, + "dependency_heads": { + "3131": "0c9e344d5a5295a218558fa4a51d867f39ff5311", + "3025": "a544ef068a46f4de3bc47d1d02149cbdc3ba547f", + "3033": "b12bbaeb5ca2e83f15433fc2dd0ba3b766595281", + "3072": "cd1bbd05251f9d8e15cbb0192f1bfe83dc138f5e", + "3109": "15eac811648182bdac7254a91fd9b841b1414ebc", + "2250": "d404b48a1e7b147556b309497d55089c837dddb2", + "2586": "7953c9a8f788a8de5cf2ced63d9a61b67c22c6f1", + "2287": "8c60765b5dea9d862b3b190d55da102a576031bf", + "2899": "2f0911ad735643a069b9790302fbf179e49f74f8" + }, + "adjacent_work": { + "3134": { + "head": "d8c0e3e88e501da6c19f858b7debf0c2e3e0be69", + "scope": "Later guarded-wrapper realization reduces calls while preserving this same collector boundary; N512 collector tests, no actual multiplicity-two collector replay supplied there. Its changed implementation is not replayed here." + } + }, + "freshness": { + "checked_at": "2026-10-17T18:08:57.334619+00:00", + "base": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "canonical_main": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "changed_guidance": [], + "priority_revision": 6, + "decision": "Finish finite semantic audit; preserve base and immutable inputs. Full retained nested comparison remains uncompleted after two bounded timeouts." + }, + "evidence_status": "Author-checked independent implementation; not independent human or formal-kernel review.", + "extended_comparison": { + "status": "not completed", + "time_limit_seconds_per_attempt": 600, + "plans": [ + { + "width": 160, + "d": 2, + "spacing": 2, + "suffix": 1, + "outer": 3 + }, + { + "width": 160, + "d": 157, + "spacing": 1, + "suffix": 2, + "outer": 14 + } + ], + "result": "Both processes exited124 without a completed receipt; not evidence of a mathematical failure.", + "script": "attempt_retained.py", + "scope": "Only the finite n guard is raised10 to18 in an authenticated in-memory copy. Original arithmetic and block-planning code remain unchanged." + } +} diff --git a/research/p104-tensor-collector-audit/VERIFY.json b/research/p104-tensor-collector-audit/VERIFY.json new file mode 100644 index 0000000000..333e855d32 --- /dev/null +++ b/research/p104-tensor-collector-audit/VERIFY.json @@ -0,0 +1,48 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/dense-paired-collector/PROOF.md", + "research/dense-paired-collector/RESULT.json", + "research/dense-paired-collector/inputs/pr3109.tar", + "research/dense-paired-collector/model.py", + "research/dense-paired-collector/sources.py", + "research/p104-blockwise-lifting/PROOF.md", + "research/p104-blockwise-lifting/README.md", + "research/p104-consumer-budget-audit/README.md", + "research/p104-lifting-residue-reduction/split.py", + "research/p104-lifting-residue-reduction/vendor/lifting.py", + "research/p104-reversible-lifting/lifting.py", + "research/p104-rounded-collector/inputs/NATIVE.json.gz", + "research/p104-rounded-collector/inputs/WORD.json", + "research/physical-ordinary-interchange/PROOF.md", + "research/selected-complex-compact-adapters/monomial.py", + "research/selected-complex-layer-closure/PROOF.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Exact source binding; every address of both actual multiplicity-two monomials and their inverses; independently evaluated full query/grid on four complete N=262144 fixtures; exact error and cleanup; complete typed receipt." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_verify.py", + "-v" + ], + "timeout_seconds": 60, + "checks": "Eight behavioral groups including source corruption, actual event/native mutations, signed-floor and phase errors, wrong query promotion, corrupted return, typed receipt changes and actual optimized CLI; credited lambda1 source calibration." + } + ] +} diff --git a/research/p104-tensor-collector-audit/attempt_retained.py b/research/p104-tensor-collector-audit/attempt_retained.py new file mode 100644 index 0000000000..cf57ef6800 --- /dev/null +++ b/research/p104-tensor-collector-audit/attempt_retained.py @@ -0,0 +1,93 @@ +"""Optional extended PR3131 comparison; neither attempted plan finished in 600s. + +Only the finite Executor n<=10 guard becomes n<=18. No arithmetic, control +plan, macro implementation or scalar oracle is changed. The archived fast +algorithm's *direct semantic* oracle remains a direct semantic oracle. +""" +import argparse +import json +from pathlib import Path +import sys +import types + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import verify as v + + +def load_model(raw): + prefix = "research/dense-paired-collector/" + sources = types.ModuleType("sources") + sources.__file__ = str(v.ROOT / (prefix + "sources.py")) + exec(compile(raw[prefix + "sources.py"], sources.__file__, "exec", optimize=0), sources.__dict__) + original = raw[prefix + "model.py"].decode() + before, after = "1 <= n <= 10 and width >= 8", "1 <= n <= 18 and width >= 8" + v.need(original.count(before) == 1 and after not in original, "one exact finite guard adapter") + adapted = original.replace(before, after) + v.need(adapted.replace(after, before) == original, "only the finite extent guard changes") + module = types.ModuleType("retained_dense_model") + module.__file__ = str(v.ROOT / (prefix + "model.py")) + previous = sys.modules.get("sources") + sys.modules["sources"] = sources + try: + exec(compile(adapted, module.__file__, "exec", optimize=0), module.__dict__) + finally: + if previous is None: + del sys.modules["sources"] + else: + sys.modules["sources"] = previous + return module + + +def run(plan): + raw, word, native = v.source_inputs() + recipe = v.bind(word, native)[0] + model = load_model(raw) + sources, query, f, beta = v.fixture(2, "promoted") + original_sources, original_query = [v.digest(x) for x in sources], v.digest(query) + # One finite plan derived from the inherited p=160 exponents, with exact + # integer inequalities. The asymptotic outer height exceeds the rank 14. + width = 160 + d = next(k for k in range(width, 0, -1) if k**1000 <= width**997) + spacing = 1 + v.need(spacing**500 <= d < (spacing+1)**500, "exact spacing floor") + suffix = (width+d-1)//d + v.need(14**10 < width**9, "outer cap fits p^(5991997/6000000)") + parameters = dict(width=width, d=d, spacing=spacing, suffix=suffix, outer=14) + if plan == "defaults": + parameters = dict(width=160, d=2, spacing=2, suffix=1, outer=3) + engine = model.Executor(18, **parameters) + result = model.collector(engine, sources, query, f, beta, recipe, multiplicity=2) + # Compare full arrays against the separately written column/parity evaluator. + F, total, fine, sent, updated = v.oracle.collector_query(sources, query, f, beta, recipe, 2) + for name, expected in (("entrance", total), ("sent", sent), ("query", updated), ("returned", fine)): + v.need(result[name] == expected, "retained nested evaluator: " + name) + v.need(result["grid"] == F == 5, "retained promoted grid") + v.need(all(z == (0, 0) for z in result["private"]), "retained private zero") + v.need([v.digest(x) for x in sources] == original_sources and v.digest(query) == original_query, + "retained source/query entrances unchanged") + v.need(engine.counts["address_gates"] == 52 and engine.counts["address_oracles"] == 104, + "actual four-wrapper gate invoice") + return dict(schema_version=1, multiplicity=2, components=1 << 18, rank=14, + fixture="promoted", input_grid=f, beta=beta, output_grid=F, + finite_guard_adapter=dict(original_max_n=10, adapted_max_n=18, + arithmetic_and_control_plan_unchanged=True), + executor_parameters=parameters, + source_sha256=original_sources, entrance_query_sha256=original_query, + sent_sha256=v.digest(sent), query_sha256=v.digest(updated), + returned_sha256=v.digest(result["returned"]), private_zero=True, + counts=engine.counts, + scope="retained nested evaluator with frozen direct semantic backend; no fast physical trace") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--plan", choices=("derived", "defaults"), default="derived") + args = parser.parse_args() + result = run(args.plan) + print(json.dumps(result, sort_keys=True, indent=2)) + print("PASS_P104_RETAINED_TENSOR_COLLECTOR n=18 components=262144 no_new_kappa", file=sys.stderr) + + +if __name__ == "__main__": + main() diff --git a/research/p104-tensor-collector-audit/oracle.py b/research/p104-tensor-collector-audit/oracle.py new file mode 100644 index 0000000000..346b1d8db2 --- /dev/null +++ b/research/p104-tensor-collector-audit/oracle.py @@ -0,0 +1,110 @@ +"""Separate tensor-by-column and parity-formula oracle. Apache-2.0. + +Prepared for commdata2338 with substantial OpenAI Codex assistance. +No predecessor executable or primary arithmetic implementation is imported. +""" + + +def turn(z, phase): + a, b = z + for _ in range(phase % 4): + a, b = -b, a + return a, b + + +def column_table(record): + table = [] + for x in range(512): + bits = [(x // (2**j)) % 2 for j in range(9)] + y = record["offset"] + for row, mask in enumerate(record["matrix_rows"]): + bit = sum(bits[j] * ((mask // (2**j)) % 2) for j in range(9)) % 2 + y ^= bit << row + exponent = record["phase"] + exponent += sum(bits[j] * record["linear_Z4"][j] for j in range(9)) + exponent += 2 * sum(bits[j] * bits[k] * ((record["quadratic_rows"][j] >> k) & 1) + for j in range(9) for k in range(j + 1, 9)) + table.append((y, exponent % 4)) + return table + + +def monomial(values, record, multiplicity): + """Apply one 512-entry tensor factor at a time, at strided field bits.""" + table = column_table(record) + result = list(values) + for column in range(multiplicity): + axes = [j * multiplicity + column for j in range(9)] + deposits = [sum(((x >> j) & 1) << axis for j, axis in enumerate(axes)) + for x in range(512)] + mask = sum(1 << axis for axis in axes) + out = [None] * len(result) + for start in range(len(result)): + if start & mask: + continue + for x, (y, phase) in enumerate(table): + out[start | deposits[y]] = turn(result[start | deposits[x]], phase) + result = out + return result + + +def rounded(values, rank): + """Closed parity formula, independently of the difference/floor lift.""" + result = list(values) + for axis in range(rank): + step = 1 << axis + for block in range(0, len(result), 2 * step): + for j in range(block, block + step): + a, b = result[j] + c, d = result[j + step] + error = ((b - d) % 2) - ((a - c) % 2) + result[j] = ((a - b + c + d + error) // 2, + (b + a + d - c - error) // 2) + result[j + step] = ((a + b + c - d + error) // 2, + (b - a + d + c - error) // 2) + return result + + +def native(values, recipe, multiplicity): + result = monomial(values, recipe["right"], multiplicity) + result = rounded(result, recipe["rank"] * multiplicity) + return monomial(result, recipe["left"], multiplicity) + + +def walsh(values, rank): + result = list(values) + for axis in range(rank): + step = 1 << axis + for block in range(0, len(result), step * 2): + for j in range(block, block + step): + a, b = result[j] + c, d = result[j + step] + result[j], result[j + step] = (a + c, b + d), (a - c, b - d) + return result + + +def ideal_numerator(values, recipe, multiplicity): + """H diag(i^popcount) H, denominator 2^rank; no rounded pair code.""" + rank = recipe["rank"] * multiplicity + result = monomial(values, recipe["right"], multiplicity) + result = walsh(result, rank) + mask = (1 << rank) - 1 + result = [turn(value, (index & mask).bit_count()) for index, value in enumerate(result)] + result = walsh(result, rank) + return monomial(result, recipe["left"], multiplicity) + + +def collector_query(sources, query, f, beta, recipe, multiplicity): + total = [(sum(source[j][0] for source in sources), sum(source[j][1] for source in sources)) + for j in range(len(query))] + maximum = max(abs(v) for pair in total for v in pair) + r, n = 7 * multiplicity, 9 * multiplicity + log_rank = 0 + while 2**log_rank < r: + log_rank += 1 + guard = log_rank + n // 2 + promotion = 0 if maximum == 0 else max(0, beta + 1 + guard - (maximum.bit_length() - 1)) + fine = [(a * 2**promotion, b * 2**promotion) for a, b in total] + sent = native(fine, recipe, multiplicity) + updated = [(a * 2**promotion + c, b * 2**promotion + d) + for (a, b), (c, d) in zip(query, sent, strict=True)] + return f + promotion, total, fine, sent, updated diff --git a/research/p104-tensor-collector-audit/test_verify.py b/research/p104-tensor-collector-audit/test_verify.py new file mode 100644 index 0000000000..5260c00148 --- /dev/null +++ b/research/p104-tensor-collector-audit/test_verify.py @@ -0,0 +1,119 @@ +"""Acceptance-boundary controls; no full tensor replay is duplicated here.""" +import copy +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import verify as v + + +class Controls(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.raw, cls.word, cls.records = v.source_inputs() + cls.recipe = v.bind(cls.word, cls.records)[0] + cls.plans = tuple(v.plan(cls.recipe[side], 1) for side in ("left", "right")) + + def test_literal_event_and_native_binding(self): + for index, field, replacement in ((2032, 2, "D31"), (2034, 3, "1"), (2039, 1, "D31")): + word = copy.deepcopy(self.word) + word["program"][index][field] = replacement + with self.assertRaisesRegex(ValueError, "fifteen-event"): + v.bind(word, self.records) + records = copy.deepcopy(self.records) + row = next(x for x in records["transports"] if 2031 in x["events"]) + row["events"].remove(2031) + with self.assertRaisesRegex(ValueError, "unique native"): + v.bind(self.word, records) + + def test_predecessor_lambda1_calibration(self): + # Explicitly credited source execution, only for this control. Neither + # independent multiplicity-two evaluator imports predecessor code. + old = {} + source = self.raw["research/p104-reversible-lifting/lifting.py"] + exec(compile(source, "authenticated PR3025 lifting.py", "exec"), old) + for mode in ("rounding", "promoted", "cancellation", "zero"): + sources, query, f, beta = v.fixture(1, mode) + expected = old["collector"](sources, query, f, beta, + old["plan"](self.recipe["left"]), old["plan"](self.recipe["right"])) + actual = v.execute(sources, query, f, beta, self.plans, 1) + for key in ("grid", "query", "sent", "private", "entrance"): + self.assertEqual(actual[key], expected[key], (mode, key)) + + def test_query_promotion_is_observable(self): + sources, query, f, beta = v.fixture(1, "cancellation") + got = v.execute(sources, query, f, beta, self.plans, 1) + self.assertGreater(got["grid"], f) + wrong = [(a+c, b+d) for (a, b), (c, d) in zip(query, got["sent"], strict=True)] + self.assertNotEqual(wrong, got["query"]) + + def test_corrupted_private_return_rejected(self): + # The return is tested against the entire gathered input, not a digest. + original = v.native + def corrupt(values, plans, rank, inverse=False, order=None): + out = original(values, plans, rank, inverse, order) + if inverse: + a, b = out[0] + out[0] = (a+1, b) + return out + v.native = corrupt + try: + sources, query, f, beta = v.fixture(1, "cancellation") + with self.assertRaisesRegex(ValueError, "paired return"): + v.execute(sources, query, f, beta, self.plans, 1) + finally: + v.native = original + + def test_signed_floor_and_wrong_phase(self): + # Replacing floor by truncation changes an actual negative-odd pair. + a, b = (-1, 0), (0, 0) + dr, di = -1, 0 + sr, si = int(dr/2), int(di/2) + dr, di = -di, dr + br, bi = sr-int(dr/2), si-int(di/2) + self.assertNotEqual(((br+dr, bi+di), (br, bi)), v.pair(a, b)) + values = [(j+1, 0) for j in range(512)] + wrong = copy.deepcopy(self.recipe["right"]) + wrong["phase"] = (wrong["phase"]+1) % 4 + self.assertNotEqual(v.apply_plan(values, v.plan(wrong, 1)), v.apply_plan(values, self.plans[1])) + + def test_typed_receipt_and_duplicate_keys(self): + expected = dict(grid=3, private_zero=True, query_sha256="first") + v.compare_receipt(dict(reversed(list(expected.items()))), expected) + for key, value in (("grid", 4), ("private_zero", 1), ("query_sha256", "second")): + changed = dict(expected, **{key: value}) + with self.assertRaisesRegex(ValueError, "typed receipt"): + v.compare_receipt(changed, expected) + with self.assertRaisesRegex(ValueError, "duplicate"): + v.read_json('{"value": 1, "value": 1}') + + def test_source_corruption_rejects_before_execution(self): + with tempfile.TemporaryDirectory() as temp: + root = Path(temp) + for path, raw in self.raw.items(): + target = root/path + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(raw) + changed = root/"research/p104-rounded-collector/inputs/WORD.json" + changed.write_bytes(changed.read_bytes()+b"\n") + original = v.ROOT + v.ROOT = root + try: + with self.assertRaisesRegex(ValueError, "source hash"): + v.source_inputs() + finally: + v.ROOT = original + + def test_actual_optimized_cli(self): + result = subprocess.run([sys.executable, "-I", "-O", "-B", str(HERE/"verify.py"), "--quick"], + capture_output=True, text=True, timeout=30) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("PASS_P104_TENSOR_COLLECTOR_AUDIT", result.stderr) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/p104-tensor-collector-audit/verify.py b/research/p104-tensor-collector-audit/verify.py new file mode 100644 index 0000000000..7c36e5f1e4 --- /dev/null +++ b/research/p104-tensor-collector-audit/verify.py @@ -0,0 +1,333 @@ +"""Finite actual tensor-collector audit; standard library and exact integers. + +Prepared for commdata2338 with substantial OpenAI Codex assistance. +The signed-floor pair and paired return are credited to Tekalign; +the actual tensor/field-major boundary is Jose Manuel's PR3131. Apache-2.0. +""" +import argparse +import gzip +import hashlib +import itertools +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +import oracle + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def no_duplicates(pairs): + out = {} + for key, value in pairs: + need(key not in out, "duplicate JSON key: " + key) + out[key] = value + return out + + +def read_json(raw): + return json.loads(raw, object_pairs_hook=no_duplicates) + + +def digest(value): + return hashlib.sha256(json.dumps(value, sort_keys=True, separators=(",", ":"), + allow_nan=False).encode()).hexdigest() + + +def compare_receipt(actual, expected): + need(json.dumps(actual, sort_keys=True, allow_nan=False) == + json.dumps(expected, sort_keys=True, allow_nan=False), "complete typed receipt") + + +def source_inputs(): + raw = {} + for row in read_json((HERE / "SOURCES.json").read_bytes())["files"]: + if row["usage"] == "input": + data = (ROOT / row["path"]).read_bytes() + need(hashlib.sha256(data).hexdigest() == row["sha256"], "source hash: " + row["path"]) + raw[row["path"]] = data + word = read_json(raw["research/p104-rounded-collector/inputs/WORD.json"]) + native = read_json(gzip.decompress(raw["research/p104-rounded-collector/inputs/NATIVE.json.gz"])) + return raw, word, native + + +def bind(word, native): + frame = [256, 136, 64, 40, 16, 4, 2, 1] + names = ["D31", "D30", "D29", "D28", "D27"] + expected = [["zero", "C", frame]] + expected += [["add", "C", name, 1, frame] for name in names] + expected += [["transport", "C", frame, [364], 7], ["add", "Q7", "C", "1", [364]], + ["transport", "C", [364], frame, 7]] + expected += [["add", "C", name, "-1", frame] for name in reversed(names)] + expected += [["erase", "C", frame]] + need(word["program"][2025:2040] == expected, "literal fifteen-event boundary") + frames = dict(word["initial_frames"]) + for event in word["program"][:2025]: + if event[0] == "transport": + need(frames[event[1]] == event[2], "prefix transport entrance") + frames[event[1]] = event[3] + elif event[0] == "add": + need(frames[event[1]] == frames[event[2]] == event[4], "prefix ADD frame") + else: + need(event[0] == "sign" and frames[event[1]] == event[3], "prefix sign frame") + need(all(frames[name] == frame for name in names) and frames["Q7"] == [364], "entrance frames") + recipes = [] + for index in (2031, 2033): + matches = [x for x in native["transports"] if index in x["events"]] + need(len(matches) == 1, "unique native event") + row = matches[0] + need(word["program"][index] == ["transport", "C", row["old"], row["new"], 7], "native binding") + need(row["recipe"]["rank"] == 7, "native rank") + recipes.append(row["recipe"]) + return recipes + + +def rot(z, phase): + a, b = z + return ((a, b), (-b, a), (-a, -b), (b, -a))[phase % 4] + + +def pair(a, b, inverse=False): + dr, di = a[0] - b[0], a[1] - b[1] + sr, si = b[0] + dr // 2, b[1] + di // 2 + dr, di = (di, -dr) if inverse else (-di, dr) + br, bi = sr - dr // 2, si - di // 2 + return (br + dr, bi + di), (br, bi) + + +def lift(values, rank, inverse=False, order=None): + out = list(values) + axes = list(range(rank)) if order is None else list(order) + for axis in reversed(axes) if inverse else axes: + bit = 1 << axis + for index in range(len(out)): + if index & bit == 0: + other = index | bit + out[index], out[other] = pair(out[index], out[other], inverse) + return out + + +def plan(record, multiplicity): + """Expand the affine/quadratic polynomial directly on 9*lambda bits.""" + n = 9 * multiplicity + rows, linear, quadratic = [], [], [] + offset, constant = 0, multiplicity * record["phase"] + for field in range(9): + for column in range(multiplicity): + axis = field * multiplicity + column + rows.append(sum(((record["matrix_rows"][field] >> j) & 1) << (j * multiplicity + column) + for j in range(9))) + offset |= ((record["offset"] >> field) & 1) << axis + linear.append(record["linear_Z4"][field]) + quadratic.append(sum(((record["quadratic_rows"][field] >> j) & 1) << (j * multiplicity + column) + for j in range(field + 1, 9))) + table = [] + for x in range(1 << n): + y = offset ^ sum(((mask & x).bit_count() % 2) << j for j, mask in enumerate(rows)) + phase = constant + sum(linear[j] + 2 * (quadratic[j] & x).bit_count() + for j in range(n) if x >> j & 1) + table.append((y, phase % 4)) + need(len({y for y, _ in table}) == 1 << n, "actual tensor bijection") + return table + + +def apply_plan(values, table, inverse=False): + out = [None] * len(values) + if inverse: + for x, (y, phase) in enumerate(table): + out[x] = rot(values[y], -phase) + else: + for x, (y, phase) in enumerate(table): + out[y] = rot(values[x], phase) + return out + + +def native(values, plans, rank, inverse=False, order=None): + left, right = plans + if inverse: + out = apply_plan(values, left, True) + out = lift(out, rank, True, order) + return apply_plan(out, right, True) + out = apply_plan(values, right) + out = lift(out, rank, False, order) + return apply_plan(out, left) + + +def fixture(multiplicity, mode): + n = 1 << (9 * multiplicity) + if mode == "rounding": + sources = [[(((j * (37 + 2 * k) + 19 * k) % 1048583) - 524291, + ((j * (53 + 4 * k) + 31 * k) % 1048601) - 524300) + for j in range(n)] for k in range(5)] + beta = 0 + elif mode == "promoted": + sources = [[(((j * (37 + 2 * k) + 19 * k) % 2053) - 1026, + ((j * (53 + 4 * k) + 31 * k) % 2063) - 1031) + for j in range(n)] for k in range(5)] + beta = 0 + else: + big = [((j % 29 - 14) * 2**70 + j % 3, (j % 31 - 15) * 2**70 - j % 5) for j in range(n)] + tail = [(j % 7 - 3, j % 11 - 5) for j in range(n)] + residual = [(int(j == 0), -int(j == 7)) for j in range(n)] if mode == "cancellation" else [(0, 0)] * n + sources = [big, [(-a, -b) for a, b in big], residual, tail, [(-a, -b) for a, b in tail]] + beta = 8 + query = [(j % 13 - 6, j % 17 - 8) for j in range(n)] + return sources, query, 3, beta + + +def execute(sources, query, f, beta, plans, multiplicity): + count, rank, n = len(query), 7 * multiplicity, 9 * multiplicity + private = [(0, 0)] * count + for source in sources: + private = [(a + c, b + d) for (a, b), (c, d) in zip(private, source, strict=True)] + entrance = private + maximum = max(abs(value) for z in private for value in z) + gamma = (rank - 1).bit_length() + n // 2 + grid = f if maximum == 0 else max(f, beta + 1 + gamma - (maximum.bit_length() - 1 - f)) + shift = grid - f + fine = [(a << shift, b << shift) for a, b in private] + sent = native(fine, plans, rank) + updated = [((a << shift) + c, (b << shift) + d) for (a, b), (c, d) in zip(query, sent, strict=True)] + returned = native(sent, plans, rank, True) + need(returned == fine, "exact paired return on the actual tensor") + divisor = 1 << shift + need(all(a % divisor == b % divisor == 0 for a, b in returned), "exact private downshift") + private = [(a // divisor, b // divisor) for a, b in returned] + for source in reversed(sources): + private = [(a - c, b - d) for (a, b), (c, d) in zip(private, source, strict=True)] + need(all(z == (0, 0) for z in private), "private erasure only at zero") + return dict(grid=grid, entrance=entrance, fine=fine, sent=sent, query=updated, private=private) + + +def check_case(recipe, plans, multiplicity, mode, return_recipe=None): + sources, query, f, beta = fixture(multiplicity, mode) + source_hashes, query_hash = [digest(x) for x in sources], digest(query) + result = execute(sources, query, f, beta, plans, multiplicity) + F, total, fine, sent, updated = oracle.collector_query(sources, query, f, beta, recipe, multiplicity) + need(result["grid"] == F and result["entrance"] == total and result["fine"] == fine, + "independent gather/grid") + need(result["sent"] == sent and result["query"] == updated, "independent actual query") + need([digest(x) for x in sources] == source_hashes and digest(query) == query_hash, "read-only entrances") + rank, count = 7 * multiplicity, len(query) + ideal = oracle.ideal_numerator(fine, recipe, multiplicity) + if return_recipe is not None: + ideal_return = oracle.ideal_numerator(ideal, return_recipe, multiplicity) + need(ideal_return == [(a << (2*rank), b << (2*rank)) for a, b in fine], + "actual outbound/return native recipe ideal fixture") + error2 = sum(((a << rank) - c)**2 + ((b << rank) - d)**2 + for (a, b), (c, d) in zip(sent, ideal, strict=True)) + norm2 = sum(a * a + b * b for a, b in fine) + need((error2 << (2 * beta + 2)) <= (norm2 << (2 * rank)), "exact relative forward bound") + need(error2 <= rank**2 * (count // 2) * (1 << (2 * rank)), "absolute pair-error bound") + need(sum(a * a + b * b for a, b in ideal) == norm2 << (2 * rank), "Walsh/native unitarity") + sent_norm2 = sum(a * a + b * b for a, b in sent) + need(error2 << (2 * beta) <= sent_norm2 << (2 * rank), "paired inverse relative bound") + if mode == "zero": + need(F == f and updated == query and error2 == 0, "zero-sum boundary") + if mode in ("rounding", "promoted") and multiplicity == 2: + need(error2 > 0, "genuine nonlinear rounding fixture") + need((F > f) == (mode == "promoted"), "promotion control distinguishes grids") + return dict(multiplicity=multiplicity, mode=mode, components=count, rank=rank, + input_grid=f, beta=beta, output_grid=F, promotion=F-f, + source_sha256=source_hashes, entrance_query_sha256=query_hash, + sent_sha256=digest(sent), query_sha256=digest(updated), + squared_error_numerator=error2, squared_error_denominator=1 << (2*rank), + input_norm2_at_working_grid=norm2, sent_norm2_at_working_grid=sent_norm2, + exact_return=True, private_zero=True, + original_return_recipe_ideal_fixture_checked=return_recipe is not None, + literal_pair_sites_both_directions=count*rank, + wrapper_values_both_directions=4*count, scalar_field_adds=11) + + +def basic_controls(recipe, plans): + checks = 0 + for ar, ai, br, bi in itertools.product(range(-3, 4), repeat=4): + values = [(ar, ai), (br, bi)] + got = list(pair(*values)) + need(got == oracle.rounded(values, 1), "signed pair/parity identity") + need(list(pair(*got, inverse=True)) == values, "pair bijection") + checks += 1 + x = [((j * 31) % 41 - 20, (j * 17) % 43 - 21) for j in range(512)] + got = native(x, plans, 7) + need(got == oracle.native(x, recipe, 1), "lambda1 independent native") + need(native(got, plans, 7, True) == x, "lambda1 literal inverse") + wrong = native(got, plans, 7, True, order=list(reversed(range(7)))) + need(wrong != x, "wrong inverse order must fail") + impulse = [(1, 0), (0, 0), (0, 0), (0, 0)] + natural = lift(impulse, 2) + reordered = lift(impulse, 2, order=[1, 0]) + need(natural != reordered, "forward order is not an ideal tensor identity") + need(lift(natural, 2, True) == impulse and lift(reordered, 2, True, [1, 0]) == impulse, + "matching cleanup alone does not distinguish changed forward word") + return dict(exhaustive_signed_pairs=checks, wrong_inverse_order_rejected=True, + order_witness=dict(input=impulse, natural=natural, reversed=reordered, + both_paired_inverses_restore=True)) + + +def tensor_controls(recipe, plans): + """Bind full maps on every address; explicit layout/global-phase controls.""" + markers = [(j + 1, 0) for j in range(1 << 18)] + receipts = [] + for side, table in zip(("left", "right"), plans, strict=True): + got = apply_plan(markers, table) + need(got == oracle.monomial(markers, recipe[side], 2), "all-address exact tensor monomial") + need(apply_plan(got, table, True) == markers, "full tensor wrapper inverse") + base = oracle.column_table(recipe[side]) + wrong_layout = None + for address, expected in enumerate(table): + lo, hi = address & 511, address >> 9 + wrong = (base[lo][0] | (base[hi][0] << 9), (base[lo][1] + base[hi][1]) % 4) + if wrong != expected: + wrong_layout = dict(address=address, correct=list(expected), copy_major=list(wrong)) + break + need(wrong_layout is not None, "copy-major without conversion changes actual map") + receipts.append(dict(side=side, addresses=len(table), output_sha256=digest(got), + wrong_layout_witness=wrong_layout)) + need(recipe["right"]["phase"] == 1, "nonzero actual right constant") + # Forgetting one factor's constant rotates every right-wrapper output by -i. + correct = plans[1][0] + wrong_constant = (correct[0], (correct[1] - 1) % 4) + need(wrong_constant != correct, "omitted tensor constant") + return dict(wrappers=receipts, omitted_tensor_constant=dict(address=0, + correct=list(correct), wrong=list(wrong_constant))) + + +def run(full=True): + _, word, records = source_inputs() + recipes = bind(word, records) + small = tuple(plan(recipes[0][side], 1) for side in ("left", "right")) + controls = basic_controls(recipes[0], small) + cases = [check_case(recipes[0], small, 1, "rounding")] + if full: + large = tuple(plan(recipes[0][side], 2) for side in ("left", "right")) + controls["tensor"] = tensor_controls(recipes[0], large) + for mode in ("rounding", "promoted", "cancellation", "zero"): + cases.append(check_case(recipes[0], large, 2, mode, + recipes[1] if mode == "rounding" else None)) + return dict(schema_version=1, actual_events=[2025, 2039], native_events=[2031, 2033], + recipe_sha256=[digest(r) for r in recipes], controls=controls, cases=cases, + scope="finite exact scalar tensor boundary; no fast physical trace, all-size proof or new kappa") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--emit", action="store_true") + parser.add_argument("--quick", action="store_true") + args = parser.parse_args() + result = run(not args.quick) + if args.emit: + print(json.dumps(result, indent=2, sort_keys=True)) + elif not args.quick: + expected = read_json((HERE / "RESULT.json").read_bytes()) + compare_receipt(result, expected) + print("PASS_P104_TENSOR_COLLECTOR_AUDIT cases=" + str(len(result["cases"])) + " no_new_kappa", file=sys.stderr) + + +if __name__ == "__main__": + main()