""" planarity.py -- checks the planarity results of section 10. Over M_2, it checks that the quantum graphs coming from subspaces S of span(sigma_x, sigma_y, sigma_z) of dimension 1, 2, 3 have the spectra of 2K_2, C_4, K_4, that the simplex is Ad_sx + Ad_sy + Ad_sz = J - 1, and that the rotations of SO_3 commuting with d are those stabilizing S. It checks the matrices used for the quantum Colin de Verdiere invariant: M = -J for the simplex K_V, and M = -d for the quantum square, including the strong Arnold hypothesis, and the fact that the quantum square has mu = 2, the matrices of corank 3 violating the conditions. Finally, it computes hom(F,X) over all the drawings of K_{3,3} and K_5 on surfaces, for a random quantum graph over M_2, and over 4 points, and records the number of distinct complex values for each genus, and up to complex conjugation, compared with the numbers of drawings up to relabeling, and up to relabeling and reflection. Results are written to planarity.log. """ import itertools import numpy as np from qspace import QSpace, Logger, close, ad, random_cp, to_tensor from diagrams import spider, edge_form, genus, all_drawings, count_distinct, drawing_orbits log = Logger("planarity.log") rng = np.random.default_rng(12) q = QSpace([2]) sx = np.array([[0, 1], [1, 0]], dtype=complex) sy = np.array([[0, -1j], [1j, 0]]) sz = np.diag([1, -1]).astype(complex) paulis = [sx, sy, sz] def rotation_unitary(): """random W in U_2, and the rotation R of R^3 with W sigma_i W^* = sum_j R_ji sigma_j""" z = rng.normal(size=(2, 2)) + 1j * rng.normal(size=(2, 2)) W, _ = np.linalg.qr(z) R = np.array([[np.trace(paulis[j] @ W @ paulis[i] @ W.conj().T).real / 2 for i in range(3)] for j in range(3)]) return W, R for k, name in [(1, "2K_2"), (2, "C_4"), (3, "K_4")]: d = sum(ad(q, paulis[i]) for i in range(k)) ev = np.sort(np.linalg.eigvals(d).real) classical = {1: [-1, -1, 1, 1], 2: [-2, 0, 0, 2], 3: [-1, -1, -1, 3]}[k] stab_ok, nstab = True, 0 for t in range(20): W, R = rotation_unitary() if t % 2 == 1: # rotations about the axis x (k = 1), z (k = 2), arbitrary (k = 3) axis = {1: sx, 2: sz, 3: R[0, 0] * sx + R[1, 0] * sy + R[2, 0] * sz}[k] th = rng.normal() W = np.cos(th / 2) * np.eye(2) + 1j * np.sin(th / 2) * axis / np.sqrt(np.trace(axis @ axis).real / 2) R = np.array([[np.trace(paulis[j] @ W @ paulis[i] @ W.conj().T).real / 2 for i in range(3)] for j in range(3)]) commutes = close(ad(q, W) @ d, d @ ad(q, W)) S = np.eye(3)[:, :k] stabilizes = np.linalg.matrix_rank(np.hstack([S, R @ S]), tol=1e-8) == k stab_ok &= (commutes == stabilizes) nstab = nstab + stabilizes # rotations about the x axis and pi-rotations about the z axis commute with d, for k = 1, 2 log(f"M_2, dim S = {k}: spectrum of {name} {np.allclose(ev, classical)}, " f"rotations commuting with d = rotations stabilizing S {stab_ok} ({nstab} of 20 samples stabilizing), E = {q.psi(d @ q.one()).real / 2:.0f}") log(f"simplex over M_2: J - 1 = Ad_sx + Ad_sy + Ad_sz {close(q.simplex(), sum(ad(q, s) for s in paulis))}") def cdv_check(name, q, d, M): N = q.N sa = close(q.adjoint(M), M) and close(q.sharp(M), M) pattern = close(q.schur_fast(M, q.J() - q.identity() - d), 0 * M) negedge = close(q.schur_fast(M, d), -d) ev = np.sort(np.linalg.eigvals(np.sqrt(q.G) @ M @ np.sqrt(q.Ginv)).real) neg = int(np.sum(ev < -1e-8)) corank = int(np.sum(np.abs(ev) < 1e-8)) # strong Arnold hypothesis: Y with Y o (1 + d) = 0 and M Y = 0 forces Y = 0 basis = [] for j in range(N * N): Y = np.zeros(N * N, dtype=complex) Y[j] = 1 basis.append(Y.reshape(N, N)) proj = lambda Y: Y - q.schur_fast(Y, q.identity() + d) Ysp = np.array([proj(Y).flatten() for Y in basis]).T u, sv, vh = np.linalg.svd(Ysp, full_matrices=False) Ybasis = u[:, sv > 1e-8] if Ybasis.shape[1] == 0: sah = True else: A = np.array([(M @ Ybasis[:, i].reshape(N, N)).flatten() for i in range(Ybasis.shape[1])]).T sah = np.linalg.matrix_rank(A, tol=1e-8) == Ybasis.shape[1] log(f"{name}: M self-adjoint and real {sa}, pattern {pattern}, M o d = -d {negedge}, " f"negative eigenvalues {neg}, corank {corank}, strong Arnold hypothesis {sah}") for blocks in [[1, 1, 1, 1, 1], [2], [1, 2], [3]]: q = QSpace(blocks) cdv_check(f"simplex over blocks {blocks}, M = -J", q, q.simplex(), -q.J()) q = QSpace([2]) d = ad(q, sx) + ad(q, sz) cdv_check("quantum square, M = -d", q, d, -d) # the quantum square has mu = 2: a matrix of corank 3 with one negative eigenvalue is -c theta_(v,v), # whose Schur rank is rank(v)^2, and this violates (1) for rank(v) = 2, and (2) for rank(v) = 1 def schur_rank(q, A): return sum(np.linalg.matrix_rank(M, tol=1e-9) for M in to_tensor(q, A).values()) ok = True for r in [1, 2]: for t in range(5): v = (rng.normal(size=(2, r)) + 1j * rng.normal(size=(2, r))) @ (rng.normal(size=(r, 2)) + 1j * rng.normal(size=(r, 2))) vv = q.to_vec([v]) M = -np.outer(vv, vv.conj()) @ q.G # -theta_(v,v), x -> - v neg = int(np.sum(np.linalg.eigvals(np.sqrt(q.G) @ M @ np.sqrt(q.Ginv)).real < -1e-9)) rk = schur_rank(q, M) ok &= neg == 1 and rk == r * r if r == 2: ok &= not close(q.schur_fast(M, ad(q, sy)), 0 * M) # (1) fails else: ok &= schur_rank(q, q.schur_fast(M, d)) < schur_rank(q, d) # (2) fails log(f"quantum square: Schur rank of d = {schur_rank(q, d)}, of 1 = {schur_rank(q, np.eye(4))}, of Ad_sy = " f"{schur_rank(q, ad(q, sy))}; the matrices -theta_(v,v) have one negative eigenvalue, Schur rank " f"rank(v)^2, and violate (1) for rank(v) = 2, and (2) for rank(v) = 1: {ok}, so mu = 2") def hom_values(q, d, adj): """hom(F,X) for all drawings, with fixed subscripts and permuted spider tensors""" E = edge_form(q, d) letters = "abcdefghijklmnopqrstuvwxyz" edges = sorted({e for h in adj.values() for e in h}) lab = {e: (letters[2 * i], letters[2 * i + 1]) for i, e in enumerate(edges)} used = {e: 0 for e in edges} vsubs = {} for v in adj: s = "" for e in adj[v]: s += lab[e][used[e]] used[e] += 1 vsubs[v] = s subs = ",".join([vsubs[v] for v in adj] + [lab[e][0] + lab[e][1] for e in edges]) spiders = {k: spider(q, k) for k in {len(h) for h in adj.values()}} ops0 = [spiders[len(adj[v])] for v in adj] + [E] * len(edges) path = np.einsum_path(subs, *ops0, optimize="greedy")[0] vals = {} for rot in all_drawings(adj): ops = [] for v in adj: perm = [rot[v].index(e) for e in adj[v]] # leg of the spider used by each edge of adj[v] ops.append(np.transpose(spiders[len(adj[v])], perm)) val = np.einsum(subs, *(ops + [E] * len(edges)), optimize=path) vals.setdefault(genus(rot), []).append(complex(val)) return ({g: count_distinct(s) for g, s in sorted(vals.items())}, {g: count_distinct([complex(v.real, abs(v.imag)) for v in s]) for g, s in sorted(vals.items())}) def complete(n): adj = {v: [] for v in range(n)} for a, b in itertools.combinations(range(n), 2): adj[a].append(f"{a}{b}") adj[b].append(f"{a}{b}") return adj def k33(): adj = {v: [] for v in range(6)} for a in range(3): for b in range(3, 6): adj[a].append(f"{a}{b}") adj[b].append(f"{a}{b}") return adj for blocks in [[1, 1, 1, 1], [2]]: q = QSpace(blocks) A = random_cp(q, rng) d = A + q.adjoint(A) d = d + q.sharp(d) for name, adj in [("K_4", complete(4)), ("K_3,3", k33()), ("K_5", complete(5))]: vals, pairs = hom_values(q, d, adj) log(f"V with blocks {blocks}, F = {name}: number of distinct complex values of hom(F,X), by genus of the drawing: " f"{vals}, and up to complex conjugation: {pairs}") if blocks == [2]: log(f" drawings of {name} up to relabeling: {drawing_orbits(adj)}, " f"and up to relabeling and reflection: {drawing_orbits(adj, True)}") log.save()