Deutsch–Jozsa (R4) #
Category: 3-Local (QM-validity).
The Deutsch–Jozsa algorithm (phase R4 of specs/nqubit-register-plan.md): one query to an
oracle for f : {0,1}ⁿ → {0,1} decides whether f is constant or balanced. The
circuit is H^⊗n ∘ U_f ∘ H^⊗n on |0ⁿ⟩, with U_f the phase oracle |x⟩ ↦ (-1)^{f(x)}|x⟩.
The amplitude of the all-zeros outcome after the circuit is (1/2ⁿ) ∑ₓ (-1)^{f(x)}
(djAmplitude_zero), so the Born probability of measuring |0ⁿ⟩ is:
1iffis constant (deutsch_jozsa_constant) — the amplitude is±1;0iffis balanced (deutsch_jozsa_balanced) — the amplitude is0.
One measurement therefore discriminates the two cases with certainty.
Honest scope. This is the discrimination statement, which needs only Hn_apply_zero
(R2) and the diagonal oracle — not Hn unitarity. Unitarity (R3, character orthogonality)
is what makes the full output distribution a normalised probability vector; the
prob(0ⁿ) = 1 vs 0 discrimination here is self-contained as a squared-amplitude computation.
The phase oracle U_f : |x⟩ ↦ (-1)^{f(x)} |x⟩ for f : {0,1}ⁿ → {0,1}.
Equations
- CSD.Empirical.QM.DeutschJozsa.phaseOracle f = Matrix.diagonal fun (x : Fin n → Fin 2) => (-1) ^ ↑(f x)
Instances For
The phase oracle's action on a register state.
Equations
Instances For
Hn 0ⁿ y = (√2⁻¹)ⁿ (the all-zeros row of the Hadamard transform).
The Deutsch–Jozsa circuit H^⊗n ∘ U_f ∘ H^⊗n.
Equations
Instances For
A function f : {0,1}ⁿ → {0,1} is balanced if it is 0 on exactly half its inputs.