Documentation

CslibFrontier.Computability.Circuit.Quantum.Oracle.Code

Finite descriptions of quantum oracle circuits #

An OracleGateCode is an existing elementary PhaseGateCode or a coherent XOR query to a fixed function on the first a + b wires. OracleCircuit.toCircuit interprets a list of these instructions through the existing Circuit semantics. It skips malformed instructions, just as Circuit.ofPhaseCodes does; OracleGateCode.WellFormed characterizes exactly the instructions that are retained. A well-formed description therefore has exactly its stated number of gates.

Elementary gates and queries are counted separately. These counts describe the finite circuit; they do not certify polynomial-time uniform generation or bound the implementation cost of the oracle. The elementary basis includes Hadamard, NOT, CNOT, Toffoli, phase and controlled phase gates, with the phase inverses. The constructions and elementary identities below are original formalization infrastructure.

Main definitions #

Main results #

A finite instruction: an elementary gate code, or a coherent query to the supplied oracle.

A query is well formed when its argument and response registers fit in the full register. An elementary gate uses the existing gate-code validity condition.

Instances For
    noncomputable def Cslib.Quantum.OracleGateCode.toPlacedGate? {a b : ℕ} (m : ℕ) (H : (Fin a → Bool) → Fin b → Bool) :

    Interpret an instruction, returning none for malformed elementary gates or a query whose two registers do not fit. The oracle is a single fixed function shared by all query instructions.

    Exactly the well-formed instructions denote placed gates.

    Whether this instruction is an oracle call, independent of its interpretation.

    @[reducible, inline]

    A finite quantum oracle-circuit description, in execution order.

    noncomputable def Cslib.Quantum.OracleCircuit.toCircuit {a b : ℕ} (m : ℕ) (H : (Fin a → Bool) → Fin b → Bool) (codes : OracleCircuit) :

    Interpret finite codes as a circuit. Malformed instructions are skipped; impose ∀ g ∈ codes, g.WellFormed a b m to rule them out.

    Number of oracle calls in the description.

    Number of elementary gates in the description; oracle calls have a separate cost.

    theorem Cslib.Quantum.OracleCircuit.toCircuit_append {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (codes₁ codes₂ : OracleCircuit) :
    toCircuit m H (codes₁ ++ codes₂) = toCircuit m H codes₁ ++ toCircuit m H codes₂

    Concatenation executes the first circuit followed by the second.

    An oracle-free description has exactly the original coded-circuit interpretation.

    theorem Cslib.Quantum.OracleCircuit.toCircuit_map_gateCode {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (codes : List GateCode) :

    Mapping ordinary gate codes to phase-free oracle instructions recovers their ordinary finite-circuit interpretation directly.

    Any even number of coherent XOR queries cancels, on arbitrary states. The total interpreter also has this property when a malformed query is skipped.

    theorem Cslib.Quantum.OracleCircuit.length_toCircuit {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (codes : OracleCircuit) (h : ∀ g ∈ codes, OracleGateCode.WellFormed a b m g) :

    Every well-formed instruction is executed, so semantic gate count equals description length.

    Oracle and elementary-gate costs exhaust the instruction list.

    theorem Cslib.Quantum.OracleCircuit.queryCount_append (codes₁ codes₂ : OracleCircuit) :
    (codes₁ ++ codes₂).queryCount = codes₁.queryCount + codes₂.queryCount

    Oracle costs add under sequential composition.

    theorem Cslib.Quantum.OracleCircuit.gateCount_append (codes₁ codes₂ : OracleCircuit) :
    (codes₁ ++ codes₂).gateCount = codes₁.gateCount + codes₂.gateCount

    Elementary-gate costs add under sequential composition.