Documentation

CslibFrontier.Computability.Circuit.Quantum.PathSum

Amplitudes of Hadamard–Toffoli circuits as path sums #

The gates of CslibFrontier/Computability/Circuit/Quantum/Code.lean act on basis states either as permutations (NOT, CNOT, Toffoli) or by branching into two basis states with amplitudes ±1/√2 (Hadamard). Following one branch per Hadamard gate gives a path: a bit string of length h, the number of Hadamard gates (Cslib.Quantum.hadamardCount). The classical simulation Cslib.Quantum.pathStep follows a path on a register written as a bit string. It writes the next path bit into the target of a Hadamard gate, flipping a sign when the old and new bits are both one, and it applies classical gates directly. Every amplitude of the circuit is then a signed count of paths divided by √2^h (Cslib.Quantum.run_ofCodes_apply): ⟨y|C|x⟩ = (∑_π ±[π ends in y]) / √2^h. This adapts the argument of Fortnow and Rogers Fortnow, Rogers, Lemma 3.2, from quantum Turing machines to circuits.

Squaring and summing over the accepting outcomes, the acceptance probability is a signed count of pairs of paths that end in the same accepting register, divided by 2^h (Cslib.Quantum.acceptProb_eq_acceptGap). Both counts are integers computed from polynomial-time simulations, which places BQP in the counting classes (CslibFrontier/Computability/Complexity/Classes/BQP/Counting.lean). The same holds for the probability that every qubit of a list S reads 1, with the pairs of paths ending in the same register in which every qubit of S is one (Cslib.Quantum.onesProb_eq_onesGap); the acceptance gap is the case S = [0]. Pairs of paths from two different basis states x and x' give the overlap of the two final states on those outcomes (Cslib.Quantum.sum_onesAt_star_run_mul_run), the projected pair gap Cslib.Quantum.onesPairGap S gs x x' over 2^h; these are the entries of the acceptance operator of a quantum verifier on its witness space.

Main definitions #

Main results #

References #

The path simulation #

One step of the path simulation. The state holds the register bits, the unread path bits and a sign. A Hadamard gate on t writes the next path bit c into t, flipping the sign when the old and new bits are both one; a classical gate flips t when all its controls are one.

The number of Hadamard gates in a list of gate codes.

The Hadamard gates are the codes flagged true.

The final register and sign of the simulation from the register x along the path π.

The signed contribution of the path π to the amplitude ⟨y|C|x⟩: ±1 when the simulation from x along π ends in y, with the sign it accumulates, and 0 otherwise.

The amplitude gap: the sum of pathTerm over all paths of one bit per Hadamard gate.

