from fractions import Fraction as Q from itertools import product from collections import Counter def run(load,check): reg=load('C286_DATA.json')['target_register'];d=load('C410_DATA.json');base=[r for r in d['labelled_links'] if r['classification']!='additional labelled coincidence'];extras=[] for r in d['labelled_links']: a,z=reg[r['input_record']],reg[r['output_record']] if a['center']==3395 and z['center']==2895:extras.append(r) check('two source labels for unique coordinate bridge',len(base)==240 and len(extras)==2) formulas=[] for r in extras: a,z=reg[r['input_record']],reg[r['output_record']];dc=a['Cainan']-z['Cainan'];dt=a['Terah60']-z['Terah60'];df=a['full430']-z['full430'];dg=a['gear']-z['gear'];rail=int(a.get('rail')=='companion');value=100+130*dc+60*dt+215*df+2*dg-rail check('source bridge formula '+z['tradition'],value==500 and (dc,dt,df,dg,rail)==(1,1,1,-2,1) and a['tradition']=='SP') formulas.append({'input_record':a,'output_record':z,'baseline_Shem_to_Flood_gap':100,'variant_difference':405,'Gear_difference':-4,'SP_companion_correction':-1,'gap':value}) allowed=sorted({130*c+60*t+215*f for c,t,f in product([-1,0,1],repeat=3)});high=[v for v in allowed if 396<=v<=405];check('variant bound forces405',high==[405]) solutions=[] for c,t,f in product([-1,0,1],repeat=3): for g1,g2,rail in product([1,2,3],[1,2,3],[0,1]): if 100+130*c+60*t+215*f+2*(g1-g2)-rail==500:solutions.append([c,t,f,g1,g2,rail]) check('bridge has one SP mode solution',solutions==[[1,1,1,1,3,1]]) def paths(links): adj={};incoming=set() for r in links:adj.setdefault(r['input_record'],[]).append(r['output_record']);incoming.add(r['output_record']) out=[] def visit(path): if path[-1] not in adj:out.append(path);return for nxt in sorted(adj[path[-1]]): assert reg[nxt]['center']==reg[path[-1]]['center']-500 visit(path+[nxt]) for start in sorted(set(adj)-incoming):visit([start]) return out before=paths(base);after=paths(base+extras);long=[p for p in after if len(p)==5];beforecounts=Counter(len(p)-1 for p in before);aftercounts=Counter(len(p)-1 for p in after) check('role-defined path domain before bridge',len(before)==192 and max(beforecounts)==2) check('two labelled continuous four-step paths',len(after)==191 and len(long)==2 and all([reg[i]['center'] for i in p]==[3895,3395,2895,2395,1895] for p in long)) check('no cross-tradition switch inside final two role arrows',all(reg[p[2]]['tradition']==reg[p[3]]['tradition'] and reg[p[4]]['tradition']=='MT' for p in long)) phases=[] for eps in product([-Q(1,4),Q(1,4)],repeat=5): ok=all(Q(a)+e1-500==Q(z)+e2 for a,z,e1,e2 in zip([3895,3395,2895,2395],[3395,2895,2395,1895],eps,eps[1:]));phases.append({'offsets':list(map(str,eps)),'all_four_translations_exact':ok}) check('one physical translation preserves both matched components',sum(p['all_four_translations_exact'] for p in phases)==2 and all(p['all_four_translations_exact']==(len(set(p['offsets']))==1) for p in phases)) first=reg[long[0][0]];second=reg[long[0][1]] def own_death(r):return [s for s in reg if s['role']==r['role'].replace('birth','death') and all(s.get(k)==r.get(k) for k in ['tradition','gear','rail','Cainan','Terah60','full430'])] nd=own_death(first);sd=own_death(second);check('four-step chain is not one biography',len(nd)==len(sd)==1 and nd[0]['center']==2945 and sd[0]['center']==2795 and first['center']-nd[0]['center']==950 and second['center']-sd[0]['center']==600) return {'step':'C411','bridge_formulas':formulas,'allowed_variant_differences':allowed,'bridge_mode_solutions':solutions,'role_defined_paths_before_bridge':before,'continuous_paths_with_bridge':after,'long_paths':[{'record_indices':p,'records':[reg[i] for i in p]} for p in long],'phase_trials':phases,'original_biography_controls':{'Noah_death':nd,'Shem_death':sd},'counts':{'role_defined_labelled_arrows':len(base),'additional_bridge_labels':len(extras),'maximal_record_paths_before_bridge':len(before),'maximum_before_edges':max(beforecounts),'maximal_record_paths_with_bridge':len(after),'continuous_four_step_record_paths':len(long),'phase_assignments':len(phases),'exact_phase_assignments':sum(p['all_four_translations_exact'] for p in phases)},'path_length_distribution_before':{str(k):v for k,v in sorted(beforecounts.items())},'path_length_distribution_after':{str(k):v for k,v in sorted(aftercounts.items())},'interpretation':'The four-step coordinate chain has two continuous source-record lifts, choosing SP or LXX CainanOFF for its G3 Flood/death pair. The bridge is a derived cross-context comparison forced by100+405−4−1=500; it is not a prescribed biography or permission to transport SP companions into other traditions. Ordinary950/600 biography deaths remain2945/2795, not the chain endpoint1895.'}