Quantum circuits #
The state of an n-qubit register is a vector of ℂ^{{0,1}^n} (Cslib.Quantum.Qubits), with
computational basis |x⟩ (Cslib.Quantum.ket) for bit strings x : Fin n → Bool. A gate is a
unitary matrix on k qubits (Cslib.Quantum.Gate). Applied to an ordered list A of k distinct
qubits of the register, written U[A] in Shi, it acts on those qubits and leaves the
others alone (Cslib.Quantum.PlacedGate):
⟨y| U[A] |x⟩ = U(y ∘ A, x ∘ A) when y and x agree off A, and 0 otherwise
(Cslib.Quantum.PlacedGate.matrix_apply). A circuit is a sequence of placed gates
(Cslib.Quantum.Circuit); its unitary is the product U_m ⋯ U_1 of its gates, the first gate
acting first (Cslib.Quantum.Circuit.matrix), and it acts on states as a linear isometric
equivalence (Cslib.Quantum.Circuit.eval).
At the end of a computation the whole register is measured in the computational basis: a unit state
ψ gives outcome y with probability |ψ_y|² (Cslib.Quantum.measure and
Cslib.Quantum.measureProb, from Complexity/Foundations/Quantum/Measurement.lean). This is the
model of Arora, Barak, Chapter 10: pure states, gates on a bounded number of qubits,
and a single final measurement in the computational basis. Mixed states and intermediate
measurements are not modelled; Arora and Barak note that they add no power. A gate set is a set of
gates of any arities (Cslib.Quantum.Circuit.IsOver). This file provides the Hadamard gate and the
classical reversible gates (Cslib.Quantum.Gate.hadamard, Cslib.Quantum.Gate.ofPerm,
Cslib.Quantum.Gate.not, Cslib.Quantum.Gate.cnot, Cslib.Quantum.Gate.toffoli); no particular
gate set is fixed here.
As in the quantum query model (Complexity/Computability/QueryComplexity/Quantum/Search.lean),
states are vectors of a Euclidean space over ℂ. Gates and circuit unitaries are elements of
Mathlib's Matrix.unitaryGroup, acting on states through Matrix.toEuclideanCLM and
Unitary.linearIsometryEquiv (Cslib.Quantum.unitaryEquiv). Placing a k-qubit unitary on the
qubits A is a monoid homomorphism (Cslib.Quantum.place).
Main definitions #
Cslib.Quantum.Qubits: then-qubit state space.Cslib.Quantum.unitaryEquiv: a unitary matrix as a linear isometric equivalence.Cslib.Quantum.Gate,Cslib.Quantum.PlacedGate: gates, and gates applied to chosen qubits.Cslib.Quantum.splitEquiv,Cslib.Quantum.place: splitting the register along chosen qubits, and placing a unitary on them.Cslib.Quantum.Circuit,Cslib.Quantum.Circuit.matrix,Cslib.Quantum.Circuit.eval: circuits, their unitaries and their action on states.Cslib.Quantum.Circuit.run,Cslib.Quantum.Circuit.measure: the final state of a circuit started in a basis state, and the distribution of its measurement.Cslib.Quantum.Circuit.IsOver: a circuit whose gates lie in a gate set.Cslib.Quantum.Gate.hadamard,Cslib.Quantum.Gate.ofPerm: the Hadamard gate and the classical reversible gates, among themCslib.Quantum.Gate.not,Cslib.Quantum.Gate.cnotandCslib.Quantum.Gate.toffoli.
Main results #
Cslib.Quantum.place_apply,Cslib.Quantum.PlacedGate.matrix_apply: the entries of a placed unitary.Cslib.Quantum.PlacedGate.eval_ket_apply: a placed gate maps|x⟩to its columnx.Cslib.Quantum.Circuit.matrix_append,Cslib.Quantum.Circuit.eval_append: running two circuits in sequence.Cslib.Quantum.Circuit.norm_eval: circuits preserve norms.Cslib.Quantum.PlacedGate.eval_ofPerm_ket: a classical reversible gate permutes basis states.Cslib.Quantum.Gate.hadamard_mul_self: the Hadamard gate is its own inverse.
References #
States and measurement #
A unitary matrix, as a linear isometric equivalence of Euclidean space.
Instances For
Gates #
Placing a unitary on the qubits A: the unitary U[A] = U ⊗ I of the whole register,
reindexed along splitEquiv A. Placement is multiplicative.
Instances For
The unitary U[A] of a placed gate on the whole register.
Instances For
The entries of a placed gate: ⟨y| U[A] |x⟩ = U(y ∘ A, x ∘ A) when y and x agree off
A, and 0 otherwise.
The action of a placed gate on states.
Instances For
Circuits #
A quantum circuit on n qubits: a sequence of placed gates, applied first to last.
Instances For
The unitary U_m ⋯ U_1 of a circuit with gates U_1, …, U_m.
Instances For
The Hadamard gate and classical reversible gates #
The Hadamard gate |b⟩ ↦ (|0⟩ + (-1)^b |1⟩)/√2.
Instances For
The classical reversible gate |x⟩ ↦ |σ x⟩ of a permutation σ of {0,1}^k.
Instances For
The classical reversible gate of an involution of {0,1}^k.
Instances For
The controlled NOT gate |a, b⟩ ↦ |a, b ⊕ a⟩.
Instances For
The Toffoli gate |a, b, c⟩ ↦ |a, b, c ⊕ (a ∧ b)⟩.
Instances For
A classical reversible gate permutes basis states: σ[A] maps |x⟩ to the basis state
that agrees with x off A and equals σ (x ∘ A) on A.