Teleportation moves an unknown qubit state |\psi\rangle = [\alpha, \beta] from a sender to a receiver who share an entangled pair. The receiver keeps a card that says, for each pair of bits the sender reports, which gate to apply. Your job is to print that card, for whichever Bell state the two stations happen to share.
The three qubits are: qubit 0 holds |\psi\rangle, qubits 1 and 2 hold the shared pair pair (four amplitudes, qubit 1 as the left bit), the sender has qubits 0 and 1, the receiver has qubit 2. The start state is kron(psi, pair), eight amplitudes, and qubit 0 is the leftmost bit: |b_0 b_1 b_2\rangle is index int("b0b1b2", 2), so |011\rangle is index 3.
- The sender applies CNOT(0, 1) (flip bit 1 of every basis state whose bit 0 is 1), then H = \tfrac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix} to qubit 0.
- The sender measures qubits 0 and 1 and reports the bits m_0 m_1. After this, the receiver's qubit is the pair of amplitudes at |m_0 m_1 0\rangle and |m_0 m_1 1\rangle, divided by its length.
- The receiver applies one gate from I (do nothing), X=\begin{pmatrix}0&1\\1&0\end{pmatrix}, Y=\begin{pmatrix}0&-i\\i&0\end{pmatrix}, Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}.
pair is always one of the four Bell states |\Phi^\pm\rangle=(|00\rangle\pm|11\rangle)/\sqrt2, |\Psi^\pm\rangle=(|01\rangle\pm|10\rangle)/\sqrt2, possibly times a global phase e^{i\phi}. Then for each outcome exactly one of the four gates turns the receiver's qubit into |\psi\rangle (up to a global phase) for every |\psi\rangle.
Write correction_card(pair) that returns a dict mapping each outcome "00", "01", "10", "11" (the string m_0 m_1) to that gate's name, "I", "X", "Y" or "Z".
Examples
Input: pair = [0.7071067811865476, 0, 0, 0.7071067811865476]
Output: {'00': 'I', '01': 'X', '10': 'Z', '11': 'Y'}
Input: pair = [0, 0.7071067811865476, 0.7071067811865476, 0]
Output: {'00': 'X', '01': 'I', '10': 'Y', '11': 'Z'}
Explanation: with |psi> = |0>, outcome 00 leaves the receiver with |1>, so X is needed.
The order of the keys does not matter.
Goals
- Simulate the sender's half of teleportation on three qubits
- Read the receiver's qubit after measuring the other two
- Find the Pauli correction for every outcome, for any shared Bell state