""" twisting.py -- checks the twisting results of section 4, relating the Weyl-Cayley graphs X_c = (M_n, sum_g c_g Ad_{U_g}) to the Cayley graphs Y_c = (Z_n^2, sum_g c_g tau_g), with tau_g f(p) = f(p+g). In the bases U_h of M_n(C) and chi_h = omega^{sigma(.,h)} of C(Z_n^2), both graphs are diagonal, with the same eigenvalues F(h) = sum_g c_g omega^{sigma(g,h)}, and both bases multiply as Z_n^2, untwisted for chi_h, and twisted by the 2-cocycle theta(g,h) = omega^{g_2 h_1} for U_h. Part 1: spectra of X_c and Y_c, and dimensions of the smallest subspaces containing 1, J, d and stable under the 4 basic operations, for random weights c and for the examples of the paper (simplex, quantum square, Weyl cycles, directed Weyl cycle, J - nE, quantum torus). Part 2: the quantum torus over M_3, S = {+-(1,0), +-(0,1)}, versus the torus graph K_3 [] K_3. The automorphism group K of the torus graph is computed by brute force (order 72), C(K) is twisted by theta, and it is checked that the twisted algebra is a Hopf *-algebra with positive Haar functional, coacting on M_3 and commuting with the quantum torus. Its center, its characters, its block decomposition C^36 + M_3(C)^4, and the moments of its main character are computed. The block decomposition is also checked exactly, via the 8 fibers of the map k = (t,A) -> A, which are 4 commutative algebras C^9 for det A = 1, and 4 twisted group algebras of Z_3^2 with nondegenerate commutator bicharacter, hence M_3(C), for det A = -1. Part 3: the maps Ad_U, Ad_Lambda, Ad_F3, with F3 the Fourier matrix, commute with the quantum torus, and generate a group of order 36, which is Z_3^2 x| Z_4, the classical version. Results are written to twisting.log. """ import itertools import numpy as np from qspace import QSpace, Logger, close, weyl, ad from products import closure rng = np.random.default_rng(27) log = Logger("twisting.log") def sig(g, h, n): return (g[1] * h[0] - g[0] * h[1]) % n def weyl_graph(n, c): q = QSpace([n]) return q, sum(w * ad(q, weyl(n, g)) for g, w in c.items()) def cayley_graph(n, c): q = QSpace([1] * (n * n)) pts = list(itertools.product(range(n), repeat=2)) d = np.zeros((n * n, n * n), dtype=complex) for a, p in enumerate(pts): for g, w in c.items(): b = pts.index(((p[0] + g[0]) % n, (p[1] + g[1]) % n)) d[a, b] += w # (d f)(p) = sum_g c_g f(p+g) return q, d def spec(d): return np.sort_complex(np.round(np.linalg.eigvals(d), 8)) def compare(name, n, c): qX, dX = weyl_graph(n, c) qY, dY = cayley_graph(n, c) s = np.allclose(spec(dX), spec(dY), atol=1e-6) cX = closure(qX, [qX.identity(), qX.J(), dX]) cY = closure(qY, [qY.identity(), qY.J(), dY]) log(f" {name:38s} n={n}: same spectrum {s}, closure dimensions {cX}, {cY}") return s and cX == cY def sym(n, gens, w=None): c = {} for i, g in enumerate(gens): x = 1 if w is None else w[i] c[g % n if isinstance(g, int) else (g[0] % n, g[1] % n)] = x c[((-g[0]) % n, (-g[1]) % n)] = np.conj(x) return c log("=== Part 1: X_c over M_n versus the Cayley graph Y_c of Z_n^2") ok = True log(" examples:") for n in [2, 3, 4]: allg = {g: 1 for g in itertools.product(range(n), repeat=2) if g != (0, 0)} ok &= compare("simplex / complete graph", n, allg) ok &= compare("quantum square / square C_4", 2, {(1, 0): 1, (0, 1): 1}) for n in [3, 4, 5, 6]: ok &= compare("Weyl cycle / n copies of C_n", n, sym(n, [(1, 0)])) for n in [2, 3, 4, 5, 6]: ok &= compare("directed Weyl cycle / n oriented n-cycles", n, {(1, 0): 1}) for n in [2, 3, 4]: ok &= compare("J-nE / complete multipartite", n, {g: 1 for g in itertools.product(range(n), repeat=2) if g[0] != 0}) ok &= compare("quantum torus / torus K_3 [] K_3", 3, sym(3, [(1, 0), (0, 1)])) log(" random weights:") for n in [2, 3, 4]: for t in range(3): els = [g for g in itertools.product(range(n), repeat=2) if g != (0, 0)] pick = [els[i] for i in rng.choice(len(els), 3, replace=False)] w = list(rng.integers(1, 4, size=3) + 1j * rng.integers(-2, 3, size=3)) if t == 2: c = {g: complex(x) for g, x in zip(pick, w)} # directed, complex else: c = sym(n, pick, [x.real for x in w]) # undirected, real ok &= compare(f"random weights, trial {t}", n, c) log(f" all comparisons agree: {ok}") log("") log("=== Part 2: the quantum torus over M_3 versus the torus graph K_3 [] K_3") n = 3 om = np.exp(2j * np.pi / n) pts = list(itertools.product(range(n), repeat=2)) P = {p: i for i, p in enumerate(pts)} S = [(1, 0), (2, 0), (0, 1), (0, 2)] adj = np.zeros((9, 9), dtype=int) for p in pts: for g in S: adj[P[p], P[((p[0] + g[0]) % n, (p[1] + g[1]) % n)]] = 1 K = [k for k in itertools.permutations(range(9)) if (adj[np.ix_(k, k)] == adj).all()] log(f" automorphism group K of the torus graph, by brute force over S_9: order {len(K)}") Kidx = {k: i for i, k in enumerate(K)} m = len(K) def compose(k1, k2): # (k1 o k2)(p) = k1(k2(p)) return tuple(k1[k2[i]] for i in range(9)) trans = [tuple(P[((p[0] + t[0]) % n, (p[1] + t[1]) % n)] for p in pts) for t in pts] log(f" translations contained in K: {all(t in Kidx for t in trans)}") # affine description: all elements of K are p -> Ap + t, with A a signed permutation matrix dets, Amat, Tvec = [], [], [] for k in K: t = pts[k[P[(0, 0)]]] c1 = np.array(pts[k[P[(1, 0)]]]) - t c2 = np.array(pts[k[P[(0, 1)]]]) - t A = np.array([c1, c2]).T % n aff = all(pts[k[P[p]]] == tuple((A @ np.array(p) + t) % n) for p in pts) dets.append((int(round(np.linalg.det(A))) % n, aff)) Amat.append(tuple(map(tuple, A))) Tvec.append(t) log(f" all elements of K are affine: {all(a for _, a in dets)}, " f"determinants: {sum(1 for d, _ in dets if d == 1)} times 1, {sum(1 for d, _ in dets if d == 2)} times -1") chi = {h: np.array([om ** sig(p, h, n) for p in pts]) for h in pts} # chi_h(p) = omega^sigma(p,h) # y_gh(k) = coefficient of chi_g in chi_h o k Y = {(g, h): np.array([np.vdot(chi[g], chi[h][list(k)]) / 9 for k in K]) for g in pts for h in pts} F = {h: sum(om ** sig(g, h, n) for g in S) for h in pts} log(f" y_gh = 0 when F(g) != F(h): {all(np.allclose(Y[g, h], 0) for g in pts for h in pts if abs(F[g] - F[h]) > 1e-9)}") # bigrading of C(K): f(k o tau_t) = chi_a(t) f(k), f(tau_t o k) = chi_b(t) f(k) R = [[Kidx[compose(k, trans[P[t]])] for k in K] for t in pts] # k -> k o tau_t L = [[Kidx[compose(trans[P[t]], k)] for k in K] for t in pts] # k -> tau_t o k Mts = np.zeros((81, m, m)) for i in range(9): for j in range(9): idx = np.array(L[j])[R[i]] # k -> tau_s o k o tau_t Mts[9 * i + j, np.arange(m), idx] = 1 proj = {} for a in pts: for b in pts: coef = np.array([np.conj(chi[a][i]) * np.conj(chi[b][j]) for i in range(9) for j in range(9)]) / 81 proj[a, b] = np.einsum('t,tkl->kl', coef, Mts) log(f" the bigrading projections are orthogonal projections, summing up to 1: " f"{all(np.allclose(p @ p, p) and np.allclose(p, p.conj().T) for p in proj.values())}, " f"{np.allclose(sum(proj.values()), np.eye(m))}") log(f" y_gh has bidegree (g,h): {all(np.allclose(proj[g, h] @ Y[g, h], Y[g, h]) for g in pts for h in pts)}") basis, degs = [], [] for (a, b), p in proj.items(): w, v = np.linalg.eigh(p) for j in np.nonzero(w > 0.5)[0]: basis.append(v[:, j]) degs.append((a, b)) B = np.array(basis).T Binv = B.conj().T dims = sorted(set(degs)) log(f" bihomogeneous orthonormal basis of C(K): {B.shape[1]} elements, {len(dims)} bidegrees") def theta(g, h): return om ** ((g[1] * h[0]) % n) # structure constants of the twisted algebra: Lst[i] = left multiplication by B_i, in the basis B Lst = np.zeros((m, m, m), dtype=complex) for i in range(m): for j in range(m): (a, b), (c, d) = degs[i], degs[j] Lst[i][:, j] = Binv @ (B[:, i] * B[:, j]) / theta(a, c) * theta(b, d) SH = np.zeros((m, m), dtype=complex) for i in range(m): (a, b) = degs[i] SH[:, i] = om ** ((b[0] * b[1] - a[0] * a[1]) % n) * (Binv @ np.conj(B[:, i])) def tw(x, z): """twisted product of x, z in C(K), given as functions on K""" return B @ np.einsum('i,ijk,k->j', Binv @ x, Lst, Binv @ z) def sharp(x): """involution of the twisted algebra""" return B @ (SH @ np.conj(Binv @ x)) ass = True for t in range(30): i, j = rng.integers(0, m, size=2) ass &= np.allclose(np.einsum('k,kab->ab', Lst[i][:, j], Lst), Lst[i] @ Lst[j]) log(f" twisted product associative (30 random checks): {ass}") one = np.ones(m, dtype=complex) x0 = rng.normal(size=m) + 1j * rng.normal(size=m) log(f" unit preserved: {np.allclose(tw(one, x0), x0) and np.allclose(tw(x0, one), x0)}") Rst = np.transpose(Lst, (2, 1, 0)) # Rst[i][:, j] = coordinates of B_j * B_i log(f" twisted algebra noncommutative: {max(np.linalg.norm(Lst[i] - Rst[i]) for i in range(m)) > 1e-6}") # explicit noncommuting generators, coming from an element of determinant -1 g = None for kk, k in enumerate(K): if dets[kk][0] == 2: for h0 in pts: for s0 in pts: if sig(h0, s0, n) != 0: h, s = h0, s0 g = [x for x in pts if abs(Y[x, h][kk]) > 1e-9][0] r = [x for x in pts if abs(Y[x, s][kk]) > 1e-9][0] break if g is not None: break break c1 = tw(Y[g, h], Y[r, s]) c2 = tw(Y[r, s], Y[g, h]) nz = np.abs(c2) > 1e-9 log(f" [y_gh][y_rs] != [y_rs][y_gh] for g={g}, h={h}, r={r}, s={s}: {not np.allclose(c1, c2)}, " f"ratio omega^{(2 * sig(h, s, n)) % n} expected, found ratio {np.round(c1[nz][0] / c2[nz][0], 6)}, " f"omega^{(2 * sig(h, s, n)) % n} = {np.round(om ** (2 * sig(h, s, n)), 6)}") # the coaction on M_3: beta(U_h) = sum_g U_g x [y_gh] U = {h: weyl(n, h) for h in pts} def mult_MA(X, Z): # (sum U_g x a_g)(sum U_r x b_r) out = {} for g1, a in X.items(): for r1, b in Z.items(): M = U[g1] @ U[r1] key = ((g1[0] + r1[0]) % n, (g1[1] + r1[1]) % n) coef = M[np.nonzero(np.abs(U[key]) > 1e-9)][0] / U[key][np.nonzero(np.abs(U[key]) > 1e-9)][0] out[key] = out.get(key, 0) + coef * tw(a, b) return out beta = {h: {g: Y[g, h] for g in pts} for h in pts} mul = True for h in pts: for k in pts: lhs = mult_MA(beta[h], beta[k]) hk = ((h[0] + k[0]) % n, (h[1] + k[1]) % n) mul &= all(np.allclose(lhs.get(g, 0), theta(h, k) * beta[hk][g]) for g in pts) log(f" beta(U_h) beta(U_k) = theta(h,k) beta(U_h+k), so beta is multiplicative: {mul}") star = True for h in pts: mh = ((-h[0]) % n, (-h[1]) % n) for g in pts: mg = ((-g[0]) % n, (-g[1]) % n) # beta(U_h)^* = sum_g U_g^* x [y_gh]^#, with U_g^* = omega^{g1 g2} U_{-g}, U_h^* = omega^{h1 h2} U_{-h} star &= np.allclose(om ** ((g[0] * g[1]) % n) * sharp(Y[g, h]), om ** ((h[0] * h[1]) % n) * Y[mg, mh]) log(f" beta(U_h)^* = beta(U_h^*), so beta is involutive: {star}") log(f" (psi x id) beta(U_h) = psi(U_h) 1, so beta preserves the trace: " f"{all(np.allclose(Y[(0, 0), h], 1.0 * (h == (0, 0))) for h in pts)}") inv = all(np.allclose(sharp(sharp(B[:, i])), B[:, i]) for i in range(m)) anti = all(np.allclose(sharp(tw(B[:, i], B[:, j])), tw(sharp(B[:, j]), sharp(B[:, i]))) for i, j in rng.integers(0, m, size=(30, 2))) log(f" # is an involution: {inv}, antimultiplicative (30 random checks): {anti}") # Hopf structure: Delta f(k1, k2) = f(k2 o k1), Haar = uniform average comp = np.array([[Kidx[compose(K[j], K[i])] for j in range(m)] for i in range(m)]) def Delta(f): return f[comp] # matrix (k1, k2) -> f(k2 o k1) def tw2(X, Z): """twisted product on C(K) x C(K), legwise""" cX = Binv @ X @ Binv.T cZ = Binv @ Z @ Binv.T out = np.einsum('ij,kl,iak,jbl->ab', cX, cZ, Lst, Lst, optimize=True) return B @ out @ B.T hop = True for t in range(4): x = Y[pts[rng.integers(9)], pts[rng.integers(9)]] z = Y[pts[rng.integers(9)], pts[rng.integers(9)]] hop &= np.allclose(Delta(tw(x, z)), tw2(Delta(x), Delta(z))) log(f" Delta is multiplicative for the twisted product (4 random checks on generators): {hop}") def haar(f): return f.mean() Gr = np.array([[haar(tw(sharp(B[:, i]), B[:, j])) for j in range(m)] for i in range(m)]) ev = np.linalg.eigvalsh((Gr + Gr.conj().T) / 2) log(f" Haar form h(x^# y) positive definite: {ev.min() > 1e-9}, Haar trace: " f"{all(np.isclose(haar(tw(B[:, i], B[:, j])), haar(tw(B[:, j], B[:, i]))) for i, j in rng.integers(0, m, size=(40, 2)))}") # structure of the twisted algebra center = m - np.linalg.matrix_rank(np.vstack([Lst[i] - Rst[i] for i in range(m)]), tol=1e-8) comm = np.array([Lst[i][:, j] - Lst[j][:, i] for i in range(m) for j in range(i + 1, m)]) crank = np.linalg.matrix_rank(comm, tol=1e-8) u, sv, _ = np.linalg.svd(comm.T, full_matrices=False) Q = u[:, :crank] grow = True while grow: # two-sided ideal generated by the commutators new = [Lst[i] @ Q for i in range(m)] + [Rst[i] @ Q for i in range(m)] M = np.hstack([Q] + new) u, sv, _ = np.linalg.svd(M, full_matrices=False) r = int(np.sum(sv > 1e-8)) grow = r > Q.shape[1] Q = u[:, :r] nchar = m - Q.shape[1] nblocks = m - crank log(f" center of dimension {center}, commutator subspace of dimension {crank}, so {nblocks} blocks; " f"abelianization of dimension {nchar}, the number of characters") # block sizes: a central element acts on the left regular representation with eigenvalue # multiplicities d^2, for the blocks M_d(C) u, sv, vh = np.linalg.svd(np.vstack([Lst[i] - Rst[i] for i in range(m)])) Z = vh[-center:].conj().T # coordinates of the central elements zc = Z @ (rng.normal(size=center) + 1j * rng.normal(size=center)) Lz = np.einsum('i,ijk->jk', zc, Lst) ev = np.linalg.eigvals(Lz) mults = [] used = np.zeros(m, bool) for i in range(m): if not used[i]: same = np.abs(ev - ev[i]) < 1e-6 used |= same mults.append(int(same.sum())) sizes = sorted(int(round(np.sqrt(x))) for x in mults) from collections import Counter log(f" block sizes: {dict(Counter(sizes))}, so the algebra is C^{Counter(sizes)[1]} + M_3(C)^{Counter(sizes)[3]}, " f"total dimension {sum(x * x for x in sizes)}") # main character: same law as the number of fixed points of K on 9 points chiK = sum(Y[g, g] for g in pts) fix = np.array([sum(1 for i in range(9) if k[i] == i) for k in K]) log(f" main character = number of fixed points: {np.allclose(chiK, fix)}") mom_tw, mom_cl, x = [], [], one for k in range(1, 7): x = tw(x, chiK) mom_tw.append(int(round(haar(x).real))) mom_cl.append(int(round(np.mean(fix.astype(float) ** k)))) log(f" moments of the main character, twisted {mom_tw}, classical {mom_cl}") # exact block structure, via the fibers of the map k = (t, A) -> A: with B_A = det(A) A^{-1}, # the functions f_{A,h}(t, A') = 1_{A = A'} omega^sigma(t,h) have bidegree (B_A h, h), the f_{A,0} # are central idempotents of the twisted algebra, and inside the fiber of A the twisted product # has commutator bicharacter omega^{(1 - det A) sigma(h, s)} fibers = sorted(set(Amat)) deg_ok = idem_ok = comm_ok = True fiber_info = [] for A in fibers: Am = np.array(A) dA = 1 if round(np.linalg.det(Am)) % n == 1 else -1 BA = (dA * Am.T) % n # signed permutation matrices: A^{-1} = A^T ind = np.array([1.0 if Amat[i] == A else 0.0 for i in range(m)], dtype=complex) f = {h: ind * np.array([om ** sig(Tvec[i], h, n) for i in range(m)]) for h in pts} deg_ok &= all(np.allclose(proj[tuple(BA @ np.array(h) % n), h] @ f[h], f[h]) for h in pts) for _ in range(3): x = rng.normal(size=m) + 1j * rng.normal(size=m) idem_ok &= np.allclose(tw(ind, x), ind * x) and np.allclose(tw(x, ind), ind * x) comm_ok &= all(np.allclose(tw(f[h], f[s]), om ** ((1 - dA) * sig(h, s, n)) * tw(f[s], f[h])) for h in pts for s in pts) Fm = np.array([f[h] for h in pts]).T # the fiber, spanned by the f_{A,h} cm = np.vstack([np.array([tw(f[h], f[s]) - tw(f[s], f[h]) for h in pts]).T for s in pts]) zdim = 9 - np.linalg.matrix_rank(cm, tol=1e-8) fiber_info.append((dA, int(np.linalg.matrix_rank(Fm, tol=1e-8)), int(zdim))) log(f" fibers of k = (t,A) -> A: {len(fibers)} fibers, f_(A,h) of bidegree (B_A h, h): {deg_ok}, " f"f_(A,0) central idempotents of the twisted algebra: {idem_ok}") log(f" commutator bicharacter omega^((1 - det A) sigma(h,s)) inside each fiber: {comm_ok}") log(f" (det A, fiber dimension, center dimension): {sorted(fiber_info, reverse=True)}") log(f" so 4 commutative fibers C^9 and 4 fibers with trivial center, which are M_3(C): " f"{sorted(fiber_info, reverse=True) == [(1, 9, 9)] * 4 + [(-1, 9, 1)] * 4}") log("") log("=== Part 3: the classical automorphisms of the quantum torus over M_3") qM = QSpace([3]) dT = sum(ad(qM, weyl(3, g)) for g in S) Fo = np.array([[om ** (a * b) for b in range(3)] for a in range(3)]) / np.sqrt(3) gens = [ad(qM, weyl(3, (1, 0))), ad(qM, weyl(3, (0, 1))), ad(qM, Fo)] log(f" Ad_U, Ad_Lambda and Ad_F, with F the Fourier matrix, commute with d: {all(close(x @ dT, dT @ x) for x in gens)}") grp = [np.eye(9, dtype=complex)] frontier = list(grp) while frontier: new = [] for x in frontier: for y in gens: z = y @ x if not any(close(z, w) for w in grp + new): new.append(z) grp += new frontier = new log(f" they generate a group of order {len(grp)}, all commuting with d: {all(close(x @ dT, dT @ x) for x in grp)}") log(f" Ad_F has order {next(k for k in range(1, 9) if close(np.linalg.matrix_power(gens[2], k), np.eye(9)))}, " f"and this group is Z_3^2 x| Z_4, matching the {nchar} characters of the twisted algebra") log.save()