def Cslib.Quantum.onesTerm (S : List ℕ) (gs : List GateCode) (x π π' : List Bool) :

The signed contribution of a pair of paths to the probability that every qubit of S reads 1: the product of their signs when both end in the same register with every qubit of S equal to one, and 0 otherwise.

The projected gap of S: the sum of onesTerm S over all pairs of paths.

The acceptance gap: the projected gap of qubit 0.

def Cslib.Quantum.onesPairTerm (S : List ℕ) (gs : List GateCode) (x x' π π' : List Bool) :

The signed contribution of a pair of paths, one from the register x and one from x', to the overlap of the two final states on the outcomes in which every qubit of S reads 1: the product of their signs when both end in the same register with every qubit of S equal to one, and 0 otherwise. For x = x' this is onesTerm (Cslib.Quantum.onesTerm_eq_onesPairTerm).

The projected pair gap of S on the registers x and x': the sum of onesPairTerm S over all pairs of paths. For x = x' this is onesGap (Cslib.Quantum.onesGap_eq_onesPairGap).

theorem Cslib.Quantum.onesTerm_eq_onesPairTerm (S : List ℕ) (gs : List GateCode) (x π π' : List Bool) :
onesTerm S gs x π π' = onesPairTerm S gs x x π π'
theorem Cslib.Quantum.onesTerm_zero (gs : List GateCode) (x π π' : List Bool) :
onesTerm [0] gs x π π' = if (pathRun gs x π).1 = (pathRun gs x π').1 ∧ (pathRun gs x π).1.headD false = true then if ((pathRun gs x π).2 ^^ (pathRun gs x π').2) = true then -1 else 1 else 0

The contribution of a pair of paths to the acceptance gap: the product of their signs when both end in the same register with qubit 0 equal to one, and 0 otherwise.

theorem Cslib.Quantum.onesPairTerm_zero (gs : List GateCode) (x x' π π' : List Bool) :
onesPairTerm [0] gs x x' π π' = if (pathRun gs x π).1 = (pathRun gs x' π').1 ∧ (pathRun gs x π).1.headD false = true then if ((pathRun gs x π).2 ^^ (pathRun gs x' π').2) = true then -1 else 1 else 0

The contribution of a pair of paths from two registers to the acceptance overlap: the product of their signs when both end in the same register with qubit 0 equal to one, and 0 otherwise.

The acceptance gap of the empty circuit is the bit of qubit 0.

theorem Cslib.Quantum.run_ofCodes_apply {m : ℕ} (gs : List GateCode) (hgs : ∀ g ∈ gs, GateCode.WellFormed m g) (x y : Fin m → Bool) :
((Circuit.ofCodes m gs).run x).ofLp y = ↑(pathGap gs (List.ofFn x) (List.ofFn y)) * ↑(√2)⁻¹ ^ hadamardCount gs

Amplitudes are path sums: for well-formed codes, the amplitude ⟨y|C|x⟩ of the decoded circuit is the amplitude gap pathGap divided by √2^h, where h counts the Hadamard gates.

The simulation keeps the register length.

theorem Cslib.Quantum.onesProb_eq_onesGap {m : ℕ} (gs : List GateCode) (hgs : ∀ g ∈ gs, GateCode.WellFormed m g) (S : List ℕ) (x : List Bool) :
onesProb m gs S x = ↑(onesGap S gs (List.ofFn (inputState m x))) / 2 ^ hadamardCount gs

Probabilities are projected gaps over 2^h: for well-formed codes, the probability that every qubit of S reads 1 is onesGap S divided by 2^h, where h counts the Hadamard gates.

theorem Cslib.Quantum.acceptProb_eq_acceptGap {m : ℕ} (gs : List GateCode) (hgs : ∀ g ∈ gs, GateCode.WellFormed m g) (x : List Bool) :

The acceptance probability is a gap over 2^h: for well-formed codes on m qubits, the acceptance probability is acceptGap divided by 2^h, where h counts the Hadamard gates.

theorem Cslib.Quantum.sum_onesAt_star_run_mul_run {m : ℕ} (gs : List GateCode) (hgs : ∀ g ∈ gs, GateCode.WellFormed m g) (S : List ℕ) (x x' : Fin m → Bool) :
∑ y ∈ onesAt m S, star (((Circuit.ofCodes m gs).run x).ofLp y) * ((Circuit.ofCodes m gs).run x').ofLp y = ↑(onesPairGap S gs (List.ofFn x) (List.ofFn x')) / 2 ^ hadamardCount gs

Overlaps are projected pair gaps over 2^h: for well-formed codes, the overlap ∑_{y ∈ onesAt m S} conj ⟨y|C|x⟩ ⟨y|C|x'⟩ of the final states from the basis states x and x' on the outcomes in which every qubit of S reads 1 is onesPairGap S divided by 2^h. The amplitudes are real, so no conjugate remains on the right.

theorem Cslib.Quantum.onesGap_nonneg_and_le (S : List ℕ) {X : List Bool} (gs : List GateCode) (hgs : ∀ g ∈ gs, GateCode.WellFormed X.length g) :
0 ≤ onesGap S gs X ∧ onesGap S gs X ≤ 2 ^ hadamardCount gs

A projected gap is a count between 0 and 2 ^ h for well-formed codes on the register X, since it is 2 ^ h times a probability.

The projected gap of no condition is 2 ^ h, the squared norm of the final state.