Research source · python

verify-one-sided-seed.py

site/public/evidence/dehn-filled-quantum-trace/one-sided-seed-attack/verify-one-sided-seed.py

186 lines. Source is displayed for inspection; it is not executed by this page.

File fingerprint

SHA-256: d28c5e145d61490582841d1d7e532b9f29d29f0dfabc274b4e3a7727d4f069a9

#!/usr/bin/env python3
"""Exact local and global checks. Standard library only; no topology census."""
from fractions import Fraction as F
from pathlib import Path
import json

ROOT = Path(__file__).resolve().parent
checks = []

def check(name, assertion):
    assert assertion, name
    checks.append(name)

def poch(q, n):
    out = F(1)
    for j in range(1, n + 1):
        out *= 1 - q ** j
    return out

def seed(m, e):
    if e > 0:
        return F(0)
    # q=16 so half-powers are rational, with exact Fraction arithmetic.
    return (-1) ** (e % 2) * F(4) ** (e*(e-1)+e*m) / poch(F(16), -e)

for m, e in [(0, 0), (2, 0), (-2, -3), (3, -1), (0, 1), (2, 2)]:
    check(f'plus recurrence at ({m},{e})',
          F(4)**e*seed(m+1,e) + F(4)**(-m)*seed(m,e+1) == seed(m,e))
check('minus recurrence fails by the exact residual',
      seed(-1,0) + seed(0,-1) - seed(0,0) == -F(16)/(1-F(16)))

for m, e, n in [(0,1,1), (2,-1,2), (-1,3,4), (3,0,0)]:
    r=n-e
    translated = F(4)**(-n*m)*seed(m,e-n)/poch(F(16),n)
    defining = (-1)**(r%2)*F(4)**(r*(r+1)-(2*r+e)*m)/(poch(F(16),r)*poch(F(16),r+e))
    check(f'local index summand reindex ({m},{e},{n})', translated == defining)

def dot(a,b): return sum(x*y for x,y in zip(a,b))
def omega(u,v):
    n=len(u)//2
    return dot(u[n:],v[:n])-dot(u[:n],v[n:])
def qform(x,y): return dot(x,x)-dot(x,y)

for x,y,alpha,beta in [
    ((1,2),(3,-1),(2,-1),(0,3)),
    ((F(1,2),F(3,2)),(-1,2),(F(1,2),F(-1,2)),(1,0)),
]:
    a=tuple(xj+aj for xj,aj in zip(x,alpha))
    d=tuple(yj+bj for yj,bj in zip(y,beta))
    raw=2*(dot(a,a)+sum(a)-dot(a,d))+2*(dot(y,alpha)-dot(x,beta))
    expanded=2*qform(x,y)+2*sum(x)+4*dot(tuple(a-b for a,b in zip(alpha,beta)),x)+2*(dot(alpha,alpha)+sum(alpha)-dot(alpha,beta))
    check('exact Weyl/seed degree cancellation '+str(x),raw==expanded)

# Three-block abstract example. These are not triangulation data.
h=(2,2,0,0,0,0)
b=(0,0,0,-1,0,-2)
Rs=((1,-1,-1),(1,-1,-1),(0,0,0))
Rl=((1,1,0),(0,0,0),(0,0,-2))
theta=((F(1,2),F(1,6),F(1,3)),(F(1,2),F(1,4),F(1,4)),(F(1,3),F(1,3),F(1,3)))
def collapse(R):
    return tuple(r-s for r,s,t in R)+tuple(t-s for r,s,t in R)
check('raw meridian and longitude collapse',collapse(Rs)==h and collapse(Rl)==b)
check('native peripheral skew',omega(h,b)==2)
check('complete strict triples',all(sum(th)==1 and min(th)>0 for th in theta))
check('zero raw meridian and longitude holonomy',
      sum(dot(th,r) for th,r in zip(theta,Rs))==0 and sum(dot(th,r) for th,r in zip(theta,Rl))==0)
check('native scalar valuations and phase',sum(r[1] for r in Rs)==-2 and sum(r[1] for r in Rl)==1)
check('positive longitude scalar from complete angles',theta[0][2]+2*theta[2][2]==1)
check('filling requires impossible strict angle sum',2*F(2)-2==2)

def clean(s): return {e:c for e,c in s.items() if c}
def add(*series):
    out={}
    for s in series:
        for e,c in s.items():out[e]=out.get(e,0)+c
    return clean(out)
def shift(s,p,c=1,cap=None):
    return clean({e+p:c*v for e,v in s.items() if cap is None or e+p<=cap})

def inverse_pochs(indices, cap):
    if cap<0:return {}
    a=[0]*(cap+1); a[0]=1
    for n in indices:
        for j in range(1,n+1):
            for e in range(4*j,cap+1):a[e]+=a[e-4*j]
    return {e:c for e,c in enumerate(a) if c}

