local_controls.py

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

3180 bytes, as of the version from 2026-11-17 10:38 (current). Recorded here, not run.

"""Builder local-law and companion controls, not an independent verdict.
The direct squareful controls import the generator. T142 and local finite
fields are separate evidence; no sibling numerical values are used.
"""
import json
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.number_field.number_field import CyclotomicField
import generate as g
import build_check as ch
B=Path(__file__).resolve().parent
rows=json.loads((B/'entries.json').read_text());data={(r['params']['a'],r['params']['b']):r for r in rows}
result={'squareful_controls':[],'conjugation_controls':[]}
for pi in [(5,0),(-1,-3)]:
 n=g.norm(pi)
 for ell in ([2] if pi==(5,0) else [2,3]):
  modulus=(1,0)
  for _ in range(ell):modulus=g.mul(modulus,pi)
  L,unshifted,_=g.exact_sum(modulus);assert unshifted==0
  for k in range(ell+1):
   shift=(1,0)
   for _ in range(k):shift=g.mul(shift,pi)
   L,val,_=g.exact_sum(modulus,shift)
   if ell==k+1:
    P=ch.K(pi[0]+pi[1]*ch.w);F,om=ch.local_field(P);es=ch.field_exponents(P);cs=[0]*(6*n)
    for x in F:
     if es[x] is not None:cs[(n*(ell*es[x])+6*ch.additive_numerator(x,P))%(6*n)]+=1
    M=CyclotomicField(6*n);expected=n**k*ch.embed_exact(L,M(cs))
   else:expected=L(0)
   assert val==expected,(pi,ell,k)
   result['squareful_controls'].append({'prime':pi,'ell':ell,'k':k,'exact':True,'nonzero':bool(val)})
 # Incorrect coprime formula at a repeated prime must fail.
 L,v,_=g.exact_sum(g.mul(pi,pi));M,vp,_=g.exact_sum(pi)
 assert v==0 and ch.embed_exact(L,vp)**2!=v
result['shared_prime_coprime_formula_rejected']=True
# Zero-extended character powers retain support even at exponent six.
F,om=ch.local_field(ch.K(-1-3*ch.w));es=ch.field_exponents(ch.K(-1-3*ch.w))
mask=[0 if e is None else 1 for x,e in es.items()]
assert sum(mask)==6 and es[F(0)] is None
result['order_six_nonunit_mask']=True
# Conjugation changes the additive sign and may need E-primary sign repair.
selected=ch.product_selection(ch.prime_ideals(500),500)
for ident,row in data.items():
 c=ch.K(ident[0]+ident[1]*ch.w);cc=ch.canonical(c.conjugate());other=coords=ch.coords(cc);rr=data[other]
 L=CyclotomicField(6*row['norm']);v=L(row['exact_coefficients']);vo=L(rr['exact_coefficients'])
 sign=1 if cc==c.conjugate() else -1;assert cc==sign*c.conjugate()
 e=sum(ch.residue_exp(ch.K(sign),pi) for pi in selected[other])%6 if sign==-1 else 0
 assert vo==(L.gen()**row['norm'])**e*ch.conjugate_exact(L,v)
 result['conjugation_controls'].append({'params':ident,'conjugate_E_primary':other,'associate_sign':sign,'symbol_exponent':e})
# Exact independent F7 polynomial for the documented Programs example.
env={};exec((B/'program-example.py').read_text(),env)
L=env['L'];v=L(data[(-1,-3)]['exact_coefficients']);assert env['G']==v
# T142 uses additive coefficient 1, whereas this table has coefficient 3.
control=json.loads((B/'T142-control.json').read_text());tau=(L.gen()**7)*v
ch.stored_contains(control['number'],ch.eval_exact(L,tau))
assert not ch.safe_contains(control['number'],ch.eval_exact(L,v))
result['T142_7_3_phase_control']=True;result['program_example_exact']=True
print('RESULT',json.dumps(result),flush=True)