"""Exact FCC docking audit for the selected 8T+7O proton. Continuous straight-translation certificate uses separating axes of the complete host-center convex cells, a conservative bound for their curved interstices. No force law, reaction rate, or nuclear bound state is inferred. """ import json,itertools,math from pathlib import Path from fractions import Fraction ROOT=Path(__file__).resolve().parent P=list(itertools.permutations(range(3))) def dot(a,b):return sum(x*y for x,y in zip(a,b)) def sub(a,b):return tuple(x-y for x,y in zip(a,b)) def add(a,b):return tuple(x+y for x,y in zip(a,b)) def cross(a,b):return (a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]) def axis(a): scale=math.lcm(*(Fraction(x).denominator for x in a));a=tuple(int(x*scale) for x in a) g=math.gcd(*a) if not g:return None a=tuple(x//g for x in a) return tuple(-x for x in a) if next(x for x in a if x)<0 else a def rotations(): for p in P: parity=(-1)**sum(p[i]>p[j] for i in range(3) for j in range(i+1,3)) for s in itertools.product((-1,1),repeat=3): if parity*math.prod(s)==1:yield tuple(tuple(s[i] if j==p[i] else 0 for j in range(3)) for i in range(3)) def rot(R,v):return tuple(dot(r,v) for r in R) def cell(kind,p): h=([tuple(v+2*s if j==a else v for j,v in enumerate(p)) for a in range(3) for s in (-1,1)] if kind=='O' else [q for q in itertools.product(*[(v-1,v+1) for v in p]) if (sum(q)//2)%2==1]) return {'type':kind,'center':tuple(p),'hosts':tuple(h)} def faces(c):return [tuple(sorted(f)) for f in itertools.combinations(c['hosts'],3) if all(dot(sub(a,b),sub(a,b))==8 for a,b in itertools.combinations(f,2))] def geometry(cells): F={} for i,c in enumerate(cells): for f in faces(c):F.setdefault(f,[]).append(i) return F def swept_overlap(a,b,d): # SAT intersection interval in the ray b(s)=b+s*d, s >= 0. fa,fb=faces(a),faces(b) normals=[cross(sub(f[1],f[0]),sub(f[2],f[0])) for f in fa+fb] ea={axis(sub(x,y)) for f in fa for x,y in itertools.combinations(f,2)};eb={axis(sub(x,y)) for f in fb for x,y in itertools.combinations(f,2)} axes={axis(n) for n in normals}|{axis(cross(x,y)) for x in ea for y in eb};axes.discard(None) lo=Fraction(0);hi=None for n in axes: av=[dot(n,h) for h in a['hosts']];bv=[dot(n,h) for h in b['hosts']];v=dot(n,d) L=min(av)-max(bv);H=max(av)-min(bv) if v==0: if not L<0lo else None def run(): source=ROOT/'fusion-evidence-inputs.json';raw=json.loads(source.read_text())['selected'];A=[cell(c['type'],c['center']) for c in raw];af=geometry(A);ak={tuple(sorted(c['hosts'])) for c in A};exposed=[f for f,cs in af.items() if len(cs)==1];AH=(2,0,0) candidates=[];seen=set();orbits=0 for R in rotations(): B=[{'type':c['type'],'center':rot(R,sub(c['center'],AH)),'hosts':tuple(rot(R,sub(h,AH)) for h in c['hosts'])} for c in A] signature=tuple(sorted((c['type'],tuple(sorted(c['hosts']))) for c in B)) if signature in seen:continue seen.add(signature);orbits+=1 bf=geometry(B);be=[f for f,cs in bf.items() if len(cs)==1];shifts=set() for a in exposed: sa=tuple(sum(h[i] for h in a) for i in range(3)) for b in be: v=tuple(sa[i]-sum(h[i] for h in b) for i in range(3)) if all(x%3==0 for x in v):shifts.add(tuple(x//3 for x in v)) for shift in shifts: if any(x%2 for x in shift) or sum(shift)%4!=2:continue C=[{'type':c['type'],'center':add(c['center'],shift),'hosts':tuple(add(h,shift) for h in c['hosts'])} for c in B] if any(tuple(sorted(c['hosts'])) in ak for c in C):continue cf=geometry(C);contacts=[(af[f][0],cf[f][0],f) for f in set(af)&set(cf) if len(af[f])==len(cf[f])==1] if not contacts:continue d=sub(shift,AH) if dot(d,d)<16:continue candidates.append((len(contacts),dot(d,d),R,shift,C,contacts,d)) candidates.sort(key=lambda x:(-x[0],x[1],x[2],x[3]));chosen=None;tested=0 for item in candidates: tested+=1 _,_,R,shift,C,contacts,d=item if all(swept_overlap(a,b,d) is None for a in A for b in C):chosen=item;break if chosen is None:raise RuntimeError('No continuously clear radial docking found') count,dist2,R,shift,B,contacts,d=chosen cells=A+B;edges=[] for f,idx in geometry(cells).items(): if len(idx)==2:edges.append(idx) reach={0} while True: new=reach|{b for a,b in edges if a in reach}|{a for a,b in edges if b in reach} if new==reach:break reach=new assert len(reach)==30 and len({tuple(sorted(c['hosts'])) for c in cells})==30 # Deliberately invalid control: moving through contact must enter hulls. invalid=any(swept_overlap(a,b,tuple(-x for x in d)) is not None for a in A for b in B) assert invalid max_radius2=max(dot(sub(h,AH),sub(h,AH)) for c in A for h in c['hosts']);assert Fraction(38,10)**2*dist2>4*max_radius2 out={'rotationCertificate':{'maxHostCellRadiusSquared':max_radius2,'minimumInitialHostSeparationSquared':str(Fraction(38,10)**2*dist2),'disjointBoundingSpheres':True},'scope':'Exact lattice-cell docking and conservative continuous translation certificate; not a fusion trajectory or bound-state prediction.','source':'8T+7O selected proton, doubled FCC coordinates','properRotationOrbits':orbits,'faceMatchedCandidates':len(candidates),'rankedCandidatesTested':tested,'rotation':R,'hostA':AH,'hostB':shift,'approachVector':d,'hostSeparationSquared':dist2,'crossContacts':count,'contacts':[{'a':a,'b':b,'face':f} for a,b,f in contacts],'cells':cells,'total':{'T':16,'O':14,'chargeNumerator':12,'chargeDenominator':6,'faceIncidences':176,'uniqueCells':30,'connected':True},'certificate':{'method':'Exact rational separating-axis intervals over all 225 cross-cell pairs, b(s)=b+s*d for every s>=0. Convex host-center cells contain the curved interstices.','testedPairs':225,'positiveVolumeIntersections':0,'inwardOvertravelRejected':invalid},'reactionLedger':{'initial':{'T':16,'O':14,'faceUnitsWithTwoNodes':146896},'proposedProductsUsingRetainedNeutron':{'T':32,'O':22,'faceUnitsWithTwoNodes':147024},'requiredNeutralInput':{'T':16,'O':8,'smallPackets':8,'faceUnits':128},'scope':'Uses the retained 20T+10O neutron, 2T+4O positron and 2T+1O neutral output. Products are bookkeeping targets, not rederived bound states.'}} return out def ledger_checks(result): p={kind:sum(c['type']==kind for c in result['cells'][:15]) for kind in ['T','O']} neutron={'T':20,'O':10};positron={'T':2,'O':4};neutral={'T':2,'O':1} initial={k:2*p[k] for k in p} products={k:p[k]+neutron[k]+positron[k]+neutral[k] for k in p} delta={k:products[k]-initial[k] for k in p} required={Fraction(delta[k],neutral[k]) for k in p} assert len(required)==1 packets=required.pop();assert packets.denominator==1 cases=[] for n in [0,6,int(packets)]: supplied={k:initial[k]+n*neutral[k] for k in p} shortfall={k:products[k]-supplied[k] for k in p} cases.append({'neutralInputs':n,'supplied':supplied,'requiredProducts':products,'shortfall':shortfall,'balanced':all(v==0 for v in shortfall.values()),'charge_e':str(Fraction(2*supplied['O']-supplied['T'],6))}) return {'requiredInputs':int(packets),'outgoingNeutralPackets':1,'netAbsorbedPackets':int(packets)-1,'cases':cases,'reactionRate':None,'energyRelease':None,'observedFusionEvents':None,'scope':'Inventory calculation only. No experimental event count is supplied; null is not a measured zero.'} if __name__=='__main__': result=run();result['ledgerChecks']=ledger_checks(result) assert result['ledgerChecks']['requiredInputs']==8 assert result['ledgerChecks']['cases'][1]['shortfall']=={'T':4,'O':2} assert result['ledgerChecks']['cases'][2]['balanced'] target=ROOT/'fusion-evidence-audit.json' target.write_text(json.dumps(result,indent=2)+'\n') print(json.dumps({'scope':result['scope'],'cells':result['total'],'certificate':result['certificate'],'ledgerChecks':result['ledgerChecks']},indent=2))