Problem 328216 · medium · Quantum Computing · Level 03 Entanglement

Two Bits Folded into One Qubit

superdense coding · Bell states · CNOT · two-qubit simulation · global phase

Two stations share a pair of qubits in the Bell state |\Phi^+\rangle = (|00\rangle + |11\rangle)/\sqrt2: the sender holds qubit 0, the receiver qubit 1. To send two classical bits with one qubit, the sender applies a few one-qubit gates to qubit 0 and posts it to the receiver, who then runs CNOT(0, 1), then H on qubit 0, and measures both qubits. The outcome is the bit string m_0 m_1 (qubit 0 first).

Write dense_readout(gates) that returns the receiver's outcome probabilities when the sender applies the gates in the list gates to qubit 0, in list order. Return a dict that maps each outcome "m0m1" with probability greater than 1e-9 to its probability.

The rules of the simulation:

  • A state of two qubits is [a_{00}, a_{01}, a_{10}, a_{11}]; qubit 0 is the leftmost bit, so |10\rangle is index 2. Measuring gives outcome b_0 b_1 with probability |a_{b_0 b_1}|^2.
  • A gate g on qubit 0 mixes the pairs that differ only in qubit 0: a'_{0b} = g_{00} a_{0b} + g_{01} a_{1b} and a'_{1b} = g_{10} a_{0b} + g_{11} a_{1b}, for b = 0, 1.
  • The gate names are "i" (identity), "x", "y", "z", "h", "s", "t": X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, Y=\begin{pmatrix}0&-i\\i&0\end{pmatrix}, Z=\mathrm{diag}(1,-1), H=\tfrac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}, S=\mathrm{diag}(1,i), T=\mathrm{diag}(1,e^{i\pi/4}).
  • CNOT(0, 1) swaps the amplitudes of |10\rangle and |11\rangle.

Examples

Input:  gates = []
Output: {'00': 1.0}

Input:  gates = ['x', 'z']
Output: {'11': 1.0}
Explanation: X then Z turns the pair into (|01> - |10>) / sqrt(2); CNOT and H
turn that into |11>. ['z', 'x'] gives -(|01> - |10>) / sqrt(2), the same state
up to a global phase, so it reads '11' too.

Input:  gates = ['t']
Output: {'00': 0.8535533905932737, '10': 0.14644660940672624}
Explanation: T is not one of the four code gates, so the readout is uncertain.

The sender's code book is: no gate for 00, X for 01, Z for 10, X then Z for 11. Values like 0.9999999999999996 for 1.0 count as correct.

Constraints

  • 0 <= len(gates) <= 20
  • probabilities are compared with a tolerance of 1e-6

Goals

  • Apply one-qubit gates to the first qubit of a shared Bell pair
  • Decode with CNOT then H and read the outcome probabilities
  • See which encodings give a certain readout and why the order of X and Z does not matter
Starting Python…