# blocks.py # Walk counts on the Cayley graphs of the free products of finite groups, not necessarily # cyclic. Each free factor is a permutation group, given by a generating set which is # stable under inverses. With N_g = sum_k N_k(g) z^k being the series counting the walks # from 1 to g, we check, up to the order K: # (1) the series N_s - z(N_1^2 - N_s^2) vanishes precisely when the generator s is a # bridge, that is, when its free factor is Z_2, with its generator; # (2) the series N_{xy} N_1 - N_x N_y vanishes precisely when the generators x,y belong # to different free factors; # (3) the projection onto the span of the pairs of generators belonging to the same free # factor belongs to the algebra generated by the operators D_k x 1, 1 x D_k and T_k, # where D_k = diag(N_k(x)) and T_k(e_x e_y) = N_k(xy) sum_{zt=xy} e_z e_t. import sys import numpy as np from planar import in_generated_algebra def compose(p, q): return tuple(p[i] for i in q) def cycles(n, *cs): p = list(range(n)) for c in cs: for a, b in zip(c, c[1:] + c[:1]): p[a] = b return tuple(p) def times(g, x): i, p = x g = list(g) if g and g[-1][0] == i: r = compose(g[-1][1], p) g.pop() if r != tuple(range(len(r))): g.append((i, r)) else: g.append((i, p)) return tuple(g) def walk_counts(S, K): N = [{(): 1}] for _ in range(K): new = {} for g, c in N[-1].items(): for x in S: h = times(g, x) new[h] = new.get(h, 0) + c N.append(new) return N def series(N, g, K): return [N[k].get(g, 0) for k in range(K + 1)] def mul(a, b, K): c = [0] * (K + 1) for i, x in enumerate(a): if x: for j, y in enumerate(b): if i + j > K: break c[i + j] += x * y return c def check(name, factors, K): S = [(i, p) for i, gens in enumerate(factors) for p in gens] for (i, p) in S: assert any(compose(p, q) == tuple(range(len(p))) for q in factors[i]), 'generating set not stable under inverses' n = len(S) N = walk_counts(S, K) el = [times((), x) for x in S] N1 = series(N, (), K) ok1 = ok2 = True for x, g in zip(S, el): Ns = series(N, g, K) d = [a - b for a, b in zip(mul(N1, N1, K), mul(Ns, Ns, K))] r = [Ns[k] - (d[k - 1] if k else 0) for k in range(K + 1)] bridge = len(factors[x[0]]) == 1 ok1 = ok1 and (not any(r) if bridge else (min(r) >= 0 and any(r))) prod = {} for a in range(n): for b in range(n): gh = times(el[a], S[b]) prod[(a, b)] = gh r = [u - v for u, v in zip(mul(series(N, gh, K), N1, K), mul(series(N, el[a], K), series(N, el[b], K), K))] ok2 = ok2 and (any(r) if S[a][0] == S[b][0] else not any(r)) ops = [] for k in range(1, K + 1): D = np.diag([float(N[k].get(g, 0)) for g in el]) T = np.zeros((n * n, n * n)) for a in range(n): for b in range(n): for c in range(n): for d in range(n): if prod[(c, d)] == prod[(a, b)]: T[c * n + d, a * n + b] = N[k].get(prod[(a, b)], 0) ops += [np.kron(D, np.eye(n)), np.kron(np.eye(n), D), T] P = np.zeros((n * n, n * n)) for a in range(n): for b in range(n): if S[a][0] == S[b][0]: P[a * n + b, a * n + b] = 1 ok3 = in_generated_algebra(ops, P)[0] print(name, ': order', K, ': bridges', ok1, ', pairs of generators', ok2, ', projection in the algebra', ok3) sys.stdout.flush() return ok1 and ok2 and ok3 a, b = cycles(4, (0, 1), (2, 3)), cycles(4, (0, 2), (1, 3)) Z2 = [cycles(2, (0, 1))] Z3 = [cycles(3, (0, 1, 2)), cycles(3, (0, 2, 1))] Z4 = [cycles(4, (0, 1, 2, 3)), cycles(4, (0, 3, 2, 1))] KLEIN = [a, b] # the square KLEIN3 = [a, b, compose(a, b)] # the tetrahedron S3A = [cycles(3, (0, 1)), cycles(3, (1, 2))] # the hexagon S3B = [cycles(3, (0, 1)), cycles(3, (1, 2)), cycles(3, (0, 2))] # the graph K_33 S3C = [cycles(3, (0, 1)), cycles(3, (0, 1, 2)), cycles(3, (0, 2, 1))] # the prism i4, j4 = cycles(8, (0, 1, 2, 3), (4, 5, 6, 7)), cycles(8, (0, 4, 2, 6), (1, 7, 3, 5)) Q8 = [i4, compose(i4, compose(i4, i4)), j4, compose(j4, compose(j4, j4))] # the quaternion group if __name__ == '__main__': tests = [('Klein * Klein', [KLEIN, KLEIN], 7), ('Z_4 * Klein', [Z4, KLEIN], 7), ('Klein(3 generators) * Z_3', [KLEIN3, Z3], 7), ('S_3(hexagon) * S_3(hexagon)', [S3A, S3A], 8), ('S_3(K_33) * Z_2', [S3B, Z2], 7), ('S_3(prism) * S_3(prism)', [S3C, S3C], 6), ('S_3(K_33) * S_3(prism)', [S3B, S3C], 6), ('Q_8 * Z_2', [Q8, Z2], 6), ('Klein * Klein * Klein', [KLEIN, KLEIN, KLEIN], 6)] good = all([check(*t) for t in tests]) print('all checks passed' if good else 'some checks failed')