Research source · python

verify-incidence-homotopy-obstruction.py

site/public/evidence/sylvester-mobius-syzygies/verify-incidence-homotopy-obstruction.py

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

File fingerprint

SHA-256: 1a5201906748e85ca56956f649f08d0d72e57d8b10b90e51289767a60fdacebb

#!/usr/bin/env python3
"""Exact formal audit of the Sylvester-line homotopy and its rank obstruction.

This script deliberately contains no matroid catalogue.  It checks the two
universal chain calculations used in the stopping note:

1. On a rank-two flat L, the symmetric third-point primitive has differential
   equal to the requested degree-four Koszul basis vector.
2. On the spanning top diagonal of a rank-r flat, the Koszul differential is
   the cellular differential of the pointed-hyperplane triangle complex.
   A third point on a line has rank two with the original pair, so adjoining
   it to a rank-(r-3) coefficient can never reach the rank-r spanning block.

All coefficients are exact integers or Fractions from the Python standard
library.
"""

from __future__ import annotations

from fractions import Fraction
from typing import Hashable


Vector = dict[Hashable, Fraction]


def add(*vectors: Vector) -> Vector:
    result: Vector = {}
    for vector in vectors:
        for basis, coefficient in vector.items():
            result[basis] = result.get(basis, Fraction(0)) + coefficient
            if not result[basis]:
                del result[basis]
    return result


def scale(coefficient: Fraction, vector: Vector) -> Vector:
    return {
        basis: coefficient * value
        for basis, value in vector.items()
        if coefficient * value
    }


def rank_two_differential(coefficient_point: str) -> Vector:
    """Differentiate y_u tensor e_a wedge e_b wedge e_c on one line."""
    a, b, c = "a", "b", "c"
    points = (a, b, c)
    result: Vector = {}
    for position, removed in enumerate(points):
        if removed == coefficient_point:
            continue  # y_u^2 = 0
        wedge = points[:position] + points[position + 1 :]
        sign = Fraction(1 if position % 2 == 0 else -1)
        result[("y_L", wedge)] = result.get(("y_L", wedge), Fraction(0)) + sign
    return result


def audit_rank_two_average() -> None:
    primitive = add(
        rank_two_differential("a"),
        rank_two_differential("b"),
        scale(Fraction(-1), rank_two_differential("c")),
    )
    expected = {("y_L", ("a", "b")): Fraction(2)}
    assert primitive == expected

    for line_size in range(3, 20):
        averaged = scale(
            Fraction(1, 2 * (line_size - 2)),
            scale(Fraction(line_size - 2), primitive),
        )
        assert averaged == {("y_L", ("a", "b")): Fraction(1)}

    print("rank-two primitive: d((y_a+y_b-y_c) tensor e_abc) = 2 y_L tensor e_ab")
    print("symmetric average: normalization cancels the m-2 identical summands exactly")


def graph_boundary(edge: str) -> Vector:
    """Boundary of the three formal edges around one top-diagonal triangle."""
    vertex_ab_c = ("G+a+b", "c")
    vertex_ac_b = ("G+a+c", "b")
    vertex_bc_a = ("G+b+c", "a")
    boundaries = {
        "[G+a;bc]": {vertex_ab_c: Fraction(1), vertex_ac_b: Fraction(-1)},
        "[G+b;ac]": {vertex_ab_c: Fraction(1), vertex_bc_a: Fraction(-1)},
        "[G+c;ab]": {vertex_ac_b: Fraction(1), vertex_bc_a: Fraction(-1)},
    }
    return boundaries[edge]


def audit_top_diagonal_triangle() -> None:
    d3_source = {
        "[G+a;bc]": Fraction(1),
        "[G+b;ac]": Fraction(-1),
        "[G+c;ab]": Fraction(1),
    }
    composite = add(
        *(scale(coefficient, graph_boundary(edge)) for edge, coefficient in d3_source.items())
    )
    assert composite == {}
    assert len(d3_source) == 3

    print("top diagonal: d3[G;abc] is the oriented boundary of a three-edge triangle")
    print("top diagonal: d2*d3 = 0 exactly in the pointed-hyperplane graph")


def audit_rank_budget() -> None:
    for ambient_rank in range(3, 50):
        coefficient_rank = ambient_rank - 3
        line_triple_rank = 2
        assert coefficient_rank + line_triple_rank == ambient_rank - 1
        assert coefficient_rank + line_triple_rank < ambient_rank

    print("line insertion: (r-3)+rank{a,b,c} = (r-3)+2 = r-1 < r")
    print("conclusion: every third-point insertion has zero projection to K_(3,r)(M;E)")


if __name__ == "__main__":
    audit_rank_two_average()
    audit_top_diagonal_triangle()
    audit_rank_budget()