Repository navigation
feat(Classes/BQP): error reduction for BQP by reversible majority vote (#896 M2) - #1930
Conversation
…M2) Define BQP by polynomial-time uniform families of quantum circuits over the Hadamard, NOT, CNOT and Toffoli gates, accepting by measuring qubit 0, with bounded error 2/3 vs 1/3 (Samuel's 2026-10-30 decision on #896). Gate codes, their decoding to M1 placed gates and the acceptance probability live under Circuit/Quantum; the class and its closure under complement under Classes. Tests cover exact deciders, interference and a family that decides nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
#896 M2) A problem is in BQP exactly when, for every polynomial q, some uniform family errs with probability at most 2^{-q(n)}. The amplified family runs 2r copies of the circuit on disjoint blocks, counts their answers with a reversible thermometer counter of CNOT/Toffoli gates, and swaps the strict majority into qubit 0. Copies on disjoint blocks act independently, so the acceptance probability is exactly that of a strict majority of 2r independent trials; a weighted exponential-moment bound gives (8/9)^r. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…ate codes The three-CNOT swap into qubit 0 is reused by the reversible compilation of Boolean circuits, so it belongs with the classical gate-code API rather than inside the amplification construction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine (independent, non-author agent): APPROVE bcbbeb9. Read the complete seven-file layer, reusing #1916 after verifying unchanged gate, uniform-family and BQP definitions. No findings.
The copy step acts on classical basis inputs with zero ancillas; disjoint placements give product amplitudes while retaining agreement outside the blocks. Classical circuits permute all basis outcomes, so retained counter garbage introduces no interference error. Fresh levels compute the thermometer recurrence, and the final swap measures a strict majority of 2r answers at qubit 0. The weighted tail bound includes ties on the completeness side and bounds soundness by a larger event; r=6q gives the stated exponent. Zero repetitions correctly yield the trivial error bound. Unary widths, wire codes and repetition counts preserve polynomial-time uniform generation and polynomial circuit size. The theorem quantifies over every Polynomial ℕ on encoding lengths and remains a decision-language result; no promise-problem claim or new abstract.
Tests cover both counter thresholds, the exact two-copy Hadamard probability 1/4 and FirstBit amplification. Independent exact path-amplitude checks passed 360 small circuit/amplification cases, including interference and r=0; 2,048 counter truth-table cases and the numerical tail/exponent bounds also passed. Whitespace and the complete sorted 3,200-module aggregate pass. This is an original formal proof of the standard amplification argument, with no new quoted source claim.
Author reports all six local gates. At the single CI inspection, Lean CI was pending, Guide running and title passed. No reviewer Lean build. Live head/history rechecked; agent approval, not human approval.
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
|
|
Carry-forward record ( |
Change
Error reduction for
BQP(the amplification half of #896 M2). Stacked on #1916; base branchclaude/bqp-896.What is proved.
Cslib.Complexity.mem_BQP_iff_forall_errorExponent:A ∈ BQP enciff, for every polynomialq : Polynomial ℕ, someUniformCircuitFamilyaccepts the encodings of members with probability at least1 - 2^{-q(n)}and other instances with probability at most2^{-q(n)}, wheren = |enc a|. Acceptance is still a single measurement of qubit 0 at the end, as in #1916's definition.Construction (
UniformCircuitFamily.amplify). On inputs of lengthn, with original widthw, it uses2rcopies:1..2rof widthw;rof the blocks' first qubits are one;The register has
(2r+1)w + 1 + (2r+1)(r+1)qubits, and the gate codes are built in polynomial time fromnin unary.Key lemmas.
Circuit.matrix_flatMap_mapWires: copies of one circuit on pairwise disjoint qubit sets act independently. Each entry of the whole circuit is the product of the copies' entries, provided the basis strings agree off the blocks. This is the tensor-product structure, proved fromplace_applywith no new linear algebra.Circuit.measureProb_eval_ofCodes: measuring after a classical (NOT/CNOT/Toffoli) circuit equals measuring before it and permuting the outcome.Counter.readBit_classicalRun_codes: the thermometer counter. At stages, leveliholds[more than i of the first s inputs are 1]. Each level is updated by the multiplexert ⊕ (b∧u) ⊕ (b∧t), and fresh ancillas keep every stage reversible.UniformCircuitFamily.acceptProb_amplify: the amplified acceptance probability is exactly∑_{b : Fin 2r → Bool, #b > r} ∏ⱼ (p if bⱼ else 1-p), wherepis the original acceptance probability.Cslib.sum_prod_le_of_card_filter_le(newFoundations/Combinatorics/MajorityVote/Weighted.lean): the weighted version of the existing counting boundcard_filter_card_filter_le_le, with the same exponential-moment proof. With good-probability ≥ 2/3, at most half of2rtrials are good with probability ≤(8/9)^r. Takingr = 6qgives2^{-q}.Sources. This is the standard majority-vote argument, carried out reversibly inside the circuit. No source locator is claimed. I checked the Arora–Barak January 2007 draft (Ch. 20, Defs. 20.13–20.14, p20.12): it does not discuss error reduction for BQP, so it is cited only for the definition, as in #1916. The classical analogue in the library is
mem_BPP_iff_forall_decidesWithErrorExponent.Existing notions considered. The new definitions are
AgreeOff,glue,PlacedGate/Circuit.mapWires,GateCode.shift,blockEmb,GateCode.classicalStep/classicalRun,readBitandCounter.*. They are circuit plumbing on top of M1'sPlacedGate,place_applyandsplitEquiv, with no parallel notion of state or gate.readBituses the same reading aseval_toPlacedGate_ket((List.ofFn x).getD c false). The BPP amplification machinery (repeatMajority, counting over random strings) works on uniform counts, not on real-weighted products, so only its bound's proof pattern is reused.Limits. The error parameter is a
Polynomial ℕ, matching BPP'sSolvesWithErrorExponent. Amplification is stated for decision problems only; there is no promise-problem version.Abstract impact. None. No selected abstract mentions
BQP.Validation
scripts/check.sh --quickfell back to all six gates because #1916 touchesreferences.bib. All six passed locally at 5b21c57; bcbbeb9 then movedswapCodesintoClassical.lean(rebuilt and tested): build,mk_all --check, test, lint, lint-style, checkInitImports. Nosorry, axioms,native_decideor heartbeat overrides.Tests (
ComplexityTests/BQPAmplification.lean):decideon concrete 9-qubit registers, on both sides of the threshold;H|0⟩family: a strict majority of two fair coins is1/4;FirstBitdecided with error2^{-q(n)}for everyq.AI assistance
Written by
worker-claude-e6cf7b0d-bqp-2(Claude Code, Opus), a subagent ofcoordinator-claude-e6cf7b0d. It needs a non-Claude-fleet review.🤖 Generated with Claude Code
https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG