#!/usr/bin/env python3 """Root-authored alternate source joins and integer cross-products. No main verifier import.""" import argparse,json,math from pathlib import Path def main(src,out): def load(n):return json.loads((src/n).read_text()) checks=[] def ck(name,value): assert value,name assert name not in checks,name checks.append(name) cum=load('C365_DATA.json')['cumulative_register'];reg=load('C286_DATA.json')['target_register'];K=529 ci={(r['role'],r['Cainan'],r['annual_index']):r for r in cum} ck('48 unique cumulative source identities',len(ci)==len(cum)==48) ck('original32 members retained',all(r in cum for r in load('C364_DATA.json')['register'])) def c(role,state,k):return ci[role,state,k]['coordinate'] def lookup(t,role,g,cainan,terah,rail=None): rs=[r for r in reg if r['tradition']==t and r['role']==role and r['gear']==g and r['Cainan']==cainan and r['Terah60']==terah and r['full430']==1 and (role.startswith('Flood') or r.get('rail')==rail)] assert len(rs)==1,(t,role,g,cainan,terah,rail,rs) return rs[0] def mt(role,g):return lookup('MT',role,g,1,1) def sp(role,g,rail=None):return lookup('SP',role,g,0,0,rail) oldnoahs=load('C300_DATA.json')['cumulative_register'] ck('source seam text',all(s in (src/'Engine_III.md').read_text() for s in ['Shem birth / Noah death','6350–6343','5890–5883'])) ck('Lamech source derivation text',all(s in (src/'File_18.md').read_text() for s in ['8053–8046','| Lamech, chain | 753 | 8048 BC |'])) for k in range(8): old=next(r for r in oldnoahs if r['profile']=='LXX_OFF' and r['role']=='Noah' and r['index']==k) ck(f'Noah provenance {k}',c('Noah birth',0,k)==-old['BC'] and c('Noah birth',1,k)==-(8053-k-753)) cv=[c('Noah birth',1,k),c('Noah birth',0,k),c('Shem',1,k),c('Shem',0,k)] ck(f'Noah cumulative lifespans {k}',cv[2]-cv[0]==cv[3]-cv[1]==950) for g in range(1,4): rv=[sp('Noah birth',g,'primary')['center'],mt('Noah birth',g)['center'],sp('Noah death',g,'primary')['center'],mt('Noah death',g)['center']] ck(f'Noah shape join {k} {g}',[cv[i+1]-cv[i] for i in range(3)]==[rv[i]-rv[i+1] for i in range(3)]==[460,490,460]) coords={r['coordinate'] for r in load('C364_DATA.json')['register']} ck('no500 or1100 source interval',not {500,1100}&{abs(a-b) for a in coords for b in coords}) for i in range(6): S=c('Shem',1,i+2);x=c('Shem',0,i+2);q=c('Flood',0,i) ck(f'cumulative joined input {i}',x-S==460 and q-x==598) ck(f'joined E internal no source {i}',23*500==25*(x-S) and S+500 not in coords) ck(f'joined J terminal no source {i}',299*600==300*(q-x) and S+1100 not in coords) matches=[];matrices=[];lifespan_rows=[] for old in load('C287_DATA.json')['rows']: if not old['complete']:continue i=old['i'];k=i+2;nr=next(r for r in old['Noah_records'] if r['tradition']=='SP');g=nr['gear'];rail=nr['rail'];e=int(rail=='companion') rv=[nr['center'],mt('Noah birth',g)['center'],sp('Noah death',g,rail)['center'],mt('Noah death',g)['center']] X=c('Noah birth',1,k);S=c('Shem',1,k);js=[] for j in range(8): cv=[X,c('Noah birth',0,j),S,c('Shem',0,j)] ok=all(cv[t+1]-cv[t]==rv[t]-rv[t+1] for t in range(3)) ck(f'annual source correspondence {i} {j}',ok==(j==k-e)) ck(f'OFF interior excludes19K {i} {j}',cv[1]+19*K!=rv[1]) if ok:js.append(j) ck(f'unique annual correspondence {i}',js==[k-e]);j=js[0];matches.append({'i':i,'OFF_index':j}) cv=[X,c('Noah birth',0,j),S,c('Shem',0,j)];d=cv[1]-cv[0] ck(f'fixed19K Noah source lift {i}',rv[2]-X==rv[0]-S==19*K) for u in [-1,1]: for v in [-1,1]: ck(f'reversal phase {i} {u} {v}',((4*cv[0]+u)+(4*rv[0]+v)==4*(cv[0]+rv[0]))==(v==-u)) ck(f'translation phase {i} {u} {v}',(4*X+u+4*19*K==4*rv[2]+v)==(u==v)) mat=[] for alpha in range(2): row=[] for beta in range(2): T=rv[2+beta]-cv[alpha] ck(f'950 bridge endpoint join {i} {alpha} {beta}',T==rv[beta]-cv[2+alpha] and cv[2+alpha]-cv[alpha]==rv[beta]-rv[2+beta]==950) ck(f'950 bridge coefficient {i} {alpha} {beta}',T==19*K-(alpha+beta)*d) recorded=next(r for r in load('C369_DATA.json')['rows'] if r['i']==i)['matrix'][alpha][beta] ck(f'950 matrix replay {i} {alpha} {beta}',T==recorded) row.append(T) mat.append(row) matrices.append({'i':i,'matrix':mat});lifespan_rows.append(i) ck('four existing native lifespan lifts',lifespan_rows==[2,3,4,5]) # Reconstruct paired conversions with actual endpoints using cross multiplication. applications=[] for i in range(6): x=c('Shem',0,i+2);A=c('Flood',0,i);B=c('Flood',1,i);y=c('Shem',0,i) ck(f'cumulative J source edge {i}',299*(y-A)==300*(x-A)) ck(f'cumulative P source edge {i}',69*(y-B)==70*(x-B)) ck(f'cumulative equal gain and sourced first segment {i}',A-B==x-c('Shem',1,i+2)==460 and x-y==2 and A-c('Shem',1,i+2)==2*K) if 2<=i<=5:applications.append(('cumulative',i,x,A,B,y)) primary=[];companion=[] for old in load('C287_DATA.json')['rows']: if not old['complete']:continue i=old['i'];nr=next(r for r in old['Noah_records'] if r['tradition']=='SP');g=nr['gear'];e=int(nr['rail']=='companion');role='Flood close' if e else 'Flood start';x=mt('Noah birth',g)['center'];A=mt(role,g+1)['center'];B=sp(role,g+1)['center'];y=mt('Noah birth',g+1)['center'] je=300*(x-A)-299*(y-A);pe=70*(x-B)-69*(y-B) ck(f'regular exact image residual numerators {i}',je==pe==e) ck(f'regular common output iff primary {i}',(je==pe==0)==(e==0)) if not e: primary.append(i);applications.append(('regular',i,x,A,B,y)) ck(f'regular sourced first segment {i}',nr['center']-x==B-A==460 and nr['center']-A==2*K and nr['center']-y==458) else: companion.append(i);Bp=sp('Flood start',g+1)['center'] ck(f'alternative SP start standalone P {i}',69*(y-Bp)==70*(x-Bp) and je==1 and Bp-A==461) ck('regular support domain',primary==[3,5] and companion==[2,4]) samephase=0 for field,i,x,A,B,y in applications: for u in [-1,1]: X=4*x+u;AA=4*A+u;BB=4*B+u;Y=4*y+u ck(f'paired component cross products {field} {i} {u}',299*(Y-AA)==300*(X-AA) and 69*(Y-BB)==70*(X-BB)) fixedJ=300*(X-4*A)-299*(Y-4*A);fixedP=70*(X-4*B)-69*(Y-4*B) ck(f'fixed pivot phase mismatch {field} {i} {u}',fixedJ==fixedP==u and fixedP*299-fixedJ*69==230*u and u!=0) samephase+=1 ck('twelve component joins',samephase==12) csel=[];rsel=[];joint=[];noah=[] for old in load('C319_DATA.json')['rows']: i=old['i'];a=old['a'];b=old['b'];key=f'{a}{b}:i{i}';x=old['S']+460;A=old['q'];B=A-460;y=c('Shem',0,i) ca=all((role,state,k) in ci for role,state,k in [('Shem',0,i+a),('Flood',0,i),('Flood',1,i)]) and old['cumulative_admitted'] ch=bool(ca and 299*(y-A)==300*(x-A) and 69*(y-B)==70*(x-B)) nr=next(r for r in reg if r['tradition']=='SP' and r['role']=='Noah birth' and r['center']==old['n'] and r['Cainan']==r['Terah60']==0 and r['full430']==1) e=int(nr['rail']=='companion');g=nr['gear'];rx=mt('Noah birth',g)['center'];AA=old['R'];BB=AA+460 ars=[r for r in reg if r['tradition']=='MT' and r['Cainan']==r['Terah60']==r['full430']==1 and r['role'].startswith('Flood') and r['center']==AA] brs=[r for r in reg if r['tradition']=='SP' and r['Cainan']==r['Terah60']==0 and r['full430']==1 and ars and r['role']==ars[0]['role'] and r['gear']==ars[0]['gear'] and r['center']==BB] ys=[r for r in reg if r['tradition']=='MT' and r['role']=='Noah birth' and r['Cainan']==r['Terah60']==r['full430']==1 and 299*(r['center']-AA)==300*(rx-AA) and 69*(r['center']-BB)==70*(rx-BB)] rh=bool(ars and brs and ys and old['regular_admitted']) ck('selector cumulative source equality '+key,ch==(a==2 and i<=5)) ck('selector regular source equality '+key,rh==(b==2 and i in [3,5])) ck('selector normal form '+key,A-x==600-a and rx-AA==600+e-b) if ch:csel.append(key) if rh:rsel.append(key) if ch and rh and old['joint_admitted']:joint.append(key) if (('Noah birth',1,i+a) in ci and old['joint_admitted'] and nr['center']-old['S']==19*K):noah.append(key) csel.sort();rsel.sort();joint.sort();noah.sort() recorded=load('C371_DATA.json')['survivors'] ck('all paired selector outputs replay',{'cumulative':csel,'regular':rsel,'joint':joint}==recorded) ck('Noah fixed19K selector replay',noah==load('C368_DATA.json')['survivors']['fixed19K_source_lift']) ck('joint selector exact two controls',joint==['22:i3','22:i5']) # Rational intersection and integral normal form from integer coefficients. ck('affine coefficient numerator',70*299-300*69==230) ck('unique intersection equation coefficients',230*598==299*460 and 23*600==30*460) ck('primitive integer outputs',math.gcd(300,299)==math.gcd(70,69)==1 and 299-69==230 and 2*299-69==529) ck('integer input versus output distinction',math.gcd(299,69)==23 and math.gcd(300,23)==1 and 300%23!=0) ck('actual primitive scale',460//230==2 and 460%230==0 and 138==69*2 and 140==70*2 and 598==299*2 and 600==300*2 and 1058==529*2) ck('C372 declared scale replay',load('C372_DATA.json')['source_scale']==2 and load('C372_DATA.json')['source_counts']=={'complete_cumulative_rows':4,'primary_regular_rows':2,'companion_controls_rejected':2}) result={'status':'passed','method':'Separately written root-agent source joins and integer cross-products; no main calculation imported. Shared frozen inputs and same analyst, not independent historical corroboration.','new_independent_agent_review':False,'check_count':len(checks),'checks':checks,'Noah_annual_matches':matches,'Noah_bridge_matrices':matrices,'cumulative_P_J_source_rows':list(range(6)),'regular_primary_P_J_source_rows':primary,'companion_failures':companion,'component_preserving_phase_joins':samephase,'fixed_pivot_phase_joins':0,'C319_survivors':{'cumulative':csel,'regular':rsel,'joint':joint},'primitive_scale':2,'C374_executed':False} out.mkdir(parents=True,exist_ok=True);(out/'ROOT_SECOND_METHOD_RESULTS.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps({'status':'passed','checks':len(checks),'joint_selector':joint})) if __name__=='__main__': p=argparse.ArgumentParser();p.add_argument('--sources',type=Path,required=True);p.add_argument('--out',type=Path,required=True);a=p.parse_args();main(a.sources,a.out)