tails=[]
def H(u,cap=48):
    if any(v%2 for v in u):return {}
    alpha=tuple(v//2 for v in u[:3]); beta=tuple(v//2 for v in u[3:])
    if alpha[2]<0:return {}
    k=max(-alpha[0],-alpha[1]); out={}
    delta=alpha[0]+alpha[1]-beta[0]-beta[1]
    const=2*(dot(alpha,alpha)+sum(alpha)-dot(alpha,beta))
    while True:
        deg=4*k*k+4*delta*k+const
        # Quadratic difference is 8k+4+4delta. Positive and increasing thereafter.
        if deg>cap and 8*k+4+4*delta>0:
            tails.append({'input':u,'cap':cap,'first_omitted_k':k,'first_omitted_degree':deg,'next_degree_increment':8*k+4+4*delta})
            break
        a=(k+alpha[0],k+alpha[1],alpha[2])
        out=add(out,shift(inverse_pochs(a,cap-deg),deg,(-1)**(sum(alpha)%2),cap))
        k+=1
    return out

CAP=48
unit=H((0,)*6,CAP)
longsq=shift(H(tuple(2*x for x in b),CAP-2),2,-1,CAP)
vacuum=add(unit,shift(longsq,0,-1))
check('unit and vacuum leading coefficients',unit.get(0)==1 and vacuum.get(0)==1 and vacuum.get(2)==1)
check('vacuum coefficients positive in certified range',all(c>0 for c in vacuum.values()))
direct={}
k=0
while 4*k*k<=CAP:
    s=shift(inverse_pochs((k,k),CAP-4*k*k),4*k*k,cap=CAP)
    direct=add(direct,s,shift(s,2+4*k,cap=CAP))
    k+=1
check('global vacuum equals exact Nahm formula with tail bound',vacuum==direct)

for u in [(0,)*6,(2,0,2,0,2,0)]:
    for j in range(3):
        uz=list(u);uz[j]-=2
        uw=list(u);uw[j+3]+=2
        first=shift(H(tuple(uz),CAP+u[j+3]),-u[j+3],cap=CAP)
        second=shift(H(tuple(uw),CAP+u[j]),-u[j],cap=CAP)
        check(f'global original-sided tetrahedron {j}, input {u}',add(first,second,shift(H(u,CAP),0,-1))=={})
    v=tuple(a+c for a,c in zip(u,h)); power=-2+omega(h,u)//2
    check('global exact native moment, input '+str(u),
          add(shift(H(v,CAP-power),power,-1,CAP),shift(H(u,CAP-2),2,cap=CAP))=={})
check('empty odd parity for the even example image',H((1,0,0,0,0,0))=={})

# Full-root reindexing really uses odd moment rows: Lambda=Z(1,0), chi=1.
def halfroot_H(uz,uw,cap=24):
    if uw%2:return {}
    out={};a=0
    while True:
        deg=2*a*a+2*a-2*a*uw+uz*uw//2
        if deg>cap and 4*a+4-2*uw>0:break
        out=add(out,shift(inverse_pochs((a,),cap-deg),deg,(-1)**(a%2),cap))
        a+=1
    return out
check('odd root input supported by odd moment translate',halfroot_H(1,0)==halfroot_H(0,0) and halfroot_H(1,0).get(0)==1)
check('odd-row original moment reindex with nontrivial Weyl factor',
      shift(halfroot_H(1,2,25),-1,cap=24)==halfroot_H(0,2,24))

# Proper actual lattice versus its saturation in half-exponent coordinates.
def proper_lattice(step,cap=12):
    out={};a=0
    while 2*a*a+2*a<=cap:
        deg=2*a*a+2*a
        out=add(out,shift(inverse_pochs((a,),cap-deg),deg,(-1)**(a%2),cap));a+=step
    return out
check('saturating the image changes the functional',proper_lattice(2).get(4,0)==0 and proper_lattice(1).get(4)==-1)

# Structural cone diagnostics, not a search over cone faces or triangulations.
check('negative quadratic direction',qform((1,),(2,))==-1)
check('null ray unit can converge',qform((1,),(1,))==0 and 2>0)
check('same null ray fails a shifted input',2-4==-2)
check('vertical null ray defeats one sign',qform((0,),(1,))==0)
M=lambda x,y:x*x+4*x*y+y*y
check('strict copositivity does not mean positive definiteness',M(1,-1)==-2 and M(1,1)==6)
check('abstract cone exact quadratic',qform((1,1,0),(0,0,0))==2)

# Native raw character congruence, including a non-real phase failure.
for raw_r,raw_p,edge_count,n in [(2,-2,0,1),(1,1,0,1),(6,2,2,1)]:
    sx=(raw_r-raw_p)//2
    phase_exponent=(2*(edge_count+n)-raw_p)%4
    desired=(2*sx)%4
    check('raw phase congruence '+str((raw_r,raw_p,edge_count,n)),
          (phase_exponent==desired)==((raw_r-2*(edge_count+n))%4==0))

# Zero-scalar-order vacuum certificate telescopes exactly.
q=F(16); x=(2,1,3);t=(1,0,2)
lhs=1-q**dot(t,x)
rhs=sum(q**sum(t[i]*x[i] for i in range(j))*(1-q**x[j])*sum(q**(r*x[j]) for r in range(t[j])) for j in range(3))
check('vacuum numerator telescopes',lhs==rhs)

result={'status':'passed','check_count':len(checks),'checks':checks,
        'example_status':'abstract presentation only; no actual triangulation example',
        'vacuum_coefficients_A_through_48':dict(sorted(vacuum.items())),
        'quadratic_tail_certificates':tails,
        'proof_boundary':'The exact cone theorem and topological applicability are not established by finite checks.'}
(ROOT/'exact-results.json').write_text(json.dumps(result,indent=2)+'\n')
print(f'PASS: {len(checks)} exact checks; all global series cutoffs have a quadratic tail certificate.')
print('The worked presentation is abstract. No additional actual filling is certified.')