Research source · python

cohomological_sewing_review.py

site/public/research-artifacts/result-review-2026-09-01-batch-10/cohomological_sewing_review.py

130 lines. Source is displayed for inspection; it is not executed by this page.

File fingerprint

SHA-256: 7eb405bc2584a2762f2867e34bdca23a55931aaf191d9be01d271a33c070acd6

#!/usr/bin/env python3
"""Independent finite checks for the reviewed cohomological sewing family.

The implementation is deliberately separate from the archived Quotient Arsenal
checkers.  It exhausts the small cyclic-group models used to test the
connecting obstruction, graph-transport comparison, and two-stage receipt.
"""

from __future__ import annotations

import itertools
import json


def connecting_obstruction() -> dict:
    # D^1=D^2=Z/4, d(x)=2x; N=2D; Q=D/N.
    rows = []
    for q in range(2):
        lifts = [x for x in range(4) if x % 2 == q]
        obstruction_values = {(2 * x) % 4 for x in lifts}
        assert len(obstruction_values) == 1
        obstruction = obstruction_values.pop()
        null_boundaries = {(2 * a) % 4 for a in (0, 2)}
        obstruction_zero = obstruction in null_boundaries
        closed_lifts = [x for x in lifts if (2 * x) % 4 == 0]
        assert obstruction_zero == bool(closed_lifts)
        rows.append(
            {
                "quotient_class": q,
                "lifts": lifts,
                "obstruction": obstruction,
                "closed_lifts": closed_lifts,
            }
        )
    return {"cases": rows, "lift_criterion_passed": True}


def transport_comparison(p: int = 7) -> dict:
    # Three-cycle with two identity transports and closing unipotent twist t.
    results = []
    for twist in range(p):
        compatible = 0
        circulations = set()
        for a0, a1, a2 in itertools.product(range(p), repeat=3):
            edge_receipt = (
                (a0 - a1) % p,
                (a1 - a2) % p,
                (a2 + twist - a0) % p,
            )
            circulations.add(sum(edge_receipt) % p)
            compatible += edge_receipt == (0, 0, 0)
        assert circulations == {twist}
        assert compatible == (p if twist == 0 else 0)
        results.append(
            {
                "twist": twist,
                "lifts_checked": p**3,
                "cycle_class": twist,
                "compatible_lifts": compatible,
            }
        )
    return {
        "coefficient_group": f"Z/{p}",
        "twists": results,
        "overlap_cycle_connecting_agreement": True,
    }


def staged_obstruction() -> dict:
    # D=Z/8, d(x)=4x, N=4D, M=2D.  The nonzero D/M class has
    # zero primary receipt in M/N and nonzero secondary receipt in N.
    odd_lifts = [1, 3, 5, 7]
    direct = {(4 * x) % 8 for x in odd_lifts}
    primary = {value % 4 for value in direct}
    secondary = direct
    closed = [x for x in odd_lifts if (4 * x) % 8 == 0]
    assert direct == {4}
    assert primary == {0}
    assert secondary == {4}
    assert not closed

    # Choice-dependence control: in M=Z/4 with d=2, the two raw
    # secondary values differ by im(delta_{N,M})={0,2}.
    raw = [(2 * x) % 4 for x in (0, 1)]
    correction_image = {(2 * x) % 4 for x in (0, 1)}
    assert raw == [0, 2]
    assert all(value in correction_image for value in raw)
    return {
        "odd_lifts": odd_lifts,
        "direct_receipt": sorted(direct),
        "primary_receipt_mod_N": sorted(primary),
        "secondary_receipt": sorted(secondary),
        "closed_global_lifts": closed,
        "raw_secondary_values": raw,
        "correction_image": sorted(correction_image),
        "primary_zero_secondary_nonzero": True,
        "secondary_coset_choice_independent": True,
    }


def non_subcomplex_control() -> dict:
    # D^0=D^1=Z/4 with d=id; N^0={0,2}, N^1={0} is not a subcomplex.
    representatives = [0, 2]
    images = representatives[:]
    assert images[0] != images[1]
    return {
        "same_proposed_quotient_class": representatives,
        "distinct_differentials": images,
        "quotient_differential_well_defined": False,
    }


def main() -> None:
    certificate = {
        "protocol": "fprd-result-review.v1",
        "review_unit": "cohomological sewing core",
        "implementation": "independent standard-library exhaustive enumeration",
        "results": {
            "connecting_obstruction": connecting_obstruction(),
            "transport_comparison": transport_comparison(),
            "staged_obstruction": staged_obstruction(),
            "missing_subcomplex_boundary": non_subcomplex_control(),
        },
        "status": "pass",
    }
    print(json.dumps(certificate, indent=2, sort_keys=True))


if __name__ == "__main__":
    main()