#!/usr/bin/env python3 """Exact finite checks for the finite higher-recognition examples. Python standard library only. No random choices or floating-point arithmetic. Run: python3 verify_higher_examples.py > higher_examples_results.json """ from itertools import combinations, product from math import comb import json def normalized_tuples(group_order, degree): return list(product(range(1, group_order), repeat=degree)) def evaluate(cochain, args): if 0 in args: return 0 return cochain.get(tuple(args), 0) def differential(group_order, cochain, args): """Trivial F_2 coefficients on an additively written cyclic group.""" value = evaluate(cochain, args[1:]) ^ evaluate(cochain, args[:-1]) for i in range(len(args)-1): merged = args[:i] + ((args[i] + args[i+1]) % group_order,) + args[i+2:] value ^= evaluate(cochain, merged) return value def c2_cocycle_check(): k = {(1, 1, 1): 1} assert all(differential(2, k, q) == 0 for q in product(range(2), repeat=4)) coboundaries = set() for bit in range(2): c = {(1, 1): bit} coboundaries.add(tuple(differential(2, c, q) for q in normalized_tuples(2, 3))) assert coboundaries == {(0,)} assert tuple(evaluate(k, q) for q in normalized_tuples(2, 3)) not in coboundaries return { 'group': 'C2', 'coefficient_module': 'C2 with trivial action', 'normalized_3_cocycle_nonzero_value': [1, 1, 1], 'all_4_tuple_cocycle_conditions_hold': True, 'normalized_2_cochain_count': 2, 'distinct_3_coboundaries': [list(x) for x in sorted(coboundaries)], 'nontrivial_H3_class': True, } def crossed_module_check(): boundary = lambda u: 2*u % 4 action = lambda t, u: ((-1)**t * u) % 4 for t, u in product(range(4), repeat=2): assert boundary(action(t, u)) == boundary(u) for u, v in product(range(4), repeat=2): assert action(boundary(u), v) == v kernel = [u for u in range(4) if boundary(u) == 0] assert kernel == [0, 2] assert all(action(t, u) == u for t in range(4) for u in kernel) a = lambda g, h: g*h values = [] for g, h, ell in product(range(2), repeat=3): kappa = (action(g, a(h, ell)) + a(g, (h+ell) % 2) - a((g+h) % 2, ell) - a(g, h)) % 4 assert kappa == 2*g*h*ell if kappa: values.append({'triple': [g, h, ell], 'kernel_element': kappa}) return { 'source_group': 'C4', 'target_group': 'C4', 'boundary_values': [boundary(u) for u in range(4)], 'kernel': kernel, 'cokernel_order': 2, 'kernel_action_is_trivial': True, 'crossed_module_axioms_hold': True, 'nonzero_associativity_cocycle_values': values, } def pentagon_failure_check(): b = {(1, 1, 1): 1} failed = [list(q) for q in product(range(3), repeat=4) if differential(3, b, q)] assert [1, 1, 1, 2] in failed return { 'group': 'C3', 'coefficient_module': 'C2 with trivial action', 'only_nonzero_associator': [1, 1, 1], 'failed_pentagon_inputs': failed, } def em_simplices_check(): """K(C2,2)_q = normalized 2-cocycles on the simplex Delta[q].""" rows = [] for q in range(5): triangles = list(combinations(range(q+1), 3)) tetrahedra = list(combinations(range(q+1), 4)) count = 0 for bits in product(range(2), repeat=len(triangles)): values = dict(zip(triangles, bits)) if all(sum(values[face] for face in combinations(tetra, 3)) % 2 == 0 for tetra in tetrahedra): count += 1 expected = 2**comb(q, 2) assert count == expected rows.append({'simplicial_degree': q, 'simplex_count': count, 'predicted_2_power_binomial_q_2': expected}) return rows def totalization_sharpness_check(max_degree=8): """Check the normalized C2 bar complexes over F3 in a finite range. For the target K(F3,r), the generator acts by epsilon=(-1)^(r+1). Every normalized cochain group is F3. The differentials alternate between epsilon-1 and 1+epsilon. The paper proves the formula and the cutoff assertion for arbitrary r; this routine verifies r=0,...,8. """ field = set(range(3)) rows = [] for r in range(max_degree+1): epsilon = 2 if r % 2 == 0 else 1 def delta(degree): return (epsilon-1 if degree % 2 == 0 else 1+epsilon) % 3 # The differential squares to zero throughout the inspected range. assert all(delta(q+1)*delta(q) % 3 == 0 for q in range(r+1)) previous = delta(r-1) if r else None current = delta(r) if r: assert previous == 0 assert current in (1, 2) inverse = next(a for a in field if a*current % 3 == 1) image_previous = {previous*a % 3 for a in field} if r else {0} full_kernel = {a for a in field if current*a % 3 == 0} truncated_kernel = field assert image_previous <= full_kernel truncated_order = len(truncated_kernel) // len(image_previous) full_order = len(full_kernel) // len(image_previous) assert truncated_order == 3 assert full_order == 1 rows.append({ 'target_truncation_r': r, 'epsilon_mod_3': epsilon, 'delta_r_minus_1_mod_3': previous, 'delta_r_mod_3': current, 'inverse_delta_r_mod_3': inverse, 'truncated_H_r_order': truncated_order, 'full_H_r_order': full_order, 'truncated_pi_0_component_count': truncated_order, 'full_pi_0_component_count': full_order, }) return { 'group': 'C2', 'coefficient_module': 'F3 with generator acting by (-1)^(r+1)', 'verified_r_min': 0, 'verified_r_max': max_degree, 'normalized_cochain_group_order_in_each_degree': 3, 'meaning_of_group_order_1': 'The zero cohomology group.', 'rows': rows, } if __name__ == '__main__': output = { 'method': 'Exact exhaustive enumeration; Python standard library.', 'c2_nonzero_k_invariant': c2_cocycle_check(), 'finite_crossed_module': crossed_module_check(), 'pentagon_failure': pentagon_failure_check(), 'K_C2_2_finite_simplicial_levels': em_simplices_check(), 'finite_totalization_sharpness': totalization_sharpness_check(), } print(json.dumps(output, indent=2, sort_keys=True))