# latticecheck.py -- check of the lattice index in the proof of Theorem 1.1: for small q and M, the lattice Lambda in # Z[w]^d (w = exp(2 pi i/q), d = M(M-1)/2, power basis of Z[w]) generated by the differences of the steps # X(x) = (w^(x_i - x_j))_{i1: piv.sort(key=lambda r:abs(r[col])); p=piv[0]; new=[p] for r in piv[1:]: f=r[col]//p[col]; r=[a-f*b for a,b in zip(r,p)] (new if r[col]!=0 else rows).append(r) piv=new if not piv: return 0 basis.append(piv[0]) det=1 for i,b in enumerate(basis): det*=b[i] return abs(det) def check(q,M): P=cyclo(q); phi=len(P)-1; h=sum(P) coords=[reduce_mod(e,P) for e in range(q)] pairs=list(itertools.combinations(range(M),2)); d=len(pairs) step=lambda x: sum((coords[(x[i]-x[j])%q] for i,j in pairs),[]) base=step([0]*M) vecs=[[a-b for a,b in zip(step(x),base)] for x in itertools.product(range(q),repeat=M) if x[0]==0] return index(vecs,d*phi)//h**d, h**((M-1)*(M-2)//2), h if __name__=="__main__": for q,M in ((2,3),(2,4),(2,5),(3,3),(3,4),(4,3),(4,4),(5,3),(6,3),(8,3),(9,3),(10,3),(12,3)): got,exp,h=check(q,M); assert got == exp; print(f"q = {q:2d}, M = {M}, h = {h}: [I^d : Lambda] = {got}, predicted {exp}")