"""Direct multiplicative checks of cyclic periods over F_19 and F_(683^2).""" import json # The constructible carry example over F_19, r=3, a=2, kappa=6. p, r, kappa = 19, 3, 6 zeta, root = 7, 4 assert pow(root, 3, p) == zeta roots = [root * pow(zeta, j, p) % p for j in range(r)] # A regular geometric cyclic order: kappa consecutive copies of each root. y = [value for value in roots for _ in range(kappa)] n = len(y) period = next(k for k in range(1, n + 1) if all(y[(i + k) % n] == y[i] for i in range(n))) delta = [y[(i + 1) % n] * pow(y[i], -1, p) % p for i in range(n)] c = [y[i] if delta[i] == zeta else 1 for i in range(n)] assert all(delta[i] in (1, zeta) for i in range(n)) assert all(pow(c[i], r, p) == delta[i] for i in range(n)) w = 1 for value in c: w = w * value % p assert period == 18 and w == zeta carry = {"p": p, "r": r, "a": 2, "kappa": kappa, "period": period, "delta_nontrivial_support_rank": delta.count(zeta), "w": w, "primitive_w": True} # The actual D/T cyclotomic example: p=683, r=3, ell=19. # F_(p^2)=F_p[i], i^2=-1, since 683 is 3 modulo 4. p, r, ell = 683, 3, 19 assert all(p % k for k in range(2, int(p ** 0.5) + 1)) q = p * p def mul(x, y): return ((x[0] * y[0] - x[1] * y[1]) % p, (x[0] * y[1] + x[1] * y[0]) % p) def power(x, exponent): if exponent < 0: exponent %= q - 1 ans = (1, 0) while exponent: if exponent & 1: ans = mul(ans, x) x = mul(x, x) exponent >>= 1 return ans one = (1, 0) u_star = next(v for b in range(p) if (v := power((b, 1), (q - 1) // 9)) != one and power(v, 3) != one) zeta = power(u_star, 3) eta = next(v for b in range(p) if (v := power((b, 1), (q - 1) // ell)) != one) assert power(u_star, 9) == one and power(eta, ell) == one n, f, M, kappa = 18, 2, 9, 3 primitive_residue = 2 assert {pow(primitive_residue, j, ell) for j in range(n)} == set(range(1, ell)) log_p = next(j for j in range(n) if pow(primitive_residue, j, ell) == p % ell) assert log_p == 9 omega = {1: 1, 2: 8} def value(c_index, s): k = (s % M) // kappa return mul(power(u_star, omega[c_index]), power(zeta, c_index * k)) for c_index in (1, 2): for s in range(n): assert power(value(c_index, s), p) == value(2 * c_index % 3, s + log_p) assert power(value(c_index, s), 8) == value(2 * c_index % 3, s) assert power(value(c_index, s), 3) == power(zeta, c_index) period = next(k for k in range(1, n + 1) if all(value(c_index, s + k) == value(c_index, s) for c_index in (1, 2) for s in range(n))) obstructions = [] for c_index in (1, 2): w = one for s in range(n): delta = mul(value(c_index, s + 1), power(value(c_index, s), -1)) assert delta in (one, power(zeta, c_index)) c_value = value(c_index, s) if delta != one else one assert power(c_value, 3) == delta w = mul(w, c_value) assert w == power(zeta, c_index * f) and w != one obstructions.append(list(w)) assert period == M actual = {"p": p, "r": r, "ell": ell, "d": 2, "a": 2, "n": n, "f": f, "period": period, "v_r_n": 2, "v_r_period": 2, "w_exponent_relative_to_Z": f, "obstructions_at_two_D_embeddings": obstructions, "frobenius_compatibility_checked": True, "tame_compatibility_checked": True, "primitive_w": True} print(json.dumps({"carry_example": carry, "actual_cyclotomic_example": actual}, indent=2))