Step 1 – Error‐model and post‐selection
Each of the two CNOT gates (first on qubits 2→1, then on 0→3) is followed by the two‐qubit depolarizing channel
\[
\mathcal D_{ij}(\rho)
=(1-p)\,\rho
+\frac p{15}\sum_{P\in\{I,X,Y,Z\}^{\otimes2}\setminus\{I\otimes I\}}
P_{ij}\,\rho\,P_{ij}\,.
\]
At the end we measure the two code‐stabilizers
\[
S_X=X_0X_1X_2X_3,\qquad
S_Z=Z_0Z_1Z_2Z_3
\]
and post‐select on the “+1” outcome for both. Any Pauli error \(P\) that anticommutes with either \(S_X\) or \(S_Z\) is rejected; errors that commute pass undetected.
We denote by
- \(\,p_A=\Pr[\text{accepted}]\),
- \(\,p_B=\Pr[\text{accepted and preserves logical GHZ}]\).
Then the logical fidelity is
\[
F_{\rm log}(p)\;=\;\frac{p_B}{p_A}\,.
\]
Step 2 – Classification of single‐gate faults
Label the first fault \(P_{21}\) (on qubits 2,1) and the second \(P_{03}\) (on 0,3). Each non-identity \(P_{ij}\) occurs with probability \(p/15\). A single‐gate error is undetected iff it lies in the local stabilizer on that pair, namely
\[
\{\,X_iX_j,\;Y_iY_j,\;Z_iZ_j\}\,.
\]
– There are 3 such undetected errors on \((2,1)\) and likewise 3 on \((0,3)\).
– Moreover, each of those three acts on the logical GHZ \(\tfrac{|00\>+|11\>}{\sqrt2}\) as \(\pm1\), so they preserve the GHZ exactly.
Thus the contributions to \(p_A\) and \(p_B\) from zero or one fault are
\[
\begin{aligned}
&\Pr[\text{no fault}]
\;=\;(1-p)^2,\\
&\Pr[\text{one undetected fault on either gate}]
\;=\;
2\,(1-p)\,\frac{3p}{15}
\quad\text{(all of these also preserve GHZ).}
\end{aligned}
\]
Step 3 – Two-fault patterns
There are \(15^2=225\) pairs \((P_{21},P_{03})\) of non-identity errors, each with prob.\ \((p/15)^2\).
– Detection accepts exactly those pairs for which \(P_{03}P_{21}\) commutes with both \(S_X\) and \(S_Z\).
One shows by a local‐syndrome counting that exactly
\[
N_{\rm acc}=57
\]
of these 225 two-fault patterns pass undetected.
– Preservation of GHZ further requires \(P_{03}P_{21}\) to lie in the full stabilizer of the physical GHZ state
\(\langle S_X,S_Z,X_AX_B,Z_AZ_B\rangle\),
and among those 57 undetected patterns exactly
\[
N_{\rm ghz}=3
\]
realize one of \(\{S_X,S_Z,S_XS_Z\}\). Each of these also preserves the GHZ.
Step 4 – Assemble \(p_A\) and \(p_B\)
Collecting all accepted cases,
\[
\begin{aligned}
p_A
&=(1-p)^2
\;+\;2\,(1-p)\,\frac{3p}{15}
\;+\;\frac{57}{15^2}\,p^2,\\
p_B
&=(1-p)^2
\;+\;2\,(1-p)\,\frac{3p}{15}
\;+\;\frac{3}{15^2}\,p^2.
\end{aligned}
\]
Simplify the coefficients (noting \(3/15=1/5\), \(57/225=64/75\), \(3/225=1/75\)):
\[
\begin{aligned}
p_A&=1-\frac{8}{5}p+\frac{64}{75}p^2,\\
p_B&=1-\frac{8}{5}p+\frac{46}{75}p^2.
\end{aligned}
\]
Step 5 – Final logical fidelity
\[
F_{\rm log}(p)
=\frac{p_B}{p_A}
=\frac{1-\tfrac85 p+\tfrac{46}{75}p^2}
{1-\tfrac85 p+\tfrac{64}{75}p^2}
\;=\;
\frac{75-120\,p+46\,p^2}{75-120\,p+64\,p^2}\,.
\]
For small \(p\), one finds
\[
F_{\rm log}(p)=1-\frac{6}{25}\,p^2+O(p^3)\,,
\]
showing that all \(O(p)\) logical infidelity is removed by post-selection.
Final Answer:
\[
\boxed{
F_{\rm log}(p)
=\frac{1-\tfrac85 p+\tfrac{46}{75}p^2}
{1-\tfrac85 p+\tfrac{64}{75}p^2}
\;=\;
\frac{75-120\,p+46\,p^2}{75-120\,p+64\,p^2}\,.
}
\]