"""Certificates for the local dimension bounds. Run with Python 3 and NumPy.""" from itertools import permutations, product import numpy as np def hadamard(q, p, root): """Use S=(1,-1), T=(2,-2), and omit the common Gauss phase.""" assert root != 1 and pow(root, q, p) == 1 def chirp(h): sign = 1 if pow(h % q, (q - 1) // 2, q) == 1 else -1 inv = pow(4 * h, -1, q) return np.array([ [sign * pow(root, (-(b - a) ** 2 * inv) % q, p) % p for b in range(q)] for a in range(q) ], dtype=np.int64) return np.block([[chirp(1), chirp(-3)], [chirp(3), -chirp(-1)]]) % p def independent_minor(matrix, p): """Lexicographic pivot columns and the original rows of the chosen pivots.""" reduced = matrix.copy() row_ids = np.arange(len(reduced)) columns = [] for col in range(matrix.shape[1]): rank = len(columns) choices = np.flatnonzero(reduced[rank:, col]) if not len(choices): continue pivot = rank + choices[0] reduced[[rank, pivot]] = reduced[[pivot, rank]] row_ids[[rank, pivot]] = row_ids[[pivot, rank]] pivot_row = reduced[rank] * pow(int(reduced[rank, col]), -1, p) % p factors = reduced[rank + 1:, col, None].copy() reduced[rank + 1:] = (reduced[rank + 1:] - factors * pivot_row) % p columns.append(col) return row_ids[:len(columns)], columns def inverse(matrix, p): n = len(matrix) augmented = np.column_stack((matrix, np.eye(n, dtype=np.int64))) for col in range(n): pivot = col + np.flatnonzero(augmented[col:, col])[0] augmented[[col, pivot]] = augmented[[pivot, col]] augmented[col] = augmented[col] * pow(int(augmented[col, col]), -1, p) % p factors = augmented[:, col, None].copy() factors[col] = 0 augmented = (augmented - factors * augmented[col]) % p result = augmented[:, n:] assert np.array_equal(matrix @ result % p, np.eye(n, dtype=np.int64)) return result def run(q, p, root, last_degree): h = hadamard(q, p, root) n = len(h) pairs = np.array(list(permutations(range(n), 2))) i, j = pairs.T inverse_entries = np.array([[pow(int(a), -1, p) for a in row] for row in h]) ratios = h[i] * inverse_entries[j] % p assert np.all(ratios.sum(axis=1) % p == 0) def differences(entries): phases = np.zeros((n, n), dtype=np.int64) phases[1:, 1:] = entries.reshape(n - 1, n - 1) return (phases[i] - phases[j]) % p def equations(coefficients): return (ratios * coefficients).sum(axis=1) % p basis = np.eye((n - 1) ** 2, dtype=np.int64) linear = np.column_stack([equations(differences(e)) for e in basis]) rows, pivots = independent_minor(linear, p) free = np.setdiff1d(np.arange(len(basis)), pivots) assert len(free) == 2 * (q - 1) pivot_inverse = inverse(linear[np.ix_(rows, pivots)], p) logs = [np.zeros_like(ratios)] exponentials = [np.ones_like(ratios)] for degree in range(1, last_degree + 1): known = np.zeros_like(ratios) for k in range(1, degree): known += k * logs[k] * exponentials[degree - k] % p known = known * pow(degree, -1, p) % p entries = np.zeros(len(basis), dtype=np.int64) if degree == 1: entries[free] = np.arange(1, len(free) + 1) rhs = (-equations(known) - linear @ entries) % p entries[pivots] = pivot_inverse @ rhs[rows] % p logs.append(differences(entries)) exponentials.append((known + logs[-1]) % p) residual = equations(exponentials[-1]) assert not residual[rows].any() failures = np.flatnonzero(residual) if len(failures): first = failures[0] print(f"q={q} p={p} root={root} rank={len(pivots)} " f"degree={degree} pair={tuple(map(int, pairs[first]))} " f"residue={residual[first]}") return degree, tuple(map(int, pairs[first])), int(residual[first]) raise AssertionError("Expected a nonzero residual") def monomials(degree, variables=4): """Enumerate exponent vectors of the given total degree.""" if variables == 1: return [(degree,)] return [(first, *tail) for first in range(degree, -1, -1) for tail in monomials(degree - first, variables - 1)] def order_ten_slice(p=101, root=95, fixed_entries=None): """Compute the multiplicative-coordinate slice over a prime field. An entry H[i,j] is replaced by H[i,j]*(1+X[i,j]). Only the eight nonpivot entries are prescribed. Store the coefficient of each monomial of X and of each ratio (1+X[a,j])/(1+X[b,j]) through degree six. """ h = hadamard(5, p, root) n = len(h) pairs = np.array(list(permutations(range(n), 2))) a, b = pairs.T inverse_h = np.array([[pow(int(x), -1, p) for x in row] for row in h]) weights = h[a] * inverse_h[b] % p assert not (weights.sum(axis=1) % p).any() def insert_entries(interior): x = np.zeros((n, n), dtype=np.int64) x[1:, 1:] = interior.reshape(n - 1, n - 1) return x def equations(ratios): return (weights * ratios).sum(axis=1) % p columns = [] for vector in np.eye((n - 1)**2, dtype=np.int64): entry = insert_entries(vector) columns.append(equations(entry[a] - entry[b])) jacobian = np.column_stack(columns) rows, pivots = independent_minor(jacobian, p) free = np.setdiff1d(np.arange(len(columns)), pivots) assert len(rows) == 73 assert free.tolist() == [70, 71, 75, 76, 77, 78, 79, 80] pivot_inverse = inverse(jacobian[np.ix_(rows, pivots)], p) first_row = np.array([1, 2, 3, 4]) slice_matrix = np.vstack([np.eye(4, dtype=np.int64), *[np.roll(first_row, -k) for k in range(4)]]) if fixed_entries is not None: # The leading sextics on the actual fibre depend only on its tangent # plane: all lower residuals vanish on the full eight-variable graph. tangent = np.zeros((81, 8), dtype=np.int64) tangent[free] = np.eye(8, dtype=np.int64) tangent[pivots] = -pivot_inverse @ jacobian[np.ix_(rows, free)] % p selected = [(i-1)*9+j-1 for i, j in fixed_entries] linear = tangent[selected] _, eliminated = independent_minor(linear, p) assert list(eliminated) == [0, 1, 2, 3] kept = np.setdiff1d(np.arange(8), eliminated) slice_matrix = np.zeros((8, 4), dtype=np.int64) slice_matrix[kept] = np.eye(4, dtype=np.int64) slice_matrix[eliminated] = -inverse(linear[:, eliminated], p) @ linear[:, kept] % p assert not (linear @ slice_matrix % p).any() entries, ratios = {}, {} for degree in range(1, 7): residuals = [] for alpha in monomials(degree): known = np.zeros_like(weights) for beta in product(*(range(i + 1) for i in alpha)): if beta == alpha or not any(beta): continue gamma = tuple(i - j for i, j in zip(alpha, beta)) known -= entries[beta][b] * ratios[gamma] known %= p vector = np.zeros(len(columns), dtype=np.int64) if degree == 1: vector[free] = slice_matrix[:, alpha.index(1)] rhs = (-equations(known) - jacobian @ vector) % p vector[pivots] = pivot_inverse @ rhs[rows] % p entries[alpha] = entry = insert_entries(vector) ratios[alpha] = (known + entry[a] - entry[b]) % p residual = equations(ratios[alpha]) assert not residual[rows].any() residuals.append(residual) coefficients = np.column_stack(residuals) if degree < 6: assert not coefficients.any() basis_rows, _ = independent_minor(coefficients, p) assert len(basis_rows) == 8 sextics = coefficients[basis_rows, :] sextic_monomials = monomials(6) ranks = [] for degree in range(6, 12): target = {alpha: j for j, alpha in enumerate(monomials(degree))} multipliers = monomials(degree - 6) products = np.zeros((len(multipliers) * len(sextics), len(target)), dtype=np.int64) for k, beta in enumerate(multipliers): indices = [target[tuple(i+j for i, j in zip(alpha, beta))] for alpha in sextic_monomials] products[k*len(sextics):(k+1)*len(sextics), indices] = sextics _, independent = independent_minor(products.T, p) ranks.append(len(independent)) print(f"Order 10, p={p}, root={root}, free={free.tolist()}") print(f"Degree 6 to 11 product ranks: {ranks}") assert ranks == [8, 32, 80, 160, 272, 364] return ranks if __name__ == "__main__": first = run(5, 101, 95, 6) second = run(7, 211, 58, 5) assert first == (6, (7, 4), 62) assert second == (5, (11, 6), 6) order_ten_slice() order_ten_slice(151, 8) if __name__ == "__main__": order_ten_slice(fixed_entries=[(1,2),(4,9),(7,4),(8,3)])