Skip to content
Quantum ComputingAN INTERACTIVE OPEN TEXTBOOK
charithj.com.au

Quantum oracles and phase kickback

A reversible function evaluation can become a phase that interference can read.

16 min readDr. Charith Jayasekara↓ Chapter PDF
By the end, you’ll be able to
  • Describe a reversible Boolean oracle.
  • Derive phase kickback using a minus-state target.

A Boolean function f(x)f(x) may discard information. Its reversible oracle keeps the input and XORs the output into a target:

Uf∣x,y⟩=∣x,y⊕f(x)⟩.U_f\lvert x,y\rangle=\lvert x,y\oplus f(x)\rangle.

This map is its own inverse. The oracle is a specified operation, not a magical free answer source; its implementation can dominate an algorithm’s cost.

The state ∣−⟩=(∣0⟩−∣1⟩)/2\lvert-\rangle=(\lvert0\rangle-\lvert1\rangle)/\sqrt2 satisfies X∣−⟩=−∣−⟩X\lvert-\rangle=-\lvert-\rangle.

So a function-controlled X on this target gives

Uf(∣x⟩∣−⟩)=(−1)f(x)∣x⟩∣−⟩.U_f\bigl(\lvert x\rangle\lvert-\rangle\bigr)=(-1)^{f(x)}\lvert x\rangle\lvert-\rangle.

The target factors out; the input receives a function-dependent phase. This is phase kickback.

Let f(x0x1)=x1f(x_0x_1)=x_1. The values on 00, 01, 10 and 11 are 0, 1, 0 and 1. A uniform input register receives signs +,−,+,−+,-,+,-. Applying H to both input qubits converts that phase pattern into a nonzero bitstring.

The Deutsch–Jozsa lab calculates this phase-kickback input register directly. It explicitly factors out the minus-state ancilla; it does not pretend to show an extra simulated wire.

Check yourself: if ff is constant one, every component acquires the same minus sign. Why is this global phase unobservable, while a balanced pattern is not?

WORKED DIAGRAM · F20Kick a function value into a relative phase
Kick a function value into a relative phaseFor f(x) = x, the target |−⟩ is an X eigenstate with eigenvalue −1. The input changes from plus to minus, while the target factors out unchanged.Input|+⟩|−⟩Uf for f(x)=x|−⟩|−⟩Read inputInput register |−⟩Apply HZ result: 1
For f(x) = x, the target |−⟩ is an X eigenstate with eigenvalue −1. The input changes from plus to minus, while the target factors out unchanged.

The example uses the Boolean function that returns its one-bit input. With a minus-state target, the oracle turns plus on the input into minus. The target remains minus. The function value appears as a phase on each input branch rather than as a classical value read out from the target. A final basis change can make that phase pattern observable.

The oracle retains x and XORs the function value into y. Keeping the original input makes the mapping invertible even when the function itself is many-to-one. A classical function that overwrites its input with its output is not automatically a valid coherent oracle. Reversible implementation may require workspace and a plan to remove unwanted intermediate information.

For one fixed input x, there are two cases. If the function value is zero, the target is untouched. If it is one, the oracle applies X to minus, producing negative minus. The common target factor can therefore be pulled outside the sum over x:

∑xax∣x⟩∣−⟩⟼∑x(−1)f(x)ax∣x⟩∣−⟩.\sum_x a_x|x\rangle|-\rangle \longmapsto\sum_x(-1)^{f(x)}a_x|x\rangle|-\rangle.

The factor is conditional on x. If the function is constant, every branch gets the same sign and the input changes at most by global phase. If the function varies, different branches can acquire different signs. Their relative phases can then affect interference. This is why a negative sign can be irrelevant in one oracle case and crucial in another.

Worked example: all four one-bit functions

Section titled “Worked example: all four one-bit functions”

For constant zero, a plus input stays plus. For constant one, it becomes negative plus, physically the same state. For the function f(x) equal to x, plus becomes minus. For its complement, plus becomes negative minus. Applying H to the input produces zero for either constant function and one for either balanced function, ignoring the common phase.

The procedure identifies a property shared by two functions rather than revealing the whole truth table. It cannot distinguish constant zero from constant one through this input-register measurement, and it does not need to. A quantum algorithm’s output is designed around a question. Claiming that it “evaluates both inputs and reads both answers” would misdescribe what the experiment actually reveals.

If the target were plus, X would leave it unchanged with eigenvalue positive one, so no phase pattern would be kicked back. If the target were zero, the oracle would generally correlate it with the input rather than factor out an unchanged eigenstate. The minus preparation is a deliberate algorithmic resource, not an arbitrary decoration on the circuit.

More generally, a controlled operation acting on an eigenstate contributes its eigenvalue to the control branch. For an eigenvalue with an arbitrary unit complex phase, that becomes the mechanism behind phase estimation. The minus-target example is the simplest case, where the eigenvalue is just negative one. Understanding this case makes the later controlled-power circuits much less mysterious.

One oracle call is a unit of query complexity, not necessarily one elementary hardware gate. The function may require many reversible operations, temporary qubits and uncomputation. A truth-table lookup might also require expensive data loading. An abstract query advantage must be combined with those costs before making a runtime claim about an application.

The explorer evaluates a small built-in phase pattern directly in a classical statevector. It does not compile an arbitrary user function into a reversible circuit. Its amplitude output represents the input register after the final H gates, with the unchanged minus ancilla factored out. This modelling choice reduces clutter without changing the promised classification task.

Select one input qubit for the original Deutsch case. Predict the input-register result for constant zero, reveal, then repeat with constant one. Explain why their final amplitudes can differ by a global sign while the probabilities match. Finally choose the balanced last-bit function and predict a nonzero output.

L05 · INTERACTIVE LABRuns on your device

Deutsch–Jozsa explorer

A constant-or-balanced Boolean oracle acts by phase kickback, followed by H on each input qubit. The unchanged |−⟩ ancilla is factored out. One input qubit gives Deutsch’s original case.

Experiment controls

Predict whether the all-zero input-register outcome can occur for the selected promised oracle.

Record a prediction to enable the results.

Results are hidden.

Prepare your experiment using the controls. Record a prediction, then reveal the statevector or run the experiment.

Changing the preparation or circuit starts a new prediction.

MODEL · Ideal pure-state vector, complex double precisionORDER · q0 is the leftmost bit
Take it further

Constant-zero and constant-one differ by a global sign before the final H gates. Explain why their measured probabilities agree.

For two or three input qubits, the same explorer illustrates Deutsch–Jozsa for its selected oracle family. A balanced last-bit function gives a particular nonzero bitstring. The general promised algorithm guarantees that all-zero is absent for a balanced function, not that every possible balanced function returns that same nonzero string.

Replace the minus target with plus in the one-bit example. Work through the oracle for both possible function values and predict the final input measurement after H. Does the circuit still classify the function?

Check your reasoning

X has eigenvalue positive one on plus, so both function values leave the target and the input amplitudes unchanged. The input remains plus and the final H returns zero for every function. The circuit no longer distinguishes constant from balanced. The oracle is unchanged; the lost advantage comes from an unsuitable target preparation.

PAUSE & THINK

Why use a minus-state target for phase kickback?

Choose your answer

Reference: IBM Quantum — Fundamentals of quantum algorithms.

ONE IDEA FURTHER

Ready for the next step?

Your progress stays in this browser.