Documentation

CslibFrontier.Computability.Circuit.Quantum.Oracle.Basic

Coherent XOR queries as placed circuit gates #

xorQuery H A queries a fixed function H coherently on the wires A: the first a wires hold its argument, the following b wires hold its XOR accumulator, and all other wires are untouched. xorQuery_eval_apply describes its action on every amplitude. No measurement or resampling occurs during a query. Oracle/ValueQuery connects it to the value-query model.

This is an operational building block, not an efficiency certificate or a random-oracle security theorem. In particular, the implementation cost of H is not charged here: an oracle circuit must count this gate as an oracle call separately from its elementary gates. The constructions and elementary identities below are original formalization infrastructure. The query convention is the one in Boneh et al., §2.1, p. 7; injective wire placement also permits other register layouts. Their efficiency and random-oracle assumptions are separate from the gate action formalized here.

Main definitions #

Main results #

References #

noncomputable def Cslib.Quantum.queryRegisters {a b m : ℕ} (A : Fin (a + b) ↪ Fin m) :
(Fin m → Bool) ≃ (Fin a → Bool) × (Fin b → Bool) × ({ j : Fin m // ¬∃ (i : Fin (a + b)), A i = j } → Bool)

Split the register along A: its first a wires are the query, its next b wires are the response, and the remaining register retains its original wire indices.

@[simp]
theorem Cslib.Quantum.queryRegisters_apply {a b m : ℕ} (A : Fin (a + b) ↪ Fin m) (z : Fin m → Bool) :
(queryRegisters A) z = (fun (i : Fin a) => z (A (Fin.castAdd b i)), fun (i : Fin b) => z (A (Fin.natAdd a i)), fun (j : { j : Fin m // ¬∃ (i : Fin (a + b)), A i = j }) => z ↑j)

Splitting a basis string reads the selected query and response wires and retains the unused wire indices for the workspace.

@[simp]
theorem Cslib.Quantum.queryRegisters_symm_query {a b m : ℕ} (A : Fin (a + b) ↪ Fin m) (x : Fin a → Bool) (y : Fin b → Bool) (w : { j : Fin m // ¬∃ (i : Fin (a + b)), A i = j } → Bool) (i : Fin a) :
(queryRegisters A).symm (x, y, w) (A (Fin.castAdd b i)) = x i

Reassembling the registers recovers a query bit at its selected wire.

@[simp]
theorem Cslib.Quantum.queryRegisters_symm_response {a b m : ℕ} (A : Fin (a + b) ↪ Fin m) (x : Fin a → Bool) (y : Fin b → Bool) (w : { j : Fin m // ¬∃ (i : Fin (a + b)), A i = j } → Bool) (i : Fin b) :
(queryRegisters A).symm (x, y, w) (A (Fin.natAdd a i)) = y i

Reassembling the registers recovers a response bit at its selected wire.

theorem Cslib.Quantum.queryRegisters_symm_workspace {a b m : ℕ} (A : Fin (a + b) ↪ Fin m) (x : Fin a → Bool) (y : Fin b → Bool) (w : { j : Fin m // ¬∃ (i : Fin (a + b)), A i = j } → Bool) (j : Fin m) (hj : ¬∃ (i : Fin (a + b)), A i = j) :
(queryRegisters A).symm (x, y, w) j = w ⟨j, hj⟩

Reassembling the registers recovers every unused workspace bit.

noncomputable def Cslib.Quantum.xorQuery {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (A : Fin (a + b) ↪ Fin m) :

A coherent function query on the chosen wires: |x, y, w⟩ ↦ |x, y + H x, w⟩. The addition on bit strings is XOR.

theorem Cslib.Quantum.xorQuery_eval_ket {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (A : Fin (a + b) ↪ Fin m) (x : Fin a → Bool) (y : Fin b → Bool) (w : { j : Fin m // ¬∃ (i : Fin (a + b)), A i = j } → Bool) :
(xorQuery H A).eval (ket ((queryRegisters A).symm (x, y, w))) = ket ((queryRegisters A).symm (x, y + H x, w))

A query preserves the argument and unused wires, and XORs the answer into the response.

theorem Cslib.Quantum.xorQuery_eval_apply {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (A : Fin (a + b) ↪ Fin m) (ψ : Qubits m) (x : Fin a → Bool) (y : Fin b → Bool) (w : { j : Fin m // ¬∃ (i : Fin (a + b)), A i = j } → Bool) :
((xorQuery H A).eval ψ).ofLp ((queryRegisters A).symm (x, y, w)) = ψ.ofLp ((queryRegisters A).symm (x, y + H x, w))

The query acts by permuting amplitudes, without observing or discarding a query register.

theorem Cslib.Quantum.xorQuery_eval_twice {a b m : ℕ} (H : (Fin a → Bool) → Fin b → Bool) (A : Fin (a + b) ↪ Fin m) (ψ : Qubits m) :
(xorQuery H A).eval ((xorQuery H A).eval ψ) = ψ

Two calls to the same XOR oracle cancel on every state.