# bridges.py # Walk series on the Cayley graphs of the free products of cyclic groups # Gamma = Z_{s_1} * ... * Z_{s_r}, with s_i in {2,3,...} or 0 (meaning infinite order). # With N_g = sum_k N_k(g) z^k being the series counting the walks from 1 to g, we check: # (1) the series N_s - z(N_1^2 - N_s^2) vanishes when the generator s is a bridge (order 2 # or infinite), and has coefficients >= 0, not all zero, otherwise; # (2) the series N_{xy} N_1 - N_x N_y vanishes when x,y are generators belonging to # different free factors, and does not vanish when x,y belong to the same free factor # of finite order >= 3. # All the series are computed up to the order K. import sys from planar import generators, times, product, walk_counts 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(orders, K): S = generators(orders) el = [times(orders, (), x) for x in S] N = walk_counts(orders, K) N1 = series(N, (), K) ok = 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 = orders[x[0]] in (0, 2) if bridge: ok = ok and not any(r) else: ok = ok and min(r) >= 0 and any(r) for x, g in zip(S, el): for y, h in zip(S, el): gh = product(orders, g, h) if gh == (): continue r = [a - b for a, b in zip(mul(series(N, gh, K), N1, K), mul(series(N, g, K), series(N, h, K), K))] if x[0] != y[0]: ok = ok and not any(r) elif orders[x[0]] >= 3: ok = ok and any(r) name = ' * '.join('Z' if s == 0 else 'Z_%d' % s for s in orders) print(name, ': order', K, ':', 'both properties hold' if ok else 'FAILURE') sys.stdout.flush() return ok if __name__ == '__main__': tests = [([2, 3], 9), ([0, 3], 8), ([2, 0, 4], 7), ([3, 3], 9), ([4, 4], 8), ([2, 2, 5], 8), ([0, 0], 8), ([3, 4, 5], 7), ([2, 6], 9), ([0, 2, 3, 3], 6)] good = all([check(o, K) for o, K in tests]) print('all checks passed' if good else 'some checks failed')