Solution (source code)

= Solution

The <Hadamard gate> conjugates the <Pauli X gate> into the <Pauli Z gate>:
$$
HXH=Z.
$$
When the control qubit is $|0\rangle$, all three circuits act as the identity on the target. When it is $|1\rangle$, the right-hand circuit acts on the target as $HXH=Z$. It therefore agrees with the <Controlled-Z gate> on every <computational basis> state, proving
$$
\boxed{CZ=(I\otimes H)\operatorname{CNOT}_{12}(I\otimes H)}.
$$
Conjugating both sides by $I\otimes H$ and using $H^2=I$ immediately gives the reverse identity
$$
\boxed{\operatorname{CNOT}_{12}=(I\otimes H)CZ(I\otimes H)}.
$$