# walks.py # Walk counts 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). # For each generator x we count the words of length k in the generators which represent x, # and we check the formula N_{p-1}(x) = K + [ord(x) = p], where p is the smallest finite # order >= 3 of the generators, and K is the corresponding count on the regular tree. import itertools, sys def generators(orders): S = [] for i, s in enumerate(orders): S.append((i, 1)) if s != 2: S.append((i, -1)) return S def multiply(orders, g, x): # g = normal form, list of (factor, exponent), x = generator (factor, +-1) i, e = x s = orders[i] g = list(g) if g and g[-1][0] == i: f = g[-1][1] + e if s: f %= s g.pop() if f: g.append((i, f)) else: g.append((i, e % s if s else e)) return tuple(g) def element(orders, x): return multiply(orders, (), x) def counts(orders, k): S = generators(orders) N = {x: 0 for x in S} targets = {element(orders, x): x for x in S} for word in itertools.product(S, repeat=k): g = () for x in word: g = multiply(orders, g, x) if g in targets: N[targets[g]] += 1 return N def tree_count(valence, k): # walks of length k between 2 neighbors on the regular tree: a[d] = walks ending at distance d a = {0: 1} for _ in range(k): b = {} for d, c in a.items(): if d == 0: b[1] = b.get(1, 0) + valence * c else: b[d + 1] = b.get(d + 1, 0) + (valence - 1) * c b[d - 1] = b.get(d - 1, 0) + c a = b # walks ending at distance 1, divided by the number of neighbors return a.get(1, 0) // valence def check(orders): S = generators(orders) finite = sorted(set(s for s in orders if s >= 3)) name = ' * '.join('Z' if s == 0 else 'Z_%d' % s for s in orders) if not finite: print(name, ': tree, nothing to check') return True p = finite[0] N = counts(orders, p - 1) K = tree_count(len(S), p - 1) ok = all(N[x] == K + (1 if orders[x[0]] == p else 0) for x in S) print(name, ': p =', p, ', K =', K, ', counts =', sorted(set((orders[x[0]], N[x]) for x in S)), ', formula', 'holds' if ok else 'FAILS') return ok examples = [[2, 3], [2, 2, 3], [0, 3], [3, 3], [3, 4], [2, 4], [4, 4], [2, 0, 4], [3, 5], [2, 5], [0, 5, 5], [2, 3, 4], [2, 2, 0, 3], [3, 3, 4], [5, 6], [2, 6], [3, 0, 0], [2, 3, 5]] good = all([check(o) for o in examples]) print('all checks passed' if good else 'some checks failed')