"""Check the 51 representatives from the Lampio--Ostergard--Szollosi catalogue. Run python catalogue.py to read the official Aalto data, or supply a local BH-10-10.txt as an argument. The output numbers the representatives from 1. """ import argparse from urllib.request import urlopen from itertools import combinations from pathlib import Path import numpy as np from sympy import ZZ from sympy.polys.matrices import DomainMatrix from mixed_jets import independent_minor def dephase(A): return (A-A[:1,:]-A[:,:1]+A[0,0])%10 def representative(): i,j=np.indices((10,10)) h=np.array([[1,3],[2,4]])[i//5,j//5] sign=(i//5+j//5>0) return (2*h*(i-j)**2+5*sign)%10 def integer_ranks(B): # Columns correspond to the 81 real phase variables. Coefficients for # rational velocities are expanded in 1,z,z^2,z^3, with z=exp(pi i/5). powers=[np.array([1,0,0,0])] for _ in range(9): a=powers[-1] powers.append(np.r_[0,a[:3]]+a[3]*np.array([-1,1,-1,1])) powers=np.array(powers) A=[] for i,k in combinations(range(10),2): a=np.zeros((10,10,4),int) a[i]=powers[(B[i]-B[k])%10]; a[k]=-a[i] A.append(a[1:,1:].reshape(81,4)) A=np.array(A) rational_rank=len(independent_minor(A.transpose(0,2,1).reshape(-1,81)%101,101)[1]) def chebyshev(a,b): coeff=[np.array(a),np.array(b)] for _ in range(2): x,y=coeff[-1] coeff.append(np.array([y,x+y])-coeff[-2]) return np.array(coeff) # Re and Im in the basis 1,t, t^2=t+1, after scaling by 2 and 1/sin(pi/5). real=chebyshev((2,0),(0,1)); imag=chebyshev((0,0),(1,0)) C=np.concatenate((A@real,A@imag)); a,b=C[:,:,0],C[:,:,1] block=np.block([[a,b],[b,a+b]]) exact=DomainMatrix.from_list(block.tolist(),ZZ).to_sparse().rref_den(method='FF')[2] return rational_rank,len(exact)//2 CATALOGUE_URL = ( "https://wiki.aalto.fi/download/attachments/120482261/BH-10-10.txt" "?api=v2&modificationDate=1499265160349&version=1" ) def read_catalogue(path=None): if path is None: adjacent = Path(__file__).with_name("BH-10-10.txt") if adjacent.is_file(): path = adjacent if path is None: with urlopen(CATALOGUE_URL, timeout=30) as response: content = response.read().decode("ascii") else: content = Path(path).read_text(encoding="ascii") records = [line.removeprefix("BH1:::") for line in content.splitlines()] if len(records) != 51 or any(len(row) != 100 or not row.isdecimal() for row in records): raise ValueError("Expected 51 records of 100 exponent digits in the order-10 catalogue.") return [np.array(list(row), dtype=int).reshape(10, 10) for row in records] def certify(path=None): data = read_catalogue(path) H=representative() certificates=[ (H,46,[0,2,7,4,8,3,6,5,1,9],[0,9,1,8,7,2,5,4,6,3]), (H.T,48,[0,6,9,4,7,5,2,8,3,1],[0,7,1,3,4,9,8,5,2,6]), (data[44].T,50,[0,2,9,1,8,4,6,7,5,3],[2,3,9,7,5,1,4,8,6,0])] for target,i,rows,cols in certificates: assert np.array_equal(dephase(data[i-1][np.ix_(rows,cols)]),dephase(target)) exceptional=[] for i,B in enumerate(data,1): pairs=sum(np.ptp((u-v)%5)==0 for a in [B,B.T] for u,v in combinations(a,2)) if not pairs: exceptional.append(i) assert integer_ranks(B)==(81,81 if i==51 else 73) assert exceptional==[45,46,48,50,51] assert not np.any(data[-1]%2) print('51 classes; 46 affine. Exceptions:',exceptional) if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("path", nargs="?", type=Path, help="local catalogue file") certify(parser.parse_args().path)