The Phase Oracle
A standard quantum oracle encodes a function by XOR-ing its output into an ancilla qubit:
This is perfectly valid, but it leaves the answer dangling in the second register. Quantum algorithms such as Deutsch's and Deutsch–Jozsa need something subtler: the information about encoded in the phase of the input register so that later interference can reveal a global property in a single query.
Phase kickback
The key move is to prepare the ancilla in the state
before calling the oracle. When the XOR leaves unchanged. When the XOR flips the ancilla:
In both cases the ancilla finishes in , but when the overall state picks up a factor of . Tracing out the ancilla, the net effect on the input register is
The function's output has kicked back onto the phase of . The ancilla is unentangled and can be discarded; the oracle has become a purely diagonal unitary on the input register:
This is the phase oracle.
Why phases matter
A global phase on a single basis state is invisible if you measure immediately — and have the same measurement probabilities. The power comes when the input is in superposition: applying to gives
Whether the two relative signs are the same or opposite determines whether a subsequent Hadamard produces or — a measurable, deterministic signal. That is exactly the interference step in Deutsch's algorithm that we will build in later lessons.
Single-qubit phase oracle
For a single-bit function the phase oracle has a simple direct representation. If and (constant zero) then — no phase anywhere. If and (constant one) then , which is a global phase and unobservable. The non-trivial cases are the two balanced functions:
- : , — this is the gate.
- : , — this is , which equals up to global phase and is also represented by .
Both balanced single-bit functions map onto the gate (up to an unobservable global phase).
Try it
Build the phase oracle for on a single qubit. The grader checks the unitary matrix, so the identity circuit will not pass — you must implement a real gate.
Sign in on the full site to ask questions and join the discussion.