from fractions import Fraction as F def run(load,check): data=load('C322_DATA.json');rev=load('C314_DATA.json');reg=load('C286_DATA.json')['target_register'];anc=load('C271_REGISTER.json');ph=[F(-1,4),F(1,4)];tested=[];hits=[];phase_trials=0;phase_hits=[] for bio in data['biographies']: g=bio['gear'];i=bio['i'];roles=bio['roles'];r=next(r for r in rev['rows'] if r['gear']==g and r['rail']=='primary') check(f'G{g} inherited reverseindex',r['i']==i and r['j']==10-i) for ar in roles: A=bio['SP_records'][ar];B=bio['MT_records'][ar] check(f'G{g} {ar} frozen membership',A in reg and B in reg and A['center']-B['center']==460) for cr in roles: C=bio['SP_records'][cr];a,b,c=A['center'],B['center'],C['center'];ok=(a-b,b-c,a-c)==(460,40,500) rec={'gear':g,'source_i':i,'anchor_role':ar,'terminal_role':cr,'A_SP':a,'B_MT':b,'C_SP':c,'spans':[a-b,b-c,a-c],'success':ok};tested.append(rec) cp=[] for ea in ph: for eb in ph: for ec in ph: phase_trials+=1;av,bv,cv=F(a)+ea,F(b)+eb,F(c)+ec;success=(av-bv,bv-cv,av-cv)==(460,40,500) if success: check(f'G{g} {ar} {cr} {ea} phasebinding',ok and ea==eb==ec) item={'phase_A':str(ea),'phase_B':str(eb),'phase_C':str(ec),'A_SP':str(av),'B_MT':str(bv),'C_SP':str(cv)};cp.append(item);phase_hits.append({'gear':g,'anchor_role':ar,'terminal_role':cr,**item}) if ok: check(f'G{g} {ar} exactphasepair',len(cp)==2) # C314's Shem output offset is opposite its cumulative ancestry. check(f'G{g} {ar} terminalrolebound',cr in ['Shem birth','Shem death']) for comp in cp: e=F(comp['phase_C']);key='Shem_birth' if cr=='Shem birth' else 'Shem_death' rc=[x for x in r['components'] if F(x[key])==F(C['center'])+e] check(f'G{g} {ar} {e} C314terminal',len(rc)==1 and F(rc[0]['Shem_ancestry_phase'])==-e) ac=[x for x in anc if x['source_event']['tradition']=='SP' and x['source_event']['gear']==g and x['source_event']['role']==ar and (ar=='Flood start' or x['source_event']['rail']=='primary')] check(f'G{g} {ar} {e} C271anchor',len(ac)==1 and ac[0]['cumulative_source']['source_index']==i and any(F(x['reflected_coordinate'])==F(A['center'])+e for x in ac[0]['phases'])) ancestry=[{'output_phase':p['phase_C'],'cumulative_Shem_target_ancestry':str(-F(p['phase_C'])),'cumulative_index_j':r['j'],'anchor_cumulative_index_i':i,'anchor_cumulative_role':'Flood' if ar=='Noah birth' else 'Shem'} for p in cp] hits.append({**rec,'records':{'A':A,'B':B,'C':C},'components':cp,'inherited_ancestry':ancestry}) check('finiteannualdomain',len(tested)==75) check('finitephasedomain',phase_trials==600) check('sixsourcechains',len(hits)==6 and len(phase_hits)==12) check('two rolefamilies',{(h['anchor_role'],h['terminal_role']) for h in hits}=={('Noah birth','Shem birth'),('Flood start','Shem death')}) return {'step':'C325','comparison_domain':tested,'hits':hits,'phase_hits':phase_hits,'counts':{'annual_triples_tested':75,'phase_triples_tested':600,'admitted_annual_triples':6,'admitted_exact_components':12,'role_families':2,'Gears':3},'operator_applied':'none; compare existing endpoints only','dependency':'A−C500 and A−B460 force B−C40; source membership and typing independently checked.','source_prescription_established':False,'phase_limit':'Matchedoutputphases require oppositeinheritedcumulativeShem-targetphase; no newphaseoperation adopted.'}