back to table · edit · history · where entries came from · files · download
4382 bytes, as of the version from 2026-11-30 10:02. Recorded here, not run.
"""Reproduce T867: p-adic singular j-invariants.
Install numberdb in SageMath, then run:
sage -python generate.py # verify every stored entry, no write
sage -python generate.py --publish # fill this authorized table only
The default selection is every negative fundamental discriminant |D| <= 100
of class number 2 or 3, every prime 5 <= p <= 97 split in Q(sqrt(D)) for which
H_D modulo p is squarefree, and every linear residue root 0 <= a < p.
Parameter order is D,p,a. Classical j is used (constant q-coefficient 744).
FLINT/Arb computes H_D in ZZ[x]. Exact modular Newton iteration lifts the
simple root a to u modulo p^N, where N is least with p^N >= 10^digits.
Conrad, Hensel's lemma, Theorem 2.1, proves the unique root is in this ball.
Qp is constructed with absolute precision N, including for nonunit roots.
No floating arithmetic, complex-to-local embeddings or approximate input
coefficients are used. This generator never offers or publishes a draft.
The separate check.py compares class polynomials with PARI polclass(D,0),
checks independent reduced-form selection, and compares every full lift with
PARI polrootspadic and digit-at-a-time Hensel lifting. See the attached
argument-selection.md and check-results.json for the finite reference policy
and actual evidence. Requires SageMath with FLINT/Arb, PARI and p-adics.
Credentials and agent/model attribution belong in the caller's environment.
"""
import functools
import os
import sys
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.rings.padics.factory import Qp
from sage.arith.misc import prime_range, kronecker
from sage.schemes.elliptic_curves.cm import hilbert_class_polynomial
R = PolynomialRing(ZZ, 'x')
@functools.lru_cache(None)
def discriminants():
return tuple(-d for d in range(1, 101)
if ZZ(-d).is_fundamental_discriminant()
and ZZ(-d).class_number() in (2, 3))
@functools.lru_cache(None)
def polynomial(D):
return R(hilbert_class_polynomial(ZZ(D), algorithm='arb'))
def precision(p, digits=100):
p, digits = int(p), int(digits)
N, modulus = 0, 1
while modulus < 10 ** digits:
N, modulus = N + 1, modulus * p
return N, modulus
@functools.lru_cache(None)
def residue_roots(D, p):
p = ZZ(p)
if kronecker(ZZ(D), p) != 1:
return ()
f = polynomial(D).change_ring(GF(p))
if f.gcd(f.derivative()).degree() != 0:
return ()
return tuple(sorted(int(a) for a in f.roots(multiplicities=False)))
def newton_lift(f, p, a, N):
p, a, N = int(p), int(a), int(N)
assert int(f(a)) % p == 0 and int(f.derivative()(a)) % p != 0
u, m = a, 1
df = f.derivative()
while m < N:
m = min(2 * m, N)
modulus = p ** m
u = (u - int(f(u)) * pow(int(df(u)), -1, modulus)) % modulus
assert int(f(u)) % modulus == 0
return u
class SingularJ(numberdb.Generator):
table = os.environ.get('NUMBERDB_TABLE', 'T867')
parameters = ('D', 'p', 'a')
type = 'Qp'
digits = 100
rigour = 'proven'
def enumerate(self):
for D in discriminants():
for p in prime_range(5, 98):
for a in residue_roots(D, int(p)):
yield {'D': D, 'p': int(p), 'a': a}
def value(self, params, digits):
D, p, a = (int(params[k]) for k in self.parameters)
assert ZZ(D).is_fundamental_discriminant() and D < 0
assert p >= 5 and ZZ(p).is_prime() and 0 <= a < p
assert a in residue_roots(D, p)
N, modulus = precision(p, digits)
u = newton_lift(polynomial(D), p, a, N)
assert 0 <= u < modulus and u % p == a
value = Qp(ZZ(p), N, print_mode='val-unit')(ZZ(u), absprec=N)
assert value.precision_absolute() == N
return value
if __name__ == '__main__':
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
numberdb.configure(api_key=sys.stdin.read().strip())
generator = SingularJ()
if '--publish' in sys.argv or os.environ.get('NUMBERDB_PUBLISH') == '1':
print(generator.publish(message=os.environ.get('NUMBERDB_EDIT_MESSAGE', 'Fill p-adic singular j-invariants')))
else:
print(generator.verify(sample=None))