From 06dce843572376eb87a84eb4893db41eab4328e6 Mon Sep 17 00:00:00 2001 From: Ruge Lin Date: Tue, 3 Nov 2026 14:19:08 +0800 Subject: [PATCH 1/3] Add Watrous learning bridge and thirty-milestone map --- .github/workflows/hosted-math.yml | 43 +++ README.md | 8 +- learning/anchor.md | 104 ++++++ learning/milestones.md | 383 ++++++++++++++++++++ llms.txt | 9 +- references/references.bib | 11 + science/interpretation.md | 2 +- verification/README.md | 4 + verification/hosted/capture_hosted_math.cjs | 274 ++++++++++++++ verification/hosted/check_rendered_math.py | 370 +++++++++++++++++++ verification/references/hosted-rendering.md | 21 ++ 11 files changed, 1226 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/hosted-math.yml create mode 100644 learning/anchor.md create mode 100644 learning/milestones.md create mode 100644 verification/hosted/capture_hosted_math.cjs create mode 100644 verification/hosted/check_rendered_math.py create mode 100644 verification/references/hosted-rendering.md diff --git a/.github/workflows/hosted-math.yml b/.github/workflows/hosted-math.yml new file mode 100644 index 0000000..74d604d --- /dev/null +++ b/.github/workflows/hosted-math.yml @@ -0,0 +1,43 @@ +name: Hosted mathematics + +on: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + rendered-mathematics: + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + REVIEW_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ env.REVIEW_SHA }} + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '24' + package-manager-cache: false + - name: Install capture dependencies + run: | + npm install --prefix "$RUNNER_TEMP/hosted-dependencies" --ignore-scripts --no-audit --no-fund playwright@1.56.1 mathjax-full@3.2.1 + "$RUNNER_TEMP/hosted-dependencies/node_modules/.bin/playwright" install --with-deps chromium --only-shell + - name: Capture and compare actual GitHub mathematics + run: | + NODE_PATH="$RUNNER_TEMP/hosted-dependencies/node_modules" node verification/hosted/capture_hosted_math.cjs \ + --root "$GITHUB_WORKSPACE" \ + --repository "$GITHUB_REPOSITORY" \ + --revision "$REVIEW_SHA" \ + --output "$RUNNER_TEMP/hosted-capture" + - name: Retain review evidence + if: ${{ always() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: hosted-math-${{ env.REVIEW_SHA }} + path: ${{ runner.temp }}/hosted-capture + if-no-files-found: error + retention-days: 14 diff --git a/README.md b/README.md index ca42d98..76c090c 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,12 @@ The upper curve is a conservative converse bound, not the exact optimum. The rig The [science overview](science/README.md) connects the proof dependencies. The independent-use communication-capacity corollary is a separate consequence; it does not add operations inside a storage interval. +## Learn the project + +The educational anchor is John Watrous, *The Theory of Quantum Information* (2018). Start with the [bridge from Watrous to spectral memory](learning/anchor.md), which identifies the relevant sections, translates conventions and works through a small protected-coherence example. The [30-milestone map](learning/milestones.md) then connects 11 background milestones to 19 milestones developing the spectral law, calibrated compiler, evidence and physical interpretation. + +The map follows this project's scientific dependencies. Each milestone states an understanding target and points to the canonical proof or example; it does not require reading the entire textbook first. Readers already familiar with quantum channels can go directly to the [spectral law](science/spectral_law.md) and [encoder](science/encoder.md). + ## Reproduce the checks With Python 3.12, run from the repository root: @@ -75,7 +81,7 @@ The checks include exact rational band enumeration, Gaussian-matrix inequalities ## Scope -This is a result for one known common Gaussian noise direction. It assumes coefficients remain within supplied calibration certificates throughout storage. The core storage theorem treats boundary operations as ideal; a separate composable error budget explains what additional boundary accuracy suffices. Physical calibration cost, local noise, drift outside the certificate, geometric circuit locality and fault-tolerant hardware overhead are not determined by this model. +This is a result for one known common Gaussian noise direction. The true couplings are fixed during the storage interval and lie within the supplied calibration certificates. The core storage theorem treats boundary operations as ideal; a separate composable error budget explains what additional boundary accuracy suffices. Physical calibration cost, local noise, unmodeled time-dependent coupling drift, geometric circuit locality and fault-tolerant hardware overhead are not determined by this model. Approximate protected subspaces, high rates under exact collective symmetry, channel comparison methods, and reversible combinatorial encoding are established ideas. The specific contribution is their finite-spectrum occupancy characterization together with a calibrated compiler certified against unrestricted endpoint codes. The [related-work account](references/related_work.md) makes the comparisons explicit, including the earlier fixed-Hamming-weight amplitude encoder coauthored by Ruge Lin. diff --git a/learning/anchor.md b/learning/anchor.md new file mode 100644 index 0000000..98da1bb --- /dev/null +++ b/learning/anchor.md @@ -0,0 +1,104 @@ +# Selected anchor: Watrous (2018) + +A memory must preserve the relative phases in an unknown quantum state, including its correlations with another system. Under common-mode dephasing, nearby noise eigenvalues acquire nearly the same random phase. This project asks how much quantum information that observation can protect at a specified finite exposure, and whether an encoder achieving nearly the best possible size can actually be compiled. + +## Selected source and version + +The single educational anchor is **John Watrous, *The Theory of Quantum Information*, Cambridge University Press, 2018**, [DOI:10.1017/9781316848142](https://doi.org/10.1017/9781316848142). + +Use the [author's book page](https://jhwatrous.github.io/books-and-courses.html), [standard-layout manuscript PDF](https://jhwatrous.github.io/TQI.pdf), and [author's errata](https://jhwatrous.github.io/TQI.errata.pdf). The linked manuscript identifies itself as the 2018 pre-publication version; section references below follow that version. The official chapter PDFs are linked directly below. This repository provides links, without redistributing the manuscript. + +The linked errata are dated July 23, 2025; they include corrected norm-conversion constants in Theorems 3.56 and 8.45. The project's interval-error estimate is proved directly, without using those conversions. + +Watrous supplies the mathematical foundations. The project's spectral occupancy law and calibrated compiler require the additional arguments identified here. Primary papers in [Related work](../references/related_work.md) supply research attribution and theorem dependencies; they are separate from this one educational anchor. + +## Targeted reading map + +Consult the sections when their role becomes relevant; completing the whole book is unnecessary. The [30-milestone map](milestones.md) organizes the project's story rather than following textbook chapter order. + +| Project need | Watrous sections and official PDF | Connection to the project | +|---|---|---| +| Operators and matrix norms | §§1.1.2–1.1.3, [Chapter 1](https://jhwatrous.github.io/TQI.1.pdf) | Eigenvalues, positive operators, spectral norm and trace norm. | +| States and inaccessible references | §§2.1.2–2.1.3, [Chapter 2](https://jhwatrous.github.io/TQI.2.pdf) | Reduced states and purifications explain what the memory must preserve. | +| Channels and classical records | §2.2.2 and the instrument discussion in §2.3.2, [Chapter 2](https://jhwatrous.github.io/TQI.2.pdf) | Choi representations, isometries and branches of an encoder instrument. | +| Operational error | §§3.1.1, 3.2, 3.3.2–3.3.3, [Chapter 3](https://jhwatrous.github.io/TQI.3.pdf) | Trace distance, fidelity conventions and error stable under references. | +| Entrywise dephasing | §4.1.3, [Chapter 4](https://jhwatrous.github.io/TQI.4.pdf) | Recognize the Gaussian channel as a Schur channel. | +| Universal converse | §§6.1.1–6.1.2, [Chapter 6](https://jhwatrous.github.io/TQI.6.pdf) | Separability and local operations support the comparison argument. | +| Optional independent-use corollary | §5.2, [Chapter 5](https://jhwatrous.github.io/TQI.5.pdf); §§8.2.1–8.2.2, [Chapter 8](https://jhwatrous.github.io/TQI.8.pdf) | Entropy, coherent information and asymptotic quantum capacity. | + +The first six rows support background milestones M01–M11 and the one-register proof. The last row supports M28–M29 only. Dynamic programming and the explicit reversible compiler are supplied in [the construction](../science/encoder.md), not assigned to an unrelated textbook chapter. + +## Notation and operational translation + +| Convention | Translation used here | +|---|---| +| Vectors and adjoints | Watrous's $`u`$, $`uv^*`$, and $`B^*`$ correspond to $`\lvert u\rangle`$, $`\lvert u\rangle\langle v\rvert`$, and $`B^\dagger`$. | +| Choi normalization | Both use unnormalized $`J(\Phi)`$. A channel with input dimension $`d`$ has $`\operatorname{Tr}J(\Phi)=d`$; $`J(\Phi)/d`$ is its normalized Choi state. | +| Channel norm | Watrous's completely bounded trace norm, written with triple bars and subscript one, is our $`\lVert\Gamma\rVert_\diamond`$. Our error is **half** that norm: $`\frac12\lVert\Lambda-\operatorname{id}\rVert_\diamond`$. | +| Fidelity | Watrous defines $`F(\rho,\sigma)=\lVert\sqrt\rho\sqrt\sigma\rVert_1`$. Our $`F_e=\langle\Omega_D\rvert\rho_{\rm out}\lvert\Omega_D\rangle`$ is an overlap without a square root: $`F_e=F(\rho_{\rm out},\lvert\Omega_D\rangle\langle\Omega_D\rvert)^2`$. | +| Dimensions and qubits | $`d`$ is physical dimension, $`D`$ logical dimension, and $`\lfloor\log_2D\rfloor`$ whole logical qubits. The compiler uses band population $`N`$ and selects $`K=2^{\lfloor\log_2N\rfloor}`$ codewords. | +| Schur matrix and noise operator | The multiplier called $`A`$ in Watrous §4.1.3 corresponds to our $`G_t`$. Our Hermitian $`A`$ instead determines $`\mathcal L_A=-[A,[A,\cdot]]/2`$ and $`\Phi_t=e^{t\mathcal L_A}`$. | +| One register and capacity | $`D_\epsilon(t;A)`$ concerns one storage interval. $`Q(\Phi_t)`$ and $`Q_{\leftrightarrow}(\Phi_t)`$ concern asymptotically many independent complete uses, measured in qubits per use. | + +Explicitly, the Choi convention is + +```math +J(\Phi)=\sum_{i,j}\Phi(|i\rangle\langle j|)\otimes|i\rangle\langle j|. +``` + +Changing tensor-factor order requires a swap, not a normalization factor. The maximally entangled target $`|\Omega_D\rangle=D^{-1/2}\sum_a|a\rangle|a\rangle`$ is normalized. + +The [model](../science/model.md) permits a retained classical record and includes every instrument outcome. The true couplings are fixed throughout the storage interval. Only the physical memory survives quantumly through storage: no retained quantum workspace, bath record, preshared entanglement or intermediate intervention is supplied. The reference in the error criterion is inaccessible, not an extra storage resource. + +## Bridge from the book to the project + +**First, identify the finite-time geometry.** In an eigenbasis of the noise operator, + +```math +\Phi_t(X)=G_t\odot X,\qquad +(G_t)_{ij}=e^{-t(\lambda_i-\lambda_j)^2/2}. +``` + +For $`t\gt0`$, the dimensionless quantity $`t(\lambda_i-\lambda_j)^2`$ determines coherence attenuation. Counting eigenvectors in a width $`t^{-1/2}`$ interval gives $`M_t`$, with multiplicities included. This counts a near-degenerate cluster; exact degeneracy is unnecessary at finite time. The approximate occupancy theorem assumes $`0\lt\epsilon\lt1/4`$. + +**Second, turn a cluster into reference-stable protection.** Watrous's norm tools allow auxiliary systems, but a dimension-independent estimate still needs proof. [Lemma 1](../science/spectral_law.md#lemma-1-reference-stable-protection-of-a-spectral-interval) centers an interval of diameter $`a`$, bounds the double-commutator generator, and integrates its semigroup to obtain half-diamond error at most $`ta^2/4`$. Subdivision supplies a sufficiently narrow populated interval. Bounding individual matrix entries alone would not establish this channel guarantee. + +**Third, rule out better general encoders.** Choi positivity from Watrous §2.2.2 converts $`G_t\preceq\mu I`$, with $`\mu=\lambda_{\max}(G_t)`$, into $`\Phi_t\le_{\rm CP}\mu\Delta`$, where $`\Delta`$ completely dephases the eigenbasis. [Lemma 2](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records) propagates this order through arbitrary encoders and conditional recoveries. The comparison output is separable even with input-dependent classical records, so its maximally entangled overlap is at most $`1/D`$. Thus $`D\le\mu/(1-\epsilon)`$. The separate Gaussian row estimate gives $`\mu\le(2+\sqrt{2\pi})M_t`$. Together with protection, this proves $`\log_2D_\epsilon=\log_2M_t+O_\epsilon(1)`$ at fixed positive error. + +**Finally, make the code executable.** For $`A=\sum_jg_jN_j`$, with $`N_j=|1\rangle\langle1|_j`$, [the compiler](../science/encoder.md) rounds certified coefficient estimates to an exact dyadic grid. It finds a populated integer-sum band by dynamic programming, then coherently ranks and unranks accepted strings. Reversing intermediate computations cleans all temporary workspace before storage. Explicit lookup gates and bit arithmetic establish polynomial resources under the stated parameter scaling. The precision certificate is an input assumption, not a claim about calibration sample cost. + +This construction loses only a constant number of qubits relative to the all-code optimum at fixed error. Neither the occupancy theorem nor this calibration-to-circuit conclusion is attributed to the textbook. + +## Worked example: one logical qubit without an exact degeneracy + +Take two physical qubits with nominal operator + +```math +A=N_1+\frac{33}{32}N_2,\qquad t=16,\qquad\epsilon=\frac1{16}. +``` + +The eigenvalues are $`0,1,33/32,65/32`$. They are all distinct, but the middle pair lies within the resolution width $`1/\sqrt t=1/4`$, so $`M_t=2`$. + +Supply estimates $`(1,33/32)`$ with certified uncertainties $`u_1=u_2=1/256`$. The compiler chooses $`\delta=1/128`$, rounded weights $`(128,132)`$, and integer width $`B=4n=8`$. The smallest maximizing closed band is $`[124,132]`$. It selects $`|01\rangle,|10\rangle`$, giving population two and one logical qubit. + +Here the selected isometry has a direct two-gate realization. Starting with $`|\psi\rangle|0\rangle`$, a CNOT from qubit one to two followed by $`X`$ on qubit two implements + +```math +\alpha|0\rangle+\beta|1\rangle +\longmapsto\alpha|01\rangle+\beta|10\rangle. +``` + +The inverse gates decode after storage. Only the two physical qubits cross the interval; the second qubit returns to zero after decoding. + +At the nominal coefficients, the selected eigenvalue gap is $`1/32`$. The logical channel is exactly + +```math +\Lambda(\rho)=(1-p)\rho+pZ\rho Z,\qquad +p=\frac{1-e^{-1/128}}2\approx0.00389103. +``` + +Here $`Z=\operatorname{diag}(1,-1)`$ acts on the decoded logical qubit. Its half-diamond error is exactly $`p`$: the norm triangle inequality gives the upper bound, and input $`|+\rangle`$ attains it. Measuring that decoded input in the $`X`$ basis returns the minus outcome with probability $`p`$; a maximally entangled input has target overlap $`1-p`$. + +For every fixed coefficient vector consistent with the supplied certificates, the compiler's conservative storage bound is instead $`9\epsilon/16=9/256`$. The nominal exact value and robust bound answer different questions. This is finite-time approximate protection: the nondegenerate nominal operator has exact storage dimension one at every positive exposure, as [Proposition 2](../science/spectral_law.md#proposition-2-exact-storage-at-every-positive-time) establishes. The example demonstrates a functioning band code, without claiming its optimality from these small numbers alone. + +[Milestone map](milestones.md) · [Scientific overview](../science/README.md) · [Repository overview](../README.md) diff --git a/learning/milestones.md b/learning/milestones.md new file mode 100644 index 0000000..537295c --- /dev/null +++ b/learning/milestones.md @@ -0,0 +1,383 @@ +# Thirty milestones for Quantum Spectral Memory + +The map follows one question: how much unknown quantum information can a finite memory preserve during a prescribed interval of Gaussian dephasing, and how can a nearly optimal code be compiled from calibrated couplings? + +**Background/preliminaries contains M01–M11.** These eleven milestones connect individual coherences, reference systems, channel representations, admissible records and coherent encoding into the complete operational question. **Narrative/innovation contains M12–M30.** These nineteen milestones assemble the spectral converse and construction, then the finite-bit compiler, before integrating examples, limiting regimes and the separate communication corollary. The allocation reflects the project's two linked results: a characterization against arbitrary codes and an explicit implementation approaching that characterization. + +The sole educational anchor is John Watrous, *The Theory of Quantum Information* (2018), using the [author-hosted manuscript](https://jhwatrous.github.io/TQI.pdf). Section numbers below refer to that version. The [anchor bridge](anchor.md) translates its notation and provides a worked example. Watrous supplies the channel-theoretic foundations; the spectral estimates, calibration arithmetic and compiler arguments have their authoritative derivations in the linked scientific pages. This map identifies the main understanding targets without replacing those proofs. + +The true coupling vector is fixed throughout each storage interval. For calibrated compilation it lies within the supplied uncertainty certificates. Uniformity over those fixed vectors does not include unmodeled time-dependent coupling drift. + +## Phase I: Background/preliminaries — M01–M11 + +### M01: Coherence between noise eigenstates + +**Central question.** Which part of a quantum state is sensitive to the separation of two noise eigenvalues? + +**Understanding target.** Explain why populations remain fixed while an off-diagonal matrix element decays according to an eigenvalue difference. Identify the noise operator separately from a system Hamiltonian, and recognize why a scalar shift has no effect. + +**Dependencies and story role.** This is the local physical starting point for the spectral geometry. + +**Conceptual connection.** Matrix entries turn dephasing into a question about which coherences a code must retain. + +**Sources.** [Watrous §§1.1.2][W1], [2.1.2][W2]; [model, (M1)–(M3)](../science/model.md#gaussian-dephasing-on-one-finite-memory). + +### M02: A register and its inaccessible reference + +**Central question.** What must survive when the logical input is part of a larger entangled state? + +**Understanding target.** Distinguish the physical memory, logical register and inaccessible reference. Explain why preserving an isolated state's appearance does not establish preservation of its external correlations, and why the reference supplies no assistance to the encoder or decoder. + +**Dependencies and story role.** Builds on M01 by enlarging the object being preserved from matrix entries to a joint state. + +**Conceptual connection.** Purification makes storage quality a statement about information beyond the memory itself. + +**Sources.** [Watrous §§2.1.2–2.1.3][W2]; [model, allowed registers and (M6)](../science/model.md#error-criterion-and-stored-dimension). + +### M03: Channel representations and complete positivity + +**Central question.** How can one physical transformation be described through its action, Choi matrix and environment? + +**Understanding target.** Relate completely positive trace-preserving maps to positive Choi matrices and isometric dilations. Track the unnormalized Choi convention, whose trace equals the input dimension. Explain why positivity must persist when an inaccessible reference is included. + +**Dependencies and story role.** Uses M02 to supply the common language for both the converse and the later capacity corollary. + +**Conceptual connection.** A channel representation converts an operational claim into an operator inequality. + +**Sources.** [Watrous §2.2.2, Theorem 2.22][W2]; [spectral law, Lemma 2](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records). + +### M04: Classical records across a quantum storage interval + +**Central question.** How can a retained classical record depend on an unknown input without becoming a quantum bypass? + +**Understanding target.** Describe an encoding instrument, its subnormalized branches and conditional recovery. Explain why all outcomes contribute to a deterministic logical channel. Identify the physical memory as the only quantum carrier through the interval, including when temporary workspace is used at its boundaries. + +**Dependencies and story role.** Combines M02–M03 into the full admissible code class. + +**Conceptual connection.** Instruments distinguish classical side information from preserved quantum coherence and postselection. + +**Sources.** [Watrous §2.3.2][W2]; [model, (M4)–(M5) and workspace assumptions](../science/model.md#allowed-storage-codes). + +### M05: Half-diamond error and reference preservation + +**Central question.** Which channel distance certifies preservation uniformly over unknown, reference-entangled inputs? + +**Understanding target.** Interpret half the completely bounded trace norm as the project's error criterion. Connect it to output trace distance, composition with channels, and a lower bound on maximally entangled target overlap. Distinguish that overlap from Watrous's square-root fidelity convention. + +**Dependencies and story role.** Gives M02–M04 a quantitative success criterion usable by both constructions and converses. + +**Conceptual connection.** An operational distance makes separate error contributions composable. + +**Sources.** [Watrous §§3.1.1, 3.2, 3.3.2–3.3.3][W3]; [model, (M6)](../science/model.md#error-criterion-and-stored-dimension); [spectral law, (S12)](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records). + +### M06: Subspace encoding and trace-preserving recovery + +**Central question.** How does an isometric code become a valid storage protocol on the entire physical state space? + +**Understanding target.** Identify the code projector, embedding and inverse action on the code. Explain why recovery needs a trace-preserving extension outside that subspace, even when the specified dephasing preserves the encoded span. Relate this extension to the allowed channel model. + +**Dependencies and story role.** Uses M03–M05 to turn a candidate collection of eigenvectors into a complete protocol. + +**Conceptual connection.** A protected subspace and an admissible decoder are separate ingredients of achievability. + +**Sources.** [Watrous §2.2.2][W2]; [spectral law, Lemma 1 and (S7)](../science/spectral_law.md#lemma-1-reference-stable-protection-of-a-spectral-interval). + +### M07: Schur channels and complete dephasing + +**Central question.** What matrix describes how a diagonal-noise channel changes every coherence? + +**Understanding target.** Recognize entrywise multiplication by a positive semidefinite matrix with unit diagonal as a Schur channel. Identify complete dephasing as its diagonal comparator. Translate Watrous's Schur multiplier matrix, called $`A`$ there, into the project's $`G_t`$; the project's $`A`$ is instead the Hermitian coupling operator. + +**Dependencies and story role.** Connects M01 and M03 to the matrix structure needed for the converse. + +**Conceptual connection.** Correlation-matrix positivity packages the entire channel, including its action on references. + +**Sources.** [Watrous §4.1.3][W4]; [spectral law, (S2), Lemma 2](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records). + +### M08: Positive channel comparison and entanglement witnesses + +**Central question.** How can comparison with a simpler channel constrain every encoding strategy? + +**Understanding target.** Interpret completely positive order as positivity of the difference after adjoining any reference. Explain why complete dephasing produces a separable comparison state and why its overlap with a maximally entangled target of dimension $`D`$ is at most $`1/D`$. + +**Dependencies and story role.** Joins the Choi representation in M03, records in M04 and Schur structure in M07 into a converse mechanism. + +**Conceptual connection.** An entanglement witness converts channel domination into a dimension bound. + +**Sources.** [Watrous §2.2.2][W2], [§§6.1.1–6.1.2][W6]; [spectral law, (S9)–(S11)](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records). + +### M09: Logical dimension, whole qubits and resource accounting + +**Central question.** Which quantities measure storage size, and which measure the cost of realizing it? + +**Understanding target.** Distinguish a logical dimension $`D`$, its logarithm and the number of whole qubits obtained by taking a floor. Separate physical storage qubits from temporary workspace, classical table bits and gates. Recognize that a constant-qubit loss is a multiplicative dimension guarantee at fixed error. + +**Dependencies and story role.** Organizes the resources introduced in M04–M08 before the constructive result. + +**Conceptual connection.** Information-theoretic size and computational cost answer different questions about the same code. + +**Sources.** [Watrous §2.1.2][W2]; [model, (M7)–(M8)](../science/model.md#error-criterion-and-stored-dimension); [encoder, resource accounting](../science/encoder.md#4-rank-and-unrank-as-total-boolean-circuits). + +### M10: Coherent basis maps and temporary workspace + +**Central question.** When does a classical map between basis labels encode an arbitrary quantum register? + +**Understanding target.** Explain how an injective label map extends linearly to an isometry. Identify why residual label-dependent workspace would retain information about the input, and how a reversible computation can erase it. Distinguish this fixed transformation from preparing a state using classically supplied amplitudes. + +**Dependencies and story role.** Adds an implementation route to the subspace protocol in M06 and the resource distinctions in M09. + +**Conceptual connection.** Reversible classical logic can realize quantum encoding while preserving external entanglement. + +**Sources.** [Watrous §§2.1.3, 2.2.2][W2]; [encoder, clean isometry](../science/encoder.md#5-clean-coherent-isometry-and-decoding-channel). + +### M11: The complete finite-memory question + +**Central question.** What must a proposed storage theorem specify before its optimality or efficiency can be assessed? + +**Understanding target.** Assemble the fixed noise operator and exposure, physical carrier, allowed encoding instrument, terminal recovery, error tolerance and resource model. Distinguish the unrestricted optimization over endpoint channels from efficient implementation for explicitly given weighted-qubit couplings. + +**Dependencies and story role.** Integrates M01–M10 into the framework used by every subsequent result. + +**Conceptual connection.** Spectral geometry becomes a memory characterization only after the operational experiment and its resources are fixed. + +**Sources.** [Watrous §2.2.2][W2], [§3.3.3][W3]; [complete operational model](../science/model.md); [scientific dependencies](../science/README.md#main-logical-dependencies). + +## Phase II: Narrative/innovation — M12–M30 + +### M12: Spectral occupancy at the noise-resolution scale + +**Central question.** Which feature of a finite spectrum remains relevant before complete dephasing has occurred? + +**Understanding target.** Explain the resolution width $`t^{-1/2}`$ and the maximum occupancy $`M_t`$. Count eigenvalues with multiplicity, handle closed endpoints consistently, and distinguish a dense group of distinct levels from an exactly degenerate eigenspace. + +**Dependencies and story role.** Applies the complete model in M11 to identify the statistic that both sides of the theorem will use. + +**Conceptual connection.** The decay of a single coherence in M01 determines a scale for counting an entire spectrum. + +**Sources.** [Watrous §4.1.3][W4]; [model, (M9)](../science/model.md#spectral-occupancy); [spectral law, (S1)–(S3)](../science/spectral_law.md#theorem-1-one-register-storage). + +### M13: From spectral bandwidth to an achievable memory + +**Central question.** Why does a narrow spectral interval protect every state in its span, including reference correlations? + +**Understanding target.** Follow the role of centering the generator, bounding its diamond norm and integrating the semigroup. Explain how subdividing a maximally occupied resolution interval supplies a sufficiently narrow cell with a controlled population. + +**Dependencies and story role.** Combines M05–M06 with M12 to establish the constructive side of the occupancy law. + +**Conceptual connection.** A bandwidth estimate becomes a whole-channel guarantee, then an achievable logical dimension. + +**Sources.** [Watrous §§3.3.2–3.3.3][W3]; [Lemma 1, (S4)–(S7)](../science/spectral_law.md#lemma-1-reference-stable-protection-of-a-spectral-interval); [achievability](../science/spectral_law.md#achievability-in-theorem-1). + +### M14: The Gaussian Gram matrix as a channel comparator + +**Central question.** How does the largest eigenvalue of the Gaussian kernel bound the full noise channel? + +**Understanding target.** Identify the common Choi support on which the noise channel has matrix $`G_t`$ and complete dephasing has the identity matrix. Explain how a spectral matrix bound yields completely positive domination and survives adjoining an arbitrary reference. + +**Dependencies and story role.** Specializes M07–M08 to the Gaussian memory and supplies the algebraic input to the unrestricted converse. + +**Conceptual connection.** An operator-norm estimate controls an operational transformation, rather than only selected coherence entries. + +**Sources.** [Watrous §2.2.2][W2], [§4.1.3][W4]; [spectral law, (S9)](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records). + +### M15: The converse for arbitrary encoders and records + +**Central question.** Why does the comparator constrain mixed encoders and input-dependent retained records as well as subspace codes? + +**Understanding target.** Track subnormalized instrument branches through the positive comparison, conditional recovery and final sum. Explain normalization and separability of the comparison output, then combine its entangled overlap bound with the half-diamond success condition. + +**Dependencies and story role.** Uses M04–M05, M08 and M14 to extend the conclusion beyond the construction in M13. + +**Conceptual connection.** The theorem compares against all allowed endpoint codes without assuming their optimal encoder selects eigenvectors. + +**Sources.** [Watrous §2.3.2][W2], [§6.1.1][W6]; [Lemma 2, (S8)–(S12)](../science/spectral_law.md#lemma-2-a-converse-for-arbitrary-encoding-and-classical-records). + +### M16: Local row sums complete the uniform occupancy law + +**Central question.** How can local spectral counts bound a global Gaussian matrix independently of dimension? + +**Understanding target.** Explain the partition into intervals of one resolution width, the summable Gaussian envelope and the maximum-row-sum estimate. Combine this bound with M13 and M15 to obtain the fixed-error additive-constant characterization of stored logical qubits. + +**Dependencies and story role.** Integrates M12–M15 into the first principal result, including its uniformity and unoptimized constants. + +**Conceptual connection.** The same occupancy statistic certifies both a useful code and the limit of every allowed code. + +**Sources.** [Watrous §1.1.3][W1], [§4.1.3][W4]; [Lemma 3, (S13)–(S14)](../science/spectral_law.md#lemma-3-gaussian-row-sums-from-local-occupancy); [Theorem 1](../science/spectral_law.md#theorem-1-one-register-storage). + +### M17: The exact-error boundary and degeneracy + +**Central question.** Why does demanding zero error recover exact eigenspace multiplicity rather than finite-resolution occupancy? + +**Understanding target.** Explain the role of strict positivity of the distinct-level Gaussian kernel, its positive block-dephasing component, and extremality of the identity channel. Connect exact correction to the largest eigenspace dimension and distinguish this statement from taking the approximate theorem's constants to zero error. + +**Dependencies and story role.** Uses M03, M08 and M16 to identify a sharp boundary of the storage characterization. + +**Conceptual connection.** Approximate spectral proximity and exact noiseless structure support different operational guarantees. + +**Sources.** [Watrous §§2.2.2–2.2.4][W2]; [Proposition 2, (S15)](../science/spectral_law.md#proposition-2-exact-storage-at-every-positive-time). + +### M18: Certified couplings and an exact dyadic grid + +**Central question.** How can finite classical input certify a useful code for true couplings that need not be rational? + +**Understanding target.** Separate supplied estimates, uncertainty certificates and actual coefficients. Explain exact dyadic grid selection from rational exposure and error, the precision condition, and the accumulated energy discrepancy for a basis string. Identify the guarantee as uniform over each fixed coupling vector consistent with the certificates throughout storage. + +**Dependencies and story role.** Uses M09, M12 and M16 to turn the characterization into a finite-input construction. + +**Conceptual connection.** Calibration uncertainty determines which spectral-band argument remains physically valid. + +**Sources.** [Watrous §1.1.2][W1]; [encoder, §1 and (2)–(7)](../science/encoder.md#1-exact-dyadic-grid-selection). + +### M19: Signed weights and the optimal closed band + +**Central question.** How does the rounded spectrum become an exact counting problem without losing negative weights or degeneracies? + +**Understanding target.** Explain the known bit flips that replace signed weights by nonnegative ones. Preserve zero-weight multiplicities and distinguish an integer band's diameter from its number of integer values. Identify the deterministic maximizing band and the power-of-two subset used for logical qubits. + +**Dependencies and story role.** Converts M18's calibration statement into the discrete object the compiler will count. + +**Conceptual connection.** A unitary relabeling preserves the physical problem while simplifying classical arithmetic. + +**Sources.** [Watrous §2.2.2][W2]; [encoder, §2 and (8)–(10)](../science/encoder.md#2-signed-weights-and-the-optimal-closed-band). + +### M20: Physical protection and constant-qubit optimality + +**Central question.** Why is the chosen rounded band protected and close to the true unrestricted optimum? + +**Understanding target.** Combine rounded bandwidth with calibration discrepancy to bound the true spectral diameter. Explain why every sufficiently narrow true interval fits an allowed rounded band, then connect its population to the occupancy converse. Track the additional loss when taking a power-of-two code dimension. + +**Dependencies and story role.** Joins M13, M16 and M18–M19 to certify the construction before its implementation. + +**Conceptual connection.** The same uncertainty bound controls both storage error and instance-wise optimality. + +**Sources.** [Watrous §3.3.2][W3]; [encoder, (11)–(13)](../science/encoder.md#storage-error); [constant-qubit guarantee](../science/encoder.md#constant-qubit-optimality). + +### M21: Counting accepted suffixes exactly + +**Central question.** How can the compiler count an exponentially large set without listing its members? + +**Understanding target.** Interpret suffix subset-sum counts and their recurrence, then explain how prefix sums count accepted completions of a partial string. Track the bit width of counts, including zero weights and the all-strings case, and the cost of finding the maximizing closed band. + +**Dependencies and story role.** Implements the discrete search defined in M19 while preserving the certificate in M20. + +**Conceptual connection.** Exact counting supplies a compact description from which coherent codeword selection can be constructed. + +**Sources.** [Watrous §2.1.2][W2] for basis labels; [encoder, §3 and (14)–(16)](../science/encoder.md#3-exact-classical-preprocessing). + +### M22: Ranking and unranking without listing codewords + +**Central question.** How do accepted-completion counts provide reversible access to the selected codewords? + +**Understanding target.** Explain how unranking chooses each next bit and how ranking accumulates preceding accepted strings. Identify their inverse relation on the selected code, and why total Boolean extensions outside that set are sufficient for circuit construction without becoming inverse there. + +**Dependencies and story role.** Uses M10 and M21 to replace a population certificate by explicit maps on logical labels. + +**Conceptual connection.** A compact classical description becomes an amplitude-independent quantum encoding route. + +**Sources.** [Watrous §2.2.2][W2] for isometries; [encoder, rank/unrank construction](../science/encoder.md#4-rank-and-unrank-as-total-boolean-circuits). + +### M23: Compiled lookups and charged polynomial resources + +**Central question.** Which operations and storage must be counted before the compiler can be called efficient? + +**Understanding target.** Explain equality-controlled table scans and explicit arithmetic gates without a unit-cost quantum-memory oracle. Account for table bits, count widths, emitted gates, work qubits and the circuit description. Relate polynomial cost to the integer sum range and distinguish polynomial exposure from polynomial dependence on its bit length. + +**Dependencies and story role.** Attaches an implementation cost to M21–M22 using M09's resource distinctions. + +**Conceptual connection.** An efficiently specified isometry requires an explicit computational realization. + +**Sources.** [Watrous §2.2.2][W2]; [encoder, (7), (16)–(18) and compilation costs](../science/encoder.md#4-rank-and-unrank-as-total-boolean-circuits). + +### M24: A clean unknown-register isometry and decoder + +**Central question.** How is the logical input transferred completely into the physical code before storage? + +**Understanding target.** Explain compute-copy-uncompute, followed by ranking to erase the original logical label. Identify the resulting phase-free basis permutation and its linear action on reference-entangled states. Follow inverse decoding on the invariant code span and the full trace-preserving channel obtained by discarding non-output registers. + +**Dependencies and story role.** Integrates M06, M10 and M21–M23 into the actual quantum implementation. + +**Conceptual connection.** Workspace cleanup enforces the physical-memory constraint, rather than merely improving memory usage. + +**Sources.** [Watrous §§2.1.3, 2.2.2][W2]; [encoder, §5 and (19)–(20)](../science/encoder.md#5-clean-coherent-isometry-and-decoding-channel). + +### M25: Composing storage and boundary-operation errors + +**Central question.** How does the ideal storage certificate survive imperfect encoding and decoding? + +**Understanding target.** Combine half-diamond errors using channel contractivity and the triangle inequality. Identify the reserved boundary-operation budget and how operation-level errors may be summed when they are composable. Include discarded imperfect workspace and noisy initialization in the appropriate boundary channel. + +**Dependencies and story role.** Connects M05, M20 and M24 to an explicit total-error statement. + +**Conceptual connection.** A mathematical storage guarantee and an implementation-error assumption fit into the same channel metric; neither determines hardware overhead by itself. + +**Sources.** [Watrous §§3.3.2–3.3.3][W3]; [encoder, §6 and (21)–(23)](../science/encoder.md#6-composable-implementation-error-budget). + +### M26: What the examples and primitive circuits establish + +**Central question.** Which aspects of the result become visible in a small code, a larger spectrum and executable circuits? + +**Understanding target.** Connect the two-qubit worked example to the nondegenerate 16-qubit bands and the small primitive-gate checks. Distinguish exact arithmetic, tested state errors, analytic channel bounds and a conservative converse ceiling. Explain what enumeration verifies and why the general compiler avoids that enumeration. + +**Dependencies and story role.** Brings M12–M25 together in concrete instances while keeping the evidence levels explicit. + +**Conceptual connection.** Examples expose the mechanism and implementation; uniform claims retain their analytical proofs. + +**Sources.** [Watrous §§3.2–3.3][W3]; [worked example](anchor.md#worked-example-one-logical-qubit-without-an-exact-degeneracy); [examples](../science/examples.md); [verification limits](../verification/README.md#what-the-checks-do-not-establish). + +### M27: Variance, extensive storage and the order of limits + +**Central question.** How can nearly all qubits remain storable at polynomial exposures while each fixed nondegenerate register eventually loses its memory? + +**Understanding target.** Connect spectral variance, concentration and occupancy to the extensive-rate bound. Distinguish a growing family of registers at prescribed exposures from infinite time at fixed dimension. Relate homogeneous fixed-weight sectors and Proposition 2 to these approximate finite-time conclusions. + +**Dependencies and story role.** Synthesizes M16–M17, M20 and M26 into the main storage interpretation. + +**Conceptual connection.** The limiting noiseless algebra and finite-resolution spectral population answer different asymptotic questions. + +**Sources.** [Watrous §4.1.3][W4]; [variance bound, (I2)–(I4)](../science/interpretation.md#a-rate-bound-from-spectral-variance); [infinite-time limit, (I5)](../science/interpretation.md#finite-time-and-the-infinite-time-algebra). + +### M28: Independent-use achievability from environmental entropy + +**Central question.** What additional communication statement follows when complete memory channels are used independently? + +**Understanding target.** Define the new experiment with fresh noise for every complete use. Explain the coherent-state dilation, displacement to the occupied interval's midpoint, environmental entropy bound and coherent-information achievable rate. Recognize the oscillator as a mathematical representation, without imposing a physical bath-energy constraint. + +**Dependencies and story role.** Uses M03, M12 and M16 for a separate corollary, beyond the single-interval storage theorem. + +**Conceptual connection.** Limited environmental distinguishability turns spectral crowding into an asymptotic communication rate. + +**Sources.** [Watrous §5.2][W5], [§8.2.2][W8]; [interpretation, (I7)–(I10) and Devetak attribution](../science/interpretation.md#lower-bound-and-coherent-state-normalization). + +### M29: Adaptive classical assistance and the converse rate + +**Central question.** How does the one-use comparator constrain protocols with classical communication between independent uses? + +**Understanding target.** Follow successive channel replacements through an adaptive deterministic protocol. Explain why the comparison output remains separable without initial shared entanglement, and how its target overlap yields an exponentially vanishing fidelity above the bound. Distinguish this rate bound from equality of assisted and unassisted capacities. + +**Dependencies and story role.** Combines M08, M14–M15 and M28 to complete the independent-use corollary. + +**Conceptual connection.** Complete positivity allows the same comparison argument to survive arbitrary permitted inter-use processing. + +**Sources.** [Watrous §6.1.2][W6], [§8.2.1][W8]; [interpretation, (I11)–(I12)](../science/interpretation.md#upper-bound-for-adaptive-classical-assistance). + +### M30: The combined contribution and its physical scope + +**Central question.** What does the occupancy law together with the calibrated compiler establish about this memory model? + +**Understanding target.** Connect arbitrary-code optimality, finite-input construction and clean quantum implementation into one instance-wise guarantee. Separate the unrestricted spectral theorem from its efficient weighted-qubit realization, fixed-error conclusions from exact storage, and single-interval storage from independent-use communication. Identify inherited techniques and the assumptions needed for a physical application. + +**Dependencies and story role.** Integrates M11–M29 into the project's complete scientific claim. + +**Conceptual connection.** Finite spectral resolution replaces exact degeneracy as the useful organizing quantity for approximate storage. + +**Sources.** [Watrous §3.3.3][W3], [§8.2.1][W8]; [scientific synthesis](../science/README.md); [specific contribution and limits](../references/related_work.md#what-remains-after-these-comparisons). + +[Scientific account](../science/README.md) · [Anchor and bridge](anchor.md) · [Repository overview](../README.md) + +[W1]: https://jhwatrous.github.io/TQI.1.pdf +[W2]: https://jhwatrous.github.io/TQI.2.pdf +[W3]: https://jhwatrous.github.io/TQI.3.pdf +[W4]: https://jhwatrous.github.io/TQI.4.pdf +[W5]: https://jhwatrous.github.io/TQI.5.pdf +[W6]: https://jhwatrous.github.io/TQI.6.pdf +[W8]: https://jhwatrous.github.io/TQI.8.pdf diff --git a/llms.txt b/llms.txt index 737925d..8ff7dc7 100644 --- a/llms.txt +++ b/llms.txt @@ -2,6 +2,13 @@ > Finite-time Gaussian dephasing: an arbitrary-spectrum storage law and a calibrated reversible compiler for weighted qubit registers. +## Reading routes + +- Story: start with [README](README.md), then [model](science/model.md), [examples](science/examples.md) and [interpretation](science/interpretation.md). +- Study: use the single [Watrous anchor and bridge](learning/anchor.md), then the [30-milestone map](learning/milestones.md). The map progresses from local concepts to the complete framework in M01–M11 and from proof and compiler components to the combined result in M12–M30. +- Theorem: [operational definitions](science/model.md), [spectral law and proof](science/spectral_law.md), then [calibrated compiler and resource bounds](science/encoder.md). +- Reproduction: [verification guide](verification/README.md), [exact compiler](verification/band_code.py), [primitive reversible circuits](verification/verify_reversible_encoder.py) and [generated examples](verification/generate_examples.py). + ## Scientific entry points - [Overview](README.md): question, principal results, scope and reproduction commands. @@ -24,4 +31,4 @@ ## Reading cautions -The unrestricted occupancy theorem does not assert efficient diagonalization. The efficient construction requires the supplied weighted-qubit form and certified calibration. Fixed-error constant-qubit optimality is distinct from accuracy-dependent bounds. The independent-use capacity result does not permit interventions inside a storage interval. The repository establishes a mathematical and algorithmic guarantee, not hardware memory advantage. +The unrestricted occupancy theorem does not assert efficient diagonalization. The efficient construction requires the supplied weighted-qubit form, fixed true couplings and certified calibration. Fixed-error constant-qubit optimality is distinct from accuracy-dependent bounds. The independent-use capacity result does not permit interventions inside a storage interval. The repository establishes a mathematical and algorithmic guarantee, not hardware memory advantage. The shared learning material describes the project's understanding targets; it contains no reader assessment or personal progress record. diff --git a/references/references.bib b/references/references.bib index fa4c2c2..086b8bc 100644 --- a/references/references.bib +++ b/references/references.bib @@ -203,6 +203,17 @@ @article{DArrigoBenentiFalci2007DephasingMemory url = {https://arxiv.org/abs/quant-ph/0703014} } +% Selected educational anchor. +@book{Watrous2018TheoryQuantumInformation, + author = {Watrous, John}, + title = {The Theory of Quantum Information}, + publisher = {Cambridge University Press}, + year = {2018}, + doi = {10.1017/9781316848142}, + url = {https://jhwatrous.github.io/TQI.pdf}, + note = {Educational anchor; section references follow the author's 2018 pre-publication version} +} + % Pinned internal benchmark: a repository source, not a journal publication. @misc{BosonicPhaseMemoryExactBenchmark, author = {{GoGoKo699}}, diff --git a/science/interpretation.md b/science/interpretation.md index c65a822..8c6c36e 100644 --- a/science/interpretation.md +++ b/science/interpretation.md @@ -49,7 +49,7 @@ For the finite dyadic construction one may use $`k=\lceil4/\sqrt\epsilon\rceil`$ \tag{I4} ``` -The compiler is polynomial for bounded couplings, polynomial $`t`$, and inverse-polynomial error tolerance. It is not asserted polynomial in the bit length of $`t`$. Required calibration accuracy is an input assumption; the number of bits specifying the estimates is not the physical cost of obtaining them. Temporary encoder workspace is cleaned before storage; decoder workspace is introduced only after storage and is discarded after recovery. Independent local noise, coupling drift beyond the stated certificate, and imperfect boundary operations require separate models and are not included in these guarantees. +The compiler is polynomial for bounded couplings, polynomial $`t`$, and inverse-polynomial error tolerance. It is not asserted polynomial in the bit length of $`t`$. The true couplings are fixed during the storage interval and lie within the supplied calibration certificates. Required calibration accuracy is an input assumption; the number of bits specifying the estimates is not the physical cost of obtaining them. Temporary encoder workspace is cleaned before storage; decoder workspace is introduced only after storage and is discarded after recovery. Independent local noise, unmodeled time-dependent coupling drift, and imperfect boundary operations require separate models and are not included in these guarantees; the [boundary-error budget](encoder.md#6-composable-implementation-error-budget) gives a separate composable extension for the last item. High rates for homogeneous collective dephasing already follow from exact noiseless sectors. For example, the perfect-memory limit in D'Arrigo, Benenti and Falci, [arXiv:quant-ph/0703014v3](https://arxiv.org/html/quant-ph/0703014v3), Section 3.3, uses the equal-weight sector with dimension of order $`2^n/\sqrt n`$. Here the occupancy law and the calibrated construction apply to unequal bounded weights, including cases without exact spectral degeneracy. diff --git a/verification/README.md b/verification/README.md index 4cd6b44..4272685 100644 --- a/verification/README.md +++ b/verification/README.md @@ -60,6 +60,10 @@ Grid selection, integer counts, rounding, codewords, gate permutations, bandwidt The example-generation script writes `results/examples.json` and the PNG/SVG figures under `figures/`. It verifies distinctness of the 65,536 exactly specified rational eigenvalues and reproduces the 16-qubit table in [the scientific examples](../science/examples.md). Those examples do not replace the mandatory checks above. +## Displayed mathematics + +The separate [GitHub rendering check](references/hosted-rendering.md) compares the actual hosted MathML with the pinned Markdown source at two viewport widths and captures screenshots for visual review. It checks presentation, independently of the numerical and circuit evidence above. + ## What the checks do not establish The analytical arguments establish the uniform spectral theorem, the unrestricted converse, the calibration guarantee, and the asymptotic resource bounds. Finite tests support the implementation and expose arithmetic or cleanup errors; they are not substitutes for those proofs. The tested state trace distances lie below the analytic bandwidth bound, but the script does not numerically optimize the unrestricted diamond norm. diff --git a/verification/hosted/capture_hosted_math.cjs b/verification/hosted/capture_hosted_math.cjs new file mode 100644 index 0000000..bd075f4 --- /dev/null +++ b/verification/hosted/capture_hosted_math.cjs @@ -0,0 +1,274 @@ +#!/usr/bin/env node +'use strict'; +// Read-only collector for the real GitHub host. See ../references/hosted-rendering.md. +// Importing this module has no network effects; dependencies load only in run(). +const fs = require('node:fs'); +const path = require('node:path'); +const cp = require('node:child_process'); +const crypto = require('node:crypto'); +const VIEWPORTS = [{width:1440,height:1000}, {width:760,height:1000}]; +const sha256 = bytes => crypto.createHash('sha256').update(bytes).digest('hex'); + +function argumentsFor(argv) { + const args = {pages:[], python:'python3'}; + for (let i=0; i['.','..'].includes(p))) throw new Error('Use exact owner/name'); + if (!/^[a-f0-9]{40}$/.test(args.revision)) throw new Error('Use a full lowercase commit SHA'); + if (new Set(args.pages).size!==args.pages.length || args.pages.some(p=>!safePath(p))) throw new Error('Use unique safe page paths'); + return args; +} +function safePath(p) { + return typeof p==='string' && p.length>0 && !p.includes('\\') && !p.includes('\0') && + !p.startsWith('/') && p.split('/').every(x=>x && x!=='.' && x!=='..'); +} +function git(root, argv) { + return cp.execFileSync('git',['--no-replace-objects',...argv],{cwd:root,encoding:'utf8',maxBuffer:32*1024*1024}); +} +function pinnedPages(args) { + const commit=git(args.root,['rev-parse',args.revision+'^{commit}']).trim(); + if (commit!==args.revision) throw new Error('Revision does not identify the supplied commit'); + const files=git(args.root,['ls-tree','-r','--name-only','-z',commit]).split('\0').filter(Boolean); + const pages=args.pages.length?args.pages:files.filter(p=>/\.(md|markdown|mdown|mkdn|mkd)$/i.test(p)); + if (!pages.length || pages.some(p=>!safePath(p) || !files.includes(p))) throw new Error('No pages or a page is absent from the pinned tree'); + // Git symlinks are not rendered Markdown source and must not be followed. + for (const p of pages) { + const item=git(args.root,['ls-tree',commit,'--',p]); + if (!/^100644 blob |^100755 blob /.test(item)) throw new Error('Page must be a regular tracked file: '+p); + } + return {pages,tree:git(args.root,['rev-parse',commit+'^{tree}']).trim()}; +} +function mathCompiler() { + const {mathjax}=require('mathjax-full/js/mathjax.js'); + const {TeX}=require('mathjax-full/js/input/tex.js'); + const {SVG}=require('mathjax-full/js/output/svg.js'); + const {liteAdaptor}=require('mathjax-full/js/adaptors/liteAdaptor.js'); + const {RegisterHTMLHandler}=require('mathjax-full/js/handlers/html.js'); + const {AllPackages}=require('mathjax-full/js/input/tex/AllPackages.js'); + const {SerializedMmlVisitor}=require('mathjax-full/js/core/MmlTree/SerializedMmlVisitor.js'); + const {STATE}=require('mathjax-full/js/core/MathItem.js'); + RegisterHTMLHandler(liteAdaptor()); + const doc=mathjax.document('',{InputJax:new TeX({packages:AllPackages,tags:'none'}),OutputJax:new SVG({fontCache:'none'})}); + const visitor=new SerializedMmlVisitor(); + return (tex,display)=>visitor.visitTree(doc.convert(tex,{display,end:STATE.CONVERT})); +} + +// Self-contained function executed inside the hosted page, also exercised by the +// local-browser regression fixture. It never injects styling or renders TeX there. +function inspectArticle(root, expected) { + function canonical(e, inherited='') { + const tag=e.localName; + if (['annotation','annotation-xml','mspace'].includes(tag)) return []; + const variant=e.getAttribute('mathvariant') || inherited; + if (['mi','mo','mn','mtext','ms'].includes(tag)) { + const text=e.textContent.trim(); + return text?[[tag,text,variant]]:[]; + } + // Preserve each structural child slot: flattening numerator and denominator + // together would confuse (a+b)/c with a/(b+c), and similarly for scripts. + const children=[...e.children].filter(c=>!['annotation','annotation-xml','mspace'].includes(c.localName)) + .map(c=>canonical(c,variant)); + if (['math','mrow','mstyle','semantics'].includes(tag)) return children.flat(); + const semantic={}; + for (const name of ['notation','accent','accentunder','linethickness','bevelled','open','close','separators']) if(e.hasAttribute(name)) semantic[name]=e.getAttribute(name); + // A table cell is an inferred row (a sequence), not a fixed-arity operator. + // GitHub inserts empty mrow alignment nodes; ignore those inside the cell + // while preserving the cell and row themselves, including empty cells. + return [[tag,semantic,tag==='mtd'?children.flat():children]]; + } + function plain(math) { + const copy=math.cloneNode(true); + for (const e of copy.querySelectorAll('annotation,annotation-xml')) e.remove(); + return copy.textContent; + } + function geometry(math, host) { + const boxes=[...math.querySelectorAll('mi,mo,mn,mtext,ms')].map(e=>e.getBoundingClientRect()).filter(b=>b.width && b.height); + if (!boxes.length) return {measurable:false}; + const left=Math.min(...boxes.map(b=>b.left)),right=Math.max(...boxes.map(b=>b.right)); + const top=Math.min(...boxes.map(b=>b.top)),bottom=Math.max(...boxes.map(b=>b.bottom)); + const width=right-left,height=bottom-top; + return {measurable:true,width,height,available_width:root.clientWidth, + overflow:width>root.clientWidth+4,collapsed:height>Math.max(200,3*width),host_width:host.getBoundingClientRect().width}; + } + let hosts=[...root.querySelectorAll('math-renderer')]; + // Some host versions expose native MathML without a custom-element wrapper. + if (!hosts.length) hosts=[...root.querySelectorAll('math')].filter(e=>!e.parentElement?.closest('math,annotation,annotation-xml')); + const pageErrors=[...root.querySelectorAll('merror,[data-mjx-error],.katex-error,math-renderer .flash-error')] + .map(e=>e.textContent.trim() || 'empty renderer error'); + const math=hosts.map((host,i)=>{ + const nodes=host.localName==='math'?[host]:[...host.querySelectorAll('math')].filter(e=>!e.parentElement?.closest('math,annotation,annotation-xml')); + const errors=[]; + if(nodes.length!==1) errors.push('Expected one accessible MathML representation; found '+nodes.length); + const actual=nodes[0],want=expected[i]; + let expectedSignature=null,actualSignature=null; + if(actual) actualSignature=JSON.stringify(canonical(actual)); + if(want) { + const parsed=new DOMParser().parseFromString(want.mml,'application/xml'); + if(parsed.querySelector('parsererror,merror')) errors.push('Source compiler returned invalid/error MathML'); + else expectedSignature=JSON.stringify(canonical(parsed.documentElement)); + } + if(!want) errors.push('Unexpected extra hosted expression'); + const match=!!actual && !!expectedSignature && expectedSignature===actualSignature; + if(!match) errors.push('Source-to-host MathML structure mismatch'); + const measure=actual?geometry(actual,host):{measurable:false}; + if(want && ['math-fence','dollar-display'].includes(want.kind) && (!measure.measurable || measure.overflow || measure.collapsed)) + errors.push('Display geometry is unmeasurable, overflowing or collapsed'); + return {rendered:!!actual,errors,text_source:'mathml',text:actual?plain(actual):'', + source_sha256:want?.source_sha256,structural_match:match, + expected_signature:expectedSignature,actual_signature:actualSignature,geometry:measure}; + }); + return {errors:pageErrors,math}; +} + +function classifyFailure(error) { + const message=String(error); + if (/ERR_BLOCKED_BY_ADMINISTRATOR|blocked by.*policy|URLBlocklist|policy denied/i.test(message)) return 'policy_denied'; + if (/HTTP (401|403)|redirected away|sign.in|authentication/i.test(message)) return 'access_required'; + if (/Cannot find module|Executable doesn't exist|browser executable/i.test(message)) return 'capability_unavailable'; + if (/ERR_NAME_NOT_RESOLVED|ENOTFOUND|ERR_CONNECTION|ERR_EMPTY_RESPONSE|ERR_INTERNET_DISCONNECTED|ECONNRESET|Timeout|timed out/i.test(message)) return 'transport_failure'; + return 'verification_failure'; +} +function writeJSON(filename, value) {fs.writeFileSync(filename,JSON.stringify(value,null,2)+'\n');} +function artifact(directory, relative, kind) { + const bytes=fs.readFileSync(path.join(directory,relative)); + return {path:relative,sha256:sha256(bytes),size_bytes:bytes.length,kind}; +} +function boundReport(inventory, tree, viewports, artifacts, failures, at) { + const boundaries=inventory.pages.map(p=>{ + const counts=viewports.map(v=>v.boundaries?.find(b=>b.path===p.path)?.captured_hosts); + return {path:p.path,url:p.url,revision:inventory.revision,source_sha256:p.source_sha256, + source_expressions:p.expressions.length, + captured_hosts:counts.length===VIEWPORTS.length && counts.every(n=>Number.isInteger(n) && n===counts[0])?counts[0]:null}; + }); + const wanted=inventory.pages.reduce((n,p)=>n+p.expressions.length,0); + failures=[...failures]; + if(JSON.stringify(viewports.map(v=>({width:v.width,height:v.height})))!==JSON.stringify(VIEWPORTS)) + failures.push('Missing, duplicate or unexpected viewport coverage'); + for(const viewport of viewports) { + if(JSON.stringify((viewport.boundaries||[]).map(b=>b.path))!==JSON.stringify(inventory.pages.map(p=>p.path))) + failures.push(viewport.width+': page coverage differs from inventory'); + for(const source of inventory.pages) { + const boundary=viewport.boundaries?.find(b=>b.path===source.path); + if(!boundary || boundary.source_sha256!==source.source_sha256 || boundary.revision!==inventory.revision || + boundary.url!==source.url || boundary.source_expressions!==source.expressions.length || boundary.captured_hosts!==source.expressions.length) + failures.push(viewport.width+': incomplete source/host coverage for '+source.path); + } + } + const structural=viewports.length===VIEWPORTS.length && viewports.every(v=>v.structural_matches===wanted); + const pass=!failures.length && structural && viewports.length===VIEWPORTS.length && viewports.every(v=>v.status==='pass'); + return {schema_version:1,kind:'hosted_math',repository:inventory.repository,revision:inventory.revision,tree, + renderer_profile:'github',captured_at:at,capture_method:'playwright-github',status:pass?'pass':'fail', + required_pages:inventory.pages.map(p=>p.path),boundaries,viewports,artifacts,failures, + structural_comparison:{status:structural?'pass':'fail',expressions_checked:structural?wanted:0}, + visual_review_required:true, + limits:'Observed GitHub MathML structure, counts, labels, relations and bounded geometry only. No independent scientific proof, exhaustive pixel review, host authenticity certificate or cross-browser guarantee.'}; +} + +async function run(args) { + const output=path.resolve(args.output); + if(fs.existsSync(output) && fs.readdirSync(output).length) throw new Error('Use an empty output directory; preserve earlier failed evidence'); + fs.mkdirSync(output,{recursive:true}); + const pinned=pinnedPages(args); + const helper=path.join(__dirname,'check_rendered_math.py'); + cp.execFileSync(args.python,[helper,'inventory','--root',args.root,'--repository',args.repository, + '--revision',args.revision,...pinned.pages.flatMap(p=>['--page',p]),'--output',path.join(output,'math-source.json')],{stdio:'pipe'}); + const inventory=JSON.parse(fs.readFileSync(path.join(output,'math-source.json'),'utf8')); + const at=new Date().toISOString(),failures=[],artifacts=[artifact(output,'math-source.json','source_inventory')],viewports=[]; + let browser; + const runtime={node:process.version}; + if(args.contract) { + fs.copyFileSync(path.resolve(args.contract),path.join(output,'math-contract.json')); + artifacts.push(artifact(output,'math-contract.json','text_contract')); + } + try { + const {chromium}=require('playwright'); + runtime.playwright=require('playwright/package.json').version; + runtime.mathjax=require('mathjax-full/package.json').version; + const compile=mathCompiler(); + const expected=Object.fromEntries(inventory.pages.map(p=>[p.path,p.expressions.map(e=>({...e, + mml:compile(e.tex,['math-fence','dollar-display'].includes(e.kind))}))])); + writeJSON(path.join(output,'expected-mathml.json'),expected); + artifacts.push(artifact(output,'expected-mathml.json','expected_mathml')); + browser=await chromium.launch({headless:true}); + runtime.browser=browser.version(); + for(const viewport of VIEWPORTS) { + const context=await browser.newContext({viewport,deviceScaleFactor:1,colorScheme:'light'}); + const capture={schema_version:1,repository:args.repository,revision:args.revision,renderer_profile:'github', + captured_at:at,capture_method:'playwright-github',pages:[]}; + let fatal=false; + try { + for(let index=0;index{ + for(let y=0,steps=0;ysetTimeout(r,50)); + } + window.scrollTo(0,0); + }); + await page.waitForTimeout(1000); + Object.assign(item,await article.evaluate(inspectArticle,expected[source.path])); + const html=prefix+'.html',png=prefix+'.png'; + fs.writeFileSync(path.join(output,html),await page.content()); + await page.screenshot({path:path.join(output,png),fullPage:true,timeout:30000}); + artifacts.push(artifact(output,html,'hosted_html'),artifact(output,png,'screenshot')); + item.artifacts={html,screenshot:png}; + } catch(error) { + item.errors.push(String(error)); + const category=classifyFailure(error); + failures.push(source.path+' at '+viewport.width+': '+category+': '+String(error)); + // Do not seek another route after an access or policy block. + fatal=['policy_denied','access_required','transport_failure'].includes(category); + } finally {capture.pages.push(item);await page.close();} + if(fatal) break; + } + } finally {await context.close();} + const captureFile='math-capture-'+viewport.width+'.json',resultFile='math-result-'+viewport.width+'.json'; + writeJSON(path.join(output,captureFile),capture);artifacts.push(artifact(output,captureFile,'hosted_capture')); + const command=[helper,'check','--inventory',path.join(output,'math-source.json'),'--capture',path.join(output,captureFile), + '--output',path.join(output,resultFile)]; + if(args.contract) command.push('--contract',path.resolve(args.contract)); + const check=cp.spawnSync(args.python,command,{encoding:'utf8'}); + if(check.error || !fs.existsSync(path.join(output,resultFile))) throw new Error('Math checker did not produce a result: '+(check.error||check.stderr)); + const result=JSON.parse(fs.readFileSync(path.join(output,resultFile),'utf8')); + artifacts.push(artifact(output,resultFile,'math_result')); + failures.push(...result.failures.map(f=>viewport.width+': '+f)); + const matches=capture.pages.reduce((n,p)=>n+p.math.filter(m=>m.structural_match && !m.errors.length).length,0); + viewports.push({...viewport,status:result.status,structural_matches:matches,capture_path:captureFile,result_path:resultFile,boundaries:result.boundaries}); + if(fatal) break; + } + } catch(error) {failures.push(classifyFailure(error)+': '+String(error));} + finally {if(browser) await browser.close();} + const report={...boundReport(inventory,pinned.tree,viewports,artifacts,failures,at),runtime}; + writeJSON(path.join(output,'hosted-report.json'),report); + console.log(JSON.stringify({status:report.status,report:path.join(output,'hosted-report.json'),sha256:sha256(fs.readFileSync(path.join(output,'hosted-report.json'))),pages:report.required_pages.length,failures:report.failures.length})); + return report.status==='pass'?0:1; +} +module.exports={argumentsFor,safePath,pinnedPages,mathCompiler,inspectArticle,classifyFailure,artifact,boundReport,VIEWPORTS,run}; +if(require.main===module) { + (async()=>{ + const args=argumentsFor(process.argv.slice(2)); + if(args.help) {console.log('capture_hosted_math.cjs --root REPO --repository owner/name --revision FULLSHA --output EMPTY_DIR [--page PATH ...] [--contract JSON] [--python python3]');return;} + process.exitCode=await run(args); + })().catch(error=>{console.error(String(error));process.exitCode=2;}); +} diff --git a/verification/hosted/check_rendered_math.py b/verification/hosted/check_rendered_math.py new file mode 100644 index 0000000..1d3bf98 --- /dev/null +++ b/verification/hosted/check_rendered_math.py @@ -0,0 +1,370 @@ +#!/usr/bin/env python3 +r"""Check captured mathematical text against pinned GitHub Markdown source. + +Usage (Python 3.10+, standard library only): + check_rendered_math.py inventory --root REPO --repository owner/name \ + --revision FULL_COMMIT --page README.md --page science/results.md \ + --output math-source.json + check_rendered_math.py check --inventory math-source.json \ + --capture math-capture.json [--contract math-contract.json] [--output result.json] + +Inventory reads Git objects at the requested commit, not the working tree. +It recognizes math fences, $`...`$, $$...$$ and single-dollar inline math, +excluding ordinary code fences/spans. This is a bounded Markdown scanner, +not the hosting renderer's parser. Inspect its inventory before capture. + +Capture schema (collect actual full accessible math text in document order): + {"schema_version": 1, "repository": "owner/name", "revision": "40 hex", + "renderer_profile": "github", "captured_at": "ISO-8601 with timezone", + "capture_method": "how the actual hosted DOM was inspected", + "pages": [{"path": "README.md", "url": "exact pinned inventory URL", + "revision": "40 hex", "source_sha256": "inventory source hash", + "errors": [], "math": [{"rendered": true, "errors": [], + "text_source": "mathml", "text": "full text, not a sample"}]}]} +Allowed text_source values: mathml, mathjax-assistive, katex-accessibility, +renderer-accessibility. Extract one accessible representation per host; +exclude TeX annotation nodes and duplicate visual/accessibility copies. +Native MathML is valid. Empty math lists are valid for math-free pages. + +Optional contract strengthens content checks without pretending to translate +arbitrary TeX. Each entry selects a path/index (1-based) and source_sha256 +(the expression hash in inventory), with expected_text and/or required_text: + {"schema_version": 1, "expressions": [{"path": "README.md", "index": 1, + "source_sha256": "expression hash", "required_text": ["d", "(C1)"], + "expected_text": "|A|", "le": "≤", "leq": "≤", "ge": "≥", "geq": "≥", + "ne": "≠", "neq": "≠", "in": "∈", "notin": "∉", "subset": "⊂", + "subseteq": "⊆", "supset": "⊃", "supseteq": "⊇", "approx": "≈", + "simeq": "≃", "equiv": "≡", "propto": "∝", "cong": "≅", "sim": "∼", + "to": "→", "rightarrow": "→", "Rightarrow": "⇒", "implies": "⇒", + "mapsto": "↦", "leftrightarrow": "↔", "Leftrightarrow": "⇔", "iff": "⇔", +} +RELATION_SYMBOLS = set("<>=") | set(RELATIONS.values()) +COMMAND = re.compile(r"\\([A-Za-z]+)") +LABEL = re.compile(r"\\tag(\*)?\{([^{}]+)\}|\\text\{\s*\(([^{}()]+)\)\s*\}") +FENCE = re.compile(r"^ {0,3}(`{3,}|~{3,})([^\n]*)\n?$") +SHA = re.compile(r"[0-9a-f]{40}") +TEXT_SOURCES = {"mathml", "mathjax-assistive", "katex-accessibility", "renderer-accessibility"} + + +def digest(text: str) -> str: + return hashlib.sha256(text.encode("utf-8")).hexdigest() + + +def compact(text: str) -> str: + return "".join(c for c in unicodedata.normalize("NFKC", text) + if not c.isspace() and unicodedata.category(c) != "Cf") + + +def escaped(text: str, index: int) -> bool: + backslashes = 0 + while index > 0 and text[index - 1] == "\\": + backslashes += 1 + index -= 1 + return bool(backslashes % 2) + + +def tex_body(text: str) -> str: + """Drop unescaped TeX comments; do not expand user macros.""" + return "\n".join(line[:next((i for i, c in enumerate(line) + if c == "%" and not escaped(line, i)), len(line))] + for line in text.splitlines()) + + +def relations(tex: str) -> dict[str, int]: + expanded = COMMAND.sub(lambda m: RELATIONS.get(m.group(1), m.group(0)), tex_body(tex)) + return dict(sorted(Counter(c for c in expanded if c in RELATION_SYMBOLS).items())) + + +def labels(tex: str) -> list[str]: + return [compact(tag if star else f"({tag or text})") + for star, tag, text in LABEL.findall(tex_body(tex))] + + +def expressions(source: str) -> list[dict]: + """Return ordered source spans; reject unterminated recognized delimiters.""" + found: list[dict] = [] + + def add(tex: str, offset: int, end: int, kind: str) -> None: + found.append({"line_start": source.count("\n", 0, offset) + 1, + "line_end": source.count("\n", 0, end) + 1, + "kind": kind, "tex": tex, "source_sha256": digest(tex), + "relations": relations(tex), "labels": labels(tex)}) + + def prose(start: int, end: int) -> None: + i = start + while i < end: + if source[i] == "$" and not escaped(source, i): + opener, closer, kind = ("$`", "`$", "github-inline") if source.startswith("$`", i) else ( + ("$$", "$$", "dollar-display") if source.startswith("$$", i) + else ("$", "$", "dollar-inline")) + j = source.find(closer, i + len(opener), end) + while j >= 0 and escaped(source, j): + j = source.find(closer, j + len(closer), end) + if j < 0 or (kind == "dollar-inline" and "\n" in source[i:j]): + raise ValueError(f"unclosed {kind} at line {source.count(chr(10), 0, i) + 1}") + add(source[i + len(opener):j], i, j + len(closer) - 1, kind) + i = j + len(closer) + elif source[i] == "`" and not escaped(source, i): + n = 1 + while i + n < end and source[i + n] == "`": + n += 1 + j = source.find("`" * n, i + n, end) + i = j + n if j >= 0 else i + n + else: + i += 1 + + lines = source.splitlines(keepends=True) + offset = start = i = 0 + while i < len(lines): + match = FENCE.match(lines[i]) + if not match: + offset += len(lines[i]) + i += 1 + continue + prose(start, offset) + marker, info = match.groups() + begin = offset + offset += len(lines[i]) + body_start = offset + i += 1 + while i < len(lines): + closing = FENCE.match(lines[i]) + if closing and closing[1][0] == marker[0] and len(closing[1]) >= len(marker) and not closing[2].strip(): + break + offset += len(lines[i]) + i += 1 + if i == len(lines): + raise ValueError(f"unclosed code fence at line {source.count(chr(10), 0, begin) + 1}") + if info.strip() == "math": + add(source[body_start:offset], begin, offset, "math-fence") + offset += len(lines[i]) + i += 1 + start = offset + prose(start, len(source)) + for index, item in enumerate(found, 1): + item["index"] = index + return found + + +def safe_path(path: str) -> bool: + return isinstance(path, str) and bool(path) and "\\" not in path and not PurePosixPath(path).is_absolute() and all( + part not in {"", ".", ".."} for part in path.split("/")) + + +def make_inventory(repository: str, revision: str, sources: dict[str, str]) -> dict: + if not isinstance(repository, str) or not isinstance(revision, str) or not re.fullmatch( + r"[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+", repository) or not SHA.fullmatch(revision): + raise ValueError("use owner/name and an exact lowercase 40-character commit SHA") + if not isinstance(sources, dict) or not sources or not all( + safe_path(p) and isinstance(s, str) for p, s in sources.items()): + raise ValueError("supply at least one safe repository-relative page path") + return {"schema_version": 1, "repository": repository, "revision": revision, + "renderer_profile": "github", "pages": [ + {"path": path, "url": f"https://github.com/{repository}/blob/{revision}/{quote(path, safe='/')}", + "source_sha256": digest(source), "source_text": source, "expressions": expressions(source)} + for path, source in sources.items()]} + + +def validate(inventory: dict, capture: dict, contract: dict | None = None) -> dict: + """Return failures rather than equating a passing text check with readiness.""" + failures: list[str] = [] + boundaries: list[dict] = [] + exceptions: list[dict] = [] + if not isinstance(inventory, dict) or not isinstance(capture, dict): + raise ValueError("inventory and capture must be JSON objects") + if type(inventory.get("schema_version")) is not int or type(capture.get("schema_version")) is not int or inventory["schema_version"] != 1 or capture["schema_version"] != 1: + raise ValueError("unsupported inventory or capture schema_version") + pages = inventory.get("pages") + if not isinstance(pages, list) or not pages or any(not isinstance(p, dict) for p in pages): + raise ValueError("inventory needs a nonempty pages array") + paths = [p.get("path") for p in pages] + if any(not isinstance(p, str) for p in paths) or len(set(paths)) != len(paths): + raise ValueError("inventory page paths must be unique strings") + rebuilt = make_inventory(inventory.get("repository", ""), inventory.get("revision", ""), + {p["path"]: p["source_text"] for p in pages}) + if inventory != rebuilt: + raise ValueError("inventory does not match its embedded source bytes/expression inventory") + for field in ("repository", "revision", "renderer_profile"): + if capture.get(field) != inventory[field]: + failures.append(f"capture {field} mismatch") + try: + timestamp = datetime.fromisoformat(capture.get("captured_at", "").replace("Z", "+00:00")) + if timestamp.tzinfo is None: + raise ValueError() + except (ValueError, AttributeError, TypeError): + failures.append("capture needs captured_at with a timezone") + if not isinstance(capture.get("capture_method"), str) or not capture["capture_method"].strip(): + failures.append("capture needs a nonempty capture_method") + captured_pages = capture.get("pages") + if not isinstance(captured_pages, list) or any(not isinstance(p, dict) for p in captured_pages): + raise ValueError("capture pages must be an array of objects") + captured_paths = [p.get("path") for p in captured_pages] + if captured_paths != paths: + failures.append("capture page paths/order differ from inventory (missing, extra or duplicate page)") + + contract = {"schema_version": 1, "expressions": []} if contract is None else contract + if not isinstance(contract, dict) or type(contract.get("schema_version")) is not int or contract["schema_version"] != 1 or not isinstance(contract.get("expressions"), list): + raise ValueError("invalid text contract schema") + rules: dict[tuple, dict] = {} + known = {(p["path"], e["index"]): e for p in pages for e in p["expressions"]} + for rule in contract["expressions"]: + if not isinstance(rule, dict): + raise ValueError("contract expressions must be objects") + key = (rule.get("path"), rule.get("index")) + if not isinstance(key[0], str) or type(key[1]) is not int or key not in known or key in rules or rule.get("source_sha256") != known[key]["source_sha256"]: + raise ValueError("unknown, duplicate or stale expression contract") + allowed = {"path", "index", "source_sha256", "required_text", "expected_text", "relation_override", + "allow_html_like_inequality", "reason", "evidence"} + if set(rule) - allowed: + raise ValueError("unknown contract field (contracts cannot skip checks)") + if "expected_text" in rule and (not isinstance(rule["expected_text"], str) or not compact(rule["expected_text"])): + raise ValueError("expected_text must be nonempty text") + if not isinstance(rule.get("required_text", []), list) or any( + not isinstance(v, str) or not compact(v) for v in rule.get("required_text", [])): + raise ValueError("required_text must be an array of nonempty text") + if "expected_text" not in rule and not rule.get("required_text"): + raise ValueError("each expression contract needs expected_text or required_text") + if "allow_html_like_inequality" in rule and not isinstance(rule["allow_html_like_inequality"], bool): + raise ValueError("allow_html_like_inequality must be boolean") + if "relation_override" in rule: + override = rule["relation_override"] + if not isinstance(override, dict) or any(k not in RELATION_SYMBOLS or type(v) is not int or v < 0 + for k, v in override.items()): + raise ValueError("relation_override must map known symbols to nonnegative integer counts") + if "relation_override" in rule or rule.get("allow_html_like_inequality"): + if not all(isinstance(rule.get(k), str) and rule[k].strip() for k in ("expected_text", "reason", "evidence")): + raise ValueError("renderer exception requires expected_text, reason and evidence") + exceptions.append(rule) + rules[key] = rule + + by_path = {p.get("path"): p for p in captured_pages if isinstance(p.get("path"), str)} + checked = 0 + for page in pages: + path = page["path"] + current = by_path.get(path) + if current is None: + continue + boundaries.append({"path": path, "source_sha256": page["source_sha256"], "url": current.get("url"), + "revision": current.get("revision"), "source_expressions": len(page["expressions"]), + "source_spans": [{k: e[k] for k in ("index", "line_start", "line_end", "source_sha256")} + for e in page["expressions"]]}) + for field, expected in (("url", page["url"]), ("revision", inventory["revision"]), ("source_sha256", page["source_sha256"])): + if current.get(field) != expected: + failures.append(f"{path}: captured {field} mismatch") + if current.get("errors") != []: + failures.append(f"{path}: renderer errors present or error evidence missing") + hosts = current.get("math") + if not isinstance(hosts, list): + failures.append(f"{path}: missing math-host array") + continue + boundaries[-1]["captured_hosts"] = len(hosts) + if len(hosts) != len(page["expressions"]): + failures.append(f"{path}: {len(page['expressions'])} source expressions, {len(hosts)} captured hosts") + for expr, host in zip(page["expressions"], hosts): + label = f"{path}:{expr['line_start']} expression {expr['index']}" + rule = rules.get((path, expr["index"]), {}) + if not isinstance(host, dict) or host.get("rendered") is not True or host.get("errors") != []: + failures.append(f"{label}: missing/unrendered host or renderer-error evidence") + continue + if host.get("text_source") not in TEXT_SOURCES or not isinstance(host.get("text"), str) or not compact(host["text"]): + failures.append(f"{label}: missing full accessible mathematical text/source") + continue + checked += 1 + text = compact(host["text"]) + expected = {k: v for k, v in rule.get("relation_override", expr["relations"]).items() if v} + actual = dict(sorted(Counter(c for c in text if c in RELATION_SYMBOLS).items())) + if expected != actual: + failures.append(f"{label}: relation mismatch; expected {expected}, captured {actual}") + for equation_label in expr["labels"]: + if equation_label not in text: + failures.append(f"{label}: missing equation label {equation_label}") + if re.search(r"<\s*[A-Za-z]", tex_body(expr["tex"])) and not rule.get("allow_html_like_inequality"): + failures.append(f"{label}: GitHub HTML-like inequality hazard; use supported syntax or a traced exact-text exception") + if "expected_text" in rule and compact(rule["expected_text"]) != text: + failures.append(f"{label}: full expected_text mismatch") + for required in rule.get("required_text", []): + if compact(required) not in text: + failures.append(f"{label}: missing required_text {required!r}") + return {"schema_version": 1, "status": "fail" if failures else "pass", + "repository": inventory["repository"], "revision": inventory["revision"], + "renderer_profile": inventory["renderer_profile"], "captured_at": capture.get("captured_at"), + "capture_method": capture.get("capture_method"), "boundaries": boundaries, + "expressions_checked": checked, "text_contracts": len(rules), "renderer_exceptions": exceptions, + "failures": failures, "visual_review_required": True, + "limits": "Counts, supported relations/visible labels and explicit text contracts only. No arbitrary TeX equivalence, scientific correctness, capture authentication or visual-layout certification."} + + +def read_json(path: Path) -> dict: + return json.loads(path.read_text(encoding="utf-8")) + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + commands = parser.add_subparsers(dest="command", required=True) + inv = commands.add_parser("inventory", help="read math source from an exact local Git commit") + inv.add_argument("--root", type=Path, required=True) + inv.add_argument("--repository", required=True) + inv.add_argument("--revision", required=True) + inv.add_argument("--page", action="append", required=True) + inv.add_argument("--output", type=Path, required=True) + check = commands.add_parser("check", help="check pinned extracted capture; does not fetch or render") + check.add_argument("--inventory", type=Path, required=True) + check.add_argument("--capture", type=Path, required=True) + check.add_argument("--contract", type=Path) + check.add_argument("--output", type=Path) + args = parser.parse_args(argv) + try: + if args.command == "inventory": + if not SHA.fullmatch(args.revision) or len(set(args.page)) != len(args.page) or not all(safe_path(p) for p in args.page): + raise ValueError("use an exact commit SHA and unique safe page paths") + commit = subprocess.check_output(["git", "--no-replace-objects", "rev-parse", f"{args.revision}^{{commit}}"], cwd=args.root, text=True).strip() + if commit != args.revision: + raise ValueError("revision does not identify the supplied commit") + sources = {p: subprocess.check_output(["git", "--no-replace-objects", "show", f"{commit}:{p}"], cwd=args.root).decode("utf-8") for p in args.page} + result = make_inventory(args.repository, commit, sources) + else: + result = validate(read_json(args.inventory), read_json(args.capture), read_json(args.contract) if args.contract else None) + output = json.dumps(result, indent=2, ensure_ascii=False) + "\n" + if args.output: + args.output.write_text(output, encoding="utf-8") + else: + print(output, end="") + return 1 if result.get("status") == "fail" else 0 + except (OSError, UnicodeError, ValueError, KeyError, TypeError, subprocess.CalledProcessError) as error: + print(f"ERROR: {error}", file=sys.stderr) + return 2 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/verification/references/hosted-rendering.md b/verification/references/hosted-rendering.md new file mode 100644 index 0000000..3bbc231 --- /dev/null +++ b/verification/references/hosted-rendering.md @@ -0,0 +1,21 @@ +# Checking the mathematics displayed on GitHub + +The [hosted-mathematics workflow](../../.github/workflows/hosted-math.yml) checks the actual GitHub pages for one exact source commit. It uses an anonymous Chromium context at viewport widths 1440 and 760 pixels. Its repository permission is `contents: read`; checkout credentials are not persisted, and the browser receives no signed-in session. + +The collector inventories every tracked Markdown page in that commit, compiles each recognized source formula to reference MathML, then compares it with the MathML supplied by GitHub. It checks expression counts, mathematical structure, scripts, fractions, relations, equation labels and bounded display geometry. HTML captures, screenshots, source inventories and the report are retained as a temporary workflow artifact, including when a check fails. + +For a local run, install Node.js 18 or later, Python 3.10 or later, Git, Playwright 1.56.1 and MathJax 3.2.1. Install Chromium with Playwright. Set `NODE_PATH` to the directory containing those temporary Node dependencies, then run: + +```bash +node verification/hosted/capture_hosted_math.cjs \ + --root /absolute/path/to/checkout \ + --repository GoGoKo699/Quantum-Spectral-Memory \ + --revision FULL_40_CHARACTER_COMMIT \ + --output /absolute/path/to/new-evidence-directory +``` + +The revision must already be available on public GitHub. Each attempt uses a new output directory so earlier failures remain distinguishable. The default scope includes all tracked Markdown files, rather than only the headline equations. + +A passing report establishes agreement for the observed source, host and viewports. Screenshots still need human inspection for mathematical readability, figures, tables and navigation. The check does not verify scientific proofs, guarantee future rendering, or establish compatibility with every browser. Temporary CI artifacts are not a permanent archive. + +[Finite scientific checks](../README.md) · [Repository overview](../../README.md) From 3a24bd8cfdbbf02b0f05be65111469d6e6180933 Mon Sep 17 00:00:00 2001 From: Ruge Lin Date: Tue, 3 Nov 2026 14:20:32 +0800 Subject: [PATCH 2/3] Pin hosted rendering to the supported Ubuntu 24.04 runtime --- .github/workflows/hosted-math.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hosted-math.yml b/.github/workflows/hosted-math.yml index 74d604d..cb3f725 100644 --- a/.github/workflows/hosted-math.yml +++ b/.github/workflows/hosted-math.yml @@ -9,7 +9,7 @@ permissions: jobs: rendered-mathematics: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 timeout-minutes: 20 env: REVIEW_SHA: ${{ github.event.pull_request.head.sha || github.sha }} From 7f1e8b2a7fdb1e7e765fa3b2364d7b07e6d60f2e Mon Sep 17 00:00:00 2001 From: Ruge Lin Date: Tue, 3 Nov 2026 14:26:21 +0800 Subject: [PATCH 3/3] Repair hosted operator notation and equation label layout --- learning/anchor.md | 6 ++--- science/encoder.md | 48 +++++++++++++++++++-------------------- science/examples.md | 2 +- science/interpretation.md | 32 +++++++++++++------------- science/model.md | 26 ++++++++++----------- science/spectral_law.md | 48 +++++++++++++++++++-------------------- 6 files changed, 81 insertions(+), 81 deletions(-) diff --git a/learning/anchor.md b/learning/anchor.md index 98da1bb..309993c 100644 --- a/learning/anchor.md +++ b/learning/anchor.md @@ -33,8 +33,8 @@ The first six rows support background milestones M01–M11 and the one-register | Convention | Translation used here | |---|---| | Vectors and adjoints | Watrous's $`u`$, $`uv^*`$, and $`B^*`$ correspond to $`\lvert u\rangle`$, $`\lvert u\rangle\langle v\rvert`$, and $`B^\dagger`$. | -| Choi normalization | Both use unnormalized $`J(\Phi)`$. A channel with input dimension $`d`$ has $`\operatorname{Tr}J(\Phi)=d`$; $`J(\Phi)/d`$ is its normalized Choi state. | -| Channel norm | Watrous's completely bounded trace norm, written with triple bars and subscript one, is our $`\lVert\Gamma\rVert_\diamond`$. Our error is **half** that norm: $`\frac12\lVert\Lambda-\operatorname{id}\rVert_\diamond`$. | +| Choi normalization | Both use unnormalized $`J(\Phi)`$. A channel with input dimension $`d`$ has $`\mathrm{Tr}J(\Phi)=d`$; $`J(\Phi)/d`$ is its normalized Choi state. | +| Channel norm | Watrous's completely bounded trace norm, written with triple bars and subscript one, is our $`\lVert\Gamma\rVert_\diamond`$. Our error is **half** that norm: $`\frac12\lVert\Lambda-\mathrm{id}\rVert_\diamond`$. | | Fidelity | Watrous defines $`F(\rho,\sigma)=\lVert\sqrt\rho\sqrt\sigma\rVert_1`$. Our $`F_e=\langle\Omega_D\rvert\rho_{\rm out}\lvert\Omega_D\rangle`$ is an overlap without a square root: $`F_e=F(\rho_{\rm out},\lvert\Omega_D\rangle\langle\Omega_D\rvert)^2`$. | | Dimensions and qubits | $`d`$ is physical dimension, $`D`$ logical dimension, and $`\lfloor\log_2D\rfloor`$ whole logical qubits. The compiler uses band population $`N`$ and selects $`K=2^{\lfloor\log_2N\rfloor}`$ codewords. | | Schur matrix and noise operator | The multiplier called $`A`$ in Watrous §4.1.3 corresponds to our $`G_t`$. Our Hermitian $`A`$ instead determines $`\mathcal L_A=-[A,[A,\cdot]]/2`$ and $`\Phi_t=e^{t\mathcal L_A}`$. | @@ -97,7 +97,7 @@ At the nominal coefficients, the selected eigenvalue gap is $`1/32`$. The logica p=\frac{1-e^{-1/128}}2\approx0.00389103. ``` -Here $`Z=\operatorname{diag}(1,-1)`$ acts on the decoded logical qubit. Its half-diamond error is exactly $`p`$: the norm triangle inequality gives the upper bound, and input $`|+\rangle`$ attains it. Measuring that decoded input in the $`X`$ basis returns the minus outcome with probability $`p`$; a maximally entangled input has target overlap $`1-p`$. +Here $`Z=\mathrm{diag}(1,-1)`$ acts on the decoded logical qubit. Its half-diamond error is exactly $`p`$: the norm triangle inequality gives the upper bound, and input $`|+\rangle`$ attains it. Measuring that decoded input in the $`X`$ basis returns the minus outcome with probability $`p`$; a maximally entangled input has target overlap $`1-p`$. For every fixed coefficient vector consistent with the supplied certificates, the compiler's conservative storage bound is instead $`9\epsilon/16=9/256`$. The nominal exact value and robust bound answer different questions. This is finite-time approximate protection: the nondegenerate nominal operator has exact storage dimension one at every positive exposure, as [Proposition 2](../science/spectral_law.md#proposition-2-exact-storage-at-every-positive-time) establishes. The example demonstrates a functioning band code, without claiming its optimality from these small numbers alone. diff --git a/science/encoder.md b/science/encoder.md index 81e7392..e53a141 100644 --- a/science/encoder.md +++ b/science/encoder.md @@ -33,7 +33,7 @@ With ideal end operations, the storage half-diamond error is at most $`9\epsilon \le 1+\log_2\frac{(2+\sqrt{2\pi})b_\epsilon}{1-\epsilon}, \qquad b_\epsilon=\left\lceil\frac4{\sqrt\epsilon}\right\rceil. -\tag{1} +\qquad\text{(1)} ``` Thus its loss is a constant number of logical qubits for fixed $`\epsilon`$, uniformly in the number, spacing, signs and degeneracies of the actual spectrum. The constant in (1) is not optimized. For inverse-polynomial $`\epsilon`$, the loss is $`O(\log(1/\epsilon))`$, not a constant independent of $`\epsilon`$. @@ -47,7 +47,7 @@ v=\frac{\epsilon}{16n^2t},\qquad e=\lfloor\log_2v\rfloor,\qquad k=\left\lfloor\frac e2\right\rfloor,\qquad \delta=2^k. -\tag{2} +\qquad\text{(2)} ``` These definitions can be evaluated with integer arithmetic. If $`v=p/q\gt 0`$, the difference between the binary lengths of $`p`$ and $`q`$ gives a candidate for $`e`$; one integer comparison against a shifted numerator or denominator determines whether to subtract one. No floating logarithm or square root is needed. Negative $`e`$ requires mathematical floor division by two. @@ -56,7 +56,7 @@ Equation (2) gives the exact certificate ```math \delta^2\le\frac{\epsilon}{16n^2t}\lt 4\delta^2. -\tag{3} +\qquad\text{(3)} ``` Equivalently, for $`\delta_*=\sqrt\epsilon/(4n\sqrt t)`$, @@ -69,7 +69,7 @@ The input precision condition is ```math u_j\le\delta/2\quad\text{for every }j. -\tag{4} +\qquad\text{(4)} ``` If the supplied certificates fail (4), this theorem does not certify that input at the requested $`t,\epsilon`$. The compiler can state the required precision; it must not silently substitute a smaller uncertainty. As a more general diagnostic, any estimates and grid give the valid bandwidth bound $`4n\delta+2\sum_j(u_j+\delta/2)`$, but the specific constants and optimality guarantee below use (4). @@ -77,8 +77,8 @@ If the supplied certificates fail (4), this theorem does not certify that input Round exactly to ```math -q_j=\operatorname{nint}(\widehat g_j/\delta)\in\mathbb Z. -\tag{5} +q_j=\mathrm{nint}(\widehat g_j/\delta)\in\mathbb Z. +\qquad\text{(5)} ``` Any fixed nearest-integer tie rule works. The prototype uses ties toward $`+\infty`$, namely $`\lfloor\widehat g_j/\delta+1/2\rfloor`$. From (4)–(5), @@ -88,7 +88,7 @@ Any fixed nearest-integer tie rule works. The prototype uses ties toward $`+\inf \qquad \left|E_x-\delta\sum_jq_jx_j\right|\le n\delta \quad\text{for every }x. -\tag{6} +\qquad\text{(6)} ``` If $`|g_j|\le G`$, then @@ -97,7 +97,7 @@ If $`|g_j|\le G`$, then S:=\sum_j|q_j| \le n(G/\delta+1) \le8n^2G\sqrt{t/\epsilon}+n. -\tag{7} +\qquad\text{(7)} ``` The number of fractional bits sufficient to specify coefficients to this accuracy is $`O(\log(n+1)+\log(1+t)+\log(1/\epsilon))`$, with the integer range charged separately through $`G`$. The full classical input length includes the rational descriptions of $`t,\epsilon,\widehat g_j,u_j`$. A description-length estimate is not a bound on physical calibration time or sample complexity. @@ -117,7 +117,7 @@ Then ```math \sum_jq_jx_j=-S_-+\sum_jh_jy_j. -\tag{8} +\qquad\text{(8)} ``` The shift $`-S_-`$ does not affect spectral diameters. Quantumly, the relabeling is a set of known $`X`$ gates. Zero weights require no special exclusion: both branches are counted, including their degeneracy. @@ -127,7 +127,7 @@ Put $`B=4n`$. Choose the smallest integer $`a\in\{0,\ldots,S\}`$ maximizing ```math N(a)=\#\left\{y\in\{0,1\}^n: a\le\sum_jh_jy_j\le a+B\right\},\qquad N=\max_aN(a). -\tag{9} +\qquad\text{(9)} ``` The interval in (9) is **closed**. It contains $`B+1`$ possible integer values and has diameter $`B`$. These are different quantities. Restricting $`a`$ to $`0,\ldots,S`$ loses nothing: a band starting below zero can be shifted to zero without losing any nonnegative sum, and a band starting above $`S`$ is empty. The definition covers $`S=0`$, $`B\gt S`$, and ties among maximizers. Since the all-zero $`y`$-string exists, $`N\ge1`$. @@ -136,7 +136,7 @@ Set ```math m=\lfloor\log_2N\rfloor,\qquad K=2^m, -\tag{10} +\qquad\text{(10)} ``` and use the first $`K`$ accepted strings in lexicographic $`y`$-order. This is a fixed deterministic order; after the known sign flips, it need not coincide with lexicographic $`x`$-order. @@ -147,7 +147,7 @@ Any two chosen strings have rounded energies separated by at most $`B\delta`$. E ```math w\le B\delta+2n\delta=6n\delta. -\tag{11} +\qquad\text{(11)} ``` For a generator supported in an interval of diameter $`w`$, center it to norm at most $`w/2`$. The double-commutator generator has diamond norm at most $`w^2/2`$. Integrating the dephasing semigroup gives @@ -157,7 +157,7 @@ For a generator supported in an interval of diameter $`w`$, center it to norm at \le\frac{tw^2}{4} \le9n^2t\delta^2 \le\frac{9\epsilon}{16}. -\tag{12} +\qquad\text{(12)} ``` This is a whole-channel statement and includes arbitrary entangled references. In the $`N_j`$ convention, one can sharpen some of these constants by using the range of the rounding-error function; the conservative bound (11) is sufficient here. @@ -177,7 +177,7 @@ By (3), a resolution interval of width $`t^{-1/2}`$ can be divided into $`b_\eps ```math N\ge\left\lceil\frac{M_t}{b_\epsilon}\right\rceil, \qquad K\ge\frac{M_t}{2b_\epsilon}. -\tag{13} +\qquad\text{(13)} ``` The integer $`b_\epsilon`$ can itself be computed without a square root: it is the least integer $`k`$ with $`k^2\epsilon\ge16`$. Combining (13) with the unrestricted spectral-occupancy converse @@ -195,7 +195,7 @@ Use suffix counts ```math F_{n+1}(s)=\mathbf1_{s=0},\qquad F_j(s)=F_{j+1}(s)+F_{j+1}(s-h_j), -\tag{14} +\qquad\text{(14)} ``` with out-of-range entries zero and $`0\le s\le S`$. For $`h_j=0`$, (14) correctly doubles the count. Counts are at most $`2^n`$, so $`c=n+1`$ bits suffice, including the all-strings case. A sliding sum over $`F_1`$ finds (9) exactly. @@ -204,7 +204,7 @@ Precompute suffix prefix sums $`P_j(z)=\sum_{s\le z}F_j(s)`$, saturated to zero ```math C_j(p)=P_{j+1}(a+B-p)-P_{j+1}(a-1-p). -\tag{15} +\qquad\text{(15)} ``` This is the number of accepted completions if the next bit is zero. Precomputing (15) avoids signed-address arithmetic during coherent lookup. The sum register uses @@ -219,7 +219,7 @@ There are $`O(n(S+1))`$ count words. The table storage is $`O(n(n+1)(S+1))`$ bit ```math O\bigl(n(S+1)(n+\ell)\bigr) -\tag{16} +\qquad\text{(16)} ``` elementary bit operations, in addition to polynomial arithmetic in the rational input length. This does not regard an $`n`$-bit count addition as a unit-cost operation. Generating and storing the compiled gate description has its own cost below. @@ -236,7 +236,7 @@ Comparisons, addition, subtraction and Boolean selection have ordinary linear-si ```math O((S+1)(\ell+n)) -\tag{17} +\qquad\text{(17)} ``` primitive reversible gates. There is no unit-cost quantum RAM operation and no uncharged loading oracle. The literal table entries determine which controlled gates the compiler emits. @@ -247,7 +247,7 @@ There are $`n`$ lookups in each rank or unrank computation. An intentionally sim G_{\mathrm{enc}}=O\bigl(n(S+1)(n+\ell)\bigr), \qquad G_{\mathrm{dec}}=G_{\mathrm{enc}}, -\tag{18} +\qquad\text{(18)} ``` primitive $`X`$, CNOT and Toffoli gates, and at most the same asymptotic number of temporary work qubits. This generous workspace bound is achieved by retaining intermediate Boolean wires and then reversing their computation. It does not require a nontrivial space-time optimization theorem. @@ -278,7 +278,7 @@ Apply $`O_U`$, then $`O_R`$, then the known physical sign flips. For every $`0\l |r\rangle_L|0^n\rangle_P|0\rangle_W \longmapsto |0^m\rangle_L|x(r)\rangle_P|0\rangle_W. -\tag{19} +\qquad\text{(19)} ``` This is a literal computational-basis permutation with no rank-dependent phase. Linearity proves the clean isometry for arbitrary superpositions and reference-entangled states. The logical input register and all work registers can be discarded or reset before storage. Neither carries any logical information in the ideal construction. @@ -288,7 +288,7 @@ The dephasing channel preserves the span of the selected computational basis str ```math \Lambda_t(|r\rangle\langle s|) =e^{-t(E_{x(r)}-E_{x(s)})^2/2}|r\rangle\langle s|. -\tag{20} +\qquad\text{(20)} ``` Discarding non-output registers defines a completely positive trace-preserving decoder on the entire physical input space, including states outside the code. No inverse is assumed to exist outside the chosen subspace. @@ -301,7 +301,7 @@ Let $`\widetilde E,\widetilde D`$ be the actual boundary channels, with all nonp ```math \eta_E+\eta_D\le7\epsilon/16. -\tag{21} +\qquad\text{(21)} ``` Contractivity and the triangle inequality give @@ -310,7 +310,7 @@ Contractivity and the triangle inequality give \frac12\|\widetilde D\Phi_t\widetilde E-\mathrm{id}\|_\diamond \le\eta_E+\frac{9\epsilon}{16}+\eta_D \le\epsilon. -\tag{22} +\qquad\text{(22)} ``` An approximate encoder may leave imperfectly cleaned work registers. They are discarded before storage rather than retained as an unintended quantum carrier; this discarding does not increase the channel-distance bound. @@ -319,7 +319,7 @@ For a circuit with $`T_{\mathrm{end}}`$ implemented operations in total, a suffi ```math \frac{7\epsilon}{16T_{\mathrm{end}}} -\tag{23} +\qquad\text{(23)} ``` per operation. More generally, the sum of the composable operation errors can be at most $`7\epsilon/16`$. Noisy initializations or resets must be included in this budget if they are not ideal. Equation (23) is a sufficient error allocation, not a fault-tolerance resource estimate or a statement that arbitrary temporally correlated hardware noise is described by independent gate channels. If a native decomposition changes the operation count, use the actual native count in (23). diff --git a/science/examples.md b/science/examples.md index 9c72065..ddb05fe 100644 --- a/science/examples.md +++ b/science/examples.md @@ -32,7 +32,7 @@ For each requested exposure, the compiler selects its dyadic grid and receives e Each code has the same conservative storage error certificate, ```math -\frac12\|\Lambda_t-\operatorname{id}\|_\diamond +\frac12\|\Lambda_t-\mathrm{id}\|_\diamond \le\frac{9\epsilon}{16}=\frac9{256}. ``` diff --git a/science/interpretation.md b/science/interpretation.md index 8c6c36e..9c6b467 100644 --- a/science/interpretation.md +++ b/science/interpretation.md @@ -10,7 +10,7 @@ For a general many-body operator, evaluating the full spectrum or implementing a ```math A=\sum_{j=1}^ng_jN_j,\qquad N_j=|1\rangle\langle1|_j. -\tag{I1} +\qquad\text{(I1)} ``` Its guarantee is relative to the optimum for the actual couplings, even though the compiler uses only estimates with a certified finite error. @@ -20,15 +20,15 @@ Its guarantee is relative to the optimum for the actual couplings, even though t Let ```math -\bar\lambda=d^{-1}\operatorname{Tr}A, -\qquad V=d^{-1}\operatorname{Tr}(A-\bar\lambda I)^2. +\bar\lambda=d^{-1}\mathrm{Tr}A, +\qquad V=d^{-1}\mathrm{Tr}(A-\bar\lambda I)^2. ``` For $`V\gt 0`$, Chebyshev's inequality implies that at least $`3d/4`$ eigenvalues lie in an interval of width $`4\sqrt V`$. Partition that interval into $`\lceil4\sqrt{Vt}\rceil`$ cells of diameter at most $`t^{-1/2}`$, assigning each boundary eigenvector to one cell. The number of cells is at most $`1+4\sqrt{Vt}`$. Pigeonholing gives ```math M_t\ge\frac{3d}{4(1+4\sqrt{Vt})}. -\tag{I2} +\qquad\text{(I2)} ``` When $`V=0`$, $`A`$ is scalar and $`M_t=d`$, so (I2) remains a valid, weaker bound. @@ -38,7 +38,7 @@ For (I1), $`d=2^n`$ and $`V=\frac14\sum_jg_j^2`$. Define $`x=t\sum_jg_j^2`$. Sin ```math m\ge n-\frac12\log_2(1+x) -\left[1+\log_2\left(\frac{4k\sqrt5}{3}\right)\right]. -\tag{I3} +\qquad\text{(I3)} ``` For the finite dyadic construction one may use $`k=\lceil4/\sqrt\epsilon\rceil`$. Thus bounded couplings and any prescribed polynomial exposure give an explicit passive code storing $`n-O_\epsilon(\log n)`$ logical qubits. The additional dimension guarantee relative to all allowed codes is @@ -46,7 +46,7 @@ For the finite dyadic construction one may use $`k=\lceil4/\sqrt\epsilon\rceil`$ ```math 0\le\log_2D_\epsilon(t;A)-m \le1+\log_2\left(\frac{Ck}{1-\epsilon}\right). -\tag{I4} +\qquad\text{(I4)} ``` The compiler is polynomial for bounded couplings, polynomial $`t`$, and inverse-polynomial error tolerance. It is not asserted polynomial in the bit length of $`t`$. The true couplings are fixed during the storage interval and lie within the supplied calibration certificates. Required calibration accuracy is an input assumption; the number of bits specifying the estimates is not the physical cost of obtaining them. Temporary encoder workspace is cleaned before storage; decoder workspace is introduced only after storage and is discarded after recovery. Independent local noise, unmodeled time-dependent coupling drift, and imperfect boundary operations require separate models and are not included in these guarantees; the [boundary-error budget](encoder.md#6-composable-implementation-error-budget) gives a separate composable extension for the last item. @@ -61,10 +61,10 @@ For each fixed finite $`A`$, the limit channel is \lim_{t\to\infty}\Phi_t=\Pi_A, \qquad \Pi_A(X)=\sum_\alpha P_\alpha X P_\alpha, -\tag{I5} +\qquad\text{(I5)} ``` -where $`P_\alpha`$ are the projectors onto distinct eigenspaces. The convergence holds in diamond norm in finite dimension. The fixed algebra is the direct sum of full matrix algebras on those eigenspaces. Its largest exact noiseless subspace has dimension $`m_*:=\max_\alpha\operatorname{rank}P_\alpha`$. Proposition 2 shows that $`D_0(t;A)=m_*`$ at every positive time. +where $`P_\alpha`$ are the projectors onto distinct eigenspaces. The convergence holds in diamond norm in finite dimension. The fixed algebra is the direct sum of full matrix algebras on those eigenspaces. Its largest exact noiseless subspace has dimension $`m_*:=\max_\alpha\mathrm{rank}P_\alpha`$. Proposition 2 shows that $`D_0(t;A)=m_*`$ at every positive time. If the spectrum is nondegenerate, $`\Pi_A`$ is entanglement breaking. Moreover $`\lambda_{\max}(G_t)\to1`$. For any fixed $`\epsilon\lt 1/2`$, eventually $`\lambda_{\max}(G_t)\lt 2(1-\epsilon)`$; the all-code converse then forces $`D_\epsilon(t;A)=1`$. Thus every fixed nondegenerate register eventually loses the ability to store even one logical qubit at that error. @@ -93,7 +93,7 @@ Then \le\log_2\lambda_{\max}(G_t) \le\log_2M_t+\log_2C. } -\tag{I6} +\qquad\text{(I6)} ``` The upper bound is a strong-converse bound for fixed-length deterministic entanglement-generation protocols. No equality between assisted and unassisted capacities is asserted. This corollary is not needed to prove the one-register theorem. @@ -107,21 +107,21 @@ Use canonical one-mode coherent states \qquad \langle\beta|\alpha\rangle =e^{-(|\alpha|^2+|\beta|^2)/2+\beta^*\alpha}. -\tag{I7} +\qquad\text{(I7)} ``` The isometry ```math V_t|i\rangle=|i\rangle\otimes|\sqrt t\,\lambda_i\rangle -\tag{I8} +\qquad\text{(I8)} ``` has reduced system channel $`\Phi_t`$, because the environmental overlap for real amplitudes is exactly $`e^{-t(\lambda_i-\lambda_j)^2/2}`$. Its complementary channel is ```math \Phi_t^c(\rho)=\sum_i\rho_{ii}|\sqrt t\,\lambda_i\rangle\langle\sqrt t\,\lambda_i|. -\tag{I9} +\qquad\text{(I9)} ``` The coherent-state environmental representation is established for the bosonic number-spectrum dephasing channel by Arqand, Memarzadeh and Mancini, [arXiv:2007.03897v4](https://arxiv.org/html/2007.03897v4), Eqs. (7)–(9) and (16)–(19). Their amplitudes $`-i\sqrt\gamma\,m`$ become real after an environment phase rotation. Here $`\gamma=t`$ in the matrix-element normalization of their Eq. (9), and (I7)–(I9) verify the finite-spectrum extension directly. @@ -131,8 +131,8 @@ This oscillator is a mathematical dilation of the specified channel. The displac Choose $`M_t`$ eigenvectors inside a resolution interval with midpoint $`c`$, and use their uniform mixture as the channel input. The system output entropy is $`\log_2M_t`$. Displace the environment by $`-\sqrt t\,c`$; this leaves its entropy unchanged. Every displaced amplitude then has absolute value at most $`1/2`$. The resulting environment state $`\tau_E`$ satisfies ```math -\operatorname{Tr}(b^\dagger b\,\tau_E)\le1/4. -\tag{I10} +\mathrm{Tr}(b^\dagger b\,\tau_E)\le1/4. +\qquad\text{(I10)} ``` For completeness, a state of mean number at most $`u\gt 0`$ has entropy at most $`h_{\rm bos}(u)`$. Compare it by nonnegativity of relative entropy with the thermal state @@ -157,14 +157,14 @@ Let $`\mu=\lambda_{\max}(G_t)`$. The CP order $`\Phi_t\le_{\rm CP}\mu\Delta`$ ho ```math \rho_L\le\mu^L\sigma_L. -\tag{I11} +\qquad\text{(I11)} ``` The comparison protocol has only entanglement-breaking communication and starts without shared entanglement. Thus $`\sigma_L`$ is separable across the sender–receiver partition. Its overlap with a maximally entangled target of dimension $`K_L`$ is at most $`1/K_L`$, so ```math F_L\le\frac{\mu^L}{K_L}. -\tag{I12} +\qquad\text{(I12)} ``` If $`\liminf_L L^{-1}\log_2K_L\gt \log_2\mu`$, the target overlap tends to zero exponentially. This proves the upper bound and its stated strong-converse meaning. Failure branches are included in the output state; no bound on a postselected normalized branch is being asserted. diff --git a/science/model.md b/science/model.md index a1baeef..3e3a23c 100644 --- a/science/model.md +++ b/science/model.md @@ -15,7 +15,7 @@ where eigenvalues are listed with multiplicity. The storage channel at exposure =-\tfrac12[A,[A,X]], \qquad \Phi_t=e^{t\mathcal L_A}. -\tag{M1} +\qquad\text{(M1)} ``` Thus @@ -23,7 +23,7 @@ Thus ```math \Phi_t(|i\rangle\langle j|) =e^{-t(\lambda_i-\lambda_j)^2/2}|i\rangle\langle j|. -\tag{M2} +\qquad\text{(M2)} ``` The normalization is fixed by (M1)–(M2). In particular, $`t(\lambda_i-\lambda_j)^2`$ is dimensionless; if $`t`$ is physical time, the noise-rate units are included in $`A`$. For $`t\gt 0`$, an equivalent random-unitary representation is @@ -31,7 +31,7 @@ The normalization is fixed by (M1)–(M2). In particular, $`t(\lambda_i-\lambda_ ```math \Phi_t(X)=\int_{\mathbb R}\frac{e^{-s^2/(2t)}}{\sqrt{2\pi t}} e^{-isA}Xe^{isA}\,ds. -\tag{M3} +\qquad\text{(M3)} ``` There is no assumption that the spectrum is equally spaced, nondegenerate, or integer valued. Shifting $`A`$ by a scalar multiple of the identity changes neither the generator nor the channel. A separate system Hamiltonian is not included in this model. @@ -50,14 +50,14 @@ is completely positive and trace nonincreasing, and $`\sum_c\mathcal E_c`$ is tr ```math \mathcal E(X)=\sum_c\mathcal E_c(X)\otimes|c\rangle\langle c|. -\tag{M4} +\qquad\text{(M4)} ``` Conditional on $`c`$, the terminal recovery $`\mathcal R_c:\mathcal B(S)\to\mathcal B(Q)`$ is an arbitrary completely positive trace-preserving map. The resulting logical channel is ```math \Lambda_t=\sum_c\mathcal R_c\circ\Phi_t\circ\mathcal E_c. -\tag{M5} +\qquad\text{(M5)} ``` The sum in (M5) includes every outcome. This is deterministic storage, with no conditioning on a favorable outcome. Ordinary mixed encoders, private randomness, shared classical randomness, and arbitrary processing of the retained record are contained in this description. A general classical outcome space is handled by replacing sums by instrument integrals; the converse uses only positivity and trace normalization and is unchanged. @@ -69,8 +69,8 @@ Temporary quantum workspace may be used during encoding and recovery. It is disc For a linear map $`\Gamma`$, $`\|\Gamma\|_\diamond`$ denotes its completely bounded trace norm. A code has error at most $`\epsilon`$ if ```math -\frac12\|\Lambda_t-\operatorname{id}_D\|_\diamond\le\epsilon. -\tag{M6} +\frac12\|\Lambda_t-\mathrm{id}_D\|_\diamond\le\epsilon. +\qquad\text{(M6)} ``` For a difference of channels this equals the maximum output trace distance over input states entangled with an inaccessible reference register of dimension $`D`$. Hence (M6) protects an unknown logical state together with all of its correlations with a reference. @@ -79,14 +79,14 @@ Let $`D_\epsilon(t;A)`$ be the largest positive integer $`D`$ for which an allow ```math D_\epsilon(t;A)\le \frac{d}{1-\epsilon},\qquad 0\le\epsilon\lt 1, -\tag{M7} +\qquad\text{(M7)} ``` so this maximum is finite. Dimension one is always feasible. Restricting a feasible code to a smaller logical subspace preserves its error bound, using an isometric embedding and a trace-preserving extension of the inverse embedding. Consequently the maximum number of whole logical qubits is ```math q_\epsilon(t;A)=\big\lfloor\log_2D_\epsilon(t;A)\big\rfloor. -\tag{M8} +\qquad\text{(M8)} ``` For $`d=2^n`$ and $`\epsilon\lt 1/2`$, (M7) implies $`q_\epsilon\le n`$. No claim that $`D_\epsilon=d`$ for every positive-error identity channel is needed: arbitrary-dimensional approximate compression with classical records is included in the model. @@ -98,7 +98,7 @@ For $`t\gt 0`$, define the noise-resolution width and its largest spectral occup ```math w_t=t^{-1/2},\qquad M_t(A)=\max_{x\in\mathbb R}\#\{i:\lambda_i\in[x,x+w_t]\}. -\tag{M9} +\qquad\text{(M9)} ``` Intervals are closed and multiplicities are counted. Since the spectrum is finite, the maximum exists. Every half-open interval of the same width has occupancy at most $`M_t`$, a fact used in the Gaussian row estimate. When an interval is partitioned, boundary eigenvectors are assigned to one cell only. Each assigned cell remains contained in a closed interval of the stated diameter. @@ -111,14 +111,14 @@ The efficient construction concerns A=\sum_{j=1}^n g_jN_j, \qquad N_j=|1\rangle\langle1|_j, \qquad |g_j|\le G. -\tag{M10} +\qquad\text{(M10)} ``` For $`x=(x_1,\ldots,x_n)\in\{0,1\}^n`$, its noise eigenvalue is ```math \lambda(x)=\sum_jg_jx_j. -\tag{M11} +\qquad\text{(M11)} ``` Weights may be negative or zero. Under the uniform distribution on computational basis strings, @@ -128,7 +128,7 @@ Weights may be negative or zero. Under the uniform distribution on computational \qquad V:=2^{-n}\sum_x(\lambda(x)-\bar\lambda)^2 =\tfrac14\sum_jg_j^2. -\tag{M12} +\qquad\text{(M12)} ``` The general spectral theorem is information theoretic and does not assume an efficient description of an eigenbasis. Efficient compilation is asserted only for the explicitly supplied form (M10), with finite-precision coupling estimates and a stated error certificate. diff --git a/science/spectral_law.md b/science/spectral_law.md index 858db9e..0c03be2 100644 --- a/science/spectral_law.md +++ b/science/spectral_law.md @@ -21,14 +21,14 @@ Then \le \frac{\lambda_{\max}(G_t)}{1-\epsilon} \le \frac{CM_t}{1-\epsilon}, } -\tag{S1} +\qquad\text{(S1)} ``` where ```math (G_t)_{ij}=e^{-t(\lambda_i-\lambda_j)^2/2}. -\tag{S2} +\qquad\text{(S2)} ``` In particular, @@ -37,7 +37,7 @@ In particular, -\log_2k_\epsilon \le\log_2D_\epsilon(t;A)-\log_2M_t \le\log_2\frac{C}{1-\epsilon}. -\tag{S3} +\qquad\text{(S3)} ``` The constants are uniform in dimension, exposure, degeneracies, and spacings. They are not optimized. The statement concerns fixed positive error; the error dependence in (S3) is not claimed sharp as $`\epsilon\downarrow0`$. @@ -47,12 +47,12 @@ The constants are uniform in dimension, exposure, degeneracies, and spacings. Th Suppose a subspace $`P S`$ is spanned by eigenvectors whose eigenvalues lie in an interval of diameter $`a\ge0`$. There is a subspace encoder and a trace-preserving terminal decoder for which ```math -\frac12\|\Lambda_t-\operatorname{id}_{\operatorname{rank}P}\|_\diamond +\frac12\|\Lambda_t-\mathrm{id}_{\mathrm{rank}P}\|_\diamond \le \min\{1,ta^2/4\}. -\tag{S4} +\qquad\text{(S4)} ``` -**Proof.** Let $`V:\mathbb C^{\operatorname{rank}P}\to S`$ be an isometry with range $`P S`$. The encoded subspace is invariant under $`\Phi_t`$. Subtract the midpoint of its spectral interval from $`V^\dagger A V`$, obtaining a Hermitian $`B`$ with $`\|B\|\le a/2`$. Scalar shifts leave the double commutator unchanged. +**Proof.** Let $`V:\mathbb C^{\mathrm{rank}P}\to S`$ be an isometry with range $`P S`$. The encoded subspace is invariant under $`\Phi_t`$. Subtract the midpoint of its spectral interval from $`V^\dagger A V`$, obtaining a Hermitian $`B`$ with $`\|B\|\le a/2`$. Scalar shifts leave the double commutator unchanged. For every ancillary register and trace-class operator $`X`$, left and right multiplication satisfy @@ -64,25 +64,25 @@ and the two terms involving $`B^2`$ obey the corresponding bounds. Therefore ```math \|\mathcal L_B\|_\diamond\le 2\|B\|^2\le a^2/2. -\tag{S5} +\qquad\text{(S5)} ``` The semigroup $`e^{s\mathcal L_B}`$ is a channel, so its diamond norm is one. Integrating the derivative gives ```math -e^{t\mathcal L_B}-\operatorname{id} +e^{t\mathcal L_B}-\mathrm{id} =\int_0^t e^{s\mathcal L_B}\mathcal L_B\,ds, \qquad -\frac12\|e^{t\mathcal L_B}-\operatorname{id}\|_\diamond +\frac12\|e^{t\mathcal L_B}-\mathrm{id}\|_\diamond \le ta^2/4. -\tag{S6} +\qquad\text{(S6)} ``` Use $`\mathcal E(X)=VXV^\dagger`$ and, for an arbitrary fixed logical density operator $`\tau_0`$, ```math -\mathcal R(Y)=V^\dagger YV+\operatorname{Tr}[(I-P)Y]\,\tau_0. -\tag{S7} +\mathcal R(Y)=V^\dagger YV+\mathrm{Tr}[(I-P)Y]\,\tau_0. +\qquad\text{(S7)} ``` This is a completely positive trace-preserving extension of the inverse embedding. The encoded channel has support inside $`P S`$, so $`\mathcal R\Phi_t\mathcal E=e^{t\mathcal L_B}`$. This proves (S4), including arbitrary inaccessible references. The bound by one is the general maximum half-diamond distance between channels. $`\square`$ @@ -103,7 +103,7 @@ Let $`\Phi_G(X)=G\odot X`$ be any Schur channel, so $`G\succeq0`$ and $`G_{ii}=1 ```math F_e\le\frac{\mu}{D}, -\tag{S8} +\qquad\text{(S8)} ``` where $`F_e=\langle\Omega_D|\rho_{RQ}^{\rm out}|\Omega_D\rangle`$ and $`\left|\Omega_D\right\rangle=D^{-1/2}\sum_{a=1}^D|a\rangle_R|a\rangle_Q`$. This is the overlap with a pure maximally entangled target, without a square root. @@ -112,7 +112,7 @@ where $`F_e=\langle\Omega_D|\rho_{RQ}^{\rm out}|\Omega_D\rangle`$ and $`\left|\O ```math \Phi_G\le_{\rm CP}\mu\Delta, -\tag{S9} +\qquad\text{(S9)} ``` meaning that $`\mu\Delta-\Phi_G`$ is completely positive. @@ -122,8 +122,8 @@ Apply the encoder instrument $`\{\mathcal E_c\}`$ to the logical half of $`|\Ome ```math \rho_{RQ}^{\rm out}\le\mu\sigma_{RQ}, \qquad -\sigma_{RQ}:=\sum_c(\operatorname{id}_R\otimes\mathcal R_c\Delta)(\rho_{RS}^{(c)}). -\tag{S10} +\sigma_{RQ}:=\sum_c(\mathrm{id}_R\otimes\mathcal R_c\Delta)(\rho_{RS}^{(c)}). +\qquad\text{(S10)} ``` The comparison state $`\sigma_{RQ}`$ is normalized and separable. Explicitly, set @@ -138,15 +138,15 @@ Then ```math \sigma_{RQ}=\sum_{c,i}X_{ci}\otimes\tau_{ci}, -\qquad \sum_{c,i}\operatorname{Tr}X_{ci}=1. -\tag{S11} +\qquad \sum_{c,i}\mathrm{Tr}X_{ci}=1. +\qquad\text{(S11)} ``` Here every $`\tau_{ci}`$ is a density operator. This explicitly includes a retained record whose distribution depends on the unknown input. For normalized product states $`\alpha\otimes\beta`$, ```math \langle\Omega_D|\alpha\otimes\beta|\Omega_D\rangle -=D^{-1}\operatorname{Tr}(\alpha^{\mathsf T}\beta)\le D^{-1}. +=D^{-1}\mathrm{Tr}(\alpha^{\mathsf T}\beta)\le D^{-1}. ``` Convexity gives the same upper bound for $`\sigma_{RQ}`$. Taking the maximally entangled overlap in (S10) proves (S8). Instrument integrals obey the same positive-operator argument. $`\square`$ @@ -155,7 +155,7 @@ If a code has half-diamond error at most $`\epsilon`$, then ```math 1-F_e\le\tfrac12\|\rho_{RQ}^{\rm out}-|\Omega_D\rangle\langle\Omega_D|\|_1\le\epsilon. -\tag{S12} +\qquad\text{(S12)} ``` Combining (S8)–(S12) gives $`D\le\mu/(1-\epsilon)`$. Since $`G\succeq0`$ has trace $`d`$, $`\mu\le d`$, proving the dimension bound in the model as well. No assertion that an optimal encoder selects eigenvectors is used in this converse. @@ -167,7 +167,7 @@ For $`G_t`$ in (S2), ```math \lambda_{\max}(G_t)\le CM_t, \qquad C=2+\sqrt{2\pi}. -\tag{S13} +\qquad\text{(S13)} ``` **Proof.** Fix $`i`$ and write $`y_j=\sqrt t(\lambda_j-\lambda_i)`$. For $`k=0,1,\ldots`$, each of the intervals $`[k,k+1)`$ and $`(-k-1,-k]`$ contains at most $`M_t`$ of the $`y_j`$, counting multiplicity. Their union covers the line; only zero is counted twice. On either interval $`e^{-y_j^2/2}\le e^{-k^2/2}`$. Therefore @@ -177,7 +177,7 @@ For $`G_t`$ in (S2), \le2M_t\sum_{k=0}^\infty e^{-k^2/2} \le2M_t\left(1+\int_0^\infty e^{-u^2/2}\,du\right) =CM_t. -\tag{S14} +\qquad\text{(S14)} ``` The spectral radius of a matrix with nonnegative entries is at most its maximum row sum. Since $`G_t\succeq0`$, its spectral radius is $`\lambda_{\max}(G_t)`$. This proves (S13) and completes Theorem 1. $`\square`$ @@ -196,7 +196,7 @@ Let $`m_*`$ be the largest eigenvalue multiplicity of $`A`$. Then ```math D_0(t;A)=m_*,\qquad t\gt 0. -\tag{S15} +\qquad\text{(S15)} ``` **Proof.** Write the distinct eigenvalues as $`\nu_1,\ldots,\nu_\ell`$, with spectral projectors $`P_\alpha`$, and define block dephasing @@ -215,7 +215,7 @@ Let $`\eta=\lambda_{\min}(H)\gt 0`$. If $`T:\mathbb C^\ell\to\mathbb C^d`$ maps for a channel $`\Theta`$. If an allowed encoder and recovery make $`\Phi_t`$ exactly the logical identity, the same convex decomposition holds for the resulting logical channels. The identity channel has a rank-one Choi matrix and is an extreme channel, so the same code must correct $`\Pi_A`$ exactly. This conclusion also holds for an encoding instrument after summing its branches. -The correlation matrix of $`\Pi_A`$ consists of all-one blocks of sizes $`\operatorname{rank}P_\alpha`$, and hence has maximum eigenvalue $`m_*`$. Lemma 2 with $`F_e=1`$ now gives $`D\le m_*`$. Encoding in a largest eigenspace attains equality. $`\square`$ +The correlation matrix of $`\Pi_A`$ consists of all-one blocks of sizes $`\mathrm{rank}P_\alpha`$, and hence has maximum eigenvalue $`m_*`$. Lemma 2 with $`F_e=1`$ now gives $`D\le m_*`$. Encoding in a largest eigenspace attains equality. $`\square`$ ## Attribution of the converse method