#!/usr/bin/env python3 """Numerical block and fusion checks on the orbits of index 5 and 6. Run with Python 3 and NumPy. """ import itertools import numpy as np def mul(p, q): # (p*q)(i) = p(q(i)) return tuple(p[i] for i in q) def inv(p): r = [0] * len(p) for i, a in enumerate(p): r[a] = i return tuple(r) def cyc(n, *cycles): # permutation of {0..n-1} from cycles on {1..n} p = list(range(n)) for c in cycles: for a, b in zip(c, c[1:] + c[:1]): p[a - 1] = b - 1 return tuple(p) def closure(gens): n = len(gens[0]); e = tuple(range(n)); G = {e}; front = [e] while front: new = [] for g in front: for s in gens: h = mul(s, g) if h not in G: G.add(h); new.append(h) front = new return sorted(G) # ---------------------------------------------------------------- algebras class Algebra: """Finite dimensional algebra, T[a,b,:] = coordinates of basis_a * basis_b.""" def __init__(self, T, unit, name): self.T = T; self.D = T.shape[0]; self.unit = unit; self.name = name def L(self, x): return np.einsum('a,abc->cb', x, self.T) def R(self, x): return np.einsum('b,abc->ca', x, self.T) def prod(self, x, y): return np.einsum('a,b,abc->c', x, y, self.T) def blocks(self, rng=np.random.default_rng(2)): """minimal central idempotents and block sizes""" D = self.D M = np.concatenate([np.transpose(self.T[:, b, :]) - np.transpose(self.T[b, :, :]) for b in range(D)]) # rows: coordinates of a*e_b - e_b*a, linear in a _, s, vh = np.linalg.svd(M, full_matrices=False) r = D - int((s > 1e-8 * s[0]).sum()) Z = vh[D - r:].conj().T # D x r, basis of the center z = Z @ (rng.standard_normal(r) + 1j * rng.standard_normal(r)) Mz = np.linalg.lstsq(Z, self.L(z) @ Z, rcond=None)[0] _, W = np.linalg.eig(Mz) out = [] for k in range(r): p = Z @ W[:, k] pp = self.prod(p, p) c = np.vdot(p, pp) / np.vdot(p, p) p = p / c assert np.abs(self.prod(p, p) - p).max() < 1e-7, "central idempotent" d2 = np.linalg.matrix_rank(self.L(p), tol=1e-7) d = int(round(d2 ** 0.5)); assert d * d == d2 out.append((d, p)) assert sum(d * d for d, _ in out) == D out.sort(key=lambda t: t[0]) return out def group_algebra(G): idx = {g: i for i, g in enumerate(G)}; D = len(G) T = np.zeros((D, D, D)) for g in G: for h in G: T[idx[g], idx[h], idx[mul(g, h)]] = 1 unit = np.zeros(D); unit[idx[tuple(range(len(G[0])))]] = 1 return Algebra(T, unit, "group algebra"), idx def fourier_family(G, idx, family): """family: list of lists of commuting generators; each generates H_i = product of cyclic groups. Returns the magic matrix of the group dual, as a dict (i,j) -> vector, and the orbits.""" D = len(G); u = {}; orbits = []; base = 0 for gens in family: orders = [] for g in gens: k, h = 1, g while h != tuple(range(len(g))): h = mul(g, h); k += 1 orders.append(k) labels = list(itertools.product(*[range(k) for k in orders])) # elements and characters def elem(a): h = tuple(range(len(gens[0]))) for g, m in zip(gens, a): for _ in range(m): h = mul(g, h) return h def chi(a, b): # character a at element b return np.exp(2j * np.pi * sum(x * y / k for x, y, k in zip(a, b, orders))) N = len(labels) P = {} for rho in labels: v = np.zeros(D, dtype=complex) for b in labels: v[idx[elem(b)]] += chi(rho, b) / N P[rho] = v for i, c in enumerate(labels): for j, d in enumerate(labels): rho = tuple((x - y) % k for x, y, k in zip(c, d, orders)) u[(base + i, base + j)] = P[rho] orbits.append(list(range(base, base + N))); base += N return u, orbits, base def twisted_functions(G, a, b): """C(G) twisted by the bicharacter s(al,be) = (-1)^(al_1 be_2) on the dual of V = = Z_2 x Z_2, on the left and on the right. Basis: Dirac masses.""" idx = {g: i for i, g in enumerate(G)}; D = len(G) V = [(i, j, mul(_pw(a, i), _pw(b, j))) for i in range(2) for j in range(2)] chars = [(p, q) for p in range(2) for q in range(2)] Q = np.zeros((16, D, D)) # Q[(al,be), g, :] = bihomogeneous part of delta_g for ia, al in enumerate(chars): for ib, be in enumerate(chars): for g in G: for (i, j, v) in V: for (k, l, w) in V: sign = (-1) ** (al[0] * i + al[1] * j + be[0] * k + be[1] * l) # (P f)(h) = 1/16 sum_{v,w} al(v) be(w) f(v h w), f = delta_g: h = v g w Q[4 * ia + ib, idx[g], idx[mul(mul(v, g), w)]] += sign / 16 S = np.zeros((16, 16)) for ia, al in enumerate(chars): for ib, be in enumerate(chars): for ja, al2 in enumerate(chars): for jb, be2 in enumerate(chars): S[4 * ia + ib, 4 * ja + jb] = (-1) ** (al[0] * al2[1] + be[0] * be2[1]) T = np.einsum('igk,ihk->ghk', Q, np.einsum('ij,jhk->ihk', S, Q)) return Algebra(T, np.ones(D), "twisted function algebra"), idx def _pw(g, k): h = tuple(range(len(g))) for _ in range(k): h = mul(g, h) return h def permutation_magic(G, idx, n): u = {} for i in range(n): for j in range(n): v = np.zeros(len(G)) for g in G: if g[j] == i: v[idx[g]] = 1 u[(i, j)] = v return u, [list(range(n))], n def irreps(A, u, n, blocks, rng): """for each block the list of matrices pi(u_ij), as a dict (i,j) -> d x d array""" D = A.D; out = [] for d, p in blocks: while True: a = A.prod(p, rng.standard_normal(D) + 1j * rng.standard_normal(D)) ev = np.linalg.eigvals(A.L(a)) ev = ev[np.abs(ev) > 1e-6] lam = [] for z in ev: if not any(abs(z - w) < 1e-5 for w in lam): lam.append(z) if len(lam) == d and min([abs(x - y) for x in lam for y in lam if x is not y] + [1]) > 1e-2: break e = p.astype(complex) for w in lam[1:]: e = A.prod(e, (a - w * p) / (lam[0] - w)) assert np.abs(A.prod(e, e) - e).max() < 1e-6 U, s, _ = np.linalg.svd(A.R(e)) Q = U[:, :d]; assert s[d - 1] > 1e-6 and (len(s) == d or s[d] < 1e-6) pi = {} for (i, j), v in u.items(): pi[(i, j)] = Q.conj().T @ A.L(v) @ Q out.append(pi) return out def get(pi, i, j, d): return pi.get((i, j), np.zeros((d, d), dtype=complex)) def tensor(pX, dX, pY, dY, n): return {(i, k): sum(np.kron(get(pX, i, j, dX), get(pY, j, k, dY)) for j in range(n)) for i in range(n) for k in range(n)} def dual(pX, dX, n): return {(i, j): get(pX, j, i, dX).T for i in range(n) for j in range(n)} def multiplicity(M, N, pW, dW, n): rows = [] for i in range(n): for k in range(n): Mik = M[(i, k)]; Wik = get(pW, i, k, dW) if np.abs(Mik).max() < 1e-12 and np.abs(Wik).max() < 1e-12: continue rows.append(np.kron(np.eye(dW), Mik) - np.kron(Wik.T, np.eye(N))) K = np.concatenate(rows) s = np.linalg.svd(K, compute_uv=False) return int((s < 1e-6).sum()) + max(0, N * dW - len(s)) def decompose(M, N, reps, degs, n): out = {}; left = N order = sorted(range(len(reps)), key=lambda t: degs[t]) for w in order: if left <= 0: break if degs[w] > left: continue m = multiplicity(M, N, reps[w], degs[w], n) if m: out[w] = m; left -= m * degs[w] assert left == 0, "decomposition" return out def generated(start, reps, degs, n, cache): S = set(start); front = set(start) while front: new = set() for x in front: for y in list(S): for (a, b) in ((x, y), (y, x)): if (a, b) not in cache: cache[(a, b)] = decompose(tensor(reps[a], degs[a], reps[b], degs[b], n), degs[a] * degs[b], reps, degs, n) new |= set(cache[(a, b)]) - S S |= new; front = new return S def check(name, algebra, coordinates, orbits, n, index, expected, adj_dim, local_dim, class_orbits, uniform=None): """Recover diagonal constituents with multiplicities, not just dimensions.""" blocks = algebra.blocks(np.random.default_rng(2)) degrees = [d for d, _ in blocks] reps = irreps(algebra, coordinates, n, blocks, np.random.default_rng(7)) ranks = [np.array([[np.linalg.matrix_rank(get(pi, i, j, d), tol=1e-6) for j in range(n)] for i in range(n)]) for pi, d in zip(reps, degrees)] regular = sum(d * rank for d, rank in zip(degrees, ranks)) for d, rank in zip(degrees, ranks): assert all(rank.sum(axis=0) == d) and all(rank.sum(axis=1) == d) cache = {} adj = set() for pi, d in zip(reps, degrees): adj.update(decompose(tensor(pi, d, dual(pi, d, n), d, n), d*d, reps, degrees, n)) adj = generated(adj, reps, degrees, n, cache) assert sum(degrees[y]**2 for y in adj) == adj_dim found = 0 for orbit in orbits: q = algebra.D // len(orbit) assert np.all(regular[np.ix_(orbit, orbit)] == q) if q != index: continue found += 1 simple_sets = [] for i in orbit: shape = sorted((d, int(rank[i,i])) for rank, d in zip(ranks, degrees) if rank[i,i]) assert shape == sorted(expected), (name, i, shape, expected) simple_sets.append(frozenset(y for y, rank in enumerate(ranks) if rank[i,i])) local = generated(set.union(set(), *simple_sets), reps, degrees, n, cache) assert sum(degrees[y]**2 for y in local) == local_dim if uniform is not None: assert (len(set(simple_sets)) == 1) == uniform if uniform: # These are the S4 and GL(2,3) examples. Verify the actual simple # constituents on both sides, including the choice of the other 3. diagonal = simple_sets[0] unit = next(x for x in diagonal if degrees[x] == 1) sign = next(x for x, d in enumerate(degrees) if d == 1 and x != unit) z = next(x for x in diagonal if degrees[x] == 2) y = next(x for x in diagonal if degrees[x] == 3) def product(x, y): if (x, y) not in cache: matrices = tensor(reps[x], degrees[x], reps[y], degrees[y], n) cache[x, y] = decompose(matrices, degrees[x] * degrees[y], reps, degrees, n) return cache[x, y] def simple_sum(*summands): return {x: summands.count(x) for x in set(summands)} other, = product(sign, y) assert degrees[other] == 3 and other != y assert product(y, sign) == simple_sum(other) assert product(sign, sign) == simple_sum(unit) assert product(z, z) == simple_sum(unit, sign, z) assert product(y, z) == product(z, y) == simple_sum(y, other) assert product(y, y) == product(other, other) == simple_sum(unit, z, y, other) assert product(y, other) == product(other, y) == simple_sum(sign, z, y, other) characters = [rank[np.ix_(orbit, orbit)] for rank, d in zip(ranks, degrees) if d == 1] orbit_count = len({tuple(np.flatnonzero(sum(characters)[:,j])) for j in range(len(orbit))}) assert orbit_count == class_orbits, (name, orbit_count) assert found, name print(f"{name:16} {algebra.D:3} {algebra.D//index:3} {index:2}" f" {str(expected):34} {adj_dim:3} {local_dim:3} {class_orbits:3}") def group_example(name, generators, orbit_generators, *expected): group = closure(generators) assert set(closure([g for family in orbit_generators for g in family])) == set(group) algebra, idx = group_algebra(group) coordinates, orbits, n = fourier_family(group, idx, orbit_generators) check(name, algebra, coordinates, orbits, n, *expected) def main(): print("Group D m q (degree, multiplicity) adj loc orbits") d5 = [(1,1),(2,1),(2,1)] f5 = [(1,1),(4,1)] r, s = cyc(5,(1,2,3,4,5)), cyc(5,(2,5),(3,4)) group_example("D5 dual", [r,s], [[s],[mul(s,r)]], 5,d5,10,10,1) f = cyc(5,(2,3,5,4)) group_example("F20 dual", [r,f], [[f],[mul(mul(r,f),inv(r))]], 5,f5,20,20,1) d = cyc(9,(1,2,3,4,5),(6,8),(7,9)) e = cyc(9,(2,5),(3,4),(6,7,8,9)) group_example("Dic5 dual", [d,e], [[e],[mul(mul(d,e),inv(d))]], 5,d5,10,10,1) a,b = cyc(4,(1,2),(3,4)),cyc(4,(1,2,3)) group_example("A4 dual", [a,b], [[a],[b]], 6,[(1,1)]*3+[(3,1)],12,12,2) r,s = cyc(6,(1,2,3,4,5,6)),cyc(6,(2,6),(3,5)) group_example("D6 dual", [r,s], [[s],[mul(s,r)]], 6,[(1,1)]*2+[(2,1)]*2,6,12,1) a,b = cyc(3,(1,2)),cyc(3,(2,3)) group_example("S3 dual", [a,b], [[a],[b],[cyc(3)]], 6,[(1,1)]*2+[(2,2)],6,6,1) a,b=cyc(4,(1,2,3,4)),cyc(4,(1,2,4,3)) shape = [(1,1),(2,1),(3,1)] group_example("S4 dual", [a,b], [[a],[b]], 6,shape,24,24,2,True) vectors = [(x,y) for x in range(3) for y in range(3) if (x,y)!=(0,0)] def mat(a,b,c,d): return tuple(vectors.index(((a*x+b*y)%3,(c*x+d*y)%3)) for x,y in vectors) g,t = mat(0,1,1,1),mat(1,1,0,1) group_example("GL(2,3) dual", [g,t], [[g],[mul(mul(t,g),inv(t))]], 6,shape,24,24,4,True) group = closure([cyc(4,(1,2)),cyc(4,(1,2,3,4))]) algebra, idx = twisted_functions(group,cyc(4,(1,2)),cyc(4,(3,4))) coordinates, orbits, n = permutation_magic(group,idx,4) check("S4 twist",algebra,coordinates,orbits,n,6,[(1,1),(1,1),(4,1)],24,24,1) if __name__ == "__main__": main()