import numpy as np

from common import MINUS, PLUS, bit_oracle, input_register
from qsim import apply, kron


def logical_and(x0, x1):
    return x0 & x1


state = apply(kron(PLUS, PLUS, MINUS), bit_oracle(logical_and, 2))
register = input_register(state)
print("la cible est toujours |−⟩ :", np.allclose(state, kron(register, MINUS)))
print("signes du registre d'entrée :", ["+" if a > 0 else "−" for a in register])
