Walsh-Hadamard transform and the XOR phase-query pipeline #
The reusable machinery shared by the single-query Hadamard-oracle-Hadamard
algorithms (Deutsch-Jozsa, Bernstein-Vazirani): the n-qubit Hadamard layer
in Walsh-Hadamard closed form [dW19, qcnotes.tex:1005-1006], and the
XOR-oracle phase-query pipeline that runs a Boolean oracle on the uniform
input register with a |−⟩ target.
The central bridge postOracleState_eq_afterPhaseQuery_tensor rewrites the
actual XOR-oracle query as the phase pattern (√(2^n))⁻¹ ∑ x (-1)^{f x}|x⟩
tensored with the unchanged |−⟩ target, so a single query followed by the
second Hadamard layer (finalJointState) factors through the input-register
finalState.
These pieces sit in a Primitives module so the Deutsch-Jozsa and
Bernstein-Vazirani algorithms can both build on them without importing one
another; each algorithm keeps only its target-specific content (the
constant/balanced promise and amplitude test for Deutsch-Jozsa; Walsh-character
orthogonality and string recovery for Bernstein-Vazirani).
Main definitions #
LeanPool.LeanQuantumAlg.WalshHadamard.Oracle n— a Boolean function on2^nlabels, queried throughGate.xorOracle.LeanPool.LeanQuantumAlg.WalshHadamard.walshSign— the Walsh-Hadamard sign(-1)^{x·y}, andhadamardLayerits closed-formn-qubit gate.LeanPool.LeanQuantumAlg.WalshHadamard.uniformState— the uniform superposition.LeanPool.LeanQuantumAlg.WalshHadamard.finalJointState— the post-circuit joint state, withfinalJointState_eq_finalState_tensorfactoring off the|−⟩target.
A Boolean oracle on 2^n input labels. It is queried through
Gate.xorOracle, not through a separate oracle type.
Equations
- QuantumAlg.WalshHadamard.Oracle n = (Fin (2 ^ n) → Bool)
Instances For
The standard XOR query gate for a Boolean oracle.
Instances For
The Walsh-Hadamard transform #
The bit of a basis label used in the Walsh-Hadamard character. The bit order only affects nonzero rows; the zero row used by Deutsch-Jozsa is independent of it.
Equations
- QuantumAlg.WalshHadamard.bit x k = (↑x).testBit ↑k
Instances For
Parity of the bitwise inner product of two basis labels.
Equations
- QuantumAlg.WalshHadamard.dotParity x y = decide (Odd {k : Fin n | (QuantumAlg.WalshHadamard.bit x k && QuantumAlg.WalshHadamard.bit y k) = true}.card)
Instances For
The Walsh-Hadamard sign (-1)^{x · y}.
Equations
Instances For
(√(2^n))⁻¹, the normalization scalar of the n-qubit Hadamard layer.
Equations
- QuantumAlg.WalshHadamard.invSqrtCard n = (↑√↑(2 ^ n))⁻¹
Instances For
Walsh-character orthogonality #
Raw n-qubit Hadamard layer in Walsh-Hadamard closed form.
Equations
Instances For
The Walsh-Hadamard closed-form matrix is unitary.
The n-qubit Hadamard layer as a unitary gate.
Equations
Instances For
Raw uniform input-register vector produced by the first Hadamard layer.
Equations
- QuantumAlg.WalshHadamard.uniformStateVec n = WithLp.toLp 2 fun (x : Fin (2 ^ n)) => QuantumAlg.WalshHadamard.invSqrtCard n
Instances For
The uniform input-register vector has unit norm.
The uniform input-register state produced by the first Hadamard layer.
Equations
Instances For
The first Hadamard layer sends |0^n⟩ to the uniform superposition.
The XOR phase-query pipeline #
The pre-Hadamard joint basis state |0^n⟩ ⊗ |−⟩.
Equations
Instances For
The joint state queried by the XOR oracle, obtained by applying the first
Hadamard layer to the input register and leaving the |−⟩ target alone.
Equations
Instances For
The queried state is the uniform input register tensored with |−⟩.
The actual post-query joint state, using the XOR oracle gate.
Equations
Instances For
The input-register state after rewriting the oracle query by phase
kickback: (√(2^n))⁻¹ ∑ x, (-1)^{f x}|x⟩.
Equations
- QuantumAlg.WalshHadamard.afterPhaseQueryVec f = WithLp.toLp 2 fun (x : Fin (2 ^ n)) => QuantumAlg.WalshHadamard.invSqrtCard n * QuantumAlg.WalshHadamard.phaseSign f x
Instances For
The phase-query vector has unit norm.
The input register after the XOR oracle has been converted into a phase query.
Equations
Instances For
The actual XOR-oracle query on the uniform input register and |−⟩
target is exactly the phase-query state tensored with the unchanged target.
The final input-register state after the second Hadamard layer, in the phase-query view.
Equations
Instances For
The actual final joint state: apply the second Hadamard layer to the input register and leave the target qubit alone.
Equations
Instances For
The actual final joint state factors as the final input-register state
and the unchanged |−⟩ target.