Documentation

CslibFrontier.Computability.Circuit.Quantum.Reversible.Sampling

Reversible quantum realization of Boolean samplers #

A De Morgan circuit on n input bits is a sampler when its inputs are fair coins. This module realizes that sampler as an elementary quantum circuit: put Hadamard gates on n zero qubits, compile the Boolean gate list with Cslib.Quantum.Reversible.codes, retain the seed and compiler garbage, and copy every Boolean output into a fresh declared output block. A single final computational-basis measurement reads that block.

The construction is exact relative to the Boolean circuit's output distribution. In particular, it introduces no additional abort or approximation: non-dyadic error, collisions, and fixed-weight guarantees remain properties of the Boolean sampler supplied by a client. Concrete instruction, qubit, measurement and encoded-description costs are kept separate from the static generator program and its offline running time.

Main definitions #

Main results #

References #

CNOT gates copying the listed Boolean output wires into fresh qubits starting at base. Output j reads outQubit z outputs[j], so an invalid wire reads the compiler's zero qubit.

The first qubit of the copied output block.

The complete register width: seeds, Boolean gates, a zero qubit, and copied outputs.

The classical suffix of the sampler: reversible Boolean evaluation followed by output copy.

The elementary quantum sampler: fair seed preparation, reversible Boolean evaluation, and copying every declared output to a fresh block.

Read the copied output block of a typed Boolean circuit from a measured basis string.

The measured output distribution of the reversible realization, started with every qubit zero. The construction performs one final computational-basis measurement and reads only the fresh copied output block.

@[simp]
theorem Cslib.Quantum.Reversible.length_outputCopyCodes (z base : ℕ) (outputs : List ℕ) :
(outputCopyCodes z base outputs).length = outputs.length
theorem Cslib.Quantum.Reversible.isClassical_outputCopyCodes {W z base : ℕ} {outputs : List ℕ} (hzb : z < base) (hW : base + outputs.length ≤ W) :

Every copied-output CNOT is classical and well formed when the target block follows z and fits in the register.

The classical suffix is well formed for the sampler's declared width.

Every gate emitted by the reversible sampler is valid for its declared register width.

Classical correctness #

theorem Cslib.Quantum.Reversible.readBit_classicalRun_outputCopyCodes {W z base : ℕ} {outputs : List ℕ} (hzb : z < base) (hW : base + outputs.length ≤ W) (X : Fin W → Bool) (hX : ∀ j < outputs.length, readBit X (base + j) = false) {j : ℕ} (hj : j < outputs.length) :
readBit (GateCode.classicalRun (outputCopyCodes z base outputs) X) (base + j) = readBit X (outQubit z (outputs.getD j 0))

Copying an output block writes source outputs[j] into target base + j, provided the target block starts after every possible source and is initially zero.

Basis-state correctness of the classical suffix: on a seed x followed by zero ancillas, the copied output block is exactly the output of the typed Boolean circuit.

Exact output law #

Exact fair-seed realization: measuring the copied output block of the reversible quantum sampler gives exactly the output distribution of the Boolean circuit on uniform inputs. The classical suffix only permutes basis states, so seed branches cannot interfere.

Output-copy code generation is polynomial time in the unary block positions and binary output wire list.

The first copied-output position is generated in polynomial time from the unary seed count and complete binary-wire circuit code.

The complete fair-seed reversible sampler is generated in polynomial time from the input arity and Boolean circuit code. This is an offline generator certificate, not an online execution-time or static generator-program-size bound.