from fractions import Fraction as F def run(load,check): reg=load('C286_DATA.json')['target_register'];rows=[] for x in load('C340_DATA.json')['rows']: if x['rail']!='primary' or x['Shem_mode_sigma']!=0:continue n,d,g=x['records']['N']['center'],x['records']['D']['center'],x['records']['N']['gear'] for h in [1,2,3]: def one(role): z=[z for z in reg if z['tradition']=='MT' and z['gear']==h and z['role']==role and z['Cainan']==z['Terah60']==z['full430']==1];check(f'i{x["i"]}/G{h}/{role}',len(z)==1);return z[0] M,R=one('Noah birth'),one('Flood start');m,r=M['center'],R['center'];k=h-g;parts=[n-m,m-d,d-r];outer=n-r check(f'i{x["i"]}/G{h} coherent600',m-r==600) check(f'i{x["i"]}/G{h} formulas',parts==[460-2*k,490+2*k,110-2*k] and outer==1060-2*k) keep2K=outer==1058;keep490=parts[:2]==[460,490] check(f'i{x["i"]}/G{h} predicates',keep2K==(k==1) and keep490==(k==0) and not(keep2K and keep490)) rows.append({'i':x['i'],'SP_gear':g,'MT_gear':h,'M':M,'R':R,'parts_N_M_D_R':parts,'N_R':outer,'keep2K':keep2K,'keep460_490':keep490,'E_ladder':F(outer)*F(25,23)==1150}) check('all six source repairs',len(rows)==6 and sum(x['keep2K'] for x in rows)==sum(x['keep460_490'] for x in rows)==2) return {'step':'C345','rows':rows,'incompatibility':'With N and D held, M-R=600 and N-R=1058 forceN-M=458 andM-D=492;460/490 instead forcesN-R=1060.','all_admitted_repairs_exhausted':True,'scope':'Restored MT context, all three ordinary Gears, primary Flood-start comparisons only.'}