#!/usr/bin/env python3 """Independent finite checks of the four-point charge classification. Only the Python standard library is required. The supplied file four_point_skeletons.json provides the 115 explicitly enumerated labelled ribbon cells. For every cell this script enumerates positive edge multiplicities directly; it does not use the closed-form multiplicity solutions in the manuscript. The geometric rank theorem is an input: P and C are the rank-one types. The script verifies its stated combinatorial consequences, not the analytic proof of that theorem. Equal-charge polynomials are checked against the actual enumerated multiplicity assignments. Their general identities and the sharp bound are also evaluated using exact rational arithmetic for a selection of positive parameters. Run from any directory: python check_charge_classification.py Defaults: total operator degree <= 28, hence <= 14 propagators; output is charge_classification_checks.json next to this script. """ import argparse import itertools import json from collections import Counter, defaultdict from fractions import Fraction from pathlib import Path def positive_compositions(total, parts): """All ordered positive integer compositions, by a direct recursion.""" if parts == 1: if total >= 1: yield (total,) return for first in range(1, total - parts + 2): for tail in positive_compositions(total - first, parts - 1): yield (first,) + tail def cell_edges(cell): """Retain each nonhomotopic parallel edge as a separate edge instance.""" answer = [] for i, j, copies in cell["adjacency"]: answer.extend([(i - 1, j - 1)] * copies) assert len(answer) == cell["edge_count"] degrees = [0] * 4 for i, j in answer: assert i != j degrees[i] += 1 degrees[j] += 1 assert degrees == cell["degrees"] assert cell["automorphism_order"] == 1 assert all(d >= 3 for d in cell["face_degrees"]) assert 4 - len(answer) + len(cell["face_degrees"]) == 2 return answer def charge_of(edges, multiplicities): degrees = [0] * 4 for (i, j), multiplicity in zip(edges, multiplicities): degrees[i] += multiplicity degrees[j] += multiplicity return tuple(degrees) def channel_exponents(edges, multiplicities): """Recover A^a B^b C^c from an equal-charge Wick monomial.""" pairs = Counter() for pair, multiplicity in zip(edges, multiplicities): pairs[pair] += multiplicity assert pairs[(0, 1)] == pairs[(2, 3)] assert pairs[(0, 2)] == pairs[(1, 3)] assert pairs[(0, 3)] == pairs[(1, 2)] return (pairs[(0, 1)], pairs[(0, 2)], pairs[(0, 3)]) def has_balance(degrees): j0, j1, j2, j3 = degrees return (j0 + j1 == j2 + j3 or j0 + j2 == j1 + j3 or j0 + j3 == j1 + j2) def complete_homogeneous(degree, variables): """Compute h_degree by its independent ascending recurrence.""" if degree < 0: return Fraction(0) coefficients = [Fraction(1)] + [Fraction(0)] * degree for variable in variables: for exponent in range(1, degree + 1): coefficients[exponent] += variable * coefficients[exponent - 1] return coefficients[degree] def interior_sum(k, parameters): a, b, c = parameters return sum((a ** i * b ** j * c ** (k - i - j) for i in range(1, k - 1) for j in range(1, k - i)), Fraction(0)) def singular_sum(k, parameters): return sum((parameters[i] ** r * parameters[j] ** (k - r) for i, j in itertools.combinations(range(3), 2) for r in range(1, k)), Fraction(0)) def evaluate_counter(counter, parameters): return sum((coefficient * parameters[0] ** exponents[0] * parameters[1] ** exponents[1] * parameters[2] ** exponents[2] for exponents, coefficient in counter.items()), Fraction(0)) def verify(max_degree, skeleton_file): with skeleton_file.open(encoding="utf-8") as stream: data = json.load(stream) cells = data["cells"] totals = Counter(cell["edge_count"] for cell in cells) assert len(cells) == 115 assert totals == {3: 20, 4: 51, 5: 36, 6: 8} observed = defaultdict(Counter) equal_charge = defaultdict(lambda: {"ac": Counter(), "singular": Counter()}) assignments = 0 for cell in cells: edges = cell_edges(cell) rank_kind = "singular" if cell["type"] in {"P", "C"} else "ac" for total_edges in range(len(edges), max_degree // 2 + 1): for multiplicities in positive_compositions(total_edges, len(edges)): degrees = charge_of(edges, multiplicities) observed[degrees][cell["type"]] += 1 assignments += 1 if len(set(degrees)) == 1: k = degrees[0] # This is checked from the full list, not imposed as a filter. assert cell["type"] in {"K", "C"}, (degrees, cell["type"]) exponents = channel_exponents(edges, multiplicities) assert sum(exponents) == k equal_charge[k][rank_kind][exponents] += 1 classifications = Counter() charge_checks = 0 for total_degree in range(4, max_degree + 1): for degrees in positive_compositions(total_degree, 4): types = observed[degrees] actual_nonzero = bool(types) actual_singular = any(types[name] for name in ("P", "C")) actual_ac = any(number for name, number in types.items() if name not in {"P", "C"}) expected_nonzero = (total_degree % 2 == 0 and total_degree >= 6 and 2 * max(degrees) <= total_degree) expected_singular = expected_nonzero and has_balance(degrees) exceptional = tuple(sorted(degrees)) in {(1, 1, 2, 2), (2, 2, 2, 2)} expected_ac = expected_nonzero and not exceptional actual = (actual_nonzero, actual_ac, actual_singular) expected = (expected_nonzero, expected_ac, expected_singular) assert actual == expected, (degrees, dict(types), actual, expected) sorted_degrees = sorted(degrees) assert has_balance(degrees) == ( sorted_degrees[0] + sorted_degrees[3] == sorted_degrees[1] + sorted_degrees[2]) category = ("zero" if not actual_nonzero else "mixed" if actual_ac and actual_singular else "purely_ac" if actual_ac else "purely_singular") classifications[category] += 1 charge_checks += 1 coefficient_checks = [] for k in range(2, max_degree // 4 + 1): ac = Counter() singular = Counter() for exponents in positive_compositions(k, 3): ac[exponents] = 2 # The two oriented tetrahedral cells. for i, j in itertools.combinations(range(3), 2): for exponent in range(1, k): powers = [0, 0, 0] powers[i], powers[j] = exponent, k - exponent singular[tuple(powers)] += 1 assert equal_charge[k]["ac"] == ac, (k, "ac") assert equal_charge[k]["singular"] == singular, (k, "singular") coefficient_checks.append({ "k": k, "ac_weighted_cells": sum(ac.values()), "singular_weighted_cells": sum(singular.values()), "normalization_per_weighted_cell": k * k, "coefficient_identity": "verified exactly from all 115 cells", }) parameter_strings = [ ("1", "1", "1"), ("2", "2", "2"), ("1", "2", "3"), ("3", "1", "2"), ("1/2", "1/2", "2"), ("1/8", "2", "8"), ("1/1000", "1", "1000"), ("1", "1", "10"), ("1", "10", "10"), ("17/13", "5/7", "11/3"), ] polynomial_records = [] enumerated_mass_evaluations = 0 for strings in parameter_strings: parameters = tuple(Fraction(value) for value in strings) for k in range(2, 21): interior = interior_sum(k, parameters) singular = singular_sum(k, parameters) ac_mass = 2 * k * k * interior singular_mass = k * k * singular total_mass = ac_mass + singular_mass factored_interior = (parameters[0] * parameters[1] * parameters[2] * complete_homogeneous(k - 3, parameters)) total_from_h = k * k * ( 2 * complete_homogeneous(k, parameters) - sum((complete_homogeneous(k, (parameters[i], parameters[j])) for i, j in itertools.combinations(range(3), 2)), Fraction(0))) assert interior == factored_interior assert total_mass == total_from_h if k in equal_charge: direct_ac = k * k * evaluate_counter(equal_charge[k]["ac"], parameters) direct_singular = k * k * evaluate_counter(equal_charge[k]["singular"], parameters) assert direct_ac == ac_mass assert direct_singular == singular_mass enumerated_mass_evaluations += 2 fraction = singular_mass / total_mass lower_bound = Fraction(3, k + 1) assert fraction >= lower_bound expected_equality = k == 2 or len(set(parameters)) == 1 assert (fraction == lower_bound) == expected_equality polynomial_records.append({ "A_B_C": list(strings), "k": k, "singular_fraction": float(fraction), "sharp_lower_bound": float(lower_bound), "gap": float(fraction - lower_bound), "equality": fraction == lower_bound, "arithmetic": "exact rational; decimals are display values only", }) return { "status": "all checks passed", "scope": ( "Finite combinatorial checks of analytically proved results; " "the geometric rank assignment P,C -> rank one is an input." ), "skeleton_source": skeleton_file.name, "skeleton_cells": len(cells), "skeleton_counts_by_edges": dict(sorted(totals.items())), "maximum_total_operator_degree": max_degree, "maximum_total_propagators": max_degree // 2, "positive_multiplicity_assignments_enumerated": assignments, "ordered_charge_vectors_checked_including_odd_totals": charge_checks, "charge_categories": dict(sorted(classifications.items())), "mismatches": 0, "equal_charge_coefficient_checks": coefficient_checks, "direct_enumerated_mass_evaluations": enumerated_mass_evaluations, "exact_rational_polynomial_and_bound_cases": len(polynomial_records), "polynomial_test_k_range": [2, 20], "positive_parameter_triples": [list(values) for values in parameter_strings], "polynomial_and_bound_records": polynomial_records, } def main(): directory = Path(__file__).resolve().parent parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--max-total-degree", type=int, default=28) parser.add_argument("--skeletons", type=Path, default=directory / "four_point_skeletons.json") parser.add_argument("--output", type=Path, default=directory / "charge_classification_checks.json") args = parser.parse_args() if args.max_total_degree < 8: parser.error("--max-total-degree must be at least 8") result = verify(args.max_total_degree, args.skeletons) with args.output.open("w", encoding="utf-8") as stream: json.dump(result, stream, ensure_ascii=False, indent=2) stream.write("\n") print(json.dumps({ key: result[key] for key in ( "status", "skeleton_cells", "maximum_total_operator_degree", "positive_multiplicity_assignments_enumerated", "ordered_charge_vectors_checked_including_odd_totals", "charge_categories", "direct_enumerated_mass_evaluations", "exact_rational_polynomial_and_bound_cases", "mismatches") }, indent=2)) print("Output: " + str(args.output)) if __name__ == "__main__": main()