import numpy as np

from common import alice_gates, branch, correct, fidelity, rounded, share_pair
from qsim import make_state

for name, psi in [("|1⟩", make_state(0, 1)), ("|−⟩", make_state(1 / np.sqrt(2), -1 / np.sqrt(2)))]:
    state = alice_gates(share_pair(psi))
    results = []
    for m0 in (0, 1):
        for m1 in (0, 1):
            _, bob = branch(state, m0, m1)
            results.append(rounded(fidelity(psi, correct(bob, m0, m1))))
    print(f"{name} : fidélité après correction, pour 00, 01, 10, 11 : {results}")
