"""Four entry phases give coordinates on each symmetric family through H_5.""" from itertools import permutations, product from math import prod import numpy as np from sympy import Matrix from mixed_jets import hadamard, independent_minor, inverse def kernel(matrix, prime): """Nullspace basis with the nonpivot coordinates equal to the identity.""" rows, pivots = independent_minor(matrix % prime, prime) free = [i for i in range(matrix.shape[1]) if i not in pivots] basis = np.zeros((matrix.shape[1], len(free)), dtype=int) basis[free] = np.eye(len(free), dtype=int) minor = matrix[np.ix_(rows, pivots)] % prime basis[pivots] = -inverse(minor, prime) @ matrix[np.ix_(rows, free)] % prime assert not (matrix @ basis % prime).any() return basis def indices(labels, a, b, sign): return [5 * block + (sign * (j + b - 2 * h * a)) % 5 for block, h in enumerate(labels) for j in range(5)] def verify(): prime = 101 base = hadamard(5, prime, 95) reciprocals = np.array([[pow(int(x), -1, prime) for x in row] for row in base]) entries = np.zeros((10, 10, 81), dtype=int) entries[1:, 1:] = np.eye(81, dtype=int).reshape(9, 9, 81) jacobian = np.array([ ((base[i] * reciprocals[k])[:, None] * (entries[i] - entries[k])).sum(axis=0) for i, k in permutations(range(10), 2) ]) % prime tangent = entries @ kernel(jacobian, prime) assert tangent.shape == (10, 10, 8) actions = [(1, 0, 1), (0, 1, 1)] actions.extend((a, b, -1) for a, b in product(range(5), repeat=2)) positions = [(1, 2), (4, 9), (7, 4), (8, 3)] determinants = [] for a, b, sign in actions: moved = tangent[indices((1, -1), a, b, sign)][:, indices((2, -2), a, b, sign)] fixed_equations = moved - moved[:1, :] - moved[:, :1] + moved[0, 0] - tangent fixed = tangent @ kernel(fixed_equations.reshape(100, 8), prime) % prime assert fixed.shape == (10, 10, 4) restriction = Matrix([fixed[i, j].tolist() for i, j in positions]) determinants.append(int(restriction.det()) % prime) assert determinants[:2] == [96, 4] assert prod(determinants[2:]) % prime == 92 print("Translation determinants:", determinants[:2]) print("Product of the 25 reversal determinants modulo 101:", prod(determinants[2:]) % prime) if __name__ == "__main__": verify()