# Copyright 2026 Alessio Mattoccia # SPDX-License-Identifier: Apache-2.0 """Replay the public Particle Theory certificates using the Python standard library.""" from fractions import Fraction from hashlib import sha256 from itertools import combinations_with_replacement, permutations import json from math import gcd from pathlib import Path EMBEDDED_RESULTS = r"""{ "schema": 1, "laboratory": "Particle Theory", "pilot": { "id": "PT-001", "fermions": 5, "absolute_charge_limit": 9, "multisets": 26334, "oriented_assignments": [ [ -9, -5, -1, 7, 8 ], [ -8, -7, 1, 5, 9 ] ], "classes_up_to_global_sign": 1 }, "models": { "PT-002": { "charges": [ -9, -5, -1, 7, 8 ], "scalar_charges": [ 1, 2 ], "witness": [ [ 0, 0, 0, 0, 1 ], [ 0, 0, 0, 1, 0 ], [ 0, 0, 1, 0, 0 ], [ 0, 1, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ], "witness_determinant": 1, "generic_rank": 5, "symbolic_matrix": [ [ "0", "0", "0", "a", "b" ], [ "0", "0", "0", "c", "0" ], [ "0", "0", "d", "0", "0" ], [ "a", "c", "0", "0", "0" ], [ "b", "0", "0", "0", "0" ] ], "minimum_scalar_count": 2 }, "PT-006": { "charges": [ -9, -5, -1, 7, 8 ], "scalar_charges": [ 3, 6 ], "witness": [ [ 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 1 ], [ 0, 0, 0, 1, 0 ], [ 0, 0, 1, 0, 0 ], [ 0, 1, 0, 0, 0 ] ], "witness_determinant": 0, "generic_rank": 4, "signed_scalar_labels": [ 6, 3, 3, -6, -6 ] }, "PT-012": { "charges": [ -7, -6, -3, 1, 1, 2, 4, 8 ], "scalar_charges": [ 5 ], "witness": [ [ 0, 0, 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0, 1, 0 ], [ 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0, 0, 0 ] ], "witness_determinant": 1, "generic_rank": 8, "pair_difference_squares": { "5": 130, "-5": 130 } } }, "fixed_points_example": { "charges": [ -1, 1 ], "scalar_charges": [ 2 ], "witness": [ [ 1, 0 ], [ 0, 1 ] ], "witness_determinant": 1, "generic_rank": 2 } } """ RESULTS_SHA256 = "545687bbe2cb20eb62a3786e259c3af0651c5620c2c0136f5c57f5442c764f5a" def require(condition, message): if not condition: raise ValueError(message) def strictly_chiral(charges): return all(q and -q not in charges for q in charges) and gcd(*charges) == 1 def anomalies(charges): return sum(charges), sum(q**3 for q in charges) def allowed(charges, scalars): return [[abs(a + b) in scalars for b in charges] for a in charges] def rank_and_determinant(entries): rows = [[Fraction(value) for value in row] for row in entries] size = len(rows) rank, determinant = 0, Fraction(1) for column in range(size): pivot = next((i for i in range(rank, size) if rows[i][column]), None) if pivot is None: continue if pivot != rank: rows[pivot], rows[rank] = rows[rank], rows[pivot] determinant = -determinant value = rows[rank][column] determinant *= value for i in range(rank + 1, size): factor = rows[i][column] / value rows[i] = [a - factor * b for a, b in zip(rows[i], rows[rank])] rank += 1 return rank, determinant if rank == size else Fraction(0) def permutations_on(support): for columns in permutations(range(len(support))): if all(support[i][j] for i, j in enumerate(columns)): yield columns def verify_pilot(pilot): limit = pilot["absolute_charge_limit"] domain = [q for q in range(-limit, limit + 1) if q] count, assignments = 0, [] for charges in combinations_with_replacement(domain, pilot["fermions"]): count += 1 if anomalies(charges) == (0, 0) and strictly_chiral(charges): assignments.append(list(charges)) canonical = {min(tuple(q), tuple(-x for x in reversed(q))) for q in assignments} require(count == pilot["multisets"] == 26334, "PT-001 count") require(assignments == pilot["oriented_assignments"], "PT-001 oriented assignments") require(len(assignments) == 2 and len(canonical) == pilot["classes_up_to_global_sign"] == 1, "PT-001 classes") return assignments def verify_model(model, rank, determinant, chiral=True): charges = model["charges"] entries = model["witness"] support = allowed(charges, model["scalar_charges"]) require(anomalies(charges) == (0, 0), "Local anomaly conditions") require(strictly_chiral(charges) == chiral, "Chirality and primitive normalization") require(len(entries) == len(charges) and all(len(row) == len(charges) for row in entries), "Matrix shape") require(all(entries[i][j] == entries[j][i] and (not entries[i][j] or support[i][j]) for i, row in enumerate(entries) for j in range(len(row))), "Symmetric, allowed mass entries") require(rank_and_determinant(entries) == (rank, determinant), "Independent exact matrix elimination") require((model["generic_rank"], model["witness_determinant"]) == (rank, determinant), "Published certificate") return support def verify_two_scalar(model, assignments): q = model["charges"] support = verify_model(model, 5, 1) require(q in assignments and model["scalar_charges"] == [1, 2], "PT-002 charges") single_scalars = {abs(a + b) for a in q for b in q} require(len(single_scalars) == 10 and 0 not in single_scalars, "PT-002 possible scalar charges") require(all(next(permutations_on(allowed(q, [h])), None) is None for h in single_scalars), "PT-002 one-scalar supports are singular") require(model["minimum_scalar_count"] == 2, "PT-002 minimum") symbolic = model["symbolic_matrix"] require(all((symbolic[i][j] != "0") == flag and symbolic[i][j] == symbolic[j][i] for i, row in enumerate(support) for j, flag in enumerate(row)), "PT-002 symbolic support") columns, = permutations_on(support) factors = sorted(symbolic[i][j] for i, j in enumerate(columns)) inversions = sum(a > b for i, a in enumerate(columns) for b in columns[i + 1:]) require(factors == list("bbccd") and inversions % 2 == 0, "PT-002 symbolic determinant b²c²d") def verify_counterexample(model, assignments): support = verify_model(model, 4, 0) labels = model["signed_scalar_labels"] scalars = model["scalar_charges"] require(model["charges"] in assignments and scalars == [3, 6], "PT-006 charges") require(len(labels) == len(support) and all(abs(label) in scalars for label in labels) and sum(labels) == 0, "PT-006 arithmetical condition") require(any(not any(row) for row in support), "PT-006 zero row gives the generic upper bound") def verify_eight(model): verify_model(model, 8, 1) q, entries = model["charges"], model["witness"] require(model["scalar_charges"] == [5], "PT-012 scalar") require(all(sum(row) == 1 and all(value in (0, 1) for value in row) and row[i] == 0 for i, row in enumerate(entries)), "PT-012 four disjoint off-diagonal blocks") squares = {5: 0, -5: 0} for i, row in enumerate(entries): j = row.index(1) if i < j: squares[q[i] + q[j]] += (q[i] - q[j])**2 require(squares == {5: 130, -5: 130}, "PT-012 cubic balance of pairs") require({str(k): v for k, v in squares.items()} == model["pair_difference_squares"], "PT-012 pair certificate") def main(): results = Path(__file__).resolve().with_name("PT_RESULTS.json") require(sha256(EMBEDDED_RESULTS.encode("utf-8")).hexdigest() == RESULTS_SHA256, "SHA-256 of embedded results") if results.is_file(): require(sha256(results.read_bytes()).hexdigest() == RESULTS_SHA256, "SHA-256 of downloaded PT_RESULTS.json") data = json.loads(EMBEDDED_RESULTS) assignments = verify_pilot(data["pilot"]) models = data["models"] verify_two_scalar(models["PT-002"], assignments) verify_counterexample(models["PT-006"], assignments) verify_eight(models["PT-012"]) boundary = data["fixed_points_example"] verify_model(boundary, 2, 1, chiral=False) require(boundary["charges"] == [-1, 1] and boundary["scalar_charges"] == [2], "PT-011 boundary example") print("PASS PT-001 26,334 multisets and one class up to sign") print("PASS PT-002 minimum two scalars, determinant b²c²d") print("PASS PT-006 rank 4 counterexample") print("PASS PT-012 eight fermions and one scalar, rank 8, determinant 1") print("PASS PT-011 fixed-point boundary example") if __name__ == "__main__": main()