Solution (source code)

= Solution

In <quantum channel discrimination>, prepare a <density operator> $\rho_{HR}$ on the channel input $H$ and an optional <quantum ancilla> $R$. Under hypothesis $j\in\{1,2\}$ the output is
$$
\omega_j=(T_j\otimes\operatorname{id}_R)(\rho_{HR}).
$$
Use a two-outcome <quantum measurement> $\{Q,I-Q\}$ and decide for $T_1$ on outcome $Q$. The conditional <Type I error> and <Type II error> are
$$
\alpha=\operatorname{Tr}[(I-Q)\omega_1],
\qquad
\beta=\operatorname{Tr}[Q\omega_2].
$$
With <prior probabilities> $p$ and $1-p$, symmetric Bayesian discrimination minimizes the average error $p\alpha+(1-p)\beta$ over the input and measurement.