Repository navigation
feat(Classes/BQP): P ⊆ BQP by reversible compilation of uniform circuits (#896) - #1936
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
…its (#896) Every polynomial-time Boolean function is computed exactly, with acceptance probability 1 or 0, by a uniform family of NOT/CNOT/Toffoli circuits: the polynomial-time uniform De Morgan circuits are compiled gate by gate onto fresh qubits, and the output wire is swapped into qubit 0. Arguments that are missing or name later wires read a never-written zero qubit, matching evalCode, so the compiler is correct on every gate list. Wire numbers are capped by the gate's unary index before conversion, so compilation runs in polynomial time. 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 at 599c6d8.
Read the complete four-file layer over approved #1930, the Boolean evaluator, uniform-circuit constructor and P/BQP definitions. Fresh targets and the untouched zero wire preserve the evaluator's semantics even for missing, repeated, forward and oversized wire indices. Output swapping handles empty inputs and out-of-range outputs. Capping binary indices before unary conversion prevents exponential compiler output. The length-only uniform constructor gives one exact family for every encoded instance; retaining garbage is sound for the final basis measurement.
Checked Arora–Barak's January 2007 draft, §20.4, pp.20.15–20.16: the gate-by-gate permutation construction and omitted uncomputation are accurately mapped. This proves P ⊆ the library's finite-gate circuit BQP; the parent documents that equivalence with other quantum models is cited. Lean tests cover both XOR outcomes, repeated/forward wires, exact probabilities and CircuitValue. Independent checks passed 1,600 gate-list cases including empty inputs, missing arguments and 1,001-bit wire indices. No curated-abstract impact.
Whitespace passes. Author reports all six local gates. At the single CI inspection, Lean CI and Guide were running; title passed. No reviewer Lean build. Live head rechecked immediately before posting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
|
|
Carry-forward record ( |
Change
P ⊆ BQP(#896), stacked on #1930 (base branchclaude/bqp-amplify-896). It reuses that PR's classical gate-code API:classicalRun,measureProb_eval_ofCodesandswapCodes.What is proved.
Cslib.Complexity.exists_uniformCircuitFamily: everyf : α → Boolthat isComputableInPolyTime f enc encBoolis computed exactly by aUniformCircuitFamilyof NOT/CNOT/Toffoli circuits. Its acceptance probability is1wheref a = trueand0where it is false.Cslib.Complexity.P_subset_BQP : P enc ⊆ BQP enc, which follows directly.Construction. The family compiles the polynomial-time uniform De Morgan circuits of
CircuitValue.exists_uniformCircuits.Reversible.codes: on inputs of lengthn, gatejof the circuit code writes the fresh qubitn + j, following the wire numbering of circuit codes.¬ais CNOT followed by NOT.a ∧ bis a Toffoli gate.a ∨ b = a ⊕ b ⊕ (a∧b)is two CNOTs and a Toffoli.evalCodereads such arguments asfalse, so the compiler is correct for every gate list and needs no well-formedness hypothesis (Reversible.readBit_classicalRun_codes).Reversible.circuitCodes: three CNOTs then swap the output wire into qubit 0. The register hasn + G + 1qubits.Polynomial time. Circuit codes write wire numbers in binary, but quantum gate codes need unary. The compiler first caps each argument at the gate's own unary number (
binary_min_unary) and only then converts it, so it never produces large unary numbers (Reversible.computableInPolyTime_codes).Sources. The construction is the gate-by-gate simulation of Boolean circuits by permutation gates in Arora–Barak, January 2007 web draft, §20.4 ("Quantum programmer's toolkit", pp. p20.15–p20.16). There it is used for Theorem 20.17 (
BPP ⊆ BQP, p20.16), and I checked both locators against that draft. AB uncompute at the end; this compilation skips that step, because only qubit 0 is measured. The module docs cite the print edition by chapter only, as #1916 does.Existing notions considered. The compiler reuses
evalCode/evalOutput,Circuit.eval_eq_evalOutputandexists_uniformCircuitsfrom the Boolean circuit library, together with the classical gate-code API from #1930. The new definitionscapArg,argQubit,gateCodes,codes,outQubit,circuitCodesandUniformCircuitFamily.ofBooleanCircuitsare compiler-specific.Abstract impact. None.
Validation
All six gates pass locally at 599c6d8: build,
mk_all --check, test, lint, lint-style and checkInitImports. Quick mode falls back to all six because the stack touchesreferences.bib. There is nosorry, axiom,native_decideor heartbeat override.Tests (
ComplexityTests/BQPClassical.lean):decideon both sides;1and0of the compiled circuit;CircuitValue ∈ BQP encCircuitValue.AI assistance
Written by
worker-claude-e6cf7b0d-bqp-2(Claude Code, Opus), a subagent ofcoordinator-claude-e6cf7b0d. It needs review from outside the Claude fleet.🤖 Generated with Claude Code
https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG