Quantum circuits with phase gates, simulated by real circuits #
The gate set of Cslib.Complexity.BQP consists of the Hadamard gate and the classical reversible
gates NOT, CNOT and Toffoli, whose matrices are real. This file adds the controlled phase gates
(Cslib.Quantum.Gate.ctrlPhase): the phase gate S = P(i) = diag(1, i), the controlled phase gate
Λ(P(i)) = diag(1, 1, 1, i), and their inverses. A gate code of the extended set
(Cslib.Quantum.PhaseGateCode) is either a gate code (false, g) (Cslib.Quantum.GateCode) or a
controlled phase gate (true, (inv, t, cs)) on the qubits t :: cs, with at most one control.
Uniform families over the extended set (Cslib.Quantum.UniformPhaseCircuitFamily) are defined as
uniform families of circuits are. The extended set contains {Λ(P(i)), H}, which Kitaev proved
universal [Kit97]; this is Theorem 1 of Aharonov.
The real simulation. A circuit is turned into a real one by adding a qubit that records
whether a real or an imaginary part is stored; Aharonov attributes this to
Bernstein, Vazirani. The real version of a gate U is Definition 1 of
Aharonov, and its entries are the blocks Cslib.Quantum.realEntry. Through this
encoding (CslibFrontier/Computability/Circuit/Quantum/RealEncoding.lean), with the encoding qubit
r after the register, the real gates simulate themselves, and a controlled phase gate on the
qubits qs becomes the rotation J = [[0, -1], [1, 0]] of r controlled by qs. Since
J = X Z and Z = H X H, it is the gate sequence H_r, X_{qs → r}, H_r, X_{qs → r}, where the
middle gates are CNOT or Toffoli gates flipping r; its inverse J⁻¹ = Z X is the reversed
sequence (Cslib.Quantum.PhaseGateCode.phaseCodes). For Λ(P(i)) this is the decomposition
Λ²[XZ] = T(1, 2, 3) H(3) T(1, 2, 3) H(3) in the proof of Theorem 2 of Aharonov.
So every circuit with controlled phase gates is simulated exactly by a circuit of at most four
times as many Hadamard, NOT, CNOT and Toffoli gates on one more qubit
(Cslib.Quantum.PhaseGateCode.realSimulates_toRealCodes), which measures the original qubits with
the same probabilities (Cslib.Quantum.PhaseGateCode.onesProb_toRealCodes). For uniform families
the translation is computed in polynomial time and preserves acceptance probabilities exactly
(Cslib.Quantum.UniformPhaseCircuitFamily.realify,
Cslib.Quantum.UniformPhaseCircuitFamily.acceptProb_realify).
Scope. This is the reduction step of Aharonov's proof that {T, H} is computationally
universal (her Theorem 2). Its other ingredient, Kitaev's universality of {Λ(P(i)), H}, and the
Solovay–Kitaev theorem behind computational universality are not formalized here. The simulation
is stated for the gates of the extended set; the real version of an arbitrary gate is not
constructed as a placed gate.
Main definitions #
Cslib.Quantum.Gate.ctrlPhase: the controlled phase gate onkqubits.Cslib.Quantum.PlacedGate.ctrlPhase: a controlled phase gate or its inverse on chosen qubits.Cslib.Quantum.PhaseGateCode,Cslib.Quantum.PhaseGateCode.WellFormed,Cslib.Quantum.PhaseGateCode.toPlacedGate?,Cslib.Quantum.Circuit.ofPhaseCodes: gate codes with controlled phase gates and the circuits they denote.Cslib.Quantum.PhaseGateCode.onesProb,Cslib.Quantum.PhaseGateCode.acceptProb: measurement probabilities, asCslib.Quantum.onesProbandCslib.Quantum.acceptProb.Cslib.Quantum.PhaseGateCode.phaseCodes,Cslib.Quantum.PhaseGateCode.realCodes,Cslib.Quantum.PhaseGateCode.toRealCodes: the real translation.Cslib.Quantum.encPhaseGateCode,Cslib.Quantum.UniformPhaseCircuitFamily: uniform families with controlled phase gates.Cslib.Quantum.UniformPhaseCircuitFamily.realify: the real simulation of such a family.Cslib.Quantum.UniformCircuitFamily.toPhaseFamily: a family without phase gates, as one with phase gates.
Main results #
Cslib.Quantum.PlacedGate.eval_ctrlPhase_ket: a controlled phase gate on a basis state.Cslib.Quantum.GateCode.im_toPlacedGate?_gate: the gates of gate codes are real.Cslib.Quantum.PhaseGateCode.realSimulates_phaseCodes: four Hadamard and classical gates simulate a controlled phase gate.Cslib.Quantum.PhaseGateCode.realSimulates_toRealCodes: the real translation simulates the circuit.Cslib.Quantum.PhaseGateCode.onesProb_toRealCodes,Cslib.Quantum.PhaseGateCode.acceptProb_toRealCodes: it measures the original qubits with the same probabilities.Cslib.Quantum.UniformPhaseCircuitFamily.acceptProb_realify,Cslib.Quantum.UniformCircuitFamily.acceptProb_toPhaseFamily: the translations between the two kinds of families preserve acceptance probabilities.
References #
- D. Aharonov, A simple proof that Toffoli and Hadamard are quantum universal, arXiv:quant-ph/0301040v1, Definition 1, Theorems 1 and 2
- E. Bernstein, U. Vazirani, Quantum complexity theory
- A. Yu. Kitaev, Quantum computations: algorithms and error correction
Controlled phase gates #
The controlled phase gate on k qubits: it multiplies |x⟩ by i when every qubit is
one. For k = 1 this is the phase gate S = P(i) = diag(1, i), and for k = 2 the controlled
phase gate Λ(P(i)) = diag(1, 1, 1, i).
The entries of the controlled phase gate (inv = false) and of its inverse (inv = true):
the diagonal entry of |x⟩ is i, respectively -i, when every qubit of x is one, and 1
otherwise.
Gate codes on a larger register #
The gates of gate codes are real: the Hadamard gate and the classical reversible gates have real entries.
A gate code simulates itself through the real encoding, on one more qubit.
Gate codes with controlled phase gates #
A gate code with phase gates: (false, g) is the gate code g (Cslib.Quantum.GateCode),
and (true, (inv, t, cs)) with at most one control cs is the controlled phase gate on the qubits
t :: cs (Cslib.Quantum.Gate.ctrlPhase): the phase gate S = diag(1, i) on qubit t when
cs = [], and the controlled phase gate Λ(S) on the qubits c and t when cs = [c]; inverted
when inv is true.
The placed gate denoted by a gate code with phase gates on m qubits, or none when the code
is not well formed.
A gate code with phase gates is well formed on m qubits: a well-formed gate code, or a
phase gate with at most one control, on distinct qubits below m.
Instances For
Exactly the well-formed codes denote gates.
A well-formed phase gate code denotes a controlled phase gate on qubits e whose
conjunction is the one read by the classical gate code with the controls t :: cs, on a register
with one more qubit.
The circuit on m qubits denoted by a list of gate codes with phase gates, applied first to
last. Codes that are not well formed are skipped.
The probability that the final measurement of the circuit with phase gate codes gs on m
qubits, started in |x 0^{m - n}⟩, finds every qubit of S in state 1.
The acceptance probability of the circuit with phase gate codes gs on m qubits on input
x: the final measurement finds qubit 0 in state 1.
The real translation #
The four Hadamard and classical gate codes that simulate a controlled phase gate on the qubits
qs (for inv, its inverse) with the encoding qubit r: the gate acts on the encoding qubit as
J = [[0, -1], [1, 0]] = X Z controlled by qs, with Z = H X H, and its inverse as
J⁻¹ = Z X.
The real translation of a gate code with phase gates, with the encoding qubit r: a gate
code is kept, and a controlled phase gate on t :: cs becomes four Hadamard and CNOT or Toffoli
gate codes (phaseCodes).
The real translation of a list of gate codes with phase gates, with the encoding qubit r.
The real translation has at most four gate codes per gate code.
Four Hadamard and classical gates simulate a controlled phase gate through the real
encoding: the phase gate on the qubits e is simulated by phaseCodes m inv qs, when the
controls qs of the classical gate read the conjunction of the qubits e.
The real translation of well-formed codes is well formed on one more qubit.
The real translation simulates the circuit: through the real encoding, with the encoding
qubit m, the translation of well-formed codes on m qubits simulates the circuit they denote.
The real translation measures the original qubits as the circuit does: for well-formed
codes on m qubits, an input that fits into them, and measured qubits below m, the real
translation on m + 1 qubits finds the qubits S all one with the same probability.
The real translation accepts as the circuit does.
The real translation is computed in polynomial time.
Uniform families with phase gates #
The encoding of gate codes with phase gates (p, g): the phase flag, then the gate code g
(Cslib.Quantum.encGateCode).
A polynomial-time uniform family of quantum circuits with phase gates: as
Cslib.Quantum.UniformCircuitFamily, over the Hadamard, NOT, CNOT and Toffoli gates and the phase
gates S, Λ(S) and their inverses. On inputs of length n it uses a register of width n
qubits, at least n and at least one, and the well-formed codes gates n; both are computed from
n in unary in polynomial time.
The number of qubits used on inputs of length
n.The gate codes of the circuit used on inputs of length
n, applied first to last.- computableInPolyTime_width : Turing.MultiTapeTM.ComputableInPolyTime self.width Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary
- computableInPolyTime_gates : Turing.MultiTapeTM.ComputableInPolyTime self.gates Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encList encPhaseGateCode)
- wellFormed (n : ℕ) (g : PhaseGateCode) : g ∈ self.gates n → PhaseGateCode.WellFormed (self.width n) g
The acceptance probability of the family on the input word x: its circuit for inputs of
length |x|, started in |x 0^{m - |x|}⟩, ends with qubit 0 measured in state 1.
The real simulation of a family with phase gates: one more qubit, the encoding qubit, and
each controlled phase gate replaced by four Hadamard and CNOT or Toffoli gates
(Cslib.Quantum.PhaseGateCode.realCodes).
The real simulation accepts as the family does, on every input.
A family over the Hadamard, NOT, CNOT and Toffoli gates, as a family with phase gates that uses none.