← All modules 05 Oracles and phase kickback

SESAME · Day 2 · Module 05 · Oracles and phase kickback

Is the function constant or balanced?

Our function takes a two-bit input and returns one bit.

InputConstant zeroConstant oneBalanced example
00010
01010
10011
11011

Constant: the same value on every input.

Balanced: zero on half the inputs, one on the other half.

We are promised one of these cases.
How many calls do we need to tell which?

Deutsch–Jozsa problem · These are examples; the supplied function is unknown.

One question · Three parts of the explanation

Interference distinguishes constant from balanced functions with one quantum query.

One query = one use of the supplied function operation.

q₀ |0⟩ H|+⟩ Hm0 q₁ |0⟩ H|+⟩ Hm1 helper |0⟩ HX|−⟩ |−⟩Uf one query m₀m₁

00 → constant · Any other input pair → balanced, under the promise.

OraclesPhase kickbackInterference

01 / Oracle access · 1.1

Oracles let us count function calls independently of their implementation.

An oracle is an operation we treat as a black box.

The box can contain a circuit with several gates.

In our example, the oracle encodes f as a quantum operation.

Classical call

The function value for one input.

Quantum call

A gate that also acts on superpositions of inputs.

01 / Oracle access · 1.1

Counting queries isolates how much function access an algorithm needs.

Two queries.

The full running time also includes the work inside the oracle and in the rest of the circuit.

01 / Oracle access · 1.2

Two matching answers can leave this four-input problem undecided.

Two queries so far

InputKnown value
000
010
10?
11?

Both completions fit

InputConstantBalanced
0000
0100
1001
1101

A third distinct query settles it: another zero → constant; a one → balanced.
Three queries in the exact classical worst case.

01 / Oracle access · 1.3

Our oracle keeps the input labels and updates a helper.

q₀ |x₀⟩ q₁ |x₁⟩ helper |y⟩ Uf one query
\[U_f|x\rangle|y\rangle=|x\rangle|y\oplus f(x)\rangle.\]

\(x\): the two-bit input label.

\(y\): the helper's basis label, 0 or 1.

\(|x\rangle|y\rangle\): the joint state.

\(\oplus\): XOR, addition modulo two.

The helper is also called the target or ancilla.

01 / Oracle access · 1.3

The oracle applies X to the helper when f(x) is one.

Two inputs from our balanced example:

\(x\)\(f(x)\)Input to \(U_f\)
\(|x\rangle|y\rangle\)
Output
\(|x\rangle|y\oplus f(x)\rangle\)
000\(|00\rangle|0\rangle\)\(|00\rangle|0\rangle\)
000\(|00\rangle|1\rangle\)\(|00\rangle|1\rangle\)
101\(|10\rangle|0\rangle\)\(|10\rangle|1\rangle\)
101\(|10\rangle|1\rangle\)\(|10\rangle|0\rangle\)

\(f(x)=0\): no flip.   \(f(x)=1\): X on the helper.

01 / Oracle access · 1.3

One query acts coherently on the input superposition.

q₀ |0⟩ H|+⟩ q₁ |0⟩ H|+⟩ helper |0⟩ |0⟩ Uf one query
\[\frac{|00\rangle+|01\rangle+|10\rangle+|11\rangle}{2}\]
\[\left(\frac12\sum_x|x\rangle\right)|0\rangle\;\xrightarrow{U_f}\;\frac12\sum_x|x\rangle|f(x)\rangle.\]

Measuring both registers here gives one input–value pair.

The helper is zero in this comparison. The sum covers 00, 01, 10 and 11.

02 / Phase kickback · 2.1

Flipping a minus helper changes only its overall sign.

helper|0⟩ XH|1⟩|−⟩
\[|-\rangle=\frac{|0\rangle-|1\rangle}{\sqrt2}.\]
\[X|-\rangle=\frac{|1\rangle-|0\rangle}{\sqrt2}=-|-\rangle.\]

For the helper alone, this overall sign represents the same physical state.

02 / Phase kickback · 2.2

The query supplies a minus sign exactly where f(x) is one.

\[|x\rangle|-\rangle\;\xrightarrow{U_f}\;(-1)^{f(x)}|x\rangle|-\rangle.\]
Input xf(x)Helper actionFactor on this term
000No flip+1
010No flip+1
101X−1
111X−1

The sign depends on the input term.

02 / Phase kickback · 2.2

The helper stays minus while the input acquires the signs.

The joint state after the query:

\[\frac12\bigl(|00\rangle|-\rangle+|01\rangle|-\rangle-|10\rangle|-\rangle-|11\rangle|-\rangle\bigr)\]

Input

\[\frac{|00\rangle+|01\rangle-|10\rangle-|11\rangle}{2}\]

A new relative-sign pattern.

⊗

Helper

\[|-\rangle\]

The same state.

Phase kickback: the conditional target operation changes phases on the input.

02 / Phase kickback · 2.2

Constant functions change all signs together.

Input labelConstant zeroConstant oneBalanced example
00+½−½+½
01+½−½+½
10+½−½−½
11+½−½−½

An overall sign leaves the physical state unchanged. The balanced case changes relative signs.

\[\underbrace{O_f|x\rangle=(-1)^{f(x)}|x\rangle}_{\text{phase oracle: input action with the minus helper}}\]

02 / Phase kickback · 2.3

A target phase can become a relative phase on a control.

Suppose U leaves our chosen target state unchanged apart from a phase:

\[U|t\rangle=e^{i\phi}|t\rangle.\]
control|+⟩ target|t⟩ U relative phase φ|t⟩controlled-U
\[\frac{|0\rangle+|1\rangle}{\sqrt2}|t\rangle\;\longrightarrow\;\frac{|0\rangle+e^{i\phi}|1\rangle}{\sqrt2}|t\rangle.\]

