From a8a1d744811cd7d1f9c43ec7ccbae85ef9695b61 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 19 Oct 2026 18:51:51 +1100 Subject: [PATCH] Construct P104 dyadic tensor code and price repeated Gram stages --- research/p104-tensor-code/PREDECESSORS.json | 10 + research/p104-tensor-code/PROOF.md | 201 ++++++++++++++++++++ research/p104-tensor-code/README.md | 78 ++++++++ research/p104-tensor-code/RESULT.json | 33 ++++ research/p104-tensor-code/SOURCES.json | 36 ++++ research/p104-tensor-code/TASK.json | 99 ++++++++++ research/p104-tensor-code/VALIDATION.json | 16 ++ research/p104-tensor-code/VERIFY.json | 45 +++++ research/p104-tensor-code/independent.py | 86 +++++++++ research/p104-tensor-code/test_verify.py | 63 ++++++ research/p104-tensor-code/verify.py | 201 ++++++++++++++++++++ 11 files changed, 868 insertions(+) create mode 100644 research/p104-tensor-code/PREDECESSORS.json create mode 100644 research/p104-tensor-code/PROOF.md create mode 100644 research/p104-tensor-code/README.md create mode 100644 research/p104-tensor-code/RESULT.json create mode 100644 research/p104-tensor-code/SOURCES.json create mode 100644 research/p104-tensor-code/TASK.json create mode 100644 research/p104-tensor-code/VALIDATION.json create mode 100644 research/p104-tensor-code/VERIFY.json create mode 100644 research/p104-tensor-code/independent.py create mode 100644 research/p104-tensor-code/test_verify.py create mode 100644 research/p104-tensor-code/verify.py diff --git a/research/p104-tensor-code/PREDECESSORS.json b/research/p104-tensor-code/PREDECESSORS.json new file mode 100644 index 0000000000..147b1f54ee --- /dev/null +++ b/research/p104-tensor-code/PREDECESSORS.json @@ -0,0 +1,10 @@ +{ + "credit": "See README; substantial OpenAI Codex assistance.", + "context_only_pending_heads": { + "3961": "afd6bb0a701e9ffd685f27674adaac86687e5f02", + "3954": "f1e2839819959cd0534d008be91ed5b79ec55a6a", + "3966": "75785ae0d1c4a8b1be00b30a07ec31106bb28937" + }, + "canonical_inputs": "SOURCES.json; no pending source dependency", + "new_scope": "One global invertible dyadic tensor code; explicit repeated-Gram scalar word, identity-side repayment and modulo13 spectral normalization boundary." +} diff --git a/research/p104-tensor-code/PROOF.md b/research/p104-tensor-code/PROOF.md new file mode 100644 index 0000000000..b570c8bdf5 --- /dev/null +++ b/research/p104-tensor-code/PROOF.md @@ -0,0 +1,201 @@ +# One dyadic code across both P104 axes + +## Question and exact scope + +PR3961 found that separately chosen row and reversed-column residual encodings +need not match. This package changes that premise: use **one invertible code on +all 21,632 data fields**, kept through both logical stages. The code is explicit, +dyadic, determinant one, preserves every independent syndrome/payload coordinate, +and has fixed X/Y return slots. It never divides by 13 or projects away a kernel. + +The canonical native-channel proof supplies the exact uncorrected endpoint +`Y += A X`, where `A=Gram/2`, sources and all 72 dirty helpers restored. The +retained copied-center caller requires an identity shear, followed by an inverse +identity shear and its physical correction/wrappers. Therefore the uncorrected +Gram experiment below is a **changed intermediate protocol**, not that completed +caller. Its scalar savings for repeated Gram pairs are not full-caller savings. +We derive the missing identity corrections explicitly rather than price them zero. + +## Dyadic triangular congruence and a global payload code + +Order the eight pivot ports `0,1,3,6,22,31,93,103` before the other 96. The pinned +fixture reconstructs `B` with 384 signed-half entries and `BB^t=12I_8`. Put + +``` +U = [ I B ] P = [ I 0 ] A = U^t P U. + [ 0 I ] [ 0 0 ] + +U^-1 = [ I -B ] M = U U^t = [ 13I B ] + [ 0 I ] [ B^t I ]. +``` + +All these U changes and inverses are over `R=Z[i,1/2]`; `det U=1`. Write +`U_r=U tensor I`, `U_c=I tensor U`, and similarly for A/P/M. On two 104 by 104 +banks define + +``` +L = U_r U_c^-t, +C = diag(L,L^-t), +Xhat=L X, Yhat=L^-t Y. +``` + +Row and column operators commute because they act on different port factors. +Neither code changes the bank names nor uses PR3882's cross-bank Pi permutation. +This is a replacement protocol; it cannot be inserted after the old literal +Pi occupancy without an additional derived and paid bridge. + +For lower and upper uncorrected Gram shears, + +``` +S_r = [I 0; A_r I], R_c = [I -A_c; 0 I], + +C S_r C^-1 = [I 0; P_r M_c I], +C R_c C^-1 = [I -M_r P_c; 0 I]. +``` + +For example, +`L^-t A_r L^-1=(U_r^-t A_r U_r^-1)(U_c U_c^t)=P_r M_c`. +The upper identity follows from `U_c^-t A_c U_c^-1=P_c`. +The same C occurs at both sides of the internal boundary: there is no row-code +to column-code transition there. This is an exact Gaussian-dyadic logical +protocol, including arbitrary real and imaginary input components. + +All data are retained. In one axis, a kernel input `(-B z,z)` becomes `(0,z)` +under U, so zero query does not mean zero payload. The decoder restores this +input exactly. Both 72-per-fiber auxiliary banks may be appended as independent +identity blocks. No helper initialization, erasure, borrowing or return is used +by this scalar code. Their required physical completion remains separate. + +## Physical operator order and fixed returns + +Let `G_0,G_1,G_2` be the actual all-role chart maps at the entrance, shared +interstage cut and exit of a proposed implementation. The retained caller gives +`G_0=diag(T,I)` and `G_2=diag(F,E)` on data, with `E=F T^-1`; its actual +intermediate owner/chart schedule is not supplied for this changed P104 protocol. +Define the physical coding map at a cut by + +``` +C_t = G_t C G_t^-1. +``` + +For a physical first stage `W1=G_1 S_r G_0^-1` and second stage +`W2=G_2 R_c G_1^-1`, the exact coded replacements are + +``` +W1hat = C_1 W1 C_0^-1 = G_1 C S_r C^-1 G_0^-1, +W2hat = C_2 W2 C_1^-1 = G_2 C R_c C^-1 G_1^-1. +``` + +For the retained data entrance and exit charts specifically, + +``` +C_0 = diag(T L T^-1, L^-t), +C_2 = diag(L, T^-1 L^-t T), +C_2^-1 = diag(L^-1, T^-1 L^t T). +``` + +Here F is common to every port and commutes with scalar port coefficients and +the positive T family. For instance, the X entry block has matrix coefficient +`T_i L_ij T_j^-1`; it is not a free scalar L_ij read across unequal charts. +At a genuinely common FULL cut, `G=diag(F,F)` and `C_t=C`; this is a useful +special case, but does not supply the missing intrinsic-source entrance. + +Their internal factors cancel in their displayed order. Port-dependent T need +not commute with U or L; no such commutation is used. The independent checker +uses noncommuting chart matrices as a control. Entry coding `C_0` and final +decoding `C_2^-1` restore the original named physical X/Y slots. Helpers are +identity blocks in C; their G maps are retained, not silently completed for free. + +These formulas specify a physical changed-caller contract. They do **not** +provide legal native recipes, shared ownership, a concrete G_1, paid cross-port +routes, or an actual adjacent completed P104 pair. Applying the bare scalar C +in physical storage would generally be wrong. Native lowering must implement +these ordered conjugates or derive an equivalent paid schedule. + +## Constructive scalar words and their complete comparison + +All counts in this section assume a common full chart, arbitrary Gaussian-dyadic +payloads, and temporarily writable donors restored after each sweep. A U or +U^-1 sweep halves 96 nonpivot donors, performs 384 signed unit ADD/SUBs and +restores by doubling. A transposed sweep uses eight pivot donors. There are no +fresh scratch arrays, cross-bank swaps, or discarded payloads. + +To encode both banks, execute four sweeps across 104 fibers each. Decode by +reversing and negating the sweeps. To apply `P_r M_c`, only eight pivot row fibers +are active: transform the source by `M=UU^t` (two sweeps), add its 104 fields +to the target row, and reverse the two sweeps. Apply `M_r P_c` analogously on +eight pivot column fibers. Every modified source is restored before the next +stage. An explicit uncoded reference computes `A=U^t P U` by a query sweep, +eight pivot deliveries, a B^t delivery, and inverse query sweep for each of +104 fibers. It is a specified constructive comparator, not an optimal word. + +| Exact scalar word | Unit ADD/SUB | Halves | Restoring doubles | +|---|---:|---:|---:| +| Global entry plus exit code | 319,488 | 43,264 | 43,264 | +| One coded **uncorrected Gram** pair | 26,240 | 3,328 | 3,328 | +| One uncoded reference Gram pair | 241,280 | 41,600 | 41,600 | + +For k repeated identical uncorrected Gram pairs, encoded ADD cost is +`319488+26240k`, compared with `241280k`; halve and double counts are each +`43264+3328k`, compared with `41600k`. One pair costs 104,448 more additions. +The first integer k giving savings in all three columns is k=2, saving 110,592 +additions and 33,280 halves and doubles each. This example demonstrates what +an amortized common code can remove: repeated query traversals on 96 nonpivot +fibers, with all entry/exit work charged. An actual repeated physical consumer +has not been identified. Other uncoded factorizations can amortize as well; +no scalar optimum, runtime speedup or native rank saving follows. + +## Identity completion restores a full-dimensional obligation + +Let `N=M^-1=U^-t U^-1`. The corrected identity shears require + +``` +C [I 0; I I] C^-1 = [I 0; N_r M_c I], +C [I -I; 0 I] C^-1 = [I -M_r N_c; 0 I]. +``` + +Hence the omitted lower/upper side terms are +`(N_r-P_r)M_c` and `M_r(N_c-P_c)`. Since +`N-P=U^-t (I-A) U^-1`, and A has eigenvalues 13 (multiplicity eight) and +zero (multiplicity 96), `I-A` is invertible. Each global side term therefore +has full rational rank **10,816**. That is algebraic rank, not a native-child +cost lower bound. In particular, compressing the Gram query to eight pivot +coordinates does not complete the required identity shear on the other 96 +independent payload coordinates. + +The complete physical bill remains + +``` +entry/exit native code + coded Gram stages + identity-side completion ++ copied-center physical endpoint correction and wrappers ++ dirty-helper completion + ownership/holding/routing/control ++ precision/recovery/admission costs. +``` + +Only the formal scalar code/Gram terms above are constructively counted here. +Every other displayed term is unresolved; none is zero by default. Reusing +PR3954's unchanged 208 mass-2576 local calls and progress assumptions retains +its 44,096 excess before added code costs. Replacing those words by this code +changes their native profile and needs a newly derived full gate. The scalar +k=2 comparison does not certify such a gate. Stop dependent native expansion +until one physical repeated consumer and its complete allowance are specified. + +## Why a free 13-eigenvalue split is invalid over the dyadic ring + +The congruence does not give a dyadic similarity to `13P`. Reduce R into F_13 +by `i -> 5` and `1/2 -> 7`. Invertible matrices over R remain invertible after +this reduction because their inverses reduce too. The Gram matrix satisfies +`A^2=13A` but has rank eight modulo 13: `V=[I B]` is surjective and V^t +injective, so `A=V^t V` has rank eight even though its square is zero. +Consequently `A_r A_c=A tensor A` has rank 64 modulo 13 and is nonzero. + +For any invertible bank-separate code `(Xhat,Yhat)=(Q X,R Y)`, the two shear +coefficients become `R A_r Q^-1` and `Q A_c R^-1`; their product is similar +to `A_r A_c`. They cannot both become scaled coordinate projectors +`alpha P_r`, `beta P_c` with `alpha beta=169`: that product reduces to zero +modulo 13, contradicting rank 64. The product 169 is forced if these are the +claimed nonzero spectral blocks. This obstruction covers bank-separate +R-invertible codes and this specific full spectral-normalization target. +It does not prohibit all joint codes, general bank-mixing programs, paid +non-dyadic primitives, or other changed graphs. Our explicit U code succeeds +by retaining the nontrivial M couplings. diff --git a/research/p104-tensor-code/README.md b/research/p104-tensor-code/README.md new file mode 100644 index 0000000000..be374d54df --- /dev/null +++ b/research/p104-tensor-code/README.md @@ -0,0 +1,78 @@ +# One dyadic tensor code across both P104 axes + +This package constructs one invertible code on all **21,632 data fields**: +`L=U_r U_c^-t`, `(Xhat,Yhat)=(L X,L^-t Y)`, with +`U=[[I,B],[0,I]]`. The same code is retained across both logical Gram stages, +so the row/column representation mismatch in [PR3961](https://github.com/CrocSwap/integer-mult-bounds/pull/3961) +is replaced by a matched shared representation. Every independent payload, +including the Gram kernel, is retained; entry and exit return fixed X/Y slots. +No division by 13, scratch array, helper erasure or free owner relabel is used. + +The exact transformed Gram coefficients are `P_r M_c` and `M_r P_c`, where +`M=UU^t`. Literal scalar words and both code boundaries are fully counted. +For two **repeated uncorrected Gram pairs** they save 110,592 unit additions +and 33,280 halves/restoring doubles each against the specified uncoded word. +One pair loses 104,448 additions. This is an exact common-chart protocol +comparison, **not a full-caller, native-rank or runtime improvement**. + +The actual retained caller requires identity shears. With `N=M^-1`, their +coded coefficients become `N_r M_c` and `M_r N_c`; the omitted side terms each +have full rational rank 10,816. Algebraic rank is not native tariff. Native +transport, actual repeated consumer, identity completion, helpers, ownership +and precision remain unpriced. No complete gate passes on the present evidence. + +A separate coefficient-ring result explains why M cannot simply be discarded: +`A tensor A` has rank 64 modulo 13, while a proposed fully normalized spectral +projector product `169 P_r P_c` is zero there. Thus invertible bank-separate +Gaussian-dyadic codes cannot perform that particular free spectral split. +This does not prohibit arbitrary joint codes or programs with a changed alphabet. + +See [PROOF.md](PROOF.md) for the physical chart-conjugation order, constructive +words, full obligation ledger and scoped module proof. [RESULT.json](RESULT.json) +contains finite counts; [TASK.json](TASK.json) records the changed premise and +next questions. Selected frontier and frozen predecessors are unchanged. + +## Reproduce + +Standard-library Python 3.12: + +``` +python3.12 -B scripts/research_package.py --package research/p104-tensor-code +python3.12 -B scripts/check_research_commit.py --package research/p104-tensor-code --check-source-history +``` + +The primary verifier authenticates three canonical-main inputs, reconstructs +the P104 matrix, executes the complete encoder/two-pair/decoder scalar word on +an arbitrary dense fixture with dirty-helper sentinels, enumerates every charged +operation, and checks the modular ranks. The separate Fraction oracle imports +only the word builders, evaluates them independently on every basis column of +two small whole-grid fixtures, and checks the tensor and physical-chart formulas. +It does not import the primary evaluator or claimed receipt. Destructive tests +cover optimized execution, false typed receipts, corrupted/missing source, +readonly Git-free replay and altered operation/return behavior. Finite evidence +supports the displayed algebra; no human or kernel theorem review is claimed. + +## Open next questions + +Find one actual repeated producer/consumer pair that can retain this shared code +through the **identity completion**, and specify every intermediate physical +chart/owner. Begin with the explicit `N-P` side maps, not an eight-coordinate +restriction of the input domain. Alternatively, derive one native triangular +code sweep with exact chart transport, fixed returns and a complete allowance. +Do not expand native construction until that allowance is favorable. A new +non-dyadic alphabet or general bank-mixing code must state its changed contract +before invoking the modulo-13 result. + +## Credit + +Chris R / Clear1nsight, with substantial OpenAI Codex assistance. Apache-2.0. +PR3961 supplies the preceding mismatch question; its source authentication/root +constructor is reused here with credit. PR3882/3940/3943/3954 retain the residual, +caller, cleanup and gate lineage. ToikY/PR3956 owns the adapter comparison and +PR3966 the independent uniform-phase gauge; neither is a premise of this replay. +Rohan Arun/PR1972, Chafik Boukhalfa/PR1991, Adam Gall/PR1940, Josie Elliston/E8, +Sagar Thakrar/PR1012, Douglas Colkitt, Dominik Scholz and the retained native, +compiler, occupancy and terminal-floor sources retain their original credit. +The code is newly derived; it does not claim their native word as implemented +in coded coordinates. Pending PRs are context only: all replay inputs and +provenance are on canonical main, so no unmerged Git object is required. diff --git a/research/p104-tensor-code/RESULT.json b/research/p104-tensor-code/RESULT.json new file mode 100644 index 0000000000..4e8d26854c --- /dev/null +++ b/research/p104-tensor-code/RESULT.json @@ -0,0 +1,33 @@ +{ + "arithmetic_scope": "exact common-chart Gaussian dyadic word; formal scalar counts, not physical/native upper bill", + "boundary_invoice": { + "add": 319488, + "double": 43264, + "half": 43264 + }, + "code": "L=U_r U_c^-t; (Xhat,Yhat)=(L X,L^-t Y)", + "coded_pair_invoice": { + "add": 26240, + "double": 3328, + "half": 3328 + }, + "data_degrees": 21632, + "first_add_break_even_integer": 2, + "first_half_break_even_integer": 2, + "full_identity_side_rank": 10816, + "mod13_gram_rank": 8, + "mod13_tensor_product_rank": 64, + "one_pair_add_difference": 104448, + "reference_pair_invoice": { + "add": 241280, + "double": 41600, + "half": 41600 + }, + "remaining": "physical chart recipes, actual repeated consumer, identity-side correction, helpers/owners, full native moment and precision", + "schema": "p104-tensor-code/1", + "source_rank": 8, + "transformed_lower": "P_r M_c", + "transformed_upper": "M_r P_c", + "two_pair_add_saving": 110592, + "two_pair_half_saving": 33280 +} diff --git a/research/p104-tensor-code/SOURCES.json b/research/p104-tensor-code/SOURCES.json new file mode 100644 index 0000000000..9d97049dca --- /dev/null +++ b/research/p104-tensor-code/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "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": "notes/copied-centers-complex.tex", + "usage": "input", + "git_blob": "fddd7bc7f2a2f749ba6eada19d153bf9243ee31c", + "sha256": "18eac6d5c5755e53230c0c12a633f38b6ce9666ef0322c1aff79394f2952af72" + }, + { + "path": "research/p104-native-channel/PROOF.md", + "usage": "input", + "git_blob": "a69311b74f74a2f8e8f411c1451baacd9bacddce", + "sha256": "5d743145d389ffdfaffc66096fa7e32c7155b18f73d74755403151d0435bb94c" + }, + { + "path": "research/p104-native-channel/inputs/P104-FIXTURE.json", + "usage": "input", + "git_blob": "2e16f99b295bb386fd13bd8fbd57b42ef54143a9", + "sha256": "516c06f6ec3cb84be588c546108de897650288576dd5fbf5fe44b9c5546ad8a4" + } + ] +} diff --git a/research/p104-tensor-code/TASK.json b/research/p104-tensor-code/TASK.json new file mode 100644 index 0000000000..b50e93e08b --- /dev/null +++ b/research/p104-tensor-code/TASK.json @@ -0,0 +1,99 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "priority_revision": 6, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "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": "A single invertible global row/column dyadic payload code, exact common-chart repeated-Gram protocol and invoices, physical chart order, full identity-side obligation and modulo-13 spectral-split obstruction.", + "scope_change_reason": "Explicit next-round assignment changes independently chosen residual encodings into one all-payload tensor code; it does not implement the original static-flag correction.", + "bottleneck_link": "Tests an information-preserving shared producer/consumer representation and identifies exactly which cross-axis coupling and full identity completion remain payable.", + "budget_minutes": 50, + "stop_rule": "Stop dependent native expansion unless actual physical producer/consumer, chart availability, identity completion and full allowance are specified and favorable.", + "outcome": "partial", + "evidence": "PROOF.md, RESULT.json, verify.py, independent.py, test_verify.py", + "author": "Chris R / Clear1nsight, with substantial OpenAI Codex assistance", + "ai_assistance": "Substantial OpenAI Codex assistance, distinct assigned agent; root coordination and independent cross-review.", + "open_questions": [ + { + "question": "Can an actual repeated physical consumer retain the global code through full identity completion?", + "why_it_matters": "Only that can convert formal repeated-Gram savings into a complete caller gain.", + "first_step": "Pin a chronological two-stage owner schedule; implement and price one N-P side map in its literal charts.", + "blocked_by": "Actual repeated consumer, native code/side recipes, dirty completion and full cost gate remain unproved." + } + ], + "checkpoint": { + "main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "priority_revision": 6, + "entry_utc": "2026-10-19T07:36:09Z", + "scope": "Assigned tensor-code item; sibling joint-compensator/dirty-catalysis/progress-cap scopes excluded; root refreshes live overlap and Discussions.", + "live_overlap_utc": "2026-10-19T07:38:11Z", + "overlap_coverage": "Root refreshed all 676 open PR bodies including drafts with complete pagination; sibling scopes excluded. Discussions and canonical claim coordinated by root.", + "claim": "https://github.com/CrocSwap/integer-mult-bounds/pull/3954#issuecomment-6262365386", + "publication_main_refresh_utc": "2026-10-19T07:50:26Z", + "overlap_helper": "43 possible matches; all 676 cached open PR bodies, no Discussion cache, sparse local packages; root separately reviewed live Discussions and exact scope." + } +} diff --git a/research/p104-tensor-code/VALIDATION.json b/research/p104-tensor-code/VALIDATION.json new file mode 100644 index 0000000000..42065a9165 --- /dev/null +++ b/research/p104-tensor-code/VALIDATION.json @@ -0,0 +1,16 @@ +{ + "schema": "p104-tensor-code-validation/1", + "environment": "3.12.3", + "checks": { + "primary": "PASS; 21632 independent payload fields, complete literal scalar word and invoices, modulo13 rank64, full identity side rank10816", + "independent": "PASS; separate Fraction evaluator on 50 basis columns and 7 negative/ordering controls; per-owner address-chart maps", + "behavioral_tests": "PASS; seven optimized controls including private writable copies of readonly Git-free fixture, source corruption/missing input, typed/duplicate receipts and altered donor restoration", + "metadata": "PASS; metadata and source pins only" + }, + "limits": [ + "No actual physical repeated caller, native code/identity-side recipes or complete cost advantage", + "Common-chart scalar word comparison is against one specified reference, not an optimum", + "Rank10816 is algebraic rank, not a native cost lower bound", + "Exact-public-head byte/history, official export and hosted CI evidence recorded after publication" + ] +} diff --git a/research/p104-tensor-code/VERIFY.json b/research/p104-tensor-code/VERIFY.json new file mode 100644 index 0000000000..4304da0081 --- /dev/null +++ b/research/p104-tensor-code/VERIFY.json @@ -0,0 +1,45 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "notes/copied-centers-complex.tex", + "research/p104-native-channel/PROOF.md", + "research/p104-native-channel/inputs/P104-FIXTURE.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Source-bound payload code, literal complete word/invoices, modulo13 and full side rank" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 120, + "checks": "Separate all-basis Fraction evaluator, tensor formulas and noncommuting physical charts" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 180, + "checks": "Optimized typed receipt, source corruption, mutation and readonly Git-free replay controls" + } + ] +} diff --git a/research/p104-tensor-code/independent.py b/research/p104-tensor-code/independent.py new file mode 100644 index 0000000000..dabddb1628 --- /dev/null +++ b/research/p104-tensor-code/independent.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +"""Independent Fraction matrix/evaluator oracle; primary builders supply words only.""" +from fractions import Fraction as Q +import importlib.util +from pathlib import Path + + +def need(ok,msg): + if not ok:raise ValueError(msg) + + +def eye(n):return [[Q(i==j) for j in range(n)] for i in range(n)] +def transpose(a):return [list(row) for row in zip(*a)] +def mm(a,b):return [[sum(x*y for x,y in zip(row,col)) for col in zip(*b)] for row in a] +def plus(a,b):return [[x+y for x,y in zip(r,s)] for r,s in zip(a,b)] +def scale(a,c):return [[c*x for x in row] for row in a] +def kron(a,b):return [[x*y for x in row for y in line] for row in a for line in b] +def block(a,b,c,d):return [r+s for r,s in zip(a,b)]+[r+s for r,s in zip(c,d)] +def zero(n):return [[Q(0) for _ in range(n)] for _ in range(n)] +def inverse(a): + n=len(a);x=[r[:]+s for r,s in zip(a,eye(n))] + for j in range(n): + k=next(i for i in range(j,n) if x[i][j]);x[j],x[k]=x[k],x[j] + t=x[j][j];x[j]=[v/t for v in x[j]] + for i in range(n): + if i!=j: + t=x[i][j];x[i]=[v-t*w for v,w in zip(x[i],x[j])] + return [r[n:] for r in x] + + +def symbolic_word(word,size): + a=eye(size) + for op in word: + if op[0]=='add':a[op[1]]=[x+op[3]*y for x,y in zip(a[op[1]],a[op[2]])] + elif op[0]=='half':a[op[1]]=[x/2 for x in a[op[1]]] + elif op[0]=='double':a[op[1]]=[x*2 for x in a[op[1]]] + else:raise ValueError('unknown operation') + return a + + +def main(): + spec=importlib.util.spec_from_file_location('word_builders',Path(__file__).with_name('verify.py'));w=importlib.util.module_from_spec(spec);spec.loader.exec_module(w) + columns=0;controls=0 + for b in ([[1,-1]],[[1,0],[-1,1]]): + p=len(b);n=p+len(b[0]);I=eye(n);P=zero(n) + for i in range(p):P[i][i]=1 + U=eye(n) + for i,row in enumerate(b): + for j,c in enumerate(row,p):U[i][j]=Q(c,2) + Ui=inverse(U);Ut=transpose(U);Uit=transpose(Ui);A=mm(mm(Ut,P),U);M=mm(U,Ut);N=mm(Uit,Ui) + L=kron(U,Uit);Li=inverse(L);Lit=transpose(Li);C=block(L,zero(n*n),zero(n*n),Lit);Ci=inverse(C) + ar=kron(A,I);ac=kron(I,A);II=eye(n*n);Z=zero(n*n) + lower=block(II,Z,ar,II);upper=block(II,scale(ac,-1),Z,II) + encoded_lower=block(II,Z,kron(P,M),II);encoded_upper=block(II,scale(kron(M,P),-1),Z,II) + need(mm(mm(C,lower),Ci)==encoded_lower,'lower tensor identity') + need(mm(mm(C,upper),Ci)==encoded_upper,'upper tensor identity') + need(symbolic_word(w.code_word(b),2*n*n)==C,'literal encoder all basis') + need(symbolic_word(w.code_word(b,True),2*n*n)==Ci,'literal decoder all basis') + need(symbolic_word(w.coded_pair(b),2*n*n)==mm(encoded_upper,encoded_lower),'literal coded pair all basis') + need(symbolic_word(w.reference_pair(b),2*n*n)==mm(upper,lower),'literal reference pair all basis') + # Full identity corrections: the missing terms are not the zero operator. + full_lower=block(II,Z,II,II);full_upper=block(II,scale(II,-1),Z,II) + need(mm(mm(C,full_lower),Ci)==block(II,Z,kron(N,M),II),'full lower correction') + need(mm(mm(C,full_upper),Ci)==block(II,scale(kron(M,N),-1),Z,II),'full upper correction') + need(encoded_lower!=mm(mm(C,full_lower),Ci),'omitted identity correction rejected');controls+=1 + need(kron(P,M)!=kron(P,I),'discarded cross-axis M rejected');controls+=1 + wrong=list(w.code_word(b));ix=next(i for i,o in enumerate(wrong) if o[0]=='double');wrong.pop(ix) + need(symbolic_word(wrong,2*n*n)!=C,'missing donor restoration rejected');controls+=1 + # Noncommuting physical charts: exact cut order, no donated basis move. + size=2*n*n + # Two address coordinates per physical role: G never mixes owners. + if n==3: + cc=kron(C,eye(2));cci=kron(Ci,eye(2));lo=kron(lower,eye(2));up=kron(upper,eye(2));G=[] + for cut in range(3): + g=eye(2*size) + for owner in range(size):g[2*owner][2*owner+1]=cut+owner+1 + G.append(g) + first=mm(mm(mm(mm(G[1],cc),lo),cci),inverse(G[0])) + second=mm(mm(mm(mm(G[2],cc),up),cci),inverse(G[1])) + total=mm(mm(mm(mm(G[2],cc),mm(up,lo)),cci),inverse(G[0])) + need(mm(second,first)==total,'ordered physical cut cancellation') + need(mm(cc,G[1])!=mm(G[1],cc),'free physical chart commute rejected');controls+=1 + columns+=size + print('PASS_P104_TENSOR_CODE_INDEPENDENT all_basis_columns='+str(columns)+' controls='+str(controls)) + +if __name__=='__main__':main() diff --git a/research/p104-tensor-code/test_verify.py b/research/p104-tensor-code/test_verify.py new file mode 100644 index 0000000000..5e9a25773c --- /dev/null +++ b/research/p104-tensor-code/test_verify.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Publication and behavioral controls for the scalar tensor-code contract.""" +import hashlib +import importlib.util +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest +HERE=Path(__file__).resolve().parent;ROOT=HERE.parents[1] + + +def snap(root):return {str(p.relative_to(root)):(hashlib.sha256(p.read_bytes()).hexdigest(),p.stat().st_mode&0o777) for p in root.rglob('*') if p.is_file()} + + +class Controls(unittest.TestCase): + def export(self,tmp): + target=Path(tmp)/'research'/HERE.name + shutil.copytree(HERE,target,ignore=shutil.ignore_patterns('__pycache__')) + for f in target.rglob('*'): + if f.is_file():f.chmod(0o644) + for row in json.loads((HERE/'SOURCES.json').read_text())['files']: + if row['usage']=='input': + q=Path(tmp)/row['path'];q.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(ROOT/row['path'],q) + return target + def cli(self,p,script='verify.py'): + return subprocess.run([sys.executable,'-I','-O','-B',str(p/script)],env={'PATH':'','LANG':'C.UTF-8'},capture_output=True,text=True,timeout=120) + def test_readonly_gitfree_optimized(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td) + for f in Path(td).rglob('*'): + if f.is_file():f.chmod(0o444) + before=snap(Path(td)) + for script in ('verify.py','independent.py'): + r=self.cli(p,script);self.assertEqual(r.returncode,0,r.stderr) + self.assertEqual(before,snap(Path(td)));self.assertFalse((Path(td)/'.git').exists()) + def test_corrupt_source(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);f=Path(td)/'notes/copied-centers-complex.tex';f.write_text(f.read_text()+'\ncorruption\n') + r=self.cli(p);self.assertNotEqual(r.returncode,0);self.assertIn('input hash',r.stderr) + def test_missing_source(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);(Path(td)/'research/p104-native-channel/inputs/P104-FIXTURE.json').unlink();self.assertNotEqual(self.cli(p).returncode,0) + def test_typed_receipt_rejects_float_integer(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);f=p/'RESULT.json';x=json.loads(f.read_text());x['first_add_break_even_integer']=2.0;f.write_text(json.dumps(x));r=self.cli(p) + self.assertNotEqual(r.returncode,0);self.assertIn('typed result mismatch',r.stderr) + def test_false_fullcaller_claim_and_free_boundary(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);f=p/'RESULT.json';x=json.loads(f.read_text());x['boundary_invoice']['add']=0;x['full_identity_side_rank']=0;f.write_text(json.dumps(x));self.assertNotEqual(self.cli(p).returncode,0) + def test_duplicate_keys(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);(p/'RESULT.json').write_text('{"a":1,"a":2}');r=self.cli(p);self.assertNotEqual(r.returncode,0);self.assertIn('duplicate JSON key',r.stderr) + def test_donor_restoration_and_alphabet(self): + spec=importlib.util.spec_from_file_location('primary_words',HERE/'verify.py');v=importlib.util.module_from_spec(spec);spec.loader.exec_module(v) + word=list(v.code_word([[1,-1]]));bad=list(word);bad.pop(next(i for i,o in enumerate(bad) if o[0]=='double')) + data=[(j+1)*4096 for j in range(18)] + self.assertNotEqual(v.evaluate(bad,data),v.evaluate(word,data)) + with self.assertRaisesRegex(ValueError,'unknown operation'):v.evaluate([('divide13',0)],data) + +if __name__=='__main__':unittest.main(verbosity=2) diff --git a/research/p104-tensor-code/verify.py b/research/p104-tensor-code/verify.py new file mode 100644 index 0000000000..7b81946424 --- /dev/null +++ b/research/p104-tensor-code/verify.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python3 +"""Exact dyadic tensor-code protocol and coefficient-ring audit; standard library, Apache-2.0.""" +import argparse +import hashlib +import itertools +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PIVOTS = (0, 1, 3, 6, 22, 31, 93, 103) + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def read(path): + def pairs(items): + ans = {} + for key, value in items: + require(key not in ans, 'duplicate JSON key') + ans[key] = value + return ans + return json.loads(path.read_text(), object_pairs_hook=pairs) + + +def authenticate(): + for row in read(HERE / 'SOURCES.json')['files']: + if row['usage'] != 'input': + continue + path = ROOT / row['path'] + require(not path.is_symlink(), 'source symlink') + data = path.read_bytes() + require(hashlib.sha256(data).hexdigest() == row['sha256'], 'input hash: ' + row['path']) + require(hashlib.sha1(b'blob ' + str(len(data)).encode() + b'\0' + data).hexdigest() == row['git_blob'], 'input blob') + + +def source_matrix(): + roots = [] + for a, b in itertools.combinations(range(8), 2): + for sign in (-1, 1): + row = [0] * 8 + row[a], row[b] = 2, 2 * sign + roots.append(tuple(row)) + roots.extend((1,) + tail for tail in itertools.product((-1, 1), repeat=7) if tail.count(-1) % 2 == 0) + fixture = read(ROOT / 'research/p104-native-channel/inputs/P104-FIXTURE.json')['section4_explicit_P104'] + removed = {tuple(row) for row in fixture['F0'] + fixture['C']} + ports = sorted(set(roots) - removed) + require(len(ports) == 104, 'P104 port count') + order = list(PIVOTS) + [i for i in range(104) if i not in PIVOTS] + ports = [ports[i] for i in order] + gram = [[sum(x*y for x,y in zip(a,b)) for b in ports] for a in ports] + require(all(gram[i][j] == 8*(i == j) for i in range(8) for j in range(8)), 'pivot Gram') + b2 = [[gram[i][j] // 4 for j in range(8,104)] for i in range(8)] + require(all(v in (-1,0,1) for row in b2 for v in row), 'signed half coefficients') + require(all(sum(b2[i][k]*b2[j][k] for k in range(96)) == 48*(i == j) for i in range(8) for j in range(8)), 'BBt=12I') + require(all(sum(b2[k][i]*b2[k][j] for k in range(8)) == gram[i+8][j+8]//2 for i in range(96) for j in range(96)), 'nonpivot Gram') + return b2 + + + +def index(bank,i,j,n): return (bank*n+i)*n+j + + +def triangular(b,bank,axis,fixed,transpose=False,inverse=False): + p=len(b);n=p+len(b[0]) + def ix(k): return index(bank,k,fixed,n) if axis==0 else index(bank,fixed,k,n) + donors=range(p) if transpose else range(p,n) + for d in donors: yield ('half',ix(d)) + for j,row in enumerate(b): + for k,v in enumerate(row,p): + if v: + dest,src=(k,j) if transpose else (j,k) + yield ('add',ix(dest),ix(src),-v if inverse else v) + for d in donors: yield ('double',ix(d)) + + +def code_word(b,inverse=False): + n=len(b)+len(b[0]) + steps=[(0,1,True,True),(0,0,False,False),(1,1,False,False),(1,0,True,True)] + if inverse: steps=[(bank,axis,t,not inv) for bank,axis,t,inv in reversed(steps)] + for bank,axis,t,inv in steps: + for fixed in range(n):yield from triangular(b,bank,axis,fixed,t,inv) + + +def coded_pair(b): + p=len(b);n=p+len(b[0]) + # lower: Y += P_r M_c X. upper: X -= M_r P_c Y. + for source,axis in ((0,1),(1,0)): + target=1-source;sign=1 if source==0 else -1 + for fixed in range(p): + yield from triangular(b,source,axis,fixed,True) + yield from triangular(b,source,axis,fixed) + for k in range(n): + i,j=(fixed,k) if axis==1 else (k,fixed) + yield ('add',index(target,i,j,n),index(source,i,j,n),sign) + yield from triangular(b,source,axis,fixed,inverse=True) + yield from triangular(b,source,axis,fixed,True,True) + + +def reference_pair(b): + p=len(b);n=p+len(b[0]) + for source,axis in ((0,0),(1,1)): + target=1-source;sign=1 if source==0 else -1 + for fixed in range(n): + def ix(bank,k):return index(bank,k,fixed,n) if axis==0 else index(bank,fixed,k,n) + yield from triangular(b,source,axis,fixed) + for j in range(p):yield ('add',ix(target,j),ix(source,j),sign) + for j in range(p):yield ('half',ix(source,j)) + for j,row in enumerate(b): + for k,v in enumerate(row,p): + if v:yield ('add',ix(target,k),ix(source,j),sign*v) + for j in range(p):yield ('double',ix(source,j)) + yield from triangular(b,source,axis,fixed,inverse=True) + + +def evaluate(word,values): + x=list(values) + for op in word: + if op[0]=='add':x[op[1]]+=op[3]*x[op[2]] + elif op[0]=='half': + require(x[op[1]]%2==0,'exact dyadic integer test scale') + x[op[1]]//=2 + elif op[0]=='double':x[op[1]]*=2 + else:raise ValueError('unknown operation') + return x + + +def invoice(word): + from collections import Counter + c=Counter(op[0] for op in word) + return {key:c[key] for key in ('add','half','double')} + + +def mod_rank(a,p=13): + a=[[x%p for x in row] for row in a];r=0 + for j in range(len(a[0])): + pivot=next((i for i in range(r,len(a)) if a[i][j]),None) + if pivot is None:continue + a[r],a[pivot]=a[pivot],a[r];scale=pow(a[r][j],-1,p);a[r]=[(x*scale)%p for x in a[r]] + for i in range(len(a)): + if i!=r: + c=a[i][j];a[i]=[(v-c*w)%p for v,w in zip(a[i],a[r])] + r+=1 + if r==len(a):break + return r + + +def result(): + authenticate();b=source_matrix();n=104;p=8 + enc=list(code_word(b));dec=list(code_word(b,True));cp=list(coded_pair(b));rp=list(reference_pair(b)) + ei=invoice(enc+dec);ci=invoice(cp);ri=invoice(rp) + require(ei=={'add':319488,'half':43264,'double':43264},'boundary invoice') + require(ci=={'add':26240,'half':3328,'double':3328},'coded pair invoice') + require(ri=={'add':241280,'half':41600,'double':41600},'reference pair invoice') + # Dense arbitrary integer fixture, including untouched dirty-helper sentinels. + data=[((i*37+i//11)%31-15)*(1<<24) for i in range(2*n*n)]+[123,-77] + require(evaluate(dec,evaluate(enc,data))==data,'full payload inverse') + reference=evaluate(rp,evaluate(rp,data)) + coded=evaluate(dec,evaluate(cp,evaluate(cp,evaluate(enc,data)))) + require(coded==reference,'actual P104 two-pair scalar endpoint') + require(coded[-2:]==data[-2:],'arbitrary dirty helper preservation') + # A nonzero kernel payload is retained in syndrome coordinates. + syndrome=[0]*(2*n*n) + syndrome[index(0,8,0,n)]=2 + for i in range(p):syndrome[index(0,i,0,n)]=-b[i][0] + require(any(syndrome),'nonzero syndrome') + require(evaluate(dec,evaluate(enc,[v*(1<<16) for v in syndrome]))==[v*(1<<16) for v in syndrome],'kernel payload retained') + # Reconstruct A mod13 from V=[I B], not by division by its eigenvalue. + v=[[int(i==j) for j in range(p)]+[(x*7)%13 for x in b[i]] for i in range(p)] + a=[[sum(v[k][i]*v[k][j] for k in range(p))%13 for j in range(n)] for i in range(n)] + rank=mod_rank(a) + require(rank==8 and all(sum(a[i][k]*a[k][j] for k in range(n))%13==0 for i in range(n) for j in range(n)),'nonzero square-zero mod13 Gram') + require(mod_rank(b)==8,'B mod13 rank') + v5=[[int(i==j) for j in range(p)]+[(x*3)%5 for x in b[i]] for i in range(p)] + side5=[[(int(i==j)-sum(v5[k][i]*v5[k][j] for k in range(p)))%5 for j in range(n)] for i in range(n)] + require(mod_rank(side5,5)==104,'full-rank identity side correction') + # 13*(1/13)=1 cannot hold for dyadic coefficients; 13 reduces to zero. + require(13%13==0 and pow(2,-1,13)==7 and 5*5%13==12,'ring homomorphism') + return {'schema':'p104-tensor-code/1','data_degrees':2*n*n,'source_rank':8,'mod13_gram_rank':rank,'mod13_tensor_product_rank':rank*rank,'full_identity_side_rank':n*n, + 'code':'L=U_r U_c^-t; (Xhat,Yhat)=(L X,L^-t Y)', + 'transformed_lower':'P_r M_c','transformed_upper':'M_r P_c', + 'boundary_invoice':ei,'coded_pair_invoice':ci,'reference_pair_invoice':ri, + 'one_pair_add_difference':ei['add']+ci['add']-ri['add'], + 'two_pair_add_saving':2*ri['add']-ei['add']-2*ci['add'], + 'two_pair_half_saving':2*ri['half']-ei['half']-2*ci['half'], + 'first_add_break_even_integer':2,'first_half_break_even_integer':2, + 'arithmetic_scope':'exact common-chart Gaussian dyadic word; formal scalar counts, not physical/native upper bill', + 'remaining':'physical chart recipes, actual repeated consumer, identity-side correction, helpers/owners, full native moment and precision'} + + +def main(): + parser=argparse.ArgumentParser();parser.add_argument('--write-result',action='store_true');parser.add_argument('--result',type=Path,default=HERE/'RESULT.json');args=parser.parse_args() + r=result() + if args.write_result:args.result.write_text(json.dumps(r,indent=2,sort_keys=True)+'\n') + else:require(json.dumps(read(args.result),sort_keys=True)==json.dumps(r,sort_keys=True),'typed result mismatch') + print('PASS_P104_TENSOR_CODE payload=21632 mod13_rank=64 two_pair_add_saving=110592 no_new_kappa') + +if __name__=='__main__':main()