#!/usr/bin/env python3 """Exact checks for several formulas in the paper. Standard library only.""" from collections import Counter from fractions import Fraction from itertools import combinations, permutations, product from math import factorial, gcd def mobius(n): if n == 1: return 1 return -sum(mobius(d) for d in range(1, n) if n % d == 0) def check_dual_blocks(n): divisors = [d for d in range(1, n + 1) if n % d == 0] actual = Counter() for tail in permutations(range(1, n)): f = (0,) + tail stabilizer = sum(all((f[(x+t) % n] - f[t]) % n == f[x] for x in range(n)) for t in range(n)) actual[stabilizer] += 1 fixed = {d: sum(gcd(i, d) == 1 for i in range(1, d + 1)) * d**(n//d - 1) * factorial(n//d - 1) for d in divisors} blocks = {} for s in divisors: count = sum(mobius(d//s) * fixed[d] for d in divisors if d % s == 0) assert actual[s] == count if count: blocks[n//s] = s*s*count//n assert sum(size**2 * copies for size, copies in blocks.items()) == factorial(n) return dict(sorted(blocks.items())) def sector(k, sign): # The exponents modulo 2k represent arguments in multiples of pi/k. roots = set(range(0 if sign == 1 else 1, 2*k, 2)) ranks, orbit_sizes = [], [] while roots: value = min(roots) orbit = {value, -value % (2*k)} roots -= orbit orbit_sizes.append(len(orbit)) if len(orbit) == 2: ranks.append((1, 1, 1, 1)) else: # Entries are grouped by the two signs of each of the two involutions. positive = (1, 0) if value == 0 else (0, 1) ranks.extend([(1, 0) + positive, (0, 1) + positive[::-1]]) # Exhaust all subsets. Record the Plancherel weight of every selected block. covers = [] for m in (1, 2): for subset in combinations(range(len(ranks)), m): if all(sum(ranks[i][j] for i in subset) == 1 for j in range(4)): covers.append(subset) assert len(covers) == len(orbit_sizes) marginals = Counter() for cover in covers: probability = Fraction(2 if len(cover) == 1 else 1, k) for i in cover: marginals[i] += probability for i, row in enumerate(ranks): assert marginals[i] == Fraction(sum(row[:2]), k) return len(covers) def check_square_words(k, sign, length): words = list(product(range(4), repeat=length)) def steps(word): return tuple(0 if x == y else 1 if x//2 == y//2 else 2 for x, y in zip(word, word[1:])) labels = [steps(word) for word in words] assert len(set(labels)) == 3**(length-1) for t in (0, 1): roots = range(0 if t == 0 or sign == 1 else 1, 2*k, 2) # In the swap representation on the two Weyl lines, the eigenlines # of the two involutions differ in phase by pi*r/k. Orthogonality # between their eigenlines occurs exactly at phase difference pi. for I, label in zip(words, labels): for bits in product(range(2), repeat=length): J = tuple(2*((x//2)^t) + b for x, b in zip(I,bits)) signs = [(x % 2) ^ b for x, b in zip(I,bits)] def survives(r): angles = [((x//2)*r + s*k) % (2*k) for x,s in zip(I,signs)] return all((v-w) % (2*k) != k for v,w in zip(angles,angles[1:])) assert any(survives(r) for r in roots) == (label == steps(J)) def check_affine(): pts = list(product(range(3), repeat=2)) counts = Counter() for a,b,c,d in product(range(3), repeat=4): if (a*d-b*c) % 3 != 1: continue for u,v in pts: counts[sum(((a*x+b*y+u) % 3, (c*x+d*y+v) % 3) == (x,y) for x,y in pts)] += 1 assert counts == {0:56, 1:135, 3:24, 9:1} return dict(sorted(counts.items())) def permute(p,q): return tuple(p[i] for i in q) def check_tori(): g = list(permutations(range(3))) def label(p): return sum(x == y for x,y in enumerate(p)) met = {(label(p),label(q)) for p,q in product(g,repeat=2) if permute(p,q) == permute(q,p)} missing = set(product({0,1,3},repeat=2)) - met assert missing == {(0,1),(1,0)} assert sum(label(p)==1 and label(q)==0 for p,q in product(g,repeat=2)) == 6 return 2*len(missing) def check_classical_covers(): perms = list(permutations(range(4))) identity = perms[0] shift = (1,2,3,0) reflection = (0,3,2,1) double1, double2 = (1,0,3,2), (2,3,0,1) def closure(generators): seen, front = {identity}, [identity] while front: x = front.pop() for g in generators: y = permute(x,g) if y not in seen: front.append(y) seen.add(y) return seen groups = [closure([shift]),closure([double1,double2]),closure([shift,reflection]), closure([double1,(1,2,0,3)]),perms] counts = [sum(all(len({p[i] for p in subset})==4 for i in range(4)) for subset in combinations(group,4)) for group in groups] assert counts == [1,1,4,3,24] return counts def check_double_cover_weights(): # The first five blocks descend to S4. The final three have nontrivial # central character. Degrees and traces are in the order used below. degrees = (1,1,2,3,3,2,2,4) traces = (1,-1,0,1,-1,0,0,0) choices = [ (Fraction(3,8), (0,0,0,1,1,0,0,0)), (Fraction(1,8), (1,1,2,0,0,0,0,0)), (Fraction(1,4), (0,0,0,0,0,1,0,1)), (Fraction(1,4), (0,0,0,0,0,0,1,1)), ] for _, mult in choices: assert sum(a*b for a,b in zip(mult,degrees)) == 6 assert sum(a*b for a,b in zip(mult,traces)) == 0 for i,d in enumerate(degrees): assert sum(w*mult[i] for w,mult in choices) == Fraction(6*d,48) return True def check_monomial_zeros(): # For l divisible by 3, subtracting the arguments of two unit vectors # with sum -1 leaves the two nontrivial cube roots, in either order. # Independently check the zero sum in the cyclotomic field, using the # elementary geometric-sum recurrence for the cyclotomic polynomials. def remainder(f, g): f = f[:] while f and f[-1] == 0: f.pop() while len(f) >= len(g): leading = f[-1] shift = len(f)-len(g) for j,c in enumerate(g): f[shift+j] -= leading*c while f and f[-1] == 0: f.pop() return f def quotient(f, g): out = [0]*(len(f)-len(g)+1) f = f[:] for i in reversed(range(len(out))): out[i] = f[i+len(g)-1] for j,c in enumerate(g): f[i+j] -= out[i]*c assert not any(f) return out polys = {} for n in range(1,25): phi = [-1]+[0]*(n-1)+[1] for d in range(1,n): if n % d == 0: phi = quotient(phi,polys[d]) polys[n] = phi if n % 3: continue zeros = [] for a,b in product(range(n),repeat=2): f = [0]*n for i in (0,a,b): f[i] += 1 if not remainder(f,phi): zeros.append((a,b)) assert set(zeros) == {(n//3,2*n//3),(2*n//3,n//3)} def check_four_point_laws(): # By Theorem 3.2, the main character of a twist inside S_4^+ has the # law of 1 + Tr(h), with h uniform on the rotation group H. from math import cos, sin, pi, sqrt def mul(a, b): return tuple(tuple(sum(a[i][k]*b[k][j] for k in range(3)) for j in range(3)) for i in range(3)) def key(a): return tuple(round(x, 6) + 0.0 for row in a for x in row) def closure(gens): e = ((1, 0, 0), (0, 1, 0), (0, 0, 1)) seen, front = {key(e): e}, [e] while front: x = front.pop() for g in gens: y = mul(x, g) if key(y) not in seen: seen[key(y)] = y front.append(y) return list(seen.values()) def rotation(axis, angle): n = sqrt(sum(a*a for a in axis)) x, y, z = (a/n for a in axis) c, s, t = cos(angle), sin(angle), 1 - cos(angle) return ((c+x*x*t, x*y*t-z*s, x*z*t+y*s), (y*x*t+z*s, c+y*y*t, y*z*t-x*s), (z*x*t-y*s, z*y*t+x*s, c+z*z*t)) def law(group): return Counter(round(1 + sum(g[i][i] for i in range(3)), 6) + 0.0 for g in group) phi = (1 + sqrt(5))/2 cyc = ((0, 0, 1), (1, 0, 0), (0, 1, 0)) octa = closure([cyc, rotation((0, 0, 1), pi/2)]) ico = closure([cyc, rotation((0, 1, phi), 2*pi/5)]) assert len(octa) == 24 and law(octa) == {0.0: 9, 1.0: 8, 2.0: 6, 4.0: 1} assert len(ico) == 60 and law(ico) == {0.0: 15, round(phi**-2, 6): 12, 1.0: 20, round(phi**2, 6): 12, 4.0: 1} masses = {} for k in range(2, 13): dihedral = closure([rotation((0, 0, 1), pi/k), rotation((1, 0, 0), pi)]) assert len(dihedral) == 4*k expected = Counter({0.0: 2*k}) for j in range(2*k): expected[round(4*cos(pi*j/(2*k))**2, 6) + 0.0] += 1 assert law(dihedral) == expected masses[k] = Fraction(law(dihedral)[0.0], 4*k) assert masses[k] == Fraction(2*k + 1, 4*k) return Fraction(9, 24), Fraction(15, 60), masses[2] def main(): for n in range(3,9): blocks = check_dual_blocks(n) print(f"Dual E_{n} block sizes and multiplicities: {blocks}") for k in range(2,19): plus,minus = sector(k,1),sector(k,-1) assert plus == k//2+1 and minus == (k+1)//2 print("All square covers and their stationary marginals checked for k = 2 through 18.") for k in (3,4,5,6): for sign in (1,-1): for length in (1,2,3,4): check_square_words(k,sign,length) print("Square orbital classes checked in degrees 1 through 4, k = 3 through 6, both signs.") assert check_double_cover_weights() check_monomial_zeros() print("Double cover height 3 weights and 9-point monomial zero atoms checked.") print("Classical 4-point cover counts:", check_classical_covers()) print("9-point affine fixed point counts:", check_affine()) print("Dimension of the common toral kernel for the swap:",check_tori()) octa, ico, kp = check_four_point_laws() print("4-point twist laws checked, masses at zero:", octa, ico, kp, "for S4, A5, KP") if __name__ == '__main__': main()