from itertools import product

import numpy as np

from common import bit_oracle

# Les 16 fonctions de 2 bits vers 1 bit, chacune donnée par sa table de vérité
inputs = list(product((0, 1), repeat=2))
all_self_inverse = True
for outputs in product((0, 1), repeat=4):
    table = dict(zip(inputs, outputs))
    U = bit_oracle(lambda x0, x1: table[(x0, x1)], 2)
    all_self_inverse = all_self_inverse and np.allclose(U @ U, np.eye(8))

print("fonctions testées :", 2**4)
print("pour toutes, U · U = identité :", all_self_inverse)