The target stays in the same state. The control acquires a relative phase.

|t⟩ names the target state; the target may contain several qubits.

02 / Phase kickback · 2.3

Interference on the control lets us learn about that phase.

control|+⟩ target|t⟩ U relative phase φ H 0 or 1 |t⟩controlled-U
\[\frac{|0\rangle+e^{i\phi}|1\rangle}{\sqrt2}\;\xrightarrow{H}\;\frac{1+e^{i\phi}}2|0\rangle+\frac{1-e^{i\phi}}2|1\rangle.\]
Phase from UControl after kickbackP(0) after HP(1) after H
\(\phi=0\)\((|0\rangle+|1\rangle)/\sqrt2\)10
\(\phi=\pi\)\((|0\rangle-|1\rangle)/\sqrt2\)01
\(\phi=\pi/2\)\((|0\rangle+i|1\rangle)/\sqrt2\)½½

Phase estimation learns about U through measurements on control qubits.

A single measurement generally does not determine the phase.

03 / Interference · 3.1

The signs leave immediate measurement probabilities unchanged.

q₀ |0⟩ H|+⟩ Hm0 q₁ |0⟩ H|+⟩ Hm1 helper |0⟩ HX|−⟩ |−⟩Uf one query m₀m₁↑ after query
Input labelConstant-zero amplitudeBalanced-example amplitudeProbability in either case
00+½+½¼
01+½+½¼
10+½−½¼
11+½−½¼

Measuring here cannot distinguish constant from balanced.

03 / Interference · 3.2

The final Hadamards distinguish our two examples.

q₀ |0⟩ H|+⟩ Hm0 q₁ |0⟩ H|+⟩ Hm1 helper |0⟩ HX|−⟩ |−⟩Uf one query m₀m₁↑ after H

For each input qubit:   \(H|+\rangle=|0\rangle,\quad H|-\rangle=|1\rangle.\)

Constant zero

\[\frac{|00\rangle+|01\rangle+|10\rangle+|11\rangle}{2}\]
\[=|+\rangle|+\rangle\;\xrightarrow{H\otimes H}\;|00\rangle\]

Our balanced example

\[\frac{|00\rangle+|01\rangle-|10\rangle-|11\rangle}{2}\]
\[=|-\rangle|+\rangle\;\xrightarrow{H\otimes H}\;|10\rangle\]

10 is the result for this balanced example. Other balanced functions can give other results.

03 / Interference · 3.2

Each input term contributes half its amplitude to 00.

Can another balanced function still give 00?

\[H|0\rangle=\frac{\textcolor{royalblue}{|0\rangle}+|1\rangle}{\sqrt2}\]
\[H|1\rangle=\frac{\textcolor{royalblue}{|0\rangle}-|1\rangle}{\sqrt2}\]

Both coefficients of \(|0\rangle\) are \(+1/\sqrt2\). For two qubits, they multiply to \(+1/2\).

For example, the basis term 10

\[\begin{aligned} (H\otimes H)|10\rangle &=\frac{|0\rangle-|1\rangle}{\sqrt2}\,\frac{|0\rangle+|1\rangle}{\sqrt2}\\[5pt] &=\textcolor{royalblue}{\tfrac12|00\rangle}+\tfrac12|01\rangle-\tfrac12|10\rangle-\tfrac12|11\rangle. \end{aligned}\]
\[\underbrace{-\frac12}_{\text{input amplitude}}\times\underbrace{\frac12}_{\text{factor to 00}}=\underbrace{-\frac14}_{\text{contribution to 00}}\]

We add all contributions to 00, then square the magnitude.

03 / Interference · 3.2

Equal signs reinforce; opposite signs cancel.

Constant zero

+¼ +¼ +¼ +¼ Σamplitude of 00
\[A(00)=1,\quad P(00)=1.\]

Our balanced example

+¼ +¼ −¼ −¼ Σamplitude of 00
\[A(00)=0,\quad P(00)=0.\]

Each contribution is ±¼. Constant one gives A(00) = −1 and also P(00) = 1.

03 / Interference · 3.3

The measured input distinguishes constant from balanced.

Equal amplitudes → function-dependent signs → interference

q₀ |0⟩ H|+⟩ Hm0 q₁ |0⟩ H|+⟩ Hm1 helper |0⟩ HX|−⟩ |−⟩Uf one query m₀m₁

00 → constant

01, 10 or 11 → balanced

One function query. An exact classification under the promise, with ideal operations.

03 / Interference · 3.3

The query comparison depends on the required certainty.

The same constant-or-balanced promise, with N possible inputs:

Exact classificationClassical worst caseQuantum
Four inputs3 queries1 query
N inputsN/2 + 1 queries1 query

N = 2ⁿ for n input bits.

If a small error probability is allowed, classical random sampling can use only a few queries.

Query count is one part of the cost. Implementing the oracle and the surrounding gates also takes work.

Oracle access / Phase kickback / Interference

Interference distinguishes constant from balanced functions with one quantum query.

01

Oracles let us analyse algorithms by counting queries.

02

Phase kickback turns conditional target flips into phases on the input.

03

Interference turns the function’s phase pattern into a measurable answer.

Practice · A different promised function

What does the same circuit tell us about this function?

q₀ |0⟩ H|+⟩ Hm0 q₁ |0⟩ H|+⟩ Hm1 helper |0⟩ HX|−⟩ |−⟩Uf one query m₀m₁↑ after query
Input xf(x)
000
011
101
110

What signs does the query produce?

What is P(00) after the final H gates?

What would measuring immediately after the query tell us?