generate.py

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

3088 bytes, as of the version from 2026-11-16 02:39. Recorded here, not run.

"""T722: Pham periods of Fermat varieties.

Install SageMath (or its modular ball and interval packages), then run:
     sage -pip install numberdb
Run: sage -python generate.py              # verify every stored entry
     sage -python generate.py --publish    # additive upload to your own draft
Configure your own API key and current engine/model provenance outside this file.

The default range is n=2,4 and d=3,...,6, with every nondecreasing tuple of
n+1 integers in 1,...,d-1 whose sum is not divisible by d. The tuple key joins
the integers with periods. The distinguished projective coordinate is fixed.
The cycle is product_j(1-T_j) Delta, with dt_1 wedge ... wedge dt_n orientation.

Gamma and exponential evaluations enclose exact rational arguments using Arb.
At 100 decimal digits the working precision is 589 bits (256 guard bits).
The build checks both component enclosures against the written decimal intervals.
For half-integral A, the phase identity proves the imaginary component exactly
zero; the real component retains its computed enclosure. No thresholding is used.
See argument-selection.md and check-results.json for coverage and measured bounds.
The default command is read-only. No removal or precision lowering is enabled.
"""
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.complex_arb import ComplexBallField
from itertools import combinations_with_replacement
import os, sys

class PhamPeriods(numberdb.Generator):
    table = 'T722'
    parameters = ('n','d','a')
    type = 'C'
    digits = 100
    rigour = 'proven'

    def enumerate(self):
        for n in (2,4):
            for d in range(3,7):
                for a in combinations_with_replacement(range(1,d),n+1):
                    if sum(a)%d:
                        yield {'n':n,'d':d,'a':'.'.join(map(str,a))}

    def value(self, params, digits):
        n,d = int(params['n']),int(params['d'])
        a = tuple(map(int,str(params['a']).split('.')))
        if not (n>=2 and n%2==0 and d>=3 and len(a)==n+1
                and all(1<=x<d for x in a) and tuple(sorted(a))==a and sum(a)%d):
            raise ValueError('Outside the defined primitive character domain')
        C=ComplexBallField(max(512,numberdb.bits(digits,losing=256)))
        z=(2*C.pi()*C.gen(0)/d).exp()
        result=C(1)
        for k in a:
            result *= (1-z**k)*C(QQ(k)/d).gamma()/d
        result /= C(QQ(sum(a))/d).gamma()
        if (2*sum(a))%d==0:
            result=C(result.real(),0)
        return result

if __name__=='__main__':
    if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':
        token=sys.stdin.read().strip()
        if '=' in token and token.split('=',1)[0].isupper():
            token=token.split('=',1)[1].strip().strip('\"\'')
        numberdb.configure(api_key=token)
    generator=PhamPeriods()
    if '--publish' in sys.argv or os.environ.get('NUMBERDB_PUBLISH')=='1':
        print(generator.publish(removing=False))
    else:
        report=generator.verify(sample=None)
        print(report)
        if not report:sys.exit(1)