B1: Bra-Ket Notated Gate

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 100

Problem Statement

Implement the operation defined by the following matrix AA on a quantum circuit qc\mathrm{qc} with 11 qubit.

A=10+01A = \ket{1}\bra{0}+\ket{0}\bra{1}

Constraints

  • In this problem, the state with different global phase will not be considered correct.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
 
    return qc

Hints

Open

A quantum state ψ=a00+a11\ket{\psi} = a_0 \ket{0} + a_1 \ket{1} can be represented as a column vector

ψ=a00+a11=(a0a1).\ket{\psi}=a_0\ket{0}+a_1\ket{1}=\begin{pmatrix}a_0\\a_1\end{pmatrix}.

The adjoint ψ\bra{\psi} of a quantum state ψ=a00+a11\ket{\psi}=a_0\ket{0}+a_1\ket{1} is defined as

ψ=ψ=(a0a1).\bra{\psi} = \ket{\psi}^{\dagger} = \begin{pmatrix}a_0^* & a_1^*\end{pmatrix}.

For quantum states ψ=(a0a1)\ket{\psi}=\begin{pmatrix}a_0\\a_1\end{pmatrix} and ϕ=(b0b1)\bra{\phi}=\begin{pmatrix}b_0^* & b_1^*\end{pmatrix}, the inner product ϕψ\braket{\phi|\psi} is defined as

ϕψ=(b0b1)(a0a1)=b0a0+b1a1.\braket{ \phi | \psi } = \begin{pmatrix} b_0^* & b_1^* \end{pmatrix} \begin{pmatrix} a_0 \\ a_1 \end{pmatrix} = b_0^* a_0 + b_1^* a_1.

Manipulating a quantum state is equivalent to multiplying a column vector by a unitary matrix from the left.

The outer product ψϕ\ket{\psi}\bra{\phi} of quantum states ψ=(a0a1)\ket{\psi}=\begin{pmatrix}a_0\\a_1\end{pmatrix} and ϕ=(b0b1)\bra{\phi}=\begin{pmatrix}b_0^* & b_1^*\end{pmatrix} is defined as

ψϕ=(a0a1)(b0b1)=(a0b0a0b1a1b0a1b1)\ket{\psi} \bra{\phi} = \begin{pmatrix} a_0 \\ a_1 \end{pmatrix} \begin{pmatrix} b_0^* & b_1^* \end{pmatrix} = \begin{pmatrix} a_0 b_0^* & a_0 b_1^* \\ a_1 b_0^* & a_1 b_1^*\end{pmatrix}

For arbitrary quantum state ω\ket{\omega}, the following equation holds:

(ψϕ)ω=ψϕω=ϕωψ(\ket{\psi} \bra{\phi}) \ket{\omega} = \ket{\psi} \braket{ \phi | \omega } = \braket{ \phi | \omega } \ket{\psi}

Please sign in to submit your answer.