From fa3e8a93059ac08da2a2666228a10226403453ce Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 21 Oct 2026 13:28:24 +0000 Subject: [PATCH] Record that the literal P104 slot exchange misses the helper gate. On the #3954 scaffold, Pi P_enc Pi matches neither the adjacent data charts nor the identity-to-full-F helper transition, and every nonnegative price of the exchange stays over capacity by at least 44096. Co-authored-by: unpaidmoon --- research/p104-literal-helper-gate/PROOF.md | 112 +++++++ research/p104-literal-helper-gate/README.md | 102 ++++++ .../p104-literal-helper-gate/SOURCES.json | 18 ++ research/p104-literal-helper-gate/TASK.json | 139 ++++++++ research/p104-literal-helper-gate/VERIFY.json | 19 ++ research/p104-literal-helper-gate/verify.py | 297 ++++++++++++++++++ 6 files changed, 687 insertions(+) create mode 100644 research/p104-literal-helper-gate/PROOF.md create mode 100644 research/p104-literal-helper-gate/README.md create mode 100644 research/p104-literal-helper-gate/SOURCES.json create mode 100644 research/p104-literal-helper-gate/TASK.json create mode 100644 research/p104-literal-helper-gate/VERIFY.json create mode 100644 research/p104-literal-helper-gate/verify.py diff --git a/research/p104-literal-helper-gate/PROOF.md b/research/p104-literal-helper-gate/PROOF.md new file mode 100644 index 0000000000..66b8435efc --- /dev/null +++ b/research/p104-literal-helper-gate/PROOF.md @@ -0,0 +1,112 @@ +# Literal correction, helper entrance, and the #3954 gate + +This is a scoped negative certificate. It does not change κ. The selected +value stays `0.001672660197076918`. + +The source contract is the two-axis scaffold in +`research/p104-two-axis-compatibility/PROOF.md` at base +`12fa8c5c844be21bfefb38a19503fbd867a11244` (PR #3954). The literal-slot +identity is the one separated in `research/p104-literal-slot-defect`. This +note does not rerun either package. + +## 1. Charts of one scaffold call + +Order the two data banks as a pair. The retained caller uses source charts +`(T, I)` and terminal charts `(F, E)`, with `T = C_U`, `F = C_I` and +`E = F T^{-1}`. Here `I` is the identity address, so `C_I = C_0`, and + +```text +C_u = ((1+i) I + (1-i) X_u) / 2. +``` + +On a Fourier character `z`, `C_u` acts by `1` when `u·z` is even and by `i` +when `u·z` is odd. Thus `C_0` is the identity operator, and `C_u = C_0` if +and only if `u = 0`. + +For a call on address `u` and a next call on address `v`, the exit chart pair +and the next entrance chart pair are + +```text +exit = (C_0, C_u^{-1}), +entrance = (C_v, C_0). +``` + +These pairs agree on both banks if and only if `C_v = C_0` and `C_u^{-1} = C_0`, +hence if and only if `u = v = 0`. Every nondegenerate line in the scaffold is +a nonzero address, so no adjacent pair of scaffold calls matches both data +banks. + +`Π P_enc Π` is the operator which intertwines one call's literal encoding +`A_T = Π L_T`. It is not a rewrite of the chart pair `(C_0, C_u^{-1})` into +`(C_v, C_0)`. + +## 2. Helper entrance and exit + +Section 1 of the #3954 proof extends every compatibility map by identity on +the 72 arbitrary dirty helper roles of a fiber. Section 5 places two disjoint +banks of those roles in the inventory + +```text +n = 104, +helper roles = 2 n · 72 = 14976, +W = 2 n^2 + 2 n · 72 = 36608. +``` + +The same section says that every persistent entrance other than the rank-one +data source chart is the identity, and that the completed contract is full +`F` on all `W` roles. The progress identity therefore charges `81` dimensions +on each helper role and subtracts only the `N = n^2` data-line sources: + +```text +helper progress demanded = 81 · 14976 = 1213056. +``` + +The identity extension acts by `1` on each helper coordinate. It sends a +helper basis vector to itself and adds no helper component to a data vector. +Its contribution to helper progress is `0`. It preserves a dirty helper +state, and it does not implement the transition from the identity entrance +to the full-`F` exit. + +So `Π P_enc Π`, extended in the way #3954 states, does not match a completed +helper exit to the next call's identity helper entrance. + +## 3. The slot exchange is not free, and zero is already too expensive + +`Π` swaps the two data slots on the `96` N-ports and fixes the `8` J-ports. +That support size is a count of coordinates, not a native tariff. The #3954 +gate records the realization of `Π` inside an unknown nonnegative physical +charge. Under hypotheses (a)–(e) of that proof, with this charge set to an +integer `s ≥ 0`, + +```text +P_total = 81 W − N = 2954432, +remaining = P_total − 208·2312 = 2473536, +lower mass = 208·2576 + remaining + s = 3009344 + s, +capacity = 81 W = 2965248, +excess = 44096 + s > 0. +``` + +The moment ratio at `a = 0` is already greater than `1` when `s = 0`. Every +larger price is worse. A negative price would be a different gate; unknown +costs in that proof are not negative. + +The local progress `2312` per call is the figure hypothesis (b) grants. This +note does not move any of that grant onto the boundary map. The boundary map +adds none. + +## 4. What a matching pair would have to change + +The conjugation identity on the two data banks remains true: on a witness +with one J port, one N port and one helper coordinate, + +```text +(Π P_enc Π ⊕ I) (A_T ⊕ I) = (A_T ⊕ I) (P ⊕ I). +``` + +The old correction, extended in the same way, fails that identity. This is +the data-slot statement already separated from the census. It does not make +the chart pairs of section 1 equal, and it does not pay section 2. + +A favorable adjacent pair needs a different chart contract or a helper word +whose proved progress can be subtracted from `1213056` without a new +nonnegative charge that puts the excess back. Neither is supplied here. diff --git a/research/p104-literal-helper-gate/README.md b/research/p104-literal-helper-gate/README.md new file mode 100644 index 0000000000..7943e7cf65 --- /dev/null +++ b/research/p104-literal-helper-gate/README.md @@ -0,0 +1,102 @@ +# Literal slot exchange against the #3954 helper gate + +**Negative interface certificate. No new κ.** Selected κ stays +`0.001672660197076918`. + +Open question 1 of `research/p104-literal-slot-defect` asks whether one +adjacent pair that uses `Π P_enc Π`, rather than `P`, matches every helper +role as well as both data banks, and whether the bill is favorable. On the +PR #3954 scaffold the answer is no. + +## Result + +The retained caller has source charts `(T, I)` and terminal charts `(F, E)`, +with `T = C_U`, `F = C_0` and `E = F T^{-1}`. For every nonzero address `u` +and every address `v`, the exit pair `(C_0, C_u^{-1})` is not the next +entrance pair `(C_v, C_0)`. Both pairs agree only for the degenerate address +`u = v = 0`, which the scaffold excludes. `Π P_enc Π` intertwines one call's +literal encoding. It does not rewrite those chart pairs. + +#3954 extends every compatibility map by identity on the 72 dirty helper +roles of a fiber. The inventory has `14976` such roles. The completed +contract charges `81` dimensions on each of them, `1213056` in total, while +the identity extension contributes `0`. A helper basis vector is fixed, so +the boundary map does not turn the identity helper entrance into the full-`F` +exit. + +`Π` itself swaps the `96` N-ports. That count is the support of the +permutation, not a native tariff. Under the published hypotheses (a)–(e), +every nonnegative added rank-mass `s` leaves the excess equal to +`44096 + s`. The zero-price gate is already over capacity `2965248` by +`44096`. The bill is not favorable. + +The block arithmetic and the integer identities are in [PROOF.md](PROOF.md). +`verify.py` recomputes the charts on `(F_2)^4`, the helper direct sum on a +two-port witness, and the gate. + +## Scope + +Task `p104-side-correction`, scope **refined**. The card asks for a changed +producer/consumer with a complete bill. This package answers the first open +question of the literal-slot certificate instead of building that producer. +The scalar obstruction in that certificate does not mention helpers or the +gate; the commutation-gap certificate has no helper roles. Those two results +stay as they are. + +Base `12fa8c5c844be21bfefb38a19503fbd867a11244`, priority revision 7. +The #3954 head retained by the family record is the source of the entrance, +exit and gate integers. This package does not import that code. + +## Reproduce + +Python 3.12, standard library, from the repository root: + +```sh +python3.12 -B scripts/research_package.py --package research/p104-literal-helper-gate +``` + +Direct check: + +```sh +python3 -B research/p104-literal-helper-gate/verify.py +``` + +Expected marker: + +```text +PASS_P104_LITERAL_HELPER_GATE charts=F2^4 nonzero_mismatch=true helper_extension=identity helper_progress=1213056 excess0=44096 ports_n=96 nonnegative_price=unfavorable no_new_kappa +``` + +The same command passes under `-O`. Not run: Lean, Docker, a selected cold +replay, the #3954 native census, and hosted CI. + +## Open next questions + +1. Can one named helper word advance one of the 72 roles per fiber and be + subtracted from the `1213056` helper-progress charge without a new + nonnegative cost that restores the excess? The identity extension + contributes none of that progress. First step: freeze one fiber, write + the identity entrance and the full-`F` exit for one role, and give the + rank-mass of the word that connects them. Blocker: no such word is in + the #3954 extension, and unknown physical costs are not negative + rank-mass. +2. Is there an adjacent pair whose charts are not `(T, I)` and `(F, E)`, + with an operator other than `Π P_enc Π`, that matches every data and + helper role under a freshly derived gate? First step: name the two chart + pairs and the helper schedule, then recompute capacity. Blocker: a + different inventory or coverage law needs its own gate. The excess + `44096` is not a theorem about that law. + +## Credit + +The entrance, exit, identity helper extension, N-port slot swap and the +`44096` gate are Chris R / Clear1nsight's PR #3954. The request for an +adjacent pair on every data and helper role is discussion #1166 comment +19034066. The question of whether `Π P_enc Π` answers that request is open +question 1 of `research/p104-literal-slot-defect`. The chart formula is the +one used in `research/p104-uniform-commutation-gap`. Predecessor lineage +named in those packages remains theirs, including Rohan Arun, Chafik +Boukhalfa and Adam Gall. + +Prepared by unpaidmoon with substantial Cursor Grok assistance. No +independent human or formal-kernel review is claimed. Apache-2.0. diff --git a/research/p104-literal-helper-gate/SOURCES.json b/research/p104-literal-helper-gate/SOURCES.json new file mode 100644 index 0000000000..fcfba8aa31 --- /dev/null +++ b/research/p104-literal-helper-gate/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + } + ] +} diff --git a/research/p104-literal-helper-gate/TASK.json b/research/p104-literal-helper-gate/TASK.json new file mode 100644 index 0000000000..dad00e6f34 --- /dev/null +++ b/research/p104-literal-helper-gate/TASK.json @@ -0,0 +1,139 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "priority_revision": 7, + "base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244", + "original_card": { + "id": "p104-side-correction", + "question": "Can a changed P104 producer/consumer contract escape the scoped slot, chart and completion obstructions with a favorable full bill?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/p104-literal-slot-defect/README.md", + "research/p104-uniform-commutation-gap/README.md", + "research/p104-uniform-encoding-gap/README.md", + "research/p104-source-chart-shortcut/README.md", + "research/p104-fiber-tag-seam/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 named successor obstructions before extending #2981 static flags. Distinguish literal-slot action, commutation, uniform encoding, source-chart shortcut and fiber-tag seam scopes; none excludes all P104 mechanisms.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Name one hypothesis changed from these exact interfaces. Write a literal producer-to-consumer timeline and an arbitrary-dirty-input positive/control pair, then charge acquisition, coefficients, completion, hosting and restoration. Stop if the same slot/fiber mismatch persists or the favorable full budget already fails. A scoped independent audit remains useful; another static count is not a new completion.", + "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.", + "Repeating a static cover, source-chart shortcut or fiber-tag seam without changing the hypothesis responsible for its obstruction." + ], + "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", + "4133", + "4136", + "4140", + "4153", + "4154", + "p104-literal-slot-defect", + "p104-uniform-commutation-gap", + "p104-uniform-encoding-gap", + "p104-source-chart-shortcut", + "p104-fiber-tag-seam" + ], + "existing_checks": [ + { + "scope": "PR #4133: literal-slot defect", + "evidence": "research/p104-literal-slot-defect/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "88666f1dee93fbd85b31fd5d6f91a219e111b5f4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4136: uniform commutation gap", + "evidence": "research/p104-uniform-commutation-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "281ce601a8be9db470de630759179c23e1dfaa88", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4140: uniform encoding gap", + "evidence": "research/p104-uniform-encoding-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "de25c6525aa866962309df5d107b32d55e6e5628", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4153: source-chart shortcut exhausts its optimistic allowance", + "evidence": "research/p104-source-chart-shortcut/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "9123241fea53df77e51ffe30d9aca1625d4bf3a8", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4154: fiber-tag seam mismatch", + "evidence": "research/p104-fiber-tag-seam/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "4ffcdaee5d6255a9cea1fe53a5424435068089d0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "On the PR #3954 two-axis scaffold, the literal correction Pi P_enc Pi extended by identity on the 72 helper roles does not match an adjacent call's data charts (T, I) to (F, E), does not advance a helper from the identity entrance to the full-F exit, and leaves the published gate over capacity for every nonnegative slot-exchange price.", + "scope_change_reason": "Open question 1 of research/p104-literal-slot-defect asks whether Pi P_enc Pi matches helper roles as well as both data banks and whether the bill is favorable. This package answers that question on the pinned #3954 entrance, exit and gate. It does not construct a new chronological correction word.", + "bottleneck_link": "The literal-slot identity already supplies an intertwiner on the two data banks. A favorable adjacent pair would still have to match helpers and beat the scaffold capacity. This certificate shows that pair is not the #3954 contract, so the obstruction stays in force and kappa does not move.", + "budget_minutes": 60, + "stop_rule": "Stop after the chart mismatch on every nonzero address of (F_2)^4, the identity helper extension on one witness, and the nonnegative gate. Do not search another gauge, price a native word, or treat the 96-port support of Pi as a tariff.", + "outcome": "negative-result", + "evidence": "PROOF.md derives the chart inequality, the zero helper-boundary progress, and the excess 44096+s. verify.py recomputes those integers and the Gaussian-integer charts, and checks that Pi P_enc Pi plus an identity helper coordinate intertwines the literal encoding while fixing the helper.", + "author": "unpaidmoon", + "ai_assistance": "Substantial Cursor Grok assistance in the proof, checker, and write-up. Not independent human or formal-kernel review.", + "open_questions": [ + { + "question": "Can one named helper word advance one of the 72 roles per fiber and be subtracted from the 1213056 helper-progress charge without a new nonnegative cost that restores the excess?", + "why_it_matters": "The identity extension contributes none of that progress. A real helper schedule is the only way this boundary could move the gate.", + "first_step": "Freeze one fiber, write the helper entrance and the full-F exit for one of its 72 roles, and give the rank-mass of the word that connects them.", + "blocked_by": "No such word is in the #3954 identity extension. Unknown physical costs cannot be entered as negative rank-mass." + }, + { + "question": "Is there an adjacent pair whose entrance and exit charts are not (T, I) and (F, E), for which some operator other than Pi P_enc Pi matches every data and helper role under a freshly derived gate?", + "why_it_matters": "This certificate rejects only the retained #3954 charts, the identity helper extension, and hypotheses (a)-(e).", + "first_step": "Name the two chart pairs and the helper schedule, then recompute capacity before any search.", + "blocked_by": "A different inventory or coverage law needs its own gate. The old excess is not a theorem about that law." + } + ] +} diff --git a/research/p104-literal-helper-gate/VERIFY.json b/research/p104-literal-helper-gate/VERIFY.json new file mode 100644 index 0000000000..65b131aee6 --- /dev/null +++ b/research/p104-literal-helper-gate/VERIFY.json @@ -0,0 +1,19 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": ["{python}", "-B", "{package}/verify.py"], + "timeout_seconds": 60, + "checks": "Chart mismatch on every nonzero address of (F_2)^4, identity helper extension, and nonnegative gate excess 44096+s" + }, + { + "argv": ["{python}", "-O", "-B", "{package}/verify.py"], + "timeout_seconds": 60, + "checks": "Same certificate with assertions removed, so the explicit require() failures still fire" + } + ] +} diff --git a/research/p104-literal-helper-gate/verify.py b/research/p104-literal-helper-gate/verify.py new file mode 100644 index 0000000000..7c65935f08 --- /dev/null +++ b/research/p104-literal-helper-gate/verify.py @@ -0,0 +1,297 @@ +#!/usr/bin/env python3 +"""Pi P_enc Pi does not match the #3954 adjacent helper contract, and no +nonnegative price of that slot exchange makes the published gate favorable. + +The arithmetic is PROOF.md. Charts are Gaussian-integer eigenvalues. The +helper coordinate is an explicit direct sum with the literal-slot encoding. +""" + +from __future__ import annotations + +M = 4 +DIM = 1 << M +ONE = (1, 0) +I_UNIT = (0, 1) +ZERO = (0, 0) + + +def require(condition, message): + if not condition: + raise SystemExit("FAIL_P104_LITERAL_HELPER_GATE " + message) + + +def parity(u: int, z: int) -> int: + return (u & z).bit_count() & 1 + + +def mul(left, right): + return ( + left[0] * right[0] - left[1] * right[1], + left[0] * right[1] + left[1] * right[0], + ) + + +def inv_unit(value): + norm = value[0] * value[0] + value[1] * value[1] + require(norm == 1, "chart value is a Gaussian unit") + return (value[0], -value[1]) + + +def c_eig(u: int, z: int): + """C_u on character z. Equals 1 when u·z is even and i when u·z is odd.""" + return ONE if parity(u, z) == 0 else I_UNIT + + +def gate(): + """Pinned #3954 scaffold integers. s is an added nonnegative rank-mass.""" + n = 104 + helpers_per_fiber = 72 + m = 81 + ports_n = n - 8 + data_lines = n * n + helper_roles = 2 * n * helpers_per_fiber + roles = 2 * data_lines + helper_roles + calls = 2 * n + local_mass = 2576 + local_progress = 2312 + progress = m * roles - data_lines + remaining = progress - calls * local_progress + lower = calls * local_mass + remaining + capacity = m * roles + return { + "n": n, + "ports_n": ports_n, + "data_lines": data_lines, + "helper_roles": helper_roles, + "roles": roles, + "calls": calls, + "progress": progress, + "remaining": remaining, + "lower": lower, + "capacity": capacity, + "excess": lower - capacity, + "helper_progress": m * helper_roles, + "local_mass": local_mass, + "local_progress": local_progress, + } + + +def favorable(added_rank_mass: int) -> bool: + """True only for a nonnegative price that lands strictly under capacity.""" + if added_rank_mass < 0: + return False + numbers = gate() + return numbers["lower"] + added_rank_mass < numbers["capacity"] + + +# --- rational block arithmetic for the literal slot plus one helper --- + +from fractions import Fraction + + +def fr(value): + return value if isinstance(value, Fraction) else Fraction(value) + + +def zeros(rows, cols): + return [[fr(0) for _ in range(cols)] for _ in range(rows)] + + +def eye(n): + return [[fr(int(i == j)) for j in range(n)] for i in range(n)] + + +def diag(values): + matrix = zeros(len(values), len(values)) + for index, value in enumerate(values): + matrix[index][index] = fr(value) + return matrix + + +def add(left, right): + return [ + [left[i][j] + right[i][j] for j in range(len(left[0]))] + for i in range(len(left)) + ] + + +def sub(left, right): + return [ + [left[i][j] - right[i][j] for j in range(len(left[0]))] + for i in range(len(left)) + ] + + +def matmul(left, right): + rows, mid = len(left), len(left[0]) + cols = len(right[0]) + out = zeros(rows, cols) + for i in range(rows): + for k in range(mid): + if left[i][k] == 0: + continue + for j in range(cols): + out[i][j] += left[i][k] * right[k][j] + return out + + +def blocks(top_left, top_right, bottom_left, bottom_right): + n = len(top_left) + out = zeros(2 * n, 2 * n) + for i in range(n): + for j in range(n): + out[i][j] = top_left[i][j] + out[i][n + j] = top_right[i][j] + out[n + i][j] = bottom_left[i][j] + out[n + i][n + j] = bottom_right[i][j] + return out + + +def inverse(matrix): + n = len(matrix) + augmented = [row[:] + eye(n)[i] for i, row in enumerate(matrix)] + for col in range(n): + pivot = next(row for row in range(col, n) if augmented[row][col] != 0) + augmented[col], augmented[pivot] = augmented[pivot], augmented[col] + pivot_value = augmented[col][col] + augmented[col] = [entry / pivot_value for entry in augmented[col]] + for row in range(n): + if row == col or augmented[row][col] == 0: + continue + factor = augmented[row][col] + augmented[row] = [ + augmented[row][j] - factor * augmented[col][j] for j in range(2 * n) + ] + return [row[n:] for row in augmented] + + +def direct_sum(data, helper): + """Place a scalar helper block on the diagonal after the data operator.""" + n = len(data) + out = zeros(n + 1, n + 1) + for i in range(n): + for j in range(n): + out[i][j] = data[i][j] + out[n][n] = fr(helper) + return out + + +def check_charts(): + """Exit charts (C_0, C_u^{-1}) equal entrance charts (C_u, C_0) only for u = 0.""" + degenerate = 0 + mismatched = 0 + for u in range(DIM): + for z in range(DIM): + exit_first = c_eig(0, z) + exit_second = inv_unit(c_eig(u, z)) + entrance_first = c_eig(u, z) + entrance_second = c_eig(0, z) + same = exit_first == entrance_first and exit_second == entrance_second + if u == 0: + require(same, "degenerate line must match both banks") + elif not same: + mismatched += 1 + # The first bank is i against 1 on every odd character. + if parity(u, z) == 1: + require(exit_first == ONE and entrance_first == I_UNIT, + "odd character separates F from T") + if u == 0: + degenerate += 1 + for v in range(1, DIM): + for z in range(DIM): + if parity(v, z) == 1: + require(c_eig(v, z) != c_eig(0, z), + "a nonzero next address misses the degenerate exit") + require(degenerate == 1, "one zero address") + # Every nonzero u fails on its 8 odd characters, two banks not required. + require(mismatched == (DIM - 1) * (DIM // 2), "every nonzero address mismatches") + + +def check_helper_extension(): + """One J port, one N port, one helper. Pi swaps only the N slots.""" + mask = [0, 1] + t_values = diag([4, 2]) + data = eye(2) + h = diag(mask) + n = 2 + j0 = sub(eye(n), h) + k = inverse(t_values) + p = blocks(eye(n), zeros(n, n), k, eye(n)) + l = blocks(data, matmul(h, t_values), zeros(n, n), eye(n)) + pi = blocks(j0, h, h, j0) + encoded = matmul(pi, l) + require(matmul(pi, pi) == eye(2 * n), "Pi is an involution on the data slots") + # Pi moves the single N coordinate and fixes the J coordinate. + require(pi[0][0] == 1 and pi[0][1] == 0, "J slot stays in the first bank") + require(pi[1][3] == 1 and pi[3][1] == 1, "N slot is the swapped coordinate") + p_enc = matmul(matmul(l, p), inverse(l)) + p_literal = matmul(matmul(pi, p_enc), pi) + require(matmul(p_literal, encoded) == matmul(encoded, p), "literal conjugation on data") + require(matmul(p, encoded) != matmul(encoded, p), "old P still fails on the literal slots") + + full_correction = direct_sum(p_literal, 1) + full_encoding = direct_sum(encoded, 1) + full_old = direct_sum(p, 1) + # P_literal A_T = A_T P, so the helper extension satisfies the same on data + # and acts as the identity on the helper. It does not commute with A_T. + require( + matmul(full_correction, full_encoding) == matmul(full_encoding, full_old), + "identity helper preserves the literal intertwining", + ) + require( + matmul(full_old, full_encoding) != matmul(full_encoding, full_old), + "old P still fails after the helper is adjoined", + ) + helper = [fr(0), fr(0), fr(0), fr(0), fr(1)] + image = [ + sum(full_correction[i][j] * helper[j] for j in range(5)) + for i in range(5) + ] + require(image == helper, "helper basis vector is fixed") + data_only = [fr(3), fr(5), fr(7), fr(11), fr(0)] + data_image = [ + sum(full_correction[i][j] * data_only[j] for j in range(5)) + for i in range(5) + ] + require(data_image[4] == 0, "a data vector gains no helper component") + # The extension's helper progress on this coordinate is zero. + require(full_correction[4][4] == 1 and all(full_correction[4][j] == 0 for j in range(4)), + "helper row is the identity row") + + +def check_gate(): + numbers = gate() + require(numbers["ports_n"] == 96, "N-port count") + require(numbers["data_lines"] == 10816, "data lines") + require(numbers["helper_roles"] == 14976, "helper roles") + require(numbers["roles"] == 36608, "role count") + require(numbers["progress"] == 2954432, "persistent progress") + require(numbers["remaining"] == 2473536, "progress after local calls") + require(numbers["lower"] == 3009344, "favorable lower mass") + require(numbers["capacity"] == 2965248, "capacity") + require(numbers["excess"] == 44096, "zero-price excess") + require(numbers["helper_progress"] == 1213056, "helper progress demanded by 81 per role") + require(not favorable(0), "zero price is already over capacity") + require(not favorable(96), "charging the N-port support does not help") + require(not favorable(-44096), "a negative price is outside the contract") + # The raw excess formula still sees the cancelled integer, and rejects it. + require(numbers["excess"] + (-44096) == 0, "arithmetic control for the boundary price") + require(numbers["lower"] - numbers["capacity"] == numbers["excess"], "excess identity") + + +def main(): + check_charts() + check_helper_extension() + check_gate() + numbers = gate() + print( + "PASS_P104_LITERAL_HELPER_GATE " + f"charts=F2^{M} nonzero_mismatch=true " + f"helper_extension=identity helper_progress={numbers['helper_progress']} " + f"excess0={numbers['excess']} ports_n={numbers['ports_n']} " + "nonnegative_price=unfavorable no_new_kappa" + ) + + +if __name__ == "__main__": + main()