from fractions import Fraction as Q def run(load,check): reg=load('C286_DATA.json')['target_register'];rat={'E':Q(25,23),'P':Q(70,69),'J':Q(300,299)};rows=[];slots=0 def aff(k,c):return(k,(1-k)*c) def comp(a,b):return(a[0]*b[0],a[0]*b[1]+a[1]) def target(r,role,rail): return [s for s in reg if s['role']==role and s['center']==r['center']-500 and all(s.get(k)==r.get(k) for k in ['tradition','gear','Cainan','Terah60','full430']) and s.get('rail')==rail] for i,h in enumerate(load('C396_DATA.json')['hits']): images={} for name,r in h['records'].items(): role='Shem death' if name=='J_Flood' else 'Shem birth';rail=h['records']['higher_Noah'].get('rail') if name=='J_Flood' else r.get('rail');hits=target(r,role,rail) check('unique labelled translation '+str((i,name)),len(hits)==1);images[name]=hits[0];slots+=1 ps=[] for k,p in enumerate(h['P_return_source_records']): hits=target(p,'Shem death','primary' if p['tradition']=='SP' else None) check('P Flood to Shem death '+str((i,k)),len(hits)==1);ps+=hits;slots+=1 x,y,V,A=[h[k] for k in ['E_input','E_output','E_Noah_pivot','J_return_pivot']] check('translated E and J endpoints '+str(i),Q(25,23)*(x-500)+(1-Q(25,23))*(V-500)==y-500 and Q(300,299)*(y-500)+(1-Q(300,299))*(A-500)==x-500) for op,p in [('E',V),('J',A)]+([('P',h['unique_P_return_pivot'])] if ps else []): for eps in [Q(0),-Q(1,4),Q(1,4)]:check('translation conjugacy '+str((i,op,eps)),comp((Q(1),Q(-500)),comp(aff(rat[op],p+eps),(Q(1),Q(500))))==aff(rat[op],p-500+eps)) rows.append({'case':i,'Noah_records':h['records'],'Shem_records':images,'P_Flood_records':h['P_return_source_records'],'P_Shem_death_records':ps,'Noah_coordinate_loop':[V,x,y,A],'Shem_coordinate_loop':[V-500,x-500,y-500,A-500],'P_pivot':h['unique_P_return_pivot']-500 if ps else None}) loops=sorted({tuple(r['Shem_coordinate_loop']) for r in rows});complete=sorted({tuple(r['Shem_coordinate_loop'])+(r['P_pivot'],) for r in rows if r['P_pivot'] is not None}) check('six source Shem loops and two complete graphs',len(loops)==6 and complete==[(2556,2533,2531,1933,2393),(2558,2535,2533,1935,2395)]) paths=[] for i,p in enumerate(load('C400_DATA.json')['path_trials']): m,b=map(Q,p['affine_coefficients']);T=(m,b+500*m-500);expected=(m,Q(p['end']-500)-m*(p['start']-500)) check('translated path map '+str(i),T==expected) paths.append({'start':p['start']-500,'end':p['end']-500,'word':p['operators_in_execution_order'],'affine_coefficients':list(map(str,T))}) return {'step':'C405','translation':-500,'loop_translations':rows,'coordinate_Shem_loops':[list(x) for x in loops],'complete_Shem_loops':[list(x) for x in complete],'translated_paths':paths,'counts':{'labelled_loop_translations':len(rows),'coordinate_loop_translations':len(loops),'labelled_source_slots':slots,'complete_E_P_J_graphs':len(complete),'whole_path_maps_checked':len(paths),'new_source_endpoints':0},'role_map':{'Noah birth':'Shem birth, same tradition/context/Gear/person rail','Flood start or close':'Shem death, same tradition/context/Gear with the corresponding person rail'},'general_identity':'T_-500 D_(k,a) T_500 = D_(k,a-500). Every admitted path and its normal form is transported, with unchanged slope.','interpretation':'This is a finite source-qualified translation and role correspondence under the existing500/100 mode; it is distinct from the failed E-chart transport to SP/LXX Shem2991/2993/2995. Flood-close events remain separate from SP person companions.'}