Quantum circuits over Hadamard and Toffoli gates, written as data #
This file fixes the gate set of the class BQP (Cslib.Complexity.BQP): the Hadamard gate and the
classical reversible gates NOT, CNOT and Toffoli of
CslibFrontier/Computability/Circuit/Quantum/Basic.lean. Their matrix entries lie in
{0, ±1, ±1/√2}.
A gate is written as a triple (h, t, cs) : Bool × ℕ × List ℕ (Cslib.Quantum.GateCode):
(true, t, []) is the Hadamard gate on qubit t, and (false, t, cs) with at most two control
qubits cs flips qubit t when every qubit of cs is one, that is NOT, CNOT or Toffoli. A code
is well formed on m qubits when its qubits are distinct and below m
(Cslib.Quantum.GateCode.WellFormed); it then denotes a placed gate
(Cslib.Quantum.GateCode.toPlacedGate?), and a list of codes denotes a circuit
(Cslib.Quantum.Circuit.ofCodes). Codes are what a polynomial-time machine outputs in the
definition of uniform circuit families.
A run starts in the basis state |x 0^{m - n}⟩ holding the input word x of length n on the
first qubits (Cslib.Quantum.inputState), and accepts when the final measurement finds qubit 0
in state 1 (Cslib.Quantum.accepting, Cslib.Quantum.acceptProb), as in
Arora, Barak, Chapter 10. More generally, Cslib.Quantum.onesProb is the
probability that the final measurement finds every qubit of a list S in state 1, the events on
which postselected classes condition.
Classical reversible gates permute basis states, updating the bit of their target
(Cslib.Quantum.GateCode.eval_toPlacedGate_ket). Appending a NOT gate on qubit 0 exchanges
acceptance and rejection (Cslib.Quantum.acceptProb_append_not).
Main definitions #
Cslib.Quantum.GateCode,Cslib.Quantum.GateCode.WellFormed,Cslib.Quantum.GateCode.toPlacedGate?: gate codes and the gates they denote.Cslib.Quantum.Circuit.ofCodes: the circuit denoted by a list of gate codes.Cslib.Quantum.inputState,Cslib.Quantum.accepting,Cslib.Quantum.acceptProb: the input basis state, the accepting outcomes and the acceptance probability.Cslib.Quantum.onesAt,Cslib.Quantum.onesProb: the outcomes in which every qubit of a list reads1, and their probability; acceptance is the case of qubit0.
Main results #
Cslib.Quantum.splitEquiv_symm_update: placing a classical gate that changes one bit.Cslib.Quantum.GateCode.eval_toPlacedGate_ket: a classical gate code updates its target bit.Cslib.Quantum.acceptProb_nonneg,Cslib.Quantum.acceptProb_le_one.Cslib.Quantum.acceptProb_append_not: a final NOT on qubit0complements the acceptance probability.
References #
Placing a bit string that differs from x ∘ A only at position i changes x only at the
qubit A i.
A classical reversible gate that changes only its bit i, to f z on input z, maps |x⟩ to
the basis state that changes only the qubit A i, to f (x ∘ A).
Gate codes #
A gate code (h, t, cs): (true, t, []) is the Hadamard gate on qubit t, and
(false, t, cs) with at most two controls cs flips qubit t when every qubit in cs is one
(the NOT, CNOT and Toffoli gates).
The placed gate denoted by a gate code on m qubits, or none when the code is not well
formed: its qubits must be distinct and below m.
A gate code is well formed on m qubits: a Hadamard gate without controls, or a classical
gate with at most two controls, on distinct qubits below m.
Instances For
Exactly the well-formed codes denote gates.
A classical gate code updates its target bit: the well-formed code (false, t, cs) maps
|x⟩ to the basis state that changes only qubit t, flipping it when every control is one.
Input, acceptance and acceptance probability #
The probability that the final measurement of the circuit with gate codes gs on m qubits,
started in |x 0^{m - n}⟩, finds every qubit of S in state 1. The acceptance probability is the
case S = [0] (Cslib.Quantum.acceptProb_eq_onesProb).