From 2fbec6ef55cc5a6b617f44824c1c75bdfd50d69b Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 19 Oct 2026 18:06:36 +1100 Subject: [PATCH 1/2] research: audit P104 cross-axis encoded boundary and transition --- .../p104-encoded-boundary/PREDECESSORS.json | 11 ++ research/p104-encoded-boundary/PROOF.md | 177 ++++++++++++++++++ research/p104-encoded-boundary/README.md | 68 +++++++ research/p104-encoded-boundary/RESULT.json | 50 +++++ research/p104-encoded-boundary/SOURCES.json | 36 ++++ research/p104-encoded-boundary/TASK.json | 95 ++++++++++ .../p104-encoded-boundary/VALIDATION.json | 16 ++ research/p104-encoded-boundary/VERIFY.json | 45 +++++ research/p104-encoded-boundary/independent.py | 88 +++++++++ research/p104-encoded-boundary/test_verify.py | 59 ++++++ research/p104-encoded-boundary/verify.py | 177 ++++++++++++++++++ 11 files changed, 822 insertions(+) create mode 100644 research/p104-encoded-boundary/PREDECESSORS.json create mode 100644 research/p104-encoded-boundary/PROOF.md create mode 100644 research/p104-encoded-boundary/README.md create mode 100644 research/p104-encoded-boundary/RESULT.json create mode 100644 research/p104-encoded-boundary/SOURCES.json create mode 100644 research/p104-encoded-boundary/TASK.json create mode 100644 research/p104-encoded-boundary/VALIDATION.json create mode 100644 research/p104-encoded-boundary/VERIFY.json create mode 100644 research/p104-encoded-boundary/independent.py create mode 100644 research/p104-encoded-boundary/test_verify.py create mode 100644 research/p104-encoded-boundary/verify.py diff --git a/research/p104-encoded-boundary/PREDECESSORS.json b/research/p104-encoded-boundary/PREDECESSORS.json new file mode 100644 index 0000000000..3d2118beac --- /dev/null +++ b/research/p104-encoded-boundary/PREDECESSORS.json @@ -0,0 +1,11 @@ +{ + "credit": "See README and source notices; substantial OpenAI Codex assistance.", + "context_only_pending_heads": { + "3882": "9d56eeedbed5e3e9bbbc8c189d66f14cf15b6067", + "3940": "51ba88c007cfbcc3d9cf22dd321f5224be3a5bb1", + "3943": "2cba526a4ebe0ef6c3c0143498adcf67dca97941", + "3954": "f1e2839819959cd0534d008be91ed5b79ec55a6a", + "3956": "f73eef845623a42363ec8d883058fab98fb1335d" + }, + "new_scope": "Axis/role orientation encoding mismatch and exact transition; no adapter optimality, private COPY retirement or coverage optimization." +} diff --git a/research/p104-encoded-boundary/PROOF.md b/research/p104-encoded-boundary/PROOF.md new file mode 100644 index 0000000000..a832f032fa --- /dev/null +++ b/research/p104-encoded-boundary/PROOF.md @@ -0,0 +1,177 @@ +# A row-to-column encoding is a separate physical interface + +## Scope and the actual source boundary + +The pinned `notes/copied-centers-complex.tex`, subsection **Two-stage phase +endpoint and its paid correction**, specifies a forward scalar shear followed +by an inverse second shear. It gives physical data outputs +`A=-F y`, `B=F T^-2 x+E y`, a paid correction, phase/sign/bank wrappers, and +**distinct** auxiliary banks. `notes/structured-bulk-complex.tex` states the +completed all-role C contract. Those sources do not contain a chronological +P104 replacement with two adjacent completed P104 calls. + +This audit therefore identifies the actual *stage boundary* and tests the +natural proposed P104 row/column interface at it. It does not claim to have +found the missing adjacent completed-call implementation. PR3954's positive +control says that a common completed C commutes with a fixed scalar bank +encoding. The new question is whether the same encoding is present on both +sides when the active fibers and source/target orientation change. It is not. + +The row and column maps below are explicitly proposed contracts. In particular +`S A_c S` is the contract obtained by swapping the source and target roles of +the forward encoding; it is **not** a replay or admission of an inverse P104 +word. An actual inverse caller may choose another encoding, whose compatibility +must then be derived separately. + +## Fixed physical slots and exact transition + +There are two data banks `X_(i,j),Y_(i,j)`, `0<=i,j<104`. Ordering each port +index by the eight pinned pivots followed by the 96 nonpivots, put + +``` +D = [I B; B^t B^t B-I], H=diag(0_8,I_96), J=I-H, +D^-1 = [ I-B B^t B ] = [ -11I B ] + [ B^t -I ] [ B^t -I ]. +``` + +The canonical fixture gives `B B^t=12I`. +Define `D_r=D tensor I`, `D_c=I tensor D`, and likewise `H_r,H_c,J_r,J_c`. +This is a genuine change of which physical owners mix; it is not a permutation +of names inside an already matched interface. + +Let `T_r,T_c` be diagonal families of invertible address operators, commuting +with their own H masks. For either axis `a`, define + +``` +L_a = [D_a H_a T_a; 0 I], +Pi_a = [J_a H_a; H_a J_a], +A_a = Pi_a L_a. +``` + +`Pi_a` swaps the X/Y slots at nonpivot ports of that axis. It records literal +PR3882 occupancy. Let `S=[0 I;I 0]` exchange source/target orientation. The +candidate reversed column encoding is `Abar_c=S A_c S`. + +A physical handoff preserving the same underlying unencoded fields must be + +``` +K = Abar_c A_r^-1 + = S Pi_c L_c S L_r^-1 Pi_r. +``` + +No factors commute past each other in this formula. It is exact on arbitrary +address functions, regardless of the noncommutation of D with the chart family. +`K A_r=Abar_c` follows by adjacent inverse cancellation. Every map is extended +by identity on both disjoint dirty-helper banks. These identities preserve all +helper values, but do not execute their required completed F transformations +or supply an owner schedule. Fixed output slots remain the named X and Y slots. + +On the common chart sector `T_r=T_c=I`, + +``` +A_r = [J_r D_r H_r; H_r D_r I], +A_r^-1 = [D_r^-1(J_r-H_r) D_r^-1 H_r; H_r J_r], +Abar_c = [I H_c D_c; H_c J_c D_c]. +``` + +Consequently the four blocks of K are + +``` +K11 = D_r^-1(J_r-H_r) + H_c D_c H_r, +K12 = D_r^-1 H_r + H_c D_c J_r, +K21 = H_c D_r^-1(J_r-H_r) + J_c D_c H_r, +K22 = H_c D_r^-1 H_r + J_c D_c J_r. +``` + +Row and column operators commute only when they act on different port factors; +the displayed order within each factor is retained. These are interface +identities, not native rank-cost estimates. + +## A physical constant-input counterexample + +Take `X_(0,0)=2` and every other data field zero, with arbitrary dirty helper +values. Both index zero ports are pivots. Under `Abar_c`, this stays exactly +`X_(0,0)=2`: the column H mask kills that pivot source. Under `A_r`, the same +X field survives and **48** additional Y fields appear at nonpivot row indices +with column index zero, each equal to +1 or -1. This follows from the first +row of B having 48 signed halves. The verifier reconstructs the canonical E8 +roots and punctures and checks the count and signs; it does not import PR3954's +matrix code. + +This is not merely an artificial choice of globally identity native operators. +For the positive physical convention `C_u=((1+i)I+(1-i)X_u)/2`, every C_u, +its inverse, and F fix constant address functions (the zero Fourier character). +Thus the counterexample lifts to that actual invariant physical sector by +assigning the displayed constants to entire arrays. It disproves identity +handoff for these named encodings before endpoint phase wrappers. It does not +price a constant-sector operation as a native child or assert every orientation +or changed encoding has the same defect. + +A common completed operator C applied on every data role commutes with both +common-chart encodings separately. Nevertheless `A_r != Abar_c`. Therefore +`C A_r=A_r C` does not imply `Abar_c^-1 C A_r=C`; the change of representation +still occurs. The independent checker includes both commutation identities as +positive controls and rejects identity handoff, omitted Pi and omitted reversal. + +## Explicit formal word and complete cost decision + +For one common-chart fiber, D factors as two triangular updates: + +1. `u_J += B u_N`. +2. `u_N = B^t u_J - u_N`. +3. `u_N += w_N`. +4. Swap the 96 nonpivot source/target slots. + +The inverse reverses those operations. There are 384 signed-half terms in each +B traversal. With temporarily writable donor arrays, each traversal halves +its donor bank, performs signed unit additions, and restores donors by doubling. +Thus either direction has 864 unit ADD/SUBs, 104 halves, 104 restoring doubles, +96 signs, and 96 explicit in-place slot swaps. This factor word uses no scratch +array. The signs and swaps remain separately charged operations. This is not +a new optimum or a comparison to PR3940/3943/3956's differently fused adapters. + +Applying the inverse to 104 row fibers and the reversed encoding to 104 column +fibers gives a formal common-chart transition invoice: + +| Operation | Count | Status | +|---|---:|---| +| Unit array ADD/SUB | 179,712 | Constructive exact scalar count | +| Array halve | 21,632 | Constructive exact scalar count | +| Restoring array double | 21,632 | Constructive exact scalar count | +| Nonpivot array sign | 19,968 | Constructive exact scalar count | +| Explicit slot swap | 19,968 | Constructive exact logical-slot count | +| Extra scratch arrays | 0 | For this factor word | +| Nonuniform chart transport, physical swap/routing and fixed-slot return | unknown | No native realization supplied | +| Dirty-helper completion, lifetime/holding, width/precision/control and recursive admission | unknown | Retained obligations | + +Role reversal is expressed by choosing source and target operands in the column +word; it does not require two extra whole-bank exchanges. Its legal physical +availability is still an obligation. The finite invoice is **not** a physical +upper bound, since native chart changes and ownership have not been realized. + +For the unchanged PR3954 scaffold, grant all new interface work zero cost. +The named hypotheses are 208 local calls, rank mass 2576 each, persistent +progress at most 2312 each, 104^2 data pairs, 72 helpers per fiber in two +disjoint banks, ambient rank 81, entrance rank one per data source, and native +rank tariff at least remaining persistent progress. Then + +``` +W = 2*104^2 + 2*104*72 = 36608, +remaining >= 81W-104^2-208*2312 = 2473536, +bill >= 208*2576+2473536 = 3009344, +capacity = 81W = 2965248, +excess >= 44096. +``` + +Adding K as external work cannot repair this failed gate. Unknown nonnegative +costs are not zero; zero is only the most favorable rejection relaxation. +For 0<=a<1 and every child rank r<=81, `(r/81)^(1-a)>=r/81`, so failure also +holds for the corresponding positive-saving moment. This is inherited gate +arithmetic under explicit hypotheses, not an independent proof of a global +coverage law. A changed owner schedule, merged operations or profile requires +a new complete ledger rather than a deduction of 44,096 units from this paper. + +Decision: **narrow and stop implementation expansion**. The exact unresolved +item is an actual completed-call pair with one shared physical encoding and +legal helper/owner returns, or a priced changed transition that also changes +the failed complete gate. The current canonical source does not supply it. diff --git a/research/p104-encoded-boundary/README.md b/research/p104-encoded-boundary/README.md new file mode 100644 index 0000000000..3fb557b535 --- /dev/null +++ b/research/p104-encoded-boundary/README.md @@ -0,0 +1,68 @@ +# P104 row/column encoded-boundary audit + +The natural row-fiber encoding and reversed column-fiber encoding do not match +at fixed physical slots, even on the constant-address sector where all positive +C_U charts act as identity. A two-unit pivot input creates 48 extra signed unit +Y fields under the row encoding and none under the column encoding. + +This adds the missing cross-axis condition to [PR3954](https://github.com/CrocSwap/integer-mult-bounds/pull/3954)'s +common-completed-C commutation control. The exact replacement is +`K = S Pi_c L_c S L_r^-1 Pi_r`; all dirty helper values are retained. A direct +common-chart factor word is counted explicitly, with physical transport, +ownership, helper completion and precision left as unknown obligations. +The unchanged favorable whole-scaffold gate still exceeds capacity by 44,096. + +**Scope:** a source-bound interface lemma and concrete physical-sector +counterexample for one proposed row/column encoding. The retained caller +supplies an actual two-stage boundary; it does not supply an actual adjacent +completed P104 pair. The reversed column encoding is a proposed swapped-role +contract, not an independently replayed inverse native word. No supplier, +new kappa, physical runtime gain or selected-frontier change is claimed. + +See [PROOF.md](PROOF.md) for equations, the full obligation ledger and stop rule; +[RESULT.json](RESULT.json) for exact finite counts; [TASK.json](TASK.json) for +scope and next questions; [PREDECESSORS.json](PREDECESSORS.json) for credit. + +## Reproduce + +Standard-library Python 3.12: + +``` +python3.12 -I -B research/p104-encoded-boundary/verify.py +python3.12 -I -O -B research/p104-encoded-boundary/independent.py +python3.12 -I -O -B research/p104-encoded-boundary/test_verify.py +python3.12 -B scripts/research_package.py --package research/p104-encoded-boundary +python3.12 -B scripts/check_research_commit.py --package research/p104-encoded-boundary --check-source-history +``` + +The primary checker reconstructs the canonical 104 roots and B, checks 208 +local inverse basis columns (all fibers are disjoint), the physical-sector +counterexample and complete conditional gate. The separate dense checker +assembles four small whole-grid operators, including varying invertible chart +blocks, without importing the primary implementation. It checks all columns +and both literal occupancy and orientation failure controls. Tests check +optimized execution, bad result/source bytes and an offline read-only export. +Finite checks support the displayed algebraic proof; no human or kernel review +or full selected supplier replay is claimed. + +## Open next questions + +The actionable question is an actual chronological pair of completed calls +whose exit and entrance share one physical encoding on every role. Begin with +one named owner schedule and its source/target orientation, not a new scalar +adapter. Its helper maps, chart transports, fixed returns and complete cost +must be specified before native expansion. Alternatively, change the owner or +coverage contract and derive a new favorable gate first. The sibling copy and +coverage studies are separate investigations, not premises of this result. + +## Credit and source history + +Chris R / Clear1nsight, with substantial OpenAI Codex assistance. Apache-2.0. +PR3882/3940/3943 and PR3954 retain credit for residual encoding, actual caller, +cleanup, and physical two-axis compatibility/gate. PR3956 independently matches +the 960/1152 adapters; this package does not repeat that comparison. 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 lineage retain their original credit. +The three live source inputs are canonical-main files. Pending PRs are credited +context; no unmerged Git object is required for replay. diff --git a/research/p104-encoded-boundary/RESULT.json b/research/p104-encoded-boundary/RESULT.json new file mode 100644 index 0000000000..6cc516e59b --- /dev/null +++ b/research/p104-encoded-boundary/RESULT.json @@ -0,0 +1,50 @@ +{ + "conditional_gate": { + "capacity": 2965248, + "excess": 44096, + "rank_bill_lower_bound": 3009344, + "remaining_rank_lower_bound": 2473536, + "width": 36608 + }, + "formal_transition_invoice": { + "explicit_in_place_slot_swaps": 19968, + "full_grid_bank_swaps": 0, + "halves": 21632, + "nonpivot_signs": 19968, + "restoring_doubles": 21632, + "scope": "homogeneous common-chart factor word only; not physical upper bound", + "scratch_arrays": 0, + "unit_add_sub": 179712 + }, + "local_inverse_basis_columns": 208, + "physical_dc_witness": { + "column_extra_slots": 0, + "first_leak": [ + 1, + 8, + 0, + 1 + ], + "input_slot": [ + "X", + 0, + 0 + ], + "input_value": 2, + "row_extra_Y_slots": 48 + }, + "pivot_ports": [ + 0, + 1, + 3, + 6, + 22, + 31, + 93, + 103 + ], + "ports": 104, + "schema": "p104-encoded-boundary/1", + "scope": "exact fixed-slot interface mismatch and formal transition; no actual global P104 pair, native supplier or frontier change", + "small_global_basis_columns": 50 +} diff --git a/research/p104-encoded-boundary/SOURCES.json b/research/p104-encoded-boundary/SOURCES.json new file mode 100644 index 0000000000..e6d2ac6adb --- /dev/null +++ b/research/p104-encoded-boundary/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": "notes/structured-bulk-complex.tex", + "usage": "input", + "git_blob": "53868b41b2fe979cae9dae242ea0e0aef5681257", + "sha256": "70eb8da7ea58cd9fcc79aa800bcc98a883ddfc505e91b45e7362afba1c8ea480" + }, + { + "path": "research/p104-native-channel/inputs/P104-FIXTURE.json", + "usage": "input", + "git_blob": "2e16f99b295bb386fd13bd8fbd57b42ef54143a9", + "sha256": "516c06f6ec3cb84be588c546108de897650288576dd5fbf5fe44b9c5546ad8a4" + } + ] +} diff --git a/research/p104-encoded-boundary/TASK.json b/research/p104-encoded-boundary/TASK.json new file mode 100644 index 0000000000..b3017e894e --- /dev/null +++ b/research/p104-encoded-boundary/TASK.json @@ -0,0 +1,95 @@ +{ + "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": "refined", + "actual_scope": "Source-bound row-to-column literal encoding compatibility at the retained two-stage boundary, exact transition, physical DC counterexample and unchanged complete gate.", + "scope_change_reason": "The assigned PR3954 handoff requires matching actual all-role encodings, beyond uniform completed-C commutation. No actual global P104 adjacent pair is supplied by the source; retain an explicit missing-implementation boundary.", + "bottleneck_link": "Tests whether encoding conversion can disappear at the next consumer, before native optimization of a failed scaffold.", + "budget_minutes": 50, + "stop_rule": "Stop native expansion on mismatched encoding or failed complete gate; publish only exact interface result and remaining owner obligations.", + "outcome": "negative-result", + "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; one explicitly assigned agent in parallel stream, root publication and cross-review.", + "open_questions": [ + { + "question": "Can one actual adjacent completed-call pair share a single encoding on every physical role?", + "why_it_matters": "Only a matched pair can remove a boundary conversion rather than move it.", + "first_step": "Pin one chronological owner schedule, derive both endpoint maps and list fixed-slot/helper obligations.", + "blocked_by": "No actual P104 global pair; unchanged PR3954 gate fails before interface costs." + } + ], + "checkpoint": { + "main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "priority_revision": 6, + "utc": "2026-10-19T07:00:00Z", + "overlap": "Root refreshed all 662 open PR bodies including drafts; agent helper and bounded Discussions 1163/1166/2750/2619 reads. No complete closed/diff survey. PR3956 comparison excluded.", + "claim": "https://github.com/CrocSwap/integer-mult-bounds/pull/3954#issuecomment-6261590999" + } +} diff --git a/research/p104-encoded-boundary/VALIDATION.json b/research/p104-encoded-boundary/VALIDATION.json new file mode 100644 index 0000000000..cc797a3fd9 --- /dev/null +++ b/research/p104-encoded-boundary/VALIDATION.json @@ -0,0 +1,16 @@ +{ + "schema": "p104-encoded-boundary-validation/1", + "environment": "3.12.3", + "checks": { + "primary": "PASS; canonical inputs authenticated, all 208 local basis fields, 48 literal-slot DC leaks, conditional gate", + "independent": "PASS; 104 dense columns across four common/varying chart examples, 12 negative controls", + "behavioral_tests": "PASS; six tests including optimized, Git-free read-only export, input corruption/missing source and false receipts", + "metadata": "PASS; metadata and pins only" + }, + "limits": [ + "No actual global P104 adjacent completed-call pair or chronological owner schedule", + "No native physical transition upper bound", + "No signed-floor, precision, all-size supplier or selected cold replay", + "Hosted CI and exact-public-head byte/history checks recorded separately after publication" + ] +} diff --git a/research/p104-encoded-boundary/VERIFY.json b/research/p104-encoded-boundary/VERIFY.json new file mode 100644 index 0000000000..96235e3d20 --- /dev/null +++ b/research/p104-encoded-boundary/VERIFY.json @@ -0,0 +1,45 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "notes/copied-centers-complex.tex", + "notes/structured-bulk-complex.tex", + "research/p104-native-channel/inputs/P104-FIXTURE.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Pinned root/encoding/DC witness and conditional gate" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 120, + "checks": "Independent dense literal/chart transition and failure controls" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 180, + "checks": "Source/result corruption, optimized and offline read-only replay" + } + ] +} diff --git a/research/p104-encoded-boundary/independent.py b/research/p104-encoded-boundary/independent.py new file mode 100644 index 0000000000..18192ba519 --- /dev/null +++ b/research/p104-encoded-boundary/independent.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +"""Separately assembled dense operator checks, no imports from primary verifier.""" +from fractions import Fraction as Q + + +def need(ok,msg): + if not ok: raise ValueError(msg) + + +def zero(n): return [[Q(0) for _ in range(n)] for _ in range(n)] +def identity(n): + a=zero(n) + for i in range(n): a[i][i]=Q(1) + return a + +def mm(a,b): + bt=list(zip(*b)) + return [[sum(x*y for x,y in zip(row,col)) for col in bt] for row in a] + +def inverse(a): + n=len(a); out=[row[:]+unit for row,unit in zip(a,identity(n))] + for j in range(n): + k=next(i for i in range(j,n) if out[i][j]) + out[j],out[k]=out[k],out[j] + t=out[j][j];out[j]=[v/t for v in out[j]] + for i in range(n): + if i!=j: + t=out[i][j] + out[i]=[v-t*w for v,w in zip(out[i],out[j])] + return [row[n:] for row in out] + + +def matrices(b,axis,chart=True): + p=len(b);n=p+len(b[0]);size=2*n*n*2 + d=zero(n) + for i in range(p): + d[i][i]=1 + for j in range(n-p):d[i][j+p]=d[j+p][i]=Q(b[i][j],2) + for i in range(n-p): + for j in range(n-p):d[i+p][j+p]=sum(Q(b[k][i]*b[k][j],4) for k in range(p))-(i==j) + def ix(bank,i,j,z):return ((bank*n+i)*n+j)*2+z + L=identity(size);Pi=identity(size);S=zero(size) + for bank in range(2): + for i in range(n): + for j in range(n): + for z in range(2):S[ix(bank,i,j,z)][ix(1-bank,i,j,z)]=1 + for fixed in range(n): + for k in range(n): + i,j=(k,fixed) if axis==0 else (fixed,k) + # Each T block invertible; different fibers/ports need not commute with D. + t=[[Q(1),Q(i+j+1)],[Q(0),Q(1)]] if chart else identity(2) + for z in range(2): + r=ix(0,i,j,z);L[r]=[Q(0)]*size + for ell in range(n): + ii,jj=(ell,fixed) if axis==0 else (fixed,ell) + L[r][ix(0,ii,jj,z)]=d[k][ell] + if k>=p: + for w in range(2):L[r][ix(1,i,j,w)]=t[z][w] + for bank in range(2): + rr=ix(bank,i,j,z);Pi[rr]=[Q(0)]*size;Pi[rr][ix(1-bank,i,j,z)]=1 + return L,Pi,S + + +def main(): + checks=0 + for b in ([[1]],[[1,-1]]): + for chart in (False,True): + lr,pr,s=matrices(b,0,chart);lc,pc,_=matrices(b,1,chart) + ar=mm(pr,lr);acbar=mm(mm(s,mm(pc,lc)),s) + # Exact physical ordered product, reversed after the bank-orientation map. + k=mm(mm(mm(mm(mm(s,pc),lc),s),inverse(lr)),pr) + need(mm(k,ar)==acbar,'K A_r = Abar_c') + need(mm(inverse(ar),ar)==identity(len(ar)),'independent inverse') + need(ar!=acbar,'identity-boundary control') + wrong=mm(mm(pc,lc),inverse(ar)) + need(mm(wrong,ar)!=acbar,'omitted source-target reversal control') + wrong=mm(mm(mm(s,lc),s),inverse(ar)) + need(mm(wrong,ar)!=acbar,'omitted literal occupancy control') + # Common address transform commutes only in homogeneous-chart test. + if not chart: + common=zero(len(ar)) + for j in range(0,len(ar),2):common[j][j+1]=1;common[j+1][j]=-1 + need(mm(common,ar)==mm(ar,common),'uniform completion control') + need(mm(common,acbar)==mm(acbar,common),'reversed completion control') + checks+=len(ar) + print('PASS_P104_BOUNDARY_DENSE columns='+str(checks)+' chart_cases=4 negative_controls=12') + +if __name__=='__main__':main() diff --git a/research/p104-encoded-boundary/test_verify.py b/research/p104-encoded-boundary/test_verify.py new file mode 100644 index 0000000000..8256847051 --- /dev/null +++ b/research/p104-encoded-boundary/test_verify.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +"""Behavioral publication/export controls; no third-party dependencies.""" +import hashlib +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest +HERE=Path(__file__).resolve().parent +ROOT=HERE.parents[1] + + +def snapshot(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 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 run_cli(self,p,*args): + return subprocess.run([sys.executable,'-I','-O','-B',str(p/'verify.py'),*args],capture_output=True,text=True,timeout=120,env={'PATH':'','LANG':'C.UTF-8'}) + def test_optimized_readonly_gitfree(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td) + for f in Path(td).rglob('*'): + if f.is_file():f.chmod(0o444) + before=snapshot(Path(td));r=self.run_cli(p) + self.assertEqual(r.returncode,0,r.stderr);self.assertEqual(snapshot(Path(td)),before) + self.assertFalse((Path(td)/'.git').exists()) + def test_source_corruption(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.run_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.run_cli(p).returncode,0) + def test_false_zero_boundary_invoice(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);f=p/'RESULT.json';r=json.loads(f.read_text());r['formal_transition_invoice']['unit_add_sub']=0;f.write_text(json.dumps(r)) + out=self.run_cli(p);self.assertNotEqual(out.returncode,0);self.assertIn('result mismatch',out.stderr) + def test_false_gate_and_identity(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);f=p/'RESULT.json';r=json.loads(f.read_text());r['conditional_gate']['excess']=0;r['physical_dc_witness']['row_extra_Y_slots']=0;f.write_text(json.dumps(r)) + self.assertNotEqual(self.run_cli(p).returncode,0) + def test_duplicate_result_key(self): + with tempfile.TemporaryDirectory() as td: + p=self.export(td);(p/'RESULT.json').write_text('{"a":1,"a":2}') + r=self.run_cli(p);self.assertNotEqual(r.returncode,0);self.assertIn('duplicate JSON key',r.stderr) + +if __name__=='__main__':unittest.main(verbosity=2) diff --git a/research/p104-encoded-boundary/verify.py b/research/p104-encoded-boundary/verify.py new file mode 100644 index 0000000000..a4650b269e --- /dev/null +++ b/research/p104-encoded-boundary/verify.py @@ -0,0 +1,177 @@ +#!/usr/bin/env python3 +"""Exact source-bound axis encoding 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 add_into(state, dest, src, coefficient): + value = state.get(dest, 0) + coefficient * state.get(src, 0) + if value: + state[dest] = value + else: + state.pop(dest, None) + + +def fiber_word(state, axis, fixed, b2, inverse=False, reverse=False): + """Literal encoding at T=I. Fractions allowed; no actual chart move claimed.""" + from fractions import Fraction + n = len(b2) + len(b2[0]); p = len(b2) + source, target = (1,0) if reverse else (0,1) + def slot(bank, k): + return (bank, k, fixed) if axis == 0 else (bank, fixed, k) + def swap(): + for k in range(p,n): + x,y=slot(source,k),slot(target,k) + vx,vy=state.get(x,0),state.get(y,0) + if vy: state[x]=vy + else: state.pop(x,None) + if vx: state[y]=vx + else: state.pop(y,None) + def scale_nonpivot(): + for k in range(p,n): + s=slot(source,k) + if s in state: state[s]=-state[s] + def forward_b(sign): + for j,row in enumerate(b2): + for k,c in enumerate(row,p): + if c: add_into(state,slot(source,j),slot(source,k),sign*Fraction(c,2)) + def transpose_b(): + for j,row in enumerate(b2): + for k,c in enumerate(row,p): + if c: add_into(state,slot(source,k),slot(source,j),Fraction(c,2)) + if inverse: + swap() + for k in range(p,n): add_into(state,slot(source,k),slot(target,k),-1) + scale_nonpivot(); transpose_b(); forward_b(-1) + else: + forward_b(1); scale_nonpivot(); transpose_b() + for k in range(p,n): add_into(state,slot(source,k),slot(target,k),1) + swap() + + +def encode(state, axis, b2, inverse=False, reverse=False): + out=dict(state) + n=len(b2)+len(b2[0]) + for fixed in range(n): fiber_word(out,axis,fixed,b2,inverse,reverse) + return out + + +def transition(state,b2): + return encode(encode(state,0,b2,inverse=True),1,b2,reverse=True) + + +def result(): + authenticate(); b2=source_matrix() + from fractions import Fraction + # Actual port-gauge DC witness; physical C_U, F and E all act as identity here. + seed={(0,0,0):Fraction(2)} + row=encode(seed,0,b2); col=encode(seed,1,b2,reverse=True) + leak={key:value for key,value in row.items() if key != (0,0,0)} + require(col == seed, 'column opposite-orientation witness') + require(len(leak)==48 and all(key[0]==1 and key[1]>=8 and key[2]==0 and abs(v)==1 for key,v in leak.items()), '48 physical slot leaks') + require(transition(row,b2)==col, 'P104 transition witness') + # Verify full inverse factor identities for all 208 local basis fields. + # Different fibers are disjoint: this covers every data column of each global axis map. + for bank in range(2): + for k in range(104): + x={(bank,k,0):Fraction(4)} + y=dict(x); fiber_word(y,0,0,b2); fiber_word(y,0,0,b2,inverse=True) + require(y==x, 'local inverse basis') + # Independent all-grid-input checks on two small rational B fixtures. + # These exercise both axes, the bank reversal, and all helper roles as untouched fields. + fixture_columns=0 + for b in ([[1,0]], [[1,-1],[0,1]]): + n=len(b)+len(b[0]) + for bank in range(2): + for i in range(n): + for j in range(n): + x={(bank,i,j):Fraction(4), (2,17,0):Fraction(7), (3,9,0):Fraction(-5)} + left=transition(encode(x,0,b),b) + right=encode(x,1,b,reverse=True) + require(left==right,'small full-grid intertwiner') + fixture_columns+=1 + require(row != col, 'identity handoff incorrectly accepted') + # Explicit favorable complete gate inherited as named hypotheses, not supplier replay. + n,h,m,local,progress=104,72,81,2576,2312 + width=2*n*n+2*n*h; capacity=m*width + remaining=capacity-n*n-2*n*progress + bill=2*n*local+remaining + require(bill-capacity==44096,'unchanged-inventory gate') + count=sum(c!=0 for r in b2 for c in r) + return {'schema':'p104-encoded-boundary/1','ports':104,'pivot_ports':list(PIVOTS), + 'physical_dc_witness':{'input_slot':['X',0,0],'input_value':2,'row_extra_Y_slots':48,'column_extra_slots':0, + 'first_leak':list(min(leak.items())[0])+[int(leak[min(leak)])]}, + 'local_inverse_basis_columns':208,'small_global_basis_columns':fixture_columns, + 'formal_transition_invoice':{'scope':'homogeneous common-chart factor word only; not physical upper bound', + 'unit_add_sub':2*n*(2*count+96),'halves':2*n*104,'restoring_doubles':2*n*104, + 'nonpivot_signs':2*n*96,'explicit_in_place_slot_swaps':2*n*96, + 'scratch_arrays':0,'full_grid_bank_swaps':0}, + 'conditional_gate':{'width':width,'capacity':capacity,'remaining_rank_lower_bound':remaining, + 'rank_bill_lower_bound':bill,'excess':bill-capacity}, + 'scope':'exact fixed-slot interface mismatch and formal transition; no actual global P104 pair, native supplier or frontier change'} + + +def main(): + p=argparse.ArgumentParser();p.add_argument('--write-result',action='store_true');p.add_argument('--result',type=Path,default=HERE/'RESULT.json');a=p.parse_args() + r=result() + if a.write_result: a.result.write_text(json.dumps(r,indent=2,sort_keys=True)+'\n') + else: require(json.dumps(read(a.result),sort_keys=True)==json.dumps(r,sort_keys=True),'result mismatch') + print('PASS_P104_ENCODED_BOUNDARY slots=21632 helpers=14976 dc_leaks=48 gate_excess=44096 no_new_kappa') + +if __name__=='__main__': main() From afd6bb0a701e9ffd685f27674adaac86687e5f02 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 19 Oct 2026 18:09:59 +1100 Subject: [PATCH 2/2] test: keep destructive export controls on writable private copies --- research/p104-encoded-boundary/test_verify.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/research/p104-encoded-boundary/test_verify.py b/research/p104-encoded-boundary/test_verify.py index 8256847051..b4c948a682 100644 --- a/research/p104-encoded-boundary/test_verify.py +++ b/research/p104-encoded-boundary/test_verify.py @@ -21,6 +21,9 @@ class Controls(unittest.TestCase): def export(self,tmp): target=Path(tmp)/'research'/HERE.name shutil.copytree(HERE,target,ignore=shutil.ignore_patterns('__pycache__')) + # Mutations belong only to private copies, even when source export is read-only. + for copied in target.rglob('*'): + if copied.is_file(): copied.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)