"""Independent finite checks for the algebraic examples in the article.""" from itertools import product from math import gcd import sympy as sp def cyclic_check(): tested = 0 for r, ell in ((3, 2), (3, 5), (3, 7), (5, 3)): for values in product(range(ell), repeat=r): if len(set(values)) == 1: continue # Coordinates are exponents relative to a primitive ell-th root. shifted = values[1:] + values[:1] sizes = [sum((b - a*j) % ell == 0 for a,b in zip(values,shifted)) for j in range(ell)] if not any(0 < size < r for size in sizes): j = sizes.index(r) assert j != 1 and pow(j, r, ell) == 1 and (ell-1) % r == 0 tested += 1 return tested def scalar_checks(): x = sp.symbols("x") assert all((i**3 - 3*i + 6) % 197 for i in range(197)) phi = sp.cyclotomic_poly(7,x) assert sp.rem(phi, x*x-106*x+1, x, modulus=251) == 0 # No integral-basis assumption: theta is a nonzero idempotent in F3 x F3. pairs = list(product(range(3), repeat=2)) assert sum((a*a % 3,b*b % 3)==(a,b) for a,b in pairs) == 4 assert sum((a*a % 3,2*a*b % 3)==(a,b) for a,b in pairs) == 2 H={1,17,19,8} cosets=[{(k*h)%45 for h in H} for k in (1,16,31,-1,-16,-31)] assert set.union(*cosets)=={j for j in range(45) if gcd(j,45)==1} assert [sum(2*j<45 for j in group) for group in cosets]==[4,2,1,0,2,3] if __name__ == "__main__": scalar_checks() print("All scalar checks passed;", cyclic_check(), "nonscalar cyclic tuples checked.")