import numpy as np

from common import MINUS, PLUS, rounded
from qsim import ONE, ZERO, apply_cnot, kron

np.set_printoptions(precision=3, suppress=True, floatmode="fixed")

# Entrées classiques : le CNOT fait ce qu'on attend, le contrôle ne bouge pas
print("|1⟩|0⟩ → |1⟩|1⟩ :", np.allclose(apply_cnot(kron(ONE, ZERO), 0, 1), kron(ONE, ONE)))

# Contrôle |+⟩, cible |−⟩
before = kron(PLUS, MINUS)
after = apply_cnot(before, control=0, target=1)
print("avant :", rounded(before))
print("après :", rounded(after))
print("après = |−⟩|−⟩ :", np.allclose(after, kron(MINUS, MINUS)))
