Boolean (XOR) oracles #
Standard quantum-circuit access to a Boolean function
f : Fin (2 ^ n) → Bool: the XOR (bit-flip) oracle on n + 1 qubits,
U_f |x⟩|b⟩ = |x⟩|b ⊕ f(x)⟩,
the unitary query form O_x : |i, b⟩ ↦ |i, b ⊕ xᵢ⟩ of
[dW19, qcnotes.tex:1151].
Conventions #
- An oracle is not a new kind of object: it is just a
Gate (n + 1), built as a basis permutation (Gate.ofPerm), hence unitary for free — "in matrix representation [it] is a permutation matrix and hence unitary" [dW19, qcnotes.tex:1154]. - Register layout matches
LeanPool.LeanQuantumAlg.prodEquiv(big-endian): input register = qubits0..n-1(most significant bits), target qubit = qubitn(least significant bit); the joint basis label isprodEquiv (x, b). - The bit flip on the target label
b : Fin (2 ^ 1)isFin.rev(0 ↦ 1, 1 ↦ 0), soif f x then b.rev else bis exactlyb ⊕ f x.
Main definitions #
LeanPool.LeanQuantumAlg.Gate.xorPerm f— the basis involution(x, b) ↦ (x, b ⊕ f x).LeanPool.LeanQuantumAlg.Gate.xorOracle f— the oracle gateU_f : Gate (n + 1);xorOracle_apply_ketcomputes its action on basis kets andxorOracle_mem_unitaryGroupgives unitarity.
Pinned Mathlib API: Equiv.permCongr (permCongr_apply), Fin.rev
(Fin.rev_rev), Equiv.apply_eq_iff_eq, Equiv.apply_eq_iff_eq_symm_apply,
Equiv.symm_apply_eq.
@[simp]
The XOR oracle is an involution.
The XOR (bit-flip) oracle of f, as a permutation gate on n + 1
qubits: U_f |x⟩|b⟩ = |x⟩|b ⊕ f(x)⟩ (input register first/most significant,
target qubit last/least significant).