""" colorings.py -- checks the quantum Hoffman bounds of section 9. For regular positively weighted undirected quantum graphs with a given coloring p_1,...,p_c, it builds the compressed matrix C = S^* d S, with S the isometry given by the vectors p_i/sqrt(psi(p_i)), and checks that C has zero diagonal and the eigenvalue k, so that c >= 1 - k/lambda_min. It also checks the ratio bound psi(p) <= N(-lambda_min)/(k - lambda_min) for independent projections p. Examples: the quantum square, the complete bipartite quantum graphs K_{V,V}, random bipartite regular graphs over M_4, the quantum complete multipartite Weyl-Cayley graphs over M_3, M_4, and the simplex. For the quantum torus over M_3, it checks that the 3 spectral projections of U Lambda form a coloring, so that chi = alpha = 3. For random non-regular graphs over M_3, M_4, M_5 with a prescribed coloring, it checks the pinching identity sum_m U^m d U^-m = 0, with U = sum_j exp(2 pi i j/c) L_(p_j), and the non-regular Hoffman bound c >= 1 - lambda_max/lambda_min. Finally, it checks that the 2 sizes of a projection, psi(p) and dim(pC(V)p), differ by the sum of r(n - r) over the blocks, with r the rank of p in a block of size n, so they agree precisely for the central projections. Results are written to colorings.log. """ import numpy as np from qspace import QSpace, Logger, close, weyl, ad log = Logger("colorings.log") rng = np.random.default_rng(10) def haar(n): z = rng.normal(size=(n, n)) + 1j * rng.normal(size=(n, n)) Q, R = np.linalg.qr(z) return Q * (np.diag(R) / abs(np.diag(R))) def independent(q, d, p): P = q.matrix_of(lambda x: [pr @ xr @ pr for pr, xr in zip(q.to_blocks(p), x)]) return close(P @ d @ P, 0 * d) def hoffman(name, q, d, colors): k = (d @ q.one())[0].real ev = np.sort(np.linalg.eigvals(d).real) lmin = ev[0] W = np.array([np.sqrt(q.G) @ p / np.sqrt(q.psi(p).real) for p in colors]).T # orthonormal coordinates Dn = np.sqrt(q.G) @ d @ np.sqrt(q.Ginv) C = W.conj().T @ Dn @ W c = len(colors) ok_colors = all(independent(q, d, p) for p in colors) and close(sum(colors), q.one()) bound = 1 - k / lmin alpha = max(q.psi(p).real for p in colors) ratio = q.N * (-lmin) / (k - lmin) log(f"{name}: regular {close(d @ q.one(), k * q.one())}, k = {k:.3f}, lambda_min = {lmin:.3f}, coloring with " f"{c} independent projections {ok_colors}, C has zero diagonal {np.allclose(np.diag(C), 0)} and eigenvalue k " f"{np.any(np.isclose(np.linalg.eigvals(C), k))}, Hoffman bound {bound:.3f} <= {c}, " f"ratio bound {alpha:.3f} <= {ratio:.3f}") q = QSpace([2]) d = ad(q, weyl(2, (1, 0))) + ad(q, weyl(2, (0, 1))) sy = np.array([[0, -1j], [1j, 0]]) hoffman("quantum square", q, d, [q.to_vec([(np.eye(2) + sy) / 2]), q.to_vec([(np.eye(2) - sy) / 2])]) for blocks in [[2], [1, 1, 2]]: q = QSpace(blocks + blocks) r0 = len(blocks) def f(x): pv = sum(q.blocks[r] * np.trace(x[r]) for r in range(r0)) pw = sum(q.blocks[r] * np.trace(x[r]) for r in range(r0, len(q.blocks))) return [(pw if r < r0 else pv) * np.eye(n) for r, n in enumerate(q.blocks)] d = q.matrix_of(f) pV = q.to_vec([np.eye(n) if r < r0 else 0 * np.eye(n) for r, n in enumerate(q.blocks)]) hoffman(f"K_V,V with V blocks {blocks}", q, d, [pV, q.one() - pV]) for t in range(3): n, h = 4, 2 q = QSpace([n]) V = haar(n) s = V @ np.diag([1, 1, -1, -1]) @ V.conj().T d = 0 for k in range(2): Wk = V @ np.block([[np.zeros((h, h)), haar(h)], [haar(h), np.zeros((h, h))]]) @ V.conj().T d = d + ad(q, Wk) + ad(q, Wk.conj().T) p = q.to_vec([(np.eye(n) + s) / 2]) hoffman(f"random bipartite regular graph over M_4, sample {t + 1}", q, d, [p, q.one() - p]) for n in [3, 4]: q = QSpace([n]) S = [(a, b) for a in range(1, n) for b in range(n)] d = sum(ad(q, weyl(n, g)) for g in S) E = q.matrix_of(lambda x: [np.diag(np.diag(x[0]))]) colors = [q.to_vec([np.diag(np.eye(n)[a])]) for a in range(n)] hoffman(f"Weyl-Cayley graph over M_{n} with S = (g_1 != 0), d = J - nE {close(d, q.J() - n * E)}", q, d, colors) q = QSpace([1, 1, 1, 1, 1]) d = q.simplex() colors = [np.eye(5)[i].astype(complex) for i in range(5)] hoffman("simplex over 5 points", q, d, colors) q = QSpace([2]) ev = np.sort(np.linalg.eigvals(q.simplex()).real) log(f"simplex over M_2: ratio bound N(-lambda_min)/(k - lambda_min) = {q.N * (-ev[0]) / (3 - ev[0]):.3f}, " f"and there are no nonzero independent projections, as M_2 has no blocks of size 1") # the quantum torus over M_3: the spectral projections of W = U Lambda form a coloring q = QSpace([3]) U3, L3 = weyl(3, (1, 0)), weyl(3, (0, 1)) dT = sum(ad(q, weyl(3, g)) for g in [(1, 0), (2, 0), (0, 1), (0, 2)]) _, vW = np.linalg.eig(U3 @ L3) ps = [np.outer(vW[:, j], vW[:, j].conj()) / np.vdot(vW[:, j], vW[:, j]) for j in range(3)] indep = all(close(P @ dT @ P, 0 * dT) for P in [q.matrix_of(lambda x, p=p: [p @ x[0] @ p]) for p in ps]) kill = all(close(p @ X @ p, 0 * p) for p in ps for X in [U3, U3.conj().T, L3, L3.conj().T]) ev = np.sort(np.linalg.eigvalsh(dT)) log(f"quantum torus over M_3: p U^(+-1) p = p Lambda^(+-1) p = 0 for the spectral projections p of U Lambda {kill}, " f"they are independent {indep}, sum up to 1 {close(sum(ps), np.eye(3))}, psi(p) = " f"{[float(round(3 * np.trace(p).real, 6)) for p in ps]}, Hoffman bounds chi >= {1 - ev[-1] / ev[0]:.0f}, " f"alpha <= {q.N * (-ev[0]) / (ev[-1] - ev[0]):.0f}, so chi = alpha = 3") # non-regular graphs with a prescribed coloring: Kraus operators with p_j K p_j = 0 for n, sizes in [(3, [1, 1, 1]), (4, [2, 1, 1]), (5, [2, 2, 1]), (4, [2, 2])]: q = QSpace([n]) V = haar(n) starts = np.cumsum([0] + sizes) ps = [V @ np.diag([1.0 if starts[j] <= a < starts[j + 1] else 0 for a in range(n)]) @ V.conj().T for j in range(len(sizes))] c = len(sizes) d = 0 for k in range(3): Z = rng.normal(size=(n, n)) + 1j * rng.normal(size=(n, n)) Z = V.conj().T @ Z @ V for j in range(c): Z[starts[j]:starts[j + 1], starts[j]:starts[j + 1]] = 0 Z = V @ Z @ V.conj().T d = d + ad(q, Z) + ad(q, Z.conj().T) regular = close(d @ q.one(), (d @ q.one())[0] * q.one()) Qs = [q.matrix_of(lambda x, p=p: [p @ x[0]]) for p in ps] indep = all(close(Q @ d @ Q, 0 * d) for Q in Qs) Uc = sum(np.exp(2j * np.pi * j / c) * Q for j, Q in enumerate(Qs)) pinch = close(sum(np.linalg.matrix_power(Uc, m) @ d @ np.linalg.matrix_power(Uc.conj().T, m) for m in range(c)), 0 * d) ev = np.sort(np.linalg.eigvalsh((d + d.conj().T) / 2)) log(f"non-regular graph over M_{n} with a coloring by {c} projections of ranks {sizes}: regular {regular}, " f"Q_j d Q_j = 0 {indep}, pinching sum = 0 {pinch}, Hoffman bound 1 - lambda_max/lambda_min = " f"{1 - ev[-1] / ev[0]:.3f} <= {c} {1 - ev[-1] / ev[0] <= c + 1e-9}") # sizes of projections: psi(p) versus dim(pC(V)p), differing by sum r(n - r) over the blocks rng_s = np.random.default_rng(21) ok_diff, ok_central = True, True for blocks in [[1, 2, 3], [2, 2], [4]]: q = QSpace(blocks) for t in range(20): ranks = [int(rng_s.integers(0, n + 1)) for n in blocks] p = [] for n, r in zip(blocks, ranks): Z = rng_s.normal(size=(n, max(r, 1))) + 1j * rng_s.normal(size=(n, max(r, 1))) Qm, _ = np.linalg.qr(Z) p.append(Qm[:, :r] @ Qm[:, :r].conj().T) pv = q.to_vec(p) size_psi = q.psi(pv).real corner = np.array([q.product(q.product(pv, x), pv) for x in np.eye(q.N)]) size_dim = np.linalg.matrix_rank(corner, tol=1e-8) ok_diff &= np.isclose(size_psi - size_dim, sum(r * (n - r) for n, r in zip(blocks, ranks))) central = all(r in (0, n) for n, r in zip(blocks, ranks)) ok_central &= (np.isclose(size_psi, size_dim) == central) log(f"sizes of projections: psi(p) - dim(pC(V)p) = sum_blocks r(n - r) {ok_diff}, equality precisely for " f"the central projections {ok_central}") log.save()