#!/usr/bin/env python3 """Job #1045 — certify the sigma-partner positions, and the split at each, by trial division. The attaining set of the twin-Jacobsthal record is closed under sigma(n) = -n-2 (mod x#) (return #424: sigma swaps the two forbidden residues 0 and -2 for every p <= x, so it permutes the slot set; a maximal gap of length G starting at s maps to one of the same length starting at sigma(s+G) = -s-G-2 (mod x#) with the ancestry reversed). That turns each recorded witness into TWO certified attaining positions, at the cost of trial division over x# and nothing else. This script, for every level whose record position is known: 1. computes t = (-s - G - 2) mod x# and checks t is a T_x slot, that t+G is a T_x slot, and that no integer strictly inside (t, t+G) is one (so the forward gap from t is exactly G); 2. reports the end/interior split at s and at t and checks the ancestries are exact reversals. Nothing here enumerates a period; every line is gcd arithmetic on uint64-sized integers (Python ints, so the 2^53 trap of the staged C tools does not apply). """ import json import sys sys.path.insert(0, 'job1007') import splits as P # noqa: E402 (the served ancestry test, gated in #424) # level -> (G2, a position attaining it); the 43# rows are the two chunk-least positions of the # staged enumerations (research/history/staging/phase1-T2b-exact-ladder.md), the rest are the # certified LADDER positions of research/exact-g2-ladder.js. KNOWN = [(37, 528, 544899485411), (41, 546, 3784200788231), (43, 618, 830330079152051), (43, 618, 1403312099425139)] def prev_prime(x): return [p for p in P.PRIMES if p < x][-1] def certify(x, G, s): Pm = P.primorial(x) def slot(n): return P.gcd(n * (n + 2), Pm) == 1 t = (-s - G - 2) % Pm gap_fwd = next(k for k in range(1, 4 * G) if slot(t + k)) inside = any(slot(n) for n in range(t + 1, t + G)) above = t > 2 ** 53 rs = P.analyse(x, prev_prime(x), s, G) rt = P.analyse(x, prev_prime(x), t, G) if inside is False else None return dict(x=x, G=G, s=s, partner=t, above_2_53=above, partner_is_slot=slot(t), forward_gap=gap_fwd, no_slot_inside=not inside, certified=bool(slot(t) and gap_fwd == G and not inside), splits_match=bool(rt and abs(rs['share'] - rt['share']) < 1e-12), ancestry_reversed=bool(rt and rt['gaps'] == rs['gaps'][::-1]), s_split=dict(L=rs['L'], gaps=rs['gaps'], ends=rs['ends'], interior=rs['sum_interior'], share=rs['share']), partner_split=None if rt is None else dict(L=rt['L'], gaps=rt['gaps'], ends=rt['ends'], interior=rt['sum_interior'], share=rt['share'])) def main(): out = [] for x, G, s in KNOWN: r = certify(x, G, s) out.append(r) print('x=%-3d A_1=%d known s=%d -> sigma-partner t=%d %s' % (x, G, s, r['partner'], 'CERTIFIED attaining position (above 2^53)' if r['certified'] and r['above_2_53'] else ('CERTIFIED attaining position' if r['certified'] else 'NOT CERTIFIED'))) print(' partner: T_x slot yes, forward gap %d (= A_1), no slot inside: %s' % (r['forward_gap'], r['no_slot_inside'])) print(' split at s: L=%d gaps=%s ends=%d interior=%d share=%.3f%s' % (r['s_split']['L'], r['s_split']['gaps'], r['s_split']['ends'], r['s_split']['interior'], r['s_split']['share'], ' [same split at the partner, ancestry reversed]' if r['splits_match'] and r['ancestry_reversed'] else ' [MISMATCH]')) json.dump(out, open('job1045/sigma-certify.json', 'w', encoding='utf-8', newline='\n'), indent=1, sort_keys=True) print() print('levels certified twice over: 37# (record nmax 2 -> the WHOLE attaining set is this one' ' sigma-orbit, so the 37# split is uniform by proof),') print('41# (2 of the 4 attaining positions), 43# (4 of the 8).') return 0 if __name__ == '__main__': sys.exit(main())