back to table · edit · history · where entries came from · files · download
2764 bytes, as of the version from 2026-10-28 13:58 (current). Recorded here, not run.
"""Run: sage -python check-program.py, beside standalone-program.py and table-before.json.
Policy: agents/runs/20261028T134956Z-repair-skills/manifest.json
Manifest SHA-256: 468f5191d13df1eaecac71d659cc26682a40378c5982ce84143ed004d1933cc7
Both archived skill versions: e37efb7e2ededf6c1d7134c673f152f648f26e0267c556aebdf3ec65765d8b4c
This checks the reader's Programs code without importing generate.py.
All arithmetic is exact; no rounded arguments or numerical error claims occur.
"""
from pathlib import Path
import json
import sys
import runpy
here = Path(__file__).resolve().parent
ns = runpy.run_path(str(here / 'standalone-program.py'))
from sage.env import SAGE_VERSION
P, t, catalog, augmented_chow = [ns[k] for k in ('P', 't', 'catalog', 'augmented_chow')]
print('Sage:', SAGE_VERSION, 'Python:', sys.version.split()[0])
# FMSV Theorem 3.21 with n=r gives these Boolean controls.
# The circuits U(r,r+1) instead have coefficients 1,4,1 and 1,11,11,1.
for rank, coefficients in [(1,[1,1]), (2,[1,3,1]), (3,[1,7,7,1])]:
value = augmented_chow(catalog.Uniform(rank, rank))
assert value == P(coefficients)
print('PASS Boolean control rank', rank, value)
raw = json.loads((here / 'table-before.json').read_text())
for name in ('Fano','NonFano'):
value = augmented_chow(getattr(catalog, name)())
stored = raw['Numbers'][name]
if isinstance(stored, dict):
stored = stored['number']
assert value == P(stored)
assert all(c.denominator() == 1 for c in value)
print('PASS stored', name, value)
# A matroid outside the generator's named catalogue dispatch.
# Independently build its flat lattice from all subset ranks and use the
# augmented Mobius recurrence, FMSV Theorem 3.14.
M = catalog.Wheel(4)
elements = sorted(M.groundset(), key=str)
n = len(elements)
ranks = [M.rank([elements[j] for j in range(n) if mask & (1 << j)])
for mask in range(1 << n)]
flats = sorted((mask for mask in range(1 << n)
if all(ranks[mask | (1 << j)] > ranks[mask]
for j in range(n) if not mask & (1 << j))),
key=lambda mask: (ranks[mask], mask))
H = {}
for f in reversed(flats):
upper = [g for g in flats if f != g and f & g == f]
if not upper:
H[f] = P.one()
continue
mu = {f: 1}
for g in upper:
mu[g] = -sum(value for h, value in mu.items() if h & g == h)
H[f] = -sum((mu[g] * sum((t**i for i in range(int(ranks[g]-ranks[f])+1)), P.zero())
* H[g] for g in upper), P.zero())
value = augmented_chow(M)
assert value == H[0]
assert all(c.denominator() == 1 for c in value)
print('PASS unlisted Wheel(4), independent subset-rank Mobius recurrence:', value)
print('PASS: all 6 comparisons; table values unchanged.')