repair-checks-20261102.py

back to table · edit · history · where entries came from · files · download

2963 bytes, as of the version from 2026-11-02 14:37 (current). Recorded here, not run.

"""Exact check of T679's unit-root terminology repair.

Run: sage -python repair_checks.py
Place repair-inputs-20261102.json beside this file. It contains the relevant
entries from fresh API snapshots, with their URLs and snapshot hashes.
No floating-point approximation or new period value is used here.
The governing skill manifest is
agents/runs/20261102T143152Z-repair-skills/manifest.json; both skill digests are
a2b28d9953264d7b0ca62663785c2952190c5be6d6d3597fd695d9a54d606278.
"""
import json
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.env import SAGE_VERSION

here = Path(__file__).resolve().parent
inputs = json.loads((here / 'repair-inputs-20261102.json').read_text())
source = inputs['local_factor']
if isinstance(source, dict):
    source = source['number']
ring = PolynomialRing(QQ, 'T')
T = ring.gen()
P = ring(source)
assert P == 1 + 2*T - 18*T**2 + 54*T**3 + 729*T**4
Q = P.reverse()
control = (T-1)*(T-3)*(T-9)*(T-27)
control_slopes = sorted(control.newton_slopes(3))
assert control_slopes == [0, 1, 2, 3]
slopes = sorted(Q.newton_slopes(3))
assert slopes == [QQ(0), QQ(3)/2, QQ(3)/2, QQ(3)]

# Independent exact lower hull of coefficient valuations of det(1 - TF).
points = [(i, ZZ(c).valuation(3)) for i, c in enumerate(P.list()) if c]
hull = []
for point in points:
    while len(hull) >= 2:
        a, b = hull[-2:]
        cross = (b[0]-a[0])*(point[1]-b[1]) - (b[1]-a[1])*(point[0]-b[0])
        if cross > 0:
            break
        hull.pop()
    hull.append(point)
hull_slopes = []
for a, b in zip(hull, hull[1:]):
    hull_slopes.extend([QQ(b[1]-a[1])/(b[0]-a[0])] * (b[0]-a[0]))
assert hull_slopes == slopes

# The displayed residue is a root of the eigenvalue polynomial modulo 3^210.
stored = inputs['unit_root']
residue_text, precision_text = stored.split(' + O(3^')
residue = ZZ(residue_text)
precision = int(precision_text.rstrip(')'))
assert precision == 210
assert residue % 3 == 1
assert Q(residue) % (ZZ(3)**precision) == 0
assert Q.derivative()(residue) % 3 != 0

print(json.dumps({
    'table': 'T679', 'checked_companion_entry': ['2.2.4', '1/2', '3'],
    'sage_version': SAGE_VERSION,
    'skill_manifest': 'agents/runs/20261102T143152Z-repair-skills/manifest.json',
    'skill_sha256': 'a2b28d9953264d7b0ca62663785c2952190c5be6d6d3597fd695d9a54d606278',
    'local_factor': str(P), 'eigenvalue_polynomial': str(Q),
    'control_root_valuations': list(map(str, control_slopes)),
    'coefficient_valuations': [[int(x), int(y)] for x, y in points],
    'lower_hull': [[int(x), int(y)] for x, y in hull],
    'eigenvalue_valuations': list(map(str, slopes)),
    'unit_residue_checked_modulo': '3^210', 'simple_unit_root': True,
    'conclusion': 'A unique unit eigenvalue exists, but the full Newton polygon is not ordinary.'
}, indent=2))