diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..9a6cb46 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,57 @@ +name: Verify science and hosted mathematics + +on: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + verify: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + env: + SOURCE_REVISION: ${{ github.event.pull_request.head.sha || github.sha }} + OPENBLAS_NUM_THREADS: 1 + OMP_NUM_THREADS: 1 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + fetch-depth: 0 + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Reproduce finite scientific checks + run: | + python -m pip install -r verification/requirements.txt + python verification/check_reference_identification.py > science-results.json + - name: Install browser and source compiler + run: | + npm install --prefix "$RUNNER_TEMP/qri-hosted-deps" --no-audit --no-fund playwright@1.56.1 mathjax-full@3.2.1 + "$RUNNER_TEMP/qri-hosted-deps/node_modules/.bin/playwright" install --with-deps chromium + - name: Capture actual pinned GitHub pages at two widths + env: + NODE_PATH: ${{ runner.temp }}/qri-hosted-deps/node_modules + run: | + node verification/hosted/capture_hosted_math.cjs \ + --root "$GITHUB_WORKSPACE" \ + --repository "$GITHUB_REPOSITORY" \ + --revision "$SOURCE_REVISION" \ + --contract verification/hosted/math-contract.json \ + --output "$GITHUB_WORKSPACE/hosted-evidence" + - name: Retain verification evidence + if: always() + uses: actions/upload-artifact@v4 + with: + name: qri-verification-${{ env.SOURCE_REVISION }} + path: | + science-results.json + hosted-evidence/ + if-no-files-found: error + retention-days: 14 diff --git a/.gitignore b/.gitignore index 5979117..e4e1abb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__/ *.py[cod] verification/results.new.json +/science-results.json +/hosted-evidence/ diff --git a/README.md b/README.md index 4dac6ef..bdaad20 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,26 @@ How much of a quantum reference library survives measurement before a future query is known? This project studies identification from supplied copies: retain the references as quantum states, or measure the entire library first and keep an unrestricted classical record. -A library contains $M$ independent Haar-distributed pure states in dimension $d$. The input consists of $m$ labeled copies of every reference and $t$ copies of a uniformly selected library member. The output is its label. No classical reference descriptions, preparation or inverse oracles, or QRAM are supplied. +A library contains $`M`$ independent Haar-distributed pure states in dimension $`d`$. The input consists of $`m`$ labeled copies of every reference and $`t`$ copies of a uniformly selected library member. The output is its label. No classical reference descriptions, preparation or inverse oracles, or QRAM are supplied. Write -$$ +```math D_s=\binom{d+s-1}{s},\qquad C=\frac{D_mD_t}{D_{m+t}}. -$$ - -For $M\ge 2$, the optimal average error obeys +``` +For $`M\ge 2`$, the optimal average error obeys -$$ +```math \frac{M-1}{8C+4(M-2)}\le e_{\mathrm{opt}}\le\frac{M-1}{C+M-1}. -$$ - -Sequential symmetric-subspace tests give an explicit decoder with error at most $2(M-1)/C$. Reliable identification therefore requires and permits $C$ of order $M/\epsilon$ for small target error $\epsilon$, up to universal constants. +``` +Sequential symmetric-subspace tests give an explicit decoder with error at most $`2(M-1)/C`$. Reliable identification therefore requires and permits $`C`$ of order $`M/\epsilon`$ for small target error $`\epsilon`$, up to universal constants. -The classical comparison allows **any collective measurement of all references**, unlimited computation and classical storage, but no quantum information from training may survive until the query arrives. Even revealing the exact later query state does not remove the fixed-reference ceiling. For each fixed positive integer $m$, as $M\to\infty$ and $d/\log M\to\infty$, +The classical comparison allows **any collective measurement of all references**, unlimited computation and classical storage, but no quantum information from training may survive until the query arrives. Even revealing the exact later query state does not remove the fixed-reference ceiling. For each fixed positive integer $`m`$, as $`M\to\infty`$ and $`d/\log M\to\infty`$, -$$ +```math P_{\mathrm{classical}}^{\mathrm{revealed}} =(1+o(1))\frac{(\log M)^m}{m!M}. -$$ - +``` The logarithm is natural. The ceiling is attained to leading order by independent covariant reference measurements; its converse includes collective training. These statements quantify loss across a delayed-query memory boundary, with a fixed supplied reference budget. | Question | Authoritative account | @@ -38,7 +35,7 @@ The logarithm is natural. The ceiling is attained to leading order by independen | Which ingredients and results are inherited? | [Related work](references/RELATED_WORK.md) | | How can the finite identities be reproduced? | [Verification](verification/README.md) | -Start with the [connected science route](science/README.md). The [LLM reading guide](llms.txt) maps questions directly to proofs. +Start with the [connected science route](science/README.md), or follow the [three-qubit walkthrough](learning/WALKTHROUGH.md). The [learning route](learning/README.md) connects the selected Watrous anchor to a [30-milestone map](learning/MILESTONES.md) and the full proofs. The [LLM reading guide](llms.txt) maps questions directly to authoritative sources. ## Reproduce @@ -47,11 +44,11 @@ python3 -m pip install -r verification/requirements.txt OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 python3 verification/check_reference_identification.py ``` -The verification guide states the tested instances, numerical tolerances and limits. Dense finite checks supplement the analytical proofs; they do not establish an unrestricted optimal measurement numerically. +The verification guide states the tested instances, numerical tolerances and limits. The [hosted-rendering check](verification/hosted/README.md) captures commit-pinned mathematical pages at wide and narrow widths. Dense finite checks supplement the analytical proofs; they do not establish an unrestricted optimal measurement numerically. ## Scope -The results are Bayesian for an independent Haar pure-state library, a uniform label, equal reference-copy counts, and one lookup. They do not establish a worst-case arbitrary-library converse, mixed-state robustness, repeatable database use, or a total-runtime speedup. The decoder scans references, consumes real quantum storage, and charges all $Mm+t$ supplied specimens. Classical shadows already provide a logarithmic reference-copy comparator for a later known query; the fixed-$m$ success separation is not an exponential reference-sample advantage. +The results are Bayesian for an independent Haar pure-state library, a uniform label, equal reference-copy counts, and one lookup. They do not establish a worst-case arbitrary-library converse, mixed-state robustness, repeatable database use, or a total-runtime speedup. The decoder scans references, consumes real quantum storage, and charges all $`Mm+t`$ supplied specimens. Classical shadows already provide a logarithmic reference-copy comparator for a later known query; the fixed $`m`$ success separation is not an exponential reference-sample advantage. ## Purpose and contact diff --git a/learning/ANCHOR_AND_BRIDGE.md b/learning/ANCHOR_AND_BRIDGE.md new file mode 100644 index 0000000..23bf8cc --- /dev/null +++ b/learning/ANCHOR_AND_BRIDGE.md @@ -0,0 +1,88 @@ +# Educational anchor and bridge + +The sole educational anchor is John Watrous, *The Theory of Quantum Information* (Cambridge University Press, 2018). Use the [author’s book page](https://cs.uwaterloo.ca/~watrous/TQI/) and its linked manuscript; the section and equation numbers below refer to the author’s standard-layout 2018 PDF. The book supplies the mathematical language. The linked project proofs supply the identification model and its evaluated bounds. Reading the whole book is unnecessary. + +## A targeted route through the anchor + +| Project prerequisite | Verified Watrous pointer | Continue here | +| --- | --- | --- | +| Density operators, mixtures, pure and flat states | [Chapter 2](https://cs.uwaterloo.ca/~watrous/TQI/TQI.2.pdf), §2.1.2; Eqs. (2.12), (2.14) | [Model](../science/model.md) | +| Partial trace and joint registers | Chapter 2, §2.1.3 | [Collective-training posterior](../science/classical_preprocessing.md#a-collective-training-measurement-still-has-positive-one-label-posteriors) | +| POVMs and outcome probabilities | Chapter 2, §2.3.1 | [Identification objective](../science/quantum_identification.md) | +| Projective and nondestructive measurements | Chapter 2, §2.3.2 | [Physical symmetry instrument](../science/resources.md) | +| Binary discrimination and the trace norm | [Chapter 3](https://cs.uwaterloo.ca/~watrous/TQI/TQI.3.pdf), §3.1.1, Theorem 3.4 | [Worked qubit example](WALKTHROUGH.md) | +| Ensemble discrimination and the PGM | Chapter 3, §3.1.2; Eqs. (3.49)–(3.52) | [PGM proof](../science/quantum_identification.md#pretty-good-measurement) | +| Permutation projector and symmetric dimension | [Chapter 7](https://cs.uwaterloo.ca/~watrous/TQI/TQI.7.pdf), §7.1.1; Proposition 7.1, Corollary 7.3 | [Averaged hypotheses](../science/quantum_identification.md#haar-averaging-gives-flat-projector-hypotheses) | +| Uniform pure-state measure and its tensor moments | Chapter 7, §7.2.1; Lemma 7.24, Eq. (7.159) | [Haar averaging](../science/model.md#symmetric-spaces) and [posterior moments](../science/classical_preprocessing.md#finite-dimensional-revealed-query-converse) | + +The pure-copy integral is in **§7.2.1**, before §7.2.2. Section 7.3 concentration machinery is not required for the project’s fixed $`m`$ asymptotic proof. + +## Translating notation + +| Watrous convention | This project | +| --- | --- | +| Unit vector $`u`$; associated pure density operator $`uu^*`$ | $`\lvert\psi\rangle`$; often the same symbol $`\psi`$ also denotes $`\lvert\psi\rangle\langle\psi\rvert`$ | +| Adjoint $`A^*`$ and identity $`1_{\mathcal X}`$ | $`A^\dagger`$ and $`I_{\mathcal X}`$ | +| POVM value $`\mu(j)`$ | Measurement effect $`E_j`$ | +| Subnormalized ensemble value $`\eta(j)`$ | $`\rho_j/M`$, because labels are uniform | +| Symmetric subspace on $`s`$ tensor factors | $`\mathcal S_s=\mathrm{Sym}^s(\mathbb C^d)`$, with dimension $`D_s`$ | + +The book’s average ensemble state is $`\sum_j\eta(j)=S/(Mr)`$ here, where $`S=\sum_jP_j`$ and $`\rho_j=P_j/r`$. Substituting this into its PGM formula cancels the scalar factors and gives $`E_j=S^{-1/2}P_jS^{-1/2}`$. All inverse square roots are restricted to their support; assigning zero-probability kernel directions completes the measurement. + +## Bridge 1: averaging does not provide descriptions + +The physical input is an unknown reference library and an unknown matching query. The algorithm cannot insert the unknown $`\psi_j`$ into a measurement formula. Nevertheless, averaging success over the specified prior is linear in the input density operator. Under label $`j`$, the query and that reference are copies of the same state, so their average is $`\Pi_{m+t}/D_{m+t}`$. Every other reference independently averages to $`\tau_m=I_{\mathcal S_m}/D_m`$. + +Their product is $`\rho_j=P_j/r`$ with $`r=D_{m+t}D_m^{M-1}`$. Thus the unknown-library problem becomes discrimination of a known **averaged** ensemble. This is a way to evaluate a universal measurement, not an oracle that reveals the sampled library. The ratio + +```math +C=\frac{\dim\mathcal H}{r} +=\frac{D_mD_t}{D_{m+t}} +``` +measures how concentrated each averaged hypothesis is relative to the common uniform state on $`\mathcal H`$. + +## Bridge 2: a collective record still has a positive posterior + +The earlier training POVM may couple every reference block. To analyze one selected label after outcome $`y`$, integrate all other references out. Their priors are scalar identities on their symmetric supports. Partial tracing the positive training effect therefore gives a positive one-block effect $`A_{y,j}`$; normalization gives a density operator $`a_{y,j}`$. + +The label remains uniform because it was chosen independently of training. Its later-query likelihood is + +```math +q_{y,j}(\psi) +=D_m\langle\psi^{\otimes m}|a_{y,j}|\psi^{\otimes m}\rangle. +``` +Conditioned on $`y`$, the query itself need not have the Haar distribution. Its density relative to Haar is $`\sum_jq_{y,j}/M`$, while its label posterior is $`q_{y,j}/\sum_iq_{y,i}`$. Multiplying the winning posterior by that query density cancels the denominator. The conditional success is exactly $`M^{-1}\int\max_jq_{y,j}(\psi)\,d\psi`$. + +Now take a positive integer moment $`s`$. Haar integration places $`ms`$ copies inside one symmetric projector: + +```math +\int q_{y,j}^s\,d\psi +=\frac{D_m^s}{D_{ms}} +\mathrm{Tr}(a_{y,j}^{\otimes s}\Pi_{ms}) +\leq\frac{D_m^s}{D_{ms}}. +``` +The last step uses only positivity, trace one and $`0\leq\Pi_{ms}\leq I`$. Consequently it covers collective training, not merely independent estimation. Bounding the maximum by an $`s`$-norm, then choosing $`s`$ of order $`\log M/m`$, produces the sharp fixed $`m`$ ceiling. The [classical proof](../science/classical_preprocessing.md) supplies both that limiting calculation and the covariant strategy attaining it. + +## Bridge 3: why the quantum converse needs three moments + +For the retained references, exact pair overlaps determine a variance-like quantity $`\beta=(M-1)/C`$. Pair overlaps alone could all come from one shared ambiguous subspace, so they do not force the desired accumulation of error. + +Concatenate bases of the hypothesis subspaces and form the Gram matrix $`G`$. Its dimension is $`n=Mr`$; include all its zero eigenvalues. The first three exact moments give + +```math +\mathbb E\lambda=1,\qquad +\mathbb E(\lambda-1)^2=\beta,\qquad +\mathbb E[\lambda(\lambda-1)^2]=\beta+\gamma, +``` +where $`\gamma=(M-1)(M-2)/C^2`$. The inherited discrimination trace bound turns success into $`\mathbb E\sqrt\lambda`$, so error is at least $`\frac12\mathbb E(\sqrt\lambda-1)^2`$. Cauchy–Schwarz converts the two controlled variance expressions into + +```math +e_{\mathrm{opt}}\geq\frac{\beta^2}{4(2\beta+\gamma)}. +``` +The [full proof](../science/quantum_identification.md#error-converse-from-three-moments) gives the polar-decomposition step and constants. Watrous provides the operator and discrimination foundations; this evaluated argument is supplied locally. + +## Research ingredients beyond the anchor + +The [related-work account](../references/RELATED_WORK.md) credits Tyson’s generalized Holevo–Curlander bound, Gao’s sequential union bound and the inherited measure-and-prepare decomposition. These are primary research dependencies, not additional educational anchors. The [resource account](../science/resources.md) supplies the explicit symmetry instrument and its charged finite precision. Neither a textbook discrimination formula nor a POVM existence theorem supplies those gate and disturbance guarantees automatically. + +Use the [worked example](WALKTHROUGH.md) for a complete small instance, then return to the [scientific route](../science/README.md). The common milestone map organizes understanding; these pages record no individual reader’s assessment or progress. diff --git a/learning/MILESTONES.md b/learning/MILESTONES.md new file mode 100644 index 0000000..39b92f8 --- /dev/null +++ b/learning/MILESTONES.md @@ -0,0 +1,251 @@ +# Thirty milestones for Quantum Reference Identification + +[Learning route](README.md) · [Scientific account](../science/README.md) + +This is a project-defined understanding map for any reader. Its sole educational anchor is John Watrous, *The Theory of Quantum Information* (2018), using the author's [official pre-publication PDF](https://cs.uwaterloo.ca/~watrous/TQI/TQI.pdf). Section references below follow that version. The anchor supplies the state, measurement, discrimination and invariant-measure framework; the linked project sources supply the specialized arguments and their research-level dependencies. + +The allocation is **12 background/preliminaries milestones and 18 narrative/innovation milestones**. The background combines the local objects into the complete delayed-query experiment. The narrative builds the quantum and classical proofs, then joins their resource and scope conditions into the scientific conclusion. More space goes to that narrative because the result depends on connecting several short arguments across an irreversible measurement boundary. This map does not replace the complete proofs or cover every neighboring topic. + +## Background and preliminaries: M01–M12 + +### M01 — Physical states and descriptions + +- **Central question:** What exactly is supplied to a quantum reference-identification algorithm? +- **Understanding target:** Distinguish a physical unknown state, its label, and a classical specification of its amplitudes. Explain why one does not automatically grant the other. +- **Dependencies and story role:** No earlier milestones; identify the individual input objects before combining them. +- **Conceptual connection:** Registers turn the phrase “quantum database” into a concrete collection of physical systems with a single-label output. +- **Source pointers:** Watrous §2.1.1–§2.1.2; [model: delayed membership query](../science/model.md#a-delayed-membership-query). + +### M02 — Pure states, mixtures and ignorance + +- **Central question:** How can each reference be pure while an averaged reference is mixed? +- **Understanding target:** Explain the density-operator description and separate randomness in preparation from a claim that an individual supplied specimen is physically maximally mixed. +- **Dependencies and story role:** M01; give each physical object a mathematical state before introducing copies. +- **Conceptual connection:** Bayesian averaging is the source of tractable hypothesis operators, not an extra depolarizing operation on the input. +- **Source pointers:** Watrous §2.1.2; [model: symmetric spaces](../science/model.md#symmetric-spaces); [Haar-averaged hypotheses](../science/quantum_identification.md#haar-averaging-gives-flat-projector-hypotheses). + +### M03 — Copies and composite registers + +- **Central question:** What information is present in several copies of one unknown state? +- **Understanding target:** Read a tensor-power state, distinguish it from independent draws of different states, and keep reference-copy and query-copy budgets separate. +- **Dependencies and story role:** M01–M02; combine specimens into a reference block and a query block. +- **Conceptual connection:** Supplied copies are a resource; writing a tensor power does not provide a cloning operation or a preparation oracle. +- **Source pointers:** Watrous §2.1.2; [model](../science/model.md#a-delayed-membership-query); [resource convention](../science/model.md#resource-convention). + +### M04 — Reductions and averaging spectators + +- **Central question:** How do the other reference blocks disappear from a one-label calculation? +- **Understanding target:** Explain partial trace and averaging over an independent spectator block, while preserving the correlations between a selected reference and its query. +- **Dependencies and story role:** M02–M03; connect local blocks to the complete library state. +- **Conceptual connection:** The same reduction principle later produces scalar projector traces and positive conditional classical-training posteriors. +- **Source pointers:** Watrous §2.1.3; [pair and triple overlaps](../science/quantum_identification.md#exact-pair-and-triple-overlaps); [collective-training posteriors](../science/classical_preprocessing.md#a-collective-training-measurement-still-has-positive-one-label-posteriors). + +### M05 — A measurement that returns a label + +- **Central question:** How is the probability of a correct identification defined? +- **Understanding target:** Explain positive measurement effects summing to the identity, the Born rule, and averaging over the uniform label and random library. +- **Dependencies and story role:** M01–M04; turn the physical experiment into a precise decision problem. +- **Conceptual connection:** Every permitted retained-quantum strategy has a joint POVM description, whereas a Bayesian guarantee need not hold for each fixed library. +- **Source pointers:** Watrous §2.3.1–§2.3.2 and §3.1.2; [model](../science/model.md#a-delayed-membership-query); [fixed and typical libraries](../science/quantum_identification.md#fixed-and-typical-libraries). + +### M06 — Channels, records and measurement disturbance + +- **Central question:** Why must a sequential decoder specify more than the probability that a test accepts? +- **Understanding target:** Distinguish an outcome probability from the corresponding change of state. Explain a measurement instrument and how a classical record can control a later operation. +- **Dependencies and story role:** M03–M05; add the temporal behavior of operations to the static measurement description. +- **Conceptual connection:** A valid rejection branch is needed for the scan; discarding every quantum training output creates the classical-preprocessing boundary. +- **Source pointers:** Watrous §2.2.1–§2.2.3 and §2.3.1–§2.3.2; [sequential decoder](../science/quantum_identification.md#sequential-symmetry-decoder); [clean reflection](../science/resources.md#a-clean-reflection-from-permutation-averaging). + +### M07 — The symmetric subspace + +- **Central question:** Which part of a many-register space contains identical pure-state copies? +- **Understanding target:** Explain permutation invariance, the symmetric projector and its dimension. Distinguish symmetry of vectors from a statement that every operator on several registers is symmetric. +- **Dependencies and story role:** M03 and M06; identify the geometric support on which the comparison test acts. +- **Conceptual connection:** Symmetry is both an information constraint and an observable that can be implemented without knowing the state amplitudes. +- **Source pointers:** Watrous §7.1.1; [symmetric spaces](../science/model.md#symmetric-spaces); [permutation-average projector](../science/resources.md#a-clean-reflection-from-permutation-averaging). + +### M08 — Haar moments as invariant averages + +- **Central question:** Why does averaging identical Haar copies give the normalized symmetric projector? +- **Understanding target:** Connect unitary invariance, support on the symmetric subspace, and normalization by its dimension. Explain the role of the input prior. +- **Dependencies and story role:** M02–M04 and M07; connect geometry to the actual random-library ensemble. +- **Conceptual connection:** The Haar moment identity converts an unknown-state classification problem into explicit finite-dimensional operators. +- **Source pointers:** Watrous §7.1.1 and §7.2.1–§7.2.2; [symmetric-space notation](../science/model.md#symmetric-spaces); [averaged hypotheses](../science/quantum_identification.md#haar-averaging-gives-flat-projector-hypotheses). + +### M09 — Ensemble discrimination and a null comparison + +- **Central question:** How can an operator inequality limit every possible decoder? +- **Understanding target:** Explain why a common positive upper bound on all hypothesis states yields a success bound after summing POVM effects. Keep a converse separate from a constructed measurement. +- **Dependencies and story role:** M05 and M08; prepare a global statement from local operator bounds. +- **Conceptual connection:** Comparing a correlated hypothesis to an independent null state is the short route to the finite-query capacity converse. +- **Source pointers:** Watrous §3.1.2; [finite-dimensional bounds](../science/quantum_identification.md#finite-dimensional-bounds); [averaged hypotheses](../science/quantum_identification.md#haar-averaging-gives-flat-projector-hypotheses). + +### M10 — Spectra, support inverses and Gram matrices + +- **Central question:** What information is gained by replacing overlapping subspaces with their Gram spectrum? +- **Understanding target:** Explain positive square roots, inverses restricted to support, and how a Gram matrix shares nonzero eigenvalues with a sum of projectors while retaining different zero multiplicities. +- **Dependencies and story role:** M05 and M07–M09; prepare the spectral language used for both achievability and error accumulation. +- **Conceptual connection:** A success construction uses an inverse square root; an all-decoder converse uses the deficit of a square-root trace. +- **Source pointers:** Watrous §1.1.3 and §3.1.2; [pretty-good measurement](../science/quantum_identification.md#pretty-good-measurement); [three-moment converse](../science/quantum_identification.md#error-converse-from-three-moments). + +### M11 — Conditional likelihoods after training + +- **Central question:** How does a classical training outcome change the distribution of the later query? +- **Understanding target:** Explain conditional probabilities and likelihoods relative to Haar measure. Distinguish a uniform prior label from the generally nonuniform conditional query marginal. +- **Dependencies and story role:** M04–M06 and M08; connect measurement outcomes with the later classical decision problem. +- **Conceptual connection:** Positive one-label posterior operators let a collective training measurement be analyzed without pretending its outcomes factor by reference. +- **Source pointers:** Watrous §1.2.2, §2.1.3 and §2.3.2; [collective-training posteriors](../science/classical_preprocessing.md#a-collective-training-measurement-still-has-positive-one-label-posteriors). + +### M12 — The complete delayed-query experiment + +- **Central question:** Which comparison isolates the value of retaining a quantum reference? +- **Understanding target:** Reconstruct the retained-quantum, classical-training and exactly revealed-query experiments, specifying when each input is available, what survives training, what is optimized, and which resources are charged. +- **Dependencies and story role:** M01–M11; integrate the background into the full problem rather than introduce another isolated definition. +- **Conceptual connection:** Chronology and resource matching determine which later inequalities express a quantum-memory advantage. +- **Source pointers:** Watrous §2.1–§2.3 and §3.1.2; [model](../science/model.md); [complete resource account](../science/resources.md#complete-input-and-memory-account); [interpretation](../science/interpretation.md). + +## Narrative and innovation: M13–M30 + +### M13 — Correlation becomes a projector hypothesis + +- **Central question:** What distinguishes the correct reference after averaging unknown state amplitudes? +- **Understanding target:** Derive the flat projector form of each hypothesis and explain why the query is jointly symmetric with precisely the selected reference block. +- **Dependencies and story role:** M07–M09 and M12; begin the contribution from its local correlated block. +- **Conceptual connection:** The rank ratio between a hypothesis support and the full input support defines the capacity parameter used throughout the finite-query result. +- **Source pointers:** Watrous §7.1.1 and §7.2.1; [Haar-averaged projector hypotheses](../science/quantum_identification.md#haar-averaging-gives-flat-projector-hypotheses). + +### M14 — Pair and triple overlap identities + +- **Central question:** How does independence control products of projectors that do not commute? +- **Understanding target:** Explain the spectator partial-trace step and obtain the second and third trace moments, keeping repeated and distinct label indices separate. +- **Dependencies and story role:** M04, M10 and M13; build the overlap data before applying either decoder or converse machinery. +- **Conceptual connection:** The third moment rules out an ambiguity pattern that pair overlaps alone could leave unresolved. +- **Source pointers:** Watrous §2.1.3 and §7.2.1; [exact overlaps](../science/quantum_identification.md#exact-pair-and-triple-overlaps); [error converse](../science/quantum_identification.md#error-converse-from-three-moments). + +### M15 — The all-decoder capacity converse + +- **Central question:** Why can no joint measurement overcome an insufficient hypothesis-support ratio? +- **Understanding target:** Apply the null-state operator comparison to every POVM and interpret the resulting success ceiling, including the random-guessing and no-reference limits. +- **Dependencies and story role:** M09, M12–M13; promote the local support calculation to a global impossibility statement. +- **Conceptual connection:** An unrestricted measurement converse is stronger than a failure analysis for a particular scan, while remaining Bayesian in the Haar library. +- **Source pointers:** Watrous §3.1.2; [finite-dimensional bounds](../science/quantum_identification.md#finite-dimensional-bounds); [averaged hypotheses](../science/quantum_identification.md#haar-averaging-gives-flat-projector-hypotheses); [model edge cases](../science/model.md#symmetric-spaces). + +### M16 — An achievable information-theoretic frontier + +- **Central question:** How can overlapping support projectors define a successful measurement? +- **Understanding target:** Explain the pretty-good measurement, its support inverse, and the Jensen and Cauchy–Schwarz steps giving its success lower bound. +- **Dependencies and story role:** M10 and M13–M15; pair the converse with a valid measurement at the same success order. +- **Conceptual connection:** Achievability of a probability frontier does not establish a fast implementation of the global inverse square root. +- **Source pointers:** Watrous §1.2.1 and §3.1.2; [pretty-good measurement](../science/quantum_identification.md#pretty-good-measurement). + +### M17 — A scan that survives earlier rejections + +- **Central question:** Why can one query block be used in a sequence of noncommuting tests? +- **Understanding target:** Explain the reject-earlier-labels/accept-correct-label path and the noncommutative union-bound guarantee. Distinguish it from unjustified independence of successive outcomes. +- **Dependencies and story role:** M06, M12–M14 and M16; replace the abstract measurement by a constructive sequential decoder. +- **Conceptual connection:** An inherited disturbance bound yields the same success order and an explicit small-error algorithm using the supplied specimens. +- **Source pointers:** Watrous §2.2–§2.3 and §3.1.2 for the instrument/discrimination framework; [sequential decoder](../science/quantum_identification.md#sequential-symmetry-decoder), which states and attributes the additional Gao bound. + +### M18 — Why errors accumulate with many labels + +- **Central question:** What prevents every false label from sharing one negligible ambiguous component? +- **Understanding target:** Follow the specialized trace bound, retain Gram zero eigenvalues, and connect the three exact moments to a quantitative error lower bound for every decoder. +- **Dependencies and story role:** M10 and M14–M17; strengthen a coarse success threshold into the all-accuracy error law. +- **Conceptual connection:** The new ensemble evaluation uses an inherited discrimination inequality; neither the inequality nor its generic spectral ingredients are claimed as new. +- **Source pointers:** Watrous §1.1.3 and §3.1.2 for matrix norms and discrimination; [three-moment error converse](../science/quantum_identification.md#error-converse-from-three-moments), including the additional Tyson dependency. + +### M19 — Capacity, dimension and library quantifiers + +- **Central question:** When can the finite-dimensional frontier be read as a query-copy scaling law? +- **Understanding target:** Combine the upper and lower bounds, retain the dimension condition when replacing capacity by a binomial coefficient, and distinguish Haar-average claims from deterministic or typical-library guarantees. +- **Dependencies and story role:** M12–M18; integrate the quantum bounds before turning to circuit realization and classical preprocessing. +- **Conceptual connection:** A fixed-reference query scale is a resource tradeoff; its sufficient separated-library conditions are not an all-library converse. +- **Source pointers:** Watrous §1.2.2 and §7.2.1–§7.2.2; [finite-query frontier](../science/interpretation.md#finite-query-frontier); [fixed and typical libraries](../science/quantum_identification.md#fixed-and-typical-libraries). + +### M20 — From a symmetry average to a true instrument + +- **Central question:** How is the required rejection channel obtained from permutation averaging? +- **Understanding target:** Explain the prepare–select–unprepare block, its clean reflection, and the flag measurement that produces the two Lüders branches while returning the ideal workspace. +- **Dependencies and story role:** M06–M07 and M17; implement the precise local operation assumed by the scan proof. +- **Conceptual connection:** An acceptance block equal to a projector is not by itself a proof of the correct Lüders rejection instrument; the reflection closes that implementation gap. +- **Source pointers:** Watrous §2.2.2–§2.2.3, §2.3.1 and §7.1.1; [clean-reflection construction](../science/resources.md#a-clean-reflection-from-permutation-averaging). The circuit construction is supplied locally rather than attributed to the anchor. + +### M21 — Finite precision and complete costs + +- **Central question:** What resources are needed for the constructive identification guarantee? +- **Understanding target:** Account for all supplied copies, stored data, active registers, comparisons and finite-gate precision. Explain why per-test approximation errors must shrink with scan length. +- **Dependencies and story role:** M12 and M17–M20; turn a mathematical instrument into a finite-resource algorithm statement. +- **Conceptual connection:** Channel-distance composition controls statistical error, while a polynomial circuit and a copy advantage do not establish a runtime advantage. +- **Source pointers:** Watrous §3.3.2–§3.3.3; [gate count and precision](../science/resources.md#gate-count-and-precision); [complete resource account](../science/resources.md#complete-input-and-memory-account), including the separately attributed synthesis dependency. + +### M22 — Collective training without a factorization assumption + +- **Central question:** How can all possible classical training records be bounded at once? +- **Understanding target:** Derive the positive effective operator for each label after an arbitrary collective reference measurement, and normalize its posterior likelihood correctly. +- **Dependencies and story role:** M04, M11–M12; begin the classical argument from the most general allowed local conditional object. +- **Conceptual connection:** Unlimited classical storage does not remove the information constraint expressed by a positive density operator on the symmetric reference space. +- **Source pointers:** Watrous §2.1.3 and §2.3.1–§2.3.2; [collective-training posterior proof](../science/classical_preprocessing.md#a-collective-training-measurement-still-has-positive-one-label-posteriors). + +### M23 — A moment converse even for a perfect later query + +- **Central question:** Why can later query information fail to repair the earlier measurement loss? +- **Understanding target:** Apply Haar moments to a posterior likelihood, bound its powers, and convert the maximum over labels into a finite-dimensional success ceiling valid for every collective training outcome. +- **Dependencies and story role:** M08–M11 and M22; promote the posterior constraint to an all-protocol classical converse. +- **Conceptual connection:** Giving away the exact later query strengthens the decoder, so the resulting ceiling also covers every finite query-copy budget under the same chronology. +- **Source pointers:** Watrous §1.2.1–§1.2.2 and §7.2.1; [finite-dimensional revealed-query converse](../science/classical_preprocessing.md#finite-dimensional-revealed-query-converse). + +### M24 — A covariant classical strategy + +- **Central question:** Can an actual classical training protocol approach that ceiling? +- **Understanding target:** Explain the independent covariant reference measurements and maximum-likelihood lookup, deriving their exact success in terms of the largest Haar overlap. Keep protocol performance separate from the finite-parameter optimum. +- **Dependencies and story role:** M05, M08, M11 and M22–M23; construct a matching candidate instead of relying on a converse alone. +- **Conceptual connection:** A continuous classical estimate is permitted by unlimited record storage; its copy cost is still the same supplied reference budget. +- **Source pointers:** Watrous §2.3 and §7.2.1–§7.2.2; [exact covariant strategy](../science/classical_preprocessing.md#a-classical-strategy-with-an-exact-finite-dimensional-success-formula). + +### M25 — Optimizing the classical moment bound + +- **Central question:** How does a finite integer-moment inequality produce the sharp logarithmic ceiling? +- **Understanding target:** Explain the moment-order choice proportional to the logarithm of the label count, the factorial estimate, and the cancellation that fixes the leading constant when the reference-copy count is fixed. +- **Dependencies and story role:** M23–M24; extract the global asymptotic upper bound without strengthening its quantifiers. +- **Conceptual connection:** A lower bound on the large symmetric dimension is sufficient; an unnecessary relative approximation would impose an unnecessarily strong dimension condition. +- **Source pointers:** Watrous §1.2.1–§1.2.2 for analytic and probabilistic tools; [asymptotic upper proof](../science/classical_preprocessing.md#upper-bound). The optimization and Stirling step are supplied in the project proof. + +### M26 — Extreme overlaps close the asymptotic sandwich + +- **Central question:** Why does the covariant strategy attain the same leading ceiling? +- **Understanding target:** Transform Haar overlaps into exponential variables, control the maximum and its fixed moments, and combine that estimate with the converse. State the fixed-reference and growing-dimension assumptions explicitly. +- **Dependencies and story role:** M24–M25; integrate the classical upper and lower arguments into the sharp saturation theorem. +- **Conceptual connection:** The theorem concerns a fixed scarce-reference budget; substituting a growing copy count into its asymptotic would change the claim. +- **Source pointers:** Watrous §1.2.2 and §7.2.1–§7.2.2; [attaining lower proof](../science/classical_preprocessing.md#attaining-lower-bound); [the sharp theorem](../science/classical_preprocessing.md#sharp-asymptotic-ceiling-for-a-fixed-reference-budget). + +### M27 — The inherited finite-query obstruction + +- **Central question:** How does a state-independent posterior component obstruct finite-query classification? +- **Understanding target:** Explain the positive measure-and-prepare decomposition and why its common component cannot identify a label. Distinguish this bound from the sharper ceiling that survives a perfectly revealed query. +- **Dependencies and story role:** M06, M08 and M22–M26; locate an important related mechanism within the completed classical account. +- **Conceptual connection:** A useful finite-query separation follows from established channel machinery; attribution prevents that inherited mechanism from absorbing the new claim. +- **Source pointers:** Watrous §2.2.2–§2.2.3 and §7.2.2 for the channel and averaging framework; [common-component account](../science/classical_preprocessing.md#the-inherited-finite-query-common-component), which identifies the additional Chiribella and Anshu–Landau–Liu sources. + +### M28 — An exactly solvable retained-quantum endpoint + +- **Central question:** What is optimal when the query is described only after the quantum references have been retained? +- **Understanding target:** Explain commuting conditional hypotheses, the independent false-pass distribution, uniform tie breaking and the exact success formula. Distinguish that endpoint from finite-copy query access. +- **Dependencies and story role:** M05, M12, M19 and M23–M27; compare the two models under the same ideal later information. +- **Conceptual connection:** Query tomography can approach the endpoint at fixed parameters, but is not granted as an efficient or finite-copy primitive. +- **Source pointers:** Watrous §2.3 and §3.1.2; [revealed-query endpoint](../science/revealed_query.md); [classical endpoint scope](../science/classical_preprocessing.md#edge-cases-and-scope). + +### M29 — A resource-matched separation + +- **Central question:** Which parameter regime demonstrates the value of retaining the supplied references? +- **Understanding target:** Explain the one-reference-copy comparison with a linear query-copy budget in sufficiently large dimension; contrast fixed-copy saturation with the logarithmic classical-copy necessity and the matched shadow upper comparator. +- **Dependencies and story role:** M19, M21 and M26–M28; connect quantum attainability, classical impossibility and known baselines into one operational statement. +- **Conceptual connection:** Matching supplied references and later information reveals a memory/chronology advantage without claiming an exponential total-sample or runtime improvement. +- **Source pointers:** Watrous §3.1.2 and §7.2.1 for the discrimination and random-state framework; [classical preprocessing loss](../science/interpretation.md#what-classical-preprocessing-loses); [growing budgets and baselines](../science/interpretation.md#growing-reference-budgets-and-matched-baselines); [related work](../references/RELATED_WORK.md). + +### M30 — The complete scientific conclusion and its boundary + +- **Central question:** What has this project established, and what would require a different theorem? +- **Understanding target:** Give a connected account of the multiclass finite-query frontier, sharp classical saturation and implementable scan, with correct attribution, input costs, dimension and chronology conditions. Identify why arbitrary libraries, mixed/noisy states, repeated reuse and runtime superiority remain outside the result. +- **Dependencies and story role:** M12–M29; synthesize the whole narrative rather than append an extra technical topic. +- **Conceptual connection:** Correct proofs, inherited tools, the surviving contribution, finite validation and scope qualifications are distinct parts of the scientific account. +- **Source pointers:** Watrous §2.1–§2.3, §3.1.2 and §7.1–§7.2 as the shared framework; [scientific route](../science/README.md); [scope and interpretation](../science/interpretation.md#what-follows-and-what-remains-outside-the-model); [attribution](../references/RELATED_WORK.md); [verification](../verification/README.md). diff --git a/learning/README.md b/learning/README.md new file mode 100644 index 0000000..2fa0634 --- /dev/null +++ b/learning/README.md @@ -0,0 +1,19 @@ +# Learning route + +[Repository](../README.md) · [Scientific account](../science/README.md) · [Thirty milestones](MILESTONES.md) + +A small unknown quantum reference library arrives before its query. The central distinction is whether those physical references survive until the query is known. The learning route builds the language needed to follow the quantum identification frontier, the classical preprocessing ceiling, and their resource-matched comparison. + +The sole educational anchor is John Watrous, *The Theory of Quantum Information* (2018). Use the author's [official pre-publication PDF](https://cs.uwaterloo.ca/~watrous/TQI/TQI.pdf), with the notation and project-specific missing steps in the [anchor bridge](ANCHOR_AND_BRIDGE.md). The relevant foundations are states and operations in Chapter 2, discrimination and channel distances in Chapter 3, and symmetry and invariant measures in Chapter 7. Chapter 1 supplies the specific linear-algebra, convexity and probability tools when they are needed. Reading the entire book is not a prerequisite. + +The [settled map](MILESTONES.md) contains exactly 30 project-defined milestones: 12 background/preliminaries targets and 18 narrative/innovation targets. The first phase combines physical inputs, measurements, symmetry and chronology into the complete experiment. The second builds the quantum and classical proofs, their implementation and their interpretation. Each target identifies its dependencies, conceptual connection, anchor sections and canonical project sources. The map is shared scientific material independent of any reader's prior knowledge or progress. + +The [worked walkthrough](WALKTHROUGH.md) gives a concrete route from a small comparison to the general statement. For a direct route through the current result: + +1. Read the [model](../science/model.md) and distinguish the three information settings. +2. Follow [finite-query quantum identification](../science/quantum_identification.md) and the [classical preprocessing theorem](../science/classical_preprocessing.md). +3. Compare their [exactly revealed-query endpoints](../science/revealed_query.md). +4. Check the [instrument and resource account](../science/resources.md), then the [regimes and limitations](../science/interpretation.md). +5. Use [related work](../references/RELATED_WORK.md) and [verification](../verification/README.md) to distinguish attribution, proof and finite checks. + +The anchor supplies foundations. The project supplies its specialized ensemble calculations, posterior moment optimization, extreme-overlap argument and clean-reflection construction. Additional primary papers remain scientific dependencies and attribution sources; they do not become extra educational anchors. diff --git a/learning/WALKTHROUGH.md b/learning/WALKTHROUGH.md new file mode 100644 index 0000000..e8f0e2d --- /dev/null +++ b/learning/WALKTHROUGH.md @@ -0,0 +1,99 @@ +# A three-qubit identification example + +Two labeled reference devices each supply one unknown qubit. Independently, their states $`\psi_1,\psi_2`$ are Haar distributed. A later device supplies one more qubit promised to be an exact copy of one reference, selected with equal probability. Return label 1 or 2. This is $`d=2`$, $`M=2`$, $`m=t=1`$: three supplied physical qubits, no state descriptions and one lookup. + +The [anchor bridge](ANCHOR_AND_BRIDGE.md) connects the calculation to Watrous §§2.1.2, 2.3.1, 3.1.1, 7.1.1 and 7.2.1. The general statements and their scope are in the [quantum proof](../science/quantum_identification.md). + +## Averaging one hypothesis + +Order the registers as $`(R_1,R_2,T)`$. If label 1 is true, $`R_1,T`$ contain the same state. Their two-copy average is uniform on the symmetric two-qubit subspace, whose basis is + +```math +|00\rangle,\quad +\frac{|01\rangle+|10\rangle}{\sqrt2},\quad +|11\rangle. +``` +Its dimension is $`D_2=3`$, while $`D_1=2`$. The other reference averages to $`I/2`$. Let $`F_{ab}`$ swap registers $`a,b`$, and put + +```math +P_1=\frac{I+F_{13}}2,\qquad +P_2=\frac{I+F_{23}}2. +``` +Each acts on the full eight-dimensional three-qubit space and has rank six. The two averaged hypotheses are + +```math +\rho_1=\frac{P_1}{6},\qquad +\rho_2=\frac{P_2}{6},\qquad +C=\frac{2\cdot2}{3}=\frac43. +``` +The processor knows these averaged operators because it knows the distribution and register layout. It still does not know either sampled reference direction. + +## An implementable decision + +Measure whether $`R_1,T`$ are symmetric. If they are, return label 1; otherwise return label 2. For two qubits this is the projective pair $`(I+F_{13})/2,(I-F_{13})/2`$. A Hadamard flag, a controlled swap of those registers, and a final Hadamard/flag measurement realize the pair; $`R_2`$ is retained but this particular decision does not use it. + +If label 1 is true, two equal pure states always lie in the symmetric subspace, so the answer is correct with probability one. If label 2 is true, $`R_1`$ and $`T`$ are independent Haar qubits. Their symmetric acceptance averages to its rank divided by the two-qubit dimension, $`3/4`$. This causes a false label-1 answer; rejection, of probability $`1/4`$, gives the correct label 2. The mean success is therefore + +```math +P_{\mathrm{one\ test}}= +\frac12\cdot1+\frac12\cdot\frac14=\frac58. +``` +The procedure uses the three supplied qubits and one flag, with no description oracle. It establishes an achievable probability, not optimality. A larger scan must preserve the correct rejection instrument and account for disturbance; the [implementation account](../science/resources.md) handles that general case. + +## What the general bounds say + +The dimension-sensitive success bounds give + +```math +\frac47\leq P_{\mathrm{opt}}\leq\frac23. +``` +Our explicit $`5/8`$ lies inside that interval. The PGM existence bound $`4/7`$ is a guaranteed lower bound, so a particular decoder may exceed it. Equivalently, combining the error statements gives $`1/3\leq e_{\mathrm{opt}}\leq3/7`$. The additional three-moment lower bound is $`3/32`$ here and is weaker than the rank-capacity lower bound $`1/3`$; universal constants need not be sharp in a small example. + +For this binary instance the exact optimum can also be computed with the established Holevo–Helstrom theorem (Watrous, Theorem 3.4). The difference is + +```math +\rho_1-\rho_2=\frac{F_{13}-F_{23}}{12}. +``` +On the one-excitation basis $`|100\rangle,|010\rangle,|001\rangle`$, the swap difference is + +```math +\begin{pmatrix} +-1&0&1\\ +0&1&-1\\ +1&-1&0 +\end{pmatrix}, +``` +with eigenvalues $`0,\sqrt3,-\sqrt3`$. Flipping every qubit gives the same spectrum on the two-excitation sector; $`|000\rangle`$ and $`|111\rangle`$ give two additional zeros. Thus $`\|\rho_1-\rho_2\|_1=\sqrt3/3`$, where the trace norm adds absolute eigenvalues. Equal-prior binary discrimination yields + +```math +P_{\mathrm{opt}}= +\frac12+\frac14\|\rho_1-\rho_2\|_1 +=\frac12+\frac{\sqrt3}{12} +\approx0.644338. +``` +This is a worked application of an inherited binary theorem; no new binary optimum is claimed. + +## Why the Gram zeros matter + +Here $`r=6`$, so the concatenated Gram matrix used in the error converse has dimension $`Mr=12`$, even though the physical space has dimension eight. Its eigenvalues are $`2`$ four times, $`3/2`$ twice, $`1/2`$ twice, and $`0`$ four times. Their averages give + +```math +\mathbb E\lambda=1,\qquad +\mathbb E\lambda^2=\frac74,\qquad +\mathbb E\lambda^3=\frac{13}4. +``` +These match $`\beta=3/4`$ and $`\gamma=0`$. Removing the four zeros would change the normalization and invalidate the identity relating the square-root deficit to error. The general proof uses all eigenvalues, rather than only the nonzero spectrum of $`P_1+P_2`$. + +## Revealing the later query changes the experiment + +Now supply the exact classical description of the query after the references have been retained. Test each reference against that known pure state. The true reference always passes, while the other passes with probability $`1/D_1=1/2`$. A unique pass identifies the label; if both pass, choose uniformly. Hence + +```math +P_{\mathrm{quantum,revealed}} +=\frac12\cdot1+\frac12\cdot\frac12=\frac34. +``` +For comparison, independently measuring both references covariantly before that description arrives gives the particular classical-record strategy in the [classical account](../science/classical_preprocessing.md). In this case its achievable revealed-query success is $`\mathbb E\max(X_1,X_2)=2/3`$, with $`X_1,X_2`$ independent uniform variables on $`[0,1]`$. That value is not asserted to be the finite-parameter optimum among all collective training measurements. + +The $`2/3`$ classical revealed-query value exceeds the finite-query quantum optimum $`0.644338`$ because it was granted extra query information. It cannot be used to judge the memory comparison at matched inputs. This toy calculation illustrates the operations and information boundary; the universal memory separation comes from the growing $`M`$, fixed $`m`$ theorem, with its stated dimension limit. + +Return to the [anchor bridge](ANCHOR_AND_BRIDGE.md), [scientific reading route](../science/README.md), or [verification guide](../verification/README.md). diff --git a/llms.txt b/llms.txt index e4afc65..11d7da4 100644 --- a/llms.txt +++ b/llms.txt @@ -4,6 +4,10 @@ Purpose: explain identification from a library of unknown supplied pure states, Canonical entry: README.md Connected argument: science/README.md +Conceptual route and sole educational anchor Watrous (2018): learning/README.md +Verified textbook sections, notation and missing steps: learning/ANCHOR_AND_BRIDGE.md +Small complete three-qubit example: learning/WALKTHROUGH.md +Exactly 30 project-defined targets (12 background, 18 narrative): learning/MILESTONES.md Task, timing, notation and edge cases: science/model.md Finite-query success/error theorem and proofs: science/quantum_identification.md Collective classical-training converse and sharp fixed-m asymptotic: science/classical_preprocessing.md @@ -12,6 +16,7 @@ Lüders symmetry measurement, finite precision and charged resources: science/re Operational regimes, dimension conditions and matched classical comparison: science/interpretation.md Attribution, closest work and comparison boundaries: references/RELATED_WORK.md Reproduction commands and finite-check limits: verification/README.md +Actual hosted mathematics, two viewports and verification limits: verification/hosted/README.md Keep the following distinctions when answering: - Haar-average one-lookup claims are not arbitrary-library or repeated-use guarantees. diff --git a/science/README.md b/science/README.md index 5f04970..ad8720b 100644 --- a/science/README.md +++ b/science/README.md @@ -12,3 +12,5 @@ Read these pages in order for the connected argument: 6. [Regimes and interpretation](interpretation.md): what the comparison establishes, dimension requirements and limitations. The [related-work account](../references/RELATED_WORK.md) distinguishes the multiclass consequence from inherited binary identification, Haar integration, state-estimation and discrimination tools. The [verification route](../verification/README.md) checks representative finite instances. + +For a conceptual route, begin with the [worked three-qubit example](../learning/WALKTHROUGH.md), then use the [Watrous bridge](../learning/ANCHOR_AND_BRIDGE.md) and [30 milestones](../learning/MILESTONES.md). diff --git a/science/classical_preprocessing.md b/science/classical_preprocessing.md index 1f8b7e6..f9b45a0 100644 --- a/science/classical_preprocessing.md +++ b/science/classical_preprocessing.md @@ -2,93 +2,83 @@ [Scientific account](README.md) · [Model](model.md) · [Quantum matching](quantum_identification.md) · [Resources](resources.md) -The chronology in this section is essential. A processor receives $m$ copies of each of $M$ independently Haar-distributed pure references in $\mathbb C^d$. It measures the **entire reference collection before learning the query**, retains an unrestricted classical record, and discards every quantum system carrying information from training. Later it receives $t$ copies of a uniformly selected reference and returns its label. The training measurement may be collective across all labels; its output length and computational cost are unrestricted. Retaining quantum side information across this boundary is outside this model. +The chronology in this section is essential. A processor receives $`m`$ copies of each of $`M`$ independently Haar-distributed pure references in $`\mathbb C^d`$. It measures the **entire reference collection before learning the query**, retains an unrestricted classical record, and discards every quantum system carrying information from training. Later it receives $`t`$ copies of a uniformly selected reference and returns its label. The training measurement may be collective across all labels; its output length and computational cost are unrestricted. Retaining quantum side information across this boundary is outside this model. -Write $P_{\mathrm{cl}}(d,M,m,t)$ for its optimal Haar-average success. Let $P_{\mathrm{cl}}^{\mathrm{rev}}(d,M,m)$ denote the more generous endpoint in which the decoder receives an exact classical description of the later query state, after training has ended. Then +Write $`P_{\mathrm{cl}}(d,M,m,t)`$ for its optimal Haar-average success. Let $`P_{\mathrm{cl}}^{\mathrm{rev}}(d,M,m)`$ denote the more generous endpoint in which the decoder receives an exact classical description of the later query state, after training has ended. Then -$$ +```math P_{\mathrm{cl}}(d,M,m,t)\leq P_{\mathrm{cl}}^{\mathrm{rev}}(d,M,m). -$$ - +``` This endpoint supplies later query information for free solely to strengthen an impossibility result. It does not supply descriptions of the reference collection or let the revealed query control the earlier measurement. -For integers $s\geq0$, define +For integers $`s\geq0`$, define -$$ +```math D_s=\binom{d+s-1}{s},\qquad -\tau_s=\frac{I_{\operatorname{Sym}^s(\mathbb C^d)}}{D_s}. -$$ - -Unless stated otherwise, $d\geq2$, $M\geq2$, and $m\geq1$ are integers. The degenerate cases appear below. +\tau_s=\frac{I_{\mathrm{Sym}^s(\mathbb C^d)}}{D_s}. +``` +Unless stated otherwise, $`d\geq2`$, $`M\geq2`$, and $`m\geq1`$ are integers. The degenerate cases appear below. ## A collective training measurement still has positive one-label posteriors -Restrict each reference block to $\mathcal K=\operatorname{Sym}^m(\mathbb C^d)$. Consider a training POVM effect $E_y\geq0$ on $\mathcal K^{\otimes M}$. The prior record probability and its effective effect on label $j$ are +Restrict each reference block to $`\mathcal K=\mathrm{Sym}^m(\mathbb C^d)`$. Consider a training POVM effect $`E_y\geq0`$ on $`\mathcal K^{\otimes M}`$. The prior record probability and its effective effect on label $`j`$ are -$$ -p_y=\operatorname{Tr}(E_y\tau_m^{\otimes M}),\qquad -A_{y,j}=\operatorname{Tr}_{\ne j} +```math +p_y=\mathrm{Tr}(E_y\tau_m^{\otimes M}),\qquad +A_{y,j}=\mathrm{Tr}_{\ne j} \left[E_y\left(I_j\otimes\tau_m^{\otimes(M-1)}\right)\right]. -$$ - -Because each $\tau_m$ is a scalar identity on its support, $A_{y,j}$ is positive and +``` +Because each $`\tau_m`$ is a scalar identity on its support, $`A_{y,j}`$ is positive and -$$ -\operatorname{Tr}A_{y,j}=D_m p_y. -$$ +```math +\mathrm{Tr}A_{y,j}=D_m p_y. +``` +For $`p_y>0`$, set $`a_{y,j}=A_{y,j}/(D_m p_y)`$. This is a density operator on $`\mathcal K`$. The selected label $`J`$ is independent of the training process, so it remains uniform after conditioning on $`y`$. Relative to normalized Haar measure, the conditional density of the query state under label $`j`$ is -For $p_y>0$, set $a_{y,j}=A_{y,j}/(D_m p_y)$. This is a density operator on $\mathcal K$. The selected label $J$ is independent of the training process, so it remains uniform after conditioning on $y$. Relative to normalized Haar measure, the conditional density of the query state under label $j$ is - -$$ +```math q_{y,j}(\psi)=D_m\langle\psi^{\otimes m}|a_{y,j}|\psi^{\otimes m}\rangle. -$$ - -It integrates to one by the Haar moment identity. The conditional query marginal, without conditioning on $j$, need not be Haar; its density is $M^{-1}\sum_jq_{y,j}$. Bayes' rule nevertheless gives the optimal revealed-query success conditional on the record as +``` +It integrates to one by the Haar moment identity. The conditional query marginal, without conditioning on $`j`$, need not be Haar; its density is $`M^{-1}\sum_jq_{y,j}`$. Bayes' rule nevertheless gives the optimal revealed-query success conditional on the record as -$$ +```math P_y^{\mathrm{rev}}=\frac1M\int\max_{j\leq M}q_{y,j}(\psi)\,d\psi. -$$ - -For a finite query, the conditional $t$-copy state is +``` +For a finite query, the conditional $`t`$-copy state is -$$ +```math \sigma_{y,j,t}=D_m\int \langle\psi^{\otimes m}|a_{y,j}|\psi^{\otimes m}\rangle (|\psi\rangle\langle\psi|)^{\otimes t}\,d\psi. -$$ - +``` No factorization of the training POVM has been assumed. Correlations between posterior reference blocks do not enter this one-query decoding objective. Continuous-outcome measurements use an effect density relative to a dominating measure; the same derivation holds almost everywhere, with integrations replacing sums. ## Finite-dimensional revealed-query converse -For every positive integer $s$, the Haar moment formula and $0\leq\Pi_{ms}\leq I$ imply +For every positive integer $`s`$, the Haar moment formula and $`0\leq\Pi_{ms}\leq I`$ imply -$$ +```math \begin{aligned} \int q_{y,j}(\psi)^s\,d\psi &=\frac{D_m^s}{D_{ms}} - \operatorname{Tr}\left(a_{y,j}^{\otimes s}\Pi_{ms}\right)\\ + \mathrm{Tr}\left(a_{y,j}^{\otimes s}\Pi_{ms}\right)\\ &\leq\frac{D_m^s}{D_{ms}}. \end{aligned} -$$ - -Here $a_{y,j}^{\otimes s}$ is positive with trace one, whether or not $a_{y,j}$ is pure or is itself a tensor power. Pointwise, $\max_jq_j\leq(\sum_jq_j^s)^{1/s}$. Integrating and using concavity of the $1/s$ power gives +``` +Here $`a_{y,j}^{\otimes s}`$ is positive with trace one, whether or not $`a_{y,j}`$ is pure or is itself a tensor power. Pointwise, $`\max_jq_j\leq(\sum_jq_j^s)^{1/s}`$. Integrating and using concavity of the $`1/s`$ power gives -$$ +```math P_y^{\mathrm{rev}} \leq M^{1/s-1}\frac{D_m}{D_{ms}^{1/s}}. -$$ - +``` The bound is independent of the record, so it also holds after averaging over an arbitrary collective training measurement. Consequently, -$$ +```math \boxed{ P_{\mathrm{cl}}^{\mathrm{rev}}(d,M,m) \leq\min\left\{1,\inf_{s\in\mathbb N_{\geq1}} M^{1/s-1}\frac{D_m}{D_{ms}^{1/s}}\right\}.} -$$ - -The separate bound $P_{\mathrm{cl}}^{\mathrm{rev}}\leq D_m/M$ follows from $q_{y,j}\leq D_m$; it is also the fixed-$d,m,M$ limit of the displayed expression as $s\to\infty$. The $s=1$ term is the trivial upper bound one. No finite value of $s$ or bounded record size is assumed in the theorem. +``` +The separate bound $`P_{\mathrm{cl}}^{\mathrm{rev}}\leq D_m/M`$ follows from $`q_{y,j}\leq D_m`$; it is also the fixed $`d,m,M`$ limit of the displayed expression as $`s\to\infty`$. The $`s=1`$ term is the trivial upper bound one. No finite value of $`s`$ or bounded record size is assumed in the theorem. The proof uses standard Haar moments and a power-method bound on discrimination. Those tools and the postmeasurement-information framework are inherited; the evaluated multiclass law is the contribution assessed here. See [the source comparison](../references/RELATED_WORK.md). @@ -96,137 +86,123 @@ The proof uses standard Haar moments and a power-method bound on discrimination. Measure each reference block independently using the covariant POVM -$$ +```math D_m|\phi^{\otimes m}\rangle\langle\phi^{\otimes m}|\,d\phi, -$$ - -and record the directions $\phi_1,\ldots,\phi_M$. The outcomes are unconditionally independent Haar directions. When the query $\psi$ is revealed, return a label maximizing $|\langle\phi_j|\psi\rangle|^2$; the exponent $m$ does not change its ordering. +``` +and record the directions $`\phi_1,\ldots,\phi_M`$. The outcomes are unconditionally independent Haar directions. When the query $`\psi`$ is revealed, return a label maximizing $`|\langle\phi_j|\psi\rangle|^2`$; the exponent $`m`$ does not change its ordering. -For a fixed revealed $\psi$, the random variables $X_j=|\langle\phi_j|\psi\rangle|^2$ are independent $\operatorname{Beta}(1,d-1)$ variables. Averaging the maximum posterior likelihood therefore gives the exact achievable value +For a fixed revealed $`\psi`$, the random variables $`X_j=|\langle\phi_j|\psi\rangle|^2`$ are independent $`\mathrm{Beta}(1,d-1)`$ variables. Averaging the maximum posterior likelihood therefore gives the exact achievable value -$$ +```math \boxed{ P_{\mathrm{cov}}(d,M,m) =\frac{D_m}{M}\mathbb E\left[\left(\max_{j\leq M}X_j\right)^m\right] \leq P_{\mathrm{cl}}^{\mathrm{rev}}(d,M,m).} -$$ - -For $m\geq1$, an equivalent integral is +``` +For $`m\geq1`$, an equivalent integral is -$$ +```math \mathbb E\left[\left(\max_jX_j\right)^m\right] =m\int_0^1x^{m-1} \left[1-\left(1-(1-x)^{d-1}\right)^M\right]dx. -$$ +``` +This is an exact formula for the specified protocol, **not** a claim of finite-parameter optimality among collective training measurements. In particular, when $`m=1`$ it simplifies to -This is an exact formula for the specified protocol, **not** a claim of finite-parameter optimality among collective training measurements. In particular, when $m=1$ it simplifies to - -$$ +```math P_{\mathrm{cov}}(d,M,1)=\frac dM \left[1-\frac{\Gamma(M+1)\Gamma(1+1/(d-1))} {\Gamma(M+1+1/(d-1))}\right]. -$$ - -At fixed $M$ and $d\to\infty$, this tends to $H_M/M$, where $H_M=\sum_{j=1}^M1/j$. That limit concerns this protocol; it does not assert the exact finite-$M$ optimum. +``` +At fixed $`M`$ and $`d\to\infty`$, this tends to $`H_M/M`$, where $`H_M=\sum_{j=1}^M1/j`$. That limit concerns this protocol; it does not assert the exact finite $`M`$ optimum. ## Sharp asymptotic ceiling for a fixed reference budget -**Theorem.** Fix a positive integer $m$. Along any sequence with $M\to\infty$ and $d/\log M\to\infty$, +**Theorem.** Fix a positive integer $`m`$. Along any sequence with $`M\to\infty`$ and $`d/\log M\to\infty`$, -$$ +```math \boxed{ P_{\mathrm{cl}}^{\mathrm{rev}}(d,M,m) =(1+o(1))\frac{(\log M)^m}{m!M}.} -$$ - -All logarithms are natural. The statement optimizes over arbitrary collective training measurements and unlimited classical records. Its quantifiers fix $m$; it is not a uniform theorem for growing $m$. +``` +All logarithms are natural. The statement optimizes over arbitrary collective training measurements and unlimited classical records. Its quantifiers fix $`m`$; it is not a uniform theorem for growing $`m`$. ### Upper bound -Let $L=\log M$ and choose $s=\lfloor L/m\rfloor$, which is positive for all sufficiently large $M$. The elementary bounds +Let $`L=\log M`$ and choose $`s=\lfloor L/m\rfloor`$, which is positive for all sufficiently large $`M`$. The elementary bounds -$$ +```math D_m=\frac{(d)_m}{m!},\qquad D_{ms}\geq\frac{d^{ms}}{(ms)!} -$$ - +``` give -$$ +```math M P_{\mathrm{cl}}^{\mathrm{rev}} \leq\frac{(d)_m}{d^m} \frac{M^{1/s}((ms)!)^{1/s}}{m!}. -$$ - -For fixed $m$, $(d)_m/d^m\to1$. Moreover, $s\sim L/m$ and $ms\sim L$. Stirling's formula gives +``` +For fixed $`m`$, $`(d)_m/d^m\to1`$. Moreover, $`s\sim L/m`$ and $`ms\sim L`$. Stirling's formula gives -$$ +```math \log\left(\frac{M^{1/s}((ms)!)^{1/s}}{L^m}\right) =\frac Ls-m+m\log\frac{ms}{L} +O\left(\frac{\log(ms)}s\right)\longrightarrow0. -$$ - -This proves the required upper bound. In particular, no approximation of $D_{ms}$ by $d^{ms}/(ms)!$ with a vanishing relative error is needed. Requiring $d/(\log M)^2\to\infty$ for that unnecessary approximation would weaken the actual theorem. +``` +This proves the required upper bound. In particular, no approximation of $`D_{ms}`$ by $`d^{ms}/(ms)!`$ with a vanishing relative error is needed. Requiring $`d/(\log M)^2\to\infty`$ for that unnecessary approximation would weaken the actual theorem. ### Attaining lower bound -Set $Y_j=-(d-1)\log(1-X_j)$. These variables are independent exponential variables of mean one. Their maximum $H=\max_jY_j$ obeys, for every fixed $0<\delta<1$, +Set $`Y_j=-(d-1)\log(1-X_j)`$. These variables are independent exponential variables of mean one. Their maximum $`H=\max_jY_j`$ obeys, for every fixed $`0\lt\delta\lt1`$, -$$ +```math \Pr[H>(1+\delta)L]\leq M^{-\delta},\qquad \Pr[H<(1-\delta)L]\leq e^{-M^\delta}. -$$ +``` +The same exponential tail bound, integrated above $`L`$, yields $`\mathbb E H^m=(1+o(1))L^m`$ for each fixed $`m`$. Let $`Z=\max_jX_j=1-e^{-H/(d-1)}`$. Since $`Z\leq H/(d-1)`$, -The same exponential tail bound, integrated above $L$, yields $\mathbb E H^m=(1+o(1))L^m$ for each fixed $m$. Let $Z=\max_jX_j=1-e^{-H/(d-1)}$. Since $Z\leq H/(d-1)$, - -$$ +```math \mathbb E Z^m\leq(1+o(1))\left(\frac Ld\right)^m. -$$ - -On the event $H\geq(1-\delta)L$, +``` +On the event $`H\geq(1-\delta)L`$, -$$ +```math Z^m\geq\left(1-e^{-(1-\delta)L/(d-1)}\right)^m =(1+o(1))\left(\frac{(1-\delta)L}{d}\right)^m, -$$ - -because $L/d\to0$. That event has probability tending to one. Taking the lower limit and then $\delta\downarrow0$ proves $\mathbb E Z^m=(1+o(1))(L/d)^m$. Finally $D_m=(1+o(1))d^m/m!$, so the exact covariant formula attains the upper bound. +``` +because $`L/d\to0`$. That event has probability tending to one. Taking the lower limit and then $`\delta\downarrow0`$ proves $`\mathbb E Z^m=(1+o(1))(L/d)^m`$. Finally $`D_m=(1+o(1))d^m/m!`$, so the exact covariant formula attains the upper bound. ## The inherited finite-query common component -For completeness, the finite-$t$ posterior channel has the universal measure-and-prepare decomposition studied by Chiribella. With $B=\binom{m+t}{m}$ and $C=D_mD_t/D_{m+t}$, the state-independent component has weight +For completeness, the finite $`t`$ posterior channel has the universal measure-and-prepare decomposition studied by Chiribella. With $`B=\binom{m+t}{m}`$ and $`C=D_mD_t/D_{m+t}`$, the state-independent component has weight -$$ +```math \alpha=\frac CB =\prod_{a=0}^{m-1}\frac{d+a}{d+t+a}. -$$ +``` +In detail, for a density operator $`a`$ on $`\mathrm{Sym}^m`$, let $`a^{(k)}`$ be its $`k`$-register reduced state and $`a^{(0)}=1`$. The symmetric-projector identity reads -In detail, for a density operator $a$ on $\operatorname{Sym}^m$, let $a^{(k)}$ be its $k$-register reduced state and $a^{(0)}=1$. The symmetric-projector identity reads - -$$ -\operatorname{Tr}_m[(a\otimes I)\Pi_{m+t}] +```math +\mathrm{Tr}_m[(a\otimes I)\Pi_{m+t}] =\frac1B\sum_{k=0}^{\min(m,t)} \binom mk\binom tk\, \Pi_t(a^{(k)}\otimes I^{\otimes(t-k)})\Pi_t. -$$ - -Every term is positive. The $k=0$ term is $I_{\operatorname{Sym}^t}/B$, giving $\sigma_{y,j,t}\geq\alpha\tau_t$. The common component cannot carry the label, so +``` +Every term is positive. The $`k=0`$ term is $`I_{\mathrm{Sym}^t}/B`$, giving $`\sigma_{y,j,t}\geq\alpha\tau_t`$. The common component cannot carry the label, so -$$ +```math P_{\mathrm{cl}}(d,M,m,t) \leq1-\alpha+\frac\alpha M \leq\frac1M+\frac{mt}{d}. -$$ - -The product formula should be used when the last relaxed bound exceeds one. The channel identity is inherited from [Chiribella, arXiv:1010.1875, Eqs. (6)–(7)](https://arxiv.org/abs/1010.1875); the posterior-common-component mechanism is used by [Anshu, Landau and Liu, arXiv:2111.03273, Lemma 7 and Theorem 9](https://arxiv.org/abs/2111.03273). Its many-label application is included for context and is not the main novelty claim. Unlike the revealed-query bound, this bound becomes uninformative as $t\to\infty$. +``` +The product formula should be used when the last relaxed bound exceeds one. The channel identity is inherited from [Chiribella, arXiv:1010.1875, Eqs. (6)–(7)](https://arxiv.org/abs/1010.1875); the posterior-common-component mechanism is used by [Anshu, Landau and Liu, arXiv:2111.03273, Lemma 7 and Theorem 9](https://arxiv.org/abs/2111.03273). Its many-label application is included for context and is not the main novelty claim. Unlike the revealed-query bound, this bound becomes uninformative as $`t\to\infty`$. ## Edge cases and scope -If $M=1$, success is one. If $d=1$ or $m=0$, the label cannot be distinguished and success is $1/M$, including at the revealed-query endpoint. If $t=0$, finite-query success is $1/M$. The beta-variable formula is stated for $d\geq2$; the $d=1$ case is handled separately. +If $`M=1`$, success is one. If $`d=1`$ or $`m=0`$, the label cannot be distinguished and success is $`1/M`$, including at the revealed-query endpoint. If $`t=0`$, finite-query success is $`1/M`$. The beta-variable formula is stated for $`d\geq2`$; the $`d=1`$ case is handled separately. -At each fixed finite $d,M,m$, ordinary query-state tomography followed by the revealed-query decision rule approaches the endpoint as $t\to\infty$. The posterior likelihoods are continuous functions of a pure state on a compact space, so consistency of the tomography estimate makes the decision regret vanish; ties do not prevent convergence of the success value. This limiting statement grants no efficient tomography or finite-query implementation for free. +At each fixed finite $`d,M,m`$, ordinary query-state tomography followed by the revealed-query decision rule approaches the endpoint as $`t\to\infty`$. The posterior likelihoods are continuous functions of a pure state on a compact space, so consistency of the tomography estimate makes the decision regret vanish; ties do not prevent convergence of the success value. This limiting statement grants no efficient tomography or finite-query implementation for free. -For fixed $m$ and a sufficiently large dimension, retained quantum references can achieve constant success with query copies of order $M^{1/m}$. The theorem above says that discarding those same references before the query arrives leaves success of order $(\log M)^m/M$ even with a perfect later query description. This is a statement about a fixed scarce-reference budget and irreversible preprocessing. It is not a computational speedup against an algorithm supplied classical descriptions of every reference, and it is not an exponential reference-sample advantage when the reference budget is allowed to grow. Classical-shadow protocols supply a known logarithmic-copy comparator in a separated-library revealed-query setting; [the source comparison](../references/RELATED_WORK.md) records that qualification. +For fixed $`m`$ and a sufficiently large dimension, retained quantum references can achieve constant success with query copies of order $`M^{1/m}`$. The theorem above says that discarding those same references before the query arrives leaves success of order $`(\log M)^m/M`$ even with a perfect later query description. This is a statement about a fixed scarce-reference budget and irreversible preprocessing. It is not a computational speedup against an algorithm supplied classical descriptions of every reference, and it is not an exponential reference-sample advantage when the reference budget is allowed to grow. Classical-shadow protocols supply a known logarithmic-copy comparator in a separated-library revealed-query setting; [the source comparison](../references/RELATED_WORK.md) records that qualification. ## Verification diff --git a/science/interpretation.md b/science/interpretation.md index 9a6d1e8..8e38c0c 100644 --- a/science/interpretation.md +++ b/science/interpretation.md @@ -2,54 +2,50 @@ ## Finite-query frontier -The [quantum identification bounds](quantum_identification.md) give a dimension-sensitive parameter $C=D_mD_t/D_{m+t}$. For $B=\binom{m+t}{m}$, its exact relation to the binomial coefficient is +The [quantum identification bounds](quantum_identification.md) give a dimension-sensitive parameter $`C=D_mD_t/D_{m+t}`$. For $`B=\binom{m+t}{m}`$, its exact relation to the binomial coefficient is -$$ +```math \frac{C}{B}=\prod_{a=0}^{m-1}\frac{d+a}{d+t+a},\qquad e^{-mt/d}B\le C\le B. -$$ - -Thus $C\sim B$ when $mt/d\to0$. This approximation is not uniform when $t$ is comparable to $d$. For fixed positive $m$ and a dimension large enough relative to $mt$, constant-success identification has query scale $t=\Theta_m(M^{1/m})$. At small target error, use the exact $C=\Theta(M/\epsilon)$ criterion and its stated constants. +``` +Thus $`C\sim B`$ when $`mt/d\to0`$. This approximation is not uniform when $`t`$ is comparable to $`d`$. For fixed positive $`m`$ and a dimension large enough relative to $`mt`$, constant-success identification has query scale $`t=\Theta_m(M^{1/m})`$. At small target error, use the exact $`C=\Theta(M/\epsilon)`$ criterion and its stated constants. For one reference copy per class, -$$ +```math C(d,1,t)=\frac{d(t+1)}{d+t}. -$$ - -As $t\to\infty$ at fixed $d,m$, $C\to D_m$. A scarce reference budget imposes a ceiling even if an arbitrarily large number of later queries is supplied. The [revealed-query endpoint](revealed_query.md) determines the retained-quantum optimum in that ideal-information comparison. +``` +As $`t\to\infty`$ at fixed $`d,m`$, $`C\to D_m`$. A scarce reference budget imposes a ceiling even if an arbitrarily large number of later queries is supplied. The [revealed-query endpoint](revealed_query.md) determines the retained-quantum optimum in that ideal-information comparison. ## What classical preprocessing loses -For each fixed $m\ge1$, arbitrary collective classical training has revealed-query success +For each fixed $`m\ge1`$, arbitrary collective classical training has revealed-query success -$$ +```math P_{\mathrm{classical}}^{\mathrm{revealed}} =(1+o(1))\frac{(\log M)^m}{m!M}, \qquad M\to\infty,\quad d/\log M\to\infty. -$$ +``` +With $`m=1`$, take $`t=aM`$ for a sufficiently large constant $`a`$ and $`d/M\to\infty`$. The quantum scan has constant success, while every classical-training protocol has success at most $`(1+o(1))\log M/M`$ even if the later query is known exactly, and that ceiling is attained to leading order. Increasing later query information cannot recover the reference information discarded before the query was known. -With $m=1$, take $t=aM$ for a sufficiently large constant $a$ and $d/M\to\infty$. The quantum scan has constant success, while every classical-training protocol has success at most $(1+o(1))\log M/M$ even if the later query is known exactly, and that ceiling is attained to leading order. Increasing later query information cannot recover the reference information discarded before the query was known. - -For any fixed positive $m$, the same comparison uses $t$ of order $M^{1/m}$ with a sufficiently large constant and $d$ large enough for the capacity condition. The theorem compares the same supplied references. The quantum algorithm really retains them; the classical protocol really discards them. +For any fixed positive $`m`$, the same comparison uses $`t`$ of order $`M^{1/m}`$ with a sufficiently large constant and $`d`$ large enough for the capacity condition. The theorem compares the same supplied references. The quantum algorithm really retains them; the classical protocol really discards them. ## Growing reference budgets and matched baselines -The fixed-$m$ asymptotic cannot be substituted at $m=\Theta(\log M)$. A finite moment converse instead gives a logarithmic necessary reference order for constant revealed-query classical success: using the integer moment $s=2$, +The fixed $`m`$ asymptotic cannot be substituted at $`m=\Theta(\log M)`$. A finite moment converse instead gives a logarithmic necessary reference order for constant revealed-query classical success: using the integer moment $`s=2`$, -$$ +```math P_{\mathrm{classical}}^{\mathrm{revealed}} \le\frac{D_m}{\sqrt{M D_{2m}}} \le\sqrt{\frac{\binom{2m}{m}}{M}} \le\frac{2^m}{\sqrt M}. -$$ - -The middle inequality follows from the product formula for $D_s$. Consequently constant success requires $m=\Omega(\log M)$. Established classical-shadow methods give the matching $O(\log M)$ reference-copy order for a later exact query in a library with a fixed separation margin, using the known rank-one query projector as an observable. This is a logarithmic reference-copy comparison, not an exponential total-sample advantage. See [related work](../references/RELATED_WORK.md) for attribution and the promise behind that comparator. +``` +The middle inequality follows from the product formula for $`D_s`$. Consequently constant success requires $`m=\Omega(\log M)`$. Established classical-shadow methods give the matching $`O(\log M)`$ reference-copy order for a later exact query in a library with a fixed separation margin, using the known rank-one query projector as an observable. This is a logarithmic reference-copy comparison, not an exponential total-sample advantage. See [related work](../references/RELATED_WORK.md) for attribution and the promise behind that comparator. -The finite-query common-component upper bound in [classical preprocessing](classical_preprocessing.md) also produces a separation at $m,t=\Theta(\log M)$ and $d\gg(\log M)^2$, with constants chosen so that $B$ is sufficiently larger than $M$. Its measure-and-prepare mechanism is inherited from prior work. +The finite-query common-component upper bound in [classical preprocessing](classical_preprocessing.md) also produces a separation at $`m,t=\Theta(\log M)`$ and $`d\gg(\log M)^2`$, with constants chosen so that $`B`$ is sufficiently larger than $`M`$. Its measure-and-prepare mechanism is inherited from prior work. ## What follows, and what remains outside the model The contribution is a multiclass copy frontier paired with a sharp classical-record saturation law across a delayed-query boundary. Quantum-memory advantages, state-comparison methods and measurement-order effects are established prior insights; the [comparison](../references/RELATED_WORK.md) makes that shared foundation explicit. -This result assumes independent Haar pure states, equal reference budgets, a uniform label and one lookup. It does not prove a worst-case arbitrary-codebook converse, robustness for mixed/noisy states, reusable references, compressed quantum memory, or a runtime advantage over classical algorithms given full reference descriptions. The constructive scan performs up to $M$ tests and stores supplied quantum inputs; no index or amplitude amplification is free. +This result assumes independent Haar pure states, equal reference budgets, a uniform label and one lookup. It does not prove a worst-case arbitrary-codebook converse, robustness for mixed/noisy states, reusable references, compressed quantum memory, or a runtime advantage over classical algorithms given full reference descriptions. The constructive scan performs up to $`M`$ tests and stores supplied quantum inputs; no index or amplitude amplification is free. diff --git a/science/model.md b/science/model.md index 292440f..4b198e5 100644 --- a/science/model.md +++ b/science/model.md @@ -2,43 +2,40 @@ ## A delayed membership query -Let $d,M\ge1$ and $m,t\ge0$ be integers. Independently sample normalized pure states $\psi_1,\ldots,\psi_M$ from Haar measure on $\mathbb C^d$. A reference block $R_j$ contains $m$ copies of $\psi_j$. A label $J$ is uniform on $\{1,\ldots,M\}$ and independent of library preparation; the query block $T$ contains $t$ copies of $\psi_J$. The task is to return $J$ once. Success is averaged over the library, label and measurement outcomes. +Let $`d,M\ge1`$ and $`m,t\ge0`$ be integers. Independently sample normalized pure states $`\psi_1,\ldots,\psi_M`$ from Haar measure on $`\mathbb C^d`$. A reference block $`R_j`$ contains $`m`$ copies of $`\psi_j`$. A label $`J`$ is uniform on $`\{1,\ldots,M\}`$ and independent of library preparation; the query block $`T`$ contains $`t`$ copies of $`\psi_J`$. The task is to return $`J`$ once. Success is averaged over the library, label and measurement outcomes. -The notation $\psi$ also denotes the rank-one density operator of a pure state. All measurements may depend on known parameters $d,M,m,t$. The state descriptions themselves are unknown. There is no preparation oracle, inverse oracle, source reflection, classical loading oracle or QRAM. +The notation $`\psi`$ also denotes the rank-one density operator of a pure state. All measurements may depend on known parameters $`d,M,m,t`$. The state descriptions themselves are unknown. There is no preparation oracle, inverse oracle, source reflection, classical loading oracle or QRAM. In the **retained-quantum model**, the reference blocks remain available when the query arrives. An arbitrary joint POVM is allowed, including adaptive processing and ancillas. The algorithm in [resources](resources.md) constructs a particular sequential measurement; an information-theoretic optimum does not imply an efficient implementation of every optimal POVM. In the **classical-training model**, an arbitrary collective POVM acts on all references before any query information arrives. Its outcome may use unlimited classical information and computation. Every quantum system correlated with training is discarded across this boundary; retained entanglement or quantum side information would change the model. The later decoder can process the query with fresh ancillas and the classical record. A classical record is not restricted to separate per-reference estimates. -The **revealed-query comparison** gives the decoder the exact classical description of the later query state after training. This is extra information, so its classical-training success upper-bounds every finite-$t$ classical-training protocol. It does not give reference descriptions. The [retained-quantum endpoint](revealed_query.md) uses the same later description while retaining physical reference blocks. +The **revealed-query comparison** gives the decoder the exact classical description of the later query state after training. This is extra information, so its classical-training success upper-bounds every finite $`t`$ classical-training protocol. It does not give reference descriptions. The [retained-quantum endpoint](revealed_query.md) uses the same later description while retaining physical reference blocks. ## Symmetric spaces Define -$$ -\mathcal S_s=\operatorname{Sym}^s(\mathbb C^d),\qquad +```math +\mathcal S_s=\mathrm{Sym}^s(\mathbb C^d),\qquad D_s=\dim\mathcal S_s=\binom{d+s-1}{s},\qquad \tau_s=I_{\mathcal S_s}/D_s. -$$ +``` +Use $`D_0=1`$. The normalized Haar moment is -Use $D_0=1$. The normalized Haar moment is - -$$ +```math \int\psi^{\otimes s}\,d\psi=\tau_s. -$$ - +``` The finite-query capacity parameter and permutation coefficient are -$$ +```math C(d,m,t)=\frac{D_mD_t}{D_{m+t}},\qquad B(m,t)=\binom{m+t}{m}. -$$ - -All logarithms are natural unless marked $\log_2$. The error $e_{\mathrm{opt}}$ is one minus the supremal Bayesian success in the retained-quantum model. $P_{\mathrm{classical}}^{\mathrm{revealed}}$ is the supremal success over all classical-training protocols with the later exact query description. +``` +All logarithms are natural unless marked $`\log_2`$. The error $`e_{\mathrm{opt}}`$ is one minus the supremal Bayesian success in the retained-quantum model. $`P_{\mathrm{classical}}^{\mathrm{revealed}}`$ is the supremal success over all classical-training protocols with the later exact query description. -For $M=1$, success is one. For $d=1$, $m=0$, or $t=0$ in the finite-query model, the hypotheses coincide and success is $1/M$. The sharp classical asymptotic holds for a **fixed positive** $m$ with $M\to\infty$ and $d/\log M\to\infty$; it makes no growing-$m$ claim. +For $`M=1`$, success is one. For $`d=1`$, $`m=0`$, or $`t=0`$ in the finite-query model, the hypotheses coincide and success is $`1/M`$. The sharp classical asymptotic holds for a **fixed positive** $`m`$ with $`M\to\infty`$ and $`d/\log M\to\infty`$; it makes no growing $`m`$ claim. ## Resource convention -Every input specimen is charged: $Mm$ reference copies and $t$ query copies. Keeping the library is a quantum memory resource. Its preparation costs are external source costs, not free algorithmic access. The explicit decoder charges its scan, work registers, known-wire swaps, classical bookkeeping, and rotation precision. A known-description comparator is an information benchmark with its own description input and measurement synthesis costs. No algorithm is asserted to return an undisturbed reusable library. +Every input specimen is charged: $`Mm`$ reference copies and $`t`$ query copies. Keeping the library is a quantum memory resource. Its preparation costs are external source costs, not free algorithmic access. The explicit decoder charges its scan, work registers, known-wire swaps, classical bookkeeping, and rotation precision. A known-description comparator is an information benchmark with its own description input and measurement synthesis costs. No algorithm is asserted to return an undisturbed reusable library. diff --git a/science/quantum_identification.md b/science/quantum_identification.md index f4e2160..1950382 100644 --- a/science/quantum_identification.md +++ b/science/quantum_identification.md @@ -1,224 +1,201 @@ # Quantum identification from supplied references -The task is to identify one member of an unknown quantum reference collection. There are $M\geq1$ labels and independent Haar pure states $\psi_1,\ldots,\psi_M$ in $\mathbb C^d$. The input contains $m$ copies of each labeled reference and $t$ query copies of $\psi_J$, with $J$ uniform on $\{1,\ldots,M\}$. Here $d\geq1$ and $m,t\geq0$ are integers. A discriminator receives these physical states, without their classical descriptions or preparation oracles, and outputs one label. It may use any joint measurement. The optimum below is the Bayesian optimum, averaged over both the independent Haar library and the uniform label. +The task is to identify one member of an unknown quantum reference collection. There are $`M\geq1`$ labels and independent Haar pure states $`\psi_1,\ldots,\psi_M`$ in $`\mathbb C^d`$. The input contains $`m`$ copies of each labeled reference and $`t`$ query copies of $`\psi_J`$, with $`J`$ uniform on $`\{1,\ldots,M\}`$. Here $`d\geq1`$ and $`m,t\geq0`$ are integers. A discriminator receives these physical states, without their classical descriptions or preparation oracles, and outputs one label. It may use any joint measurement. The optimum below is the Bayesian optimum, averaged over both the independent Haar library and the uniform label. Write -$$ +```math D_s=\binom{d+s-1}{s},\qquad C=\frac{D_mD_t}{D_{m+t}}. -$$ - -The dimension $D_s$ is that of $\operatorname{Sym}^s(\mathbb C^d)$, with $D_0=1$. Let $P_{\mathrm{opt}}$ be the optimal success probability and $e_{\mathrm{opt}}=1-P_{\mathrm{opt}}$. +``` +The dimension $`D_s`$ is that of $`\mathrm{Sym}^s(\mathbb C^d)`$, with $`D_0=1`$. Let $`P_{\mathrm{opt}}`$ be the optimal success probability and $`e_{\mathrm{opt}}=1-P_{\mathrm{opt}}`$. ## Finite-dimensional bounds -For every $M\geq2$, +For every $`M\geq2`$, -$$ +```math \frac{C}{C+M-1} \leq P_{\mathrm{opt}} \leq \min\!\left\{1,\frac CM\right\}, -$$ - +``` and -$$ +```math \max\!\left\{0,1-\frac CM, \frac{M-1}{8C+4(M-2)}\right\} \leq e_{\mathrm{opt}} \leq \frac{M-1}{C+M-1}. -$$ - +``` A sequential algorithm using true projective symmetry measurements satisfies -$$ +```math e_{\mathrm{seq}}\leq \min\!\left\{1,\frac{2(M-1)}C\right\}. -$$ - -Thus $P_{\mathrm{opt}}=\Theta(\min\{1,C/M\})$ and $e_{\mathrm{opt}}=\Theta(\min\{1,(M-1)/C\})$, with absolute constants. The two order statements describe different parts of the same tradeoff: success when identification is difficult, and error when it is reliable. Neither asserts an exact formula for the finite-query optimum. +``` +Thus $`P_{\mathrm{opt}}=\Theta(\min\{1,C/M\})`$ and $`e_{\mathrm{opt}}=\Theta(\min\{1,(M-1)/C\})`$, with absolute constants. The two order statements describe different parts of the same tradeoff: success when identification is difficult, and error when it is reliable. Neither asserts an exact formula for the finite-query optimum. -For $0<\epsilon\leq1/8$, error at most $\epsilon$ requires +For $`0\lt\epsilon\leq1/8`$, error at most $`\epsilon`$ requires -$$ +```math C\geq\frac{M-1}{16\epsilon}, -$$ +``` +whereas the sequential algorithm attains that error whenever $`C\geq2(M-1)/\epsilon`$. If the necessary lower bound exceeds the available maximum of $`C`$, the requested error is impossible with that reference budget. Failing the sufficient scan condition alone does not prove impossibility. -whereas the sequential algorithm attains that error whenever $C\geq2(M-1)/\epsilon$. If the necessary lower bound exceeds the available maximum of $C$, the requested error is impossible with that reference budget. Failing the sufficient scan condition alone does not prove impossibility. - -When $M=1$, the error is zero. When $d=1$, $m=0$, or $t=0$, the label carries no observable information and $P_{\mathrm{opt}}=1/M$ exactly. The displayed general bounds remain valid but need not be tight in their constants. +When $`M=1`$, the error is zero. When $`d=1`$, $`m=0`$, or $`t=0`$, the label carries no observable information and $`P_{\mathrm{opt}}=1/M`$ exactly. The displayed general bounds remain valid but need not be tight in their constants. ## Haar averaging gives flat projector hypotheses Use the support space -$$ +```math \mathcal H= -\left(\operatorname{Sym}^{m}\mathbb C^d\right)^{\otimes M} -\otimes\operatorname{Sym}^{t}\mathbb C^d, +\left(\mathrm{Sym}^{m}\mathbb C^d\right)^{\otimes M} +\otimes\mathrm{Sym}^{t}\mathbb C^d, \qquad L=\dim\mathcal H=D_m^MD_t. -$$ - -Let $P_j$ be the orthogonal projector that symmetrizes the query registers jointly with reference block $j$, and acts as the identity on the other reference blocks. The restriction to $\mathcal H$ is well defined: a state symmetric on the combined block is separately symmetric on either subblock. Every $P_j$ has rank +``` +Let $`P_j`$ be the orthogonal projector that symmetrizes the query registers jointly with reference block $`j`$, and acts as the identity on the other reference blocks. The restriction to $`\mathcal H`$ is well defined: a state symmetric on the combined block is separately symmetric on either subblock. Every $`P_j`$ has rank -$$ +```math r=D_{m+t}D_m^{M-1}=\frac LC. -$$ - +``` The Haar moment identity -$$ +```math \int\psi^{\otimes s}\,d\psi =\frac{\Pi_s}{D_s} -$$ - +``` and independence of the other references give the averaged hypotheses -$$ +```math \rho_j=\frac{P_j}{r}. -$$ - +``` This reduction includes adaptive protocols and intermediate measurements: any such protocol is a final POVM on its initial supplied systems. It does not replace a correlated or known reference collection by the independent Haar model. -The null state $\rho_0=I_{\mathcal H}/L$ obeys $\rho_j\leq C\rho_0$. Therefore every POVM $\{E_j\}_{j=1}^M$ satisfies +The null state $`\rho_0=I_{\mathcal H}/L`$ obeys $`\rho_j\leq C\rho_0`$. Therefore every POVM $`\{E_j\}_{j=1}^M`$ satisfies -$$ +```math P_{\mathrm{success}} -=\frac1M\sum_j\operatorname{Tr}(E_j\rho_j) -\leq\frac CM\sum_j\operatorname{Tr}(E_j\rho_0) +=\frac1M\sum_j\mathrm{Tr}(E_j\rho_j) +\leq\frac CM\sum_j\mathrm{Tr}(E_j\rho_0) =\frac CM. -$$ - +``` This proves the success converse without computational or measurement-locality assumptions. ## Exact pair and triple overlaps -Suppressing identity factors on the other reference blocks, the partial trace over the private reference block $R_j$ is +Suppressing identity factors on the other reference blocks, the partial trace over the private reference block $`R_j`$ is -$$ -\operatorname{Tr}_{R_j}P_j +```math +\mathrm{Tr}_{R_j}P_j =\frac{D_{m+t}}{D_t}I_T =\frac{D_m}{C}I_T. -$$ - -Unitary covariance makes this partial trace a scalar on the irreducible query space $\operatorname{Sym}^t\mathbb C^d$, and the full trace fixes the scalar. Tracing a label that occurs only once in a product then gives +``` +Unitary covariance makes this partial trace a scalar on the irreducible query space $`\mathrm{Sym}^t\mathbb C^d`$, and the full trace fixes the scalar. Tracing a label that occurs only once in a product then gives -$$ -\operatorname{Tr}(P_iP_j)=\frac rC +```math +\mathrm{Tr}(P_iP_j)=\frac rC \quad(i\neq j),\qquad -\operatorname{Tr}(P_iP_jP_k)=\frac r{C^2} +\mathrm{Tr}(P_iP_jP_k)=\frac r{C^2} \quad(i,j,k\text{ distinct}). -$$ - +``` The second formula does not assume commuting projectors. The block traced at each step belongs to only one projector, so operators on all remaining blocks can be taken outside that partial trace. -Put $S=\sum_jP_j$, $\beta=(M-1)/C$, and $\gamma=(M-1)(M-2)/C^2$. Expansion of the powers, with cyclicity of trace and $P_j^2=P_j$, gives +Put $`S=\sum_jP_j`$, $`\beta=(M-1)/C`$, and $`\gamma=(M-1)(M-2)/C^2`$. Expansion of the powers, with cyclicity of trace and $`P_j^2=P_j`$, gives -$$ +```math \begin{aligned} -\operatorname{Tr}S&=Mr,\\ -\operatorname{Tr}S^2&=Mr(1+\beta),\\ -\operatorname{Tr}S^3&=Mr(1+3\beta+\gamma). +\mathrm{Tr}S&=Mr,\\ +\mathrm{Tr}S^2&=Mr(1+\beta),\\ +\mathrm{Tr}S^3&=Mr(1+3\beta+\gamma). \end{aligned} -$$ - +``` ## Pretty-good measurement -On $\operatorname{supp}S$, define +On $`\mathrm{supp}S`$, define -$$ +```math E_j=S^{-1/2}P_jS^{-1/2}. -$$ - +``` The inverse is the support inverse. The orthogonal complement has zero probability under every hypothesis and can be assigned to any label. For a fixed label, -$$ -\operatorname{Tr}(P_jS) +```math +\mathrm{Tr}(P_jS) =r\left(1+\frac{M-1}{C}\right). -$$ +``` +Apply scalar Jensen to the spectral distribution of $`S`$ under the positive normalized functional $`X\mapsto\mathrm{Tr}(P_jX)/r`$. Since $`x^{-1/2}`$ is convex on positive numbers, -Apply scalar Jensen to the spectral distribution of $S$ under the positive normalized functional $X\mapsto\operatorname{Tr}(P_jX)/r$. Since $x^{-1/2}$ is convex on positive numbers, - -$$ -\operatorname{Tr}(P_jS^{-1/2}) +```math +\mathrm{Tr}(P_jS^{-1/2}) \geq\frac{r}{\sqrt{1+(M-1)/C}}. -$$ - -For $X_j=P_jS^{-1/2}P_j$, Cauchy–Schwarz on its rank-$r$ support gives +``` +For $`X_j=P_jS^{-1/2}P_j`$, Cauchy–Schwarz on its rank $`r`$ support gives -$$ -\operatorname{Tr}(X_j^2) -\geq\frac{[\operatorname{Tr}X_j]^2}{r} +```math +\mathrm{Tr}(X_j^2) +\geq\frac{[\mathrm{Tr}X_j]^2}{r} \geq\frac{r}{1+(M-1)/C}. -$$ - -As $\operatorname{Tr}(E_j\rho_j)=\operatorname{Tr}(X_j^2)/r$, averaging proves $P_{\mathrm{opt}}\geq C/(C+M-1)$. This measurement establishes the information bound; its global inverse square root is not used as an efficient implementation claim. +``` +As $`\mathrm{Tr}(E_j\rho_j)=\mathrm{Tr}(X_j^2)/r`$, averaging proves $`P_{\mathrm{opt}}\geq C/(C+M-1)`$. This measurement establishes the information bound; its global inverse square root is not used as an efficient implementation claim. ## Sequential symmetry decoder -Test $\{P_j,I-P_j\}$ in a fixed label order, stopping at the first acceptance. If every test rejects, output any label. Under hypothesis $j$, consider the outcome sequence that rejects labels $1,\ldots,j-1$ and accepts $j$. The correct projector has initial rejection probability zero, and every earlier incorrect projector has initial acceptance probability $1/C$. +Test $`\{P_j,I-P_j\}`$ in a fixed label order, stopping at the first acceptance. If every test rejects, output any label. Under hypothesis $`j`$, consider the outcome sequence that rejects labels $`1,\ldots,j-1`$ and accepts $`j`$. The correct projector has initial rejection probability zero, and every earlier incorrect projector has initial acceptance probability $`1/C`$. Gao's noncommutative union bound, with its factor four, therefore gives -$$ +```math \Pr[\mathrm{error}\mid J=j] \leq\frac{4(j-1)}C. -$$ - -Averaging the uniformly distributed label proves $e_{\mathrm{seq}}\leq2(M-1)/C$, with the trivial cap at one. The union bound applies to the mixed averaged hypotheses by linearity or purification. It explicitly accounts for the disturbance caused by earlier rejections; independent-test reasoning would not justify this protocol. +``` +Averaging the uniformly distributed label proves $`e_{\mathrm{seq}}\leq2(M-1)/C`$, with the trivial cap at one. The union bound applies to the mixed averaged hypotheses by linearity or purification. It explicitly accounts for the disturbance caused by earlier rejections; independent-test reasoning would not justify this protocol. -An efficient algorithm also attains the success order in the difficult regime. If $C<4$, random guessing suffices up to a constant factor. Otherwise choose a uniformly random subset of +An efficient algorithm also attains the success order in the difficult regime. If $`C\lt4`$, random guessing suffices up to a constant factor. Otherwise choose a uniformly random subset of -$$ +```math \ell=\min\{M,\lfloor C/4\rfloor\} -$$ - -labels and run the scan on that subset. Conditional on including the true label, the mean error is at most $2(\ell-1)/C\leq1/2$. This yields success at least $\frac1{16}\min\{1,C/M\}$, using at most $\ell$ comparisons. The full scan is the useful version for small target error. +``` +labels and run the scan on that subset. Conditional on including the true label, the mean error is at most $`2(\ell-1)/C\leq1/2`$. This yields success at least $`\frac1{16}\min\{1,C/M\}`$, using at most $`\ell`$ comparisons. The full scan is the useful version for small target error. ## Error converse from three moments The discrimination trace bound used here is the established generalized Holevo–Curlander bound, not a new inequality. Its specialized application can be proved directly. -Choose isometries $V_j:\mathbb C^r\to\mathcal H$ with $V_jV_j^\dagger=P_j$, concatenate them as $T=[V_1\ \cdots\ V_M]$, and let $G=T^\dagger T$ on an $n=Mr$ dimensional space. The nonzero spectra of $G$ and $S=TT^\dagger$ agree. The zero multiplicities of $G$ must be retained below. +Choose isometries $`V_j:\mathbb C^r\to\mathcal H`$ with $`V_jV_j^\dagger=P_j`$, concatenate them as $`T=[V_1\ \cdots\ V_M]`$, and let $`G=T^\dagger T`$ on an $`n=Mr`$ dimensional space. The nonzero spectra of $`G`$ and $`S=TT^\dagger`$ agree. The zero multiplicities of $`G`$ must be retained below. -For a POVM $\{E_j\}$ set $B_j=V_j^\dagger E_jV_j$, so $0\leq B_j\leq I$. Stack $\sqrt{E_j}$ into an isometry $A:\mathcal H\to\bigoplus_j\mathcal H$. In the polar decomposition $\sqrt{E_j}V_j=W_j\sqrt{B_j}$, each $W_j$ can be a contraction, and $W=\bigoplus_jW_j$ is also a contraction. Thus +For a POVM $`\{E_j\}`$ set $`B_j=V_j^\dagger E_jV_j`$, so $`0\leq B_j\leq I`$. Stack $`\sqrt{E_j}`$ into an isometry $`A:\mathcal H\to\bigoplus_j\mathcal H`$. In the polar decomposition $`\sqrt{E_j}V_j=W_j\sqrt{B_j}`$, each $`W_j`$ can be a contraction, and $`W=\bigoplus_jW_j`$ is also a contraction. Thus -$$ -\sum_j\operatorname{Tr}\sqrt{B_j} -=\operatorname{Tr}(W^\dagger AT) +```math +\sum_j\mathrm{Tr}\sqrt{B_j} +=\mathrm{Tr}(W^\dagger AT) \leq\|T\|_1 -=\operatorname{Tr}\sqrt G. -$$ - -Since $\operatorname{Tr}B_j\leq\operatorname{Tr}\sqrt{B_j}$, +=\mathrm{Tr}\sqrt G. +``` +Since $`\mathrm{Tr}B_j\leq\mathrm{Tr}\sqrt{B_j}`$, -$$ +```math P_{\mathrm{success}} -\leq\frac{\operatorname{Tr}\sqrt G}{n}. -$$ - -Let $\mathbb E$ denote the empirical mean over all $n$ eigenvalues $\lambda\geq0$ of $G$. The exact moments above imply +\leq\frac{\mathrm{Tr}\sqrt G}{n}. +``` +Let $`\mathbb E`$ denote the empirical mean over all $`n`$ eigenvalues $`\lambda\geq0`$ of $`G`$. The exact moments above imply -$$ +```math \mathbb E\lambda=1,\quad \mathbb E(\lambda-1)^2=\beta,\quad \mathbb E\bigl[\lambda(\lambda-1)^2\bigr]=\beta+\gamma. -$$ - +``` Consequently -$$ +```math e_{\mathrm{opt}} \geq1-\mathbb E\sqrt\lambda =\frac12\mathbb E(\sqrt\lambda-1)^2. -$$ - -Cauchy–Schwarz and $(\sqrt\lambda+1)^2\leq2(\lambda+1)$ give +``` +Cauchy–Schwarz and $`(\sqrt\lambda+1)^2\leq2(\lambda+1)`$ give -$$ +```math \begin{aligned} \beta^2 &\leq @@ -227,50 +204,45 @@ $$ &\leq2(2\beta+\gamma)\, \mathbb E(\sqrt\lambda-1)^2. \end{aligned} -$$ +``` +For $`M\geq2`$, $`\beta>0`$. Substitution yields -For $M\geq2$, $\beta>0$. Substitution yields - -$$ +```math e_{\mathrm{opt}} \geq\frac{\beta^2}{4(2\beta+\gamma)} =\frac{M-1}{8C+4(M-2)}. -$$ - +``` Pair overlaps alone would not establish this error accumulation: different subspaces could all share one small ambiguous component. The exact third moment controls that obstruction for this ensemble. The exactly revealed-query optimum has its proof in the [endpoint account](revealed_query.md). Dimension-dependent regimes are collected in [interpretation](interpretation.md). ## Fixed and typical libraries -Write $B=\binom{m+t}{m}$. For a deterministic library set $x_{ij}=|\langle\psi_i|\psi_j\rangle|^2$. A false comparison has exact acceptance +Write $`B=\binom{m+t}{m}`$. For a deterministic library set $`x_{ij}=|\langle\psi_i|\psi_j\rangle|^2`$. A false comparison has exact acceptance -$$ +```math F_{m,t}(x)= \frac{\displaystyle\sum_{a=0}^{\min(m,t)} \binom ma\binom ta x^a}{\binom{m+t}{m}}. -$$ - -To see this, average all permutations of the $m+t$ systems and group them by the number $a$ of positions transferred across each of the two constant-state blocks. There are $m!t!\binom ma\binom ta$ such permutations, and their product-state expectation is $x^a$. Vandermonde's identity verifies $F_{m,t}(1)=1$. +``` +To see this, average all permutations of the $`m+t`$ systems and group them by the number $`a`$ of positions transferred across each of the two constant-state blocks. There are $`m!t!\binom ma\binom ta`$ such permutations, and their product-state expectation is $`x^a`$. Vandermonde's identity verifies $`F_{m,t}(1)=1`$. The same sequential algorithm, with the same fixed operations, obeys the deterministic mean-error bound -$$ +```math e_{\mathrm{seq}}(\text{library}) -\leq\frac4M\sum_{i\delta]=(1-\delta)^{d-1}\leq e^{-(d-1)\delta}$. A union bound gives maximum overlap at most +For $`d\geq2`$, independent Haar pairs satisfy $`\Pr[x_{ij}>\delta]=(1-\delta)^{d-1}\leq e^{-(d-1)\delta}`$. A union bound gives maximum overlap at most -$$ +```math \delta=\frac{2\log M+\log(1/\eta)}{d-1} -$$ - -with probability at least $1-\eta$ whenever the displayed $\delta\leq1$. If $d-1\geq mt[2\log M+\log(1/\eta)]$, the false-comparison factor $e^{mt\delta}$ is at most $e$. +``` +with probability at least $`1-\eta`$ whenever the displayed $`\delta\leq1`$. If $`d-1\geq mt[2\log M+\log(1/\eta)]`$, the false-comparison factor $`e^{mt\delta}`$ is at most $`e`$. -The Bayesian converse must not be promoted to an all-library converse. For any fixed universal discriminator, Markov's inequality gives $\Pr_{\mathrm{library}}[P_{\mathrm{success}}\geq s]\leq C/(Ms)$ for $s>0$. A conditioning event $E$ of positive Haar probability has conditional mean success at most $C/[M\Pr(E)]$. These are precisely the available typical-library and promise-family consequences. +The Bayesian converse must not be promoted to an all-library converse. For any fixed universal discriminator, Markov's inequality gives $`\Pr_{\mathrm{library}}[P_{\mathrm{success}}\geq s]\leq C/(Ms)`$ for $`s>0`$. A conditioning event $`E`$ of positive Haar probability has conditional mean success at most $`C/[M\Pr(E)]`$. These are precisely the available typical-library and promise-family consequences. ## Attribution and verification diff --git a/science/resources.md b/science/resources.md index f195779..b5dc839 100644 --- a/science/resources.md +++ b/science/resources.md @@ -1,85 +1,79 @@ # Implementing and charging the symmetry scan -The sequential decoder uses at most $M$ true Lüders measurements of joint symmetry on the query block and one reference block. It needs no description of the unknown input states, no state-preparation or inverse oracle, and no QRAM. This page gives a conservative implementation bound, without claiming an optimal gate count or a faster database lookup. +The sequential decoder uses at most $`M`$ true Lüders measurements of joint symmetry on the query block and one reference block. It needs no description of the unknown input states, no state-preparation or inverse oracle, and no QRAM. This page gives a conservative implementation bound, without claiming an optimal gate count or a faster database lookup. -Let $K=m+t\geq2$ and $q=\lceil\log_2d\rceil$. Encode each physical qudit in $q$ qubits. A permutation preserves the valid $d$-dimensional subspace of every register, so the embedding does not change the symmetry projector on the supplied inputs. The cases $m=0$, $t=0$, or $d=1$ require only random guessing. +Let $`K=m+t\geq2`$ and $`q=\lceil\log_2d\rceil`$. Encode each physical qudit in $`q`$ qubits. A permutation preserves the valid $`d`$-dimensional subspace of every register, so the embedding does not change the symmetry projector on the supplied inputs. The cases $`m=0`$, $`t=0`$, or $`d=1`$ require only random guessing. ## A clean reflection from permutation averaging -Let $P$ be the symmetric projector on the selected $K$ qudits. Its permutation-average form is +Let $`P`$ be the symmetric projector on the selected $`K`$ qudits. Its permutation-average form is -$$ +```math P=\frac1{K!}\sum_{\pi\in S_K}U_\pi. -$$ +``` +Prepare independent index registers uniformly on the known intervals $`\{0,\ldots,k-1\}`$ for $`k=2,\ldots,K`$. The associated Fisher–Yates swaps give a one-to-one encoding of all $`K!`$ permutations. Let $`V`$ be this known-state preparation and let $`U_{\mathrm{sel}}`$ apply the permutation specified by those registers. Invalid index encodings can be assigned arbitrary unitary actions, because their ideal prepared amplitudes vanish. With $`A=O(K\log K)`$ index qubits, define -Prepare independent index registers uniformly on the known intervals $\{0,\ldots,k-1\}$ for $k=2,\ldots,K$. The associated Fisher–Yates swaps give a one-to-one encoding of all $K!$ permutations. Let $V$ be this known-state preparation and let $U_{\mathrm{sel}}$ apply the permutation specified by those registers. Invalid index encodings can be assigned arbitrary unitary actions, because their ideal prepared amplitudes vanish. With $A=O(K\log K)$ index qubits, define - -$$ +```math W=(V^\dagger\otimes I)U_{\mathrm{sel}}(V\otimes I), \qquad (\langle0|\otimes I)W(|0\rangle\otimes I)=P. -$$ - -For $u\in\operatorname{ran}P$, all permutations fix $u$, so $W(|0\rangle u)=|0\rangle u$. For $v\in\ker P$, the zero-ancilla component of $W(|0\rangle v)$ vanishes. Thus, writing $Z_0=2|0\rangle\langle0|-I$, +``` +For $`u\in\mathrm{ran}P`$, all permutations fix $`u`$, so $`W(|0\rangle u)=|0\rangle u`$. For $`v\in\ker P`$, the zero-ancilla component of $`W(|0\rangle v)`$ vanishes. Thus, writing $`Z_0=2|0\rangle\langle0|-I`$, -$$ +```math W^\dagger(Z_0\otimes I)W(|0\rangle v) =|0\rangle(2P-I)v -$$ - -for every data vector $v$. This implements the reflection $R=2P-I$ and returns all permutation workspace to zero in the ideal gate model. +``` +for every data vector $`v`$. This implements the reflection $`R=2P-I`$ and returns all permutation workspace to zero in the ideal gate model. -Prepare an outcome flag in $|+\rangle$, control only the middle $Z_0$ on that flag, and apply the two surrounding $W,W^\dagger$ unconditionally. On the flag-zero branch those two unitaries cancel; on flag one they implement $R$. A final Hadamard and flag measurement have data Kraus operators +Prepare an outcome flag in $`|+\rangle`$, control only the middle $`Z_0`$ on that flag, and apply the two surrounding $`W,W^\dagger`$ unconditionally. On the flag-zero branch those two unitaries cancel; on flag one they implement $`R`$. A final Hadamard and flag measurement have data Kraus operators -$$ +```math \frac{I+R}{2}=P,\qquad \frac{I-R}{2}=I-P. -$$ - -The instrument is therefore the exact Lüders pair $\rho\mapsto P\rho P$ or $\rho\mapsto(I-P)\rho(I-P)$. Measuring the original permutation-average success flag alone would not establish the required rejection channel; the reflection construction supplies it. +``` +The instrument is therefore the exact Lüders pair $`\rho\mapsto P\rho P`$ or $`\rho\mapsto(I-P)\rho(I-P)`$. Measuring the original permutation-average success flag alone would not establish the required rejection channel; the reflection construction supplies it. ## Gate count and precision -For each candidate Fisher–Yates index, compute an equality flag in $O(\log k)$ reversible gates, use it for $q$ controlled swaps between specified wires, and uncompute it. Summation over all candidate indices and steps gives $O(K^2(q+\log K))$ elementary reversible gates. Known interval-state preparation can be implemented by a direct binary-tree rotation construction using at most $O(K^2\log K)$ gates across all intervals. The reflection about the all-zero ancilla state needs $O(A)$ gates with clean scratch. Therefore one ideal comparison uses +For each candidate Fisher–Yates index, compute an equality flag in $`O(\log k)`$ reversible gates, use it for $`q`$ controlled swaps between specified wires, and uncompute it. Summation over all candidate indices and steps gives $`O(K^2(q+\log K))`$ elementary reversible gates. Known interval-state preparation can be implemented by a direct binary-tree rotation construction using at most $`O(K^2\log K)`$ gates across all intervals. The reflection about the all-zero ancilla state needs $`O(A)`$ gates with clean scratch. Therefore one ideal comparison uses -$$ +```math G=O\!\left(K^2(q+\log K)\right) -$$ - -elementary gates, counting arbitrary one-qubit rotations, and $O(K\log K)$ ancillary qubits beyond the selected data registers. This is polynomial in the physical input size and in $\log d$; it is not a polynomial-in-$d$ Schur-transform assumption. +``` +elementary gates, counting arbitrary one-qubit rotations, and $`O(K\log K)`$ ancillary qubits beyond the selected data registers. This is polynomial in the physical input size and in $`\log d`$; it is not a polynomial-in $`d`$ Schur-transform assumption. -For a finite gate set, choose each synthesized rotation to have operator error $O(\delta/G)$. Composition bounds then give operator error $O(\delta)$ for the comparison circuit and diamond-norm error $O(\delta)$ for its complete measurement instrument, including workspace reset. An adaptive hybrid argument over at most $M$ comparisons gives added statistical error $O(M\delta)$. Choosing $\delta=\Theta(\eta/M)$ makes this at most the specified $\eta>0$. +For a finite gate set, choose each synthesized rotation to have operator error $`O(\delta/G)`$. Composition bounds then give operator error $`O(\delta)`$ for the comparison circuit and diamond-norm error $`O(\delta)`$ for its complete measurement instrument, including workspace reset. An adaptive hybrid argument over at most $`M`$ comparisons gives added statistical error $`O(M\delta)`$. Choosing $`\delta=\Theta(\eta/M)`$ makes this at most the specified $`\eta>0`$. -Using single-qubit Clifford+T approximation with $O(\log(1/\zeta))$ gate count for operator error $\zeta$, a conservative total scan count is +Using single-qubit Clifford+T approximation with $`O(\log(1/\zeta))`$ gate count for operator error $`\zeta`$, a conservative total scan count is -$$ +```math O\!\left( MG\log\frac{MG}{\eta} \right),\qquad G=O\!\left(K^2(q+\log K)\right). -$$ - +``` Alternatively, a generic Solovay–Kitaev compiler gives the same polynomial resource statement with a polylogarithmic precision factor. The near-logarithmic rotation-synthesis count concerns circuit size; compiler classical runtime and its arithmetic assumptions should be charged if a concrete compiled implementation is requested. The supplied-copy result needs no uncharged computation on the unknown states. -The finite-gate circuit may leave a small residual workspace error. The diamond-instrument bound includes discarding and resetting that workspace; finite precision is not described as exact cleanup. With this synthesis choice, the actual success is at least $1-2(M-1)/C-\eta$, clipped at zero. +The finite-gate circuit may leave a small residual workspace error. The diamond-instrument bound includes discarding and resetting that workspace; finite precision is not described as exact cleanup. With this synthesis choice, the actual success is at least $`1-2(M-1)/C-\eta`$, clipped at zero. ## Complete input and memory account | Resource | Charged amount for the full scan | | --- | --- | -| Supplied reference copies | $Mm$ unknown physical states | -| Supplied query copies | $t$ unknown physical states | -| Data storage when references precede query | $(Mm+t)q$ qubits | -| Additional circuit workspace | $O(K\log K)$ qubits | -| Active data per comparison | $Kq$ qubits | -| Comparisons | At most $M$ | -| Classical output | One label, requiring $\lceil\log_2M\rceil$ bits | -| Finite-gate scan | $O(MG\log(MG/\eta))$ gates under the stated synthesis convention | +| Supplied reference copies | $`Mm`$ unknown physical states | +| Supplied query copies | $`t`$ unknown physical states | +| Data storage when references precede query | $`(Mm+t)q`$ qubits | +| Additional circuit workspace | $`O(K\log K)`$ qubits | +| Active data per comparison | $`Kq`$ qubits | +| Comparisons | At most $`M`$ | +| Classical output | One label, requiring $`\lceil\log_2M\rceil`$ bits | +| Finite-gate scan | $`O(MG\log(MG/\eta))`$ gates under the stated synthesis convention | -All source-preparation or acquisition costs are additional charged costs for the $Mm+t$ supplied copies. The Haar model specifies an input distribution; it does not assert efficient preparation of arbitrary Haar states. The reference bank is physically retained until it is used or discarded, rather than supplied through a free addressing oracle. Controlled swaps connect known wires, and the label scan is classical control. +All source-preparation or acquisition costs are additional charged costs for the $`Mm+t`$ supplied copies. The Haar model specifies an input distribution; it does not assert efficient preparation of arbitrary Haar states. The reference bank is physically retained until it is used or discarded, rather than supplied through a free addressing oracle. Controlled swaps connect known wires, and the label scan is classical control. -The same $t$ query copies are used across comparisons. Their disturbance is already included in the noncommutative union-bound analysis. This is a single-lookup theorem: later reuse of the references or queries is not guaranteed, and the protocol may consume or disturb both. A random-subset decoder can retain fewer references after an initial choice, but acquisition of the original $Mm$ supplied states is still charged. +The same $`t`$ query copies are used across comparisons. Their disturbance is already included in the noncommutative union-bound analysis. This is a single-lookup theorem: later reuse of the references or queries is not guaranteed, and the protocol may consume or disturb both. A random-subset decoder can retain fewer references after an initial choice, but acquisition of the original $`Mm`$ supplied states is still charged. -For $m=1$ and $t$ proportional to $M$, the bound is polynomial but can scale as $\widetilde O(M^3\log d)$. The result establishes the number of supplied quantum specimens needed for identification and the possibility of a finite circuit. It does not establish a runtime advantage over a classical algorithm with fully described templates. +For $`m=1`$ and $`t`$ proportional to $`M`$, the bound is polynomial but can scale as $`\widetilde O(M^3\log d)`$. The result establishes the number of supplied quantum specimens needed for identification and the possibility of a finite circuit. It does not establish a runtime advantage over a classical algorithm with fully described templates. Primary synthesis reference: [Ross and Selinger, Optimal ancilla-free Clifford+T approximation of z-rotations](https://arxiv.org/abs/1403.2975). The quantum union bound is [Gao, Phys. Rev. A 92, 052331 (2015)](https://arxiv.org/abs/1410.5688). The clean-reflection derivation above is included explicitly so the instrument and its rejected branch can be checked without an oracle implementation assumption. diff --git a/science/revealed_query.md b/science/revealed_query.md index e64ae4d..c21ed5c 100644 --- a/science/revealed_query.md +++ b/science/revealed_query.md @@ -1,27 +1,25 @@ # Exactly revealed query -Consider a stronger experiment: after the reference systems have been retained, the exact query state $\psi$ is supplied as a classical description. Conditional on $\psi$, the reference hypotheses are +Consider a stronger experiment: after the reference systems have been retained, the exact query state $`\psi`$ is supplied as a classical description. Conditional on $`\psi`$, the reference hypotheses are -$$ +```math \rho_j^{(\psi)} =\psi^{\otimes m}_{R_j}\otimes \bigotimes_{i\neq j}\frac{I_{R_i}}{D_m}. -$$ +``` +These hypotheses commute. Measure each reference block against the rank-one projector $`\psi^{\otimes m}`$. The true label always passes. Every other label independently passes with probability $`p=1/D_m`$. The common eigenbasis resolves all available information; conditional on its passing set the posterior is uniform on that set. Uniform tie breaking is therefore optimal, and -These hypotheses commute. Measure each reference block against the rank-one projector $\psi^{\otimes m}$. The true label always passes. Every other label independently passes with probability $p=1/D_m$. The common eigenbasis resolves all available information; conditional on its passing set the posterior is uniform on that set. Uniform tie breaking is therefore optimal, and - -$$ +```math \begin{aligned} P_{\mathrm{quantum,revealed}} -&=\mathbb E\!\left[\frac1{1+\operatorname{Bin}(M-1,1/D_m)}\right]\\ +&=\mathbb E\!\left[\frac1{1+\mathrm{Bin}(M-1,1/D_m)}\right]\\ &=\frac{D_m}{M} \left[1-\left(1-\frac1{D_m}\right)^M\right]. \end{aligned} -$$ - -For example, use $1/(k+1)=\int_0^1x^k\,dx$ in the binomial average to obtain the second line. This formula includes $D_m=1$ and $M=1$ without taking limits. When $M/D_m\to0$ with $M\geq2$, its error is asymptotic to $(M-1)/(2D_m)$. +``` +For example, use $`1/(k+1)=\int_0^1x^k\,dx`$ in the binomial average to obtain the second line. This formula includes $`D_m=1`$ and $`M=1`$ without taking limits. When $`M/D_m\to0`$ with $`M\geq2`$, its error is asymptotic to $`(M-1)/(2D_m)`$. -The revealed-query experiment upper bounds every finite-query success probability. It supplies extra information; it is not the finite-$t$ optimum or a free tomography primitive. At fixed $d,m,M$, consistent pure-state tomography as $t\to\infty$, followed by the conditional reference measurement, approaches the revealed-query optimum. Thus it is also the limiting endpoint of the finite-query problem, without a claimed finite-copy tomography rate. +The revealed-query experiment upper bounds every finite-query success probability. It supplies extra information; it is not the finite $`t`$ optimum or a free tomography primitive. At fixed $`d,m,M`$, consistent pure-state tomography as $`t\to\infty`$, followed by the conditional reference measurement, approaches the revealed-query optimum. Thus it is also the limiting endpoint of the finite-query problem, without a claimed finite-copy tomography rate. Return to [finite-query identification](quantum_identification.md) or compare the [classical-record endpoint](classical_preprocessing.md). diff --git a/verification/README.md b/verification/README.md index fe2b1a0..11ea087 100644 --- a/verification/README.md +++ b/verification/README.md @@ -44,3 +44,5 @@ roundoff. Assertions use explicit numerical tolerances. A passed finite check is neither a proof of an arbitrary-parameter statement nor a novelty review. The checked dependency versions are pinned in [requirements.txt](requirements.txt). The saved [results.json](results.json) records the reproducible reference run; `results.new.json` is an optional fresh output for comparison. + +See [hosted mathematics](hosted/README.md) for the separate source-to-GitHub rendering check and its visual-review limits. diff --git a/verification/hosted/README.md b/verification/hosted/README.md new file mode 100644 index 0000000..5382294 --- /dev/null +++ b/verification/hosted/README.md @@ -0,0 +1,20 @@ +# Checking the hosted mathematical account + +The read-only [verification workflow](../../.github/workflows/verify.yml) captures the actual commit-pinned GitHub rendering of every tracked Markdown page at widths 1440 and 760 pixels. It compares each inline and display expression, including table cells, with MathML compiled from the same pinned source. A source hash and complete expression count bind every page; headline expressions also have explicit text contracts. + +The collector and source checker are a matched copy of version 0.10.0 of the Merlin–Arthur verification helpers. The collector opens an anonymous browser and requires public pinned pages. It does not request credentials or change repository settings. + +To reproduce with Node.js 18 or newer, Python 3.10 or newer, Git, Playwright 1.56.1, MathJax 3.2.1 and Chromium installed: + +```bash +NODE_PATH=/absolute/dependency-directory/node_modules node verification/hosted/capture_hosted_math.cjs \ + --root /absolute/repository-checkout \ + --repository GoGoKo699/Quantum-Reference-Identification \ + --revision FULL_COMMIT_SHA \ + --contract verification/hosted/math-contract.json \ + --output /absolute/new-evidence-directory +``` + +Replace the paths and commit with the actual checkout and inspected revision. The output directory must be new or empty so earlier failures remain available. The report includes exact source and page identities, both viewport results, captured host counts, structural comparisons, screenshot hashes and any failures. + +A passing report checks source-to-host correspondence and bounded equation geometry. It does not establish proof validity, priority, full page legibility or future renderer behavior. Inspect the saved screenshots, all flagged or repaired formulas, ordinary tables and navigation separately. The finite scientific checks have their own [reproduction route](../README.md). Workflow artifacts expire; the durable review record preserves the report and its source pin separately. 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/hosted/math-contract.json b/verification/hosted/math-contract.json new file mode 100644 index 0000000..cc46e82 --- /dev/null +++ b/verification/hosted/math-contract.json @@ -0,0 +1,101 @@ +{ + "schema_version": 1, + "expressions": [ + { + "path": "README.md", + "index": 5, + "source_sha256": "b517ec1db003919915a8b7a5c8e27e7a3b9594d90147595be029f3ae68dcb3a7", + "expected_text": "\n \n D\n s\n \n =\n \n \n (\n \n \n \n d\n +\n s\n −\n 1\n \n s\n \n \n )\n \n \n ,\n \n \n \n C\n =\n \n \n \n D\n m\n \n \n D\n t\n \n \n \n D\n \n m\n +\n t\n \n \n \n .\n" + }, + { + "path": "README.md", + "index": 7, + "source_sha256": "d1b73ea42d329cddd0d80ae4abda25288984148238be41775cbca5c7e0a82aab", + "expected_text": "\n \n \n M\n −\n 1\n \n \n 8\n C\n +\n 4\n (\n M\n −\n 2\n )\n \n \n ≤\n \n e\n \n \n opt\n \n \n \n ≤\n \n \n M\n −\n 1\n \n \n C\n +\n M\n −\n 1\n \n \n .\n" + }, + { + "path": "README.md", + "index": 15, + "source_sha256": "6b9671bf5bbf6c1cf159ee8acf23baec59b7991c4487d24738f57ff31d549704", + "expected_text": "\n \n P\n \n \n classical\n \n \n \n \n revealed\n \n \n \n =\n (\n 1\n +\n o\n (\n 1\n )\n )\n \n \n (\n log\n ⁡\n M\n \n )\n m\n \n \n \n m\n !\n M\n \n \n .\n" + }, + { + "path": "learning/ANCHOR_AND_BRIDGE.md", + "index": 4, + "source_sha256": "930b39e95376c1afbcd43c63d9bb876d0a44a3f81432a299ffec865ecddbb4a1", + "expected_text": "\n |\n ψ\n ⟩\n" + }, + { + "path": "learning/ANCHOR_AND_BRIDGE.md", + "index": 6, + "source_sha256": "55c19a5a0b6e38ae66fc36123e5ee5f2a0db470e28330b85ef572e106119f6af", + "expected_text": "\n |\n ψ\n ⟩\n ⟨\n ψ\n |\n" + }, + { + "path": "learning/WALKTHROUGH.md", + "index": 36, + "source_sha256": "996f06d3c4b90db25f993f379d2d64d56d6115e3a1454de53abd2cddf2209eb5", + "expected_text": "\n \n P\n \n \n opt\n \n \n \n =\n \n 1\n 2\n \n +\n \n 1\n 4\n \n ∥\n \n ρ\n 1\n \n −\n \n ρ\n 2\n \n \n ∥\n 1\n \n =\n \n 1\n 2\n \n +\n \n \n 3\n \n 12\n \n ≈\n 0.644338\n .\n" + }, + { + "path": "learning/WALKTHROUGH.md", + "index": 48, + "source_sha256": "255540598648d601d38978c9f40acff2e7c93a3a54a75bdb374605189a6d62cc", + "expected_text": "\n \n P\n \n \n quantum\n ,\n revealed\n \n \n \n =\n \n 1\n 2\n \n ⋅\n 1\n +\n \n 1\n 2\n \n ⋅\n \n 1\n 2\n \n =\n \n 3\n 4\n \n .\n" + }, + { + "path": "science/classical_preprocessing.md", + "index": 41, + "source_sha256": "e36ac5671ab570c0e49f93e181913def5b5b9bcca6cccc0008df56cd8ac5b713", + "expected_text": "\n \n \n \n \n \n P\n \n \n cl\n \n \n \n \n rev\n \n \n \n (\n d\n ,\n M\n ,\n m\n )\n ≤\n min\n \n {\n 1\n ,\n \n inf\n \n s\n ∈\n \n \n N\n \n \n ≥\n 1\n \n \n \n \n \n M\n \n 1\n \n /\n \n s\n −\n 1\n \n \n \n \n D\n m\n \n \n D\n \n m\n s\n \n \n 1\n \n /\n \n s\n \n \n \n }\n \n .\n \n \n \n \n" + }, + { + "path": "science/classical_preprocessing.md", + "index": 69, + "source_sha256": "1c1cf3e948fbf79f4c80e663ecad50bdec91b24db8b9179f38aadb86738c46b6", + "expected_text": "\n \n \n \n \n \n P\n \n \n cl\n \n \n \n \n rev\n \n \n \n (\n d\n ,\n M\n ,\n m\n )\n =\n (\n 1\n +\n o\n (\n 1\n )\n )\n \n \n (\n log\n ⁡\n M\n \n )\n m\n \n \n \n m\n !\n M\n \n \n .\n \n \n \n \n" + }, + { + "path": "science/classical_preprocessing.md", + "index": 114, + "source_sha256": "b08de312b67e00dc0b4e32fef2bb3cf435eb6bc7aa45c68c02eaaf77391df387", + "expected_text": "\n \n P\n \n \n cl\n \n \n \n (\n d\n ,\n M\n ,\n m\n ,\n t\n )\n ≤\n 1\n −\n α\n +\n \n α\n M\n \n ≤\n \n 1\n M\n \n +\n \n \n m\n t\n \n d\n \n .\n" + }, + { + "path": "science/quantum_identification.md", + "index": 18, + "source_sha256": "22cc3250d3e87d72a426ea3ef7e456cfa21c9d0a15070cbb03976d327f4c3389", + "expected_text": "\n \n C\n \n C\n +\n M\n −\n 1\n \n \n ≤\n \n P\n \n \n opt\n \n \n \n ≤\n min\n \n \n \n \n {\n 1\n ,\n \n C\n M\n \n }\n \n ,\n" + }, + { + "path": "science/quantum_identification.md", + "index": 19, + "source_sha256": "7a8180eb27c3a567a6a6ded1110b816b70883ada3d1e7438d5516969a28cb3ce", + "expected_text": "\n max\n \n \n \n \n {\n 0\n ,\n 1\n −\n \n C\n M\n \n ,\n \n \n M\n −\n 1\n \n \n 8\n C\n +\n 4\n (\n M\n −\n 2\n )\n \n \n }\n \n ≤\n \n e\n \n \n opt\n \n \n \n ≤\n \n \n M\n −\n 1\n \n \n C\n +\n M\n −\n 1\n \n \n .\n" + }, + { + "path": "science/quantum_identification.md", + "index": 107, + "source_sha256": "8fc6365b8706e1998f311e8fc482d183a29f7bd9a77f71cf2d82695a7dca2c27", + "expected_text": "\n \n e\n \n \n opt\n \n \n \n ≥\n \n \n β\n 2\n \n \n 4\n (\n 2\n β\n +\n γ\n )\n \n \n =\n \n \n M\n −\n 1\n \n \n 8\n C\n +\n 4\n (\n M\n −\n 2\n )\n \n \n .\n" + }, + { + "path": "science/resources.md", + "index": 25, + "source_sha256": "1f38a5110b3ceeb88a4a25d1d1f07938b582ac50f8a73741a0dc95f90834f939", + "expected_text": "\n \n W\n †\n \n (\n \n Z\n 0\n \n ⊗\n I\n )\n W\n (\n |\n 0\n ⟩\n v\n )\n =\n |\n 0\n ⟩\n (\n 2\n P\n −\n I\n )\n v\n" + }, + { + "path": "science/resources.md", + "index": 53, + "source_sha256": "9ff4c07bd7b18310611ef26d9f05512b49683f5ec7162aaa6f09fa5ff73194cd", + "expected_text": "\n O\n \n \n \n \n (\n M\n G\n log\n ⁡\n \n \n M\n G\n \n η\n \n )\n \n ,\n \n \n \n G\n =\n O\n \n \n \n \n (\n \n K\n 2\n \n (\n q\n +\n log\n ⁡\n K\n )\n )\n \n .\n" + }, + { + "path": "science/revealed_query.md", + "index": 6, + "source_sha256": "77f148a3cc5089a520a3aaa50b254e11fd33bb46cc03b95bde1e0e4374a41cd9", + "expected_text": "\n \n \n \n \n P\n \n \n quantum\n ,\n revealed\n \n \n \n \n \n \n =\n \n E\n \n \n \n \n \n [\n \n 1\n \n 1\n +\n \n Bin\n \n (\n M\n −\n 1\n ,\n 1\n \n /\n \n \n D\n m\n \n )\n \n \n ]\n \n \n \n \n \n \n \n =\n \n \n D\n m\n \n M\n \n \n [\n 1\n −\n \n \n (\n 1\n −\n \n 1\n \n D\n m\n \n \n )\n \n M\n \n ]\n \n .\n \n \n \n" + } + ] +}