Ex4 15

$\def\abs#1{|#1|}\def\i{\mathbf {i}}\def\ket#1{|{#1}\rangle}\def\bra#1{\langle{#1}|}\def\braket#1#2{\langle{#1}|{#2}\rangle}\def\tr{\mathord{\mbox{tr}}}\mathbf{Exercise\ 5.15}$

Design a circuit that determines if two single qubits are in the same quantum state. The circuit may include an ancilla qubit to be measured. The measurement should give a positive answer if the two-qubit states are identical, a negative answer if the two-qubit states are orthogonal, and be more likely to give a positive answer the closer the states are to being identical.